const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/LeadSiteHome-5r1d5obS.js","assets/useLeadSiteSearchSuggestions-7nj7za0S.js","assets/CityPagesModule-1GfD9CZf.js","assets/imageOptimization-rphVJGSj.js","assets/LeadSiteLuxuryHome-Jv-ALhIS.js","assets/LeadSiteLandRanchHome-D3b6t0hr.js","assets/LeadSiteSearch-6WIDcv25.js","assets/SaveSearchButton-Bgu8rux4.js","assets/LeadSiteMap-BDnmLySg.js","assets/LeadSiteLuxurySearch-D8cf-b7B.js","assets/LeadSiteListingDetail-BLGNzWWU.js","assets/ListingVideoTour-C-x-hVmZ.js","assets/useListingVideos-BbAQs7HI.js","assets/LeadSiteLuxuryListingDetail-DXccqCnl.js","assets/LeadSiteCityPage-Diicdo3c.js","assets/LeadSiteSubdivisionPage-DkLlyCgv.js","assets/PostcardManager-CudIP7LW.js","assets/usePostcardZones-Ct4Asoky.js","assets/DirectMail-DbKxtDVx.js","assets/jspdf.es.min-CIaYfFIC.js","assets/LeadSiteEditor-DkORUxos.js","assets/VideoUrlField-ClKkvfSi.js","assets/LeadSiteEditor-BzY4kI8E.css","assets/AdminLeadSiteThemes-zILf3j1c.js","assets/MLSListingDetail-Ut9chNGy.js","assets/EmailCampaignComposer-PFi8HVtD.js","assets/EditorModeSelector-DA_fAORb.js","assets/SharedCampaignTemplates-CzBVbO9k.js","assets/TemplateEditorDialog-C9dN8kqe.js","assets/AgentTemplates-CZMJeecN.js","assets/TheLocalMoveHome-ChEmcuti.js","assets/tlm-hero-bg-BbD3acLf.js","assets/TheLocalMoveGetStarted-BUestkVb.js"])))=>i.map(i=>d[i]); var Zmt=Object.defineProperty;var dAe=t=>{throw TypeError(t)};var Ymt=(t,s,r)=>s in t?Zmt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r;var En=(t,s,r)=>Ymt(t,typeof s!="symbol"?s+"":s,r),yxe=(t,s,r)=>s.has(t)||dAe("Cannot "+r);var ms=(t,s,r)=>(yxe(t,s,"read from private field"),r?r.call(t):s.get(t)),za=(t,s,r)=>s.has(t)?dAe("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,r),zn=(t,s,r,n)=>(yxe(t,s,"write to private field"),n?n.call(t,r):s.set(t,r),r),Ii=(t,s,r)=>(yxe(t,s,"access private method"),r);var Y7=(t,s,r,n)=>({set _(a){zn(t,s,a,r)},get _(){return ms(t,s,n)}});function Xmt(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 Qmt="modulepreload",Jmt=function(t){return"/"+t},uAe={},Ba=function(s,r,n){let a=Promise.resolve();if(r&&r.length>0){document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),i=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));a=Promise.allSettled(r.map(d=>{if(d=Jmt(d),d in uAe)return;uAe[d]=!0;const u=d.endsWith(".css"),p=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${p}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":Qmt,u||(f.as="script"),f.crossOrigin="",f.href=d,i&&f.setAttribute("nonce",i),document.head.appendChild(f),u)return new Promise((y,_)=>{f.addEventListener("load",y),f.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${d}`)))})}))}function o(l){const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=l,window.dispatchEvent(i),!i.defaultPrevented)throw l}return a.then(l=>{for(const i of l||[])i.status==="rejected"&&o(i.reason);return s().catch(o)})};var gd=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ao(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function ept(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 yBe={exports:{}},Lde={},vBe={exports:{}},Gi={};/** * @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 gR=Symbol.for("react.element"),tpt=Symbol.for("react.portal"),spt=Symbol.for("react.fragment"),rpt=Symbol.for("react.strict_mode"),npt=Symbol.for("react.profiler"),apt=Symbol.for("react.provider"),ipt=Symbol.for("react.context"),opt=Symbol.for("react.forward_ref"),lpt=Symbol.for("react.suspense"),cpt=Symbol.for("react.memo"),dpt=Symbol.for("react.lazy"),hAe=Symbol.iterator;function upt(t){return t===null||typeof t!="object"?null:(t=hAe&&t[hAe]||t["@@iterator"],typeof t=="function"?t:null)}var _Be={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},bBe=Object.assign,wBe={};function AA(t,s,r){this.props=t,this.context=s,this.refs=wBe,this.updater=r||_Be}AA.prototype.isReactComponent={};AA.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")};AA.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function jBe(){}jBe.prototype=AA.prototype;function a2e(t,s,r){this.props=t,this.context=s,this.refs=wBe,this.updater=r||_Be}var i2e=a2e.prototype=new jBe;i2e.constructor=a2e;bBe(i2e,AA.prototype);i2e.isPureReactComponent=!0;var mAe=Array.isArray,NBe=Object.prototype.hasOwnProperty,o2e={current:null},kBe={key:!0,ref:!0,__self:!0,__source:!0};function SBe(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)NBe.call(s,n)&&!kBe.hasOwnProperty(n)&&(a[n]=s[n]);var i=arguments.length-2;if(i===1)a.children=r;else if(1>>1,ge=oe[he];if(0>>1;hea(Me,ve))kea(Re,Me)?(oe[he]=Re,oe[ke]=ve,he=ke):(oe[he]=Me,oe[qe]=ve,he=qe);else if(kea(Re,ve))oe[he]=Re,oe[ke]=ve,he=ke;else break e}}return me}function a(oe,me){var ve=oe.sortIndex-me.sortIndex;return ve!==0?ve:oe.id-me.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var l=Date,i=l.now();t.unstable_now=function(){return l.now()-i}}var d=[],u=[],p=1,f=null,y=3,_=!1,b=!1,N=!1,w=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function A(oe){for(var me=r(u);me!==null;){if(me.callback===null)n(u);else if(me.startTime<=oe)n(u),me.sortIndex=me.expirationTime,s(d,me);else break;me=r(u)}}function I(oe){if(N=!1,A(oe),!b)if(r(d)!==null)b=!0,ie(L);else{var me=r(u);me!==null&&ae(I,me.startTime-oe)}}function L(oe,me){b=!1,N&&(N=!1,S(q),q=-1),_=!0;var ve=y;try{for(A(me),f=r(d);f!==null&&(!(f.expirationTime>me)||oe&&!te());){var he=f.callback;if(typeof he=="function"){f.callback=null,y=f.priorityLevel;var ge=he(f.expirationTime<=me);me=t.unstable_now(),typeof ge=="function"?f.callback=ge:f===r(d)&&n(d),A(me)}else n(d);f=r(d)}if(f!==null)var je=!0;else{var qe=r(u);qe!==null&&ae(I,qe.startTime-me),je=!1}return je}finally{f=null,y=ve,_=!1}}var O=!1,V=null,q=-1,B=5,U=-1;function te(){return!(t.unstable_now()-Uoe||125he?(oe.sortIndex=ve,s(u,oe),r(d)===null&&oe===r(u)&&(N?(S(q),q=-1):N=!0,ae(I,ve-he))):(oe.sortIndex=ge,s(d,oe),b||_||(b=!0,ie(L))),oe},t.unstable_shouldYield=te,t.unstable_wrapCallback=function(oe){var me=y;return function(){var ve=y;y=me;try{return oe.apply(this,arguments)}finally{y=ve}}}})(EBe);ABe.exports=EBe;var wpt=ABe.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 jpt=k,xf=wpt;function Gr(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"),E0e=Object.prototype.hasOwnProperty,Npt=/^[: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]*$/,fAe={},xAe={};function kpt(t){return E0e.call(xAe,t)?!0:E0e.call(fAe,t)?!1:Npt.test(t)?xAe[t]=!0:(fAe[t]=!0,!1)}function Spt(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 Cpt(t,s,r,n){if(s===null||typeof s>"u"||Spt(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 Dm(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 fh={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){fh[t]=new Dm(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var s=t[0];fh[s]=new Dm(s,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){fh[t]=new Dm(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){fh[t]=new Dm(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){fh[t]=new Dm(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){fh[t]=new Dm(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){fh[t]=new Dm(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){fh[t]=new Dm(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){fh[t]=new Dm(t,5,!1,t.toLowerCase(),null,!1,!1)});var d2e=/[\-:]([a-z])/g;function u2e(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(d2e,u2e);fh[s]=new Dm(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(d2e,u2e);fh[s]=new Dm(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(d2e,u2e);fh[s]=new Dm(s,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){fh[t]=new Dm(t,1,!1,t.toLowerCase(),null,!1,!1)});fh.xlinkHref=new Dm("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){fh[t]=new Dm(t,1,!1,t.toLowerCase(),null,!0,!0)});function h2e(t,s,r,n){var a=fh.hasOwnProperty(s)?fh[s]:null;(a!==null?a.type!==0:n||!(2i||a[l]!==o[i]){var d=` `+a[l].replace(" at new "," at ");return t.displayName&&d.includes("")&&(d=d.replace("",t.displayName)),d}while(1<=l&&0<=i);break}}}finally{bxe=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?SI(t):""}function Mpt(t){switch(t.tag){case 5:return SI(t.type);case 16:return SI("Lazy");case 13:return SI("Suspense");case 19:return SI("SuspenseList");case 0:case 2:case 15:return t=wxe(t.type,!1),t;case 11:return t=wxe(t.type.render,!1),t;case 1:return t=wxe(t.type,!0),t;default:return""}}function D0e(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 q5:return"Fragment";case $5:return"Portal";case P0e:return"Profiler";case m2e:return"StrictMode";case I0e:return"Suspense";case L0e:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case LBe:return(t.displayName||"Context")+".Consumer";case IBe:return(t._context.displayName||"Context")+".Provider";case p2e:var s=t.render;return t=t.displayName,t||(t=s.displayName||s.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case f2e:return s=t.displayName||null,s!==null?s:D0e(t.type)||"Memo";case A_:s=t._payload,t=t._init;try{return D0e(t(s))}catch{}}return null}function Tpt(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 D0e(s);case 8:return s===m2e?"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 Ub(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function RBe(t){var s=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function Apt(t){var s=RBe(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 J7(t){t._valueTracker||(t._valueTracker=Apt(t))}function OBe(t){if(!t)return!1;var s=t._valueTracker;if(!s)return!0;var r=s.getValue(),n="";return t&&(n=RBe(t)?t.checked?"true":"false":t.value),t=n,t!==r?(s.setValue(t),!0):!1}function hoe(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 R0e(t,s){var r=s.checked;return $c({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??t._wrapperState.initialChecked})}function yAe(t,s){var r=s.defaultValue==null?"":s.defaultValue,n=s.checked!=null?s.checked:s.defaultChecked;r=Ub(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 FBe(t,s){s=s.checked,s!=null&&h2e(t,"checked",s,!1)}function O0e(t,s){FBe(t,s);var r=Ub(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")?F0e(t,s.type,r):s.hasOwnProperty("defaultValue")&&F0e(t,s.type,Ub(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(t.defaultChecked=!!s.defaultChecked)}function vAe(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 F0e(t,s,r){(s!=="number"||hoe(t.ownerDocument)!==t)&&(r==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+r&&(t.defaultValue=""+r))}var CI=Array.isArray;function hM(t,s,r,n){if(t=t.options,s){s={};for(var a=0;a"+s.valueOf().toString()+"",s=ez.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;s.firstChild;)t.appendChild(s.firstChild)}});function I8(t,s){if(s){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=s;return}}t.textContent=s}var GI={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},Ept=["Webkit","ms","Moz","O"];Object.keys(GI).forEach(function(t){Ept.forEach(function(s){s=s+t.charAt(0).toUpperCase()+t.substring(1),GI[s]=GI[t]})});function qBe(t,s,r){return s==null||typeof s=="boolean"||s===""?"":r||typeof s!="number"||s===0||GI.hasOwnProperty(t)&&GI[t]?(""+s).trim():s+"px"}function UBe(t,s){t=t.style;for(var r in s)if(s.hasOwnProperty(r)){var n=r.indexOf("--")===0,a=qBe(r,s[r],n);r==="float"&&(r="cssFloat"),n?t.setProperty(r,a):t[r]=a}}var Ppt=$c({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 $0e(t,s){if(s){if(Ppt[t]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(Gr(137,t));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(Gr(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(Gr(61))}if(s.style!=null&&typeof s.style!="object")throw Error(Gr(62))}}function q0e(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 x2e(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var V0e=null,mM=null,pM=null;function wAe(t){if(t=_R(t)){if(typeof V0e!="function")throw Error(Gr(280));var s=t.stateNode;s&&(s=zde(s),V0e(t.stateNode,t.type,s))}}function VBe(t){mM?pM?pM.push(t):pM=[t]:mM=t}function HBe(){if(mM){var t=mM,s=pM;if(pM=mM=null,wAe(t),s)for(t=0;t>>=0,t===0?32:31-(Upt(t)/Vpt|0)|0}var tz=64,sz=4194304;function MI(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 xoe(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=MI(i):(o&=l,o!==0&&(n=MI(o)))}else l=r&~a,l!==0?n=MI(l):o!==0&&(n=MI(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 yR(t,s,r){t.pendingLanes|=s,s!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,s=31-Mg(s),t[s]=r}function Kpt(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=KI),EAe=" ",PAe=!1;function u$e(t,s){switch(t){case"keyup":return wft.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function h$e(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var U5=!1;function Nft(t,s){switch(t){case"compositionend":return h$e(s);case"keypress":return s.which!==32?null:(PAe=!0,EAe);case"textInput":return t=s.data,t===EAe&&PAe?null:t;default:return null}}function kft(t,s){if(U5)return t==="compositionend"||!N2e&&u$e(t,s)?(t=c$e(),z9=b2e=ib=null,U5=!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=RAe(r)}}function x$e(t,s){return t&&s?t===s?!0:t&&t.nodeType===3?!1:s&&s.nodeType===3?x$e(t,s.parentNode):"contains"in t?t.contains(s):t.compareDocumentPosition?!!(t.compareDocumentPosition(s)&16):!1:!1}function g$e(){for(var t=window,s=hoe();s instanceof t.HTMLIFrameElement;){try{var r=typeof s.contentWindow.location.href=="string"}catch{r=!1}if(r)t=s.contentWindow;else break;s=hoe(t.document)}return s}function k2e(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 Lft(t){var s=g$e(),r=t.focusedElem,n=t.selectionRange;if(s!==r&&r&&r.ownerDocument&&x$e(r.ownerDocument.documentElement,r)){if(n!==null&&k2e(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=OAe(r,o);var l=OAe(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,V5=null,Y0e=null,YI=null,X0e=!1;function FAe(t,s,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;X0e||V5==null||V5!==hoe(n)||(n=V5,"selectionStart"in n&&k2e(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}),YI&&z8(YI,n)||(YI=n,n=voe(Y0e,"onSelect"),0W5||(t.current=rve[W5],rve[W5]=null,W5--)}function Ll(t,s){W5++,rve[W5]=t.current,t.current=s}var Vb={},Fh=lw(Vb),up=lw(!1),FS=Vb;function _T(t,s){var r=t.type.contextTypes;if(!r)return Vb;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 hp(t){return t=t.childContextTypes,t!=null}function boe(){rc(up),rc(Fh)}function HAe(t,s,r){if(Fh.current!==Vb)throw Error(Gr(168));Ll(Fh,s),Ll(up,r)}function S$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(Gr(108,Tpt(t)||"Unknown",a));return $c({},r,n)}function woe(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Vb,FS=Fh.current,Ll(Fh,t),Ll(up,up.current),!0}function GAe(t,s,r){var n=t.stateNode;if(!n)throw Error(Gr(169));r?(t=S$e(t,s,FS),n.__reactInternalMemoizedMergedChildContext=t,rc(up),rc(Fh),Ll(Fh,t)):rc(up),Ll(up,r)}var Cv=null,Bde=!1,Rxe=!1;function C$e(t){Cv===null?Cv=[t]:Cv.push(t)}function Gft(t){Bde=!0,C$e(t)}function cw(){if(!Rxe&&Cv!==null){Rxe=!0;var t=0,s=Yo;try{var r=Cv;for(Yo=1;t>=l,a-=l,Fv=1<<32-Mg(s)+a|r<q?(B=V,V=null):B=V.sibling;var U=y(S,V,A[q],I);if(U===null){V===null&&(V=B);break}t&&V&&U.alternate===null&&s(S,V),C=o(U,C,q),O===null?L=U:O.sibling=U,O=U,V=B}if(q===A.length)return r(S,V),yc&&V2(S,q),L;if(V===null){for(;qq?(B=V,V=null):B=V.sibling;var te=y(S,V,U.value,I);if(te===null){V===null&&(V=B);break}t&&V&&te.alternate===null&&s(S,V),C=o(te,C,q),O===null?L=te:O.sibling=te,O=te,V=B}if(U.done)return r(S,V),yc&&V2(S,q),L;if(V===null){for(;!U.done;q++,U=A.next())U=f(S,U.value,I),U!==null&&(C=o(U,C,q),O===null?L=U:O.sibling=U,O=U);return yc&&V2(S,q),L}for(V=n(S,V);!U.done;q++,U=A.next())U=_(V,S,q,U.value,I),U!==null&&(t&&U.alternate!==null&&V.delete(U.key===null?q:U.key),C=o(U,C,q),O===null?L=U:O.sibling=U,O=U);return t&&V.forEach(function(Y){return s(S,Y)}),yc&&V2(S,q),L}function w(S,C,A,I){if(typeof A=="object"&&A!==null&&A.type===q5&&A.key===null&&(A=A.props.children),typeof A=="object"&&A!==null){switch(A.$$typeof){case Q7:e:{for(var L=A.key,O=C;O!==null;){if(O.key===L){if(L=A.type,L===q5){if(O.tag===7){r(S,O.sibling),C=a(O,A.props.children),C.return=S,S=C;break e}}else if(O.elementType===L||typeof L=="object"&&L!==null&&L.$$typeof===A_&&ZAe(L)===O.type){r(S,O.sibling),C=a(O,A.props),C.ref=V6(S,O,A),C.return=S,S=C;break e}r(S,O);break}else s(S,O);O=O.sibling}A.type===q5?(C=U4(A.props.children,S.mode,I,A.key),C.return=S,S=C):(I=W9(A.type,A.key,A.props,null,S.mode,I),I.ref=V6(S,C,A),I.return=S,S=I)}return l(S);case $5:e:{for(O=A.key;C!==null;){if(C.key===O)if(C.tag===4&&C.stateNode.containerInfo===A.containerInfo&&C.stateNode.implementation===A.implementation){r(S,C.sibling),C=a(C,A.children||[]),C.return=S,S=C;break e}else{r(S,C);break}else s(S,C);C=C.sibling}C=Vxe(A,S.mode,I),C.return=S,S=C}return l(S);case A_:return O=A._init,w(S,C,O(A._payload),I)}if(CI(A))return b(S,C,A,I);if(z6(A))return N(S,C,A,I);cz(S,A)}return typeof A=="string"&&A!==""||typeof A=="number"?(A=""+A,C!==null&&C.tag===6?(r(S,C.sibling),C=a(C,A),C.return=S,S=C):(r(S,C),C=Uxe(A,S.mode,I),C.return=S,S=C),l(S)):r(S,C)}return w}var wT=E$e(!0),P$e=E$e(!1),koe=lw(null),Soe=null,Y5=null,T2e=null;function A2e(){T2e=Y5=Soe=null}function E2e(t){var s=koe.current;rc(koe),t._currentValue=s}function ive(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 xM(t,s){Soe=t,T2e=Y5=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&s&&(ip=!0),t.firstContext=null)}function Nx(t){var s=t._currentValue;if(T2e!==t)if(t={context:t,memoizedValue:s,next:null},Y5===null){if(Soe===null)throw Error(Gr(308));Y5=t,Soe.dependencies={lanes:0,firstContext:t}}else Y5=Y5.next=t;return s}var p4=null;function P2e(t){p4===null?p4=[t]:p4.push(t)}function I$e(t,s,r,n){var a=s.interleaved;return a===null?(r.next=r,P2e(s)):(r.next=a.next,a.next=r),s.interleaved=r,u1(t,n)}function u1(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 I2e(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function L$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 Hv(t,s){return{eventTime:t,lane:s,tag:0,payload:null,callback:null,next:null}}function vb(t,s,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,yo&2){var a=n.pending;return a===null?s.next=s:(s.next=a.next,a.next=s),n.pending=s,u1(t,r)}return a=n.interleaved,a===null?(s.next=s,P2e(n)):(s.next=a.next,a.next=s),n.interleaved=s,u1(t,r)}function $9(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,y2e(t,r)}}function YAe(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 Coe(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 d=i,u=d.next;d.next=null,l===null?o=u:l.next=u,l=d;var p=t.alternate;p!==null&&(p=p.updateQueue,i=p.lastBaseUpdate,i!==l&&(i===null?p.firstBaseUpdate=u:i.next=u,p.lastBaseUpdate=d))}if(o!==null){var f=a.baseState;l=0,p=u=d=null,i=o;do{var y=i.lane,_=i.eventTime;if((n&y)===y){p!==null&&(p=p.next={eventTime:_,lane:0,tag:i.tag,payload:i.payload,callback:i.callback,next:null});e:{var b=t,N=i;switch(y=s,_=r,N.tag){case 1:if(b=N.payload,typeof b=="function"){f=b.call(_,f,y);break e}f=b;break e;case 3:b.flags=b.flags&-65537|128;case 0:if(b=N.payload,y=typeof b=="function"?b.call(_,f,y):b,y==null)break e;f=$c({},f,y);break e;case 2:E_=!0}}i.callback!==null&&i.lane!==0&&(t.flags|=64,y=a.effects,y===null?a.effects=[i]:y.push(i))}else _={eventTime:_,lane:y,tag:i.tag,payload:i.payload,callback:i.callback,next:null},p===null?(u=p=_,d=f):p=p.next=_,l|=y;if(i=i.next,i===null){if(i=a.shared.pending,i===null)break;y=i,i=y.next,y.next=null,a.lastBaseUpdate=y,a.shared.pending=null}}while(!0);if(p===null&&(d=f),a.baseState=d,a.firstBaseUpdate=u,a.lastBaseUpdate=p,s=a.shared.interleaved,s!==null){a=s;do l|=a.lane,a=a.next;while(a!==s)}else o===null&&(a.shared.lanes=0);$S|=l,t.lanes=l,t.memoizedState=f}}function XAe(t,s,r){if(t=s.effects,s.effects=null,t!==null)for(s=0;sr?r:4,t(!0);var n=Fxe.transition;Fxe.transition={};try{t(!1),s()}finally{Yo=r,Fxe.transition=n}}function X$e(){return kx().memoizedState}function Yft(t,s,r){var n=bb(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},Q$e(t))J$e(s,r);else if(r=I$e(t,s,r,n),r!==null){var a=km();Tg(r,t,n,a),eqe(r,s,n)}}function Xft(t,s,r){var n=bb(t),a={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(Q$e(t))J$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,Fg(i,l)){var d=s.interleaved;d===null?(a.next=a,P2e(s)):(a.next=d.next,d.next=a),s.interleaved=a;return}}catch{}finally{}r=I$e(t,s,a,n),r!==null&&(a=km(),Tg(r,t,n,a),eqe(r,s,n))}}function Q$e(t){var s=t.alternate;return t===zc||s!==null&&s===zc}function J$e(t,s){XI=Toe=!0;var r=t.pending;r===null?s.next=s:(s.next=r.next,r.next=s),t.pending=s}function eqe(t,s,r){if(r&4194240){var n=s.lanes;n&=t.pendingLanes,r|=n,s.lanes=r,y2e(t,r)}}var Aoe={readContext:Nx,useCallback:Nh,useContext:Nh,useEffect:Nh,useImperativeHandle:Nh,useInsertionEffect:Nh,useLayoutEffect:Nh,useMemo:Nh,useReducer:Nh,useRef:Nh,useState:Nh,useDebugValue:Nh,useDeferredValue:Nh,useTransition:Nh,useMutableSource:Nh,useSyncExternalStore:Nh,useId:Nh,unstable_isNewReconciler:!1},Qft={readContext:Nx,useCallback:function(t,s){return Cy().memoizedState=[t,s===void 0?null:s],t},useContext:Nx,useEffect:JAe,useImperativeHandle:function(t,s,r){return r=r!=null?r.concat([t]):null,U9(4194308,4,G$e.bind(null,s,t),r)},useLayoutEffect:function(t,s){return U9(4194308,4,t,s)},useInsertionEffect:function(t,s){return U9(4,2,t,s)},useMemo:function(t,s){var r=Cy();return s=s===void 0?null:s,t=t(),r.memoizedState=[t,s],t},useReducer:function(t,s,r){var n=Cy();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=Yft.bind(null,zc,t),[n.memoizedState,t]},useRef:function(t){var s=Cy();return t={current:t},s.memoizedState=t},useState:QAe,useDebugValue:$2e,useDeferredValue:function(t){return Cy().memoizedState=t},useTransition:function(){var t=QAe(!1),s=t[0];return t=Zft.bind(null,t[1]),Cy().memoizedState=t,[s,t]},useMutableSource:function(){},useSyncExternalStore:function(t,s,r){var n=zc,a=Cy();if(yc){if(r===void 0)throw Error(Gr(407));r=r()}else{if(r=s(),Ou===null)throw Error(Gr(349));BS&30||F$e(n,s,r)}a.memoizedState=r;var o={value:r,getSnapshot:s};return a.queue=o,JAe(B$e.bind(null,n,o,t),[t]),n.flags|=2048,W8(9,z$e.bind(null,n,o,r,s),void 0,null),r},useId:function(){var t=Cy(),s=Ou.identifierPrefix;if(yc){var r=zv,n=Fv;r=(n&~(1<<32-Mg(n)-1)).toString(32)+r,s=":"+s+"R"+r,r=H8++,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[Fy]=s,t[q8]=n,dqe(t,s,!1,!1),s.stateNode=t;e:{switch(l=q0e(r,n),r){case"dialog":Kl("cancel",t),Kl("close",t),a=n;break;case"iframe":case"object":case"embed":Kl("load",t),a=n;break;case"video":case"audio":for(a=0;akT&&(s.flags|=128,n=!0,H6(o,!1),s.lanes=4194304)}else{if(!n)if(t=Moe(l),t!==null){if(s.flags|=128,n=!0,r=t.updateQueue,r!==null&&(s.updateQueue=r,s.flags|=4),H6(o,!0),o.tail===null&&o.tailMode==="hidden"&&!l.alternate&&!yc)return kh(s),null}else 2*xd()-o.renderingStartTime>kT&&r!==1073741824&&(s.flags|=128,n=!0,H6(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=xd(),s.sibling=null,r=Lc.current,Ll(Lc,n?r&1|2:r&1),s):(kh(s),null);case 22:case 23:return W2e(),n=s.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(s.flags|=8192),n&&s.mode&1?Gp&1073741824&&(kh(s),s.subtreeFlags&6&&(s.flags|=8192)):kh(s),null;case 24:return null;case 25:return null}throw Error(Gr(156,s.tag))}function ixt(t,s){switch(C2e(s),s.tag){case 1:return hp(s.type)&&boe(),t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 3:return jT(),rc(up),rc(Fh),R2e(),t=s.flags,t&65536&&!(t&128)?(s.flags=t&-65537|128,s):null;case 5:return D2e(s),null;case 13:if(rc(Lc),t=s.memoizedState,t!==null&&t.dehydrated!==null){if(s.alternate===null)throw Error(Gr(340));bT()}return t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 19:return rc(Lc),null;case 4:return jT(),null;case 10:return E2e(s.type._context),null;case 22:case 23:return W2e(),null;case 24:return null;default:return null}}var uz=!1,Ah=!1,oxt=typeof WeakSet=="function"?WeakSet:Set,Xn=null;function X5(t,s){var r=t.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){Zc(t,s,n)}else r.current=null}function fve(t,s,r){try{r()}catch(n){Zc(t,s,n)}}var dEe=!1;function lxt(t,s){if(Q0e=goe,t=g$e(),k2e(t)){if("selectionStart"in t)var r={start:t.selectionStart,end:t.selectionEnd};else e:{r=(r=t.ownerDocument)&&r.defaultView||window;var n=r.getSelection&&r.getSelection();if(n&&n.rangeCount!==0){r=n.anchorNode;var a=n.anchorOffset,o=n.focusNode;n=n.focusOffset;try{r.nodeType,o.nodeType}catch{r=null;break e}var l=0,i=-1,d=-1,u=0,p=0,f=t,y=null;t:for(;;){for(var _;f!==r||a!==0&&f.nodeType!==3||(i=l+a),f!==o||n!==0&&f.nodeType!==3||(d=l+n),f.nodeType===3&&(l+=f.nodeValue.length),(_=f.firstChild)!==null;)y=f,f=_;for(;;){if(f===t)break t;if(y===r&&++u===a&&(i=l),y===o&&++p===n&&(d=l),(_=f.nextSibling)!==null)break;f=y,y=f.parentNode}f=_}r=i===-1||d===-1?null:{start:i,end:d}}else r=null}r=r||{start:0,end:0}}else r=null;for(J0e={focusedElem:t,selectionRange:r},goe=!1,Xn=s;Xn!==null;)if(s=Xn,t=s.child,(s.subtreeFlags&1028)!==0&&t!==null)t.return=s,Xn=t;else for(;Xn!==null;){s=Xn;try{var b=s.alternate;if(s.flags&1024)switch(s.tag){case 0:case 11:case 15:break;case 1:if(b!==null){var N=b.memoizedProps,w=b.memoizedState,S=s.stateNode,C=S.getSnapshotBeforeUpdate(s.elementType===s.type?N:hg(s.type,N),w);S.__reactInternalSnapshotBeforeUpdate=C}break;case 3:var A=s.stateNode.containerInfo;A.nodeType===1?A.textContent="":A.nodeType===9&&A.documentElement&&A.removeChild(A.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Gr(163))}}catch(I){Zc(s,s.return,I)}if(t=s.sibling,t!==null){t.return=s.return,Xn=t;break}Xn=s.return}return b=dEe,dEe=!1,b}function QI(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&&fve(s,r,o)}a=a.next}while(a!==n)}}function Ude(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 xve(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 mqe(t){var s=t.alternate;s!==null&&(t.alternate=null,mqe(s)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(s=t.stateNode,s!==null&&(delete s[Fy],delete s[q8],delete s[sve],delete s[Vft],delete s[Hft])),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 pqe(t){return t.tag===5||t.tag===3||t.tag===4}function uEe(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||pqe(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 gve(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=_oe));else if(n!==4&&(t=t.child,t!==null))for(gve(t,s,r),t=t.sibling;t!==null;)gve(t,s,r),t=t.sibling}function yve(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(yve(t,s,r),t=t.sibling;t!==null;)yve(t,s,r),t=t.sibling}var eh=null,fg=!1;function m_(t,s,r){for(r=r.child;r!==null;)fqe(t,s,r),r=r.sibling}function fqe(t,s,r){if(Wy&&typeof Wy.onCommitFiberUnmount=="function")try{Wy.onCommitFiberUnmount(Dde,r)}catch{}switch(r.tag){case 5:Ah||X5(r,s);case 6:var n=eh,a=fg;eh=null,m_(t,s,r),eh=n,fg=a,eh!==null&&(fg?(t=eh,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):eh.removeChild(r.stateNode));break;case 18:eh!==null&&(fg?(t=eh,r=r.stateNode,t.nodeType===8?Dxe(t.parentNode,r):t.nodeType===1&&Dxe(t,r),O8(t)):Dxe(eh,r.stateNode));break;case 4:n=eh,a=fg,eh=r.stateNode.containerInfo,fg=!0,m_(t,s,r),eh=n,fg=a;break;case 0:case 11:case 14:case 15:if(!Ah&&(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)&&fve(r,s,l),a=a.next}while(a!==n)}m_(t,s,r);break;case 1:if(!Ah&&(X5(r,s),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(i){Zc(r,s,i)}m_(t,s,r);break;case 21:m_(t,s,r);break;case 22:r.mode&1?(Ah=(n=Ah)||r.memoizedState!==null,m_(t,s,r),Ah=n):m_(t,s,r);break;default:m_(t,s,r)}}function hEe(t){var s=t.updateQueue;if(s!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new oxt),s.forEach(function(n){var a=gxt.bind(null,t,n);r.has(n)||(r.add(n),n.then(a,a))})}}function ag(t,s){var r=s.deletions;if(r!==null)for(var n=0;na&&(a=l),n&=~o}if(n=a,n=xd()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*dxt(n/1960))-n,10t?16:t,ob===null)var n=!1;else{if(t=ob,ob=null,Ioe=0,yo&6)throw Error(Gr(331));var a=yo;for(yo|=4,Xn=t.current;Xn!==null;){var o=Xn,l=o.child;if(Xn.flags&16){var i=o.deletions;if(i!==null){for(var d=0;dxd()-H2e?q4(t,0):V2e|=r),mp(t,s)}function jqe(t,s){s===0&&(t.mode&1?(s=sz,sz<<=1,!(sz&130023424)&&(sz=4194304)):s=1);var r=km();t=u1(t,s),t!==null&&(yR(t,s,r),mp(t,r))}function xxt(t){var s=t.memoizedState,r=0;s!==null&&(r=s.retryLane),jqe(t,r)}function gxt(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(Gr(314))}n!==null&&n.delete(s),jqe(t,r)}var Nqe;Nqe=function(t,s,r){if(t!==null)if(t.memoizedProps!==s.pendingProps||up.current)ip=!0;else{if(!(t.lanes&r)&&!(s.flags&128))return ip=!1,nxt(t,s,r);ip=!!(t.flags&131072)}else ip=!1,yc&&s.flags&1048576&&M$e(s,Noe,s.index);switch(s.lanes=0,s.tag){case 2:var n=s.type;V9(t,s),t=s.pendingProps;var a=_T(s,Fh.current);xM(s,r),a=F2e(null,s,n,t,a,r);var o=z2e();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,hp(n)?(o=!0,woe(s)):o=!1,s.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,I2e(s),a.updater=qde,s.stateNode=a,a._reactInternals=s,lve(s,n,t,r),s=uve(null,s,n,!0,o,r)):(s.tag=0,yc&&o&&S2e(s),mm(null,s,a,r),s=s.child),s;case 16:n=s.elementType;e:{switch(V9(t,s),t=s.pendingProps,a=n._init,n=a(n._payload),s.type=n,a=s.tag=vxt(n),t=hg(n,t),a){case 0:s=dve(null,s,n,t,r);break e;case 1:s=oEe(null,s,n,t,r);break e;case 11:s=aEe(null,s,n,t,r);break e;case 14:s=iEe(null,s,n,hg(n.type,t),r);break e}throw Error(Gr(306,n,""))}return s;case 0:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:hg(n,a),dve(t,s,n,a,r);case 1:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:hg(n,a),oEe(t,s,n,a,r);case 3:e:{if(oqe(s),t===null)throw Error(Gr(387));n=s.pendingProps,o=s.memoizedState,a=o.element,L$e(t,s),Coe(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=NT(Error(Gr(423)),s),s=lEe(t,s,n,r,a);break e}else if(n!==a){a=NT(Error(Gr(424)),s),s=lEe(t,s,n,r,a);break e}else for(tf=yb(s.stateNode.containerInfo.firstChild),rf=s,yc=!0,_g=null,r=P$e(s,null,n,r),s.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(bT(),n===a){s=h1(t,s,r);break e}mm(t,s,n,r)}s=s.child}return s;case 5:return D$e(s),t===null&&ave(s),n=s.type,a=s.pendingProps,o=t!==null?t.memoizedProps:null,l=a.children,eve(n,a)?l=null:o!==null&&eve(n,o)&&(s.flags|=32),iqe(t,s),mm(t,s,l,r),s.child;case 6:return t===null&&ave(s),null;case 13:return lqe(t,s,r);case 4:return L2e(s,s.stateNode.containerInfo),n=s.pendingProps,t===null?s.child=wT(s,null,n,r):mm(t,s,n,r),s.child;case 11:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:hg(n,a),aEe(t,s,n,a,r);case 7:return mm(t,s,s.pendingProps,r),s.child;case 8:return mm(t,s,s.pendingProps.children,r),s.child;case 12:return mm(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,Ll(koe,n._currentValue),n._currentValue=l,o!==null)if(Fg(o.value,l)){if(o.children===a.children&&!up.current){s=h1(t,s,r);break e}}else for(o=s.child,o!==null&&(o.return=s);o!==null;){var i=o.dependencies;if(i!==null){l=o.child;for(var d=i.firstContext;d!==null;){if(d.context===n){if(o.tag===1){d=Hv(-1,r&-r),d.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var p=u.pending;p===null?d.next=d:(d.next=p.next,p.next=d),u.pending=d}}o.lanes|=r,d=o.alternate,d!==null&&(d.lanes|=r),ive(o.return,r,s),i.lanes|=r;break}d=d.next}}else if(o.tag===10)l=o.type===s.type?null:o.child;else if(o.tag===18){if(l=o.return,l===null)throw Error(Gr(341));l.lanes|=r,i=l.alternate,i!==null&&(i.lanes|=r),ive(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}mm(t,s,a.children,r),s=s.child}return s;case 9:return a=s.type,n=s.pendingProps.children,xM(s,r),a=Nx(a),n=n(a),s.flags|=1,mm(t,s,n,r),s.child;case 14:return n=s.type,a=hg(n,s.pendingProps),a=hg(n.type,a),iEe(t,s,n,a,r);case 15:return nqe(t,s,s.type,s.pendingProps,r);case 17:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:hg(n,a),V9(t,s),s.tag=1,hp(n)?(t=!0,woe(s)):t=!1,xM(s,r),tqe(s,n,a),lve(s,n,a,r),uve(null,s,n,!0,t,r);case 19:return cqe(t,s,r);case 22:return aqe(t,s,r)}throw Error(Gr(156,s.tag))};function kqe(t,s){return QBe(t,s)}function yxt(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 dx(t,s,r,n){return new yxt(t,s,r,n)}function Z2e(t){return t=t.prototype,!(!t||!t.isReactComponent)}function vxt(t){if(typeof t=="function")return Z2e(t)?1:0;if(t!=null){if(t=t.$$typeof,t===p2e)return 11;if(t===f2e)return 14}return 2}function wb(t,s){var r=t.alternate;return r===null?(r=dx(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 W9(t,s,r,n,a,o){var l=2;if(n=t,typeof t=="function")Z2e(t)&&(l=1);else if(typeof t=="string")l=5;else e:switch(t){case q5:return U4(r.children,a,o,s);case m2e:l=8,a|=8;break;case P0e:return t=dx(12,r,s,a|2),t.elementType=P0e,t.lanes=o,t;case I0e:return t=dx(13,r,s,a),t.elementType=I0e,t.lanes=o,t;case L0e:return t=dx(19,r,s,a),t.elementType=L0e,t.lanes=o,t;case DBe:return Hde(r,a,o,s);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case IBe:l=10;break e;case LBe:l=9;break e;case p2e:l=11;break e;case f2e:l=14;break e;case A_:l=16,n=null;break e}throw Error(Gr(130,t==null?t:typeof t,""))}return s=dx(l,r,s,a),s.elementType=t,s.type=n,s.lanes=o,s}function U4(t,s,r,n){return t=dx(7,t,n,s),t.lanes=r,t}function Hde(t,s,r,n){return t=dx(22,t,n,s),t.elementType=DBe,t.lanes=r,t.stateNode={isHidden:!1},t}function Uxe(t,s,r){return t=dx(6,t,null,s),t.lanes=r,t}function Vxe(t,s,r){return s=dx(4,t.children!==null?t.children:[],t.key,s),s.lanes=r,s.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},s}function _xt(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=Nxe(0),this.expirationTimes=Nxe(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Nxe(0),this.identifierPrefix=n,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function Y2e(t,s,r,n,a,o,l,i,d){return t=new _xt(t,s,r,i,d),s===1?(s=1,o===!0&&(s|=8)):s=0,o=dx(3,null,null,s),t.current=o,o.stateNode=t,o.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},I2e(o),t}function bxt(t,s,r){var n=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Tqe)}catch(t){console.error(t)}}Tqe(),TBe.exports=wf;var op=TBe.exports;const eje=ao(op);var Aqe,_Ee=op;Aqe=_Ee.createRoot,_Ee.hydrateRoot;const Sxt=1,Cxt=1e6;let Hxe=0;function Mxt(){return Hxe=(Hxe+1)%Number.MAX_SAFE_INTEGER,Hxe.toString()}const Gxe=new Map,bEe=t=>{if(Gxe.has(t))return;const s=setTimeout(()=>{Gxe.delete(t),tL({type:"REMOVE_TOAST",toastId:t})},Cxt);Gxe.set(t,s)},Txt=(t,s)=>{switch(s.type){case"ADD_TOAST":return{...t,toasts:[s.toast,...t.toasts].slice(0,Sxt)};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?bEe(r):t.toasts.forEach(n=>{bEe(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)}}},K9=[];let Z9={toasts:[]};function tL(t){Z9=Txt(Z9,t),K9.forEach(s=>{s(Z9)})}function fn({...t}){const s=Mxt(),r=a=>tL({type:"UPDATE_TOAST",toast:{...a,id:s}}),n=()=>tL({type:"DISMISS_TOAST",toastId:s});return tL({type:"ADD_TOAST",toast:{...t,id:s,open:!0,onOpenChange:a=>{a||n()}}}),{id:s,dismiss:n,update:r}}function ja(){const[t,s]=k.useState(Z9);return k.useEffect(()=>(K9.push(s),()=>{const r=K9.indexOf(s);r>-1&&K9.splice(r,1)}),[t]),{...t,toast:fn,dismiss:r=>tL({type:"DISMISS_TOAST",toastId:r})}}function Mr(t,s,{checkForDefaultPrevented:r=!0}={}){return function(a){if(t==null||t(a),r===!1||!a.defaultPrevented)return s==null?void 0:s(a)}}function wEe(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function m1(...t){return s=>{let r=!1;const n=t.map(a=>{const o=wEe(a,s);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a{const{children:l,...i}=o,d=k.useMemo(()=>i,Object.values(i));return e.jsx(r.Provider,{value:d,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 qc(t,s=[]){let r=[];function n(o,l){const i=k.createContext(l),d=r.length;r=[...r,l];const u=f=>{var S;const{scope:y,children:_,...b}=f,N=((S=y==null?void 0:y[t])==null?void 0:S[d])||i,w=k.useMemo(()=>b,Object.values(b));return e.jsx(N.Provider,{value:w,children:_})};u.displayName=o+"Provider";function p(f,y){var N;const _=((N=y==null?void 0:y[t])==null?void 0:N[d])||i,b=k.useContext(_);if(b)return b;if(l!==void 0)return l;throw new Error(`\`${f}\` must be used within \`${o}\``)}return[u,p]}const a=()=>{const o=r.map(l=>k.createContext(l));return function(i){const d=(i==null?void 0:i[t])||o;return k.useMemo(()=>({[`__scope${t}`]:{...i,[t]:d}}),[i,d])}};return a.scopeName=t,[n,Ext(a,...s)]}function Ext(...t){const s=t[0];if(t.length===1)return s;const r=()=>{const n=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(o){const l=n.reduce((i,{useScope:d,scopeName:u})=>{const f=d(o)[`__scope${u}`];return{...i,...f}},{});return k.useMemo(()=>({[`__scope${s.scopeName}`]:l}),[l])}};return r.scopeName=s.scopeName,r}function Hb(t){const s=Pxt(t),r=k.forwardRef((n,a)=>{const{children:o,...l}=n,i=k.Children.toArray(o),d=i.find(Ixt);if(d){const u=d.props.children,p=i.map(f=>f===d?k.Children.count(u)>1?k.Children.only(null):k.isValidElement(u)?u.props.children:null:f);return e.jsx(s,{...l,ref:a,children:k.isValidElement(u)?k.cloneElement(u,void 0,p):null})}return e.jsx(s,{...l,ref:a,children:o})});return r.displayName=`${t}.Slot`,r}var tje=Hb("Slot");function Pxt(t){const s=k.forwardRef((r,n)=>{const{children:a,...o}=r;if(k.isValidElement(a)){const l=Dxt(a),i=Lxt(o,a.props);return a.type!==k.Fragment&&(i.ref=n?m1(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 Eqe=Symbol("radix.slottable");function Pqe(t){const s=({children:r})=>e.jsx(e.Fragment,{children:r});return s.displayName=`${t}.Slottable`,s.__radixId=Eqe,s}function Ixt(t){return k.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Eqe}function Lxt(t,s){const r={...s};for(const n in s){const a=t[n],o=s[n];/^on[A-Z]/.test(n)?a&&o?r[n]=(...i)=>{const d=o(...i);return a(...i),d}:a&&(r[n]=a):n==="style"?r[n]={...a,...o}:n==="className"&&(r[n]=[a,o].filter(Boolean).join(" "))}return{...t,...r}}function Dxt(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 wR(t){const s=t+"CollectionProvider",[r,n]=qc(s),[a,o]=r(s,{collectionRef:{current:null},itemMap:new Map}),l=N=>{const{scope:w,children:S}=N,C=xt.useRef(null),A=xt.useRef(new Map).current;return e.jsx(a,{scope:w,itemMap:A,collectionRef:C,children:S})};l.displayName=s;const i=t+"CollectionSlot",d=Hb(i),u=xt.forwardRef((N,w)=>{const{scope:S,children:C}=N,A=o(i,S),I=Ta(w,A.collectionRef);return e.jsx(d,{ref:I,children:C})});u.displayName=i;const p=t+"CollectionItemSlot",f="data-radix-collection-item",y=Hb(p),_=xt.forwardRef((N,w)=>{const{scope:S,children:C,...A}=N,I=xt.useRef(null),L=Ta(w,I),O=o(p,S);return xt.useEffect(()=>(O.itemMap.set(I,{ref:I,...A}),()=>void O.itemMap.delete(I))),e.jsx(y,{[f]:"",ref:L,children:C})});_.displayName=p;function b(N){const w=o(t+"CollectionConsumer",N);return xt.useCallback(()=>{const C=w.collectionRef.current;if(!C)return[];const A=Array.from(C.querySelectorAll(`[${f}]`));return Array.from(w.itemMap.values()).sort((O,V)=>A.indexOf(O.ref.current)-A.indexOf(V.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:l,Slot:u,ItemSlot:_},b,n]}var Rxt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Jr=Rxt.reduce((t,s)=>{const r=Hb(`Primitive.${s}`),n=k.forwardRef((a,o)=>{const{asChild:l,...i}=a,d=l?r:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(d,{...i,ref:o})});return n.displayName=`Primitive.${s}`,{...t,[s]:n}},{});function sje(t,s){t&&op.flushSync(()=>t.dispatchEvent(s))}function ed(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 Oxt(t,s=globalThis==null?void 0:globalThis.document){const r=ed(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 Fxt="DismissableLayer",jve="dismissableLayer.update",zxt="dismissableLayer.pointerDownOutside",Bxt="dismissableLayer.focusOutside",jEe,Iqe=k.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),dw=k.forwardRef((t,s)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,onDismiss:i,...d}=t,u=k.useContext(Iqe),[p,f]=k.useState(null),y=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,_]=k.useState({}),b=Ta(s,V=>f(V)),N=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),S=N.indexOf(w),C=p?N.indexOf(p):-1,A=u.layersWithOutsidePointerEventsDisabled.size>0,I=C>=S,L=qxt(V=>{const q=V.target,B=[...u.branches].some(U=>U.contains(q));!I||B||(a==null||a(V),l==null||l(V),V.defaultPrevented||i==null||i())},y),O=Uxt(V=>{const q=V.target;[...u.branches].some(U=>U.contains(q))||(o==null||o(V),l==null||l(V),V.defaultPrevented||i==null||i())},y);return Oxt(V=>{C===u.layers.size-1&&(n==null||n(V),!V.defaultPrevented&&i&&(V.preventDefault(),i()))},y),k.useEffect(()=>{if(p)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(jEe=y.body.style.pointerEvents,y.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),NEe(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(y.body.style.pointerEvents=jEe)}},[p,y,r,u]),k.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),NEe())},[p,u]),k.useEffect(()=>{const V=()=>_({});return document.addEventListener(jve,V),()=>document.removeEventListener(jve,V)},[]),e.jsx(Jr.div,{...d,ref:b,style:{pointerEvents:A?I?"auto":"none":void 0,...t.style},onFocusCapture:Mr(t.onFocusCapture,O.onFocusCapture),onBlurCapture:Mr(t.onBlurCapture,O.onBlurCapture),onPointerDownCapture:Mr(t.onPointerDownCapture,L.onPointerDownCapture)})});dw.displayName=Fxt;var $xt="DismissableLayerBranch",Lqe=k.forwardRef((t,s)=>{const r=k.useContext(Iqe),n=k.useRef(null),a=Ta(s,n);return k.useEffect(()=>{const o=n.current;if(o)return r.branches.add(o),()=>{r.branches.delete(o)}},[r.branches]),e.jsx(Jr.div,{...t,ref:a})});Lqe.displayName=$xt;function qxt(t,s=globalThis==null?void 0:globalThis.document){const r=ed(t),n=k.useRef(!1),a=k.useRef(()=>{});return k.useEffect(()=>{const o=i=>{if(i.target&&!n.current){let d=function(){Dqe(zxt,r,u,{discrete:!0})};const u={originalEvent:i};i.pointerType==="touch"?(s.removeEventListener("click",a.current),a.current=d,s.addEventListener("click",a.current,{once:!0})):d()}else s.removeEventListener("click",a.current);n.current=!1},l=window.setTimeout(()=>{s.addEventListener("pointerdown",o)},0);return()=>{window.clearTimeout(l),s.removeEventListener("pointerdown",o),s.removeEventListener("click",a.current)}},[s,r]),{onPointerDownCapture:()=>n.current=!0}}function Uxt(t,s=globalThis==null?void 0:globalThis.document){const r=ed(t),n=k.useRef(!1);return k.useEffect(()=>{const a=o=>{o.target&&!n.current&&Dqe(Bxt,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 NEe(){const t=new CustomEvent(jve);document.dispatchEvent(t)}function Dqe(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?sje(a,o):a.dispatchEvent(o)}var Vxt=dw,Hxt=Lqe,od=globalThis!=null&&globalThis.document?k.useLayoutEffect:()=>{},Gxt="Portal",IA=k.forwardRef((t,s)=>{var i;const{container:r,...n}=t,[a,o]=k.useState(!1);od(()=>o(!0),[]);const l=r||a&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return l?eje.createPortal(e.jsx(Jr.div,{...n,ref:s}),l):null});IA.displayName=Gxt;function Wxt(t,s){return k.useReducer((r,n)=>s[r][n]??r,t)}var jd=t=>{const{present:s,children:r}=t,n=Kxt(s),a=typeof r=="function"?r({present:n.isPresent}):k.Children.only(r),o=Ta(n.ref,Zxt(a));return typeof r=="function"||n.isPresent?k.cloneElement(a,{ref:o}):null};jd.displayName="Presence";function Kxt(t){const[s,r]=k.useState(),n=k.useRef(null),a=k.useRef(t),o=k.useRef("none"),l=t?"mounted":"unmounted",[i,d]=Wxt(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return k.useEffect(()=>{const u=pz(n.current);o.current=i==="mounted"?u:"none"},[i]),od(()=>{const u=n.current,p=a.current;if(p!==t){const y=o.current,_=pz(u);t?d("MOUNT"):_==="none"||(u==null?void 0:u.display)==="none"?d("UNMOUNT"):d(p&&y!==_?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,d]),od(()=>{if(s){let u;const p=s.ownerDocument.defaultView??window,f=_=>{const N=pz(n.current).includes(_.animationName);if(_.target===s&&N&&(d("ANIMATION_END"),!a.current)){const w=s.style.animationFillMode;s.style.animationFillMode="forwards",u=p.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=w)})}},y=_=>{_.target===s&&(o.current=pz(n.current))};return s.addEventListener("animationstart",y),s.addEventListener("animationcancel",f),s.addEventListener("animationend",f),()=>{p.clearTimeout(u),s.removeEventListener("animationstart",y),s.removeEventListener("animationcancel",f),s.removeEventListener("animationend",f)}}else d("ANIMATION_END")},[s,d]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:k.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function pz(t){return(t==null?void 0:t.animationName)||"none"}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)}var Yxt=c2e[" useInsertionEffect ".trim().toString()]||od;function Uu({prop:t,defaultProp:s,onChange:r=()=>{},caller:n}){const[a,o,l]=Xxt({defaultProp:s,onChange:r}),i=t!==void 0,d=i?t:a;{const p=k.useRef(t!==void 0);k.useEffect(()=>{const f=p.current;f!==i&&console.warn(`${n} is changing from ${f?"controlled":"uncontrolled"} to ${i?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),p.current=i},[i,n])}const u=k.useCallback(p=>{var f;if(i){const y=Qxt(p)?p(t):p;y!==t&&((f=l.current)==null||f.call(l,y))}else o(p)},[i,t,o,l]);return[d,u]}function Xxt({defaultProp:t,onChange:s}){const[r,n]=k.useState(t),a=k.useRef(r),o=k.useRef(s);return Yxt(()=>{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 Qxt(t){return typeof t=="function"}var Rqe=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"}),Jxt="VisuallyHidden",Yde=k.forwardRef((t,s)=>e.jsx(Jr.span,{...t,ref:s,style:{...Rqe,...t.style}}));Yde.displayName=Jxt;var egt=Yde,rje="ToastProvider",[nje,tgt,sgt]=wR("Toast"),[Oqe,RTs]=qc("Toast",[sgt]),[rgt,Xde]=Oqe(rje),Fqe=t=>{const{__scopeToast:s,label:r="Notification",duration:n=5e3,swipeDirection:a="right",swipeThreshold:o=50,children:l}=t,[i,d]=k.useState(null),[u,p]=k.useState(0),f=k.useRef(!1),y=k.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${rje}\`. Expected non-empty \`string\`.`),e.jsx(nje.Provider,{scope:s,children:e.jsx(rgt,{scope:s,label:r,duration:n,swipeDirection:a,swipeThreshold:o,toastCount:u,viewport:i,onViewportChange:d,onToastAdd:k.useCallback(()=>p(_=>_+1),[]),onToastRemove:k.useCallback(()=>p(_=>_-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:y,children:l})})};Fqe.displayName=rje;var zqe="ToastViewport",ngt=["F8"],Nve="toast.viewportPause",kve="toast.viewportResume",Bqe=k.forwardRef((t,s)=>{const{__scopeToast:r,hotkey:n=ngt,label:a="Notifications ({hotkey})",...o}=t,l=Xde(zqe,r),i=tgt(r),d=k.useRef(null),u=k.useRef(null),p=k.useRef(null),f=k.useRef(null),y=Ta(s,f,l.onViewportChange),_=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),b=l.toastCount>0;k.useEffect(()=>{const w=S=>{var A;n.length!==0&&n.every(I=>S[I]||S.code===I)&&((A=f.current)==null||A.focus())};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[n]),k.useEffect(()=>{const w=d.current,S=f.current;if(b&&w&&S){const C=()=>{if(!l.isClosePausedRef.current){const O=new CustomEvent(Nve);S.dispatchEvent(O),l.isClosePausedRef.current=!0}},A=()=>{if(l.isClosePausedRef.current){const O=new CustomEvent(kve);S.dispatchEvent(O),l.isClosePausedRef.current=!1}},I=O=>{!w.contains(O.relatedTarget)&&A()},L=()=>{w.contains(document.activeElement)||A()};return w.addEventListener("focusin",C),w.addEventListener("focusout",I),w.addEventListener("pointermove",C),w.addEventListener("pointerleave",L),window.addEventListener("blur",C),window.addEventListener("focus",A),()=>{w.removeEventListener("focusin",C),w.removeEventListener("focusout",I),w.removeEventListener("pointermove",C),w.removeEventListener("pointerleave",L),window.removeEventListener("blur",C),window.removeEventListener("focus",A)}}},[b,l.isClosePausedRef]);const N=k.useCallback(({tabbingDirection:w})=>{const C=i().map(A=>{const I=A.ref.current,L=[I,...ggt(I)];return w==="forwards"?L:L.reverse()});return(w==="forwards"?C.reverse():C).flat()},[i]);return k.useEffect(()=>{const w=f.current;if(w){const S=C=>{var L,O,V;const A=C.altKey||C.ctrlKey||C.metaKey;if(C.key==="Tab"&&!A){const q=document.activeElement,B=C.shiftKey;if(C.target===w&&B){(L=u.current)==null||L.focus();return}const Y=N({tabbingDirection:B?"backwards":"forwards"}),J=Y.findIndex(X=>X===q);Wxe(Y.slice(J+1))?C.preventDefault():B?(O=u.current)==null||O.focus():(V=p.current)==null||V.focus()}};return w.addEventListener("keydown",S),()=>w.removeEventListener("keydown",S)}},[i,N]),e.jsxs(Hxt,{ref:d,role:"region","aria-label":a.replace("{hotkey}",_),tabIndex:-1,style:{pointerEvents:b?void 0:"none"},children:[b&&e.jsx(Sve,{ref:u,onFocusFromOutsideViewport:()=>{const w=N({tabbingDirection:"forwards"});Wxe(w)}}),e.jsx(nje.Slot,{scope:r,children:e.jsx(Jr.ol,{tabIndex:-1,...o,ref:y})}),b&&e.jsx(Sve,{ref:p,onFocusFromOutsideViewport:()=>{const w=N({tabbingDirection:"backwards"});Wxe(w)}})]})});Bqe.displayName=zqe;var $qe="ToastFocusProxy",Sve=k.forwardRef((t,s)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...a}=t,o=Xde($qe,r);return e.jsx(Yde,{"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()}})});Sve.displayName=$qe;var jR="Toast",agt="toast.swipeStart",igt="toast.swipeMove",ogt="toast.swipeCancel",lgt="toast.swipeEnd",qqe=k.forwardRef((t,s)=>{const{forceMount:r,open:n,defaultOpen:a,onOpenChange:o,...l}=t,[i,d]=Uu({prop:n,defaultProp:a??!0,onChange:o,caller:jR});return e.jsx(jd,{present:r||i,children:e.jsx(ugt,{open:i,...l,ref:s,onClose:()=>d(!1),onPause:ed(t.onPause),onResume:ed(t.onResume),onSwipeStart:Mr(t.onSwipeStart,u=>{u.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Mr(t.onSwipeMove,u=>{const{x:p,y:f}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","move"),u.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${p}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${f}px`)}),onSwipeCancel:Mr(t.onSwipeCancel,u=>{u.currentTarget.setAttribute("data-swipe","cancel"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:Mr(t.onSwipeEnd,u=>{const{x:p,y:f}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","end"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${p}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${f}px`),d(!1)})})})});qqe.displayName=jR;var[cgt,dgt]=Oqe(jR,{onClose(){}}),ugt=k.forwardRef((t,s)=>{const{__scopeToast:r,type:n="foreground",duration:a,open:o,onClose:l,onEscapeKeyDown:i,onPause:d,onResume:u,onSwipeStart:p,onSwipeMove:f,onSwipeCancel:y,onSwipeEnd:_,...b}=t,N=Xde(jR,r),[w,S]=k.useState(null),C=Ta(s,X=>S(X)),A=k.useRef(null),I=k.useRef(null),L=a||N.duration,O=k.useRef(0),V=k.useRef(L),q=k.useRef(0),{onToastAdd:B,onToastRemove:U}=N,te=ed(()=>{var ce;(w==null?void 0:w.contains(document.activeElement))&&((ce=N.viewport)==null||ce.focus()),l()}),Y=k.useCallback(X=>{!X||X===1/0||(window.clearTimeout(q.current),O.current=new Date().getTime(),q.current=window.setTimeout(te,X))},[te]);k.useEffect(()=>{const X=N.viewport;if(X){const ce=()=>{Y(V.current),u==null||u()},ie=()=>{const ae=new Date().getTime()-O.current;V.current=V.current-ae,window.clearTimeout(q.current),d==null||d()};return X.addEventListener(Nve,ie),X.addEventListener(kve,ce),()=>{X.removeEventListener(Nve,ie),X.removeEventListener(kve,ce)}}},[N.viewport,L,d,u,Y]),k.useEffect(()=>{o&&!N.isClosePausedRef.current&&Y(L)},[o,L,N.isClosePausedRef,Y]),k.useEffect(()=>(B(),()=>U()),[B,U]);const J=k.useMemo(()=>w?Zqe(w):null,[w]);return N.viewport?e.jsxs(e.Fragment,{children:[J&&e.jsx(hgt,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:J}),e.jsx(cgt,{scope:r,onClose:te,children:op.createPortal(e.jsx(nje.ItemSlot,{scope:r,children:e.jsx(Vxt,{asChild:!0,onEscapeKeyDown:Mr(i,()=>{N.isFocusedToastEscapeKeyDownRef.current||te(),N.isFocusedToastEscapeKeyDownRef.current=!1}),children:e.jsx(Jr.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":o?"open":"closed","data-swipe-direction":N.swipeDirection,...b,ref:C,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:Mr(t.onKeyDown,X=>{X.key==="Escape"&&(i==null||i(X.nativeEvent),X.nativeEvent.defaultPrevented||(N.isFocusedToastEscapeKeyDownRef.current=!0,te()))}),onPointerDown:Mr(t.onPointerDown,X=>{X.button===0&&(A.current={x:X.clientX,y:X.clientY})}),onPointerMove:Mr(t.onPointerMove,X=>{if(!A.current)return;const ce=X.clientX-A.current.x,ie=X.clientY-A.current.y,ae=!!I.current,oe=["left","right"].includes(N.swipeDirection),me=["left","up"].includes(N.swipeDirection)?Math.min:Math.max,ve=oe?me(0,ce):0,he=oe?0:me(0,ie),ge=X.pointerType==="touch"?10:2,je={x:ve,y:he},qe={originalEvent:X,delta:je};ae?(I.current=je,fz(igt,f,qe,{discrete:!1})):kEe(je,N.swipeDirection,ge)?(I.current=je,fz(agt,p,qe,{discrete:!1}),X.target.setPointerCapture(X.pointerId)):(Math.abs(ce)>ge||Math.abs(ie)>ge)&&(A.current=null)}),onPointerUp:Mr(t.onPointerUp,X=>{const ce=I.current,ie=X.target;if(ie.hasPointerCapture(X.pointerId)&&ie.releasePointerCapture(X.pointerId),I.current=null,A.current=null,ce){const ae=X.currentTarget,oe={originalEvent:X,delta:ce};kEe(ce,N.swipeDirection,N.swipeThreshold)?fz(lgt,_,oe,{discrete:!0}):fz(ogt,y,oe,{discrete:!0}),ae.addEventListener("click",me=>me.preventDefault(),{once:!0})}})})})}),N.viewport)})]}):null}),hgt=t=>{const{__scopeToast:s,children:r,...n}=t,a=Xde(jR,s),[o,l]=k.useState(!1),[i,d]=k.useState(!1);return fgt(()=>l(!0)),k.useEffect(()=>{const u=window.setTimeout(()=>d(!0),1e3);return()=>window.clearTimeout(u)},[]),i?null:e.jsx(IA,{asChild:!0,children:e.jsx(Yde,{...n,children:o&&e.jsxs(e.Fragment,{children:[a.label," ",r]})})})},mgt="ToastTitle",Uqe=k.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(Jr.div,{...n,ref:s})});Uqe.displayName=mgt;var pgt="ToastDescription",Vqe=k.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(Jr.div,{...n,ref:s})});Vqe.displayName=pgt;var Hqe="ToastAction",Gqe=k.forwardRef((t,s)=>{const{altText:r,...n}=t;return r.trim()?e.jsx(Kqe,{altText:r,asChild:!0,children:e.jsx(aje,{...n,ref:s})}):(console.error(`Invalid prop \`altText\` supplied to \`${Hqe}\`. Expected non-empty \`string\`.`),null)});Gqe.displayName=Hqe;var Wqe="ToastClose",aje=k.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t,a=dgt(Wqe,r);return e.jsx(Kqe,{asChild:!0,children:e.jsx(Jr.button,{type:"button",...n,ref:s,onClick:Mr(t.onClick,a.onClose)})})});aje.displayName=Wqe;var Kqe=k.forwardRef((t,s)=>{const{__scopeToast:r,altText:n,...a}=t;return e.jsx(Jr.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":n||void 0,...a,ref:s})});function Zqe(t){const s=[];return Array.from(t.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&s.push(n.textContent),xgt(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(...Zqe(n))}}),s}function fz(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?sje(a,o):a.dispatchEvent(o)}var kEe=(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 fgt(t=()=>{}){const s=ed(t);od(()=>{let r=0,n=0;return r=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(s)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(n)}},[s])}function xgt(t){return t.nodeType===t.ELEMENT_NODE}function ggt(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 Wxe(t){const s=document.activeElement;return t.some(r=>r===s?!0:(r.focus(),document.activeElement!==s))}var ygt=Fqe,Yqe=Bqe,Xqe=qqe,Qqe=Uqe,Jqe=Vqe,eUe=Gqe,tUe=aje;function sUe(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,CEe=bi,bC=(t,s)=>r=>{var n;if((s==null?void 0:s.variants)==null)return CEe(t,r==null?void 0:r.class,r==null?void 0:r.className);const{variants:a,defaultVariants:o}=s,l=Object.keys(a).map(u=>{const p=r==null?void 0:r[u],f=o==null?void 0:o[u];if(p===null)return null;const y=SEe(p)||SEe(f);return a[u][y]}),i=r&&Object.entries(r).reduce((u,p)=>{let[f,y]=p;return y===void 0||(u[f]=y),u},{}),d=s==null||(n=s.compoundVariants)===null||n===void 0?void 0:n.reduce((u,p)=>{let{class:f,className:y,..._}=p;return Object.entries(_).every(b=>{let[N,w]=b;return Array.isArray(w)?w.includes({...o,...i}[N]):{...o,...i}[N]===w})?[...u,f,y]:u},[]);return CEe(t,l,d,r==null?void 0:r.class,r==null?void 0:r.className)};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vgt=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),rUe=(...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 _gt={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 nUe=k.forwardRef(({color:t="currentColor",size:s=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:a="",children:o,iconNode:l,...i},d)=>k.createElement("svg",{ref:d,..._gt,width:s,height:s,stroke:t,strokeWidth:n?Number(r)*24/Number(s):r,className:rUe("lucide",a),...i},[...l.map(([u,p])=>k.createElement(u,p)),...Array.isArray(o)?o:[o]]));/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z=(t,s)=>{const r=k.forwardRef(({className:n,...a},o)=>k.createElement(nUe,{ref:o,iconNode:s,className:rUe(`lucide-${vgt(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 Y9=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 X9=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 J9=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 lh=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 eB=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 tB=Z("Airplay",[["path",{d:"M5 17H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-1",key:"ns4c3b"}],["path",{d:"m12 15 5 6H7Z",key:"14qnn2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G2=Z("AlarmClockCheck",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}],["path",{d:"m9 13 2 2 4-4",key:"6343dt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W2=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 sB=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 K2=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 rB=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 nB=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 aB=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 iB=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 oB=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 V4=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 lB=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 cB=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 dB=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 uB=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 hB=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 mB=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 pB=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 fB=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 xB=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 gB=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 yB=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 H4=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 G4=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 vB=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 _B=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 bB=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 wB=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 jB=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 NB=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 kB=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 SB=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 CB=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 MB=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 TB=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 AB=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 EB=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 PB=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 IB=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 LB=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 DB=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 RB=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 OB=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 FB=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 zB=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 sL=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 BB=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 rL=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 $B=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 yM=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 qB=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 UB=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 VB=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 HB=Z("ArrowBigLeftDash",[["path",{d:"M19 15V9",key:"1hci5f"}],["path",{d:"M15 15h-3v4l-7-7 7-7v4h3v6z",key:"16tjna"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GB=Z("ArrowBigLeft",[["path",{d:"M18 15h-6v4l-7-7 7-7v4h6v6z",key:"lbrdak"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WB=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 KB=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 YB=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 XB=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 Z2=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 JB=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 e$=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 t$=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 nL=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 s$=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 r$=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 n$=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 Y2=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 X2=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 Ih=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 a$=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 i$=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 o$=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 Oa=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 l$=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 Gv=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 c$=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 Wa=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 d$=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 u$=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 Q2=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 td=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 h$=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 m$=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 p$=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 J2=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 aL=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 f$=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 x$=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 ej=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 uu=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 g$=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 y$=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 v$=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 _$=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 b$=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 w$=Z("AudioWaveform",[["path",{d:"M2 13a2 2 0 0 0 2-2V7a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0V4a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0v-4a2 2 0 0 1 2-2",key:"57tc96"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nc=Z("Award",[["path",{d:"m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526",key:"1yiouv"}],["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const j$=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 tj=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 N$=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 k$=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 S$=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 C$=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 sj=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 M$=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 T$=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 A$=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 E$=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 P$=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 I$=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 L$=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 D$=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 R$=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 O$=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 F$=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 z$=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 B$=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 $$=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 q$=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 iL=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 U$=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 V$=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 H$=Z("Banknote",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M6 12h.01M18 12h.01",key:"113zkx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G$=Z("Barcode",[["path",{d:"M3 5v14",key:"1nt18q"}],["path",{d:"M8 5v14",key:"1ybrkv"}],["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"M17 5v14",key:"ycjyhj"}],["path",{d:"M21 5v14",key:"nzette"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W$=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 nf=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 K$=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 Y$=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 X$=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 J$=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 eq=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 tq=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 sq=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 W4=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 rq=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 Zy=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 nq=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 aq=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 iq=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 oq=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 lq=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 cq=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 Wv=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 dq=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 uq=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 Sm=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 rj=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 nj=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 hq=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 mq=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 pq=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 fq=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 xq=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 gq=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 yq=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 vq=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 _q=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 bq=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 wq=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 jq=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 Nq=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 kq=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 Sq=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 Cq=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 K4=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 Mq=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 Tq=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 Aq=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 Eq=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 Pq=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 Iq=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 Lq=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 aj=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 Dq=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 Rq=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 Oq=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 Fq=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 zq=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 Bq=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 $q=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 qq=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 Uq=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 Vq=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 ch=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 Hq=Z("BookPlus",[["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gq=Z("BookText",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M8 11h8",key:"vwpz6n"}],["path",{d:"M8 7h6",key:"1f0q6e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wq=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 Kq=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 Yq=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 Xq=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 Jq=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 eU=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 oL=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 tU=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 fx=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 sU=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 rU=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 nU=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 vM=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 aU=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 iU=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 ij=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 oU=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 lU=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 cU=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 lL=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 dU=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 uU=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 hU=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 mU=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 dh=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 pU=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 fU=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 xU=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 gU=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 yU=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 pa=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 Z4=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 vU=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 _U=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 bU=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 wU=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 jU=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 Fu=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 _M=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 NU=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 kU=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 SU=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 CU=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 cL=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 bM=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 MU=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 _d=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 TU=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 AU=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 EU=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 PU=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 dL=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 IU=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 jb=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 LU=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 DU=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 RU=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 OU=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 FU=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 cn=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 zU=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 xx=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 BU=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 $U=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 qU=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 UU=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 VU=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 oj=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 HU=Z("CarFront",[["path",{d:"m21 8-2 2-1.5-3.7A2 2 0 0 0 15.646 5H8.4a2 2 0 0 0-1.903 1.257L5 10 3 8",key:"1imjwt"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 14h.01",key:"7oqj8z"}],["rect",{width:"18",height:"8",x:"3",y:"10",rx:"2",key:"a7itu8"}],["path",{d:"M5 18v2",key:"ppbyun"}],["path",{d:"M19 18v2",key:"gy7782"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GU=Z("CarTaxiFront",[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"m21 8-2 2-1.5-3.7A2 2 0 0 0 15.646 5H8.4a2 2 0 0 0-1.903 1.257L5 10 3 8",key:"1imjwt"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 14h.01",key:"7oqj8z"}],["rect",{width:"18",height:"8",x:"3",y:"10",rx:"2",key:"a7itu8"}],["path",{d:"M5 18v2",key:"ppbyun"}],["path",{d:"M19 18v2",key:"gy7782"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WU=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 KU=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 ZU=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 YU=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 XU=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 QU=Z("CaseUpper",[["path",{d:"m3 15 4-8 4 8",key:"1vwr6u"}],["path",{d:"M4 13h6",key:"1r9ots"}],["path",{d:"M15 11h4.5a2 2 0 0 1 0 4H15V7h4a2 2 0 0 1 0 4",key:"1sqfas"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JU=Z("CassetteTape",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["circle",{cx:"8",cy:"10",r:"2",key:"1xl4ub"}],["path",{d:"M8 12h8",key:"1wcyev"}],["circle",{cx:"16",cy:"10",r:"2",key:"r14t7q"}],["path",{d:"m6 20 .7-2.9A1.4 1.4 0 0 1 8.1 16h7.8a1.4 1.4 0 0 1 1.4 1l.7 3",key:"l01ucn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eV=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 tV=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 sV=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 rV=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 lj=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 cj=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 nV=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 aV=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 iV=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 dj=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 uj=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 hj=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 oV=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 mj=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 lV=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 so=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 cV=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 pj=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 dV=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 uV=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 fj=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 xj=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 hV=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 gj=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 yj=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 vj=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 mV=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 uL=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 Zn=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 pV=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 fV=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 Bi=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 xV=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 gV=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 Xo=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 xa=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 af=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 yV=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 vV=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 _V=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 bV=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 wV=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 jV=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 NV=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 gx=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 kV=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 SV=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 CV=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 MV=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 TV=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 ro=Z("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _j=Z("CircleArrowDown",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8 12 4 4 4-4",key:"k98ssh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bj=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 wj=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 jj=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 Nj=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 kj=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 Sj=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 Cj=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 si=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 $n=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 Mj=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 Tj=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 Aj=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 Ej=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 AV=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 Pj=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 EV=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 PV=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 IV=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 LV=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 DV=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 RV=Z("CircleFadingArrowUp",[["path",{d:"M12 2a10 10 0 0 1 7.38 16.75",key:"175t95"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}],["path",{d:"M2.5 8.875a10 10 0 0 0-.5 3",key:"1vce0s"}],["path",{d:"M2.83 16a10 10 0 0 0 2.43 3.4",key:"o3fkw4"}],["path",{d:"M4.636 5.235a10 10 0 0 1 .891-.857",key:"1szpfk"}],["path",{d:"M8.644 21.42a10 10 0 0 0 7.631-.38",key:"9yhvd4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OV=Z("CircleFadingPlus",[["path",{d:"M12 2a10 10 0 0 1 7.38 16.75",key:"175t95"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"M2.5 8.875a10 10 0 0 0-.5 3",key:"1vce0s"}],["path",{d:"M2.83 16a10 10 0 0 0 2.43 3.4",key:"o3fkw4"}],["path",{d:"M4.636 5.235a10 10 0 0 1 .891-.857",key:"1szpfk"}],["path",{d:"M8.644 21.42a10 10 0 0 0 7.631-.38",key:"9yhvd4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ij=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 Mv=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 Lj=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 FV=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 Dj=Z("CircleParkingOff",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m5 5 14 14",key:"11anup"}],["path",{d:"M13 13a3 3 0 1 0 0-6H9v2",key:"uoagbd"}],["path",{d:"M9 17v-2.34",key:"a9qo08"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rj=Z("CircleParking",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9 17V7h4a3 3 0 0 1 0 6H9",key:"1dfk2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oj=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 Fj=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 rp=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 zj=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 Bj=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 $j=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 zV=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 qj=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 Uj=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 Vj=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 Jl=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 sd=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 BV=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 $V=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 qV=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 wM=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 UV=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 Nb=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 VV=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 HV=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 Hj=Z("ClipboardPenLine",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",key:"1oijnt"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-.5",key:"1but9f"}],["path",{d:"M16 4h2a2 2 0 0 1 1.73 1",key:"1p8n7l"}],["path",{d:"M8 18h1",key:"13wk12"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gj=Z("ClipboardPen",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",key:"1oijnt"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-5.5",key:"cereej"}],["path",{d:"M4 13.5V6a2 2 0 0 1 2-2h2",key:"5ua5vh"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GV=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 WV=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 KV=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 ZV=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 YV=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 XV=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 QV=Z("Clock11",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 9.5 8",key:"l5bg6f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JV=Z("Clock12",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12",key:"1fub01"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eH=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 tH=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 sH=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 rH=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 nH=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 aH=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 iH=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 oH=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 lH=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 cH=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 dH=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 nn=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 uH=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 hH=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 Wj=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 mH=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 pH=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 fH=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 xH=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 gH=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 yH=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 vH=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 _H=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 bH=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 wH=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 jH=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 NH=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 Kj=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 kH=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 SH=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 Bv=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 CH=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 Zj=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 Y4=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 MH=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 TH=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 X4=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 AH=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 hL=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 Yj=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 Xj=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 EH=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 PH=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 IH=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 jM=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 LH=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 DH=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 RH=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 OH=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 FH=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 Qj=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 Q4=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 zH=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 BH=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 $H=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 qH=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 UH=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 VH=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 HH=Z("CopyPlus",[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GH=Z("CopySlash",[["line",{x1:"12",x2:"18",y1:"18",y2:"12",key:"ebkxgr"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WH=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 Va=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 KH=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 ZH=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 YH=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 XH=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 QH=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 JH=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 eG=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 tG=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 sG=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 rG=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 nG=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 aG=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 yx=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 iG=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 oG=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 lG=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 cG=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 Cm=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 dG=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 uG=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 hG=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 mG=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 pG=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 fG=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 xG=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 mL=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 gG=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 yG=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 vG=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 _G=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 Jj=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 bG=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 wG=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 jG=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 NG=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 kG=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 SG=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 CG=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 MG=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 TG=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 AG=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 EG=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 PG=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 IG=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 LG=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 DG=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 RG=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 OG=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 FG=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 zG=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 _c=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 BG=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 $G=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 Kv=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 qG=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 Qa=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 UG=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 VG=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 HG=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 GG=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 WG=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 Ag=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 KG=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 ZG=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 YG=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 XG=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 QG=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 JG=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 eN=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 eW=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 tW=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 sW=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 NM=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 ix=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 Zp=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 rW=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 nW=Z("EqualNot",[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}],["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aW=Z("Equal",[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iW=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 oW=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 lW=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 cW=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 Yr=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 dW=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 pp=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 jn=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 hu=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 uW=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 hW=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 mW=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 pW=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 fW=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 xW=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 gW=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 yW=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 vW=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 _W=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 tN=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 bW=Z("FileBadge2",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m14 12.5 1 5.5-3-1-3 1 1-5.5",key:"14xlky"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wW=Z("FileBadge",[["path",{d:"M12 22h6a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"12ixgl"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M5 17a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",key:"u0c8gj"}],["path",{d:"M7 16.5 8 22l-3-1-3 1 1-5.5",key:"5gm2nr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jW=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 sN=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 rN=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 nN=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 aN=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 NW=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 kW=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 SW=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 CW=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 MW=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 iN=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 TW=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 AW=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 J4=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 EW=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 kb=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 PW=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 IW=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 LW=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 DW=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 RW=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 OW=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 FW=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 zW=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 BW=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 $W=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 qW=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 oN=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 lN=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 UW=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 VW=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 HW=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 GW=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 WW=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 KW=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 ZW=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 Zv=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 pL=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 YW=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 XW=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 vn=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 QW=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 JW=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 eK=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 tK=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 sK=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 rK=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 nK=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 aK=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 iK=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 oK=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 lK=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 kM=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 cK=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 Rd=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 dK=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 Eg=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 uK=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 hK=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 mK=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 pK=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 fK=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 xK=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 gK=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 yK=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 Yv=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 vK=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 rd=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 _K=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 bK=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 wK=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 Sb=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 jK=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 NK=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 fL=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 kK=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 SK=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 kg=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 CK=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 MK=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 TK=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 AK=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 EK=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 PK=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 IK=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 LK=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 DK=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 cN=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 RK=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 OK=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 FK=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 zK=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 BK=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 $K=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 qK=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 UK=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 VK=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 HK=Z("FolderMinus",[["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GK=Z("FolderOpenDot",[["path",{d:"m6 14 1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2h3.93a2 2 0 0 1 1.66.9l.82 1.2a2 2 0 0 0 1.66.9H18a2 2 0 0 1 2 2v2",key:"1nmvlm"}],["circle",{cx:"14",cy:"15",r:"1",key:"1gm4qj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mm=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 WK=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 dN=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 KK=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 ZK=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 YK=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 XK=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 QK=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 JK=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 eZ=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 tZ=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 sZ=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 rZ=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 nZ=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 aZ=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 iZ=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 oZ=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 lZ=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 cZ=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 dZ=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 uZ=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 hZ=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 mZ=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 pZ=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 fZ=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 xZ=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 gZ=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 yZ=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 vZ=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 _Z=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 bZ=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 wZ=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 eS=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 hi=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 jZ=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 NZ=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 uN=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 kZ=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 SZ=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 CZ=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 MZ=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 TZ=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 AZ=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 EZ=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 PZ=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 IZ=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 LZ=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 DZ=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 RZ=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 OZ=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 FZ=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 zZ=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 BZ=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 $Z=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 qZ=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 UZ=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 Lh=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 VZ=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 HZ=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 hN=Z("Grid2x2Plus",[["path",{d:"M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3",key:"11za1p"}],["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M19 22v-6",key:"qhmiwi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GZ=Z("Grid2x2X",[["path",{d:"M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3",key:"11za1p"}],["path",{d:"m16 16 5 5",key:"8tpb07"}],["path",{d:"m16 21 5-5",key:"193jll"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mN=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 Xf=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 WZ=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 mu=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 KZ=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 ZZ=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 YZ=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 XZ=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 QZ=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 JZ=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 eY=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 pN=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 tY=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 sY=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 xL=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 gL=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 rY=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 nY=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 yL=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 aY=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 tS=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 iY=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 oY=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 SM=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 CM=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 vL=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 lY=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 cY=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 dY=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 uY=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 hY=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 mY=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 pY=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 fY=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 xY=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 gY=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 yY=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 Xa=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 vY=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 _Y=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 bY=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 MM=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 wY=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 jY=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 NY=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 kY=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 SY=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 CY=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 MY=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 Mn=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 fN=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 xN=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 TY=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 AY=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 EY=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 PY=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 IY=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 Xv=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 LY=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 DY=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 qo=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 RY=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 OY=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 FY=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 gN=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 yN=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 zY=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 BY=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 sS=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 $Y=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 rS=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 qY=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 UY=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 VY=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 HY=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 Yy=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 nS=Z("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GY=Z("KeySquare",[["path",{d:"M12.4 2.7a2.5 2.5 0 0 1 3.4 0l5.5 5.5a2.5 2.5 0 0 1 0 3.4l-3.7 3.7a2.5 2.5 0 0 1-3.4 0L8.7 9.8a2.5 2.5 0 0 1 0-3.4z",key:"165ttr"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"m9.4 10.6-6.814 6.814A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814",key:"1ubxi2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fp=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 WY=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 KY=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 ZY=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 YY=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 XY=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 QY=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 JY=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 eX=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 tX=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 sX=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 rX=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 nX=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 aX=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 vN=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 iX=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 oX=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 lX=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 cX=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 dX=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 uX=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 _L=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 aS=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 xp=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 hX=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 mX=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 pX=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 iS=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 fX=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 xX=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 gX=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 yX=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 vX=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 oS=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 TM=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 _X=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 bX=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 Cb=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 wX=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 Do=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 vo=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 gp=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 jX=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 NX=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 kX=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 SX=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 CX=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 MX=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 TX=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 Xy=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 AX=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 EX=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 PX=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 IX=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 LX=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 DX=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 RX=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 Dh=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 us=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 OX=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 FX=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 zX=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 BX=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 AM=Z("Locate",[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _N=Z("LockKeyholeOpen",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{width:"18",height:"12",x:"3",y:"10",rx:"2",key:"l0tzu3"}],["path",{d:"M7 10V7a5 5 0 0 1 9.33-2.5",key:"car5b7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $X=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 bN=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 ad=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 lS=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 EM=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 qX=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 UX=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 VX=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 HX=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 GX=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 WX=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 KX=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 bL=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 ZX=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 YX=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 XX=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 wL=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 tr=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 QX=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 JX=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 eQ=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 tQ=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 sQ=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 rQ=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 nQ=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 aQ=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 iQ=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 oQ=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 lQ=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 cQ=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 Ia=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 dQ=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 cS=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 uQ=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 hQ=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 jL=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 Qv=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 mQ=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 uh=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 pQ=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 fQ=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 dS=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 xQ=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 gQ=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 yQ=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 PM=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 vQ=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 _Q=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 bQ=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 NL=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 wQ=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 jQ=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 NQ=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 Fl=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 kQ=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 SQ=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 CQ=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 MQ=Z("MessageSquareDot",[["path",{d:"M11.7 3H5a2 2 0 0 0-2 2v16l4-4h12a2 2 0 0 0 2-2v-2.7",key:"uodpkb"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TQ=Z("MessageSquareHeart",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M14.8 7.5a1.84 1.84 0 0 0-2.6 0l-.2.3-.3-.3a1.84 1.84 0 1 0-2.4 2.8L12 13l2.7-2.7c.9-.9.8-2.1.1-2.8",key:"1blaws"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AQ=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 kL=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 EQ=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 IM=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 SL=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 PQ=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 IQ=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 LQ=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 DQ=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 RQ=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 wi=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 OQ=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 FQ=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 wN=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 CL=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 zQ=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 BQ=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 $Q=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 qQ=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 UQ=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 VQ=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 HQ=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 GQ=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 Qy=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 WQ=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 KQ=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 ZQ=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 YQ=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 XQ=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 QQ=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 JQ=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 eJ=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 tJ=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 sJ=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 uS=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 rJ=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 hS=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 nJ=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 aJ=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 iJ=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 oJ=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 lJ=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 cJ=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 dJ=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 Tm=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 au=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 uJ=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 jN=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 hJ=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 mJ=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 pJ=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 fJ=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 xJ=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 gJ=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 yJ=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 vJ=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 _J=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 bJ=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 wJ=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 jJ=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 NJ=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 kJ=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 SJ=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 CJ=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 MJ=Z("Music",[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TJ=Z("Navigation2Off",[["path",{d:"M9.31 9.31 5 21l7-4 7 4-1.17-3.17",key:"qoq2o2"}],["path",{d:"M14.53 8.88 12 2l-1.17 3.17",key:"k3sjzy"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AJ=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 EJ=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 ML=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 PJ=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 Jv=Z("Newspaper",[["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2",key:"7pis2x"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M10 6h8v4h-8V6Z",key:"smlsk5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IJ=Z("Nfc",[["path",{d:"M6 8.32a7.43 7.43 0 0 1 0 7.36",key:"9iaqei"}],["path",{d:"M9.46 6.21a11.76 11.76 0 0 1 0 11.58",key:"1yha7l"}],["path",{d:"M12.91 4.1a15.91 15.91 0 0 1 .01 15.8",key:"4iu2gk"}],["path",{d:"M16.37 2a20.16 20.16 0 0 1 0 20",key:"sap9u2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LJ=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 DJ=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 RJ=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 OJ=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 FJ=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 zJ=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 BJ=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 $J=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 Tv=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 qJ=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 NN=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 kN=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 UJ=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 VJ=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 HJ=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 GJ=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 WJ=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 KJ=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 ZJ=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 YJ=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 XJ=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 QJ=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 JJ=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 eee=Z("PackageX",[["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}],["path",{d:"m17 13 5 5m-5 0 5-5",key:"im3w4b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cl=Z("Package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7",key:"yx3hmr"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tee=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 see=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 SN=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 ree=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 zl=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 nee=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 CN=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 aee=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 iee=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 MN=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 TN=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 AN=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 EN=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 oee=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 PN=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 lee=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 cee=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 dee=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 IN=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 uee=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 hee=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 mee=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 pee=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 Av=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 mS=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 fee=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 xee=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 qd=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 hh=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 gee=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 yee=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 Ev=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 vee=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 Mb=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 Ry=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 _ee=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 bee=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 wee=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 ga=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 jee=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 LM=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 Nee=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 kee=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 See=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 Cee=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 Mee=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 Tee=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 Aee=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 Eee=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 In=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 Pee=Z("Pi",[["line",{x1:"9",x2:"9",y1:"4",y2:"20",key:"ovs5a5"}],["path",{d:"M4 7c0-1.7 1.3-3 3-3h13",key:"10pag4"}],["path",{d:"M18 20c-1.7 0-3-1.3-3-3V4",key:"1gaosr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iee=Z("Piano",[["path",{d:"M18.5 8c-1.4 0-2.6-.8-3.2-2A6.87 6.87 0 0 0 2 9v11a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-8.5C22 9.6 20.4 8 18.5 8",key:"lag0yf"}],["path",{d:"M2 14h20",key:"myj16y"}],["path",{d:"M6 14v4",key:"9ng0ue"}],["path",{d:"M10 14v4",key:"1v8uk5"}],["path",{d:"M14 14v4",key:"1tqops"}],["path",{d:"M18 14v4",key:"18uqwm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lee=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 Dee=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 Ree=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 Oee=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 Fee=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 zee=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 Bee=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 $ee=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 qee=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 TL=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 Tb=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 Uee=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 Vee=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 Hee=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 Gee=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 Wee=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 Co=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 Kee=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 LN=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 AL=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 Zee=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 Yee=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 Xee=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 Qee=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 Jee=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 ete=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 tte=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 ste=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 rte=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 EL=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 Pg=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 nte=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 PL=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 ate=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 ite=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 ote=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 lte=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 Jy=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 pS=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 cte=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 dte=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 ute=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 hte=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 mte=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 pte=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 e1=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 fte=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 xte=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 gte=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 yte=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 vte=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 _te=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 bte=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 wte=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 jte=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 Nte=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 kte=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 Ste=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 Cte=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 Mte=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 DN=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 Tte=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 Ate=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 Ete=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 Pte=Z("Redo2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ite=Z("RedoDot",[["circle",{cx:"12",cy:"17",r:"1",key:"1ixnty"}],["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fS=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 Lte=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 DM=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 Dte=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 Zi=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 Rte=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 Ote=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 Fte=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 zte=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 Bte=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 IL=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 $te=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 qte=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 Ute=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 LL=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 Vte=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 Hte=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 e0=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 Gte=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 Wte=Z("RollerCoaster",[["path",{d:"M6 19V5",key:"1r845m"}],["path",{d:"M10 19V6.8",key:"9j2tfs"}],["path",{d:"M14 19v-7.8",key:"10s8qv"}],["path",{d:"M18 5v4",key:"1tajlv"}],["path",{d:"M18 19v-6",key:"ielfq3"}],["path",{d:"M22 19V9",key:"158nzp"}],["path",{d:"M2 19V9a4 4 0 0 1 4-4c2 0 4 1.33 6 4s4 4 6 4a4 4 0 1 0-3-6.65",key:"1930oh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RN=Z("Rotate3d",[["path",{d:"M16.466 7.5C15.643 4.237 13.952 2 12 2 9.239 2 7 6.477 7 12s2.239 10 5 10c.342 0 .677-.069 1-.2",key:"10n0gc"}],["path",{d:"m15.194 13.707 3.814 1.86-1.86 3.814",key:"16shm9"}],["path",{d:"M19 15.57c-1.804.885-4.274 1.43-7 1.43-5.523 0-10-2.239-10-5s4.477-5 10-5c4.838 0 8.873 1.718 9.8 4",key:"1lxi77"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kte=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 t0=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 Zte=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 DL=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 Yte=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 Xte=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 Qte=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 ON=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 FN=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 Jte=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 ese=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 xS=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 tse=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 sse=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 rse=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 nse=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 ase=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 ise=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 ose=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 lse=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 bc=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 zN=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 RL=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 cse=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 dse=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 use=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 hse=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 mse=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 pse=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 fse=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 xse=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 gse=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 yse=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 vse=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 _se=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 bse=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 wse=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 jse=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 Nse=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 kse=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 Sse=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 Cse=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 OL=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 ln=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 Mse=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 BN=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 Tse=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 _n=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 Ase=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 Ese=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 Pse=Z("ServerCog",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5",key:"tn8das"}],["path",{d:"M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5",key:"1g2pve"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m15.7 13.4-.9-.3",key:"1jwmzr"}],["path",{d:"m9.2 10.9-.9-.3",key:"qapnim"}],["path",{d:"m10.6 15.7.3-.9",key:"quwk0k"}],["path",{d:"m13.6 15.7-.4-1",key:"cb9xp7"}],["path",{d:"m10.8 9.3-.4-1",key:"1uaiz5"}],["path",{d:"m8.3 13.6 1-.4",key:"s6srou"}],["path",{d:"m14.7 10.8 1-.4",key:"4d31cq"}],["path",{d:"m13.4 8.3-.3.9",key:"1bm987"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ise=Z("ServerCrash",[["path",{d:"M6 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-2",key:"4b9dqc"}],["path",{d:"M6 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-2",key:"22nnkd"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m13 6-4 6h6l-4 6",key:"14hqih"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lse=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 Dse=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 FL=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 So=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 Rse=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 id=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 zL=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 Ose=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 Fse=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 zse=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 Bse=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 t1=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 $se=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 qse=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 Use=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 gS=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 Vse=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 Hse=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 $N=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 zu=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 Gse=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 Wse=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 Kse=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 s0=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 Zse=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 lp=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 Yse=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 Xse=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 Qse=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 Jse=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 yS=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 ere=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 tre=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 sre=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 rre=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 nre=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 are=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 ire=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 ore=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 lre=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 cre=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 dre=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 ure=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 hre=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 mre=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 pre=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 fre=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 vS=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 qN=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 xre=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 gre=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 Ig=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 yre=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 vre=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 _re=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 qy=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 bre=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 wre=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 jre=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 Nre=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 kre=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 Or=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 Sre=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 Cre=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 Mre=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 Tre=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 Are=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 Ere=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 Pre=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 _S=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 UN=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 VN=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 HN=Z("SquareArrowDownRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m8 8 8 8",key:"1imecy"}],["path",{d:"M16 8v8H8",key:"1lbpgo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GN=Z("SquareArrowDown",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8 12 4 4 4-4",key:"k98ssh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WN=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 KN=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 ZN=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 YN=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 XN=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 QN=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 JN=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 ek=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 tk=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 sk=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 rk=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 ky=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 Pv=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 nk=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 ak=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 ik=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 ok=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 lk=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 ck=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 Ire=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 Lre=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 dk=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 uk=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 hk=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 mk=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 pk=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 fk=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 xk=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 gk=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 yk=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 vk=Z("SquareM",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 16V8l4 4 4-4v8",key:"141u4e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _k=Z("SquareMenu",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 8h10",key:"1jw688"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bk=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 wk=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 jk=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 Nk=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 Wc=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 kk=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 Sk=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 Ck=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 Mk=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 Tk=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 Ak=Z("SquarePower",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dre=Z("SquareRadical",[["path",{d:"M7 12h2l2 5 2-10h4",key:"1fxv6h"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ek=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 Pk=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 Ik=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 Lk=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 Dk=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 Rre=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 Ore=Z("SquareStack",[["path",{d:"M4 10c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h4c1.1 0 2 .9 2 2",key:"4i38lg"}],["path",{d:"M10 16c-1.1 0-2-.9-2-2v-4c0-1.1.9-2 2-2h4c1.1 0 2 .9 2 2",key:"mlte4a"}],["rect",{width:"8",height:"8",x:"14",y:"14",rx:"2",key:"1fa9i4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rk=Z("SquareTerminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ok=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 Fk=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 zk=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 r0=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 Fre=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 zre=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 Bre=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 $re=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 qre=Z("StarOff",[["path",{d:"M8.34 8.34 2 9.27l5 4.87L5.82 21 12 17.77 18.18 21l-.59-3.43",key:"16m0ql"}],["path",{d:"M18.42 12.76 22 9.27l-6.91-1L12 2l-1.44 2.91",key:"1vt8nq"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gn=Z("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ure=Z("StepBack",[["line",{x1:"18",x2:"18",y1:"20",y2:"4",key:"cun8e5"}],["polygon",{points:"14,20 4,12 14,4",key:"ypakod"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vre=Z("StepForward",[["line",{x1:"6",x2:"6",y1:"4",y2:"20",key:"fy8qot"}],["polygon",{points:"10,4 20,12 10,20",key:"1mc1pf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hre=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 Gre=Z("Sticker",[["path",{d:"M15.5 3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2V8.5L15.5 3Z",key:"1wis1t"}],["path",{d:"M14 3v4a2 2 0 0 0 2 2h4",key:"36rjfy"}],["path",{d:"M8 13h.01",key:"1sbv64"}],["path",{d:"M16 13h.01",key:"wip0gl"}],["path",{d:"M10 16s.8 1 2 1c1.3 0 2-1 2-1",key:"1vvgv3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wre=Z("StickyNote",[["path",{d:"M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z",key:"qazsjp"}],["path",{d:"M15 3v4a2 2 0 0 0 2 2h4",key:"40519r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kre=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 Zre=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 Yre=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 BL=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 Xre=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 Qre=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 Jre=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 ene=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 tne=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 s1=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 sne=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 rne=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 nne=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 ane=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 ine=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 one=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 lne=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 cne=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 dne=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 RM=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 une=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 hne=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 mne=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 pne=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 fne=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 xne=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 OM=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 gne=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 yne=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 vne=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 mh=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 _ne=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 bne=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 wne=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 jne=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 Nne=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 kne=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 Sne=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 Rh=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 Cne=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 Mne=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 Tne=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 Ane=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 Bk=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 Ene=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 Pne=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 Ine=Z("TextCursorInput",[["path",{d:"M5 4h1a3 3 0 0 1 3 3 3 3 0 0 1 3-3h1",key:"18xjzo"}],["path",{d:"M13 20h-1a3 3 0 0 1-3-3 3 3 0 0 1-3 3H5",key:"fj48gi"}],["path",{d:"M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1",key:"1n9rhb"}],["path",{d:"M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7",key:"13ksps"}],["path",{d:"M9 7v10",key:"1vc8ob"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lne=Z("TextCursor",[["path",{d:"M17 22h-1a4 4 0 0 1-4-4V6a4 4 0 0 1 4-4h1",key:"uvaxm9"}],["path",{d:"M7 22h1a4 4 0 0 0 4-4v-1",key:"11xy8d"}],["path",{d:"M7 2h1a4 4 0 0 1 4 4v1",key:"1uw06m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dne=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 Rne=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 $k=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 One=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 Fne=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 zne=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 Bne=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 $ne=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 $L=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 Bu=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 qne=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 Une=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 Vne=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 Hne=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 Gne=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 Wne=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 Kne=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 Zne=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 Yne=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 Xne=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 Qne=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 Jne=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 eae=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 tae=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 sae=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 rae=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 nae=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 aae=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 iae=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 oae=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 lae=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 cae=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 dae=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 uae=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 hae=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 qk=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 vr=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 mae=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 pae=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 Uk=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 Ab=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 fae=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 xae=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 bS=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 gae=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 Qo=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 Dc=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 yae=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 vae=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 Fi=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 UL=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 _ae=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 bae=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 Vk=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 wae=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 jae=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 Nae=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 kae=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 Sae=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 Cae=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 VL=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 Tae=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 Aae=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 wS=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 Eae=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 Pae=Z("UnfoldVertical",[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m15 5-3-3-3 3",key:"itvq4r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iae=Z("Ungroup",[["rect",{width:"8",height:"6",x:"5",y:"4",rx:"1",key:"nzclkv"}],["rect",{width:"8",height:"6",x:"11",y:"14",rx:"1",key:"4tytwb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hk=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 Lae=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 jS=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 Dae=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 Ra=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 Rae=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 n0=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 HL=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 GL=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 Oae=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 Jo=Z("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gk=Z("UserRoundCheck",[["path",{d:"M2 21a8 8 0 0 1 13.292-6",key:"bjp14o"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wk=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 Kk=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 Fae=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 Zk=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 zae=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 Yk=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 Xk=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 Bae=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 $ae=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 Ai=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 Qk=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 ir=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 Jk=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 e4=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 qae=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 FM=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 Uae=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 Vae=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 Hae=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 Gae=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 Wae=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 Kae=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 yn=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 Zae=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 Yae=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 Xae=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 Qae=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 Jae=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 eie=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 tie=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 sie=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 rie=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 nie=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 aie=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 t4=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 WL=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 iie=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 Iv=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 oie=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 lie=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 cie=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 die=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 uie=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 hie=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 mie=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 pie=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 fie=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 xie=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 gie=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 yie=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 vie=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 _ie=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 bie=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 wie=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 jie=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 Nie=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 kie=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 Sie=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 Cie=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 Mie=Z("Wine",[["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M12 15v7",key:"t2xh3l"}],["path",{d:"M12 15a5 5 0 0 0 5-5c0-2-.5-4-2-8H9c-1.5 4-2 6-2 8a5 5 0 0 0 5 5Z",key:"10ffi3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tie=Z("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aie=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 Eie=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 Lg=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 kr=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 Pie=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 Iie=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 Oh=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 Eb=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 zM=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 bgt=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:Y9,AArrowUp:X9,ALargeSmall:Q9,Accessibility:J9,Activity:lh,AirVent:eB,Airplay:tB,AlarmClock:rB,AlarmClockCheck:G2,AlarmClockMinus:W2,AlarmClockOff:sB,AlarmClockPlus:K2,AlarmSmoke:nB,Album:aB,AlignCenter:V4,AlignCenterHorizontal:iB,AlignCenterVertical:oB,AlignEndHorizontal:lB,AlignEndVertical:cB,AlignHorizontalDistributeCenter:dB,AlignHorizontalDistributeEnd:uB,AlignHorizontalDistributeStart:hB,AlignHorizontalJustifyCenter:mB,AlignHorizontalJustifyEnd:pB,AlignHorizontalJustifyStart:fB,AlignHorizontalSpaceAround:xB,AlignHorizontalSpaceBetween:gB,AlignJustify:yB,AlignLeft:H4,AlignRight:G4,AlignStartHorizontal:vB,AlignStartVertical:_B,AlignVerticalDistributeCenter:bB,AlignVerticalDistributeEnd:wB,AlignVerticalDistributeStart:jB,AlignVerticalJustifyCenter:NB,AlignVerticalJustifyEnd:kB,AlignVerticalJustifyStart:SB,AlignVerticalSpaceAround:CB,AlignVerticalSpaceBetween:MB,Ambulance:TB,Ampersand:AB,Ampersands:EB,Amphora:PB,Anchor:IB,Angry:LB,Annoyed:DB,Antenna:RB,Anvil:OB,Aperture:FB,AppWindow:sL,AppWindowMac:zB,Apple:BB,Archive:yM,ArchiveRestore:rL,ArchiveX:$B,Armchair:qB,ArrowBigDown:VB,ArrowBigDownDash:UB,ArrowBigLeft:GB,ArrowBigLeftDash:HB,ArrowBigRight:KB,ArrowBigRightDash:WB,ArrowBigUp:YB,ArrowBigUpDash:ZB,ArrowDown:Ih,ArrowDown01:XB,ArrowDown10:QB,ArrowDownAZ:Z2,ArrowDownFromLine:JB,ArrowDownLeft:e$,ArrowDownNarrowWide:t$,ArrowDownRight:nL,ArrowDownToDot:s$,ArrowDownToLine:r$,ArrowDownUp:n$,ArrowDownWideNarrow:Y2,ArrowDownZA:X2,ArrowLeft:Oa,ArrowLeftFromLine:a$,ArrowLeftRight:i$,ArrowLeftToLine:o$,ArrowRight:Wa,ArrowRightFromLine:l$,ArrowRightLeft:Gv,ArrowRightToLine:c$,ArrowUp:uu,ArrowUp01:d$,ArrowUp10:u$,ArrowUpAZ:Q2,ArrowUpDown:td,ArrowUpFromDot:h$,ArrowUpFromLine:m$,ArrowUpLeft:p$,ArrowUpNarrowWide:J2,ArrowUpRight:aL,ArrowUpToLine:f$,ArrowUpWideNarrow:x$,ArrowUpZA:ej,ArrowsUpFromLine:g$,Asterisk:y$,AtSign:v$,Atom:_$,AudioLines:b$,AudioWaveform:w$,Award:nc,Axe:j$,Axis3d:tj,Baby:N$,Backpack:k$,Badge:$$,BadgeAlert:S$,BadgeCent:C$,BadgeCheck:sj,BadgeDollarSign:M$,BadgeEuro:T$,BadgeHelp:A$,BadgeIndianRupee:E$,BadgeInfo:P$,BadgeJapaneseYen:I$,BadgeMinus:L$,BadgePercent:D$,BadgePlus:R$,BadgePoundSterling:O$,BadgeRussianRuble:F$,BadgeSwissFranc:z$,BadgeX:B$,BaggageClaim:q$,Ban:iL,Banana:U$,Bandage:V$,Banknote:H$,Barcode:G$,Baseline:W$,Bath:nf,Battery:J$,BatteryCharging:K$,BatteryFull:Z$,BatteryLow:Y$,BatteryMedium:X$,BatteryWarning:Q$,Beaker:eq,Bean:sq,BeanOff:tq,Bed:Zy,BedDouble:W4,BedSingle:rq,Beef:nq,Beer:iq,BeerOff:aq,Bell:Sm,BellDot:oq,BellElectric:lq,BellMinus:cq,BellOff:Wv,BellPlus:dq,BellRing:uq,BetweenHorizontalEnd:rj,BetweenHorizontalStart:nj,BetweenVerticalEnd:hq,BetweenVerticalStart:mq,BicepsFlexed:pq,Bike:fq,Binary:xq,Binoculars:gq,Biohazard:yq,Bird:vq,Bitcoin:_q,Blend:bq,Blinds:wq,Blocks:jq,Bluetooth:Cq,BluetoothConnected:Nq,BluetoothOff:kq,BluetoothSearching:Sq,Bold:K4,Bolt:Mq,Bomb:Tq,Bone:Aq,Book:Qq,BookA:Eq,BookAudio:Pq,BookCheck:Iq,BookCopy:Lq,BookDashed:aj,BookDown:Dq,BookHeadphones:Rq,BookHeart:Oq,BookImage:Fq,BookKey:zq,BookLock:Bq,BookMarked:$q,BookMinus:qq,BookOpen:ch,BookOpenCheck:Uq,BookOpenText:Vq,BookPlus:Hq,BookText:Gq,BookType:Wq,BookUp:Zq,BookUp2:Kq,BookUser:Yq,BookX:Xq,Bookmark:fx,BookmarkCheck:Jq,BookmarkMinus:eU,BookmarkPlus:oL,BookmarkX:tU,BoomBox:sU,Bot:vM,BotMessageSquare:rU,BotOff:nU,Box:aU,Boxes:iU,Braces:ij,Brackets:oU,Brain:lL,BrainCircuit:lU,BrainCog:cU,BrickWall:dU,Briefcase:dh,BriefcaseBusiness:uU,BriefcaseConveyorBelt:hU,BriefcaseMedical:mU,BringToFront:pU,Brush:fU,Bug:yU,BugOff:xU,BugPlay:gU,Building:Z4,Building2:pa,Bus:_U,BusFront:vU,Cable:wU,CableCar:bU,Cake:Fu,CakeSlice:jU,Calculator:_M,Calendar:cn,Calendar1:NU,CalendarArrowDown:kU,CalendarArrowUp:SU,CalendarCheck:cL,CalendarCheck2:CU,CalendarClock:bM,CalendarCog:MU,CalendarDays:_d,CalendarFold:TU,CalendarHeart:AU,CalendarMinus:PU,CalendarMinus2:EU,CalendarOff:dL,CalendarPlus:jb,CalendarPlus2:IU,CalendarRange:LU,CalendarSearch:DU,CalendarSync:RU,CalendarX:FU,CalendarX2:OU,Camera:xx,CameraOff:zU,Candy:qU,CandyCane:BU,CandyOff:$U,Cannabis:UU,Captions:oj,CaptionsOff:VU,Car:WU,CarFront:HU,CarTaxiFront:GU,Caravan:KU,Carrot:ZU,CaseLower:YU,CaseSensitive:XU,CaseUpper:QU,CassetteTape:JU,Cast:eV,Castle:tV,Cat:sV,Cctv:rV,ChartArea:lj,ChartBar:dj,ChartBarBig:cj,ChartBarDecreasing:nV,ChartBarIncreasing:aV,ChartBarStacked:iV,ChartCandlestick:uj,ChartColumn:so,ChartColumnBig:hj,ChartColumnDecreasing:oV,ChartColumnIncreasing:mj,ChartColumnStacked:lV,ChartGantt:cV,ChartLine:pj,ChartNetwork:dV,ChartNoAxesColumn:xj,ChartNoAxesColumnDecreasing:uV,ChartNoAxesColumnIncreasing:fj,ChartNoAxesCombined:hV,ChartNoAxesGantt:gj,ChartPie:yj,ChartScatter:vj,ChartSpline:mV,Check:Zn,CheckCheck:uL,ChefHat:pV,Cherry:fV,ChevronDown:Bi,ChevronFirst:xV,ChevronLast:gV,ChevronLeft:Xo,ChevronRight:xa,ChevronUp:af,ChevronsDown:vV,ChevronsDownUp:yV,ChevronsLeft:wV,ChevronsLeftRight:bV,ChevronsLeftRightEllipsis:_V,ChevronsRight:NV,ChevronsRightLeft:jV,ChevronsUp:kV,ChevronsUpDown:gx,Chrome:SV,Church:CV,Cigarette:TV,CigaretteOff:MV,Circle:sd,CircleAlert:ro,CircleArrowDown:_j,CircleArrowLeft:bj,CircleArrowOutDownLeft:wj,CircleArrowOutDownRight:jj,CircleArrowOutUpLeft:Nj,CircleArrowOutUpRight:kj,CircleArrowRight:Sj,CircleArrowUp:Cj,CircleCheck:$n,CircleCheckBig:si,CircleChevronDown:Mj,CircleChevronLeft:Tj,CircleChevronRight:Aj,CircleChevronUp:Ej,CircleDashed:AV,CircleDivide:Pj,CircleDollarSign:EV,CircleDot:IV,CircleDotDashed:PV,CircleEllipsis:LV,CircleEqual:DV,CircleFadingArrowUp:RV,CircleFadingPlus:OV,CircleGauge:Ij,CircleHelp:Mv,CircleMinus:Lj,CircleOff:FV,CircleParking:Rj,CircleParkingOff:Dj,CirclePause:Oj,CirclePercent:Fj,CirclePlay:rp,CirclePlus:zj,CirclePower:Bj,CircleSlash:zV,CircleSlash2:$j,CircleStop:qj,CircleUser:Vj,CircleUserRound:Uj,CircleX:Jl,CircuitBoard:BV,Citrus:$V,Clapperboard:qV,Clipboard:ZV,ClipboardCheck:wM,ClipboardCopy:UV,ClipboardList:Nb,ClipboardMinus:VV,ClipboardPaste:HV,ClipboardPen:Gj,ClipboardPenLine:Hj,ClipboardPlus:GV,ClipboardType:WV,ClipboardX:KV,Clock:nn,Clock1:YV,Clock10:XV,Clock11:QV,Clock12:JV,Clock2:eH,Clock3:tH,Clock4:sH,Clock5:rH,Clock6:nH,Clock7:aH,Clock8:iH,Clock9:oH,ClockAlert:lH,ClockArrowDown:cH,ClockArrowUp:dH,Cloud:kH,CloudAlert:uH,CloudCog:hH,CloudDownload:Wj,CloudDrizzle:mH,CloudFog:pH,CloudHail:fH,CloudLightning:xH,CloudMoon:yH,CloudMoonRain:gH,CloudOff:vH,CloudRain:bH,CloudRainWind:_H,CloudSnow:wH,CloudSun:NH,CloudSunRain:jH,CloudUpload:Kj,Cloudy:SH,Clover:Bv,Club:CH,Code:Y4,CodeXml:Zj,Codepen:MH,Codesandbox:TH,Coffee:X4,Cog:AH,Coins:hL,Columns2:Yj,Columns3:Xj,Columns4:EH,Combine:PH,Command:IH,Compass:jM,Component:LH,Computer:DH,ConciergeBell:RH,Cone:OH,Construction:FH,Contact:Q4,ContactRound:Qj,Container:zH,Contrast:BH,Cookie:$H,CookingPot:qH,Copy:Va,CopyCheck:UH,CopyMinus:VH,CopyPlus:HH,CopySlash:GH,CopyX:WH,Copyleft:KH,Copyright:ZH,CornerDownLeft:YH,CornerDownRight:XH,CornerLeftDown:QH,CornerLeftUp:JH,CornerRightDown:eG,CornerRightUp:tG,CornerUpLeft:sG,CornerUpRight:rG,Cpu:nG,CreativeCommons:aG,CreditCard:yx,Croissant:iG,Crop:oG,Cross:lG,Crosshair:cG,Crown:Cm,Cuboid:dG,CupSoda:uG,Currency:hG,Cylinder:mG,Dam:pG,Database:mL,DatabaseBackup:fG,DatabaseZap:xG,Delete:gG,Dessert:yG,Diameter:vG,Diamond:wG,DiamondMinus:_G,DiamondPercent:Jj,DiamondPlus:bG,Dice1:jG,Dice2:NG,Dice3:kG,Dice4:SG,Dice5:CG,Dice6:MG,Dices:TG,Diff:AG,Disc:LG,Disc2:EG,Disc3:PG,DiscAlbum:IG,Divide:DG,Dna:OG,DnaOff:RG,Dock:FG,Dog:zG,DollarSign:_c,Donut:BG,DoorClosed:$G,DoorOpen:Kv,Dot:qG,Download:Qa,DraftingCompass:UG,Drama:VG,Dribbble:HG,Drill:GG,Droplet:WG,Droplets:Ag,Drum:KG,Drumstick:ZG,Dumbbell:YG,Ear:QG,EarOff:XG,Earth:eN,EarthLock:JG,Eclipse:eW,Egg:NM,EggFried:tW,EggOff:sW,Ellipsis:Zp,EllipsisVertical:ix,Equal:aW,EqualApproximately:rW,EqualNot:nW,Eraser:iW,EthernetPort:oW,Euro:lW,Expand:cW,ExternalLink:Yr,Eye:jn,EyeClosed:dW,EyeOff:pp,Facebook:hu,Factory:uW,Fan:hW,FastForward:mW,Feather:pW,Fence:fW,FerrisWheel:xW,Figma:gW,File:kM,FileArchive:yW,FileAudio:_W,FileAudio2:vW,FileAxis3d:tN,FileBadge:wW,FileBadge2:bW,FileBox:jW,FileChartColumn:rN,FileChartColumnIncreasing:sN,FileChartLine:nN,FileChartPie:aN,FileCheck:kW,FileCheck2:NW,FileClock:SW,FileCode:MW,FileCode2:CW,FileCog:iN,FileDiff:TW,FileDigit:AW,FileDown:J4,FileHeart:EW,FileImage:kb,FileInput:PW,FileJson:LW,FileJson2:IW,FileKey:RW,FileKey2:DW,FileLock:FW,FileLock2:OW,FileMinus:BW,FileMinus2:zW,FileMusic:$W,FileOutput:qW,FilePen:lN,FilePenLine:oN,FilePlus:VW,FilePlus2:UW,FileQuestion:HW,FileScan:GW,FileSearch:KW,FileSearch2:WW,FileSliders:ZW,FileSpreadsheet:Zv,FileStack:pL,FileSymlink:YW,FileTerminal:XW,FileText:vn,FileType:JW,FileType2:QW,FileUp:eK,FileUser:tK,FileVideo:rK,FileVideo2:sK,FileVolume:aK,FileVolume2:nK,FileWarning:iK,FileX:lK,FileX2:oK,Files:cK,Film:Rd,Filter:Eg,FilterX:dK,Fingerprint:uK,FireExtinguisher:hK,Fish:fK,FishOff:mK,FishSymbol:pK,Flag:Yv,FlagOff:xK,FlagTriangleLeft:gK,FlagTriangleRight:yK,Flame:rd,FlameKindling:vK,Flashlight:bK,FlashlightOff:_K,FlaskConical:Sb,FlaskConicalOff:wK,FlaskRound:jK,FlipHorizontal:fL,FlipHorizontal2:NK,FlipVertical:SK,FlipVertical2:kK,Flower:CK,Flower2:kg,Focus:MK,FoldHorizontal:TK,FoldVertical:AK,Folder:rZ,FolderArchive:EK,FolderCheck:PK,FolderClock:IK,FolderClosed:LK,FolderCode:DK,FolderCog:cN,FolderDot:RK,FolderDown:OK,FolderGit:zK,FolderGit2:FK,FolderHeart:BK,FolderInput:$K,FolderKanban:qK,FolderKey:UK,FolderLock:VK,FolderMinus:HK,FolderOpen:Mm,FolderOpenDot:GK,FolderOutput:WK,FolderPen:dN,FolderPlus:KK,FolderRoot:ZK,FolderSearch:XK,FolderSearch2:YK,FolderSymlink:QK,FolderSync:JK,FolderTree:eZ,FolderUp:tZ,FolderX:sZ,Folders:nZ,Footprints:aZ,Forklift:iZ,Forward:oZ,Frame:lZ,Framer:cZ,Frown:dZ,Fuel:uZ,Fullscreen:hZ,GalleryHorizontal:pZ,GalleryHorizontalEnd:mZ,GalleryThumbnails:fZ,GalleryVertical:gZ,GalleryVerticalEnd:xZ,Gamepad:vZ,Gamepad2:yZ,Gauge:_Z,Gavel:bZ,Gem:wZ,Ghost:eS,Gift:hi,GitBranch:NZ,GitBranchPlus:jZ,GitCommitHorizontal:uN,GitCommitVertical:kZ,GitCompare:CZ,GitCompareArrows:SZ,GitFork:MZ,GitGraph:TZ,GitMerge:AZ,GitPullRequest:RZ,GitPullRequestArrow:EZ,GitPullRequestClosed:PZ,GitPullRequestCreate:LZ,GitPullRequestCreateArrow:IZ,GitPullRequestDraft:DZ,Github:OZ,Gitlab:FZ,GlassWater:zZ,Glasses:BZ,Globe:nd,GlobeLock:$Z,Goal:qZ,Grab:UZ,GraduationCap:Lh,Grape:VZ,Grid2x2:mN,Grid2x2Check:HZ,Grid2x2Plus:hN,Grid2x2X:GZ,Grid3x3:Xf,Grip:KZ,GripHorizontal:WZ,GripVertical:mu,Group:ZZ,Guitar:YZ,Ham:XZ,Hammer:QZ,Hand:xL,HandCoins:JZ,HandHeart:eY,HandHelping:pN,HandMetal:tY,HandPlatter:sY,Handshake:gL,HardDrive:yL,HardDriveDownload:rY,HardDriveUpload:nY,HardHat:aY,Hash:tS,Haze:iY,HdmiPort:oY,Heading:uY,Heading1:SM,Heading2:CM,Heading3:vL,Heading4:lY,Heading5:cY,Heading6:dY,HeadphoneOff:hY,Headphones:mY,Headset:pY,Heart:Xa,HeartCrack:fY,HeartHandshake:xY,HeartOff:gY,HeartPulse:yY,Heater:vY,Hexagon:_Y,Highlighter:bY,History:MM,Hop:jY,HopOff:wY,Hospital:NY,Hotel:kY,Hourglass:SY,House:Mn,HousePlug:CY,HousePlus:MY,IceCreamBowl:fN,IceCreamCone:xN,IdCard:TY,Image:qo,ImageDown:AY,ImageMinus:EY,ImageOff:PY,ImagePlay:IY,ImagePlus:Xv,ImageUp:LY,ImageUpscale:DY,Images:RY,Import:OY,Inbox:FY,IndentDecrease:gN,IndentIncrease:yN,IndianRupee:zY,Infinity:BY,Info:sS,InspectionPanel:$Y,Instagram:pu,Italic:rS,IterationCcw:qY,IterationCw:UY,JapaneseYen:VY,Joystick:HY,Kanban:Yy,Key:fp,KeyRound:nS,KeySquare:GY,Keyboard:ZY,KeyboardMusic:WY,KeyboardOff:KY,Lamp:tX,LampCeiling:YY,LampDesk:XY,LampFloor:QY,LampWallDown:JY,LampWallUp:eX,LandPlot:sX,Landmark:rX,Languages:nX,Laptop:iX,LaptopMinimal:vN,LaptopMinimalCheck:aX,Lasso:lX,LassoSelect:oX,Laugh:cX,Layers:_L,Layers2:dX,Layers3:uX,LayoutDashboard:aS,LayoutGrid:xp,LayoutList:hX,LayoutPanelLeft:mX,LayoutPanelTop:pX,LayoutTemplate:iS,Leaf:fX,LeafyGreen:xX,Lectern:gX,LetterText:yX,Library:oS,LibraryBig:vX,LifeBuoy:TM,Ligature:_X,Lightbulb:Cb,LightbulbOff:bX,Link:vo,Link2:Do,Link2Off:wX,Linkedin:gp,List:Dh,ListCheck:jX,ListChecks:NX,ListCollapse:kX,ListEnd:SX,ListFilter:CX,ListMinus:MX,ListMusic:TX,ListOrdered:Xy,ListPlus:AX,ListRestart:EX,ListStart:PX,ListTodo:IX,ListTree:LX,ListVideo:DX,ListX:RX,Loader:FX,LoaderCircle:us,LoaderPinwheel:OX,Locate:AM,LocateFixed:zX,LocateOff:BX,Lock:ad,LockKeyhole:$X,LockKeyholeOpen:_N,LockOpen:bN,LogIn:lS,LogOut:EM,Logs:qX,Lollipop:UX,Luggage:VX,Magnet:HX,Mail:tr,MailCheck:GX,MailMinus:WX,MailOpen:KX,MailPlus:bL,MailQuestion:ZX,MailSearch:YX,MailWarning:XX,MailX:wL,Mailbox:QX,Mails:JX,Map:cS,MapPin:Ia,MapPinCheck:tQ,MapPinCheckInside:eQ,MapPinHouse:sQ,MapPinMinus:nQ,MapPinMinusInside:rQ,MapPinOff:aQ,MapPinPlus:oQ,MapPinPlusInside:iQ,MapPinX:cQ,MapPinXInside:lQ,MapPinned:dQ,Martini:uQ,Maximize:jL,Maximize2:hQ,Medal:Qv,Megaphone:uh,MegaphoneOff:mQ,Meh:pQ,MemoryStick:fQ,Menu:dS,Merge:xQ,MessageCircle:Fl,MessageCircleCode:gQ,MessageCircleDashed:yQ,MessageCircleHeart:PM,MessageCircleMore:vQ,MessageCircleOff:_Q,MessageCirclePlus:bQ,MessageCircleQuestion:NL,MessageCircleReply:wQ,MessageCircleWarning:jQ,MessageCircleX:NQ,MessageSquare:wi,MessageSquareCode:kQ,MessageSquareDashed:SQ,MessageSquareDiff:CQ,MessageSquareDot:MQ,MessageSquareHeart:TQ,MessageSquareLock:AQ,MessageSquareMore:kL,MessageSquareOff:EQ,MessageSquarePlus:IM,MessageSquareQuote:SL,MessageSquareReply:PQ,MessageSquareShare:IQ,MessageSquareText:LQ,MessageSquareWarning:DQ,MessageSquareX:RQ,MessagesSquare:OQ,Mic:CL,MicOff:FQ,MicVocal:wN,Microchip:zQ,Microscope:BQ,Microwave:$Q,Milestone:qQ,Milk:VQ,MilkOff:UQ,Minimize:GQ,Minimize2:HQ,Minus:Qy,Monitor:hS,MonitorCheck:WQ,MonitorCog:KQ,MonitorDot:ZQ,MonitorDown:YQ,MonitorOff:XQ,MonitorPause:QQ,MonitorPlay:JQ,MonitorSmartphone:eJ,MonitorSpeaker:tJ,MonitorStop:sJ,MonitorUp:uS,MonitorX:rJ,Moon:aJ,MoonStar:nJ,Mountain:oJ,MountainSnow:iJ,Mouse:uJ,MouseOff:lJ,MousePointer:au,MousePointer2:cJ,MousePointerBan:dJ,MousePointerClick:Tm,Move:NJ,Move3d:jN,MoveDiagonal:mJ,MoveDiagonal2:hJ,MoveDown:xJ,MoveDownLeft:pJ,MoveDownRight:fJ,MoveHorizontal:gJ,MoveLeft:yJ,MoveRight:vJ,MoveUp:wJ,MoveUpLeft:_J,MoveUpRight:bJ,MoveVertical:jJ,Music:MJ,Music2:kJ,Music3:SJ,Music4:CJ,Navigation:ML,Navigation2:AJ,Navigation2Off:TJ,NavigationOff:EJ,Network:PJ,Newspaper:Jv,Nfc:IJ,Notebook:OJ,NotebookPen:LJ,NotebookTabs:DJ,NotebookText:RJ,NotepadText:zJ,NotepadTextDashed:FJ,Nut:$J,NutOff:BJ,Octagon:UJ,OctagonAlert:Tv,OctagonMinus:qJ,OctagonPause:NN,OctagonX:kN,Omega:VJ,Option:HJ,Orbit:GJ,Origami:WJ,Package:cl,Package2:KJ,PackageCheck:ZJ,PackageMinus:YJ,PackageOpen:XJ,PackagePlus:QJ,PackageSearch:JJ,PackageX:eee,PaintBucket:tee,PaintRoller:see,Paintbrush:ree,PaintbrushVertical:SN,Palette:zl,PanelBottom:iee,PanelBottomClose:nee,PanelBottomDashed:CN,PanelBottomOpen:aee,PanelLeft:EN,PanelLeftClose:MN,PanelLeftDashed:TN,PanelLeftOpen:AN,PanelRight:cee,PanelRightClose:oee,PanelRightDashed:PN,PanelRightOpen:lee,PanelTop:hee,PanelTopClose:dee,PanelTopDashed:IN,PanelTopOpen:uee,PanelsLeftBottom:mee,PanelsRightBottom:pee,PanelsTopLeft:Av,Paperclip:mS,Parentheses:fee,ParkingMeter:xee,PartyPopper:qd,Pause:hh,PawPrint:gee,PcCase:yee,Pen:Ry,PenLine:Ev,PenOff:vee,PenTool:Mb,Pencil:ga,PencilLine:_ee,PencilOff:bee,PencilRuler:wee,Pentagon:jee,Percent:LM,PersonStanding:Nee,PhilippinePeso:kee,Phone:In,PhoneCall:See,PhoneForwarded:Cee,PhoneIncoming:Mee,PhoneMissed:Tee,PhoneOff:Aee,PhoneOutgoing:Eee,Pi:Pee,Piano:Iee,Pickaxe:Lee,PictureInPicture:Ree,PictureInPicture2:Dee,PiggyBank:Oee,Pilcrow:Bee,PilcrowLeft:Fee,PilcrowRight:zee,Pill:qee,PillBottle:$ee,Pin:Tb,PinOff:TL,Pipette:Uee,Pizza:Vee,Plane:Wee,PlaneLanding:Hee,PlaneTakeoff:Gee,Play:Co,Plug:AL,Plug2:Kee,PlugZap:LN,Plus:qs,Pocket:Yee,PocketKnife:Zee,Podcast:Xee,Pointer:Jee,PointerOff:Qee,Popcorn:ete,Popsicle:tte,PoundSterling:ste,Power:EL,PowerOff:rte,Presentation:Pg,Printer:PL,PrinterCheck:nte,Projector:ate,Proportions:ite,Puzzle:ote,Pyramid:lte,QrCode:Jy,Quote:pS,Rabbit:cte,Radar:dte,Radiation:ute,Radical:hte,Radio:e1,RadioReceiver:mte,RadioTower:pte,Radius:fte,RailSymbol:xte,Rainbow:gte,Rat:yte,Ratio:vte,Receipt:Mte,ReceiptCent:_te,ReceiptEuro:bte,ReceiptIndianRupee:wte,ReceiptJapaneseYen:jte,ReceiptPoundSterling:Nte,ReceiptRussianRuble:kte,ReceiptSwissFranc:Ste,ReceiptText:Cte,RectangleEllipsis:DN,RectangleHorizontal:Tte,RectangleVertical:Ate,Recycle:Ete,Redo:fS,Redo2:Pte,RedoDot:Ite,RefreshCcw:DM,RefreshCcwDot:Lte,RefreshCw:Zi,RefreshCwOff:Dte,Refrigerator:Rte,Regex:Ote,RemoveFormatting:Fte,Repeat:IL,Repeat1:zte,Repeat2:Bte,Replace:qte,ReplaceAll:$te,Reply:LL,ReplyAll:Ute,Rewind:Vte,Ribbon:Hte,Rocket:e0,RockingChair:Gte,RollerCoaster:Wte,Rotate3d:RN,RotateCcw:t0,RotateCcwSquare:Kte,RotateCw:DL,RotateCwSquare:Zte,Route:Xte,RouteOff:Yte,Router:Qte,Rows2:ON,Rows3:FN,Rows4:Jte,Rss:ese,Ruler:xS,RussianRuble:tse,Sailboat:sse,Salad:rse,Sandwich:nse,Satellite:ise,SatelliteDish:ase,Save:bc,SaveAll:ose,SaveOff:lse,Scale:RL,Scale3d:zN,Scaling:cse,Scan:gse,ScanBarcode:dse,ScanEye:use,ScanFace:hse,ScanLine:mse,ScanQrCode:pse,ScanSearch:fse,ScanText:xse,School:yse,Scissors:_se,ScissorsLineDashed:vse,ScreenShare:wse,ScreenShareOff:bse,Scroll:Nse,ScrollText:jse,Search:ln,SearchCheck:kse,SearchCode:Sse,SearchSlash:Cse,SearchX:OL,Section:Mse,Send:_n,SendHorizontal:BN,SendToBack:Tse,SeparatorHorizontal:Ase,SeparatorVertical:Ese,Server:Dse,ServerCog:Pse,ServerCrash:Ise,ServerOff:Lse,Settings:So,Settings2:FL,Shapes:Rse,Share:zL,Share2:id,Sheet:Ose,Shell:Fse,Shield:zu,ShieldAlert:zse,ShieldBan:Bse,ShieldCheck:t1,ShieldEllipsis:$se,ShieldHalf:qse,ShieldMinus:Use,ShieldOff:gS,ShieldPlus:Vse,ShieldQuestion:Hse,ShieldX:$N,Ship:Wse,ShipWheel:Gse,Shirt:Kse,ShoppingBag:s0,ShoppingBasket:Zse,ShoppingCart:lp,Shovel:Yse,ShowerHead:Xse,Shrink:Qse,Shrub:Jse,Shuffle:yS,Sigma:ere,Signal:are,SignalHigh:tre,SignalLow:sre,SignalMedium:rre,SignalZero:nre,Signature:ire,Signpost:lre,SignpostBig:ore,Siren:cre,SkipBack:dre,SkipForward:ure,Skull:hre,Slack:mre,Slash:pre,Slice:fre,SlidersHorizontal:vS,SlidersVertical:qN,Smartphone:Ig,SmartphoneCharging:xre,SmartphoneNfc:gre,Smile:vre,SmilePlus:yre,Snail:_re,Snowflake:qy,Sofa:bre,Soup:wre,Space:jre,Spade:Nre,Sparkle:kre,Sparkles:Or,Speaker:Sre,Speech:Cre,SpellCheck:Tre,SpellCheck2:Mre,Spline:Are,Split:Ere,SprayCan:Pre,Sprout:_S,Square:r0,SquareActivity:UN,SquareArrowDown:GN,SquareArrowDownLeft:VN,SquareArrowDownRight:HN,SquareArrowLeft:WN,SquareArrowOutDownLeft:KN,SquareArrowOutDownRight:ZN,SquareArrowOutUpLeft:YN,SquareArrowOutUpRight:XN,SquareArrowRight:QN,SquareArrowUp:tk,SquareArrowUpLeft:JN,SquareArrowUpRight:ek,SquareAsterisk:sk,SquareBottomDashedScissors:rk,SquareChartGantt:ky,SquareCheck:nk,SquareCheckBig:Pv,SquareChevronDown:ak,SquareChevronLeft:ik,SquareChevronRight:ok,SquareChevronUp:lk,SquareCode:ck,SquareDashed:hk,SquareDashedBottom:Lre,SquareDashedBottomCode:Ire,SquareDashedKanban:dk,SquareDashedMousePointer:uk,SquareDivide:mk,SquareDot:pk,SquareEqual:fk,SquareFunction:xk,SquareKanban:gk,SquareLibrary:yk,SquareM:vk,SquareMenu:_k,SquareMinus:bk,SquareMousePointer:wk,SquareParking:Nk,SquareParkingOff:jk,SquarePen:Wc,SquarePercent:kk,SquarePi:Sk,SquarePilcrow:Ck,SquarePlay:Mk,SquarePlus:Tk,SquarePower:Ak,SquareRadical:Dre,SquareScissors:Ek,SquareSigma:Pk,SquareSlash:Ik,SquareSplitHorizontal:Lk,SquareSplitVertical:Dk,SquareSquare:Rre,SquareStack:Ore,SquareTerminal:Rk,SquareUser:Fk,SquareUserRound:Ok,SquareX:zk,Squircle:Fre,Squirrel:zre,Stamp:Bre,Star:Gn,StarHalf:$re,StarOff:qre,StepBack:Ure,StepForward:Vre,Stethoscope:Hre,Sticker:Gre,StickyNote:Wre,Store:Kre,StretchHorizontal:Zre,StretchVertical:Yre,Strikethrough:BL,Subscript:Xre,Sun:s1,SunDim:Qre,SunMedium:Jre,SunMoon:ene,SunSnow:tne,Sunrise:sne,Sunset:rne,Superscript:nne,SwatchBook:ane,SwissFranc:ine,SwitchCamera:one,Sword:lne,Swords:cne,Syringe:dne,Table:OM,Table2:RM,TableCellsMerge:une,TableCellsSplit:hne,TableColumnsSplit:mne,TableOfContents:pne,TableProperties:fne,TableRowsSplit:xne,Tablet:yne,TabletSmartphone:gne,Tablets:vne,Tag:mh,Tags:_ne,Tally1:bne,Tally2:wne,Tally3:jne,Tally4:Nne,Tally5:kne,Tangent:Sne,Target:Rh,Telescope:Cne,Tent:Tne,TentTree:Mne,Terminal:Ane,TestTube:Ene,TestTubeDiagonal:Bk,TestTubes:Pne,Text:One,TextCursor:Lne,TextCursorInput:Ine,TextQuote:Dne,TextSearch:Rne,TextSelect:$k,Theater:Fne,Thermometer:$ne,ThermometerSnowflake:zne,ThermometerSun:Bne,ThumbsDown:$L,ThumbsUp:Bu,Ticket:qL,TicketCheck:qne,TicketMinus:Une,TicketPercent:Vne,TicketPlus:Hne,TicketSlash:Gne,TicketX:Wne,Tickets:Zne,TicketsPlane:Kne,Timer:Qne,TimerOff:Yne,TimerReset:Xne,ToggleLeft:Jne,ToggleRight:eae,Toilet:tae,Tornado:sae,Torus:rae,Touchpad:aae,TouchpadOff:nae,TowerControl:iae,ToyBrick:oae,Tractor:lae,TrafficCone:cae,TrainFront:uae,TrainFrontTunnel:dae,TrainTrack:hae,TramFront:qk,Trash:mae,Trash2:vr,TreeDeciduous:pae,TreePalm:Uk,TreePine:Ab,Trees:fae,Trello:xae,TrendingDown:bS,TrendingUp:Qo,TrendingUpDown:gae,Triangle:vae,TriangleAlert:Dc,TriangleRight:yae,Trophy:Fi,Truck:UL,Turtle:_ae,Tv:wae,TvMinimal:Vk,TvMinimalPlay:bae,Twitch:jae,Twitter:Nae,Type:Sae,TypeOutline:kae,Umbrella:Mae,UmbrellaOff:Cae,Underline:VL,Undo:wS,Undo2:Tae,UndoDot:Aae,UnfoldHorizontal:Eae,UnfoldVertical:Pae,Ungroup:Iae,University:Hk,Unlink:jS,Unlink2:Lae,Unplug:Dae,Upload:Ra,Usb:Rae,User:Ai,UserCheck:n0,UserCog:HL,UserMinus:GL,UserPen:Oae,UserPlus:Jo,UserRound:Xk,UserRoundCheck:Gk,UserRoundCog:Wk,UserRoundMinus:Kk,UserRoundPen:Fae,UserRoundPlus:Zk,UserRoundSearch:zae,UserRoundX:Yk,UserSearch:Bae,UserX:$ae,Users:ir,UsersRound:Qk,Utensils:e4,UtensilsCrossed:Jk,UtilityPole:qae,Variable:FM,Vault:Uae,Vegan:Vae,VenetianMask:Hae,Vibrate:Wae,VibrateOff:Gae,Video:yn,VideoOff:Kae,Videotape:Zae,View:Yae,Voicemail:Xae,Volleyball:Qae,Volume:rie,Volume1:Jae,Volume2:eie,VolumeOff:tie,VolumeX:sie,Vote:nie,Wallet:WL,WalletCards:aie,WalletMinimal:t4,Wallpaper:iie,Wand:oie,WandSparkles:Iv,Warehouse:lie,WashingMachine:cie,Watch:die,Waves:uie,Waypoints:hie,Webcam:mie,Webhook:fie,WebhookOff:pie,Weight:xie,Wheat:yie,WheatOff:gie,WholeWord:vie,Wifi:Nie,WifiHigh:_ie,WifiLow:bie,WifiOff:wie,WifiZero:jie,Wind:Sie,WindArrowDown:kie,Wine:Mie,WineOff:Cie,Workflow:Tie,Worm:Aie,WrapText:Eie,Wrench:Lg,X:kr,Youtube:Pie,Zap:Oh,ZapOff:Iie,ZoomIn:Eb,ZoomOut:zM},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 ije=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:Y9,AArrowDownIcon:Y9,AArrowUp:X9,AArrowUpIcon:X9,ALargeSmall:Q9,ALargeSmallIcon:Q9,Accessibility:J9,AccessibilityIcon:J9,Activity:lh,ActivityIcon:lh,ActivitySquare:UN,ActivitySquareIcon:UN,AirVent:eB,AirVentIcon:eB,Airplay:tB,AirplayIcon:tB,AlarmCheck:G2,AlarmCheckIcon:G2,AlarmClock:rB,AlarmClockCheck:G2,AlarmClockCheckIcon:G2,AlarmClockIcon:rB,AlarmClockMinus:W2,AlarmClockMinusIcon:W2,AlarmClockOff:sB,AlarmClockOffIcon:sB,AlarmClockPlus:K2,AlarmClockPlusIcon:K2,AlarmMinus:W2,AlarmMinusIcon:W2,AlarmPlus:K2,AlarmPlusIcon:K2,AlarmSmoke:nB,AlarmSmokeIcon:nB,Album:aB,AlbumIcon:aB,AlertCircle:ro,AlertCircleIcon:ro,AlertOctagon:Tv,AlertOctagonIcon:Tv,AlertTriangle:Dc,AlertTriangleIcon:Dc,AlignCenter:V4,AlignCenterHorizontal:iB,AlignCenterHorizontalIcon:iB,AlignCenterIcon:V4,AlignCenterVertical:oB,AlignCenterVerticalIcon:oB,AlignEndHorizontal:lB,AlignEndHorizontalIcon:lB,AlignEndVertical:cB,AlignEndVerticalIcon:cB,AlignHorizontalDistributeCenter:dB,AlignHorizontalDistributeCenterIcon:dB,AlignHorizontalDistributeEnd:uB,AlignHorizontalDistributeEndIcon:uB,AlignHorizontalDistributeStart:hB,AlignHorizontalDistributeStartIcon:hB,AlignHorizontalJustifyCenter:mB,AlignHorizontalJustifyCenterIcon:mB,AlignHorizontalJustifyEnd:pB,AlignHorizontalJustifyEndIcon:pB,AlignHorizontalJustifyStart:fB,AlignHorizontalJustifyStartIcon:fB,AlignHorizontalSpaceAround:xB,AlignHorizontalSpaceAroundIcon:xB,AlignHorizontalSpaceBetween:gB,AlignHorizontalSpaceBetweenIcon:gB,AlignJustify:yB,AlignJustifyIcon:yB,AlignLeft:H4,AlignLeftIcon:H4,AlignRight:G4,AlignRightIcon:G4,AlignStartHorizontal:vB,AlignStartHorizontalIcon:vB,AlignStartVertical:_B,AlignStartVerticalIcon:_B,AlignVerticalDistributeCenter:bB,AlignVerticalDistributeCenterIcon:bB,AlignVerticalDistributeEnd:wB,AlignVerticalDistributeEndIcon:wB,AlignVerticalDistributeStart:jB,AlignVerticalDistributeStartIcon:jB,AlignVerticalJustifyCenter:NB,AlignVerticalJustifyCenterIcon:NB,AlignVerticalJustifyEnd:kB,AlignVerticalJustifyEndIcon:kB,AlignVerticalJustifyStart:SB,AlignVerticalJustifyStartIcon:SB,AlignVerticalSpaceAround:CB,AlignVerticalSpaceAroundIcon:CB,AlignVerticalSpaceBetween:MB,AlignVerticalSpaceBetweenIcon:MB,Ambulance:TB,AmbulanceIcon:TB,Ampersand:AB,AmpersandIcon:AB,Ampersands:EB,AmpersandsIcon:EB,Amphora:PB,AmphoraIcon:PB,Anchor:IB,AnchorIcon:IB,Angry:LB,AngryIcon:LB,Annoyed:DB,AnnoyedIcon:DB,Antenna:RB,AntennaIcon:RB,Anvil:OB,AnvilIcon:OB,Aperture:FB,ApertureIcon:FB,AppWindow:sL,AppWindowIcon:sL,AppWindowMac:zB,AppWindowMacIcon:zB,Apple:BB,AppleIcon:BB,Archive:yM,ArchiveIcon:yM,ArchiveRestore:rL,ArchiveRestoreIcon:rL,ArchiveX:$B,ArchiveXIcon:$B,AreaChart:lj,AreaChartIcon:lj,Armchair:qB,ArmchairIcon:qB,ArrowBigDown:VB,ArrowBigDownDash:UB,ArrowBigDownDashIcon:UB,ArrowBigDownIcon:VB,ArrowBigLeft:GB,ArrowBigLeftDash:HB,ArrowBigLeftDashIcon:HB,ArrowBigLeftIcon:GB,ArrowBigRight:KB,ArrowBigRightDash:WB,ArrowBigRightDashIcon:WB,ArrowBigRightIcon:KB,ArrowBigUp:YB,ArrowBigUpDash:ZB,ArrowBigUpDashIcon:ZB,ArrowBigUpIcon:YB,ArrowDown:Ih,ArrowDown01:XB,ArrowDown01Icon:XB,ArrowDown10:QB,ArrowDown10Icon:QB,ArrowDownAZ:Z2,ArrowDownAZIcon:Z2,ArrowDownAz:Z2,ArrowDownAzIcon:Z2,ArrowDownCircle:_j,ArrowDownCircleIcon:_j,ArrowDownFromLine:JB,ArrowDownFromLineIcon:JB,ArrowDownIcon:Ih,ArrowDownLeft:e$,ArrowDownLeftFromCircle:wj,ArrowDownLeftFromCircleIcon:wj,ArrowDownLeftFromSquare:KN,ArrowDownLeftFromSquareIcon:KN,ArrowDownLeftIcon:e$,ArrowDownLeftSquare:VN,ArrowDownLeftSquareIcon:VN,ArrowDownNarrowWide:t$,ArrowDownNarrowWideIcon:t$,ArrowDownRight:nL,ArrowDownRightFromCircle:jj,ArrowDownRightFromCircleIcon:jj,ArrowDownRightFromSquare:ZN,ArrowDownRightFromSquareIcon:ZN,ArrowDownRightIcon:nL,ArrowDownRightSquare:HN,ArrowDownRightSquareIcon:HN,ArrowDownSquare:GN,ArrowDownSquareIcon:GN,ArrowDownToDot:s$,ArrowDownToDotIcon:s$,ArrowDownToLine:r$,ArrowDownToLineIcon:r$,ArrowDownUp:n$,ArrowDownUpIcon:n$,ArrowDownWideNarrow:Y2,ArrowDownWideNarrowIcon:Y2,ArrowDownZA:X2,ArrowDownZAIcon:X2,ArrowDownZa:X2,ArrowDownZaIcon:X2,ArrowLeft:Oa,ArrowLeftCircle:bj,ArrowLeftCircleIcon:bj,ArrowLeftFromLine:a$,ArrowLeftFromLineIcon:a$,ArrowLeftIcon:Oa,ArrowLeftRight:i$,ArrowLeftRightIcon:i$,ArrowLeftSquare:WN,ArrowLeftSquareIcon:WN,ArrowLeftToLine:o$,ArrowLeftToLineIcon:o$,ArrowRight:Wa,ArrowRightCircle:Sj,ArrowRightCircleIcon:Sj,ArrowRightFromLine:l$,ArrowRightFromLineIcon:l$,ArrowRightIcon:Wa,ArrowRightLeft:Gv,ArrowRightLeftIcon:Gv,ArrowRightSquare:QN,ArrowRightSquareIcon:QN,ArrowRightToLine:c$,ArrowRightToLineIcon:c$,ArrowUp:uu,ArrowUp01:d$,ArrowUp01Icon:d$,ArrowUp10:u$,ArrowUp10Icon:u$,ArrowUpAZ:Q2,ArrowUpAZIcon:Q2,ArrowUpAz:Q2,ArrowUpAzIcon:Q2,ArrowUpCircle:Cj,ArrowUpCircleIcon:Cj,ArrowUpDown:td,ArrowUpDownIcon:td,ArrowUpFromDot:h$,ArrowUpFromDotIcon:h$,ArrowUpFromLine:m$,ArrowUpFromLineIcon:m$,ArrowUpIcon:uu,ArrowUpLeft:p$,ArrowUpLeftFromCircle:Nj,ArrowUpLeftFromCircleIcon:Nj,ArrowUpLeftFromSquare:YN,ArrowUpLeftFromSquareIcon:YN,ArrowUpLeftIcon:p$,ArrowUpLeftSquare:JN,ArrowUpLeftSquareIcon:JN,ArrowUpNarrowWide:J2,ArrowUpNarrowWideIcon:J2,ArrowUpRight:aL,ArrowUpRightFromCircle:kj,ArrowUpRightFromCircleIcon:kj,ArrowUpRightFromSquare:XN,ArrowUpRightFromSquareIcon:XN,ArrowUpRightIcon:aL,ArrowUpRightSquare:ek,ArrowUpRightSquareIcon:ek,ArrowUpSquare:tk,ArrowUpSquareIcon:tk,ArrowUpToLine:f$,ArrowUpToLineIcon:f$,ArrowUpWideNarrow:x$,ArrowUpWideNarrowIcon:x$,ArrowUpZA:ej,ArrowUpZAIcon:ej,ArrowUpZa:ej,ArrowUpZaIcon:ej,ArrowsUpFromLine:g$,ArrowsUpFromLineIcon:g$,Asterisk:y$,AsteriskIcon:y$,AsteriskSquare:sk,AsteriskSquareIcon:sk,AtSign:v$,AtSignIcon:v$,Atom:_$,AtomIcon:_$,AudioLines:b$,AudioLinesIcon:b$,AudioWaveform:w$,AudioWaveformIcon:w$,Award:nc,AwardIcon:nc,Axe:j$,AxeIcon:j$,Axis3D:tj,Axis3DIcon:tj,Axis3d:tj,Axis3dIcon:tj,Baby:N$,BabyIcon:N$,Backpack:k$,BackpackIcon:k$,Badge:$$,BadgeAlert:S$,BadgeAlertIcon:S$,BadgeCent:C$,BadgeCentIcon:C$,BadgeCheck:sj,BadgeCheckIcon:sj,BadgeDollarSign:M$,BadgeDollarSignIcon:M$,BadgeEuro:T$,BadgeEuroIcon:T$,BadgeHelp:A$,BadgeHelpIcon:A$,BadgeIcon:$$,BadgeIndianRupee:E$,BadgeIndianRupeeIcon:E$,BadgeInfo:P$,BadgeInfoIcon:P$,BadgeJapaneseYen:I$,BadgeJapaneseYenIcon:I$,BadgeMinus:L$,BadgeMinusIcon:L$,BadgePercent:D$,BadgePercentIcon:D$,BadgePlus:R$,BadgePlusIcon:R$,BadgePoundSterling:O$,BadgePoundSterlingIcon:O$,BadgeRussianRuble:F$,BadgeRussianRubleIcon:F$,BadgeSwissFranc:z$,BadgeSwissFrancIcon:z$,BadgeX:B$,BadgeXIcon:B$,BaggageClaim:q$,BaggageClaimIcon:q$,Ban:iL,BanIcon:iL,Banana:U$,BananaIcon:U$,Bandage:V$,BandageIcon:V$,Banknote:H$,BanknoteIcon:H$,BarChart:fj,BarChart2:xj,BarChart2Icon:xj,BarChart3:so,BarChart3Icon:so,BarChart4:mj,BarChart4Icon:mj,BarChartBig:hj,BarChartBigIcon:hj,BarChartHorizontal:dj,BarChartHorizontalBig:cj,BarChartHorizontalBigIcon:cj,BarChartHorizontalIcon:dj,BarChartIcon:fj,Barcode:G$,BarcodeIcon:G$,Baseline:W$,BaselineIcon:W$,Bath:nf,BathIcon:nf,Battery:J$,BatteryCharging:K$,BatteryChargingIcon:K$,BatteryFull:Z$,BatteryFullIcon:Z$,BatteryIcon:J$,BatteryLow:Y$,BatteryLowIcon:Y$,BatteryMedium:X$,BatteryMediumIcon:X$,BatteryWarning:Q$,BatteryWarningIcon:Q$,Beaker:eq,BeakerIcon:eq,Bean:sq,BeanIcon:sq,BeanOff:tq,BeanOffIcon:tq,Bed:Zy,BedDouble:W4,BedDoubleIcon:W4,BedIcon:Zy,BedSingle:rq,BedSingleIcon:rq,Beef:nq,BeefIcon:nq,Beer:iq,BeerIcon:iq,BeerOff:aq,BeerOffIcon:aq,Bell:Sm,BellDot:oq,BellDotIcon:oq,BellElectric:lq,BellElectricIcon:lq,BellIcon:Sm,BellMinus:cq,BellMinusIcon:cq,BellOff:Wv,BellOffIcon:Wv,BellPlus:dq,BellPlusIcon:dq,BellRing:uq,BellRingIcon:uq,BetweenHorizonalEnd:rj,BetweenHorizonalEndIcon:rj,BetweenHorizonalStart:nj,BetweenHorizonalStartIcon:nj,BetweenHorizontalEnd:rj,BetweenHorizontalEndIcon:rj,BetweenHorizontalStart:nj,BetweenHorizontalStartIcon:nj,BetweenVerticalEnd:hq,BetweenVerticalEndIcon:hq,BetweenVerticalStart:mq,BetweenVerticalStartIcon:mq,BicepsFlexed:pq,BicepsFlexedIcon:pq,Bike:fq,BikeIcon:fq,Binary:xq,BinaryIcon:xq,Binoculars:gq,BinocularsIcon:gq,Biohazard:yq,BiohazardIcon:yq,Bird:vq,BirdIcon:vq,Bitcoin:_q,BitcoinIcon:_q,Blend:bq,BlendIcon:bq,Blinds:wq,BlindsIcon:wq,Blocks:jq,BlocksIcon:jq,Bluetooth:Cq,BluetoothConnected:Nq,BluetoothConnectedIcon:Nq,BluetoothIcon:Cq,BluetoothOff:kq,BluetoothOffIcon:kq,BluetoothSearching:Sq,BluetoothSearchingIcon:Sq,Bold:K4,BoldIcon:K4,Bolt:Mq,BoltIcon:Mq,Bomb:Tq,BombIcon:Tq,Bone:Aq,BoneIcon:Aq,Book:Qq,BookA:Eq,BookAIcon:Eq,BookAudio:Pq,BookAudioIcon:Pq,BookCheck:Iq,BookCheckIcon:Iq,BookCopy:Lq,BookCopyIcon:Lq,BookDashed:aj,BookDashedIcon:aj,BookDown:Dq,BookDownIcon:Dq,BookHeadphones:Rq,BookHeadphonesIcon:Rq,BookHeart:Oq,BookHeartIcon:Oq,BookIcon:Qq,BookImage:Fq,BookImageIcon:Fq,BookKey:zq,BookKeyIcon:zq,BookLock:Bq,BookLockIcon:Bq,BookMarked:$q,BookMarkedIcon:$q,BookMinus:qq,BookMinusIcon:qq,BookOpen:ch,BookOpenCheck:Uq,BookOpenCheckIcon:Uq,BookOpenIcon:ch,BookOpenText:Vq,BookOpenTextIcon:Vq,BookPlus:Hq,BookPlusIcon:Hq,BookTemplate:aj,BookTemplateIcon:aj,BookText:Gq,BookTextIcon:Gq,BookType:Wq,BookTypeIcon:Wq,BookUp:Zq,BookUp2:Kq,BookUp2Icon:Kq,BookUpIcon:Zq,BookUser:Yq,BookUserIcon:Yq,BookX:Xq,BookXIcon:Xq,Bookmark:fx,BookmarkCheck:Jq,BookmarkCheckIcon:Jq,BookmarkIcon:fx,BookmarkMinus:eU,BookmarkMinusIcon:eU,BookmarkPlus:oL,BookmarkPlusIcon:oL,BookmarkX:tU,BookmarkXIcon:tU,BoomBox:sU,BoomBoxIcon:sU,Bot:vM,BotIcon:vM,BotMessageSquare:rU,BotMessageSquareIcon:rU,BotOff:nU,BotOffIcon:nU,Box:aU,BoxIcon:aU,BoxSelect:hk,BoxSelectIcon:hk,Boxes:iU,BoxesIcon:iU,Braces:ij,BracesIcon:ij,Brackets:oU,BracketsIcon:oU,Brain:lL,BrainCircuit:lU,BrainCircuitIcon:lU,BrainCog:cU,BrainCogIcon:cU,BrainIcon:lL,BrickWall:dU,BrickWallIcon:dU,Briefcase:dh,BriefcaseBusiness:uU,BriefcaseBusinessIcon:uU,BriefcaseConveyorBelt:hU,BriefcaseConveyorBeltIcon:hU,BriefcaseIcon:dh,BriefcaseMedical:mU,BriefcaseMedicalIcon:mU,BringToFront:pU,BringToFrontIcon:pU,Brush:fU,BrushIcon:fU,Bug:yU,BugIcon:yU,BugOff:xU,BugOffIcon:xU,BugPlay:gU,BugPlayIcon:gU,Building:Z4,Building2:pa,Building2Icon:pa,BuildingIcon:Z4,Bus:_U,BusFront:vU,BusFrontIcon:vU,BusIcon:_U,Cable:wU,CableCar:bU,CableCarIcon:bU,CableIcon:wU,Cake:Fu,CakeIcon:Fu,CakeSlice:jU,CakeSliceIcon:jU,Calculator:_M,CalculatorIcon:_M,Calendar:cn,Calendar1:NU,Calendar1Icon:NU,CalendarArrowDown:kU,CalendarArrowDownIcon:kU,CalendarArrowUp:SU,CalendarArrowUpIcon:SU,CalendarCheck:cL,CalendarCheck2:CU,CalendarCheck2Icon:CU,CalendarCheckIcon:cL,CalendarClock:bM,CalendarClockIcon:bM,CalendarCog:MU,CalendarCogIcon:MU,CalendarDays:_d,CalendarDaysIcon:_d,CalendarFold:TU,CalendarFoldIcon:TU,CalendarHeart:AU,CalendarHeartIcon:AU,CalendarIcon:cn,CalendarMinus:PU,CalendarMinus2:EU,CalendarMinus2Icon:EU,CalendarMinusIcon:PU,CalendarOff:dL,CalendarOffIcon:dL,CalendarPlus:jb,CalendarPlus2:IU,CalendarPlus2Icon:IU,CalendarPlusIcon:jb,CalendarRange:LU,CalendarRangeIcon:LU,CalendarSearch:DU,CalendarSearchIcon:DU,CalendarSync:RU,CalendarSyncIcon:RU,CalendarX:FU,CalendarX2:OU,CalendarX2Icon:OU,CalendarXIcon:FU,Camera:xx,CameraIcon:xx,CameraOff:zU,CameraOffIcon:zU,CandlestickChart:uj,CandlestickChartIcon:uj,Candy:qU,CandyCane:BU,CandyCaneIcon:BU,CandyIcon:qU,CandyOff:$U,CandyOffIcon:$U,Cannabis:UU,CannabisIcon:UU,Captions:oj,CaptionsIcon:oj,CaptionsOff:VU,CaptionsOffIcon:VU,Car:WU,CarFront:HU,CarFrontIcon:HU,CarIcon:WU,CarTaxiFront:GU,CarTaxiFrontIcon:GU,Caravan:KU,CaravanIcon:KU,Carrot:ZU,CarrotIcon:ZU,CaseLower:YU,CaseLowerIcon:YU,CaseSensitive:XU,CaseSensitiveIcon:XU,CaseUpper:QU,CaseUpperIcon:QU,CassetteTape:JU,CassetteTapeIcon:JU,Cast:eV,CastIcon:eV,Castle:tV,CastleIcon:tV,Cat:sV,CatIcon:sV,Cctv:rV,CctvIcon:rV,ChartArea:lj,ChartAreaIcon:lj,ChartBar:dj,ChartBarBig:cj,ChartBarBigIcon:cj,ChartBarDecreasing:nV,ChartBarDecreasingIcon:nV,ChartBarIcon:dj,ChartBarIncreasing:aV,ChartBarIncreasingIcon:aV,ChartBarStacked:iV,ChartBarStackedIcon:iV,ChartCandlestick:uj,ChartCandlestickIcon:uj,ChartColumn:so,ChartColumnBig:hj,ChartColumnBigIcon:hj,ChartColumnDecreasing:oV,ChartColumnDecreasingIcon:oV,ChartColumnIcon:so,ChartColumnIncreasing:mj,ChartColumnIncreasingIcon:mj,ChartColumnStacked:lV,ChartColumnStackedIcon:lV,ChartGantt:cV,ChartGanttIcon:cV,ChartLine:pj,ChartLineIcon:pj,ChartNetwork:dV,ChartNetworkIcon:dV,ChartNoAxesColumn:xj,ChartNoAxesColumnDecreasing:uV,ChartNoAxesColumnDecreasingIcon:uV,ChartNoAxesColumnIcon:xj,ChartNoAxesColumnIncreasing:fj,ChartNoAxesColumnIncreasingIcon:fj,ChartNoAxesCombined:hV,ChartNoAxesCombinedIcon:hV,ChartNoAxesGantt:gj,ChartNoAxesGanttIcon:gj,ChartPie:yj,ChartPieIcon:yj,ChartScatter:vj,ChartScatterIcon:vj,ChartSpline:mV,ChartSplineIcon:mV,Check:Zn,CheckCheck:uL,CheckCheckIcon:uL,CheckCircle:si,CheckCircle2:$n,CheckCircle2Icon:$n,CheckCircleIcon:si,CheckIcon:Zn,CheckSquare:Pv,CheckSquare2:nk,CheckSquare2Icon:nk,CheckSquareIcon:Pv,ChefHat:pV,ChefHatIcon:pV,Cherry:fV,CherryIcon:fV,ChevronDown:Bi,ChevronDownCircle:Mj,ChevronDownCircleIcon:Mj,ChevronDownIcon:Bi,ChevronDownSquare:ak,ChevronDownSquareIcon:ak,ChevronFirst:xV,ChevronFirstIcon:xV,ChevronLast:gV,ChevronLastIcon:gV,ChevronLeft:Xo,ChevronLeftCircle:Tj,ChevronLeftCircleIcon:Tj,ChevronLeftIcon:Xo,ChevronLeftSquare:ik,ChevronLeftSquareIcon:ik,ChevronRight:xa,ChevronRightCircle:Aj,ChevronRightCircleIcon:Aj,ChevronRightIcon:xa,ChevronRightSquare:ok,ChevronRightSquareIcon:ok,ChevronUp:af,ChevronUpCircle:Ej,ChevronUpCircleIcon:Ej,ChevronUpIcon:af,ChevronUpSquare:lk,ChevronUpSquareIcon:lk,ChevronsDown:vV,ChevronsDownIcon:vV,ChevronsDownUp:yV,ChevronsDownUpIcon:yV,ChevronsLeft:wV,ChevronsLeftIcon:wV,ChevronsLeftRight:bV,ChevronsLeftRightEllipsis:_V,ChevronsLeftRightEllipsisIcon:_V,ChevronsLeftRightIcon:bV,ChevronsRight:NV,ChevronsRightIcon:NV,ChevronsRightLeft:jV,ChevronsRightLeftIcon:jV,ChevronsUp:kV,ChevronsUpDown:gx,ChevronsUpDownIcon:gx,ChevronsUpIcon:kV,Chrome:SV,ChromeIcon:SV,Church:CV,ChurchIcon:CV,Cigarette:TV,CigaretteIcon:TV,CigaretteOff:MV,CigaretteOffIcon:MV,Circle:sd,CircleAlert:ro,CircleAlertIcon:ro,CircleArrowDown:_j,CircleArrowDownIcon:_j,CircleArrowLeft:bj,CircleArrowLeftIcon:bj,CircleArrowOutDownLeft:wj,CircleArrowOutDownLeftIcon:wj,CircleArrowOutDownRight:jj,CircleArrowOutDownRightIcon:jj,CircleArrowOutUpLeft:Nj,CircleArrowOutUpLeftIcon:Nj,CircleArrowOutUpRight:kj,CircleArrowOutUpRightIcon:kj,CircleArrowRight:Sj,CircleArrowRightIcon:Sj,CircleArrowUp:Cj,CircleArrowUpIcon:Cj,CircleCheck:$n,CircleCheckBig:si,CircleCheckBigIcon:si,CircleCheckIcon:$n,CircleChevronDown:Mj,CircleChevronDownIcon:Mj,CircleChevronLeft:Tj,CircleChevronLeftIcon:Tj,CircleChevronRight:Aj,CircleChevronRightIcon:Aj,CircleChevronUp:Ej,CircleChevronUpIcon:Ej,CircleDashed:AV,CircleDashedIcon:AV,CircleDivide:Pj,CircleDivideIcon:Pj,CircleDollarSign:EV,CircleDollarSignIcon:EV,CircleDot:IV,CircleDotDashed:PV,CircleDotDashedIcon:PV,CircleDotIcon:IV,CircleEllipsis:LV,CircleEllipsisIcon:LV,CircleEqual:DV,CircleEqualIcon:DV,CircleFadingArrowUp:RV,CircleFadingArrowUpIcon:RV,CircleFadingPlus:OV,CircleFadingPlusIcon:OV,CircleGauge:Ij,CircleGaugeIcon:Ij,CircleHelp:Mv,CircleHelpIcon:Mv,CircleIcon:sd,CircleMinus:Lj,CircleMinusIcon:Lj,CircleOff:FV,CircleOffIcon:FV,CircleParking:Rj,CircleParkingIcon:Rj,CircleParkingOff:Dj,CircleParkingOffIcon:Dj,CirclePause:Oj,CirclePauseIcon:Oj,CirclePercent:Fj,CirclePercentIcon:Fj,CirclePlay:rp,CirclePlayIcon:rp,CirclePlus:zj,CirclePlusIcon:zj,CirclePower:Bj,CirclePowerIcon:Bj,CircleSlash:zV,CircleSlash2:$j,CircleSlash2Icon:$j,CircleSlashIcon:zV,CircleSlashed:$j,CircleSlashedIcon:$j,CircleStop:qj,CircleStopIcon:qj,CircleUser:Vj,CircleUserIcon:Vj,CircleUserRound:Uj,CircleUserRoundIcon:Uj,CircleX:Jl,CircleXIcon:Jl,CircuitBoard:BV,CircuitBoardIcon:BV,Citrus:$V,CitrusIcon:$V,Clapperboard:qV,ClapperboardIcon:qV,Clipboard:ZV,ClipboardCheck:wM,ClipboardCheckIcon:wM,ClipboardCopy:UV,ClipboardCopyIcon:UV,ClipboardEdit:Gj,ClipboardEditIcon:Gj,ClipboardIcon:ZV,ClipboardList:Nb,ClipboardListIcon:Nb,ClipboardMinus:VV,ClipboardMinusIcon:VV,ClipboardPaste:HV,ClipboardPasteIcon:HV,ClipboardPen:Gj,ClipboardPenIcon:Gj,ClipboardPenLine:Hj,ClipboardPenLineIcon:Hj,ClipboardPlus:GV,ClipboardPlusIcon:GV,ClipboardSignature:Hj,ClipboardSignatureIcon:Hj,ClipboardType:WV,ClipboardTypeIcon:WV,ClipboardX:KV,ClipboardXIcon:KV,Clock:nn,Clock1:YV,Clock10:XV,Clock10Icon:XV,Clock11:QV,Clock11Icon:QV,Clock12:JV,Clock12Icon:JV,Clock1Icon:YV,Clock2:eH,Clock2Icon:eH,Clock3:tH,Clock3Icon:tH,Clock4:sH,Clock4Icon:sH,Clock5:rH,Clock5Icon:rH,Clock6:nH,Clock6Icon:nH,Clock7:aH,Clock7Icon:aH,Clock8:iH,Clock8Icon:iH,Clock9:oH,Clock9Icon:oH,ClockAlert:lH,ClockAlertIcon:lH,ClockArrowDown:cH,ClockArrowDownIcon:cH,ClockArrowUp:dH,ClockArrowUpIcon:dH,ClockIcon:nn,Cloud:kH,CloudAlert:uH,CloudAlertIcon:uH,CloudCog:hH,CloudCogIcon:hH,CloudDownload:Wj,CloudDownloadIcon:Wj,CloudDrizzle:mH,CloudDrizzleIcon:mH,CloudFog:pH,CloudFogIcon:pH,CloudHail:fH,CloudHailIcon:fH,CloudIcon:kH,CloudLightning:xH,CloudLightningIcon:xH,CloudMoon:yH,CloudMoonIcon:yH,CloudMoonRain:gH,CloudMoonRainIcon:gH,CloudOff:vH,CloudOffIcon:vH,CloudRain:bH,CloudRainIcon:bH,CloudRainWind:_H,CloudRainWindIcon:_H,CloudSnow:wH,CloudSnowIcon:wH,CloudSun:NH,CloudSunIcon:NH,CloudSunRain:jH,CloudSunRainIcon:jH,CloudUpload:Kj,CloudUploadIcon:Kj,Cloudy:SH,CloudyIcon:SH,Clover:Bv,CloverIcon:Bv,Club:CH,ClubIcon:CH,Code:Y4,Code2:Zj,Code2Icon:Zj,CodeIcon:Y4,CodeSquare:ck,CodeSquareIcon:ck,CodeXml:Zj,CodeXmlIcon:Zj,Codepen:MH,CodepenIcon:MH,Codesandbox:TH,CodesandboxIcon:TH,Coffee:X4,CoffeeIcon:X4,Cog:AH,CogIcon:AH,Coins:hL,CoinsIcon:hL,Columns:Yj,Columns2:Yj,Columns2Icon:Yj,Columns3:Xj,Columns3Icon:Xj,Columns4:EH,Columns4Icon:EH,ColumnsIcon:Yj,Combine:PH,CombineIcon:PH,Command:IH,CommandIcon:IH,Compass:jM,CompassIcon:jM,Component:LH,ComponentIcon:LH,Computer:DH,ComputerIcon:DH,ConciergeBell:RH,ConciergeBellIcon:RH,Cone:OH,ConeIcon:OH,Construction:FH,ConstructionIcon:FH,Contact:Q4,Contact2:Qj,Contact2Icon:Qj,ContactIcon:Q4,ContactRound:Qj,ContactRoundIcon:Qj,Container:zH,ContainerIcon:zH,Contrast:BH,ContrastIcon:BH,Cookie:$H,CookieIcon:$H,CookingPot:qH,CookingPotIcon:qH,Copy:Va,CopyCheck:UH,CopyCheckIcon:UH,CopyIcon:Va,CopyMinus:VH,CopyMinusIcon:VH,CopyPlus:HH,CopyPlusIcon:HH,CopySlash:GH,CopySlashIcon:GH,CopyX:WH,CopyXIcon:WH,Copyleft:KH,CopyleftIcon:KH,Copyright:ZH,CopyrightIcon:ZH,CornerDownLeft:YH,CornerDownLeftIcon:YH,CornerDownRight:XH,CornerDownRightIcon:XH,CornerLeftDown:QH,CornerLeftDownIcon:QH,CornerLeftUp:JH,CornerLeftUpIcon:JH,CornerRightDown:eG,CornerRightDownIcon:eG,CornerRightUp:tG,CornerRightUpIcon:tG,CornerUpLeft:sG,CornerUpLeftIcon:sG,CornerUpRight:rG,CornerUpRightIcon:rG,Cpu:nG,CpuIcon:nG,CreativeCommons:aG,CreativeCommonsIcon:aG,CreditCard:yx,CreditCardIcon:yx,Croissant:iG,CroissantIcon:iG,Crop:oG,CropIcon:oG,Cross:lG,CrossIcon:lG,Crosshair:cG,CrosshairIcon:cG,Crown:Cm,CrownIcon:Cm,Cuboid:dG,CuboidIcon:dG,CupSoda:uG,CupSodaIcon:uG,CurlyBraces:ij,CurlyBracesIcon:ij,Currency:hG,CurrencyIcon:hG,Cylinder:mG,CylinderIcon:mG,Dam:pG,DamIcon:pG,Database:mL,DatabaseBackup:fG,DatabaseBackupIcon:fG,DatabaseIcon:mL,DatabaseZap:xG,DatabaseZapIcon:xG,Delete:gG,DeleteIcon:gG,Dessert:yG,DessertIcon:yG,Diameter:vG,DiameterIcon:vG,Diamond:wG,DiamondIcon:wG,DiamondMinus:_G,DiamondMinusIcon:_G,DiamondPercent:Jj,DiamondPercentIcon:Jj,DiamondPlus:bG,DiamondPlusIcon:bG,Dice1:jG,Dice1Icon:jG,Dice2:NG,Dice2Icon:NG,Dice3:kG,Dice3Icon:kG,Dice4:SG,Dice4Icon:SG,Dice5:CG,Dice5Icon:CG,Dice6:MG,Dice6Icon:MG,Dices:TG,DicesIcon:TG,Diff:AG,DiffIcon:AG,Disc:LG,Disc2:EG,Disc2Icon:EG,Disc3:PG,Disc3Icon:PG,DiscAlbum:IG,DiscAlbumIcon:IG,DiscIcon:LG,Divide:DG,DivideCircle:Pj,DivideCircleIcon:Pj,DivideIcon:DG,DivideSquare:mk,DivideSquareIcon:mk,Dna:OG,DnaIcon:OG,DnaOff:RG,DnaOffIcon:RG,Dock:FG,DockIcon:FG,Dog:zG,DogIcon:zG,DollarSign:_c,DollarSignIcon:_c,Donut:BG,DonutIcon:BG,DoorClosed:$G,DoorClosedIcon:$G,DoorOpen:Kv,DoorOpenIcon:Kv,Dot:qG,DotIcon:qG,DotSquare:pk,DotSquareIcon:pk,Download:Qa,DownloadCloud:Wj,DownloadCloudIcon:Wj,DownloadIcon:Qa,DraftingCompass:UG,DraftingCompassIcon:UG,Drama:VG,DramaIcon:VG,Dribbble:HG,DribbbleIcon:HG,Drill:GG,DrillIcon:GG,Droplet:WG,DropletIcon:WG,Droplets:Ag,DropletsIcon:Ag,Drum:KG,DrumIcon:KG,Drumstick:ZG,DrumstickIcon:ZG,Dumbbell:YG,DumbbellIcon:YG,Ear:QG,EarIcon:QG,EarOff:XG,EarOffIcon:XG,Earth:eN,EarthIcon:eN,EarthLock:JG,EarthLockIcon:JG,Eclipse:eW,EclipseIcon:eW,Edit:Wc,Edit2:Ry,Edit2Icon:Ry,Edit3:Ev,Edit3Icon:Ev,EditIcon:Wc,Egg:NM,EggFried:tW,EggFriedIcon:tW,EggIcon:NM,EggOff:sW,EggOffIcon:sW,Ellipsis:Zp,EllipsisIcon:Zp,EllipsisVertical:ix,EllipsisVerticalIcon:ix,Equal:aW,EqualApproximately:rW,EqualApproximatelyIcon:rW,EqualIcon:aW,EqualNot:nW,EqualNotIcon:nW,EqualSquare:fk,EqualSquareIcon:fk,Eraser:iW,EraserIcon:iW,EthernetPort:oW,EthernetPortIcon:oW,Euro:lW,EuroIcon:lW,Expand:cW,ExpandIcon:cW,ExternalLink:Yr,ExternalLinkIcon:Yr,Eye:jn,EyeClosed:dW,EyeClosedIcon:dW,EyeIcon:jn,EyeOff:pp,EyeOffIcon:pp,Facebook:hu,FacebookIcon:hu,Factory:uW,FactoryIcon:uW,Fan:hW,FanIcon:hW,FastForward:mW,FastForwardIcon:mW,Feather:pW,FeatherIcon:pW,Fence:fW,FenceIcon:fW,FerrisWheel:xW,FerrisWheelIcon:xW,Figma:gW,FigmaIcon:gW,File:kM,FileArchive:yW,FileArchiveIcon:yW,FileAudio:_W,FileAudio2:vW,FileAudio2Icon:vW,FileAudioIcon:_W,FileAxis3D:tN,FileAxis3DIcon:tN,FileAxis3d:tN,FileAxis3dIcon:tN,FileBadge:wW,FileBadge2:bW,FileBadge2Icon:bW,FileBadgeIcon:wW,FileBarChart:sN,FileBarChart2:rN,FileBarChart2Icon:rN,FileBarChartIcon:sN,FileBox:jW,FileBoxIcon:jW,FileChartColumn:rN,FileChartColumnIcon:rN,FileChartColumnIncreasing:sN,FileChartColumnIncreasingIcon:sN,FileChartLine:nN,FileChartLineIcon:nN,FileChartPie:aN,FileChartPieIcon:aN,FileCheck:kW,FileCheck2:NW,FileCheck2Icon:NW,FileCheckIcon:kW,FileClock:SW,FileClockIcon:SW,FileCode:MW,FileCode2:CW,FileCode2Icon:CW,FileCodeIcon:MW,FileCog:iN,FileCog2:iN,FileCog2Icon:iN,FileCogIcon:iN,FileDiff:TW,FileDiffIcon:TW,FileDigit:AW,FileDigitIcon:AW,FileDown:J4,FileDownIcon:J4,FileEdit:lN,FileEditIcon:lN,FileHeart:EW,FileHeartIcon:EW,FileIcon:kM,FileImage:kb,FileImageIcon:kb,FileInput:PW,FileInputIcon:PW,FileJson:LW,FileJson2:IW,FileJson2Icon:IW,FileJsonIcon:LW,FileKey:RW,FileKey2:DW,FileKey2Icon:DW,FileKeyIcon:RW,FileLineChart:nN,FileLineChartIcon:nN,FileLock:FW,FileLock2:OW,FileLock2Icon:OW,FileLockIcon:FW,FileMinus:BW,FileMinus2:zW,FileMinus2Icon:zW,FileMinusIcon:BW,FileMusic:$W,FileMusicIcon:$W,FileOutput:qW,FileOutputIcon:qW,FilePen:lN,FilePenIcon:lN,FilePenLine:oN,FilePenLineIcon:oN,FilePieChart:aN,FilePieChartIcon:aN,FilePlus:VW,FilePlus2:UW,FilePlus2Icon:UW,FilePlusIcon:VW,FileQuestion:HW,FileQuestionIcon:HW,FileScan:GW,FileScanIcon:GW,FileSearch:KW,FileSearch2:WW,FileSearch2Icon:WW,FileSearchIcon:KW,FileSignature:oN,FileSignatureIcon:oN,FileSliders:ZW,FileSlidersIcon:ZW,FileSpreadsheet:Zv,FileSpreadsheetIcon:Zv,FileStack:pL,FileStackIcon:pL,FileSymlink:YW,FileSymlinkIcon:YW,FileTerminal:XW,FileTerminalIcon:XW,FileText:vn,FileTextIcon:vn,FileType:JW,FileType2:QW,FileType2Icon:QW,FileTypeIcon:JW,FileUp:eK,FileUpIcon:eK,FileUser:tK,FileUserIcon:tK,FileVideo:rK,FileVideo2:sK,FileVideo2Icon:sK,FileVideoIcon:rK,FileVolume:aK,FileVolume2:nK,FileVolume2Icon:nK,FileVolumeIcon:aK,FileWarning:iK,FileWarningIcon:iK,FileX:lK,FileX2:oK,FileX2Icon:oK,FileXIcon:lK,Files:cK,FilesIcon:cK,Film:Rd,FilmIcon:Rd,Filter:Eg,FilterIcon:Eg,FilterX:dK,FilterXIcon:dK,Fingerprint:uK,FingerprintIcon:uK,FireExtinguisher:hK,FireExtinguisherIcon:hK,Fish:fK,FishIcon:fK,FishOff:mK,FishOffIcon:mK,FishSymbol:pK,FishSymbolIcon:pK,Flag:Yv,FlagIcon:Yv,FlagOff:xK,FlagOffIcon:xK,FlagTriangleLeft:gK,FlagTriangleLeftIcon:gK,FlagTriangleRight:yK,FlagTriangleRightIcon:yK,Flame:rd,FlameIcon:rd,FlameKindling:vK,FlameKindlingIcon:vK,Flashlight:bK,FlashlightIcon:bK,FlashlightOff:_K,FlashlightOffIcon:_K,FlaskConical:Sb,FlaskConicalIcon:Sb,FlaskConicalOff:wK,FlaskConicalOffIcon:wK,FlaskRound:jK,FlaskRoundIcon:jK,FlipHorizontal:fL,FlipHorizontal2:NK,FlipHorizontal2Icon:NK,FlipHorizontalIcon:fL,FlipVertical:SK,FlipVertical2:kK,FlipVertical2Icon:kK,FlipVerticalIcon:SK,Flower:CK,Flower2:kg,Flower2Icon:kg,FlowerIcon:CK,Focus:MK,FocusIcon:MK,FoldHorizontal:TK,FoldHorizontalIcon:TK,FoldVertical:AK,FoldVerticalIcon:AK,Folder:rZ,FolderArchive:EK,FolderArchiveIcon:EK,FolderCheck:PK,FolderCheckIcon:PK,FolderClock:IK,FolderClockIcon:IK,FolderClosed:LK,FolderClosedIcon:LK,FolderCode:DK,FolderCodeIcon:DK,FolderCog:cN,FolderCog2:cN,FolderCog2Icon:cN,FolderCogIcon:cN,FolderDot:RK,FolderDotIcon:RK,FolderDown:OK,FolderDownIcon:OK,FolderEdit:dN,FolderEditIcon:dN,FolderGit:zK,FolderGit2:FK,FolderGit2Icon:FK,FolderGitIcon:zK,FolderHeart:BK,FolderHeartIcon:BK,FolderIcon:rZ,FolderInput:$K,FolderInputIcon:$K,FolderKanban:qK,FolderKanbanIcon:qK,FolderKey:UK,FolderKeyIcon:UK,FolderLock:VK,FolderLockIcon:VK,FolderMinus:HK,FolderMinusIcon:HK,FolderOpen:Mm,FolderOpenDot:GK,FolderOpenDotIcon:GK,FolderOpenIcon:Mm,FolderOutput:WK,FolderOutputIcon:WK,FolderPen:dN,FolderPenIcon:dN,FolderPlus:KK,FolderPlusIcon:KK,FolderRoot:ZK,FolderRootIcon:ZK,FolderSearch:XK,FolderSearch2:YK,FolderSearch2Icon:YK,FolderSearchIcon:XK,FolderSymlink:QK,FolderSymlinkIcon:QK,FolderSync:JK,FolderSyncIcon:JK,FolderTree:eZ,FolderTreeIcon:eZ,FolderUp:tZ,FolderUpIcon:tZ,FolderX:sZ,FolderXIcon:sZ,Folders:nZ,FoldersIcon:nZ,Footprints:aZ,FootprintsIcon:aZ,ForkKnife:e4,ForkKnifeCrossed:Jk,ForkKnifeCrossedIcon:Jk,ForkKnifeIcon:e4,Forklift:iZ,ForkliftIcon:iZ,FormInput:DN,FormInputIcon:DN,Forward:oZ,ForwardIcon:oZ,Frame:lZ,FrameIcon:lZ,Framer:cZ,FramerIcon:cZ,Frown:dZ,FrownIcon:dZ,Fuel:uZ,FuelIcon:uZ,Fullscreen:hZ,FullscreenIcon:hZ,FunctionSquare:xk,FunctionSquareIcon:xk,GalleryHorizontal:pZ,GalleryHorizontalEnd:mZ,GalleryHorizontalEndIcon:mZ,GalleryHorizontalIcon:pZ,GalleryThumbnails:fZ,GalleryThumbnailsIcon:fZ,GalleryVertical:gZ,GalleryVerticalEnd:xZ,GalleryVerticalEndIcon:xZ,GalleryVerticalIcon:gZ,Gamepad:vZ,Gamepad2:yZ,Gamepad2Icon:yZ,GamepadIcon:vZ,GanttChart:gj,GanttChartIcon:gj,GanttChartSquare:ky,GanttChartSquareIcon:ky,Gauge:_Z,GaugeCircle:Ij,GaugeCircleIcon:Ij,GaugeIcon:_Z,Gavel:bZ,GavelIcon:bZ,Gem:wZ,GemIcon:wZ,Ghost:eS,GhostIcon:eS,Gift:hi,GiftIcon:hi,GitBranch:NZ,GitBranchIcon:NZ,GitBranchPlus:jZ,GitBranchPlusIcon:jZ,GitCommit:uN,GitCommitHorizontal:uN,GitCommitHorizontalIcon:uN,GitCommitIcon:uN,GitCommitVertical:kZ,GitCommitVerticalIcon:kZ,GitCompare:CZ,GitCompareArrows:SZ,GitCompareArrowsIcon:SZ,GitCompareIcon:CZ,GitFork:MZ,GitForkIcon:MZ,GitGraph:TZ,GitGraphIcon:TZ,GitMerge:AZ,GitMergeIcon:AZ,GitPullRequest:RZ,GitPullRequestArrow:EZ,GitPullRequestArrowIcon:EZ,GitPullRequestClosed:PZ,GitPullRequestClosedIcon:PZ,GitPullRequestCreate:LZ,GitPullRequestCreateArrow:IZ,GitPullRequestCreateArrowIcon:IZ,GitPullRequestCreateIcon:LZ,GitPullRequestDraft:DZ,GitPullRequestDraftIcon:DZ,GitPullRequestIcon:RZ,Github:OZ,GithubIcon:OZ,Gitlab:FZ,GitlabIcon:FZ,GlassWater:zZ,GlassWaterIcon:zZ,Glasses:BZ,GlassesIcon:BZ,Globe:nd,Globe2:eN,Globe2Icon:eN,GlobeIcon:nd,GlobeLock:$Z,GlobeLockIcon:$Z,Goal:qZ,GoalIcon:qZ,Grab:UZ,GrabIcon:UZ,GraduationCap:Lh,GraduationCapIcon:Lh,Grape:VZ,GrapeIcon:VZ,Grid:Xf,Grid2X2:mN,Grid2X2Icon:mN,Grid2X2Plus:hN,Grid2X2PlusIcon:hN,Grid2x2:mN,Grid2x2Check:HZ,Grid2x2CheckIcon:HZ,Grid2x2Icon:mN,Grid2x2Plus:hN,Grid2x2PlusIcon:hN,Grid2x2X:GZ,Grid2x2XIcon:GZ,Grid3X3:Xf,Grid3X3Icon:Xf,Grid3x3:Xf,Grid3x3Icon:Xf,GridIcon:Xf,Grip:KZ,GripHorizontal:WZ,GripHorizontalIcon:WZ,GripIcon:KZ,GripVertical:mu,GripVerticalIcon:mu,Group:ZZ,GroupIcon:ZZ,Guitar:YZ,GuitarIcon:YZ,Ham:XZ,HamIcon:XZ,Hammer:QZ,HammerIcon:QZ,Hand:xL,HandCoins:JZ,HandCoinsIcon:JZ,HandHeart:eY,HandHeartIcon:eY,HandHelping:pN,HandHelpingIcon:pN,HandIcon:xL,HandMetal:tY,HandMetalIcon:tY,HandPlatter:sY,HandPlatterIcon:sY,Handshake:gL,HandshakeIcon:gL,HardDrive:yL,HardDriveDownload:rY,HardDriveDownloadIcon:rY,HardDriveIcon:yL,HardDriveUpload:nY,HardDriveUploadIcon:nY,HardHat:aY,HardHatIcon:aY,Hash:tS,HashIcon:tS,Haze:iY,HazeIcon:iY,HdmiPort:oY,HdmiPortIcon:oY,Heading:uY,Heading1:SM,Heading1Icon:SM,Heading2:CM,Heading2Icon:CM,Heading3:vL,Heading3Icon:vL,Heading4:lY,Heading4Icon:lY,Heading5:cY,Heading5Icon:cY,Heading6:dY,Heading6Icon:dY,HeadingIcon:uY,HeadphoneOff:hY,HeadphoneOffIcon:hY,Headphones:mY,HeadphonesIcon:mY,Headset:pY,HeadsetIcon:pY,Heart:Xa,HeartCrack:fY,HeartCrackIcon:fY,HeartHandshake:xY,HeartHandshakeIcon:xY,HeartIcon:Xa,HeartOff:gY,HeartOffIcon:gY,HeartPulse:yY,HeartPulseIcon:yY,Heater:vY,HeaterIcon:vY,HelpCircle:Mv,HelpCircleIcon:Mv,HelpingHand:pN,HelpingHandIcon:pN,Hexagon:_Y,HexagonIcon:_Y,Highlighter:bY,HighlighterIcon:bY,History:MM,HistoryIcon:MM,Home:Mn,HomeIcon:Mn,Hop:jY,HopIcon:jY,HopOff:wY,HopOffIcon:wY,Hospital:NY,HospitalIcon:NY,Hotel:kY,HotelIcon:kY,Hourglass:SY,HourglassIcon:SY,House:Mn,HouseIcon:Mn,HousePlug:CY,HousePlugIcon:CY,HousePlus:MY,HousePlusIcon:MY,IceCream:xN,IceCream2:fN,IceCream2Icon:fN,IceCreamBowl:fN,IceCreamBowlIcon:fN,IceCreamCone:xN,IceCreamConeIcon:xN,IceCreamIcon:xN,Icon:nUe,IdCard:TY,IdCardIcon:TY,Image:qo,ImageDown:AY,ImageDownIcon:AY,ImageIcon:qo,ImageMinus:EY,ImageMinusIcon:EY,ImageOff:PY,ImageOffIcon:PY,ImagePlay:IY,ImagePlayIcon:IY,ImagePlus:Xv,ImagePlusIcon:Xv,ImageUp:LY,ImageUpIcon:LY,ImageUpscale:DY,ImageUpscaleIcon:DY,Images:RY,ImagesIcon:RY,Import:OY,ImportIcon:OY,Inbox:FY,InboxIcon:FY,Indent:yN,IndentDecrease:gN,IndentDecreaseIcon:gN,IndentIcon:yN,IndentIncrease:yN,IndentIncreaseIcon:yN,IndianRupee:zY,IndianRupeeIcon:zY,Infinity:BY,InfinityIcon:BY,Info:sS,InfoIcon:sS,Inspect:wk,InspectIcon:wk,InspectionPanel:$Y,InspectionPanelIcon:$Y,Instagram:pu,InstagramIcon:pu,Italic:rS,ItalicIcon:rS,IterationCcw:qY,IterationCcwIcon:qY,IterationCw:UY,IterationCwIcon:UY,JapaneseYen:VY,JapaneseYenIcon:VY,Joystick:HY,JoystickIcon:HY,Kanban:Yy,KanbanIcon:Yy,KanbanSquare:gk,KanbanSquareDashed:dk,KanbanSquareDashedIcon:dk,KanbanSquareIcon:gk,Key:fp,KeyIcon:fp,KeyRound:nS,KeyRoundIcon:nS,KeySquare:GY,KeySquareIcon:GY,Keyboard:ZY,KeyboardIcon:ZY,KeyboardMusic:WY,KeyboardMusicIcon:WY,KeyboardOff:KY,KeyboardOffIcon:KY,Lamp:tX,LampCeiling:YY,LampCeilingIcon:YY,LampDesk:XY,LampDeskIcon:XY,LampFloor:QY,LampFloorIcon:QY,LampIcon:tX,LampWallDown:JY,LampWallDownIcon:JY,LampWallUp:eX,LampWallUpIcon:eX,LandPlot:sX,LandPlotIcon:sX,Landmark:rX,LandmarkIcon:rX,Languages:nX,LanguagesIcon:nX,Laptop:iX,Laptop2:vN,Laptop2Icon:vN,LaptopIcon:iX,LaptopMinimal:vN,LaptopMinimalCheck:aX,LaptopMinimalCheckIcon:aX,LaptopMinimalIcon:vN,Lasso:lX,LassoIcon:lX,LassoSelect:oX,LassoSelectIcon:oX,Laugh:cX,LaughIcon:cX,Layers:_L,Layers2:dX,Layers2Icon:dX,Layers3:uX,Layers3Icon:uX,LayersIcon:_L,Layout:Av,LayoutDashboard:aS,LayoutDashboardIcon:aS,LayoutGrid:xp,LayoutGridIcon:xp,LayoutIcon:Av,LayoutList:hX,LayoutListIcon:hX,LayoutPanelLeft:mX,LayoutPanelLeftIcon:mX,LayoutPanelTop:pX,LayoutPanelTopIcon:pX,LayoutTemplate:iS,LayoutTemplateIcon:iS,Leaf:fX,LeafIcon:fX,LeafyGreen:xX,LeafyGreenIcon:xX,Lectern:gX,LecternIcon:gX,LetterText:yX,LetterTextIcon:yX,Library:oS,LibraryBig:vX,LibraryBigIcon:vX,LibraryIcon:oS,LibrarySquare:yk,LibrarySquareIcon:yk,LifeBuoy:TM,LifeBuoyIcon:TM,Ligature:_X,LigatureIcon:_X,Lightbulb:Cb,LightbulbIcon:Cb,LightbulbOff:bX,LightbulbOffIcon:bX,LineChart:pj,LineChartIcon:pj,Link:vo,Link2:Do,Link2Icon:Do,Link2Off:wX,Link2OffIcon:wX,LinkIcon:vo,Linkedin:gp,LinkedinIcon:gp,List:Dh,ListCheck:jX,ListCheckIcon:jX,ListChecks:NX,ListChecksIcon:NX,ListCollapse:kX,ListCollapseIcon:kX,ListEnd:SX,ListEndIcon:SX,ListFilter:CX,ListFilterIcon:CX,ListIcon:Dh,ListMinus:MX,ListMinusIcon:MX,ListMusic:TX,ListMusicIcon:TX,ListOrdered:Xy,ListOrderedIcon:Xy,ListPlus:AX,ListPlusIcon:AX,ListRestart:EX,ListRestartIcon:EX,ListStart:PX,ListStartIcon:PX,ListTodo:IX,ListTodoIcon:IX,ListTree:LX,ListTreeIcon:LX,ListVideo:DX,ListVideoIcon:DX,ListX:RX,ListXIcon:RX,Loader:FX,Loader2:us,Loader2Icon:us,LoaderCircle:us,LoaderCircleIcon:us,LoaderIcon:FX,LoaderPinwheel:OX,LoaderPinwheelIcon:OX,Locate:AM,LocateFixed:zX,LocateFixedIcon:zX,LocateIcon:AM,LocateOff:BX,LocateOffIcon:BX,Lock:ad,LockIcon:ad,LockKeyhole:$X,LockKeyholeIcon:$X,LockKeyholeOpen:_N,LockKeyholeOpenIcon:_N,LockOpen:bN,LockOpenIcon:bN,LogIn:lS,LogInIcon:lS,LogOut:EM,LogOutIcon:EM,Logs:qX,LogsIcon:qX,Lollipop:UX,LollipopIcon:UX,LucideAArrowDown:Y9,LucideAArrowUp:X9,LucideALargeSmall:Q9,LucideAccessibility:J9,LucideActivity:lh,LucideActivitySquare:UN,LucideAirVent:eB,LucideAirplay:tB,LucideAlarmCheck:G2,LucideAlarmClock:rB,LucideAlarmClockCheck:G2,LucideAlarmClockMinus:W2,LucideAlarmClockOff:sB,LucideAlarmClockPlus:K2,LucideAlarmMinus:W2,LucideAlarmPlus:K2,LucideAlarmSmoke:nB,LucideAlbum:aB,LucideAlertCircle:ro,LucideAlertOctagon:Tv,LucideAlertTriangle:Dc,LucideAlignCenter:V4,LucideAlignCenterHorizontal:iB,LucideAlignCenterVertical:oB,LucideAlignEndHorizontal:lB,LucideAlignEndVertical:cB,LucideAlignHorizontalDistributeCenter:dB,LucideAlignHorizontalDistributeEnd:uB,LucideAlignHorizontalDistributeStart:hB,LucideAlignHorizontalJustifyCenter:mB,LucideAlignHorizontalJustifyEnd:pB,LucideAlignHorizontalJustifyStart:fB,LucideAlignHorizontalSpaceAround:xB,LucideAlignHorizontalSpaceBetween:gB,LucideAlignJustify:yB,LucideAlignLeft:H4,LucideAlignRight:G4,LucideAlignStartHorizontal:vB,LucideAlignStartVertical:_B,LucideAlignVerticalDistributeCenter:bB,LucideAlignVerticalDistributeEnd:wB,LucideAlignVerticalDistributeStart:jB,LucideAlignVerticalJustifyCenter:NB,LucideAlignVerticalJustifyEnd:kB,LucideAlignVerticalJustifyStart:SB,LucideAlignVerticalSpaceAround:CB,LucideAlignVerticalSpaceBetween:MB,LucideAmbulance:TB,LucideAmpersand:AB,LucideAmpersands:EB,LucideAmphora:PB,LucideAnchor:IB,LucideAngry:LB,LucideAnnoyed:DB,LucideAntenna:RB,LucideAnvil:OB,LucideAperture:FB,LucideAppWindow:sL,LucideAppWindowMac:zB,LucideApple:BB,LucideArchive:yM,LucideArchiveRestore:rL,LucideArchiveX:$B,LucideAreaChart:lj,LucideArmchair:qB,LucideArrowBigDown:VB,LucideArrowBigDownDash:UB,LucideArrowBigLeft:GB,LucideArrowBigLeftDash:HB,LucideArrowBigRight:KB,LucideArrowBigRightDash:WB,LucideArrowBigUp:YB,LucideArrowBigUpDash:ZB,LucideArrowDown:Ih,LucideArrowDown01:XB,LucideArrowDown10:QB,LucideArrowDownAZ:Z2,LucideArrowDownAz:Z2,LucideArrowDownCircle:_j,LucideArrowDownFromLine:JB,LucideArrowDownLeft:e$,LucideArrowDownLeftFromCircle:wj,LucideArrowDownLeftFromSquare:KN,LucideArrowDownLeftSquare:VN,LucideArrowDownNarrowWide:t$,LucideArrowDownRight:nL,LucideArrowDownRightFromCircle:jj,LucideArrowDownRightFromSquare:ZN,LucideArrowDownRightSquare:HN,LucideArrowDownSquare:GN,LucideArrowDownToDot:s$,LucideArrowDownToLine:r$,LucideArrowDownUp:n$,LucideArrowDownWideNarrow:Y2,LucideArrowDownZA:X2,LucideArrowDownZa:X2,LucideArrowLeft:Oa,LucideArrowLeftCircle:bj,LucideArrowLeftFromLine:a$,LucideArrowLeftRight:i$,LucideArrowLeftSquare:WN,LucideArrowLeftToLine:o$,LucideArrowRight:Wa,LucideArrowRightCircle:Sj,LucideArrowRightFromLine:l$,LucideArrowRightLeft:Gv,LucideArrowRightSquare:QN,LucideArrowRightToLine:c$,LucideArrowUp:uu,LucideArrowUp01:d$,LucideArrowUp10:u$,LucideArrowUpAZ:Q2,LucideArrowUpAz:Q2,LucideArrowUpCircle:Cj,LucideArrowUpDown:td,LucideArrowUpFromDot:h$,LucideArrowUpFromLine:m$,LucideArrowUpLeft:p$,LucideArrowUpLeftFromCircle:Nj,LucideArrowUpLeftFromSquare:YN,LucideArrowUpLeftSquare:JN,LucideArrowUpNarrowWide:J2,LucideArrowUpRight:aL,LucideArrowUpRightFromCircle:kj,LucideArrowUpRightFromSquare:XN,LucideArrowUpRightSquare:ek,LucideArrowUpSquare:tk,LucideArrowUpToLine:f$,LucideArrowUpWideNarrow:x$,LucideArrowUpZA:ej,LucideArrowUpZa:ej,LucideArrowsUpFromLine:g$,LucideAsterisk:y$,LucideAsteriskSquare:sk,LucideAtSign:v$,LucideAtom:_$,LucideAudioLines:b$,LucideAudioWaveform:w$,LucideAward:nc,LucideAxe:j$,LucideAxis3D:tj,LucideAxis3d:tj,LucideBaby:N$,LucideBackpack:k$,LucideBadge:$$,LucideBadgeAlert:S$,LucideBadgeCent:C$,LucideBadgeCheck:sj,LucideBadgeDollarSign:M$,LucideBadgeEuro:T$,LucideBadgeHelp:A$,LucideBadgeIndianRupee:E$,LucideBadgeInfo:P$,LucideBadgeJapaneseYen:I$,LucideBadgeMinus:L$,LucideBadgePercent:D$,LucideBadgePlus:R$,LucideBadgePoundSterling:O$,LucideBadgeRussianRuble:F$,LucideBadgeSwissFranc:z$,LucideBadgeX:B$,LucideBaggageClaim:q$,LucideBan:iL,LucideBanana:U$,LucideBandage:V$,LucideBanknote:H$,LucideBarChart:fj,LucideBarChart2:xj,LucideBarChart3:so,LucideBarChart4:mj,LucideBarChartBig:hj,LucideBarChartHorizontal:dj,LucideBarChartHorizontalBig:cj,LucideBarcode:G$,LucideBaseline:W$,LucideBath:nf,LucideBattery:J$,LucideBatteryCharging:K$,LucideBatteryFull:Z$,LucideBatteryLow:Y$,LucideBatteryMedium:X$,LucideBatteryWarning:Q$,LucideBeaker:eq,LucideBean:sq,LucideBeanOff:tq,LucideBed:Zy,LucideBedDouble:W4,LucideBedSingle:rq,LucideBeef:nq,LucideBeer:iq,LucideBeerOff:aq,LucideBell:Sm,LucideBellDot:oq,LucideBellElectric:lq,LucideBellMinus:cq,LucideBellOff:Wv,LucideBellPlus:dq,LucideBellRing:uq,LucideBetweenHorizonalEnd:rj,LucideBetweenHorizonalStart:nj,LucideBetweenHorizontalEnd:rj,LucideBetweenHorizontalStart:nj,LucideBetweenVerticalEnd:hq,LucideBetweenVerticalStart:mq,LucideBicepsFlexed:pq,LucideBike:fq,LucideBinary:xq,LucideBinoculars:gq,LucideBiohazard:yq,LucideBird:vq,LucideBitcoin:_q,LucideBlend:bq,LucideBlinds:wq,LucideBlocks:jq,LucideBluetooth:Cq,LucideBluetoothConnected:Nq,LucideBluetoothOff:kq,LucideBluetoothSearching:Sq,LucideBold:K4,LucideBolt:Mq,LucideBomb:Tq,LucideBone:Aq,LucideBook:Qq,LucideBookA:Eq,LucideBookAudio:Pq,LucideBookCheck:Iq,LucideBookCopy:Lq,LucideBookDashed:aj,LucideBookDown:Dq,LucideBookHeadphones:Rq,LucideBookHeart:Oq,LucideBookImage:Fq,LucideBookKey:zq,LucideBookLock:Bq,LucideBookMarked:$q,LucideBookMinus:qq,LucideBookOpen:ch,LucideBookOpenCheck:Uq,LucideBookOpenText:Vq,LucideBookPlus:Hq,LucideBookTemplate:aj,LucideBookText:Gq,LucideBookType:Wq,LucideBookUp:Zq,LucideBookUp2:Kq,LucideBookUser:Yq,LucideBookX:Xq,LucideBookmark:fx,LucideBookmarkCheck:Jq,LucideBookmarkMinus:eU,LucideBookmarkPlus:oL,LucideBookmarkX:tU,LucideBoomBox:sU,LucideBot:vM,LucideBotMessageSquare:rU,LucideBotOff:nU,LucideBox:aU,LucideBoxSelect:hk,LucideBoxes:iU,LucideBraces:ij,LucideBrackets:oU,LucideBrain:lL,LucideBrainCircuit:lU,LucideBrainCog:cU,LucideBrickWall:dU,LucideBriefcase:dh,LucideBriefcaseBusiness:uU,LucideBriefcaseConveyorBelt:hU,LucideBriefcaseMedical:mU,LucideBringToFront:pU,LucideBrush:fU,LucideBug:yU,LucideBugOff:xU,LucideBugPlay:gU,LucideBuilding:Z4,LucideBuilding2:pa,LucideBus:_U,LucideBusFront:vU,LucideCable:wU,LucideCableCar:bU,LucideCake:Fu,LucideCakeSlice:jU,LucideCalculator:_M,LucideCalendar:cn,LucideCalendar1:NU,LucideCalendarArrowDown:kU,LucideCalendarArrowUp:SU,LucideCalendarCheck:cL,LucideCalendarCheck2:CU,LucideCalendarClock:bM,LucideCalendarCog:MU,LucideCalendarDays:_d,LucideCalendarFold:TU,LucideCalendarHeart:AU,LucideCalendarMinus:PU,LucideCalendarMinus2:EU,LucideCalendarOff:dL,LucideCalendarPlus:jb,LucideCalendarPlus2:IU,LucideCalendarRange:LU,LucideCalendarSearch:DU,LucideCalendarSync:RU,LucideCalendarX:FU,LucideCalendarX2:OU,LucideCamera:xx,LucideCameraOff:zU,LucideCandlestickChart:uj,LucideCandy:qU,LucideCandyCane:BU,LucideCandyOff:$U,LucideCannabis:UU,LucideCaptions:oj,LucideCaptionsOff:VU,LucideCar:WU,LucideCarFront:HU,LucideCarTaxiFront:GU,LucideCaravan:KU,LucideCarrot:ZU,LucideCaseLower:YU,LucideCaseSensitive:XU,LucideCaseUpper:QU,LucideCassetteTape:JU,LucideCast:eV,LucideCastle:tV,LucideCat:sV,LucideCctv:rV,LucideChartArea:lj,LucideChartBar:dj,LucideChartBarBig:cj,LucideChartBarDecreasing:nV,LucideChartBarIncreasing:aV,LucideChartBarStacked:iV,LucideChartCandlestick:uj,LucideChartColumn:so,LucideChartColumnBig:hj,LucideChartColumnDecreasing:oV,LucideChartColumnIncreasing:mj,LucideChartColumnStacked:lV,LucideChartGantt:cV,LucideChartLine:pj,LucideChartNetwork:dV,LucideChartNoAxesColumn:xj,LucideChartNoAxesColumnDecreasing:uV,LucideChartNoAxesColumnIncreasing:fj,LucideChartNoAxesCombined:hV,LucideChartNoAxesGantt:gj,LucideChartPie:yj,LucideChartScatter:vj,LucideChartSpline:mV,LucideCheck:Zn,LucideCheckCheck:uL,LucideCheckCircle:si,LucideCheckCircle2:$n,LucideCheckSquare:Pv,LucideCheckSquare2:nk,LucideChefHat:pV,LucideCherry:fV,LucideChevronDown:Bi,LucideChevronDownCircle:Mj,LucideChevronDownSquare:ak,LucideChevronFirst:xV,LucideChevronLast:gV,LucideChevronLeft:Xo,LucideChevronLeftCircle:Tj,LucideChevronLeftSquare:ik,LucideChevronRight:xa,LucideChevronRightCircle:Aj,LucideChevronRightSquare:ok,LucideChevronUp:af,LucideChevronUpCircle:Ej,LucideChevronUpSquare:lk,LucideChevronsDown:vV,LucideChevronsDownUp:yV,LucideChevronsLeft:wV,LucideChevronsLeftRight:bV,LucideChevronsLeftRightEllipsis:_V,LucideChevronsRight:NV,LucideChevronsRightLeft:jV,LucideChevronsUp:kV,LucideChevronsUpDown:gx,LucideChrome:SV,LucideChurch:CV,LucideCigarette:TV,LucideCigaretteOff:MV,LucideCircle:sd,LucideCircleAlert:ro,LucideCircleArrowDown:_j,LucideCircleArrowLeft:bj,LucideCircleArrowOutDownLeft:wj,LucideCircleArrowOutDownRight:jj,LucideCircleArrowOutUpLeft:Nj,LucideCircleArrowOutUpRight:kj,LucideCircleArrowRight:Sj,LucideCircleArrowUp:Cj,LucideCircleCheck:$n,LucideCircleCheckBig:si,LucideCircleChevronDown:Mj,LucideCircleChevronLeft:Tj,LucideCircleChevronRight:Aj,LucideCircleChevronUp:Ej,LucideCircleDashed:AV,LucideCircleDivide:Pj,LucideCircleDollarSign:EV,LucideCircleDot:IV,LucideCircleDotDashed:PV,LucideCircleEllipsis:LV,LucideCircleEqual:DV,LucideCircleFadingArrowUp:RV,LucideCircleFadingPlus:OV,LucideCircleGauge:Ij,LucideCircleHelp:Mv,LucideCircleMinus:Lj,LucideCircleOff:FV,LucideCircleParking:Rj,LucideCircleParkingOff:Dj,LucideCirclePause:Oj,LucideCirclePercent:Fj,LucideCirclePlay:rp,LucideCirclePlus:zj,LucideCirclePower:Bj,LucideCircleSlash:zV,LucideCircleSlash2:$j,LucideCircleSlashed:$j,LucideCircleStop:qj,LucideCircleUser:Vj,LucideCircleUserRound:Uj,LucideCircleX:Jl,LucideCircuitBoard:BV,LucideCitrus:$V,LucideClapperboard:qV,LucideClipboard:ZV,LucideClipboardCheck:wM,LucideClipboardCopy:UV,LucideClipboardEdit:Gj,LucideClipboardList:Nb,LucideClipboardMinus:VV,LucideClipboardPaste:HV,LucideClipboardPen:Gj,LucideClipboardPenLine:Hj,LucideClipboardPlus:GV,LucideClipboardSignature:Hj,LucideClipboardType:WV,LucideClipboardX:KV,LucideClock:nn,LucideClock1:YV,LucideClock10:XV,LucideClock11:QV,LucideClock12:JV,LucideClock2:eH,LucideClock3:tH,LucideClock4:sH,LucideClock5:rH,LucideClock6:nH,LucideClock7:aH,LucideClock8:iH,LucideClock9:oH,LucideClockAlert:lH,LucideClockArrowDown:cH,LucideClockArrowUp:dH,LucideCloud:kH,LucideCloudAlert:uH,LucideCloudCog:hH,LucideCloudDownload:Wj,LucideCloudDrizzle:mH,LucideCloudFog:pH,LucideCloudHail:fH,LucideCloudLightning:xH,LucideCloudMoon:yH,LucideCloudMoonRain:gH,LucideCloudOff:vH,LucideCloudRain:bH,LucideCloudRainWind:_H,LucideCloudSnow:wH,LucideCloudSun:NH,LucideCloudSunRain:jH,LucideCloudUpload:Kj,LucideCloudy:SH,LucideClover:Bv,LucideClub:CH,LucideCode:Y4,LucideCode2:Zj,LucideCodeSquare:ck,LucideCodeXml:Zj,LucideCodepen:MH,LucideCodesandbox:TH,LucideCoffee:X4,LucideCog:AH,LucideCoins:hL,LucideColumns:Yj,LucideColumns2:Yj,LucideColumns3:Xj,LucideColumns4:EH,LucideCombine:PH,LucideCommand:IH,LucideCompass:jM,LucideComponent:LH,LucideComputer:DH,LucideConciergeBell:RH,LucideCone:OH,LucideConstruction:FH,LucideContact:Q4,LucideContact2:Qj,LucideContactRound:Qj,LucideContainer:zH,LucideContrast:BH,LucideCookie:$H,LucideCookingPot:qH,LucideCopy:Va,LucideCopyCheck:UH,LucideCopyMinus:VH,LucideCopyPlus:HH,LucideCopySlash:GH,LucideCopyX:WH,LucideCopyleft:KH,LucideCopyright:ZH,LucideCornerDownLeft:YH,LucideCornerDownRight:XH,LucideCornerLeftDown:QH,LucideCornerLeftUp:JH,LucideCornerRightDown:eG,LucideCornerRightUp:tG,LucideCornerUpLeft:sG,LucideCornerUpRight:rG,LucideCpu:nG,LucideCreativeCommons:aG,LucideCreditCard:yx,LucideCroissant:iG,LucideCrop:oG,LucideCross:lG,LucideCrosshair:cG,LucideCrown:Cm,LucideCuboid:dG,LucideCupSoda:uG,LucideCurlyBraces:ij,LucideCurrency:hG,LucideCylinder:mG,LucideDam:pG,LucideDatabase:mL,LucideDatabaseBackup:fG,LucideDatabaseZap:xG,LucideDelete:gG,LucideDessert:yG,LucideDiameter:vG,LucideDiamond:wG,LucideDiamondMinus:_G,LucideDiamondPercent:Jj,LucideDiamondPlus:bG,LucideDice1:jG,LucideDice2:NG,LucideDice3:kG,LucideDice4:SG,LucideDice5:CG,LucideDice6:MG,LucideDices:TG,LucideDiff:AG,LucideDisc:LG,LucideDisc2:EG,LucideDisc3:PG,LucideDiscAlbum:IG,LucideDivide:DG,LucideDivideCircle:Pj,LucideDivideSquare:mk,LucideDna:OG,LucideDnaOff:RG,LucideDock:FG,LucideDog:zG,LucideDollarSign:_c,LucideDonut:BG,LucideDoorClosed:$G,LucideDoorOpen:Kv,LucideDot:qG,LucideDotSquare:pk,LucideDownload:Qa,LucideDownloadCloud:Wj,LucideDraftingCompass:UG,LucideDrama:VG,LucideDribbble:HG,LucideDrill:GG,LucideDroplet:WG,LucideDroplets:Ag,LucideDrum:KG,LucideDrumstick:ZG,LucideDumbbell:YG,LucideEar:QG,LucideEarOff:XG,LucideEarth:eN,LucideEarthLock:JG,LucideEclipse:eW,LucideEdit:Wc,LucideEdit2:Ry,LucideEdit3:Ev,LucideEgg:NM,LucideEggFried:tW,LucideEggOff:sW,LucideEllipsis:Zp,LucideEllipsisVertical:ix,LucideEqual:aW,LucideEqualApproximately:rW,LucideEqualNot:nW,LucideEqualSquare:fk,LucideEraser:iW,LucideEthernetPort:oW,LucideEuro:lW,LucideExpand:cW,LucideExternalLink:Yr,LucideEye:jn,LucideEyeClosed:dW,LucideEyeOff:pp,LucideFacebook:hu,LucideFactory:uW,LucideFan:hW,LucideFastForward:mW,LucideFeather:pW,LucideFence:fW,LucideFerrisWheel:xW,LucideFigma:gW,LucideFile:kM,LucideFileArchive:yW,LucideFileAudio:_W,LucideFileAudio2:vW,LucideFileAxis3D:tN,LucideFileAxis3d:tN,LucideFileBadge:wW,LucideFileBadge2:bW,LucideFileBarChart:sN,LucideFileBarChart2:rN,LucideFileBox:jW,LucideFileChartColumn:rN,LucideFileChartColumnIncreasing:sN,LucideFileChartLine:nN,LucideFileChartPie:aN,LucideFileCheck:kW,LucideFileCheck2:NW,LucideFileClock:SW,LucideFileCode:MW,LucideFileCode2:CW,LucideFileCog:iN,LucideFileCog2:iN,LucideFileDiff:TW,LucideFileDigit:AW,LucideFileDown:J4,LucideFileEdit:lN,LucideFileHeart:EW,LucideFileImage:kb,LucideFileInput:PW,LucideFileJson:LW,LucideFileJson2:IW,LucideFileKey:RW,LucideFileKey2:DW,LucideFileLineChart:nN,LucideFileLock:FW,LucideFileLock2:OW,LucideFileMinus:BW,LucideFileMinus2:zW,LucideFileMusic:$W,LucideFileOutput:qW,LucideFilePen:lN,LucideFilePenLine:oN,LucideFilePieChart:aN,LucideFilePlus:VW,LucideFilePlus2:UW,LucideFileQuestion:HW,LucideFileScan:GW,LucideFileSearch:KW,LucideFileSearch2:WW,LucideFileSignature:oN,LucideFileSliders:ZW,LucideFileSpreadsheet:Zv,LucideFileStack:pL,LucideFileSymlink:YW,LucideFileTerminal:XW,LucideFileText:vn,LucideFileType:JW,LucideFileType2:QW,LucideFileUp:eK,LucideFileUser:tK,LucideFileVideo:rK,LucideFileVideo2:sK,LucideFileVolume:aK,LucideFileVolume2:nK,LucideFileWarning:iK,LucideFileX:lK,LucideFileX2:oK,LucideFiles:cK,LucideFilm:Rd,LucideFilter:Eg,LucideFilterX:dK,LucideFingerprint:uK,LucideFireExtinguisher:hK,LucideFish:fK,LucideFishOff:mK,LucideFishSymbol:pK,LucideFlag:Yv,LucideFlagOff:xK,LucideFlagTriangleLeft:gK,LucideFlagTriangleRight:yK,LucideFlame:rd,LucideFlameKindling:vK,LucideFlashlight:bK,LucideFlashlightOff:_K,LucideFlaskConical:Sb,LucideFlaskConicalOff:wK,LucideFlaskRound:jK,LucideFlipHorizontal:fL,LucideFlipHorizontal2:NK,LucideFlipVertical:SK,LucideFlipVertical2:kK,LucideFlower:CK,LucideFlower2:kg,LucideFocus:MK,LucideFoldHorizontal:TK,LucideFoldVertical:AK,LucideFolder:rZ,LucideFolderArchive:EK,LucideFolderCheck:PK,LucideFolderClock:IK,LucideFolderClosed:LK,LucideFolderCode:DK,LucideFolderCog:cN,LucideFolderCog2:cN,LucideFolderDot:RK,LucideFolderDown:OK,LucideFolderEdit:dN,LucideFolderGit:zK,LucideFolderGit2:FK,LucideFolderHeart:BK,LucideFolderInput:$K,LucideFolderKanban:qK,LucideFolderKey:UK,LucideFolderLock:VK,LucideFolderMinus:HK,LucideFolderOpen:Mm,LucideFolderOpenDot:GK,LucideFolderOutput:WK,LucideFolderPen:dN,LucideFolderPlus:KK,LucideFolderRoot:ZK,LucideFolderSearch:XK,LucideFolderSearch2:YK,LucideFolderSymlink:QK,LucideFolderSync:JK,LucideFolderTree:eZ,LucideFolderUp:tZ,LucideFolderX:sZ,LucideFolders:nZ,LucideFootprints:aZ,LucideForkKnife:e4,LucideForkKnifeCrossed:Jk,LucideForklift:iZ,LucideFormInput:DN,LucideForward:oZ,LucideFrame:lZ,LucideFramer:cZ,LucideFrown:dZ,LucideFuel:uZ,LucideFullscreen:hZ,LucideFunctionSquare:xk,LucideGalleryHorizontal:pZ,LucideGalleryHorizontalEnd:mZ,LucideGalleryThumbnails:fZ,LucideGalleryVertical:gZ,LucideGalleryVerticalEnd:xZ,LucideGamepad:vZ,LucideGamepad2:yZ,LucideGanttChart:gj,LucideGanttChartSquare:ky,LucideGauge:_Z,LucideGaugeCircle:Ij,LucideGavel:bZ,LucideGem:wZ,LucideGhost:eS,LucideGift:hi,LucideGitBranch:NZ,LucideGitBranchPlus:jZ,LucideGitCommit:uN,LucideGitCommitHorizontal:uN,LucideGitCommitVertical:kZ,LucideGitCompare:CZ,LucideGitCompareArrows:SZ,LucideGitFork:MZ,LucideGitGraph:TZ,LucideGitMerge:AZ,LucideGitPullRequest:RZ,LucideGitPullRequestArrow:EZ,LucideGitPullRequestClosed:PZ,LucideGitPullRequestCreate:LZ,LucideGitPullRequestCreateArrow:IZ,LucideGitPullRequestDraft:DZ,LucideGithub:OZ,LucideGitlab:FZ,LucideGlassWater:zZ,LucideGlasses:BZ,LucideGlobe:nd,LucideGlobe2:eN,LucideGlobeLock:$Z,LucideGoal:qZ,LucideGrab:UZ,LucideGraduationCap:Lh,LucideGrape:VZ,LucideGrid:Xf,LucideGrid2X2:mN,LucideGrid2X2Plus:hN,LucideGrid2x2:mN,LucideGrid2x2Check:HZ,LucideGrid2x2Plus:hN,LucideGrid2x2X:GZ,LucideGrid3X3:Xf,LucideGrid3x3:Xf,LucideGrip:KZ,LucideGripHorizontal:WZ,LucideGripVertical:mu,LucideGroup:ZZ,LucideGuitar:YZ,LucideHam:XZ,LucideHammer:QZ,LucideHand:xL,LucideHandCoins:JZ,LucideHandHeart:eY,LucideHandHelping:pN,LucideHandMetal:tY,LucideHandPlatter:sY,LucideHandshake:gL,LucideHardDrive:yL,LucideHardDriveDownload:rY,LucideHardDriveUpload:nY,LucideHardHat:aY,LucideHash:tS,LucideHaze:iY,LucideHdmiPort:oY,LucideHeading:uY,LucideHeading1:SM,LucideHeading2:CM,LucideHeading3:vL,LucideHeading4:lY,LucideHeading5:cY,LucideHeading6:dY,LucideHeadphoneOff:hY,LucideHeadphones:mY,LucideHeadset:pY,LucideHeart:Xa,LucideHeartCrack:fY,LucideHeartHandshake:xY,LucideHeartOff:gY,LucideHeartPulse:yY,LucideHeater:vY,LucideHelpCircle:Mv,LucideHelpingHand:pN,LucideHexagon:_Y,LucideHighlighter:bY,LucideHistory:MM,LucideHome:Mn,LucideHop:jY,LucideHopOff:wY,LucideHospital:NY,LucideHotel:kY,LucideHourglass:SY,LucideHouse:Mn,LucideHousePlug:CY,LucideHousePlus:MY,LucideIceCream:xN,LucideIceCream2:fN,LucideIceCreamBowl:fN,LucideIceCreamCone:xN,LucideIdCard:TY,LucideImage:qo,LucideImageDown:AY,LucideImageMinus:EY,LucideImageOff:PY,LucideImagePlay:IY,LucideImagePlus:Xv,LucideImageUp:LY,LucideImageUpscale:DY,LucideImages:RY,LucideImport:OY,LucideInbox:FY,LucideIndent:yN,LucideIndentDecrease:gN,LucideIndentIncrease:yN,LucideIndianRupee:zY,LucideInfinity:BY,LucideInfo:sS,LucideInspect:wk,LucideInspectionPanel:$Y,LucideInstagram:pu,LucideItalic:rS,LucideIterationCcw:qY,LucideIterationCw:UY,LucideJapaneseYen:VY,LucideJoystick:HY,LucideKanban:Yy,LucideKanbanSquare:gk,LucideKanbanSquareDashed:dk,LucideKey:fp,LucideKeyRound:nS,LucideKeySquare:GY,LucideKeyboard:ZY,LucideKeyboardMusic:WY,LucideKeyboardOff:KY,LucideLamp:tX,LucideLampCeiling:YY,LucideLampDesk:XY,LucideLampFloor:QY,LucideLampWallDown:JY,LucideLampWallUp:eX,LucideLandPlot:sX,LucideLandmark:rX,LucideLanguages:nX,LucideLaptop:iX,LucideLaptop2:vN,LucideLaptopMinimal:vN,LucideLaptopMinimalCheck:aX,LucideLasso:lX,LucideLassoSelect:oX,LucideLaugh:cX,LucideLayers:_L,LucideLayers2:dX,LucideLayers3:uX,LucideLayout:Av,LucideLayoutDashboard:aS,LucideLayoutGrid:xp,LucideLayoutList:hX,LucideLayoutPanelLeft:mX,LucideLayoutPanelTop:pX,LucideLayoutTemplate:iS,LucideLeaf:fX,LucideLeafyGreen:xX,LucideLectern:gX,LucideLetterText:yX,LucideLibrary:oS,LucideLibraryBig:vX,LucideLibrarySquare:yk,LucideLifeBuoy:TM,LucideLigature:_X,LucideLightbulb:Cb,LucideLightbulbOff:bX,LucideLineChart:pj,LucideLink:vo,LucideLink2:Do,LucideLink2Off:wX,LucideLinkedin:gp,LucideList:Dh,LucideListCheck:jX,LucideListChecks:NX,LucideListCollapse:kX,LucideListEnd:SX,LucideListFilter:CX,LucideListMinus:MX,LucideListMusic:TX,LucideListOrdered:Xy,LucideListPlus:AX,LucideListRestart:EX,LucideListStart:PX,LucideListTodo:IX,LucideListTree:LX,LucideListVideo:DX,LucideListX:RX,LucideLoader:FX,LucideLoader2:us,LucideLoaderCircle:us,LucideLoaderPinwheel:OX,LucideLocate:AM,LucideLocateFixed:zX,LucideLocateOff:BX,LucideLock:ad,LucideLockKeyhole:$X,LucideLockKeyholeOpen:_N,LucideLockOpen:bN,LucideLogIn:lS,LucideLogOut:EM,LucideLogs:qX,LucideLollipop:UX,LucideLuggage:VX,LucideMSquare:vk,LucideMagnet:HX,LucideMail:tr,LucideMailCheck:GX,LucideMailMinus:WX,LucideMailOpen:KX,LucideMailPlus:bL,LucideMailQuestion:ZX,LucideMailSearch:YX,LucideMailWarning:XX,LucideMailX:wL,LucideMailbox:QX,LucideMails:JX,LucideMap:cS,LucideMapPin:Ia,LucideMapPinCheck:tQ,LucideMapPinCheckInside:eQ,LucideMapPinHouse:sQ,LucideMapPinMinus:nQ,LucideMapPinMinusInside:rQ,LucideMapPinOff:aQ,LucideMapPinPlus:oQ,LucideMapPinPlusInside:iQ,LucideMapPinX:cQ,LucideMapPinXInside:lQ,LucideMapPinned:dQ,LucideMartini:uQ,LucideMaximize:jL,LucideMaximize2:hQ,LucideMedal:Qv,LucideMegaphone:uh,LucideMegaphoneOff:mQ,LucideMeh:pQ,LucideMemoryStick:fQ,LucideMenu:dS,LucideMenuSquare:_k,LucideMerge:xQ,LucideMessageCircle:Fl,LucideMessageCircleCode:gQ,LucideMessageCircleDashed:yQ,LucideMessageCircleHeart:PM,LucideMessageCircleMore:vQ,LucideMessageCircleOff:_Q,LucideMessageCirclePlus:bQ,LucideMessageCircleQuestion:NL,LucideMessageCircleReply:wQ,LucideMessageCircleWarning:jQ,LucideMessageCircleX:NQ,LucideMessageSquare:wi,LucideMessageSquareCode:kQ,LucideMessageSquareDashed:SQ,LucideMessageSquareDiff:CQ,LucideMessageSquareDot:MQ,LucideMessageSquareHeart:TQ,LucideMessageSquareLock:AQ,LucideMessageSquareMore:kL,LucideMessageSquareOff:EQ,LucideMessageSquarePlus:IM,LucideMessageSquareQuote:SL,LucideMessageSquareReply:PQ,LucideMessageSquareShare:IQ,LucideMessageSquareText:LQ,LucideMessageSquareWarning:DQ,LucideMessageSquareX:RQ,LucideMessagesSquare:OQ,LucideMic:CL,LucideMic2:wN,LucideMicOff:FQ,LucideMicVocal:wN,LucideMicrochip:zQ,LucideMicroscope:BQ,LucideMicrowave:$Q,LucideMilestone:qQ,LucideMilk:VQ,LucideMilkOff:UQ,LucideMinimize:GQ,LucideMinimize2:HQ,LucideMinus:Qy,LucideMinusCircle:Lj,LucideMinusSquare:bk,LucideMonitor:hS,LucideMonitorCheck:WQ,LucideMonitorCog:KQ,LucideMonitorDot:ZQ,LucideMonitorDown:YQ,LucideMonitorOff:XQ,LucideMonitorPause:QQ,LucideMonitorPlay:JQ,LucideMonitorSmartphone:eJ,LucideMonitorSpeaker:tJ,LucideMonitorStop:sJ,LucideMonitorUp:uS,LucideMonitorX:rJ,LucideMoon:aJ,LucideMoonStar:nJ,LucideMoreHorizontal:Zp,LucideMoreVertical:ix,LucideMountain:oJ,LucideMountainSnow:iJ,LucideMouse:uJ,LucideMouseOff:lJ,LucideMousePointer:au,LucideMousePointer2:cJ,LucideMousePointerBan:dJ,LucideMousePointerClick:Tm,LucideMousePointerSquareDashed:uk,LucideMove:NJ,LucideMove3D:jN,LucideMove3d:jN,LucideMoveDiagonal:mJ,LucideMoveDiagonal2:hJ,LucideMoveDown:xJ,LucideMoveDownLeft:pJ,LucideMoveDownRight:fJ,LucideMoveHorizontal:gJ,LucideMoveLeft:yJ,LucideMoveRight:vJ,LucideMoveUp:wJ,LucideMoveUpLeft:_J,LucideMoveUpRight:bJ,LucideMoveVertical:jJ,LucideMusic:MJ,LucideMusic2:kJ,LucideMusic3:SJ,LucideMusic4:CJ,LucideNavigation:ML,LucideNavigation2:AJ,LucideNavigation2Off:TJ,LucideNavigationOff:EJ,LucideNetwork:PJ,LucideNewspaper:Jv,LucideNfc:IJ,LucideNotebook:OJ,LucideNotebookPen:LJ,LucideNotebookTabs:DJ,LucideNotebookText:RJ,LucideNotepadText:zJ,LucideNotepadTextDashed:FJ,LucideNut:$J,LucideNutOff:BJ,LucideOctagon:UJ,LucideOctagonAlert:Tv,LucideOctagonMinus:qJ,LucideOctagonPause:NN,LucideOctagonX:kN,LucideOmega:VJ,LucideOption:HJ,LucideOrbit:GJ,LucideOrigami:WJ,LucideOutdent:gN,LucidePackage:cl,LucidePackage2:KJ,LucidePackageCheck:ZJ,LucidePackageMinus:YJ,LucidePackageOpen:XJ,LucidePackagePlus:QJ,LucidePackageSearch:JJ,LucidePackageX:eee,LucidePaintBucket:tee,LucidePaintRoller:see,LucidePaintbrush:ree,LucidePaintbrush2:SN,LucidePaintbrushVertical:SN,LucidePalette:zl,LucidePalmtree:Uk,LucidePanelBottom:iee,LucidePanelBottomClose:nee,LucidePanelBottomDashed:CN,LucidePanelBottomInactive:CN,LucidePanelBottomOpen:aee,LucidePanelLeft:EN,LucidePanelLeftClose:MN,LucidePanelLeftDashed:TN,LucidePanelLeftInactive:TN,LucidePanelLeftOpen:AN,LucidePanelRight:cee,LucidePanelRightClose:oee,LucidePanelRightDashed:PN,LucidePanelRightInactive:PN,LucidePanelRightOpen:lee,LucidePanelTop:hee,LucidePanelTopClose:dee,LucidePanelTopDashed:IN,LucidePanelTopInactive:IN,LucidePanelTopOpen:uee,LucidePanelsLeftBottom:mee,LucidePanelsLeftRight:Xj,LucidePanelsRightBottom:pee,LucidePanelsTopBottom:FN,LucidePanelsTopLeft:Av,LucidePaperclip:mS,LucideParentheses:fee,LucideParkingCircle:Rj,LucideParkingCircleOff:Dj,LucideParkingMeter:xee,LucideParkingSquare:Nk,LucideParkingSquareOff:jk,LucidePartyPopper:qd,LucidePause:hh,LucidePauseCircle:Oj,LucidePauseOctagon:NN,LucidePawPrint:gee,LucidePcCase:yee,LucidePen:Ry,LucidePenBox:Wc,LucidePenLine:Ev,LucidePenOff:vee,LucidePenSquare:Wc,LucidePenTool:Mb,LucidePencil:ga,LucidePencilLine:_ee,LucidePencilOff:bee,LucidePencilRuler:wee,LucidePentagon:jee,LucidePercent:LM,LucidePercentCircle:Fj,LucidePercentDiamond:Jj,LucidePercentSquare:kk,LucidePersonStanding:Nee,LucidePhilippinePeso:kee,LucidePhone:In,LucidePhoneCall:See,LucidePhoneForwarded:Cee,LucidePhoneIncoming:Mee,LucidePhoneMissed:Tee,LucidePhoneOff:Aee,LucidePhoneOutgoing:Eee,LucidePi:Pee,LucidePiSquare:Sk,LucidePiano:Iee,LucidePickaxe:Lee,LucidePictureInPicture:Ree,LucidePictureInPicture2:Dee,LucidePieChart:yj,LucidePiggyBank:Oee,LucidePilcrow:Bee,LucidePilcrowLeft:Fee,LucidePilcrowRight:zee,LucidePilcrowSquare:Ck,LucidePill:qee,LucidePillBottle:$ee,LucidePin:Tb,LucidePinOff:TL,LucidePipette:Uee,LucidePizza:Vee,LucidePlane:Wee,LucidePlaneLanding:Hee,LucidePlaneTakeoff:Gee,LucidePlay:Co,LucidePlayCircle:rp,LucidePlaySquare:Mk,LucidePlug:AL,LucidePlug2:Kee,LucidePlugZap:LN,LucidePlugZap2:LN,LucidePlus:qs,LucidePlusCircle:zj,LucidePlusSquare:Tk,LucidePocket:Yee,LucidePocketKnife:Zee,LucidePodcast:Xee,LucidePointer:Jee,LucidePointerOff:Qee,LucidePopcorn:ete,LucidePopsicle:tte,LucidePoundSterling:ste,LucidePower:EL,LucidePowerCircle:Bj,LucidePowerOff:rte,LucidePowerSquare:Ak,LucidePresentation:Pg,LucidePrinter:PL,LucidePrinterCheck:nte,LucideProjector:ate,LucideProportions:ite,LucidePuzzle:ote,LucidePyramid:lte,LucideQrCode:Jy,LucideQuote:pS,LucideRabbit:cte,LucideRadar:dte,LucideRadiation:ute,LucideRadical:hte,LucideRadio:e1,LucideRadioReceiver:mte,LucideRadioTower:pte,LucideRadius:fte,LucideRailSymbol:xte,LucideRainbow:gte,LucideRat:yte,LucideRatio:vte,LucideReceipt:Mte,LucideReceiptCent:_te,LucideReceiptEuro:bte,LucideReceiptIndianRupee:wte,LucideReceiptJapaneseYen:jte,LucideReceiptPoundSterling:Nte,LucideReceiptRussianRuble:kte,LucideReceiptSwissFranc:Ste,LucideReceiptText:Cte,LucideRectangleEllipsis:DN,LucideRectangleHorizontal:Tte,LucideRectangleVertical:Ate,LucideRecycle:Ete,LucideRedo:fS,LucideRedo2:Pte,LucideRedoDot:Ite,LucideRefreshCcw:DM,LucideRefreshCcwDot:Lte,LucideRefreshCw:Zi,LucideRefreshCwOff:Dte,LucideRefrigerator:Rte,LucideRegex:Ote,LucideRemoveFormatting:Fte,LucideRepeat:IL,LucideRepeat1:zte,LucideRepeat2:Bte,LucideReplace:qte,LucideReplaceAll:$te,LucideReply:LL,LucideReplyAll:Ute,LucideRewind:Vte,LucideRibbon:Hte,LucideRocket:e0,LucideRockingChair:Gte,LucideRollerCoaster:Wte,LucideRotate3D:RN,LucideRotate3d:RN,LucideRotateCcw:t0,LucideRotateCcwSquare:Kte,LucideRotateCw:DL,LucideRotateCwSquare:Zte,LucideRoute:Xte,LucideRouteOff:Yte,LucideRouter:Qte,LucideRows:ON,LucideRows2:ON,LucideRows3:FN,LucideRows4:Jte,LucideRss:ese,LucideRuler:xS,LucideRussianRuble:tse,LucideSailboat:sse,LucideSalad:rse,LucideSandwich:nse,LucideSatellite:ise,LucideSatelliteDish:ase,LucideSave:bc,LucideSaveAll:ose,LucideSaveOff:lse,LucideScale:RL,LucideScale3D:zN,LucideScale3d:zN,LucideScaling:cse,LucideScan:gse,LucideScanBarcode:dse,LucideScanEye:use,LucideScanFace:hse,LucideScanLine:mse,LucideScanQrCode:pse,LucideScanSearch:fse,LucideScanText:xse,LucideScatterChart:vj,LucideSchool:yse,LucideSchool2:Hk,LucideScissors:_se,LucideScissorsLineDashed:vse,LucideScissorsSquare:Ek,LucideScissorsSquareDashedBottom:rk,LucideScreenShare:wse,LucideScreenShareOff:bse,LucideScroll:Nse,LucideScrollText:jse,LucideSearch:ln,LucideSearchCheck:kse,LucideSearchCode:Sse,LucideSearchSlash:Cse,LucideSearchX:OL,LucideSection:Mse,LucideSend:_n,LucideSendHorizonal:BN,LucideSendHorizontal:BN,LucideSendToBack:Tse,LucideSeparatorHorizontal:Ase,LucideSeparatorVertical:Ese,LucideServer:Dse,LucideServerCog:Pse,LucideServerCrash:Ise,LucideServerOff:Lse,LucideSettings:So,LucideSettings2:FL,LucideShapes:Rse,LucideShare:zL,LucideShare2:id,LucideSheet:Ose,LucideShell:Fse,LucideShield:zu,LucideShieldAlert:zse,LucideShieldBan:Bse,LucideShieldCheck:t1,LucideShieldClose:$N,LucideShieldEllipsis:$se,LucideShieldHalf:qse,LucideShieldMinus:Use,LucideShieldOff:gS,LucideShieldPlus:Vse,LucideShieldQuestion:Hse,LucideShieldX:$N,LucideShip:Wse,LucideShipWheel:Gse,LucideShirt:Kse,LucideShoppingBag:s0,LucideShoppingBasket:Zse,LucideShoppingCart:lp,LucideShovel:Yse,LucideShowerHead:Xse,LucideShrink:Qse,LucideShrub:Jse,LucideShuffle:yS,LucideSidebar:EN,LucideSidebarClose:MN,LucideSidebarOpen:AN,LucideSigma:ere,LucideSigmaSquare:Pk,LucideSignal:are,LucideSignalHigh:tre,LucideSignalLow:sre,LucideSignalMedium:rre,LucideSignalZero:nre,LucideSignature:ire,LucideSignpost:lre,LucideSignpostBig:ore,LucideSiren:cre,LucideSkipBack:dre,LucideSkipForward:ure,LucideSkull:hre,LucideSlack:mre,LucideSlash:pre,LucideSlashSquare:Ik,LucideSlice:fre,LucideSliders:qN,LucideSlidersHorizontal:vS,LucideSlidersVertical:qN,LucideSmartphone:Ig,LucideSmartphoneCharging:xre,LucideSmartphoneNfc:gre,LucideSmile:vre,LucideSmilePlus:yre,LucideSnail:_re,LucideSnowflake:qy,LucideSofa:bre,LucideSortAsc:J2,LucideSortDesc:Y2,LucideSoup:wre,LucideSpace:jre,LucideSpade:Nre,LucideSparkle:kre,LucideSparkles:Or,LucideSpeaker:Sre,LucideSpeech:Cre,LucideSpellCheck:Tre,LucideSpellCheck2:Mre,LucideSpline:Are,LucideSplit:Ere,LucideSplitSquareHorizontal:Lk,LucideSplitSquareVertical:Dk,LucideSprayCan:Pre,LucideSprout:_S,LucideSquare:r0,LucideSquareActivity:UN,LucideSquareArrowDown:GN,LucideSquareArrowDownLeft:VN,LucideSquareArrowDownRight:HN,LucideSquareArrowLeft:WN,LucideSquareArrowOutDownLeft:KN,LucideSquareArrowOutDownRight:ZN,LucideSquareArrowOutUpLeft:YN,LucideSquareArrowOutUpRight:XN,LucideSquareArrowRight:QN,LucideSquareArrowUp:tk,LucideSquareArrowUpLeft:JN,LucideSquareArrowUpRight:ek,LucideSquareAsterisk:sk,LucideSquareBottomDashedScissors:rk,LucideSquareChartGantt:ky,LucideSquareCheck:nk,LucideSquareCheckBig:Pv,LucideSquareChevronDown:ak,LucideSquareChevronLeft:ik,LucideSquareChevronRight:ok,LucideSquareChevronUp:lk,LucideSquareCode:ck,LucideSquareDashed:hk,LucideSquareDashedBottom:Lre,LucideSquareDashedBottomCode:Ire,LucideSquareDashedKanban:dk,LucideSquareDashedMousePointer:uk,LucideSquareDivide:mk,LucideSquareDot:pk,LucideSquareEqual:fk,LucideSquareFunction:xk,LucideSquareGanttChart:ky,LucideSquareKanban:gk,LucideSquareLibrary:yk,LucideSquareM:vk,LucideSquareMenu:_k,LucideSquareMinus:bk,LucideSquareMousePointer:wk,LucideSquareParking:Nk,LucideSquareParkingOff:jk,LucideSquarePen:Wc,LucideSquarePercent:kk,LucideSquarePi:Sk,LucideSquarePilcrow:Ck,LucideSquarePlay:Mk,LucideSquarePlus:Tk,LucideSquarePower:Ak,LucideSquareRadical:Dre,LucideSquareScissors:Ek,LucideSquareSigma:Pk,LucideSquareSlash:Ik,LucideSquareSplitHorizontal:Lk,LucideSquareSplitVertical:Dk,LucideSquareSquare:Rre,LucideSquareStack:Ore,LucideSquareTerminal:Rk,LucideSquareUser:Fk,LucideSquareUserRound:Ok,LucideSquareX:zk,LucideSquircle:Fre,LucideSquirrel:zre,LucideStamp:Bre,LucideStar:Gn,LucideStarHalf:$re,LucideStarOff:qre,LucideStars:Or,LucideStepBack:Ure,LucideStepForward:Vre,LucideStethoscope:Hre,LucideSticker:Gre,LucideStickyNote:Wre,LucideStopCircle:qj,LucideStore:Kre,LucideStretchHorizontal:Zre,LucideStretchVertical:Yre,LucideStrikethrough:BL,LucideSubscript:Xre,LucideSubtitles:oj,LucideSun:s1,LucideSunDim:Qre,LucideSunMedium:Jre,LucideSunMoon:ene,LucideSunSnow:tne,LucideSunrise:sne,LucideSunset:rne,LucideSuperscript:nne,LucideSwatchBook:ane,LucideSwissFranc:ine,LucideSwitchCamera:one,LucideSword:lne,LucideSwords:cne,LucideSyringe:dne,LucideTable:OM,LucideTable2:RM,LucideTableCellsMerge:une,LucideTableCellsSplit:hne,LucideTableColumnsSplit:mne,LucideTableOfContents:pne,LucideTableProperties:fne,LucideTableRowsSplit:xne,LucideTablet:yne,LucideTabletSmartphone:gne,LucideTablets:vne,LucideTag:mh,LucideTags:_ne,LucideTally1:bne,LucideTally2:wne,LucideTally3:jne,LucideTally4:Nne,LucideTally5:kne,LucideTangent:Sne,LucideTarget:Rh,LucideTelescope:Cne,LucideTent:Tne,LucideTentTree:Mne,LucideTerminal:Ane,LucideTerminalSquare:Rk,LucideTestTube:Ene,LucideTestTube2:Bk,LucideTestTubeDiagonal:Bk,LucideTestTubes:Pne,LucideText:One,LucideTextCursor:Lne,LucideTextCursorInput:Ine,LucideTextQuote:Dne,LucideTextSearch:Rne,LucideTextSelect:$k,LucideTextSelection:$k,LucideTheater:Fne,LucideThermometer:$ne,LucideThermometerSnowflake:zne,LucideThermometerSun:Bne,LucideThumbsDown:$L,LucideThumbsUp:Bu,LucideTicket:qL,LucideTicketCheck:qne,LucideTicketMinus:Une,LucideTicketPercent:Vne,LucideTicketPlus:Hne,LucideTicketSlash:Gne,LucideTicketX:Wne,LucideTickets:Zne,LucideTicketsPlane:Kne,LucideTimer:Qne,LucideTimerOff:Yne,LucideTimerReset:Xne,LucideToggleLeft:Jne,LucideToggleRight:eae,LucideToilet:tae,LucideTornado:sae,LucideTorus:rae,LucideTouchpad:aae,LucideTouchpadOff:nae,LucideTowerControl:iae,LucideToyBrick:oae,LucideTractor:lae,LucideTrafficCone:cae,LucideTrain:qk,LucideTrainFront:uae,LucideTrainFrontTunnel:dae,LucideTrainTrack:hae,LucideTramFront:qk,LucideTrash:mae,LucideTrash2:vr,LucideTreeDeciduous:pae,LucideTreePalm:Uk,LucideTreePine:Ab,LucideTrees:fae,LucideTrello:xae,LucideTrendingDown:bS,LucideTrendingUp:Qo,LucideTrendingUpDown:gae,LucideTriangle:vae,LucideTriangleAlert:Dc,LucideTriangleRight:yae,LucideTrophy:Fi,LucideTruck:UL,LucideTurtle:_ae,LucideTv:wae,LucideTv2:Vk,LucideTvMinimal:Vk,LucideTvMinimalPlay:bae,LucideTwitch:jae,LucideTwitter:Nae,LucideType:Sae,LucideTypeOutline:kae,LucideUmbrella:Mae,LucideUmbrellaOff:Cae,LucideUnderline:VL,LucideUndo:wS,LucideUndo2:Tae,LucideUndoDot:Aae,LucideUnfoldHorizontal:Eae,LucideUnfoldVertical:Pae,LucideUngroup:Iae,LucideUniversity:Hk,LucideUnlink:jS,LucideUnlink2:Lae,LucideUnlock:bN,LucideUnlockKeyhole:_N,LucideUnplug:Dae,LucideUpload:Ra,LucideUploadCloud:Kj,LucideUsb:Rae,LucideUser:Ai,LucideUser2:Xk,LucideUserCheck:n0,LucideUserCheck2:Gk,LucideUserCircle:Vj,LucideUserCircle2:Uj,LucideUserCog:HL,LucideUserCog2:Wk,LucideUserMinus:GL,LucideUserMinus2:Kk,LucideUserPen:Oae,LucideUserPlus:Jo,LucideUserPlus2:Zk,LucideUserRound:Xk,LucideUserRoundCheck:Gk,LucideUserRoundCog:Wk,LucideUserRoundMinus:Kk,LucideUserRoundPen:Fae,LucideUserRoundPlus:Zk,LucideUserRoundSearch:zae,LucideUserRoundX:Yk,LucideUserSearch:Bae,LucideUserSquare:Fk,LucideUserSquare2:Ok,LucideUserX:$ae,LucideUserX2:Yk,LucideUsers:ir,LucideUsers2:Qk,LucideUsersRound:Qk,LucideUtensils:e4,LucideUtensilsCrossed:Jk,LucideUtilityPole:qae,LucideVariable:FM,LucideVault:Uae,LucideVegan:Vae,LucideVenetianMask:Hae,LucideVerified:sj,LucideVibrate:Wae,LucideVibrateOff:Gae,LucideVideo:yn,LucideVideoOff:Kae,LucideVideotape:Zae,LucideView:Yae,LucideVoicemail:Xae,LucideVolleyball:Qae,LucideVolume:rie,LucideVolume1:Jae,LucideVolume2:eie,LucideVolumeOff:tie,LucideVolumeX:sie,LucideVote:nie,LucideWallet:WL,LucideWallet2:t4,LucideWalletCards:aie,LucideWalletMinimal:t4,LucideWallpaper:iie,LucideWand:oie,LucideWand2:Iv,LucideWandSparkles:Iv,LucideWarehouse:lie,LucideWashingMachine:cie,LucideWatch:die,LucideWaves:uie,LucideWaypoints:hie,LucideWebcam:mie,LucideWebhook:fie,LucideWebhookOff:pie,LucideWeight:xie,LucideWheat:yie,LucideWheatOff:gie,LucideWholeWord:vie,LucideWifi:Nie,LucideWifiHigh:_ie,LucideWifiLow:bie,LucideWifiOff:wie,LucideWifiZero:jie,LucideWind:Sie,LucideWindArrowDown:kie,LucideWine:Mie,LucideWineOff:Cie,LucideWorkflow:Tie,LucideWorm:Aie,LucideWrapText:Eie,LucideWrench:Lg,LucideX:kr,LucideXCircle:Jl,LucideXOctagon:kN,LucideXSquare:zk,LucideYoutube:Pie,LucideZap:Oh,LucideZapOff:Iie,LucideZoomIn:Eb,LucideZoomOut:zM,Luggage:VX,LuggageIcon:VX,MSquare:vk,MSquareIcon:vk,Magnet:HX,MagnetIcon:HX,Mail:tr,MailCheck:GX,MailCheckIcon:GX,MailIcon:tr,MailMinus:WX,MailMinusIcon:WX,MailOpen:KX,MailOpenIcon:KX,MailPlus:bL,MailPlusIcon:bL,MailQuestion:ZX,MailQuestionIcon:ZX,MailSearch:YX,MailSearchIcon:YX,MailWarning:XX,MailWarningIcon:XX,MailX:wL,MailXIcon:wL,Mailbox:QX,MailboxIcon:QX,Mails:JX,MailsIcon:JX,Map:cS,MapIcon:cS,MapPin:Ia,MapPinCheck:tQ,MapPinCheckIcon:tQ,MapPinCheckInside:eQ,MapPinCheckInsideIcon:eQ,MapPinHouse:sQ,MapPinHouseIcon:sQ,MapPinIcon:Ia,MapPinMinus:nQ,MapPinMinusIcon:nQ,MapPinMinusInside:rQ,MapPinMinusInsideIcon:rQ,MapPinOff:aQ,MapPinOffIcon:aQ,MapPinPlus:oQ,MapPinPlusIcon:oQ,MapPinPlusInside:iQ,MapPinPlusInsideIcon:iQ,MapPinX:cQ,MapPinXIcon:cQ,MapPinXInside:lQ,MapPinXInsideIcon:lQ,MapPinned:dQ,MapPinnedIcon:dQ,Martini:uQ,MartiniIcon:uQ,Maximize:jL,Maximize2:hQ,Maximize2Icon:hQ,MaximizeIcon:jL,Medal:Qv,MedalIcon:Qv,Megaphone:uh,MegaphoneIcon:uh,MegaphoneOff:mQ,MegaphoneOffIcon:mQ,Meh:pQ,MehIcon:pQ,MemoryStick:fQ,MemoryStickIcon:fQ,Menu:dS,MenuIcon:dS,MenuSquare:_k,MenuSquareIcon:_k,Merge:xQ,MergeIcon:xQ,MessageCircle:Fl,MessageCircleCode:gQ,MessageCircleCodeIcon:gQ,MessageCircleDashed:yQ,MessageCircleDashedIcon:yQ,MessageCircleHeart:PM,MessageCircleHeartIcon:PM,MessageCircleIcon:Fl,MessageCircleMore:vQ,MessageCircleMoreIcon:vQ,MessageCircleOff:_Q,MessageCircleOffIcon:_Q,MessageCirclePlus:bQ,MessageCirclePlusIcon:bQ,MessageCircleQuestion:NL,MessageCircleQuestionIcon:NL,MessageCircleReply:wQ,MessageCircleReplyIcon:wQ,MessageCircleWarning:jQ,MessageCircleWarningIcon:jQ,MessageCircleX:NQ,MessageCircleXIcon:NQ,MessageSquare:wi,MessageSquareCode:kQ,MessageSquareCodeIcon:kQ,MessageSquareDashed:SQ,MessageSquareDashedIcon:SQ,MessageSquareDiff:CQ,MessageSquareDiffIcon:CQ,MessageSquareDot:MQ,MessageSquareDotIcon:MQ,MessageSquareHeart:TQ,MessageSquareHeartIcon:TQ,MessageSquareIcon:wi,MessageSquareLock:AQ,MessageSquareLockIcon:AQ,MessageSquareMore:kL,MessageSquareMoreIcon:kL,MessageSquareOff:EQ,MessageSquareOffIcon:EQ,MessageSquarePlus:IM,MessageSquarePlusIcon:IM,MessageSquareQuote:SL,MessageSquareQuoteIcon:SL,MessageSquareReply:PQ,MessageSquareReplyIcon:PQ,MessageSquareShare:IQ,MessageSquareShareIcon:IQ,MessageSquareText:LQ,MessageSquareTextIcon:LQ,MessageSquareWarning:DQ,MessageSquareWarningIcon:DQ,MessageSquareX:RQ,MessageSquareXIcon:RQ,MessagesSquare:OQ,MessagesSquareIcon:OQ,Mic:CL,Mic2:wN,Mic2Icon:wN,MicIcon:CL,MicOff:FQ,MicOffIcon:FQ,MicVocal:wN,MicVocalIcon:wN,Microchip:zQ,MicrochipIcon:zQ,Microscope:BQ,MicroscopeIcon:BQ,Microwave:$Q,MicrowaveIcon:$Q,Milestone:qQ,MilestoneIcon:qQ,Milk:VQ,MilkIcon:VQ,MilkOff:UQ,MilkOffIcon:UQ,Minimize:GQ,Minimize2:HQ,Minimize2Icon:HQ,MinimizeIcon:GQ,Minus:Qy,MinusCircle:Lj,MinusCircleIcon:Lj,MinusIcon:Qy,MinusSquare:bk,MinusSquareIcon:bk,Monitor:hS,MonitorCheck:WQ,MonitorCheckIcon:WQ,MonitorCog:KQ,MonitorCogIcon:KQ,MonitorDot:ZQ,MonitorDotIcon:ZQ,MonitorDown:YQ,MonitorDownIcon:YQ,MonitorIcon:hS,MonitorOff:XQ,MonitorOffIcon:XQ,MonitorPause:QQ,MonitorPauseIcon:QQ,MonitorPlay:JQ,MonitorPlayIcon:JQ,MonitorSmartphone:eJ,MonitorSmartphoneIcon:eJ,MonitorSpeaker:tJ,MonitorSpeakerIcon:tJ,MonitorStop:sJ,MonitorStopIcon:sJ,MonitorUp:uS,MonitorUpIcon:uS,MonitorX:rJ,MonitorXIcon:rJ,Moon:aJ,MoonIcon:aJ,MoonStar:nJ,MoonStarIcon:nJ,MoreHorizontal:Zp,MoreHorizontalIcon:Zp,MoreVertical:ix,MoreVerticalIcon:ix,Mountain:oJ,MountainIcon:oJ,MountainSnow:iJ,MountainSnowIcon:iJ,Mouse:uJ,MouseIcon:uJ,MouseOff:lJ,MouseOffIcon:lJ,MousePointer:au,MousePointer2:cJ,MousePointer2Icon:cJ,MousePointerBan:dJ,MousePointerBanIcon:dJ,MousePointerClick:Tm,MousePointerClickIcon:Tm,MousePointerIcon:au,MousePointerSquareDashed:uk,MousePointerSquareDashedIcon:uk,Move:NJ,Move3D:jN,Move3DIcon:jN,Move3d:jN,Move3dIcon:jN,MoveDiagonal:mJ,MoveDiagonal2:hJ,MoveDiagonal2Icon:hJ,MoveDiagonalIcon:mJ,MoveDown:xJ,MoveDownIcon:xJ,MoveDownLeft:pJ,MoveDownLeftIcon:pJ,MoveDownRight:fJ,MoveDownRightIcon:fJ,MoveHorizontal:gJ,MoveHorizontalIcon:gJ,MoveIcon:NJ,MoveLeft:yJ,MoveLeftIcon:yJ,MoveRight:vJ,MoveRightIcon:vJ,MoveUp:wJ,MoveUpIcon:wJ,MoveUpLeft:_J,MoveUpLeftIcon:_J,MoveUpRight:bJ,MoveUpRightIcon:bJ,MoveVertical:jJ,MoveVerticalIcon:jJ,Music:MJ,Music2:kJ,Music2Icon:kJ,Music3:SJ,Music3Icon:SJ,Music4:CJ,Music4Icon:CJ,MusicIcon:MJ,Navigation:ML,Navigation2:AJ,Navigation2Icon:AJ,Navigation2Off:TJ,Navigation2OffIcon:TJ,NavigationIcon:ML,NavigationOff:EJ,NavigationOffIcon:EJ,Network:PJ,NetworkIcon:PJ,Newspaper:Jv,NewspaperIcon:Jv,Nfc:IJ,NfcIcon:IJ,Notebook:OJ,NotebookIcon:OJ,NotebookPen:LJ,NotebookPenIcon:LJ,NotebookTabs:DJ,NotebookTabsIcon:DJ,NotebookText:RJ,NotebookTextIcon:RJ,NotepadText:zJ,NotepadTextDashed:FJ,NotepadTextDashedIcon:FJ,NotepadTextIcon:zJ,Nut:$J,NutIcon:$J,NutOff:BJ,NutOffIcon:BJ,Octagon:UJ,OctagonAlert:Tv,OctagonAlertIcon:Tv,OctagonIcon:UJ,OctagonMinus:qJ,OctagonMinusIcon:qJ,OctagonPause:NN,OctagonPauseIcon:NN,OctagonX:kN,OctagonXIcon:kN,Omega:VJ,OmegaIcon:VJ,Option:HJ,OptionIcon:HJ,Orbit:GJ,OrbitIcon:GJ,Origami:WJ,OrigamiIcon:WJ,Outdent:gN,OutdentIcon:gN,Package:cl,Package2:KJ,Package2Icon:KJ,PackageCheck:ZJ,PackageCheckIcon:ZJ,PackageIcon:cl,PackageMinus:YJ,PackageMinusIcon:YJ,PackageOpen:XJ,PackageOpenIcon:XJ,PackagePlus:QJ,PackagePlusIcon:QJ,PackageSearch:JJ,PackageSearchIcon:JJ,PackageX:eee,PackageXIcon:eee,PaintBucket:tee,PaintBucketIcon:tee,PaintRoller:see,PaintRollerIcon:see,Paintbrush:ree,Paintbrush2:SN,Paintbrush2Icon:SN,PaintbrushIcon:ree,PaintbrushVertical:SN,PaintbrushVerticalIcon:SN,Palette:zl,PaletteIcon:zl,Palmtree:Uk,PalmtreeIcon:Uk,PanelBottom:iee,PanelBottomClose:nee,PanelBottomCloseIcon:nee,PanelBottomDashed:CN,PanelBottomDashedIcon:CN,PanelBottomIcon:iee,PanelBottomInactive:CN,PanelBottomInactiveIcon:CN,PanelBottomOpen:aee,PanelBottomOpenIcon:aee,PanelLeft:EN,PanelLeftClose:MN,PanelLeftCloseIcon:MN,PanelLeftDashed:TN,PanelLeftDashedIcon:TN,PanelLeftIcon:EN,PanelLeftInactive:TN,PanelLeftInactiveIcon:TN,PanelLeftOpen:AN,PanelLeftOpenIcon:AN,PanelRight:cee,PanelRightClose:oee,PanelRightCloseIcon:oee,PanelRightDashed:PN,PanelRightDashedIcon:PN,PanelRightIcon:cee,PanelRightInactive:PN,PanelRightInactiveIcon:PN,PanelRightOpen:lee,PanelRightOpenIcon:lee,PanelTop:hee,PanelTopClose:dee,PanelTopCloseIcon:dee,PanelTopDashed:IN,PanelTopDashedIcon:IN,PanelTopIcon:hee,PanelTopInactive:IN,PanelTopInactiveIcon:IN,PanelTopOpen:uee,PanelTopOpenIcon:uee,PanelsLeftBottom:mee,PanelsLeftBottomIcon:mee,PanelsLeftRight:Xj,PanelsLeftRightIcon:Xj,PanelsRightBottom:pee,PanelsRightBottomIcon:pee,PanelsTopBottom:FN,PanelsTopBottomIcon:FN,PanelsTopLeft:Av,PanelsTopLeftIcon:Av,Paperclip:mS,PaperclipIcon:mS,Parentheses:fee,ParenthesesIcon:fee,ParkingCircle:Rj,ParkingCircleIcon:Rj,ParkingCircleOff:Dj,ParkingCircleOffIcon:Dj,ParkingMeter:xee,ParkingMeterIcon:xee,ParkingSquare:Nk,ParkingSquareIcon:Nk,ParkingSquareOff:jk,ParkingSquareOffIcon:jk,PartyPopper:qd,PartyPopperIcon:qd,Pause:hh,PauseCircle:Oj,PauseCircleIcon:Oj,PauseIcon:hh,PauseOctagon:NN,PauseOctagonIcon:NN,PawPrint:gee,PawPrintIcon:gee,PcCase:yee,PcCaseIcon:yee,Pen:Ry,PenBox:Wc,PenBoxIcon:Wc,PenIcon:Ry,PenLine:Ev,PenLineIcon:Ev,PenOff:vee,PenOffIcon:vee,PenSquare:Wc,PenSquareIcon:Wc,PenTool:Mb,PenToolIcon:Mb,Pencil:ga,PencilIcon:ga,PencilLine:_ee,PencilLineIcon:_ee,PencilOff:bee,PencilOffIcon:bee,PencilRuler:wee,PencilRulerIcon:wee,Pentagon:jee,PentagonIcon:jee,Percent:LM,PercentCircle:Fj,PercentCircleIcon:Fj,PercentDiamond:Jj,PercentDiamondIcon:Jj,PercentIcon:LM,PercentSquare:kk,PercentSquareIcon:kk,PersonStanding:Nee,PersonStandingIcon:Nee,PhilippinePeso:kee,PhilippinePesoIcon:kee,Phone:In,PhoneCall:See,PhoneCallIcon:See,PhoneForwarded:Cee,PhoneForwardedIcon:Cee,PhoneIcon:In,PhoneIncoming:Mee,PhoneIncomingIcon:Mee,PhoneMissed:Tee,PhoneMissedIcon:Tee,PhoneOff:Aee,PhoneOffIcon:Aee,PhoneOutgoing:Eee,PhoneOutgoingIcon:Eee,Pi:Pee,PiIcon:Pee,PiSquare:Sk,PiSquareIcon:Sk,Piano:Iee,PianoIcon:Iee,Pickaxe:Lee,PickaxeIcon:Lee,PictureInPicture:Ree,PictureInPicture2:Dee,PictureInPicture2Icon:Dee,PictureInPictureIcon:Ree,PieChart:yj,PieChartIcon:yj,PiggyBank:Oee,PiggyBankIcon:Oee,Pilcrow:Bee,PilcrowIcon:Bee,PilcrowLeft:Fee,PilcrowLeftIcon:Fee,PilcrowRight:zee,PilcrowRightIcon:zee,PilcrowSquare:Ck,PilcrowSquareIcon:Ck,Pill:qee,PillBottle:$ee,PillBottleIcon:$ee,PillIcon:qee,Pin:Tb,PinIcon:Tb,PinOff:TL,PinOffIcon:TL,Pipette:Uee,PipetteIcon:Uee,Pizza:Vee,PizzaIcon:Vee,Plane:Wee,PlaneIcon:Wee,PlaneLanding:Hee,PlaneLandingIcon:Hee,PlaneTakeoff:Gee,PlaneTakeoffIcon:Gee,Play:Co,PlayCircle:rp,PlayCircleIcon:rp,PlayIcon:Co,PlaySquare:Mk,PlaySquareIcon:Mk,Plug:AL,Plug2:Kee,Plug2Icon:Kee,PlugIcon:AL,PlugZap:LN,PlugZap2:LN,PlugZap2Icon:LN,PlugZapIcon:LN,Plus:qs,PlusCircle:zj,PlusCircleIcon:zj,PlusIcon:qs,PlusSquare:Tk,PlusSquareIcon:Tk,Pocket:Yee,PocketIcon:Yee,PocketKnife:Zee,PocketKnifeIcon:Zee,Podcast:Xee,PodcastIcon:Xee,Pointer:Jee,PointerIcon:Jee,PointerOff:Qee,PointerOffIcon:Qee,Popcorn:ete,PopcornIcon:ete,Popsicle:tte,PopsicleIcon:tte,PoundSterling:ste,PoundSterlingIcon:ste,Power:EL,PowerCircle:Bj,PowerCircleIcon:Bj,PowerIcon:EL,PowerOff:rte,PowerOffIcon:rte,PowerSquare:Ak,PowerSquareIcon:Ak,Presentation:Pg,PresentationIcon:Pg,Printer:PL,PrinterCheck:nte,PrinterCheckIcon:nte,PrinterIcon:PL,Projector:ate,ProjectorIcon:ate,Proportions:ite,ProportionsIcon:ite,Puzzle:ote,PuzzleIcon:ote,Pyramid:lte,PyramidIcon:lte,QrCode:Jy,QrCodeIcon:Jy,Quote:pS,QuoteIcon:pS,Rabbit:cte,RabbitIcon:cte,Radar:dte,RadarIcon:dte,Radiation:ute,RadiationIcon:ute,Radical:hte,RadicalIcon:hte,Radio:e1,RadioIcon:e1,RadioReceiver:mte,RadioReceiverIcon:mte,RadioTower:pte,RadioTowerIcon:pte,Radius:fte,RadiusIcon:fte,RailSymbol:xte,RailSymbolIcon:xte,Rainbow:gte,RainbowIcon:gte,Rat:yte,RatIcon:yte,Ratio:vte,RatioIcon:vte,Receipt:Mte,ReceiptCent:_te,ReceiptCentIcon:_te,ReceiptEuro:bte,ReceiptEuroIcon:bte,ReceiptIcon:Mte,ReceiptIndianRupee:wte,ReceiptIndianRupeeIcon:wte,ReceiptJapaneseYen:jte,ReceiptJapaneseYenIcon:jte,ReceiptPoundSterling:Nte,ReceiptPoundSterlingIcon:Nte,ReceiptRussianRuble:kte,ReceiptRussianRubleIcon:kte,ReceiptSwissFranc:Ste,ReceiptSwissFrancIcon:Ste,ReceiptText:Cte,ReceiptTextIcon:Cte,RectangleEllipsis:DN,RectangleEllipsisIcon:DN,RectangleHorizontal:Tte,RectangleHorizontalIcon:Tte,RectangleVertical:Ate,RectangleVerticalIcon:Ate,Recycle:Ete,RecycleIcon:Ete,Redo:fS,Redo2:Pte,Redo2Icon:Pte,RedoDot:Ite,RedoDotIcon:Ite,RedoIcon:fS,RefreshCcw:DM,RefreshCcwDot:Lte,RefreshCcwDotIcon:Lte,RefreshCcwIcon:DM,RefreshCw:Zi,RefreshCwIcon:Zi,RefreshCwOff:Dte,RefreshCwOffIcon:Dte,Refrigerator:Rte,RefrigeratorIcon:Rte,Regex:Ote,RegexIcon:Ote,RemoveFormatting:Fte,RemoveFormattingIcon:Fte,Repeat:IL,Repeat1:zte,Repeat1Icon:zte,Repeat2:Bte,Repeat2Icon:Bte,RepeatIcon:IL,Replace:qte,ReplaceAll:$te,ReplaceAllIcon:$te,ReplaceIcon:qte,Reply:LL,ReplyAll:Ute,ReplyAllIcon:Ute,ReplyIcon:LL,Rewind:Vte,RewindIcon:Vte,Ribbon:Hte,RibbonIcon:Hte,Rocket:e0,RocketIcon:e0,RockingChair:Gte,RockingChairIcon:Gte,RollerCoaster:Wte,RollerCoasterIcon:Wte,Rotate3D:RN,Rotate3DIcon:RN,Rotate3d:RN,Rotate3dIcon:RN,RotateCcw:t0,RotateCcwIcon:t0,RotateCcwSquare:Kte,RotateCcwSquareIcon:Kte,RotateCw:DL,RotateCwIcon:DL,RotateCwSquare:Zte,RotateCwSquareIcon:Zte,Route:Xte,RouteIcon:Xte,RouteOff:Yte,RouteOffIcon:Yte,Router:Qte,RouterIcon:Qte,Rows:ON,Rows2:ON,Rows2Icon:ON,Rows3:FN,Rows3Icon:FN,Rows4:Jte,Rows4Icon:Jte,RowsIcon:ON,Rss:ese,RssIcon:ese,Ruler:xS,RulerIcon:xS,RussianRuble:tse,RussianRubleIcon:tse,Sailboat:sse,SailboatIcon:sse,Salad:rse,SaladIcon:rse,Sandwich:nse,SandwichIcon:nse,Satellite:ise,SatelliteDish:ase,SatelliteDishIcon:ase,SatelliteIcon:ise,Save:bc,SaveAll:ose,SaveAllIcon:ose,SaveIcon:bc,SaveOff:lse,SaveOffIcon:lse,Scale:RL,Scale3D:zN,Scale3DIcon:zN,Scale3d:zN,Scale3dIcon:zN,ScaleIcon:RL,Scaling:cse,ScalingIcon:cse,Scan:gse,ScanBarcode:dse,ScanBarcodeIcon:dse,ScanEye:use,ScanEyeIcon:use,ScanFace:hse,ScanFaceIcon:hse,ScanIcon:gse,ScanLine:mse,ScanLineIcon:mse,ScanQrCode:pse,ScanQrCodeIcon:pse,ScanSearch:fse,ScanSearchIcon:fse,ScanText:xse,ScanTextIcon:xse,ScatterChart:vj,ScatterChartIcon:vj,School:yse,School2:Hk,School2Icon:Hk,SchoolIcon:yse,Scissors:_se,ScissorsIcon:_se,ScissorsLineDashed:vse,ScissorsLineDashedIcon:vse,ScissorsSquare:Ek,ScissorsSquareDashedBottom:rk,ScissorsSquareDashedBottomIcon:rk,ScissorsSquareIcon:Ek,ScreenShare:wse,ScreenShareIcon:wse,ScreenShareOff:bse,ScreenShareOffIcon:bse,Scroll:Nse,ScrollIcon:Nse,ScrollText:jse,ScrollTextIcon:jse,Search:ln,SearchCheck:kse,SearchCheckIcon:kse,SearchCode:Sse,SearchCodeIcon:Sse,SearchIcon:ln,SearchSlash:Cse,SearchSlashIcon:Cse,SearchX:OL,SearchXIcon:OL,Section:Mse,SectionIcon:Mse,Send:_n,SendHorizonal:BN,SendHorizonalIcon:BN,SendHorizontal:BN,SendHorizontalIcon:BN,SendIcon:_n,SendToBack:Tse,SendToBackIcon:Tse,SeparatorHorizontal:Ase,SeparatorHorizontalIcon:Ase,SeparatorVertical:Ese,SeparatorVerticalIcon:Ese,Server:Dse,ServerCog:Pse,ServerCogIcon:Pse,ServerCrash:Ise,ServerCrashIcon:Ise,ServerIcon:Dse,ServerOff:Lse,ServerOffIcon:Lse,Settings:So,Settings2:FL,Settings2Icon:FL,SettingsIcon:So,Shapes:Rse,ShapesIcon:Rse,Share:zL,Share2:id,Share2Icon:id,ShareIcon:zL,Sheet:Ose,SheetIcon:Ose,Shell:Fse,ShellIcon:Fse,Shield:zu,ShieldAlert:zse,ShieldAlertIcon:zse,ShieldBan:Bse,ShieldBanIcon:Bse,ShieldCheck:t1,ShieldCheckIcon:t1,ShieldClose:$N,ShieldCloseIcon:$N,ShieldEllipsis:$se,ShieldEllipsisIcon:$se,ShieldHalf:qse,ShieldHalfIcon:qse,ShieldIcon:zu,ShieldMinus:Use,ShieldMinusIcon:Use,ShieldOff:gS,ShieldOffIcon:gS,ShieldPlus:Vse,ShieldPlusIcon:Vse,ShieldQuestion:Hse,ShieldQuestionIcon:Hse,ShieldX:$N,ShieldXIcon:$N,Ship:Wse,ShipIcon:Wse,ShipWheel:Gse,ShipWheelIcon:Gse,Shirt:Kse,ShirtIcon:Kse,ShoppingBag:s0,ShoppingBagIcon:s0,ShoppingBasket:Zse,ShoppingBasketIcon:Zse,ShoppingCart:lp,ShoppingCartIcon:lp,Shovel:Yse,ShovelIcon:Yse,ShowerHead:Xse,ShowerHeadIcon:Xse,Shrink:Qse,ShrinkIcon:Qse,Shrub:Jse,ShrubIcon:Jse,Shuffle:yS,ShuffleIcon:yS,Sidebar:EN,SidebarClose:MN,SidebarCloseIcon:MN,SidebarIcon:EN,SidebarOpen:AN,SidebarOpenIcon:AN,Sigma:ere,SigmaIcon:ere,SigmaSquare:Pk,SigmaSquareIcon:Pk,Signal:are,SignalHigh:tre,SignalHighIcon:tre,SignalIcon:are,SignalLow:sre,SignalLowIcon:sre,SignalMedium:rre,SignalMediumIcon:rre,SignalZero:nre,SignalZeroIcon:nre,Signature:ire,SignatureIcon:ire,Signpost:lre,SignpostBig:ore,SignpostBigIcon:ore,SignpostIcon:lre,Siren:cre,SirenIcon:cre,SkipBack:dre,SkipBackIcon:dre,SkipForward:ure,SkipForwardIcon:ure,Skull:hre,SkullIcon:hre,Slack:mre,SlackIcon:mre,Slash:pre,SlashIcon:pre,SlashSquare:Ik,SlashSquareIcon:Ik,Slice:fre,SliceIcon:fre,Sliders:qN,SlidersHorizontal:vS,SlidersHorizontalIcon:vS,SlidersIcon:qN,SlidersVertical:qN,SlidersVerticalIcon:qN,Smartphone:Ig,SmartphoneCharging:xre,SmartphoneChargingIcon:xre,SmartphoneIcon:Ig,SmartphoneNfc:gre,SmartphoneNfcIcon:gre,Smile:vre,SmileIcon:vre,SmilePlus:yre,SmilePlusIcon:yre,Snail:_re,SnailIcon:_re,Snowflake:qy,SnowflakeIcon:qy,Sofa:bre,SofaIcon:bre,SortAsc:J2,SortAscIcon:J2,SortDesc:Y2,SortDescIcon:Y2,Soup:wre,SoupIcon:wre,Space:jre,SpaceIcon:jre,Spade:Nre,SpadeIcon:Nre,Sparkle:kre,SparkleIcon:kre,Sparkles:Or,SparklesIcon:Or,Speaker:Sre,SpeakerIcon:Sre,Speech:Cre,SpeechIcon:Cre,SpellCheck:Tre,SpellCheck2:Mre,SpellCheck2Icon:Mre,SpellCheckIcon:Tre,Spline:Are,SplineIcon:Are,Split:Ere,SplitIcon:Ere,SplitSquareHorizontal:Lk,SplitSquareHorizontalIcon:Lk,SplitSquareVertical:Dk,SplitSquareVerticalIcon:Dk,SprayCan:Pre,SprayCanIcon:Pre,Sprout:_S,SproutIcon:_S,Square:r0,SquareActivity:UN,SquareActivityIcon:UN,SquareArrowDown:GN,SquareArrowDownIcon:GN,SquareArrowDownLeft:VN,SquareArrowDownLeftIcon:VN,SquareArrowDownRight:HN,SquareArrowDownRightIcon:HN,SquareArrowLeft:WN,SquareArrowLeftIcon:WN,SquareArrowOutDownLeft:KN,SquareArrowOutDownLeftIcon:KN,SquareArrowOutDownRight:ZN,SquareArrowOutDownRightIcon:ZN,SquareArrowOutUpLeft:YN,SquareArrowOutUpLeftIcon:YN,SquareArrowOutUpRight:XN,SquareArrowOutUpRightIcon:XN,SquareArrowRight:QN,SquareArrowRightIcon:QN,SquareArrowUp:tk,SquareArrowUpIcon:tk,SquareArrowUpLeft:JN,SquareArrowUpLeftIcon:JN,SquareArrowUpRight:ek,SquareArrowUpRightIcon:ek,SquareAsterisk:sk,SquareAsteriskIcon:sk,SquareBottomDashedScissors:rk,SquareBottomDashedScissorsIcon:rk,SquareChartGantt:ky,SquareChartGanttIcon:ky,SquareCheck:nk,SquareCheckBig:Pv,SquareCheckBigIcon:Pv,SquareCheckIcon:nk,SquareChevronDown:ak,SquareChevronDownIcon:ak,SquareChevronLeft:ik,SquareChevronLeftIcon:ik,SquareChevronRight:ok,SquareChevronRightIcon:ok,SquareChevronUp:lk,SquareChevronUpIcon:lk,SquareCode:ck,SquareCodeIcon:ck,SquareDashed:hk,SquareDashedBottom:Lre,SquareDashedBottomCode:Ire,SquareDashedBottomCodeIcon:Ire,SquareDashedBottomIcon:Lre,SquareDashedIcon:hk,SquareDashedKanban:dk,SquareDashedKanbanIcon:dk,SquareDashedMousePointer:uk,SquareDashedMousePointerIcon:uk,SquareDivide:mk,SquareDivideIcon:mk,SquareDot:pk,SquareDotIcon:pk,SquareEqual:fk,SquareEqualIcon:fk,SquareFunction:xk,SquareFunctionIcon:xk,SquareGanttChart:ky,SquareGanttChartIcon:ky,SquareIcon:r0,SquareKanban:gk,SquareKanbanIcon:gk,SquareLibrary:yk,SquareLibraryIcon:yk,SquareM:vk,SquareMIcon:vk,SquareMenu:_k,SquareMenuIcon:_k,SquareMinus:bk,SquareMinusIcon:bk,SquareMousePointer:wk,SquareMousePointerIcon:wk,SquareParking:Nk,SquareParkingIcon:Nk,SquareParkingOff:jk,SquareParkingOffIcon:jk,SquarePen:Wc,SquarePenIcon:Wc,SquarePercent:kk,SquarePercentIcon:kk,SquarePi:Sk,SquarePiIcon:Sk,SquarePilcrow:Ck,SquarePilcrowIcon:Ck,SquarePlay:Mk,SquarePlayIcon:Mk,SquarePlus:Tk,SquarePlusIcon:Tk,SquarePower:Ak,SquarePowerIcon:Ak,SquareRadical:Dre,SquareRadicalIcon:Dre,SquareScissors:Ek,SquareScissorsIcon:Ek,SquareSigma:Pk,SquareSigmaIcon:Pk,SquareSlash:Ik,SquareSlashIcon:Ik,SquareSplitHorizontal:Lk,SquareSplitHorizontalIcon:Lk,SquareSplitVertical:Dk,SquareSplitVerticalIcon:Dk,SquareSquare:Rre,SquareSquareIcon:Rre,SquareStack:Ore,SquareStackIcon:Ore,SquareTerminal:Rk,SquareTerminalIcon:Rk,SquareUser:Fk,SquareUserIcon:Fk,SquareUserRound:Ok,SquareUserRoundIcon:Ok,SquareX:zk,SquareXIcon:zk,Squircle:Fre,SquircleIcon:Fre,Squirrel:zre,SquirrelIcon:zre,Stamp:Bre,StampIcon:Bre,Star:Gn,StarHalf:$re,StarHalfIcon:$re,StarIcon:Gn,StarOff:qre,StarOffIcon:qre,Stars:Or,StarsIcon:Or,StepBack:Ure,StepBackIcon:Ure,StepForward:Vre,StepForwardIcon:Vre,Stethoscope:Hre,StethoscopeIcon:Hre,Sticker:Gre,StickerIcon:Gre,StickyNote:Wre,StickyNoteIcon:Wre,StopCircle:qj,StopCircleIcon:qj,Store:Kre,StoreIcon:Kre,StretchHorizontal:Zre,StretchHorizontalIcon:Zre,StretchVertical:Yre,StretchVerticalIcon:Yre,Strikethrough:BL,StrikethroughIcon:BL,Subscript:Xre,SubscriptIcon:Xre,Subtitles:oj,SubtitlesIcon:oj,Sun:s1,SunDim:Qre,SunDimIcon:Qre,SunIcon:s1,SunMedium:Jre,SunMediumIcon:Jre,SunMoon:ene,SunMoonIcon:ene,SunSnow:tne,SunSnowIcon:tne,Sunrise:sne,SunriseIcon:sne,Sunset:rne,SunsetIcon:rne,Superscript:nne,SuperscriptIcon:nne,SwatchBook:ane,SwatchBookIcon:ane,SwissFranc:ine,SwissFrancIcon:ine,SwitchCamera:one,SwitchCameraIcon:one,Sword:lne,SwordIcon:lne,Swords:cne,SwordsIcon:cne,Syringe:dne,SyringeIcon:dne,Table:OM,Table2:RM,Table2Icon:RM,TableCellsMerge:une,TableCellsMergeIcon:une,TableCellsSplit:hne,TableCellsSplitIcon:hne,TableColumnsSplit:mne,TableColumnsSplitIcon:mne,TableIcon:OM,TableOfContents:pne,TableOfContentsIcon:pne,TableProperties:fne,TablePropertiesIcon:fne,TableRowsSplit:xne,TableRowsSplitIcon:xne,Tablet:yne,TabletIcon:yne,TabletSmartphone:gne,TabletSmartphoneIcon:gne,Tablets:vne,TabletsIcon:vne,Tag:mh,TagIcon:mh,Tags:_ne,TagsIcon:_ne,Tally1:bne,Tally1Icon:bne,Tally2:wne,Tally2Icon:wne,Tally3:jne,Tally3Icon:jne,Tally4:Nne,Tally4Icon:Nne,Tally5:kne,Tally5Icon:kne,Tangent:Sne,TangentIcon:Sne,Target:Rh,TargetIcon:Rh,Telescope:Cne,TelescopeIcon:Cne,Tent:Tne,TentIcon:Tne,TentTree:Mne,TentTreeIcon:Mne,Terminal:Ane,TerminalIcon:Ane,TerminalSquare:Rk,TerminalSquareIcon:Rk,TestTube:Ene,TestTube2:Bk,TestTube2Icon:Bk,TestTubeDiagonal:Bk,TestTubeDiagonalIcon:Bk,TestTubeIcon:Ene,TestTubes:Pne,TestTubesIcon:Pne,Text:One,TextCursor:Lne,TextCursorIcon:Lne,TextCursorInput:Ine,TextCursorInputIcon:Ine,TextIcon:One,TextQuote:Dne,TextQuoteIcon:Dne,TextSearch:Rne,TextSearchIcon:Rne,TextSelect:$k,TextSelectIcon:$k,TextSelection:$k,TextSelectionIcon:$k,Theater:Fne,TheaterIcon:Fne,Thermometer:$ne,ThermometerIcon:$ne,ThermometerSnowflake:zne,ThermometerSnowflakeIcon:zne,ThermometerSun:Bne,ThermometerSunIcon:Bne,ThumbsDown:$L,ThumbsDownIcon:$L,ThumbsUp:Bu,ThumbsUpIcon:Bu,Ticket:qL,TicketCheck:qne,TicketCheckIcon:qne,TicketIcon:qL,TicketMinus:Une,TicketMinusIcon:Une,TicketPercent:Vne,TicketPercentIcon:Vne,TicketPlus:Hne,TicketPlusIcon:Hne,TicketSlash:Gne,TicketSlashIcon:Gne,TicketX:Wne,TicketXIcon:Wne,Tickets:Zne,TicketsIcon:Zne,TicketsPlane:Kne,TicketsPlaneIcon:Kne,Timer:Qne,TimerIcon:Qne,TimerOff:Yne,TimerOffIcon:Yne,TimerReset:Xne,TimerResetIcon:Xne,ToggleLeft:Jne,ToggleLeftIcon:Jne,ToggleRight:eae,ToggleRightIcon:eae,Toilet:tae,ToiletIcon:tae,Tornado:sae,TornadoIcon:sae,Torus:rae,TorusIcon:rae,Touchpad:aae,TouchpadIcon:aae,TouchpadOff:nae,TouchpadOffIcon:nae,TowerControl:iae,TowerControlIcon:iae,ToyBrick:oae,ToyBrickIcon:oae,Tractor:lae,TractorIcon:lae,TrafficCone:cae,TrafficConeIcon:cae,Train:qk,TrainFront:uae,TrainFrontIcon:uae,TrainFrontTunnel:dae,TrainFrontTunnelIcon:dae,TrainIcon:qk,TrainTrack:hae,TrainTrackIcon:hae,TramFront:qk,TramFrontIcon:qk,Trash:mae,Trash2:vr,Trash2Icon:vr,TrashIcon:mae,TreeDeciduous:pae,TreeDeciduousIcon:pae,TreePalm:Uk,TreePalmIcon:Uk,TreePine:Ab,TreePineIcon:Ab,Trees:fae,TreesIcon:fae,Trello:xae,TrelloIcon:xae,TrendingDown:bS,TrendingDownIcon:bS,TrendingUp:Qo,TrendingUpDown:gae,TrendingUpDownIcon:gae,TrendingUpIcon:Qo,Triangle:vae,TriangleAlert:Dc,TriangleAlertIcon:Dc,TriangleIcon:vae,TriangleRight:yae,TriangleRightIcon:yae,Trophy:Fi,TrophyIcon:Fi,Truck:UL,TruckIcon:UL,Turtle:_ae,TurtleIcon:_ae,Tv:wae,Tv2:Vk,Tv2Icon:Vk,TvIcon:wae,TvMinimal:Vk,TvMinimalIcon:Vk,TvMinimalPlay:bae,TvMinimalPlayIcon:bae,Twitch:jae,TwitchIcon:jae,Twitter:Nae,TwitterIcon:Nae,Type:Sae,TypeIcon:Sae,TypeOutline:kae,TypeOutlineIcon:kae,Umbrella:Mae,UmbrellaIcon:Mae,UmbrellaOff:Cae,UmbrellaOffIcon:Cae,Underline:VL,UnderlineIcon:VL,Undo:wS,Undo2:Tae,Undo2Icon:Tae,UndoDot:Aae,UndoDotIcon:Aae,UndoIcon:wS,UnfoldHorizontal:Eae,UnfoldHorizontalIcon:Eae,UnfoldVertical:Pae,UnfoldVerticalIcon:Pae,Ungroup:Iae,UngroupIcon:Iae,University:Hk,UniversityIcon:Hk,Unlink:jS,Unlink2:Lae,Unlink2Icon:Lae,UnlinkIcon:jS,Unlock:bN,UnlockIcon:bN,UnlockKeyhole:_N,UnlockKeyholeIcon:_N,Unplug:Dae,UnplugIcon:Dae,Upload:Ra,UploadCloud:Kj,UploadCloudIcon:Kj,UploadIcon:Ra,Usb:Rae,UsbIcon:Rae,User:Ai,User2:Xk,User2Icon:Xk,UserCheck:n0,UserCheck2:Gk,UserCheck2Icon:Gk,UserCheckIcon:n0,UserCircle:Vj,UserCircle2:Uj,UserCircle2Icon:Uj,UserCircleIcon:Vj,UserCog:HL,UserCog2:Wk,UserCog2Icon:Wk,UserCogIcon:HL,UserIcon:Ai,UserMinus:GL,UserMinus2:Kk,UserMinus2Icon:Kk,UserMinusIcon:GL,UserPen:Oae,UserPenIcon:Oae,UserPlus:Jo,UserPlus2:Zk,UserPlus2Icon:Zk,UserPlusIcon:Jo,UserRound:Xk,UserRoundCheck:Gk,UserRoundCheckIcon:Gk,UserRoundCog:Wk,UserRoundCogIcon:Wk,UserRoundIcon:Xk,UserRoundMinus:Kk,UserRoundMinusIcon:Kk,UserRoundPen:Fae,UserRoundPenIcon:Fae,UserRoundPlus:Zk,UserRoundPlusIcon:Zk,UserRoundSearch:zae,UserRoundSearchIcon:zae,UserRoundX:Yk,UserRoundXIcon:Yk,UserSearch:Bae,UserSearchIcon:Bae,UserSquare:Fk,UserSquare2:Ok,UserSquare2Icon:Ok,UserSquareIcon:Fk,UserX:$ae,UserX2:Yk,UserX2Icon:Yk,UserXIcon:$ae,Users:ir,Users2:Qk,Users2Icon:Qk,UsersIcon:ir,UsersRound:Qk,UsersRoundIcon:Qk,Utensils:e4,UtensilsCrossed:Jk,UtensilsCrossedIcon:Jk,UtensilsIcon:e4,UtilityPole:qae,UtilityPoleIcon:qae,Variable:FM,VariableIcon:FM,Vault:Uae,VaultIcon:Uae,Vegan:Vae,VeganIcon:Vae,VenetianMask:Hae,VenetianMaskIcon:Hae,Verified:sj,VerifiedIcon:sj,Vibrate:Wae,VibrateIcon:Wae,VibrateOff:Gae,VibrateOffIcon:Gae,Video:yn,VideoIcon:yn,VideoOff:Kae,VideoOffIcon:Kae,Videotape:Zae,VideotapeIcon:Zae,View:Yae,ViewIcon:Yae,Voicemail:Xae,VoicemailIcon:Xae,Volleyball:Qae,VolleyballIcon:Qae,Volume:rie,Volume1:Jae,Volume1Icon:Jae,Volume2:eie,Volume2Icon:eie,VolumeIcon:rie,VolumeOff:tie,VolumeOffIcon:tie,VolumeX:sie,VolumeXIcon:sie,Vote:nie,VoteIcon:nie,Wallet:WL,Wallet2:t4,Wallet2Icon:t4,WalletCards:aie,WalletCardsIcon:aie,WalletIcon:WL,WalletMinimal:t4,WalletMinimalIcon:t4,Wallpaper:iie,WallpaperIcon:iie,Wand:oie,Wand2:Iv,Wand2Icon:Iv,WandIcon:oie,WandSparkles:Iv,WandSparklesIcon:Iv,Warehouse:lie,WarehouseIcon:lie,WashingMachine:cie,WashingMachineIcon:cie,Watch:die,WatchIcon:die,Waves:uie,WavesIcon:uie,Waypoints:hie,WaypointsIcon:hie,Webcam:mie,WebcamIcon:mie,Webhook:fie,WebhookIcon:fie,WebhookOff:pie,WebhookOffIcon:pie,Weight:xie,WeightIcon:xie,Wheat:yie,WheatIcon:yie,WheatOff:gie,WheatOffIcon:gie,WholeWord:vie,WholeWordIcon:vie,Wifi:Nie,WifiHigh:_ie,WifiHighIcon:_ie,WifiIcon:Nie,WifiLow:bie,WifiLowIcon:bie,WifiOff:wie,WifiOffIcon:wie,WifiZero:jie,WifiZeroIcon:jie,Wind:Sie,WindArrowDown:kie,WindArrowDownIcon:kie,WindIcon:Sie,Wine:Mie,WineIcon:Mie,WineOff:Cie,WineOffIcon:Cie,Workflow:Tie,WorkflowIcon:Tie,Worm:Aie,WormIcon:Aie,WrapText:Eie,WrapTextIcon:Eie,Wrench:Lg,WrenchIcon:Lg,X:kr,XCircle:Jl,XCircleIcon:Jl,XIcon:kr,XOctagon:kN,XOctagonIcon:kN,XSquare:zk,XSquareIcon:zk,Youtube:Pie,YoutubeIcon:Pie,Zap:Oh,ZapIcon:Oh,ZapOff:Iie,ZapOffIcon:Iie,ZoomIn:Eb,ZoomInIcon:Eb,ZoomOut:zM,ZoomOutIcon:zM,createLucideIcon:Z,icons:bgt},Symbol.toStringTag,{value:"Module"})),oje="-",wgt=t=>{const s=Ngt(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:l=>{const i=l.split(oje);return i[0]===""&&i.length!==1&&i.shift(),aUe(i,s)||jgt(l)},getConflictingClassGroupIds:(l,i)=>{const d=r[l]||[];return i&&n[l]?[...d,...n[l]]:d}}},aUe=(t,s)=>{var l;if(t.length===0)return s.classGroupId;const r=t[0],n=s.nextPart.get(r),a=n?aUe(t.slice(1),n):void 0;if(a)return a;if(s.validators.length===0)return;const o=t.join(oje);return(l=s.validators.find(({validator:i})=>i(o)))==null?void 0:l.classGroupId},MEe=/^\[(.+)\]$/,jgt=t=>{if(MEe.test(t)){const s=MEe.exec(t)[1],r=s==null?void 0:s.substring(0,s.indexOf(":"));if(r)return"arbitrary.."+r}},Ngt=t=>{const{theme:s,prefix:r}=t,n={nextPart:new Map,validators:[]};return Sgt(Object.entries(t.classGroups),r).forEach(([o,l])=>{Cve(l,n,o,s)}),n},Cve=(t,s,r,n)=>{t.forEach(a=>{if(typeof a=="string"){const o=a===""?s:TEe(s,a);o.classGroupId=r;return}if(typeof a=="function"){if(kgt(a)){Cve(a(n),s,r,n);return}s.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([o,l])=>{Cve(l,TEe(s,o),r,n)})})},TEe=(t,s)=>{let r=t;return s.split(oje).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},kgt=t=>t.isThemeGetter,Sgt=(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,Cgt=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)}}},iUe="!",Mgt=t=>{const{separator:s,experimentalParseClassName:r}=t,n=s.length===1,a=s[0],o=s.length,l=i=>{const d=[];let u=0,p=0,f;for(let w=0;wp?f-p:void 0;return{modifiers:d,hasImportantModifier:_,baseClassName:b,maybePostfixModifierPosition:N}};return r?i=>r({className:i,parseClassName:l}):l},Tgt=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},Agt=t=>({cache:Cgt(t.cacheSize),parseClassName:Mgt(t),...wgt(t)}),Egt=/\s+/,Pgt=(t,s)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a}=s,o=[],l=t.trim().split(Egt);let i="";for(let d=l.length-1;d>=0;d-=1){const u=l[d],{modifiers:p,hasImportantModifier:f,baseClassName:y,maybePostfixModifierPosition:_}=r(u);let b=!!_,N=n(b?y.substring(0,_):y);if(!N){if(!b){i=u+(i.length>0?" "+i:i);continue}if(N=n(y),!N){i=u+(i.length>0?" "+i:i);continue}b=!1}const w=Tgt(p).join(":"),S=f?w+iUe:w,C=S+N;if(o.includes(C))continue;o.push(C);const A=a(N,b);for(let I=0;I0?" "+i:i)}return i};function Igt(){let t=0,s,r,n="";for(;t{if(typeof t=="string")return t;let s,r="";for(let n=0;nf(p),t());return r=Agt(u),n=r.cache.get,a=r.cache.set,o=i,i(d)}function i(d){const u=n(d);if(u)return u;const p=Pgt(d,r);return a(d,p),p}return function(){return o(Igt.apply(null,arguments))}}const Gl=t=>{const s=r=>r[t]||[];return s.isThemeGetter=!0,s},lUe=/^\[(?:([a-z-]+):)?(.+)\]$/i,Dgt=/^\d+\/\d+$/,Rgt=new Set(["px","full","screen"]),Ogt=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Fgt=/\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$/,zgt=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,Bgt=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,$gt=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,hv=t=>BM(t)||Rgt.has(t)||Dgt.test(t),p_=t=>LA(t,"length",Zgt),BM=t=>!!t&&!Number.isNaN(Number(t)),Kxe=t=>LA(t,"number",BM),W6=t=>!!t&&Number.isInteger(Number(t)),qgt=t=>t.endsWith("%")&&BM(t.slice(0,-1)),Mi=t=>lUe.test(t),f_=t=>Ogt.test(t),Ugt=new Set(["length","size","percentage"]),Vgt=t=>LA(t,Ugt,cUe),Hgt=t=>LA(t,"position",cUe),Ggt=new Set(["image","url"]),Wgt=t=>LA(t,Ggt,Xgt),Kgt=t=>LA(t,"",Ygt),K6=()=>!0,LA=(t,s,r)=>{const n=lUe.exec(t);return n?n[1]?typeof s=="string"?n[1]===s:s.has(n[1]):r(n[2]):!1},Zgt=t=>Fgt.test(t)&&!zgt.test(t),cUe=()=>!1,Ygt=t=>Bgt.test(t),Xgt=t=>$gt.test(t),Qgt=()=>{const t=Gl("colors"),s=Gl("spacing"),r=Gl("blur"),n=Gl("brightness"),a=Gl("borderColor"),o=Gl("borderRadius"),l=Gl("borderSpacing"),i=Gl("borderWidth"),d=Gl("contrast"),u=Gl("grayscale"),p=Gl("hueRotate"),f=Gl("invert"),y=Gl("gap"),_=Gl("gradientColorStops"),b=Gl("gradientColorStopPositions"),N=Gl("inset"),w=Gl("margin"),S=Gl("opacity"),C=Gl("padding"),A=Gl("saturate"),I=Gl("scale"),L=Gl("sepia"),O=Gl("skew"),V=Gl("space"),q=Gl("translate"),B=()=>["auto","contain","none"],U=()=>["auto","hidden","clip","visible","scroll"],te=()=>["auto",Mi,s],Y=()=>[Mi,s],J=()=>["",hv,p_],X=()=>["auto",BM,Mi],ce=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ie=()=>["solid","dashed","dotted","double","none"],ae=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],oe=()=>["start","end","center","between","around","evenly","stretch"],me=()=>["","0",Mi],ve=()=>["auto","avoid","all","avoid-page","page","left","right","column"],he=()=>[BM,Mi];return{cacheSize:500,separator:":",theme:{colors:[K6],spacing:[hv,p_],blur:["none","",f_,Mi],brightness:he(),borderColor:[t],borderRadius:["none","","full",f_,Mi],borderSpacing:Y(),borderWidth:J(),contrast:he(),grayscale:me(),hueRotate:he(),invert:me(),gap:Y(),gradientColorStops:[t],gradientColorStopPositions:[qgt,p_],inset:te(),margin:te(),opacity:he(),padding:Y(),saturate:he(),scale:he(),sepia:me(),skew:he(),space:Y(),translate:Y()},classGroups:{aspect:[{aspect:["auto","square","video",Mi]}],container:["container"],columns:[{columns:[f_]}],"break-after":[{"break-after":ve()}],"break-before":[{"break-before":ve()}],"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(),Mi]}],overflow:[{overflow:U()}],"overflow-x":[{"overflow-x":U()}],"overflow-y":[{"overflow-y":U()}],overscroll:[{overscroll:B()}],"overscroll-x":[{"overscroll-x":B()}],"overscroll-y":[{"overscroll-y":B()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[N]}],"inset-x":[{"inset-x":[N]}],"inset-y":[{"inset-y":[N]}],start:[{start:[N]}],end:[{end:[N]}],top:[{top:[N]}],right:[{right:[N]}],bottom:[{bottom:[N]}],left:[{left:[N]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",W6,Mi]}],basis:[{basis:te()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Mi]}],grow:[{grow:me()}],shrink:[{shrink:me()}],order:[{order:["first","last","none",W6,Mi]}],"grid-cols":[{"grid-cols":[K6]}],"col-start-end":[{col:["auto",{span:["full",W6,Mi]},Mi]}],"col-start":[{"col-start":X()}],"col-end":[{"col-end":X()}],"grid-rows":[{"grid-rows":[K6]}],"row-start-end":[{row:["auto",{span:[W6,Mi]},Mi]}],"row-start":[{"row-start":X()}],"row-end":[{"row-end":X()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Mi]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Mi]}],gap:[{gap:[y]}],"gap-x":[{"gap-x":[y]}],"gap-y":[{"gap-y":[y]}],"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:[C]}],px:[{px:[C]}],py:[{py:[C]}],ps:[{ps:[C]}],pe:[{pe:[C]}],pt:[{pt:[C]}],pr:[{pr:[C]}],pb:[{pb:[C]}],pl:[{pl:[C]}],m:[{m:[w]}],mx:[{mx:[w]}],my:[{my:[w]}],ms:[{ms:[w]}],me:[{me:[w]}],mt:[{mt:[w]}],mr:[{mr:[w]}],mb:[{mb:[w]}],ml:[{ml:[w]}],"space-x":[{"space-x":[V]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[V]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Mi,s]}],"min-w":[{"min-w":[Mi,s,"min","max","fit"]}],"max-w":[{"max-w":[Mi,s,"none","full","min","max","fit","prose",{screen:[f_]},f_]}],h:[{h:[Mi,s,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Mi,s,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Mi,s,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Mi,s,"auto","min","max","fit"]}],"font-size":[{text:["base",f_,p_]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Kxe]}],"font-family":[{font:[K6]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",Mi]}],"line-clamp":[{"line-clamp":["none",BM,Kxe]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",hv,Mi]}],"list-image":[{"list-image":["none",Mi]}],"list-style-type":[{list:["none","disc","decimal",Mi]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[S]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[S]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ie(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",hv,p_]}],"underline-offset":[{"underline-offset":["auto",hv,Mi]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:Y()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Mi]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Mi]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[S]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...ce(),Hgt]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Vgt]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Wgt]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[b]}],"gradient-via-pos":[{via:[b]}],"gradient-to-pos":[{to:[b]}],"gradient-from":[{from:[_]}],"gradient-via":[{via:[_]}],"gradient-to":[{to:[_]}],rounded:[{rounded:[o]}],"rounded-s":[{"rounded-s":[o]}],"rounded-e":[{"rounded-e":[o]}],"rounded-t":[{"rounded-t":[o]}],"rounded-r":[{"rounded-r":[o]}],"rounded-b":[{"rounded-b":[o]}],"rounded-l":[{"rounded-l":[o]}],"rounded-ss":[{"rounded-ss":[o]}],"rounded-se":[{"rounded-se":[o]}],"rounded-ee":[{"rounded-ee":[o]}],"rounded-es":[{"rounded-es":[o]}],"rounded-tl":[{"rounded-tl":[o]}],"rounded-tr":[{"rounded-tr":[o]}],"rounded-br":[{"rounded-br":[o]}],"rounded-bl":[{"rounded-bl":[o]}],"border-w":[{border:[i]}],"border-w-x":[{"border-x":[i]}],"border-w-y":[{"border-y":[i]}],"border-w-s":[{"border-s":[i]}],"border-w-e":[{"border-e":[i]}],"border-w-t":[{"border-t":[i]}],"border-w-r":[{"border-r":[i]}],"border-w-b":[{"border-b":[i]}],"border-w-l":[{"border-l":[i]}],"border-opacity":[{"border-opacity":[S]}],"border-style":[{border:[...ie(),"hidden"]}],"divide-x":[{"divide-x":[i]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[i]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[S]}],"divide-style":[{divide:ie()}],"border-color":[{border:[a]}],"border-color-x":[{"border-x":[a]}],"border-color-y":[{"border-y":[a]}],"border-color-s":[{"border-s":[a]}],"border-color-e":[{"border-e":[a]}],"border-color-t":[{"border-t":[a]}],"border-color-r":[{"border-r":[a]}],"border-color-b":[{"border-b":[a]}],"border-color-l":[{"border-l":[a]}],"divide-color":[{divide:[a]}],"outline-style":[{outline:["",...ie()]}],"outline-offset":[{"outline-offset":[hv,Mi]}],"outline-w":[{outline:[hv,p_]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:J()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[S]}],"ring-offset-w":[{"ring-offset":[hv,p_]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",f_,Kgt]}],"shadow-color":[{shadow:[K6]}],opacity:[{opacity:[S]}],"mix-blend":[{"mix-blend":[...ae(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":ae()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[d]}],"drop-shadow":[{"drop-shadow":["","none",f_,Mi]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[p]}],invert:[{invert:[f]}],saturate:[{saturate:[A]}],sepia:[{sepia:[L]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[d]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[p]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[S]}],"backdrop-saturate":[{"backdrop-saturate":[A]}],"backdrop-sepia":[{"backdrop-sepia":[L]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[l]}],"border-spacing-x":[{"border-spacing-x":[l]}],"border-spacing-y":[{"border-spacing-y":[l]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Mi]}],duration:[{duration:he()}],ease:[{ease:["linear","in","out","in-out",Mi]}],delay:[{delay:he()}],animate:[{animate:["none","spin","ping","pulse","bounce",Mi]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[I]}],"scale-x":[{"scale-x":[I]}],"scale-y":[{"scale-y":[I]}],rotate:[{rotate:[W6,Mi]}],"translate-x":[{"translate-x":[q]}],"translate-y":[{"translate-y":[q]}],"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",Mi]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Mi]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":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",Mi]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[hv,p_,Kxe]}],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"]}}},Jgt=Lgt(Qgt);function Ot(...t){return Jgt(bi(t))}function Il(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 AEe(t){const s=new Date(t);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(s)}function Qde(t){return t?t.replace(/<[^>]*>/g,""):""}const eyt=ygt,dUe=k.forwardRef(({className:t,...s},r)=>e.jsx(Yqe,{ref:r,className:Ot("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}));dUe.displayName=Yqe.displayName;const tyt=bC("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"}}),uUe=k.forwardRef(({className:t,variant:s,...r},n)=>e.jsx(Xqe,{ref:n,className:Ot(tyt({variant:s}),t),...r}));uUe.displayName=Xqe.displayName;const syt=k.forwardRef(({className:t,...s},r)=>e.jsx(eUe,{ref:r,className:Ot("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}));syt.displayName=eUe.displayName;const hUe=k.forwardRef(({className:t,...s},r)=>e.jsx(tUe,{ref:r,className:Ot("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(kr,{className:"h-4 w-4"})}));hUe.displayName=tUe.displayName;const mUe=k.forwardRef(({className:t,...s},r)=>e.jsx(Qqe,{ref:r,className:Ot("text-sm font-semibold",t),...s}));mUe.displayName=Qqe.displayName;const pUe=k.forwardRef(({className:t,...s},r)=>e.jsx(Jqe,{ref:r,className:Ot("text-sm opacity-90",t),...s}));pUe.displayName=Jqe.displayName;function ryt(){const{toasts:t}=ja();return e.jsxs(eyt,{children:[t.map(function({id:s,title:r,description:n,action:a,...o}){return e.jsxs(uUe,{...o,children:[e.jsxs("div",{className:"grid gap-1",children:[r&&e.jsx(mUe,{children:r}),n&&e.jsx(pUe,{children:n})]}),a,e.jsx(hUe,{})]},s)}),e.jsx(dUe,{})]})}var EEe=["light","dark"],nyt="(prefers-color-scheme: dark)",ayt=k.createContext(void 0),iyt={setTheme:t=>{},themes:[]},oyt=()=>{var t;return(t=k.useContext(ayt))!=null?t:iyt};k.memo(({forcedTheme:t,storageKey:s,attribute:r,enableSystem:n,enableColorScheme:a,defaultTheme:o,value:l,attrs:i,nonce:d})=>{let u=o==="system",p=r==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${i.map(b=>`'${b}'`).join(",")})`};`:`var d=document.documentElement,n='${r}',s='setAttribute';`,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":"",y=(b,N=!1,w=!0)=>{let S=l?l[b]:b,C=N?b+"|| ''":`'${S}'`,A="";return a&&w&&!N&&EEe.includes(b)&&(A+=`d.style.colorScheme = '${b}';`),r==="class"?N||S?A+=`c.add(${C})`:A+="null":S&&(A+=`d[s](n,${C})`),A},_=t?`!function(){${p}${y(t)}}()`:n?`!function(){try{${p}var e=localStorage.getItem('${s}');if('system'===e||(!e&&${u})){var t='${nyt}',m=window.matchMedia(t);if(m.media!==t||m.matches){${y("dark")}}else{${y("light")}}}else if(e){${l?`var x=${JSON.stringify(l)};`:""}${y(l?"x[e]":"e",!0)}}${u?"":"else{"+y(o,!1,!1)+"}"}${f}}catch(e){}}()`:`!function(){try{${p}var e=localStorage.getItem('${s}');if(e){${l?`var x=${JSON.stringify(l)};`:""}${y(l?"x[e]":"e",!0)}}else{${y(o,!1,!1)};}${f}}catch(t){}}();`;return k.createElement("script",{nonce:d,dangerouslySetInnerHTML:{__html:_}})});var lyt=t=>{switch(t){case"success":return uyt;case"info":return myt;case"warning":return hyt;case"error":return pyt;default:return null}},cyt=Array(12).fill(0),dyt=({visible:t,className:s})=>xt.createElement("div",{className:["sonner-loading-wrapper",s].filter(Boolean).join(" "),"data-visible":t},xt.createElement("div",{className:"sonner-spinner"},cyt.map((r,n)=>xt.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),uyt=xt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},xt.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"})),hyt=xt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},xt.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"})),myt=xt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},xt.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"})),pyt=xt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},xt.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"})),fyt=xt.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"},xt.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),xt.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),xyt=()=>{let[t,s]=xt.useState(document.hidden);return xt.useEffect(()=>{let r=()=>{s(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),t},Mve=1,gyt=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:Mve++,l=this.toasts.find(d=>d.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(d=>d.id===o?(this.publish({...d,...s,id:o,title:n}),{...d,...s,id:o,dismissible:i,title:n}):d):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],xt.isValidElement(u))o=!1,this.create({id:n,type:"default",message:u});else if(vyt(u)&&!u.ok){o=!1;let p=typeof r.error=="function"?await r.error(`HTTP error! status: ${u.status}`):r.error,f=typeof r.description=="function"?await r.description(`HTTP error! status: ${u.status}`):r.description;this.create({id:n,type:"error",message:p,description:f})}else if(r.success!==void 0){o=!1;let p=typeof r.success=="function"?await r.success(u):r.success,f=typeof r.description=="function"?await r.description(u):r.description;this.create({id:n,type:"success",message:p,description:f})}}).catch(async u=>{if(l=["reject",u],r.error!==void 0){o=!1;let p=typeof r.error=="function"?await r.error(u):r.error,f=typeof r.description=="function"?await r.description(u):r.description;this.create({id:n,type:"error",message:p,description:f})}}).finally(()=>{var u;o&&(this.dismiss(n),n=void 0),(u=r.finally)==null||u.call(r)}),d=()=>new Promise((u,p)=>i.then(()=>l[0]==="reject"?p(l[1]):u(l[1])).catch(p));return typeof n!="string"&&typeof n!="number"?{unwrap:d}:Object.assign(n,{unwrap:d})},this.custom=(s,r)=>{let n=(r==null?void 0:r.id)||Mve++;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}},ep=new gyt,yyt=(t,s)=>{let r=(s==null?void 0:s.id)||Mve++;return ep.addToast({title:t,...s,id:r}),r},vyt=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",_yt=yyt,byt=()=>ep.toasts,wyt=()=>ep.getActiveToasts(),pe=Object.assign(_yt,{success:ep.success,info:ep.info,warning:ep.warning,error:ep.error,custom:ep.custom,message:ep.message,promise:ep.promise,dismiss:ep.dismiss,loading:ep.loading},{getHistory:byt,getToasts:wyt});function jyt(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))}jyt(`: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 xz(t){return t.label!==void 0}var Nyt=3,kyt="32px",Syt="16px",PEe=4e3,Cyt=356,Myt=14,Tyt=20,Ayt=200;function ig(...t){return t.filter(Boolean).join(" ")}function Eyt(t){let[s,r]=t.split("-"),n=[];return s&&n.push(s),r&&n.push(r),n}var Pyt=t=>{var s,r,n,a,o,l,i,d,u,p,f;let{invert:y,toast:_,unstyled:b,interacting:N,setHeights:w,visibleToasts:S,heights:C,index:A,toasts:I,expanded:L,removeToast:O,defaultRichColors:V,closeButton:q,style:B,cancelButtonStyle:U,actionButtonStyle:te,className:Y="",descriptionClassName:J="",duration:X,position:ce,gap:ie,loadingIcon:ae,expandByDefault:oe,classNames:me,icons:ve,closeButtonAriaLabel:he="Close toast",pauseWhenPageIsHidden:ge}=t,[je,qe]=xt.useState(null),[Me,ke]=xt.useState(null),[Re,Ve]=xt.useState(!1),[Ne,Ue]=xt.useState(!1),[Ie,ye]=xt.useState(!1),[ct,fe]=xt.useState(!1),[$e,Ye]=xt.useState(!1),[tt,Te]=xt.useState(0),[We,Ke]=xt.useState(0),ot=xt.useRef(_.duration||X||PEe),He=xt.useRef(null),Je=xt.useRef(null),ut=A===0,mt=A+1<=S,et=_.type,Ze=_.dismissible!==!1,kt=_.className||"",Ut=_.descriptionClassName||"",Nt=xt.useMemo(()=>C.findIndex(cr=>cr.toastId===_.id)||0,[C,_.id]),es=xt.useMemo(()=>{var cr;return(cr=_.closeButton)!=null?cr:q},[_.closeButton,q]),ds=xt.useMemo(()=>_.duration||X||PEe,[_.duration,X]),js=xt.useRef(0),lr=xt.useRef(0),Lt=xt.useRef(0),Es=xt.useRef(null),[fr,Hs]=ce.split("-"),mr=xt.useMemo(()=>C.reduce((cr,Br,Kr)=>Kr>=Nt?cr:cr+Br.height,0),[C,Nt]),an=xyt(),Cr=_.invert||y,Fr=et==="loading";lr.current=xt.useMemo(()=>Nt*ie+mr,[Nt,mr]),xt.useEffect(()=>{ot.current=ds},[ds]),xt.useEffect(()=>{Ve(!0)},[]),xt.useEffect(()=>{let cr=Je.current;if(cr){let Br=cr.getBoundingClientRect().height;return Ke(Br),w(Kr=>[{toastId:_.id,height:Br,position:_.position},...Kr]),()=>w(Kr=>Kr.filter(Sn=>Sn.toastId!==_.id))}},[w,_.id]),xt.useLayoutEffect(()=>{if(!Re)return;let cr=Je.current,Br=cr.style.height;cr.style.height="auto";let Kr=cr.getBoundingClientRect().height;cr.style.height=Br,Ke(Kr),w(Sn=>Sn.find(ai=>ai.toastId===_.id)?Sn.map(ai=>ai.toastId===_.id?{...ai,height:Kr}:ai):[{toastId:_.id,height:Kr,position:_.position},...Sn])},[Re,_.title,_.description,w,_.id]);let $r=xt.useCallback(()=>{Ue(!0),Te(lr.current),w(cr=>cr.filter(Br=>Br.toastId!==_.id)),setTimeout(()=>{O(_)},Ayt)},[_,O,w,lr]);xt.useEffect(()=>{if(_.promise&&et==="loading"||_.duration===1/0||_.type==="loading")return;let cr;return L||N||ge&&an?(()=>{if(Lt.current{var Br;(Br=_.onAutoClose)==null||Br.call(_,_),$r()},ot.current)),()=>clearTimeout(cr)},[L,N,_,et,ge,an,$r]),xt.useEffect(()=>{_.delete&&$r()},[$r,_.delete]);function nr(){var cr,Br,Kr;return ve!=null&&ve.loading?xt.createElement("div",{className:ig(me==null?void 0:me.loader,(cr=_==null?void 0:_.classNames)==null?void 0:cr.loader,"sonner-loader"),"data-visible":et==="loading"},ve.loading):ae?xt.createElement("div",{className:ig(me==null?void 0:me.loader,(Br=_==null?void 0:_.classNames)==null?void 0:Br.loader,"sonner-loader"),"data-visible":et==="loading"},ae):xt.createElement(dyt,{className:ig(me==null?void 0:me.loader,(Kr=_==null?void 0:_.classNames)==null?void 0:Kr.loader),visible:et==="loading"})}return xt.createElement("li",{tabIndex:0,ref:Je,className:ig(Y,kt,me==null?void 0:me.toast,(s=_==null?void 0:_.classNames)==null?void 0:s.toast,me==null?void 0:me.default,me==null?void 0:me[et],(r=_==null?void 0:_.classNames)==null?void 0:r[et]),"data-sonner-toast":"","data-rich-colors":(n=_.richColors)!=null?n:V,"data-styled":!(_.jsx||_.unstyled||b),"data-mounted":Re,"data-promise":!!_.promise,"data-swiped":$e,"data-removed":Ne,"data-visible":mt,"data-y-position":fr,"data-x-position":Hs,"data-index":A,"data-front":ut,"data-swiping":Ie,"data-dismissible":Ze,"data-type":et,"data-invert":Cr,"data-swipe-out":ct,"data-swipe-direction":Me,"data-expanded":!!(L||oe&&Re),style:{"--index":A,"--toasts-before":A,"--z-index":I.length-A,"--offset":`${Ne?tt:lr.current}px`,"--initial-height":oe?"auto":`${We}px`,...B,..._.style},onDragEnd:()=>{ye(!1),qe(null),Es.current=null},onPointerDown:cr=>{Fr||!Ze||(He.current=new Date,Te(lr.current),cr.target.setPointerCapture(cr.pointerId),cr.target.tagName!=="BUTTON"&&(ye(!0),Es.current={x:cr.clientX,y:cr.clientY}))},onPointerUp:()=>{var cr,Br,Kr,Sn;if(ct||!Ze)return;Es.current=null;let ai=Number(((cr=Je.current)==null?void 0:cr.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),as=Number(((Br=Je.current)==null?void 0:Br.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),qn=new Date().getTime()-((Kr=He.current)==null?void 0:Kr.getTime()),un=je==="x"?ai:as,qr=Math.abs(un)/qn;if(Math.abs(un)>=Tyt||qr>.11){Te(lr.current),(Sn=_.onDismiss)==null||Sn.call(_,_),ke(je==="x"?ai>0?"right":"left":as>0?"down":"up"),$r(),fe(!0),Ye(!1);return}ye(!1),qe(null)},onPointerMove:cr=>{var Br,Kr,Sn,ai;if(!Es.current||!Ze||((Br=window.getSelection())==null?void 0:Br.toString().length)>0)return;let as=cr.clientY-Es.current.y,qn=cr.clientX-Es.current.x,un=(Kr=t.swipeDirections)!=null?Kr:Eyt(ce);!je&&(Math.abs(qn)>1||Math.abs(as)>1)&&qe(Math.abs(qn)>Math.abs(as)?"x":"y");let qr={x:0,y:0};je==="y"?(un.includes("top")||un.includes("bottom"))&&(un.includes("top")&&as<0||un.includes("bottom")&&as>0)&&(qr.y=as):je==="x"&&(un.includes("left")||un.includes("right"))&&(un.includes("left")&&qn<0||un.includes("right")&&qn>0)&&(qr.x=qn),(Math.abs(qr.x)>0||Math.abs(qr.y)>0)&&Ye(!0),(Sn=Je.current)==null||Sn.style.setProperty("--swipe-amount-x",`${qr.x}px`),(ai=Je.current)==null||ai.style.setProperty("--swipe-amount-y",`${qr.y}px`)}},es&&!_.jsx?xt.createElement("button",{"aria-label":he,"data-disabled":Fr,"data-close-button":!0,onClick:Fr||!Ze?()=>{}:()=>{var cr;$r(),(cr=_.onDismiss)==null||cr.call(_,_)},className:ig(me==null?void 0:me.closeButton,(a=_==null?void 0:_.classNames)==null?void 0:a.closeButton)},(o=ve==null?void 0:ve.close)!=null?o:fyt):null,_.jsx||k.isValidElement(_.title)?_.jsx?_.jsx:typeof _.title=="function"?_.title():_.title:xt.createElement(xt.Fragment,null,et||_.icon||_.promise?xt.createElement("div",{"data-icon":"",className:ig(me==null?void 0:me.icon,(l=_==null?void 0:_.classNames)==null?void 0:l.icon)},_.promise||_.type==="loading"&&!_.icon?_.icon||nr():null,_.type!=="loading"?_.icon||(ve==null?void 0:ve[et])||lyt(et):null):null,xt.createElement("div",{"data-content":"",className:ig(me==null?void 0:me.content,(i=_==null?void 0:_.classNames)==null?void 0:i.content)},xt.createElement("div",{"data-title":"",className:ig(me==null?void 0:me.title,(d=_==null?void 0:_.classNames)==null?void 0:d.title)},typeof _.title=="function"?_.title():_.title),_.description?xt.createElement("div",{"data-description":"",className:ig(J,Ut,me==null?void 0:me.description,(u=_==null?void 0:_.classNames)==null?void 0:u.description)},typeof _.description=="function"?_.description():_.description):null),k.isValidElement(_.cancel)?_.cancel:_.cancel&&xz(_.cancel)?xt.createElement("button",{"data-button":!0,"data-cancel":!0,style:_.cancelButtonStyle||U,onClick:cr=>{var Br,Kr;xz(_.cancel)&&Ze&&((Kr=(Br=_.cancel).onClick)==null||Kr.call(Br,cr),$r())},className:ig(me==null?void 0:me.cancelButton,(p=_==null?void 0:_.classNames)==null?void 0:p.cancelButton)},_.cancel.label):null,k.isValidElement(_.action)?_.action:_.action&&xz(_.action)?xt.createElement("button",{"data-button":!0,"data-action":!0,style:_.actionButtonStyle||te,onClick:cr=>{var Br,Kr;xz(_.action)&&((Kr=(Br=_.action).onClick)==null||Kr.call(Br,cr),!cr.defaultPrevented&&$r())},className:ig(me==null?void 0:me.actionButton,(f=_==null?void 0:_.classNames)==null?void 0:f.actionButton)},_.action.label):null))};function IEe(){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 Iyt(t,s){let r={};return[t,s].forEach((n,a)=>{let o=a===1,l=o?"--mobile-offset":"--offset",i=o?Syt:kyt;function d(u){["top","right","bottom","left"].forEach(p=>{r[`${l}-${p}`]=typeof u=="number"?`${u}px`:u})}typeof n=="number"||typeof n=="string"?d(n):typeof n=="object"?["top","right","bottom","left"].forEach(u=>{n[u]===void 0?r[`${l}-${u}`]=i:r[`${l}-${u}`]=typeof n[u]=="number"?`${n[u]}px`:n[u]}):d(i)}),r}var Lyt=k.forwardRef(function(t,s){let{invert:r,position:n="bottom-right",hotkey:a=["altKey","KeyT"],expand:o,closeButton:l,className:i,offset:d,mobileOffset:u,theme:p="light",richColors:f,duration:y,style:_,visibleToasts:b=Nyt,toastOptions:N,dir:w=IEe(),gap:S=Myt,loadingIcon:C,icons:A,containerAriaLabel:I="Notifications",pauseWhenPageIsHidden:L}=t,[O,V]=xt.useState([]),q=xt.useMemo(()=>Array.from(new Set([n].concat(O.filter(ge=>ge.position).map(ge=>ge.position)))),[O,n]),[B,U]=xt.useState([]),[te,Y]=xt.useState(!1),[J,X]=xt.useState(!1),[ce,ie]=xt.useState(p!=="system"?p:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),ae=xt.useRef(null),oe=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),me=xt.useRef(null),ve=xt.useRef(!1),he=xt.useCallback(ge=>{V(je=>{var qe;return(qe=je.find(Me=>Me.id===ge.id))!=null&&qe.delete||ep.dismiss(ge.id),je.filter(({id:Me})=>Me!==ge.id)})},[]);return xt.useEffect(()=>ep.subscribe(ge=>{if(ge.dismiss){V(je=>je.map(qe=>qe.id===ge.id?{...qe,delete:!0}:qe));return}setTimeout(()=>{eje.flushSync(()=>{V(je=>{let qe=je.findIndex(Me=>Me.id===ge.id);return qe!==-1?[...je.slice(0,qe),{...je[qe],...ge},...je.slice(qe+1)]:[ge,...je]})})})}),[]),xt.useEffect(()=>{if(p!=="system"){ie(p);return}if(p==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?ie("dark"):ie("light")),typeof window>"u")return;let ge=window.matchMedia("(prefers-color-scheme: dark)");try{ge.addEventListener("change",({matches:je})=>{ie(je?"dark":"light")})}catch{ge.addListener(({matches:qe})=>{try{ie(qe?"dark":"light")}catch(Me){console.error(Me)}})}},[p]),xt.useEffect(()=>{O.length<=1&&Y(!1)},[O]),xt.useEffect(()=>{let ge=je=>{var qe,Me;a.every(ke=>je[ke]||je.code===ke)&&(Y(!0),(qe=ae.current)==null||qe.focus()),je.code==="Escape"&&(document.activeElement===ae.current||(Me=ae.current)!=null&&Me.contains(document.activeElement))&&Y(!1)};return document.addEventListener("keydown",ge),()=>document.removeEventListener("keydown",ge)},[a]),xt.useEffect(()=>{if(ae.current)return()=>{me.current&&(me.current.focus({preventScroll:!0}),me.current=null,ve.current=!1)}},[ae.current]),xt.createElement("section",{ref:s,"aria-label":`${I} ${oe}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},q.map((ge,je)=>{var qe;let[Me,ke]=ge.split("-");return O.length?xt.createElement("ol",{key:ge,dir:w==="auto"?IEe():w,tabIndex:-1,ref:ae,className:i,"data-sonner-toaster":!0,"data-theme":ce,"data-y-position":Me,"data-lifted":te&&O.length>1&&!o,"data-x-position":ke,style:{"--front-toast-height":`${((qe=B[0])==null?void 0:qe.height)||0}px`,"--width":`${Cyt}px`,"--gap":`${S}px`,..._,...Iyt(d,u)},onBlur:Re=>{ve.current&&!Re.currentTarget.contains(Re.relatedTarget)&&(ve.current=!1,me.current&&(me.current.focus({preventScroll:!0}),me.current=null))},onFocus:Re=>{Re.target instanceof HTMLElement&&Re.target.dataset.dismissible==="false"||ve.current||(ve.current=!0,me.current=Re.relatedTarget)},onMouseEnter:()=>Y(!0),onMouseMove:()=>Y(!0),onMouseLeave:()=>{J||Y(!1)},onDragEnd:()=>Y(!1),onPointerDown:Re=>{Re.target instanceof HTMLElement&&Re.target.dataset.dismissible==="false"||X(!0)},onPointerUp:()=>X(!1)},O.filter(Re=>!Re.position&&je===0||Re.position===ge).map((Re,Ve)=>{var Ne,Ue;return xt.createElement(Pyt,{key:Re.id,icons:A,index:Ve,toast:Re,defaultRichColors:f,duration:(Ne=N==null?void 0:N.duration)!=null?Ne:y,className:N==null?void 0:N.className,descriptionClassName:N==null?void 0:N.descriptionClassName,invert:r,visibleToasts:b,closeButton:(Ue=N==null?void 0:N.closeButton)!=null?Ue:l,interacting:J,position:ge,style:N==null?void 0:N.style,unstyled:N==null?void 0:N.unstyled,classNames:N==null?void 0:N.classNames,cancelButtonStyle:N==null?void 0:N.cancelButtonStyle,actionButtonStyle:N==null?void 0:N.actionButtonStyle,removeToast:he,toasts:O.filter(Ie=>Ie.position==Re.position),heights:B.filter(Ie=>Ie.position==Re.position),setHeights:U,expandByDefault:o,gap:S,loadingIcon:C,expanded:te,pauseWhenPageIsHidden:L,swipeDirections:t.swipeDirections})})):null}))});const Dyt=({...t})=>{const{theme:s="system"}=oyt();return e.jsx(Lyt,{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 Ryt=c2e[" useId ".trim().toString()]||(()=>{}),Oyt=0;function fu(t){const[s,r]=k.useState(Ryt());return od(()=>{r(n=>n??String(Oyt++))},[t]),s?`radix-${s}`:""}const Fyt=["top","right","bottom","left"],Gb=Math.min,Yp=Math.max,Roe=Math.round,gz=Math.floor,Wb=t=>({x:t,y:t}),zyt={left:"right",right:"left",bottom:"top",top:"bottom"},Byt={start:"end",end:"start"};function Tve(t,s,r){return Yp(t,Gb(s,r))}function p1(t,s){return typeof t=="function"?t(s):t}function f1(t){return t.split("-")[0]}function DA(t){return t.split("-")[1]}function lje(t){return t==="x"?"y":"x"}function cje(t){return t==="y"?"height":"width"}function Kb(t){return["top","bottom"].includes(f1(t))?"y":"x"}function dje(t){return lje(Kb(t))}function $yt(t,s,r){r===void 0&&(r=!1);const n=DA(t),a=dje(t),o=cje(a);let l=a==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return s.reference[o]>s.floating[o]&&(l=Ooe(l)),[l,Ooe(l)]}function qyt(t){const s=Ooe(t);return[Ave(t),s,Ave(s)]}function Ave(t){return t.replace(/start|end/g,s=>Byt[s])}function Uyt(t,s,r){const n=["left","right"],a=["right","left"],o=["top","bottom"],l=["bottom","top"];switch(t){case"top":case"bottom":return r?s?a:n:s?n:a;case"left":case"right":return s?o:l;default:return[]}}function Vyt(t,s,r,n){const a=DA(t);let o=Uyt(f1(t),r==="start",n);return a&&(o=o.map(l=>l+"-"+a),s&&(o=o.concat(o.map(Ave)))),o}function Ooe(t){return t.replace(/left|right|bottom|top/g,s=>zyt[s])}function Hyt(t){return{top:0,right:0,bottom:0,left:0,...t}}function fUe(t){return typeof t!="number"?Hyt(t):{top:t,right:t,bottom:t,left:t}}function Foe(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 LEe(t,s,r){let{reference:n,floating:a}=t;const o=Kb(s),l=dje(s),i=cje(l),d=f1(s),u=o==="y",p=n.x+n.width/2-a.width/2,f=n.y+n.height/2-a.height/2,y=n[i]/2-a[i]/2;let _;switch(d){case"top":_={x:p,y:n.y-a.height};break;case"bottom":_={x:p,y:n.y+n.height};break;case"right":_={x:n.x+n.width,y:f};break;case"left":_={x:n.x-a.width,y:f};break;default:_={x:n.x,y:n.y}}switch(DA(s)){case"start":_[l]-=y*(r&&u?-1:1);break;case"end":_[l]+=y*(r&&u?-1:1);break}return _}const Gyt=async(t,s,r)=>{const{placement:n="bottom",strategy:a="absolute",middleware:o=[],platform:l}=r,i=o.filter(Boolean),d=await(l.isRTL==null?void 0:l.isRTL(s));let u=await l.getElementRects({reference:t,floating:s,strategy:a}),{x:p,y:f}=LEe(u,n,d),y=n,_={},b=0;for(let N=0;N({name:"arrow",options:t,async fn(s){const{x:r,y:n,placement:a,rects:o,platform:l,elements:i,middlewareData:d}=s,{element:u,padding:p=0}=p1(t,s)||{};if(u==null)return{};const f=fUe(p),y={x:r,y:n},_=dje(a),b=cje(_),N=await l.getDimensions(u),w=_==="y",S=w?"top":"left",C=w?"bottom":"right",A=w?"clientHeight":"clientWidth",I=o.reference[b]+o.reference[_]-y[_]-o.floating[b],L=y[_]-o.reference[_],O=await(l.getOffsetParent==null?void 0:l.getOffsetParent(u));let V=O?O[A]:0;(!V||!await(l.isElement==null?void 0:l.isElement(O)))&&(V=i.floating[A]||o.floating[b]);const q=I/2-L/2,B=V/2-N[b]/2-1,U=Gb(f[S],B),te=Gb(f[C],B),Y=U,J=V-N[b]-te,X=V/2-N[b]/2+q,ce=Tve(Y,X,J),ie=!d.arrow&&DA(a)!=null&&X!==ce&&o.reference[b]/2-(XX<=0)){var te,Y;const X=(((te=o.flip)==null?void 0:te.index)||0)+1,ce=V[X];if(ce)return{data:{index:X,overflows:U},reset:{placement:ce}};let ie=(Y=U.filter(ae=>ae.overflows[0]<=0).sort((ae,oe)=>ae.overflows[1]-oe.overflows[1])[0])==null?void 0:Y.placement;if(!ie)switch(_){case"bestFit":{var J;const ae=(J=U.filter(oe=>{if(O){const me=Kb(oe.placement);return me===C||me==="y"}return!0}).map(oe=>[oe.placement,oe.overflows.filter(me=>me>0).reduce((me,ve)=>me+ve,0)]).sort((oe,me)=>oe[1]-me[1])[0])==null?void 0:J[0];ae&&(ie=ae);break}case"initialPlacement":ie=i;break}if(a!==ie)return{reset:{placement:ie}}}return{}}}};function DEe(t,s){return{top:t.top-s.height,right:t.right-s.width,bottom:t.bottom-s.height,left:t.left-s.width}}function REe(t){return Fyt.some(s=>t[s]>=0)}const Zyt=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(s){const{rects:r}=s,{strategy:n="referenceHidden",...a}=p1(t,s);switch(n){case"referenceHidden":{const o=await Z8(s,{...a,elementContext:"reference"}),l=DEe(o,r.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:REe(l)}}}case"escaped":{const o=await Z8(s,{...a,altBoundary:!0}),l=DEe(o,r.floating);return{data:{escapedOffsets:l,escaped:REe(l)}}}default:return{}}}}};async function Yyt(t,s){const{placement:r,platform:n,elements:a}=t,o=await(n.isRTL==null?void 0:n.isRTL(a.floating)),l=f1(r),i=DA(r),d=Kb(r)==="y",u=["left","top"].includes(l)?-1:1,p=o&&d?-1:1,f=p1(s,t);let{mainAxis:y,crossAxis:_,alignmentAxis:b}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return i&&typeof b=="number"&&(_=i==="end"?b*-1:b),d?{x:_*p,y:y*u}:{x:y*u,y:_*p}}const Xyt=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(s){var r,n;const{x:a,y:o,placement:l,middlewareData:i}=s,d=await Yyt(s,t);return l===((r=i.offset)==null?void 0:r.placement)&&(n=i.arrow)!=null&&n.alignmentOffset?{}:{x:a+d.x,y:o+d.y,data:{...d,placement:l}}}}},Qyt=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(s){const{x:r,y:n,placement:a}=s,{mainAxis:o=!0,crossAxis:l=!1,limiter:i={fn:w=>{let{x:S,y:C}=w;return{x:S,y:C}}},...d}=p1(t,s),u={x:r,y:n},p=await Z8(s,d),f=Kb(f1(a)),y=lje(f);let _=u[y],b=u[f];if(o){const w=y==="y"?"top":"left",S=y==="y"?"bottom":"right",C=_+p[w],A=_-p[S];_=Tve(C,_,A)}if(l){const w=f==="y"?"top":"left",S=f==="y"?"bottom":"right",C=b+p[w],A=b-p[S];b=Tve(C,b,A)}const N=i.fn({...s,[y]:_,[f]:b});return{...N,data:{x:N.x-r,y:N.y-n,enabled:{[y]:o,[f]:l}}}}}},Jyt=function(t){return t===void 0&&(t={}),{options:t,fn(s){const{x:r,y:n,placement:a,rects:o,middlewareData:l}=s,{offset:i=0,mainAxis:d=!0,crossAxis:u=!0}=p1(t,s),p={x:r,y:n},f=Kb(a),y=lje(f);let _=p[y],b=p[f];const N=p1(i,s),w=typeof N=="number"?{mainAxis:N,crossAxis:0}:{mainAxis:0,crossAxis:0,...N};if(d){const A=y==="y"?"height":"width",I=o.reference[y]-o.floating[A]+w.mainAxis,L=o.reference[y]+o.reference[A]-w.mainAxis;_L&&(_=L)}if(u){var S,C;const A=y==="y"?"width":"height",I=["top","left"].includes(f1(a)),L=o.reference[f]-o.floating[A]+(I&&((S=l.offset)==null?void 0:S[f])||0)+(I?0:w.crossAxis),O=o.reference[f]+o.reference[A]+(I?0:((C=l.offset)==null?void 0:C[f])||0)-(I?w.crossAxis:0);bO&&(b=O)}return{[y]:_,[f]:b}}}},e0t=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(s){var r,n;const{placement:a,rects:o,platform:l,elements:i}=s,{apply:d=()=>{},...u}=p1(t,s),p=await Z8(s,u),f=f1(a),y=DA(a),_=Kb(a)==="y",{width:b,height:N}=o.floating;let w,S;f==="top"||f==="bottom"?(w=f,S=y===(await(l.isRTL==null?void 0:l.isRTL(i.floating))?"start":"end")?"left":"right"):(S=f,w=y==="end"?"top":"bottom");const C=N-p.top-p.bottom,A=b-p.left-p.right,I=Gb(N-p[w],C),L=Gb(b-p[S],A),O=!s.middlewareData.shift;let V=I,q=L;if((r=s.middlewareData.shift)!=null&&r.enabled.x&&(q=A),(n=s.middlewareData.shift)!=null&&n.enabled.y&&(V=C),O&&!y){const U=Yp(p.left,0),te=Yp(p.right,0),Y=Yp(p.top,0),J=Yp(p.bottom,0);_?q=b-2*(U!==0||te!==0?U+te:Yp(p.left,p.right)):V=N-2*(Y!==0||J!==0?Y+J:Yp(p.top,p.bottom))}await d({...s,availableWidth:q,availableHeight:V});const B=await l.getDimensions(i.floating);return b!==B.width||N!==B.height?{reset:{rects:!0}}:{}}}};function Jde(){return typeof window<"u"}function RA(t){return xUe(t)?(t.nodeName||"").toLowerCase():"#document"}function of(t){var s;return(t==null||(s=t.ownerDocument)==null?void 0:s.defaultView)||window}function b0(t){var s;return(s=(xUe(t)?t.ownerDocument:t.document)||window.document)==null?void 0:s.documentElement}function xUe(t){return Jde()?t instanceof Node||t instanceof of(t).Node:!1}function zg(t){return Jde()?t instanceof Element||t instanceof of(t).Element:!1}function h0(t){return Jde()?t instanceof HTMLElement||t instanceof of(t).HTMLElement:!1}function OEe(t){return!Jde()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof of(t).ShadowRoot}function NR(t){const{overflow:s,overflowX:r,overflowY:n,display:a}=Bg(t);return/auto|scroll|overlay|hidden|clip/.test(s+n+r)&&!["inline","contents"].includes(a)}function t0t(t){return["table","td","th"].includes(RA(t))}function eue(t){return[":popover-open",":modal"].some(s=>{try{return t.matches(s)}catch{return!1}})}function uje(t){const s=hje(),r=zg(t)?Bg(t):t;return r.transform!=="none"||r.perspective!=="none"||(r.containerType?r.containerType!=="normal":!1)||!s&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!s&&(r.filter?r.filter!=="none":!1)||["transform","perspective","filter"].some(n=>(r.willChange||"").includes(n))||["paint","layout","strict","content"].some(n=>(r.contain||"").includes(n))}function s0t(t){let s=Zb(t);for(;h0(s)&&!ST(s);){if(uje(s))return s;if(eue(s))return null;s=Zb(s)}return null}function hje(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function ST(t){return["html","body","#document"].includes(RA(t))}function Bg(t){return of(t).getComputedStyle(t)}function tue(t){return zg(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Zb(t){if(RA(t)==="html")return t;const s=t.assignedSlot||t.parentNode||OEe(t)&&t.host||b0(t);return OEe(s)?s.host:s}function gUe(t){const s=Zb(t);return ST(s)?t.ownerDocument?t.ownerDocument.body:t.body:h0(s)&&NR(s)?s:gUe(s)}function Y8(t,s,r){var n;s===void 0&&(s=[]),r===void 0&&(r=!0);const a=gUe(t),o=a===((n=t.ownerDocument)==null?void 0:n.body),l=of(a);if(o){const i=Eve(l);return s.concat(l,l.visualViewport||[],NR(a)?a:[],i&&r?Y8(i):[])}return s.concat(a,Y8(a,[],r))}function Eve(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function yUe(t){const s=Bg(t);let r=parseFloat(s.width)||0,n=parseFloat(s.height)||0;const a=h0(t),o=a?t.offsetWidth:r,l=a?t.offsetHeight:n,i=Roe(r)!==o||Roe(n)!==l;return i&&(r=o,n=l),{width:r,height:n,$:i}}function mje(t){return zg(t)?t:t.contextElement}function $M(t){const s=mje(t);if(!h0(s))return Wb(1);const r=s.getBoundingClientRect(),{width:n,height:a,$:o}=yUe(s);let l=(o?Roe(r.width):r.width)/n,i=(o?Roe(r.height):r.height)/a;return(!l||!Number.isFinite(l))&&(l=1),(!i||!Number.isFinite(i))&&(i=1),{x:l,y:i}}const r0t=Wb(0);function vUe(t){const s=of(t);return!hje()||!s.visualViewport?r0t:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function n0t(t,s,r){return s===void 0&&(s=!1),!r||s&&r!==of(t)?!1:s}function US(t,s,r,n){s===void 0&&(s=!1),r===void 0&&(r=!1);const a=t.getBoundingClientRect(),o=mje(t);let l=Wb(1);s&&(n?zg(n)&&(l=$M(n)):l=$M(t));const i=n0t(o,r,n)?vUe(o):Wb(0);let d=(a.left+i.x)/l.x,u=(a.top+i.y)/l.y,p=a.width/l.x,f=a.height/l.y;if(o){const y=of(o),_=n&&zg(n)?of(n):n;let b=y,N=Eve(b);for(;N&&n&&_!==b;){const w=$M(N),S=N.getBoundingClientRect(),C=Bg(N),A=S.left+(N.clientLeft+parseFloat(C.paddingLeft))*w.x,I=S.top+(N.clientTop+parseFloat(C.paddingTop))*w.y;d*=w.x,u*=w.y,p*=w.x,f*=w.y,d+=A,u+=I,b=of(N),N=Eve(b)}}return Foe({width:p,height:f,x:d,y:u})}function a0t(t){let{elements:s,rect:r,offsetParent:n,strategy:a}=t;const o=a==="fixed",l=b0(n),i=s?eue(s.floating):!1;if(n===l||i&&o)return r;let d={scrollLeft:0,scrollTop:0},u=Wb(1);const p=Wb(0),f=h0(n);if((f||!f&&!o)&&((RA(n)!=="body"||NR(l))&&(d=tue(n)),h0(n))){const y=US(n);u=$M(n),p.x=y.x+n.clientLeft,p.y=y.y+n.clientTop}return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-d.scrollLeft*u.x+p.x,y:r.y*u.y-d.scrollTop*u.y+p.y}}function i0t(t){return Array.from(t.getClientRects())}function Pve(t,s){const r=tue(t).scrollLeft;return s?s.left+r:US(b0(t)).left+r}function o0t(t){const s=b0(t),r=tue(t),n=t.ownerDocument.body,a=Yp(s.scrollWidth,s.clientWidth,n.scrollWidth,n.clientWidth),o=Yp(s.scrollHeight,s.clientHeight,n.scrollHeight,n.clientHeight);let l=-r.scrollLeft+Pve(t);const i=-r.scrollTop;return Bg(n).direction==="rtl"&&(l+=Yp(s.clientWidth,n.clientWidth)-a),{width:a,height:o,x:l,y:i}}function l0t(t,s){const r=of(t),n=b0(t),a=r.visualViewport;let o=n.clientWidth,l=n.clientHeight,i=0,d=0;if(a){o=a.width,l=a.height;const u=hje();(!u||u&&s==="fixed")&&(i=a.offsetLeft,d=a.offsetTop)}return{width:o,height:l,x:i,y:d}}function c0t(t,s){const r=US(t,!0,s==="fixed"),n=r.top+t.clientTop,a=r.left+t.clientLeft,o=h0(t)?$M(t):Wb(1),l=t.clientWidth*o.x,i=t.clientHeight*o.y,d=a*o.x,u=n*o.y;return{width:l,height:i,x:d,y:u}}function FEe(t,s,r){let n;if(s==="viewport")n=l0t(t,r);else if(s==="document")n=o0t(b0(t));else if(zg(s))n=c0t(s,r);else{const a=vUe(t);n={...s,x:s.x-a.x,y:s.y-a.y}}return Foe(n)}function _Ue(t,s){const r=Zb(t);return r===s||!zg(r)||ST(r)?!1:Bg(r).position==="fixed"||_Ue(r,s)}function d0t(t,s){const r=s.get(t);if(r)return r;let n=Y8(t,[],!1).filter(i=>zg(i)&&RA(i)!=="body"),a=null;const o=Bg(t).position==="fixed";let l=o?Zb(t):t;for(;zg(l)&&!ST(l);){const i=Bg(l),d=uje(l);!d&&i.position==="fixed"&&(a=null),(o?!d&&!a:!d&&i.position==="static"&&!!a&&["absolute","fixed"].includes(a.position)||NR(l)&&!d&&_Ue(t,l))?n=n.filter(p=>p!==l):a=i,l=Zb(l)}return s.set(t,n),n}function u0t(t){let{element:s,boundary:r,rootBoundary:n,strategy:a}=t;const l=[...r==="clippingAncestors"?eue(s)?[]:d0t(s,this._c):[].concat(r),n],i=l[0],d=l.reduce((u,p)=>{const f=FEe(s,p,a);return u.top=Yp(f.top,u.top),u.right=Gb(f.right,u.right),u.bottom=Gb(f.bottom,u.bottom),u.left=Yp(f.left,u.left),u},FEe(s,i,a));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function h0t(t){const{width:s,height:r}=yUe(t);return{width:s,height:r}}function m0t(t,s,r){const n=h0(s),a=b0(s),o=r==="fixed",l=US(t,!0,o,s);let i={scrollLeft:0,scrollTop:0};const d=Wb(0);if(n||!n&&!o)if((RA(s)!=="body"||NR(a))&&(i=tue(s)),n){const _=US(s,!0,o,s);d.x=_.x+s.clientLeft,d.y=_.y+s.clientTop}else a&&(d.x=Pve(a));let u=0,p=0;if(a&&!n&&!o){const _=a.getBoundingClientRect();p=_.top+i.scrollTop,u=_.left+i.scrollLeft-Pve(a,_)}const f=l.left+i.scrollLeft-d.x-u,y=l.top+i.scrollTop-d.y-p;return{x:f,y,width:l.width,height:l.height}}function Zxe(t){return Bg(t).position==="static"}function zEe(t,s){if(!h0(t)||Bg(t).position==="fixed")return null;if(s)return s(t);let r=t.offsetParent;return b0(t)===r&&(r=r.ownerDocument.body),r}function bUe(t,s){const r=of(t);if(eue(t))return r;if(!h0(t)){let a=Zb(t);for(;a&&!ST(a);){if(zg(a)&&!Zxe(a))return a;a=Zb(a)}return r}let n=zEe(t,s);for(;n&&t0t(n)&&Zxe(n);)n=zEe(n,s);return n&&ST(n)&&Zxe(n)&&!uje(n)?r:n||s0t(t)||r}const p0t=async function(t){const s=this.getOffsetParent||bUe,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 f0t(t){return Bg(t).direction==="rtl"}const x0t={convertOffsetParentRelativeRectToViewportRelativeRect:a0t,getDocumentElement:b0,getClippingRect:u0t,getOffsetParent:bUe,getElementRects:p0t,getClientRects:i0t,getDimensions:h0t,getScale:$M,isElement:zg,isRTL:f0t};function g0t(t,s){let r=null,n;const a=b0(t);function o(){var i;clearTimeout(n),(i=r)==null||i.disconnect(),r=null}function l(i,d){i===void 0&&(i=!1),d===void 0&&(d=1),o();const{left:u,top:p,width:f,height:y}=t.getBoundingClientRect();if(i||s(),!f||!y)return;const _=gz(p),b=gz(a.clientWidth-(u+f)),N=gz(a.clientHeight-(p+y)),w=gz(u),C={rootMargin:-_+"px "+-b+"px "+-N+"px "+-w+"px",threshold:Yp(0,Gb(1,d))||1};let A=!0;function I(L){const O=L[0].intersectionRatio;if(O!==d){if(!A)return l();O?l(!1,O):n=setTimeout(()=>{l(!1,1e-7)},1e3)}A=!1}try{r=new IntersectionObserver(I,{...C,root:a.ownerDocument})}catch{r=new IntersectionObserver(I,C)}r.observe(t)}return l(!0),o}function y0t(t,s,r,n){n===void 0&&(n={});const{ancestorScroll:a=!0,ancestorResize:o=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:d=!1}=n,u=mje(t),p=a||o?[...u?Y8(u):[],...Y8(s)]:[];p.forEach(S=>{a&&S.addEventListener("scroll",r,{passive:!0}),o&&S.addEventListener("resize",r)});const f=u&&i?g0t(u,r):null;let y=-1,_=null;l&&(_=new ResizeObserver(S=>{let[C]=S;C&&C.target===u&&_&&(_.unobserve(s),cancelAnimationFrame(y),y=requestAnimationFrame(()=>{var A;(A=_)==null||A.observe(s)})),r()}),u&&!d&&_.observe(u),_.observe(s));let b,N=d?US(t):null;d&&w();function w(){const S=US(t);N&&(S.x!==N.x||S.y!==N.y||S.width!==N.width||S.height!==N.height)&&r(),N=S,b=requestAnimationFrame(w)}return r(),()=>{var S;p.forEach(C=>{a&&C.removeEventListener("scroll",r),o&&C.removeEventListener("resize",r)}),f==null||f(),(S=_)==null||S.disconnect(),_=null,d&&cancelAnimationFrame(b)}}const v0t=Xyt,_0t=Qyt,b0t=Kyt,w0t=e0t,j0t=Zyt,BEe=Wyt,N0t=Jyt,k0t=(t,s,r)=>{const n=new Map,a={platform:x0t,...r},o={...a.platform,_c:n};return Gyt(t,s,{...a,platform:o})};var Lie=typeof document<"u"?k.useLayoutEffect:k.useEffect;function zoe(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(!zoe(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)&&!zoe(t[o],s[o]))return!1}return!0}return t!==t&&s!==s}function wUe(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function $Ee(t,s){const r=wUe(t);return Math.round(s*r)/r}function Yxe(t){const s=k.useRef(t);return Lie(()=>{s.current=t}),s}function S0t(t){t===void 0&&(t={});const{placement:s="bottom",strategy:r="absolute",middleware:n=[],platform:a,elements:{reference:o,floating:l}={},transform:i=!0,whileElementsMounted:d,open:u}=t,[p,f]=k.useState({x:0,y:0,strategy:r,placement:s,middlewareData:{},isPositioned:!1}),[y,_]=k.useState(n);zoe(y,n)||_(n);const[b,N]=k.useState(null),[w,S]=k.useState(null),C=k.useCallback(oe=>{oe!==O.current&&(O.current=oe,N(oe))},[]),A=k.useCallback(oe=>{oe!==V.current&&(V.current=oe,S(oe))},[]),I=o||b,L=l||w,O=k.useRef(null),V=k.useRef(null),q=k.useRef(p),B=d!=null,U=Yxe(d),te=Yxe(a),Y=Yxe(u),J=k.useCallback(()=>{if(!O.current||!V.current)return;const oe={placement:s,strategy:r,middleware:y};te.current&&(oe.platform=te.current),k0t(O.current,V.current,oe).then(me=>{const ve={...me,isPositioned:Y.current!==!1};X.current&&!zoe(q.current,ve)&&(q.current=ve,op.flushSync(()=>{f(ve)}))})},[y,s,r,te,Y]);Lie(()=>{u===!1&&q.current.isPositioned&&(q.current.isPositioned=!1,f(oe=>({...oe,isPositioned:!1})))},[u]);const X=k.useRef(!1);Lie(()=>(X.current=!0,()=>{X.current=!1}),[]),Lie(()=>{if(I&&(O.current=I),L&&(V.current=L),I&&L){if(U.current)return U.current(I,L,J);J()}},[I,L,J,U,B]);const ce=k.useMemo(()=>({reference:O,floating:V,setReference:C,setFloating:A}),[C,A]),ie=k.useMemo(()=>({reference:I,floating:L}),[I,L]),ae=k.useMemo(()=>{const oe={position:r,left:0,top:0};if(!ie.floating)return oe;const me=$Ee(ie.floating,p.x),ve=$Ee(ie.floating,p.y);return i?{...oe,transform:"translate("+me+"px, "+ve+"px)",...wUe(ie.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:me,top:ve}},[r,i,ie.floating,p.x,p.y]);return k.useMemo(()=>({...p,update:J,refs:ce,elements:ie,floatingStyles:ae}),[p,J,ce,ie,ae])}const C0t=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?BEe({element:n.current,padding:a}).fn(r):{}:n?BEe({element:n,padding:a}).fn(r):{}}}},M0t=(t,s)=>({...v0t(t),options:[t,s]}),T0t=(t,s)=>({..._0t(t),options:[t,s]}),A0t=(t,s)=>({...N0t(t),options:[t,s]}),E0t=(t,s)=>({...b0t(t),options:[t,s]}),P0t=(t,s)=>({...w0t(t),options:[t,s]}),I0t=(t,s)=>({...j0t(t),options:[t,s]}),L0t=(t,s)=>({...C0t(t),options:[t,s]});var D0t="Arrow",jUe=k.forwardRef((t,s)=>{const{children:r,width:n=10,height:a=5,...o}=t;return e.jsx(Jr.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"})})});jUe.displayName=D0t;var R0t=jUe;function kR(t){const[s,r]=k.useState(void 0);return od(()=>{if(t){r({width:t.offsetWidth,height:t.offsetHeight});const n=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const o=a[0];let l,i;if("borderBoxSize"in o){const d=o.borderBoxSize,u=Array.isArray(d)?d[0]:d;l=u.inlineSize,i=u.blockSize}else l=t.offsetWidth,i=t.offsetHeight;r({width:l,height:i})});return n.observe(t,{box:"border-box"}),()=>n.unobserve(t)}else r(void 0)},[t]),s}var pje="Popper",[NUe,w0]=qc(pje),[O0t,kUe]=NUe(pje),SUe=t=>{const{__scopePopper:s,children:r}=t,[n,a]=k.useState(null);return e.jsx(O0t,{scope:s,anchor:n,onAnchorChange:a,children:r})};SUe.displayName=pje;var CUe="PopperAnchor",MUe=k.forwardRef((t,s)=>{const{__scopePopper:r,virtualRef:n,...a}=t,o=kUe(CUe,r),l=k.useRef(null),i=Ta(s,l);return k.useEffect(()=>{o.onAnchorChange((n==null?void 0:n.current)||l.current)}),n?null:e.jsx(Jr.div,{...a,ref:i})});MUe.displayName=CUe;var fje="PopperContent",[F0t,z0t]=NUe(fje),TUe=k.forwardRef((t,s)=>{var Re,Ve,Ne,Ue,Ie,ye;const{__scopePopper:r,side:n="bottom",sideOffset:a=0,align:o="center",alignOffset:l=0,arrowPadding:i=0,avoidCollisions:d=!0,collisionBoundary:u=[],collisionPadding:p=0,sticky:f="partial",hideWhenDetached:y=!1,updatePositionStrategy:_="optimized",onPlaced:b,...N}=t,w=kUe(fje,r),[S,C]=k.useState(null),A=Ta(s,ct=>C(ct)),[I,L]=k.useState(null),O=kR(I),V=(O==null?void 0:O.width)??0,q=(O==null?void 0:O.height)??0,B=n+(o!=="center"?"-"+o:""),U=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},te=Array.isArray(u)?u:[u],Y=te.length>0,J={padding:U,boundary:te.filter($0t),altBoundary:Y},{refs:X,floatingStyles:ce,placement:ie,isPositioned:ae,middlewareData:oe}=S0t({strategy:"fixed",placement:B,whileElementsMounted:(...ct)=>y0t(...ct,{animationFrame:_==="always"}),elements:{reference:w.anchor},middleware:[M0t({mainAxis:a+q,alignmentAxis:l}),d&&T0t({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?A0t():void 0,...J}),d&&E0t({...J}),P0t({...J,apply:({elements:ct,rects:fe,availableWidth:$e,availableHeight:Ye})=>{const{width:tt,height:Te}=fe.reference,We=ct.floating.style;We.setProperty("--radix-popper-available-width",`${$e}px`),We.setProperty("--radix-popper-available-height",`${Ye}px`),We.setProperty("--radix-popper-anchor-width",`${tt}px`),We.setProperty("--radix-popper-anchor-height",`${Te}px`)}}),I&&L0t({element:I,padding:i}),q0t({arrowWidth:V,arrowHeight:q}),y&&I0t({strategy:"referenceHidden",...J})]}),[me,ve]=PUe(ie),he=ed(b);od(()=>{ae&&(he==null||he())},[ae,he]);const ge=(Re=oe.arrow)==null?void 0:Re.x,je=(Ve=oe.arrow)==null?void 0:Ve.y,qe=((Ne=oe.arrow)==null?void 0:Ne.centerOffset)!==0,[Me,ke]=k.useState();return od(()=>{S&&ke(window.getComputedStyle(S).zIndex)},[S]),e.jsx("div",{ref:X.setFloating,"data-radix-popper-content-wrapper":"",style:{...ce,transform:ae?ce.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Me,"--radix-popper-transform-origin":[(Ue=oe.transformOrigin)==null?void 0:Ue.x,(Ie=oe.transformOrigin)==null?void 0:Ie.y].join(" "),...((ye=oe.hide)==null?void 0:ye.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:e.jsx(F0t,{scope:r,placedSide:me,onArrowChange:L,arrowX:ge,arrowY:je,shouldHideArrow:qe,children:e.jsx(Jr.div,{"data-side":me,"data-align":ve,...N,ref:A,style:{...N.style,animation:ae?void 0:"none"}})})})});TUe.displayName=fje;var AUe="PopperArrow",B0t={top:"bottom",right:"left",bottom:"top",left:"right"},EUe=k.forwardRef(function(s,r){const{__scopePopper:n,...a}=s,o=z0t(AUe,n),l=B0t[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(R0t,{...a,ref:r,style:{...a.style,display:"block"}})})});EUe.displayName=AUe;function $0t(t){return t!==null}var q0t=t=>({name:"transformOrigin",options:t,fn(s){var w,S,C;const{placement:r,rects:n,middlewareData:a}=s,l=((w=a.arrow)==null?void 0:w.centerOffset)!==0,i=l?0:t.arrowWidth,d=l?0:t.arrowHeight,[u,p]=PUe(r),f={start:"0%",center:"50%",end:"100%"}[p],y=(((S=a.arrow)==null?void 0:S.x)??0)+i/2,_=(((C=a.arrow)==null?void 0:C.y)??0)+d/2;let b="",N="";return u==="bottom"?(b=l?f:`${y}px`,N=`${-d}px`):u==="top"?(b=l?f:`${y}px`,N=`${n.floating.height+d}px`):u==="right"?(b=`${-d}px`,N=l?f:`${_}px`):u==="left"&&(b=`${n.floating.width+d}px`,N=l?f:`${_}px`),{data:{x:b,y:N}}}});function PUe(t){const[s,r="center"]=t.split("-");return[s,r]}var SR=SUe,OA=MUe,CR=TUe,MR=EUe,[sue,FTs]=qc("Tooltip",[w0]),rue=w0(),IUe="TooltipProvider",U0t=700,Ive="tooltip.open",[V0t,xje]=sue(IUe),LUe=t=>{const{__scopeTooltip:s,delayDuration:r=U0t,skipDelayDuration:n=300,disableHoverableContent:a=!1,children:o}=t,l=k.useRef(!0),i=k.useRef(!1),d=k.useRef(0);return k.useEffect(()=>{const u=d.current;return()=>window.clearTimeout(u)},[]),e.jsx(V0t,{scope:s,isOpenDelayedRef:l,delayDuration:r,onOpen:k.useCallback(()=>{window.clearTimeout(d.current),l.current=!1},[]),onClose:k.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>l.current=!0,n)},[n]),isPointerInTransitRef:i,onPointerInTransitChange:k.useCallback(u=>{i.current=u},[]),disableHoverableContent:a,children:o})};LUe.displayName=IUe;var X8="Tooltip",[H0t,nue]=sue(X8),DUe=t=>{const{__scopeTooltip:s,children:r,open:n,defaultOpen:a,onOpenChange:o,disableHoverableContent:l,delayDuration:i}=t,d=xje(X8,t.__scopeTooltip),u=rue(s),[p,f]=k.useState(null),y=fu(),_=k.useRef(0),b=l??d.disableHoverableContent,N=i??d.delayDuration,w=k.useRef(!1),[S,C]=Uu({prop:n,defaultProp:a??!1,onChange:V=>{V?(d.onOpen(),document.dispatchEvent(new CustomEvent(Ive))):d.onClose(),o==null||o(V)},caller:X8}),A=k.useMemo(()=>S?w.current?"delayed-open":"instant-open":"closed",[S]),I=k.useCallback(()=>{window.clearTimeout(_.current),_.current=0,w.current=!1,C(!0)},[C]),L=k.useCallback(()=>{window.clearTimeout(_.current),_.current=0,C(!1)},[C]),O=k.useCallback(()=>{window.clearTimeout(_.current),_.current=window.setTimeout(()=>{w.current=!0,C(!0),_.current=0},N)},[N,C]);return k.useEffect(()=>()=>{_.current&&(window.clearTimeout(_.current),_.current=0)},[]),e.jsx(SR,{...u,children:e.jsx(H0t,{scope:s,contentId:y,open:S,stateAttribute:A,trigger:p,onTriggerChange:f,onTriggerEnter:k.useCallback(()=>{d.isOpenDelayedRef.current?O():I()},[d.isOpenDelayedRef,O,I]),onTriggerLeave:k.useCallback(()=>{b?L():(window.clearTimeout(_.current),_.current=0)},[L,b]),onOpen:I,onClose:L,disableHoverableContent:b,children:r})})};DUe.displayName=X8;var Lve="TooltipTrigger",RUe=k.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=nue(Lve,r),o=xje(Lve,r),l=rue(r),i=k.useRef(null),d=Ta(s,i,a.onTriggerChange),u=k.useRef(!1),p=k.useRef(!1),f=k.useCallback(()=>u.current=!1,[]);return k.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),e.jsx(OA,{asChild:!0,...l,children:e.jsx(Jr.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...n,ref:d,onPointerMove:Mr(t.onPointerMove,y=>{y.pointerType!=="touch"&&!p.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),p.current=!0)}),onPointerLeave:Mr(t.onPointerLeave,()=>{a.onTriggerLeave(),p.current=!1}),onPointerDown:Mr(t.onPointerDown,()=>{a.open&&a.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Mr(t.onFocus,()=>{u.current||a.onOpen()}),onBlur:Mr(t.onBlur,a.onClose),onClick:Mr(t.onClick,a.onClose)})})});RUe.displayName=Lve;var G0t="TooltipPortal",[zTs,W0t]=sue(G0t,{forceMount:void 0}),CT="TooltipContent",OUe=k.forwardRef((t,s)=>{const r=W0t(CT,t.__scopeTooltip),{forceMount:n=r.forceMount,side:a="top",...o}=t,l=nue(CT,t.__scopeTooltip);return e.jsx(jd,{present:n||l.open,children:l.disableHoverableContent?e.jsx(FUe,{side:a,...o,ref:s}):e.jsx(K0t,{side:a,...o,ref:s})})}),K0t=k.forwardRef((t,s)=>{const r=nue(CT,t.__scopeTooltip),n=xje(CT,t.__scopeTooltip),a=k.useRef(null),o=Ta(s,a),[l,i]=k.useState(null),{trigger:d,onClose:u}=r,p=a.current,{onPointerInTransitChange:f}=n,y=k.useCallback(()=>{i(null),f(!1)},[f]),_=k.useCallback((b,N)=>{const w=b.currentTarget,S={x:b.clientX,y:b.clientY},C=J0t(S,w.getBoundingClientRect()),A=evt(S,C),I=tvt(N.getBoundingClientRect()),L=rvt([...A,...I]);i(L),f(!0)},[f]);return k.useEffect(()=>()=>y(),[y]),k.useEffect(()=>{if(d&&p){const b=w=>_(w,p),N=w=>_(w,d);return d.addEventListener("pointerleave",b),p.addEventListener("pointerleave",N),()=>{d.removeEventListener("pointerleave",b),p.removeEventListener("pointerleave",N)}}},[d,p,_,y]),k.useEffect(()=>{if(l){const b=N=>{const w=N.target,S={x:N.clientX,y:N.clientY},C=(d==null?void 0:d.contains(w))||(p==null?void 0:p.contains(w)),A=!svt(S,l);C?y():A&&(y(),u())};return document.addEventListener("pointermove",b),()=>document.removeEventListener("pointermove",b)}},[d,p,l,u,y]),e.jsx(FUe,{...t,ref:o})}),[Z0t,Y0t]=sue(X8,{isInside:!1}),X0t=Pqe("TooltipContent"),FUe=k.forwardRef((t,s)=>{const{__scopeTooltip:r,children:n,"aria-label":a,onEscapeKeyDown:o,onPointerDownOutside:l,...i}=t,d=nue(CT,r),u=rue(r),{onClose:p}=d;return k.useEffect(()=>(document.addEventListener(Ive,p),()=>document.removeEventListener(Ive,p)),[p]),k.useEffect(()=>{if(d.trigger){const f=y=>{const _=y.target;_!=null&&_.contains(d.trigger)&&p()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[d.trigger,p]),e.jsx(dw,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:f=>f.preventDefault(),onDismiss:p,children:e.jsxs(CR,{"data-state":d.stateAttribute,...u,...i,ref:s,style:{...i.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[e.jsx(X0t,{children:n}),e.jsx(Z0t,{scope:r,isInside:!0,children:e.jsx(egt,{id:d.contentId,role:"tooltip",children:a||n})})]})})});OUe.displayName=CT;var zUe="TooltipArrow",Q0t=k.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=rue(r);return Y0t(zUe,r).isInside?null:e.jsx(MR,{...a,...n,ref:s})});Q0t.displayName=zUe;function J0t(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 evt(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 tvt(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 svt(t,s){const{x:r,y:n}=t;let a=!1;for(let o=0,l=s.length-1;on!=y>n&&r<(f-u)*(n-p)/(y-p)+u&&(a=!a)}return a}function rvt(t){const s=t.slice();return s.sort((r,n)=>r.xn.x?1:r.yn.y?1:0),nvt(s)}function nvt(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 avt=LUe,ivt=DUe,ovt=RUe,BUe=OUe;const S1=avt,ec=ivt,tc=ovt,Dl=k.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(BUe,{ref:n,sideOffset:s,className:Ot("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}));Dl.displayName=BUe.displayName;var FA=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(){}},VS=typeof window>"u"||"Deno"in globalThis;function pm(){}function lvt(t,s){return typeof t=="function"?t(s):t}function Dve(t){return typeof t=="number"&&t>=0&&t!==1/0}function $Ue(t,s){return Math.max(t+(s||0)-Date.now(),0)}function Pb(t,s){return typeof t=="function"?t(s):t}function ex(t,s){return typeof t=="function"?t(s):t}function qEe(t,s){const{type:r="all",exact:n,fetchStatus:a,predicate:o,queryKey:l,stale:i}=t;if(l){if(n){if(s.queryHash!==gje(l,s.options))return!1}else if(!Q8(s.queryKey,l))return!1}if(r!=="all"){const d=s.isActive();if(r==="active"&&!d||r==="inactive"&&d)return!1}return!(typeof i=="boolean"&&s.isStale()!==i||a&&a!==s.state.fetchStatus||o&&!o(s))}function UEe(t,s){const{exact:r,status:n,predicate:a,mutationKey:o}=t;if(o){if(!s.options.mutationKey)return!1;if(r){if(HS(s.options.mutationKey)!==HS(o))return!1}else if(!Q8(s.options.mutationKey,o))return!1}return!(n&&s.state.status!==n||a&&!a(s))}function gje(t,s){return((s==null?void 0:s.queryKeyHashFn)||HS)(t)}function HS(t){return JSON.stringify(t,(s,r)=>Rve(r)?Object.keys(r).sort().reduce((n,a)=>(n[a]=r[a],n),{}):r)}function Q8(t,s){return t===s?!0:typeof t!=typeof s?!1:t&&s&&typeof t=="object"&&typeof s=="object"?Object.keys(s).every(r=>Q8(t[r],s[r])):!1}function qUe(t,s){if(t===s)return t;const r=VEe(t)&&VEe(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?[]:{},d=new Set(n);let u=0;for(let p=0;p{setTimeout(s,t)})}function Ove(t,s,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,s):r.structuralSharing!==!1?qUe(t,s):s}function dvt(t,s,r=0){const n=[...t,s];return r&&n.length>r?n.slice(1):n}function uvt(t,s,r=0){const n=[s,...t];return r&&n.length>r?n.slice(0,-1):n}var yje=Symbol();function UUe(t,s){return!t.queryFn&&(s!=null&&s.initialPromise)?()=>s.initialPromise:!t.queryFn||t.queryFn===yje?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function VUe(t,s){return typeof t=="function"?t(...s):!!t}var P4,Y_,oT,oBe,hvt=(oBe=class extends FA{constructor(){super();za(this,P4);za(this,Y_);za(this,oT);zn(this,oT,s=>{if(!VS&&window.addEventListener){const r=()=>s();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){ms(this,Y_)||this.setEventListener(ms(this,oT))}onUnsubscribe(){var s;this.hasListeners()||((s=ms(this,Y_))==null||s.call(this),zn(this,Y_,void 0))}setEventListener(s){var r;zn(this,oT,s),(r=ms(this,Y_))==null||r.call(this),zn(this,Y_,s(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(s){ms(this,P4)!==s&&(zn(this,P4,s),this.onFocus())}onFocus(){const s=this.isFocused();this.listeners.forEach(r=>{r(s)})}isFocused(){var s;return typeof ms(this,P4)=="boolean"?ms(this,P4):((s=globalThis.document)==null?void 0:s.visibilityState)!=="hidden"}},P4=new WeakMap,Y_=new WeakMap,oT=new WeakMap,oBe),vje=new hvt,lT,X_,cT,lBe,mvt=(lBe=class extends FA{constructor(){super();za(this,lT,!0);za(this,X_);za(this,cT);zn(this,cT,s=>{if(!VS&&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(){ms(this,X_)||this.setEventListener(ms(this,cT))}onUnsubscribe(){var s;this.hasListeners()||((s=ms(this,X_))==null||s.call(this),zn(this,X_,void 0))}setEventListener(s){var r;zn(this,cT,s),(r=ms(this,X_))==null||r.call(this),zn(this,X_,s(this.setOnline.bind(this)))}setOnline(s){ms(this,lT)!==s&&(zn(this,lT,s),this.listeners.forEach(n=>{n(s)}))}isOnline(){return ms(this,lT)}},lT=new WeakMap,X_=new WeakMap,cT=new WeakMap,lBe),$oe=new mvt;function Fve(){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 pvt(t){return Math.min(1e3*2**t,3e4)}function HUe(t){return(t??"online")==="online"?$oe.isOnline():!0}var GUe=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 GUe}function WUe(t){let s=!1,r=0,n=!1,a;const o=Fve(),l=N=>{var w;n||(y(new GUe(N)),(w=t.abort)==null||w.call(t))},i=()=>{s=!0},d=()=>{s=!1},u=()=>vje.isFocused()&&(t.networkMode==="always"||$oe.isOnline())&&t.canRun(),p=()=>HUe(t.networkMode)&&t.canRun(),f=N=>{var w;n||(n=!0,(w=t.onSuccess)==null||w.call(t,N),a==null||a(),o.resolve(N))},y=N=>{var w;n||(n=!0,(w=t.onError)==null||w.call(t,N),a==null||a(),o.reject(N))},_=()=>new Promise(N=>{var w;a=S=>{(n||u())&&N(S)},(w=t.onPause)==null||w.call(t)}).then(()=>{var N;a=void 0,n||(N=t.onContinue)==null||N.call(t)}),b=()=>{if(n)return;let N;const w=r===0?t.initialPromise:void 0;try{N=w??t.fn()}catch(S){N=Promise.reject(S)}Promise.resolve(N).then(f).catch(S=>{var O;if(n)return;const C=t.retry??(VS?0:3),A=t.retryDelay??pvt,I=typeof A=="function"?A(r,S):A,L=C===!0||typeof C=="number"&&ru()?void 0:_()).then(()=>{s?y(S):b()})})};return{promise:o,cancel:l,continue:()=>(a==null||a(),o),cancelRetry:i,continueRetry:d,canStart:p,start:()=>(p()?b():_().then(b),o)}}var fvt=t=>setTimeout(t,0);function xvt(){let t=[],s=0,r=i=>{i()},n=i=>{i()},a=fvt;const o=i=>{s?t.push(i):a(()=>{r(i)})},l=()=>{const i=t;t=[],i.length&&a(()=>{n(()=>{i.forEach(d=>{r(d)})})})};return{batch:i=>{let d;s++;try{d=i()}finally{s--,s||l()}return d},batchCalls:i=>(...d)=>{o(()=>{i(...d)})},schedule:o,setNotifyFunction:i=>{r=i},setBatchNotifyFunction:i=>{n=i},setScheduler:i=>{a=i}}}var nu=xvt(),I4,cBe,KUe=(cBe=class{constructor(){za(this,I4)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Dve(this.gcTime)&&zn(this,I4,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(VS?1/0:5*60*1e3))}clearGcTimeout(){ms(this,I4)&&(clearTimeout(ms(this,I4)),zn(this,I4,void 0))}},I4=new WeakMap,cBe),dT,L4,Jf,D4,Sh,mR,R4,mg,_v,dBe,gvt=(dBe=class extends KUe{constructor(s){super();za(this,mg);za(this,dT);za(this,L4);za(this,Jf);za(this,D4);za(this,Sh);za(this,mR);za(this,R4);zn(this,R4,!1),zn(this,mR,s.defaultOptions),this.setOptions(s.options),this.observers=[],zn(this,D4,s.client),zn(this,Jf,ms(this,D4).getQueryCache()),this.queryKey=s.queryKey,this.queryHash=s.queryHash,zn(this,dT,yvt(this.options)),this.state=s.state??ms(this,dT),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var s;return(s=ms(this,Sh))==null?void 0:s.promise}setOptions(s){this.options={...ms(this,mR),...s},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&ms(this,Jf).remove(this)}setData(s,r){const n=Ove(this.state.data,s,this.options);return Ii(this,mg,_v).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(s,r){Ii(this,mg,_v).call(this,{type:"setState",state:s,setStateOptions:r})}cancel(s){var n,a;const r=(n=ms(this,Sh))==null?void 0:n.promise;return(a=ms(this,Sh))==null||a.cancel(s),r?r.then(pm).catch(pm):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(ms(this,dT))}isActive(){return this.observers.some(s=>ex(s.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===yje||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(s=>Pb(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:!$Ue(this.state.dataUpdatedAt,s)}onFocus(){var r;const s=this.observers.find(n=>n.shouldFetchOnWindowFocus());s==null||s.refetch({cancelRefetch:!1}),(r=ms(this,Sh))==null||r.continue()}onOnline(){var r;const s=this.observers.find(n=>n.shouldFetchOnReconnect());s==null||s.refetch({cancelRefetch:!1}),(r=ms(this,Sh))==null||r.continue()}addObserver(s){this.observers.includes(s)||(this.observers.push(s),this.clearGcTimeout(),ms(this,Jf).notify({type:"observerAdded",query:this,observer:s}))}removeObserver(s){this.observers.includes(s)&&(this.observers=this.observers.filter(r=>r!==s),this.observers.length||(ms(this,Sh)&&(ms(this,R4)?ms(this,Sh).cancel({revert:!0}):ms(this,Sh).cancelRetry()),this.scheduleGc()),ms(this,Jf).notify({type:"observerRemoved",query:this,observer:s}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Ii(this,mg,_v).call(this,{type:"invalidate"})}fetch(s,r){var u,p,f;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(ms(this,Sh))return ms(this,Sh).continueRetry(),ms(this,Sh).promise}if(s&&this.setOptions(s),!this.options.queryFn){const y=this.observers.find(_=>_.options.queryFn);y&&this.setOptions(y.options)}const n=new AbortController,a=y=>{Object.defineProperty(y,"signal",{enumerable:!0,get:()=>(zn(this,R4,!0),n.signal)})},o=()=>{const y=UUe(this.options,r),b=(()=>{const N={client:ms(this,D4),queryKey:this.queryKey,meta:this.meta};return a(N),N})();return zn(this,R4,!1),this.options.persister?this.options.persister(y,b,this):y(b)},i=(()=>{const y={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:ms(this,D4),state:this.state,fetchFn:o};return a(y),y})();(u=this.options.behavior)==null||u.onFetch(i,this),zn(this,L4,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((p=i.fetchOptions)==null?void 0:p.meta))&&Ii(this,mg,_v).call(this,{type:"fetch",meta:(f=i.fetchOptions)==null?void 0:f.meta});const d=y=>{var _,b,N,w;Xxe(y)&&y.silent||Ii(this,mg,_v).call(this,{type:"error",error:y}),Xxe(y)||((b=(_=ms(this,Jf).config).onError)==null||b.call(_,y,this),(w=(N=ms(this,Jf).config).onSettled)==null||w.call(N,this.state.data,y,this)),this.scheduleGc()};return zn(this,Sh,WUe({initialPromise:r==null?void 0:r.initialPromise,fn:i.fetchFn,abort:n.abort.bind(n),onSuccess:y=>{var _,b,N,w;if(y===void 0){d(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(y)}catch(S){d(S);return}(b=(_=ms(this,Jf).config).onSuccess)==null||b.call(_,y,this),(w=(N=ms(this,Jf).config).onSettled)==null||w.call(N,y,this.state.error,this),this.scheduleGc()},onError:d,onFail:(y,_)=>{Ii(this,mg,_v).call(this,{type:"failed",failureCount:y,error:_})},onPause:()=>{Ii(this,mg,_v).call(this,{type:"pause"})},onContinue:()=>{Ii(this,mg,_v).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0})),ms(this,Sh).start()}},dT=new WeakMap,L4=new WeakMap,Jf=new WeakMap,D4=new WeakMap,Sh=new WeakMap,mR=new WeakMap,R4=new WeakMap,mg=new WeakSet,_v=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,...ZUe(n.data,this.options),fetchMeta:s.meta??null};case"success":return zn(this,L4,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&&ms(this,L4)?{...ms(this,L4),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),nu.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),ms(this,Jf).notify({query:this,type:"updated",action:s})})},dBe);function ZUe(t,s){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:HUe(s.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function yvt(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 Iy,uBe,vvt=(uBe=class extends FA{constructor(s={}){super();za(this,Iy);this.config=s,zn(this,Iy,new Map)}build(s,r,n){const a=r.queryKey,o=r.queryHash??gje(a,r);let l=this.get(o);return l||(l=new gvt({client:s,queryKey:a,queryHash:o,options:s.defaultQueryOptions(r),state:n,defaultOptions:s.getQueryDefaults(a)}),this.add(l)),l}add(s){ms(this,Iy).has(s.queryHash)||(ms(this,Iy).set(s.queryHash,s),this.notify({type:"added",query:s}))}remove(s){const r=ms(this,Iy).get(s.queryHash);r&&(s.destroy(),r===s&&ms(this,Iy).delete(s.queryHash),this.notify({type:"removed",query:s}))}clear(){nu.batch(()=>{this.getAll().forEach(s=>{this.remove(s)})})}get(s){return ms(this,Iy).get(s)}getAll(){return[...ms(this,Iy).values()]}find(s){const r={exact:!0,...s};return this.getAll().find(n=>qEe(r,n))}findAll(s={}){const r=this.getAll();return Object.keys(s).length>0?r.filter(n=>qEe(s,n)):r}notify(s){nu.batch(()=>{this.listeners.forEach(r=>{r(s)})})}onFocus(){nu.batch(()=>{this.getAll().forEach(s=>{s.onFocus()})})}onOnline(){nu.batch(()=>{this.getAll().forEach(s=>{s.onOnline()})})}},Iy=new WeakMap,uBe),Ly,um,O4,Dy,w_,hBe,_vt=(hBe=class extends KUe{constructor(s){super();za(this,Dy);za(this,Ly);za(this,um);za(this,O4);this.mutationId=s.mutationId,zn(this,um,s.mutationCache),zn(this,Ly,[]),this.state=s.state||YUe(),this.setOptions(s.options),this.scheduleGc()}setOptions(s){this.options=s,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(s){ms(this,Ly).includes(s)||(ms(this,Ly).push(s),this.clearGcTimeout(),ms(this,um).notify({type:"observerAdded",mutation:this,observer:s}))}removeObserver(s){zn(this,Ly,ms(this,Ly).filter(r=>r!==s)),this.scheduleGc(),ms(this,um).notify({type:"observerRemoved",mutation:this,observer:s})}optionalRemove(){ms(this,Ly).length||(this.state.status==="pending"?this.scheduleGc():ms(this,um).remove(this))}continue(){var s;return((s=ms(this,O4))==null?void 0:s.continue())??this.execute(this.state.variables)}async execute(s){var o,l,i,d,u,p,f,y,_,b,N,w,S,C,A,I,L,O,V,q;const r=()=>{Ii(this,Dy,w_).call(this,{type:"continue"})};zn(this,O4,WUe({fn:()=>this.options.mutationFn?this.options.mutationFn(s):Promise.reject(new Error("No mutationFn found")),onFail:(B,U)=>{Ii(this,Dy,w_).call(this,{type:"failed",failureCount:B,error:U})},onPause:()=>{Ii(this,Dy,w_).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>ms(this,um).canRun(this)}));const n=this.state.status==="pending",a=!ms(this,O4).canStart();try{if(n)r();else{Ii(this,Dy,w_).call(this,{type:"pending",variables:s,isPaused:a}),await((l=(o=ms(this,um).config).onMutate)==null?void 0:l.call(o,s,this));const U=await((d=(i=this.options).onMutate)==null?void 0:d.call(i,s));U!==this.state.context&&Ii(this,Dy,w_).call(this,{type:"pending",context:U,variables:s,isPaused:a})}const B=await ms(this,O4).start();return await((p=(u=ms(this,um).config).onSuccess)==null?void 0:p.call(u,B,s,this.state.context,this)),await((y=(f=this.options).onSuccess)==null?void 0:y.call(f,B,s,this.state.context)),await((b=(_=ms(this,um).config).onSettled)==null?void 0:b.call(_,B,null,this.state.variables,this.state.context,this)),await((w=(N=this.options).onSettled)==null?void 0:w.call(N,B,null,s,this.state.context)),Ii(this,Dy,w_).call(this,{type:"success",data:B}),B}catch(B){try{throw await((C=(S=ms(this,um).config).onError)==null?void 0:C.call(S,B,s,this.state.context,this)),await((I=(A=this.options).onError)==null?void 0:I.call(A,B,s,this.state.context)),await((O=(L=ms(this,um).config).onSettled)==null?void 0:O.call(L,void 0,B,this.state.variables,this.state.context,this)),await((q=(V=this.options).onSettled)==null?void 0:q.call(V,void 0,B,s,this.state.context)),B}finally{Ii(this,Dy,w_).call(this,{type:"error",error:B})}}finally{ms(this,um).runNext(this)}}},Ly=new WeakMap,um=new WeakMap,O4=new WeakMap,Dy=new WeakSet,w_=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),nu.batch(()=>{ms(this,Ly).forEach(n=>{n.onMutationUpdate(s)}),ms(this,um).notify({mutation:this,type:"updated",action:s})})},hBe);function YUe(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Lv,pg,pR,mBe,bvt=(mBe=class extends FA{constructor(s={}){super();za(this,Lv);za(this,pg);za(this,pR);this.config=s,zn(this,Lv,new Set),zn(this,pg,new Map),zn(this,pR,0)}build(s,r,n){const a=new _vt({mutationCache:this,mutationId:++Y7(this,pR)._,options:s.defaultMutationOptions(r),state:n});return this.add(a),a}add(s){ms(this,Lv).add(s);const r=yz(s);if(typeof r=="string"){const n=ms(this,pg).get(r);n?n.push(s):ms(this,pg).set(r,[s])}this.notify({type:"added",mutation:s})}remove(s){if(ms(this,Lv).delete(s)){const r=yz(s);if(typeof r=="string"){const n=ms(this,pg).get(r);if(n)if(n.length>1){const a=n.indexOf(s);a!==-1&&n.splice(a,1)}else n[0]===s&&ms(this,pg).delete(r)}}this.notify({type:"removed",mutation:s})}canRun(s){const r=yz(s);if(typeof r=="string"){const n=ms(this,pg).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=yz(s);if(typeof r=="string"){const a=(n=ms(this,pg).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(){nu.batch(()=>{ms(this,Lv).forEach(s=>{this.notify({type:"removed",mutation:s})}),ms(this,Lv).clear(),ms(this,pg).clear()})}getAll(){return Array.from(ms(this,Lv))}find(s){const r={exact:!0,...s};return this.getAll().find(n=>UEe(r,n))}findAll(s={}){return this.getAll().filter(r=>UEe(s,r))}notify(s){nu.batch(()=>{this.listeners.forEach(r=>{r(s)})})}resumePausedMutations(){const s=this.getAll().filter(r=>r.state.isPaused);return nu.batch(()=>Promise.all(s.map(r=>r.continue().catch(pm))))}},Lv=new WeakMap,pg=new WeakMap,pR=new WeakMap,mBe);function yz(t){var s;return(s=t.options.scope)==null?void 0:s.id}function qoe(t){return{onFetch:(s,r)=>{var p,f,y,_,b;const n=s.options,a=(y=(f=(p=s.fetchOptions)==null?void 0:p.meta)==null?void 0:f.fetchMore)==null?void 0:y.direction,o=((_=s.state.data)==null?void 0:_.pages)||[],l=((b=s.state.data)==null?void 0:b.pageParams)||[];let i={pages:[],pageParams:[]},d=0;const u=async()=>{let N=!1;const w=A=>{Object.defineProperty(A,"signal",{enumerable:!0,get:()=>(s.signal.aborted?N=!0:s.signal.addEventListener("abort",()=>{N=!0}),s.signal)})},S=UUe(s.options,s.fetchOptions),C=async(A,I,L)=>{if(N)return Promise.reject();if(I==null&&A.pages.length)return Promise.resolve(A);const V=(()=>{const te={client:s.client,queryKey:s.queryKey,pageParam:I,direction:L?"backward":"forward",meta:s.options.meta};return w(te),te})(),q=await S(V),{maxPages:B}=s.options,U=L?uvt:dvt;return{pages:U(A.pages,q,B),pageParams:U(A.pageParams,I,B)}};if(a&&o.length){const A=a==="backward",I=A?XUe:zve,L={pages:o,pageParams:l},O=I(n,L);i=await C(L,O,A)}else{const A=t??o.length;do{const I=d===0?l[0]??n.initialPageParam:zve(n,i);if(d>0&&I==null)break;i=await C(i,I),d++}while(d{var N,w;return(w=(N=s.options).persister)==null?void 0:w.call(N,u,{client:s.client,queryKey:s.queryKey,meta:s.options.meta,signal:s.signal},r)}:s.fetchFn=u}}}function zve(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 XUe(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 wvt(t,s){return s?zve(t,s)!=null:!1}function jvt(t,s){return!s||!t.getPreviousPageParam?!1:XUe(t,s)!=null}var Gc,Q_,J_,uT,hT,eb,mT,pT,pBe,Nvt=(pBe=class{constructor(t={}){za(this,Gc);za(this,Q_);za(this,J_);za(this,uT);za(this,hT);za(this,eb);za(this,mT);za(this,pT);zn(this,Gc,t.queryCache||new vvt),zn(this,Q_,t.mutationCache||new bvt),zn(this,J_,t.defaultOptions||{}),zn(this,uT,new Map),zn(this,hT,new Map),zn(this,eb,0)}mount(){Y7(this,eb)._++,ms(this,eb)===1&&(zn(this,mT,vje.subscribe(async t=>{t&&(await this.resumePausedMutations(),ms(this,Gc).onFocus())})),zn(this,pT,$oe.subscribe(async t=>{t&&(await this.resumePausedMutations(),ms(this,Gc).onOnline())})))}unmount(){var t,s;Y7(this,eb)._--,ms(this,eb)===0&&((t=ms(this,mT))==null||t.call(this),zn(this,mT,void 0),(s=ms(this,pT))==null||s.call(this),zn(this,pT,void 0))}isFetching(t){return ms(this,Gc).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return ms(this,Q_).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=ms(this,Gc).get(s.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const s=this.defaultQueryOptions(t),r=ms(this,Gc).build(this,s),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(Pb(s.staleTime,r))&&this.prefetchQuery(s),Promise.resolve(n))}getQueriesData(t){return ms(this,Gc).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=ms(this,Gc).get(n.queryHash),o=a==null?void 0:a.state.data,l=lvt(s,o);if(l!==void 0)return ms(this,Gc).build(this,n).setData(l,{...r,manual:!0})}setQueriesData(t,s,r){return nu.batch(()=>ms(this,Gc).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,s,r)]))}getQueryState(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=ms(this,Gc).get(s.queryHash))==null?void 0:r.state}removeQueries(t){const s=ms(this,Gc);nu.batch(()=>{s.findAll(t).forEach(r=>{s.remove(r)})})}resetQueries(t,s){const r=ms(this,Gc);return nu.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},s)))}cancelQueries(t,s={}){const r={revert:!0,...s},n=nu.batch(()=>ms(this,Gc).findAll(t).map(a=>a.cancel(r)));return Promise.all(n).then(pm).catch(pm)}invalidateQueries(t,s={}){return nu.batch(()=>(ms(this,Gc).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=nu.batch(()=>ms(this,Gc).findAll(t).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let o=a.fetch(void 0,r);return r.throwOnError||(o=o.catch(pm)),a.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(n).then(pm)}fetchQuery(t){const s=this.defaultQueryOptions(t);s.retry===void 0&&(s.retry=!1);const r=ms(this,Gc).build(this,s);return r.isStaleByTime(Pb(s.staleTime,r))?r.fetch(s):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(pm).catch(pm)}fetchInfiniteQuery(t){return t.behavior=qoe(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(pm).catch(pm)}ensureInfiniteQueryData(t){return t.behavior=qoe(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return $oe.isOnline()?ms(this,Q_).resumePausedMutations():Promise.resolve()}getQueryCache(){return ms(this,Gc)}getMutationCache(){return ms(this,Q_)}getDefaultOptions(){return ms(this,J_)}setDefaultOptions(t){zn(this,J_,t)}setQueryDefaults(t,s){ms(this,uT).set(HS(t),{queryKey:t,defaultOptions:s})}getQueryDefaults(t){const s=[...ms(this,uT).values()],r={};return s.forEach(n=>{Q8(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,s){ms(this,hT).set(HS(t),{mutationKey:t,defaultOptions:s})}getMutationDefaults(t){const s=[...ms(this,hT).values()],r={};return s.forEach(n=>{Q8(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const s={...ms(this,J_).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return s.queryHash||(s.queryHash=gje(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===yje&&(s.enabled=!1),s}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...ms(this,J_).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){ms(this,Gc).clear(),ms(this,Q_).clear()}},Gc=new WeakMap,Q_=new WeakMap,J_=new WeakMap,uT=new WeakMap,hT=new WeakMap,eb=new WeakMap,mT=new WeakMap,pT=new WeakMap,pBe),Xm,eo,fR,hm,F4,fT,tb,sb,xR,xT,gT,z4,B4,rb,yT,Uo,AI,Bve,$ve,qve,Uve,Vve,Hve,Gve,JUe,fBe,QUe=(fBe=class extends FA{constructor(s,r){super();za(this,Uo);za(this,Xm);za(this,eo);za(this,fR);za(this,hm);za(this,F4);za(this,fT);za(this,tb);za(this,sb);za(this,xR);za(this,xT);za(this,gT);za(this,z4);za(this,B4);za(this,rb);za(this,yT,new Set);this.options=r,zn(this,Xm,s),zn(this,sb,null),zn(this,tb,Fve()),this.options.experimental_prefetchInRender||ms(this,tb).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&&(ms(this,eo).addObserver(this),GEe(ms(this,eo),this.options)?Ii(this,Uo,AI).call(this):this.updateResult(),Ii(this,Uo,Uve).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Wve(ms(this,eo),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Wve(ms(this,eo),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ii(this,Uo,Vve).call(this),Ii(this,Uo,Hve).call(this),ms(this,eo).removeObserver(this)}setOptions(s){const r=this.options,n=ms(this,eo);if(this.options=ms(this,Xm).defaultQueryOptions(s),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ex(this.options.enabled,ms(this,eo))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Ii(this,Uo,Gve).call(this),ms(this,eo).setOptions(this.options),r._defaulted&&!Boe(this.options,r)&&ms(this,Xm).getQueryCache().notify({type:"observerOptionsUpdated",query:ms(this,eo),observer:this});const a=this.hasListeners();a&&WEe(ms(this,eo),n,this.options,r)&&Ii(this,Uo,AI).call(this),this.updateResult(),a&&(ms(this,eo)!==n||ex(this.options.enabled,ms(this,eo))!==ex(r.enabled,ms(this,eo))||Pb(this.options.staleTime,ms(this,eo))!==Pb(r.staleTime,ms(this,eo)))&&Ii(this,Uo,Bve).call(this);const o=Ii(this,Uo,$ve).call(this);a&&(ms(this,eo)!==n||ex(this.options.enabled,ms(this,eo))!==ex(r.enabled,ms(this,eo))||o!==ms(this,rb))&&Ii(this,Uo,qve).call(this,o)}getOptimisticResult(s){const r=ms(this,Xm).getQueryCache().build(ms(this,Xm),s),n=this.createResult(r,s);return Svt(this,n)&&(zn(this,hm,n),zn(this,fT,this.options),zn(this,F4,ms(this,eo).state)),n}getCurrentResult(){return ms(this,hm)}trackResult(s,r){return new Proxy(s,{get:(n,a)=>(this.trackProp(a),r==null||r(a),Reflect.get(n,a))})}trackProp(s){ms(this,yT).add(s)}getCurrentQuery(){return ms(this,eo)}refetch({...s}={}){return this.fetch({...s})}fetchOptimistic(s){const r=ms(this,Xm).defaultQueryOptions(s),n=ms(this,Xm).getQueryCache().build(ms(this,Xm),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(s){return Ii(this,Uo,AI).call(this,{...s,cancelRefetch:s.cancelRefetch??!0}).then(()=>(this.updateResult(),ms(this,hm)))}createResult(s,r){var B;const n=ms(this,eo),a=this.options,o=ms(this,hm),l=ms(this,F4),i=ms(this,fT),u=s!==n?s.state:ms(this,fR),{state:p}=s;let f={...p},y=!1,_;if(r._optimisticResults){const U=this.hasListeners(),te=!U&&GEe(s,r),Y=U&&WEe(s,n,r,a);(te||Y)&&(f={...f,...ZUe(p.data,s.options)}),r._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:b,errorUpdatedAt:N,status:w}=f;_=f.data;let S=!1;if(r.placeholderData!==void 0&&_===void 0&&w==="pending"){let U;o!=null&&o.isPlaceholderData&&r.placeholderData===(i==null?void 0:i.placeholderData)?(U=o.data,S=!0):U=typeof r.placeholderData=="function"?r.placeholderData((B=ms(this,gT))==null?void 0:B.state.data,ms(this,gT)):r.placeholderData,U!==void 0&&(w="success",_=Ove(o==null?void 0:o.data,U,r),y=!0)}if(r.select&&_!==void 0&&!S)if(o&&_===(l==null?void 0:l.data)&&r.select===ms(this,xR))_=ms(this,xT);else try{zn(this,xR,r.select),_=r.select(_),_=Ove(o==null?void 0:o.data,_,r),zn(this,xT,_),zn(this,sb,null)}catch(U){zn(this,sb,U)}ms(this,sb)&&(b=ms(this,sb),_=ms(this,xT),N=Date.now(),w="error");const C=f.fetchStatus==="fetching",A=w==="pending",I=w==="error",L=A&&C,O=_!==void 0,q={status:w,fetchStatus:f.fetchStatus,isPending:A,isSuccess:w==="success",isError:I,isInitialLoading:L,isLoading:L,data:_,dataUpdatedAt:f.dataUpdatedAt,error:b,errorUpdatedAt:N,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:C,isRefetching:C&&!A,isLoadingError:I&&!O,isPaused:f.fetchStatus==="paused",isPlaceholderData:y,isRefetchError:I&&O,isStale:_je(s,r),refetch:this.refetch,promise:ms(this,tb),isEnabled:ex(r.enabled,s)!==!1};if(this.options.experimental_prefetchInRender){const U=J=>{q.status==="error"?J.reject(q.error):q.data!==void 0&&J.resolve(q.data)},te=()=>{const J=zn(this,tb,q.promise=Fve());U(J)},Y=ms(this,tb);switch(Y.status){case"pending":s.queryHash===n.queryHash&&U(Y);break;case"fulfilled":(q.status==="error"||q.data!==Y.value)&&te();break;case"rejected":(q.status!=="error"||q.error!==Y.reason)&&te();break}}return q}updateResult(){const s=ms(this,hm),r=this.createResult(ms(this,eo),this.options);if(zn(this,F4,ms(this,eo).state),zn(this,fT,this.options),ms(this,F4).data!==void 0&&zn(this,gT,ms(this,eo)),Boe(r,s))return;zn(this,hm,r);const n=()=>{if(!s)return!0;const{notifyOnChangeProps:a}=this.options,o=typeof a=="function"?a():a;if(o==="all"||!o&&!ms(this,yT).size)return!0;const l=new Set(o??ms(this,yT));return this.options.throwOnError&&l.add("error"),Object.keys(ms(this,hm)).some(i=>{const d=i;return ms(this,hm)[d]!==s[d]&&l.has(d)})};Ii(this,Uo,JUe).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ii(this,Uo,Uve).call(this)}},Xm=new WeakMap,eo=new WeakMap,fR=new WeakMap,hm=new WeakMap,F4=new WeakMap,fT=new WeakMap,tb=new WeakMap,sb=new WeakMap,xR=new WeakMap,xT=new WeakMap,gT=new WeakMap,z4=new WeakMap,B4=new WeakMap,rb=new WeakMap,yT=new WeakMap,Uo=new WeakSet,AI=function(s){Ii(this,Uo,Gve).call(this);let r=ms(this,eo).fetch(this.options,s);return s!=null&&s.throwOnError||(r=r.catch(pm)),r},Bve=function(){Ii(this,Uo,Vve).call(this);const s=Pb(this.options.staleTime,ms(this,eo));if(VS||ms(this,hm).isStale||!Dve(s))return;const n=$Ue(ms(this,hm).dataUpdatedAt,s)+1;zn(this,z4,setTimeout(()=>{ms(this,hm).isStale||this.updateResult()},n))},$ve=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(ms(this,eo)):this.options.refetchInterval)??!1},qve=function(s){Ii(this,Uo,Hve).call(this),zn(this,rb,s),!(VS||ex(this.options.enabled,ms(this,eo))===!1||!Dve(ms(this,rb))||ms(this,rb)===0)&&zn(this,B4,setInterval(()=>{(this.options.refetchIntervalInBackground||vje.isFocused())&&Ii(this,Uo,AI).call(this)},ms(this,rb)))},Uve=function(){Ii(this,Uo,Bve).call(this),Ii(this,Uo,qve).call(this,Ii(this,Uo,$ve).call(this))},Vve=function(){ms(this,z4)&&(clearTimeout(ms(this,z4)),zn(this,z4,void 0))},Hve=function(){ms(this,B4)&&(clearInterval(ms(this,B4)),zn(this,B4,void 0))},Gve=function(){const s=ms(this,Xm).getQueryCache().build(ms(this,Xm),this.options);if(s===ms(this,eo))return;const r=ms(this,eo);zn(this,eo,s),zn(this,fR,s.state),this.hasListeners()&&(r==null||r.removeObserver(this),s.addObserver(this))},JUe=function(s){nu.batch(()=>{s.listeners&&this.listeners.forEach(r=>{r(ms(this,hm))}),ms(this,Xm).getQueryCache().notify({query:ms(this,eo),type:"observerResultsUpdated"})})},fBe);function kvt(t,s){return ex(s.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&s.retryOnMount===!1)}function GEe(t,s){return kvt(t,s)||t.state.data!==void 0&&Wve(t,s,s.refetchOnMount)}function Wve(t,s,r){if(ex(s.enabled,t)!==!1&&Pb(s.staleTime,t)!=="static"){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&_je(t,s)}return!1}function WEe(t,s,r,n){return(t!==s||ex(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&_je(t,r)}function _je(t,s){return ex(s.enabled,t)!==!1&&t.isStaleByTime(Pb(s.staleTime,t))}function Svt(t,s){return!Boe(t.getCurrentResult(),s)}var Cvt=class extends QUe{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:qoe()})}getOptimisticResult(t){return t.behavior=qoe(),super.getOptimisticResult(t)}fetchNextPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"backward"}}})}createResult(t,s){var b,N;const{state:r}=t,n=super.createResult(t,s),{isFetching:a,isRefetching:o,isError:l,isRefetchError:i}=n,d=(N=(b=r.fetchMeta)==null?void 0:b.fetchMore)==null?void 0:N.direction,u=l&&d==="forward",p=a&&d==="forward",f=l&&d==="backward",y=a&&d==="backward";return{...n,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:wvt(s,r.data),hasPreviousPage:jvt(s,r.data),isFetchNextPageError:u,isFetchingNextPage:p,isFetchPreviousPageError:f,isFetchingPreviousPage:y,isRefetchError:i&&!u&&!f,isRefetching:o&&!p&&!y}}},nb,ab,Qm,Dv,l1,Die,Kve,xBe,Mvt=(xBe=class extends FA{constructor(r,n){super();za(this,l1);za(this,nb);za(this,ab);za(this,Qm);za(this,Dv);zn(this,nb,r),this.setOptions(n),this.bindMethods(),Ii(this,l1,Die).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=ms(this,nb).defaultMutationOptions(r),Boe(this.options,n)||ms(this,nb).getMutationCache().notify({type:"observerOptionsUpdated",mutation:ms(this,Qm),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&HS(n.mutationKey)!==HS(this.options.mutationKey)?this.reset():((a=ms(this,Qm))==null?void 0:a.state.status)==="pending"&&ms(this,Qm).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=ms(this,Qm))==null||r.removeObserver(this)}onMutationUpdate(r){Ii(this,l1,Die).call(this),Ii(this,l1,Kve).call(this,r)}getCurrentResult(){return ms(this,ab)}reset(){var r;(r=ms(this,Qm))==null||r.removeObserver(this),zn(this,Qm,void 0),Ii(this,l1,Die).call(this),Ii(this,l1,Kve).call(this)}mutate(r,n){var a;return zn(this,Dv,n),(a=ms(this,Qm))==null||a.removeObserver(this),zn(this,Qm,ms(this,nb).getMutationCache().build(ms(this,nb),this.options)),ms(this,Qm).addObserver(this),ms(this,Qm).execute(r)}},nb=new WeakMap,ab=new WeakMap,Qm=new WeakMap,Dv=new WeakMap,l1=new WeakSet,Die=function(){var n;const r=((n=ms(this,Qm))==null?void 0:n.state)??YUe();zn(this,ab,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},Kve=function(r){nu.batch(()=>{var n,a,o,l,i,d,u,p;if(ms(this,Dv)&&this.hasListeners()){const f=ms(this,ab).variables,y=ms(this,ab).context;(r==null?void 0:r.type)==="success"?((a=(n=ms(this,Dv)).onSuccess)==null||a.call(n,r.data,f,y),(l=(o=ms(this,Dv)).onSettled)==null||l.call(o,r.data,null,f,y)):(r==null?void 0:r.type)==="error"&&((d=(i=ms(this,Dv)).onError)==null||d.call(i,r.error,f,y),(p=(u=ms(this,Dv)).onSettled)==null||p.call(u,void 0,r.error,f,y))}this.listeners.forEach(f=>{f(ms(this,ab))})})},xBe),eVe=k.createContext(void 0),Qt=t=>{const s=k.useContext(eVe);if(!s)throw new Error("No QueryClient set, use QueryClientProvider to set one");return s},Tvt=({client:t,children:s})=>(k.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),e.jsx(eVe.Provider,{value:t,children:s})),tVe=k.createContext(!1),Avt=()=>k.useContext(tVe);tVe.Provider;function Evt(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Pvt=k.createContext(Evt()),Ivt=()=>k.useContext(Pvt),Lvt=(t,s)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(s.isReset()||(t.retryOnMount=!1))},Dvt=t=>{k.useEffect(()=>{t.clearReset()},[t])},Rvt=({result:t,errorResetBoundary:s,throwOnError:r,query:n,suspense:a})=>t.isError&&!s.isReset()&&!t.isFetching&&n&&(a&&t.data===void 0||VUe(r,[t.error,n])),Ovt=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))}},Fvt=(t,s)=>t.isLoading&&t.isFetching&&!s,zvt=(t,s)=>(t==null?void 0:t.suspense)&&s.isPending,KEe=(t,s,r)=>s.fetchOptimistic(t).catch(()=>{r.clearReset()});function sVe(t,s,r){var f,y,_,b,N;const n=Avt(),a=Ivt(),o=Qt(),l=o.defaultQueryOptions(t);(y=(f=o.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||y.call(f,l),l._optimisticResults=n?"isRestoring":"optimistic",Ovt(l),Lvt(l,a),Dvt(a);const i=!o.getQueryCache().get(l.queryHash),[d]=k.useState(()=>new s(o,l)),u=d.getOptimisticResult(l),p=!n&&t.subscribed!==!1;if(k.useSyncExternalStore(k.useCallback(w=>{const S=p?d.subscribe(nu.batchCalls(w)):pm;return d.updateResult(),S},[d,p]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),k.useEffect(()=>{d.setOptions(l)},[l,d]),zvt(l,u))throw KEe(l,d,a);if(Rvt({result:u,errorResetBoundary:a,throwOnError:l.throwOnError,query:o.getQueryCache().get(l.queryHash),suspense:l.suspense}))throw u.error;if((b=(_=o.getDefaultOptions().queries)==null?void 0:_._experimental_afterQuery)==null||b.call(_,l,u),l.experimental_prefetchInRender&&!VS&&Fvt(u,n)){const w=i?KEe(l,d,a):(N=o.getQueryCache().get(l.queryHash))==null?void 0:N.promise;w==null||w.catch(pm).finally(()=>{d.updateResult()})}return l.notifyOnChangeProps?u:d.trackResult(u)}function gt(t,s){return sVe(t,QUe)}function Pt(t,s){const r=Qt(),[n]=k.useState(()=>new Mvt(r,t));k.useEffect(()=>{n.setOptions(t)},[n,t]);const a=k.useSyncExternalStore(k.useCallback(l=>n.subscribe(nu.batchCalls(l)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),o=k.useCallback((l,i)=>{n.mutate(l,i).catch(pm)},[n]);if(a.error&&VUe(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}function Bvt(t,s){return sVe(t,Cvt)}/** * @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 J8(){return J8=Object.assign?Object.assign.bind():function(t){for(var s=1;s"u")throw new Error(s)}function rVe(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function qvt(){return Math.random().toString(36).substr(2,8)}function YEe(t,s){return{usr:t.state,key:t.key,idx:s}}function Zve(t,s,r,n){return r===void 0&&(r=null),J8({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof s=="string"?zA(s):s,{state:r,key:s&&s.key||n||qvt()})}function Uoe(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 zA(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 Uvt(t,s,r,n){n===void 0&&(n={});let{window:a=document.defaultView,v5Compat:o=!1}=n,l=a.history,i=lb.Pop,d=null,u=p();u==null&&(u=0,l.replaceState(J8({},l.state,{idx:u}),""));function p(){return(l.state||{idx:null}).idx}function f(){i=lb.Pop;let w=p(),S=w==null?null:w-u;u=w,d&&d({action:i,location:N.location,delta:S})}function y(w,S){i=lb.Push;let C=Zve(N.location,w,S);u=p()+1;let A=YEe(C,u),I=N.createHref(C);try{l.pushState(A,"",I)}catch(L){if(L instanceof DOMException&&L.name==="DataCloneError")throw L;a.location.assign(I)}o&&d&&d({action:i,location:N.location,delta:1})}function _(w,S){i=lb.Replace;let C=Zve(N.location,w,S);u=p();let A=YEe(C,u),I=N.createHref(C);l.replaceState(A,"",I),o&&d&&d({action:i,location:N.location,delta:0})}function b(w){let S=a.location.origin!=="null"?a.location.origin:a.location.href,C=typeof w=="string"?w:Uoe(w);return C=C.replace(/ $/,"%20"),bd(S,"No window.location.(origin|href) available to create URL for href: "+C),new URL(C,S)}let N={get action(){return i},get location(){return t(a,l)},listen(w){if(d)throw new Error("A history only accepts one active listener");return a.addEventListener(ZEe,f),d=w,()=>{a.removeEventListener(ZEe,f),d=null}},createHref(w){return s(a,w)},createURL:b,encodeLocation(w){let S=b(w);return{pathname:S.pathname,search:S.search,hash:S.hash}},push:y,replace:_,go(w){return l.go(w)}};return N}var XEe;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(XEe||(XEe={}));function Vvt(t,s,r){return r===void 0&&(r="/"),Hvt(t,s,r,!1)}function Hvt(t,s,r,n){let a=typeof s=="string"?zA(s):s,o=bje(a.pathname||"/",r);if(o==null)return null;let l=nVe(t);Gvt(l);let i=null;for(let d=0;i==null&&d{let d={relativePath:i===void 0?o.path||"":i,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};d.relativePath.startsWith("/")&&(bd(d.relativePath.startsWith(n),'Absolute route path "'+d.relativePath+'" nested under path '+('"'+n+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),d.relativePath=d.relativePath.slice(n.length));let u=Ib([n,d.relativePath]),p=r.concat(d);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+'".')),nVe(o.children,s,p,u)),!(o.path==null&&!o.index)&&s.push({path:u,score:Jvt(u,o.index),routesMeta:p})};return t.forEach((o,l)=>{var i;if(o.path===""||!((i=o.path)!=null&&i.includes("?")))a(o,l);else for(let d of aVe(o.path))a(o,l,d)}),s}function aVe(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=aVe(n.join("/")),i=[];return i.push(...l.map(d=>d===""?o:[o,d].join("/"))),a&&i.push(...l),i.map(d=>t.startsWith("/")&&d===""?"/":d)}function Gvt(t){t.sort((s,r)=>s.score!==r.score?r.score-s.score:e1t(s.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const Wvt=/^:[\w-]+$/,Kvt=3,Zvt=2,Yvt=1,Xvt=10,Qvt=-2,QEe=t=>t==="*";function Jvt(t,s){let r=t.split("/"),n=r.length;return r.some(QEe)&&(n+=Qvt),s&&(n+=Zvt),r.filter(a=>!QEe(a)).reduce((a,o)=>a+(Wvt.test(o)?Kvt:o===""?Yvt:Xvt),n)}function e1t(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 t1t(t,s,r){let{routesMeta:n}=t,a={},o="/",l=[];for(let i=0;i{let{paramName:y,isOptional:_}=p;if(y==="*"){let N=i[f]||"";l=o.slice(0,o.length-N.length).replace(/(.)\/+$/,"$1")}const b=i[f];return _&&!b?u[y]=void 0:u[y]=(b||"").replace(/%2F/g,"/"),u},{}),pathname:o,pathnameBase:l,pattern:t}}function s1t(t,s,r){s===void 0&&(s=!1),r===void 0&&(r=!0),rVe(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let n=[],a="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,i,d)=>(n.push({paramName:i,isOptional:d!=null}),d?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(n.push({paramName:"*"}),a+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?a+="\\/*$":t!==""&&t!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,s?void 0:"i"),n]}function r1t(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return rVe(!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 bje(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 n1t(t,s){s===void 0&&(s="/");let{pathname:r,search:n="",hash:a=""}=typeof t=="string"?zA(t):t;return{pathname:r?r.startsWith("/")?r:a1t(r,s):s,search:l1t(n),hash:c1t(a)}}function a1t(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 Qxe(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 i1t(t){return t.filter((s,r)=>r===0||s.route.path&&s.route.path.length>0)}function wje(t,s){let r=i1t(t);return s?r.map((n,a)=>a===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function jje(t,s,r,n){n===void 0&&(n=!1);let a;typeof t=="string"?a=zA(t):(a=J8({},t),bd(!a.pathname||!a.pathname.includes("?"),Qxe("?","pathname","search",a)),bd(!a.pathname||!a.pathname.includes("#"),Qxe("#","pathname","hash",a)),bd(!a.search||!a.search.includes("#"),Qxe("#","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 y=l.split("/");for(;y[0]==="..";)y.shift(),f-=1;a.pathname=y.join("/")}i=f>=0?s[f]:"/"}let d=n1t(a,i),u=l&&l!=="/"&&l.endsWith("/"),p=(o||l===".")&&r.endsWith("/");return!d.pathname.endsWith("/")&&(u||p)&&(d.pathname+="/"),d}const Ib=t=>t.join("/").replace(/\/\/+/g,"/"),o1t=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),l1t=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,c1t=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function d1t(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const iVe=["post","put","patch","delete"];new Set(iVe);const u1t=["get",...iVe];new Set(u1t);/** * 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 eD(){return eD=Object.assign?Object.assign.bind():function(t){for(var s=1;s{i.current=!0}),k.useCallback(function(u,p){if(p===void 0&&(p={}),!i.current)return;if(typeof u=="number"){n.go(u);return}let f=jje(u,JSON.parse(l),o,p.relative==="path");t==null&&s!=="/"&&(f.pathname=f.pathname==="/"?s:Ib([s,f.pathname])),(p.replace?n.replace:n.push)(f,p.state,p)},[s,n,l,o,t])}const f1t=k.createContext(null);function x1t(t){let s=k.useContext(j0).outlet;return s&&k.createElement(f1t.Provider,{value:t},s)}function io(){let{matches:t}=k.useContext(j0),s=t[t.length-1];return s?s.params:{}}function cVe(t,s){let{relative:r}=s===void 0?{}:s,{future:n}=k.useContext(uw),{matches:a}=k.useContext(j0),{pathname:o}=$l(),l=JSON.stringify(wje(a,n.v7_relativeSplatPath));return k.useMemo(()=>jje(t,JSON.parse(l),o,r==="path"),[t,l,o,r])}function g1t(t,s){return y1t(t,s)}function y1t(t,s,r,n){BA()||bd(!1);let{navigator:a}=k.useContext(uw),{matches:o}=k.useContext(j0),l=o[o.length-1],i=l?l.params:{};l&&l.pathname;let d=l?l.pathnameBase:"/";l&&l.route;let u=$l(),p;if(s){var f;let w=typeof s=="string"?zA(s):s;d==="/"||(f=w.pathname)!=null&&f.startsWith(d)||bd(!1),p=w}else p=u;let y=p.pathname||"/",_=y;if(d!=="/"){let w=d.replace(/^\//,"").split("/");_="/"+y.replace(/^\//,"").split("/").slice(w.length).join("/")}let b=Vvt(t,{pathname:_}),N=j1t(b&&b.map(w=>Object.assign({},w,{params:Object.assign({},i,w.params),pathname:Ib([d,a.encodeLocation?a.encodeLocation(w.pathname).pathname:w.pathname]),pathnameBase:w.pathnameBase==="/"?d:Ib([d,a.encodeLocation?a.encodeLocation(w.pathnameBase).pathname:w.pathnameBase])})),o,r,n);return s&&N?k.createElement(aue.Provider,{value:{location:eD({pathname:"/",search:"",hash:"",state:null,key:"default"},p),navigationType:lb.Pop}},N):N}function v1t(){let t=C1t(),s=d1t(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 _1t=k.createElement(v1t,null);class b1t 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(j0.Provider,{value:this.props.routeContext},k.createElement(oVe.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function w1t(t){let{routeContext:s,match:r,children:n}=t,a=k.useContext(Nje);return a&&a.static&&a.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=r.route.id),k.createElement(j0.Provider,{value:s},n)}function j1t(t,s,r,n){var a;if(s===void 0&&(s=[]),r===void 0&&(r=null),n===void 0&&(n=null),t==null){var o;if(!r)return null;if(r.errors)t=r.matches;else if((o=n)!=null&&o.v7_partialHydration&&s.length===0&&!r.initialized&&r.matches.length>0)t=r.matches;else return null}let l=t,i=(a=r)==null?void 0:a.errors;if(i!=null){let p=l.findIndex(f=>f.route.id&&(i==null?void 0:i[f.route.id])!==void 0);p>=0||bd(!1),l=l.slice(0,Math.min(l.length,p+1))}let d=!1,u=-1;if(r&&n&&n.v7_partialHydration)for(let p=0;p=0?l=l.slice(0,u+1):l=[l[0]];break}}}return l.reduceRight((p,f,y)=>{let _,b=!1,N=null,w=null;r&&(_=i&&f.route.id?i[f.route.id]:void 0,N=f.route.errorElement||_1t,d&&(u<0&&y===0?(b=!0,w=null):u===y&&(b=!0,w=f.route.hydrateFallbackElement||null)));let S=s.concat(l.slice(0,y+1)),C=()=>{let A;return _?A=N:b?A=w:f.route.Component?A=k.createElement(f.route.Component,null):f.route.element?A=f.route.element:A=p,k.createElement(w1t,{match:f,routeContext:{outlet:p,matches:S,isDataRoute:r!=null},children:A})};return r&&(f.route.ErrorBoundary||f.route.errorElement||y===0)?k.createElement(b1t,{location:r.location,revalidation:r.revalidation,component:N,error:_,children:C(),routeContext:{outlet:null,matches:S,isDataRoute:!0}}):C()},null)}var dVe=function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t}(dVe||{}),Voe=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}(Voe||{});function N1t(t){let s=k.useContext(Nje);return s||bd(!1),s}function k1t(t){let s=k.useContext(h1t);return s||bd(!1),s}function S1t(t){let s=k.useContext(j0);return s||bd(!1),s}function uVe(t){let s=S1t(),r=s.matches[s.matches.length-1];return r.route.id||bd(!1),r.route.id}function C1t(){var t;let s=k.useContext(oVe),r=k1t(Voe.UseRouteError),n=uVe(Voe.UseRouteError);return s!==void 0?s:(t=r.errors)==null?void 0:t[n]}function M1t(){let{router:t}=N1t(dVe.UseNavigateStable),s=uVe(Voe.UseNavigateStable),r=k.useRef(!1);return lVe(()=>{r.current=!0}),k.useCallback(function(a,o){o===void 0&&(o={}),r.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,eD({fromRouteId:s},o)))},[t,s])}function T1t(t,s){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function Jxe(t){let{to:s,replace:r,state:n,relative:a}=t;BA()||bd(!1);let{future:o,static:l}=k.useContext(uw),{matches:i}=k.useContext(j0),{pathname:d}=$l(),u=wr(),p=jje(s,wje(i,o.v7_relativeSplatPath),d,a==="path"),f=JSON.stringify(p);return k.useEffect(()=>u(JSON.parse(f),{replace:r,state:n,relative:a}),[u,f,a,r,n]),null}function A1t(t){return x1t(t.context)}function ys(t){bd(!1)}function E1t(t){let{basename:s="/",children:r=null,location:n,navigationType:a=lb.Pop,navigator:o,static:l=!1,future:i}=t;BA()&&bd(!1);let d=s.replace(/^\/*/,"/"),u=k.useMemo(()=>({basename:d,navigator:o,static:l,future:eD({v7_relativeSplatPath:!1},i)}),[d,i,o,l]);typeof n=="string"&&(n=zA(n));let{pathname:p="/",search:f="",hash:y="",state:_=null,key:b="default"}=n,N=k.useMemo(()=>{let w=bje(p,d);return w==null?null:{location:{pathname:w,search:f,hash:y,state:_,key:b},navigationType:a}},[d,p,f,y,_,b,a]);return N==null?null:k.createElement(uw.Provider,{value:u},k.createElement(aue.Provider,{children:r,value:N}))}function Hoe(t){let{children:s,location:r}=t;return g1t(Yve(s),r)}new Promise(()=>{});function Yve(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,Yve(n.props.children,o));return}n.type!==ys&&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=Yve(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 Xve(){return Xve=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&(r[a]=t[a]);return r}function I1t(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function L1t(t,s){return t.button===0&&(!s||s==="_self")&&!I1t(t)}function Qve(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 D1t(t,s){let r=Qve(t);return s&&s.forEach((n,a)=>{r.has(a)||s.getAll(a).forEach(o=>{r.append(a,o)})}),r}const R1t=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],O1t="6";try{window.__reactRouterVersion=O1t}catch{}const F1t="startTransition",ePe=c2e[F1t];function z1t(t){let{basename:s,children:r,future:n,window:a}=t,o=k.useRef();o.current==null&&(o.current=$vt({window:a,v5Compat:!0}));let l=o.current,[i,d]=k.useState({action:l.action,location:l.location}),{v7_startTransition:u}=n||{},p=k.useCallback(f=>{u&&ePe?ePe(()=>d(f)):d(f)},[d,u]);return k.useLayoutEffect(()=>l.listen(p),[l,p]),k.useEffect(()=>T1t(n),[n]),k.createElement(E1t,{basename:s,children:r,location:i.location,navigationType:i.action,navigator:l,future:n})}const B1t=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",$1t=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,da=k.forwardRef(function(s,r){let{onClick:n,relative:a,reloadDocument:o,replace:l,state:i,target:d,to:u,preventScrollReset:p,viewTransition:f}=s,y=P1t(s,R1t),{basename:_}=k.useContext(uw),b,N=!1;if(typeof u=="string"&&$1t.test(u)&&(b=u,B1t))try{let A=new URL(window.location.href),I=u.startsWith("//")?new URL(A.protocol+u):new URL(u),L=bje(I.pathname,_);I.origin===A.origin&&L!=null?u=L+I.search+I.hash:N=!0}catch{}let w=m1t(u,{relative:a}),S=q1t(u,{replace:l,state:i,target:d,preventScrollReset:p,relative:a,viewTransition:f});function C(A){n&&n(A),A.defaultPrevented||S(A)}return k.createElement("a",Xve({},y,{href:b||w,onClick:N||o?n:C,ref:r,target:d}))});var tPe;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(tPe||(tPe={}));var sPe;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(sPe||(sPe={}));function q1t(t,s){let{target:r,replace:n,state:a,preventScrollReset:o,relative:l,viewTransition:i}=s===void 0?{}:s,d=wr(),u=$l(),p=cVe(t,{relative:l});return k.useCallback(f=>{if(L1t(f,r)){f.preventDefault();let y=n!==void 0?n:Uoe(u)===Uoe(p);d(t,{replace:y,state:a,preventScrollReset:o,relative:l,viewTransition:i})}},[u,d,p,n,a,r,t,o,l,i])}function Nc(t){let s=k.useRef(Qve(t)),r=k.useRef(!1),n=$l(),a=k.useMemo(()=>D1t(n.search,r.current?null:s.current),[n.search]),o=wr(),l=k.useCallback((i,d)=>{const u=Qve(typeof i=="function"?i(a):i);r.current=!0,o("?"+u,d)},[o,a]);return[a,l]}var U1t=typeof Element<"u",V1t=typeof Map=="function",H1t=typeof Set=="function",G1t=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function Rie(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(!Rie(t[n],s[n]))return!1;return!0}var o;if(V1t&&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(!Rie(n.value[1],s.get(n.value[0])))return!1;return!0}if(H1t&&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(G1t&&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(U1t&&t instanceof Element)return!1;for(n=r;n--!==0;)if(!((a[n]==="_owner"||a[n]==="__v"||a[n]==="__o")&&t.$$typeof)&&!Rie(t[a[n]],s[a[n]]))return!1;return!0}return t!==t&&s!==s}var W1t=function(s,r){try{return Rie(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 K1t=ao(W1t);var Z1t=function(t,s,r,n,a,o,l,i){if(!t){var d;if(s===void 0)d=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[r,n,a,o,l,i],p=0;d=new Error(s.replace(/%s/g,function(){return u[p++]})),d.name="Invariant Violation"}throw d.framesToPop=1,d}},Y1t=Z1t;const rPe=ao(Y1t);var X1t=function(s,r,n,a){var o=n?n.call(a,s,r):void 0;if(o!==void 0)return!!o;if(s===r)return!0;if(typeof s!="object"||!s||typeof r!="object"||!r)return!1;var l=Object.keys(s),i=Object.keys(r);if(l.length!==i.length)return!1;for(var d=Object.prototype.hasOwnProperty.bind(r),u=0;u(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(hVe||{}),ege={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"]}},nPe=Object.values(hVe),kje={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},J1t=Object.entries(kje).reduce((t,[s,r])=>(t[r]=s,t),{}),Sg="data-rh",qM={DEFAULT_TITLE:"defaultTitle",DEFER:"defer",ENCODE_SPECIAL_CHARACTERS:"encodeSpecialCharacters",ON_CHANGE_CLIENT_STATE:"onChangeClientState",TITLE_TEMPLATE:"titleTemplate",PRIORITIZE_SEO_TAGS:"prioritizeSeoTags"},UM=(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},e_t=t=>{let s=UM(t,"title");const r=UM(t,qM.TITLE_TEMPLATE);if(Array.isArray(s)&&(s=s.join("")),r&&s)return r.replace(/%s/g,()=>s);const n=UM(t,qM.DEFAULT_TITLE);return s||n||void 0},t_t=t=>UM(t,qM.ON_CHANGE_CLIENT_STATE)||(()=>{}),tge=(t,s)=>s.filter(r=>typeof r[t]<"u").map(r=>r[t]).reduce((r,n)=>({...r,...n}),{}),s_t=(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),Z6=(t,s,r)=>{const n={};return r.filter(a=>Array.isArray(a[t])?!0:(typeof a[t]<"u"&&r_t(`Helmet: ${t} should be of type "Array". Instead found type "${typeof a[t]}"`),!1)).map(a=>a[t]).reverse().reduce((a,o)=>{const l={};o.filter(d=>{let u;const p=Object.keys(d);for(let y=0;ya.push(d));const i=Object.keys(l);for(let d=0;d{if(Array.isArray(t)&&t.length){for(let r=0;r({baseTag:s_t(["href"],t),bodyAttributes:tge("bodyAttributes",t),defer:UM(t,qM.DEFER),encode:UM(t,qM.ENCODE_SPECIAL_CHARACTERS),htmlAttributes:tge("htmlAttributes",t),linkTags:Z6("link",["rel","href"],t),metaTags:Z6("meta",["name","charset","http-equiv","property","itemprop"],t),noscriptTags:Z6("noscript",["innerHTML"],t),onChangeClientState:t_t(t),scriptTags:Z6("script",["src","innerHTML"],t),styleTags:Z6("style",["cssText"],t),title:e_t(t),titleAttributes:tge("titleAttributes",t),prioritizeSeoTags:n_t(t,qM.PRIORITIZE_SEO_TAGS)}),mVe=t=>Array.isArray(t)?t.join(""):t,i_t=(t,s)=>{const r=Object.keys(t);for(let n=0;nArray.isArray(t)?t.reduce((r,n)=>(i_t(n,s)?r.priority.push(n):r.default.push(n),r),{priority:[],default:[]}):{default:t,priority:[]},aPe=(t,s)=>({...t,[s]:void 0}),o_t=["noscript","script","style"],Jve=(t,s=!0)=>s===!1?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),pVe=t=>Object.keys(t).reduce((s,r)=>{const n=typeof t[r]<"u"?`${r}="${t[r]}"`:`${r}`;return s?`${s} ${n}`:n},""),l_t=(t,s,r,n)=>{const a=pVe(r),o=mVe(s);return a?`<${t} ${Sg}="true" ${a}>${Jve(o,n)}`:`<${t} ${Sg}="true">${Jve(o,n)}`},c_t=(t,s,r=!0)=>s.reduce((n,a)=>{const o=a,l=Object.keys(o).filter(u=>!(u==="innerHTML"||u==="cssText")).reduce((u,p)=>{const f=typeof o[p]>"u"?p:`${p}="${Jve(o[p],r)}"`;return u?`${u} ${f}`:f},""),i=o.innerHTML||o.cssText||"",d=o_t.indexOf(t)===-1;return`${n}<${t} ${Sg}="true" ${l}${d?"/>":`>${i}`}`},""),fVe=(t,s={})=>Object.keys(t).reduce((r,n)=>{const a=kje[n];return r[a||n]=t[n],r},s),d_t=(t,s,r)=>{const n={key:s,[Sg]:!0},a=fVe(r,n);return[xt.createElement("title",a,s)]},Oie=(t,s)=>s.map((r,n)=>{const a={key:n,[Sg]:!0};return Object.keys(r).forEach(o=>{const i=kje[o]||o;if(i==="innerHTML"||i==="cssText"){const d=r.innerHTML||r.cssText;a.dangerouslySetInnerHTML={__html:d}}else a[i]=r[o]}),xt.createElement(t,a)}),Qf=(t,s,r=!0)=>{switch(t){case"title":return{toComponent:()=>d_t(t,s.title,s.titleAttributes),toString:()=>l_t(t,s.title,s.titleAttributes,r)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>fVe(s),toString:()=>pVe(s)};default:return{toComponent:()=>Oie(t,s),toString:()=>c_t(t,s,r)}}},u_t=({metaTags:t,linkTags:s,scriptTags:r,encode:n})=>{const a=sge(t,ege.meta),o=sge(s,ege.link),l=sge(r,ege.script);return{priorityMethods:{toComponent:()=>[...Oie("meta",a.priority),...Oie("link",o.priority),...Oie("script",l.priority)],toString:()=>`${Qf("meta",a.priority,n)} ${Qf("link",o.priority,n)} ${Qf("script",l.priority,n)}`},metaTags:a.default,linkTags:o.default,scriptTags:l.default}},h_t=t=>{const{baseTag:s,bodyAttributes:r,encode:n=!0,htmlAttributes:a,noscriptTags:o,styleTags:l,title:i="",titleAttributes:d,prioritizeSeoTags:u}=t;let{linkTags:p,metaTags:f,scriptTags:y}=t,_={toComponent:()=>{},toString:()=>""};return u&&({priorityMethods:_,linkTags:p,metaTags:f,scriptTags:y}=u_t(t)),{priority:_,base:Qf("base",s,n),bodyAttributes:Qf("bodyAttributes",r,n),htmlAttributes:Qf("htmlAttributes",a,n),link:Qf("link",p,n),meta:Qf("meta",f,n),noscript:Qf("noscript",o,n),script:Qf("script",y,n),style:Qf("style",l,n),title:Qf("title",{title:i,titleAttributes:d},n)}},e1e=h_t,vz=[],xVe=!!(typeof window<"u"&&window.document&&window.document.createElement),t1e=class{constructor(t,s){En(this,"instances",[]);En(this,"canUseDOM",xVe);En(this,"context");En(this,"value",{setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?vz:this.instances,add:t=>{(this.canUseDOM?vz:this.instances).push(t)},remove:t=>{const s=(this.canUseDOM?vz:this.instances).indexOf(t);(this.canUseDOM?vz:this.instances).splice(s,1)}}});this.context=t,this.canUseDOM=s||!1,s||(t.helmet=e1e({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},m_t={},gVe=xt.createContext(m_t),$4,yVe=($4=class extends k.Component{constructor(r){super(r);En(this,"helmetData");this.helmetData=new t1e(this.props.context||{},$4.canUseDOM)}render(){return xt.createElement(gVe.Provider,{value:this.helmetData.value},this.props.children)}},En($4,"canUseDOM",xVe),$4),o5=(t,s)=>{const r=document.head||document.querySelector("head"),n=r.querySelectorAll(`${t}[${Sg}]`),a=[].slice.call(n),o=[];let l;return s&&s.length&&s.forEach(i=>{const d=document.createElement(t);for(const u in i)if(Object.prototype.hasOwnProperty.call(i,u))if(u==="innerHTML")d.innerHTML=i.innerHTML;else if(u==="cssText")d.styleSheet?d.styleSheet.cssText=i.cssText:d.appendChild(document.createTextNode(i.cssText));else{const p=u,f=typeof i[p]>"u"?"":i[p];d.setAttribute(u,f)}d.setAttribute(Sg,"true"),a.some((u,p)=>(l=p,d.isEqualNode(u)))?a.splice(l,1):o.push(d)}),a.forEach(i=>{var d;return(d=i.parentNode)==null?void 0:d.removeChild(i)}),o.forEach(i=>r.appendChild(i)),{oldTags:a,newTags:o}},s1e=(t,s)=>{const r=document.getElementsByTagName(t)[0];if(!r)return;const n=r.getAttribute(Sg),a=n?n.split(","):[],o=[...a],l=Object.keys(s);for(const i of l){const d=s[i]||"";r.getAttribute(i)!==d&&r.setAttribute(i,d),a.indexOf(i)===-1&&a.push(i);const u=o.indexOf(i);u!==-1&&o.splice(u,1)}for(let i=o.length-1;i>=0;i-=1)r.removeAttribute(o[i]);a.length===o.length?r.removeAttribute(Sg):r.getAttribute(Sg)!==l.join(",")&&r.setAttribute(Sg,l.join(","))},p_t=(t,s)=>{typeof t<"u"&&document.title!==t&&(document.title=mVe(t)),s1e("title",s)},iPe=(t,s)=>{const{baseTag:r,bodyAttributes:n,htmlAttributes:a,linkTags:o,metaTags:l,noscriptTags:i,onChangeClientState:d,scriptTags:u,styleTags:p,title:f,titleAttributes:y}=t;s1e("body",n),s1e("html",a),p_t(f,y);const _={baseTag:o5("base",r),linkTags:o5("link",o),metaTags:o5("meta",l),noscriptTags:o5("noscript",i),scriptTags:o5("script",u),styleTags:o5("style",p)},b={},N={};Object.keys(_).forEach(w=>{const{newTags:S,oldTags:C}=_[w];S.length&&(b[w]=S),C.length&&(N[w]=_[w].oldTags)}),s&&s(),d(t,b,N)},Y6=null,f_t=t=>{Y6&&cancelAnimationFrame(Y6),t.defer?Y6=requestAnimationFrame(()=>{iPe(t,()=>{Y6=null})}):(iPe(t),Y6=null)},x_t=f_t,oPe=class extends k.Component{constructor(){super(...arguments);En(this,"rendered",!1)}shouldComponentUpdate(s){return!Q1t(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=a_t(s.get().map(o=>{const l={...o.props};return delete l.context,l}));yVe.canUseDOM?x_t(a):e1e&&(n=e1e(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}},A0e,kl=(A0e=class extends k.Component{shouldComponentUpdate(t){return!K1t(aPe(this.props,"helmetData"),aPe(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 rPe(nPe.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 ${nPe.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`),rPe(!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 xt.Children.forEach(t,n=>{if(!n||!n.props)return;const{children:a,...o}=n.props,l=Object.keys(o).reduce((d,u)=>(d[J1t[u]||u]=o[u],d),{});let{type:i}=n;switch(typeof i=="symbol"?i=i.toString():this.warnOnInvalidChildren(n,a),i){case"Symbol(react.fragment)":s=this.mapChildrenToProps(a,s);break;case"link":case"meta":case"noscript":case"script":case"style":r=this.flattenArrayTypeChildren(n,r,l,a);break;default:s=this.mapObjectTypeChildren(n,s,l,a);break}}),this.mapArrayTypeChildrenToProps(r,s)}render(){const{children:t,...s}=this.props;let r={...s},{helmetData:n}=s;if(t&&(r=this.mapChildrenToProps(t,r)),n&&!(n instanceof t1e)){const a=n;n=new t1e(a.context,!0),delete r.helmetData}return n?xt.createElement(oPe,{...r,context:n.value}):xt.createElement(gVe.Consumer,null,a=>xt.createElement(oPe,{...r,context:a}))}},En(A0e,"defaultProps",{defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1}),A0e);const g_t=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>Ba(async()=>{const{default:n}=await Promise.resolve().then(()=>$A);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)};class Sje extends Error{constructor(s,r="FunctionsError",n){super(s),this.name=r,this.context=n}}class y_t extends Sje{constructor(s){super("Failed to send a request to the Edge Function","FunctionsFetchError",s)}}class v_t extends Sje{constructor(s){super("Relay Error invoking the Edge Function","FunctionsRelayError",s)}}class __t extends Sje{constructor(s){super("Edge Function returned a non-2xx status code","FunctionsHttpError",s)}}var r1e;(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"})(r1e||(r1e={}));var b_t=function(t,s,r,n){function a(o){return o instanceof r?o:new r(function(l){l(o)})}return new(r||(r=Promise))(function(o,l){function i(p){try{u(n.next(p))}catch(f){l(f)}}function d(p){try{u(n.throw(p))}catch(f){l(f)}}function u(p){p.done?o(p.value):a(p.value).then(i,d)}u((n=n.apply(t,s||[])).next())})};class w_t{constructor(s,{headers:r={},customFetch:n,region:a=r1e.Any}={}){this.url=s,this.headers=r,this.region=a,this.fetch=g_t(n)}setAuth(s){this.headers.Authorization=`Bearer ${s}`}invoke(s,r={}){var n;return b_t(this,void 0,void 0,function*(){try{const{headers:a,method:o,body:l}=r;let i={},{region:d}=r;d||(d=this.region),d&&d!=="any"&&(i["x-region"]=d);let u;l&&(a&&!Object.prototype.hasOwnProperty.call(a,"Content-Type")||!a)&&(typeof Blob<"u"&&l instanceof Blob||l instanceof ArrayBuffer?(i["Content-Type"]="application/octet-stream",u=l):typeof l=="string"?(i["Content-Type"]="text/plain",u=l):typeof FormData<"u"&&l instanceof FormData?u=l:(i["Content-Type"]="application/json",u=JSON.stringify(l)));const p=yield this.fetch(`${this.url}/${s}`,{method:o||"POST",headers:Object.assign(Object.assign(Object.assign({},i),this.headers),a),body:u}).catch(b=>{throw new y_t(b)}),f=p.headers.get("x-relay-error");if(f&&f==="true")throw new v_t(p);if(!p.ok)throw new __t(p);let y=((n=p.headers.get("Content-Type"))!==null&&n!==void 0?n:"text/plain").split(";")[0].trim(),_;return y==="application/json"?_=yield p.json():y==="application/octet-stream"?_=yield p.blob():y==="text/event-stream"?_=p:y==="multipart/form-data"?_=yield p.formData():_=yield p.text(),{data:_,error:null}}catch(a){return{data:null,error:a}}})}}var np={},Cje={},iue={},TR={},oue={},lue={},j_t=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")},MT=j_t();const N_t=MT.fetch,vVe=MT.fetch.bind(MT),_Ve=MT.Headers,k_t=MT.Request,S_t=MT.Response,$A=Object.freeze(Object.defineProperty({__proto__:null,Headers:_Ve,Request:k_t,Response:S_t,default:vVe,fetch:N_t},Symbol.toStringTag,{value:"Module"})),C_t=ept($A);var cue={};Object.defineProperty(cue,"__esModule",{value:!0});let M_t=class extends Error{constructor(s){super(s.message),this.name="PostgrestError",this.details=s.details,this.hint=s.hint,this.code=s.code}};cue.default=M_t;var bVe=gd&&gd.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(lue,"__esModule",{value:!0});const T_t=bVe(C_t),A_t=bVe(cue);let E_t=class{constructor(s){this.shouldThrowOnError=!1,this.method=s.method,this.url=s.url,this.headers=s.headers,this.schema=s.schema,this.body=s.body,this.shouldThrowOnError=s.shouldThrowOnError,this.signal=s.signal,this.isMaybeSingle=s.isMaybeSingle,s.fetch?this.fetch=s.fetch:typeof fetch>"u"?this.fetch=T_t.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(s,r){return this.headers=Object.assign({},this.headers),this.headers[s]=r,this}then(s,r){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),this.method!=="GET"&&this.method!=="HEAD"&&(this.headers["Content-Type"]="application/json");const n=this.fetch;let a=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async o=>{var l,i,d;let u=null,p=null,f=null,y=o.status,_=o.statusText;if(o.ok){if(this.method!=="HEAD"){const S=await o.text();S===""||(this.headers.Accept==="text/csv"||this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?p=S:p=JSON.parse(S))}const N=(l=this.headers.Prefer)===null||l===void 0?void 0:l.match(/count=(exact|planned|estimated)/),w=(i=o.headers.get("content-range"))===null||i===void 0?void 0:i.split("/");N&&w&&w.length>1&&(f=parseInt(w[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(p)&&(p.length>1?(u={code:"PGRST116",details:`Results contain ${p.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},p=null,f=null,y=406,_="Not Acceptable"):p.length===1?p=p[0]:p=null)}else{const N=await o.text();try{u=JSON.parse(N),Array.isArray(u)&&o.status===404&&(p=[],u=null,y=200,_="OK")}catch{o.status===404&&N===""?(y=204,_="No Content"):u={message:N}}if(u&&this.isMaybeSingle&&(!((d=u==null?void 0:u.details)===null||d===void 0)&&d.includes("0 rows"))&&(u=null,y=200,_="OK"),u&&this.shouldThrowOnError)throw new A_t.default(u)}return{error:u,data:p,count:f,status:y,statusText:_}});return this.shouldThrowOnError||(a=a.catch(o=>{var l,i,d;return{error:{message:`${(l=o==null?void 0:o.name)!==null&&l!==void 0?l:"FetchError"}: ${o==null?void 0:o.message}`,details:`${(i=o==null?void 0:o.stack)!==null&&i!==void 0?i:""}`,hint:"",code:`${(d=o==null?void 0:o.code)!==null&&d!==void 0?d:""}`},data:null,count:null,status:0,statusText:""}})),a.then(s,r)}returns(){return this}overrideTypes(){return this}};lue.default=E_t;var P_t=gd&&gd.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(oue,"__esModule",{value:!0});const I_t=P_t(lue);let L_t=class extends I_t.default{select(s){let r=!1;const n=(s??"*").split("").map(a=>/\s/.test(a)&&!r?"":(a==='"'&&(r=!r),a)).join("");return this.url.searchParams.set("select",n),this.headers.Prefer&&(this.headers.Prefer+=","),this.headers.Prefer+="return=representation",this}order(s,{ascending:r=!0,nullsFirst:n,foreignTable:a,referencedTable:o=a}={}){const l=o?`${o}.order`:"order",i=this.url.searchParams.get(l);return this.url.searchParams.set(l,`${i?`${i},`:""}${s}.${r?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(s,{foreignTable:r,referencedTable:n=r}={}){const a=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(a,`${s}`),this}range(s,r,{foreignTable:n,referencedTable:a=n}={}){const o=typeof a>"u"?"offset":`${a}.offset`,l=typeof a>"u"?"limit":`${a}.limit`;return this.url.searchParams.set(o,`${s}`),this.url.searchParams.set(l,`${r-s+1}`),this}abortSignal(s){return this.signal=s,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return this.method==="GET"?this.headers.Accept="application/json":this.headers.Accept="application/vnd.pgrst.object+json",this.isMaybeSingle=!0,this}csv(){return this.headers.Accept="text/csv",this}geojson(){return this.headers.Accept="application/geo+json",this}explain({analyze:s=!1,verbose:r=!1,settings:n=!1,buffers:a=!1,wal:o=!1,format:l="text"}={}){var i;const d=[s?"analyze":null,r?"verbose":null,n?"settings":null,a?"buffers":null,o?"wal":null].filter(Boolean).join("|"),u=(i=this.headers.Accept)!==null&&i!==void 0?i:"application/json";return this.headers.Accept=`application/vnd.pgrst.plan+${l}; for="${u}"; options=${d};`,l==="json"?this:this}rollback(){var s;return((s=this.headers.Prefer)!==null&&s!==void 0?s:"").trim().length>0?this.headers.Prefer+=",tx=rollback":this.headers.Prefer="tx=rollback",this}returns(){return this}};oue.default=L_t;var D_t=gd&&gd.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(TR,"__esModule",{value:!0});const R_t=D_t(oue);let O_t=class extends R_t.default{eq(s,r){return this.url.searchParams.append(s,`eq.${r}`),this}neq(s,r){return this.url.searchParams.append(s,`neq.${r}`),this}gt(s,r){return this.url.searchParams.append(s,`gt.${r}`),this}gte(s,r){return this.url.searchParams.append(s,`gte.${r}`),this}lt(s,r){return this.url.searchParams.append(s,`lt.${r}`),this}lte(s,r){return this.url.searchParams.append(s,`lte.${r}`),this}like(s,r){return this.url.searchParams.append(s,`like.${r}`),this}likeAllOf(s,r){return this.url.searchParams.append(s,`like(all).{${r.join(",")}}`),this}likeAnyOf(s,r){return this.url.searchParams.append(s,`like(any).{${r.join(",")}}`),this}ilike(s,r){return this.url.searchParams.append(s,`ilike.${r}`),this}ilikeAllOf(s,r){return this.url.searchParams.append(s,`ilike(all).{${r.join(",")}}`),this}ilikeAnyOf(s,r){return this.url.searchParams.append(s,`ilike(any).{${r.join(",")}}`),this}is(s,r){return this.url.searchParams.append(s,`is.${r}`),this}in(s,r){const n=Array.from(new Set(r)).map(a=>typeof a=="string"&&new RegExp("[,()]").test(a)?`"${a}"`:`${a}`).join(",");return this.url.searchParams.append(s,`in.(${n})`),this}contains(s,r){return typeof r=="string"?this.url.searchParams.append(s,`cs.${r}`):Array.isArray(r)?this.url.searchParams.append(s,`cs.{${r.join(",")}}`):this.url.searchParams.append(s,`cs.${JSON.stringify(r)}`),this}containedBy(s,r){return typeof r=="string"?this.url.searchParams.append(s,`cd.${r}`):Array.isArray(r)?this.url.searchParams.append(s,`cd.{${r.join(",")}}`):this.url.searchParams.append(s,`cd.${JSON.stringify(r)}`),this}rangeGt(s,r){return this.url.searchParams.append(s,`sr.${r}`),this}rangeGte(s,r){return this.url.searchParams.append(s,`nxl.${r}`),this}rangeLt(s,r){return this.url.searchParams.append(s,`sl.${r}`),this}rangeLte(s,r){return this.url.searchParams.append(s,`nxr.${r}`),this}rangeAdjacent(s,r){return this.url.searchParams.append(s,`adj.${r}`),this}overlaps(s,r){return typeof r=="string"?this.url.searchParams.append(s,`ov.${r}`):this.url.searchParams.append(s,`ov.{${r.join(",")}}`),this}textSearch(s,r,{config:n,type:a}={}){let o="";a==="plain"?o="pl":a==="phrase"?o="ph":a==="websearch"&&(o="w");const l=n===void 0?"":`(${n})`;return this.url.searchParams.append(s,`${o}fts${l}.${r}`),this}match(s){return Object.entries(s).forEach(([r,n])=>{this.url.searchParams.append(r,`eq.${n}`)}),this}not(s,r,n){return this.url.searchParams.append(s,`not.${r}.${n}`),this}or(s,{foreignTable:r,referencedTable:n=r}={}){const a=n?`${n}.or`:"or";return this.url.searchParams.append(a,`(${s})`),this}filter(s,r,n){return this.url.searchParams.append(s,`${r}.${n}`),this}};TR.default=O_t;var F_t=gd&&gd.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(iue,"__esModule",{value:!0});const X6=F_t(TR);let z_t=class{constructor(s,{headers:r={},schema:n,fetch:a}){this.url=s,this.headers=r,this.schema=n,this.fetch=a}select(s,{head:r=!1,count:n}={}){const a=r?"HEAD":"GET";let o=!1;const l=(s??"*").split("").map(i=>/\s/.test(i)&&!o?"":(i==='"'&&(o=!o),i)).join("");return this.url.searchParams.set("select",l),n&&(this.headers.Prefer=`count=${n}`),new X6.default({method:a,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(s,{count:r,defaultToNull:n=!0}={}){const a="POST",o=[];if(this.headers.Prefer&&o.push(this.headers.Prefer),r&&o.push(`count=${r}`),n||o.push("missing=default"),this.headers.Prefer=o.join(","),Array.isArray(s)){const l=s.reduce((i,d)=>i.concat(Object.keys(d)),[]);if(l.length>0){const i=[...new Set(l)].map(d=>`"${d}"`);this.url.searchParams.set("columns",i.join(","))}}return new X6.default({method:a,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:this.fetch,allowEmpty:!1})}upsert(s,{onConflict:r,ignoreDuplicates:n=!1,count:a,defaultToNull:o=!0}={}){const l="POST",i=[`resolution=${n?"ignore":"merge"}-duplicates`];if(r!==void 0&&this.url.searchParams.set("on_conflict",r),this.headers.Prefer&&i.push(this.headers.Prefer),a&&i.push(`count=${a}`),o||i.push("missing=default"),this.headers.Prefer=i.join(","),Array.isArray(s)){const d=s.reduce((u,p)=>u.concat(Object.keys(p)),[]);if(d.length>0){const u=[...new Set(d)].map(p=>`"${p}"`);this.url.searchParams.set("columns",u.join(","))}}return new X6.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:this.fetch,allowEmpty:!1})}update(s,{count:r}={}){const n="PATCH",a=[];return this.headers.Prefer&&a.push(this.headers.Prefer),r&&a.push(`count=${r}`),this.headers.Prefer=a.join(","),new X6.default({method:n,url:this.url,headers:this.headers,schema:this.schema,body:s,fetch:this.fetch,allowEmpty:!1})}delete({count:s}={}){const r="DELETE",n=[];return s&&n.push(`count=${s}`),this.headers.Prefer&&n.unshift(this.headers.Prefer),this.headers.Prefer=n.join(","),new X6.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}};iue.default=z_t;var due={},uue={};Object.defineProperty(uue,"__esModule",{value:!0});uue.version=void 0;uue.version="0.0.0-automated";Object.defineProperty(due,"__esModule",{value:!0});due.DEFAULT_HEADERS=void 0;const B_t=uue;due.DEFAULT_HEADERS={"X-Client-Info":`postgrest-js/${B_t.version}`};var wVe=gd&&gd.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Cje,"__esModule",{value:!0});const $_t=wVe(iue),q_t=wVe(TR),U_t=due;let V_t=class jVe{constructor(s,{headers:r={},schema:n,fetch:a}={}){this.url=s,this.headers=Object.assign(Object.assign({},U_t.DEFAULT_HEADERS),r),this.schemaName=n,this.fetch=a}from(s){const r=new URL(`${this.url}/${s}`);return new $_t.default(r,{headers:Object.assign({},this.headers),schema:this.schemaName,fetch:this.fetch})}schema(s){return new jVe(this.url,{headers:this.headers,schema:s,fetch:this.fetch})}rpc(s,r={},{head:n=!1,get:a=!1,count:o}={}){let l;const i=new URL(`${this.url}/rpc/${s}`);let d;n||a?(l=n?"HEAD":"GET",Object.entries(r).filter(([p,f])=>f!==void 0).map(([p,f])=>[p,Array.isArray(f)?`{${f.join(",")}}`:`${f}`]).forEach(([p,f])=>{i.searchParams.append(p,f)})):(l="POST",d=r);const u=Object.assign({},this.headers);return o&&(u.Prefer=`count=${o}`),new q_t.default({method:l,url:i,headers:u,schema:this.schemaName,body:d,fetch:this.fetch,allowEmpty:!1})}};Cje.default=V_t;var qA=gd&&gd.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(np,"__esModule",{value:!0});np.PostgrestError=np.PostgrestBuilder=np.PostgrestTransformBuilder=np.PostgrestFilterBuilder=np.PostgrestQueryBuilder=np.PostgrestClient=void 0;const NVe=qA(Cje);np.PostgrestClient=NVe.default;const kVe=qA(iue);np.PostgrestQueryBuilder=kVe.default;const SVe=qA(TR);np.PostgrestFilterBuilder=SVe.default;const CVe=qA(oue);np.PostgrestTransformBuilder=CVe.default;const MVe=qA(lue);np.PostgrestBuilder=MVe.default;const TVe=qA(cue);np.PostgrestError=TVe.default;var H_t=np.default={PostgrestClient:NVe.default,PostgrestQueryBuilder:kVe.default,PostgrestFilterBuilder:SVe.default,PostgrestTransformBuilder:CVe.default,PostgrestBuilder:MVe.default,PostgrestError:TVe.default};const{PostgrestClient:G_t,PostgrestQueryBuilder:GTs,PostgrestFilterBuilder:WTs,PostgrestTransformBuilder:KTs,PostgrestBuilder:ZTs,PostgrestError:YTs}=H_t;let n1e;typeof window>"u"?n1e=require("ws"):n1e=window.WebSocket;const W_t=n1e,K_t="2.11.10",Z_t={"X-Client-Info":`realtime-js/${K_t}`},Y_t="1.0.0",AVe=1e4,X_t=1e3;var VM;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(VM||(VM={}));var dm;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(dm||(dm={}));var xg;(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"})(xg||(xg={}));var a1e;(function(t){t.websocket="websocket"})(a1e||(a1e={}));var c4;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(c4||(c4={}));class Q_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 d=n.decode(s.slice(l,l+o));l=l+o;const u=JSON.parse(n.decode(s.slice(l,s.byteLength)));return{ref:null,topic:i,event:d,payload:u}}}class EVe{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)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}var Al;(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"})(Al||(Al={}));const lPe=(t,s,r={})=>{var n;const a=(n=r.skipTypes)!==null&&n!==void 0?n:[];return Object.keys(s).reduce((o,l)=>(o[l]=J_t(l,t,s,a),o),{})},J_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)?PVe(o,l):i1e(l)},PVe=(t,s)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return rbt(s,r)}switch(t){case Al.bool:return ebt(s);case Al.float4:case Al.float8:case Al.int2:case Al.int4:case Al.int8:case Al.numeric:case Al.oid:return tbt(s);case Al.json:case Al.jsonb:return sbt(s);case Al.timestamp:return nbt(s);case Al.abstime:case Al.date:case Al.daterange:case Al.int4range:case Al.int8range:case Al.money:case Al.reltime:case Al.text:case Al.time:case Al.timestamptz:case Al.timetz:case Al.tsrange:case Al.tstzrange:return i1e(s);default:return i1e(s)}},i1e=t=>t,ebt=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},tbt=t=>{if(typeof t=="string"){const s=parseFloat(t);if(!Number.isNaN(s))return s}return t},sbt=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch(s){return console.log(`JSON parse error: ${s}`),t}return t},rbt=(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=>PVe(s,i))}return t},nbt=t=>typeof t=="string"?t.replace(" ","T"):t,IVe=t=>{let s=t;return s=s.replace(/^ws/i,"http"),s=s.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,""),s.replace(/\/+$/,"")};class rge{constructor(s,r,n={},a=AVe){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 cPe;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(cPe||(cPe={}));class KL{constructor(s,r){this.channel=s,this.state={},this.pendingDiffs=[],this.joinRef=null,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=KL.syncState(this.state,a,o,l),this.pendingDiffs.forEach(d=>{this.state=KL.syncDiff(this.state,d,o,l)}),this.pendingDiffs=[],i()}),this.channel._on(n.diff,{},a=>{const{onJoin:o,onLeave:l,onSync:i}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(a):(this.state=KL.syncDiff(this.state,a,o,l),i())}),this.onJoin((a,o,l)=>{this.channel._trigger("presence",{event:"join",key:a,currentPresences:o,newPresences:l})}),this.onLeave((a,o,l)=>{this.channel._trigger("presence",{event:"leave",key:a,currentPresences:o,leftPresences:l})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(s,r,n,a){const o=this.cloneDeep(s),l=this.transformState(r),i={},d={};return this.map(o,(u,p)=>{l[u]||(d[u]=p)}),this.map(l,(u,p)=>{const f=o[u];if(f){const y=p.map(w=>w.presence_ref),_=f.map(w=>w.presence_ref),b=p.filter(w=>_.indexOf(w.presence_ref)<0),N=f.filter(w=>y.indexOf(w.presence_ref)<0);b.length>0&&(i[u]=b),N.length>0&&(d[u]=N)}else i[u]=p}),this.syncDiff(o,{joins:i,leaves:d},n,a)}static syncDiff(s,r,n,a){const{joins:o,leaves:l}={joins:this.transformState(r.joins),leaves:this.transformState(r.leaves)};return n||(n=()=>{}),a||(a=()=>{}),this.map(o,(i,d)=>{var u;const p=(u=s[i])!==null&&u!==void 0?u:[];if(s[i]=this.cloneDeep(d),p.length>0){const f=s[i].map(_=>_.presence_ref),y=p.filter(_=>f.indexOf(_.presence_ref)<0);s[i].unshift(...y)}n(i,p,d)}),this.map(l,(i,d)=>{let u=s[i];if(!u)return;const p=d.map(f=>f.presence_ref);u=u.filter(f=>p.indexOf(f.presence_ref)<0),s[i]=u,a(i,u,d),u.length===0&&delete s[i]}),s}static map(s,r){return Object.getOwnPropertyNames(s).map(n=>r(n,s[n]))}static transformState(s){return s=this.cloneDeep(s),Object.getOwnPropertyNames(s).reduce((r,n)=>{const a=s[n];return"metas"in a?r[n]=a.metas.map(o=>(o.presence_ref=o.phx_ref,delete o.phx_ref,delete o.phx_ref_prev,o)):r[n]=a,r},{})}static cloneDeep(s){return JSON.parse(JSON.stringify(s))}onJoin(s){this.caller.onJoin=s}onLeave(s){this.caller.onLeave=s}onSync(s){this.caller.onSync=s}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var dPe;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(dPe||(dPe={}));var uPe;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(uPe||(uPe={}));var Nv;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(Nv||(Nv={}));class Mje{constructor(s,r={config:{}},n){this.topic=s,this.params=r,this.socket=n,this.bindings={},this.state=dm.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=s.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:""},private:!1},r.config),this.timeout=this.socket.timeout,this.joinPush=new rge(this,xg.join,this.params,this.timeout),this.rejoinTimer=new EVe(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=dm.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(a=>a.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=dm.closed,this.socket._remove(this)}),this._onError(a=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,a),this.state=dm.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=dm.errored,this.rejoinTimer.scheduleTimeout())}),this._on(xg.reply,{},(a,o)=>{this._trigger(this._replyEventName(o),a)}),this.presence=new KL(this),this.broadcastEndpointURL=IVe(this.socket.endPoint)+"/api/broadcast",this.private=this.params.config.private||!1}subscribe(s,r=this.timeout){var n,a;if(this.socket.isConnected()||this.socket.connect(),this.joinedOnce)throw"tried to subscribe multiple times. 'subscribe' can only be called a single time per channel instance";{const{config:{broadcast:o,presence:l,private:i}}=this.params;this._onError(p=>s==null?void 0:s(Nv.CHANNEL_ERROR,p)),this._onClose(()=>s==null?void 0:s(Nv.CLOSED));const d={},u={broadcast:o,presence:l,postgres_changes:(a=(n=this.bindings.postgres_changes)===null||n===void 0?void 0:n.map(p=>p.filter))!==null&&a!==void 0?a:[],private:i};this.socket.accessTokenValue&&(d.access_token=this.socket.accessTokenValue),this.updateJoinPayload(Object.assign({config:u},d)),this.joinedOnce=!0,this._rejoin(r),this.joinPush.receive("ok",async({postgres_changes:p})=>{var f;if(this.socket.setAuth(),p===void 0){s==null||s(Nv.SUBSCRIBED);return}else{const y=this.bindings.postgres_changes,_=(f=y==null?void 0:y.length)!==null&&f!==void 0?f:0,b=[];for(let N=0;N<_;N++){const w=y[N],{filter:{event:S,schema:C,table:A,filter:I}}=w,L=p&&p[N];if(L&&L.event===S&&L.schema===C&&L.table===A&&L.filter===I)b.push(Object.assign(Object.assign({},w),{id:L.id}));else{this.unsubscribe(),this.state=dm.errored,s==null||s(Nv.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=b,s&&s(Nv.SUBSCRIBED);return}}).receive("error",p=>{this.state=dm.errored,s==null||s(Nv.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(p).join(", ")||"error")))}).receive("timeout",()=>{s==null||s(Nv.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._on(s,r,n)}async send(s,r={}){var n,a;if(!this._canPush()&&s.type==="broadcast"){const{event:o,payload:l}=s,d={method:"POST",headers:{Authorization:this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"",apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:o,payload:l,private:this.private}]})};try{const u=await this._fetchWithTimeout(this.broadcastEndpointURL,d,(n=r.timeout)!==null&&n!==void 0?n:this.timeout);return await((a=u.body)===null||a===void 0?void 0:a.cancel()),u.ok?"ok":"error"}catch(u){return u.name==="AbortError"?"timed out":"error"}}else return new Promise(o=>{var l,i,d;const u=this._push(s.type,s,r.timeout||this.timeout);s.type==="broadcast"&&!(!((d=(i=(l=this.params)===null||l===void 0?void 0:l.config)===null||i===void 0?void 0:i.broadcast)===null||d===void 0)&&d.ack)&&o("ok"),u.receive("ok",()=>o("ok")),u.receive("error",()=>o("error")),u.receive("timeout",()=>o("timed out"))})}updateJoinPayload(s){this.joinPush.updatePayload(s)}unsubscribe(s=this.timeout){this.state=dm.leaving;const r=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(xg.close,"leave",this._joinRef())};return this.joinPush.destroy(),new Promise(n=>{const a=new rge(this,xg.leave,{},s);a.receive("ok",()=>{r(),n("ok")}).receive("timeout",()=>{r(),n("timed out")}).receive("error",()=>{n("error")}),a.send(),this._canPush()||a.trigger("ok",{})})}teardown(){this.pushBuffer.forEach(s=>s.destroy()),this.rejoinTimer&&clearTimeout(this.rejoinTimer.timer),this.joinPush.destroy()}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 rge(this,s,r,n);return this._canPush()?a.send():(a.startTimeout(),this.pushBuffer.push(a)),a}_onMessage(s,r,n){return r}_isMember(s){return this.topic===s}_joinRef(){return this.joinPush.ref}_trigger(s,r,n){var a,o;const l=s.toLocaleLowerCase(),{close:i,error:d,leave:u,join:p}=xg;if(n&&[i,d,u,p].indexOf(l)>=0&&n!==this._joinRef())return;let y=this._onMessage(l,r,n);if(r&&!y)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(l)?(a=this.bindings.postgres_changes)===null||a===void 0||a.filter(_=>{var b,N,w;return((b=_.filter)===null||b===void 0?void 0:b.event)==="*"||((w=(N=_.filter)===null||N===void 0?void 0:N.event)===null||w===void 0?void 0:w.toLocaleLowerCase())===l}).map(_=>_.callback(y,n)):(o=this.bindings[l])===null||o===void 0||o.filter(_=>{var b,N,w,S,C,A;if(["broadcast","presence","postgres_changes"].includes(l))if("id"in _){const I=_.id,L=(b=_.filter)===null||b===void 0?void 0:b.event;return I&&((N=r.ids)===null||N===void 0?void 0:N.includes(I))&&(L==="*"||(L==null?void 0:L.toLocaleLowerCase())===((w=r.data)===null||w===void 0?void 0:w.type.toLocaleLowerCase()))}else{const I=(C=(S=_==null?void 0:_.filter)===null||S===void 0?void 0:S.event)===null||C===void 0?void 0:C.toLocaleLowerCase();return I==="*"||I===((A=r==null?void 0:r.event)===null||A===void 0?void 0:A.toLocaleLowerCase())}else return _.type.toLocaleLowerCase()===l}).map(_=>{if(typeof y=="object"&&"ids"in y){const b=y.data,{schema:N,table:w,commit_timestamp:S,type:C,errors:A}=b;y=Object.assign(Object.assign({},{schema:N,table:w,commit_timestamp:S,eventType:C,new:{},old:{},errors:A}),this._getPayloadRecords(b))}_.callback(y,n)})}_isClosed(){return this.state===dm.closed}_isJoined(){return this.state===dm.joined}_isJoining(){return this.state===dm.joining}_isLeaving(){return this.state===dm.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].filter(a=>{var o;return!(((o=a.type)===null||o===void 0?void 0:o.toLocaleLowerCase())===n&&Mje.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(xg.close,{},s)}_onError(s){this._on(xg.error,{},r=>s(r))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(s=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=dm.joining,this.joinPush.resend(s))}_getPayloadRecords(s){const r={new:{},old:{}};return(s.type==="INSERT"||s.type==="UPDATE")&&(r.new=lPe(s.columns,s.record)),(s.type==="UPDATE"||s.type==="DELETE")&&(r.old=lPe(s.columns,s.old_record)),r}}const hPe=()=>{},abt=` addEventListener("message", (e) => { if (e.data.event === "start") { setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); } });`;class ibt{constructor(s,r){var n;this.accessTokenValue=null,this.apiKey=null,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers=Z_t,this.params={},this.timeout=AVe,this.heartbeatIntervalMs=25e3,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=hPe,this.ref=0,this.logger=hPe,this.conn=null,this.sendBuffer=[],this.serializer=new Q_t,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._resolveFetch=o=>{let l;return o?l=o:typeof fetch>"u"?l=(...i)=>Ba(async()=>{const{default:d}=await Promise.resolve().then(()=>$A);return{default:d}},void 0).then(({default:d})=>d(...i)):l=fetch,(...i)=>l(...i)},this.endPoint=`${s}/${a1e.websocket}`,this.httpEndpoint=IVe(s),r!=null&&r.transport?this.transport=r.transport:this.transport=null,r!=null&&r.params&&(this.params=r.params),r!=null&&r.headers&&(this.headers=Object.assign(Object.assign({},this.headers),r.headers)),r!=null&&r.timeout&&(this.timeout=r.timeout),r!=null&&r.logger&&(this.logger=r.logger),(r!=null&&r.logLevel||r!=null&&r.log_level)&&(this.logLevel=r.logLevel||r.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),r!=null&&r.heartbeatIntervalMs&&(this.heartbeatIntervalMs=r.heartbeatIntervalMs);const a=(n=r==null?void 0:r.params)===null||n===void 0?void 0:n.apikey;if(a&&(this.accessTokenValue=a,this.apiKey=a),this.reconnectAfterMs=r!=null&&r.reconnectAfterMs?r.reconnectAfterMs:o=>[1e3,2e3,5e3,1e4][o-1]||1e4,this.encode=r!=null&&r.encode?r.encode:(o,l)=>l(JSON.stringify(o)),this.decode=r!=null&&r.decode?r.decode:this.serializer.decode.bind(this.serializer),this.reconnectTimer=new EVe(async()=>{this.disconnect(),this.connect()},this.reconnectAfterMs),this.fetch=this._resolveFetch(r==null?void 0:r.fetch),r!=null&&r.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.worker=(r==null?void 0:r.worker)||!1,this.workerUrl=r==null?void 0:r.workerUrl}this.accessToken=(r==null?void 0:r.accessToken)||null}connect(){if(!this.conn){if(this.transport||(this.transport=W_t),this.transport){typeof window<"u"&&this.transport===window.WebSocket?this.conn=new this.transport(this.endpointURL()):this.conn=new this.transport(this.endpointURL(),void 0,{headers:this.headers}),this.setupConnection();return}this.conn=new obt(this.endpointURL(),void 0,{close:()=>{this.conn=null}})}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:Y_t}))}disconnect(s,r){this.conn&&(this.conn.onclose=function(){},s?this.conn.close(s,r??""):this.conn.close(),this.conn=null,this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.reset(),this.channels.forEach(n=>n.teardown()))}getChannels(){return this.channels}async removeChannel(s){const r=await s.unsubscribe();return this.channels=this.channels.filter(n=>n._joinRef!==s._joinRef),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 VM.connecting:return c4.Connecting;case VM.open:return c4.Open;case VM.closing:return c4.Closing;default:return c4.Closed}}isConnected(){return this.connectionState()===c4.Open}channel(s,r={config:{}}){const n=`realtime:${s}`,a=this.getChannels().find(o=>o.topic===n);if(a)return a;{const o=new Mje(`realtime:${s}`,r,this);return this.channels.push(o),o}}push(s){const{topic:r,event:n,payload:a,ref:o}=s,l=()=>{this.encode(s,i=>{var d;(d=this.conn)===null||d===void 0||d.send(i)})};this.log("push",`${r} ${n} (${o})`,a),this.isConnected()?l():this.sendBuffer.push(l)}async setAuth(s=null){let r=s||this.accessToken&&await this.accessToken()||this.accessTokenValue;this.accessTokenValue!=r&&(this.accessTokenValue=r,this.channels.forEach(n=>{r&&n.updateJoinPayload({access_token:r,version:this.headers&&this.headers["X-Client-Info"]}),n.joinedOnce&&n._isJoined()&&n._push(xg.access_token,{access_token:r})}))}async sendHeartbeat(){var s;if(!this.isConnected()){this.heartbeatCallback("disconnected");return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),this.heartbeatCallback("timeout"),(s=this.conn)===null||s===void 0||s.close(X_t,"hearbeat timeout");return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.heartbeatCallback("sent"),await this.setAuth()}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)}setupConnection(){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))}_onConnMessage(s){this.decode(s.data,r=>{let{topic:n,event:a,payload:o,ref:l}=r;n==="phoenix"&&a==="phx_reply"&&this.heartbeatCallback(r.payload.status=="ok"?"ok":"error"),l&&l===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null),this.log("receive",`${o.status||""} ${n} ${a} ${l&&"("+l+")"||""}`,o),Array.from(this.channels).filter(i=>i._isMember(n)).forEach(i=>i._trigger(a,o,l)),this.stateChangeCallbacks.message.forEach(i=>i(r))})}_onConnOpen(){if(this.log("transport",`connected to ${this.endpointURL()}`),this.flushSendBuffer(),this.reconnectTimer.reset(),!this.worker)this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs);else{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})}this.stateChangeCallbacks.open.forEach(s=>s())}_onConnClose(s){this.log("transport","close",s),this._triggerChanError(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(r=>r(s))}_onConnError(s){this.log("transport",s.message),this._triggerChanError(),this.stateChangeCallbacks.error.forEach(r=>r(s))}_triggerChanError(){this.channels.forEach(s=>s._trigger(xg.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([abt],{type:"application/javascript"});r=URL.createObjectURL(n)}return r}}class obt{constructor(s,r,n){this.binaryType="arraybuffer",this.onclose=()=>{},this.onerror=()=>{},this.onmessage=()=>{},this.onopen=()=>{},this.readyState=VM.connecting,this.send=()=>{},this.url=null,this.url=s,this.close=n.close}}class Tje extends Error{constructor(s){super(s),this.__isStorageError=!0,this.name="StorageError"}}function Eu(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}class lbt extends Tje{constructor(s,r){super(s),this.name="StorageApiError",this.status=r}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class o1e extends Tje{constructor(s,r){super(s),this.name="StorageUnknownError",this.originalError=r}}var cbt=function(t,s,r,n){function a(o){return o instanceof r?o:new r(function(l){l(o)})}return new(r||(r=Promise))(function(o,l){function i(p){try{u(n.next(p))}catch(f){l(f)}}function d(p){try{u(n.throw(p))}catch(f){l(f)}}function u(p){p.done?o(p.value):a(p.value).then(i,d)}u((n=n.apply(t,s||[])).next())})};const LVe=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>Ba(async()=>{const{default:n}=await Promise.resolve().then(()=>$A);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},dbt=()=>cbt(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield Ba(()=>Promise.resolve().then(()=>$A),void 0)).Response:Response}),l1e=t=>{if(Array.isArray(t))return t.map(r=>l1e(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]=l1e(n)}),s};var wC=function(t,s,r,n){function a(o){return o instanceof r?o:new r(function(l){l(o)})}return new(r||(r=Promise))(function(o,l){function i(p){try{u(n.next(p))}catch(f){l(f)}}function d(p){try{u(n.throw(p))}catch(f){l(f)}}function u(p){p.done?o(p.value):a(p.value).then(i,d)}u((n=n.apply(t,s||[])).next())})};const nge=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),ubt=(t,s,r)=>wC(void 0,void 0,void 0,function*(){const n=yield dbt();t instanceof n&&!(r!=null&&r.noResolveJson)?t.json().then(a=>{s(new lbt(nge(a),t.status||500))}).catch(a=>{s(new o1e(nge(a),a))}):s(new o1e(nge(t),t))}),hbt=(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"},s==null?void 0:s.headers),n&&(a.body=JSON.stringify(n)),Object.assign(Object.assign({},a),r))};function AR(t,s,r,n,a,o){return wC(this,void 0,void 0,function*(){return new Promise((l,i)=>{t(r,hbt(s,n,a,o)).then(d=>{if(!d.ok)throw d;return n!=null&&n.noResolveJson?d:d.json()}).then(d=>l(d)).catch(d=>ubt(d,i,n))})})}function Goe(t,s,r,n){return wC(this,void 0,void 0,function*(){return AR(t,"GET",s,r,n)})}function P_(t,s,r,n,a){return wC(this,void 0,void 0,function*(){return AR(t,"POST",s,n,a,r)})}function mbt(t,s,r,n,a){return wC(this,void 0,void 0,function*(){return AR(t,"PUT",s,n,a,r)})}function pbt(t,s,r,n){return wC(this,void 0,void 0,function*(){return AR(t,"HEAD",s,Object.assign(Object.assign({},r),{noResolveJson:!0}),n)})}function DVe(t,s,r,n,a){return wC(this,void 0,void 0,function*(){return AR(t,"DELETE",s,n,a,r)})}var Zm=function(t,s,r,n){function a(o){return o instanceof r?o:new r(function(l){l(o)})}return new(r||(r=Promise))(function(o,l){function i(p){try{u(n.next(p))}catch(f){l(f)}}function d(p){try{u(n.throw(p))}catch(f){l(f)}}function u(p){p.done?o(p.value):a(p.value).then(i,d)}u((n=n.apply(t,s||[])).next())})};const fbt={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},mPe={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class xbt{constructor(s,r={},n,a){this.url=s,this.headers=r,this.bucketId=n,this.fetch=LVe(a)}uploadOrUpdate(s,r,n,a){return Zm(this,void 0,void 0,function*(){try{let o;const l=Object.assign(Object.assign({},mPe),a);let i=Object.assign(Object.assign({},this.headers),s==="POST"&&{"x-upsert":String(l.upsert)});const d=l.metadata;typeof Blob<"u"&&n instanceof Blob?(o=new FormData,o.append("cacheControl",l.cacheControl),d&&o.append("metadata",this.encodeMetadata(d)),o.append("",n)):typeof FormData<"u"&&n instanceof FormData?(o=n,o.append("cacheControl",l.cacheControl),d&&o.append("metadata",this.encodeMetadata(d))):(o=n,i["cache-control"]=`max-age=${l.cacheControl}`,i["content-type"]=l.contentType,d&&(i["x-metadata"]=this.toBase64(this.encodeMetadata(d)))),a!=null&&a.headers&&(i=Object.assign(Object.assign({},i),a.headers));const u=this._removeEmptyFolders(r),p=this._getFinalPath(u),f=yield this.fetch(`${this.url}/object/${p}`,Object.assign({method:s,body:o,headers:i},l!=null&&l.duplex?{duplex:l.duplex}:{})),y=yield f.json();return f.ok?{data:{path:u,id:y.Id,fullPath:y.Key},error:null}:{data:null,error:y}}catch(o){if(Eu(o))return{data:null,error:o};throw o}})}upload(s,r,n){return Zm(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",s,r,n)})}uploadToSignedUrl(s,r,n,a){return Zm(this,void 0,void 0,function*(){const o=this._removeEmptyFolders(s),l=this._getFinalPath(o),i=new URL(this.url+`/object/upload/sign/${l}`);i.searchParams.set("token",r);try{let d;const u=Object.assign({upsert:mPe.upsert},a),p=Object.assign(Object.assign({},this.headers),{"x-upsert":String(u.upsert)});typeof Blob<"u"&&n instanceof Blob?(d=new FormData,d.append("cacheControl",u.cacheControl),d.append("",n)):typeof FormData<"u"&&n instanceof FormData?(d=n,d.append("cacheControl",u.cacheControl)):(d=n,p["cache-control"]=`max-age=${u.cacheControl}`,p["content-type"]=u.contentType);const f=yield this.fetch(i.toString(),{method:"PUT",body:d,headers:p}),y=yield f.json();return f.ok?{data:{path:o,fullPath:y.Key},error:null}:{data:null,error:y}}catch(d){if(Eu(d))return{data:null,error:d};throw d}})}createSignedUploadUrl(s,r){return Zm(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 P_(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 Tje("No token returned by API");return{data:{signedUrl:l.toString(),path:s,token:i},error:null}}catch(n){if(Eu(n))return{data:null,error:n};throw n}})}update(s,r,n){return Zm(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",s,r,n)})}move(s,r,n){return Zm(this,void 0,void 0,function*(){try{return{data:yield P_(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(Eu(a))return{data:null,error:a};throw a}})}copy(s,r,n){return Zm(this,void 0,void 0,function*(){try{return{data:{path:(yield P_(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(Eu(a))return{data:null,error:a};throw a}})}createSignedUrl(s,r,n){return Zm(this,void 0,void 0,function*(){try{let a=this._getFinalPath(s),o=yield P_(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(Eu(a))return{data:null,error:a};throw a}})}createSignedUrls(s,r,n){return Zm(this,void 0,void 0,function*(){try{const a=yield P_(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(Eu(a))return{data:null,error:a};throw a}})}download(s,r){return Zm(this,void 0,void 0,function*(){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}`:"";try{const i=this._getFinalPath(s);return{data:yield(yield Goe(this.fetch,`${this.url}/${a}/${i}${l}`,{headers:this.headers,noResolveJson:!0})).blob(),error:null}}catch(i){if(Eu(i))return{data:null,error:i};throw i}})}info(s){return Zm(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{const n=yield Goe(this.fetch,`${this.url}/object/info/${r}`,{headers:this.headers});return{data:l1e(n),error:null}}catch(n){if(Eu(n))return{data:null,error:n};throw n}})}exists(s){return Zm(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{return yield pbt(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if(Eu(n)&&n instanceof o1e){const a=n.originalError;if([400,404].includes(a==null?void 0:a.status))return{data:!1,error:n}}throw n}})}getPublicUrl(s,r){const n=this._getFinalPath(s),a=[],o=r!=null&&r.download?`download=${r.download===!0?"":r.download}`:"";o!==""&&a.push(o);const i=typeof(r==null?void 0:r.transform)<"u"?"render/image":"object",d=this.transformOptsToQueryString((r==null?void 0:r.transform)||{});d!==""&&a.push(d);let u=a.join("&");return u!==""&&(u=`?${u}`),{data:{publicUrl:encodeURI(`${this.url}/${i}/public/${n}${u}`)}}}remove(s){return Zm(this,void 0,void 0,function*(){try{return{data:yield DVe(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:s},{headers:this.headers}),error:null}}catch(r){if(Eu(r))return{data:null,error:r};throw r}})}list(s,r,n){return Zm(this,void 0,void 0,function*(){try{const a=Object.assign(Object.assign(Object.assign({},fbt),r),{prefix:s||""});return{data:yield P_(this.fetch,`${this.url}/object/list/${this.bucketId}`,a,{headers:this.headers},n),error:null}}catch(a){if(Eu(a))return{data:null,error:a};throw a}})}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}`}_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 gbt="2.7.1",ybt={"X-Client-Info":`storage-js/${gbt}`};var l5=function(t,s,r,n){function a(o){return o instanceof r?o:new r(function(l){l(o)})}return new(r||(r=Promise))(function(o,l){function i(p){try{u(n.next(p))}catch(f){l(f)}}function d(p){try{u(n.throw(p))}catch(f){l(f)}}function u(p){p.done?o(p.value):a(p.value).then(i,d)}u((n=n.apply(t,s||[])).next())})};class vbt{constructor(s,r={},n){this.url=s,this.headers=Object.assign(Object.assign({},ybt),r),this.fetch=LVe(n)}listBuckets(){return l5(this,void 0,void 0,function*(){try{return{data:yield Goe(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(s){if(Eu(s))return{data:null,error:s};throw s}})}getBucket(s){return l5(this,void 0,void 0,function*(){try{return{data:yield Goe(this.fetch,`${this.url}/bucket/${s}`,{headers:this.headers}),error:null}}catch(r){if(Eu(r))return{data:null,error:r};throw r}})}createBucket(s,r={public:!1}){return l5(this,void 0,void 0,function*(){try{return{data:yield P_(this.fetch,`${this.url}/bucket`,{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(Eu(n))return{data:null,error:n};throw n}})}updateBucket(s,r){return l5(this,void 0,void 0,function*(){try{return{data:yield mbt(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(Eu(n))return{data:null,error:n};throw n}})}emptyBucket(s){return l5(this,void 0,void 0,function*(){try{return{data:yield P_(this.fetch,`${this.url}/bucket/${s}/empty`,{},{headers:this.headers}),error:null}}catch(r){if(Eu(r))return{data:null,error:r};throw r}})}deleteBucket(s){return l5(this,void 0,void 0,function*(){try{return{data:yield DVe(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(Eu(r))return{data:null,error:r};throw r}})}}class _bt extends vbt{constructor(s,r={},n){super(s,r,n)}from(s){return new xbt(this.url,this.headers,s,this.fetch)}}const bbt="2.49.10";let EI="";typeof Deno<"u"?EI="deno":typeof document<"u"?EI="web":typeof navigator<"u"&&navigator.product==="ReactNative"?EI="react-native":EI="node";const wbt={"X-Client-Info":`supabase-js-${EI}/${bbt}`},jbt={headers:wbt},Nbt={schema:"public"},kbt={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},Sbt={};var Cbt=function(t,s,r,n){function a(o){return o instanceof r?o:new r(function(l){l(o)})}return new(r||(r=Promise))(function(o,l){function i(p){try{u(n.next(p))}catch(f){l(f)}}function d(p){try{u(n.throw(p))}catch(f){l(f)}}function u(p){p.done?o(p.value):a(p.value).then(i,d)}u((n=n.apply(t,s||[])).next())})};const Mbt=t=>{let s;return t?s=t:typeof fetch>"u"?s=vVe:s=fetch,(...r)=>s(...r)},Tbt=()=>typeof Headers>"u"?_Ve:Headers,Abt=(t,s,r)=>{const n=Mbt(r),a=Tbt();return(o,l)=>Cbt(void 0,void 0,void 0,function*(){var i;const d=(i=yield s())!==null&&i!==void 0?i:t;let u=new a(l==null?void 0:l.headers);return u.has("apikey")||u.set("apikey",t),u.has("Authorization")||u.set("Authorization",`Bearer ${d}`),n(o,Object.assign(Object.assign({},l),{headers:u}))})};var Ebt=function(t,s,r,n){function a(o){return o instanceof r?o:new r(function(l){l(o)})}return new(r||(r=Promise))(function(o,l){function i(p){try{u(n.next(p))}catch(f){l(f)}}function d(p){try{u(n.throw(p))}catch(f){l(f)}}function u(p){p.done?o(p.value):a(p.value).then(i,d)}u((n=n.apply(t,s||[])).next())})};function Pbt(t){return t.endsWith("/")?t:t+"/"}function Ibt(t,s){var r,n;const{db:a,auth:o,realtime:l,global:i}=t,{db:d,auth:u,realtime:p,global:f}=s,y={db:Object.assign(Object.assign({},d),a),auth:Object.assign(Object.assign({},u),o),realtime:Object.assign(Object.assign({},p),l),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:()=>Ebt(this,void 0,void 0,function*(){return""})};return t.accessToken?y.accessToken=t.accessToken:delete y.accessToken,y}const RVe="2.69.1",E5=30*1e3,c1e=3,age=c1e*E5,Lbt="http://localhost:9999",Dbt="supabase.auth.token",Rbt={"X-Client-Info":`gotrue-js/${RVe}`},d1e="X-Supabase-Api-Version",OVe={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},Obt=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,Fbt=6e5;class Aje extends Error{constructor(s,r,n){super(s),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=n}}function Ti(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class zbt extends Aje{constructor(s,r,n){super(s,r,n),this.name="AuthApiError",this.status=r,this.code=n}}function Bbt(t){return Ti(t)&&t.name==="AuthApiError"}class FVe extends Aje{constructor(s,r){super(s),this.name="AuthUnknownError",this.originalError=r}}class hw extends Aje{constructor(s,r,n,a){super(s,n,a),this.name=r,this.status=n}}class j_ extends hw{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function $bt(t){return Ti(t)&&t.name==="AuthSessionMissingError"}class ige extends hw{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class _z extends hw{constructor(s){super(s,"AuthInvalidCredentialsError",400,void 0)}}class bz extends hw{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 qbt(t){return Ti(t)&&t.name==="AuthImplicitGrantRedirectError"}class pPe extends hw{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 u1e extends hw{constructor(s,r){super(s,"AuthRetryableFetchError",r,void 0)}}function oge(t){return Ti(t)&&t.name==="AuthRetryableFetchError"}class fPe extends hw{constructor(s,r,n){super(s,"AuthWeakPasswordError",r,"weak_password"),this.reasons=n}}class ZL extends hw{constructor(s){super(s,"AuthInvalidJwtError",400,"invalid_jwt")}}const xPe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),gPe=` \r=`.split(""),Ubt=(()=>{const t=new Array(128);for(let s=0;s-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 yPe(t){const s=[],r=l=>{s.push(String.fromCodePoint(l))},n={utf8seq:0,codepoint:0},a={queue:0,queuedBits:0},o=l=>{Gbt(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 Hbt(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}Vbt(n,s)}}function Gbt(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 Wbt(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};for(let a=0;as.push(r)),new Uint8Array(s)}function Zbt(t){return Math.round(Date.now()/1e3)+t}function Ybt(){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 Sy=()=>typeof window<"u"&&typeof document<"u",R2={tested:!1,writable:!1},YL=()=>{if(!Sy())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(R2.tested)return R2.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),R2.tested=!0,R2.writable=!0}catch{R2.tested=!0,R2.writable=!1}return R2.writable};function Xbt(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 BVe=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>Ba(async()=>{const{default:n}=await Promise.resolve().then(()=>$A);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},Qbt=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",$Ve=async(t,s,r)=>{await t.setItem(s,JSON.stringify(r))},wz=async(t,s)=>{const r=await t.getItem(s);if(!r)return null;try{return JSON.parse(r)}catch{return r}},jz=async(t,s)=>{await t.removeItem(s)};class hue{constructor(){this.promise=new hue.promiseConstructor((s,r)=>{this.resolve=s,this.reject=r})}}hue.promiseConstructor=Promise;function lge(t){const s=t.split(".");if(s.length!==3)throw new ZL("Invalid JWT structure");for(let n=0;n{setTimeout(()=>s(null),t)})}function ewt(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 twt(t){return("0"+t.toString(16)).substr(-2)}function swt(){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,twt).join("")}async function rwt(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 nwt(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 rwt(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function c5(t,s,r=!1){const n=swt();let a=n;r&&(a+="/PASSWORD_RECOVERY"),await $Ve(t,`${s}-code-verifier`,a);const o=await nwt(n);return[o,n===o?"plain":"s256"]}const awt=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function iwt(t){const s=t.headers.get(d1e);if(!s||!s.match(awt))return null;try{return new Date(`${s}T00:00:00.0Z`)}catch{return null}}function owt(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 lwt(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")}}var cwt=function(t,s){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&s.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(t);at.msg||t.message||t.error_description||t.error||JSON.stringify(t),dwt=[502,503,504];async function vPe(t){var s;if(!Qbt(t))throw new u1e(s4(t),0);if(dwt.includes(t.status))throw new u1e(s4(t),t.status);let r;try{r=await t.json()}catch(o){throw new FVe(s4(o),o)}let n;const a=iwt(t);if(a&&a.getTime()>=OVe["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 fPe(s4(r),t.status,((s=r.weak_password)===null||s===void 0?void 0:s.reasons)||[]);if(n==="session_not_found")throw new j_}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 fPe(s4(r),t.status,r.weak_password.reasons);throw new zbt(s4(r),t.status||500,n)}const uwt=(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 Ki(t,s,r,n){var a;const o=Object.assign({},n==null?void 0:n.headers);o[d1e]||(o[d1e]=OVe["2024-01-01"].name),n!=null&&n.jwt&&(o.Authorization=`Bearer ${n.jwt}`);const l=(a=n==null?void 0:n.query)!==null&&a!==void 0?a:{};n!=null&&n.redirectTo&&(l.redirect_to=n.redirectTo);const i=Object.keys(l).length?"?"+new URLSearchParams(l).toString():"",d=await hwt(t,s,r+i,{headers:o,noResolveJson:n==null?void 0:n.noResolveJson},{},n==null?void 0:n.body);return n!=null&&n.xform?n==null?void 0:n.xform(d):{data:Object.assign({},d),error:null}}async function hwt(t,s,r,n,a,o){const l=uwt(s,n,a,o);let i;try{i=await t(r,Object.assign({},l))}catch(d){throw console.error(d),new u1e(s4(d),0)}if(i.ok||await vPe(i),n!=null&&n.noResolveJson)return i;try{return await i.json()}catch(d){await vPe(d)}}function N_(t){var s;let r=null;xwt(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=Zbt(t.expires_in)));const n=(s=t.user)!==null&&s!==void 0?s:t;return{data:{session:r,user:n},error:null}}function _Pe(t){const s=N_(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 V_(t){var s;return{data:{user:(s=t.user)!==null&&s!==void 0?s:t},error:null}}function mwt(t){return{data:t,error:null}}function pwt(t){const{action_link:s,email_otp:r,hashed_token:n,redirect_to:a,verification_type:o}=t,l=cwt(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),i={action_link:s,email_otp:r,hashed_token:n,redirect_to:a,verification_type:o},d=Object.assign({},l);return{data:{properties:i,user:d},error:null}}function fwt(t){return t}function xwt(t){return t.access_token&&t.refresh_token&&t.expires_in}var gwt=function(t,s){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&s.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(t);a0&&(_.forEach(b=>{const N=parseInt(b.split(";")[0].split("=")[1].substring(0,1)),w=JSON.parse(b.split(";")[1].split("=")[1]);u[`${w}Page`]=N}),u.total=parseInt(y)),{data:Object.assign(Object.assign({},f),u),error:null}}catch(u){if(Ti(u))return{data:{users:[]},error:u};throw u}}async getUserById(s){try{return await Ki(this.fetch,"GET",`${this.url}/admin/users/${s}`,{headers:this.headers,xform:V_})}catch(r){if(Ti(r))return{data:{user:null},error:r};throw r}}async updateUserById(s,r){try{return await Ki(this.fetch,"PUT",`${this.url}/admin/users/${s}`,{body:r,headers:this.headers,xform:V_})}catch(n){if(Ti(n))return{data:{user:null},error:n};throw n}}async deleteUser(s,r=!1){try{return await Ki(this.fetch,"DELETE",`${this.url}/admin/users/${s}`,{headers:this.headers,body:{should_soft_delete:r},xform:V_})}catch(n){if(Ti(n))return{data:{user:null},error:n};throw n}}async _listFactors(s){try{const{data:r,error:n}=await Ki(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(Ti(r))return{data:null,error:r};throw r}}async _deleteFactor(s){try{return{data:await Ki(this.fetch,"DELETE",`${this.url}/admin/users/${s.userId}/factors/${s.id}`,{headers:this.headers}),error:null}}catch(r){if(Ti(r))return{data:null,error:r};throw r}}}const vwt={getItem:t=>YL()?globalThis.localStorage.getItem(t):null,setItem:(t,s)=>{YL()&&globalThis.localStorage.setItem(t,s)},removeItem:t=>{YL()&&globalThis.localStorage.removeItem(t)}};function bPe(t={}){return{getItem:s=>t[s]||null,setItem:(s,r)=>{t[s]=r},removeItem:s=>{delete t[s]}}}function _wt(){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)}}const d5={debug:!!(globalThis&&YL()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class qVe extends Error{constructor(s){super(s),this.isAcquireTimeout=!0}}class bwt extends qVe{}async function wwt(t,s,r){d5.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,s);const n=new globalThis.AbortController;return s>0&&setTimeout(()=>{n.abort(),d5.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){d5.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,a.name);try{return await r()}finally{d5.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,a.name)}}else{if(s===0)throw d5.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new bwt(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(d5.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()}}))}_wt();const jwt={url:Lbt,storageKey:Dbt,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:Rbt,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function wPe(t,s,r){return await r()}class tD{constructor(s){var r,n;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=tD.nextInstanceID,tD.nextInstanceID+=1,this.instanceID>0&&Sy()&&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({},jwt),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 ywt({url:a.url,headers:a.headers,fetch:a.fetch}),this.url=a.url,this.headers=a.headers,this.fetch=BVe(a.fetch),this.lock=a.lock||wPe,this.detectSessionInUrl=a.detectSessionInUrl,this.flowType=a.flowType,this.hasCustomAuthorizationHeader=a.hasCustomAuthorizationHeader,a.lock?this.lock=a.lock:Sy()&&(!((r=globalThis==null?void 0:globalThis.navigator)===null||r===void 0)&&r.locks)?this.lock=wwt:this.lock=wPe,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)},this.persistSession?a.storage?this.storage=a.storage:YL()?this.storage=vwt:(this.memoryStorage={},this.storage=bPe(this.memoryStorage)):(this.memoryStorage={},this.storage=bPe(this.memoryStorage)),Sy()&&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} (${RVe}) ${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=Xbt(window.location.href);let n="none";if(this._isImplicitGrantCallback(r)?n="implicit":await this._isPKCECallback(r)&&(n="pkce"),Sy()&&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),qbt(o)){const d=(s=o.details)===null||s===void 0?void 0:s.code;if(d==="identity_already_exists"||d==="identity_not_found"||d==="single_identity_not_deletable")return{error:o}}return await this._removeSession(),{error:o}}const{session:l,redirectType:i}=a;return this._debug("#_initialize()","detected session in URL",l,"redirect type",i),await this._saveSession(l),setTimeout(async()=>{i==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",l):await this._notifyAllSubscribers("SIGNED_IN",l)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(r){return Ti(r)?{error:r}:{error:new FVe("Unexpected error during initialization",r)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(s){var r,n,a;try{const o=await Ki(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:N_}),{data:l,error:i}=o;if(i||!l)return{data:{user:null,session:null},error:i};const d=l.session,u=l.user;return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",d)),{data:{user:u,session:d},error:null}}catch(o){if(Ti(o))return{data:{user:null,session:null},error:o};throw o}}async signUp(s){var r,n,a;try{let o;if("email"in s){const{email:p,password:f,options:y}=s;let _=null,b=null;this.flowType==="pkce"&&([_,b]=await c5(this.storage,this.storageKey)),o=await Ki(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:y==null?void 0:y.emailRedirectTo,body:{email:p,password:f,data:(r=y==null?void 0:y.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:y==null?void 0:y.captchaToken},code_challenge:_,code_challenge_method:b},xform:N_})}else if("phone"in s){const{phone:p,password:f,options:y}=s;o=await Ki(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:p,password:f,data:(n=y==null?void 0:y.data)!==null&&n!==void 0?n:{},channel:(a=y==null?void 0:y.channel)!==null&&a!==void 0?a:"sms",gotrue_meta_security:{captcha_token:y==null?void 0:y.captchaToken}},xform:N_})}else throw new _z("You must provide either an email or phone number and a password");const{data:l,error:i}=o;if(i||!l)return{data:{user:null,session:null},error:i};const d=l.session,u=l.user;return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",d)),{data:{user:u,session:d},error:null}}catch(o){if(Ti(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 Ki(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:_Pe})}else if("phone"in s){const{phone:o,password:l,options:i}=s;r=await Ki(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:_Pe})}else throw new _z("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 ige}:(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(Ti(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 _exchangeCodeForSession(s){const r=await wz(this.storage,`${this.storageKey}-code-verifier`),[n,a]=(r??"").split("/");try{const{data:o,error:l}=await Ki(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:s,code_verifier:n},xform:N_});if(await jz(this.storage,`${this.storageKey}-code-verifier`),l)throw l;return!o||!o.session||!o.user?{data:{user:null,session:null,redirectType:null},error:new ige}:(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(Ti(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 Ki(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:N_}),{data:d,error:u}=i;return u?{data:{user:null,session:null},error:u}:!d||!d.session||!d.user?{data:{user:null,session:null},error:new ige}:(d.session&&(await this._saveSession(d.session),await this._notifyAllSubscribers("SIGNED_IN",d.session)),{data:d,error:u})}catch(r){if(Ti(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOtp(s){var r,n,a,o,l;try{if("email"in s){const{email:i,options:d}=s;let u=null,p=null;this.flowType==="pkce"&&([u,p]=await c5(this.storage,this.storageKey));const{error:f}=await Ki(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:i,data:(r=d==null?void 0:d.data)!==null&&r!==void 0?r:{},create_user:(n=d==null?void 0:d.shouldCreateUser)!==null&&n!==void 0?n:!0,gotrue_meta_security:{captcha_token:d==null?void 0:d.captchaToken},code_challenge:u,code_challenge_method:p},redirectTo:d==null?void 0:d.emailRedirectTo});return{data:{user:null,session:null},error:f}}if("phone"in s){const{phone:i,options:d}=s,{data:u,error:p}=await Ki(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:i,data:(a=d==null?void 0:d.data)!==null&&a!==void 0?a:{},create_user:(o=d==null?void 0:d.shouldCreateUser)!==null&&o!==void 0?o:!0,gotrue_meta_security:{captcha_token:d==null?void 0:d.captchaToken},channel:(l=d==null?void 0:d.channel)!==null&&l!==void 0?l:"sms"}});return{data:{user:null,session:null,messageId:u==null?void 0:u.message_id},error:p}}throw new _z("You must provide either an email or phone number.")}catch(i){if(Ti(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 Ki(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},s),{gotrue_meta_security:{captcha_token:o}}),redirectTo:a,xform:N_});if(i)throw i;if(!l)throw new Error("An error occurred on token verification.");const d=l.session,u=l.user;return d!=null&&d.access_token&&(await this._saveSession(d),await this._notifyAllSubscribers(s.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",d)),{data:{user:u,session:d},error:null}}catch(a){if(Ti(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 Ki(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:mwt})}catch(o){if(Ti(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 j_;const{error:a}=await Ki(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return{data:{user:null,session:null},error:a}})}catch(s){if(Ti(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 Ki(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 Ki(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 _z("You must provide either an email or phone number and a type")}catch(r){if(Ti(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 wz(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()(!l&&u==="user"&&(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."),l=!0,this.suppressGetSessionWarning=!0),Reflect.get(d,u,p))})}return{data:{session:s},error:null}}const{session:a,error:o}=await this._callRefreshToken(s.refresh_token);return o?{data:{session:null},error:o}:{data:{session:a},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(s){return s?await this._getUser(s):(await this.initializePromise,await this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(s){try{return s?await Ki(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:s,xform:V_}):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 j_}:await Ki(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:V_})})}catch(r){if(Ti(r))return $bt(r)&&(await this._removeSession(),await jz(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 j_;const l=a.session;let i=null,d=null;this.flowType==="pkce"&&s.email!=null&&([i,d]=await c5(this.storage,this.storageKey));const{data:u,error:p}=await Ki(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:r==null?void 0:r.emailRedirectTo,body:Object.assign(Object.assign({},s),{code_challenge:i,code_challenge_method:d}),jwt:l.access_token,xform:V_});if(p)throw p;return l.user=u.user,await this._saveSession(l),await this._notifyAllSubscribers("USER_UPDATED",l),{data:{user:l.user},error:null}})}catch(n){if(Ti(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 j_;const r=Date.now()/1e3;let n=r,a=!0,o=null;const{payload:l}=lge(s.access_token);if(l.exp&&(n=l.exp,a=n<=r),a){const{session:i,error:d}=await this._callRefreshToken(s.refresh_token);if(d)return{data:{user:null,session:null},error:d};if(!i)return{data:{user:null,session:null},error:null};o=i}else{const{data:i,error:d}=await this._getUser(s.access_token);if(d)throw d;o={access_token:s.access_token,refresh_token:s.refresh_token,user:i.user,token_type:"bearer",expires_in:n-r,expires_at:n},await this._saveSession(o),await this._notifyAllSubscribers("SIGNED_IN",o)}return{data:{user:o.user,session:o},error:null}}catch(r){if(Ti(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 j_;const{session: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(Ti(r))return{data:{user:null,session:null},error:r};throw r}}async _getSessionFromURL(s,r){try{if(!Sy())throw new bz("No browser detected.");if(s.error||s.error_description||s.error_code)throw new bz(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 pPe("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new bz("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 pPe("No code detected.");const{data:C,error:A}=await this._exchangeCodeForSession(s.code);if(A)throw A;const I=new URL(window.location.href);return I.searchParams.delete("code"),window.history.replaceState(window.history.state,"",I.toString()),{data:{session:C.session,redirectType:null},error:null}}const{provider_token:n,provider_refresh_token:a,access_token:o,refresh_token:l,expires_in:i,expires_at:d,token_type:u}=s;if(!o||!i||!l||!u)throw new bz("No session defined in URL");const p=Math.round(Date.now()/1e3),f=parseInt(i);let y=p+f;d&&(y=parseInt(d));const _=y-p;_*1e3<=E5&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${_}s, should have been closer to ${f}s`);const b=y-f;p-b>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",b,y,p):p-b<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",b,y,p);const{data:N,error:w}=await this._getUser(o);if(w)throw w;const S={provider_token:n,provider_refresh_token:a,access_token:o,expires_in:f,expires_at:y,refresh_token:l,token_type:u,user:N.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:S,redirectType:s.type},error:null}}catch(n){if(Ti(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 wz(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&&!(Bbt(i)&&(i.status===404||i.status===401||i.status===403)))return{error:i}}return s!=="others"&&(await this._removeSession(),await jz(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(s){const r=Ybt(),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 Ki(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(Ti(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(Ti(r))return{data:null,error:r};throw r}}async linkIdentity(s){var r;try{const{data:n,error:a}=await this._useSession(async o=>{var l,i,d,u,p;const{data:f,error:y}=o;if(y)throw y;const _=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,s.provider,{redirectTo:(l=s.options)===null||l===void 0?void 0:l.redirectTo,scopes:(i=s.options)===null||i===void 0?void 0:i.scopes,queryParams:(d=s.options)===null||d===void 0?void 0:d.queryParams,skipBrowserRedirect:!0});return await Ki(this.fetch,"GET",_,{headers:this.headers,jwt:(p=(u=f.session)===null||u===void 0?void 0:u.access_token)!==null&&p!==void 0?p:void 0})});if(a)throw a;return Sy()&&!(!((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(Ti(n))return{data:{provider:s.provider,url:null},error:n};throw n}}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 Ki(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(Ti(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 ewt(async a=>(a>0&&await Jbt(200*Math.pow(2,a-1)),this._debug(r,"refreshing attempt",a),await Ki(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:s},headers:this.headers,xform:N_})),(a,o)=>{const l=200*Math.pow(2,a);return o&&oge(o)&&Date.now()+l-n{try{await i.callback(s,r)}catch(d){o.push(d)}});if(await Promise.all(l),o.length>0){for(let i=0;ithis._autoRefreshTokenTick(),E5);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)/E5);this._debug("#_autoRefreshTokenTick()",`access token expires in ${a} ticks, a tick lasts ${E5}ms, refresh threshold is ${c1e} ticks`),a<=c1e&&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 qVe)this._debug("auto refresh token tick lock not available");else throw s}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!Sy()||!(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 Ki(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(Ti(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}:{issuer:s.issuer}),{data:d,error:u}=await Ki(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"&&(!((a=d==null?void 0:d.totp)===null||a===void 0)&&a.qr_code)&&(d.totp.qr_code=`data:image/svg+xml;utf-8,${d.totp.qr_code}`),{data:d,error:null})})}catch(r){if(Ti(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{data:l,error:i}=await Ki(this.fetch,"POST",`${this.url}/factors/${s.factorId}/verify`,{body:{code:s.code,challenge_id:s.challengeId},headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token});return i?{data:null,error:i}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+l.expires_in},l)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",l),{data:l,error:i})})}catch(r){if(Ti(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;return o?{data:null,error:o}:await Ki(this.fetch,"POST",`${this.url}/factors/${s.factorId}/challenge`,{body:{channel:s.channel},headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token})})}catch(r){if(Ti(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(){const{data:{user:s},error:r}=await this.getUser();if(r)return{data:null,error:r};const n=(s==null?void 0:s.factors)||[],a=n.filter(l=>l.factor_type==="totp"&&l.status==="verified"),o=n.filter(l=>l.factor_type==="phone"&&l.status==="verified");return{data:{all:n,totp:a,phone:o},error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async s=>{var r,n;const{data:{session:a},error:o}=s;if(o)return{data:null,error:o};if(!a)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:l}=lge(a.access_token);let i=null;l.aal&&(i=l.aal);let d=i;((n=(r=a.user.factors)===null||r===void 0?void 0:r.filter(f=>f.status==="verified"))!==null&&n!==void 0?n:[]).length>0&&(d="aal2");const p=l.amr||[];return{data:{currentLevel:i,nextLevel:d,currentAuthenticationMethods:p},error:null}}))}async fetchJwk(s,r={keys:[]}){let n=r.keys.find(l=>l.kid===s);if(n||(n=this.jwks.keys.find(l=>l.kid===s),n&&this.jwks_cached_at+Fbt>Date.now()))return n;const{data:a,error:o}=await Ki(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(o)throw o;if(!a.keys||a.keys.length===0)throw new ZL("JWKS is empty");if(this.jwks=a,this.jwks_cached_at=Date.now(),n=a.keys.find(l=>l.kid===s),!n)throw new ZL("No matching signing key found in JWKS");return n}async getClaims(s,r={keys:[]}){try{let n=s;if(!n){const{data:_,error:b}=await this.getSession();if(b||!_.session)return{data:null,error:b};n=_.session.access_token}const{header:a,payload:o,signature:l,raw:{header:i,payload:d}}=lge(n);if(owt(o.exp),!a.kid||a.alg==="HS256"||!("crypto"in globalThis&&"subtle"in globalThis.crypto)){const{error:_}=await this.getUser(n);if(_)throw _;return{data:{claims:o,header:a,signature:l},error:null}}const u=lwt(a.alg),p=await this.fetchJwk(a.kid,r),f=await crypto.subtle.importKey("jwk",p,u,!0,["verify"]);if(!await crypto.subtle.verify(u,f,l,Kbt(`${i}.${d}`)))throw new ZL("Invalid JWT signature");return{data:{claims:o,header:a,signature:l},error:null}}catch(n){if(Ti(n))return{data:null,error:n};throw n}}}tD.nextInstanceID=0;const Nwt=tD;class kwt extends Nwt{constructor(s){super(s)}}var Swt=function(t,s,r,n){function a(o){return o instanceof r?o:new r(function(l){l(o)})}return new(r||(r=Promise))(function(o,l){function i(p){try{u(n.next(p))}catch(f){l(f)}}function d(p){try{u(n.throw(p))}catch(f){l(f)}}function u(p){p.done?o(p.value):a(p.value).then(i,d)}u((n=n.apply(t,s||[])).next())})};class Cwt{constructor(s,r,n){var a,o,l;if(this.supabaseUrl=s,this.supabaseKey=r,!s)throw new Error("supabaseUrl is required.");if(!r)throw new Error("supabaseKey is required.");const i=Pbt(s),d=new URL(i);this.realtimeUrl=new URL("realtime/v1",d),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",d),this.storageUrl=new URL("storage/v1",d),this.functionsUrl=new URL("functions/v1",d);const u=`sb-${d.hostname.split(".")[0]}-auth-token`,p={db:Nbt,realtime:Sbt,auth:Object.assign(Object.assign({},kbt),{storageKey:u}),global:jbt},f=Ibt(n??{},p);this.storageKey=(a=f.auth.storageKey)!==null&&a!==void 0?a:"",this.headers=(o=f.global.headers)!==null&&o!==void 0?o:{},f.accessToken?(this.accessToken=f.accessToken,this.auth=new Proxy({},{get:(y,_)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(_)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((l=f.auth)!==null&&l!==void 0?l:{},this.headers,f.global.fetch),this.fetch=Abt(r,this._getAccessToken.bind(this),f.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},f.realtime)),this.rest=new G_t(new URL("rest/v1",d).href,{headers:this.headers,schema:f.db.schema,fetch:this.fetch}),f.accessToken||this._listenForAuthEvents()}get functions(){return new w_t(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}get storage(){return new _bt(this.storageUrl.href,this.headers,this.fetch)}from(s){return this.rest.from(s)}schema(s){return this.rest.schema(s)}rpc(s,r={},n={}){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()}_getAccessToken(){var s,r;return Swt(this,void 0,void 0,function*(){if(this.accessToken)return yield this.accessToken();const{data:n}=yield this.auth.getSession();return(r=(s=n.session)===null||s===void 0?void 0:s.access_token)!==null&&r!==void 0?r:null})}_initSupabaseAuthClient({autoRefreshToken:s,persistSession:r,detectSessionInUrl:n,storage:a,storageKey:o,flowType:l,lock:i,debug:d},u,p){const f={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new kwt({url:this.authUrl.href,headers:Object.assign(Object.assign({},f),u),storageKey:o,autoRefreshToken:s,persistSession:r,detectSessionInUrl:n,storage:a,flowType:l,lock:i,debug:d,fetch:p,hasCustomAuthorizationHeader:"Authorization"in this.headers})}_initRealtimeClient(s){return new ibt(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:s==="SIGNED_OUT"&&(this.realtime.setAuth(),r=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const Mwt=(t,s,r)=>new Cwt(t,s,r),Twt="https://relzejiswnotikjgvjhz.supabase.co",Awt="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM",G=Mwt(Twt,Awt,{auth:{storage:localStorage,persistSession:!0,autoRefreshToken:!0}}),UVe=k.createContext(void 0),Ewt=({children:t})=>{const[s,r]=k.useState(null),[n,a]=k.useState(null),[o,l]=k.useState(!0),[i,d]=k.useState(!0),[u,p]=k.useState(!1),[f,y]=k.useState(!1),[_,b]=k.useState(null),[N,w]=k.useState([]),[S,C]=k.useState(null),A=k.useRef(null),I=k.useRef(!1),L=k.useRef(!1),O=wr(),V=()=>{p(!1),y(!1),b(null),w([]),C(null),A.current=null,I.current=!1},q=async Y=>{if(!(I.current&&A.current===Y)&&!L.current){L.current=!0,d(!0);try{console.log("Checking roles via RPC for user:",Y);const[{data:J,error:X},{data:ce,error:ie}]=await Promise.all([G.rpc("has_role",{_user_id:Y,_role:"admin"}),G.rpc("has_role",{_user_id:Y,_role:"brokerage_manager"})]);if(X||ie)console.error("Role RPC errors:",{isAdminError:X,isBrokerError:ie}),p(!1),y(!1);else{const me=!!J,ve=!!ce;console.log("RPC roles result:",{adminValue:me,brokerValue:ve}),p(me),y(ve)}const{data:ae,error:oe}=await G.from("profiles").select("brokerage_id").eq("id",Y).single();if(b(!oe&&ae?ae.brokerage_id:null),ce){console.log("Fetching managed brokerages for user:",Y);const{data:me,error:ve}=await G.from("brokerage_manager_assignments").select("brokerage_id").eq("user_id",Y);if(console.log("Managed brokerage assignments result:",{assignments:me,assignmentsError:ve}),ve||!me){console.error("Error fetching managed brokerage assignments:",ve),w([]);return}const he=Array.from(new Set(me.map(Me=>Me.brokerage_id).filter(Boolean)));if(he.length===0){w([]);return}const{data:ge,error:je}=await G.from("brokerages").select("id, name").in("id",he);if(console.log("Managed brokerages details result:",{brokeragesData:ge,brokeragesError:je}),je||!ge){console.error("Error fetching managed brokerages details:",je),w([]);return}const qe=ge.map(Me=>({id:Me.id,name:Me.name})).sort((Me,ke)=>he.indexOf(Me.id)-he.indexOf(ke.id));console.log("Parsed managed brokerages:",qe),w(qe),qe.length>0&&C(Me=>Me??qe[0].id)}else console.log("User is not a brokerage manager, skipping managed brokerages fetch"),w([]);A.current=Y,I.current=!0}catch(J){console.error("Unexpected error in checkRoles:",J),V()}finally{L.current=!1,d(!1)}}};k.useEffect(()=>{let Y=!0,J=!1;const X=()=>{!Y||J||(J=!0,l(!1))},{data:{subscription:ce}}=G.auth.onAuthStateChange((oe,me)=>{console.log("Auth event:",oe),Y&&(a(me),r((me==null?void 0:me.user)??null),X(),oe==="PASSWORD_RECOVERY"&&(console.log("Password recovery detected, redirecting to profile"),setTimeout(()=>{O("/profile?reset=true")},100)),me!=null&&me.user?(!I.current||A.current!==me.user.id)&&setTimeout(()=>{q(me.user.id)},0):(V(),d(!1)))}),ie=window.setTimeout(()=>{console.warn("Auth initialization timeout reached. Continuing without blocking UI."),X()},4e3);return(async()=>{try{const{data:{session:oe}}=await G.auth.getSession();if(!Y)return;a(oe),r((oe==null?void 0:oe.user)??null),oe!=null&&oe.user?await q(oe.user.id):V()}catch(oe){console.error("Error restoring auth session:",oe),Y&&(a(null),r(null),V())}finally{X()}})(),()=>{Y=!1,window.clearTimeout(ie),ce.unsubscribe()}},[]);const B=async(Y,J)=>{const{error:X}=await G.auth.signInWithPassword({email:Y,password:J});if(X)throw pe.error(X.message),X;pe.success("Welcome back!");const ce=sessionStorage.getItem("redirectAfterLogin")||"/dashboard";sessionStorage.removeItem("redirectAfterLogin"),O(ce)},U=async(Y,J,X)=>{var me;const ce=`${window.location.origin}/dashboard`,ie=localStorage.getItem("levelup_referral_code")||null,{data:ae,error:oe}=await G.auth.signUp({email:Y,password:J,options:{emailRedirectTo:ce,data:{name:X,referred_by_code:ie}}});if(oe)throw pe.error(oe.message),oe;if(ie&&((me=ae.user)!=null&&me.id))try{await G.from("profiles").update({referred_by_code:ie}).eq("id",ae.user.id),localStorage.removeItem("levelup_referral_code")}catch(ve){console.warn("Failed to attach referral code to profile",ve)}pe.success("Account created! Welcome to LevelUp."),O("/dashboard")},te=async()=>{try{const{data:{session:Y}}=await G.auth.getSession();if(Y){const{error:J}=await G.auth.signOut();J?J.message==="Auth session missing!"?console.warn("Sign out warning (ignored):",J.message):(console.error("Sign out error:",J),pe.error(J.message)):pe.success("Signed out successfully")}else console.log("No active session found, redirecting to auth");r(null),a(null),p(!1),y(!1),b(null),w([]),C(null),O("/auth")}catch(Y){console.error("Unexpected sign out error:",Y),O("/auth")}};return e.jsx(UVe.Provider,{value:{user:s,session:n,loading:o,rolesLoading:i,signIn:B,signUp:U,signOut:te,isAdmin:u,isBrokerageManager:f,brokerageId:_,managedBrokerages:N,selectedBrokerageId:S,setSelectedBrokerageId:C},children:t})},Us=()=>{const t=k.useContext(UVe);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t},VVe=k.createContext(void 0),O2="levelup_admin_session",x_="levelup_impersonation",cge="levelup_impersonation_return",Pwt=({children:t})=>{const[s,r]=k.useState(!1),[n,a]=k.useState(null),[o,l]=k.useState(!1);k.useEffect(()=>{const u=sessionStorage.getItem(x_);if(u)try{const p=JSON.parse(u);r(!0),a(p)}catch{sessionStorage.removeItem(x_)}},[]);const i=async(u,p)=>{l(!0);try{const{data:{session:f}}=await G.auth.getSession();if(!f)return pe.error("No active session found"),!1;const y={access_token:f.access_token,refresh_token:f.refresh_token};sessionStorage.setItem(O2,JSON.stringify(y)),p&&sessionStorage.setItem(cge,p);const _=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})}),b=await _.json();if(!_.ok)throw new Error(b.error||"Failed to impersonate user");const N={id:b.targetUser.id,name:b.targetUser.name,email:b.targetUser.email};if(sessionStorage.setItem(x_,JSON.stringify(N)),b.method==="session"){const{error:w}=await G.auth.setSession({access_token:b.access_token,refresh_token:b.refresh_token});if(w)throw console.error("Set session error:",w),sessionStorage.removeItem(O2),sessionStorage.removeItem(x_),new Error("Failed to establish impersonation session")}else{const w=b.type||"recovery",{error:S}=await G.auth.verifyOtp({token_hash:b.token_hash,type:w});if(S)throw console.error("Verify OTP error:",S),sessionStorage.removeItem(O2),sessionStorage.removeItem(x_),new Error("Failed to establish impersonation session")}return r(!0),a(N),pe.success(`Now viewing as ${N.name}`),window.location.href="/dashboard",!0}catch(f){return console.error("Impersonation error:",f),pe.error(f.message||"Failed to impersonate user"),sessionStorage.removeItem(O2),sessionStorage.removeItem(x_),!1}finally{l(!1)}},d=async()=>{l(!0);try{const u=sessionStorage.getItem(O2);if(!u){await G.auth.signOut(),window.location.href="/auth";return}const p=JSON.parse(u);await G.auth.signOut();const{error:f}=await G.auth.setSession({access_token:p.access_token,refresh_token:p.refresh_token});if(sessionStorage.removeItem(O2),sessionStorage.removeItem(x_),f){console.error("Failed to restore admin session:",f),pe.error("Admin session expired, please sign in again"),window.location.href="/auth";return}r(!1),a(null),pe.success("Returned to your account");const y=sessionStorage.getItem(cge)||"/admin/members";sessionStorage.removeItem(cge),window.location.href=y}catch(u){console.error("Stop impersonation error:",u),pe.error("Failed to restore admin session"),sessionStorage.removeItem(O2),sessionStorage.removeItem(x_),window.location.href="/auth"}finally{l(!1)}};return e.jsx(VVe.Provider,{value:{isImpersonating:s,impersonatedUser:n,startImpersonation:i,stopImpersonation:d,isLoading:o},children:t})},mue=()=>{const t=k.useContext(VVe);if(t===void 0)throw new Error("useImpersonation must be used within an ImpersonationProvider");return t},TT=bC("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"}}),W=k.forwardRef(({className:t,variant:s,size:r,asChild:n=!1,...a},o)=>{const l=n?tje:"button";return e.jsx(l,{className:Ot(TT({variant:s,size:r,className:t})),ref:o,...a})});W.displayName="Button";const Iwt=()=>{const{isImpersonating:t,impersonatedUser:s,stopImpersonation:r,isLoading:n}=mue();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(Dc,{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(W,{size:"sm",variant:"secondary",onClick:r,disabled:n,className:"bg-amber-100 hover:bg-amber-200 text-amber-950 border-0",children:n?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(kr,{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"})]})})]})})},HVe=k.createContext(void 0),u5="levelup_acting_as",Nz="levelup_acting_as_self",Lwt=({children:t})=>{const{user:s}=Us(),[r,n]=k.useState(!1),[a,o]=k.useState([]),[l,i]=k.useState(null),[d,u]=k.useState({}),[p,f]=k.useState(!0),[y,_]=k.useState(()=>sessionStorage.getItem(Nz)==="true");k.useEffect(()=>{if(!(s!=null&&s.id)){n(!1),o([]),i(null),u({}),f(!1);return}(async()=>{f(!0);try{const{data:A}=await G.rpc("has_role",{_user_id:s.id,_role:"assistant"});if(!A){n(!1),o([]),i(null),u({}),f(!1);return}n(!0);const{data:I,error:L}=await G.from("agent_assistant_assignments").select("agent_id, permissions").eq("assistant_id",s.id);if(L||!I||I.length===0){o([]),f(!1);return}const O=I.map(B=>B.agent_id),{data:V}=await G.from("profiles").select("id, name, email, avatar_url").in("id",O),q=(V||[]).map(B=>({id:B.id,name:B.name||B.email||"Unknown",email:B.email||"",avatar_url:B.avatar_url}));if(o(q),sessionStorage.getItem(Nz)==="true")_(!0),i(null),u({});else{const B=sessionStorage.getItem(u5);if(B){const U=q.find(te=>te.id===B);if(U){i(U);const te=I.find(Y=>Y.agent_id===B);u((te==null?void 0:te.permissions)||{})}else if(q.length>0){i(q[0]);const te=I.find(Y=>Y.agent_id===q[0].id);u((te==null?void 0:te.permissions)||{}),sessionStorage.setItem(u5,q[0].id)}}else if(q.length>0){i(q[0]);const U=I.find(te=>te.agent_id===q[0].id);u((U==null?void 0:U.permissions)||{}),sessionStorage.setItem(u5,q[0].id)}}}catch(A){console.error("Error loading assistant data:",A)}finally{f(!1)}})()},[s==null?void 0:s.id]);const b=C=>{i(C),_(!1),sessionStorage.removeItem(Nz),C?(sessionStorage.setItem(u5,C.id),G.from("agent_assistant_assignments").select("permissions").eq("assistant_id",(s==null?void 0:s.id)||"").eq("agent_id",C.id).single().then(({data:A})=>{u((A==null?void 0:A.permissions)||{})})):(sessionStorage.removeItem(u5),u({}))},N=()=>{_(!0),i(null),u({}),sessionStorage.setItem(Nz,"true"),sessionStorage.removeItem(u5)},w=C=>!r||y?!0:d[C]===!0,S=r&&l&&!y?l.id:(s==null?void 0:s.id)||null;return e.jsx(HVe.Provider,{value:{isAssistant:r,assignedAgents:a,actingAsAgent:l,setActingAsAgent:b,effectiveUserId:S,permissions:d,hasPermission:w,isLoading:p,isActingAsSelf:y,setActingAsSelf:N},children:t})},Eje=()=>{const t=k.useContext(HVe);if(t===void 0)throw new Error("useActingAs must be used within an ActingAsProvider");return t},ya=()=>{const{effectiveUserId:t}=Eje();return t};var GVe={exports:{}},WVe={};/** * @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 AT=k;function Dwt(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var Rwt=typeof Object.is=="function"?Object.is:Dwt,Owt=AT.useState,Fwt=AT.useEffect,zwt=AT.useLayoutEffect,Bwt=AT.useDebugValue;function $wt(t,s){var r=s(),n=Owt({inst:{value:r,getSnapshot:s}}),a=n[0].inst,o=n[1];return zwt(function(){a.value=r,a.getSnapshot=s,dge(a)&&o({inst:a})},[t,r,s]),Fwt(function(){return dge(a)&&o({inst:a}),t(function(){dge(a)&&o({inst:a})})},[t]),Bwt(r),r}function dge(t){var s=t.getSnapshot;t=t.value;try{var r=s();return!Rwt(t,r)}catch{return!0}}function qwt(t,s){return s()}var Uwt=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?qwt:$wt;WVe.useSyncExternalStore=AT.useSyncExternalStore!==void 0?AT.useSyncExternalStore:Uwt;GVe.exports=WVe;var Vwt=GVe.exports;function Hwt(){return Vwt.useSyncExternalStore(Gwt,()=>!0,()=>!1)}function Gwt(){return()=>{}}var Pje="Avatar",[Wwt,XTs]=qc(Pje),[Kwt,KVe]=Wwt(Pje),ZVe=k.forwardRef((t,s)=>{const{__scopeAvatar:r,...n}=t,[a,o]=k.useState("idle");return e.jsx(Kwt,{scope:r,imageLoadingStatus:a,onImageLoadingStatusChange:o,children:e.jsx(Jr.span,{...n,ref:s})})});ZVe.displayName=Pje;var YVe="AvatarImage",XVe=k.forwardRef((t,s)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:a=()=>{},...o}=t,l=KVe(YVe,r),i=Zwt(n,o),d=ed(u=>{a(u),l.onImageLoadingStatusChange(u)});return od(()=>{i!=="idle"&&d(i)},[i,d]),i==="loaded"?e.jsx(Jr.img,{...o,ref:s,src:n}):null});XVe.displayName=YVe;var QVe="AvatarFallback",JVe=k.forwardRef((t,s)=>{const{__scopeAvatar:r,delayMs:n,...a}=t,o=KVe(QVe,r),[l,i]=k.useState(n===void 0);return k.useEffect(()=>{if(n!==void 0){const d=window.setTimeout(()=>i(!0),n);return()=>window.clearTimeout(d)}},[n]),l&&o.imageLoadingStatus!=="loaded"?e.jsx(Jr.span,{...a,ref:s}):null});JVe.displayName=QVe;function jPe(t,s){return t?s?(t.src!==s&&(t.src=s),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function Zwt(t,{referrerPolicy:s,crossOrigin:r}){const n=Hwt(),a=k.useRef(null),o=n?(a.current||(a.current=new window.Image),a.current):null,[l,i]=k.useState(()=>jPe(o,t));return od(()=>{i(jPe(o,t))},[o,t]),od(()=>{const d=f=>()=>{i(f)};if(!o)return;const u=d("loaded"),p=d("error");return o.addEventListener("load",u),o.addEventListener("error",p),s&&(o.referrerPolicy=s),typeof r=="string"&&(o.crossOrigin=r),()=>{o.removeEventListener("load",u),o.removeEventListener("error",p)}},[o,r,s]),l}var eHe=ZVe,tHe=XVe,sHe=JVe;const Nn=k.forwardRef(({className:t,...s},r)=>e.jsx(eHe,{ref:r,className:Ot("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...s}));Nn.displayName=eHe.displayName;const Ma=k.forwardRef(({className:t,...s},r)=>e.jsx(tHe,{ref:r,className:Ot("aspect-square h-full w-full",t),...s}));Ma.displayName=tHe.displayName;const kn=k.forwardRef(({className:t,...s},r)=>e.jsx(sHe,{ref:r,className:Ot("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...s}));kn.displayName=sHe.displayName;const Ywt=bC("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 Qe({className:t,variant:s,...r}){return e.jsx("div",{className:Ot(Ywt({variant:s}),t),...r})}var Xwt=k.createContext(void 0);function mw(t){const s=k.useContext(Xwt);return t||s||"ltr"}var uge=0;function pue(){k.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??NPe()),document.body.insertAdjacentElement("beforeend",t[1]??NPe()),uge++,()=>{uge===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(s=>s.remove()),uge--}},[])}function NPe(){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 hge="focusScope.autoFocusOnMount",mge="focusScope.autoFocusOnUnmount",kPe={bubbles:!1,cancelable:!0},Qwt="FocusScope",ER=k.forwardRef((t,s)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...l}=t,[i,d]=k.useState(null),u=ed(a),p=ed(o),f=k.useRef(null),y=Ta(s,N=>d(N)),_=k.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;k.useEffect(()=>{if(n){let N=function(A){if(_.paused||!i)return;const I=A.target;i.contains(I)?f.current=I:k_(f.current,{select:!0})},w=function(A){if(_.paused||!i)return;const I=A.relatedTarget;I!==null&&(i.contains(I)||k_(f.current,{select:!0}))},S=function(A){if(document.activeElement===document.body)for(const L of A)L.removedNodes.length>0&&k_(i)};document.addEventListener("focusin",N),document.addEventListener("focusout",w);const C=new MutationObserver(S);return i&&C.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",N),document.removeEventListener("focusout",w),C.disconnect()}}},[n,i,_.paused]),k.useEffect(()=>{if(i){CPe.add(_);const N=document.activeElement;if(!i.contains(N)){const S=new CustomEvent(hge,kPe);i.addEventListener(hge,u),i.dispatchEvent(S),S.defaultPrevented||(Jwt(n2t(rHe(i)),{select:!0}),document.activeElement===N&&k_(i))}return()=>{i.removeEventListener(hge,u),setTimeout(()=>{const S=new CustomEvent(mge,kPe);i.addEventListener(mge,p),i.dispatchEvent(S),S.defaultPrevented||k_(N??document.body,{select:!0}),i.removeEventListener(mge,p),CPe.remove(_)},0)}}},[i,u,p,_]);const b=k.useCallback(N=>{if(!r&&!n||_.paused)return;const w=N.key==="Tab"&&!N.altKey&&!N.ctrlKey&&!N.metaKey,S=document.activeElement;if(w&&S){const C=N.currentTarget,[A,I]=e2t(C);A&&I?!N.shiftKey&&S===I?(N.preventDefault(),r&&k_(A,{select:!0})):N.shiftKey&&S===A&&(N.preventDefault(),r&&k_(I,{select:!0})):S===C&&N.preventDefault()}},[r,n,_.paused]);return e.jsx(Jr.div,{tabIndex:-1,...l,ref:y,onKeyDown:b})});ER.displayName=Qwt;function Jwt(t,{select:s=!1}={}){const r=document.activeElement;for(const n of t)if(k_(n,{select:s}),document.activeElement!==r)return}function e2t(t){const s=rHe(t),r=SPe(s,t),n=SPe(s.reverse(),t);return[r,n]}function rHe(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 SPe(t,s){for(const r of t)if(!t2t(r,{upTo:s}))return r}function t2t(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 s2t(t){return t instanceof HTMLInputElement&&"select"in t}function k_(t,{select:s=!1}={}){if(t&&t.focus){const r=document.activeElement;t.focus({preventScroll:!0}),t!==r&&s2t(t)&&s&&t.select()}}var CPe=r2t();function r2t(){let t=[];return{add(s){const r=t[0];s!==r&&(r==null||r.pause()),t=MPe(t,s),t.unshift(s)},remove(s){var r;t=MPe(t,s),(r=t[0])==null||r.resume()}}}function MPe(t,s){const r=[...t],n=r.indexOf(s);return n!==-1&&r.splice(n,1),r}function n2t(t){return t.filter(s=>s.tagName!=="A")}var pge="rovingFocusGroup.onEntryFocus",a2t={bubbles:!1,cancelable:!0},PR="RovingFocusGroup",[h1e,nHe,i2t]=wR(PR),[o2t,pw]=qc(PR,[i2t]),[l2t,c2t]=o2t(PR),aHe=k.forwardRef((t,s)=>e.jsx(h1e.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(h1e.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(d2t,{...t,ref:s})})}));aHe.displayName=PR;var d2t=k.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:a=!1,dir:o,currentTabStopId:l,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:p=!1,...f}=t,y=k.useRef(null),_=Ta(s,y),b=mw(o),[N,w]=Uu({prop:l,defaultProp:i??null,onChange:d,caller:PR}),[S,C]=k.useState(!1),A=ed(u),I=nHe(r),L=k.useRef(!1),[O,V]=k.useState(0);return k.useEffect(()=>{const q=y.current;if(q)return q.addEventListener(pge,A),()=>q.removeEventListener(pge,A)},[A]),e.jsx(l2t,{scope:r,orientation:n,dir:b,loop:a,currentTabStopId:N,onItemFocus:k.useCallback(q=>w(q),[w]),onItemShiftTab:k.useCallback(()=>C(!0),[]),onFocusableItemAdd:k.useCallback(()=>V(q=>q+1),[]),onFocusableItemRemove:k.useCallback(()=>V(q=>q-1),[]),children:e.jsx(Jr.div,{tabIndex:S||O===0?-1:0,"data-orientation":n,...f,ref:_,style:{outline:"none",...t.style},onMouseDown:Mr(t.onMouseDown,()=>{L.current=!0}),onFocus:Mr(t.onFocus,q=>{const B=!L.current;if(q.target===q.currentTarget&&B&&!S){const U=new CustomEvent(pge,a2t);if(q.currentTarget.dispatchEvent(U),!U.defaultPrevented){const te=I().filter(ie=>ie.focusable),Y=te.find(ie=>ie.active),J=te.find(ie=>ie.id===N),ce=[Y,J,...te].filter(Boolean).map(ie=>ie.ref.current);lHe(ce,p)}}L.current=!1}),onBlur:Mr(t.onBlur,()=>C(!1))})})}),iHe="RovingFocusGroupItem",oHe=k.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:a=!1,tabStopId:o,children:l,...i}=t,d=fu(),u=o||d,p=c2t(iHe,r),f=p.currentTabStopId===u,y=nHe(r),{onFocusableItemAdd:_,onFocusableItemRemove:b,currentTabStopId:N}=p;return k.useEffect(()=>{if(n)return _(),()=>b()},[n,_,b]),e.jsx(h1e.ItemSlot,{scope:r,id:u,focusable:n,active:a,children:e.jsx(Jr.span,{tabIndex:f?0:-1,"data-orientation":p.orientation,...i,ref:s,onMouseDown:Mr(t.onMouseDown,w=>{n?p.onItemFocus(u):w.preventDefault()}),onFocus:Mr(t.onFocus,()=>p.onItemFocus(u)),onKeyDown:Mr(t.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){p.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const S=m2t(w,p.orientation,p.dir);if(S!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let A=y().filter(I=>I.focusable).map(I=>I.ref.current);if(S==="last")A.reverse();else if(S==="prev"||S==="next"){S==="prev"&&A.reverse();const I=A.indexOf(w.currentTarget);A=p.loop?p2t(A,I+1):A.slice(I+1)}setTimeout(()=>lHe(A))}}),children:typeof l=="function"?l({isCurrentTabStop:f,hasTabStop:N!=null}):l})})});oHe.displayName=iHe;var u2t={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function h2t(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function m2t(t,s,r){const n=h2t(t.key,r);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return u2t[n]}function lHe(t,s=!1){const r=document.activeElement;for(const n of t)if(n===r||(n.focus({preventScroll:s}),document.activeElement!==r))return}function p2t(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var fue=aHe,xue=oHe,f2t=function(t){if(typeof document>"u")return null;var s=Array.isArray(t)?t[0]:t;return s.ownerDocument.body},h5=new WeakMap,kz=new WeakMap,Sz={},fge=0,cHe=function(t){return t&&(t.host||cHe(t.parentNode))},x2t=function(t,s){return s.map(function(r){if(t.contains(r))return r;var n=cHe(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=x2t(s,Array.isArray(t)?t:[t]);Sz[r]||(Sz[r]=new WeakMap);var o=Sz[r],l=[],i=new Set,d=new Set(a),u=function(f){!f||i.has(f)||(i.add(f),u(f.parentNode))};a.forEach(u);var p=function(f){!f||d.has(f)||Array.prototype.forEach.call(f.children,function(y){if(i.has(y))p(y);else try{var _=y.getAttribute(n),b=_!==null&&_!=="false",N=(h5.get(y)||0)+1,w=(o.get(y)||0)+1;h5.set(y,N),o.set(y,w),l.push(y),N===1&&b&&kz.set(y,!0),w===1&&y.setAttribute(r,"true"),b||y.setAttribute(n,"true")}catch(S){console.error("aria-hidden: cannot operate on ",y,S)}})};return p(s),i.clear(),fge++,function(){l.forEach(function(f){var y=h5.get(f)-1,_=o.get(f)-1;h5.set(f,y),o.set(f,_),y||(kz.has(f)||f.removeAttribute(n),kz.delete(f)),_||f.removeAttribute(r)}),fge--,fge||(h5=new WeakMap,h5=new WeakMap,kz=new WeakMap,Sz={})}},gue=function(t,s,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(t)?t:[t]),a=f2t(t);return a?(n.push.apply(n,Array.from(a.querySelectorAll("[aria-live]"))),g2t(n,a,r,"aria-hidden")):function(){return null}},zy=function(){return zy=Object.assign||function(s){for(var r,n=1,a=arguments.length;n"u")return L2t;var s=D2t(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])}},O2t=mHe(),HM="data-scroll-locked",F2t=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(v2t,` { overflow: hidden `).concat(n,`; padding-right: `).concat(i,"px ").concat(n,`; } body[`).concat(HM,`] { 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(Fie,` { right: `).concat(i,"px ").concat(n,`; } .`).concat(zie,` { margin-right: `).concat(i,"px ").concat(n,`; } .`).concat(Fie," .").concat(Fie,` { right: 0 `).concat(n,`; } .`).concat(zie," .").concat(zie,` { margin-right: 0 `).concat(n,`; } body[`).concat(HM,`] { `).concat(_2t,": ").concat(i,`px; } `)},APe=function(){var t=parseInt(document.body.getAttribute(HM)||"0",10);return isFinite(t)?t:0},z2t=function(){k.useEffect(function(){return document.body.setAttribute(HM,(APe()+1).toString()),function(){var t=APe()-1;t<=0?document.body.removeAttribute(HM):document.body.setAttribute(HM,t.toString())}},[])},B2t=function(t){var s=t.noRelative,r=t.noImportant,n=t.gapMode,a=n===void 0?"margin":n;z2t();var o=k.useMemo(function(){return R2t(a)},[a]);return k.createElement(O2t,{styles:F2t(o,!s,a,r?"":"!important")})},m1e=!1;if(typeof window<"u")try{var Cz=Object.defineProperty({},"passive",{get:function(){return m1e=!0,!0}});window.addEventListener("test",Cz,Cz),window.removeEventListener("test",Cz,Cz)}catch{m1e=!1}var m5=m1e?{passive:!1}:!1,$2t=function(t){return t.tagName==="TEXTAREA"},pHe=function(t,s){if(!(t instanceof Element))return!1;var r=window.getComputedStyle(t);return r[s]!=="hidden"&&!(r.overflowY===r.overflowX&&!$2t(t)&&r[s]==="visible")},q2t=function(t){return pHe(t,"overflowY")},U2t=function(t){return pHe(t,"overflowX")},EPe=function(t,s){var r=s.ownerDocument,n=s;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var a=fHe(t,n);if(a){var o=xHe(t,n),l=o[1],i=o[2];if(l>i)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},V2t=function(t){var s=t.scrollTop,r=t.scrollHeight,n=t.clientHeight;return[s,r,n]},H2t=function(t){var s=t.scrollLeft,r=t.scrollWidth,n=t.clientWidth;return[s,r,n]},fHe=function(t,s){return t==="v"?q2t(s):U2t(s)},xHe=function(t,s){return t==="v"?V2t(s):H2t(s)},G2t=function(t,s){return t==="h"&&s==="rtl"?-1:1},W2t=function(t,s,r,n,a){var o=G2t(t,window.getComputedStyle(s).direction),l=o*n,i=r.target,d=s.contains(i),u=!1,p=l>0,f=0,y=0;do{if(!i)break;var _=xHe(t,i),b=_[0],N=_[1],w=_[2],S=N-w-o*b;(b||S)&&fHe(t,i)&&(f+=S,y+=b);var C=i.parentNode;i=C&&C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.host:C}while(!d&&i!==document.body||d&&(s.contains(i)||s===i));return(p&&(Math.abs(f)<1||!a)||!p&&(Math.abs(y)<1||!a))&&(u=!0),u},Mz=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},PPe=function(t){return[t.deltaX,t.deltaY]},IPe=function(t){return t&&"current"in t?t.current:t},K2t=function(t,s){return t[0]===s[0]&&t[1]===s[1]},Z2t=function(t){return` .block-interactivity-`.concat(t,` {pointer-events: none;} .allow-interactivity-`).concat(t,` {pointer-events: all;} `)},Y2t=0,p5=[];function X2t(t){var s=k.useRef([]),r=k.useRef([0,0]),n=k.useRef(),a=k.useState(Y2t++)[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 N=y2t([t.lockRef.current],(t.shards||[]).map(IPe),!0).filter(Boolean);return N.forEach(function(w){return w.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),N.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var i=k.useCallback(function(N,w){if("touches"in N&&N.touches.length===2||N.type==="wheel"&&N.ctrlKey)return!l.current.allowPinchZoom;var S=Mz(N),C=r.current,A="deltaX"in N?N.deltaX:C[0]-S[0],I="deltaY"in N?N.deltaY:C[1]-S[1],L,O=N.target,V=Math.abs(A)>Math.abs(I)?"h":"v";if("touches"in N&&V==="h"&&O.type==="range")return!1;var q=EPe(V,O);if(!q)return!0;if(q?L=V:(L=V==="v"?"h":"v",q=EPe(V,O)),!q)return!1;if(!n.current&&"changedTouches"in N&&(A||I)&&(n.current=L),!L)return!0;var B=n.current||L;return W2t(B,w,N,B==="h"?A:I,!0)},[]),d=k.useCallback(function(N){var w=N;if(!(!p5.length||p5[p5.length-1]!==o)){var S="deltaY"in w?PPe(w):Mz(w),C=s.current.filter(function(L){return L.name===w.type&&(L.target===w.target||w.target===L.shadowParent)&&K2t(L.delta,S)})[0];if(C&&C.should){w.cancelable&&w.preventDefault();return}if(!C){var A=(l.current.shards||[]).map(IPe).filter(Boolean).filter(function(L){return L.contains(w.target)}),I=A.length>0?i(w,A[0]):!l.current.noIsolation;I&&w.cancelable&&w.preventDefault()}}},[]),u=k.useCallback(function(N,w,S,C){var A={name:N,delta:w,target:S,should:C,shadowParent:Q2t(S)};s.current.push(A),setTimeout(function(){s.current=s.current.filter(function(I){return I!==A})},1)},[]),p=k.useCallback(function(N){r.current=Mz(N),n.current=void 0},[]),f=k.useCallback(function(N){u(N.type,PPe(N),N.target,i(N,t.lockRef.current))},[]),y=k.useCallback(function(N){u(N.type,Mz(N),N.target,i(N,t.lockRef.current))},[]);k.useEffect(function(){return p5.push(o),t.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:y}),document.addEventListener("wheel",d,m5),document.addEventListener("touchmove",d,m5),document.addEventListener("touchstart",p,m5),function(){p5=p5.filter(function(N){return N!==o}),document.removeEventListener("wheel",d,m5),document.removeEventListener("touchmove",d,m5),document.removeEventListener("touchstart",p,m5)}},[]);var _=t.removeScrollBar,b=t.inert;return k.createElement(k.Fragment,null,b?k.createElement(o,{styles:Z2t(a)}):null,_?k.createElement(B2t,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function Q2t(t){for(var s=null;t!==null;)t instanceof ShadowRoot&&(s=t.host,t=t.host),t=t.parentNode;return s}const J2t=C2t(hHe,X2t);var IR=k.forwardRef(function(t,s){return k.createElement(yue,zy({},t,{ref:s,sideCar:J2t}))});IR.classNames=yue.classNames;var p1e=["Enter"," "],ejt=["ArrowDown","PageUp","Home"],gHe=["ArrowUp","PageDown","End"],tjt=[...ejt,...gHe],sjt={ltr:[...p1e,"ArrowRight"],rtl:[...p1e,"ArrowLeft"]},rjt={ltr:["ArrowLeft"],rtl:["ArrowRight"]},LR="Menu",[sD,njt,ajt]=wR(LR),[jC,yHe]=qc(LR,[ajt,w0,pw]),vue=w0(),vHe=pw(),[ijt,NC]=jC(LR),[ojt,DR]=jC(LR),_He=t=>{const{__scopeMenu:s,open:r=!1,children:n,dir:a,onOpenChange:o,modal:l=!0}=t,i=vue(s),[d,u]=k.useState(null),p=k.useRef(!1),f=ed(o),y=mw(a);return k.useEffect(()=>{const _=()=>{p.current=!0,document.addEventListener("pointerdown",b,{capture:!0,once:!0}),document.addEventListener("pointermove",b,{capture:!0,once:!0})},b=()=>p.current=!1;return document.addEventListener("keydown",_,{capture:!0}),()=>{document.removeEventListener("keydown",_,{capture:!0}),document.removeEventListener("pointerdown",b,{capture:!0}),document.removeEventListener("pointermove",b,{capture:!0})}},[]),e.jsx(SR,{...i,children:e.jsx(ijt,{scope:s,open:r,onOpenChange:f,content:d,onContentChange:u,children:e.jsx(ojt,{scope:s,onClose:k.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:p,dir:y,modal:l,children:n})})})};_He.displayName=LR;var ljt="MenuAnchor",Ije=k.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=vue(r);return e.jsx(OA,{...a,...n,ref:s})});Ije.displayName=ljt;var Lje="MenuPortal",[cjt,bHe]=jC(Lje,{forceMount:void 0}),wHe=t=>{const{__scopeMenu:s,forceMount:r,children:n,container:a}=t,o=NC(Lje,s);return e.jsx(cjt,{scope:s,forceMount:r,children:e.jsx(jd,{present:r||o.open,children:e.jsx(IA,{asChild:!0,container:a,children:n})})})};wHe.displayName=Lje;var vx="MenuContent",[djt,Dje]=jC(vx),jHe=k.forwardRef((t,s)=>{const r=bHe(vx,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=NC(vx,t.__scopeMenu),l=DR(vx,t.__scopeMenu);return e.jsx(sD.Provider,{scope:t.__scopeMenu,children:e.jsx(jd,{present:n||o.open,children:e.jsx(sD.Slot,{scope:t.__scopeMenu,children:l.modal?e.jsx(ujt,{...a,ref:s}):e.jsx(hjt,{...a,ref:s})})})})}),ujt=k.forwardRef((t,s)=>{const r=NC(vx,t.__scopeMenu),n=k.useRef(null),a=Ta(s,n);return k.useEffect(()=>{const o=n.current;if(o)return gue(o)},[]),e.jsx(Rje,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Mr(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),hjt=k.forwardRef((t,s)=>{const r=NC(vx,t.__scopeMenu);return e.jsx(Rje,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),mjt=Hb("MenuContent.ScrollLock"),Rje=k.forwardRef((t,s)=>{const{__scopeMenu:r,loop:n=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:l,disableOutsidePointerEvents:i,onEntryFocus:d,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:f,onInteractOutside:y,onDismiss:_,disableOutsideScroll:b,...N}=t,w=NC(vx,r),S=DR(vx,r),C=vue(r),A=vHe(r),I=njt(r),[L,O]=k.useState(null),V=k.useRef(null),q=Ta(s,V,w.onContentChange),B=k.useRef(0),U=k.useRef(""),te=k.useRef(0),Y=k.useRef(null),J=k.useRef("right"),X=k.useRef(0),ce=b?IR:k.Fragment,ie=b?{as:mjt,allowPinchZoom:!0}:void 0,ae=me=>{var Re,Ve;const ve=U.current+me,he=I().filter(Ne=>!Ne.disabled),ge=document.activeElement,je=(Re=he.find(Ne=>Ne.ref.current===ge))==null?void 0:Re.textValue,qe=he.map(Ne=>Ne.textValue),Me=kjt(qe,ve,je),ke=(Ve=he.find(Ne=>Ne.textValue===Me))==null?void 0:Ve.ref.current;(function Ne(Ue){U.current=Ue,window.clearTimeout(B.current),Ue!==""&&(B.current=window.setTimeout(()=>Ne(""),1e3))})(ve),ke&&setTimeout(()=>ke.focus())};k.useEffect(()=>()=>window.clearTimeout(B.current),[]),pue();const oe=k.useCallback(me=>{var he,ge;return J.current===((he=Y.current)==null?void 0:he.side)&&Cjt(me,(ge=Y.current)==null?void 0:ge.area)},[]);return e.jsx(djt,{scope:r,searchRef:U,onItemEnter:k.useCallback(me=>{oe(me)&&me.preventDefault()},[oe]),onItemLeave:k.useCallback(me=>{var ve;oe(me)||((ve=V.current)==null||ve.focus(),O(null))},[oe]),onTriggerLeave:k.useCallback(me=>{oe(me)&&me.preventDefault()},[oe]),pointerGraceTimerRef:te,onPointerGraceIntentChange:k.useCallback(me=>{Y.current=me},[]),children:e.jsx(ce,{...ie,children:e.jsx(ER,{asChild:!0,trapped:a,onMountAutoFocus:Mr(o,me=>{var ve;me.preventDefault(),(ve=V.current)==null||ve.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:e.jsx(dw,{asChild:!0,disableOutsidePointerEvents:i,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:f,onInteractOutside:y,onDismiss:_,children:e.jsx(fue,{asChild:!0,...A,dir:S.dir,orientation:"vertical",loop:n,currentTabStopId:L,onCurrentTabStopIdChange:O,onEntryFocus:Mr(d,me=>{S.isUsingKeyboardRef.current||me.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(CR,{role:"menu","aria-orientation":"vertical","data-state":zHe(w.open),"data-radix-menu-content":"",dir:S.dir,...C,...N,ref:q,style:{outline:"none",...N.style},onKeyDown:Mr(N.onKeyDown,me=>{const he=me.target.closest("[data-radix-menu-content]")===me.currentTarget,ge=me.ctrlKey||me.altKey||me.metaKey,je=me.key.length===1;he&&(me.key==="Tab"&&me.preventDefault(),!ge&&je&&ae(me.key));const qe=V.current;if(me.target!==qe||!tjt.includes(me.key))return;me.preventDefault();const ke=I().filter(Re=>!Re.disabled).map(Re=>Re.ref.current);gHe.includes(me.key)&&ke.reverse(),jjt(ke)}),onBlur:Mr(t.onBlur,me=>{me.currentTarget.contains(me.target)||(window.clearTimeout(B.current),U.current="")}),onPointerMove:Mr(t.onPointerMove,rD(me=>{const ve=me.target,he=X.current!==me.clientX;if(me.currentTarget.contains(ve)&&he){const ge=me.clientX>X.current?"right":"left";J.current=ge,X.current=me.clientX}}))})})})})})})});jHe.displayName=vx;var pjt="MenuGroup",Oje=k.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Jr.div,{role:"group",...n,ref:s})});Oje.displayName=pjt;var fjt="MenuLabel",NHe=k.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Jr.div,{...n,ref:s})});NHe.displayName=fjt;var Woe="MenuItem",LPe="menu.itemSelect",_ue=k.forwardRef((t,s)=>{const{disabled:r=!1,onSelect:n,...a}=t,o=k.useRef(null),l=DR(Woe,t.__scopeMenu),i=Dje(Woe,t.__scopeMenu),d=Ta(s,o),u=k.useRef(!1),p=()=>{const f=o.current;if(!r&&f){const y=new CustomEvent(LPe,{bubbles:!0,cancelable:!0});f.addEventListener(LPe,_=>n==null?void 0:n(_),{once:!0}),sje(f,y),y.defaultPrevented?u.current=!1:l.onClose()}};return e.jsx(kHe,{...a,ref:d,disabled:r,onClick:Mr(t.onClick,p),onPointerDown:f=>{var y;(y=t.onPointerDown)==null||y.call(t,f),u.current=!0},onPointerUp:Mr(t.onPointerUp,f=>{var y;u.current||(y=f.currentTarget)==null||y.click()}),onKeyDown:Mr(t.onKeyDown,f=>{const y=i.searchRef.current!=="";r||y&&f.key===" "||p1e.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});_ue.displayName=Woe;var kHe=k.forwardRef((t,s)=>{const{__scopeMenu:r,disabled:n=!1,textValue:a,...o}=t,l=Dje(Woe,r),i=vHe(r),d=k.useRef(null),u=Ta(s,d),[p,f]=k.useState(!1),[y,_]=k.useState("");return k.useEffect(()=>{const b=d.current;b&&_((b.textContent??"").trim())},[o.children]),e.jsx(sD.ItemSlot,{scope:r,disabled:n,textValue:a??y,children:e.jsx(xue,{asChild:!0,...i,focusable:!n,children:e.jsx(Jr.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...o,ref:u,onPointerMove:Mr(t.onPointerMove,rD(b=>{n?l.onItemLeave(b):(l.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Mr(t.onPointerLeave,rD(b=>l.onItemLeave(b))),onFocus:Mr(t.onFocus,()=>f(!0)),onBlur:Mr(t.onBlur,()=>f(!1))})})})}),xjt="MenuCheckboxItem",SHe=k.forwardRef((t,s)=>{const{checked:r=!1,onCheckedChange:n,...a}=t;return e.jsx(EHe,{scope:t.__scopeMenu,checked:r,children:e.jsx(_ue,{role:"menuitemcheckbox","aria-checked":Koe(r)?"mixed":r,...a,ref:s,"data-state":zje(r),onSelect:Mr(a.onSelect,()=>n==null?void 0:n(Koe(r)?!0:!r),{checkForDefaultPrevented:!1})})})});SHe.displayName=xjt;var CHe="MenuRadioGroup",[gjt,yjt]=jC(CHe,{value:void 0,onValueChange:()=>{}}),MHe=k.forwardRef((t,s)=>{const{value:r,onValueChange:n,...a}=t,o=ed(n);return e.jsx(gjt,{scope:t.__scopeMenu,value:r,onValueChange:o,children:e.jsx(Oje,{...a,ref:s})})});MHe.displayName=CHe;var THe="MenuRadioItem",AHe=k.forwardRef((t,s)=>{const{value:r,...n}=t,a=yjt(THe,t.__scopeMenu),o=r===a.value;return e.jsx(EHe,{scope:t.__scopeMenu,checked:o,children:e.jsx(_ue,{role:"menuitemradio","aria-checked":o,...n,ref:s,"data-state":zje(o),onSelect:Mr(n.onSelect,()=>{var l;return(l=a.onValueChange)==null?void 0:l.call(a,r)},{checkForDefaultPrevented:!1})})})});AHe.displayName=THe;var Fje="MenuItemIndicator",[EHe,vjt]=jC(Fje,{checked:!1}),PHe=k.forwardRef((t,s)=>{const{__scopeMenu:r,forceMount:n,...a}=t,o=vjt(Fje,r);return e.jsx(jd,{present:n||Koe(o.checked)||o.checked===!0,children:e.jsx(Jr.span,{...a,ref:s,"data-state":zje(o.checked)})})});PHe.displayName=Fje;var _jt="MenuSeparator",IHe=k.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Jr.div,{role:"separator","aria-orientation":"horizontal",...n,ref:s})});IHe.displayName=_jt;var bjt="MenuArrow",LHe=k.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=vue(r);return e.jsx(MR,{...a,...n,ref:s})});LHe.displayName=bjt;var wjt="MenuSub",[QTs,DHe]=jC(wjt),PI="MenuSubTrigger",RHe=k.forwardRef((t,s)=>{const r=NC(PI,t.__scopeMenu),n=DR(PI,t.__scopeMenu),a=DHe(PI,t.__scopeMenu),o=Dje(PI,t.__scopeMenu),l=k.useRef(null),{pointerGraceTimerRef:i,onPointerGraceIntentChange:d}=o,u={__scopeMenu:t.__scopeMenu},p=k.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return k.useEffect(()=>p,[p]),k.useEffect(()=>{const f=i.current;return()=>{window.clearTimeout(f),d(null)}},[i,d]),e.jsx(Ije,{asChild:!0,...u,children:e.jsx(kHe,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":a.contentId,"data-state":zHe(r.open),...t,ref:m1(s,a.onTriggerChange),onClick:f=>{var y;(y=t.onClick)==null||y.call(t,f),!(t.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Mr(t.onPointerMove,rD(f=>{o.onItemEnter(f),!f.defaultPrevented&&!t.disabled&&!r.open&&!l.current&&(o.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{r.onOpenChange(!0),p()},100))})),onPointerLeave:Mr(t.onPointerLeave,rD(f=>{var _,b;p();const y=(_=r.content)==null?void 0:_.getBoundingClientRect();if(y){const N=(b=r.content)==null?void 0:b.dataset.side,w=N==="right",S=w?-5:5,C=y[w?"left":"right"],A=y[w?"right":"left"];o.onPointerGraceIntentChange({area:[{x:f.clientX+S,y:f.clientY},{x:C,y:y.top},{x:A,y:y.top},{x:A,y:y.bottom},{x:C,y:y.bottom}],side:N}),window.clearTimeout(i.current),i.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(f),f.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Mr(t.onKeyDown,f=>{var _;const y=o.searchRef.current!=="";t.disabled||y&&f.key===" "||sjt[n.dir].includes(f.key)&&(r.onOpenChange(!0),(_=r.content)==null||_.focus(),f.preventDefault())})})})});RHe.displayName=PI;var OHe="MenuSubContent",FHe=k.forwardRef((t,s)=>{const r=bHe(vx,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=NC(vx,t.__scopeMenu),l=DR(vx,t.__scopeMenu),i=DHe(OHe,t.__scopeMenu),d=k.useRef(null),u=Ta(s,d);return e.jsx(sD.Provider,{scope:t.__scopeMenu,children:e.jsx(jd,{present:n||o.open,children:e.jsx(sD.Slot,{scope:t.__scopeMenu,children:e.jsx(Rje,{id:i.contentId,"aria-labelledby":i.triggerId,...a,ref:u,align:"start",side:l.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:p=>{var f;l.isUsingKeyboardRef.current&&((f=d.current)==null||f.focus()),p.preventDefault()},onCloseAutoFocus:p=>p.preventDefault(),onFocusOutside:Mr(t.onFocusOutside,p=>{p.target!==i.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Mr(t.onEscapeKeyDown,p=>{l.onClose(),p.preventDefault()}),onKeyDown:Mr(t.onKeyDown,p=>{var _;const f=p.currentTarget.contains(p.target),y=rjt[l.dir].includes(p.key);f&&y&&(o.onOpenChange(!1),(_=i.trigger)==null||_.focus(),p.preventDefault())})})})})})});FHe.displayName=OHe;function zHe(t){return t?"open":"closed"}function Koe(t){return t==="indeterminate"}function zje(t){return Koe(t)?"indeterminate":t?"checked":"unchecked"}function jjt(t){const s=document.activeElement;for(const r of t)if(r===s||(r.focus(),document.activeElement!==s))return}function Njt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}function kjt(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=Njt(t,Math.max(o,0));a.length===1&&(l=l.filter(u=>u!==r));const d=l.find(u=>u.toLowerCase().startsWith(a.toLowerCase()));return d!==r?d:void 0}function Sjt(t,s){const{x:r,y:n}=t;let a=!1;for(let o=0,l=s.length-1;on!=y>n&&r<(f-u)*(n-p)/(y-p)+u&&(a=!a)}return a}function Cjt(t,s){if(!s)return!1;const r={x:t.clientX,y:t.clientY};return Sjt(r,s)}function rD(t){return s=>s.pointerType==="mouse"?t(s):void 0}var Mjt=_He,Tjt=Ije,Ajt=wHe,Ejt=jHe,Pjt=Oje,Ijt=NHe,Ljt=_ue,Djt=SHe,Rjt=MHe,Ojt=AHe,Fjt=PHe,zjt=IHe,Bjt=LHe,$jt=RHe,qjt=FHe,bue="DropdownMenu",[Ujt,JTs]=qc(bue,[yHe]),Rm=yHe(),[Vjt,BHe]=Ujt(bue),$He=t=>{const{__scopeDropdownMenu:s,children:r,dir:n,open:a,defaultOpen:o,onOpenChange:l,modal:i=!0}=t,d=Rm(s),u=k.useRef(null),[p,f]=Uu({prop:a,defaultProp:o??!1,onChange:l,caller:bue});return e.jsx(Vjt,{scope:s,triggerId:fu(),triggerRef:u,contentId:fu(),open:p,onOpenChange:f,onOpenToggle:k.useCallback(()=>f(y=>!y),[f]),modal:i,children:e.jsx(Mjt,{...d,open:p,onOpenChange:f,dir:n,modal:i,children:r})})};$He.displayName=bue;var qHe="DropdownMenuTrigger",UHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...a}=t,o=BHe(qHe,r),l=Rm(r);return e.jsx(Tjt,{asChild:!0,...l,children:e.jsx(Jr.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:m1(s,o.triggerRef),onPointerDown:Mr(t.onPointerDown,i=>{!n&&i.button===0&&i.ctrlKey===!1&&(o.onOpenToggle(),o.open||i.preventDefault())}),onKeyDown:Mr(t.onKeyDown,i=>{n||(["Enter"," "].includes(i.key)&&o.onOpenToggle(),i.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(i.key)&&i.preventDefault())})})})});UHe.displayName=qHe;var Hjt="DropdownMenuPortal",VHe=t=>{const{__scopeDropdownMenu:s,...r}=t,n=Rm(s);return e.jsx(Ajt,{...n,...r})};VHe.displayName=Hjt;var HHe="DropdownMenuContent",GHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=BHe(HHe,r),o=Rm(r),l=k.useRef(!1);return e.jsx(Ejt,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...n,ref:s,onCloseAutoFocus:Mr(t.onCloseAutoFocus,i=>{var d;l.current||(d=a.triggerRef.current)==null||d.focus(),l.current=!1,i.preventDefault()}),onInteractOutside:Mr(t.onInteractOutside,i=>{const d=i.detail.originalEvent,u=d.button===0&&d.ctrlKey===!0,p=d.button===2||u;(!a.modal||p)&&(l.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});GHe.displayName=HHe;var Gjt="DropdownMenuGroup",Wjt=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Pjt,{...a,...n,ref:s})});Wjt.displayName=Gjt;var Kjt="DropdownMenuLabel",WHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Ijt,{...a,...n,ref:s})});WHe.displayName=Kjt;var Zjt="DropdownMenuItem",KHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Ljt,{...a,...n,ref:s})});KHe.displayName=Zjt;var Yjt="DropdownMenuCheckboxItem",ZHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Djt,{...a,...n,ref:s})});ZHe.displayName=Yjt;var Xjt="DropdownMenuRadioGroup",Qjt=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Rjt,{...a,...n,ref:s})});Qjt.displayName=Xjt;var Jjt="DropdownMenuRadioItem",YHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Ojt,{...a,...n,ref:s})});YHe.displayName=Jjt;var eNt="DropdownMenuItemIndicator",XHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Fjt,{...a,...n,ref:s})});XHe.displayName=eNt;var tNt="DropdownMenuSeparator",QHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(zjt,{...a,...n,ref:s})});QHe.displayName=tNt;var sNt="DropdownMenuArrow",rNt=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Bjt,{...a,...n,ref:s})});rNt.displayName=sNt;var nNt="DropdownMenuSubTrigger",JHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx($jt,{...a,...n,ref:s})});JHe.displayName=nNt;var aNt="DropdownMenuSubContent",eGe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(qjt,{...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)"}})});eGe.displayName=aNt;var iNt=$He,oNt=UHe,lNt=VHe,tGe=GHe,sGe=WHe,rGe=KHe,nGe=ZHe,aGe=YHe,iGe=XHe,oGe=QHe,lGe=JHe,cGe=eGe;const Hd=iNt,Gd=oNt,cNt=k.forwardRef(({className:t,inset:s,children:r,...n},a)=>e.jsxs(lGe,{ref:a,className:Ot("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(xa,{className:"ml-auto h-4 w-4"})]}));cNt.displayName=lGe.displayName;const dNt=k.forwardRef(({className:t,...s},r)=>e.jsx(cGe,{ref:r,className:Ot("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}));dNt.displayName=cGe.displayName;const Nd=k.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(lNt,{children:e.jsx(tGe,{ref:n,sideOffset:s,className:Ot("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})}));Nd.displayName=tGe.displayName;const _a=k.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(rGe,{ref:n,className:Ot("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}));_a.displayName=rGe.displayName;const uNt=k.forwardRef(({className:t,children:s,checked:r,...n},a)=>e.jsxs(nGe,{ref:a,className:Ot("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(iGe,{children:e.jsx(Zn,{className:"h-4 w-4"})})}),s]}));uNt.displayName=nGe.displayName;const hNt=k.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(aGe,{ref:n,className:Ot("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(iGe,{children:e.jsx(sd,{className:"h-2 w-2 fill-current"})})}),s]}));hNt.displayName=aGe.displayName;const f1e=k.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(sGe,{ref:n,className:Ot("px-2 py-1.5 text-sm font-semibold",s&&"pl-8",t),...r}));f1e.displayName=sGe.displayName;const Yb=k.forwardRef(({className:t,...s},r)=>e.jsx(oGe,{ref:r,className:Ot("-mx-1 my-1 h-px bg-muted",t),...s}));Yb.displayName=oGe.displayName;const mNt=()=>{const{isAssistant:t,actingAsAgent:s,assignedAgents:r,setActingAsAgent:n,isActingAsSelf:a,setActingAsSelf:o}=Eje();if(!t)return null;const l=i=>i.split(" ").map(d=>d[0]).join("").toUpperCase().slice(0,2);return e.jsx("div",{className:"fixed top-0 left-0 right-0 z-[2147483647] bg-primary text-primary-foreground px-4 py-1.5 shadow-lg",style:{height:"40px"},children:e.jsxs("div",{className:"container mx-auto flex items-center justify-between gap-4 h-full",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[a?e.jsxs(e.Fragment,{children:[e.jsx(Ai,{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(ir,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"font-medium text-sm",children:"Acting as"})]}),e.jsxs(Hd,{children:[e.jsx(Gd,{asChild:!0,children:e.jsxs(W,{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(Ai,{className:"h-4 w-4"}),e.jsx("strong",{children:"My Account"})]}):s?e.jsxs(e.Fragment,{children:[e.jsxs(Nn,{className:"h-5 w-5",children:[e.jsx(Ma,{src:s.avatar_url||void 0}),e.jsx(kn,{className:"text-[10px] bg-primary-foreground/30",children:l(s.name)})]}),e.jsx("strong",{children:s.name})]}):e.jsx("strong",{children:"Select..."}),e.jsx(Bi,{className:"h-3 w-3"})]})}),e.jsxs(Nd,{align:"start",className:"z-[2147483647]",children:[e.jsxs(_a,{onClick:o,className:"gap-2",children:[e.jsx(Ai,{className:"h-4 w-4"}),e.jsx("span",{children:"My Account"}),a&&e.jsx(Qe,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]}),e.jsx(Yb,{}),r.map(i=>e.jsxs(_a,{onClick:()=>n(i),className:"gap-2",children:[e.jsxs(Nn,{className:"h-6 w-6",children:[e.jsx(Ma,{src:i.avatar_url||void 0}),e.jsx(kn,{className:"text-[10px]",children:l(i.name)})]}),e.jsx("span",{children:i.name}),!a&&i.id===(s==null?void 0:s.id)&&e.jsx(Qe,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]},i.id))]})]})]}),e.jsx(Qe,{variant:"secondary",className:"bg-primary-foreground/20 text-primary-foreground border-0 text-xs",children:a?"Personal Mode":"Assistant Mode"})]})})},rr=({children:t,requireAdmin:s=!1,requireBrokerageManager:r=!1})=>{const{user:n,loading:a,rolesLoading:o,isAdmin:l,isBrokerageManager:i}=Us(),d=$l();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=d.pathname+d.search+d.hash;return u&&u!=="/auth"&&sessionStorage.setItem("redirectAfterLogin",u),e.jsx(Jxe,{to:"/auth",replace:!0})}return s&&!l?e.jsx(Jxe,{to:"/dashboard",replace:!0}):r&&!i&&!l?e.jsx(Jxe,{to:"/dashboard",replace:!0}):e.jsx(e.Fragment,{children:t})};var Bje={};(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 ve=new OffscreenCanvas(1,1),he=ve.getContext("2d");he.fillRect(0,0,1,1);var ge=ve.transferToImageBitmap();he.createPattern(ge,"no-repeat")}catch{return!1}return!0}();function d(){}function u(ve){var he=r.exports.Promise,ge=he!==void 0?he:s.Promise;return typeof ge=="function"?new ge(ve):(ve(d,d),null)}var p=function(ve,he){return{transform:function(ge){if(ve)return ge;if(he.has(ge))return he.get(ge);var je=new OffscreenCanvas(ge.width,ge.height),qe=je.getContext("2d");return qe.drawImage(ge,0,0),he.set(ge,je),je},clear:function(){he.clear()}}}(i,new Map),f=function(){var ve=Math.floor(16.666666666666668),he,ge,je={},qe=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(he=function(Me){var ke=Math.random();return je[ke]=requestAnimationFrame(function Re(Ve){qe===Ve||qe+ve-1{const{data:s,error:r}=await G.from("celebration_queue").select("*").eq("user_id",t.id).is("seen_at",null).order("created_at",{ascending:!0});if(r)throw r;return s},enabled:!!(t!=null&&t.id),refetchOnWindowFocus:!0,staleTime:0})}function fNt(){const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("celebration_queue").update({seen_at:new Date().toISOString()}).eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["celebrations"]})}})}function xNt(){const t=Qt(),{user:s}=Us();return Pt({mutationFn:async r=>{const{error:n}=await G.from("celebration_queue").insert({user_id:r.user_id,celebration_type:r.celebration_type,title:r.title,message:r.message||null,points_amount:r.points_amount||null,created_by:s==null?void 0:s.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["celebrations"]})}})}var wue="Dialog",[dGe,uGe]=qc(wue),[gNt,Hg]=dGe(wue),hGe=t=>{const{__scopeDialog:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!0}=t,i=k.useRef(null),d=k.useRef(null),[u,p]=Uu({prop:n,defaultProp:a??!1,onChange:o,caller:wue});return e.jsx(gNt,{scope:s,triggerRef:i,contentRef:d,contentId:fu(),titleId:fu(),descriptionId:fu(),open:u,onOpenChange:p,onOpenToggle:k.useCallback(()=>p(f=>!f),[p]),modal:l,children:r})};hGe.displayName=wue;var mGe="DialogTrigger",pGe=k.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Hg(mGe,r),o=Ta(s,a.triggerRef);return e.jsx(Jr.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":Uje(a.open),...n,ref:o,onClick:Mr(t.onClick,a.onOpenToggle)})});pGe.displayName=mGe;var $je="DialogPortal",[yNt,fGe]=dGe($je,{forceMount:void 0}),xGe=t=>{const{__scopeDialog:s,forceMount:r,children:n,container:a}=t,o=Hg($je,s);return e.jsx(yNt,{scope:s,forceMount:r,children:k.Children.map(n,l=>e.jsx(jd,{present:r||o.open,children:e.jsx(IA,{asChild:!0,container:a,children:l})}))})};xGe.displayName=$je;var Zoe="DialogOverlay",gGe=k.forwardRef((t,s)=>{const r=fGe(Zoe,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=Hg(Zoe,t.__scopeDialog);return o.modal?e.jsx(jd,{present:n||o.open,children:e.jsx(_Nt,{...a,ref:s})}):null});gGe.displayName=Zoe;var vNt=Hb("DialogOverlay.RemoveScroll"),_Nt=k.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Hg(Zoe,r);return e.jsx(IR,{as:vNt,allowPinchZoom:!0,shards:[a.contentRef],children:e.jsx(Jr.div,{"data-state":Uje(a.open),...n,ref:s,style:{pointerEvents:"auto",...n.style}})})}),GS="DialogContent",yGe=k.forwardRef((t,s)=>{const r=fGe(GS,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=Hg(GS,t.__scopeDialog);return e.jsx(jd,{present:n||o.open,children:o.modal?e.jsx(bNt,{...a,ref:s}):e.jsx(wNt,{...a,ref:s})})});yGe.displayName=GS;var bNt=k.forwardRef((t,s)=>{const r=Hg(GS,t.__scopeDialog),n=k.useRef(null),a=Ta(s,r.contentRef,n);return k.useEffect(()=>{const o=n.current;if(o)return gue(o)},[]),e.jsx(vGe,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Mr(t.onCloseAutoFocus,o=>{var l;o.preventDefault(),(l=r.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Mr(t.onPointerDownOutside,o=>{const l=o.detail.originalEvent,i=l.button===0&&l.ctrlKey===!0;(l.button===2||i)&&o.preventDefault()}),onFocusOutside:Mr(t.onFocusOutside,o=>o.preventDefault())})}),wNt=k.forwardRef((t,s)=>{const r=Hg(GS,t.__scopeDialog),n=k.useRef(!1),a=k.useRef(!1);return e.jsx(vGe,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var l,i;(l=t.onCloseAutoFocus)==null||l.call(t,o),o.defaultPrevented||(n.current||(i=r.triggerRef.current)==null||i.focus(),o.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:o=>{var d,u;(d=t.onInteractOutside)==null||d.call(t,o),o.defaultPrevented||(n.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=o.target;((u=r.triggerRef.current)==null?void 0:u.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),vGe=k.forwardRef((t,s)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,...l}=t,i=Hg(GS,r),d=k.useRef(null),u=Ta(s,d);return pue(),e.jsxs(e.Fragment,{children:[e.jsx(ER,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(dw,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":Uje(i.open),...l,ref:u,onDismiss:()=>i.onOpenChange(!1)})}),e.jsxs(e.Fragment,{children:[e.jsx(NNt,{titleId:i.titleId}),e.jsx(SNt,{contentRef:d,descriptionId:i.descriptionId})]})]})}),qje="DialogTitle",_Ge=k.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Hg(qje,r);return e.jsx(Jr.h2,{id:a.titleId,...n,ref:s})});_Ge.displayName=qje;var bGe="DialogDescription",wGe=k.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Hg(bGe,r);return e.jsx(Jr.p,{id:a.descriptionId,...n,ref:s})});wGe.displayName=bGe;var jGe="DialogClose",NGe=k.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Hg(jGe,r);return e.jsx(Jr.button,{type:"button",...n,ref:s,onClick:Mr(t.onClick,()=>a.onOpenChange(!1))})});NGe.displayName=jGe;function Uje(t){return t?"open":"closed"}var kGe="DialogTitleWarning",[jNt,SGe]=Axt(kGe,{contentName:GS,titleName:qje,docsSlug:"dialog"}),NNt=({titleId:t})=>{const s=SGe(kGe),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},kNt="DialogDescriptionWarning",SNt=({contentRef:t,descriptionId:s})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${SGe(kNt).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},jue=hGe,Vje=pGe,Nue=xGe,UA=gGe,VA=yGe,RR=_Ge,OR=wGe,FR=NGe;const fs=jue,mi=Vje,CNt=Nue,eAs=FR,CGe=k.forwardRef(({className:t,...s},r)=>e.jsx(UA,{ref:r,className:Ot("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}));CGe.displayName=UA.displayName;const ps=k.forwardRef(({className:t,children:s,overlayClassName:r,...n},a)=>e.jsxs(CNt,{children:[e.jsx(CGe,{className:r}),e.jsxs(VA,{ref:a,className:Ot("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(FR,{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(kr,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ps.displayName=VA.displayName;const ks=({className:t,...s})=>e.jsx("div",{className:Ot("flex flex-col space-y-1.5 text-center sm:text-left",t),...s});ks.displayName="DialogHeader";const gn=({className:t,...s})=>e.jsx("div",{className:Ot("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});gn.displayName="DialogFooter";const _s=k.forwardRef(({className:t,...s},r)=>e.jsx(RR,{ref:r,className:Ot("text-lg font-semibold leading-none tracking-tight",t),...s}));_s.displayName=RR.displayName;const Ir=k.forwardRef(({className:t,...s},r)=>e.jsx(OR,{ref:r,className:Ot("text-sm text-muted-foreground",t),...s}));Ir.displayName=OR.displayName;const MNt={points_earned:Fi,listing_created:Mn,deal_closed:_c,custom:Gn},RPe={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"},OPe=()=>{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 TNt(){const{user:t}=Us(),s=Qt(),{data:r}=pNt(),n=fNt(),[a,o]=k.useState(null),[l,i]=k.useState(!1),d=k.useCallback(()=>{const _=Date.now()+3e3,b={startVelocity:30,spread:360,ticks:60,zIndex:9999},N=(S,C)=>Math.random()*(C-S)+S,w=setInterval(()=>{const S=_-Date.now();if(S<=0){clearInterval(w);return}const C=50*(S/3e3);DPe({...b,particleCount:C,origin:{x:N(.1,.3),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]}),DPe({...b,particleCount:C,origin:{x:N(.7,.9),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]})},250)},[]);k.useEffect(()=>{OPe()||r&&r.length>0&&!a&&(o(r[0]),i(!0),setTimeout(d,100))},[r,a,d]);const u=async()=>{if(a){const y=a.id;i(!1),o(null),s.setQueryData(["celebrations","pending",t==null?void 0:t.id],_=>(_==null?void 0:_.filter(b=>b.id!==y))??[]),await n.mutateAsync(y)}};if(OPe()||!a)return null;const p=MNt[a.celebration_type]||Gn,f=RPe[a.celebration_type]||RPe.custom;return e.jsx(fs,{open:l,onOpenChange:y=>!y&&u(),children:e.jsxs(ps,{className:"sm:max-w-md text-center border-0 overflow-hidden",children:[e.jsx("div",{className:`absolute inset-0 bg-gradient-to-br ${f} opacity-10`}),e.jsxs("div",{className:"relative z-10 py-6",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:`w-20 h-20 rounded-full bg-gradient-to-br ${f} flex items-center justify-center animate-bounce`,children:e.jsx(p,{className:"w-10 h-10 text-white"})})}),e.jsxs("div",{className:"flex justify-center gap-1 mb-4",children:[e.jsx(Or,{className:"w-5 h-5 text-yellow-500 animate-pulse"}),e.jsx(Or,{className:"w-5 h-5 text-yellow-500 animate-pulse delay-75"}),e.jsx(Or,{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(W,{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 MGe="/assets/levelup-logo-horizontal-DEFNc0ms.png",Hje="/assets/levelup-logo-white-C2RAgAoG.png",ANt="/assets/listings-hero-BI9Ki9Dq.jpg",De=k.forwardRef(({className:t,type:s,...r},n)=>e.jsx("input",{type:s,className:Ot("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}));De.displayName="Input";var TGe={exports:{}};(function(t,s){(function(r,n){t.exports=n()})(gd,function(){let r,n,a;function o(i,d){if(!r)r=d;else if(!n)n=d;else{const u={};r(u),a=d(u);const p="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+")(undefined, sharedChunk); self.onerror = null;";typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(a.workerUrl=window.URL.createObjectURL(new Blob([p],{type:"text/javascript"})))}}o(["exports"],function(i){var d=1e-6,u=typeof Float32Array<"u"?Float32Array:Array;function p(x,c){var h=c[0],g=c[1],j=c[2],T=c[3],P=h*T-j*g;return P?(x[0]=T*(P=1/P),x[1]=-g*P,x[2]=-j*P,x[3]=h*P,x):null}function f(){var x=new u(9);return u!=Float32Array&&(x[1]=0,x[2]=0,x[3]=0,x[5]=0,x[6]=0,x[7]=0),x[0]=1,x[4]=1,x[8]=1,x}function y(x,c){var h=c[0],g=c[1],j=c[2],T=c[3],P=c[4],R=c[5],F=c[6],H=c[7],Q=c[8];return x[0]=P*Q-R*H,x[1]=j*H-g*Q,x[2]=g*R-j*P,x[3]=R*F-T*Q,x[4]=h*Q-j*F,x[5]=j*T-h*R,x[6]=T*H-P*F,x[7]=g*F-h*H,x[8]=h*P-g*T,x}function _(x,c,h){var g=c[0],j=c[1],T=c[2],P=c[3],R=c[4],F=c[5],H=c[6],Q=c[7],se=c[8],re=h[0],le=h[1],ue=h[2],_e=h[3],Ce=h[4],Ee=h[5],Ge=h[6],Be=h[7],nt=h[8];return x[0]=re*g+le*P+ue*H,x[1]=re*j+le*R+ue*Q,x[2]=re*T+le*F+ue*se,x[3]=_e*g+Ce*P+Ee*H,x[4]=_e*j+Ce*R+Ee*Q,x[5]=_e*T+Ce*F+Ee*se,x[6]=Ge*g+Be*P+nt*H,x[7]=Ge*j+Be*R+nt*Q,x[8]=Ge*T+Be*F+nt*se,x}function b(){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 N(x){var c=new u(16);return c[0]=x[0],c[1]=x[1],c[2]=x[2],c[3]=x[3],c[4]=x[4],c[5]=x[5],c[6]=x[6],c[7]=x[7],c[8]=x[8],c[9]=x[9],c[10]=x[10],c[11]=x[11],c[12]=x[12],c[13]=x[13],c[14]=x[14],c[15]=x[15],c}function w(x){return x[0]=1,x[1]=0,x[2]=0,x[3]=0,x[4]=0,x[5]=1,x[6]=0,x[7]=0,x[8]=0,x[9]=0,x[10]=1,x[11]=0,x[12]=0,x[13]=0,x[14]=0,x[15]=1,x}function S(x,c){var h=c[0],g=c[1],j=c[2],T=c[3],P=c[4],R=c[5],F=c[6],H=c[7],Q=c[8],se=c[9],re=c[10],le=c[11],ue=c[12],_e=c[13],Ce=c[14],Ee=c[15],Ge=h*R-g*P,Be=h*F-j*P,nt=h*H-T*P,it=g*F-j*R,lt=g*H-T*R,Rt=j*H-T*F,jt=Q*_e-se*ue,It=Q*Ce-re*ue,Mt=Q*Ee-le*ue,Tt=se*Ce-re*_e,rs=se*Ee-le*_e,ls=re*Ee-le*Ce,xs=Ge*ls-Be*rs+nt*Tt+it*Mt-lt*It+Rt*jt;return xs?(x[0]=(R*ls-F*rs+H*Tt)*(xs=1/xs),x[1]=(j*rs-g*ls-T*Tt)*xs,x[2]=(_e*Rt-Ce*lt+Ee*it)*xs,x[3]=(re*lt-se*Rt-le*it)*xs,x[4]=(F*Mt-P*ls-H*It)*xs,x[5]=(h*ls-j*Mt+T*It)*xs,x[6]=(Ce*nt-ue*Rt-Ee*Be)*xs,x[7]=(Q*Rt-re*nt+le*Be)*xs,x[8]=(P*rs-R*Mt+H*jt)*xs,x[9]=(g*Mt-h*rs-T*jt)*xs,x[10]=(ue*lt-_e*nt+Ee*Ge)*xs,x[11]=(se*nt-Q*lt-le*Ge)*xs,x[12]=(R*It-P*Tt-F*jt)*xs,x[13]=(h*Tt-g*It+j*jt)*xs,x[14]=(_e*Be-ue*it-Ce*Ge)*xs,x[15]=(Q*it-se*Be+re*Ge)*xs,x):null}function C(x,c,h){var g=c[0],j=c[1],T=c[2],P=c[3],R=c[4],F=c[5],H=c[6],Q=c[7],se=c[8],re=c[9],le=c[10],ue=c[11],_e=c[12],Ce=c[13],Ee=c[14],Ge=c[15],Be=h[0],nt=h[1],it=h[2],lt=h[3];return x[0]=Be*g+nt*R+it*se+lt*_e,x[1]=Be*j+nt*F+it*re+lt*Ce,x[2]=Be*T+nt*H+it*le+lt*Ee,x[3]=Be*P+nt*Q+it*ue+lt*Ge,x[4]=(Be=h[4])*g+(nt=h[5])*R+(it=h[6])*se+(lt=h[7])*_e,x[5]=Be*j+nt*F+it*re+lt*Ce,x[6]=Be*T+nt*H+it*le+lt*Ee,x[7]=Be*P+nt*Q+it*ue+lt*Ge,x[8]=(Be=h[8])*g+(nt=h[9])*R+(it=h[10])*se+(lt=h[11])*_e,x[9]=Be*j+nt*F+it*re+lt*Ce,x[10]=Be*T+nt*H+it*le+lt*Ee,x[11]=Be*P+nt*Q+it*ue+lt*Ge,x[12]=(Be=h[12])*g+(nt=h[13])*R+(it=h[14])*se+(lt=h[15])*_e,x[13]=Be*j+nt*F+it*re+lt*Ce,x[14]=Be*T+nt*H+it*le+lt*Ee,x[15]=Be*P+nt*Q+it*ue+lt*Ge,x}function A(x,c,h){var g,j,T,P,R,F,H,Q,se,re,le,ue,_e=h[0],Ce=h[1],Ee=h[2];return c===x?(x[12]=c[0]*_e+c[4]*Ce+c[8]*Ee+c[12],x[13]=c[1]*_e+c[5]*Ce+c[9]*Ee+c[13],x[14]=c[2]*_e+c[6]*Ce+c[10]*Ee+c[14],x[15]=c[3]*_e+c[7]*Ce+c[11]*Ee+c[15]):(j=c[1],T=c[2],P=c[3],R=c[4],F=c[5],H=c[6],Q=c[7],se=c[8],re=c[9],le=c[10],ue=c[11],x[0]=g=c[0],x[1]=j,x[2]=T,x[3]=P,x[4]=R,x[5]=F,x[6]=H,x[7]=Q,x[8]=se,x[9]=re,x[10]=le,x[11]=ue,x[12]=g*_e+R*Ce+se*Ee+c[12],x[13]=j*_e+F*Ce+re*Ee+c[13],x[14]=T*_e+H*Ce+le*Ee+c[14],x[15]=P*_e+Q*Ce+ue*Ee+c[15]),x}function I(x,c,h){var g=h[0],j=h[1],T=h[2];return x[0]=c[0]*g,x[1]=c[1]*g,x[2]=c[2]*g,x[3]=c[3]*g,x[4]=c[4]*j,x[5]=c[5]*j,x[6]=c[6]*j,x[7]=c[7]*j,x[8]=c[8]*T,x[9]=c[9]*T,x[10]=c[10]*T,x[11]=c[11]*T,x[12]=c[12],x[13]=c[13],x[14]=c[14],x[15]=c[15],x}function L(x,c,h){var g=Math.sin(h),j=Math.cos(h),T=c[4],P=c[5],R=c[6],F=c[7],H=c[8],Q=c[9],se=c[10],re=c[11];return c!==x&&(x[0]=c[0],x[1]=c[1],x[2]=c[2],x[3]=c[3],x[12]=c[12],x[13]=c[13],x[14]=c[14],x[15]=c[15]),x[4]=T*j+H*g,x[5]=P*j+Q*g,x[6]=R*j+se*g,x[7]=F*j+re*g,x[8]=H*j-T*g,x[9]=Q*j-P*g,x[10]=se*j-R*g,x[11]=re*j-F*g,x}function O(x,c,h){var g=Math.sin(h),j=Math.cos(h),T=c[0],P=c[1],R=c[2],F=c[3],H=c[8],Q=c[9],se=c[10],re=c[11];return c!==x&&(x[4]=c[4],x[5]=c[5],x[6]=c[6],x[7]=c[7],x[12]=c[12],x[13]=c[13],x[14]=c[14],x[15]=c[15]),x[0]=T*j-H*g,x[1]=P*j-Q*g,x[2]=R*j-se*g,x[3]=F*j-re*g,x[8]=T*g+H*j,x[9]=P*g+Q*j,x[10]=R*g+se*j,x[11]=F*g+re*j,x}function V(x,c,h){var g=Math.sin(h),j=Math.cos(h),T=c[0],P=c[1],R=c[2],F=c[3],H=c[4],Q=c[5],se=c[6],re=c[7];return c!==x&&(x[8]=c[8],x[9]=c[9],x[10]=c[10],x[11]=c[11],x[12]=c[12],x[13]=c[13],x[14]=c[14],x[15]=c[15]),x[0]=T*j+H*g,x[1]=P*j+Q*g,x[2]=R*j+se*g,x[3]=F*j+re*g,x[4]=H*j-T*g,x[5]=Q*j-P*g,x[6]=se*j-R*g,x[7]=re*j-F*g,x}function q(x,c){return x[0]=c[0],x[1]=0,x[2]=0,x[3]=0,x[4]=0,x[5]=c[1],x[6]=0,x[7]=0,x[8]=0,x[9]=0,x[10]=c[2],x[11]=0,x[12]=0,x[13]=0,x[14]=0,x[15]=1,x}function B(x,c,h){var g,j,T,P=h[0],R=h[1],F=h[2],H=Math.sqrt(P*P+R*R+F*F);return H0&&(T=1/Math.sqrt(T)),x[0]=c[0]*T,x[1]=c[1]*T,x[2]=c[2]*T,x}function Ue(x,c){return x[0]*c[0]+x[1]*c[1]+x[2]*c[2]}function Ie(x,c,h){var g=c[0],j=c[1],T=c[2],P=h[0],R=h[1],F=h[2];return x[0]=j*F-T*R,x[1]=T*P-g*F,x[2]=g*R-j*P,x}function ye(x,c,h,g){var j=c[0],T=c[1],P=c[2];return x[0]=j+g*(h[0]-j),x[1]=T+g*(h[1]-T),x[2]=P+g*(h[2]-P),x}function ct(x,c,h){var g=c[0],j=c[1],T=c[2],P=h[3]*g+h[7]*j+h[11]*T+h[15];return x[0]=(h[0]*g+h[4]*j+h[8]*T+h[12])/(P=P||1),x[1]=(h[1]*g+h[5]*j+h[9]*T+h[13])/P,x[2]=(h[2]*g+h[6]*j+h[10]*T+h[14])/P,x}function fe(x,c,h){var g=c[0],j=c[1],T=c[2];return x[0]=g*h[0]+j*h[3]+T*h[6],x[1]=g*h[1]+j*h[4]+T*h[7],x[2]=g*h[2]+j*h[5]+T*h[8],x}function $e(x,c,h){var g=h[0],j=h[1],T=h[2],P=h[3],R=c[0],F=c[1],H=c[2],Q=j*H-T*F,se=T*R-g*H,re=g*F-j*R;return x[0]=R+P*(Q+=Q)+j*(re+=re)-T*(se+=se),x[1]=F+P*se+T*Q-g*re,x[2]=H+P*re+g*se-j*Q,x}function Ye(x){return x[0]=0,x[1]=0,x[2]=0,x}function tt(x,c){return x[0]===c[0]&&x[1]===c[1]&&x[2]===c[2]}var Te=me,We=ve,Ke=ce;function ot(){var x=new u(4);return u!=Float32Array&&(x[0]=0,x[1]=0,x[2]=0,x[3]=0),x}function He(x,c,h){return x[0]=c[0]*h,x[1]=c[1]*h,x[2]=c[2]*h,x[3]=c[3]*h,x}function Je(x,c){var h=c[0],g=c[1],j=c[2],T=c[3],P=h*h+g*g+j*j+T*T;return P>0&&(P=1/Math.sqrt(P)),x[0]=h*P,x[1]=g*P,x[2]=j*P,x[3]=T*P,x}function ut(x,c){return x[0]*c[0]+x[1]*c[1]+x[2]*c[2]+x[3]*c[3]}function mt(x,c,h){var g=c[0],j=c[1],T=c[2],P=c[3];return x[0]=h[0]*g+h[4]*j+h[8]*T+h[12]*P,x[1]=h[1]*g+h[5]*j+h[9]*T+h[13]*P,x[2]=h[2]*g+h[6]*j+h[10]*T+h[14]*P,x[3]=h[3]*g+h[7]*j+h[11]*T+h[15]*P,x}function et(){var x=new u(4);return u!=Float32Array&&(x[0]=0,x[1]=0,x[2]=0),x[3]=1,x}function Ze(x){return x[0]=0,x[1]=0,x[2]=0,x[3]=1,x}function kt(x,c,h){h*=.5;var g=c[0],j=c[1],T=c[2],P=c[3],R=Math.sin(h),F=Math.cos(h);return x[0]=g*F+P*R,x[1]=j*F+T*R,x[2]=T*F-j*R,x[3]=P*F-g*R,x}function Ut(x,c,h){h*=.5;var g=c[0],j=c[1],T=c[2],P=c[3],R=Math.sin(h),F=Math.cos(h);return x[0]=g*F-T*R,x[1]=j*F+P*R,x[2]=T*F+g*R,x[3]=P*F-j*R,x}J(),ot();var Nt,es,ds,js=Je,lr=(Nt=J(),es=ie(1,0,0),ds=ie(0,1,0),function(x,c,h){var g=Ue(c,h);return g<-.999999?(Ie(Nt,es,c),Ke(Nt)<1e-6&&Ie(Nt,ds,c),Ne(Nt,Nt),function(j,T,P){P*=.5;var R=Math.sin(P);j[0]=R*T[0],j[1]=R*T[1],j[2]=R*T[2],j[3]=Math.cos(P)}(x,Nt,Math.PI),x):g>.999999?(x[0]=0,x[1]=0,x[2]=0,x[3]=1,x):(Ie(Nt,c,h),x[0]=Nt[0],x[1]=Nt[1],x[2]=Nt[2],x[3]=1+g,js(x,x))});function Lt(){var x=new u(2);return u!=Float32Array&&(x[0]=0,x[1]=0),x}function Es(x,c){var h=new u(2);return h[0]=x,h[1]=c,h}function fr(x,c,h){return x[0]=c,x[1]=h,x}function Hs(x,c,h){return x[0]=c[0]+h[0],x[1]=c[1]+h[1],x}function mr(x,c,h){return x[0]=c[0]-h[0],x[1]=c[1]-h[1],x}function an(x,c,h){return x[0]=c[0]*h,x[1]=c[1]*h,x}function Cr(x){var c=x[0],h=x[1];return Math.sqrt(c*c+h*h)}function Fr(x,c){var h=c[0],g=c[1],j=h*h+g*g;return j>0&&(j=1/Math.sqrt(j)),x[0]=c[0]*j,x[1]=c[1]*j,x}function $r(x,c){return x[0]*c[0]+x[1]*c[1]}et(),et(),f();var nr,cr,Br=mr;function Kr(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x.default:x}Lt();var Sn=function(){if(cr)return nr;function x(c,h,g,j){this.cx=3*c,this.bx=3*(g-c)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*h,this.by=3*(j-h)-this.cy,this.ay=1-this.cy-this.by,this.p1x=c,this.p1y=h,this.p2x=g,this.p2y=j}return cr=1,nr=x,x.prototype={sampleCurveX:function(c){return((this.ax*c+this.bx)*c+this.cx)*c},sampleCurveY:function(c){return((this.ay*c+this.by)*c+this.cy)*c},sampleCurveDerivativeX:function(c){return(3*this.ax*c+2*this.bx)*c+this.cx},solveCurveX:function(c,h){if(h===void 0&&(h=1e-6),c<0)return 0;if(c>1)return 1;for(var g=c,j=0;j<8;j++){var T=this.sampleCurveX(g)-c;if(Math.abs(T)T?R=g:F=g,g=.5*(F-R)+R;return g},solve:function(c,h){return this.sampleCurveY(this.solveCurveX(c,h))}},nr}(),ai=Kr(Sn);function as(x,c){this.x=x,this.y=c}function qn(x,c){if(Array.isArray(x)){if(!Array.isArray(c)||x.length!==c.length)return!1;for(let h=0;h=1)return 1;const c=x*x,h=c*x;return 4*(x<.5?h:3*(x-c)+h-.75)}function $t(x,c,h,g){const j=new ai(x,c,h,g);return function(T){return j.solve(T)}}const Se=$t(.25,.1,.25,1);function Fe(x,c,h){return Math.min(h,Math.max(c,x))}function Xe(x,c,h){return(h=Fe((h-x)/(c-x),0,1))*h*(3-2*h)}function yt(x,c,h){const g=h-c,j=((x-c)%g+g)%g+c;return j===c?h:j}function bt(x,c,h){if(!x.length)return h(null,[]);let g=x.length;const j=new Array(x.length);let T=null;x.forEach((P,R)=>{c(P,(F,H)=>{F&&(T=F),j[R]=H,--g===0&&h(T,j)})})}let At=1;function Gt(){return At++}function Vt(x){return x<=1?1:Math.pow(2,Math.ceil(Math.log2(x)))}function Xt(x,c){x.forEach(h=>{c[h]&&(c[h]=c[h].bind(c))})}function Is(x,c,h){const g={};for(const j in x)g[j]=c.call(this,x[j],j,x);return g}function bs(x,c,h){const g={};for(const j in x)c.call(this,x[j],j,x)&&(g[j]=x[j]);return g}function or(x){return Array.isArray(x)?x.map(or):typeof x=="object"&&x?Is(x,or):x}function Rr(x,c){for(let h=0;h=0)return!0;return!1}const Wr={};function zr(x){Wr[x]||(typeof console<"u"&&console.warn(x),Wr[x]=!0)}function hn(x,c,h){return(h.y-x.y)*(c.x-x.x)>(c.y-x.y)*(h.x-x.x)}function Wn(x){let c=0;for(let h,g,j=0,T=x.length,P=T-1;j@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(h,g,j,T)=>{const P=j||T;return c[g]=!P||P.toLowerCase(),""}),c["max-age"]){const h=parseInt(c["max-age"],10);isNaN(h)?delete c["max-age"]:c["max-age"]=h}return c}let wo,Yi=null;function ii(x,c){return[x[4*c],x[4*c+1],x[4*c+2],x[4*c+3]]}function $i(x,c,h,g){for(;c>1;x[j]>1;x[j]<=g?c=j+1:h=j}return c}function ui(x){return x>0?1/(1.001-x):1+x}function qi(x){return x>0?1-1/(1.001-x):-x}function Xi(x,c,h){return(x-c.min)*(h.max-h.min)/(c.max-c.min)+h.min}const ha={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(!ha.API_URL)return null;try{const x=new URL(ha.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:"/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"/mapbox-gl-js/meshopt_simd_v0.20.wasm",BUILDING_GEN_URL:"/mapbox-gl-js/building-gen/building_gen_v1.2.4.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1",TILE_PROVIDER_URLS:Object.assign(Object.create(null),{pmtiles:"/mapbox-gl-js/mapbox-gl-pmtiles-provider-v0.0.1.js"})};function sl(){return new URL(ha.DRACO_URL,ha.API_URL).href}function ac(){if(typeof WebAssembly!="object")throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return new URL(function(){if(wo===void 0){if(typeof WebAssembly!="object")return!1;const x=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);wo=WebAssembly.validate(x)}return wo}()?ha.MESHOPT_SIMD_URL:ha.MESHOPT_URL,ha.API_URL).href}function ic(){return new URL(ha.BUILDING_GEN_URL,ha.API_URL).href}function bu(x){return ha.API_URL_REGEX.test(x)}function wu(x){return ha.API_SPRITE_REGEX.test(x)}let Fm,kd,ju,zm,Wu,Bm;function Sd(){return Fm==null&&(Fm=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&typeof self.createImageBitmap=="function"),Fm}const Cd={now:()=>zm!==void 0?zm:performance.now(),setNow(x){zm=x},restoreNow(){zm=void 0},frame(x){const c=requestAnimationFrame(x);return{cancel:()=>cancelAnimationFrame(c)}},getImageData(x,c=0){const{width:h,height:g}=x;Wu||(Wu=document.createElement("canvas"));const j=Wu.getContext("2d",{willReadFrequently:!0});if(!j)throw new Error("failed to create canvas 2d context");return(h>Wu.width||g>Wu.height)&&(Wu.width=h,Wu.height=g),j.clearRect(-c,-c,h+2*c,g+2*c),j.drawImage(x,0,0,h,g),j.getImageData(-c,-c,h+2*c,g+2*c)},resolveURL:x=>(kd||(kd=document.createElement("a")),kd.href=x,kd.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(ju==null&&(ju=window.matchMedia("(prefers-reduced-motion: reduce)")),ju.matches)},hasCanvasFingerprintNoise(){if(Bm!==void 0)return Bm;if(!Sd())return Bm=!1,!1;const x=new OffscreenCanvas(85,1),c=x.getContext("2d",{willReadFrequently:!0});let h=0;for(let j=0;j0?`?${T}`:""}`}const gh="mapbox-tiles";let kp=500,Sp=50;const Ew=["language","worldview","jobid"];let Kh;function Cf(){try{return caches}catch{}}function zx(){const x=Cf();x&&Kh==null&&(Kh=x.open(gh))}let Md=1/0;const Bx={supported:!1,testSupport:function(x){!Pw&&Wd&&(yh?Mf(x):Cp=x)}};let Cp,Wd,Pw=!1,yh=!1;const Qg=typeof self<"u"?self:{};function Mf(x){const c=x.createTexture();x.bindTexture(x.TEXTURE_2D,c);try{if(x.texImage2D(x.TEXTURE_2D,0,x.RGBA,x.RGBA,x.UNSIGNED_BYTE,Wd),x.isContextLost())return;Bx.supported=!0}catch{}x.deleteTexture(c),Pw=!0}Qg.document&&(Wd=Qg.document.createElement("img"),Wd.onload=function(){Cp&&Mf(Cp),Cp=null,yh=!0},Wd.onerror=function(){Pw=!0,Cp=null},Wd.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const D0={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Iconset:"Iconset",Image:"Image",Model:"Model"};Object.freeze(D0);class Iw extends Error{constructor(c,h,g){h===401&&bu(g)&&(c+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(c),this.status=h,this.url=g}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}function P1(x){return typeof x=="object"&&x!==null&&"status"in x&&x.status===404}const Sa=ua()?()=>self.worker.referrer:()=>(location.protocol==="blob:"?parent:self).location.href,Jg=function(x,c){return/^file:/.test(h=x.url)||/^file:/.test(Sa())&&!/^\w+:/.test(h)?function(g,j){const T=new XMLHttpRequest;T.open(g.method||"GET",g.url,!0),g.type==="arrayBuffer"&&(T.responseType="arraybuffer");for(const P in g.headers)T.setRequestHeader(P,g.headers[P]);return g.type==="json"&&(T.responseType="text",T.setRequestHeader("Accept","application/json")),T.withCredentials=g.credentials==="include",T.onerror=()=>{j(new Error(T.statusText))},T.onload=()=>{if((T.status>=200&&T.status<300||T.status===0)&&T.response!==null){let P=T.response;if(g.type==="json")try{P=JSON.parse(T.response)}catch(F){return j(F)}const R=new Headers;T.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(F=>{const H=F.split(": "),Q=H.shift(),se=H.join(": ");R.append(Q,se)}),j(null,P,R)}else j(new Iw(T.statusText,T.status,g.url))},T.send(g.body),{cancel:()=>T.abort()}}(x,c):function(g,j){const T=new AbortController,P=new Request(g.url,{method:g.method||"GET",body:g.body,credentials:g.credentials,headers:g.headers,referrer:Sa(),referrerPolicy:g.referrerPolicy,signal:T.signal});let R=!1,F=!1;const H=(Q=P.url).indexOf("sku=")>0&&bu(Q);var Q;g.type==="json"&&P.headers.set("Accept","application/json");const se=(le,ue,_e)=>{if(F)return;if(le&&le.message!=="SecurityError"&&zr(le.toString()),ue&&_e)return re(ue);const Ce=Date.now();fetch(P).then(Ee=>{if(Ee.ok){const Ge=H?Ee.clone():null;return re(Ee,Ge,Ce)}return j(new Iw(Ee.statusText,Ee.status,g.url))}).catch(Ee=>{Ee.name!=="AbortError"&&j(new Error(`${Ee.message} ${g.url}`))})},re=(le,ue,_e)=>{(g.type==="arrayBuffer"?le.arrayBuffer():g.type==="json"?le.json():le.text()).then(Ce=>{F||(ue&&_e&&function(Ee,Ge,Be){if(zx(),Kh==null)return;const nt=To(Ge.headers.get("cache-control")||"");if(nt["no-store"])return;const it={status:Ge.status,statusText:Ge.statusText,headers:new Headers};Ge.headers.forEach((Mt,Tt)=>it.headers.set(Tt,Mt)),nt["max-age"]&&it.headers.set("Expires",new Date(Be+1e3*nt["max-age"]).toUTCString());const lt=it.headers.get("expires");if(!lt||new Date(lt).getTime()-Be<42e4)return;let Rt=Aw(Ee.url,{persistentParams:Ew});if(Ge.status===206){const Mt=Ee.headers.get("Range");if(!Mt)return;it.status=200,Rt=L0(Rt,{range:Mt})}const jt=new Response((It=Ge.status)!==200&&It!==404&&[101,103,204,205,304].includes(It)?null:Ge.body,it);var It;zx(),Kh!=null&&Kh.then(Mt=>Mt.put(Rt,jt)).catch(Mt=>zr(Mt.message))}(P,ue,_e),R=!0,j(null,Ce,le.headers))}).catch(Ce=>{F||j(new Error(Ce.message))})};return H?function(le,ue){if(zx(),Kh==null)return ue(null);Kh.then(_e=>{let Ce=Aw(le.url,{persistentParams:Ew});const Ee=le.headers.get("Range");Ee&&(Ce=L0(Ce,{range:Ee})),_e.match(Ce).then(Ge=>{const Be=function(nt){if(!nt)return!1;const it=new Date(nt.headers.get("expires")||0),lt=To(nt.headers.get("cache-control")||"");return Number(it)>Date.now()&&!lt["no-cache"]}(Ge);_e.delete(Ce).catch(ue),Be&&_e.put(Ce,Ge.clone()).catch(ue),ue(null,Ge,Be)}).catch(ue)}).catch(ue)}(P,se):se(null,null),{cancel:()=>{F=!0,R||T.abort()}}}(x,c);var h},ey=function(x,c){return Jg(Object.assign(x,{type:"arrayBuffer"}),c)};function OE(x){const c=document.createElement("a");return c.href=x,c.protocol===location.protocol&&c.host===location.host}let $x,Tf;$x=[],Tf=0;const ty=function(x,c){if(Bx.supported&&(x.headers||(x.headers={}),x.headers.accept="image/webp,*/*"),Tf>=ha.MAX_PARALLEL_IMAGE_REQUESTS){const T={requestParameters:x,callback:c,cancelled:!1,cancel(){this.cancelled=!0}};return $x.push(T),T}Tf++;let h=!1;const g=()=>{if(!h)for(h=!0,Tf--;$x.length&&Tf{g(),T?c(T):P&&function(F,H){const Q=new Blob([new Uint8Array(F)],{type:"image/png"});createImageBitmap(Q).then(se=>{H(null,se)}).catch(se=>{H(new Error(`Could not load image because of ${se.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(P,(F,H)=>c(F,H,R))});return{cancel:()=>{j.cancel(),g()}}};var R0,I1,RC,Af={exports:{}},OC={exports:{}},Ct={exports:{}},Fs=function(){if(RC)return Af.exports;RC=1;var x=(R0||(R0=1,OC.exports=function(h,g){var j,T,P,R,F,H,Q,se;for(T=h.length-(j=3&h.length),P=g,F=3432918353,H=461845907,se=0;se>>16)*F&65535)<<16)&4294967295)<<15|Q>>>17))*H+(((Q>>>16)*H&65535)<<16)&4294967295)<<13|P>>>19))+((5*(P>>>16)&65535)<<16)&4294967295))+(((R>>>16)+58964&65535)<<16);switch(Q=0,j){case 3:Q^=(255&h.charCodeAt(se+2))<<16;case 2:Q^=(255&h.charCodeAt(se+1))<<8;case 1:P^=Q=(65535&(Q=(Q=(65535&(Q^=255&h.charCodeAt(se)))*F+(((Q>>>16)*F&65535)<<16)&4294967295)<<15|Q>>>17))*H+(((Q>>>16)*H&65535)<<16)&4294967295}return P^=h.length,P=2246822507*(65535&(P^=P>>>16))+((2246822507*(P>>>16)&65535)<<16)&4294967295,P=3266489909*(65535&(P^=P>>>13))+((3266489909*(P>>>16)&65535)<<16)&4294967295,(P^=P>>>16)>>>0}),OC.exports),c=(I1||(I1=1,Ct.exports=function(h,g){for(var j,T=h.length,P=g^T,R=0;T>=4;)j=1540483477*(65535&(j=255&h.charCodeAt(R)|(255&h.charCodeAt(++R))<<8|(255&h.charCodeAt(++R))<<16|(255&h.charCodeAt(++R))<<24))+((1540483477*(j>>>16)&65535)<<16),P=1540483477*(65535&P)+((1540483477*(P>>>16)&65535)<<16)^(j=1540483477*(65535&(j^=j>>>24))+((1540483477*(j>>>16)&65535)<<16)),T-=4,++R;switch(T){case 3:P^=(255&h.charCodeAt(R+2))<<16;case 2:P^=(255&h.charCodeAt(R+1))<<8;case 1:P=1540483477*(65535&(P^=255&h.charCodeAt(R)))+((1540483477*(P>>>16)&65535)<<16)}return P=1540483477*(65535&(P^=P>>>13))+((1540483477*(P>>>16)&65535)<<16),(P^=P>>>15)>>>0}),Ct.exports);return Af.exports=x,Af.exports.murmur3=x,Af.exports.murmur2=c,Af.exports}(),ar=Kr(Fs);class tn{constructor(c,...h){Object.assign(this,h[0]||{}),this.type=c}}class xn extends tn{constructor(c,h={}){super("error",Object.assign({error:c},h))}}function oa(x,c,h){h[x]&&h[x].indexOf(c)!==-1||(h[x]=h[x]||[],h[x].push(c))}function fa(x,c,h){if(h&&h[x]){const g=h[x].indexOf(c);g!==-1&&h[x].splice(g,1)}}class Ei{on(c,h){return this._listeners=this._listeners||{},oa(c,h,this._listeners),this}off(c,h){return fa(c,h,this._listeners),fa(c,h,this._oneTimeListeners),this}once(c,h){return h?(this._oneTimeListeners=this._oneTimeListeners||{},oa(c,h,this._oneTimeListeners),this):new Promise(g=>{this.once(c,g)})}fire(c,h){const g=typeof c=="string"?new tn(c,h):c,j=g.type;if(this.listens(j)){g.target=this;const T=this._listeners&&this._listeners[j]?this._listeners[j].slice():[];for(const F of T)F.call(this,g);const P=this._oneTimeListeners&&this._oneTimeListeners[j]?this._oneTimeListeners[j].slice():[];for(const F of P)fa(j,F,this._oneTimeListeners),F.call(this,g);const R=this._eventedParent;if(R){const F=typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData;Object.assign(g,F),R.fire(g)}}else g instanceof xn&&console.error(g.error);return this}listens(c){return!!(this._listeners&&this._listeners[c]&&this._listeners[c].length>0||this._oneTimeListeners&&this._oneTimeListeners[c]&&this._oneTimeListeners[c].length>0||this._eventedParent&&this._eventedParent.listens(c))}setEventedParent(c,h){return this._eventedParent=c,this._eventedParentData=h,this}}class kc{constructor(c){typeof c=="string"?this.name=c:(this.name=c.name,this.iconsetId=c.iconsetId)}static from(c){return new kc(c)}static toString(c){return c.iconsetId?`${c.name}${c.iconsetId}`:c.name}static parse(c){const[h,g]=c.split("");return new kc({name:h,iconsetId:g})}static isEqual(c,h){return c.name===h.name&&c.iconsetId===h.iconsetId}toString(){return kc.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var $m,Zh={},O0=function(){if($m)return Zh;$m=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 c(T){return(T=Math.round(T))<0?0:T>255?255:T}function h(T){return c(T[T.length-1]==="%"?parseFloat(T)/100*255:parseInt(T))}function g(T){return(P=T[T.length-1]==="%"?parseFloat(T)/100:parseFloat(T))<0?0:P>1?1:P;var P}function j(T,P,R){return R<0?R+=1:R>1&&(R-=1),6*R<1?T+(P-T)*R*6:2*R<1?P:3*R<2?T+(P-T)*(2/3-R)*6:T}try{Zh.parseCSSColor=function(T){var P,R=T.replace(/ /g,"").toLowerCase();if(R in x)return x[R].slice();if(R[0]==="#")return R.length===4?(P=parseInt(R.substr(1),16))>=0&&P<=4095?[(3840&P)>>4|(3840&P)>>8,240&P|(240&P)>>4,15&P|(15&P)<<4,1]:null:R.length===7&&(P=parseInt(R.substr(1),16))>=0&&P<=16777215?[(16711680&P)>>16,(65280&P)>>8,255&P,1]:null;var F=R.indexOf("("),H=R.indexOf(")");if(F!==-1&&H+1===R.length){var Q=R.substr(0,F),se=R.substr(F+1,H-(F+1)).split(","),re=1;switch(Q){case"rgba":if(se.length!==4)return null;re=g(se.pop());case"rgb":return se.length!==3?null:[h(se[0]),h(se[1]),h(se[2]),re];case"hsla":if(se.length!==4)return null;re=g(se.pop());case"hsl":if(se.length!==3)return null;var le=(parseFloat(se[0])%360+360)%360/360,ue=g(se[1]),_e=g(se[2]),Ce=_e<=.5?_e*(ue+1):_e+ue-_e*ue,Ee=2*_e-Ce;return[c(255*j(Ee,Ce,le+1/3)),c(255*j(Ee,Ce,le)),c(255*j(Ee,Ce,le-1/3)),re];default:return null}}return null}}catch{}return Zh}();class Aa{constructor(c,h,g,j=1){this.r=c,this.g=h,this.b=g,this.a=j}static parse(c){if(!c)return;if(c instanceof Aa)return c;if(typeof c!="string")return;const h=O0.parseCSSColor(c);return h?new Aa(h[0]/255,h[1]/255,h[2]/255,h[3]):void 0}toString(){const[c,h,g,j]=[this.r,this.g,this.b,this.a];return`rgba(${Math.round(255*c)},${Math.round(255*h)},${Math.round(255*g)},${j})`}toNonPremultipliedRenderColor(c){const{r:h,g,b:j,a:T}=this;return new FC(c,h,g,j,T)}toPremultipliedRenderColor(c){const{r:h,g,b:j,a:T}=this;return new L1(c,h*T,g*T,j*T,T)}clone(){return new Aa(this.r,this.g,this.b,this.a)}}class FE{constructor(c,h,g,j,T,P=!1){if(this.premultiplied=!1,this.premultiplied=P,c){const R=c.image.height,F=R*R;this.premultiplied?(h=T===0?0:h/T*(R-1),g=T===0?0:g/T*(R-1),j=T===0?0:j/T*(R-1)):(h*=R-1,g*=R-1,j*=R-1),h=Math.max(0,Math.min(R-1,h)),g=Math.max(0,Math.min(R-1,g)),j=Math.max(0,Math.min(R-1,j));const H=Math.floor(h),Q=Math.floor(g),se=Math.floor(j),re=Math.ceil(h),le=Math.ceil(g),ue=Math.ceil(j),_e=h-H,Ce=g-Q,Ee=j-se,Ge=c.image.data,Be=4*(H+Q*F+se*R),nt=4*(H+Q*F+ue*R),it=4*(H+le*F+se*R),lt=4*(H+le*F+ue*R),Rt=4*(re+Q*F+se*R),jt=4*(re+Q*F+ue*R),It=4*(re+le*F+se*R),Mt=4*(re+le*F+ue*R);this.r=on(on(on(Ge[Be],Ge[nt],Ee),on(Ge[it],Ge[lt],Ee),Ce),on(on(Ge[Rt],Ge[jt],Ee),on(Ge[It],Ge[Mt],Ee),Ce),_e)/255*(this.premultiplied?T:1),this.g=on(on(on(Ge[Be+1],Ge[nt+1],Ee),on(Ge[it+1],Ge[lt+1],Ee),Ce),on(on(Ge[Rt+1],Ge[jt+1],Ee),on(Ge[It+1],Ge[Mt+1],Ee),Ce),_e)/255*(this.premultiplied?T:1),this.b=on(on(on(Ge[Be+2],Ge[nt+2],Ee),on(Ge[it+2],Ge[lt+2],Ee),Ce),on(on(Ge[Rt+2],Ge[jt+2],Ee),on(Ge[It+2],Ge[Mt+2],Ee),Ce),_e)/255*(this.premultiplied?T:1),this.a=T}else this.r=h,this.g=g,this.b=j,this.a=T}toArray(){const{r:c,g:h,b:g,a:j}=this;return[255*c,255*h,255*g,j]}toHslaArray(){let{r:c,g:h,b:g,a:j}=this;if(this.premultiplied){if(j===0)return[0,0,0,0];const ue=1/j;c*=ue,h*=ue,g*=ue}const T=Math.min(Math.max(c,0),1),P=Math.min(Math.max(h,0),1),R=Math.min(Math.max(g,0),1),F=Math.min(T,P,R),H=Math.max(T,P,R),Q=H-F,se=.5*(F+H);if(Q===0)return[0,0,100*se,j];const re=se>.5?Q/(2-H-F):Q/(H+F);let le;switch(H){case T:le=60*((P-R)/Q+(Pon(g,c[j],h))}Aa.black=new Aa(0,0,0,1),Aa.white=new Aa(1,1,1,1),Aa.transparent=new Aa(0,0,0,0),Aa.red=new Aa(1,0,0,1),Aa.blue=new Aa(0,0,1,1);var zC=Object.freeze({__proto__:null,array:Mp,color:function(x,c,h){return new Aa(on(x.r,c.r,h),on(x.g,c.g,h),on(x.b,c.b,h),on(x.a,c.a,h))},number:on});class qm extends Error{constructor(c,h){super(h),this.message=h,this.key=c}}class F0{constructor(c,h=[]){this.parent=c,this.bindings={};for(const[g,j]of h)this.bindings[g]=j}concat(c){return new F0(this,c)}get(c){if(this.bindings[c])return this.bindings[c];if(this.parent)return this.parent.get(c);throw new Error(`${c} not found in scope.`)}has(c){return!!this.bindings[c]||!!this.parent&&this.parent.has(c)}}const qx={kind:"null"},Dr={kind:"number"},ri={kind:"string"},oi={kind:"boolean"},Nu={kind:"color"},sy={kind:"object"},li={kind:"value"},z0={kind:"collator"},Lw={kind:"formatted"},Dw={kind:"resolvedImage"};function Kd(x,c){return{kind:"array",itemType:x,N:c}}function Sl(x){if(x.kind==="array"){const c=Sl(x.itemType);return typeof x.N=="number"?`array<${c}, ${x.N}>`:x.itemType.kind==="value"?"array":`array<${c}>`}return x.kind}const ipe=[qx,Dr,ri,oi,Nu,Lw,sy,Kd(li),Dw];function Rw(x,c){if(c.kind==="error")return null;if(x.kind==="array"){if(c.kind==="array"&&(c.N===0&&c.itemType.kind==="value"||!Rw(x.itemType,c.itemType))&&(typeof x.N!="number"||x.N===c.N))return null}else{if(x.kind===c.kind)return null;if(x.kind==="value"){for(const h of ipe)if(!Rw(h,c))return null}}return`Expected ${Sl(x)} but found ${Sl(c)} instead.`}function zE(x,c){return c.some(h=>h.kind===x.kind)}function D1(x,c){return c.some(h=>h==="null"?x===null:h==="array"?Array.isArray(x):h==="object"?x&&!Array.isArray(x)&&typeof x=="object":h===typeof x)}function Ux(x,c){return x.kind==="array"&&c.kind==="array"?x.N===c.N&&Ux(x.itemType,c.itemType):x.kind===c.kind}class BE{constructor(c,h,g){this.sensitivity=c?h?"variant":"case":h?"accent":"base",this.locale=g,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(c,h){return this.collator.compare(c,h)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Ow{constructor(c,h,g,j,T){this.text=c.normalize?c.normalize():c,this.image=h,this.scale=g,this.fontStack=j,this.textColor=T}}class Td{constructor(c){this.sections=c}static fromString(c){return new Td([new Ow(c,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(c=>c.text.length!==0||!!c.image&&c.image.hasPrimary())}static factory(c){return c instanceof Td?c:Td.fromString(c)}toString(){return this.sections.length===0?"":this.sections.map(c=>c.text).join("")}serialize(){const c=["format"];for(const h of this.sections){if(h.image){const j=h.image.getPrimary().id.toString();c.push(["image",j]);continue}c.push(h.text);const g={};h.fontStack&&(g["text-font"]=["literal",h.fontStack.split(",")]),h.scale&&(g["font-scale"]=h.scale),h.textColor&&(g["text-color"]=["rgba"].concat(h.textColor.toNonPremultipliedRenderColor(null).toArray())),c.push(g)}return c}}class Um{constructor(c,h={}){this.id=kc.from(c),this.params=h.params,this.sx=h.sx||1,this.sy=h.sy||1}toString(){return JSON.stringify(this)}static parse(c){let h,g,j,T;try{({id:h,params:g,sx:j,sy:T}=JSON.parse(c)||{})}catch{return null}return h?new Um(h,{params:g,sx:j,sy:T}):null}scaleSelf(c,h=c){return this.sx*=c,this.sy*=h,this}}class Ku{constructor(c,h,g,j,T=!1){this.primaryId=kc.from(c),this.primaryOptions=h,g&&(this.secondaryId=kc.from(g)),this.secondaryOptions=j,this.available=T}toString(){return this.primaryId&&this.secondaryId?`[${this.primaryId.name},${this.secondaryId.name}]`:this.primaryId.name}hasPrimary(){return!!this.primaryId}getPrimary(){return new Um(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new Um(this.secondaryId,this.secondaryOptions):null}static from(c){return typeof c=="string"?Ku.build({name:c}):c}static build(c,h,g,j){return!c||typeof c=="object"&&!("name"in c)?null:new Ku(c,g,h,j)}}function IO(x,c,h,g){return typeof x=="number"&&x>=0&&x<=255&&typeof c=="number"&&c>=0&&c<=255&&typeof h=="number"&&h>=0&&h<=255?g===void 0||typeof g=="number"&&g>=0&&g<=1?null:`Invalid rgba value [${[x,c,h,g].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof g=="number"?[x,c,h,g]:[x,c,h]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function R1(x){if(x===null||typeof x=="string"||typeof x=="boolean"||typeof x=="number"||x instanceof Aa||x instanceof BE||x instanceof Td||x instanceof Ku)return!0;if(Array.isArray(x)){for(const c of x)if(!R1(c))return!1;return!0}if(typeof x=="object"){for(const c in x)if(!R1(x[c]))return!1;return!0}return!1}function Oo(x){if(x===null)return qx;if(typeof x=="string")return ri;if(typeof x=="boolean")return oi;if(typeof x=="number")return Dr;if(x instanceof Aa)return Nu;if(x instanceof BE)return z0;if(x instanceof Td)return Lw;if(x instanceof Ku)return Dw;if(Array.isArray(x)){const c=x.length;let h;for(const g of x){const j=Oo(g);if(h){if(h===j)continue;h=li;break}h=j}return Kd(h||li,c)}return sy}function rn(x){const c=typeof x;return x===null?"":c==="string"||c==="number"||c==="boolean"?String(x):x instanceof Td||x instanceof Ku||x instanceof Aa?x.toString():JSON.stringify(x)}class Sr{constructor(c,h){this.type=c,this.value=h}static parse(c,h){if(c.length!==2)return h.error(`'literal' expression requires exactly one argument, but found ${c.length-1} instead.`);if(!R1(c[1]))return h.error("invalid value");const g=c[1];let j=Oo(g);const T=h.expectedType;return j.kind!=="array"||j.N!==0||!T||T.kind!=="array"||typeof T.N=="number"&&T.N!==0||(j=T),new Sr(j,g)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof Aa?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof Td?this.value.serialize():this.value}}class dl{constructor(c){this.name="ExpressionEvaluationError",this.message=c}toJSON(){return this.message}}const dn={string:ri,number:Dr,boolean:oi,object:sy};class Yh{constructor(c,h){this.type=c,this.args=h}static parse(c,h){if(c.length<2)return h.error("Expected at least one argument.");let g,j=1;const T=c[0];if(T==="array"){let R,F;if(c.length>2){const H=c[1];if(typeof H!="string"||!(H in dn)||H==="object")return h.error('The item type argument of "array" must be one of string, number, boolean',1);R=dn[H],j++}else R=li;if(c.length>3){if(c[2]!==null&&(typeof c[2]!="number"||c[2]<0||c[2]!==Math.floor(c[2])))return h.error('The length argument to "array" must be a positive integer literal',2);F=c[2],j++}g=Kd(R,F)}else g=dn[T];const P=[];for(;jc.outputDefined())}serialize(){const c=this.type,h=[c.kind];if(c.kind==="array"){const g=c.itemType;if(g.kind==="string"||g.kind==="number"||g.kind==="boolean"){h.push(g.kind);const j=c.N;(typeof j=="number"||this.args.length>1)&&h.push(j)}}return h.concat(this.args.map(g=>g.serialize()))}}class B0{constructor(c){this.type=Lw,this.sections=c}static parse(c,h){if(c.length<2)return h.error("Expected at least one argument.");const g=c[1];if(!Array.isArray(g)&&typeof g=="object")return h.error("First argument must be an image or text section.");const j=[];let T=!1;for(let P=1;P<=c.length-1;++P){const R=c[P];if(T&&typeof R=="object"&&!Array.isArray(R)){T=!1;let F=null;if(R["font-scale"]&&(F=h.parseObjectValue(R["font-scale"],P,"font-scale",Dr),!F))return null;let H=null;if(R["text-font"]&&(H=h.parseObjectValue(R["text-font"],P,"text-font",Kd(ri)),!H))return null;let Q=null;if(R["text-color"]&&(Q=h.parseObjectValue(R["text-color"],P,"text-color",Nu),!Q))return null;const se=j[j.length-1];se.scale=F,se.font=H,se.textColor=Q}else{const F=h.parse(c[P],P,li);if(!F)return null;const H=F.type.kind;if(H!=="string"&&H!=="value"&&H!=="null"&&H!=="resolvedImage")return h.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");T=!0,j.push({content:F,scale:null,font:null,textColor:null})}}return new B0(j)}evaluate(c){return new Td(this.sections.map(h=>{const g=h.content.evaluate(c);return Ux(Oo(g),Dw)?new Ow("",g,null,null,null):new Ow(rn(g),null,h.scale?h.scale.evaluate(c):null,h.font?h.font.evaluate(c).join(","):null,h.textColor?h.textColor.evaluate(c):null)}))}eachChild(c){for(const h of this.sections)c(h.content),h.scale&&c(h.scale),h.font&&c(h.font),h.textColor&&c(h.textColor)}outputDefined(){return!1}serialize(){const c=["format"];for(const h of this.sections){c.push(h.content.serialize());const g={};h.scale&&(g["font-scale"]=h.scale.serialize()),h.font&&(g["text-font"]=h.font.serialize()),h.textColor&&(g["text-color"]=h.textColor.serialize()),c.push(g)}return c}}class Xr{constructor(c,h,g,j){this._imageWarnHistory={},this.type=Dw,this.namePrimary=c,this.nameSecondary=h,g&&(this.paramsPrimary=g.params,this.iconsetIdPrimary=g.iconset?g.iconset.id:void 0),j&&(this.paramsSecondary=j.params,this.iconsetIdSecondary=j.iconset?j.iconset.id:void 0)}static parse(c,h){if(c.length<2)return h.error("Expected two or more arguments.");let g=1;const j=[];function T(){if(gkc.isEqual(P,T)),j.available){const P=j.getSecondary()?j.getSecondary().id:null;P&&(j.available=c.availableImages.some(R=>kc.isEqual(R,P)))}}return j}eachChild(c){if(c(this.namePrimary),this.paramsPrimary)for(const h in this.paramsPrimary)this.paramsPrimary[h]&&c(this.paramsPrimary[h]);if(this.nameSecondary&&(c(this.nameSecondary),this.paramsSecondary))for(const h in this.paramsSecondary)this.paramsSecondary[h]&&c(this.paramsSecondary[h])}outputDefined(){return!1}serializeOptions(c,h){const g={};if(h&&(g.iconset={id:h}),c){g.params={};for(const j in c)c[j]&&(g.params[j]=c[j].serialize())}return Object.keys(g).length>0?g:void 0}serialize(){const c=["image",this.namePrimary.serialize()];if(this.paramsPrimary||this.iconsetIdPrimary){const h=this.serializeOptions(this.paramsPrimary,this.iconsetIdPrimary);h&&c.push(h)}if(this.nameSecondary&&(c.push(this.nameSecondary.serialize()),this.paramsSecondary||this.iconsetIdSecondary)){const h=this.serializeOptions(this.paramsSecondary,this.iconsetIdSecondary);h&&c.push(h)}return c}}function Fw(x){return $C(x)?"string":zw(x)?"number":Bw(x)?"boolean":Array.isArray(x)?"array":x===null?"null":BC(x)?"object":typeof x}function BC(x){return x!=null&&!Array.isArray(x)&&typeof x!="function"&&!(x instanceof String||x instanceof Number||x instanceof Boolean)&&typeof x=="object"}function $C(x){return typeof x=="string"||x instanceof String}function zw(x){return typeof x=="number"||x instanceof Number}function Bw(x){return typeof x=="boolean"||x instanceof Boolean}const ope={"to-boolean":oi,"to-color":Nu,"to-number":Dr,"to-string":ri};class Tp{constructor(c,h){this.type=c,this.args=h}static parse(c,h){if(c.length<2)return h.error("Expected at least one argument.");const g=c[0],j=[];let T=qx;if(g==="to-array"){if(!Array.isArray(c[1]))return null;const P=c[1].length;if(h.expectedType){if(h.expectedType.kind!=="array")return h.error(`Expected ${h.expectedType.kind} but found array.`);T=Kd(h.expectedType.itemType,P)}else{if(!(P>0&&R1(c[1][0])))return null;T=Kd(Oo(c[1][0]),P)}for(let R=0;R4?`Invalid rbga value ${JSON.stringify(h)}: expected an array containing either three or four numeric values.`:IO(h[0],h[1],h[2],h[3]),!g))return new Aa(h[0]/255,h[1]/255,h[2]/255,h[3])}throw new dl(g||`Could not parse color from value '${typeof h=="string"?h:String(JSON.stringify(h))}'`)}if(this.type.kind==="number"){let h=null;for(const g of this.args){if(h=g.evaluate(c),h===null)return 0;const j=Number(h);if(!isNaN(j))return j}throw new dl(`Could not convert ${JSON.stringify(h)} to number.`)}return this.type.kind==="formatted"?Td.fromString(rn(this.args[0].evaluate(c))):this.type.kind==="resolvedImage"?Ku.build(rn(this.args[0].evaluate(c))):this.type.kind==="array"?this.args.map(h=>h.evaluate(c)):rn(this.args[0].evaluate(c))}eachChild(c){this.args.forEach(c)}outputDefined(){return this.args.every(c=>c.outputDefined())}serialize(){if(this.type.kind==="formatted")return new B0([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new Xr(this.args[0]).serialize();const c=this.type.kind==="array"?[]:[`to-${this.type.kind}`];return this.eachChild(h=>{c.push(h.serialize())}),c}}const $0=["Unknown","Point","LineString","Polygon"];class $w{constructor(c,h,g){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=c,this.options=h,this.iconImageUseTheme=g}id(){return this.feature&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?$0[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}measureLight(c){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const c=this.featureDistanceData.center,h=this.featureDistanceData.scale,{x:g,y:j}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(g*h-c[0])+this.featureDistanceData.bearing[1]*(j*h-c[1])}return 0}parseColor(c){let h=this._parseColorCache[c];return h||(h=this._parseColorCache[c]=Aa.parse(c)),h}getConfig(c){return this.options?this.options.get(c):null}}class oc{constructor(c,h,g,j,T){this.name=c,this.type=h,this._evaluate=g,this.args=j,this._overloadIndex=T}evaluate(c){if(!this._evaluate){const h=oc.definitions[this.name];this._evaluate=Array.isArray(h)?h[2]:h.overloads[this._overloadIndex][1]}return this._evaluate(c,this.args)}eachChild(c){this.args.forEach(c)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(c=>c.serialize()))}static parse(c,h){const g=c[0],j=oc.definitions[g];if(!j)return h.error(`Unknown expression "${g}". If you wanted a literal array, use ["literal", [...]].`,0);const T=Array.isArray(j)?j[0]:j.type,P=Array.isArray(j)?[[j[1],j[2]]]:j.overloads,R=[];let F=null,H=-1;for(const[Q,se]of P){if(Array.isArray(Q)&&Q.length!==c.length-1)continue;R.push(Q),H++,F=new ZC(h.registry,h.path,null,h.scope,void 0,h._scope,h.options,h.iconImageUseTheme);const re=[];let le=!1;for(let ue=1;uere)).map(ry).join(" | "),se=[];for(let re=1;reh;){if(g-h>600){const F=g-h+1,H=c-h+1,Q=Math.log(F),se=.5*Math.exp(2*Q/3),re=.5*Math.sqrt(Q*se*(F-se)/F)*(H-F/2<0?-1:1);LO(x,c,Math.max(h,Math.floor(c-H*se/F+re)),Math.min(g,Math.floor(c+(F-H)*se/F+re)),j)}const T=x[c];let P=h,R=g;for(qw(x,h,c),j(x[g],T)>0&&qw(x,h,g);P0;)R--}j(x[h],T)===0?qw(x,h,R):(R++,qw(x,R,g)),R<=c&&(h=R+1),c<=R&&(g=R-1)}}function qw(x,c,h){const g=x[c];x[c]=x[h],x[h]=g}function UC(x,c){return xc?1:0}function DO(x){let c=0;for(let h,g,j=0,T=x.length,P=T-1;j=c[2]||x[1]<=c[1]||x[3]>=c[3])}function lpe(x,c,h){const g=x[0]-c[0],j=x[1]-c[1],T=x[0]-h[0],P=x[1]-h[1];return g*P-T*j===0&&g*T<=0&&j*P<=0}function $E(x,c,h){return c[1]>x[1]!=h[1]>x[1]&&x[0]<(h[0]-c[0])*(x[1]-c[1])/(h[1]-c[1])+c[0]}function O1(x,c,h=!1){let g=!1;for(let j=0,T=c.length;j0&&R<0||P<0&&R>0}function Vw(x,c,h,g){return(j=[g[0]-h[0],g[1]-h[1]])[0]*(T=[c[0]-x[0],c[1]-x[1]])[1]-j[1]*T[0]!==0&&!(!RO(x,c,h,g)||!RO(h,g,x,c));var j,T}function qE(x){const c=new as(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),h=new as(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const g of x[0])c.x>g.x&&(c.x=g.x),c.y>g.y&&(c.y=g.y),h.xh[2]){const j=.5*g;let T=x[0]-h[0]>j?-g:h[0]-x[0]>j?g:0;T===0&&(T=x[0]-h[2]>j?-g:h[2]-x[0]>j?g:0),x[0]+=T}Ap(c,x)}function HE(x,c,h,g){const j=Math.pow(2,g.z)*ny,T=[g.x*ny,g.y*ny],P=[];if(!x)return P;for(const R of x)for(const F of R){const H=[F.x+T[0],F.y+T[1]];Vm(H,c,h,j),P.push(H)}return P}function GE(x,c,h,g){const j=Math.pow(2,g.z)*ny,T=[g.x*ny,g.y*ny],P=[];if(!x)return P;for(const F of x){const H=[];for(const Q of F){const se=[Q.x+T[0],Q.y+T[1]];Ap(c,se),H.push(se)}P.push(H)}if(c[2]-c[0]<=j/2){(R=c)[0]=R[1]=1/0,R[2]=R[3]=-1/0;for(const F of P)for(const H of F)Vm(H,c,h,j)}var R;return P}class ay{constructor(c,h){this.type=oi,this.geojson=c,this.geometries=h}static parse(c,h){if(c.length!==2)return h.error(`'within' expression requires exactly one argument, but found ${c.length-1} instead.`);if(R1(c[1])){const g=c[1];if(g.type==="FeatureCollection")for(let j=0;jh)return HC(T,P,(h-(g-R))/R)}return c[c.length-1]}pointToSegmentDistance(c,h,g){let[j,T]=h,P=Xh(g[0]-j)*this.kx,R=(g[1]-T)*this.ky;if(P!==0||R!==0){const F=(Xh(c[0]-j)*this.kx*P+(c[1]-T)*this.ky*R)/(P*P+R*R);F>1?(j=g[0],T=g[1]):F>0&&(j+=P/this.kx*F,T+=R/this.ky*F)}return P=Xh(c[0]-j)*this.kx,R=(c[1]-T)*this.ky,Math.sqrt(P*P+R*R)}pointOnLine(c,h){let g=1/0,j=c[0][0],T=c[0][1],P=0,R=0;for(let F=0;F1?(H=c[F+1][0],Q=c[F+1][1]):le>0&&(H+=se/this.kx*le,Q+=re/this.ky*le)),se=Xh(h[0]-H)*this.kx,re=(h[1]-Q)*this.ky;const ue=se*se+re*re;ueT.index||j.index===T.index&&j.t>T.t){const H=j;j=T,T=H}const P=[j.point],R=j.index+1,F=T.index;!ZE(g[R],P[0])&&R<=F&&P.push(g[R]);for(let H=R+1;H<=F;H++)P.push(g[H]);return ZE(g[F],T.point)||P.push(T.point),P}lineSliceAlong(c,h,g){let j=0;const T=[];for(let P=0;Pc&&T.length===0&&T.push(HC(R,F,(c-(j-H))/H)),j>=h)return T.push(HC(R,F,(h-(j-H))/H)),T;j>c&&T.push(F)}return T}bufferPoint(c,h){const g=h/this.ky,j=h/this.kx;return[c[0]-j,c[1]-g,c[0]+j,c[1]+g]}bufferBBox(c,h){const g=h/this.ky,j=h/this.kx;return[c[0]-j,c[1]-g,c[2]+j,c[3]+g]}insideBBox(c,h){return Xh(c[0]-h[0])>=0&&Xh(c[0]-h[2])<=0&&c[1]>=h[1]&&c[1]<=h[3]}}function ZE(x,c){return x[0]===c[0]&&x[1]===c[1]}function HC(x,c,h){const g=Xh(c[0]-x[0]);return[x[0]+g*h,x[1]+(c[1]-x[1])*h]}function Xh(x){for(;x<-180;)x+=360;for(;x>180;)x-=360;return x}class Gw{constructor(c=[],h=(g,j)=>gj?1:0){if(this.data=c,this.length=this.data.length,this.compare=h,this.length>0)for(let g=(this.length>>1)-1;g>=0;g--)this._down(g)}push(c){this.data.push(c),this._up(this.length++)}pop(){if(this.length===0)return;const c=this.data[0],h=this.data.pop();return--this.length>0&&(this.data[0]=h,this._down(0)),c}peek(){return this.data[0]}_up(c){const{data:h,compare:g}=this,j=h[c];for(;c>0;){const T=c-1>>1,P=h[T];if(g(j,P)>=0)break;h[c]=P,c=T}h[c]=j}_down(c){const{data:h,compare:g}=this,j=this.length>>1,T=h[c];for(;c=0)break;h[c]=h[P],c=P}h[c]=T}}var sr=8192;function FO(x,c){return c.dist-x.dist}function zO(x){const c=[1/0,1/0,-1/0,-1/0];if(c.length!==x.length)return!1;for(let h=0;h=x[0]&&x[1]x[1])return[null,null];const h=U0(x);if(c){if(h===2)return[x,null];const g=Math.floor(h/2);return[[x[0],x[0]+g],[x[0]+g,x[1]]]}{if(h===1)return[x,null];const g=Math.floor(h/2)-1;return[[x[0],x[0]+g],[x[0]+g+1,x[1]]]}}function iy(x,c){const h=[1/0,1/0,-1/0,-1/0];if(!Ep(c,x.length))return h;for(let g=c[0];g<=c[1];++g)Ap(h,x[g]);return h}function Ww(x){const c=[1/0,1/0,-1/0,-1/0];for(let h=0;hc[2]&&(g=x[0]-c[2]),x[1]>c[3]&&(j=x[1]-c[3]),x[3]=g)return g;if(Uw(j,T)){if(VO(x,c))return 0}else if(VO(c,x))return 0;let P=g;for(const R of x)for(let F=0,H=R.length,Q=H-1;F=T)continue;const Q=H.range1;if(U0(Q)<=R){if(!Ep(Q,x.length))return NaN;if(c){const se=oo(x,Q,h,g);if((T=Math.min(T,se))===0)return T}else for(let se=Q[0];se<=Q[1];++se){const re=mpe(x[se],h,g);if((T=Math.min(T,re))===0)return T}}else{const se=B1(Q,c);if(se[0]!==null){const re=$1(iy(x,se[0]),F,g);re=P)continue;const se=Q.range1,re=Q.range2;if(U0(se)<=F&&U0(re)<=H){if(!Ep(se,x.length)||!Ep(re,h.length))return NaN;if(c&&g?P=Math.min(P,hpe(x,se,h,re,j)):c||g?c&&!g?P=Math.min(P,qO(h,re,x,se,j)):!c&&g&&(P=Math.min(P,qO(x,se,h,re,j))):P=Math.min(P,UO(x,se,h,re,j)),P===0)return P}else{const le=B1(se,c),ue=B1(re,g);GC(R,P,j,x,h,le[0],ue[0]),GC(R,P,j,x,h,le[0],ue[1]),GC(R,P,j,x,h,le[1],ue[0]),GC(R,P,j,x,h,le[1],ue[1])}}return P}function XE(x,c,h,g,j=1/0){let T=j;const P=iy(x,[0,x.length-1]);for(const R of h)if(!(T!==1/0&&$1(P,iy(R,[0,R.length-1]),g)>=T)&&(T=Math.min(T,HO(x,c,R,!0,g,T)),T===0))return T;return T}function WC(x,c,h,g,j=1/0){let T=j;const P=iy(x,[0,x.length-1]);for(const R of h){if(T!==1/0&&$1(P,Ww(R),g)>=T)continue;const F=fpe(x,c,R,g,T);if(isNaN(F))return F;if((T=Math.min(T,F))===0)return T}return T}function QE(x){return x==="Point"||x==="MultiPoint"||x==="LineString"||x==="MultiLineString"||x==="Polygon"||x==="MultiPolygon"}class V0{constructor(c,h){this.type=Dr,this.geojson=c,this.geometries=h}static parse(c,h){if(c.length!==2)return h.error(`'distance' expression requires either one argument, but found ' ${c.length-1} instead.`);if(R1(c[1])){const g=c[1];if(g.type==="FeatureCollection"){for(let j=0;j{c&&!H0(h)&&(c=!1)}),c}function q1(x){if(x instanceof oc&&x.name==="feature-state")return!1;let c=!0;return x.eachChild(h=>{c&&!q1(h)&&(c=!1)}),c}function Ef(x,c){if(x instanceof oc&&c.indexOf(x.name)>=0)return!1;let h=!0;return x.eachChild(g=>{h&&!Ef(g,c)&&(h=!1)}),h}function GO(x,c,h){return[x,c,h].filter(Boolean).join("")}function JE(x,c){switch(x){case"string":return rn(c);case"number":return+c;case"boolean":return!!c;case"color":return Aa.parse(c);case"formatted":return Td.fromString(rn(c));case"resolvedImage":return Ku.build(rn(c))}return c}function WO(x,c,h,g){return g!==void 0&&(x=g*Math.round(x/g)),c!==void 0&&xh&&(x=h),x}class U1{constructor(c,h,g,j=!1){this.type=c,this.key=h,this.scope=g,this.featureConstant=j}static parse(c,h){let g=h.expectedType;if(g==null&&(g=li),c.length<2||c.length>3)return h.error("Invalid number of arguments for 'config' expression.");const j=h.parse(c[1],1);if(!(j instanceof Sr))return h.error("Key name of 'config' expression must be a string literal.");let T,P=!0;const R=rn(j.value);if(c.length>=3){const F=h.parse(c[2],2);if(!(F instanceof Sr))return h.error("Scope of 'config' expression must be a string literal.");T=rn(F.value)}if(h.options){const F=GO(R,T,h._scope),H=h.options.get(F);H&&(P=H0(H.value||H.default))}return new U1(g,R,T,P)}evaluate(c){const h=GO(this.key,this.scope,c.scope),g=c.getConfig(h);if(!g)return null;const{type:j,value:T,values:P,minValue:R,maxValue:F,stepValue:H}=g,Q=g.default.evaluate(c);let se=Q;if(T){const re=c.scope;c.scope=(re||"").split("").slice(1).join(""),se=T.evaluate(c),c.scope=re}return j&&(se=JE(j,se)),se===void 0||R===void 0&&F===void 0&&H===void 0||(typeof se=="number"?se=WO(se,R,F,H):Array.isArray(se)&&(se=se.map(re=>typeof re=="number"?WO(re,R,F,H):re))),T!==void 0&&se!==void 0&&P&&!P.includes(se)&&(se=Q,j&&(se=JE(j,se))),(j&&j!==this.type||se!==void 0&&!Ux(Oo(se),this.type))&&(se=JE(this.type.kind,se)),se}eachChild(){}outputDefined(){return!1}serialize(){const c=["config",this.key];return this.scope&&c.concat(this.scope),c}}class KC{constructor(c,h){this.type=h.type,this.name=c,this.boundExpression=h}static parse(c,h){if(c.length!==2||typeof c[1]!="string")return h.error("'var' expression requires exactly one string literal argument.");const g=c[1];return h.scope.has(g)?new KC(g,h.scope.get(g)):h.error(`Unknown variable "${g}". Make sure "${g}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(c){return this.boundExpression.evaluate(c)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class ZC{constructor(c,h=[],g,j=new F0,T=[],P,R,F){this.registry=c,this.path=h,this.key=h.map(H=>typeof H=="string"?`['${H}']`:`[${H}]`).join(""),this.scope=j,this.errors=T,this.expectedType=g,this._scope=P,this.options=R,this.iconImageUseTheme=F}parse(c,h,g,j,T={}){return h||g?this.concat(h,null,g,j)._parse(c,T):this._parse(c,T)}parseObjectValue(c,h,g,j,T,P={}){return this.concat(h,g,j,T)._parse(c,P)}_parse(c,h){function g(j,T,P){return P==="assert"?new Yh(T,[j]):P==="coerce"?new Tp(T,[j]):j}if(c!==null&&typeof c!="string"&&typeof c!="boolean"&&typeof c!="number"||(c=["literal",c]),Array.isArray(c)){if(c.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const j=typeof c[0]=="string"?this.registry[c[0]]:void 0;if(j){let T=j.parse(c,this);if(!T)return null;if(this.expectedType){const P=this.expectedType,R=T.type;if(P.kind!=="string"&&P.kind!=="number"&&P.kind!=="boolean"&&P.kind!=="object"&&P.kind!=="array"||R.kind!=="value")if(P.kind!=="color"&&P.kind!=="formatted"&&P.kind!=="resolvedImage"||R.kind!=="value"&&R.kind!=="string"){if(this.checkSubtype(P,R))return null}else T=g(T,P,h.typeAnnotation||"coerce");else T=g(T,P,h.typeAnnotation||"assert")}if(!(T instanceof Sr)&&T.type.kind!=="resolvedImage"&&eP(T)){const P=new $w(this._scope,this.options,this.iconImageUseTheme);try{T=new Sr(T.type,T.evaluate(P))}catch(R){return this.error(R.message),null}}return T}return Tp.parse(["to-array",c],this)}return this.error(c===void 0?"'undefined' value invalid. Use null instead.":typeof c=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof c} instead.`)}concat(c,h,g,j){let T=typeof c=="number"?this.path.concat(c):this.path;T=typeof h=="string"?T.concat(h):T;const P=j?this.scope.concat(j):this.scope;return new ZC(this.registry,T,g||null,P,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(c,...h){const g=`${this.key}${h.map(j=>`[${j}]`).join("")}`;this.errors.push(new qm(g,c))}checkSubtype(c,h){const g=Rw(c,h);return g&&this.error(g),g}}function eP(x){if(x instanceof KC)return eP(x.boundExpression);if(x instanceof oc&&x.name==="error"||x instanceof qC||x instanceof ay||x instanceof V0||x instanceof U1)return!1;const c=x instanceof Tp||x instanceof Yh;let h=!0;return x.eachChild(g=>{h=c?h&&eP(g):h&&g instanceof Sr}),!!h&&H0(x)&&Ef(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","is-active-floor"])}function YC(x,c){const h=x.length-1;let g,j,T=0,P=h,R=0;for(;T<=P;)if(R=Math.floor((T+P)/2),g=x[R],j=x[R+1],g<=c){if(R===h||cc))throw new dl("Input is not a number.");P=R-1}return 0}class Kw{constructor(c,h,g){this.type=c,this.input=h,this.labels=[],this.outputs=[];for(const[j,T]of g)this.labels.push(j),this.outputs.push(T)}static parse(c,h){if(c.length-1<4)return h.error(`Expected at least 4 arguments, but found only ${c.length-1}.`);if((c.length-1)%2!=0)return h.error("Expected an even number of arguments.");const g=h.parse(c[1],1,Dr);if(!g)return null;const j=[];let T=null;h.expectedType&&h.expectedType.kind!=="value"&&(T=h.expectedType);for(let P=1;P=R)return h.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',H);const se=h.parse(F,Q,T);if(!se)return null;T=T||se.type,j.push([R,se])}return new Kw(T,g,j)}evaluate(c){const h=this.labels,g=this.outputs;if(h.length===1)return g[0].evaluate(c);const j=this.input.evaluate(c);if(j<=h[0])return g[0].evaluate(c);const T=h.length;return j>=h[T-1]?g[T-1].evaluate(c):g[YC(h,j)].evaluate(c)}eachChild(c){c(this.input);for(const h of this.outputs)c(h)}outputDefined(){return this.outputs.every(c=>c.outputDefined())}serialize(){const c=["step",this.input.serialize()];for(let h=0;h0&&c.push(this.labels[h]),c.push(this.outputs[h].serialize());return c}}const KO=.95047,ZO=1.08883,YO=4/29,V1=6/29,XO=3*V1*V1,xpe=V1*V1*V1,gpe=Math.PI/180,ype=180/Math.PI;function tP(x){return x>xpe?Math.pow(x,1/3):x/XO+YO}function sP(x){return x>V1?x*x*x:XO*(x-YO)}function Zw(x){return 255*(x<=.0031308?12.92*x:1.055*Math.pow(x,1/2.4)-.055)}function H1(x){return(x/=255)<=.04045?x/12.92:Math.pow((x+.055)/1.055,2.4)}function rP(x){const c=H1(x.r),h=H1(x.g),g=H1(x.b),j=tP((.4124564*c+.3575761*h+.1804375*g)/KO),T=tP((.2126729*c+.7151522*h+.072175*g)/1);return{l:116*T-16,a:500*(j-T),b:200*(T-tP((.0193339*c+.119192*h+.9503041*g)/ZO)),alpha:x.a}}function QO(x){let c=(x.l+16)/116,h=isNaN(x.a)?c:c+x.a/500,g=isNaN(x.b)?c:c-x.b/200;return c=1*sP(c),h=KO*sP(h),g=ZO*sP(g),new Aa(Zw(3.2404542*h-1.5371385*c-.4985314*g),Zw(-.969266*h+1.8760108*c+.041556*g),Zw(.0556434*h-.2040259*c+1.0572252*g),x.alpha)}function vpe(x,c,h){const g=c-x;return x+h*(g>180||g<-180?g-360*Math.round(g/360):g)}const Yw={forward:rP,reverse:QO,interpolate:function(x,c,h){return{l:on(x.l,c.l,h),a:on(x.a,c.a,h),b:on(x.b,c.b,h),alpha:on(x.alpha,c.alpha,h)}}},G1={forward:function(x){const{l:c,a:h,b:g}=rP(x),j=Math.atan2(g,h)*ype;return{h:j<0?j+360:j,c:Math.sqrt(h*h+g*g),l:c,alpha:x.a}},reverse:function(x){const c=x.h*gpe,h=x.c;return QO({l:x.l,a:Math.cos(c)*h,b:Math.sin(c)*h,alpha:x.alpha})},interpolate:function(x,c,h){return{h:vpe(x.h,c.h,h),c:on(x.c,c.c,h),l:on(x.l,c.l,h),alpha:on(x.alpha,c.alpha,h)}}};var nP=Object.freeze({__proto__:null,hcl:G1,lab:Yw});class Ad{constructor(c,h,g,j,T){this.type=c,this.operator=h,this.interpolation=g,this.input=j,this.labels=[],this.outputs=[];for(const[P,R]of T)this.labels.push(P),this.outputs.push(R)}static interpolationFactor(c,h,g,j){let T=0;if(c.name==="exponential")T=XC(h,c.base,g,j);else if(c.name==="linear")T=XC(h,1,g,j);else if(c.name==="cubic-bezier"){const P=c.controlPoints;T=new ai(P[0],P[1],P[2],P[3]).solve(XC(h,1,g,j))}return T}static parse(c,h){let[g,j,T,...P]=c;if(!Array.isArray(j)||j.length===0)return h.error("Expected an interpolation type expression.",1);if(j[0]==="linear")j={name:"linear"};else if(j[0]==="exponential"){const H=j[1];if(typeof H!="number")return h.error("Exponential interpolation requires a numeric base.",1,1);j={name:"exponential",base:H}}else{if(j[0]!=="cubic-bezier")return h.error(`Unknown interpolation type ${String(j[0])}`,1,0);{const H=j.slice(1);if(H.length!==4||H.some(Q=>typeof Q!="number"||Q<0||Q>1))return h.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);j={name:"cubic-bezier",controlPoints:H}}}if(c.length-1<4)return h.error(`Expected at least 4 arguments, but found only ${c.length-1}.`);if(c.length-1>3&&(c.length-1)%2!=0)return h.error("Expected an even number of arguments.");if(T=h.parse(T,2,Dr),!T)return null;const R=[];let F=null;g==="interpolate-hcl"||g==="interpolate-lab"?F=Nu:h.expectedType&&h.expectedType.kind!=="value"&&(F=h.expectedType);for(let H=0;H=Q)return h.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',re);const ue=h.parse(se,le,F);if(!ue)return null;F=F||ue.type,R.push([Q,ue])}return F.kind==="number"||F.kind==="color"||F.kind==="array"&&F.itemType.kind==="number"&&typeof F.N=="number"?new Ad(F,g,j,T,R):h.error(`Type ${Sl(F)} is not interpolatable.`)}evaluate(c){const h=this.labels,g=this.outputs;if(h.length===1)return g[0].evaluate(c);const j=this.input.evaluate(c);if(j<=h[0])return g[0].evaluate(c);const T=h.length;if(j>=h[T-1])return g[T-1].evaluate(c);const P=YC(h,j),R=Ad.interpolationFactor(this.interpolation,j,h[P],h[P+1]),F=g[P].evaluate(c),H=g[P+1].evaluate(c);return this.operator==="interpolate"?zC[this.type.kind.toLowerCase()](F,H,R):this.operator==="interpolate-hcl"?G1.reverse(G1.interpolate(G1.forward(F),G1.forward(H),R)):Yw.reverse(Yw.interpolate(Yw.forward(F),Yw.forward(H),R))}eachChild(c){c(this.input);for(const h of this.outputs)c(h)}outputDefined(){return this.outputs.every(c=>c.outputDefined())}serialize(){let c;c=this.interpolation.name==="linear"?["linear"]:this.interpolation.name==="exponential"?this.interpolation.base===1?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier",...this.interpolation.controlPoints];const h=[this.operator,c,this.input.serialize()];for(let g=0;gRw(j,R.type));return new Xw(P?li:g,T)}evaluate(c){let h,g=null,j=0;for(const T of this.args){if(j++,g=T.evaluate(c),g&&g instanceof Ku&&!g.available&&(h||(h=g),g=null,j===this.args.length))return h;if(g!==null)break}return g}eachChild(c){this.args.forEach(c)}outputDefined(){return this.args.every(c=>c.outputDefined())}serialize(){const c=["coalesce"];return this.eachChild(h=>{c.push(h.serialize())}),c}}class QC{constructor(c,h){this.type=h.type,this.bindings=[].concat(c),this.result=h}evaluate(c){return this.result.evaluate(c)}eachChild(c){for(const h of this.bindings)c(h[1]);c(this.result)}static parse(c,h){if(c.length<4)return h.error(`Expected at least 3 arguments, but found ${c.length-1} instead.`);const g=[];for(let T=1;T=g.length)throw new dl("Array index out of bounds: index exceeds array size");if(h!==Math.floor(h))throw new dl("Array index must be an integer. Use at-interpolated for fractional indices");return g[h]}eachChild(c){c(this.index),c(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class Jw{constructor(c,h,g){this.type=c,this.index=h,this.input=g}static parse(c,h){if(c.length!==3)return h.error(`Expected 2 arguments, but found ${c.length-1} instead.`);const g=h.parse(c[1],1,Dr),j=h.parse(c[2],2,Kd(h.expectedType||li));return g&&j?new Jw(j.type.itemType,g,j):null}evaluate(c){const h=this.index.evaluate(c),g=this.input.evaluate(c);if(h<0)throw new dl(`Array index out of bounds: ${h} < 0.`);if(h>g.length-1)throw new dl(`Array index out of bounds: ${h} > ${g.length-1}.`);if(h===Math.floor(h))return g[h];const j=Math.floor(h),T=Math.ceil(h),P=g[j],R=g[T];if(typeof P!="number"||typeof R!="number")throw new dl(`Cannot interpolate between non-number values at index ${h}.`);const F=h-j;return P*(1-F)+R*F}eachChild(c){c(this.index),c(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class e2{constructor(c,h){this.type=oi,this.needle=c,this.haystack=h}static parse(c,h){if(c.length!==3)return h.error(`Expected 2 arguments, but found ${c.length-1} instead.`),null;const g=h.parse(c[1],1,li),j=h.parse(c[2],2,li);return g&&j?zE(g.type,[oi,ri,Dr,qx,li])?new e2(g,j):(h.error(`Expected first argument to be of type boolean, string, number or null, but found ${Sl(g.type)} instead`),null):null}evaluate(c){const h=this.needle.evaluate(c),g=this.haystack.evaluate(c);if(g==null)return!1;if(!D1(h,["boolean","string","number","null"]))throw new dl(`Expected first argument to be of type boolean, string, number or null, but found ${Sl(Oo(h))} instead.`);if(!D1(g,["string","array"]))throw new dl(`Expected second argument to be of type array or string, but found ${Sl(Oo(g))} instead.`);return g.indexOf(h)>=0}eachChild(c){c(this.needle),c(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class JC{constructor(c,h,g){this.type=Dr,this.needle=c,this.haystack=h,this.fromIndex=g}static parse(c,h){if(c.length<=2||c.length>=5)return h.error(`Expected 3 or 4 arguments, but found ${c.length-1} instead.`),null;const g=h.parse(c[1],1,li),j=h.parse(c[2],2,li);if(!g||!j)return null;if(!zE(g.type,[oi,ri,Dr,qx,li]))return h.error(`Expected first argument to be of type boolean, string, number or null, but found ${Sl(g.type)} instead`),null;if(c.length===4){const T=h.parse(c[3],3,Dr);return T?new JC(g,j,T):null}return new JC(g,j)}evaluate(c){const h=this.needle.evaluate(c),g=this.haystack.evaluate(c);if(!D1(h,["boolean","string","number","null"]))throw new dl(`Expected first argument to be of type boolean, string, number or null, but found ${Sl(Oo(h))} instead.`);if(!D1(g,["string","array"]))throw new dl(`Expected second argument to be of type array or string, but found ${Sl(Oo(g))} instead.`);if(this.fromIndex){const j=this.fromIndex.evaluate(c);return g.indexOf(h,j)}return g.indexOf(h)}eachChild(c){c(this.needle),c(this.haystack),this.fromIndex&&c(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){const c=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),c]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class aP{constructor(c,h,g,j,T,P){this.inputType=c,this.type=h,this.input=g,this.cases=j,this.outputs=T,this.otherwise=P}static parse(c,h){if(c.length<5)return h.error(`Expected at least 4 arguments, but found only ${c.length-1}.`);if(c.length%2!=1)return h.error("Expected an even number of arguments.");let g,j;h.expectedType&&h.expectedType.kind!=="value"&&(j=h.expectedType);const T={},P=[];for(let H=2;HNumber.MAX_SAFE_INTEGER)return re.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof ue=="number"&&Math.floor(ue)!==ue)return re.error("Numeric branch labels must be integer values.");if(g){if(re.checkSubtype(g,Oo(ue)))return null}else g=Oo(ue);if(T[String(ue)]!==void 0)return re.error("Branch labels must be unique.");T[String(ue)]=P.length}const le=h.parse(se,H,j);if(!le)return null;j=j||le.type,P.push(le)}const R=h.parse(c[1],1,li);if(!R)return null;const F=h.parse(c[c.length-1],c.length-1,j);return F?R.type.kind!=="value"&&h.concat(1).checkSubtype(g,R.type)?null:new aP(g,j,R,T,P,F):null}evaluate(c){const h=this.input.evaluate(c);return(Ux(Oo(h),this.inputType)&&this.outputs[this.cases[h]]||this.otherwise).evaluate(c)}eachChild(c){c(this.input),this.outputs.forEach(c),c(this.otherwise)}outputDefined(){return this.outputs.every(c=>c.outputDefined())&&this.otherwise.outputDefined()}serialize(){const c=["match",this.input.serialize()],h=Object.keys(this.cases).sort(),g=[],j={};for(const P of h){const R=j[this.cases[P]];R===void 0?(j[this.cases[P]]=g.length,g.push([this.cases[P],[P]])):g[R][1].push(P)}const T=P=>this.inputType.kind==="number"?Number(P):P;for(const[P,R]of g)c.push(R.length===1?T(R[0]):R.map(T)),c.push(this.outputs[P].serialize());return c.push(this.otherwise.serialize()),c}}class e3{constructor(c,h,g){this.type=c,this.branches=h,this.otherwise=g}static parse(c,h){if(c.length<4)return h.error(`Expected at least 3 arguments, but found only ${c.length-1}.`),null;if(c.length%2!=0)return h.error("Expected an odd number of arguments."),null;let g;h.expectedType&&h.expectedType.kind!=="value"&&(g=h.expectedType);const j=[];for(let P=1;Ph.outputDefined())&&this.otherwise.outputDefined()}serialize(){const c=["case"];return this.eachChild(h=>{c.push(h.serialize())}),c}}class t2{constructor(c,h,g,j){this.type=c,this.input=h,this.beginIndex=g,this.endIndex=j}static parse(c,h){if(c.length<=2||c.length>=5)return h.error(`Expected 3 or 4 arguments, but found ${c.length-1} instead.`),null;const g=h.parse(c[1],1,li),j=h.parse(c[2],2,Dr);if(!g||!j)return null;if(!zE(g.type,[Kd(li),ri,li]))return h.error(`Expected first argument to be of type array or string, but found ${Sl(g.type)} instead`),null;if(c.length===4){const T=h.parse(c[3],3,Dr);return T?new t2(g.type,g,j,T):null}return new t2(g.type,g,j)}evaluate(c){const h=this.input.evaluate(c),g=this.beginIndex.evaluate(c);if(!D1(h,["string","array"]))throw new dl(`Expected first argument to be of type array or string, but found ${Sl(Oo(h))} instead.`);if(this.endIndex){const j=this.endIndex.evaluate(c);return h.slice(g,j)}return h.slice(g)}eachChild(c){c(this.input),c(this.beginIndex),this.endIndex&&c(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){const c=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),c]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}class iP{constructor(c,h){this.type=Kd(ri),this.str=c,this.delimiter=h}static parse(c,h){if(c.length!==3)return h.error(`Expected 2 arguments, but found ${c.length-1} instead.`);const g=h.parse(c[1],1,ri),j=h.parse(c[2],2,ri);return g&&j?new iP(g,j):void 0}evaluate(c){const h=this.str.evaluate(c),g=this.delimiter.evaluate(c);return h.split(g)}eachChild(c){c(this.str),c(this.delimiter)}outputDefined(){return!1}serialize(){return["split",this.str.serialize(),this.delimiter.serialize()]}}function JO(x,c){return x==="=="||x==="!="?c.kind==="boolean"||c.kind==="string"||c.kind==="number"||c.kind==="null"||c.kind==="value":c.kind==="string"||c.kind==="number"||c.kind==="value"}function eF(x,c,h,g){return g.compare(c,h)===0}function G0(x,c,h){const g=x!=="=="&&x!=="!=";return class AGe{constructor(T,P,R){this.type=oi,this.lhs=T,this.rhs=P,this.collator=R,this.hasUntypedArgument=T.type.kind==="value"||P.type.kind==="value"}static parse(T,P){if(T.length!==3&&T.length!==4)return P.error("Expected two or three arguments.");const R=T[0];let F=P.parse(T[1],1,li);if(!F)return null;if(!JO(R,F.type))return P.concat(1).error(`"${R}" comparisons are not supported for type '${Sl(F.type)}'.`);let H=P.parse(T[2],2,li);if(!H)return null;if(!JO(R,H.type))return P.concat(2).error(`"${R}" comparisons are not supported for type '${Sl(H.type)}'.`);if(F.type.kind!==H.type.kind&&F.type.kind!=="value"&&H.type.kind!=="value")return P.error(`Cannot compare types '${Sl(F.type)}' and '${Sl(H.type)}'.`);g&&(F.type.kind==="value"&&H.type.kind!=="value"?F=new Yh(H.type,[F]):F.type.kind!=="value"&&H.type.kind==="value"&&(H=new Yh(F.type,[H])));let Q=null;if(T.length===4){if(F.type.kind!=="string"&&H.type.kind!=="string"&&F.type.kind!=="value"&&H.type.kind!=="value")return P.error("Cannot use collator to compare non-string types.");if(Q=P.parse(T[3],3,z0),!Q)return null}return new AGe(F,H,Q)}evaluate(T){const P=this.lhs.evaluate(T),R=this.rhs.evaluate(T);if(g&&this.hasUntypedArgument){const F=Oo(P),H=Oo(R);if(F.kind!==H.kind||F.kind!=="string"&&F.kind!=="number")throw new dl(`Expected arguments for "${x}" to be (string, string) or (number, number), but found (${F.kind}, ${H.kind}) instead.`)}if(this.collator&&!g&&this.hasUntypedArgument){const F=Oo(P),H=Oo(R);if(F.kind!=="string"||H.kind!=="string")return c(T,P,R)}return this.collator?h(T,P,R,this.collator.evaluate(T)):c(T,P,R)}eachChild(T){T(this.lhs),T(this.rhs),this.collator&&T(this.collator)}outputDefined(){return!0}serialize(){const T=[x];return this.eachChild(P=>{T.push(P.serialize())}),T}}}const tF=G0("==",function(x,c,h){return c===h},eF),t3=G0("!=",function(x,c,h){return c!==h},function(x,c,h,g){return!eF(0,c,h,g)}),_pe=G0("<",function(x,c,h){return c",function(x,c,h){return c>h},function(x,c,h,g){return g.compare(c,h)>0}),bpe=G0("<=",function(x,c,h){return c<=h},function(x,c,h,g){return g.compare(c,h)<=0}),wpe=G0(">=",function(x,c,h){return c>=h},function(x,c,h,g){return g.compare(c,h)>=0});class s3{constructor(c,h,g,j,T,P){this.type=ri,this.number=c,this.locale=h,this.currency=g,this.unit=j,this.minFractionDigits=T,this.maxFractionDigits=P}static parse(c,h){if(c.length!==3)return h.error("Expected two arguments.");const g=h.parse(c[1],1,Dr);if(!g)return null;const j=c[2];if(typeof j!="object"||Array.isArray(j))return h.error("NumberFormat options argument must be an object.");let T=null;if(j.locale&&(T=h.parseObjectValue(j.locale,2,"locale",ri),!T))return null;let P=null;if(j.currency&&(P=h.parseObjectValue(j.currency,2,"currency",ri),!P))return null;let R=null;if(j.unit&&(R=h.parseObjectValue(j.unit,2,"unit",ri),!R))return null;let F=null;if(j["min-fraction-digits"]&&(F=h.parseObjectValue(j["min-fraction-digits"],2,"min-fraction-digits",Dr),!F))return null;let H=null;return j["max-fraction-digits"]&&(H=h.parseObjectValue(j["max-fraction-digits"],2,"max-fraction-digits",Dr),!H)?null:new s3(g,T,P,R,F,H)}evaluate(c){return new Intl.NumberFormat(this.locale?this.locale.evaluate(c):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(c):void 0,unit:this.unit?this.unit.evaluate(c):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(c):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(c):void 0}).format(this.number.evaluate(c))}eachChild(c){c(this.number),this.locale&&c(this.locale),this.currency&&c(this.currency),this.unit&&c(this.unit),this.minFractionDigits&&c(this.minFractionDigits),this.maxFractionDigits&&c(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const c={};return this.locale&&(c.locale=this.locale.serialize()),this.currency&&(c.currency=this.currency.serialize()),this.unit&&(c.unit=this.unit.serialize()),this.minFractionDigits&&(c["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(c["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),c]}}class r3{constructor(c){this.type=Dr,this.input=c}static parse(c,h){if(c.length!==2)return h.error(`Expected 1 argument, but found ${c.length-1} instead.`),null;const g=h.parse(c[1],1);return g?g.type.kind!=="array"&&g.type.kind!=="string"&&g.type.kind!=="value"?(h.error(`Expected argument of type string or array, but found ${Sl(g.type)} instead.`),null):new r3(g):null}evaluate(c){const h=this.input.evaluate(c);if(typeof h=="string"||Array.isArray(h))return h.length;throw new dl(`Expected value to be of type string or array, but found ${Sl(Oo(h))} instead.`)}eachChild(c){c(this.input)}outputDefined(){return!1}serialize(){const c=["length"];return this.eachChild(h=>{c.push(h.serialize())}),c}}function rF(x){return function(){x=1831565813+(x|=0)|0;let c=Math.imul(x^x>>>15,1|x);return c=c+Math.imul(c^c>>>7,61|c)^c,((c^c>>>14)>>>0)/4294967296}}const W1={"==":tF,"!=":t3,">":sF,"<":_pe,">=":wpe,"<=":bpe,array:Yh,at:Qw,"at-interpolated":Jw,boolean:Yh,case:e3,coalesce:Xw,collator:qC,format:B0,image:Xr,in:e2,"index-of":JC,interpolate:Ad,"interpolate-hcl":Ad,"interpolate-lab":Ad,length:r3,let:QC,literal:Sr,match:aP,number:Yh,"number-format":s3,object:Yh,slice:t2,step:Kw,string:Yh,"to-boolean":Tp,"to-color":Tp,"to-number":Tp,"to-string":Tp,var:KC,within:ay,distance:V0,config:U1,split:iP};function nF(x,[c,h,g,j]){c=c.evaluate(x),h=h.evaluate(x),g=g.evaluate(x);const T=j?j.evaluate(x):1,P=IO(c,h,g,T);if(P)throw new dl(P);return new Aa(c/255,h/255,g/255,T)}function aF(x,[c,h,g,j]){c=c.evaluate(x),h=h.evaluate(x),g=g.evaluate(x);const T=j?j.evaluate(x):1,P=function(H,Q,se,re){return typeof H=="number"&&H>=0&&H<=360?typeof Q=="number"&&Q>=0&&Q<=100&&typeof se=="number"&&se>=0&&se<=100?re===void 0||typeof re=="number"&&re>=0&&re<=1?null:`Invalid hsla value [${[H,Q,se,re].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${(typeof re=="number"?[H,Q,se,re]:[H,Q,se]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${(typeof re=="number"?[H,Q,se,re]:[H,Q,se]).join(", ")}]: 'h' must be between 0 and 360.`}(c,h,g,T);if(P)throw new dl(P);const R=`hsla(${c}, ${h}%, ${g}%, ${T})`,F=Aa.parse(R);if(!F)throw new dl(`Failed to parse HSLA color: ${R}`);return F}function s2(x,c){return x in c}function n3(x,c){const h=c[x];return h===void 0?null:h}function oy(x){return{type:x}}function a3(x){if(x instanceof U1)return new Set([x.key]);let c=new Set;return x.eachChild(h=>{c=new Set([...c,...a3(h)])}),c}function i3(x){if(x instanceof oc&&x.name==="is-active-floor")return!0;let c=!1;return x.eachChild(h=>{!c&&i3(h)&&(c=!0)}),c}function iF(x){return{result:"success",value:x}}function ly(x){return{result:"error",value:x}}function r2(x,c){return!!x&&!!x.parameters&&x.parameters.indexOf(c)>-1}function o3(x){return x["property-type"]==="data-driven"}function oF(x){return r2(x.expression,"measure-light")}function oP(x){return r2(x.expression,"zoom")}function l3(x){return!!x.expression&&x.expression.interpolated}function lP(x){return typeof x=="object"&&x!==null&&!Array.isArray(x)}function lF(x){return x}function cF(x,c){const h=c.type==="color",g=x.stops&&typeof x.stops[0][0]=="object",j=g||!(g||x.property!==void 0),T=x.type||(l3(c)?"exponential":"interval");if(h&&((x=Object.assign({},x)).stops&&(x.stops=x.stops.map(H=>[H[0],Aa.parse(H[1])])),x.default=Aa.parse(x.default?x.default:c.default)),x.colorSpace&&x.colorSpace!=="rgb"&&!nP[x.colorSpace])throw new Error(`Unknown color space: ${x.colorSpace}`);let P,R,F;if(T==="exponential")P=dF;else if(T==="interval")P=Npe;else if(T==="categorical"){P=jpe,R=Object.create(null);for(const H of x.stops)R[H[0]]=H[1];F=typeof x.stops[0][0]}else{if(T!=="identity")throw new Error(`Unknown function type "${T}"`);P=uF}if(g){const H={},Q=[];for(let le=0;lele[0]),evaluate:({zoom:le},ue)=>dF({stops:se,base:x.base},c,le).evaluate(le,ue)}}if(j){const H=T==="exponential"?{name:"exponential",base:x.base!==void 0?x.base:1}:null;return{kind:"camera",interpolationType:H,interpolationFactor:Ad.interpolationFactor.bind(void 0,H),zoomStops:x.stops.map(Q=>Q[0]),evaluate:({zoom:Q})=>P(x,c,Q,R,F)}}return{kind:"source",evaluate(H,Q){const se=Q&&Q.properties?Q.properties[x.property]:void 0;return se===void 0?Pf(x.default,c.default):P(x,c,se,R,F)}}}function Pf(x,c,h){return x!==void 0?x:c!==void 0?c:h!==void 0?h:void 0}function jpe(x,c,h,g,j){return Pf(typeof h===j?g[h]:void 0,x.default,c.default)}function Npe(x,c,h){if(!zw(h))return Pf(x.default,c.default);const g=x.stops.length;if(g===1||h<=x.stops[0][0])return x.stops[0][1];if(h>=x.stops[g-1][0])return x.stops[g-1][1];const j=YC(x.stops.map(T=>T[0]),h);return x.stops[j][1]}function dF(x,c,h){const g=x.base!==void 0?x.base:1;if(!zw(h))return Pf(x.default,c.default);const j=x.stops.length;if(j===1||h<=x.stops[0][0])return x.stops[0][1];if(h>=x.stops[j-1][0])return x.stops[j-1][1];const T=YC(x.stops.map(Q=>Q[0]),h),P=function(Q,se,re,le){const ue=le-re,_e=Q-re;return ue===0?0:se===1?_e/ue:(Math.pow(se,_e)-1)/(Math.pow(se,ue)-1)}(h,g,x.stops[T][0],x.stops[T+1][0]),R=x.stops[T][1],F=x.stops[T+1][1];let H=zC[c.type]||lF;if(x.colorSpace&&x.colorSpace!=="rgb"){const Q=nP[x.colorSpace];H=(se,re)=>Q.reverse(Q.interpolate(Q.forward(se),Q.forward(re),P))}return typeof R.evaluate=="function"?{evaluate(...Q){const se=R.evaluate.apply(void 0,Q),re=F.evaluate.apply(void 0,Q);if(se!==void 0&&re!==void 0)return H(se,re,P)}}:H(R,F,P)}function uF(x,c,h){return c.type==="color"?h=Aa.parse(h):c.type==="formatted"?h=Td.fromString(h.toString()):c.type==="resolvedImage"?h=Ku.build(h.toString()):Fw(h)===c.type||c.type==="enum"&&c.values[h]||(h=void 0),Pf(h,x.default,c.default)}oc.register(W1,{error:[{kind:"error"},[ri],(x,[c])=>{throw new dl(c.evaluate(x))}],typeof:[ri,[li],(x,[c])=>Sl(Oo(c.evaluate(x)))],"to-rgba":[Kd(Dr,4),[Nu],(x,[c])=>c.evaluate(x).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[Kd(Dr,4),[Nu],(x,[c])=>c.evaluate(x).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[Nu,[Dr,Dr,Dr],nF],rgba:[Nu,[Dr,Dr,Dr,Dr],nF],hsl:[Nu,[Dr,Dr,Dr],aF],hsla:[Nu,[Dr,Dr,Dr,Dr],aF],has:{type:oi,overloads:[[[ri],(x,[c])=>s2(c.evaluate(x),x.properties())],[[ri,sy],(x,[c,h])=>s2(c.evaluate(x),h.evaluate(x))]]},get:{type:li,overloads:[[[ri],(x,[c])=>n3(c.evaluate(x),x.properties())],[[ri,sy],(x,[c,h])=>n3(c.evaluate(x),h.evaluate(x))]]},"feature-state":[li,[ri],(x,[c])=>n3(c.evaluate(x),x.featureState||{})],properties:[sy,[],x=>x.properties()],"geometry-type":[ri,[],x=>x.geometryType()],worldview:[ri,[],x=>x.globals.worldview||""],"is-active-floor":[oi,oy(ri),(x,c)=>{if(!(x.globals&&x.globals.activeFloors&&x.globals.activeFloors.size>0))return!1;if(c.length===0)return!0;const h=x.globals.activeFloors;return c.some(g=>{const j=g.evaluate(x);return h.has(j)})}],id:[li,[],x=>x.id()],zoom:[Dr,[],x=>x.globals.zoom],pitch:[Dr,[],x=>x.globals.pitch||0],"distance-from-center":[Dr,[],x=>x.distanceFromCenter()],"measure-light":[Dr,[ri],(x,[c])=>x.measureLight(c.evaluate(x))],"heatmap-density":[Dr,[],x=>x.globals.heatmapDensity||0],"line-progress":[Dr,[],x=>x.globals.lineProgress||0],"raster-value":[Dr,[],x=>x.globals.rasterValue||0],"raster-particle-speed":[Dr,[],x=>x.globals.rasterParticleSpeed||0],"sky-radial-progress":[Dr,[],x=>x.globals.skyRadialProgress||0],accumulated:[li,[],x=>x.globals.accumulated===void 0?null:x.globals.accumulated],"+":[Dr,oy(Dr),(x,c)=>{let h=0;for(const g of c)h+=g.evaluate(x);return h}],"*":[Dr,oy(Dr),(x,c)=>{let h=1;for(const g of c)h*=g.evaluate(x);return h}],"-":{type:Dr,overloads:[[[Dr,Dr],(x,[c,h])=>c.evaluate(x)-h.evaluate(x)],[[Dr],(x,[c])=>-c.evaluate(x)]]},"/":[Dr,[Dr,Dr],(x,[c,h])=>c.evaluate(x)/h.evaluate(x)],"%":[Dr,[Dr,Dr],(x,[c,h])=>c.evaluate(x)%h.evaluate(x)],ln2:[Dr,[],()=>Math.LN2],pi:[Dr,[],()=>Math.PI],e:[Dr,[],()=>Math.E],"^":[Dr,[Dr,Dr],(x,[c,h])=>Math.pow(c.evaluate(x),h.evaluate(x))],sqrt:[Dr,[Dr],(x,[c])=>Math.sqrt(c.evaluate(x))],log10:[Dr,[Dr],(x,[c])=>Math.log(c.evaluate(x))/Math.LN10],ln:[Dr,[Dr],(x,[c])=>Math.log(c.evaluate(x))],log2:[Dr,[Dr],(x,[c])=>Math.log2(c.evaluate(x))],sin:[Dr,[Dr],(x,[c])=>Math.sin(c.evaluate(x))],cos:[Dr,[Dr],(x,[c])=>Math.cos(c.evaluate(x))],tan:[Dr,[Dr],(x,[c])=>Math.tan(c.evaluate(x))],asin:[Dr,[Dr],(x,[c])=>Math.asin(c.evaluate(x))],acos:[Dr,[Dr],(x,[c])=>Math.acos(c.evaluate(x))],atan:[Dr,[Dr],(x,[c])=>Math.atan(c.evaluate(x))],min:[Dr,oy(Dr),(x,c)=>Math.min(...c.map(h=>h.evaluate(x)))],max:[Dr,oy(Dr),(x,c)=>Math.max(...c.map(h=>h.evaluate(x)))],abs:[Dr,[Dr],(x,[c])=>Math.abs(c.evaluate(x))],round:[Dr,[Dr],(x,[c])=>{const h=c.evaluate(x);return h<0?-Math.round(-h):Math.round(h)}],floor:[Dr,[Dr],(x,[c])=>Math.floor(c.evaluate(x))],ceil:[Dr,[Dr],(x,[c])=>Math.ceil(c.evaluate(x))],"filter-==":[oi,[ri,li],(x,[c,h])=>x.properties()[c.value]===h.value],"filter-id-==":[oi,[li],(x,[c])=>x.id()===c.value],"filter-type-==":[oi,[ri],(x,[c])=>x.geometryType()===c.value],"filter-<":[oi,[ri,li],(x,[c,h])=>{const g=x.properties()[c.value],j=h.value;return typeof g==typeof j&&g{const h=x.id(),g=c.value;return typeof h==typeof g&&h":[oi,[ri,li],(x,[c,h])=>{const g=x.properties()[c.value],j=h.value;return typeof g==typeof j&&g>j}],"filter-id->":[oi,[li],(x,[c])=>{const h=x.id(),g=c.value;return typeof h==typeof g&&h>g}],"filter-<=":[oi,[ri,li],(x,[c,h])=>{const g=x.properties()[c.value],j=h.value;return typeof g==typeof j&&g<=j}],"filter-id-<=":[oi,[li],(x,[c])=>{const h=x.id(),g=c.value;return typeof h==typeof g&&h<=g}],"filter->=":[oi,[ri,li],(x,[c,h])=>{const g=x.properties()[c.value],j=h.value;return typeof g==typeof j&&g>=j}],"filter-id->=":[oi,[li],(x,[c])=>{const h=x.id(),g=c.value;return typeof h==typeof g&&h>=g}],"filter-has":[oi,[li],(x,[c])=>c.value in x.properties()],"filter-has-id":[oi,[],x=>x.id()!==null&&x.id()!==void 0],"filter-type-in":[oi,[Kd(ri)],(x,[c])=>c.value.indexOf(x.geometryType())>=0],"filter-id-in":[oi,[Kd(li)],(x,[c])=>c.value.indexOf(x.id())>=0],"filter-in-small":[oi,[ri,Kd(li)],(x,[c,h])=>h.value.indexOf(x.properties()[c.value])>=0],"filter-in-large":[oi,[ri,Kd(li)],(x,[c,h])=>function(g,j,T,P){for(;T<=P;){const R=T+P>>1;if(j[R]===g)return!0;j[R]>g?P=R-1:T=R+1}return!1}(x.properties()[c.value],h.value,0,h.value.length-1)],all:{type:oi,overloads:[[[oi,oi],(x,[c,h])=>c.evaluate(x)&&h.evaluate(x)],[oy(oi),(x,c)=>{for(const h of c)if(!h.evaluate(x))return!1;return!0}]]},any:{type:oi,overloads:[[[oi,oi],(x,[c,h])=>c.evaluate(x)||h.evaluate(x)],[oy(oi),(x,c)=>{for(const h of c)if(h.evaluate(x))return!0;return!1}]]},"!":[oi,[oi],(x,[c])=>!c.evaluate(x)],"is-supported-script":[oi,[ri],(x,[c])=>{const h=x.globals&&x.globals.isSupportedScript;return!h||h(c.evaluate(x))}],upcase:[ri,[ri],(x,[c])=>c.evaluate(x).toUpperCase()],downcase:[ri,[ri],(x,[c])=>c.evaluate(x).toLowerCase()],concat:[ri,oy(li),(x,c)=>c.map(h=>rn(h.evaluate(x))).join("")],"resolved-locale":[ri,[z0],(x,[c])=>c.evaluate(x).resolvedLocale()],random:[Dr,[Dr,Dr,li],(x,c)=>{const[h,g,j]=c.map(P=>P.evaluate(x));if(h>g||h===g)return h;let T;if(typeof j=="string")T=function(P){let R=0;if(P.length===0)return R;for(let F=0;FJSON.stringify(se)).join(", ")}, but found ${JSON.stringify(Q)} instead.`);return Q}catch(Q){const se=Q;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 n2(x){return Array.isArray(x)&&x.length>0&&typeof x[0]=="string"&&x[0]in W1}function cy(x,c,h,g,j){const T=new ZC(W1,[],c?function(R){const F={color:Nu,string:ri,number:Dr,enum:ri,boolean:oi,formatted:Lw,resolvedImage:Dw};return R.type==="array"?Kd(F[R.value]||li,R.length):F[R.type]}(c):void 0,void 0,void 0,h,g,j),P=T.parse(x,void 0,void 0,void 0,c&&c.type==="string"?{typeAnnotation:"coerce"}:void 0);return P?iF(new c3(P,c,h,g,j)):ly(T.errors)}class K1{constructor(c,h,g,j){this.kind=c,this._styleExpression=h,this.isLightConstant=g,this.isLineProgressConstant=j,this.isStateDependent=c!=="constant"&&!q1(h.expression),this.configDependencies=a3(h.expression),this.isIndoorDependent=i3(h.expression)}evaluateWithoutErrorHandling(c,h,g,j,T,P){return this._styleExpression.evaluateWithoutErrorHandling(c,h,g,j,T,P)}evaluate(c,h,g,j,T,P,R){return this._styleExpression.evaluate(c,h,g,j,T,P,void 0,void 0,R)}}class W0{constructor(c,h,g,j,T,P){this.kind=c,this.zoomStops=g,this._styleExpression=h,this.isStateDependent=c!=="camera"&&!q1(h.expression),this.isIndoorDependent=i3(h.expression),this.isLightConstant=T,this.isLineProgressConstant=P,this.configDependencies=a3(h.expression),this.interpolationType=j}evaluateWithoutErrorHandling(c,h,g,j,T,P){return this._styleExpression.evaluateWithoutErrorHandling(c,h,g,j,T,P)}evaluate(c,h,g,j,T,P){return this._styleExpression.evaluate(c,h,g,j,T,P)}interpolationFactor(c,h,g){return this.interpolationType?Ad.interpolationFactor(this.interpolationType,c,h,g):0}}function cP(x,c,h,g,j){if((x=cy(x,c,h,g,j)).result==="error")return x;const T=x.value.expression,P=H0(T);if(!P&&!o3(c))return ly([new qm("","data expressions not supported")]);const R=Ef(T,["zoom","pitch","distance-from-center"]);if(!R&&!oP(c))return ly([new qm("","zoom expressions not supported")]);const F=Ef(T,["measure-light"]);if(!F&&!oF(c))return ly([new qm("","measure-light expression not supported")]);const H=Ef(T,["line-progress"]);if(!H&&!function(re){return r2(re.expression,"line-progress")}(c))return ly([new qm("","line-progress expression not supported")]);const Q=c.expression&&c.expression.relaxZoomRestriction,se=Pp(T);return se||R||Q?se instanceof qm?ly([se]):se instanceof Ad&&!l3(c)?ly([new qm("",'"interpolate" expressions cannot be used with this property')]):iF(se?new W0(P&&H?"camera":"composite",x.value,se.labels,se instanceof Ad?se.interpolation:void 0,F,H):new K1(P&&H?"constant":"source",x.value,F,H)):ly([new qm("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class d3{constructor(c,h){this._parameters=c,this._specification=h,Object.assign(this,cF(this._parameters,this._specification))}static deserialize(c){return new d3(c._parameters,c._specification)}static serialize(c){return{_parameters:c._parameters,_specification:c._specification}}}function Pp(x){let c=null;if(x instanceof QC)c=Pp(x.result);else if(x instanceof Xw){for(const h of x.args)if(c=Pp(h),c)break}else(x instanceof Kw||x instanceof Ad)&&x.input instanceof oc&&x.input.name==="zoom"&&(c=x);return c instanceof qm||x.eachChild(h=>{const g=Pp(h);g instanceof qm?c=g:c&&g&&c!==g&&(c=new qm("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),c}var dP,hF,a2=function(){if(hF)return dP;hF=1,dP=c;var x=3;function c(h,g,j){var T=this.cells=[];if(h instanceof ArrayBuffer){this.arrayBuffer=h;var P=new Int32Array(this.arrayBuffer);h=P[0],this.d=(g=P[1])+2*(j=P[2]);for(var R=0;R=re[_e+0]&&T>=re[_e+1])?(F[ue]=!0,R.push(se[ue])):F[ue]=!1}}},c.prototype._forEachCell=function(h,g,j,T,P,R,F,H){for(var Q=this._convertToCellCoord(h),se=this._convertToCellCoord(g),re=this._convertToCellCoord(j),le=this._convertToCellCoord(T),ue=Q;ue<=re;ue++)for(var _e=se;_e<=le;_e++){var Ce=this.d*_e+ue;if((!H||H(this._convertFromCellCoord(ue),this._convertFromCellCoord(_e),this._convertFromCellCoord(ue+1),this._convertFromCellCoord(_e+1)))&&P.call(this,h,g,j,T,Ce,R,F,H))return}},c.prototype._convertFromCellCoord=function(h){return(h-this.padding)/this.scale},c.prototype._convertToCellCoord=function(h){return Math.max(0,Math.min(this.d-1,Math.floor(h*this.scale)+this.padding))},c.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var h=this.cells,g=x+this.cells.length+1+1,j=0,T=0;T=0||(j[T]=Hx(x[T],c)));x instanceof Error&&(j.message=x.message)}if(j.$name)throw new Error("$name property is reserved for worker serialization logic.");return g!=="Object"&&(j.$name=g),j}throw new Error("can't serialize object of type "+typeof x)}function dy(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||i2(x)||x instanceof ImageBitmap||ArrayBuffer.isView(x)||x instanceof ImageData)return x;if(Array.isArray(x))return x.map(dy);if(typeof x=="object"){const c=x.$name||"Object";if(c==="Map"){const j=x.entries||[],T=new Map;for(let P=0;Px>=1536&&x<=1791,u3=x=>x>=1872&&x<=1919,h3=x=>x>=2208&&x<=2303,m3=x=>x>=11904&&x<=12031,Gx=x=>x>=12032&&x<=12255,uP=x=>x>=12272&&x<=12287,o2=x=>x>=12288&&x<=12351,l2=x=>x>=12352&&x<=12447,Z0=x=>x>=12448&&x<=12543,hP=x=>x>=12544&&x<=12591,p3=x=>x>=12704&&x<=12735,If=x=>x>=12736&&x<=12783,pF=x=>x>=12784&&x<=12799,fF=x=>x>=12800&&x<=13055,xF=x=>x>=13056&&x<=13311,mP=x=>x>=13312&&x<=19903,f3=x=>x>=19968&&x<=40959,c2=x=>x>=40960&&x<=42127,pP=x=>x>=42128&&x<=42191,fP=x=>x>=44032&&x<=55215,x3=x=>x>=63744&&x<=64255,xP=x=>x>=64336&&x<=65023,gF=x=>x>=65040&&x<=65055,gP=x=>x>=65072&&x<=65103,yF=x=>x>=65104&&x<=65135,yP=x=>x>=65136&&x<=65279,vP=x=>x>=65280&&x<=65519;function _P(x){for(const c of x)if(bP(c.charCodeAt(0)))return!0;return!1}function kpe(x){for(const c of x)if(!Spe(c.charCodeAt(0)))return!1;return!0}function Spe(x){return!(mF(x)||u3(x)||h3(x)||xP(x)||yP(x))}function Cpe(x){return!(x<11904||!(p3(x)||hP(x)||gP(x)||x3(x)||xF(x)||m3(x)||If(x)||o2(x)||mP(x)||f3(x)||fF(x)||vP(x)||l2(x)||uP(x)||Gx(x)||pF(x)||Z0(x)||gF(x)||pP(x)||c2(x)))}function bP(x){return!(x!==746&&x!==747&&(x<4352||!(p3(x)||hP(x)||gP(x)&&!(x>=65097&&x<=65103)||x3(x)||xF(x)||m3(x)||If(x)||!(!o2(x)||x>=12296&&x<=12305||x>=12308&&x<=12319||x===12336)||mP(x)||f3(x)||fF(x)||(c=>c>=12592&&c<=12687)(x)||(c=>c>=43360&&c<=43391)(x)||(c=>c>=55216&&c<=55295)(x)||(c=>c>=4352&&c<=4607)(x)||fP(x)||l2(x)||uP(x)||(c=>c>=12688&&c<=12703)(x)||Gx(x)||pF(x)||Z0(x)&&x!==12540||!(!vP(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)||!(!yF(x)||x>=65112&&x<=65118||x>=65123&&x<=65126)||(c=>c>=5120&&c<=5759)(x)||(c=>c>=6320&&c<=6399)(x)||gF(x)||(c=>c>=19904&&c<=19967)(x)||c2(x)||pP(x))))}function vF(x){return x===12312||x===12313||x===12316||x===12540||x===12448}function Y0(x){return!(bP(x)||function(c){return!!((h=>h>=128&&h<=255)(c)&&(c===167||c===169||c===174||c===177||c===188||c===189||c===190||c===215||c===247)||(h=>h>=8192&&h<=8303)(c)&&(c===8214||c===8224||c===8225||c===8240||c===8241||c===8251||c===8252||c===8258||c===8263||c===8264||c===8265||c===8273)||(h=>h>=8448&&h<=8527)(c)||(h=>h>=8528&&h<=8591)(c)||(h=>h>=8960&&h<=9215)(c)&&(c>=8960&&c<=8967||c>=8972&&c<=8991||c>=8996&&c<=9e3||c===9003||c>=9085&&c<=9114||c>=9150&&c<=9165||c===9167||c>=9169&&c<=9179||c>=9186&&c<=9215)||(h=>h>=9216&&h<=9279)(c)&&c!==9251||(h=>h>=9280&&h<=9311)(c)||(h=>h>=9312&&h<=9471)(c)||(h=>h>=9632&&h<=9727)(c)||(h=>h>=9728&&h<=9983)(c)&&!(c>=9754&&c<=9759)||(h=>h>=11008&&h<=11263)(c)&&(c>=11026&&c<=11055||c>=11088&&c<=11097||c>=11192&&c<=11243)||o2(c)||Z0(c)||(h=>h>=57344&&h<=63743)(c)||gP(c)||yF(c)||vP(c)||c===8734||c===8756||c===8757||c>=9984&&c<=10087||c>=10102&&c<=10131||c===65532||c===65533)}(x))}function _F(x){return mF(x)||u3(x)||h3(x)||xP(x)||yP(x)}function wP(x){return x>=1424&&x<=2303||xP(x)||yP(x)}function g3(x,c){return!(!c&&wP(x)||x>=2304&&x<=3583||x>=3840&&x<=4255||(h=>h>=6016&&h<=6143)(x))}function Mpe(x){for(const c of x)if(wP(c.charCodeAt(0)))return!0;return!1}const vh={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let Lf=null,Zd=vh.unavailable,Qh=null;const bF=function(x){x&&typeof x=="string"&&x.indexOf("NetworkError")>-1&&(Zd=vh.error),Lf&&Lf(x)};function jP(){NP.fire(new tn("pluginStateChange",{pluginStatus:Zd,pluginURL:Qh}))}const NP=new Ei,kP=function(){return Zd},wF=function(){if(Zd!==vh.deferred||!Qh)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Zd=vh.loading,jP(),Qh&&ey({url:Qh},x=>{x?bF(x):(Zd=vh.loaded,jP())})},Wx={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Zd===vh.loaded||Wx.applyArabicShaping!=null,isLoading:()=>Zd===vh.loading,setState(x){Zd=x.pluginStatus,Qh=x.pluginURL},isParsing:()=>Zd===vh.parsing,isParsed:()=>Zd===vh.parsed,getPluginURL:()=>Qh},jF=function(){Wx.isLoading()||Wx.isLoaded()||kP()!=="deferred"||wF()};class Ka{constructor(c,h){this.zoom=c,h?(this.now=h.now,this.fadeDuration=h.fadeDuration,this.transition=h.transition,this.pitch=h.pitch,this.brightness=h.brightness,this.worldview=h.worldview,this.activeFloors=h.activeFloors):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(c){return function(h,g){for(const j of h)if(!g3(j.charCodeAt(0),g))return!1;return!0}(c,Wx.isLoaded())}}class Y1{constructor(c,h,g,j,T){this.property=c,this.value=h,this.expression=function(P,R,F,H,Q){if(lP(P))return new d3(P,R);if(n2(P)||Array.isArray(P)&&P.length>0){const se=cP(P,R,F,H,Q);if(se.result==="error")throw new Error(se.value.map(re=>`${re.key}: ${re.message}`).join(", "));return se.value}{let se=P;return typeof P=="string"&&R.type==="color"&&(se=Aa.parse(P)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>se}}}(h===void 0?c.specification.default:h,c.specification,g,j,T)}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(c,h,g,j){return this.property.possiblyEvaluate(this,c,h,g,j)}}class y3{constructor(c,h,g,j){this.property=c,this.value=new Y1(c,void 0,h,g,j)}transitioned(c,h){return new X1(this.property,this.value,h,Object.assign({},c.transition,this.transition),c.now)}untransitioned(){return new X1(this.property,this.value,null,{},0)}}class v3{constructor(c,h,g,j){this._properties=c,this._values=Object.create(c.defaultTransitionablePropertyValues),this._scope=h,this._options=g,this._iconImageUseTheme=j,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(c){return or(this._values[c].value.value)}setValue(c,h){this._values.hasOwnProperty(c)||(this._values[c]=new y3(this._values[c].property,this._scope,this._options,this._iconImageUseTheme)),this._values[c].value=new Y1(this._values[c].property,h===null?void 0:or(h),this._scope,this._options,this._iconImageUseTheme),this._values[c].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[c].value.expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[c].value.isIndoorDependent())}setTransitionOrValue(c,h){h&&(this._options=h);const g=this._properties.properties;if(c)for(const j in c){const T=c[j];if(j.endsWith("-transition")){const P=j.slice(0,-11);g[P]&&this.setTransition(P,T)}else g.hasOwnProperty(j)&&this.setValue(j,T)}}getTransition(c){return or(this._values[c].transition)}setTransition(c,h){this._values.hasOwnProperty(c)||(this._values[c]=new y3(this._values[c].property)),this._values[c].transition=or(h)||void 0}serialize(){const c={};for(const h of Object.keys(this._values)){const g=this.getValue(h);g!==void 0&&(c[h]=g);const j=this.getTransition(h);j!==void 0&&(c[`${h}-transition`]=j)}return c}transitioned(c,h){const g=new SP(this._properties);for(const j of Object.keys(this._values))g._values[j]=this._values[j].transitioned(c,h._values[j]);return g}untransitioned(){const c=new SP(this._properties);for(const h of Object.keys(this._values))c._values[h]=this._values[h].untransitioned();return c}isIndoorDependent(){return this._isIndoorDependent}}class X1{constructor(c,h,g,j,T){const P=j.delay||0,R=j.duration||0;T=T||0,this.property=c,this.value=h,this.begin=T+P,this.end=this.begin+R,c.specification.transition&&(j.delay||j.duration)&&(this.prior=g)}possiblyEvaluate(c,h,g){const j=c.now||0,T=this.value.possiblyEvaluate(c,h,g),P=this.prior;if(P){if(j>this.end)return this.prior=null,T;if(this.value.isDataDriven())return this.prior=null,T;if(j":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-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]},"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-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]},"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},"line-blend-mode":{"type":"enum","values":{"default":1,"multiply":1,"additive":1},"default":"default","expression":{"parameters":["zoom"]}}},"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"]},"appearance":true,"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"]},"appearance":true,"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"appearance":true,"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"appearance":true,"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"]},"appearance":true,"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"]},"appearance":true,"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"]},"appearance":true,"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"]},"appearance":true,"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"appearance":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"]},"appearance":true,"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"]},"appearance":true,"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"]},"appearance":true,"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"]},"appearance":true,"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"]},"appearance":true,"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"]},"appearance":true,"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"appearance":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,"appearance":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"]}},"raster-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1},"default":"sea","expression":{}}},"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":{}},"model-ignore-line-cutout":{"type":"boolean","default":false,"expression":{}}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"promoteId":{"*":{"type":"*"}}}');function NF(x){return x instanceof Number||x instanceof String||x instanceof Boolean?x.valueOf():x}function _3(x){if(Array.isArray(x))return x.map(_3);if(x instanceof Object&&!(x instanceof Number||x instanceof String||x instanceof Boolean)){const c={};for(const h in x)c[h]=_3(x[h]);return c}return NF(x)}function MP(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 c of x.slice(1))if(!MP(c)&&typeof c!="boolean")return!1;return!0;default:return!0}}function b3(x,c="",h=null,g="fill"){if(x==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};MP(x)||(x=w3(x));const j=x;let T=!0;try{T=function(Q){if(!J1(Q))return Q;let se=_3(Q);return SF(se),se=kF(se),se}(j)}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(j,null,2)} `)}let P=null,R=null;if(g!=="background"&&g!=="sky"&&g!=="slot"){R=Wt[`filter_${g}`];const Q=cy(T,R,c,h);if(Q.result==="error")throw new Error(Q.value.map(se=>`${se.key}: ${se.message}`).join(", "));P=(se,re,le)=>Q.value.evaluate(se,re,{},le)}let F=null,H=null;if(T!==j){const Q=cy(j,R,c,h);if(Q.result==="error")throw new Error(Q.value.map(se=>`${se.key}: ${se.message}`).join(", "));F=(se,re,le,ue,_e)=>Q.value.evaluate(se,re,{},le,void 0,void 0,ue,_e),H=!H0(Q.value.expression)}return{filter:P,dynamicFilter:F||void 0,needGeometry:MF(T),needFeature:!!H}}function kF(x){if(!Array.isArray(x))return x;const c=function(h){if(CF.has(h[0])){for(let g=1;gkF(h))}function SF(x){let c=!1;const h=[];if(x[0]==="case"){for(let g=1;g",">=","<","<=","to-boolean"]);function Tpe(x,c){return xc?1:0}function MF(x){if(!Array.isArray(x))return!1;if(x[0]==="within"||x[0]==="distance")return!0;for(let c=1;c"||c==="<="||c===">="?j3(x[1],x[2],c):c==="any"?(h=x.slice(1),["any"].concat(h.map(w3))):c==="all"?["all"].concat(x.slice(1).map(w3)):c==="none"?["all"].concat(x.slice(1).map(w3).map(d2)):c==="in"?TP(x[1],x.slice(2)):c==="!in"?d2(TP(x[1],x.slice(2))):c==="has"?Zx(x[1]):c!=="!has"||d2(Zx(x[1]));var h}function j3(x,c,h){switch(x){case"$type":return[`filter-type-${h}`,c];case"$id":return[`filter-id-${h}`,c];default:return[`filter-${h}`,x,c]}}function TP(x,c){if(c.length===0)return!1;switch(x){case"$type":return["filter-type-in",["literal",c]];case"$id":return["filter-id-in",["literal",c]];default:return c.length>200&&!c.some(h=>typeof h!=typeof c[0])?["filter-in-large",x,["literal",c.sort(Tpe)]]:["filter-in-small",x,["literal",c]]}}function Zx(x){switch(x){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",x]}}function d2(x){return["!",x]}const u2="";function Q0(x,c){return c?`${x}${u2}${c}`:x}function TF(x){const c=x.indexOf(u2);return c>=0?x.slice(c+1):""}let AF;const AP=()=>AF||(AF=new Qi({"icon-size":new Gs(Wt.layout_symbol["icon-size"]),"icon-image":new Gs(Wt.layout_symbol["icon-image"]),"icon-rotate":new Gs(Wt.layout_symbol["icon-rotate"]),"icon-offset":new Gs(Wt.layout_symbol["icon-offset"]),"text-size":new Gs(Wt.layout_symbol["text-size"]),"text-rotate":new Gs(Wt.layout_symbol["text-rotate"]),"text-offset":new Gs(Wt.layout_symbol["text-offset"])}));let EP;const PP=()=>EP||(EP=new Qi({"icon-opacity":new Gs(Wt.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new Gs(Wt.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new Gs(Wt.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Gs(Wt.paint_symbol["text-emissive-strength"]),"icon-color":new Gs(Wt.paint_symbol["icon-color"]),"icon-halo-color":new Gs(Wt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Gs(Wt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Gs(Wt.paint_symbol["icon-halo-blur"]),"icon-translate":new Gs(Wt.paint_symbol["icon-translate"]),"text-opacity":new Gs(Wt.paint_symbol["text-opacity"]),"text-occlusion-opacity":new Gs(Wt.paint_symbol["text-occlusion-opacity"]),"text-color":new Gs(Wt.paint_symbol["text-color"],{runtimeType:Nu,getOverride:x=>x.textColor,hasOverride:x=>!!x.textColor}),"text-halo-color":new Gs(Wt.paint_symbol["text-halo-color"]),"text-halo-width":new Gs(Wt.paint_symbol["text-halo-width"]),"text-halo-blur":new Gs(Wt.paint_symbol["text-halo-blur"]),"text-translate":new Gs(Wt.paint_symbol["text-translate"]),"symbol-z-offset":new Gs(Wt.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new Gs({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new Gs({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new Gs({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new Gs({type:"string",default:"default","property-type":"data-driven"})}));class Ape{constructor(c,h,g,j,T,P){this._conditionSpec=c,this._propertiesSpec=g;const R=cy(c,Wt.appearance.condition);if(R.result==="success"&&(this.condition=R.value),this.name=h,g){this.layoutProperties=new Kx(AP()),this.unevaluatedLayout=new CP(AP(),j,T,P),this.paintProperties=new Kx(PP()),this.unevaluatedPaint=new CP(PP(),j,T,"");for(const F in g)F in this.unevaluatedLayout._values?this.unevaluatedLayout.setValue(F,g[F]):F in this.unevaluatedPaint._values&&this.unevaluatedPaint.setValue(F,g[F])}}isActive(c){return!(this.condition||!c.isHidden||this.name!=="hidden")||this.condition.evaluate(c.globals,c.feature,c.featureState,c.canonical)}getCondition(){return this.condition}getName(){return this.name}getLayoutProperty(c){return this.layoutProperties.get(c)}getPaintProperty(c){return this.paintProperties.get(c)}getUnevaluatedLayoutProperties(){return this.unevaluatedLayout}getUnevaluatedLayoutProperty(c){return this.unevaluatedLayout._values[c]}getUnevaluatedPaintProperty(c){return this.unevaluatedPaint._values[c]}recalculate(c,h,g){this.unevaluatedLayout&&(this.layoutProperties=this.unevaluatedLayout.possiblyEvaluate(c,void 0,h,g)),this.unevaluatedPaint&&(this.paintProperties=this.unevaluatedPaint.possiblyEvaluate(c,void 0,h,""))}serialize(){const c={};c.condition=this.condition.expression.serialize(),this.name&&(c.name=this.name);const h=this.unevaluatedLayout?this.unevaluatedLayout.serialize():{},g=this.unevaluatedPaint?this.unevaluatedPaint.serialize():{},j=Object.assign({},h,g);return Object.keys(j).length>0&&(c.properties=j),c}hasIconLayoutProperties(){const c=this.hasLayoutProperty("icon-image"),h=this.hasLayoutProperty("icon-size"),g=this.hasLayoutProperty("icon-offset"),j=this.hasLayoutProperty("icon-rotate");return c||h||g||j}hasTextLayoutProperties(){const c=this.hasLayoutProperty("text-size"),h=this.hasLayoutProperty("text-offset"),g=this.hasLayoutProperty("text-rotate");return c||h||g}hasIconPaintProperties(){return!!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(c=>!c.endsWith("-use-theme")).some(c=>(c.startsWith("icon-")||c==="symbol-z-offset")&&this.hasPaintProperty(c))}hasTextPaintProperties(){return!!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(c=>!c.endsWith("-use-theme")).some(c=>(c.startsWith("text-")||c==="symbol-z-offset")&&this.hasPaintProperty(c))}hasLayoutProperty(c){return this.unevaluatedLayout&&this.unevaluatedLayout._values[c].value!==void 0}hasPaintProperty(c){return this.unevaluatedPaint&&this.unevaluatedPaint._values[c].value!==void 0}}const IP="-transition",Epe=new Set(["fill","line","background","hillshade","raster"]);class Yd extends Ei{constructor(c,h,g,j,T,P){if(super(),this.id=c.id,this.fqid=Q0(this.id,g),this.type=c.type,this.scope=g,this.lut=j,this.options=T,this.iconImageUseTheme=P,this.appearances=new Array,this.appearancesVersion=0,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.expressionDependencies={isIndoorDependent:!1,configDependencies:new Set},c.type!=="custom"){if(this.metadata=c.metadata,this.minzoom=c.minzoom,this.maxzoom=c.maxzoom,c.type&&c.type!=="background"&&c.type!=="sky"&&c.type!=="slot"){this.source=c.source,this.sourceLayer=c["source-layer"],this.filter=c.filter;const R=cy(this.filter,Wt[`filter_${c.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(c.slot&&(this.slot=c.slot),c.appearances&&this.setAppearances(c.appearances),h.layout&&(this._unevaluatedLayout=new CP(h.layout,this.scope,T,this.iconImageUseTheme),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._unevaluatedLayout.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._unevaluatedLayout.isIndoorDependent()),h.paint){this._transitionablePaint=new v3(h.paint,this.scope,T);for(const R in c.paint)this.setPaintProperty(R,c.paint[R]);for(const R in c.layout)this.setLayoutProperty(R,c.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 Kx(h.paint)}}}onAdd(c){}onRemove(c){}isDraped(c){return!this.is3D(!0)&&Epe.has(this.type)}getLayoutProperty(c){return c==="visibility"?this.visibility:this._unevaluatedLayout.getValue(c)}setLayoutProperty(c,h){if(this.type==="custom"&&c==="visibility")return void(this.visibility=h);const g=this._unevaluatedLayout;g._properties.properties[c]&&(g.setValue(c,h),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...g.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||g.isIndoorDependent(),c==="visibility"&&this.possiblyEvaluateVisibility())}setAppearances(c){this.appearances=[],c.forEach(h=>{this.appearances.push(new Ape(h.condition,h.name,h.properties,this.scope,this.options,this.iconImageUseTheme))}),this.appearancesVersion++}possiblyEvaluateVisibility(){this._unevaluatedLayout._values.visibility&&(this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0}))}getPaintProperty(c){return c.endsWith(IP)?this._transitionablePaint.getTransition(c.slice(0,-11)):this._transitionablePaint.getValue(c)}isPaintProperty(c){return!!this._transitionablePaint._properties.properties[c]}setPaintProperty(c,h){const g=this._transitionablePaint,j=g._properties.properties;if(c.endsWith(IP)){const se=c.slice(0,-11);return j[se]&&g.setTransition(se,h||void 0),!1}if(!j[c])return!1;const T=g._values[c],P=T.value.isDataDriven(),R=T.value;g.setValue(c,h),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...g.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||g.isIndoorDependent(),this._handleSpecialPaintPropertyUpdate(c);const F=g._values[c].value,H=F.isDataDriven(),Q=c.endsWith("pattern")||c==="line-dasharray";return H||P||Q||this._handleOverridablePaintPropertyUpdate(c,R,F)}_handleSpecialPaintPropertyUpdate(c){}getProgramIds(){return null}getDefaultProgramParams(c,h,g){return null}_handleOverridablePaintPropertyUpdate(c,h,g){return!1}isHidden(c){return!!(this.minzoom&&c=this.maxzoom)||this.visibility==="none"}updateTransitions(c){this._transitioningPaint=this._transitionablePaint.transitioned(c,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(c,h){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(c,void 0,h,this.iconImageUseTheme)),this.paint=this._transitioningPaint.possiblyEvaluate(c,void 0,h)}serialize(){const c={id:this.id,type:this.type,slot:this.slot,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.appearances.length!==0&&(c.appearances=this.appearances.map(h=>h.serialize())),bs(c,(h,g)=>!(h===void 0||g==="layout"&&!Object.keys(h).length||g==="paint"&&!Object.keys(h).length))}is3D(c){return!1}hasElevation(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}hasShadowPass(){return!1}canCastShadows(){return!1}hasLightBeamPass(){return!1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}_clear(){}isStateDependent(){for(const c in this.paint._values){const h=this.paint.get(c);if(h instanceof X0&&o3(h.property.specification)&&(h.value.kind==="source"||h.value.kind==="composite")&&h.value.isStateDependent)return!0}for(const c of this.appearances)if(!q1(c.condition.expression))return!0;return!1}compileFilter(c){this._filterCompiled||(this._featureFilter=b3(this.filter,this.scope,c),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}dynamicFilterNeedsGeometry(){return this._featureFilter.needGeometry}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(c){this._stats&&(c.renderPass==="shadow"?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}getAppearances(){return this.appearances}queryRenderedFeatures(c,h,g){return{}}queryRadius(c){}queryIntersectsFeature(c,h,g,j,T,P,R,F,H,Q){}}const N3={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class h2{constructor(c,h){this._structArray=c,this._pos1=h*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}const Ppe=new ArrayBuffer(0);class Oi{constructor(){this._reallocCount=0,this.capacity=0,this.length=0}static serialize(c,h){return c._trim(),h&&c.arrayBuffer&&h.add(c.arrayBuffer),{length:c.length,arrayBuffer:c.arrayBuffer}}static deserialize(c){const h=Object.create(this.prototype);return h.arrayBuffer=c.arrayBuffer,h.length=c.length,c.arrayBuffer?h.capacity=c.arrayBuffer.byteLength/h.bytesPerElement:(h.capacity=0,h.arrayBuffer=Ppe),h._refreshViews(),h}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(c){this.reserve(c),this.length=c}reserve(c){if(c>this.capacity){this._reallocCount++,this.capacity=Math.max(c,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const h=this.uint8;this._refreshViews(),h&&this.uint8.set(h)}}reserveForAdditional(c){this.reserve(this.length+c)}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...c){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...c){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function la(x,c=1){let h=0,g=0;return{members:x.map(j=>{const T=N3[j.type].BYTES_PER_ELEMENT,P=h=EF(h,Math.max(c,T)),R=j.components||1;return g=Math.max(g,T),h+=T*R,{name:j.name,type:j.type,components:R,offset:P}}),size:EF(h,Math.max(g,c)),alignment:c}}function EF(x,c){return Math.ceil(x/c)*c}class _h extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,h){const g=this.length;return this.resize(g+1),this.emplace(g,c,h)}emplace(c,h,g){const j=2*c;return this.int16[j+0]=h,this.int16[j+1]=g,c}}_h.prototype.bytesPerElement=4,yr(_h,"StructArrayLayout2i4");class Df extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,h,g){const j=this.length;return this.resize(j+1),this.emplace(j,c,h,g)}emplace(c,h,g,j){const T=3*c;return this.int16[T+0]=h,this.int16[T+1]=g,this.int16[T+2]=j,c}}Df.prototype.bytesPerElement=6,yr(Df,"StructArrayLayout3i6");class dd extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,h,g,j){const T=this.length;return this.resize(T+1),this.emplace(T,c,h,g,j)}emplace(c,h,g,j,T){const P=4*c;return this.int16[P+0]=h,this.int16[P+1]=g,this.uint16[P+2]=j,this.uint16[P+3]=T,c}}dd.prototype.bytesPerElement=8,yr(dd,"StructArrayLayout2i2ui8");class Jh extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c){const h=this.length;return this.resize(h+1),this.emplace(h,c)}emplace(c,h){return this.float32[1*c+0]=h,c}}Jh.prototype.bytesPerElement=4,yr(Jh,"StructArrayLayout1f4");class LP extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g){const j=this.length;return this.resize(j+1),this.emplace(j,c,h,g)}emplace(c,h,g,j){const T=4*c,P=2*c;return this.int16[T+0]=h,this.int16[T+1]=g,this.float32[P+1]=j,c}}LP.prototype.bytesPerElement=8,yr(LP,"StructArrayLayout2i1f8");class DP extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,h,g){const j=this.length;return this.resize(j+1),this.emplace(j,c,h,g)}emplace(c,h,g,j){const T=4*c;return this.int16[T+0]=h,this.int16[T+1]=g,this.int16[T+2]=j,c}}DP.prototype.bytesPerElement=8,yr(DP,"StructArrayLayout3i8");class RP extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,h,g,j){const T=this.length;return this.resize(T+1),this.emplace(T,c,h,g,j)}emplace(c,h,g,j,T){const P=4*c;return this.int16[P+0]=h,this.int16[P+1]=g,this.int16[P+2]=j,this.int16[P+3]=T,c}}RP.prototype.bytesPerElement=8,yr(RP,"StructArrayLayout4i8");class OP extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T){const P=this.length;return this.resize(P+1),this.emplace(P,c,h,g,j,T)}emplace(c,h,g,j,T,P){const R=5*c;return this.int16[R+0]=h,this.int16[R+1]=g,this.int16[R+2]=j,this.int16[R+3]=T,this.int16[R+4]=P,c}}OP.prototype.bytesPerElement=10,yr(OP,"StructArrayLayout5i10");class m2 extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P,R){const F=this.length;return this.resize(F+1),this.emplace(F,c,h,g,j,T,P,R)}emplace(c,h,g,j,T,P,R,F){const H=6*c,Q=12*c,se=3*c;return this.int16[H+0]=h,this.int16[H+1]=g,this.uint8[Q+4]=j,this.uint8[Q+5]=T,this.uint8[Q+6]=P,this.uint8[Q+7]=R,this.float32[se+2]=F,c}}m2.prototype.bytesPerElement=12,yr(m2,"StructArrayLayout2i4ub1f12");class Hm extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g){const j=this.length;return this.resize(j+1),this.emplace(j,c,h,g)}emplace(c,h,g,j){const T=3*c;return this.float32[T+0]=h,this.float32[T+1]=g,this.float32[T+2]=j,c}}Hm.prototype.bytesPerElement=12,yr(Hm,"StructArrayLayout3f12");class Rf extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T){const P=this.length;return this.resize(P+1),this.emplace(P,c,h,g,j,T)}emplace(c,h,g,j,T,P){const R=6*c,F=3*c;return this.uint16[R+0]=h,this.uint16[R+1]=g,this.uint16[R+2]=j,this.uint16[R+3]=T,this.float32[F+2]=P,c}}Rf.prototype.bytesPerElement=12,yr(Rf,"StructArrayLayout4ui1f12");class e_ extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,h,g,j){const T=this.length;return this.resize(T+1),this.emplace(T,c,h,g,j)}emplace(c,h,g,j,T){const P=4*c;return this.uint16[P+0]=h,this.uint16[P+1]=g,this.uint16[P+2]=j,this.uint16[P+3]=T,c}}e_.prototype.bytesPerElement=8,yr(e_,"StructArrayLayout4ui8");class k3 extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P){const R=this.length;return this.resize(R+1),this.emplace(R,c,h,g,j,T,P)}emplace(c,h,g,j,T,P,R){const F=6*c;return this.int16[F+0]=h,this.int16[F+1]=g,this.int16[F+2]=j,this.int16[F+3]=T,this.int16[F+4]=P,this.int16[F+5]=R,c}}k3.prototype.bytesPerElement=12,yr(k3,"StructArrayLayout6i12");class FP extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P,R,F,H,Q,se,re){const le=this.length;return this.resize(le+1),this.emplace(le,c,h,g,j,T,P,R,F,H,Q,se,re)}emplace(c,h,g,j,T,P,R,F,H,Q,se,re,le){const ue=12*c;return this.int16[ue+0]=h,this.int16[ue+1]=g,this.int16[ue+2]=j,this.int16[ue+3]=T,this.uint16[ue+4]=P,this.uint16[ue+5]=R,this.uint16[ue+6]=F,this.uint16[ue+7]=H,this.int16[ue+8]=Q,this.int16[ue+9]=se,this.int16[ue+10]=re,this.int16[ue+11]=le,c}}FP.prototype.bytesPerElement=24,yr(FP,"StructArrayLayout4i4ui4i24");class zP extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P){const R=this.length;return this.resize(R+1),this.emplace(R,c,h,g,j,T,P)}emplace(c,h,g,j,T,P,R){const F=10*c,H=5*c;return this.int16[F+0]=h,this.int16[F+1]=g,this.int16[F+2]=j,this.float32[H+2]=T,this.float32[H+3]=P,this.float32[H+4]=R,c}}zP.prototype.bytesPerElement=20,yr(zP,"StructArrayLayout3i3f20");class Yx extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g,j){const T=this.length;return this.resize(T+1),this.emplace(T,c,h,g,j)}emplace(c,h,g,j,T){const P=4*c;return this.float32[P+0]=h,this.float32[P+1]=g,this.float32[P+2]=j,this.float32[P+3]=T,c}}Yx.prototype.bytesPerElement=16,yr(Yx,"StructArrayLayout4f16");class p2 extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(c){const h=this.length;return this.resize(h+1),this.emplace(h,c)}emplace(c,h){return this.uint32[1*c+0]=h,c}}p2.prototype.bytesPerElement=4,yr(p2,"StructArrayLayout1ul4");class Gm extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,h){const g=this.length;return this.resize(g+1),this.emplace(g,c,h)}emplace(c,h,g){const j=2*c;return this.uint16[j+0]=h,this.uint16[j+1]=g,c}}Gm.prototype.bytesPerElement=4,yr(Gm,"StructArrayLayout2ui4");class S3 extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P,R,F,H,Q,se,re,le){const ue=this.length;return this.resize(ue+1),this.emplace(ue,c,h,g,j,T,P,R,F,H,Q,se,re,le)}emplace(c,h,g,j,T,P,R,F,H,Q,se,re,le,ue){const _e=20*c,Ce=10*c;return this.int16[_e+0]=h,this.int16[_e+1]=g,this.int16[_e+2]=j,this.int16[_e+3]=T,this.int16[_e+4]=P,this.float32[Ce+3]=R,this.float32[Ce+4]=F,this.float32[Ce+5]=H,this.float32[Ce+6]=Q,this.int16[_e+14]=se,this.uint32[Ce+8]=re,this.uint16[_e+18]=le,this.uint16[_e+19]=ue,c}}S3.prototype.bytesPerElement=40,yr(S3,"StructArrayLayout5i4f1i1ul2ui40");class f2 extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P,R){const F=this.length;return this.resize(F+1),this.emplace(F,c,h,g,j,T,P,R)}emplace(c,h,g,j,T,P,R,F){const H=8*c;return this.int16[H+0]=h,this.int16[H+1]=g,this.int16[H+2]=j,this.int16[H+4]=T,this.int16[H+5]=P,this.int16[H+6]=R,this.int16[H+7]=F,c}}f2.prototype.bytesPerElement=16,yr(f2,"StructArrayLayout3i2i2i16");class BP extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T){const P=this.length;return this.resize(P+1),this.emplace(P,c,h,g,j,T)}emplace(c,h,g,j,T,P){const R=4*c,F=8*c;return this.float32[R+0]=h,this.float32[R+1]=g,this.float32[R+2]=j,this.int16[F+6]=T,this.int16[F+7]=P,c}}BP.prototype.bytesPerElement=16,yr(BP,"StructArrayLayout2f1f2i16");class x2 extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P){const R=this.length;return this.resize(R+1),this.emplace(R,c,h,g,j,T,P)}emplace(c,h,g,j,T,P,R){const F=20*c,H=5*c;return this.uint8[F+0]=h,this.uint8[F+1]=g,this.float32[H+1]=j,this.float32[H+2]=T,this.float32[H+3]=P,this.float32[H+4]=R,c}}x2.prototype.bytesPerElement=20,yr(x2,"StructArrayLayout2ub4f20");class Ao extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,h,g){const j=this.length;return this.resize(j+1),this.emplace(j,c,h,g)}emplace(c,h,g,j){const T=3*c;return this.uint16[T+0]=h,this.uint16[T+1]=g,this.uint16[T+2]=j,c}}Ao.prototype.bytesPerElement=6,yr(Ao,"StructArrayLayout3ui6");class C3 extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P,R,F,H,Q,se,re,le,ue,_e,Ce,Ee,Ge,Be,nt,it){const lt=this.length;return this.resize(lt+1),this.emplace(lt,c,h,g,j,T,P,R,F,H,Q,se,re,le,ue,_e,Ce,Ee,Ge,Be,nt,it)}emplace(c,h,g,j,T,P,R,F,H,Q,se,re,le,ue,_e,Ce,Ee,Ge,Be,nt,it,lt){const Rt=30*c,jt=15*c,It=60*c;return this.int16[Rt+0]=h,this.int16[Rt+1]=g,this.int16[Rt+2]=j,this.float32[jt+2]=T,this.float32[jt+3]=P,this.uint16[Rt+8]=R,this.uint16[Rt+9]=F,this.uint32[jt+5]=H,this.uint32[jt+6]=Q,this.uint32[jt+7]=se,this.uint16[Rt+16]=re,this.uint16[Rt+17]=le,this.uint16[Rt+18]=ue,this.float32[jt+10]=_e,this.float32[jt+11]=Ce,this.uint8[It+48]=Ee,this.uint8[It+49]=Ge,this.uint8[It+50]=Be,this.uint32[jt+13]=nt,this.int16[Rt+28]=it,this.uint8[It+58]=lt,c}}C3.prototype.bytesPerElement=60,yr(C3,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class $P extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P,R,F,H,Q,se,re,le,ue,_e,Ce,Ee,Ge,Be,nt,it,lt,Rt,jt,It,Mt,Tt,rs,ls,xs,Ns,gs,Rs){const ts=this.length;return this.resize(ts+1),this.emplace(ts,c,h,g,j,T,P,R,F,H,Q,se,re,le,ue,_e,Ce,Ee,Ge,Be,nt,it,lt,Rt,jt,It,Mt,Tt,rs,ls,xs,Ns,gs,Rs)}emplace(c,h,g,j,T,P,R,F,H,Q,se,re,le,ue,_e,Ce,Ee,Ge,Be,nt,it,lt,Rt,jt,It,Mt,Tt,rs,ls,xs,Ns,gs,Rs,ts){const ws=20*c,Ts=40*c,Os=80*c;return this.float32[ws+0]=h,this.float32[ws+1]=g,this.int16[Ts+4]=j,this.int16[Ts+5]=T,this.int16[Ts+6]=P,this.int16[Ts+7]=R,this.int16[Ts+8]=F,this.int16[Ts+9]=H,this.int16[Ts+10]=Q,this.int16[Ts+11]=se,this.int16[Ts+12]=re,this.uint16[Ts+13]=le,this.uint16[Ts+14]=ue,this.uint16[Ts+15]=_e,this.uint16[Ts+16]=Ce,this.uint16[Ts+17]=Ee,this.uint16[Ts+18]=Ge,this.uint16[Ts+19]=Be,this.uint16[Ts+20]=nt,this.uint16[Ts+21]=it,this.uint16[Ts+22]=lt,this.uint16[Ts+23]=Rt,this.uint16[Ts+24]=jt,this.uint16[Ts+25]=It,this.uint16[Ts+26]=Mt,this.uint16[Ts+27]=Tt,this.uint32[ws+14]=rs,this.float32[ws+15]=ls,this.float32[ws+16]=xs,this.float32[ws+17]=Ns,this.float32[ws+18]=gs,this.uint8[Os+76]=Rs,this.uint16[Ts+39]=ts,c}}$P.prototype.bytesPerElement=80,yr($P,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class M3 extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P){const R=this.length;return this.resize(R+1),this.emplace(R,c,h,g,j,T,P)}emplace(c,h,g,j,T,P,R){const F=6*c;return this.float32[F+0]=h,this.float32[F+1]=g,this.float32[F+2]=j,this.float32[F+3]=T,this.float32[F+4]=P,this.float32[F+5]=R,c}}M3.prototype.bytesPerElement=24,yr(M3,"StructArrayLayout6f24");class J0 extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T){const P=this.length;return this.resize(P+1),this.emplace(P,c,h,g,j,T)}emplace(c,h,g,j,T,P){const R=5*c;return this.float32[R+0]=h,this.float32[R+1]=g,this.float32[R+2]=j,this.float32[R+3]=T,this.float32[R+4]=P,c}}J0.prototype.bytesPerElement=20,yr(J0,"StructArrayLayout5f20");class g2 extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P,R){const F=this.length;return this.resize(F+1),this.emplace(F,c,h,g,j,T,P,R)}emplace(c,h,g,j,T,P,R,F){const H=7*c;return this.float32[H+0]=h,this.float32[H+1]=g,this.float32[H+2]=j,this.float32[H+3]=T,this.float32[H+4]=P,this.float32[H+5]=R,this.float32[H+6]=F,c}}g2.prototype.bytesPerElement=28,yr(g2,"StructArrayLayout7f28");class qP extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P,R,F,H,Q,se){const re=this.length;return this.resize(re+1),this.emplace(re,c,h,g,j,T,P,R,F,H,Q,se)}emplace(c,h,g,j,T,P,R,F,H,Q,se,re){const le=11*c;return this.float32[le+0]=h,this.float32[le+1]=g,this.float32[le+2]=j,this.float32[le+3]=T,this.float32[le+4]=P,this.float32[le+5]=R,this.float32[le+6]=F,this.float32[le+7]=H,this.float32[le+8]=Q,this.float32[le+9]=se,this.float32[le+10]=re,c}}qP.prototype.bytesPerElement=44,yr(qP,"StructArrayLayout11f44");class UP extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P,R,F,H){const Q=this.length;return this.resize(Q+1),this.emplace(Q,c,h,g,j,T,P,R,F,H)}emplace(c,h,g,j,T,P,R,F,H,Q){const se=9*c;return this.float32[se+0]=h,this.float32[se+1]=g,this.float32[se+2]=j,this.float32[se+3]=T,this.float32[se+4]=P,this.float32[se+5]=R,this.float32[se+6]=F,this.float32[se+7]=H,this.float32[se+8]=Q,c}}UP.prototype.bytesPerElement=36,yr(UP,"StructArrayLayout9f36");class ev extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h){const g=this.length;return this.resize(g+1),this.emplace(g,c,h)}emplace(c,h,g){const j=2*c;return this.float32[j+0]=h,this.float32[j+1]=g,c}}ev.prototype.bytesPerElement=8,yr(ev,"StructArrayLayout2f8");class VP extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,h,g,j){const T=this.length;return this.resize(T+1),this.emplace(T,c,h,g,j)}emplace(c,h,g,j,T){const P=6*c;return this.uint32[3*c+0]=h,this.uint16[P+2]=g,this.uint16[P+3]=j,this.uint16[P+4]=T,c}}VP.prototype.bytesPerElement=12,yr(VP,"StructArrayLayout1ul3ui12");class tv extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c){const h=this.length;return this.resize(h+1),this.emplace(h,c)}emplace(c,h){return this.uint16[1*c+0]=h,c}}tv.prototype.bytesPerElement=2,yr(tv,"StructArrayLayout1ui2");class HP extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P,R,F,H,Q,se,re,le,ue,_e,Ce){const Ee=this.length;return this.resize(Ee+1),this.emplace(Ee,c,h,g,j,T,P,R,F,H,Q,se,re,le,ue,_e,Ce)}emplace(c,h,g,j,T,P,R,F,H,Q,se,re,le,ue,_e,Ce,Ee){const Ge=16*c;return this.float32[Ge+0]=h,this.float32[Ge+1]=g,this.float32[Ge+2]=j,this.float32[Ge+3]=T,this.float32[Ge+4]=P,this.float32[Ge+5]=R,this.float32[Ge+6]=F,this.float32[Ge+7]=H,this.float32[Ge+8]=Q,this.float32[Ge+9]=se,this.float32[Ge+10]=re,this.float32[Ge+11]=le,this.float32[Ge+12]=ue,this.float32[Ge+13]=_e,this.float32[Ge+14]=Ce,this.float32[Ge+15]=Ee,c}}HP.prototype.bytesPerElement=64,yr(HP,"StructArrayLayout16f64");class T3 extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,g,j,T,P,R){const F=this.length;return this.resize(F+1),this.emplace(F,c,h,g,j,T,P,R)}emplace(c,h,g,j,T,P,R,F){const H=10*c,Q=5*c;return this.uint16[H+0]=h,this.uint16[H+1]=g,this.uint16[H+2]=j,this.uint16[H+3]=T,this.float32[Q+2]=P,this.float32[Q+3]=R,this.float32[Q+4]=F,c}}T3.prototype.bytesPerElement=20,yr(T3,"StructArrayLayout4ui3f20");class A3 extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c){const h=this.length;return this.resize(h+1),this.emplace(h,c)}emplace(c,h){return this.int16[1*c+0]=h,c}}A3.prototype.bytesPerElement=2,yr(A3,"StructArrayLayout1i2");class E3 extends Oi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(c){const h=this.length;return this.resize(h+1),this.emplace(h,c)}emplace(c,h){return this.uint8[1*c+0]=h,c}}E3.prototype.bytesPerElement=1,yr(E3,"StructArrayLayout1ub1");class PF extends h2{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]}}PF.prototype.size=40;class GP extends S3{get(c){return new PF(this,c)}}yr(GP,"CollisionBoxArray");class IF extends h2{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(c){this._structArray.uint8[this._pos1+49]=c}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(c){this._structArray.uint8[this._pos1+50]=c}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(c){this._structArray.uint32[this._pos4+13]=c}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(c){this._structArray.uint8[this._pos1+58]=c}}IF.prototype.size=60;class LF extends C3{get(c){return new IF(this,c)}}yr(LF,"PlacedSymbolArray");class y2 extends h2{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(c){this._structArray.uint32[this._pos4+14]=c}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(c){this._structArray.float32[this._pos4+18]=c}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}get elevationFeatureIndex(){return this._structArray.uint16[this._pos2+39]}}y2.prototype.size=80;class DF extends $P{get(c){return new y2(this,c)}}yr(DF,"SymbolInstanceArray");class RF extends Jh{getoffsetX(c){return this.float32[1*c+0]}}yr(RF,"GlyphOffsetArray");class v2 extends _h{getx(c){return this.int16[2*c+0]}gety(c){return this.int16[2*c+1]}}yr(v2,"SymbolLineVertexArray");class OF extends h2{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]}}OF.prototype.size=12;class WP extends VP{get(c){return new OF(this,c)}}yr(WP,"FeatureIndexArray");class FF extends Gm{geta_centroid_pos0(c){return this.uint16[2*c+0]}geta_centroid_pos1(c){return this.uint16[2*c+1]}}yr(FF,"FillExtrusionCentroidArray");class KP extends h2{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]}}KP.prototype.size=6;class ZP extends Df{get(c){return new KP(this,c)}}yr(ZP,"FillExtrusionWallArray");const zF=la([{name:"a_pos",components:2,type:"Int16"}],4),Ipe=la([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),Lpe=la([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class ji{constructor(c=[]){this.segments=c}_prepareSegment(c,h,g,j,T){let P=this.segments[this.segments.length-1];return c>ji.MAX_VERTEX_ARRAY_LENGTH&&zr(`Max vertices per segment is ${ji.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${c}`),(!P||P.vertexLength+c>ji.MAX_VERTEX_ARRAY_LENGTH||P.sortKey!==j||T!==void 0&&P&&P.batchIndex!==void 0&&P.batchIndex!==T)&&(P={vertexOffset:h,primitiveOffset:g,vertexLength:0,primitiveLength:0},j!==void 0&&(P.sortKey=j),T!==void 0&&(P.batchIndex=T),this.segments.push(P)),P}prepareSegment(c,h,g,j,T){return this._prepareSegment(c,h.length,g.length,j,T)}get(){return this.segments}destroy(){for(const c of this.segments)for(const h in c.vaos)c.vaos[h].destroy()}static simpleSegment(c,h,g,j){return new ji([{vertexOffset:c,primitiveOffset:h,vertexLength:g,primitiveLength:j,vaos:{},sortKey:0}])}}function P3(x,c){return 256*(x=Fe(Math.floor(x),0,255))+Fe(Math.floor(c),0,255)}ji.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,yr(ji,"SegmentVector");const Dpe=la([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Rpe=la([{name:"a_pattern_b",components:4,type:"Uint16"}]),Ope=la([{name:"a_dash",components:4,type:"Uint16"}]);class _2{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(c,h,g,j){this.ids.push(YP(c)),this.positions.push(h,g,j)}eachPosition(c,h){const g=YP(c);let j=0,T=this.ids.length-1;for(;j>1;this.ids[P]>=g?T=P:j=P+1}for(;this.ids[j]===g;)h(this.positions[3*j],this.positions[3*j+1],this.positions[3*j+2]),j++}static serialize(c,h){const g=new Float64Array(c.ids),j=new Uint32Array(c.positions);return b2(g,j,0,g.length-1),h&&(h.add(g.buffer),h.add(j.buffer)),{ids:g,positions:j}}static deserialize(c){const h=new _2;let g;h.ids=c.ids,h.positions=c.positions;for(const j of h.ids)j!==g&&h.uniqueIds.push(j),g=j;return h.indexed=!0,h}}function YP(x){const c=+x;return Number.isSafeInteger(c)?c:ar(String(x))}function b2(x,c,h,g){for(;h>1];let T=h-1,P=g+1;for(;;){do T++;while(x[T]j);if(T>=P)break;em(x,T,P),em(c,3*T,3*P),em(c,3*T+1,3*P+1),em(c,3*T+2,3*P+2)}P-h`u_${T}`),this.type=g,this.context=j}setUniform(c,h,g,j,T){const P=j.constantOr(this.value);h.set(c,T,P instanceof Aa?P.toPremultipliedRenderColor(this.lutExpression&&this.lutExpression.kind==="constant"&&this.lutExpression.value==="none"?null:this.context.lut):P)}getBinding(c,h){return this.type==="color"?new zpe(c):new Cl(c)}}class ee{constructor(c,h){this.uniformNames=h.map(g=>`u_${g}`),this.pattern=null,this.patternTransition=null,this.pixelRatio=1}setConstantPatternPositions(c,h){this.pixelRatio=c.pixelRatio||1,this.pattern=c.tl.concat(c.br),this.patternTransition=h?h.tl.concat(h.br):this.pattern}setUniform(c,h,g,j,T){let P=null;T!=="u_pattern"&&T!=="u_dash"||(P=this.pattern),T==="u_pattern_b"&&(P=this.patternTransition),T==="u_pixel_ratio"&&(P=this.pixelRatio),P&&h.set(c,T,P)}getBinding(c,h){return h==="u_pattern"||h==="u_pattern_b"||h==="u_dash"?new Fpe(c):new Cl(c)}}class ne{constructor(c,h,g,j){this.expression=c,this.type=g,this.maxValue=0,this.paintVertexAttributes=h.map(T=>({name:`a_${T}`,type:"Float32",components:g==="color"?2:1,offset:0})),this.paintVertexArray=new j}populatePaintArray(c,h,g,j,T,P,R,F){const H=this.paintVertexArray.length,Q=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate(new Ka(0,{brightness:P,worldview:F}),h,{},T,j,R):this.expression.kind==="constant"&&this.expression.value,se=$(this.lutExpression,h,{},j,T,P,R,F);this.paintVertexArray.resize(c),this._setPaintValue(H,c,Q,se?null:this.context.lut)}updatePaintArray(c,h,g,j,T,P,R,F){const H=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate({zoom:0,brightness:R,worldview:F},g,j,void 0,T):this.expression.kind==="constant"&&this.expression.value,Q=$(this.lutExpression,g,j,T,void 0,R,void 0,F);this._setPaintValue(c,h,H,Q?null:this.context.lut)}_setPaintValue(c,h,g,j){if(this.type==="color"){const T=z(g.toPremultipliedRenderColor(j));for(let P=c;P`u_${R}_t`),this.type=g,this.useIntegerZoom=j,this.context=T,this.maxValue=0,this.paintVertexAttributes=h.map(R=>({name:`a_${R}`,type:"Float32",components:g==="color"?4:2,offset:0})),this.paintVertexArray=new P}populatePaintArray(c,h,g,j,T,P,R,F){const H=this.expression.evaluate(new Ka(this.context.zoom,{brightness:P,worldview:F}),h,{},T,j,R),Q=this.expression.evaluate(new Ka(this.context.zoom+1,{brightness:P,worldview:F}),h,{},T,j,R),se=$(this.lutExpression,h,{},j,T,P,R,F),re=this.paintVertexArray.length;this.paintVertexArray.resize(c),this._setPaintValue(re,c,H,Q,se?null:this.context.lut)}updatePaintArray(c,h,g,j,T,P,R,F){const H=this.expression.evaluate({zoom:this.context.zoom,brightness:R,worldview:F},g,j,void 0,T),Q=this.expression.evaluate({zoom:this.context.zoom+1,brightness:R,worldview:F},g,j,void 0,T),se=$(this.lutExpression,g,j,T,void 0,R,void 0,F);this._setPaintValue(c,h,H,Q,se?null:this.context.lut)}_setPaintValue(c,h,g,j,T){if(this.type==="color"){const P=z(g.toPremultipliedRenderColor(T)),R=z(j.toPremultipliedRenderColor(T));for(let F=c;F!0){this.binders={},this._buffers=[],this.context=h;const j=[],T=c;for(const P in c.paint._values){const R=T.paint.get(P);if(P.endsWith("-use-theme")||!g(P)||!(R instanceof X0&&o3(R.property.specification)))continue;const F=Le(P,c.type),H=R.value,Q=R.property.specification.type,se=!!R.property.useIntegerZoom,re=P==="line-dasharray"||P.endsWith("pattern"),le=T.paint.get(`${P}-use-theme`),ue=P==="line-dasharray"&&T.layout.get("line-cap").value.kind!=="constant"||le&&le.value.kind!=="constant";if(H.kind!=="constant"||ue)if(H.kind==="source"||ue||re){const _e=dt(P,Q,"source");this.binders[P]=re?new we(H,F,Q,_e,c.id):new ne(H,F,Q,_e),j.push(`/a_${P}`)}else{const _e=dt(P,Q,"composite");this.binders[P]=new de(H,F,Q,se,h,_e),j.push(`/z_${P}`)}else this.binders[P]=re?new ee(H.value,F):new K(H.value,F,Q,h),j.push(`/u_${P}`);le&&(this.binders[P].lutExpression=le.value)}this.cacheKey=j.sort().join("")}getMaxValue(c){const h=this.binders[c];return h instanceof ne||h instanceof de?h.maxValue:0}populatePaintArrays(c,h,g,j,T,P,R,F){for(const H in this.binders){const Q=this.binders[H];Q.context=this.context,(Q instanceof ne||Q instanceof de||Q instanceof we)&&Q.populatePaintArray(c,h,g,j,T,P,R,F)}}setConstantPatternPositions(c,h){for(const g in this.binders){const j=this.binders[g];j instanceof ee&&j.setConstantPatternPositions(c,h)}}getPatternTransitionVertexBuffer(c){const h=this.binders[c];return h instanceof we?h.paintTransitionVertexBuffer:null}updatePaintArrays(c,h,g,j,T,P,R,F,H,Q){let se=!1;const re=Object.keys(c),le=re.length!==0&&!F,ue=le?re:h.uniqueIds;this.context.lut=T.lut;for(const _e in this.binders){const Ce=this.binders[_e];if(Ce.context=this.context,(Ce instanceof ne||Ce instanceof de||Ce instanceof we)&&Ce.expression&&Ce.expression.kind&&Ce.expression.kind!=="constant"&&(Ce.expression.isStateDependent===!0||Ce.expression.isLightConstant===!1)){const Ee=T.paint.get(_e);Ce.expression=Ee.value;for(const Ge of ue){const Be=c[Ge.toString()];h.eachPosition(Ge,(nt,it,lt)=>{const Rt=j.feature(nt);Ce.updatePaintArray(it,lt,Rt,Be,P,R,H,Q)})}if(!le)for(const Ge of g.uniqueIds){const Be=c[Ge.toString()];g.eachPosition(Ge,(nt,it,lt)=>{const Rt=j.feature(nt);Ce.updatePaintArray(it,lt,Rt,Be,P,R,H,Q)})}se=!0}}return se}defines(){const c=[];for(const h in this.binders){const g=this.binders[h];(g instanceof K||g instanceof ee)&&c.push(...g.uniformNames.map(j=>`#define HAS_UNIFORM_${j}`))}return c}getPaintVertexBuffers(){return this._buffers}getUniforms(c){const h=[];for(const g in this.binders){const j=this.binders[g];if(j instanceof K||j instanceof ee||j instanceof de)for(const T of j.uniformNames)h.push({name:T,property:g,binding:j.getBinding(c,T)})}return h}setUniforms(c,h,g,j,T){for(const{name:P,property:R,binding:F}of g)this.binders[R].setUniform(c,F,T,j.get(R),P)}updatePaintBuffers(){this._buffers=[];for(const c in this.binders){const h=this.binders[c];(h instanceof ne||h instanceof de||h instanceof we)&&h.paintVertexBuffer&&this._buffers.push(h.paintVertexBuffer),h instanceof we&&h.paintTransitionVertexBuffer&&this._buffers.push(h.paintTransitionVertexBuffer)}}upload(c){for(const h in this.binders){const g=this.binders[h];(g instanceof ne||g instanceof de||g instanceof we)&&g.upload(c)}this.updatePaintBuffers()}destroy(){for(const c in this.binders){const h=this.binders[c];(h instanceof ne||h instanceof de||h instanceof we)&&h.destroy()}}}class Ae{constructor(c,h,g=()=>!0){this.programConfigurations={};for(const j of c)this.programConfigurations[j.id]=new be(j,h,g);this.needsUpload=!1,this._featureMap=new _2,this._featureMapWithoutIds=new _2,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(c,h,g,j,T,P,R,F,H){for(const Q in this.programConfigurations)this.programConfigurations[Q].populatePaintArrays(c,h,j,T,P,R,F,H);h.id!==void 0?this._featureMap.add(h.id,g,this._bufferOffset,c):(this._featureMapWithoutIds.add(this._idlessCounter,g,this._bufferOffset,c),this._idlessCounter+=1),this._bufferOffset=c,this.needsUpload=!0}updatePaintArrays(c,h,g,j,T,P,R,F){for(const H of g)this.needsUpload=this.programConfigurations[H.id].updatePaintArrays(c,this._featureMap,this._featureMapWithoutIds,h,H,j,T,P,R||0,F)||this.needsUpload}get(c){return this.programConfigurations[c]}upload(c){if(this.needsUpload){for(const h in this.programConfigurations)this.programConfigurations[h].upload(c);this.needsUpload=!1}}destroy(){for(const c in this.programConfigurations)this.programConfigurations[c].destroy()}}const ze={"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 Le(x,c){return ze[x]||[x.replace(`${c}-`,"").replace(/-/g,"_")]}const rt={"line-pattern":{source:Rf,composite:Rf},"fill-pattern":{source:Rf,composite:Rf},"fill-extrusion-pattern":{source:Rf,composite:Rf},"line-dasharray":{source:e_,composite:e_}},st={color:{source:ev,composite:Yx},number:{source:Jh,composite:ev}};function dt(x,c,h){const g=rt[x];return g&&g[h]||st[c][h]}yr(K,"ConstantBinder"),yr(ee,"PatternConstantBinder"),yr(ne,"SourceExpressionBinder"),yr(we,"PatternCompositeBinder"),yr(de,"CompositeExpressionBinder"),yr(be,"ProgramConfiguration",{omit:["_buffers"]}),yr(Ae,"ProgramConfigurationSet");const pt=sr/Math.PI/2,at=64,Bt=[at,32,16],wt=-pt,Ft=pt;function ft(x,c,h,g=pt){return h=Zr(h),[x*Math.sin(h)*g,-c*g,x*Math.cos(h)*g]}function _t(x,c,h){return ft(Math.cos(Zr(x)),Math.sin(Zr(x)),c,h)}const Et=63710088e-1,Kt=2*Math.PI*Et;class qt{constructor(c,h){if(isNaN(c)||isNaN(h))throw new Error(`Invalid LngLat object: (${c}, ${h})`);if(this.lng=+c,this.lat=+h,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new qt(yt(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(c){const h=Math.PI/180,g=this.lat*h,j=c.lat*h,T=Math.sin(g)*Math.sin(j)+Math.cos(g)*Math.cos(j)*Math.cos((c.lng-this.lng)*h);return Et*Math.acos(Math.min(T,1))}toBounds(c=0){const h=360*c/40075017,g=h/Math.cos(Math.PI/180*this.lat);return new ns({lng:this.lng-g,lat:this.lat-h},{lng:this.lng+g,lat:this.lat+h})}toEcef(c){return _t(this.lat,this.lng,pt+c*pt/Et)}static convert(c){if(c instanceof qt)return c;if(Array.isArray(c)&&(c.length===2||c.length===3))return new qt(Number(c[0]),Number(c[1]));if(!Array.isArray(c)&&typeof c=="object"&&c!==null)return new qt(Number("lng"in c?c.lng:c.lon),Number(c.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}class ns{constructor(c,h){c&&(h?this.setSouthWest(c).setNorthEast(h):Array.isArray(c)&&c.length===4?this.setSouthWest([c[0],c[1]]).setNorthEast([c[2],c[3]]):this.setSouthWest(c[0]).setNorthEast(c[1]))}setNorthEast(c){return this._ne=c instanceof qt?new qt(c.lng,c.lat):qt.convert(c),this}setSouthWest(c){return this._sw=c instanceof qt?new qt(c.lng,c.lat):qt.convert(c),this}extend(c){const h=this._sw,g=this._ne;let j,T;if(c instanceof qt)j=c,T=c;else{if(!(c instanceof ns))return Array.isArray(c)?c.length===4||c.every(Array.isArray)?this.extend(ns.convert(c)):this.extend(qt.convert(c)):typeof c=="object"&&c!==null&&c.hasOwnProperty("lat")&&(c.hasOwnProperty("lon")||c.hasOwnProperty("lng"))?this.extend(qt.convert(c)):this;if(j=c._sw,T=c._ne,!j||!T)return this}return h||g?(h.lng=Math.min(j.lng,h.lng),h.lat=Math.min(j.lat,h.lat),g.lng=Math.max(T.lng,g.lng),g.lat=Math.max(T.lat,g.lat)):(this._sw=new qt(j.lng,j.lat),this._ne=new qt(T.lng,T.lat)),this}getCenter(){return new qt((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 qt(this.getWest(),this.getNorth())}getSouthEast(){return new qt(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(c){const{lng:h,lat:g}=qt.convert(c);let j=this._sw.lng<=h&&h<=this._ne.lng;return this._sw.lng>this._ne.lng&&(j=this._sw.lng>=h&&h>=this._ne.lng),this._sw.lat<=g&&g<=this._ne.lat&&j}static convert(c){if(c)return c instanceof ns?c:new ns(c)}}function Jt(x){return Kt*Math.cos(x*Math.PI/180)}function Cs(x){return(180+x)/360}function Ls(x){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+x*Math.PI/360)))/360}function Zt(x,c){return x/Jt(c)}function Ht(x){return 360*x-180}function ss(x){return 360/Math.PI*Math.atan(Math.exp((180-360*x)*Math.PI/180))-90}function is(x,c){return x*Jt(ss(c))}const hs=85.051129;function Qs(x){return Math.cos(Zr(Fe(x,-85.051129,hs)))}function Ws(x,c){const h=Fe(c,0,25.5),g=Math.pow(2,h);return Qs(x)*Kt/(512*g)}function Ks(x){return 1/Math.cos(x*Math.PI/180)}function As(x,c=0){const h=Math.exp(Math.PI*(1-(x.y+c/sr)/(1<=F?(Pr(x,c,h,H,Q,T,se,R,F),Pr(x,H,Q,g,j,se,P,R,F)):x.push(P)}function pr(x,c,h){let g=x[0],j=g.x,T=g.y;c(g);const P=[g];for(let R=1;Rx.x+1||gx.y+1)&&zr("Geometry exceeds allowed extent, reduce your vector tile buffer size"),x}function Vr(x,c,h){const g=x.loadGeometry(),j=x.extent,T=sr/j;if(c&&h&&h.projection.isReprojectedInTileSpace){const P=1<{const le=Ht((c.x+re.x/j)/P),ue=ss((c.y+re.y/j)/P),_e=Q.project(le,ue);re.x=(_e.x*R-F)*j,re.y=(_e.y*R-H)*j};for(let re=0;re=j||ue.y<0||ue.y>=j||(se(ue),le.push(ue));g[re]=le}}for(const P of g)for(const R of P)Un(R,T);return g}function Vn(x,c){return{type:x.type,id:x.id,properties:x.properties,geometry:c?Vr(x):[]}}class pn{constructor(c,h,g,j,T){this.properties={},this.extent=g,this.type=0,this.id=void 0,this._pbf=c,this._geometry=-1,this._keys=j,this._values=T,c.readFields(Ea,this,h)}loadGeometry(){const c=this._pbf;c.pos=this._geometry;const h=c.readVarint()+c.pos,g=[];let j,T=1,P=0,R=0,F=0;for(;c.pos>3}if(P--,T===1||T===2)R+=c.readSVarint(),F+=c.readSVarint(),T===1&&(j&&g.push(j),j=[]),j&&j.push(new as(R,F));else{if(T!==7)throw new Error(`unknown command ${T}`);j&&j.push(j[0].clone())}}return j&&g.push(j),g}bbox(){const c=this._pbf;c.pos=this._geometry;const h=c.readVarint()+c.pos;let g=1,j=0,T=0,P=0,R=1/0,F=-1/0,H=1/0,Q=-1/0;for(;c.pos>3}if(j--,g===1||g===2)T+=c.readSVarint(),P+=c.readSVarint(),TF&&(F=T),PQ&&(Q=P);else if(g!==7)throw new Error(`unknown command ${g}`)}return[R,H,F,Q]}toGeoJSON(c,h,g){const j=this.extent*Math.pow(2,g),T=this.extent*c,P=this.extent*h,R=this.loadGeometry();function F(re){return[360*(re.x+T)/j-180,360/Math.PI*Math.atan(Math.exp((1-2*(re.y+P)/j)*Math.PI))-90]}function H(re){return re.map(F)}let Q;if(this.type===1){const re=[];for(const ue of R)re.push(ue[0]);const le=H(re);Q=re.length===1?{type:"Point",coordinates:le[0]}:{type:"MultiPoint",coordinates:le}}else if(this.type===2){const re=R.map(H);Q=re.length===1?{type:"LineString",coordinates:re[0]}:{type:"MultiLineString",coordinates:re}}else{if(this.type!==3)throw new Error("unknown feature type");{const re=function(ue){const _e=ue.length;if(_e<=1)return[ue];const Ce=[];let Ee,Ge;for(let Be=0;Be<_e;Be++){const nt=pi(ue[Be]);nt!==0&&(Ge===void 0&&(Ge=nt<0),Ge===nt<0?(Ee&&Ce.push(Ee),Ee=[ue[Be]]):Ee&&Ee.push(ue[Be]))}return Ee&&Ce.push(Ee),Ce}(R),le=[];for(const ue of re)le.push(ue.map(H));Q=le.length===1?{type:"Polygon",coordinates:le[0]}:{type:"MultiPolygon",coordinates:le}}}const se={type:"Feature",geometry:Q,properties:this.properties};return this.id!=null&&(se.id=this.id),se}}function Ea(x,c,h){x===1?c.id=h.readVarint():x===2?function(g,j){const T=g.readVarint()+g.pos;for(;g.pos=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[c];const h=this._pbf.readVarint()+this._pbf.pos;return new pn(this._pbf,h,this.extent,this._keys,this._values)}}function Ni(x,c,h){x===15?c.version=h.readVarint():x===1?c.name=h.readString():x===5?c.extent=h.readVarint():x===2?c._features.push(h.pos):x===3?c._keys.push(h.readString()):x===4&&c._values.push(function(g){let j=null;const T=g.readVarint()+g.pos;for(;g.pos>3;j=P===1?g.readString():P===2?g.readFloat():P===3?g.readDouble():P===4?g.readVarint64():P===5?g.readVarint():P===6?g.readSVarint():P===7?g.readBoolean():null}if(j==null)throw new Error("unknown feature value");return j}(h))}class $a{constructor(c,h){this.layers=c.readFields(On,{},h)}}function On(x,c,h){if(x===3){const g=new Wi(h,h.readVarint()+h.pos);g.length&&(c[g.name]=g)}}const Fn="3d_elevation_id",ki="level";class Ji{constructor(){this._valid=!1}reset(c){return this.feature=c,this._valid=!0,this._geometry=c.loadGeometry(),this._geometry.length!==0&&this._geometry[0].length!==0||(this._valid=!1),this}geometry(c,h){return this._valid&&c(h(this._geometry)),this}require(c,h,g){return this.get(c,!0,h,g)}optional(c,h,g){return this.get(c,!1,h,g)}success(){return this._valid}get(c,h,g,j){const T=this.feature.properties.hasOwnProperty(c)?+this.feature.properties[c]:void 0;return this._valid&&T!==void 0&&!Number.isNaN(T)?g(j?j(T):T):h&&(this._valid=!1),this}}class qa{constructor(c,h){this.featureFunc=c,this.vertexFunc=h}parseFeature(c,h,g){return this.featureFunc(c,h,g)}parseVertex(c,h,g){return this.vertexFunc(c,h,g)}}const Cn=new qa((x,c,h)=>x.reset(c).require(Fn,g=>{h.id=g}).optional("fixed_height_relative",g=>{h.constantHeight=g},fi.decodeRelativeHeight).geometry(g=>{h.bounds=g},qE).success(),(x,c,h)=>x.reset(c).require(Fn,g=>{h.id=g}).require("elevation_idx",g=>{h.idx=g}).require("extent",g=>{h.extent=g}).require("height_relative",g=>{h.height=g},fi.decodeRelativeHeight).geometry(g=>{h.position=g},fi.getPoint).success()),Ui=new qa((x,c,h)=>x.reset(c).require(Fn,g=>{h.id=g}).optional("fixed_height",g=>{h.constantHeight=g},fi.decodeMetricHeight).geometry(g=>{h.bounds=g},qE).success(),(x,c,h)=>x.reset(c).require(Fn,g=>{h.id=g}).require("elevation_idx",g=>{h.idx=g}).require("extent",g=>{h.extent=g}).require("height",g=>{h.height=g},fi.decodeMetricHeight).geometry(g=>{h.position=g},fi.getPoint).success());class fi{static getPoint(c){return Es(c[0][0].x,c[0][0].y)}static decodeRelativeHeight(c){return 1e-4*c*5}static decodeMetricHeight(c){return 1e-4*c}static getVersionSchema(c){return c?c==="1.0.1"?Ui:void 0:Cn}static parse(c){const h=[],g=[],j=c.length,T=new Ji;for(let P=0;P=0);if(T===0)return 0;T!==c.length&&(h=!1)}return h?2:1}function Ml(x,c){for(const h of x.projections){const g=ul(c,x.points[0],h.axis);if(h.projection[1]g[1])return 0}return 1}function Sc(x,c){let h=0;const g=[0,0,0,0];for(let j=0;j=0&&h++;return h}class bh{constructor(c,h){this.points=c||new Array(8).fill([0,0,0]),this.planes=h||new Array(6).fill([0,0,0,0]),this.bounds=ei.fromPoints(this.points),this.projections=[],this.frustumEdges=[Te([],this.points[2],this.points[3]),Te([],this.points[0],this.points[3]),Te([],this.points[4],this.points[0]),Te([],this.points[5],this.points[1]),Te([],this.points[6],this.points[2]),Te([],this.points[7],this.points[3])];for(const g of this.frustumEdges){const j=[0,-g[2],g[1]],T=[g[2],0,-g[0]];this.projections.push({axis:j,projection:ul(this.points,this.points[0],j)}),this.projections.push({axis:T,projection:ul(this.points,this.points[0],T)})}}static fromInvProjectionMatrix(c,h,g,j){const T=Math.pow(2,g),P=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(H=>{const Q=mt([],H,c),se=1/Q[3]/h*T;return(re=Q)[0]=(le=Q)[0]*(ue=[se,se,j?1/Q[3]:se,se])[0],re[1]=le[1]*ue[1],re[2]=le[2]*ue[2],re[3]=le[3]*ue[3],re;var re,le,ue}),R=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(H=>{const Q=Ne([],Ie([],Te([],P[H[0]],P[H[1]]),Te([],P[H[2]],P[H[1]]))),se=-Ue(Q,P[H[1]]);return Q.concat(se)}),F=[];for(let H=0;HH[1]||H[0]>F[1])return 0}return 1}containsPoint(c){for(const h of this.planes){const g=h[3];if(Ue([h[0],h[1],h[2]],c)+g<0)return!1}return!0}}class ei{static fromPoints(c){const h=[1/0,1/0,1/0],g=[-1/0,-1/0,-1/0];for(const j of c)he(h,h,j),ge(g,g,j);return new ei(h,g)}static fromTileIdAndHeight(c,h,g){const j=1<c.max[h]||c.min[h]>this.max[h])return!1;return!0}intersectsAabbXY(c){return!(this.min[0]>c.max[0]||c.min[0]>this.max[0]||this.min[1]>c.max[1]||c.min[1]>this.max[1])}encapsulate(c){for(let h=0;h<3;h++)this.min[h]=Math.min(this.min[h],c.min[h]),this.max[h]=Math.max(this.max[h],c.max[h])}encapsulatePoint(c){for(let h=0;h<3;h++)this.min[h]=Math.min(this.min[h],c[h]),this.max[h]=Math.max(this.max[h],c[h])}closestPoint(c){return[Math.max(Math.min(this.max[0],c[0]),this.min[0]),Math.max(Math.min(this.max[1],c[1]),this.min[1]),Math.max(Math.min(this.max[2],c[2]),this.min[2])]}}yr(ei,"Aabb");class tm{constructor(c,h){this.feature=c,this.metersToTile=h,this.index=0}get(){const c=this.feature.vertices[this.index],h=this.feature.vertexProps[this.index].dir,g=h[1],j=-h[0],T=(c.extent+1)*this.metersToTile;return[new as(Math.trunc(c.position[0]+g*T),Math.trunc(c.position[1]+j*T)),new as(Math.trunc(c.position[0]-g*T),Math.trunc(c.position[1]-j*T))]}next(){this.index++}valid(){return this.index{return R.a0?je(F,F,1/H):ae(F,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(c){if(this.edges.length===0)return;let h=0,g=Number.POSITIVE_INFINITY,j=0;const[T,P,R,F,H,Q,se]=this._tmpVec2;fr(se,c.x,c.y);const re=new Vo(se,null);for(let le=0;le0?$r(F,R)/nt:0,lt=Fe(it,0,1),Rt=Math.abs((it-lt)*this.edgeProps[le].len);mr(H,se,Ce),fr(Q,_e[1],-_e[0]);const jt=Rt+Math.abs($r(H,Q));jt=0;--P){const R=this.edges[P].a,F=this.edges[P].b,{position:H,height:Q,extent:se}=this.vertices[R],{position:re,height:le,extent:ue}=this.vertices[F],_e=this.vertexProps[R].dir,Ce=this.vertexProps[F].dir;if(ae(h,H[0]/c,H[1]/c,Q),ae(g,re[0]/c,re[1]/c,le),ae(j,_e[1],-_e[0],0),je(j,j,se),ae(T,Ce[1],-Ce[0],0),je(T,T,ue),this.distSqLines(ie(h[0]+.5*j[0],h[1]+.5*j[1],h[2]+.5*j[2]),ie(g[0]-.5*T[0],g[1]-.5*T[1],g[2]-.5*T[2]),ie(h[0]-.5*j[0],h[1]-.5*j[1],h[2]-.5*j[2]),ie(g[0]+.5*T[0],g[1]+.5*T[1],g[2]+.5*T[2]))<=.0025000000000000005)continue;const Ee=this.vertices.length,Ge=Hs(Lt(),H,re);this.vertices.push({position:an(Ge,Ge,.5),height:.5*(Q+le),extent:.5*(se+ue)});const Be=Hs(Lt(),_e,Ce);this.vertexProps.push({dir:Fr(Be,Be)}),this.edges.splice(P,1),this.edgeProps.splice(P,1),this.edges.push({a:R,b:Ee}),this.edges.push({a:Ee,b:F});const nt=mr(Lt(),this.vertices[Ee].position,H),it=Cr(nt),lt={vec:nt,dir:an(Lt(),nt,1/it),len:it};this.edgeProps.push(lt),this.edgeProps.push(lt)}}distSqLines(c,h,g,j){const T=me(J(),h,c),P=me(J(),j,g),R=me(J(),c,g),F=Ue(T,T),H=Ue(T,P),Q=Ue(T,R),se=Ue(P,P),re=Ue(P,R),le=F*se-H*H;if(le===0)return ke(ye(T,g,j,Ue(R,P)/Ue(P,P)),c);const ue=(F*re-H*Q)/le;return ke(ye(T,c,h,(H*re-Q*se)/le),ye(P,g,j,ue))}}class Ci{static parseFrom(c,h){const g=fi.parse(c);if(!g)return[];let{vertices:j,features:T}=g;const P=1/As(h);T.sort((Q,se)=>Q.id-se.id),j.sort((Q,se)=>Q.id-se.id||Q.idx-se.idx),j=j.filter((Q,se,re)=>se===re.findIndex(le=>le.id===Q.id&&le.idx===Q.idx));const R=new Array;let F=0;const H=j.length;for(const Q of T){if(Q.constantHeight){R.push(new sm(Q.id,Q.bounds,Q.constantHeight));continue}for(;F!==H&&j[F].idj.id===g)}}class Pi{constructor(c,h){this.zScale=1,this.xOffset=0,this.yOffset=0,c.equals(h)||(this.zScale=Math.pow(2,h.z-c.z),this.xOffset=(c.x*this.zScale-h.x)*sr,this.yOffset=(c.y*this.zScale-h.y)*sr)}constantElevation(c,h){if(c.constantHeight!=null)return this.computeBiasedHeight(c.constantHeight,h)}pointElevation(c,h,g){const j=this.constantElevation(h,g);return j??(c.x=c.x*this.zScale+this.xOffset,c.y=c.y*this.zScale+this.yOffset,this.computeBiasedHeight(h.pointElevation(c),g))}computeBiasedHeight(c,h){return h<=0?c:c+h*Xe(0,h,c>=0?c:Math.abs(.5*c))}}yr(sm,"ElevationFeature");class ci{constructor(c){this.zoom=c.zoom,this.overscaling=c.overscaling,this.layers=c.layers,this.layerIds=this.layers.map(h=>h.fqid),this.index=c.index,this.hasPattern=!1,this.projection=c.projection,this.layoutVertexArray=new _h,this.indexArray=new Ao,this.segments=new ji,this.programConfigurations=new Ae(c.layers,{zoom:c.zoom,lut:c.lut}),this.stateDependentLayerIds=this.layers.filter(h=>h.isStateDependent()).map(h=>h.id),this.elevationMode=this.layers[0].layout.get("circle-elevation-reference"),this.hasElevation=!1,this.elevationMode!=="none"&&(this.elevatedLayoutVertexArray=new Jh),this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,h){}updateAppearances(c,h,g,j){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(c,h,g,j){const T=this.layers[0],P=[];let R=null;T.type==="circle"&&(R=T.layout.get("circle-sort-key"));for(const{feature:H,id:Q,index:se,sourceLayerIndex:re}of c){const le=this.layers[0]._featureFilter.needGeometry,ue=Vn(H,le);if(!this.layers[0]._featureFilter.filter(new Ka(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),ue,g))continue;const _e=R?R.evaluate(ue,{},g):void 0,Ce={id:Q,properties:H.properties,type:H.type,sourceLayerIndex:re,index:se,geometry:le?ue.geometry:Vr(H,g,j),patterns:{},sortKey:_e};P.push(Ce)}R&&P.sort((H,Q)=>H.sortKey-Q.sortKey);let F=null;j.projection.name==="globe"&&(this.globeExtVertexArray=new k3,F=j.projection);for(const H of P){const{geometry:Q,index:se,sourceLayerIndex:re}=H,le=c[se].feature;this.addFeature(H,Q,se,h.availableImages,g,F,h.brightness,h.elevationFeatures),h.featureIndex.insert(le,Q,se,re,this.index)}this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}update(c,h,g,j,T,P,R){this.programConfigurations.updatePaintArrays(c,h,T,g,j,P,R,this.worldview)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(c){this.uploaded||(this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,zF.members),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=c.createVertexBuffer(this.globeExtVertexArray,Lpe.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=c.createVertexBuffer(this.elevatedLayoutVertexArray,Ipe.members))),this.programConfigurations.upload(c),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy())}addFeature(c,h,g,j,T,P,R,F){let H;this.elevationMode!=="none"&&(H=Ci.getElevationFeature(c,F));for(const Q of h)for(const se of Q){const re=se.x,le=se.y;if(re<0||re>=sr||le<0||le>=sr)continue;if(P){const Ce=P.projectTilePoint(re,le,T),Ee=P.upVector(T,re,le);this.addGlobeExtVertex(Ce,Ee),this.addGlobeExtVertex(Ce,Ee),this.addGlobeExtVertex(Ce,Ee),this.addGlobeExtVertex(Ce,Ee)}const ue=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,c.sortKey),_e=ue.vertexLength;if(this.addCircleVertex(re,le,-1,-1),this.addCircleVertex(re,le,1,-1),this.addCircleVertex(re,le,1,1),this.addCircleVertex(re,le,-1,1),this.elevationMode!=="none"){const Ce=H?H.pointElevation(new as(re,le)):0;this.hasElevation=this.hasElevation||Ce!==0;for(let Ee=0;Ee<4;Ee++)this.elevatedLayoutVertexArray.emplaceBack(Ce)}this.indexArray.emplaceBack(_e,_e+1,_e+2),this.indexArray.emplaceBack(_e,_e+2,_e+3),ue.vertexLength+=4,ue.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,c,g,{},j,T,R,void 0,this.worldview)}addCircleVertex(c,h,g,j){this.layoutVertexArray.emplaceBack(2*c+(g+1)/2,2*h+(j+1)/2)}addGlobeExtVertex(c,h){this.globeExtVertexArray.emplaceBack(c.x,c.y,c.z,h[0]*16384,h[1]*16384,h[2]*16384)}}function Fo(x,c){for(let h=0;h1){if(uy(x,c))return!0;for(let g=0;g1?h:h.sub(c)._mult(j)._add(c))}function s_(x,c){let h,g,j,T=!1;for(let P=0;Pc.y!=j.y>c.y&&c.x<(j.x-g.x)*(c.y-g.y)/(j.y-g.y)+g.x&&(T=!T)}return T}function Zu(x,c){let h=!1;for(let g=0,j=x.length-1;gc.y!=P.y>c.y&&c.x<(P.x-T.x)*(c.y-T.y)/(P.y-T.y)+T.x&&(h=!h)}return h}function hy(x,c,h,g,j){for(const P of x)if(c<=P.x&&h<=P.y&&g>=P.x&&j>=P.y)return!0;const T=[new as(c,h),new as(c,j),new as(g,j),new as(g,h)];if(x.length>2){for(const P of T)if(Zu(x,P))return!0}for(let P=0;Pj.x&&c.x>j.x||x.yj.y&&c.y>j.y)return!1;const T=hn(x,c,h[0]);return T!==hn(x,c,h[1])||T!==hn(x,c,h[2])||T!==hn(x,c,h[3])}function py(x,c,h,g,j,T){let P=c.y-x.y,R=x.x-c.x;if(T=T||0){const F=P*P+R*R;if(F===0)return!0;const H=Math.sqrt(F);P/=H,R/=H}return!((h.x-x.x)*P+(h.y-x.y)*R-T<0||(g.x-x.x)*P+(g.y-x.y)*R-T<0||(j.x-x.x)*P+(j.y-x.y)*R-T<0)}function L3(x,c,h,g,j,T,P){return!(py(x,c,g,j,T,P)||py(c,h,g,j,T,P)||py(h,x,g,j,T,P)||py(g,j,x,c,h,P)||py(j,T,x,c,h,P)||py(T,g,x,c,h,P))}function r_(x,c,h){const g=c.paint.get(x).value;return g.kind==="constant"?g.value:h.programConfigurations.get(c.id).getMaxValue(x)}function BF(x){return Math.sqrt(x[0]*x[0]+x[1]*x[1])}function QCe(x,c,h,g,j){if(!c[0]&&!c[1])return x;const T=as.convert(c)._mult(j);h==="viewport"&&T._rotate(-g);const P=[];for(let R=0;R>h&&c.y===this.y>>h}url(c,h){const g=function(T,P,R){const F=2**R,H=2*Math.PI*6378137,Q=H*(T/F-.5),se=H*(.5-(P+1)/F);return`${Q},${se},${Q+H/F},${se+H/F}`}(this.x,this.y,this.z),j=function(T,P,R){let F,H="";for(let Q=T;Q>0;Q--)F=1<this.canonical.z?new ku(c,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new ku(c,this.wrap,c,this.canonical.x>>h,this.canonical.y>>h)}calculateScaledKey(c,h=!0){if(this.overscaledZ===c&&h)return this.key;if(c>this.canonical.z)return D3(this.wrap*+h,c,this.canonical.z,this.canonical.x,this.canonical.y);{const g=this.canonical.z-c;return D3(this.wrap*+h,c,c,this.canonical.x>>g,this.canonical.y>>g)}}isChildOf(c){if(c.wrap!==this.wrap)return!1;const h=this.canonical.z-c.canonical.z;return c.overscaledZ===0||c.overscaledZ>h&&c.canonical.y===this.canonical.y>>h}children(c){if(this.overscaledZ>=c)return[new ku(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const h=this.canonical.z+1,g=2*this.canonical.x,j=2*this.canonical.y;return[new ku(h,this.wrap,h,g,j),new ku(h,this.wrap,h,g+1,j),new ku(h,this.wrap,h,g,j+1),new ku(h,this.wrap,h,g+1,j+1)]}isLessThan(c){return this.wrapc.wrap)&&(this.overscaledZc.overscaledZ)&&(this.canonical.xc.canonical.x)&&this.canonical.y{let c=x.canonical.x-1,h=x.wrap;return c<0&&(c=(1<{let c=x.canonical.x+1,h=x.wrap;return c===1<new ku(x.overscaledZ,x.wrap,x.canonical.z,x.canonical.x,(x.canonical.y===0?1<new ku(x.overscaledZ,x.wrap,x.canonical.z,x.canonical.x,x.canonical.y===(1<1?null:function(g,j,T,P){const R=Math.sin(T);return g*(Math.sin((1-P)*T)/R)+j*(Math.sin(P*T)/R)}(x.a[c],x.b[c],x.angle,Fe(h,0,1))+x.center[c]}function fy(x){if(x.z<=1)return Qct[x.z+2*x.y+x.x];const c=$pe(UF(x));return ei.fromPoints(c)}function nv(x,c,h){return je(x,x,1-h),qe(x,x,c,h)}function a3e(x,c){const h=av(c.zoom);if(h===0)return fy(x);const g=UF(x),j=$pe(g),T=Cs(g.getWest())*c.worldSize,P=Cs(g.getEast())*c.worldSize,R=Ls(g.getNorth())*c.worldSize,F=Ls(g.getSouth())*c.worldSize,H=[T,R,0],Q=[P,R,0],se=[T,F,0],re=[P,F,0],le=S([],c.globeMatrix);return ct(H,H,le),ct(Q,Q,le),ct(se,se,le),ct(re,re,le),j[0]=nv(j[0],se,h),j[1]=nv(j[1],re,h),j[2]=nv(j[2],Q,h),j[3]=nv(j[3],H,h),ei.fromPoints(j)}function i3e(x,c,h){for(const g of x)ct(g,g,c),je(g,g,h)}function o3e(x,c,h,g){const j=c/x.worldSize,T=x.globeMatrix;if(h.z<=1){const It=fy(h).getCorners();return i3e(It,T,j),ei.fromPoints(It)}const P=UF(h,g),R=$pe(P,pt+qF(x._tileCoverLift));i3e(R,T,j);const F=Number.MAX_VALUE,H=[-F,-F,-F],Q=[F,F,F];if(P.contains(x.center)){for(const Tt of R)he(Q,Q,Tt),ge(H,H,Tt);H[2]=0;const It=x.point,Mt=[It.x*j,It.y*j,0];return he(Q,Q,Mt),ge(H,H,Mt),new ei(Q,H)}if(x._tileCoverLift>0){for(const It of R)he(Q,Q,It),ge(H,H,It);return new ei(Q,H)}const se=[T[12]*j,T[13]*j,T[14]*j],re=P.getCenter(),le=Fe(x.center.lat,-85.051129,hs),ue=Fe(re.lat,-85.051129,hs),_e=Cs(x.center.lng),Ce=Ls(le);let Ee=_e-Cs(re.lng);const Ge=Ce-Ls(ue);Ee>.5?Ee-=1:Ee<-.5&&(Ee+=1);let Be=0;Math.abs(Ee)>Math.abs(Ge)?Be=Ee>=0?1:3:(Be=Ge>=0?0:2,qe(se,se,[T[4]*j,T[5]*j,T[6]*j],-Math.sin(Zr(Ge>=0?P.getSouth():P.getNorth()))*pt));const nt=R[Be],it=R[(Be+1)%4],lt=new Jct(nt,it,se),Rt=[Bpe(lt,0)||nt[0],Bpe(lt,1)||nt[1],Bpe(lt,2)||nt[2]],jt=av(x.zoom);if(jt>0){const It=function({x:Tt,y:rs,z:ls},xs,Ns,gs,Rs){const ts=1/(1<.5?xr=-1:er<-.5&&(xr=1),ws=((ws+xr)*xs-(gs*=xs))*Ns+gs,Ts=((Ts+xr)*xs-gs)*Ns+gs,Os=(Os*xs-(Rs*=xs))*Ns+Rs,Zs=(Zs*xs-Rs)*Ns+Rs,[[ws,Zs,0],[Ts,Zs,0],[Ts,Os,0],[ws,Os,0]]}(h,c,x._pixelsPerMercatorPixel,_e,Ce);for(let Tt=0;TtMath.PI/2*1.01}const h3e=Zr(85),edt=Math.cos(h3e),tdt=Math.sin(h3e),sdt=b(),m3e=x=>{const c=[];return x.paint.get("circle-pitch-alignment")==="map"&&c.push("PITCH_WITH_MAP"),x.paint.get("circle-pitch-scale")==="map"&&c.push("SCALE_WITH_MAP"),c};function p3e(x,c,h,g,j,T,P,R,F){if(T&&x.queryGeometry.isAboveHorizon)return!1;T&&(F*=x.pixelToTileUnitsFactor);const H=x.tileID.canonical,Q=h.projection.upVectorScale(H,h.center.lat,h.worldSize).metersToTile;for(const se of c)for(const re of se){const le=re.add(R),ue=j&&h.elevation?h.elevation.exaggeration()*j.getElevationAt(le.x,le.y,!0):0,_e=h.projection.projectTilePoint(le.x,le.y,H);if(ue>0){const Be=h.projection.upVector(H,le.x,le.y);_e.x+=Be[0]*Q*ue,_e.y+=Be[1]*Q*ue,_e.z+=Be[2]*Q*ue}const Ce=T?le:rdt(_e.x,_e.y,_e.z,g),Ee=T?x.tilespaceRays.map(Be=>adt(Be,ue)):x.queryGeometry.screenGeometry,Ge=mt([],[_e.x,_e.y,_e.z,1],g);if(!P&&T?F*=Ge[3]/h.cameraToCenterDistance:P&&!T&&(F*=h.cameraToCenterDistance/Ge[3]),T){const Be=ss((re.y/sr+H.y)/(1<x.width||j.height>x.height||h.x>x.width-j.width||h.y>x.height-j.height)throw new RangeError("out of range source coordinates for image copy");if(j.width>c.width||j.height>c.height||g.x>c.width-j.width||g.y>c.height-j.height)throw new RangeError("out of range destination coordinates for image copy");const F=x.data,H=c.data,Q=T===4&&R;for(let se=0;se{c[x.evaluationKey]=F;const H=x.expression.evaluate(c),Q=H?H.toNonPremultipliedRenderColor(null):null;Q&&(j.data[P+R+0]=Math.floor(255*Q.r),j.data[P+R+1]=Math.floor(255*Q.g),j.data[P+R+2]=Math.floor(255*Q.b),j.data[P+R+3]=Math.floor(255*Q.a))};if(x.clips)for(let P=0,R=0;P80*h){R=x[0],F=x[1];let Q=R,se=F;for(let re=h;reQ&&(Q=le),ue>se&&(se=ue)}H=Math.max(Q-R,se-F),H=H!==0?32767/H:0}return t6(T,P,h,R,F,H,0),P}function N3e(x,c,h,g,j){let T;if(j===function(P,R,F,H){let Q=0;for(let se=R,re=F-H;se0)for(let P=c;P=c;P-=g)T=M3e(P/g|0,x[P],x[P+1],T);return T&&O3(T,T.next)&&(n6(T),T=T.next),T}function k2(x,c){if(!x)return x;c||(c=x);let h,g=x;do if(h=!1,g.steiner||!O3(g,g.next)&&Cc(g.prev,g,g.next)!==0)g=g.next;else{if(n6(g),g=c=g.prev,g===g.next)break;h=!0}while(h||g!==c);return c}function t6(x,c,h,g,j,T,P){if(!x)return;!P&&T&&function(F,H,Q,se){let re=F;do re.z===0&&(re.z=Gpe(re.x,re.y,H,Q,se)),re.prevZ=re.prev,re.nextZ=re.next,re=re.next;while(re!==F);re.prevZ.nextZ=null,re.prevZ=null,function(le){let ue,_e=1;do{let Ce,Ee=le;le=null;let Ge=null;for(ue=0;Ee;){ue++;let Be=Ee,nt=0;for(let lt=0;lt<_e&&(nt++,Be=Be.nextZ,Be);lt++);let it=_e;for(;nt>0||it>0&&Be;)nt!==0&&(it===0||!Be||Ee.z<=Be.z)?(Ce=Ee,Ee=Ee.nextZ,nt--):(Ce=Be,Be=Be.nextZ,it--),Ge?Ge.nextZ=Ce:le=Ce,Ce.prevZ=Ge,Ge=Ce;Ee=Be}Ge.nextZ=null,_e*=2}while(ue>1)}(re)}(x,g,j,T);let R=x;for(;x.prev!==x.next;){const F=x.prev,H=x.next;if(T?udt(x,g,j,T):ddt(x))c.push(F.i,x.i,H.i),n6(x),x=H.next,R=H.next;else if((x=H)===R){P?P===1?t6(x=hdt(k2(x),c),c,h,g,j,T,2):P===2&&mdt(x,c,h,g,j,T):t6(k2(x),c,h,g,j,T,1);break}}}function ddt(x){const c=x.prev,h=x,g=x.next;if(Cc(c,h,g)>=0)return!1;const j=c.x,T=h.x,P=g.x,R=c.y,F=h.y,H=g.y,Q=Math.min(j,T,P),se=Math.min(R,F,H),re=Math.max(j,T,P),le=Math.max(R,F,H);let ue=g.next;for(;ue!==c;){if(ue.x>=Q&&ue.x<=re&&ue.y>=se&&ue.y<=le&&s6(j,R,T,F,P,H,ue.x,ue.y)&&Cc(ue.prev,ue,ue.next)>=0)return!1;ue=ue.next}return!0}function udt(x,c,h,g){const j=x.prev,T=x,P=x.next;if(Cc(j,T,P)>=0)return!1;const R=j.x,F=T.x,H=P.x,Q=j.y,se=T.y,re=P.y,le=Math.min(R,F,H),ue=Math.min(Q,se,re),_e=Math.max(R,F,H),Ce=Math.max(Q,se,re),Ee=Gpe(le,ue,c,h,g),Ge=Gpe(_e,Ce,c,h,g);let Be=x.prevZ,nt=x.nextZ;for(;Be&&Be.z>=Ee&&nt&&nt.z<=Ge;){if(Be.x>=le&&Be.x<=_e&&Be.y>=ue&&Be.y<=Ce&&Be!==j&&Be!==P&&s6(R,Q,F,se,H,re,Be.x,Be.y)&&Cc(Be.prev,Be,Be.next)>=0||(Be=Be.prevZ,nt.x>=le&&nt.x<=_e&&nt.y>=ue&&nt.y<=Ce&&nt!==j&&nt!==P&&s6(R,Q,F,se,H,re,nt.x,nt.y)&&Cc(nt.prev,nt,nt.next)>=0))return!1;nt=nt.nextZ}for(;Be&&Be.z>=Ee;){if(Be.x>=le&&Be.x<=_e&&Be.y>=ue&&Be.y<=Ce&&Be!==j&&Be!==P&&s6(R,Q,F,se,H,re,Be.x,Be.y)&&Cc(Be.prev,Be,Be.next)>=0)return!1;Be=Be.prevZ}for(;nt&&nt.z<=Ge;){if(nt.x>=le&&nt.x<=_e&&nt.y>=ue&&nt.y<=Ce&&nt!==j&&nt!==P&&s6(R,Q,F,se,H,re,nt.x,nt.y)&&Cc(nt.prev,nt,nt.next)>=0)return!1;nt=nt.nextZ}return!0}function hdt(x,c){let h=x;do{const g=h.prev,j=h.next.next;!O3(g,j)&&S3e(g,h,h.next,j)&&r6(g,j)&&r6(j,g)&&(c.push(g.i,h.i,j.i),n6(h),n6(h.next),h=x=j),h=h.next}while(h!==x);return k2(h)}function mdt(x,c,h,g,j,T){let P=x;do{let R=P.next.next;for(;R!==P.prev;){if(P.i!==R.i&&ydt(P,R)){let F=C3e(P,R);return P=k2(P,P.next),F=k2(F,F.next),t6(P,c,h,g,j,T,0),void t6(F,c,h,g,j,T,0)}R=R.next}P=P.next}while(P!==x)}function pdt(x,c){let h=x.x-c.x;return h===0&&(h=x.y-c.y,h===0)&&(h=(x.next.y-x.y)/(x.next.x-x.x)-(c.next.y-c.y)/(c.next.x-c.x)),h}function fdt(x,c){const h=function(j,T){let P=T;const R=j.x,F=j.y;let H,Q=-1/0;if(O3(j,P))return P;do{if(O3(j,P.next))return P.next;if(F<=P.y&&F>=P.next.y&&P.next.y!==P.y){const _e=P.x+(F-P.y)*(P.next.x-P.x)/(P.next.y-P.y);if(_e<=R&&_e>Q&&(Q=_e,H=P.x=P.x&&P.x>=re&&R!==P.x&&k3e(FH.x||P.x===H.x&&xdt(H,P)))&&(H=P,ue=_e)}P=P.next}while(P!==se);return H}(x,c);if(!h)return c;const g=C3e(h,x);return k2(g,g.next),k2(h,h.next)}function xdt(x,c){return Cc(x.prev,x,c.prev)<0&&Cc(c.next,x,x.next)<0}function Gpe(x,c,h,g,j){return(x=1431655765&((x=858993459&((x=252645135&((x=16711935&((x=(x-h)*j|0)|x<<8))|x<<4))|x<<2))|x<<1))|(c=1431655765&((c=858993459&((c=252645135&((c=16711935&((c=(c-g)*j|0)|c<<8))|c<<4))|c<<2))|c<<1))<<1}function gdt(x){let c=x,h=x;do(c.x=(x-P)*(T-R)&&(x-P)*(g-R)>=(h-P)*(c-R)&&(h-P)*(T-R)>=(j-P)*(g-R)}function s6(x,c,h,g,j,T,P,R){return!(x===P&&c===R)&&k3e(x,c,h,g,j,T,P,R)}function ydt(x,c){return x.next.i!==c.i&&x.prev.i!==c.i&&!function(h,g){let j=h;do{if(j.i!==h.i&&j.next.i!==h.i&&j.i!==g.i&&j.next.i!==g.i&&S3e(j,j.next,h,g))return!0;j=j.next}while(j!==h);return!1}(x,c)&&(r6(x,c)&&r6(c,x)&&function(h,g){let j=h,T=!1;const P=(h.x+g.x)/2,R=(h.y+g.y)/2;do j.y>R!=j.next.y>R&&j.next.y!==j.y&&P<(j.next.x-j.x)*(R-j.y)/(j.next.y-j.y)+j.x&&(T=!T),j=j.next;while(j!==h);return T}(x,c)&&(Cc(x.prev,x,c.prev)||Cc(x,c.prev,c))||O3(x,c)&&Cc(x.prev,x,x.next)>0&&Cc(c.prev,c,c.next)>0)}function Cc(x,c,h){return(c.y-x.y)*(h.x-c.x)-(c.x-x.x)*(h.y-c.y)}function O3(x,c){return x.x===c.x&&x.y===c.y}function S3e(x,c,h,g){const j=GF(Cc(x,c,h)),T=GF(Cc(x,c,g)),P=GF(Cc(h,g,x)),R=GF(Cc(h,g,c));return j!==T&&P!==R||!(j!==0||!HF(x,h,c))||!(T!==0||!HF(x,g,c))||!(P!==0||!HF(h,x,g))||!(R!==0||!HF(h,c,g))}function HF(x,c,h){return c.x<=Math.max(x.x,h.x)&&c.x>=Math.min(x.x,h.x)&&c.y<=Math.max(x.y,h.y)&&c.y>=Math.min(x.y,h.y)}function GF(x){return x>0?1:x<0?-1:0}function r6(x,c){return Cc(x.prev,x,x.next)<0?Cc(x,c,x.next)>=0&&Cc(x,x.prev,c)>=0:Cc(x,c,x.prev)<0||Cc(x,x.next,c)<0}function C3e(x,c){const h=Wpe(x.i,x.x,x.y),g=Wpe(c.i,c.x,c.y),j=x.next,T=c.prev;return x.next=c,c.prev=x,h.next=j,j.prev=h,g.next=h,h.prev=g,T.next=g,g.prev=T,g}function M3e(x,c,h,g){const j=Wpe(x,c,h);return g?(j.next=g.next,j.prev=g,g.next.prev=j,g.next=j):(j.prev=j,j.next=j),j}function n6(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 Wpe(x,c,h){return{i:x,x:c,y:h,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function a6(x,c){const h=x.length;if(h<=1)return[x];const g=[];let j,T;for(let P=0;P1)for(let P=0;P=sr&&h>=sr}static evaluate(c){if(c.length===0)return new iv;let h=[];for(const F of c)h.push(...F.portals);if(h.length===0)return new iv;for(const F of h){const H=F.va,Q=F.vb;(iv.isOnBorder(H.x,Q.x)||iv.isOnBorder(H.y,Q.y))&&(F.type="border")}const g=h.filter(F=>F.type!=="unevaluated"),j=h.filter(F=>F.type==="unevaluated");if(j.length===0)return new iv;j.sort((F,H)=>F.hash===H.hash?F.isTunnel===H.isTunnel?0:F.isTunnel?-1:1:F.hashF.hashT!=="fill-tunnel-structure-color"),this.tunnelProgramConfigurations=new Ae(h,{zoom:g,lut:j},T=>T!=="fill-bridge-guard-rail-color")}addVertices(c,h){const g=this.unevalVertices.length;for(let j=0;j=T.min.x&&se.x<=T.max.x&&se.y>=T.min.y&&se.y<=T.max.y||re.x>=T.min.x&&re.x<=T.max.x&&re.y>=T.min.y&&re.y<=T.max.y||my(se,re,R))||this.isOnBorder(se.x,re.x)||this.isOnBorder(se.y,re.y))continue;const le=rm.computeEdgeHash(this.unevalVertices[H],this.unevalVertices[Q]);let ue,_e=this.vertexHashLookup.get(rm.computePosHash(se));_e!=null?ue=_e.next:(_e=this.vertexHashLookup.get(rm.computePosHash(re)),ue=_e!=null?_e.prev:le),this.unevalEdges.push({polygonIdx:c,a:H,b:Q,hash:le,portalHash:ue,isTunnel:j,type:"unevaluated",featureInfo:P})}}addPortalCandidates(c,h,g,j,T){if(h.length!==0){this.vertexHashLookup.clear();for(const P of h){if(P.length===0)continue;const R=P[0];let F=rm.computeEdgeHash(R[R.length-2],R[R.length-1]);for(let H=0;H({vertexOffset:0,primitiveOffset:this.indexArray.length}),g=re=>{re.primitiveLength=this.indexArray.length-re.primitiveOffset},j=new _dt(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(c.portals,this.unevalEdges);const T=h(),P=h(),R=h(),F=(re,le)=>{re.sort((_e,Ce)=>_e.type===le&&Ce.type!==le?-1:_e.type!==le&&Ce.type===le?1:0);const ue=re.findIndex(_e=>_e.type!==le);return ue>=0?ue:re.length};let H=0;this.unevalEdges.length>0&&(H=F(this.unevalEdges,"none"),this.constructBridgeStructures(j,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:H},this.tileToMeters)),g(R);const Q=h(),se=h();if(this.unevalEdges.length>0){const re=this.unevalEdges.splice(H),le=F(re,"tunnel")+H;this.unevalEdges.push(...re),this.constructTunnelStructures(j,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:H},{min:H,max:le})}g(Q),j.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),g(se),j.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),g(P),j.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),g(T),this.maskSegments=ji.simpleSegment(0,se.primitiveOffset,0,se.primitiveLength),this.depthSegments=ji.simpleSegment(0,P.primitiveOffset,0,P.primitiveLength),this.renderableBridgeSegments=ji.simpleSegment(0,R.primitiveOffset,0,R.primitiveLength),this.renderableTunnelSegments=ji.simpleSegment(0,Q.primitiveOffset,0,Q.primitiveLength),this.shadowCasterSegments=ji.simpleSegment(0,T.primitiveOffset,0,T.primitiveLength)}update(c,h,g,j,T,P,R,F){this.bridgeProgramConfigurations.updatePaintArrays(c,h,T,g,j,P,R,F),this.tunnelProgramConfigurations.updatePaintArrays(c,h,T,g,j,P,R,F)}upload(c){this.vertexBuffer||this.vertexPositions.length===0||this.vertexNormals.length===0||this.indexArray.length===0||(this.vertexBuffer=c.createVertexBuffer(this.vertexPositions,ldt.members),this.vertexBufferNormal=c.createVertexBuffer(this.vertexNormals,cdt.members),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.bridgeProgramConfigurations.upload(c),this.tunnelProgramConfigurations.upload(c))}destroy(){this.vertexBuffer&&(this.vertexBuffer.destroy(),this.vertexBufferNormal.destroy(),this.indexBuffer.destroy()),this.maskSegments&&(this.maskSegments.destroy(),this.depthSegments.destroy(),this.renderableBridgeSegments.destroy(),this.renderableTunnelSegments.destroy(),this.shadowCasterSegments.destroy()),this.bridgeProgramConfigurations.destroy(),this.tunnelProgramConfigurations.destroy()}populatePaintArrays(c,h,g,j,T){const P=(R,F)=>{for(let H=0;Hae(Ns,h[gs].x,h[gs].y,g[gs]*F),se=J(),re=J(),le=J(),ue=J(),_e=J(),Ce=(Ns,gs)=>{const Rs=R.get(rm.computePosHash(h[gs])),ts=Rs.from,ws=Rs.to;if(!ts||!ws)return;Q(se,ts),Q(re,gs),Q(le,ws),Ye(ue),tt(se,re)||(Te(_e,re,se),Ne(ue,_e)),tt(le,re)||(Te(_e,le,re),oe(ue,ue,Ne(_e,_e)));const Ts=Ke(ue);return Ts>0?je(Ns,ue,1/Ts):void 0};let Ee=Number.POSITIVE_INFINITY;this.sortSubarray(j,T.min,T.max,(Ns,gs)=>Ns.featureInfo.featureIndex-gs.featureInfo.featureIndex);const Ge=J(),Be=J(),nt=J(),it=J(),lt=J(),Rt=J(),jt=J(),It=J(),Mt=J(),Tt=[J(),J(),J(),J()],rs=[J(),J(),J(),J()],ls=[{coord:new as(0,0),height:0},{coord:new as(0,0),height:0}],xs=(Ns,gs)=>Ns>gs;for(let Ns=T.min;NsEe.featureInfo.featureIndex-Ge.featureInfo.featureIndex;this.sortSubarray(j,T.min,T.max,F),this.sortSubarray(j,P.min,P.max,F);const H=Ee=>Ne(Ee,Ee),Q=[{coord:new as(0,0),height:0},{coord:new as(0,0),height:0}],se=(Ee,Ge)=>EeR.hash===F.hash?F.polygonIdx-R.polygonIdx:F.hash>R.hash?1:-1);let g=0,j=0,T=0,P=h[g].polygonIdx;do j++,(j===h.length||h[g].hash!==h[j].hash)&&((j-g===1||h[j-1].polygonIdx!==P)&&(TH.portalHashQ.hash?R++:Q.hash>H.portalHash?F++:(H.type=Q.type,R++)}}}isOnBorder(c,h){return c<=0&&h<=0||c>=sr&&h>=sr}addFeatureSection(c,h,g,j){return c!==h&&(h=c,g.push({featureIndex:c,vertexStart:j.getVertexCount()}),j.clearVertexLookup()),h}sortSubarray(c,h,g,j){const T=c.slice(h,g);T.sort(j),c.splice(h,T.length,...T)}static computeEdgeHash(c,h){return(c.y===h.y&&c.x>h.x||c.y>h.y)&&([c,h]=[h,c]),BigInt(rm.computePosHash(c))<<32n|BigInt(rm.computePosHash(h))}static computePosHash(c){return((65535&c.x)<<16|65535&c.y)>>>0}}function bdt(x,c){return x>c?1:x0))return h;h=h.left}}return null}contains(c){for(var h=this._root,g=this._compare;h;){var j=g(c,h.key);if(j===0)return!0;h=j<0?h.left:h.right}return!1}remove(c){var h=this.find(c);if(!h)return!1;if(this.splay(h),h.left)if(h.right){var g=this.minNode(h.right);g.parent!==h&&(this.replace(g,g.right),g.right=h.right,g.right.parent=g),this.replace(h,g),g.left=h.left,g.left.parent=g}else this.replace(h,h.left);else this.replace(h,h.right);return this._size--,!0}removeNode(c){if(!c)return!1;if(this.splay(c),c.left)if(c.right){var h=this.minNode(c.right);h.parent!==c&&(this.replace(h,h.right),h.right=c.right,h.right.parent=h),this.replace(c,h),h.left=c.left,h.left.parent=h}else this.replace(c,c.left);else this.replace(c,c.right);return this._size--,!0}erase(c){var h=this.find(c);if(h){this.splay(h);var g=h.left,j=h.right,T=null;g&&(g.parent=null,T=this.maxNode(g),this.splay(T),this._root=T),j&&(g?T.right=j:this._root=j,j.parent=T),this._size--}}pop(){var c=this._root,h=null;if(c){for(;c.left;)c=c.left;h={key:c.key,data:c.data},this.remove(c.key)}return h}next(c){var h=c;if(h)if(h.right)for(h=h.right;h&&h.left;)h=h.left;else for(h=c.parent;h&&h.right===c;)c=h,h=h.parent;return h}prev(c){var h=c;if(h)if(h.left)for(h=h.left;h&&h.right;)h=h.right;else for(h=c.parent;h&&h.left===c;)c=h,h=h.parent;return h}forEach(c){for(var h=this._root,g=[],j=!1,T=0;!j;)h?(g.push(h),h=h.left):g.length>0?(c(h=g.pop(),T++),h=h.right):j=!0;return this}range(c,h,g,j){const T=[],P=this._compare;let R,F=this._root;for(;T.length!==0||F;)if(F)T.push(F),F=F.left;else{if(F=T.pop(),R=P(F.key,h),R>0)break;if(P(F.key,c)>=0&&g.call(j,F))return this;F=F.right}return this}keys(){for(var c=this._root,h=[],g=[],j=!1;!j;)c?(h.push(c),c=c.left):h.length>0?(c=h.pop(),g.push(c.key),c=c.right):j=!0;return g}values(){for(var c=this._root,h=[],g=[],j=!1;!j;)c?(h.push(c),c=c.left):h.length>0?(c=h.pop(),g.push(c.data),c=c.right):j=!0;return g}at(c){for(var h=this._root,g=[],j=!1,T=0;!j;)if(h)g.push(h),h=h.left;else if(g.length>0){if(h=g.pop(),T===c)return h;T++,h=h.right}else j=!0;return null}load(c=[],h=[],g=!1){if(this._size!==0)throw new Error("bulk-load: tree is not empty");const j=c.length;return g&&Qpe(c,h,0,j-1,this._compare),this._root=Xpe(null,c,h,0,j),this._size=j,this}min(){var c=this.minNode(this._root);return c?c.key:null}max(){var c=this.maxNode(this._root);return c?c.key:null}isEmpty(){return this._root===null}get size(){return this._size}static createTree(c,h,g,j,T){return new Ype(g,T).load(c,h,j)}}function Xpe(x,c,h,g,j){const T=j-g;if(T>0){const P=g+Math.floor(T/2),R={key:c[P],data:h[P],parent:x};return R.left=Xpe(R,c,h,g,P),R.right=Xpe(R,c,h,P+1,j),R}return null}function Qpe(x,c,h,g,j){if(h>=g)return;const T=x[h+g>>1];let P=h-1,R=g+1;for(;;){do P++;while(j(x[P],T)<0);do R--;while(j(x[R],T)>0);if(P>=R)break;let F=x[P];x[P]=x[R],x[R]=F,F=c[P],c[P]=c[R],c[R]=F}Qpe(x,c,h,R,j),Qpe(x,c,R+1,g,j)}const A3e=11102230246251565e-32,jh=134217729,wdt=(3+8*A3e)*A3e;function Jpe(x,c,h,g,j){let T,P,R,F,H=c[0],Q=g[0],se=0,re=0;Q>H==Q>-H?(T=H,H=c[++se]):(T=Q,Q=g[++re]);let le=0;if(seH==Q>-H?(P=H+T,R=T-(P-H),H=c[++se]):(P=Q+T,R=T-(P-Q),Q=g[++re]),T=P,R!==0&&(j[le++]=R);seH==Q>-H?(P=T+H,F=P-T,R=T-(P-F)+(H-F),H=c[++se]):(P=T+Q,F=P-T,R=T-(P-F)+(Q-F),Q=g[++re]),T=P,R!==0&&(j[le++]=R);for(;se0:(g[0]-c[0])*(h[1]-c[1])-(h[0]-c[0])*(g[1]-c[1])>0}isAbove(c){return!this.isBelow(c)}isVertical(){return this.point[0]===this.otherEvent.point[0]}get inResult(){return this.resultTransition!==0}clone(){const c=new z3(this.point,this.left,this.otherEvent,this.isSubject,this.type);return c.contourId=this.contourId,c.resultTransition=this.resultTransition,c.prevInResult=this.prevInResult,c.isExteriorRing=this.isExteriorRing,c.inOut=this.inOut,c.otherInOut=this.otherInOut,c}}function xy(x,c){return x[0]===c[0]&&x[1]===c[1]}function efe(x,c,h){const g=function(j,T,P,R,F,H){const Q=(T-H)*(P-F),se=(j-F)*(R-H),re=Q-se;if(Q===0||se===0||Q>0!=se>0)return re;const le=Math.abs(Q+se);return Math.abs(re)>=33306690738754716e-32*le?re:-function(ue,_e,Ce,Ee,Ge,Be,nt){let it,lt,Rt,jt,It,Mt,Tt,rs,ls,xs,Ns,gs,Rs,ts,ws,Ts,Os,Zs;const xr=ue-Ge,er=Ce-Ge,Js=_e-Be,Ys=Ee-Be;ts=xr*Ys,Mt=jh*xr,Tt=Mt-(Mt-xr),rs=xr-Tt,Mt=jh*Ys,ls=Mt-(Mt-Ys),xs=Ys-ls,ws=rs*xs-(ts-Tt*ls-rs*ls-Tt*xs),Ts=Js*er,Mt=jh*Js,Tt=Mt-(Mt-Js),rs=Js-Tt,Mt=jh*er,ls=Mt-(Mt-er),xs=er-ls,Os=rs*xs-(Ts-Tt*ls-rs*ls-Tt*xs),Ns=ws-Os,It=ws-Ns,F3[0]=ws-(Ns+It)+(It-Os),gs=ts+Ns,It=gs-ts,Rs=ts-(gs-It)+(Ns-It),Ns=Rs-Ts,It=Rs-Ns,F3[1]=Rs-(Ns+It)+(It-Ts),Zs=gs+Ns,It=Zs-gs,F3[2]=gs-(Zs-It)+(Ns-It),F3[3]=Zs;let ur=function(Na,An){let Ca=An[0];for(let Hn=1;Hn<4;Hn++)Ca+=An[Hn];return Ca}(0,F3),Nr=22204460492503146e-32*nt;if(ur>=Nr||-ur>=Nr||(It=ue-xr,it=ue-(xr+It)+(It-Ge),It=Ce-er,Rt=Ce-(er+It)+(It-Ge),It=_e-Js,lt=_e-(Js+It)+(It-Be),It=Ee-Ys,jt=Ee-(Ys+It)+(It-Be),it===0&<===0&&Rt===0&&jt===0)||(Nr=11093356479670487e-47*nt+wdt*Math.abs(ur),ur+=xr*jt+Ys*it-(Js*Rt+er*lt),ur>=Nr||-ur>=Nr))return ur;ts=it*Ys,Mt=jh*it,Tt=Mt-(Mt-it),rs=it-Tt,Mt=jh*Ys,ls=Mt-(Mt-Ys),xs=Ys-ls,ws=rs*xs-(ts-Tt*ls-rs*ls-Tt*xs),Ts=lt*er,Mt=jh*lt,Tt=Mt-(Mt-lt),rs=lt-Tt,Mt=jh*er,ls=Mt-(Mt-er),xs=er-ls,Os=rs*xs-(Ts-Tt*ls-rs*ls-Tt*xs),Ns=ws-Os,It=ws-Ns,nm[0]=ws-(Ns+It)+(It-Os),gs=ts+Ns,It=gs-ts,Rs=ts-(gs-It)+(Ns-It),Ns=Rs-Ts,It=Rs-Ns,nm[1]=Rs-(Ns+It)+(It-Ts),Zs=gs+Ns,It=Zs-gs,nm[2]=gs-(Zs-It)+(Ns-It),nm[3]=Zs;const Ur=Jpe(4,F3,4,nm,E3e);ts=xr*jt,Mt=jh*xr,Tt=Mt-(Mt-xr),rs=xr-Tt,Mt=jh*jt,ls=Mt-(Mt-jt),xs=jt-ls,ws=rs*xs-(ts-Tt*ls-rs*ls-Tt*xs),Ts=Js*Rt,Mt=jh*Js,Tt=Mt-(Mt-Js),rs=Js-Tt,Mt=jh*Rt,ls=Mt-(Mt-Rt),xs=Rt-ls,Os=rs*xs-(Ts-Tt*ls-rs*ls-Tt*xs),Ns=ws-Os,It=ws-Ns,nm[0]=ws-(Ns+It)+(It-Os),gs=ts+Ns,It=gs-ts,Rs=ts-(gs-It)+(Ns-It),Ns=Rs-Ts,It=Rs-Ns,nm[1]=Rs-(Ns+It)+(It-Ts),Zs=gs+Ns,It=Zs-gs,nm[2]=gs-(Zs-It)+(Ns-It),nm[3]=Zs;const Er=Jpe(Ur,E3e,4,nm,P3e);ts=it*jt,Mt=jh*it,Tt=Mt-(Mt-it),rs=it-Tt,Mt=jh*jt,ls=Mt-(Mt-jt),xs=jt-ls,ws=rs*xs-(ts-Tt*ls-rs*ls-Tt*xs),Ts=lt*Rt,Mt=jh*lt,Tt=Mt-(Mt-lt),rs=lt-Tt,Mt=jh*Rt,ls=Mt-(Mt-Rt),xs=Rt-ls,Os=rs*xs-(Ts-Tt*ls-rs*ls-Tt*xs),Ns=ws-Os,It=ws-Ns,nm[0]=ws-(Ns+It)+(It-Os),gs=ts+Ns,It=gs-ts,Rs=ts-(gs-It)+(Ns-It),Ns=Rs-Ts,It=Rs-Ns,nm[1]=Rs-(Ns+It)+(It-Ts),Zs=gs+Ns,It=Zs-gs,nm[2]=gs-(Zs-It)+(Ns-It),nm[3]=Zs;const Tn=Jpe(Er,P3e,4,nm,I3e);return I3e[Tn-1]}(j,T,P,R,F,H,le)}(x[0],x[1],c[0],c[1],h[0],h[1]);return g>0?-1:g<0?1:0}function a_(x,c){const h=x.point,g=c.point;return h[0]>g[0]?1:h[0]g[1]?1:-1:function(j,T,P){return j.left!==T.left?j.left?1:-1:efe(P,j.otherEvent.point,T.otherEvent.point)!==0?j.isBelow(T.otherEvent.point)?-1:1:!j.isSubject&&T.isSubject?1:-1}(x,c,h)}function i_(x,c,h){const g=new z3(c,!1,x,x.isSubject),j=new z3(c,!0,x.otherEvent,x.isSubject);return xy(x.point,x.otherEvent.point)&&console.warn("what is that, a collapsed segment?",x),g.contourId=j.contourId=x.contourId,a_(j,x.otherEvent)>0&&(x.otherEvent.left=!0,j.left=!1),x.otherEvent.otherEvent=j,x.otherEvent=g,h.push(j),h.push(g),h}function WF(x,c){return x[0]*c[1]-x[1]*c[0]}function tfe(x,c){return x[0]*c[0]+x[1]*c[1]}function sfe(x,c,h){const g=function(F,H,Q,se){const re=[H[0]-F[0],H[1]-F[1]],le=[se[0]-Q[0],se[1]-Q[1]];function ue(Rt,jt,It){return[Rt[0]+jt*It[0],Rt[1]+jt*It[1]]}const _e=[Q[0]-F[0],Q[1]-F[1]];let Ce=WF(re,le),Ee=Ce*Ce;const Ge=tfe(re,re);if(Ee>0){const Rt=WF(_e,le)/Ce;if(Rt<0||Rt>1)return null;const jt=WF(_e,re)/Ce;return jt<0||jt>1?null:Rt===0||Rt===1?[ue(F,Rt,re)]:jt===0||jt===1?[ue(Q,jt,le)]:[ue(F,Rt,re)]}if(Ce=WF(_e,re),Ee=Ce*Ce,Ee>0)return null;const Be=tfe(re,_e)/Ge,nt=Be+tfe(re,le)/Ge,it=Math.min(Be,nt),lt=Math.max(Be,nt);return it<=1&<>=0?it===1?[ue(F,it>0?it:0,re)]:lt===0?[ue(F,lt<1?lt:1,re)]:[ue(F,it>0?it:0,re),ue(F,lt<1?lt:1,re)]:null}(x.point,x.otherEvent.point,c.point,c.otherEvent.point),j=g?g.length:0;if(j===0||j===1&&(xy(x.point,c.point)||xy(x.otherEvent.point,c.otherEvent.point))||j===2&&x.isSubject===c.isSubject)return 0;if(j===1)return!xy(x.point,g[0])&&!xy(x.otherEvent.point,g[0])&&i_(x,g[0],h),!xy(c.point,g[0])&&!xy(c.otherEvent.point,g[0])&&i_(c,g[0],h),1;const T=[];let P=!1,R=!1;return xy(x.point,c.point)?P=!0:a_(x,c)===1?T.push(c,x):T.push(x,c),xy(x.otherEvent.point,c.otherEvent.point)?R=!0:a_(x.otherEvent,c.otherEvent)===1?T.push(c.otherEvent,x.otherEvent):T.push(x.otherEvent,c.otherEvent),P&&R||P?(c.type=1,x.type=c.inOut===x.inOut?2:3,P&&!R&&i_(T[1].otherEvent,T[0].point,h),2):R?(i_(T[0],T[1].point,h),3):T[0]!==T[3].otherEvent?(i_(T[0],T[1].point,h),i_(T[1],T[2].point,h),3):(i_(T[0],T[1].point,h),i_(T[3].otherEvent,T[2].point,h),3)}function jdt(x,c){if(x===c)return 0;if(efe(x.point,x.otherEvent.point,c.point)!==0||efe(x.point,x.otherEvent.point,c.otherEvent.point)!==0)return xy(x.point,c.point)?x.isBelow(c.otherEvent.point)?-1:1:x.point[0]===c.point[0]?x.point[1](c.contourId??0)?1:-1}return a_(x,c)===1?1:-1}class Ndt{constructor(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null}isExterior(){return this.holeOf==null}}function kdt(x,c,h,g){let j,T=x+1,P=c[x].point;const R=c.length;for(Tg;)T--;return T}function Sdt(x,c,h){const g=new Ndt;if(x.prevInResult!=null){const j=x.prevInResult,T=j.outputContourId;if(j.resultTransition>0){const P=c[T];if(P.holeOf!=null){const R=P.holeOf;c[R].holeIds.push(h),g.holeOf=R,g.depth=c[T].depth}else c[T].holeIds.push(h),g.holeOf=T,g.depth=c[T].depth+1}else g.holeOf=null,g.depth=c[T].depth}else g.holeOf=null,g.depth=0;return g}const D3e=Math.max,R3e=Math.min;let KF=0;function O3e(x,c,h,g,j,T){let P,R,F,H,Q,se;for(P=0,R=x.length-1;P0?se.left=!0:Q.left=!0;const re=F[0],le=F[1];j[0]=R3e(j[0],re),j[1]=R3e(j[1],le),j[2]=D3e(j[2],re),j[3]=D3e(j[3],le),g.push(Q),g.push(se)}}const ZF=[];function F3e(x,c,h){let g=x,j=c;typeof x[0][0][0]=="number"&&(g=[x]),typeof c[0][0][0]=="number"&&(j=[c]);let T=function(re,le,ue){let _e=null;return re.length*le.length===0&&(ue===0?_e=ZF:ue===2?_e=re:(ue===1||ue===3)&&(_e=re.length===0?le:re)),_e}(g,j,h);if(T)return T===ZF?null:T;const P=[1/0,1/0,-1/0,-1/0],R=[1/0,1/0,-1/0,-1/0],F=function(re,le,ue,_e,Ce){const Ee=new Gw(void 0,a_);let Ge,Be,nt,it,lt,Rt;for(nt=0,it=re.length;nt_e[2]||_e[0]>ue[2]||ue[1]>_e[3]||_e[1]>ue[3])&&(Ce===0?Ee=ZF:Ce===2?Ee=re:(Ce===1||Ce===3)&&(Ee=re.concat(le))),Ee}(g,j,P,R,h),T)return T===ZF?null:T;const H=function(re,le,ue,_e,Ce,Ee){const Ge=new Ype(jdt),Be=[],nt=Math.min(_e[2],Ce[2]);let it,lt,Rt;for(;re.length!==0;){let jt=re.pop();if(Be.push(jt),Ee===0&&jt.point[0]>nt||Ee===2&&jt.point[0]>_e[2])break;if(jt.left){lt=it=Ge.insert(jt),Rt=Ge.minNode(),it=it!==Rt?Ge.prev(it):null,lt=Ge.next(lt);const It=it?it.key:null;let Mt;if(o6(jt,It,Ee),lt&&sfe(jt,lt.key,re)===2&&(o6(jt,It,Ee),o6(lt.key,jt,Ee)),it&&sfe(it.key,jt,re)===2){let Tt=it;Tt=Tt!==Rt?Ge.prev(Tt):null,Mt=Tt?Tt.key:null,o6(It,Mt,Ee),o6(jt,It,Ee)}}else jt=jt.otherEvent,lt=it=Ge.find(jt),it&<&&(it=it!==Rt?Ge.prev(it):null,lt=Ge.next(lt),Ge.remove(jt),lt&&it&&sfe(it.key,lt.key,re))}return Be}(F,0,0,P,R,h),Q=function(re){let le,ue;const _e=function(Ge){let Be,nt,it,lt,Rt;const jt=[];for(nt=0,it=Ge.length;nt{Ce[Rt]=!0,Rt<_e.length&&_e[Rt]&&(_e[Rt].outputContourId=Ge)};let it=le,lt=le;for(Be.points.push(_e[le].point);nt(it),it=_e[it].otherPos,nt(it),Be.points.push(_e[it].point),it=kdt(it,_e,Ce,lt),!(it==lt||it>=_e.length)&&_e[it];);Ee.push(Be)}return Ee}(H),se=[];for(let re=0;re{P.push(new as(se,F+(se-R)/(H-R)*(Q-F)))}:(P,R,F,H,Q,se)=>{P.push(new as(R+(se-F)/(Q-F)*(H-R),se))};for(const P of x){const R=[];for(const F of P){if(F.length<=2)continue;const H=[];for(let re=0;rec&&T(H,le,ue,_e,Ce,c):Ee>h?Ge=c&&T(H,le,ue,_e,Ce,c),Ge>h&&Ee<=h&&T(H,le,ue,_e,Ce,h)}let Q=F[F.length-1];const se=g===0?Q.x:Q.y;se>=c&&se<=h&&H.push(Q),H.length&&(Q=H[H.length-1],H[0].x===Q.x&&H[0].y===Q.y||H.push(H[0]),R.push(H))}R.length&&j.push(R)}return j}function Cdt(x,c){const h=F3e(rfe(x),rfe([c]),0);return h==null?[]:z3e(h)}function Mdt(x,c,h=0){let j=rfe(x,65536);const T=[];for(;c.valid();c.next()){const[P,R]=c.get();let F=P.x*65536,H=P.y*65536,Q=R.x*65536,se=R.y*65536;const re=Q-F,le=se-H,ue=Math.hypot(re,le);if(ue===0)continue;F-=re*h,H-=le*h,Q+=re*h,se+=le*h;const _e=Math.trunc(le/ue*3),Ce=-Math.trunc(re/ue*3);T.push([[[F,H],[Q,se],[Q+_e,se+Ce],[F+_e,H+Ce],[F,H]]])}return T.length>0&&(j=F3e(j,T,2)),z3e(j,1/65536,128)}function rfe(x,c=1){return[x.map(h=>h.map(g=>[g.x*c,g.y*c]))]}function z3e(x,c=1,h){return x.map(g=>g.map((j,T)=>{const P=j.map(R=>{let F=R[0],H=R[1];return h&&(F=Math.round(F/h)*h,H=Math.round(H/h)*h),new as(F*c,H*c)._round()});return T>0&&P.reverse(),P}))}class nfe{constructor(c,h){this.layoutVertexArray=new _h,this.indexArray=new Ao,this.lineIndexArray=new Gm,this.triangleSegments=new ji,this.lineSegments=new ji,this.programConfigurations=new Ae(c.layers,{zoom:c.zoom,lut:c.lut}),this.uploaded=!1,h&&(this.elevatedLayoutVertexArray=new Jh)}update(c,h,g,j,T,P,R,F){this.programConfigurations.updatePaintArrays(c,h,T,g,j,P,R,F)}isEmpty(){return this.layoutVertexArray.length===0}needsUpload(){return this.programConfigurations.needsUpload}upload(c){this.uploaded||(this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,idt.members),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.lineIndexBuffer=c.createIndexBuffer(this.lineIndexArray),this.elevatedLayoutVertexArray&&this.elevatedLayoutVertexArray.length>0&&(this.elevatedLayoutVertexBuffer=c.createVertexBuffer(this.elevatedLayoutVertexArray,odt.members))),this.programConfigurations.upload(c),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.lineIndexBuffer.destroy(),this.programConfigurations.destroy(),this.triangleSegments.destroy(),this.lineSegments.destroy())}populatePaintArrays(c,h,g,j,T,P,R){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,c,h,g,j,T,P,void 0,R)}}class XF{constructor(c){this.zoom=c.zoom,this.pixelRatio=c.pixelRatio,this.overscaling=c.overscaling,this.layers=c.layers,this.layerIds=this.layers.map(h=>h.fqid),this.index=c.index,this.hasPattern=!1,this.patternFeatures=[],this.lut=c.lut,this.bufferData=new nfe(c,!1),this.elevationBufferData=new nfe(c,!0),this.stateDependentLayerIds=this.layers.filter(h=>h.isStateDependent()).map(h=>h.id),this.projection=c.projection,this.elevationMode=this.layers[0].layout.get("fill-elevation-reference"),this.sourceLayerIndex=c.sourceLayerIndex,this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,h){}updateAppearances(c,h,g,j){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(c,h,g,j){this.hasPattern=Kpe("fill",this.layers,this.pixelRatio,h);const T=this.layers[0].layout.get("fill-sort-key"),P=[];for(const{feature:R,id:F,index:H,sourceLayerIndex:Q}of c){const se=this.layers[0]._featureFilter.needGeometry,re=Vn(R,se);if(!this.layers[0]._featureFilter.filter(new Ka(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),re,g))continue;const le=T?T.evaluate(re,{},g,h.availableImages):void 0,ue={id:F,properties:R.properties,type:R.type,sourceLayerIndex:Q,index:H,geometry:se?re.geometry:Vr(R,g,j),patterns:{},sortKey:le};P.push(ue)}T&&P.sort((R,F)=>R.sortKey-F.sortKey);for(const R of P){const{geometry:F,index:H,sourceLayerIndex:Q}=R;if(this.hasPattern){const se=Zpe("fill",this.layers,R,this.zoom,this.pixelRatio,h);this.patternFeatures.push(se)}else this.addFeature(R,F,H,g,{},h.availableImages,h.brightness,h.elevationFeatures);h.featureIndex.insert(c[H].feature,F,H,Q,this.index)}}update(c,h,g,j,T,P,R){this.bufferData.update(c,h,g,j,T,P,R,this.worldview),this.elevationBufferData.update(c,h,g,j,T,P,R,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(c,h,g,j,T,P,R,this.worldview)}addFeatures(c,h,g,j,T,P){for(const R of this.patternFeatures)this.addFeature(R,R.geometry,R.index,h,g,j,P,c.elevationFeatures)}isEmpty(){return this.bufferData.isEmpty()&&this.elevationBufferData.isEmpty()}uploadPending(){return!this.uploaded||this.bufferData.needsUpload()||this.elevationBufferData.needsUpload()}upload(c){this.bufferData.upload(c),this.elevationBufferData.upload(c),this.elevatedStructures&&this.elevatedStructures.upload(c)}destroy(){this.bufferData.destroy(),this.elevationBufferData.destroy(),this.elevatedStructures&&this.elevatedStructures.destroy()}addFeature(c,h,g,j,T,P=[],R,F){const H=a6(h,500);this.elevationMode!=="none"?this.addElevatedRoadFeature(c,H,j,g,F):this.addGeometry(H,this.bufferData),this.bufferData.populatePaintArrays(c,g,T,P,j,R,this.worldview),this.elevationBufferData.populatePaintArrays(c,g,T,P,j,R,this.worldview)}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}setEvaluatedPortalGraph(c,h,g,j,T){this.elevatedStructures&&(this.elevatedStructures.construct(c),this.elevatedStructures.populatePaintArrays(h,g,j,T,this.worldview))}addElevatedRoadFeature(c,h,g,j,T){const P=new Array,R=Ci.getElevationFeature(c,T);if(!R)return void this.addGeometry(h,this.bufferData);{const H=this.clipPolygonsToTile(h,1);H.length>0&&P.push({polygons:H,elevationFeature:R,elevationTileID:g})}const F={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(c,{},g),featureIndex:j};for(const H of P)if(H.elevationFeature){if(this.elevationMode==="hd-road-base"){this.elevatedStructures||(this.elevatedStructures=new rm(H.elevationTileID,this.layers,this.zoom,this.lut));const se=H.elevationFeature.isTunnel();let re=0;c.properties.hasOwnProperty(ki)&&(re=+c.properties[ki]),this.elevatedStructures.addPortalCandidates(H.elevationFeature.id,H.polygons,se,H.elevationFeature,re)}H.elevationFeature.constantHeight==null&&(H.polygons=this.prepareElevatedPolygons(H.polygons,H.elevationFeature,H.elevationTileID));const Q=new Pi(g,H.elevationTileID);this.addElevatedGeometry(H.polygons,Q,H.elevationFeature,this.elevationMode==="hd-road-base"?0:.05,j,F)}}addElevatedGeometry(c,h,g,j,T,P){const R={elevation:g,elevationSampler:h,bias:j,index:T,featureInfo:P},[F,H]=this.addGeometry(c,this.elevationBufferData,R);this.elevationBufferData.heightRange==null?this.elevationBufferData.heightRange={min:F,max:H}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,F),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,H))}addGeometry(c,h,g){let j=Number.POSITIVE_INFINITY,T=Number.NEGATIVE_INFINITY,P=null;g&&(P=g.elevationSampler.constantElevation(g.elevation,g.bias),P!=null&&(j=P,T=P));const R=(F,H,Q)=>{if(g!=null)if(H.push(F),P!=null)h.elevatedLayoutVertexArray.emplaceBack(P),Q.push(P);else{const se=g.elevationSampler.pointElevation(F,g.elevation,g.bias);h.elevatedLayoutVertexArray.emplaceBack(se),Q.push(se),j=Math.min(j,se),T=Math.max(T,se)}};for(const F of c){let H=0;for(const Be of F)H+=Be.length;const Q=h.triangleSegments.prepareSegment(H,h.layoutVertexArray,h.indexArray),se=Q.vertexLength,re=[],le=[],ue=[],_e=[],Ce=[],Ee=h.layoutVertexArray.length;for(const Be of F){if(Be.length===0)continue;Be!==F[0]&&le.push(re.length/2);const nt=h.lineSegments.prepareSegment(Be.length,h.layoutVertexArray,h.lineIndexArray),it=nt.vertexLength;g&&Ce.push(h.layoutVertexArray.length-Ee),R(Be[0],ue,_e),h.layoutVertexArray.emplaceBack(Be[0].x,Be[0].y),h.lineIndexArray.emplaceBack(it+Be.length-1,it),re.push(Be[0].x),re.push(Be[0].y);for(let lt=1;lt0&&g&&this.elevationMode==="hd-road-base"){const Be=g.elevation.isTunnel(),nt=g.elevation.safeArea,it=this.elevatedStructures.addVertices(ue,_e);this.elevatedStructures.addTriangles(Ge,it,Be);const lt=Ce.length;if(lt>0){for(let Rt=0;Rt=g&&le.max.x<=T&&le.min.y>=j&&le.max.y<=P?F:H).push(re)}if(F.length===c.length)return c;const Q=[new as(g,j),new as(T,j),new as(T,P),new as(g,P),new as(g,j)],se=F;for(const re of H)se.push(...Cdt(re,Q));return se}}let B3e,$3e,q3e,U3e;yr(XF,"FillBucket",{omit:["layers","patternFeatures"]}),yr(nfe,"FillBufferData"),yr(rm,"ElevatedStructures");class QF{constructor(c,h,g,j){if(this.triangleCount=h.length/3,this.min=new as(0,0),this.max=new as(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],this.triangleCount===0||c.length===0)return;const[T,P]=[c[0].clone(),c[0].clone()];for(let se=1;sese.cellIdx-re.cellIdx||se.triIdx-re.triIdx);let Q=0;for(;Qthis.max.x||this.min.x>c.x||c.y>this.max.y||this.min.y>c.y)return;const g=gy(c.x-this.min.x,this.xScale,this.cellsX),j=gy(c.y-this.min.y,this.yScale,this.cellsY),T=this.cells[j*this.cellsX+g];if(T){this._lazyInitLookup();for(let P=0;Pthis.max.x||this.min.x>h.x||c.y>this.max.y||this.min.y>h.y)return;this._lazyInitLookup();const j=gy(c.x-this.min.x,this.xScale,this.cellsX),T=gy(h.x-this.min.x,this.xScale,this.cellsX),P=gy(c.y-this.min.y,this.yScale,this.cellsY),R=gy(h.y-this.min.y,this.yScale,this.cellsY);for(let F=P;F<=R;F++)for(let H=j;H<=T;H++){const Q=this.cells[F*this.cellsX+H];if(Q)for(let se=0;seh.fqid),this.index=c.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter(h=>h.isStateDependent()).map(h=>h.id),this.footprints=[],this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,h){for(const g of this.footprints)h.push({footprint:g,id:c})}updateAppearances(c,h,g,j){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(c,h,g,j){const T=[];for(const{feature:P,id:R,index:F,sourceLayerIndex:H}of c){const Q=this.layers[0]._featureFilter.needGeometry,se=Vn(P,Q);if(!this.layers[0]._featureFilter.filter(new Ka(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),se,g))continue;const re={id:R,properties:P.properties,type:P.type,sourceLayerIndex:H,index:F,geometry:Q?se.geometry:Vr(P,g,j),patterns:{}};T.push(re)}for(const P of T){const{geometry:R,index:F,sourceLayerIndex:H}=P;this.addFeature(P,R,F,g,{},h.availableImages,h.brightness),h.featureIndex.insert(c[F].feature,R,F,H,this.index)}}isEmpty(){return this.footprints.length===0}uploadPending(){return!1}upload(c){}update(c,h,g,j,T,P,R){}destroy(){}addFeature(c,h,g,j,T,P=[],R){for(const F of a6(h,2)){const H=[],Q=[],se=[],re=new as(1/0,1/0),le=new as(-1/0,-1/0);for(const Ce of F)if(Ce.length!==0){Ce!==F[0]&&se.push(Q.length/2);for(let Ee=0;Eec.max.x||x.max.xc.max.y||x.max.ynew as((F.x+T.x*sr)*R-P.x*sr,(F.y+T.y*sr)*R-P.y*sr))}return ife(h,j,x.indices,0,x.indices.length,0,0)}function Z3e(x,c,h,g){const j=Math.pow(2,g.z-h.z);return new as((x+h.x*sr)*j-g.x*sr,(c+h.y*sr)*j-g.y*sr)}function Y3e(x,c){const h=[];c.grid.queryPoint(x,h);const g=c.indices,j=c.vertices;for(let T=0;T0&&(g.length>1&&h.push(g),g=[])}return g.length>1&&h.push(g),h}const lfe=pn.types,zdt=["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"],Bdt=["fill-extrusion-flood-light-ground-radius"],$dt=Math.pow(2,13),qdt=Math.pow(2,15)-1,s7=new as(0,1),ov=2147483648,r7=1073741824;function c6(x,c,h,g,j,T,P,R){x.emplaceBack((c<<1)+P,(h<<1)+T,(Math.floor(g*$dt)<<1)+j,Math.round(R))}function d6(x,c,h){x.emplaceBack(c.x*sr,c.y*sr,h?1:0)}function n7(x,c,h,g,j,T){x.emplaceBack(c.x,c.y,(h.x<<1)+g,(h.y<<1)+j,T)}function u6(x,c,h){x.emplaceBack(c.x,c.y,c.z,h[0]*16384,h[1]*16384,h[2]*16384)}class Q3e{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class cfe{constructor(){this.centroidXY=new as(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 as(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new as(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0,this.groupCentroidPos=new as(0,0)}span(){return new as(this.max.x-this.min.x,this.max.y-this.min.y)}}class dfe{constructor(){this.acc=new as(0,0),this.accCount=0,this.centroidDataIndex=0}startRing(c,h){c.min.x===Number.MAX_VALUE&&(c.min.x=c.max.x=h.x,c.min.y=c.max.y=h.y)}appendEdge(c,h,g){this.accCount++,this.acc._add(h);let j=!!this.borders;h.xc.max.x&&(c.max.x=h.x,j=!0),h.yc.max.y&&(c.max.y=h.y,j=!0),((h.x===0||h.x===sr)&&h.x===g.x)!=((h.y===0||h.y===sr)&&h.y===g.y)&&this.processBorderOverlap(h,g),j&&this.checkBorderIntersection(h,g)}checkBorderIntersection(c,h){h.x<0!=c.x<0&&this.addBorderIntersection(0,on(h.y,c.y,(0-h.x)/(c.x-h.x))),h.x>sr!=c.x>sr&&this.addBorderIntersection(1,on(h.y,c.y,(sr-h.x)/(c.x-h.x))),h.y<0!=c.y<0&&this.addBorderIntersection(2,on(h.x,c.x,(0-h.y)/(c.y-h.y))),h.y>sr!=c.y>sr&&this.addBorderIntersection(3,on(h.x,c.x,(sr-h.y)/(c.y-h.y)))}addBorderIntersection(c,h){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const g=this.borders[c];hg[1]&&(g[1]=h)}processBorderOverlap(c,h){if(c.x===h.x){if(c.y===h.y)return;const g=c.x===0?0:1;this.addBorderIntersection(g,h.y),this.addBorderIntersection(g,c.y)}else{const g=c.y===0?2:3;this.addBorderIntersection(g,h.x),this.addBorderIntersection(g,c.x)}}centroid(){return this.accCount===0?new as(0,0):new as(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce((c,h)=>c+ +(h[0]!==Number.MAX_VALUE),0):0}}function J3e(x,c){const h=x.add(c)._unit(),g=Fe(x.x*h.x+x.y*h.y,-1,1);var j,T,P;return P=Math.acos(g),Math.min(4,Math.max(-4,Math.tan(P)))/4*qdt*((j=x).x*(T=c).y-j.y*T.x<0?-1:1)}const Udt=[x=>x.x<0,x=>x.x>sr,x=>x.y<0,x=>x.y>sr];function Vdt(x,c,h,g){const j=[4];if(g===0)return j;h._mult(g);const T=x.sub(h),P=c.sub(h),R=[x,c,T,P];for(let F=0;F<4;F++)for(const H of R)if(Udt[F](H)){j.push(F);break}return j}class ufe{constructor(c){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new OP,this.indexArray=new Ao,this.programConfigurations=new Ae(c.layers,{zoom:c.zoom,lut:c.lut},h=>Bdt.includes(h)),this._segments=new ji,this.hiddenByLandmarkVertexArray=new E3,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new ji}getDefaultSegment(){return this.regionSegments[4]}hasData(){return this.vertexArray.length!==0}addData(c,h,g,j=!1){const T=c.length;if(T>2){let P=Math.max(0,this._segments.get().length-1);const R=this._segments._prepareSegment(4*T,this.vertexArray.length,2*this._segmentToGroundQuads[P].length);let F;P!==this._segments.get().length-1&&(P++,this._segmentToGroundQuads[P]=[],this._segmentToRegionTriCounts[P]=[0,0,0,0,0]);{const H=c[0],Q=c[1];F=J3e(H.sub(c[T-1])._perp()._unit(),Q.sub(H)._perp()._unit())}for(let H=0;Hj.region-T.region);for(let g=0;gF+H,0);let R=0;for(let F=0;F<=4;F++){const H=P[F];if(H!==0){let Q=this.regionSegments[F];Q||(Q=this.regionSegments[F]=new ji);const se={vertexOffset:T.vertexOffset,primitiveOffset:T.primitiveOffset+R,vertexLength:T.vertexLength,primitiveLength:H};Q.get().push(se)}R+=H}for(let F=0;F0?this.hiddenByLandmarkVertexBuffer=c.createVertexBuffer(this.hiddenByLandmarkVertexArray,Ldt.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this.groundRadiusBuffer&&this.groundRadiusBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let c=0;c<=4;c++){const h=this.regionSegments[c];h&&h.destroy()}}}}class a7{constructor(c){this.zoom=c.zoom,this.canonical=c.canonical,this.overscaling=c.overscaling,this.layers=c.layers,this.pixelRatio=c.pixelRatio,this.layerIds=this.layers.map(h=>h.fqid),this.index=c.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=c.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Ao,this.footprintVertices=new _h,this.footprintSegments=[],this.layoutVertexArray=new RP,this.centroidVertexArray=new FF,this.wallVertexArray=new ZP,this.indexArray=new Ao,this.programConfigurations=new Ae(c.layers,{zoom:c.zoom,lut:c.lut},h=>zdt.includes(h)),this.segments=new ji,this.stateDependentLayerIds=this.layers.filter(h=>h.isStateDependent()).map(h=>h.id),this.groundEffect=new ufe(c),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.buildingGroups=new Map,this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,h){}updateAppearances(c,h,g,j){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(c,h,g,j){this.features=[],this.hasPattern=Kpe("fill-extrusion",this.layers,this.pixelRatio,h),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.selfDEMTileTimestamp=Number.MAX_VALUE,this.borderDEMTileTimestamp=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],this.tileToMeter=As(g),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:T,id:P,index:R,sourceLayerIndex:F}of c){const H=this.layers[0]._featureFilter.needGeometry,Q=Vn(T,H);if(!this.layers[0]._featureFilter.filter(new Ka(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),Q,g))continue;const se={id:P,sourceLayerIndex:F,index:R,geometry:H?Q.geometry:Vr(T,g,j),properties:T.properties,type:T.type,patterns:{}},re=this.layoutVertexArray.length,le=lfe[se.type]==="Polygon";if(this.hasPattern)this.features.push({featureId:T.id,feature:Zpe("fill-extrusion",this.layers,se,this.zoom,this.pixelRatio,h)});else if(this.wallMode)for(const ue of se.geometry)for(const _e of X3e(ue,le))this.addFeature(T.id,se,[_e],R,g,{},h.availableImages,j,h.brightness);else this.addFeature(T.id,se,se.geometry,R,g,{},h.availableImages,j,h.brightness);h.featureIndex.insert(T,se.geometry,R,F,this.index,re)}this._finalizeBuildingGroups(),this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(c,h,g,j,T,P){for(const{featureId:R,feature:F}of this.features){const H=lfe[F.type]==="Polygon",{geometry:Q}=F;if(this.wallMode)for(const se of Q)for(const re of X3e(se,H))this.addFeature(R,F,[re],F.index,h,g,j,T,P);else this.addFeature(R,F,Q,F.index,h,g,j,T,P)}this._finalizeBuildingGroups(),this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles()}update(c,h,g,j,T,P,R){this.programConfigurations.updatePaintArrays(c,h,T,g,j,P,R,this.worldview),this.groundEffect.update(c,h,T,g,j,P,R,this.worldview)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(c){this.uploaded||(this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,Rdt),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.wallVertexBuffer=c.createVertexBuffer(this.wallVertexArray,Idt.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=c.createVertexBuffer(this.layoutVertexExtArray,Ddt.members,!0)),this.groundEffect.upload(c)),this.groundEffect.uploadPaintProperties(c),this.programConfigurations.upload(c),this.uploaded=!0}uploadCentroid(c){this.groundEffect.uploadHiddenByLandmark(c),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=c.createVertexBuffer(this.centroidVertexArray,Pdt.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(c,h,g,j,T,P,R,F,H){const Q=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(h,{})/this.tileToMeter,se=[new as(0,0),new as(sr,sr)],re=F.projection,le=re.name==="globe",ue=this.wallMode||lfe[h.type]==="Polygon",_e=new dfe;_e.centroidDataIndex=this.centroidData.length;const Ce=new cfe;Ce.buildingId=c,h.properties&&h.properties.hasOwnProperty("building_id")&&(Ce.buildingId=Number(h.properties.building_id)),_e.buildingId=Ce.buildingId;const Ee=this.layers[0].paint.get("fill-extrusion-base").evaluate(h,{},T)<=0,Ge=this.layers[0].paint.get("fill-extrusion-height").evaluate(h,{},T);let Be;if(Ce.height=Ge,Ce.vertexArrayOffset=this.layoutVertexArray.length,Ce.groundVertexArrayOffset=this.groundEffect.vertexArray.length,le&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new k3),this.wallMode){if(le)return void zr("Non zero fill-extrusion-line-width is not yet supported on globe.");if(g.length!==1)return;Be=function(Mt){const Tt=Mt[0].x===Mt[Mt.length-1].x&&Mt[0].y===Mt[Mt.length-1].y;(function(Js){let Ys=0;const ur=Js.length;for(let Nr=0;Nr=0})(Mt)||(Mt=Mt.reverse());const ls={geometry:[],joinNormals:[],indices:[]},xs=[],Ns=[],gs=[];let Rs=Mt.length;for(;Rs>=2&&Mt[Rs-1].equals(Mt[Rs-2]);)Rs--;if(Rs<(Tt?3:2))return ls;let ts,ws,Ts,Os,Zs,xr=0;for(;xr0;let Er="miter";const Tn=2;Er==="miter"&&Nr>Tn&&(Er="bevel"),Er==="bevel"&&(Nr>100&&(Er="flipbevel"),Nr{const Za=new as(An.x,An.y),Da=new as(An.x,An.y);Za.x+=Ca.x*xo,Za.y+=Ca.y*xo,Da.x-=Ca.x*Math.max(Hn,1),Da.y-=Ca.y*Math.max(Hn,1),gs.push(Ca),xs.push(Za),Ns.push(Da)};if(Er==="miter")Ys._mult(Nr),Na(ts,Ys,0,0);else if(Er==="flipbevel")Ys=Zs.mult(-1),Na(ts,Ys,0,0),Na(ts,Ys.mult(-1),0,0);else{const An=-Math.sqrt(Nr*Nr-1),Ca=Ur?An:0,Hn=Ur?0:An;ws&&Na(ts,Os,Ca,Hn),Ts&&Na(ts,Zs,Ca,Hn)}}ls.geometry=[...xs,...Ns.reverse(),xs[0]],ls.joinNormals=[...gs,...gs.reverse(),gs[gs.length-1]];const er=ls.geometry.length-1;for(let Js=0;JsMt<(Tt.length-1)/2||Mt===Tt.length-1,it=this.wallMode?[g]:a6(g,500);for(let Mt=it.length-1;Mt>=0;Mt--){const Tt=it[Mt];(Tt.length===0||Gdt(Tt[0]))&&it.splice(Mt,1)}let lt;if(le)lt=i5e(it,se,T);else{lt=[];for(const Mt of it)lt.push({polygon:Mt,bounds:se})}const Rt=ue?this.edgeRadius:0,jt=Rt>0&&this.zoom<17,It=(Mt,Tt)=>{if(Mt.length===0)return!1;const rs=Mt[Mt.length-1];return Tt.x===rs.x&&Tt.y===rs.y};for(const{polygon:Mt,bounds:Tt}of lt){let rs=0,ls=0;for(const Rs of Mt)ue&&!Rs[0].equals(Rs[Rs.length-1])&&Rs.push(Rs[0]),ls+=ue?Rs.length-1:Rs.length;const xs=this.segments.prepareSegment((ue?5:4)*ls,this.layoutVertexArray,this.indexArray);Ce.footprintSegIdx<0&&(Ce.footprintSegIdx=this.footprintSegments.length),Ce.polygonSegIdx<0&&(Ce.polygonSegIdx=this.polygonSegments.length);const Ns={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},gs=new Q3e;if(gs.vertexOffset=this.footprintVertices.length,gs.indexOffset=3*this.footprintIndices.length,gs.ringIndices=[],ue){const Rs=[],ts=[];rs=xs.vertexLength;for(let Ts=0;Ts4&&r5e(ts[ts.length-2],ts[0],ts[1]),Ts=Rt?Hdt(ts[ts.length-2],ts[0],ts[1],Rt):0;const Os=[];let Zs,xr,er;xr=ts[1].sub(ts[0])._perp()._unit();let Js=!0;for(let Ys=1,ur=0;Ys0?1:0,Ca=Nr.dist(Ur);if(ur+Ca>32768&&(ur=0),Rt){er=Er.sub(Ur)._perp()._unit();let Da=t5e(Nr,Ur,Er,e5e(xr,er),Rt);isNaN(Da)&&(Da=0);const Si=Ur.sub(Nr)._unit();Nr=Nr.add(Si.mult(Ts))._round(),Ur=Ur.add(Si.mult(-Da))._round(),Ts=Da,xr=er,Ee&&this.zoom>=17&&(It(Os,Nr)||Os.push(Nr),It(Os,Ur)||Os.push(Ur))}const Hn=xs.vertexLength,xo=ts.length>4&&r5e(Nr,Ur,Er);let Za=n5e(ur,ws,Js);if(c6(this.layoutVertexArray,Nr.x,Nr.y,Na,An,0,0,Za),c6(this.layoutVertexArray,Nr.x,Nr.y,Na,An,0,1,Za),this.wallMode){const Da=nt(Ys-1,ts),Si=Be.joinNormals[Ys-1];d6(this.wallVertexArray,Si,Da),d6(this.wallVertexArray,Si,Da)}if(ur+=Ca,Za=n5e(ur,xo,!Js),ws=xo,c6(this.layoutVertexArray,Ur.x,Ur.y,Na,An,0,0,Za),c6(this.layoutVertexArray,Ur.x,Ur.y,Na,An,0,1,Za),this.wallMode){const Da=nt(Ys,ts),Si=Be.joinNormals[Ys];d6(this.wallVertexArray,Si,Da),d6(this.wallVertexArray,Si,Da)}if(xs.vertexLength+=4,this.indexArray.emplaceBack(Hn+0,Hn+1,Hn+2),this.indexArray.emplaceBack(Hn+1,Hn+3,Hn+2),xs.primitiveLength+=2,Rt){const Da=rs+(Ys===1?ts.length-2:Ys-2),Si=Ys===1?rs:Da+1;if(this.indexArray.emplaceBack(Hn+1,Da,Hn+3),this.indexArray.emplaceBack(Da,Si,Hn+3),xs.primitiveLength+=2,Zs===void 0&&(Zs=Hn),!hfe(Er,ts[Ys],Tt)){const lo=Ys===ts.length-1?Zs:xs.vertexLength;this.indexArray.emplaceBack(Hn+2,Hn+3,lo),this.indexArray.emplaceBack(Hn+3,lo+1,lo),this.indexArray.emplaceBack(Hn+3,Si,lo+1),xs.primitiveLength+=3}Js=!Js}if(le){const Da=this.layoutVertexExtArray,Si=re.projectTilePoint(Nr.x,Nr.y,T),lo=re.projectTilePoint(Ur.x,Ur.y,T),cc=re.upVector(T,Nr.x,Nr.y),co=re.upVector(T,Ur.x,Ur.y);u6(Da,Si,cc),u6(Da,Si,cc),u6(Da,lo,co),u6(Da,lo,co)}}ue&&(rs+=ts.length-1),Ee&&Rt&&this.zoom>=17&&(Os.length!==0&&It(Os,Os[0])&&Os.pop(),this.groundEffect.addData(Os,Tt,Q,Rt>0))}this.footprintSegments.push(gs),Ns.triangleCount=this.indexArray.length-Ns.triangleArrayOffset,this.polygonSegments.push(Ns),++Ce.footprintSegLen,++Ce.polygonSegLen}if(Ce.vertexCount=this.layoutVertexArray.length-Ce.vertexArrayOffset,Ce.groundVertexCount=this.groundEffect.vertexArray.length-Ce.groundVertexArrayOffset,Ce.vertexCount!==0){if(Ce.centroidXY=_e.borders?s7:this.encodeCentroid(_e,Ce),h.properties&&h.properties.hasOwnProperty("building_id")){const Mt=Ce.buildingId;let Tt=this.buildingGroups.get(Mt);Tt||(Tt={accX:0,accY:0,accCount:0,mergedMin:new as(Number.MAX_VALUE,Number.MAX_VALUE),mergedMax:new as(-Number.MAX_VALUE,-Number.MAX_VALUE),partIndices:[]},this.buildingGroups.set(Mt,Tt)),Tt.accX+=_e.acc.x,Tt.accY+=_e.acc.y,Tt.accCount+=_e.accCount,Tt.mergedMin.x=Math.min(Tt.mergedMin.x,Ce.min.x),Tt.mergedMin.y=Math.min(Tt.mergedMin.y,Ce.min.y),Tt.mergedMax.x=Math.max(Tt.mergedMax.x,Ce.max.x),Tt.mergedMax.y=Math.max(Tt.mergedMax.y,Ce.max.y),Tt.partIndices.push(this.centroidData.length)}if(this.centroidData.push(Ce),_e.borders){this.featuresOnBorder.push(_e);const Mt=this.featuresOnBorder.length-1;for(let Tt=0;Tt<_e.borders.length;Tt++)_e.borders[Tt][0]!==Number.MAX_VALUE&&this.borderFeatureIndices[Tt].push(Mt)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,h,j,P,R,T,H,void 0,this.worldview),this.groundEffect.addPaintPropertiesData(h,j,P,R,T,H,this.worldview),this.maxHeight=Math.max(this.maxHeight,Ge)}}_finalizeBuildingGroups(){for(const[,c]of this.buildingGroups){if(c.partIndices.length===0)continue;const h=new dfe;h.acc=new as(c.accX,c.accY),h.accCount=c.accCount;const g=new cfe;g.min=c.mergedMin,g.max=c.mergedMax;const j=this.encodeCentroid(h,g),T=h.centroid();for(const P of c.partIndices){const R=this.centroidData[P];R.centroidXY.x===s7.x&&R.centroidXY.y===s7.y||(R.centroidXY=j),R.min=c.mergedMin,R.max=c.mergedMax,R.groupCentroidPos=T}}this.buildingGroups.clear()}sortBorders(){for(let c=0;cthis.featuresOnBorder[h].borders[c][0]-this.featuresOnBorder[g].borders[c][0])}splitToSubtiles(){const c=[];for(let R=0;Rsr),Q=2*H+(+(F.min.x+F.max.x>sr)^H);for(let se=0;seR.triangleSegmentIdx===F.triangleSegmentIdx?R.subtile-F.subtile:R.triangleSegmentIdx-F.triangleSegmentIdx);let g=0,j=0,T=0;for(const R of c){if(R.triangleSegmentIdx!==g)break;T++}const P=c.length;for(;j!==c.length;){g=c[j].triangleSegmentIdx;let R=0,F=j,H=j;for(let Q=F;Q0&&this.triangleSubSegments.push({segment:le,min:se,max:re}),F=H;for(let ue=F;ue[_e[0]*(1-Ee[0])+Ce[0]*Ee[0],_e[1]*(1-Ee[1])+Ce[1]*Ee[1]],le=[],ue=[];for(const _e of this.triangleSubSegments){le[0]=_e.min.x/sr,le[1]=_e.min.y/sr,ue[0]=_e.max.x/sr,ue[1]=_e.max.y/sr;const Ce=re(Q,se,le),Ee=re(Q,se,ue);if(new ei([Ce[0],Ce[1],T],[Ee[0],Ee[1],P]).intersectsPrecise(g)===0){H&&(j.segments.push(H),H=void 0);continue}const Ge=_e.segment;H&&H.vertexOffset!==Ge.vertexOffset&&(j.segments.push(H),H=void 0),H?(H.vertexLength+=Ge.vertexLength,H.primitiveLength+=Ge.primitiveLength):H={vertexOffset:Ge.vertexOffset,primitiveLength:Ge.primitiveLength,vertexLength:Ge.vertexLength,primitiveOffset:Ge.primitiveOffset,sortKey:void 0,vaos:{}}}return H&&j.segments.push(H),j}encodeCentroid(c,h){const g=c.centroid(),j=h.span(),T=Math.min(7,Math.round(j.x*this.tileToMeter/10)),P=Math.min(6,Math.round(j.y*this.tileToMeter/10));return new as(Fe(g.x,1,8191)<<3|T,Fe(g.y,1,8191)<<3|P)}encodeBorderCentroid(c){if(!c.borders)return new as(0,0);const h=c.borders,g=Number.MAX_VALUE;if(h[0][0]!==g||h[1][0]!==g){const j=h[0][0]!==g?0:1;return new as(6|(h[0][0]!==g?0:65528),(h[j][0]+h[j][1])/2<<3|6)}{const j=h[2][0]!==g?2:3;return new as((h[j][0]+h[j][1])/2<<3|6,6|(h[2][0]!==g?0:65528))}}showCentroid(c){const h=this.centroidData[c.centroidDataIndex];if(h.flags&=ov,h.groupCentroidPos.x!==0||h.groupCentroidPos.y!==0){const g=h.span(),j=Math.min(7,Math.round(g.x*this.tileToMeter/10)),T=Math.min(6,Math.round(g.y*this.tileToMeter/10));h.centroidXY=new as(Fe(h.groupCentroidPos.x,1,8191)<<3|j,Fe(h.groupCentroidPos.y,1,8191)<<3|T)}else h.centroidXY=new as(0,0);this.writeCentroidToBuffer(h)}writeCentroidToBuffer(c){this.groundEffect.updateHiddenByLandmark(c);const h=c.vertexArrayOffset,g=c.vertexCount+c.vertexArrayOffset,j=-1073741824&c.flags?s7:c.centroidXY,T=this.centroidVertexArray.geta_centroid_pos0(h);if(this.centroidVertexArray.geta_centroid_pos1(h)!==j.y||T!==j.x){for(let P=h;PF.max.x||F.min.x>P.max.x||P.min.y>F.max.y||F.min.y>P.max.y||P.footprint.buildingIds.has(F.buildingId)&&(F.flags|=P.clipMask!==t7.None?-1073741824:ov);else for(const F of this.centroidData)if(!(F.flags&ov||F.flags&r7||P.min.x>F.max.x||F.min.x>P.max.x||P.min.y>F.max.y||F.min.y>P.max.y))for(let H=0;Hh!=le>h&&c<(this.footprintVertices.int16[2*(Q+P.vertexOffset)+0]-se)*(h-re)/(le-re)+se&&(j=!j)}R=F}}return j}getHeightAtTileCoord(c,h){let g=Number.NEGATIVE_INFINITY,j=!0;const T=4*(c+sr)*sr+(h+sr);if(this.partLookup.hasOwnProperty(T)){const P=this.partLookup[T];return P?{height:P.height,hidden:!!(P.flags&ov)}:void 0}for(const P of this.centroidData)c>P.max.x||P.min.x>c||h>P.max.y||P.min.y>h||P.height<=g||this.footprintContainsPoint(c,h,P)&&(g=P.height,this.partLookup[T]=P,j=!!(P.flags&ov));if(g!==Number.NEGATIVE_INFINITY)return{height:g,hidden:j};this.partLookup[T]=void 0}}function e5e(x,c){const h=x.add(c)._unit();return x.x*h.x+x.y*h.y}function Hdt(x,c,h,g){const j=c.sub(x)._perp()._unit(),T=h.sub(c)._perp()._unit();return t5e(x,c,h,e5e(j,T),g)}function t5e(x,c,h,g,j){const T=Math.sqrt(1-g*g);return Math.min(x.dist(c)/3,c.dist(h)/3,j*T/g)}function hfe(x,c,h){return x.xh[1].x&&c.x>h[1].x||x.yh[1].y&&c.y>h[1].y}function s5e(x,c){return x.xc[1].x||x.yc[1].y}function Gdt(x){return x.every(c=>c.x<=0)||x.every(c=>c.x>=sr)||x.every(c=>c.y<=0)||x.every(c=>c.y>=sr)}function r5e(x,c,h){if(x.x<0||x.x>=sr||c.x<0||c.x>=sr||h.x<0||h.x>=sr)return!1;const g=h.sub(c),j=g.perp(),T=x.sub(c);return(g.x*T.x+g.y*T.y)/Math.sqrt((g.x*g.x+g.y*g.y)*(T.x*T.x+T.y*T.y))>-.866&&j.x*T.x+j.y*T.y<0}function n5e(x,c,h){const g=c?2|x:-3&x;return h?1|g:-2&g}function a5e(){const x=Math.PI/32,c=Math.tan(x),h=Et;return h*Math.sqrt(1+2*c*c)-h}function i5e(x,c,h){const g=1<{for(const jt of lt)ue.push({polygon:jt,bounds:Rt})},Ce=Math.ceil(Math.log2(Q)),Ee=Math.ceil(Math.log2(se)),Ge=Ce-Ee,Be=[];for(let lt=0;lt0?0:1);for(let lt=0;ltRt+1?it.push({polygons:xs,bounds:gs,depth:Rt+1}):_e(xs,gs)}if(Ns.length){const gs=[new as(jt===0?ls:It.x,jt===1?ls:It.y),Mt];Be.length>Rt+1?it.push({polygons:Ns,bounds:gs,depth:Rt+1}):_e(Ns,gs)}}return ue}(x,c,Math.ceil((T-j)/11.25),Math.ceil((P-R)/11.25),1,(F,H,Q)=>{if(F===0)return .5*(H+Q);{const se=ss((h.y+H/sr)/g);return(Ls(.5*(ss((h.y+Q/sr)/g)+se))*g-h.y)*sr}})}function Wdt(x,c,h,g,j,T){const P=Math.pow(2,g.z-j.z);for(let R=0;R=F[P]&&(R=c,F=x),R[P]j&&d5e(R,F,P,j),R[P]T&&d5e(F,R,P,T)}}function i7(x,c,h,g,j,T){const P=[];for(let R=0;R=g&&ue.x>=g||(le.x>=g?le=new as(g,le.y+(g-le.x)/(ue.x-le.x)*(ue.y-le.y))._round():ue.x>=g&&(ue=new as(g,le.y+(g-le.x)/(ue.x-le.x)*(ue.y-le.y))._round()),le.y>=j&&ue.y>=j||(le.y>=j?le=new as(le.x+(j-le.y)/(ue.y-le.y)*(ue.x-le.x),j)._round():ue.y>=j&&(ue=new as(le.x+(j-le.y)/(ue.y-le.y)*(ue.x-le.x),j)._round()),H&&le.equals(H[H.length-1])||(H=[le],P.push(H),T&&T.push({progress:{min:Ce+h5e(Ee,Ge,le)*_e,max:1},parentIndex:R,prevPoint:Ee,nextPoint:Ge})),H.push(ue),T&&(T[T.length-1].progress.max=Ce+h5e(Ee,Ge,ue)*_e,T[T.length-1].nextPoint=Ge)))))}if(T&&se>0)for(let re=Q;reH.t-Q.t);let P=0,R=0,F=[];for(g.push(F);P!==x.length;){if(R===T.length){for(;P!==x.length;)F.length!==0&&F[F.length-1].equals(x[P])||F.push(x[P]),P++;break}T[R].t<=P?(F.length!==0&&F[F.length-1].equals(T[R].point)||F.push(T[R].point),Math.trunc(T[R].t),R++):(F.length!==0&&F[F.length-1].equals(x[P])||F.push(x[P]),P++)}}function h5e(x,c,h){return x.x!==c.x?(h.x-x.x)/(c.x-x.x):x.y!==c.y?(h.y-x.y)/(c.y-x.y):0}function h6(x,c){return x.x*c.x+x.y*c.y}function m5e(x,c){if(x.length===1){let h=0;const g=c[h++];let j;for(;!j||g.equals(j);)if(j=c[h++],!j)return 1/0;for(;h{ls[0]=xs,ls[1]=Ns,ls[2]=gs,ls[3]=1},rs=a5e();le>0&&(le+=rs),ue+=rs;for(const ls of re){const xs=[],Ns=[];for(const gs of ls){const Rs=gs.x+_e.x,ts=gs.y+_e.y,ws=se.projection.projectTilePoint(Rs,ts,it),Ts=se.projection.upVector(it,gs.x,gs.y);let Os=le,Zs=ue;if(Ee){const xr=x5e(Rs,ts,le,ue,Ee,Ge,Be,nt);Os+=xr.base,Zs+=xr.top}le!==0?Tt(It,ws.x+Ts[0]*jt*Os,ws.y+Ts[1]*jt*Os,ws.z+Ts[2]*jt*Os):Tt(It,ws.x,ws.y,ws.z),Tt(Mt,ws.x+Ts[0]*jt*Zs,ws.y+Ts[1]*jt*Zs,ws.z+Ts[2]*jt*Zs),ct(It,It,Ce),ct(Mt,Mt,Ce),xs.push(new S2(It[0],It[1],It[2])),Ns.push(new S2(Mt[0],Mt[1],Mt[2]))}lt.push(xs),Rt.push(Ns)}return[lt,Rt]}(x,c,h,g,j,T,P,R,F,H,Q):P?function(se,re,le,ue,_e,Ce,Ee,Ge,Be){const nt=[],it=[],lt=[0,0,0,1];for(const Rt of se){const jt=[],It=[];for(const Mt of Rt){const Tt=Mt.x+ue.x,rs=Mt.y+ue.y,ls=x5e(Tt,rs,re,le,Ce,Ee,Ge,Be);lt[0]=Tt,lt[1]=rs,lt[2]=ls.base,lt[3]=1,mt(lt,lt,_e),lt[3]=Math.max(lt[3],1e-5);const xs=new S2(lt[0]/lt[3],lt[1]/lt[3],lt[2]/lt[3]);lt[0]=Tt,lt[1]=rs,lt[2]=ls.top,lt[3]=1,mt(lt,lt,_e),lt[3]=Math.max(lt[3],1e-5);const Ns=new S2(lt[0]/lt[3],lt[1]/lt[3],lt[2]/lt[3]);jt.push(xs),It.push(Ns)}nt.push(jt),it.push(It)}return[nt,it]}(c,h,g,j,T,P,R,F,H):function(se,re,le,ue,_e){const Ce=[],Ee=[],Ge=_e[8]*re,Be=_e[9]*re,nt=_e[10]*re,it=_e[11]*re,lt=_e[8]*le,Rt=_e[9]*le,jt=_e[10]*le,It=_e[11]*le;for(const Mt of se){const Tt=[],rs=[];for(const ls of Mt){const xs=ls.x+ue.x,Ns=ls.y+ue.y,gs=_e[0]*xs+_e[4]*Ns+_e[12],Rs=_e[1]*xs+_e[5]*Ns+_e[13],ts=_e[2]*xs+_e[6]*Ns+_e[14],ws=_e[3]*xs+_e[7]*Ns+_e[15],Ts=gs+Ge,Os=Rs+Be,Zs=ts+nt,xr=Math.max(ws+it,1e-5),er=gs+lt,Js=Rs+Rt,Ys=ts+jt,ur=Math.max(ws+It,1e-5);Tt.push(new S2(Ts/xr,Os/xr,Zs/xr)),rs.push(new S2(er/ur,Js/ur,Ys/ur))}Ce.push(Tt),Ee.push(rs)}return[Ce,Ee]}(c,h,g,j,T)}function x5e(x,c,h,g,j,T,P,R){const F=P*j.getElevationAt(x,c,!0,!0),H=T[0]!==0,Q=H?T[1]===0?P*(T[0]/7-450):P*function(se,re,le){const ue=Math.floor(re[0]/8),_e=Math.floor(re[1]/8),Ce=10*(re[0]-8*ue),Ee=10*(re[1]-8*_e),Ge=se.getElevationAt(ue,_e,!0,!0),Be=se.getMeterToDEM(le),nt=Math.floor(.5*(Ce*Be-1)),it=Math.floor(.5*(Ee*Be-1)),lt=se.tileCoordToPixel(ue,_e),Rt=2*nt+1,jt=2*it+1,It=function(Ns,gs,Rs,ts,ws){return[Ns.getElevationAtPixel(gs,Rs,!0),Ns.getElevationAtPixel(gs+ws,Rs,!0),Ns.getElevationAtPixel(gs,Rs+ws,!0),Ns.getElevationAtPixel(gs+ts,Rs+ws,!0)]}(se,lt.x-nt,lt.y-it,Rt,jt),Mt=Math.abs(It[0]-It[1]),Tt=Math.abs(It[2]-It[3]),rs=Math.abs(It[0]-It[2])+Math.abs(It[1]-It[3]),ls=Math.min(.25,.5*Be*(Mt+Tt)/Rt),xs=Math.min(.25,.5*Be*rs/jt);return Ge+Math.max(ls*Ce,xs*Ee)}(j,T,R):F;return{base:F+(h===0?-1:h),top:H?Math.max(Q+g,F+h+2):F+g}}const mfe=4096;class Zdt{constructor(c){this.module=c,this.memoryStack=this.module.malloc(mfe),this.memoryStackNextFree=this.memoryStack}createIntArray(c){const h=this.memoryStackNextFree;return this.memoryStackNextFree+=c.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>mfe?-1:(new Int32Array(this.module.heap32.buffer,h,c.length).set(c),h)}createFloatArray(c){const h=this.memoryStackNextFree;return this.memoryStackNextFree+=c.length*Float32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>mfe?-1:(new Float32Array(this.module.heapF32.buffer,h,c.length).set(c),h)}readStringBuffer(c){let h="";for(;this.module.heapU8[c]!==0;)h+=String.fromCharCode(this.module.heapU8[c]),++c;return h}setStyle(c){const h=c.normalScale;this.module.setStyle(h[0],h[1],h[2],c.tileToMeters)}setAOOptions(c,h){this.module.setAOOptions(c?1:0,h)}setMetricOptions(c,h){this.module.setMetricOptions(c?1:0,h)}setStructuralOptions(c){this.module.setStructuralOptions(c?1:0)}setFacadeOptions(c,h){this.module.setFacadeOptions(c,h?1:0)}setFauxFacadeOptions(c,h,g){this.module.setFauxFacadeOptions(c?1:0,h?1:0,g)}setFacadeClassifierOptions(c){this.module.setFacadeClassifierOptions(c)}generateMesh(c,h){this.memoryStackNextFree=this.memoryStack;for(const R of c){const F=this.createIntArray(R.ringIndices),H=this.createFloatArray(R.coordinates);if(F===-1||H===-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,H,F,R.ringIndices.length-1)}for(const R of h){let F;F=R.entrances?JSON.parse(R.entrances):[];const H=this.createFloatArray(F),Q=this.createFloatArray(R.coordinates);if(H===-1||Q===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(R.sourceId,R.crossPerc,R.distanceToRoad,H,F.length,Q,R.coordinates.length)}if(!this.module.generateMesh()){const R=this.module.getLastError();return this.readStringBuffer(R)}const g=this.module.getMeshCount(),j=new Array(g);for(let R=0;R>2)-3,Ce=le[ue++]>>2;if(ue++,j.json=JSON.parse(S5e.decode(le.subarray(ue,ue+Ce))),ue+=Ce,ue<_e){const Ee=le[ue++];ue++;const Ge=c+(ue<<2);j.buffers[0]=x.slice(Ge,Ge+Ee)}}else j.json=JSON.parse(S5e.decode(new Uint8Array(x,c)));const{buffers:T,images:P,meshes:R,extensionsUsed:F,bufferViews:H}=j.json;if(T){const le=[];for(let ue=0;ue>>0,Math.ceil(1.2*nt)),lt=Math.ceil((it-nt)/65536);try{return _e.grow(lt),Ce(),!0}catch{return!1}},b:Ee}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(le,Ge):le.then(Be=>Be.arrayBuffer()).then(Be=>WebAssembly.instantiate(Be,Ge))).then(Be=>{const{Rb:nt,Qb:it,P:lt,T:Rt,X:jt,Ja:It,La:Mt,Qa:Tt,Va:rs,Wa:ls,eb:xs,jb:Ns,f:gs,e:Rs,yb:ts,zb:ws,Ab:Ts,Bb:Os,Db:Zs,Gb:xr}=Be.instance.exports;_e=Rs;const er=(()=>{let Js=0,Ys=0,ur=0,Nr=0;return Ur=>{ur&&(nt(Nr),nt(Js),Ys+=ur,ur=Js=0),Js||(Ys+=128,Js=it(Ys));const Er=Ur.length+7&-8;let Tn=Js;Er>=Ys&&(ur=Er,Tn=Nr=it(Er));for(let Na=0;Na{Qx=le,m6=void 0}))}()),re&&Q.push(function(){if(pfe)return;const le=function(ue){let _e;const Ce=WebAssembly.instantiateStreaming(ue,{}).then(Be=>{_e=Be.instance,_e.exports.__wasm_call_ctors()}),Ee={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},Ge={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:Ce,supported:!0,decodeGltfBuffer(Be,nt,it,lt,Rt,jt){(function(It,Mt,Tt,rs,ls,xs,Ns){const gs=It.exports.sbrk,Rs=rs+3&-4,ts=gs(Rs*ls),ws=gs(xs.length),Ts=new Uint8Array(It.exports.memory.buffer);Ts.set(xs,ws);const Os=Mt(ts,rs,ls,ws,xs.length);if(Os===0&&Ns&&Ns(ts,Rs,ls),Tt.set(Ts.subarray(ts,ts+rs*ls)),gs(ts-gs(0)),Os!==0)throw new Error(`Malformed buffer data: ${Os}`)})(_e,_e.exports[Ge[Rt]],Be,nt,it,lt,_e.exports[Ee[jt]])}}}(fetch(ac()));return le.ready.then(()=>{pfe=le})}()),P)for(let le=0;le{const R=Jg(g,(F,H)=>{F?P(F):T(H)});j&&j.addEventListener("abort",()=>{R.cancel(),P(new DOMException("Aborted","AbortError"))},{once:!0})})}({url:x,type:"arrayBuffer"},c);return T5e(h,0,x,c)}function xfe(x){switch(x){case WebGL2RenderingContext.RGBA8:case WebGL2RenderingContext.RGBA16F: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 gfe(x){switch(x){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.RGBA16F:return WebGL2RenderingContext.HALF_FLOAT;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 yy{constructor(c,h,g,j){this.context=c,this.format=g,this.useMipmap=j&&j.useMipmap,this.texture=c.gl.createTexture(),this.update(h,{premultiply:j&&j.premultiply})}update(c,h){const g=c&&c instanceof HTMLVideoElement&&c.width===0?c.videoWidth:c.width,j=c&&c instanceof HTMLVideoElement&&c.height===0?c.videoHeight:c.height,{context:T}=this,{gl:P}=T,{x:R,y:F}=h&&h.position?h.position:{x:0,y:0},H=R+g,Q=F+j;this.size&&(this.size[0]!==H||this.size[1]!==Q)&&(!h||h.recreateWhenResize===void 0||h.recreateWhenResize)&&(P.bindTexture(P.TEXTURE_2D,null),P.deleteTexture(this.texture),this.texture=P.createTexture(),this.size=null),P.bindTexture(P.TEXTURE_2D,this.texture),T.pixelStoreUnpackFlipY.set(!1),T.pixelStoreUnpack.set(1),T.pixelStoreUnpackPremultiplyAlpha.set(this.format===P.RGBA8&&(!h||h.premultiply!==!1));const se=c instanceof HTMLImageElement||c instanceof HTMLCanvasElement||c instanceof HTMLVideoElement||c instanceof ImageData||ImageBitmap&&c instanceof ImageBitmap;if(!this.size&&H>0&&Q>0){const re=this.useMipmap?Math.floor(Math.log2(Math.max(H,Q)))+1:1;P.texStorage2D(P.TEXTURE_2D,re,this.format,H,Q),this.size=[H,Q]}this.size&&(se?P.texSubImage2D(P.TEXTURE_2D,0,R,F,xfe(this.format),gfe(this.format),c):"data"in c&&c.data&&P.texSubImage2D(P.TEXTURE_2D,0,R,F,g,j,xfe(this.format),gfe(this.format),c.data)),this.useMipmap&&P.generateMipmap(P.TEXTURE_2D)}bind(c,h,g=!1){const{context:j}=this,{gl:T}=j;T.bindTexture(T.TEXTURE_2D,this.texture),c!==this.minFilter&&(T.texParameteri(T.TEXTURE_2D,T.TEXTURE_MAG_FILTER,c),T.texParameteri(T.TEXTURE_2D,T.TEXTURE_MIN_FILTER,this.useMipmap&&!g?c===T.NEAREST?T.NEAREST_MIPMAP_NEAREST:T.LINEAR_MIPMAP_LINEAR:c),this.minFilter=c),h!==this.wrapS&&(T.texParameteri(T.TEXTURE_2D,T.TEXTURE_WRAP_S,h),T.texParameteri(T.TEXTURE_2D,T.TEXTURE_WRAP_T,h),this.wrapS=h)}bindExtraParam(c,h,g,j,T){const{context:P}=this,{gl:R}=P;R.bindTexture(R.TEXTURE_2D,this.texture),h!==this.magFilter&&(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_MAG_FILTER,h),this.magFilter=h),c!==this.minFilter&&(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_MIN_FILTER,this.useMipmap?c===R.NEAREST?R.NEAREST_MIPMAP_NEAREST:R.LINEAR_MIPMAP_LINEAR:c),this.minFilter=c),g!==this.wrapS&&(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_WRAP_S,g),this.wrapS=g),j!==this.wrapT&&(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_WRAP_T,j),this.wrapT=j),T!==this.compareMode&&(T?(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_COMPARE_MODE,R.COMPARE_REF_TO_TEXTURE),R.texParameteri(R.TEXTURE_2D,R.TEXTURE_COMPARE_FUNC,T)):R.texParameteri(R.TEXTURE_2D,R.TEXTURE_COMPARE_MODE,R.NONE),this.compareMode=T)}destroy(){const{gl:c}=this.context;c.deleteTexture(this.texture),this.texture=null}}class f6{constructor(c,h){this.context=c,this.texture=h}bind(c,h){const{context:g}=this,{gl:j}=g;j.bindTexture(j.TEXTURE_2D,this.texture),c!==this.minFilter&&(j.texParameteri(j.TEXTURE_2D,j.TEXTURE_MAG_FILTER,c),j.texParameteri(j.TEXTURE_2D,j.TEXTURE_MIN_FILTER,c),this.minFilter=c),h!==this.wrapS&&(j.texParameteri(j.TEXTURE_2D,j.TEXTURE_WRAP_S,h),j.texParameteri(j.TEXTURE_2D,j.TEXTURE_WRAP_T,h),this.wrapS=h)}}const sut=la([{name:"a_pos_3f",components:3,type:"Float32"}]),rut=la([{name:"a_color_3f",components:3,type:"Float32"}]),nut=la([{name:"a_color_4f",components:4,type:"Float32"}]),aut=la([{name:"a_uv_2f",components:2,type:"Float32"}]),iut=la([{name:"a_normal_3f",components:3,type:"Float32"}]),out=la([{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"}]),lut=la([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function E5e(x,c){const h=d7(x.projection,x.zoom,x.width,x.height),g=function(T,P,R,F,H){const Q=new qt(R.lng-180*o_,R.lat),se=new qt(R.lng+180*o_,R.lat),re=T.project(Q.lng,Q.lat),le=T.project(se.lng,se.lat),ue=-Math.atan2(le.y-re.y,le.x-re.x),_e=jr.fromLngLat(R);_e.y=Fe(_e.y,-1+o_,1-o_);const Ce=_e.toLngLat(),Ee=T.project(Ce.lng,Ce.lat),Ge=jr.fromLngLat(Ce);Ge.x+=o_;const Be=Ge.toLngLat(),nt=T.project(Be.lng,Be.lat),it=I5e(nt.x-Ee.x,nt.y-Ee.y,ue),lt=jr.fromLngLat(Ce);lt.y+=o_;const Rt=lt.toLngLat(),jt=T.project(Rt.lng,Rt.lat),It=I5e(jt.x-Ee.x,jt.y-Ee.y,ue),Mt=Math.abs(it.x)/Math.abs(It.y),Tt=w([]);V(Tt,Tt,-ue*(1-(H?0:F)));const rs=w([]);return I(rs,rs,[1,1-(1-Mt)*F,1]),rs[4]=-It.x/It.y*F,V(rs,rs,ue),C(rs,Tt,rs),rs}(x.projection,0,x.center,h,c),j=P5e(x);return I(g,g,[j,j,1]),g}function P5e(x){const c=x.projection,h=d7(x.projection,x.zoom,x.width,x.height),g=yfe(c,x.center),j=yfe(c,qt.convert(c.center));return Math.pow(2,g*h+(1-h)*j)}function d7(x,c,h,g,j=1/0){const T=x.range;if(!T)return 0;const P=Math.min(j,Math.max(h,g)),R=Math.log2(P/1024);return Xe(T[0]+R,T[1]+R,c)}const o_=1/4e4;function yfe(x,c){const h=Fe(c.lat,-85.051129,hs),g=new qt(c.lng-180*o_,h),j=new qt(c.lng+180*o_,h),T=x.project(g.lng,h),P=x.project(j.lng,h),R=jr.fromLngLat(g),F=jr.fromLngLat(j),H=P.x-T.x,Q=P.y-T.y,se=F.x-R.x,re=F.y-R.y,le=Math.sqrt((se*se+re*re)/(H*H+Q*Q));return Math.log2(le)}function I5e(x,c,h){const g=Math.cos(h),j=Math.sin(h);return{x:x*g-c*j,y:x*j+c*g}}function L5e(x,c,h){w(x),V(x,x,Zr(c[2])),L(x,x,Zr(c[0])),O(x,x,Zr(c[1])),I(x,x,h),C(x,x,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function u7(x,c,h,g,j,T,P,R){const F=[h[0]-c[0],h[1]-c[1],0],H=[g[0]-c[0],g[1]-c[1],0];if(ce(F)<1e-12||ce(H)<1e-12)return Ze(x);const Q=Ie([],F,H);Ne(Q,Q),me(H,g,c),F[2]=(T-j)*R,H[2]=(P-j)*R;const se=F;return Ie(se,F,H),Ne(se,se),lr(x,Q,se)}function h7(x,c,h=!1){const g=av(c.zoom),j=function(T,P,R){const F=P.worldSize,H=[T[12],T[13],T[14]],Q=ss(H[1]/F),se=Ht(H[0]/F),re=w([]),le=Zt(1,Q)*F,ue=Zt(1,0)*F*Ws(Q,P.zoom),_e=1/Upe(F);let Ce=ue*_e;if(R){const nt=d7(P.projection,P.zoom,P.width,P.height,1024);Ce=_e*P.projection.pixelSpaceConversion(P.center.lat,F,nt)}const Ee=_t(Q,se);oe(Ee,Ee,je([],Ne([],Ee),le*Ce*H[2]));const Ge=function(nt){const it=[nt[0],nt[1],nt[2]];let lt=[0,1,0];const Rt=Ie([],lt,it);return Ie(lt,it,Rt),Re(lt)===0&&(lt=[0,1,0],Ie(Rt,it,lt)),Ne(Rt,Rt),Ne(lt,lt),Ne(it,it),[Rt[0],Rt[1],Rt[2],0,lt[0],lt[1],lt[2],0,it[0],it[1],it[2],0,nt[0],nt[1],nt[2],1]}(Ee);I(re,re,[Ce,Ce,Ce*le]),A(re,re,[-H[0],-H[1],-H[2]]);const Be=C([],P.globeMatrix,Ge);return C(Be,Be,re),C(Be,Be,T),Be}(x,c,h);if(g>0){const T=function(P,R){const F=R.worldSize,H=Zt(1,0)*F*Ws(R.center.lat,R.zoom)/Upe(F),Q=Zt(1,R.center.lat)*F,se=w([]);O(se,se,Zr(R.center.lng)),L(se,se,Zr(R.center.lat)),A(se,se,[0,0,pt]),I(se,se,[H,H,H*Q]);const re=R.point;return A(se,se,[-re.x,-re.y,0]),C(se,se,P),C(se,R.globeMatrix,se)}(x,c);return function(P,R,F){const H=(ue,_e,Ce)=>{const Ee=ce(ue),Ge=ce(_e),Be=nv(ue,_e,Ce);return je(Be,Be,1/ce(Be)*on(Ee,Ge,Ce))},Q=H([P[0],P[1],P[2]],[R[0],R[1],R[2]],F),se=H([P[4],P[5],P[6]],[R[4],R[5],R[6]],F),re=H([P[8],P[9],P[10]],[R[8],R[9],R[10]],F),le=nv([P[12],P[13],P[14]],[R[12],R[13],R[14]],F);return[Q[0],Q[1],Q[2],0,se[0],se[1],se[2],0,re[0],re[1],re[2],0,le[0],le[1],le[2],1]}(j,T,g)}return j}function vfe(x,c,h,g){const j=ei.projectAabbCorners(g,h);let T=Number.MAX_VALUE;for(let R=0;R0||Ce===0&&ue[0]*_e[0]+ue[1]*_e[1]>=0&&ue[0]*ue[0]+ue[1]*ue[1]>_e[0]*_e[0]+_e[1]*_e[1])&&(Q=le)}se=Q}while(se!==H);return F.length>0&&F.push(F[0]),F}(j);if(Fo(x,P))return T}const C2=64,$3={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function m7(x,c,h,g,j,T,P,R,F,H=!1){const Q=h.zoom,se=h.project(g),re=Ws(g.lat,Q),le=1/re;w(x),A(x,x,[se.x+P[0]*le,se.y+P[1]*le,P[2]]);let ue=1,_e=1;const Ce=h.worldSize;if(H){if(h.projection.name==="mercator"){let nt=0;h.elevation&&(nt=h.elevation.getAtPointOrZero(new jr(se.x/Ce,se.y/Ce),0));const it=mt([],[se.x,se.y,nt,1],h.projMatrix)[3]/h.cameraToCenterDistance;ue=it,_e=it*Ws(h.center.lat,Q)}else if(h.projection.name==="globe"){const nt=h7(x,h),it=[0,0,0,1];mt(it,it,C([],h.projMatrix,nt));const lt=it[3]/h.cameraToCenterDistance,Rt=av(Q),jt=h.projection.pixelsPerMeter(g.lat,Ce)*Ws(g.lat,Q),It=h.projection.pixelsPerMeter(h.center.lat,Ce)*Ws(h.center.lat,Q);ue=lt/on(jt,Qs(h.center.lat),Rt),_e=lt*re/jt,ue*=It,_e*=It}}else ue=le;I(x,x,[ue,ue,_e]);const Ee=[...x],Ge=c.orientation,Be=[];if(L5e(Be,[Ge[0]+(j?j[0]:0),Ge[1]+(j?j[1]:0),Ge[2]+(j?j[2]:0)],T),C(x,Ee,Be),R&&h.elevation){let nt=0;const it=[];if(F&&h.elevation){nt=function(Rt,jt,It,Mt,Tt){const rs=jt.elevation;if(!rs)return 0;const ls=ei.projectAabbCorners(It,Mt),xs=Zt(1,Tt.lat)*jt.worldSize,Ns=function(Ys,ur){const Nr=[0,0,1],Ur=[{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 Er of Ur){const Tn=Ys[Er.corners[0]],Na=Ys[Er.corners[1]],An=Ys[Er.corners[2]],Ca=[Na[0]-Tn[0],Na[1]-Tn[1],ur*(Na[2]-Tn[2])],Hn=Ie(Ca,Ca,[An[0]-Tn[0],An[1]-Tn[1],ur*(An[2]-Tn[2])]);Ne(Hn,Hn),Er.dotProductWithUp=Ue(Hn,Nr)}return Ur.sort((Er,Tn)=>Er.dotProductWithUp-Tn.dotProductWithUp),Ur[0].corners}(ls,xs),gs=ls[Ns[0]],Rs=ls[Ns[1]],ts=ls[Ns[2]],ws=ls[Ns[3]],Ts=rs.getAtPointOrZero(new jr(gs[0]/jt.worldSize,gs[1]/jt.worldSize),0),Os=rs.getAtPointOrZero(new jr(Rs[0]/jt.worldSize,Rs[1]/jt.worldSize),0),Zs=rs.getAtPointOrZero(new jr(ts[0]/jt.worldSize,ts[1]/jt.worldSize),0),xr=rs.getAtPointOrZero(new jr(ws[0]/jt.worldSize,ws[1]/jt.worldSize),0),er=(Ts+xr)/2,Js=(Os+Zs)/2;return er>Js?Os=c.gl.NEAREST_MIPMAP_NEAREST}),x.uploaded=!0,x.image=null)}function cut(x,c,h){x.indexBuffer=c.createIndexBuffer(x.indexArray,!1,!0),x.vertexBuffer=c.createVertexBuffer(x.vertexArray,sut.members,!1,!0),x.normalArray&&(x.normalBuffer=c.createVertexBuffer(x.normalArray,iut.members,!1,!0)),x.texcoordArray&&(x.texcoordBuffer=c.createVertexBuffer(x.texcoordArray,aut.members,!1,!0)),x.colorArray&&(x.colorBuffer=c.createVertexBuffer(x.colorArray,(x.colorArray.bytesPerElement===12?rut:nut).members,!1,!0)),x.featureArray&&(x.pbrBuffer=c.createVertexBuffer(x.featureArray,lut.members,!0)),x.segments=ji.simpleSegment(0,0,x.vertexArray.length,x.indexArray.length);const g=x.material;g.pbrMetallicRoughness.baseColorTexture&&x6(g.pbrMetallicRoughness.baseColorTexture,c),g.pbrMetallicRoughness.metallicRoughnessTexture&&x6(g.pbrMetallicRoughness.metallicRoughnessTexture,c),g.normalTexture&&x6(g.normalTexture,c),g.occlusionTexture&&x6(g.occlusionTexture,c,h),g.emissionTexture&&x6(g.emissionTexture,c)}function _fe(x,c,h){if(x.meshes)for(const g of x.meshes)cut(g,c,h);if(x.children)for(const g of x.children)_fe(g,c,h)}function p7(x){if(x.meshes)for(const c of x.meshes)c.indexArray.destroy(),c.vertexArray.destroy(),c.colorArray&&c.colorArray.destroy(),c.normalArray&&c.normalArray.destroy(),c.texcoordArray&&c.texcoordArray.destroy(),c.featureArray&&c.featureArray.destroy();if(x.children)for(const c of x.children)p7(c)}function dut(x){x.pbrMetallicRoughness.baseColorTexture&&x.pbrMetallicRoughness.baseColorTexture.gfxTexture&&x.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),x.pbrMetallicRoughness.metallicRoughnessTexture&&x.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&x.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),x.normalTexture&&x.normalTexture.gfxTexture&&x.normalTexture.gfxTexture.destroy(),x.emissionTexture&&x.emissionTexture.gfxTexture&&x.emissionTexture.gfxTexture.destroy(),x.occlusionTexture&&x.occlusionTexture.gfxTexture&&x.occlusionTexture.gfxTexture.destroy()}function bfe(x){if(x.meshes)for(const c of x.meshes)c.vertexBuffer&&(c.vertexBuffer.destroy(),c.indexBuffer.destroy(),c.normalBuffer&&c.normalBuffer.destroy(),c.texcoordBuffer&&c.texcoordBuffer.destroy(),c.colorBuffer&&c.colorBuffer.destroy(),c.pbrBuffer&&c.pbrBuffer.destroy(),c.segments.destroy(),c.material&&dut(c.material));if(x.footprintDebugMesh&&(x.footprintDebugMesh.vertexBuffer.destroy(),x.footprintDebugMesh.indexBuffer.destroy(),x.footprintDebugMesh.segments.destroy()),x.children)for(const c of x.children)bfe(c)}function M2(x,c){const h=x.json.bufferViews[c.bufferView],g=l7[c.componentType];return new g(x.buffers[h.buffer],(c.byteOffset||0)+(h.byteOffset||0),c.count*(h.byteStride&&h.byteStride!==p6[c.type]*g.BYTES_PER_ELEMENT?h.byteStride/g.BYTES_PER_ELEMENT:p6[c.type]))}function wfe(x,c,h,g){const j=l7[c.componentType],T=function(Q){switch(Q){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(j),P=x.json.bufferViews[c.bufferView],R=P.byteStride?P.byteStride/j.BYTES_PER_ELEMENT:p6[c.type],F=h.float32,H=F.length/h.capacity;for(let Q=0,se=0;Q0){for(let Ce=0;Ce<_e;Ce++){const Ee=3*re[Ce];ue[0]+=le[Ee],ue[1]+=le[Ee+1],ue[2]+=le[Ee+2]}ue[0]/=_e,ue[1]/=_e,ue[2]/=_e}return ue}(F,Q),j.COLOR_0!==void 0){const re=c.json.accessors[j.COLOR_0],le=p6[re.type],ue=M2(c,re);T.colorArray=le===3?new Hm:new Yx,T.colorArray.resize(re.count),wfe(c,re,T.colorArray,ue)}if(j.NORMAL!==void 0){T.normalArray=new Hm;const re=c.json.accessors[j.NORMAL];T.normalArray.resize(re.count);const le=M2(c,re);wfe(c,re,T.normalArray,le)}if(j.TEXCOORD_0!==void 0&&h.length>0){T.texcoordArray=new ev;const re=c.json.accessors[j.TEXCOORD_0];T.texcoordArray.resize(re.count);const le=M2(c,re);wfe(c,re,T.texcoordArray,le)}if(j._FEATURE_ID_RGBA4444!==void 0){const re=c.json.accessors[j._FEATURE_ID_RGBA4444];c.json.extensionsUsed&&c.json.extensionsUsed.includes("EXT_meshopt_compression")&&(T.featureData=M2(c,re))}j._FEATURE_RGBA4444!==void 0&&(T.featureData=new Uint32Array(M2(c,c.json.accessors[j._FEATURE_RGBA4444]).buffer));const se=x.material;return T.material=function(re,le){const{emissiveFactor:ue=[0,0,0],alphaMode:_e="OPAQUE",alphaCutoff:Ce=.5,normalTexture:Ee,occlusionTexture:Ge,emissiveTexture:Be,doubleSided:nt,name:it}=re,{baseColorFactor:lt=[1,1,1,1],metallicFactor:Rt=1,roughnessFactor:jt=1,baseColorTexture:It,metallicRoughnessTexture:Mt}=re.pbrMetallicRoughness||{},Tt=Ge?le[Ge.index]:void 0;if(Ge&&Ge.extensions&&Ge.extensions.KHR_texture_transform&&Tt){const rs=Ge.extensions.KHR_texture_transform;Tt.offsetScale=[rs.offset[0],rs.offset[1],rs.scale[0],rs.scale[1]]}return{name:it,pbrMetallicRoughness:{baseColorFactor:new Aa(...lt),metallicFactor:Rt,roughnessFactor:jt,baseColorTexture:It?le[It.index]:void 0,metallicRoughnessTexture:Mt?le[Mt.index]:void 0},doubleSided:nt,emissiveFactor:new Aa(...ue),alphaMode:_e,alphaCutoff:Ce,normalTexture:Ee?le[Ee.index]:void 0,occlusionTexture:Tt,emissionTexture:Be?le[Be.index]:void 0,defined:re.defined===void 0}}(se!==void 0?c.json.materials[se]:{defined:!1},h),T}function R5e(x,c,h){const{matrix:g,rotation:j,translation:T,scale:P,mesh:R,extras:F,children:H,name:Q}=x,se={};if(se.name=Q,se.localMatrix=g||function(re,le,ue,_e){var Ce=le[0],Ee=le[1],Ge=le[2],Be=le[3],nt=Ce+Ce,it=Ee+Ee,lt=Ge+Ge,Rt=Ce*nt,jt=Ce*it,It=Ce*lt,Mt=Ee*it,Tt=Ee*lt,rs=Ge*lt,ls=Be*nt,xs=Be*it,Ns=Be*lt,gs=_e[0],Rs=_e[1],ts=_e[2];return re[0]=(1-(Mt+rs))*gs,re[1]=(jt+Ns)*gs,re[2]=(It-xs)*gs,re[3]=0,re[4]=(jt-Ns)*Rs,re[5]=(1-(Rt+rs))*Rs,re[6]=(Tt+ls)*Rs,re[7]=0,re[8]=(It+xs)*ts,re[9]=(Tt-ls)*ts,re[10]=(1-(Rt+Mt))*ts,re[11]=0,re[12]=ue[0],re[13]=ue[1],re[14]=ue[2],re[15]=1,re}([],j||[0,0,0,1],T||[0,0,0],P||[1,1,1]),se.globalMatrix=N(se.localMatrix),R!==void 0){se.meshes=h[R];const re=se.anchor=[0,0];for(const le of se.meshes){const{min:ue,max:_e}=le.aabb;re[0]+=ue[0]+_e[0],re[1]+=ue[1]+_e[1]}re[0]=Math.floor(re[0]/se.meshes.length/2),re[1]=Math.floor(re[1]/se.meshes.length/2)}if(F&&(F.id&&(se.id=F.id),F.lights&&(se.lights=function(re){if(!re.length)return[];const le=function(Ge){const Be=atob(Ge),nt=new Uint8Array(Be.length);for(let it=0;it1&&g[g.length-1].equals(g[0])&&g.pop();let j=0;for(let P=0;P0&&g.reverse();const T=R3(g.flatMap(P=>[P.x,P.y]),[]);return T.length===0?null:{vertices:g,indices:T}}function put(x,c){const h=[],g=[];let j=0;const T=[];for(const P of x){j=h.length;const R=P.vertexArray.float32,F=P.indexArray.uint16;for(let H=0;H0&&([g[P+1],g[P+2]]=[g[P+2],g[P+1]])}return{vertices:h,indices:g}}function jfe(x){const c=function(F,H){const Q=[],se=WebGL2RenderingContext;if(F.json.textures)for(const re of F.json.textures){const le={magFilter:se.LINEAR,minFilter:se.NEAREST,wrapS:se.REPEAT,wrapT:se.REPEAT};re.sampler!==void 0&&Object.assign(le,F.json.samplers[re.sampler]),Q.push({image:H[re.source],sampler:le,uploaded:!1})}return Q}(x,x.images),h=function(F,H){const Q=[];for(const se of F.json.meshes){const re=[];for(const le of se.primitives)re.push(uut(le,F,H));Q.push(re)}return Q}(x,c),{scenes:g,scene:j,nodes:T}=x.json,P=g?g[j||0].nodes:[...T.keys()],R=[];for(const F of P)R.push(R5e(T[F],x,h));return function(F,H,Q){const se={},re=new Set;for(let le=0;le0){const le=Array.from(re.values()).sort((ue,_e)=>ue-_e);for(let ue=le.length-1;ue>=0;ue--)F.splice(le[ue],1)}}(R,P,x.json.nodes),R}function fut(x){x.heightmap=new Float32Array(4096),x.heightmap.fill(-1);const c=x.vertexArray.float32,h=x.aabb.min[0]-1,g=x.aabb.min[1]-1,j=C2/(x.aabb.max[0]-h+2),T=C2/(x.aabb.max[1]-g+2);for(let P=0;Px.heightmap[H*C2+F]&&(x.heightmap[H*C2+F]=R)}}function O5e(x,c,h,g,j){h.reserve(h.length+4*x.length),g.reserve(g.length+10*x.length),j.reserve(j.length+10*x.length);let T=g.length;for(const P of x){const R=Math.min(10,Math.max(4,1.3*P.height))*c,F=[-P.normal[1],P.normal[0],0],H=Math.min(.29,.1*P.width/P.depth),Q=P.width-2*P.depth*c*(H+.01),se=qe([],P.pos,F,Q/2),re=qe([],P.pos,F,-Q/2),le=[se[0],se[1],se[2]+P.height],ue=[re[0],re[1],re[2]+P.height],_e=qe([],P.normal,F,H);je(_e,_e,R);const Ce=qe([],P.normal,F,-H);je(Ce,Ce,R),oe(_e,se,_e),oe(Ce,re,Ce),se[2]+=.1,re[2]+=.1,g.emplaceBack(_e[0],_e[1],_e[2]),g.emplaceBack(Ce[0],Ce[1],Ce[2]),g.emplaceBack(se[0],se[1],se[2]),g.emplaceBack(re[0],re[1],re[2]),g.emplaceBack(le[0],le[1],le[2]),g.emplaceBack(ue[0],ue[1],ue[2]),g.emplaceBack(se[0],se[1],se[2]),g.emplaceBack(re[0],re[1],re[2]),g.emplaceBack(_e[0],_e[1],_e[2]),g.emplaceBack(Ce[0],Ce[1],Ce[2]);const Ee=Q/R/2;j.emplaceBack(-Ee-H,-1,Ee,.8),j.emplaceBack(Ee+H,-1,Ee,.8),j.emplaceBack(-Ee,0,Ee,1.3),j.emplaceBack(Ee,0,Ee,1.3),j.emplaceBack(Ee+H,-.8,Ee,.7),j.emplaceBack(Ee+H,-.8,Ee,.7),j.emplaceBack(0,0,Ee,1.3),j.emplaceBack(0,0,Ee,1.3),j.emplaceBack(Ee+H,-1.2,Ee,.8),j.emplaceBack(Ee+H,-1.2,Ee,.8),h.emplaceBack(6+T,4+T,8+T),h.emplaceBack(7+T,9+T,5+T),h.emplaceBack(0+T,1+T,2+T),h.emplaceBack(1+T,3+T,2+T),T+=10}}function xut(x,c){const h={};h.indexArray=new Ao,h.vertexArray=new Hm,h.colorArray=new Yx,O5e(x,c,h.indexArray,h.vertexArray,h.colorArray);const g={defined:!0};g.emissiveFactor=Aa.black;const j={};return j.baseColorFactor=Aa.white,g.pbrMetallicRoughness=j,h.material=g,h.aabb=new ei([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),h}const F5e=la([{name:"a_pos_3f",components:3,type:"Float32"}]),gut=la([{name:"a_normal_3",components:3,type:"Int16"}]),yut=la([{name:"a_centroid_3",components:3,type:"Int16"}]),z5e=la([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),vut=la([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),_ut=la([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),but=la([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),wut=la([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),jut=la([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Int16"}]),B5e=pn.types,f7=32767;function Nut(x,c){const h=sr+c;for(const g of x)for(const j of g)if(j.x<-c||j.x>h||j.y<-c||j.y>h)return!1;return!0}function kut(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 Nfe{constructor(){this.layoutVertexArray=new Hm,this.layoutAttenuationArray=new Yx,this.layoutColorArray=new Gm,this.indexArray=new Ao,this.indexArrayForConflation=new Ao,this.segmentsBucket=new ji}}class kfe{constructor(c){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new ji,this.entranceBloom=new Nfe;const h=66560;this.layoutVertexArray=new Hm,this.layoutVertexArray.reserve(h),this.layoutNormalArray=new Df,this.layoutNormalArray.reserve(h),this.layoutCentroidArray=new Df,this.layoutCentroidArray.reserve(h),this.layoutColorArray=new Gm,this.layoutColorArray.reserve(h),this.layoutFloodLightDataArray=new A3,this.layoutFloodLightDataArray.reserve(h),this.layoutAOArray=new E3,this.layoutAOArray.reserve(h),this.indexArray=new Ao,this.indexArray.reserve(66560),this.indexArrayForConflation=new Ao,this.segmentsBucket=new ji,this.entranceBloom=new Nfe,c&&(this.layoutFacadePaintArray=new Gm,this.layoutFacadeDataArray=new e_,this.layoutFacadeVerticalRangeArray=new Gm)}reserve(c,h,g){this.layoutVertexArray.reserveForAdditional(c),this.layoutCentroidArray.reserveForAdditional(c),this.layoutFloodLightDataArray.reserveForAdditional(c),this.layoutNormalArray.reserveForAdditional(c),this.layoutAOArray.reserveForAdditional(c),this.layoutColorArray.reserveForAdditional(c),this.indexArray.reserveForAdditional(h),g&&(this.layoutFacadePaintArray.reserveForAdditional(c),this.layoutFacadeDataArray.reserveForAdditional(c),this.layoutFacadeVerticalRangeArray.reserveForAdditional(c))}}class $5e{constructor(c){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new ev,this.footprintsIndices=new tv,this.footprintsMin=new as(1/0,1/0),this.footprintsMax=new as(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new kfe(!1),this.buildingWithFacade=new kfe(!0),this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=new Map,this.buildingIds=new Set,this.footprintLookup={},this.zoom=c.zoom,this.canonical=c.canonical,this.layers=c.layers,this.layerIds=this.layers.map(h=>h.fqid),this.index=c.index,this.hasPattern=!1,this.worldview=c.worldview,this.lut=c.lut,this.programConfigurations=new Ae(c.layers,{zoom:c.zoom,lut:c.lut}),this.stateDependentLayerIds=this.layers.filter(h=>h.isStateDependent()).map(h=>h.id),this.projection=c.projection,this.groundEffect=new ufe(c),this.groundEffect.groundRadiusArray=new Jh,this.hasAppearances=null}updateFootprints(c,h){const g=new QF([],[],1),j={vertices:[],indices:new Uint32Array(0),grid:g,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};h.push({footprint:j,id:c})}updateAppearances(c,h,g,j){return{hasLayoutChanges:!1,hasUboChanges:!1}}prepare(){return function(){if(o7!=null||g5e!=null)return null;if(B3!=null)return B3;const c=fetch(ic());return B3=function(h){let g,j,T,P,R;function F(){g=new Uint8Array(R.buffer),j=new Int16Array(R.buffer),T=new Int32Array(R.buffer),P=new Float32Array(R.buffer)}function H(){throw new Error("Unexpected BuildingGen error.")}const Q=()=>{},se={a:{a:H,f:function(re){const le=g.length,ue=Math.max(re>>>0,Math.ceil(1.2*le)),_e=Math.ceil((ue-le)/65536);try{return R.grow(_e),F(),!0}catch{return!1}},g:H,b:Q,c:Q,d:Q,e:Q}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(h,se):h.then(re=>re.arrayBuffer()).then(re=>WebAssembly.instantiate(re,se))).then(re=>{const le=re.instance.exports;return(0,le.g)(),R=le.f,F(),new Zdt({setStyle:le.h,setAOOptions:le.i,setMetricOptions:le.j,setStructuralOptions:le.k,setFacadeOptions:le.l,setFauxFacadeOptions:le.m,setFacadeClassifierOptions:le.n,addFeature:le.o,addFacade:le.p,generateMesh:le.q,getLastError:le.r,getOuterRingLength:le.s,getMeshCount:le.t,getPositionsPtr:le.u,getPositionsLength:le.v,getNormalsPtr:le.w,getNormalsLength:le.x,getAOPtr:le.y,getAOLength:le.z,getUVPtr:le.A,getUVLength:le.B,getFauxFacadePtr:le.C,getFauxFacadeLength:le.D,getIndicesPtr:le.E,getIndicesLength:le.F,getBuildingPart:le.G,getRingCount:le.H,getRingPtr:le.I,getRingLength:le.J,malloc:le.K,free:le.L,heapU8:g,heap16:j,heap32:T,heapF32:P})})}(c).then(h=>(B3=null,o7=h,o7)).catch(h=>{zr("Could not load building-gen"),B3=null,g5e=h instanceof Error?h:new Error("Unknown error")}),B3}()}populate(c,h,g,j){const T=Ydt();if(!T)return;const P=As(g);this.tileToMeter=P,this.brightness=h.brightness,T.setStyle({normalScale:[1,-1,P],tileToMeters:P}),T.setAOOptions(!1,.3),T.setMetricOptions(!1,16),T.setStructuralOptions(!0),T.setFacadeClassifierOptions(3);const R=new Map,F=new Map;let H=0;for(const{feature:Ee}of c){if(B5e[Ee.type]!=="LineString"){R.set(Ee.id,Ee.properties.source_id);continue}const Ge=this.layers[0]._featureFilter.needGeometry;if(Ge&&!this.layers[0]._featureFilter.filter(new Ka(this.zoom),Ee,g))continue;const Be=Vn(Ee,Ge);if(!Ge&&!this.layers[0]._featureFilter.filter(new Ka(this.zoom),Be,g))continue;const nt=Ge?Be.geometry:Vr(Ee,g,j),it=[];for(const It of nt)for(const Mt of It)it.push(Mt.x),it.push(Mt.y);const lt={coordinates:it,crossPerc:Ee.properties.cross_perc,distanceToRoad:Ee.properties.distance_to_road,entrances:Ee.properties.entrances,sourceId:0},Rt=Ee.properties.source_id;let jt=F.get(Rt);jt||(jt=[],F.set(Rt,jt)),jt.push(lt),++H}this.maxHeight=0;const Q=new Array,se=new Set,re=Ee=>{Ee!=null&&se.add(Ee)},le=(Ee,Ge)=>{Ee!=null&&Q.push({buildingId:Ee,footprintIndex:Ge})},ue=64*(c.length-H),_e=ue/2;this.buildingWithFacade.reserve(ue,_e,!0),this.buildingWithoutFacade.reserve(2*ue,2*_e,!1),this.footprintsIndices.reserve(16*(c.length-H)),this.footprintsVertices.reserve(8*(c.length-H));for(const{feature:Ee,id:Ge,index:Be,sourceLayerIndex:nt}of c){if(B5e[Ee.type]==="LineString")continue;const it=this.layers[0]._featureFilter.needGeometry;if(it&&!this.layers[0]._featureFilter.filter(new Ka(this.zoom),Ee,g))continue;let lt=null;if(Ee.properties&&Ee.properties.hasOwnProperty("building_id")&&(lt=Number(Ee.properties.building_id),se.has(lt)))continue;const Rt=Vn(Ee,it);if(!it&&!this.layers[0]._featureFilter.filter(new Ka(this.zoom),Rt,g))continue;const jt=it?Rt.geometry:Vr(Ee,g,j),It=a6(jt,500);let Mt=!1;for(const ea of It)if(ea.length!==1){Mt=!0;break}if(Mt){re(lt);continue}if(!Nut(jt,163)){re(lt);continue}const Tt=this.layers[0],rs=kut(Tt.layout.get("building-roof-shape").evaluate(Ee,{},g)),ls=Tt.layout.get("building-base").evaluate(Ee,{},g),xs=Tt.layout.get("building-height").evaluate(Ee,{},g),Ns=Tt.layout.get("building-flood-light-ground-radius").evaluate(Ee,{},g),gs=Tt.paint.get("building-ambient-occlusion-intensity"),Rs=Ns/this.tileToMeter;Ee.properties["building-part"]="roof";const ts=Tt.paint.get("building-color").evaluate(Ee,{},this.canonical).toPremultipliedRenderColor(this.lut),ws=Tt.paint.get("building-emissive-strength").evaluate(Ee,{},this.canonical);Ee.properties["building-part"]="wall";const Ts=Tt.paint.get("building-color").evaluate(Ee,{},this.canonical).toPremultipliedRenderColor(this.lut),Os=Tt.paint.get("building-emissive-strength").evaluate(Ee,{},this.canonical);Ee.properties["building-part"]="window";const Zs=Tt.paint.get("building-color").evaluate(Ee,{},this.canonical).toPremultipliedRenderColor(this.lut),xr=Tt.paint.get("building-emissive-strength").evaluate(Ee,{},this.canonical);Ee.properties["building-part"]="door";const er=Tt.paint.get("building-color").evaluate(Ee,{},this.canonical).toPremultipliedRenderColor(this.lut),Js=Tt.paint.get("building-emissive-strength").evaluate(Ee,{},this.canonical);let Ys=Tt.layout.get("building-flood-light-wall-radius").evaluate(Ee,{},g);Ys=Fe(Ys,0,2048);const ur=Ys/2048*f7,Nr=R.get(Ge),Ur=F.get(Nr)||[],Er=Ur.length!==0&&Tt.layout.get("building-facade").evaluate(Ee,{},g);T.setFacadeOptions(4,!0),T.setFauxFacadeOptions(Er,!1,1);let Tn=0,Na=0,An=0,Ca=0,Hn=0,xo=0,Za=0,Da=0,Si=0,lo=0,cc=0;if(Er){let ea=Math.round(Tt.layout.get("building-facade-floors").evaluate(Ee,{},g));if(ls===0){ea=Math.max(1,ea-(Ur.length>0?1:0));let Io=4;if(xs>100){const Vl=[10,13,15];Io=Vl[Ee.id?Ee.id%Vl.length:0]}else xs<=10&&(Io=3);T.setFacadeOptions(Io,!0),Hn=(xs<15?1.3:1.61803)*Io/P}else Hn=ls/P;xo=xs/P,Hn=Math.min(Hn,xo),An=Tt.layout.get("building-facade-unit-width").evaluate(Ee,{},g)/P,Ca=(xo-Hn)/ea,T.setFauxFacadeOptions(!0,!0,An);const Ac=Tt.layout.get("building-facade-window").evaluate(Ee,{},g);Tn=Ac[0],Na=Ac[1],Za=Math.floor(65535*Math.min(1,Hn/sr)),Da=Math.floor(65535*Math.min(1,xo/sr)),Si=Math.floor(255*Tn)<<8|Math.floor(255*Na),lo=Math.floor(65535*Math.min(1,An/sr)),cc=Math.floor(65535*Math.min(1,Ca/sr))}const co=Array(It.length),Eo={x:1/0,y:1/0},rl={x:-1/0,y:-1/0},Po={x:0,y:0};let hd=0;for(let ea=0;ea0){const Io=[],Vl=Array(Ac.length+1);Vl[0]=0;for(let Rp=0;Rpsr||Eo.y<0||rl.y>sr)&&this.featuresOnBorder.push({featureId:Ee.id,footprintIndex:this.footprints.length});{const ea=R3(uv,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+ea.length),this.footprintsIndices.uint16.set(ea,e5),this.buildingIds.add(lt??Ee.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,Lp.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,Lp.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,Dp.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,Dp.y);const Ac={footprintVertexOffset:dv,footprintVertexLength:this.footprintsVertices.length-dv,footprintIndexOffset:e5,footprintIndexLength:this.footprintsIndices.length-e5,min:Lp,max:Dp,hiddenFlags:0,indicesOffset:V7,indicesLength:fxe,bloomIndicesOffset:md,bloomIndicesLength:go,groundEffectVertexOffset:D2,groundEffectVertexLength:t5,hasFauxFacade:Er,height:J3,promoteId:Ge,feature:Rt,parts:Mc,buildingBloom:Cu},Io=this.footprints.length;Ee.id!==void 0&&this.featureFootprintLookup.set(Ee.id,Io),le(lt,Io),this.footprints.push(Ac)}this.programConfigurations.populatePaintArrays(Kn.layoutVertexArray.length,Ee,Be,{},h.availableImages,g,h.brightness),this.groundEffect.addPaintPropertiesData(Ee,Be,{},h.availableImages,g,h.brightness),h.featureIndex.insert(Ee,jt,Be,nt,this.index,Xd)}Q.forEach(({buildingId:Ee,footprintIndex:Ge})=>{se.has(Ee)&&(this.footprints[Ge].hiddenFlags|=4)});const Ce=new Set;this.buildingIds.forEach((Ee,Ge,Be)=>{se.has(Ee)||Ce.add(Ee)}),this.buildingIds=Ce,this.groundEffect.prepareBorderSegments()}update(c,h,g,j,T,P,R){this.programConfigurations.updatePaintArrays(c,h,T,g,j,P,R),this.groundEffect.update(c,h,T,g,j,P,R),this.evaluate(this.layers[0],c),this.colorBufferUploaded=!1}isEmpty(){return this.buildingWithoutFacade.layoutVertexArray.length===0&&this.buildingWithFacade.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(c){const h=g=>{g.layoutVertexBuffer=c.createVertexBuffer(g.layoutVertexArray,F5e.members),g.layoutNormalBuffer=c.createVertexBuffer(g.layoutNormalArray,gut.members),g.layoutCentroidBuffer=c.createVertexBuffer(g.layoutCentroidArray,yut.members),g.layoutFloodLightDataBuffer=c.createVertexBuffer(g.layoutFloodLightDataArray,jut.members),g.layoutFacadeDataArray&&g.layoutFacadeDataArray.length&&(g.layoutFacadeDataBuffer=c.createVertexBuffer(g.layoutFacadeDataArray,_ut.members)),g.layoutFacadeVerticalRangeArray&&g.layoutFacadeVerticalRangeArray.length&&(g.layoutFacadeVerticalRangeBuffer=c.createVertexBuffer(g.layoutFacadeVerticalRangeArray,but.members)),g.entranceBloom.layoutVertexArray.length&&(g.entranceBloom.layoutVertexBuffer=c.createVertexBuffer(g.entranceBloom.layoutVertexArray,F5e.members),g.entranceBloom.layoutAttenuationBuffer=c.createVertexBuffer(g.entranceBloom.layoutAttenuationArray,wut.members)),this.uploadUpdatedColorBuffer(c),this.uploadUpdatedIndexBuffer(c)};this.uploaded||(h(this.buildingWithoutFacade),h(this.buildingWithFacade),this.groundEffect.upload(c)),this.groundEffect.uploadPaintProperties(c),this.programConfigurations.upload(c),this.uploaded=!0}destroy(){const c=h=>{h.layoutVertexBuffer&&(h.layoutVertexBuffer.destroy(),h.layoutNormalBuffer.destroy(),h.layoutColorBuffer.destroy(),h.segmentsBucket.destroy(),h.indexBuffer&&h.indexBuffer.destroy(),h.entranceBloom.layoutVertexBuffer&&(h.entranceBloom.layoutVertexBuffer.destroy(),h.entranceBloom.layoutColorBuffer.destroy(),h.entranceBloom.layoutAttenuationBuffer.destroy(),h.entranceBloom.indexBuffer.destroy(),h.entranceBloom.segmentsBucket.destroy()))};c(this.buildingWithoutFacade),c(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy()}updateFootprintHiddenFlags(c,h,g=!0){let j=!1;const T=g?h:0,P=0|(g?-1:~h);this.groundEffect.hiddenByLandmarkVertexArray.length===0&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const R of c){const F=this.footprints[R],H=F.hiddenFlags&P|T;F.hiddenFlags!==H&&(F.hiddenFlags=H,j=!0,this.groundEffect.updateHiddenByLandmarkRange(F.groundEffectVertexOffset,F.groundEffectVertexLength,F.hiddenFlags!==0))}return j&&(this.indexArrayForConflationUploaded=!1),j}uploadUpdatedIndexBuffer(c){if(this.groundEffect.uploadHiddenByLandmark(c),this.indexArrayForConflationUploaded)return;const h=j=>{j.indexArray.length!==0&&(j.indexArrayForConflation.resize(j.indexArray.length),j.indexArrayForConflation.uint16.set(j.indexArray.uint16),j.entranceBloom.indexArrayForConflation.resize(j.entranceBloom.indexArray.length),j.entranceBloom.indexArrayForConflation.uint16.set(j.entranceBloom.indexArray.uint16))};h(this.buildingWithoutFacade),h(this.buildingWithFacade);for(const j of this.footprints){const T=j.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,P=j.indicesOffset+j.indicesLength;if(j.hiddenFlags!==0){for(let F=j.indicesOffset;F{j.indexArray.length!==0&&(j.indexBuffer?j.indexBuffer.updateData(j.indexArrayForConflation):j.indexBuffer=c.createIndexBuffer(j.indexArrayForConflation,!0),j.entranceBloom.indexBuffer?j.entranceBloom.indexBuffer.updateData(j.entranceBloom.indexArrayForConflation):j.entranceBloom.indexBuffer=c.createIndexBuffer(j.entranceBloom.indexArrayForConflation,!0))};g(this.buildingWithoutFacade),g(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(c){const h=g=>{g.layoutColorBuffer?g.layoutColorBuffer.updateData(g.layoutColorArray):g.layoutColorBuffer=c.createVertexBuffer(g.layoutColorArray,z5e.members,!0),g.layoutFacadePaintArray&&(g.layoutFacadePaintBuffer?g.layoutFacadePaintBuffer.updateData(g.layoutFacadePaintArray):g.layoutFacadePaintBuffer=c.createVertexBuffer(g.layoutFacadePaintArray,vut.members,!0)),g.entranceBloom.layoutColorBuffer?g.entranceBloom.layoutColorBuffer.updateData(g.entranceBloom.layoutColorArray):g.entranceBloom.layoutColorBuffer=c.createVertexBuffer(g.entranceBloom.layoutColorArray,z5e.members,!0)};h(this.buildingWithoutFacade),h(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(c,h){const g=c.paint.get("building-ambient-occlusion-intensity");for(const j of this.footprints){if(4&j.hiddenFlags)continue;const T=h[j.promoteId],P=j.feature;P.properties["building-part"]="roof";const R=c.paint.get("building-color").evaluate(P,T,this.canonical).toPremultipliedRenderColor(this.lut),F=c.paint.get("building-emissive-strength").evaluate(P,T,this.canonical);P.properties["building-part"]="wall";const H=c.paint.get("building-color").evaluate(P,T,this.canonical).toPremultipliedRenderColor(this.lut),Q=c.paint.get("building-emissive-strength").evaluate(P,T,this.canonical);P.properties["building-part"]="window";const se=c.paint.get("building-color").evaluate(P,T,this.canonical).toPremultipliedRenderColor(this.lut),re=c.paint.get("building-emissive-strength").evaluate(P,T,this.canonical);P.properties["building-part"]="door";const le=c.paint.get("building-color").evaluate(P,T,this.canonical).toPremultipliedRenderColor(this.lut),ue=c.paint.get("building-emissive-strength").evaluate(P,T,this.canonical),_e=j.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const Ee of j.parts){let Ge,Be=R;Ee.part===1?(Be=R,Ge=F):Ee.part===0?(Be=H,Ge=Q):Ee.part===2?(Be=se,Ge=re):Ee.part===3&&(Be=le,Ge=ue),Ge=Fe(Ge,0,1);for(let nt=0;ntP.max.x||F.max.xP.max.y||F.max.yR.max.x||R.min.x>c||h>R.max.y||R.min.y>h||R.height<=g||Sut(P,this.footprintsVertices.float32.subarray(2*R.footprintVertexOffset,2*(R.footprintVertexOffset+R.footprintVertexLength)),this.footprintsIndices.uint16.subarray(R.footprintIndexOffset,R.footprintIndexOffset+R.footprintIndexLength))&&(g=R.height,this.footprintLookup[T]=R,j=R.hiddenFlags!==0);if(g!==Number.NEGATIVE_INFINITY)return{height:g,hidden:j};this.footprintLookup[T]=void 0}}function Sut(x,c,h){for(let g=0;g1&&(F=c[++R]);const Q=Math.abs(H-F.left),se=Math.abs(H-F.right),re=Math.min(Q,se);let le;const ue=T/g*(j+1);if(F.isDash){const _e=j-Math.abs(ue);le=Math.sqrt(re*re+_e*_e)}else le=j-Math.sqrt(re*re+ue*ue);this.image.data[P+H]=Math.max(0,Math.min(255,le+128))}}}addRegularDash(c,h){for(let F=c.length-1;F>=0;--F){const H=c[F],Q=c[F+1];H.zeroLength?c.splice(F,1):Q&&Q.isDash===H.isDash&&(Q.left=H.left,c.splice(F,1))}const g=c[0],j=c[c.length-1];g.isDash===j.isDash&&(g.left=j.left-this.width,j.right=g.right+this.width);const T=this.width*this.nextRow;let P=0,R=c[P];for(let F=0;F1&&(R=c[++P]);const H=Math.abs(F-R.left),Q=Math.abs(F-R.right),se=Math.min(H,Q);this.image.data[T+F]=Math.max(0,Math.min(255,(R.isDash?se:-se)+h+128))}}addDash(c,h){const g=this.getKey(c,h);if(this.positions[g])return this.positions[g];const j=h==="round",T=j?7:0,P=2*T+1;if(this.nextRow+P>this.height)return zr("LineAtlas out of space"),null;c.length===0&&c.push(1);let R=0;for(let se=0;seh.fqid),this.index=c.index,this.projection=c.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(h=>{this.gradients[h.id]={}}),this.layoutVertexArray=new m2,this.layoutVertexArray2=new Hm,this.patternVertexArray=new Hm,this.indexArray=new Ao,this.programConfigurations=new Ae(c.layers,{zoom:c.zoom,lut:c.lut}),this.segments=new ji,this.maxLineLength=0,this.zOffsetVertexArray=new Hm,this.elevationGroundScaleVertexArray=new Jh,this.stateDependentLayerIds=this.layers.filter(h=>h.isStateDependent()).map(h=>h.id),this.tessellationStep=c.tessellationStep?c.tessellationStep:128,this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,h){}updateAppearances(c,h,g,j){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(c,h,g,j){this.hasPattern=Kpe("line",this.layers,this.pixelRatio,h);const T=this.layers[0].layout.get("line-sort-key");this.tileToMeter=As(g);const P=this.layers[0].layout.get("line-elevation-reference");if(P==="hd-road-markup")this.elevationType="road";else{const re=this.layers[0].layout.get("line-z-offset"),le=re.isConstant()&&!re.constantOr(0);this.elevationType=P!=="sea"&&P!=="ground"&&le?"none":"offset",this.elevationType==="offset"&&P==="none"&&zr(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`),this.isSeaLevelReference=P==="sea"}const R=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope=this.elevationType==="offset"&&R!==void 0;const F=[];for(const{feature:re,id:le,index:ue,sourceLayerIndex:_e}of c){const Ce=this.layers[0]._featureFilter.needGeometry,Ee=Vn(re,Ce);if(!this.layers[0]._featureFilter.filter(new Ka(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),Ee,g))continue;const Ge=T?T.evaluate(Ee,{},g):void 0,Be={id:le,properties:re.properties,type:re.type,sourceLayerIndex:_e,index:ue,geometry:Ce?Ee.geometry:Vr(re,g,j),patterns:{},sortKey:Ge};F.push(Be)}T&&F.sort((re,le)=>re.sortKey-le.sortKey);const{lineAtlas:H,featureIndex:Q}=h,se=this.addConstantDashes(H);for(const re of F){const{geometry:le,index:ue,sourceLayerIndex:_e}=re;if(se&&this.addFeatureDashes(re,H),this.hasPattern){const Ce=Zpe("line",this.layers,re,this.zoom,this.pixelRatio,h);this.patternFeatures.push(Ce)}else this.addFeature(re,le,ue,g,H.positions,h.availableImages,h.brightness,h.elevationFeatures);Q.insert(c[ue].feature,le,ue,_e,this.index)}}addConstantDashes(c){let h=!1;for(const g of this.layers){const j=g.paint.get("line-dasharray").value,T=g.layout.get("line-cap").value;if(j.kind!=="constant"||T.kind!=="constant")h=!0;else{const P=T.value,R=j.value;if(!R)continue;c.addDash(R,P)}}return h}addFeatureDashes(c,h){const g=this.zoom;for(const j of this.layers){const T=j.paint.get("line-dasharray").value,P=j.layout.get("line-cap").value;if(T.kind==="constant"&&P.kind==="constant")continue;let R,F;if(T.kind==="constant"){if(R=T.value,!R)continue}else R=T.evaluate({zoom:g},c);F=P.kind==="constant"?P.value:P.evaluate({zoom:g},c),h.addDash(R,F),c.patterns[j.id]=[h.getKey(R,F)]}}update(c,h,g,j,T,P,R,F,H){this.programConfigurations.updatePaintArrays(c,h,T,g,j,P,R,H)}addFeatures(c,h,g,j,T,P){for(const R of this.patternFeatures)this.addFeature(R,R.geometry,R.index,h,g,j,P,c.elevationFeatures)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(c){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=c.createVertexBuffer(this.layoutVertexArray2,Iut)),this.patternVertexArray.length!==0&&(this.patternVertexBuffer=c.createVertexBuffer(this.patternVertexArray,Dut)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=c.createVertexBuffer(this.zOffsetVertexArray,Tut.members,!0)),!this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexArray.length>0&&(this.elevationGroundScaleVertexBuffer=c.createVertexBuffer(this.elevationGroundScaleVertexArray,Aut.members,!0)),this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,Eut),this.indexBuffer=c.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(c),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(c,h){let g,j;if(h&&h>0?(g=`mapbox_clip_start_${h}`,j=`mapbox_clip_end_${h}`):(g="mapbox_clip_start",j="mapbox_clip_end"),c.properties&&c.properties.hasOwnProperty(g)&&c.properties.hasOwnProperty(j))return{start:+c.properties[g],end:+c.properties[j]}}addFeature(c,h,g,j,T,P,R,F){const H=this.layers[0].layout,Q=H.get("line-join").evaluate(c,{}),se=H.get("line-cap").evaluate(c,{}),re=H.get("line-miter-limit"),le=H.get("line-round-limit");this.lineClips=this.lineFeatureClips(c),this.lineFeature=c;const ue=!(!c.properties||!c.properties.hasOwnProperty("mapbox_line_metrics"))&&c.properties.mapbox_line_metrics;this.zOffsetValue=H.get("line-z-offset").value;const _e=this.layers[0].paint.get("line-width").value;if(_e.kind!=="constant"&&_e.isLineProgressConstant===!1&&(this.variableWidthValue=_e),this.isSeaLevelReference){const Ce=H.get("line-elevation-ground-scale").value;Ce.kind==="constant"&&Ce.value===0||(this.elevationGroundScaleValue=Ce)}if(this.elevationType==="road"){const Ce=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(c,h,j,F,Q,se,re,le)){const[Ee,Ge]=this.clipRuntimeLinesToTile(h,1);for(let Be=0;Be0?it.parentIndex:null)}this.fillNonElevatedRoadSegment(Ce)}}else for(let Ce=0;Ce0?Ce:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,c,g,T,P,j,R,void 0,this.worldview)}computeSegNextDir(c,h){return c.nextPoint.sub(h.at(-2)).unit()}computeSegPrevDir(c,h){return h[1].sub(c.prevPoint).unit()}clipLinesToTile(c,h){return i7(c,-h,-h,sr+h,sr+h)}clipRuntimeLinesToTile(c,h){const g=[];return[i7(c,-h,-h,sr+h,sr+h,g),g]}addElevatedRoadFeature(c,h,g,j,T,P,R,F){const H=[],Q=Ci.getElevationFeature(c,j);if(Q){const se=this.clipLinesToTile(h,1),re=this.prepareElevatedLines(se,Q,g);for(const le of re)H.push({geometry:le,elevation:Q,elevationTileID:g,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(H.length===0)return!1;for(const se of H){const re=this.layoutVertexArray.length;this.addLine(se.geometry,c,g,T,P,R,F);const le=new Pi(g,se.elevationTileID);if(se.elevation)for(let ue=re;ue>1,this.layoutVertexArray.int16[6*ue+1]>>1),Ce=le.pointElevation(_e,se.elevation,.05);this.updateHeightRange(Ce),this.zOffsetVertexArray.emplaceBack(Ce,0,0)}else this.fillNonElevatedRoadSegment(re)}return!0}prepareElevatedLines(c,h,g){if(h.constantHeight!=null)return c;const j=[],T=1/As(g);for(const P of c)Kdt(P,new tm(h,T),0,j);return j}fillNonElevatedRoadSegment(c){for(let h=c;h0,re=F&&F.progress.max<1;if(this.lineClips){let It={min:this.lineClips.start,max:this.lineClips.end},Mt=1;if(F){const ls=this.lineClips.end-this.lineClips.start;It=function(xs,Ns,gs){return{min:Xi(xs.min,Ns,gs),max:Xi(xs.max,Ns,gs)}}(F.progress,{min:0,max:1},It),ls>0&&(Mt=(It.max-It.min)/ls)}const Tt=+h.properties.mapbox_clip_feature_len,rs=+h.properties.mapbox_clip_seg_len;if(Number.isNaN(Tt)||Number.isNaN(rs)){for(let xs=0;xs=2&&c[ue-1].equals(c[ue-2]);)ue--;let _e=0;for(;_e0,ws=this.overscaling<=16?122880/(512*this.overscaling):0;if(Mt&&Tt==="round"){if(NsP&&(Tt="bevel"),Tt==="bevel"&&(Ns>2&&(Tt="flipbevel"),Ns2*ws){const Zs=Ee.sub(Ee.sub(Ge)._mult(ws/Ts)._round());this.updateDistance(Ge,Zs),this.addCurrentVertex(Zs,nt,0,0,Ce,jt),Ge=Zs}this.updateDistance(Ge,Ee),ls._mult(Ns),this.addCurrentVertex(Ee,ls,0,0,Ce,jt);const Os=Ee.dist(Be);if(Os>2*ws){const Zs=Ee.add(Be.sub(Ee)._mult(ws/Os)._round());this.updateDistance(Ee,Zs),this.addCurrentVertex(Zs,it,0,0,Ce,jt),Ee=Zs}}else ls._mult(Ns),this.addCurrentVertex(Ee,ls,0,0,Ce,jt);else if(Tt==="flipbevel"){if(Ns>100)ls=it.mult(-1);else{const Ts=Ns*nt.add(it).mag()/nt.sub(it).mag();ls._perp()._mult(Ts*(ts?-1:1))}this.addCurrentVertex(Ee,ls,0,0,Ce,jt),this.addCurrentVertex(Ee,ls.mult(-1),0,0,Ce,jt)}else if(Tt==="bevel"||Tt==="fakeround"){const Ts=Ee.dist(Ge);let Os=1;if(this.elevationType==="offset"&&Tt==="bevel"&&this.currentLineJoinType!=="round"&&!this.patternJoinNone&&jt!=null&&Ge&&Be){const ur=4*ws;Ts1){this.lineSoFar=c.w;const _e=(h.x-c.x)/se,Ce=(h.y-c.y)/se,Ee=(h.z-c.z)/se,Ge=(h.w-c.w)/se,Be=h.x-c.x,nt=h.y-c.y,it=Math.sqrt(Be*Be+nt*nt);if(it===0)return;const lt=-nt/it,Rt=Be/it,jt=lt,It=Rt,Mt=-lt,Tt=-Rt;for(let rs=1;rs=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,Q),F.primitiveLength++),P?this.e2=Q:this.e1=Q,H!=null&&this.zOffsetVertexArray.emplaceBack(H.zOffset,H.variableWidth,H.variableWidth),this.elevationGroundScaleValue){const se=H?H.elevationGroundScale:this.evaluateElevationGroundScale();this.elevationGroundScaleVertexArray.emplaceBack(se)}}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance}updateDistance(c,h){this.prevDistance=this.distance,this.distance+=c.dist(h),this.updateScaledDistance()}}function Sfe(x,c,h){return x.xh||x.yh}let H5e,G5e;function W5e(x,c,h){return c*(sr/(x.tileSize*Math.pow(2,h-x.tileID.overscaledZ)))}yr(x7,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const K5e=(x,c,h)=>(1-h)*x+h*c;function Z5e(x,c){return 1/W5e(x,1,c.tileZoom)}function Y5e(x,c,h,g){return x.translatePosMatrix(g||c.tileID.projMatrix,c,h.paint.get("line-translate"),h.paint.get("line-translate-anchor"))}const X5e=x=>{const c=[];Q5e(x)&&c.push("RENDER_LINE_DASH"),x.paint.get("line-gradient")&&c.push("RENDER_LINE_GRADIENT"),x.paint.get("line-blend-mode")==="multiply"&&c.push("LINE_BLEND_MULTIPLY");const h=x.paint.get("line-trim-offset");h[0]===0&&h[1]===0||c.push("RENDER_LINE_TRIM_OFFSET"),x.paint.get("line-border-width").constantOr(1)!==0&&c.push("RENDER_LINE_BORDER");const g=x.layout.get("line-join").constantOr("miter")==="none",j=!!x.paint.get("line-pattern").constantOr(1);return g&&j&&c.push("LINE_JOIN_NONE"),c};function Q5e(x){const c=x.paint.get("line-dasharray").value;return c.kind!=="constant"||c.value}let Cfe;const J5e=()=>Cfe||(Cfe={layout:H5e||(H5e=new Qi({"line-cap":new Gs(Wt.layout_line["line-cap"]),"line-join":new Gs(Wt.layout_line["line-join"]),"line-miter-limit":new Xs(Wt.layout_line["line-miter-limit"]),"line-round-limit":new Xs(Wt.layout_line["line-round-limit"]),"line-sort-key":new Gs(Wt.layout_line["line-sort-key"]),"line-z-offset":new Gs(Wt.layout_line["line-z-offset"]),"line-elevation-reference":new Xs(Wt.layout_line["line-elevation-reference"]),"line-cross-slope":new Xs(Wt.layout_line["line-cross-slope"]),visibility:new Xs(Wt.layout_line.visibility),"line-width-unit":new Xs(Wt.layout_line["line-width-unit"]),"line-elevation-ground-scale":new Gs(Wt.layout_line["line-elevation-ground-scale"])})),paint:G5e||(G5e=new Qi({"line-opacity":new Gs(Wt.paint_line["line-opacity"]),"line-color":new Gs(Wt.paint_line["line-color"]),"line-translate":new Xs(Wt.paint_line["line-translate"]),"line-translate-anchor":new Xs(Wt.paint_line["line-translate-anchor"]),"line-width":new Gs(Wt.paint_line["line-width"]),"line-gap-width":new Gs(Wt.paint_line["line-gap-width"]),"line-offset":new Gs(Wt.paint_line["line-offset"]),"line-blur":new Gs(Wt.paint_line["line-blur"]),"line-dasharray":new Gs(Wt.paint_line["line-dasharray"]),"line-pattern":new Gs(Wt.paint_line["line-pattern"]),"line-pattern-cross-fade":new Xs(Wt.paint_line["line-pattern-cross-fade"]),"line-gradient":new Q1(Wt.paint_line["line-gradient"]),"line-trim-offset":new Xs(Wt.paint_line["line-trim-offset"]),"line-trim-fade-range":new Xs(Wt.paint_line["line-trim-fade-range"]),"line-trim-color":new Xs(Wt.paint_line["line-trim-color"]),"line-emissive-strength":new Gs(Wt.paint_line["line-emissive-strength"]),"line-border-width":new Gs(Wt.paint_line["line-border-width"]),"line-border-color":new Gs(Wt.paint_line["line-border-color"]),"line-occlusion-opacity":new Xs(Wt.paint_line["line-occlusion-opacity"]),"line-blend-mode":new Xs(Wt.paint_line["line-blend-mode"]),"line-color-use-theme":new Gs({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new Gs({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new Gs({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new Gs({type:"string",default:"default","property-type":"data-driven"})}))},Cfe);class zut extends Gs{possiblyEvaluate(c,h){return h=new Ka(Math.floor(h.zoom),{now:h.now,fadeDuration:h.fadeDuration,transition:h.transition,worldview:h.worldview}),super.possiblyEvaluate(c,h)}evaluate(c,h,g,j){return h=Object.assign({},h,{zoom:Math.floor(h.zoom)}),super.evaluate(c,h,g,j)}}let g6;function eMe(x,c){return c>0?c+2*x:x}const But=la([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),$ut=la([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),qut=la([{name:"a_projected_pos",components:4,type:"Float32"}],4);la([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Uut=la([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Vut=la([{name:"a_feature_index",components:1,type:"Float32"}],4),Hut=la([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),Gut=la([{name:"a_texb",components:2,type:"Uint16"}]),Wut=la([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),Kut=la([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);la([{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 tMe=la([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Zut=la([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);la([{name:"triangle",components:3,type:"Uint16"}]),la([{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"}]),la([{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"}]),la([{type:"Float32",name:"offsetX"}]),la([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);const Mfe=class Bie{constructor(c=null,h=0,g=4096){this.batchIndex=h,this.headerBuffer=null,this.propertiesBuffer=null,this.blockIndicesBuffer=null,this.context=c||null,this.propsDwords=g,this.totalBytes=4*this.propsDwords,this.headerData=new Uint32Array(Bie.HEADER_DWORDS),this.propertiesData=new Float32Array(this.propsDwords),this.blockIndicesData=new Uint32Array(this.propsDwords);for(let j=0;jc.maxUniformBlockSize)throw new Error(`UBO size ${this.totalBytes} exceeds device limit ${c.maxUniformBlockSize}`);if(this.headerBuffer=h.createBuffer(),!this.headerBuffer)throw new Error("Failed to create header UBO buffer");if(h.bindBuffer(h.UNIFORM_BUFFER,this.headerBuffer),h.bufferData(h.UNIFORM_BUFFER,Bie.HEADER_BYTES,h.DYNAMIC_DRAW),this.propertiesBuffer=h.createBuffer(),!this.propertiesBuffer)throw new Error("Failed to create properties UBO buffer");if(h.bindBuffer(h.UNIFORM_BUFFER,this.propertiesBuffer),h.bufferData(h.UNIFORM_BUFFER,this.totalBytes,h.DYNAMIC_DRAW),this.blockIndicesBuffer=h.createBuffer(),!this.blockIndicesBuffer)throw new Error("Failed to create block-indices UBO buffer");h.bindBuffer(h.UNIFORM_BUFFER,this.blockIndicesBuffer),h.bufferData(h.UNIFORM_BUFFER,this.totalBytes,h.DYNAMIC_DRAW),h.bindBuffer(h.UNIFORM_BUFFER,null)}writeHeader(c){const h=this.headerData;h[0]=c.dataDrivenMask,h[1]=c.zoomDependentMask,h[2]=c.dataDrivenBlockSizeVec4,h[3]=c.offsets[0],h[4]=c.offsets[1],h[5]=c.offsets[2],h[6]=c.offsets[3],h[7]=c.offsets[4],h[8]=c.offsets[5],h[9]=c.offsets[6],h[10]=c.offsets[7],h[11]=c.offsets[8]}writeDataDrivenBlock(c,h,g){const j=4*g.dataDrivenBlockSizeVec4;if(j===0)return;const T=h*j;if(T+j>this.propertiesData.length)throw new Error(`UBO write out of bounds: feature index ${h} exceeds propertiesData capacity`);for(let P=0;P<9;P++)g.dataDrivenMask&1<{if(!R)return;const H=g.getUniformBlockIndex(h,P);H!==g.INVALID_INDEX&&(g.uniformBlockBinding(h,H,F),g.bindBufferBase(g.UNIFORM_BUFFER,F,R))},T=3*this.batchIndex;j("SymbolPaintPropertiesHeaderUniform",this.headerBuffer,T),j("SymbolPaintPropertiesUniform",this.propertiesBuffer,T+1),j("SymbolPaintPropertiesIndexUniform",this.blockIndicesBuffer,T+2)}destroy(){if(this.context){const c=this.context.gl;this.headerBuffer&&(c.deleteBuffer(this.headerBuffer),this.headerBuffer=null),this.propertiesBuffer&&(c.deleteBuffer(this.propertiesBuffer),this.propertiesBuffer=null),this.blockIndicesBuffer&&(c.deleteBuffer(this.blockIndicesBuffer),this.blockIndicesBuffer=null)}}};Mfe.HEADER_DWORDS=12,Mfe.HEADER_BYTES=48;let Tfe=Mfe;function Afe(x,c,h,g){return[P3(255*x,255*c),P3(255*h,255*g)]}function sMe(x,c,h,g,j,T,P,R){return!!x&&(x.kind==="constant"?x.value==="none":x.kind==="composite"||x.kind==="source"?x.evaluate({zoom:0,brightness:T,worldview:R},c,h,j,g,P)==="none":typeof x=="string"&&x==="none")}yr(Tfe,"SymbolPropertiesUBO",{omit:["headerBuffer","propertiesBuffer","blockIndicesBuffer"]});class Efe{constructor(c,h,g,j,T="",P,R){this.layer=c,this.zoom=h,this.lut=g,this.isText=j,this.propDefs=this._getPropDefs(),this.worldview=T,this.maxUniformBufferBindings=P||24,this.uboSizeDwords=R||4096,this.featureVertexRangesFromId=new Map,this.allFeatures=[],this.ubos=[],this.featureCount=0,this.cachedHeader=null,this.maxFeaturesPerBatch=0,this.propertyHashToUBOIndex=new Map,this.canDeduplicate=this._checkIfAllPropertiesAreConstant(c,j),this.cachedParams=null,this.cachedParamsNext=null,this.cachedBrightness=void 0,this.cachedConstantUniforms=null,this.cachedConstantRenderZoom=null,this.cachedConstantBrightness=void 0,this.activeAppearanceByVtIndex=new Map}_getPropDefs(){const c=this.isText?"text":"icon";return[{name:`${c}-color`,useThemeName:`${c}-color-use-theme`,isColor:!0},{name:`${c}-halo-color`,useThemeName:`${c}-halo-color-use-theme`,isColor:!0},{name:`${c}-opacity`,useThemeName:null,isColor:!1},{name:`${c}-halo-width`,useThemeName:null,isColor:!1},{name:`${c}-halo-blur`,useThemeName:null,isColor:!1},{name:`${c}-emissive-strength`,useThemeName:null,isColor:!1},{name:`${c}-occlusion-opacity`,useThemeName:null,isColor:!1},{name:"symbol-z-offset",useThemeName:null,isColor:!1},{name:`${c}-translate`,useThemeName:null,isColor:!1,isVec2:!0}]}buildHeader(){const c=this.layer.paint,h=this.propDefs;let g=0,j=0,T=0,P=0;const R=[0,0,0,0,0,0,0,0,0];for(let F=0;F<9;F++){const{name:H,isColor:Q,isVec2:se}=h[F],re=c.get(H),le=!(!re||typeof re.isConstant!="function"||re.isConstant()),ue=this._appearancesHavePaintProperties(H),_e=le||ue,Ce=!(!re||!re.value||re.value.kind!=="composite"),Ee=this.layer._transitionablePaint._values[H],Ge=!_e&&(Ee&&Ee.value&&Ee.value.expression&&Ee.value.expression.kind)==="camera";_e?(g|=1<h.hasPaintProperty(c):this.isText?h=>h.hasTextPaintProperties():h=>h.hasIconPaintProperties())}_checkIfAllPropertiesAreConstant(c,h){const g=c.paint,j=h?"text":"icon",T=[`${j}-color`,`${j}-halo-color`,`${j}-opacity`,`${j}-halo-width`,`${j}-halo-blur`,`${j}-emissive-strength`,`${j}-occlusion-opacity`,"symbol-z-offset",`${j}-translate`];for(const P of T){const R=g.get(P);if(R&&typeof R=="object"&&"isConstant"in R&&!R.isConstant())return!1}return!this._appearancesHavePaintProperties()}_hashDataDrivenValues(c,h){if(h.dataDrivenMask===0)return"";const g=[];for(let j=0;j<9;j++){if(!(h.dataDrivenMask&1<=ue){zr(`Too many symbol features: batch ${re} requires binding points up to ${3*re+2}, device limit ${ue}. Some features will render incorrectly.`);const Ce={batchIndex:0,localFeatureIndex:0,vtFeatureIndex:h,featureId:F};return this.allFeatures.push(Ce),F!=null&&(this.featureVertexRangesFromId.has(F)||this.featureVertexRangesFromId.set(F,[]),this.featureVertexRangesFromId.get(F).push(Ce)),0}this.ubos[re]||(this.ubos[re]=new Tfe(R,re,this.uboSizeDwords),this.ubos[re].writeHeader(H)),this.ubos[re].writeDataDrivenBlock(Q,le,H);const _e={batchIndex:re,localFeatureIndex:le,vtFeatureIndex:h,featureId:F};return this.allFeatures.push(_e),F!=null&&(this.featureVertexRangesFromId.has(F)||this.featureVertexRangesFromId.set(F,[]),this.featureVertexRangesFromId.get(F).push(_e)),le}updateFeatures(c,h,g,j,T,P,R){if(this.layer=h,this.cachedConstantUniforms=null,!this.cachedHeader)return;const F=this.cachedHeader;for(const H of c){const Q=this.featureVertexRangesFromId.get(H);if(!Q)continue;const se=P[H]||{};for(const re of Q){if(!g)continue;const le=g.feature(re.vtFeatureIndex);if(!le)continue;const ue={type:le.type,id:H,properties:le.properties||{},geometry:[]},_e=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(re.vtFeatureIndex):void 0,Ce=this.evaluateAllProperties(ue,se,j,T,R,void 0,_e);this.ubos[re.batchIndex]&&this.ubos[re.batchIndex].writeDataDrivenBlock(Ce,re.localFeatureIndex,F)}}}updateDynamicExpressions(c,h,g,j,T,P){if(this.layer=c,this.cachedConstantUniforms=null,!this.cachedHeader)return;const R=this.cachedHeader;for(const F of this.allFeatures){if(!h)continue;const H=h.feature(F.vtFeatureIndex);if(!H)continue;const Q=F.featureId!=null&&T[F.featureId]||{},se={type:H.type,id:F.featureId,properties:H.properties||{},geometry:[]},re=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(F.vtFeatureIndex):void 0,le=this.evaluateAllProperties(se,Q,g,j,P,void 0,re);this.ubos[F.batchIndex]&&this.ubos[F.batchIndex].writeDataDrivenBlock(le,F.localFeatureIndex,R)}}updateFeaturePaintForAppearance(c,h,g,j,T,P,R){if(!this.layer||(this.activeAppearanceByVtIndex||(this.activeAppearanceByVtIndex=new Map),this.activeAppearanceByVtIndex.set(c,R||null),!this.cachedHeader))return!1;const F=this.cachedHeader;if(F.dataDrivenMask===0)return!1;let H=!1;for(const Q of this.allFeatures){if(Q.vtFeatureIndex!==c)continue;const se=this.evaluateAllProperties(h,g,j,T,P,void 0,R);this.ubos[Q.batchIndex]&&(this.ubos[Q.batchIndex].writeDataDrivenBlock(se,Q.localFeatureIndex,F),H=!0)}return H}getConstantUniformValues(c,h){const g=this.cachedHeader,j=!(!g||!g.cameraMask);if(this.cachedConstantUniforms&&this.cachedConstantBrightness===h&&(!j||this.cachedConstantRenderZoom===c))return this.cachedConstantUniforms;const T=this.layer.paint,P=this.propDefs,R=j?new Ka(c,{brightness:h,worldview:this.worldview}):null,F={type:1,id:void 0,properties:{},geometry:[]},H=re=>{const le=P[re],ue=T.get(le.name);if(!ue)return[0,0,0,1];const _e=le.useThemeName?T.get(le.useThemeName):void 0,Ce=sMe(_e&&typeof _e!="string"?_e.value:void 0,F,{},[],void 0,h,void 0,this.worldview)?null:this.lut;let Ee;Ee=g&&g.cameraMask&1<{const ue=T.get(P[re].name);if(!ue)return le;if(g&&g.cameraMask&1<{g.text=function(j,T,P){const R=T.layout.get("text-transform").evaluate(P,{});return R==="uppercase"?j=j.toLocaleUpperCase():R==="lowercase"&&(j=j.toLocaleLowerCase()),Wx.applyArabicShaping&&(j=Wx.applyArabicShaping(j)),j}(g.text,c,h)}),x}const y6={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Xut(x){return x==="︶"||x==="﹈"||x==="︸"||x==="﹄"||x==="﹂"||x==="︾"||x==="︼"||x==="︺"||x==="︘"||x==="﹀"||x==="︐"||x==="︓"||x==="︔"||x==="`"||x===" ̄"||x==="︑"||x==="︒"}function Qut(x){return x==="︵"||x==="﹇"||x==="︷"||x==="﹃"||x==="﹁"||x==="︽"||x==="︻"||x==="︹"||x==="︗"||x==="︿"}const Pfe=4294967296,rMe=1/Pfe,nMe=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");let g7=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,c,h=this.length){for(;this.pos>3,T=this.pos;this.type=7&g,x(j,c,this),this.pos===T&&this.skip(g)}return c}readMessage(x,c){return this.readFields(x,c,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)*Pfe;return this.pos+=8,x}readSFixed64(){const x=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Pfe;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 c=this.buf;let h,g;return g=c[this.pos++],h=127&g,g<128?h:(g=c[this.pos++],h|=(127&g)<<7,g<128?h:(g=c[this.pos++],h|=(127&g)<<14,g<128?h:(g=c[this.pos++],h|=(127&g)<<21,g<128?h:(g=c[this.pos],h|=(15&g)<<28,function(j,T,P){const R=P.buf;let F,H;if(H=R[P.pos++],F=(112&H)>>4,H<128||(H=R[P.pos++],F|=(127&H)<<3,H<128)||(H=R[P.pos++],F|=(127&H)<<10,H<128)||(H=R[P.pos++],F|=(127&H)<<17,H<128)||(H=R[P.pos++],F|=(127&H)<<24,H<128)||(H=R[P.pos++],F|=(1&H)<<31,H<128))return q3(j,F,T);throw new Error("Expected varint not more than 10 bytes")}(h,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,c=this.pos;return this.pos=x,x-c>=12&&nMe?nMe.decode(this.buf.subarray(c,x)):function(h,g,j){let T="",P=g;for(;P239?4:R>223?3:R>191?2:1;if(P+re>j)break;re===1?R<128&&(se=R):re===2?(F=h[P+1],(192&F)==128&&(se=(31&R)<<6|63&F,se<=127&&(se=null))):re===3?(F=h[P+1],H=h[P+2],(192&F)==128&&(192&H)==128&&(se=(15&R)<<12|(63&F)<<6|63&H,(se<=2047||se>=55296&&se<=57343)&&(se=null))):re===4&&(F=h[P+1],H=h[P+2],Q=h[P+3],(192&F)==128&&(192&H)==128&&(192&Q)==128&&(se=(15&R)<<18|(63&F)<<12|(63&H)<<6|63&Q,(se<=65535||se>=1114112)&&(se=null))),se===null?(se=65533,re=1):se>65535&&(se-=65536,T+=String.fromCharCode(se>>>10&1023|55296),se=56320|1023&se),T+=String.fromCharCode(se),P+=re}return T}(this.buf,c,x)}readBytes(){const x=this.readVarint()+this.pos,c=this.buf.subarray(this.pos,x);return this.pos=x,c}readPackedVarint(x=[],c){const h=this.readPackedEnd();for(;this.pos127;);else if(c===2)this.pos=this.readVarint()+this.pos;else if(c===5)this.pos+=4;else{if(c!==1)throw new Error(`Unimplemented type: ${c}`);this.pos+=8}}writeTag(x,c){this.writeVarint(x<<3|c)}realloc(x){let c=this.length||16;for(;c268435455||x<0?function(c,h){let g,j;if(c>=0?(g=c%4294967296|0,j=c/4294967296|0):(g=~(-c%4294967296),j=~(-c/4294967296),4294967295^g?g=g+1|0:(g=0,j=j+1|0)),c>=18446744073709552e3||c<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");h.realloc(10),function(T,P,R){R.buf[R.pos++]=127&T|128,T>>>=7,R.buf[R.pos++]=127&T|128,T>>>=7,R.buf[R.pos++]=127&T|128,T>>>=7,R.buf[R.pos++]=127&T|128,R.buf[R.pos]=127&(T>>>=7)}(g,0,h),function(T,P){const R=(7&T)<<4;P.buf[P.pos++]|=R|((T>>>=3)?128:0),T&&(P.buf[P.pos++]=127&T|((T>>>=7)?128:0),T&&(P.buf[P.pos++]=127&T|((T>>>=7)?128:0),T&&(P.buf[P.pos++]=127&T|((T>>>=7)?128:0),T&&(P.buf[P.pos++]=127&T|((T>>>=7)?128:0),T&&(P.buf[P.pos++]=127&T)))))}(j,h)}(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 c=this.pos;this.pos=function(g,j,T){for(let P,R,F=0;F55295&&P<57344){if(!R){P>56319||F+1===j.length?(g[T++]=239,g[T++]=191,g[T++]=189):R=P;continue}if(P<56320){g[T++]=239,g[T++]=191,g[T++]=189,R=P;continue}P=R-55296<<10|P-56320|65536,R=null}else R&&(g[T++]=239,g[T++]=191,g[T++]=189,R=null);P<128?g[T++]=P:(P<2048?g[T++]=P>>6|192:(P<65536?g[T++]=P>>12|224:(g[T++]=P>>18|240,g[T++]=P>>12&63|128),g[T++]=P>>6&63|128),g[T++]=63&P|128)}return T}(this.buf,x,this.pos);const h=this.pos-c;h>=128&&aMe(c,h,this),this.pos=c-1,this.writeVarint(h),this.pos+=h}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 c=x.length;this.writeVarint(c),this.realloc(c);for(let h=0;h=128&&aMe(h,g,this),this.pos=h-1,this.writeVarint(g),this.pos+=g}writeMessage(x,c,h){this.writeTag(x,2),this.writeRawMessage(c,h)}writePackedVarint(x,c){c.length&&this.writeMessage(x,Jut,c)}writePackedSVarint(x,c){c.length&&this.writeMessage(x,eht,c)}writePackedBoolean(x,c){c.length&&this.writeMessage(x,rht,c)}writePackedFloat(x,c){c.length&&this.writeMessage(x,tht,c)}writePackedDouble(x,c){c.length&&this.writeMessage(x,sht,c)}writePackedFixed32(x,c){c.length&&this.writeMessage(x,nht,c)}writePackedSFixed32(x,c){c.length&&this.writeMessage(x,aht,c)}writePackedFixed64(x,c){c.length&&this.writeMessage(x,iht,c)}writePackedSFixed64(x,c){c.length&&this.writeMessage(x,oht,c)}writeBytesField(x,c){this.writeTag(x,2),this.writeBytes(c)}writeFixed32Field(x,c){this.writeTag(x,5),this.writeFixed32(c)}writeSFixed32Field(x,c){this.writeTag(x,5),this.writeSFixed32(c)}writeFixed64Field(x,c){this.writeTag(x,1),this.writeFixed64(c)}writeSFixed64Field(x,c){this.writeTag(x,1),this.writeSFixed64(c)}writeVarintField(x,c){this.writeTag(x,0),this.writeVarint(c)}writeSVarintField(x,c){this.writeTag(x,0),this.writeSVarint(c)}writeStringField(x,c){this.writeTag(x,2),this.writeString(c)}writeFloatField(x,c){this.writeTag(x,5),this.writeFloat(c)}writeDoubleField(x,c){this.writeTag(x,1),this.writeDouble(c)}writeBooleanField(x,c){this.writeVarintField(x,+c)}};function q3(x,c,h){return h?4294967296*c+(x>>>0):4294967296*(c>>>0)+(x>>>0)}function aMe(x,c,h){const g=c<=16383?1:c<=2097151?2:c<=268435455?3:Math.floor(Math.log(c)/(7*Math.LN2));h.realloc(g);for(let j=h.pos-1;j>=x;j--)h.buf[j+g]=h.buf[j]}function Jut(x,c){for(let h=0;h=0&&g>=c&&y7[this.text.charCodeAt(g)];g--)h--;this.text=this.text.substring(c,h),this.sectionIndex=this.sectionIndex.slice(c,h)}substring(c,h){const g=new U3;return g.text=this.text.substring(c,h),g.sectionIndex=this.sectionIndex.slice(c,h),g.sections=this.sections,g}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((c,h)=>Math.max(c,this.sections[h].scale),0)}addTextSection(c,h){this.text+=c.text,this.sections.push(v6.forText(c.scale,c.fontStack||h));const g=this.sections.length-1;for(let j=0;j=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Ife(x,c,h,g,j,T,P,R,F,H,Q,se,re,le,ue,_e=1,Ce=1){const Ee=U3.fromFeature(x,j,_e,Ce);se===am.vertical&&Ee.verticalizePunctuation(re);let Ge=[];const Be=function(jt,It,Mt,Tt,rs,ls,xs=1){if(!jt)return[];const Ns=[],gs=function(ws,Ts,Os,Zs,xr,er,Js=1){let Ys=0;for(let ur=0;ur=0;let ts=0;for(let ws=0;ws0&&Xd>Hn&&(Hn=Xd)}else{const Mc=Mt[lo.fontStack];if(!Mc)continue;Mc[co]&&(Po=Mc[co]);const Cu=It[lo.fontStack];if(!Cu)continue;const md=Cu.glyphs[co];if(!md)continue;if(rl=md.metrics,dc=co!==8203?lc:0,Js){const go=Cu.ascender!==void 0?Math.abs(Cu.ascender):0,Xd=Cu.descender!==void 0?Math.abs(Cu.descender):0,Tc=(go+Xd)*Eo;xo-h/2;){if(P--,P<0)return!1;R-=x[P].dist(T),T=x[P]}R+=x[P].dist(x[P+1]),P++;const F=[];let H=0;for(;Rg;)H-=F.shift().angleDelta;if(H>j)return!1;P++,R+=Q.dist(se)}return!0}function fMe(x){let c=0;for(let h=0;hH){const ue=(H-F)/le,_e=on(se.x,re.x,ue),Ce=on(se.y,re.y,ue),Ee=new cv(_e,Ce,0,re.angleTo(se),Q);return!P||pMe(x,Ee,R,P,c)?Ee:void 0}F+=le}}function pht(x,c,h,g,j,T,P,R,F){const H=xMe(g,T,P),Q=gMe(g,j),se=Q*P,re=x[0].x===0||x[0].x===F||x[0].y===0||x[0].y===F;return c-se=0&&nt=0&&it=0&&re+H<=Q){const lt=new cv(nt,it,0,Ge,ue);g&&!pMe(x,lt,T,g,j)||le.push(lt)}}se+=Ee}return R||le.length||P||(le=yMe(x,se/2,h,g,j,T,P,!0,F)),le}function vMe(x){let c=0,h=0;for(const P of x)c+=P.w*P.h,h=Math.max(h,P.w);x.sort((P,R)=>R.h-P.h);const g=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(c/.95)),h),h:1/0}];let j=0,T=0;for(const P of x)for(let R=g.length-1;R>=0;R--){const F=g[R];if(!(P.w>F.w||P.h>F.h)){if(P.x=F.x,P.y=F.y,T=Math.max(T,P.y+P.h),j=Math.max(j,P.x+P.w),P.w===F.w&&P.h===F.h){const H=g.pop();H&&Rc.id?1:x.versionc.version?1:x.sxc.sx?1:x.syc.sy?1:0}function Ffe(x){let c=0;for(let h=0;h0,_Me(c,g,this.iconDescriptors,T),_Me(h,g,this.patternDescriptors,T),this.iconDescriptors.sort(_7),this.patternDescriptors.sort(_7);let P=0;const R=j?j.data:"";R&&(P=Jx(P,Ffe(R))),P=Jx(P,1);for(const F of this.iconDescriptors)P=Jx(P,Ffe(F.id)),P=Jx(P,F.version),P=Jx(P,F.sx),P=Jx(P,F.sy);P=Jx(P,1);for(const F of this.patternDescriptors)P=Jx(P,Ffe(F.id)),P=Jx(P,F.version),P=Jx(P,F.sx),P=Jx(P,F.sy);this.hash=P}subsetOf(c){return this.isSubsetArray(this.iconDescriptors,c.iconDescriptors,_7)&&this.isSubsetArray(this.patternDescriptors,c.patternDescriptors,_7)}isSubsetArray(c,h,g){let j=0,T=0;if(c.length>h.length)return!1;for(;j{const P=j.variant.id.toString().localeCompare(T.variant.id.toString());return P!==0?P:j.variant.sx!==T.variant.sx?j.variant.sx-T.variant.sx:j.variant.sy!==T.variant.sy?j.variant.sy-T.variant.sy:0});const g=new Map;for(const j of h)g.set(j.key,j.value);return g}class bMe{constructor(c){this.sourceAtlasHash=c}}class wMe{constructor(c,h,g,j){const T=new Map,P=new Map;this.haveRenderCallbacks=[];const R=[],F=j!==void 0,H=F?new Map:void 0,Q=F?$fe(c,H):c,se=F?$fe(h,H):h;this.addImages(Q,T,1,R),this.addImages(se,P,2,R);const{w:re,h:le}=vMe(R),ue=new Pd({width:re||1,height:le||1});for(const[_e,Ce]of Q.entries()){const Ee=T.get(_e).paddedRect;Pd.copy(Ce.data,ue,{x:0,y:0},{x:Ee.x+1,y:Ee.y+1},Ce.data,null,Ce.sdf)}for(const[_e,Ce]of se.entries()){const Ee=P.get(_e),Ge=Ee.paddedRect;let Be=Ee.padding;const nt=Ge.x+Be,it=Ge.y+Be,lt=Ce.data.width,Rt=Ce.data.height;Be=Be>1?Be-1:Be,Pd.copy(Ce.data,ue,{x:0,y:0},{x:nt,y:it},Ce.data,g),Pd.copy(Ce.data,ue,{x:0,y:Rt-Be},{x:nt,y:it-Be},{width:lt,height:Be},g),Pd.copy(Ce.data,ue,{x:0,y:0},{x:nt,y:it+Rt},{width:lt,height:Be},g),Pd.copy(Ce.data,ue,{x:lt-Be,y:0},{x:nt-Be,y:it},{width:Be,height:Rt},g),Pd.copy(Ce.data,ue,{x:0,y:0},{x:nt+lt,y:it},{width:Be,height:Rt},g),Pd.copy(Ce.data,ue,{x:lt-Be,y:Rt-Be},{x:nt-Be,y:it-Be},{width:Be,height:Be},g),Pd.copy(Ce.data,ue,{x:0,y:Rt-Be},{x:nt+lt,y:it-Be},{width:Be,height:Be},g),Pd.copy(Ce.data,ue,{x:0,y:0},{x:nt+lt,y:it+Rt},{width:Be,height:Be},g),Pd.copy(Ce.data,ue,{x:lt-Be,y:0},{x:nt-Be,y:it+Rt},{width:Be,height:Be},g)}this.lut=g,this.image=ue,this.iconPositions=T,this.patternPositions=P,F&&(this.contentDescriptor=new zfe(Q,se,j,g,H))}addImages(c,h,g,j){for(const[T,P]of c.entries()){const{bin:R,imagePosition:F,imageVariant:H}=Bfe(T,P,g);h.set(T,F),j.push(R),P.hasRenderCallback&&this.haveRenderCallbacks.push(H.id)}}patchUpdatedImages(c,h,g,j){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(T=>c.hasImage(T,g)),c.dispatchRenderCallbacks(this.haveRenderCallbacks,g);for(const T of c.getUpdatedImages(g)){for(const P of this.iconPositions.keys()){const R=Um.parse(P);if(kc.isEqual(R.id,T)){const F=c.getImage(T,g);this.patchUpdatedImage(this.iconPositions.get(P),F,h,null)}}for(const P of this.patternPositions.keys()){const R=Um.parse(P);if(kc.isEqual(R.id,T)){const F=c.getImage(T,g);this.patchUpdatedImage(this.patternPositions.get(P),F,h,j||this.lut)}}}}patchUpdatedImage(c,h,g,j=null){if(!c||!h||c.version===h.version)return;c.version=h.version;const[T,P]=c.tl,R=c.sdf;if(this.lut||R){const F={width:h.data.width,height:h.data.height},H=new Pd(F);Pd.copy(h.data,H,{x:0,y:0},{x:0,y:0},F,j,R),g.update(H,{position:{x:T,y:P},recreateWhenResize:!1})}else g.update(h.data,{position:{x:T,y:P},recreateWhenResize:!1})}}yr(_6,"ImagePosition"),yr(wMe,"ImageAtlas",{omit:["lut"]}),yr(bMe,"ImageAtlasReference");class b6{constructor(c){this.pendingRequests=new Map,this.cachedRanges=new Map,this.useServerFontComposition=!c||c.useServerFontComposition===void 0||c.useServerFontComposition}loadGlyphRange(c,h,g,j,T){if(this.useServerFontComposition)return void b6.loadGlyphRange(c,h,g,j,T);const P=c.split(",").map(R=>R.trim()).filter(R=>R.length>0);P.length!==0?P.length!==1?this._loadMultipleFonts(P,h,g,j,T):this._loadFont(P[0],h,g,j,T):T(new Error("Empty fontstack"))}_loadMultipleFonts(c,h,g,j,T){const P=c.map(()=>null),R={completed:0,firstError:null,callbackCalled:!1},F=(H,Q,se)=>{if(!R.callbackCalled&&(Q&&!R.firstError&&(R.firstError=Q),se&&(P[H]=se),R.completed++,R.completed===c.length)){R.callbackCalled=!0;const re=P.filter(ue=>ue!==null);if(re.length===0)return void T(R.firstError||new Error("All fonts failed to load"));const le=this._composeGlyphs(re);T(null,le)}};for(let H=0;H{F(H,Q,se)})}_loadFont(c,h,g,j,T){const P=`${c}:${h}`;if(this.cachedRanges.has(P)){const F=this.cachedRanges.get(P);return void Cd.frame(()=>T(null,F))}const R=this.pendingRequests.get(P);R?R.push(T):(this.pendingRequests.set(P,[T]),b6.loadGlyphRange(c,h,g,j,(F,H)=>{F||this.cachedRanges.set(P,H||null);const Q=this.pendingRequests.get(P);if(this.pendingRequests.delete(P),Q)for(const se of Q)se(F,H)}))}_composeGlyphs(c){const h={};let g,j;for(const T of c)if(g===void 0&&T.ascender!==void 0&&(g=T.ascender),j===void 0&&T.descender!==void 0&&(j=T.descender),T.glyphs)for(const P in T.glyphs)h[P]===void 0&&(h[P]=T.glyphs[P]);return{glyphs:h,ascender:g,descender:j}}}b6.loadGlyphRange=function(x,c,h,g,j){const T=256*c,P=T+255,R=g.transformRequest(g.normalizeGlyphsURL(h).replace("{fontstack}",x).replace("{range}",`${T}-${P}`),D0.Glyphs);ey(R,(F,H)=>{if(F)j(F);else if(H){const Q={},se=function(re){return new g7(re).readFields(lht,{})}(H);for(const re of se.glyphs)Q[re.id]=re;j(null,{glyphs:Q,ascender:se.ascender,descender:se.descender})}})};const w6=1e20;function jMe(x,c,h,g,j,T,P,R,F){for(let H=c;H-1);F++,T[F]=R,P[F]=H,P[F+1]=w6}for(let R=0,F=0;R{if(P){j.ascender=P.ascender,j.descender=P.descender;for(const R in P.glyphs)this._doesCharSupportLocalGlyph(+R)||(j.glyphs[+R]=P.glyphs[+R]);j.ranges[h]=!0}for(const R of j.requests[h]||[])R(T,P);delete j.requests[h]}))}getGlyphs(c,h){const g=[],j=this.url||ha.GLYPHS_URL;for(const T in c)for(const P of c[T])g.push({stack:T,id:P});bt(g,({stack:T,id:P},R)=>{let F=this.entries[T];F||(F=this.entries[T]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let H=F.glyphs[P];if(H!==void 0)return void R(null,{stack:T,id:P,glyph:H});if(H=this._tinySDF(F,T,P),H)return F.glyphs[P]=H,void R(null,{stack:T,id:P,glyph:H});const Q=Math.floor(P/256);if(256*Q>65535)return zr("glyphs > 65535 not supported"),void R(null,{stack:T,id:P,glyph:H});if(F.ranges[Q])return void R(null,{stack:T,id:P,glyph:H});let se=F.requests[Q];se||(se=F.requests[Q]=[],this.glyphLoader.loadGlyphRange(T,Q,j,this.requestManager,(re,le)=>{if(le){F.ascender=le.ascender,F.descender=le.descender;for(const ue in le.glyphs)this._doesCharSupportLocalGlyph(+ue)||(F.glyphs[+ue]=le.glyphs[+ue]);F.ranges[Q]=!0}for(const ue of se)ue(re,le);delete F.requests[Q]})),se.push((re,le)=>{re?R(re):le&&R(null,{stack:T,id:P,glyph:le.glyphs[P]||null})})},(T,P)=>{if(T)h(T);else if(P){const R={};for(const{stack:F,id:H,glyph:Q}of P)R[F]===void 0&&(R[F]={}),R[F].glyphs===void 0&&(R[F].glyphs={}),R[F].glyphs[H]=Q&&{id:Q.id,bitmap:Q.bitmap.clone(),metrics:Q.metrics},R[F].ascender=this.entries[F].ascender,R[F].descender=this.entries[F].descender;h(null,R)}})}_doesCharSupportLocalGlyph(c){return this.localGlyphMode!==qfe.none&&(this.localGlyphMode===qfe.all?!!this.localFontFamily:!!this.localFontFamily&&(f3(c)||fP(c)||l2(c)||Z0(c)||o2(c)||mP(c)||(h=c)>=131072&&h<=173791||(g=>g>=66736&&g<=66815)(c)));var h}_tinySDF(c,h,g){const j=this.localFontFamily;if(!j||!this._doesCharSupportLocalGlyph(g))return;let T=c.tinySDF;if(!T){let Ce="400";/bold/i.test(h)?Ce="900":/medium/i.test(h)?Ce="500":/light/i.test(h)&&(Ce="200"),T=c.tinySDF=new b7.TinySDF({fontFamily:j,fontWeight:Ce,fontSize:48,buffer:6,radius:16}),T.fontWeight=Ce}const P=T.fontWeight;if(this.localGlyphs[P][g])return this.localGlyphs[P][g];const R=String.fromCodePoint(g),{data:F,width:H,height:Q,glyphWidth:se,glyphHeight:re,glyphLeft:le,glyphTop:ue,glyphAdvance:_e}=T.draw(R);return this.localGlyphs[P][g]={id:g,bitmap:new n_({width:H,height:Q},F),metrics:{width:se/2,height:re/2,left:le/2,top:ue/2-27,advance:_e/2,localGlyph:!0}}}}function kMe(x,c){return x+c[1]-c[0]}function Ufe(x,c,h,g,j=1){const T=[],P=x.imagePrimary,R=P.pixelRatio,F=P.paddedRect.w-2,H=P.paddedRect.h-2,Q=(x.right-x.left)*j,se=(x.bottom-x.top)*j,re=P.stretchX||[[0,F]],le=P.stretchY||[[0,H]],ue=re.reduce(kMe,0),_e=le.reduce(kMe,0),Ce=F-ue,Ee=H-_e;let Ge=0,Be=ue,nt=0,it=_e,lt=0,Rt=Ce,jt=0,It=Ee;if(P.content&&g){const Tt=P.content;Ge=w7(re,0,Tt[0]),nt=w7(le,0,Tt[1]),Be=w7(re,Tt[0],Tt[2]),it=w7(le,Tt[1],Tt[3]),lt=Tt[0]-Ge,jt=Tt[1]-nt,Rt=Tt[2]-Tt[0]-Be,It=Tt[3]-Tt[1]-it}const Mt=(Tt,rs,ls,xs)=>{const Ns=j7(Tt.stretch-Ge,Be,Q,x.left*j),gs=N7(Tt.fixed-lt,Rt,Tt.stretch,ue),Rs=j7(rs.stretch-nt,it,se,x.top*j),ts=N7(rs.fixed-jt,It,rs.stretch,_e),ws=j7(ls.stretch-Ge,Be,Q,x.left*j),Ts=N7(ls.fixed-lt,Rt,ls.stretch,ue),Os=j7(xs.stretch-nt,it,se,x.top*j),Zs=N7(xs.fixed-jt,It,xs.stretch,_e),xr=new as(Ns,Rs),er=new as(ws,Rs),Js=new as(ws,Os),Ys=new as(Ns,Os),ur=new as(gs/R,ts/R),Nr=new as(Ts/R,Zs/R),Ur=c*Math.PI/180;if(Ur){const Hn=Math.sin(Ur),xo=Math.cos(Ur),Za=[xo,-Hn,Hn,xo];xr._matMult(Za),er._matMult(Za),Ys._matMult(Za),Js._matMult(Za)}const Er=Tt.stretch+Tt.fixed,Tn=ls.stretch+ls.fixed,Na=rs.stretch+rs.fixed,An=xs.stretch+xs.fixed,Ca=x.imageSecondary;return{tl:xr,tr:er,bl:Ys,br:Js,texPrimary:{x:P.paddedRect.x+1+Er,y:P.paddedRect.y+1+Na,w:Tn-Er,h:An-Na},texSecondary:Ca?{x:Ca.paddedRect.x+1+Er,y:Ca.paddedRect.y+1+Na,w:Tn-Er,h:An-Na}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:ur,pixelOffsetBR:Nr,minFontScaleX:Rt/R/Q,minFontScaleY:It/R/se,isSDF:h}};if(P.stretchX||P.stretchY){const Tt=SMe(re,Ce,ue),rs=SMe(le,Ee,_e);for(let ls=0;ls0?[Ge,-Be]:nt<0?[-Ge,Be]:Ge===0?[Be,Ge]:[Be,-Ge]}(h);let le=Math.abs(c.top-c.bottom);for(const Ee of c.positionedLines)le-=Ee.lineOffset;const ue=c.positionedLines.length,_e=le/ue;let Ce=c.top-h[1];for(let Ee=0;EeT)&&(T=ue.x),(!le||ue.y>P)&&(P=ue.y)}const F=Math.min(T-g,P-j);let H=F/2;const Q=new Gw([],yht);if(F===0)return new as(g,j);for(let le=g;lese.d||!se.d)&&(se=le,h&&console.log("found best %d after %d probes",Math.round(1e4*le.d)/1e4,re)),le.max-se.d<=c||(H=le.h/2,Q.push(new H3(le.p.x-H,le.p.y-H,H,x)),Q.push(new H3(le.p.x+H,le.p.y-H,H,x)),Q.push(new H3(le.p.x-H,le.p.y+H,H,x)),Q.push(new H3(le.p.x+H,le.p.y+H,H,x)),re+=4)}return h&&(console.log(`num probes: ${re}`),console.log(`best distance: ${se.d}`)),se.p}function yht(x,c){return c.max-x.max}b7.TinySDF=class{constructor({fontSize:x=24,buffer:c=3,radius:h=8,cutoff:g=.25,fontFamily:j="sans-serif",fontWeight:T="normal",fontStyle:P="normal",lang:R=null}={}){this.buffer=c,this.cutoff=g,this.radius=h,this.lang=R;const F=this.size=x+4*c,H=this._createCanvas(F),Q=this.ctx=H.getContext("2d",{willReadFrequently:!0});Q.font=`${P} ${T} ${x}px ${j}`,Q.textBaseline="alphabetic",Q.textAlign="left",Q.fillStyle="black",this.gridOuter=new Float64Array(F*F),this.gridInner=new Float64Array(F*F),this.f=new Float64Array(F),this.z=new Float64Array(F+1),this.v=new Uint16Array(F)}_createCanvas(x){const c=document.createElement("canvas");return c.width=c.height=x,c}draw(x){const{width:c,actualBoundingBoxAscent:h,actualBoundingBoxDescent:g,actualBoundingBoxLeft:j,actualBoundingBoxRight:T}=this.ctx.measureText(x),P=Math.ceil(h),R=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(T-j))),F=Math.min(this.size-this.buffer,P+Math.ceil(g)),H=R+2*this.buffer,Q=F+2*this.buffer,se=Math.max(H*Q,0),re=new Uint8ClampedArray(se),le={data:re,width:H,height:Q,glyphWidth:R,glyphHeight:F,glyphTop:P,glyphLeft:0,glyphAdvance:c};if(R===0||F===0)return le;const{ctx:ue,buffer:_e,gridInner:Ce,gridOuter:Ee}=this;this.lang&&(ue.lang=this.lang),ue.clearRect(_e,_e,R,F),ue.fillText(x,_e,_e+P);const Ge=ue.getImageData(_e,_e,R,F);Ee.fill(w6,0,se),Ce.fill(0,0,se);for(let Be=0;Be0?Rt*Rt:0,Ce[lt]=Rt<0?Rt*Rt:0}}jMe(Ee,0,0,H,Q,H,this.f,this.v,this.z),jMe(Ce,_e,_e,R,F,H,this.f,this.v,this.z);for(let Be=0;BeT.y!=_e.y>T.y&&T.x<(_e.x-ue.x)*(T.y-ue.y)/(_e.y-ue.y)+ue.x&&(R=!R),F=Math.min(F,Of(T,ue,_e))}}return(R?1:-1)*Math.sqrt(F)}(this.p,j),this.max=this.d+this.h*Math.SQRT2}}const vht=Object.keys,Vfe=Number.POSITIVE_INFINITY,_ht=Math.sqrt(2);function l_(x,c,h,g,j,T){const P=Dfe(x)&&x.collisionPadding?x.collisionPadding:[0,0,0,0],R={top:x.top-P[1],bottom:x.bottom+P[3],left:x.left-P[0],right:x.right+P[2],scaled:!1};return g!==void 0&&function(F,H){F.top*=H,F.bottom*=H,F.left*=H,F.right*=H,F.scaled=!0}(R,g),T&&(R.left+=T[0],R.right+=T[0],R.top+=T[1],R.bottom+=T[1]),h&&function(F,H,Q){if(!H)return;const se=Zr(H),re=new as(Q?Q[0]:0,Q?Q[1]:0),le=new as(F.left,F.top),ue=new as(F.right,F.top),_e=new as(F.left,F.bottom),Ce=new as(F.right,F.bottom);le._rotateAround(se,re),ue._rotateAround(se,re),_e._rotateAround(se,re),Ce._rotateAround(se,re),F.left=Math.min(le.x,ue.x,_e.x,Ce.x),F.right=Math.max(le.x,ue.x,_e.x,Ce.x),F.top=Math.min(le.y,ue.y,_e.y,Ce.y),F.bottom=Math.max(le.y,ue.y,_e.y,Ce.y)}(R,h,j),c?{top:Math.min(c.top,R.top),bottom:Math.max(c.bottom,R.bottom),left:Math.min(c.left,R.left),right:Math.max(c.right,R.right),scaled:c.scaled||R.scaled}:R}function TMe(x,[c,h]){let g=0,j=0;if(h===Vfe){c<0&&(c=0);const T=c/_ht;switch(x){case"top-right":case"top-left":j=T-7;break;case"bottom-right":case"bottom-left":j=7-T;break;case"bottom":j=7-c;break;case"top":j=c-7}switch(x){case"top-right":case"bottom-right":g=-T;break;case"top-left":case"bottom-left":g=T;break;case"left":g=c;break;case"right":g=-c}}else{switch(c=Math.abs(c),h=Math.abs(h),x){case"top-right":case"top-left":case"top":j=h-7;break;case"bottom-right":case"bottom-left":case"bottom":j=7-h}switch(x){case"top-right":case"bottom-right":case"right":g=-c;break;case"top-left":case"bottom-left":case"left":g=c}}return[g,j]}function bht(x,c,h,g,j,T,P,R,F,H,Q,se,re,le,ue){const _e=x.layers[0],Ce=_e.appearances;if(Ce.length===0)return{iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const Ee={iconBBox:null,iconVerticalBBox:null},Ge={textBBox:null,textVerticalBBox:null},{baseIconRotate:Be,baseTextRotate:nt,iconScaleFactor:it}=function(Rt,jt,It){const Mt=Rt.get("icon-rotate").evaluate(jt,{},It),Tt=Rt.get("text-rotate").evaluate(jt,{},It),[rs,ls]=Rt.get("icon-size-scale-range");return{baseIconRotate:Mt,baseTextRotate:Tt,iconScaleFactor:Fe(1,rs,ls)}}(g,j,T);c&&(Ee.iconBBox=l_(c,Ee.iconBBox,Be),h)&&(Ee.iconVerticalBBox=l_(h,Ee.iconVerticalBBox,Be+90));const lt=S7(se.horizontal);lt&&(Ge.textBBox=l_(lt,Ge.textBBox,nt,1,le)),se.vertical&&(Ge.textVerticalBBox=l_(se.vertical,Ge.textVerticalBBox,nt+90,1,le));for(const Rt of Ce)Rt.hasIconLayoutProperties()&&wht(Ee,x,_e,Rt,j,T,R,Be,P,F,c,H,it,Q,ue),Rt.hasTextLayoutProperties()&&jht(Ge,_e,Rt,j,T,le,nt,re,lt,se.vertical);return{iconBBox:Ee.iconBBox,iconVerticalBBox:Ee.iconVerticalBBox,textBBox:Ge.textBBox,textVerticalBBox:Ge.textVerticalBBox}}function wht(x,c,h,g,j,T,P,R,F,H,Q,se,re,le,ue){const{appearanceIconOffset:_e,appearanceIconRotate:Ce,appearanceIconSize:Ee}=AMe(g,h,j,T,P,R,F,H.iconScaleFactor);let Ge=null,Be=null,nt=null;g.hasLayoutProperty("icon-image")?nt=function(lt,Rt,jt,It,Mt,Tt,rs,ls){let xs=null;const Ns=Rt.getAppearanceValueAndResolveTokens(jt,"icon-image",It,Mt,ls);if(Ns){const gs=lt.getResolvedImageFromTokens(Ns),Rs=jt.hasLayoutProperty("icon-size")?jt.getUnevaluatedLayoutProperty("icon-size"):Rt._unevaluatedLayout._values["icon-size"],ts=j6(gs,T2(lt.zoom,Rs,lt.worldview,ls),Rs,Mt,lt.zoom,It,lt.pixelRatio,rs,lt.worldview,ls);xs=Tt.get(ts.iconPrimary.toString())}return xs}(c,h,g,j,T,se,re,ue):Q&&(nt=Q.imagePrimary),nt&&(Ge=v7(nt,null,_e,le),c.allowVerticalPlacement&&(Be=v7(nt,null,_e,le)));const it=F>0?Ee/F:1;Ge&&(x.iconBBox=l_(Ge,x.iconBBox,Ce,it!==1?it:void 0)),Be&&(x.iconVerticalBBox=l_(Be,x.iconVerticalBBox,Ce+90,it!==1?it:void 0))}function AMe(x,c,h,g,j,T,P,R){const F=x.hasLayoutProperty("icon-offset")?c.getAppearanceValueAndResolveTokens(x,"icon-offset",h,g,[]):null,H=F&&Array.isArray(F)?F:j,Q=x.hasLayoutProperty("icon-rotate")?c.getAppearanceValueAndResolveTokens(x,"icon-rotate",h,g,[]):null,se=typeof Q=="number"?Q:T,re=x.hasLayoutProperty("icon-size")?c.getAppearanceValueAndResolveTokens(x,"icon-size",h,g,[]):null;return{appearanceIconOffset:H,appearanceIconRotate:se,appearanceIconSize:typeof re=="number"?re*R:P}}function jht(x,c,h,g,j,T,P,R,F,H){const{appearanceTextOffset:Q,appearanceTextRotate:se,appearanceTextSize:re}=EMe(h,c,g,j,T,P,R),le=re/R,ue=[(Q[0]-T[0])*le,(Q[1]-T[1])*le],_e=ue[0]!==0||ue[1]!==0;F&&(x.textBBox=l_(F,x.textBBox,se,le,Q,_e?ue:void 0)),H&&(x.textVerticalBBox=l_(H,x.textVerticalBBox,se+90,le,Q,_e?ue:void 0))}function EMe(x,c,h,g,j,T,P){const R=x.hasLayoutProperty("text-offset")?c.getAppearanceValueAndResolveTokens(x,"text-offset",h,g,[]):null,F=R&&Array.isArray(R)?[R[0]*lc,R[1]*lc]:j,H=x.hasLayoutProperty("text-rotate")?c.getAppearanceValueAndResolveTokens(x,"text-rotate",h,g,[]):null,Q=typeof H=="number"?H:T,se=x.hasLayoutProperty("text-size")?c.getAppearanceValueAndResolveTokens(x,"text-size",h,g,[]):null;return{appearanceTextOffset:F,appearanceTextRotate:Q,appearanceTextSize:typeof se=="number"?se:P}}function k7(x,c,h,g,j,T,P,R,F){if(!c||!c.usvg)return;const H=mMe(g),Q=mMe(j),se=T!=="both"&&T!=="width"||!uMe(g)?1:Q.width/H.width,re=T!=="both"&&T!=="height"||!hMe(g)?1:Q.height/H.height;h.scaleSelf(se,re);const le=h.toString();P.set(le,h),R.set(le,c);const{imagePosition:ue}=Bfe(le,c,1);F.set(le,ue)}function PMe(x,c,h,g,j,T,P,R,F,H){if(!x)return;const Q=function(se,re,le,ue,_e,Ce,Ee){if(se.kind==="camera")return se.maxSize;if(se.kind==="composite"){const Ge=re.possiblyEvaluate(new Ka(se.maxZoom,{worldview:Ce}),le,Ee).evaluate(_e,{},le,Ee),Be=re.possiblyEvaluate(new Ka(se.minZoom,{worldview:Ce}),le,Ee).evaluate(_e,{},le,Ee);return Math.max(Ge,Be)}return re.possiblyEvaluate(new Ka(ue,{worldview:Ce}),le,Ee).evaluate(_e,{},le,Ee)}(c,h,g,j,T,F,H);return x.scaleSelf(Q*R*P)}function j6(x,c,h,g,j,T,P,R,F,H){return{iconPrimary:PMe(x.getPrimary(),c,h,g,j,T,P,R,F,H),iconSecondary:PMe(x.getSecondary(),c,h,g,j,T,P,R,F,H)}}function Nht(x,c,h){if(!c)return;const g=h.get(x.toString()),j=h.get(c.toString());g&&j&&(g.paddedRect.w===j.paddedRect.w&&g.paddedRect.h===j.paddedRect.h||zr(`Mismatch in icon variant sizes: ${x.toString()} and ${c.toString()}`),g.usvg!==j.usvg&&zr(`Mismatch in icon variant image types: ${x.id} and ${c.id}`))}function IMe(x,c,h,g){if(!x)return;const j=c.get(h.toString());if(j&&(x.imagePrimary=j),g){const T=c.get(g.toString());x.imageSecondary=T}}function kht(x,c){for(const h in x.horizontal)LMe(x.horizontal[h],c);LMe(x.vertical,c)}function LMe(x,c){if(x){for(const h of x.positionedLines)for(const g of h.positionedGlyphs)if(g.image!==null){const j=g.image.toString();g.rect=c.get(j).paddedRect}}}function Hfe(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 Sht(x,c,h,g,j,T,P,R,F){const H=S7(T.horizontal)||T.vertical,Q=h.get("icon-text-fit-padding").evaluate(g,{},j);let se,re=c;return c&&F!=="none"&&(x.allowVerticalPlacement&&T.vertical&&(se=Rfe(c,T.vertical,F,Q,R,P)),H&&(re=Rfe(c,H,F,Q,R,P))),{defaultShapedIcon:re,verticallyShapedIcon:se}}function DMe(x,c){return x*c/24}function Cht(x,c,h,g,j,T,P,R,F,H,Q,se,re,le,ue,_e,Ce,Ee,Ge,Be,nt,it,lt,Rt){let jt=P.textMaxSize.evaluate(c,{},re);jt===void 0?jt=R*P.textScaleFactor:jt*=P.textScaleFactor;const It=x.layers[0].layout,Mt=DMe(R,P.textScaleFactor),Tt=S7(h.horizontal)||h.vertical,rs=x.hasAnyAppearanceLayoutProperty(["text-size","text-offset","text-rotate"]),ls=x.getAppearanceFeatureData(c.index);(Ce!=="none"||rs)&&ls&&(ls.textShaping=Tt,ls.iconTextFitPadding=It.get("icon-text-fit-padding").evaluate(c,{},re),ls.fontScale=Mt,ls.textScaleFactor=P.textScaleFactor);const xs=le.name==="globe",Ns=x.tilePixelRatio*jt/24,gs=(Zs=x.overscaling,x.zoom>18&&Zs>2&&(Zs>>=1),Math.max(sr/(512*Zs),1)*It.get("symbol-spacing")),Rs=It.get("text-padding")*x.tilePixelRatio,ts=It.get("icon-padding")*x.tilePixelRatio,ws=Zr(It.get("text-max-angle")),Ts=It.get("icon-rotation-alignment")==="map"&&Be!=="point",Os=gs/2;var Zs;x.hasAnyIconTextFit===!1&&Ce!=="none"&&(x.hasAnyIconTextFit=!0);const xr=c.properties?+c.properties[Fn]:null,er=xr&&x.elevationFeatureIdToIndex?x.elevationFeatureIdToIndex.get(xr):65535,Js=(Ys,ur,Nr)=>{if(ur.x<0||ur.x>=sr||ur.y<0||ur.y>=sr)return;let Ur=null;if(xs){const{x:Er,y:Tn,z:Na}=le.projectTilePoint(ur.x,ur.y,Nr);Ur={anchor:new cv(Er,Tn,Na,0,void 0),up:le.upVector(Nr,ur.x,ur.y)}}(function(Er,Tn,Na,An,Ca,Hn,xo,Za,Da,Si,lo,cc,co,Eo,rl,Po,hd,dc,Kn,Su,zo,Mc,Cu,md,go,Xd,Tc,V7,J3,Yu,fxe,e5){const dv=Er.addToLineVertexArray(Tn,An);let uv,Lp,Dp,D2,t5,ea,Ac,Io=0,Vl=0,Rp=0,im=0,om=-1,lm=-1;const Bf={};let H7=ar("");const rg=Na?Na.anchor:Tn,s5=V7!=="none";let r5=0,Tl=0;if(Da._unevaluatedLayout.getValue("text-radial-offset")===void 0){const Bo=Da.layout.get("text-offset").evaluate(zo,{},go);r5=Bo[0]*lc,Tl=Bo[1]*lc}else r5=Da.layout.get("text-radial-offset").evaluate(zo,{},go)*lc,Tl=Vfe;if(Er.allowVerticalPlacement&&Ca.vertical){const Bo=Ca.vertical;if(rl)ea=Kfe(Bo),Za&&(Ac=Kfe(Za));else{const Mu=Da.layout.get("text-rotate").evaluate(zo,{},go)+90;Dp=C7(Si,rg,Tn,lo,cc,co,Bo,Eo,Mu,Po,e5),Za&&(D2=C7(Si,rg,Tn,lo,cc,co,Za,dc,Mu,null,fxe))}}if(Hn){const Bo=Da.layout.get("icon-rotate").evaluate(zo,{},go),Mu=Ufe(Hn,Bo,Cu,s5,Mc.iconScaleFactor),Xu=Za?Ufe(Za,Bo,Cu,s5,Mc.iconScaleFactor):void 0;Lp=C7(Si,rg,Tn,lo,cc,co,Hn,dc,Bo,null,Yu);const qf=function(ng,F6,n5,qmt,Umt,sAe,rAe,Vmt,LTs,gxe){const nAe=ng.layers[0],aAe=nAe.appearances;let a5=F6.length;if(n5&&(a5=Math.max(a5,n5.length)),aAe.length===0)return a5;const[Hmt,Gmt]=qmt.get("icon-size-scale-range"),Wmt=Fe(1,Hmt,Gmt);for(const Z7 of aAe)if(Z7.hasLayoutProperty("icon-image")){const iAe=nAe.getAppearanceValueAndResolveTokens(Z7,"icon-image",sAe,rAe,gxe);if(iAe){const oAe=ng.getResolvedImageFromTokens(iAe);if(oAe){const lAe=Z7.hasLayoutProperty("icon-size")?Z7.getUnevaluatedLayoutProperty("icon-size"):Umt._values["icon-size"],Kmt=j6(oAe,T2(ng.zoom,lAe,ng.worldview,gxe),lAe,rAe,ng.zoom,sAe,ng.pixelRatio,Wmt,ng.worldview,gxe),cAe=Vmt.get(Kmt.iconPrimary.toString());cAe&&(a5=Math.max(a5,fht(cAe)))}}}return a5}(Er,Mu,Xu,Da.layout,Da._unevaluatedLayout,zo,go,Er.iconAtlasPositions,0,md);Io=4*qf;const G7=Da.layout.get("icon-size").evaluate(zo,{},go,md),W7=Mc.compositeIconSizes?Mc.compositeIconSizes[0].evaluate(zo,{},go,md):0,xxe=Mc.compositeIconSizes?Mc.compositeIconSizes[1].evaluate(zo,{},go,md):0,K7=Wfe(Er.layerIds[0],Er.iconSizeData,G7,Mc.iconScaleFactor,W7,xxe);Er.addSymbols(Er.icon,Mu,K7,Su,Kn,zo,void 0,Na,Tn,dv.lineStartIndex,dv.lineLength,-1,md,go,Xd,Tc,Er.symbolInstances.length,qf),om=Er.icon.placedSymbolArray.length-1,Xu&&(Vl=4*qf,Er.addSymbols(Er.icon,Xu,K7,Su,Kn,zo,am.vertical,Na,Tn,dv.lineStartIndex,dv.lineLength,-1,md,go,Xd,Tc,Er.symbolInstances.length,qf),lm=Er.icon.placedSymbolArray.length-1)}for(const Bo in Ca.horizontal){const Mu=Bo,Xu=Ca.horizontal[Mu];uv||(H7=ar(Xu.text),rl?t5=Kfe(Xu):uv=C7(Si,rg,Tn,lo,cc,co,Xu,Eo,Da.layout.get("text-rotate").evaluate(zo,{},go),Po,e5));const qf=Xu.positionedLines.length===1;if(Rp+=RMe(Er,Na,Tn,Xu,xo,Da,rl,zo,Po,dv,Ca.vertical?am.horizontal:am.horizontalOnly,qf?vht(Ca.horizontal):[Mu],Bf,om,Mc,md,go,Er.symbolInstances.length,Xd),qf)break}Ca.vertical&&(im+=RMe(Er,Na,Tn,Ca.vertical,xo,Da,rl,zo,Po,dv,am.vertical,["vertical"],Bf,lm,Mc,md,go,Er.symbolInstances.length,Xd));let hl=-1;const Hl=(Bo,Mu)=>Bo?Math.max(Bo,Mu):Mu;hl=Hl(t5,hl),hl=Hl(ea,hl),hl=Hl(Ac,hl);const $f=hl>-1?1:0;Er.glyphOffsetArray.length>=65535&&zr("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),zo.sortKey!==void 0&&Er.addToSortKeyRanges(Er.symbolInstances.length,zo.sortKey),Er.symbolInstances.emplaceBack(Tn.x,Tn.y,rg.x,rg.y,rg.z,Bf.right>=0?Bf.right:-1,Bf.center>=0?Bf.center:-1,Bf.left>=0?Bf.left:-1,Bf.vertical>=0?Bf.vertical:-1,om,lm,H7,uv!==void 0?uv:Er.collisionBoxArray.length,uv!==void 0?uv+1:Er.collisionBoxArray.length,Dp!==void 0?Dp:Er.collisionBoxArray.length,Dp!==void 0?Dp+1:Er.collisionBoxArray.length,Lp!==void 0?Lp:Er.collisionBoxArray.length,Lp!==void 0?Lp+1:Er.collisionBoxArray.length,D2||Er.collisionBoxArray.length,D2?D2+1:Er.collisionBoxArray.length,lo,Rp,im,Io,Vl,$f,0,r5,Tl,hl,0,s5?1:0,J3)})(x,ur,Ur,Ys,h,g,T,j,x.layers[0],x.collisionBoxArray,c.index,c.sourceLayerIndex,x.index,Rs,Ge,H,0,ts,Ts,Ee,c,P,Q,se,re,ue,_e,Ce,er,nt,it,lt)};if(Be==="line")for(const Ys of i7(c.geometry,0,0,sr,sr)){const ur=pht(Ys,gs,ws,h.vertical||Tt,g,24,Ns,x.overscaling,sr);for(const Nr of ur)Tt&&Mht(x,Tt.text,Os,Nr)||Js(Ys,Nr,re)}else if(Be==="line-center"){for(const Ys of c.geometry)if(Ys.length>1){const ur=mht(Ys,ws,h.vertical||Tt,g,24,Ns);ur&&Js(Ys,ur,re)}}else if(c.type==="Polygon")for(const Ys of a6(c.geometry,0)){const ur=ght(Ys,16);Js(Ys[0],new cv(ur.x,ur.y,0,0,void 0),re)}else if(c.type==="LineString")for(const Ys of c.geometry)Js(Ys,new cv(Ys[0].x,Ys[0].y,0,0,void 0),re);else if(c.type==="Point")for(const Ys of c.geometry)for(const ur of Ys)Js([ur],new cv(ur.x,ur.y,0,0,void 0),re)}const Gfe=255,A2=Gfe*lv;function RMe(x,c,h,g,j,T,P,R,F,H,Q,se,re,le,ue,_e,Ce,Ee,Ge){const Be=MMe(0,g,F,T,P,R,j,x.allowVerticalPlacement,void 0,ue.textScaleFactor),nt=T.layout.get("text-size").evaluate(R,{},Ce),it=ue.compositeTextSizes?ue.compositeTextSizes[0].evaluate(R,{},Ce):0,lt=ue.compositeTextSizes?ue.compositeTextSizes[1].evaluate(R,{},Ce):0,Rt=Wfe(x.layerIds[0],x.textSizeData,nt,ue.textScaleFactor,it,lt);x.addSymbols(x.text,Be,Rt,F,P,R,Q,c,h,H.lineStartIndex,H.lineLength,le,_e,Ce,Ge,!1,Ee,Be.length);for(const jt of se)re[jt]=x.text.placedSymbolArray.length-1;return 4*Be.length}function Wfe(x,c,h,g,j,T){const P=c;let R=null;return P.kind==="source"?(R=[lv*h*g],R[0]>A2&&zr(`${x}: Value for "text-size" is >= ${Gfe}. Reduce your "text-size".`)):P.kind==="composite"&&(R=[lv*j*g,lv*T*g],(R[0]>A2||R[1]>A2)&&zr(`${x}: Value for "text-size" is >= ${Gfe}. Reduce your "text-size".`)),R}function S7(x){for(const c in x)return x[c];return null}function C7(x,c,h,g,j,T,P,R,F,H,Q){let se,re,le,ue;if(se=Q?Q.top:P.top,re=Q?Q.bottom:P.bottom,le=Q?Q.left:P.left,ue=Q?Q.right:P.right,Dfe(P)&&P.collisionPadding){const _e=P.collisionPadding;le-=_e[0],se-=_e[1],ue+=_e[2],re+=_e[3]}if(F){const _e=new as(le,se),Ce=new as(ue,se),Ee=new as(le,re),Ge=new as(ue,re),Be=Zr(F);let nt=new as(0,0);H&&(nt=new as(H[0],H[1])),_e._rotateAround(Be,nt),Ce._rotateAround(Be,nt),Ee._rotateAround(Be,nt),Ge._rotateAround(Be,nt),le=Math.min(_e.x,Ce.x,Ee.x,Ge.x),ue=Math.max(_e.x,Ce.x,Ee.x,Ge.x),se=Math.min(_e.y,Ce.y,Ee.y,Ge.y),re=Math.max(_e.y,Ce.y,Ee.y,Ge.y)}return x.emplaceBack(c.x,c.y,c.z,h.x,h.y,le,se,ue,re,R,g,j,T),x.length-1}function Kfe(x){Dfe(x)&&x.collisionPadding&&(x.top-=x.collisionPadding[1],x.bottom+=x.collisionPadding[3]);const c=x.bottom-x.top;return c>0?Math.max(10,c):null}function Mht(x,c,h,g){const j=x.compareText;if(c in j){const T=j[c];for(let P=T.length-1;P>=0;P--)if(g.dist(T[P])Be&&(nt(lt,xs,jt,It,rs,ls),nt(xs,Rt,rs,ls,Mt,Tt))}nt(se,re,g,T,j,T),nt(re,le,j,T,j,P),nt(le,ue,j,P,g,P),nt(ue,se,g,P,g,T),_e-=Be,Ce-=Be,Ee+=Be,Ge+=Be;const it=1/Math.max(Ee-_e,Ge-Ce);return{scale:it,x:_e*it,y:Ce*it,x2:Ee*it,y2:Ge*it,projection:c}}function FMe(x,{x:c,y:h},g=0){return new as(((c-g)*x.scale-x.x)*sr,(h*x.scale-x.y)*sr)}const Tht=w(new Float32Array(16));class c_{constructor(c){this.spec=c,this.name=c.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(c,h){return{x:0,y:0,z:0}}unproject(c,h){return new qt(0,0)}projectTilePoint(c,h,g){return{x:c,y:h,z:0}}locationPoint(c,h,g,j=!0){return c._coordinatePoint(c.locationCoordinate(h,g),j)}pixelsPerMeter(c,h){return Zt(1,c)*h}pixelSpaceConversion(c,h,g){return 1}farthestPixelDistance(c){return OMe(c,c.pixelsPerMeter)}pointCoordinate(c,h,g,j){const T=c.horizonLineFromTop(!1),P=new as(h,Math.max(T,g));return c.rayIntersectionCoordinate(c.pointRayIntersection(P,j))}pointCoordinate3D(c,h,g){const j=new as(h,g);if(c.elevation)return c.elevation.pointCoordinate(j);{const T=this.pointCoordinate(c,j.x,j.y,0);return[T.x,T.y,T.z]}}isPointAboveHorizon(c,h){if(c.elevation&&c.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(c,h.x,h.y);const g=c.horizonLineFromTop();return h.y0?h<-G3+g&&(h=-G3+g):h>G3-g&&(h=G3-g);const P=T/Math.pow(T7(h),j);let R=P*Math.sin(j*c),F=T-P*Math.cos(j*c);return R=.5*(R/Math.PI+.5),F=.5*(F/Math.PI+.5),{x:R,y:this.southernCenter?F:1-F,z:0}}unproject(c,h){c=(2*c-.5)*Math.PI,this.southernCenter&&(h=1-h),h=(2*(1-h)-.5)*Math.PI;const{n:g,f:j}=this,T=j-h,P=Math.sign(T),R=Math.sign(g)*Math.sqrt(c*c+T*T);let F=Math.atan2(c,Math.abs(T))*P;T*g<0&&(F-=Math.PI*Math.sign(c)*P);const H=Fe(La(F/g)+this.center[0],-180,180),Q=Fe(La(2*Math.atan(Math.pow(j/R,1/g))-G3),-85.051129,hs);return new qt(H,this.southernCenter?-Q:Q)}}class zMe extends c_{constructor(c){super(c),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(c,h){return{x:Cs(c),y:Ls(h),z:0}}unproject(c,h){const g=Ht(c),j=ss(h);return new qt(g,j)}}const BMe=Zr(hs);class Lht extends c_{project(c,h){const g=(h=Zr(h))*h,j=g*g;return{x:.5*((c=Zr(c))*(.8707-.131979*g+j*(j*(.003971*g-.001529*j)-.013791))/Math.PI+.5),y:1-.5*(h*(1.007226+g*(.015085+j*(.028874*g-.044475-.005916*j)))/Math.PI+1),z:0}}unproject(c,h){c=(2*c-.5)*Math.PI;let g=h=(2*(1-h)-1)*Math.PI,j=25,T=0,P=g*g;do{P=g*g;const H=P*P;T=(g*(1.007226+P*(.015085+H*(.028874*P-.044475-.005916*H)))-h)/(1.007226+P*(.045255+H*(.259866*P-.311325-.005916*11*H))),g=Fe(g-T,-BMe,BMe)}while(Math.abs(T)>1e-6&&--j>0);P=g*g;const R=Fe(La(c/(.8707+P*(P*(P*P*P*(.003971-.001529*P)-.013791)-.131979))),-180,180),F=La(g);return new qt(R,F)}}const $Me=Zr(hs);class Dht extends c_{project(c,h){h=Zr(h),c=Zr(c);const g=Math.cos(h),j=2/Math.PI,T=Math.acos(g*Math.cos(c/2)),P=Math.sin(T)/T,R=.5*(c*j+2*g*Math.sin(c/2)/P)||0,F=.5*(h+Math.sin(h)/P)||0;return{x:.5*(R/Math.PI+.5),y:1-.5*(F/Math.PI+1),z:0}}unproject(c,h){let g=c=(2*c-.5)*Math.PI,j=h=(2*(1-h)-1)*Math.PI,T=25;const P=1e-6;let R=0,F=0;do{const H=Math.cos(j),Q=Math.sin(j),se=2*Q*H,re=Q*Q,le=H*H,ue=Math.cos(g/2),_e=Math.sin(g/2),Ce=2*ue*_e,Ee=_e*_e,Ge=1-le*ue*ue,Be=Ge?1/Ge:0,nt=Ge?Math.acos(H*ue)*Math.sqrt(1/Ge):0,it=.5*(2*nt*H*_e+2*g/Math.PI)-c,lt=.5*(nt*Q+j)-h,Rt=.5*Be*(le*Ee+nt*H*ue*re)+1/Math.PI,jt=Be*(Ce*se/4-nt*Q*_e),It=.125*Be*(se*_e-nt*Q*le*Ce),Mt=.5*Be*(re*ue+nt*Ee*H)+.5,Tt=jt*It-Mt*Rt;R=(lt*jt-it*Mt)/Tt,F=(it*It-lt*Rt)/Tt,g=Fe(g-R,-Math.PI,Math.PI),j=Fe(j-F,-$Me,$Me)}while((Math.abs(R)>P||Math.abs(F)>P)&&--T>0);return new qt(La(g),La(j))}}class qMe extends c_{constructor(c){super(c),this.center=c.center||[0,0],this.parallels=c.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Zr(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(c,h){const{scale:g,cosPhi:j}=this;return{x:Zr(c)*j*g+.5,y:-Math.sin(Zr(h))/j*g+.5,z:0}}unproject(c,h){const{scale:g,cosPhi:j}=this,T=-(h-.5)/g,P=Fe(La((c-.5)/g)/j,-180,180),R=Math.asin(Fe(T*j,-1,1)),F=Fe(La(R),-85.051129,hs);return new qt(P,F)}}class Rht extends zMe{constructor(c){super(c),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(c,h,g){const j=QP(c,h,g);return ct(j,j,JP(fy(g))),{x:j[0],y:j[1],z:j[2]}}locationPoint(c,h,g){const j=_t(h.lat,h.lng),T=Ne([],j),P=g?c._centerAltitude+g:c.elevation?c.elevation.getAtPointOrZero(c.locationCoordinate(h),c._centerAltitude):c._centerAltitude;qe(j,j,T,Zt(1,0)*sr*P);const R=w(new Float64Array(16));return C(R,c.pixelMatrix,c.globeMatrix),ct(j,j,R),new as(j[0],j[1])}pixelsPerMeter(c,h){return Zt(1,0)*h}pixelSpaceConversion(c,h,g){const j=Zt(1,c)*h,T=on(Zt(1,45)*h,j,g);return this.pixelsPerMeter(c,h)/T}createTileMatrix(c,h,g){const j=qpe(fy(g.canonical));return C(new Float64Array(16),c.globeMatrix,j)}createInversionMatrix(c,h){const{center:g}=c,j=JP(fy(h));return O(j,j,Zr(g.lng)),L(j,j,Zr(g.lat)),I(j,j,[c._pixelsPerMercatorPixel,c._pixelsPerMercatorPixel,1]),Float32Array.from(j)}pointCoordinate(c,h,g,j){return n3e(c,h,g,!0)||new jr(0,0)}pointCoordinate3D(c,h,g){const j=this.pointCoordinate(c,h,g,0);return[j.x,j.y,j.z]}isPointAboveHorizon(c,h){return!n3e(c,h.x,h.y,!1)}farthestPixelDistance(c){const h=function(j,T){const P=j.cameraToCenterDistance,R=j._centerAltitude*T,F=j._camera,H=j._camera.forward(),Q=oe([],je([],H,-P),[0,0,R]),se=j.worldSize/(2*Math.PI),re=[0,0,-se],le=j.width/j.height,ue=Math.tan(j.fovAboveCenter),_e=je([],F.up(),ue),Ce=je([],F.right(),ue*le),Ee=Ne([],oe([],oe([],H,_e),Ce)),Ge=[];let Be;if(new ra(Q,Ee).closestPointOnSphere(re,se,Ge)){const nt=oe([],Ge,re),it=Te([],nt,Q);Be=Math.cos(j.fovAboveCenter)*ce(it)}else{const nt=Te([],Q,re),it=Te([],re,Q);Ne(it,it);const lt=ce(nt)-se;Be=Math.sqrt(lt*(lt+2*se));const Rt=Math.acos(Be/(se+lt))-Math.acos(Ue(H,it));Be*=Math.cos(Rt)}return 1.01*Be}(c,this.pixelsPerMeter(c.center.lat,c.worldSize)),g=av(c.zoom);if(g>0){const j=OMe(c,Zt(1,c.center.lat)*c.worldSize),T=c.worldSize/(2*Math.PI),P=Math.max(c.width,c.height)/c.worldSize*Math.PI;return on(h,j+T*(1-Math.cos(P)),Math.pow(g,10))}return h}upVector(c,h,g){return QP(h,g,c,1)}upVectorScale(c){return{metersToTile:qF(VF(fy(c)))}}}function UMe(x){const c=x.parallels,h=!!c&&Math.abs(c[0]+c[1])<.01;switch(x.name){case"mercator":return new zMe(x);case"equirectangular":return new Pht(x);case"naturalEarth":return new Lht(x);case"equalEarth":return new Eht(x);case"winkelTripel":return new Dht(x);case"albers":return h?new qMe(x):new Aht(x);case"lambertConformalConic":return h?new qMe(x):new Iht(x);case"globe":return new Rht(x)}throw new Error(`Invalid projection name: ${x.name}`)}class Oht{constructor(c,h){this.lastParams=null,this.lastAllFeaturesIndex=-2,this.appearancesVersion=h,this.appearances=c;const g=c.map(j=>function(T){if(!T.condition)return{featureDependent:!1,stateDependent:!1,zoomDependent:!1,pitchDependent:!1,brightnessDependent:!1,worldviewDependent:!1};const P=T.condition.expression;return{featureDependent:!H0(P),stateDependent:!q1(P),zoomDependent:!Ef(P,["zoom"]),pitchDependent:!Ef(P,["pitch"]),brightnessDependent:!Ef(P,["brightness","measure-light"]),worldviewDependent:!Ef(P,["worldview"])}}(j));this.anyFeatureDependent=g.some(j=>j.featureDependent),this.anyStateDependent=g.some(j=>j.stateDependent)}update(c,h){const g=this.lastParams,j=!g||g.zoom!==c.zoom||g.pitch!==(c.pitch||0)||g.brightness!==(c.brightness||0)||g.worldview!==c.worldview;this.lastParams={zoom:c.zoom,pitch:c.pitch||0,brightness:c.brightness||0,worldview:c.worldview};const T=h&&this.anyStateDependent;if(!j&&!T&&this.lastAllFeaturesIndex!==-2)return{kind:"no-changes"};if(!this.anyFeatureDependent&&!T){const P=this.evaluateAllFeatures(c);return P===this.lastAllFeaturesIndex?{kind:"no-changes"}:(this.lastAllFeaturesIndex=P,{kind:"all-features",appearanceIndex:P})}return{kind:"per-feature"}}evaluateAllFeatures(c){for(let h=0;h{for(let j=0;jP-R),T=new Map;for(const P of j){const R=g.get(P);T.set(P,new ji(R))}return h&&(this.cachedBatchIndices=j,this.cachedBatchSegments=T),{batchIndices:j,batchSegments:T}}snapshotSymbolVertexData(c,h){const g=c*K3;return this.layoutVertexArray.uint16.slice(g,g+h*K3)}restoreSymbolVertexData(c,h){this.layoutVertexArray.uint16.set(h,c*K3)}updateSymbolVertexData(c,h,g,j,T,P,R,F,H,Q,se,re,le){const ue=this.layoutVertexArray.uint16,_e=c*K3;ue[_e]=h,ue[_e+1]=g,ue[_e+2]=j,ue[_e+3]=T,ue[_e+4]=P,ue[_e+5]=R,ue[_e+6]=F,ue[_e+7]=H,ue[_e+8]=Q,ue[_e+9]=se,ue[_e+10]=re,ue[_e+11]=le}upload(c,h,g,j,T,P){this.isEmpty()||(g&&(this.cachedBatchIndices=null,this.cachedBatchSegments=null,this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,But.members,!!P),this.indexBuffer=c.createIndexBuffer(this.indexArray,h),this.dynamicLayoutVertexBuffer=c.createVertexBuffer(this.dynamicLayoutVertexArray,qut.members,!0),this.opacityVertexBuffer=c.createVertexBuffer(this.opacityVertexArray,zht,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=c.createVertexBuffer(this.iconTransitioningVertexArray,Gut.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=c.createVertexBuffer(this.globeExtVertexArray,$ut.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||T)&&(this.zOffsetVertexBuffer=c.createVertexBuffer(this.zOffsetVertexArray,Uut.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=c.createVertexBuffer(this.orientationVertexArray,Hut.members,!0)),this.opacityVertexBuffer.itemSize=1,this.featureIdArray&&this.featureIdArray.length>0&&(this.featureIdBuffer=c.createVertexBuffer(this.featureIdArray,Vut.members,!1))),(g||j)&&(this.programConfigurations.upload(c),this.uboBinder&&this.uboBinder.upload(c)))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.orientationVertexBuffer&&this.orientationVertexBuffer.destroy(),this.featureIdBuffer&&this.featureIdBuffer.destroy(),this.uboBinder&&this.uboBinder.destroy())}}yr(Zfe,"SymbolBuffers",{omit:["cachedBatchIndices","cachedBatchSegments"]});class Yfe{constructor(c,h,g){this.layoutVertexArray=new c,this.layoutAttributes=h,this.indexArray=new g,this.segments=new ji,this.collisionVertexArray=new x2,this.collisionVertexArrayExt=new Yx}upload(c){this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=c.createVertexBuffer(this.collisionVertexArray,Wut.members,!0),this.collisionVertexBufferExt=c.createVertexBuffer(this.collisionVertexArrayExt,Kut.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}yr(Yfe,"CollisionBuffers");class eg{constructor(c){this.collisionBoxArray=c.collisionBoxArray,this.zoom=c.zoom,this.overscaling=c.overscaling,this.layers=c.layers,this.layerIds=this.layers.map(P=>P.fqid),this.index=c.index,this.pixelRatio=c.pixelRatio,this.sourceLayerIndex=c.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=w([]),this.placementViewportMatrix=w([]);const h=this.layers[0]._unevaluatedLayout._values;this.worldview=c.worldview,this.localizable=c.localizable,this.maxUniformBufferBindings=c.maxUniformBufferBindings,this.maxUniformBlockSizeDwords=c.maxUniformBlockSizeDwords,this.disableSymbolUBO=c.disableSymbolUBO,this.textSizeData=T2(this.zoom,h["text-size"],this.worldview,c.availableImages),this.iconSizeData=T2(this.zoom,h["icon-size"],this.worldview,c.availableImages);const g=this.layers[0].layout,j=g.get("symbol-sort-key"),T=g.get("symbol-z-order");this.lut=c.lut,this.canOverlap=g.get("text-allow-overlap")||g.get("icon-allow-overlap")||g.get("text-ignore-placement")||g.get("icon-ignore-placement"),this.sortFeaturesByKey=T!=="viewport-y"&&j.constantOr(1)!==void 0,this.sortFeaturesByY=(T==="viewport-y"||T==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=g.get("text-writing-mode").map(P=>am[P]),this.stateDependentLayerIds=this.layers.filter(P=>P.isStateDependent()).map(P=>P.id),this.sourceID=c.sourceID,this.projection=c.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=!1,this.elevationType="none",this.elevationStateComplete=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.hasAnySecondaryIcon=!1,this.hasAppearances=null,this.featureAppearances=null,this.featureAppearanceData=new Map}hasAnyAppearanceLayoutProperty(c){const h=this.layers[0].getAppearances();if(!h||h.length===0)return!1;const g=Array.isArray(c)?c:[c];return h.some(j=>g.some(T=>j.hasLayoutProperty(T)))}getAppearanceFeatureData(c){return this.featureAppearanceData.get(c)}createArrays(){this.text=new Zfe(new Ae(this.layers,{zoom:this.zoom,lut:this.lut},c=>c.startsWith("text")||c.startsWith("symbol"))),this.icon=new Zfe(new Ae(this.layers,{zoom:this.zoom,lut:this.lut},c=>c.startsWith("icon")||c.startsWith("symbol"))),this.disableSymbolUBO||(this.text.uboBinder=new Efe(this.layers[0],this.zoom,this.lut,!0,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords),this.icon.uboBinder=new Efe(this.layers[0],this.zoom,this.lut,!1,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords)),this.glyphOffsetArray=new RF,this.lineVertexArray=new v2,this.symbolInstances=new DF}calculateGlyphDependencies(c,h,g,j,T){for(const P of c){const R=P.codePointAt(0);if(R===void 0)break;if(h[R]=!0,j&&T&&R<=65535){const F=y6[P];F&&(h[F.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(c,h,g,j,T,P,R){if(!c.hasLayoutProperty("icon-size"))return R*P;let F=1;const H=c.getUnevaluatedLayoutProperty("icon-size"),Q=T2(this.zoom,H,this.worldview,T),se=V3(Q,h);if(Q.kind!=="constant"&&Q.kind!=="camera"||(F=se.uSize),Q.kind==="composite"){const{minZoom:re,maxZoom:le}=Q,ue=H.possiblyEvaluate(new Ka(re,{worldview:this.worldview}),j),_e=H.possiblyEvaluate(new Ka(le,{worldview:this.worldview}),j),Ce=ue.evaluate(g,{},j,T);F=Ce+(_e.evaluate(g,{},j,T)-Ce)*se.uSizeT}return Q.kind==="source"&&(F=H.possiblyEvaluate(new Ka(this.zoom,{worldview:this.worldview}),j).evaluate(g,{},j,T)),F*P}updateFootprints(c,h){}updateReplacement(c,h){if(h.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=h.updateTime;const g=h.getReplacementRegionsForTile(c.toUnwrapped(),!0);return!e7(this.activeReplacements,g)&&(this.activeReplacements=g,!0)}getResolvedImageFromTokens(c){return typeof c=="string"?Ku.build(c):c}populate(c,h,g,j){const T=this.layers[0],P=T.layout,R=this.projection.name==="globe",F=P.get("text-font"),H=P.get("text-field"),Q=P.get("icon-image"),[se,re]=P.get("icon-size-scale-range"),le=Fe(h.scaleFactor||1,se,re),[ue,_e]=P.get("text-size-scale-range"),Ce=Fe(h.scaleFactor||1,ue,_e),Ee=(H.value.kind!=="constant"||H.value.value instanceof Td&&!H.value.value.isEmpty()||H.value.value.toString().length>0)&&(F.value.kind!=="constant"||F.value.value.length>0),Ge=Q.value.kind!=="constant"||!!Q.value.value||Object.keys(Q.parameters).length>0,Be=this.hasAnyAppearanceLayoutProperty("icon-image"),nt=P.get("symbol-sort-key");if(this.features=[],this.featureAppearanceData=new Map,!Ee&&!Ge&&!Be)return;const it=h.iconDependencies,lt=h.glyphDependencies,Rt=h.availableImages,jt=new Ka(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),It=Mt=>{const Tt=Mt.id.toString();it.has(Tt)?it.get(Tt).push(Mt):it.set(Tt,[Mt])};for(const Mt of c){const{feature:Tt,id:rs,index:ls,sourceLayerIndex:xs}=Mt,Ns=T._featureFilter.needGeometry,gs=Vn(Tt,Ns);if(!T._featureFilter.filter(jt,gs,g))continue;if(Ns||(gs.geometry=Vr(Tt,g,j)),R&&Tt.type!==1&&g.z<=5){const er=gs.geometry,Js=.98078528056,Ys=(ur,Nr)=>Ue(QP(ur.x,ur.y,g,1),QP(Nr.x,Nr.y,g,1)){if(!er.getLayoutProperty("icon-image"))return;const Js=this.getCombinedIconPrimary(er,ws,gs,g,Rt,Zs,le);Js&&It(Js)}),Rs){const er=F.evaluate(gs,{},g).join(","),Js=P.get("text-rotation-alignment")==="map"&&P.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(am.vertical)>=0;for(const Ys of Rs.sections)if(Ys.image){const ur=Ys.image.getPrimary().scaleSelf(this.pixelRatio*Ce),Nr=ur.id.toString(),Ur=it.get(Nr)||[];Ur.push(ur),it.set(Nr,Ur)}else{const ur=_P(Rs.toString()),Nr=Ys.fontStack||er,Ur=lt[Nr]=lt[Nr]||{};this.calculateGlyphDependencies(Ys.text,Ur,Js,this.allowVerticalPlacement,ur)}}}if(P.get("symbol-placement")==="line"&&(this.features=function(Mt){const Tt={},rs={},ls=[];let xs=0;function Ns(ws){ls.push(Mt[ws]),xs++}function gs(ws,Ts,Os){const Zs=rs[ws];return delete rs[ws],rs[Ts]=Zs,ls[Zs].geometry[0].pop(),ls[Zs].geometry[0]=ls[Zs].geometry[0].concat(Os[0]),Zs}function Rs(ws,Ts,Os){const Zs=Tt[Ts];return delete Tt[Ts],Tt[ws]=Zs,ls[Zs].geometry[0].shift(),ls[Zs].geometry[0]=Os[0].concat(ls[Zs].geometry[0]),Zs}function ts(ws,Ts,Os){const Zs=Os?Ts[0][Ts[0].length-1]:Ts[0][0];return`${ws}:${Zs.x}:${Zs.y}`}for(let ws=0;wsws.geometry)}(this.features)),P.get("symbol-elevation-reference")==="hd-road-markup"){if(this.elevationType="road",h.elevationFeatures){!this.elevationFeatures&&h.elevationFeatures.length>0&&(this.elevationFeatures=[],this.elevationFeatureIdToIndex=new Map);for(const Mt of h.elevationFeatures)this.elevationFeatureIdToIndex.set(Mt.id,this.elevationFeatures.length),this.elevationFeatures.push(Mt)}}else P.get("symbol-z-elevate")&&(this.elevationType="offset");this.elevationType!=="none"&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((Mt,Tt)=>Mt.sortKey-Tt.sortKey)}getCombinedIconPrimary(c,h,g,j,T,P,R){let F,H;if(c.hasLayoutProperty("icon-image")){const Q=h.getAppearanceValueAndResolveTokens(c,"icon-image",g,j,T);F=this.getResolvedImageFromTokens(Q)}else{const Q=h.getValueAndResolveTokens("icon-image",g,j,T);F=this.getResolvedImageFromTokens(Q)}if(F){const Q=c.hasLayoutProperty("icon-size")?c.getUnevaluatedLayoutProperty("icon-size"):h._unevaluatedLayout._values["icon-size"];H=j6(F,T2(this.zoom,Q,this.worldview,T),Q,j,this.zoom,P,this.pixelRatio,R,this.worldview,T).iconPrimary}return H}updateSymbolInstanceIconVertices(c,h,g,j,T,P){const{canonical:R,availableImages:F,globalProperties:H,layer:Q,iconScaleFactor:se,featureState:re,layoutIconOffset:le,layoutIconSize:ue,layoutIconRotate:_e}=P;if(c.placedIconSymbolIndex<0)return{vertexOffsetDelta:0,hasChanges:!1};if(h.activeAppearanceIndex===g)return{vertexOffsetDelta:c.numIconVertices,hasChanges:!1};const Ce=g>=0?Q.appearances[g]:null;if(Ce){const Ee=this.getCombinedIconPrimary(Ce,Q,j,R,F,{sortKey:void 0,text:void 0,icon:null,index:c.featureIndex,sourceLayerIndex:c.featureIndex,geometry:[],properties:h.properties,type:"Point",id:h.id},se);if(!Ee)return{vertexOffsetDelta:0,hasChanges:!1};const Ge=Ee.toString(),Be=this.iconAtlasPositions&&this.iconAtlasPositions.get(Ge);if(Be){const{appearanceIconOffset:nt,appearanceIconRotate:it}=AMe(Ce,Q,j,R,le,_e,ue,se);let lt=v7(Be,void 0,nt,Q.layout.get("icon-anchor").evaluate(j,re,R));const Rt=Be.sdf,jt=Q.layout.get("icon-text-fit").constantOr("none");jt!=="none"&&h.textShaping&&h.iconTextFitPadding&&h.fontScale&&(lt=Rfe(lt,h.textShaping,jt,h.iconTextFitPadding,nt,h.fontScale));const It=this.calculateEffectiveAppearanceIconSize(Ce,H.zoom,j,R,F,se,ue),Mt=0,Tt=1+(Math.min(A2,Math.round(It*lv))<<1),rs=Ufe(lt,it,Rt,jt!=="none",se);h.isUsingAppearanceIconVertexData||(h.isUsingAppearanceIconVertexData=!0,h.layoutBasedIconVertexData=this.icon.snapshotSymbolVertexData(T,c.numIconVertices));const ls=Math.floor(c.numIconVertices/4),xs=Math.min(rs.length,ls);let Ns=T;for(let Rs=0;Rs0||c.numVerticalGlyphVertices>0;if(!nt)return{vertexOffsetDelta:nt?c.numHorizontalGlyphVertices+c.numVerticalGlyphVertices:0,hasChanges:!1};if(h.activeAppearanceIndex===g)return{vertexOffsetDelta:c.numHorizontalGlyphVertices+c.numVerticalGlyphVertices,hasChanges:!1};const it=g>=0?F.appearances[g]:null;if(it&&h.textShaping){const{appearanceTextOffset:lt,appearanceTextRotate:Rt,appearanceTextSize:jt}=EMe(it,F,j,R,re,ue,le);h.fontScale=DMe(jt,h.textScaleFactor);const It=it.getUnevaluatedLayoutProperty("text-size");let Mt=this.textSizeData,Tt=Ee,rs=Ge;it.hasLayoutProperty("text-size")&&(Mt=T2(this.zoom,It,this.worldview,Be),Tt=this.textSizeData.kind==="composite"?this.textSizeData.minZoom:0,rs=this.textSizeData.kind==="composite"?this.textSizeData.maxZoom:0);const ls=h.textShaping.bottom-re[1],xs=h.textShaping.left-re[0],Ns=h.textShaping.right-re[0];h.textShaping.top=lt[1]+(h.textShaping.top-re[1]),h.textShaping.bottom=lt[1]+ls,h.textShaping.left=lt[0]+xs,h.textShaping.right=lt[0]+Ns;const gs=MMe(0,h.textShaping,lt,F,!1,j,Q,this.allowVerticalPlacement,Rt),Rs=jt&&Mt.kind==="composite"?It.possiblyEvaluate(new Ka(Tt,{}),R).evaluate(j,se,R):_e,ts=jt&&Mt.kind==="composite"?It.possiblyEvaluate(new Ka(rs,{}),R).evaluate(j,se,R):Ce,ws=Wfe(it.name,Mt,jt,H,Rs,ts),Ts=Array.isArray(ws)?ws[1]:jt,Os=0,Zs=1+(Math.min(A2,Math.round(Ts*lv))<<1);h.isUsingAppearanceTextVertexData||(h.isUsingAppearanceTextVertexData=!0,h.layoutBasedTextVertexData=this.text.snapshotSymbolVertexData(T,c.numHorizontalGlyphVertices+c.numVerticalGlyphVertices));for(let xr=0;xr0){const H=new Set(Object.keys(c).map(Q=>{const se=Number(Q);return!isNaN(se)&&Number.isSafeInteger(se)&&String(se)===Q?se:Q}));this.text.uboBinder&&this.text.uboBinder.updateFeatures(H,T[0],h,F,g,c,R),this.icon.uboBinder&&this.icon.uboBinder.updateFeatures(H,T[0],h,F,g,c,R)}}}updateRoadElevation(c){if(this.elevationType!=="road"||!this.elevationFeatures||this.elevationStateComplete)return;this.elevationStateComplete=!0,this.hasAnyZOffset=!1;let h=!1;const g=As(c),j=1/g;let T=!1,P=!1;for(let R=0;R0||re>0,Ce=le>0,Ee=this.elevationFeatures[F.elevationFeatureIndex];if(Ee){const Ge=new as(F.tileAnchorX,F.tileAnchorY),Be=.075+Ee.pointElevation(Ge);F.zOffset!==Be&&(h=!0,F.zOffset=Be),Be!==0&&(this.hasAnyZOffset=!0);const nt=Ee.computeSlopeNormal(Ge,j),it=lr(et(),ie(0,0,1),nt);$e(H,H,it),$e(Q,Q,it),H[2]*=g,Q[2]*=g,H[0]===1&&H[1]===0&&H[2]===0&&Q[0]===0&&Q[1]===1&&Q[2]===0||(T=T||_e,P=P||Ce)}if(_e&&(A7(this.text.orientationVertexArray,se,H,Q),A7(this.text.orientationVertexArray,re,H,Q)),Ce){const{placedIconSymbolIndex:Ge,verticalPlacedIconSymbolIndex:Be}=F;Ge>=0&&A7(this.icon.orientationVertexArray,le,H,Q),Be>=0&&A7(this.icon.orientationVertexArray,ue,H,Q)}}T||(this.text.orientationVertexArray=void 0),P||(this.icon.orientationVertexArray=void 0),h&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0)}updateZOffset(){const c=(T,P,R)=>{g+=P,g>T.length&&T.resize(g);for(let F=-P;F<0;F++)T.emplace(F+g,R)},h=(T,P,R)=>{j+=P,j>T.length&&T.resize(j);for(let F=-P;F<0;F++)T.emplace(F+j,R)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let g=0,j=0;for(let T=0;T0;if((R>0||F>0)&&(c(this.text.zOffsetVertexArray,R,Q),c(this.text.zOffsetVertexArray,F,Q)),se){const{placedIconSymbolIndex:re,verticalPlacedIconSymbolIndex:le}=P;re>=0&&h(this.icon.zOffsetVertexArray,H,Q),le>=0&&h(this.icon.zOffsetVertexArray,P.numVerticalIconVertices,Q)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(c,h,g,j,T){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(c),this.iconCollisionBox.upload(c)),this.text.upload(c,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.hasAppearances===null&&(this.hasAppearances=this.layers.some(P=>P.appearances&&P.appearances.length>0)),this.icon.upload(c,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.uploaded=!0}updateAppearances(c,h,g,j,T,P=!1){const R={hasLayoutChanges:!1,hasUboChanges:!1};if(!c||!g||!this.featureAppearanceData)return R;const F=h||{},H=this.icon.layoutVertexArray&&this.icon.layoutVertexArray.length>0&&this.icon.layoutVertexArray.arrayBuffer,Q=this.text.layoutVertexArray&&this.text.layoutVertexArray.length>0&&this.text.layoutVertexArray.arrayBuffer;if(!H&&!Q)return R;const se=this.layers[0],re=se.layout;this.featureAppearances&&this.featureAppearances.appearancesVersion===se.appearancesVersion||(this.featureAppearances=new Oht(se.appearances,se.appearancesVersion));const le=this.featureAppearances.update(j,P);if(le.kind==="no-changes")return R;let ue=1,_e=0,Ce=!1,Ee=!1;if(H){const[lt,Rt]=re.get("icon-size-scale-range");ue=Fe(1,lt,Rt)}let Ge=1,Be=0,nt=!1;if(Q){const[lt,Rt]=re.get("text-size-scale-range");Ge=Fe(1,lt,Rt)}const it=new Map;if(T&&g)for(const lt of g){const Rt=T.getImage(lt,se.scope);if(Rt){const jt=new Um(lt.toString());it.set(jt.toString(),Rt)}}for(let lt=0;ltNs.isActive({globals:j,feature:Tt,canonical:c,featureState:Mt})):-1;rs=xs>=0?xs:-1}const ls=jt.activeAppearanceIndex!==rs;if(Q){const xs=re.get("text-size"),Ns=this.textSizeData.kind==="composite"?this.textSizeData.minZoom:0,gs=this.textSizeData.kind==="composite"?this.textSizeData.maxZoom:0,Rs={canonical:c,layer:se,featureState:Mt,availableImages:g,textScaleFactor:Ge,imageMap:it,layoutTextOffset:re.get("text-offset").evaluate(Tt,Mt,c).map(ws=>ws*lc),layoutTextSize:xs.evaluate(Tt,Mt,c),layoutTextRotate:re.get("text-rotate").evaluate(Tt,Mt,c),layoutMinZoomSize:xs.evaluate(Tt,{zoom:Ns},c),layoutMaxZoomSize:xs.evaluate(Tt,{zoom:gs},c),layoutTextSizeMinZoom:Ns,layoutTextSizeMaxZoom:gs},ts=this.updateSymbolInstanceTextVertices(Rt,jt,rs,Tt,Be,Rs);Be+=ts.vertexOffsetDelta,nt=nt||ts.hasChanges}if(H){const xs={canonical:c,layer:se,featureState:Mt,availableImages:g,globalProperties:j,iconScaleFactor:ue,layoutIconOffset:re.get("icon-offset").evaluate(Tt,Mt,c),layoutIconSize:re.get("icon-size").evaluate(Tt,Mt,c,g),layoutIconRotate:re.get("icon-rotate").evaluate(Tt,Mt,c)},Ns=this.updateSymbolInstanceIconVertices(Rt,jt,rs,Tt,_e,xs);_e+=Ns.vertexOffsetDelta,Ce=Ce||Ns.hasChanges}if(ls){const xs=Rt.featureIndex,Ns=j?j.brightness:null,gs=Mt||{},Rs=rs>=0?se.appearances[rs]:null;this.text.uboBinder&&(this.text.uboBinder.layer=se,Ee=this.text.uboBinder.updateFeaturePaintForAppearance(xs,Tt,gs,c,g,Ns,Rs)||Ee),this.icon.uboBinder&&(this.icon.uboBinder.layer=se,Ee=this.icon.uboBinder.updateFeaturePaintForAppearance(xs,Tt,gs,c,g,Ns,Rs)||Ee)}jt.activeAppearanceIndex=rs}return Ce&&this.icon.layoutVertexBuffer&&this.icon.layoutVertexArray.arrayBuffer!==null&&this.icon.layoutVertexArray.length===this.icon.layoutVertexBuffer.length&&this.icon.layoutVertexBuffer.updateData(this.icon.layoutVertexArray),nt&&this.text.layoutVertexBuffer&&this.text.layoutVertexArray.arrayBuffer!==null&&this.text.layoutVertexArray.length===this.text.layoutVertexBuffer.length&&this.text.layoutVertexBuffer.updateData(this.text.layoutVertexArray),{hasLayoutChanges:Ce||nt,hasUboChanges:Ee}}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=UMe(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(c,h){const g=this.lineVertexArray.length;if(c.segment!==void 0)for(const{x:j,y:T}of h)this.lineVertexArray.emplaceBack(j,T);return{lineStartIndex:g,lineLength:this.lineVertexArray.length-g}}addSymbols(c,h,g,j,T,P,R,F,H,Q,se,re,le,ue,_e,Ce,Ee,Ge){const Be=c.indexArray,nt=c.layoutVertexArray,it=c.globeExtVertexArray,lt=Ge,Rt=c.uboBinder?c.uboBinder.getCurrentBatchIndex():void 0,jt=c.segments.prepareSegment(4*lt,nt,Be,this.canOverlap?P.sortKey:void 0,Rt),It=this.glyphOffsetArray.length,Mt=jt.vertexLength,Tt=this.allowVerticalPlacement&&R===am.vertical?Math.PI/2:0,rs=P.text&&P.text.sections;let ls=nt.length,xs=-1;for(let Rs=0;Rs=0)){const Rs=4*Ns;for(let ts=0;ts=0?h.rightJustifiedTextSymbolIndex:h.centerJustifiedTextSymbolIndex>=0?h.centerJustifiedTextSymbolIndex:h.leftJustifiedTextSymbolIndex>=0?h.leftJustifiedTextSymbolIndex:h.verticalPlacedTextSymbolIndex>=0?h.verticalPlacedTextSymbolIndex:j),P=Ofe(this.textSizeData,c,T)/lc;return this.tilePixelRatio*P}getSymbolInstanceIconSize(c,h,g){const j=this.icon.placedSymbolArray.get(g),T=Ofe(this.iconSizeData,c,j);return this.tilePixelRatio*T}_commitDebugCollisionVertexUpdate(c,h,g,j){c.emplaceBack(h,-g,-g,j),c.emplaceBack(h,g,-g,j),c.emplaceBack(h,g,g,j),c.emplaceBack(h,-g,g,j)}_updateTextDebugCollisionBoxes(c,h,g,j,T,P,R){for(let F=j;F0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(c,h){const g=c.placedSymbolArray.get(h),j=g.vertexStartIndex+4*g.numGlyphs;for(let T=g.vertexStartIndex;Tj[R]-j[F]||T[F]-T[R]),P}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let c=0;cthis.symbolInstances.get(h).zOffset-this.symbolInstances.get(c).zOffset)}addToSortKeyRanges(c,h){const g=this.sortKeyRanges[this.sortKeyRanges.length-1];g&&g.sortKey===h?g.symbolInstanceEnd=c+1:this.sortKeyRanges.push({sortKey:h,symbolInstanceStart:c,symbolInstanceEnd:c+1})}sortFeatures(c){if(this.sortFeaturesByY&&this.sortedAngle!==c)if(this.text.segments.get().length>1||this.icon.segments.get().length>1)this.sortFeaturesWithinSegments();else{this.symbolInstanceIndexes=this.getSortedSymbolIndexes(c),this.sortedAngle=c,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const h of this.symbolInstanceIndexes){const g=this.symbolInstances.get(h);this.featureSortOrder.push(g.featureIndex);const{rightJustifiedTextSymbolIndex:j,centerJustifiedTextSymbolIndex:T,leftJustifiedTextSymbolIndex:P,verticalPlacedTextSymbolIndex:R,placedIconSymbolIndex:F,verticalPlacedIconSymbolIndex:H}=g;j>=0&&this.addIndicesForPlacedSymbol(this.text,j),T>=0&&T!==j&&this.addIndicesForPlacedSymbol(this.text,T),P>=0&&P!==T&&P!==j&&this.addIndicesForPlacedSymbol(this.text,P),R>=0&&this.addIndicesForPlacedSymbol(this.text,R),F>=0&&this.addIndicesForPlacedSymbol(this.icon,F),H>=0&&this.addIndicesForPlacedSymbol(this.icon,H)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}getOrCreateSortedSymbolsByBatch(c,h){const g=(this.text.uboBinder&&this.text.uboBinder.maxFeaturesPerBatch>0?this.text.uboBinder:this.icon.uboBinder&&this.icon.uboBinder.maxFeaturesPerBatch>0?this.icon.uboBinder:null).maxFeaturesPerBatch;if(this.symbolsByBatch)for(const j of this.symbolsByBatch.values())for(const T of j){const P=this.symbolInstances.get(T.index);T.rotatedY=0|Math.round(c*P.tileAnchorX+h*P.tileAnchorY)}else{this.symbolsByBatch=new Map;for(let j=0;jT.rotatedY-P.rotatedY||P.featureIndex-T.featureIndex);return this.symbolsByBatch}rebuildTextSegmentIndices(c,h){for(const g of c){const j=g.batchIndex;if(j===void 0)continue;const T=h.get(j);if(!T){g.primitiveOffset=this.text.indexArray.length,g.primitiveLength=0;continue}g.primitiveOffset=this.text.indexArray.length;const P=this.text.indexArray.length;for(const{index:R}of T){const F=this.symbolInstances.get(R),{rightJustifiedTextSymbolIndex:H,centerJustifiedTextSymbolIndex:Q,leftJustifiedTextSymbolIndex:se,verticalPlacedTextSymbolIndex:re}=F;H>=0&&this.addIndicesForPlacedSymbol(this.text,H),Q>=0&&Q!==H&&this.addIndicesForPlacedSymbol(this.text,Q),se>=0&&se!==Q&&se!==H&&this.addIndicesForPlacedSymbol(this.text,se),re>=0&&this.addIndicesForPlacedSymbol(this.text,re)}g.primitiveLength=this.text.indexArray.length-P}}rebuildIconSegmentIndices(c,h){for(const g of c){const j=g.batchIndex;if(j===void 0)continue;const T=h.get(j);if(!T){g.primitiveOffset=this.icon.indexArray.length,g.primitiveLength=0;continue}g.primitiveOffset=this.icon.indexArray.length;const P=this.icon.indexArray.length;for(const{index:R}of T){const F=this.symbolInstances.get(R),{placedIconSymbolIndex:H,verticalPlacedIconSymbolIndex:Q}=F;H>=0&&this.addIndicesForPlacedSymbol(this.icon,H),Q>=0&&this.addIndicesForPlacedSymbol(this.icon,Q)}g.primitiveLength=this.icon.indexArray.length-P}}sortFeaturesWithinSegments(){this.featureSortOrder=[];const c=Math.sin(this.sortedAngle),h=Math.cos(this.sortedAngle),g=this.getOrCreateSortedSymbolsByBatch(c,h),j=Array.from(g.keys()).sort((T,P)=>T-P);for(const T of j){const P=g.get(T);for(const{index:R}of P){const F=this.symbolInstances.get(R);this.featureSortOrder.push(F.featureIndex)}}this.text.indexArray.clear(),this.icon.indexArray.clear(),this.rebuildTextSegmentIndices(this.text.segments.get(),g),this.rebuildIconSegmentIndices(this.icon.segments.get(),g),this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}getElevationFeatureForText(c){const h=this.symbolInstances.get(this.text.symbolInstanceIndices[c]).elevationFeatureIndex;let g;return this.elevationFeatures&&hg in x?String(x[g]):"")}let HMe,GMe,Xfe;yr(eg,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),eg.addDynamicAttributes=W3;class WMe{constructor(c){this.type=c.property.overrides?c.property.overrides.runtimeType:qx,this.defaultValue=c}evaluate(c){if(c.formattedSection){const h=this.defaultValue.property.overrides;if(h&&h.hasOverride(c.formattedSection))return h.getOverride(c.formattedSection)}return c.feature&&c.featureState?this.defaultValue.evaluate(c.feature,c.featureState):this.defaultValue.property.specification.default}eachChild(c){this.defaultValue.isConstant()||c(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}yr(WMe,"FormatSectionOverride",{omit:["defaultValue"]});const Qfe=()=>Xfe||(Xfe={layout:HMe||(HMe=new Qi({"symbol-placement":new Xs(Wt.layout_symbol["symbol-placement"]),"symbol-spacing":new Xs(Wt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Xs(Wt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Gs(Wt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Xs(Wt.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Xs(Wt.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new Xs(Wt.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new Xs(Wt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Xs(Wt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Xs(Wt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Xs(Wt.layout_symbol["icon-rotation-alignment"]),"icon-size":new Gs(Wt.layout_symbol["icon-size"]),"icon-size-scale-range":new Xs(Wt.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new Gs(Wt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Gs(Wt.layout_symbol["icon-text-fit-padding"]),"icon-image":new Gs(Wt.layout_symbol["icon-image"]),"icon-image-use-theme":new Xs({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new Gs(Wt.layout_symbol["icon-rotate"]),"icon-padding":new Xs(Wt.layout_symbol["icon-padding"]),"icon-keep-upright":new Xs(Wt.layout_symbol["icon-keep-upright"]),"icon-offset":new Gs(Wt.layout_symbol["icon-offset"]),"icon-anchor":new Gs(Wt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Xs(Wt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Xs(Wt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Xs(Wt.layout_symbol["text-rotation-alignment"]),"text-field":new Gs(Wt.layout_symbol["text-field"]),"text-font":new Gs(Wt.layout_symbol["text-font"]),"text-size":new Gs(Wt.layout_symbol["text-size"]),"text-size-scale-range":new Xs(Wt.layout_symbol["text-size-scale-range"]),"text-max-width":new Gs(Wt.layout_symbol["text-max-width"]),"text-line-height":new Gs(Wt.layout_symbol["text-line-height"]),"text-letter-spacing":new Gs(Wt.layout_symbol["text-letter-spacing"]),"text-justify":new Gs(Wt.layout_symbol["text-justify"]),"text-radial-offset":new Gs(Wt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Xs(Wt.layout_symbol["text-variable-anchor"]),"text-anchor":new Gs(Wt.layout_symbol["text-anchor"]),"text-max-angle":new Xs(Wt.layout_symbol["text-max-angle"]),"text-writing-mode":new Xs(Wt.layout_symbol["text-writing-mode"]),"text-rotate":new Gs(Wt.layout_symbol["text-rotate"]),"text-padding":new Xs(Wt.layout_symbol["text-padding"]),"text-keep-upright":new Xs(Wt.layout_symbol["text-keep-upright"]),"text-transform":new Gs(Wt.layout_symbol["text-transform"]),"text-offset":new Gs(Wt.layout_symbol["text-offset"]),"text-allow-overlap":new Xs(Wt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Xs(Wt.layout_symbol["text-ignore-placement"]),"text-optional":new Xs(Wt.layout_symbol["text-optional"]),visibility:new Xs(Wt.layout_symbol.visibility)})),paint:GMe||(GMe=new Qi({"icon-opacity":new Gs(Wt.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new Gs(Wt.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new Gs(Wt.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Gs(Wt.paint_symbol["text-emissive-strength"]),"icon-color":new Gs(Wt.paint_symbol["icon-color"]),"icon-halo-color":new Gs(Wt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Gs(Wt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Gs(Wt.paint_symbol["icon-halo-blur"]),"icon-translate":new Xs(Wt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Xs(Wt.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Xs(Wt.paint_symbol["icon-image-cross-fade"]),"text-opacity":new Gs(Wt.paint_symbol["text-opacity"]),"text-occlusion-opacity":new Gs(Wt.paint_symbol["text-occlusion-opacity"]),"text-color":new Gs(Wt.paint_symbol["text-color"],{runtimeType:Nu,getOverride:x=>x.textColor,hasOverride:x=>!!x.textColor}),"text-halo-color":new Gs(Wt.paint_symbol["text-halo-color"]),"text-halo-width":new Gs(Wt.paint_symbol["text-halo-width"]),"text-halo-blur":new Gs(Wt.paint_symbol["text-halo-blur"]),"text-translate":new Xs(Wt.paint_symbol["text-translate"]),"text-translate-anchor":new Xs(Wt.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Xs(Wt.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Xs(Wt.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Xs(Wt.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Xs(Wt.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new Gs(Wt.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new Gs({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new Gs({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new Gs({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new Gs({type:"string",default:"default","property-type":"data-driven"})}))},Xfe);class E7 extends Yd{constructor(c,h,g,j){super(c,Qfe(),h,g,j,c.layout?c.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=w([]),this.hasOcclusionOpacityProperties=c.paint!==void 0&&("icon-occlusion-opacity"in c.paint||"text-occlusion-opacity"in c.paint)}_handleSpecialPaintPropertyUpdate(c){c!=="icon-occlusion-opacity"&&c!=="text-occlusion-opacity"||(this.hasOcclusionOpacityProperties=!0)}recalculate(c,h){super.recalculate(c,h),this.appearances&&this.appearances.forEach(j=>{j.recalculate(c,h,this.iconImageUseTheme)}),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const g=this.layout.get("text-writing-mode");if(g){const j=[];for(const T of g)j.indexOf(T)<0&&j.push(T);this.layout._values["text-writing-mode"]=j}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getColorAdjustmentMatrix(c,h,g,j){return this._saturation===c&&this._contrast===h&&this._brightnessMin===g&&this._brightnessMax===j||(this._colorAdjustmentMatrix=function(T,P,R,F){T=qi(T),P=ui(P);const H=b(),Q=T/3,se=1-2*Q,re=[se,Q,Q,0,Q,se,Q,0,Q,Q,se,0,0,0,0,1],le=.5-.5*P,ue=F-R;return C(H,[ue,0,0,0,0,ue,0,0,0,0,ue,0,R,R,R,1],[P,0,0,0,0,P,0,0,0,0,P,0,le,le,le,1]),C(H,H,re),H}(c,h,g,j),this._saturation=c,this._contrast=h,this._brightnessMin=g,this._brightnessMax=j),this._colorAdjustmentMatrix}getValueAndResolveTokens(c,h,g,j){const T=this.layout.get(c).evaluate(h,{},g,j),P=this._unevaluatedLayout._values[c];return P.isDataDriven()||n2(P.value)||!T?T:VMe(h.properties,T)}getAppearanceValueAndResolveTokens(c,h,g,j,T){const P=c.getLayoutProperty(h);if(!P)return;const R=P.evaluate(g,{},j,T),F=c.getUnevaluatedLayoutProperties()._values[h];return F.isDataDriven()||n2(F.value)||!R||typeof R!="string"?R:VMe(g.properties,R)}createBucket(c){return new eg(c)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const c of Qfe().paint.overridableProperties){if(!E7.hasPaintOverride(this.layout,c))continue;const h=this.paint.get(c),g=new WMe(h),j=new c3(g,h.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme"));let T=null;T=h.value.kind==="constant"||h.value.kind==="source"?new K1("source",j):new W0("composite",j,h.value.zoomStops,h.value.interpolationType),this.paint._values[c]=new X0(h.property,T,h.parameters)}}_handleOverridablePaintPropertyUpdate(c,h,g){return!(!this.layout||h.isDataDriven()||g.isDataDriven())&&E7.hasPaintOverride(this.layout,c)}static hasPaintOverride(c,h){const g=c.get("text-field"),j=Qfe().paint.properties[h];let T=!1;const P=R=>{for(const F of R)if(j.overrides&&j.overrides.hasOverride(F))return void(T=!0)};if(g.value.kind==="constant"&&g.value.value instanceof Td)P(g.value.value.sections);else if(g.value.kind==="source"){const R=H=>{T||(H instanceof Sr&&Oo(H.value)===Lw?P(H.value.sections):H instanceof B0?P(H.sections):H.eachChild(R))},F=g.value;F._styleExpression&&R(F._styleExpression.expression)}return T}getProgramIds(){return["symbol"]}getDefaultProgramParams(c,h,g){return{config:new be(this,{zoom:h,lut:g}),overrideFog:!1}}hasElevation(){return this.layout&&this.layout.get("symbol-elevation-reference")==="hd-road-markup"}}let KMe,ZMe,YMe,XMe;var P7=la([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Uint16",components:2}]);function I7(x,c,h,g,j,T,P,R){const F=[x,c,1,h,g,1,j,T,1],H=[P,R,1],Q=y([],F),[se,re,le]=fe(H,H,Q);return _(F,F,[se,0,0,0,re,0,0,0,le])}function QMe(x,c,h,g,j,T,P,R){const F=function(H,Q,se,re,le,ue,_e,Ce){const Ee=I7(0,0,1,0,1,1,0,1),Ge=I7(H,Q,se,re,le,ue,_e,Ce);return _(Ge,Ge,y([],Ee))}(x,c,h,g,j,T,P,R);return[F[2]/F[8]/sr,F[5]/F[8]/sr]}function L7(x){return[x[0],Math.min(Math.max(x[1],-85.051129),hs)]}class JMe extends Ei{constructor(c,h,g,j){super(),this.id=c,this.dispatcher=g,this.coordinates=h.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(j),this.options=h,this._dirty=!1}load(c,h){if(this._loaded=h||!1,this.fire(new tn("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return c&&(this.coordinates=c),this._loaded=!0,void this._finishLoading();this._imageRequest=ty(this.map._requestManager.transformRequest(this.url,D0.Image),(g,j)=>{this._imageRequest=null,this._loaded=!0,g?this.fire(new xn(g)):j&&(this.image=j,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,c&&(this.coordinates=c),this._finishLoading())})}loaded(){return this._loaded}updateImage(c){return c.url?(this._imageRequest&&c.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=c.url,this.load(c.coordinates,this._loaded),this):this}setTexture(c){if(!(c.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new f6(this.map.painter.context,c.handle),this.width=c.dimensions[0],this.height=c.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new tn("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(c){this.map=c,this.load()}onRemove(c){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof f6||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(c){if(this.coordinates=c,this._boundsArray=void 0,this._unsupportedCoords=!1,!c.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let h=c[0][1],g=c[0][1];for(const T of c)T[1]>g&&(g=T[1]),T[1]hs?this.onNorthPole=!0:j<-85.051129&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const T=c.map(jr.fromLngLat);this.tileID=function(P){let R=1/0,F=1/0,H=-1/0,Q=-1/0;for(const _e of P)R=Math.min(R,_e.x),F=Math.min(F,_e.y),H=Math.max(H,_e.x),Q=Math.max(Q,_e.y);const se=Math.max(H-R,Q-F),re=Math.max(0,Math.floor(-Math.log2(se))),le=Math.pow(2,re);let ue=Math.floor((R+H)/2*le);return ue>1&&(ue-=1),new N2(re,ue,Math.floor((F+Q)/2*le))}(T),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new tn("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof f6||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(c){for(const Ce in this.tiles){const Ee=this.tiles[Ce];Ee.state!=="loaded"&&(Ee.state="loaded",Ee.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const h=E2(new N2(0,0,0),this.map.transform.projection),g=[h.projection.project(this.coordinates[0][0],this.coordinates[0][1]),h.projection.project(this.coordinates[1][0],this.coordinates[1][1]),h.projection.project(this.coordinates[2][0],this.coordinates[2][1]),h.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(Ce){const Ee=Ce[1].x-Ce[0].x,Ge=Ce[1].y-Ce[0].y,Be=Ce[2].x-Ce[1].x,nt=Ce[2].y-Ce[1].y,it=Ce[3].x-Ce[2].x,lt=Ce[3].y-Ce[2].y,Rt=Ce[0].x-Ce[3].x,jt=Ce[0].y-Ce[3].y,It=Ee*nt-Be*Ge,Mt=Be*lt-it*nt,Tt=it*jt-Rt*lt,rs=Rt*Ge-Ee*jt;return It>0&&Mt>0&&Tt>0&&rs>0||It<0&&Mt<0&&Tt<0&&rs<0}(g))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const j=E2(this.tileID,this.map.transform.projection),[T,P,R,F]=this.coordinates.map(Ce=>{const Ee=j.projection.project(Ce[0],Ce[1]);return FMe(j,Ee)._round()});this.perspectiveTransform=QMe(T.x,T.y,P.x,P.y,R.x,R.y,F.x,F.y);const H=this._boundsArray=new dd;H.emplaceBack(T.x,T.y,0,0),H.emplaceBack(P.x,P.y,sr,0),H.emplaceBack(F.x,F.y,0,sr),H.emplaceBack(R.x,R.y,sr,sr),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=c.createVertexBuffer(H,P7.members),this.boundsSegments=ji.simpleSegment(0,0,4,2);const Q=[],se=function(Ce){return[L7(Ce[0]),L7(Ce[1]),L7(Ce[2]),L7(Ce[3])]}(this.coordinates),[re,le,ue,_e]=function(Ce){let Ee=Ce[0][0],Ge=Ee,Be=Ce[0][1],nt=Be;for(let it=1;itGe&&(Ge=Ce[it][0]),Ce[it][1]nt&&(nt=Ce[it][1]);return[Ee,Be,Ge-Ee,nt-Be]}(se);{const Ce=new dd,[Ee,Ge,Be,nt]=function(gs){let Rs=gs[0].x,ts=Rs,ws=gs[0].y,Ts=ws;for(let Os=1;Osts&&(ts=gs[Os].x),gs[Os].yTs&&(Ts=gs[Os].y);return[Rs,ws,ts-Rs,Ts-ws]}(g),it=gs=>[(gs.x-Ee)/Be,(gs.y-Ge)/nt],[lt,Rt,jt,It]=g.map(it),Mt=function(gs,Rs,ts,ws,Ts,Os,Zs,xr){const er=I7(0,0,1,0,1,1,0,1);return _(er,er,y([],I7(gs,Rs,ts,ws,Ts,Os,Zs,xr)))}(lt[0],lt[1],Rt[0],Rt[1],jt[0],jt[1],It[0],It[1]);this.elevatedGlobePerspectiveTransform=QMe(lt[0],lt[1],Rt[0],Rt[1],jt[0],jt[1],It[0],It[1]);const Tt=(gs,Rs)=>{Q.push(gs.lng);const ts=Math.round((gs.lng-re)/ue*sr),ws=Math.round((gs.lat-le)/_e*sr),Ts=it(Rs),Os=fe([],[Ts[0],Ts[1],1],Mt),Zs=Math.round(Os[0]/Os[2]*sr),xr=Math.round(Os[1]/Os[2]*sr);Ce.emplaceBack(ts,ws,Zs,xr)},rs=g[3].x-g[0].x,ls=g[3].y-g[0].y,xs=g[2].x-g[1].x,Ns=g[2].y-g[1].y;for(let gs=0;gs<65;gs++){const Rs=gs/64,ts=[g[0].x+Rs*rs,g[0].y+Rs*ls],ws=[g[1].x+Rs*xs,g[1].y+Rs*Ns],Ts=ws[0]-ts[0],Os=ws[1]-ts[1];for(let Zs=0;Zs<65;Zs++){const xr=Zs/64,er={x:ts[0]+Ts*xr,y:ts[1]+Os*xr};Tt(h.projection.unproject(er.x,er.y),er)}}this.elevatedGlobeVertexBuffer=c.createVertexBuffer(Ce,P7.members)}{this.maxLongitudeTriangleSize=0;let Ce=[],Ee=new Ao;const Ge=(Be,nt,it)=>{Ee.emplaceBack(Be,nt,it);const lt=Q[Be],Rt=Q[nt],jt=Q[it],It=Math.min(Math.min(lt,Rt),jt),Mt=Math.max(Math.max(lt,Rt),jt)-It;Mt>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=Mt),Ce.push(It+Mt/2)};for(let Be=0;Be<64;Be++)for(let nt=0;nt<64;nt++){const it=65*Be+nt,lt=it+1,Rt=it+65,jt=Rt+1;Ge(it,Rt,lt),Ge(lt,Rt,jt)}[Ce,Ee]=function(Be,nt){const it=Array.from({length:Be.length},(jt,It)=>It);it.sort((jt,It)=>Be[jt]-Be[It]);const lt=[],Rt=new Ao;for(let jt=0;jt{P.segments.push({vertexOffset:0,primitiveOffset:se,vertexLength:h.segments[0].vertexLength,primitiveLength:re,sortKey:void 0,vaos:{}})},F=.51*this.maxLongitudeTriangleSize;if(Math.abs(g[0]-j)<=F){const se=tl(g,0,g.length,j+F);return se===g.length||R(se,$i(g,se+1,g.length,j+360-F)-se),P}j0}}let tTe,sTe,rTe,nTe,aTe,iTe,oTe;class lTe extends Yd{constructor(c,h,g,j){super(c,{layout:tTe||(tTe=new Qi({visibility:new Xs(Wt["layout_raster-particle"].visibility)})),paint:sTe||(sTe=new Qi({"raster-particle-array-band":new Xs(Wt["paint_raster-particle"]["raster-particle-array-band"]),"raster-particle-count":new Xs(Wt["paint_raster-particle"]["raster-particle-count"]),"raster-particle-color":new Q1(Wt["paint_raster-particle"]["raster-particle-color"]),"raster-particle-max-speed":new Xs(Wt["paint_raster-particle"]["raster-particle-max-speed"]),"raster-particle-speed-factor":new Xs(Wt["paint_raster-particle"]["raster-particle-speed-factor"]),"raster-particle-fade-opacity-factor":new Xs(Wt["paint_raster-particle"]["raster-particle-fade-opacity-factor"]),"raster-particle-reset-rate-factor":new Xs(Wt["paint_raster-particle"]["raster-particle-reset-rate-factor"]),"raster-particle-elevation":new Xs(Wt["paint_raster-particle"]["raster-particle-elevation"]),"raster-particle-color-use-theme":new Gs({type:"string",default:"default","property-type":"data-driven"})}))},h,g,j),this._updateColorRamp(),this.lastInvalidatedAt=Cd.now()}_clear(){this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null),this.tileFramebuffer&&(this.tileFramebuffer.destroy(),this.tileFramebuffer=null),this.particleFramebuffer&&(this.particleFramebuffer.destroy(),this.particleFramebuffer=null)}onRemove(c){this.colorRampTexture&&this.colorRampTexture.destroy(),this.tileFramebuffer&&this.tileFramebuffer.destroy(),this.particleFramebuffer&&this.particleFramebuffer.destroy()}hasColorMap(){return!!this._transitionablePaint._values["raster-particle-color"].value.value}getProgramIds(){return["rasterParticle"]}hasOffscreenPass(){return this.visibility!=="none"}isDraped(c){return!1}_handleSpecialPaintPropertyUpdate(c){c!=="raster-particle-color"&&c!=="raster-particle-max-speed"||(this._updateColorRamp(),this._invalidateAnimationState()),c==="raster-particle-count"&&this._invalidateAnimationState()}_updateColorRamp(){if(!this.hasColorMap())return;const c=this._transitionablePaint._values["raster-particle-color"].value.expression,h=this._transitionablePaint._values["raster-particle-max-speed"].value.expression.evaluate({zoom:0});this.colorRamp=e6({expression:c,evaluationKey:"rasterParticleSpeed",image:this.colorRamp,clips:[{start:0,end:h}],resolution:256}),this.colorRampTexture=null}_invalidateAnimationState(){this.lastInvalidatedAt=Cd.now()}tileCoverLift(){return this.paint.get("raster-particle-elevation")}}class qht extends Yd{constructor(c,h){super(c,{},h,null),this.implementation=c,c.slot&&(this.slot=c.slot)}is3D(c){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}isDraped(c){return this.implementation.renderToTile!==void 0}shouldRedrape(){return!!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(c){this.implementation.onAdd&&this.implementation.onAdd(c,c.painter.context.gl)}onRemove(c){this.implementation.onRemove&&this.implementation.onRemove(c,c.painter.context.gl)}}function exe(x,c,h){const g=[0,0,1],j=Ze([]);return Ut(j,j,h?-Zr(x)+Math.PI:Zr(x)),kt(j,j,-Zr(c)),$e(g,g,j),Ne(g,g)}class D7{constructor(c,h,g,j){this.message=(c?`${c}: `:"")+g,j&&(this.identifier=j),h!=null&&h.__line__&&(this.line=h.__line__)}}function txe(x,c){const h=x.indexOf("://")===-1;try{return new URL(x,h&&c?"http://example.com":void 0),!0}catch{return!1}}class cTe{constructor(c,h){this.feature=c,this.instancedDataOffset=h,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class dTe{constructor(){this.maxScale=1,this.maxXYTranslationDistance=0,this.instancedDataArray=new HP,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}colorForInstance(c){const h=16*c,g=this.instancedDataArray.float32;let j=Math.floor(g[h+2]);const T=1.05*(g[h+2]-j);return j/=100,[g[h]%1*1.05,g[h+1]%1*1.05,T,j]}tileCoordinatesForInstance(c){const h=16*c,g=this.instancedDataArray.float32;let j=g[h+0];return j=j>sr?j-sr:j,new as(Math.trunc(j),Math.trunc(g[h+1]))}translationForInstance(c){const h=16*c,g=this.instancedDataArray.float32;return[g[h+4],g[h+5],g[h+6]]}rotationScaleForInstance(c){const h=16*c,g=this.instancedDataArray.float32;return[g[h+7],g[h+8],g[h+9],g[h+10],g[h+11],g[h+12],g[h+13],g[h+14],g[h+15]]}transformForInstance(c){const h=16*c,g=this.instancedDataArray.float32;return[g[h+7],g[h+8],g[h+9],g[h+4],g[h+10],g[h+11],g[h+12],g[h+5],g[h+13],g[h+14],g[h+15],g[h+6],0,0,0,1]}}class sxe{constructor(c){this.zoom=c.zoom,this.canonical=c.canonical,this.overscaledZ=this.canonical.z+Math.log2(c.overscaling),this.layers=c.layers,this.layerIds=this.layers.map(h=>h.fqid),this.projection=c.projection,this.index=c.index,this.worldview=c.worldview,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter(h=>h.isStateDependent()).map(h=>h.id),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z+1?0:this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.styleDefinedModelURLs=c.styleDefinedModelURLs,this.hasAppearances=null}updateFootprints(c,h){}updateAppearances(c,h,g,j){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(c,h,g,j){this.tileToMeter=As(g);const T=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);const P=this.layers[0].paint.get("model-elevation-reference")==="hd-road-markup"?h.elevationFeatures:void 0;for(const{feature:R,id:F,index:H,sourceLayerIndex:Q}of c){const se=F??(R.properties&&R.properties.hasOwnProperty("id")?R.properties.id:void 0),re=Vn(R,T);if(!this.layers[0]._featureFilter.filter(new Ka(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),re,g))continue;const le={id:se,sourceLayerIndex:Q,index:H,geometry:T?re.geometry:Vr(R,g,j),properties:R.properties,type:R.type,patterns:{}},ue=this.addFeature(le,le.geometry,re,P,g);ue&&h.featureIndex.insert(R,le.geometry,H,Q,this.index,this.instancesPerModel[ue].instancedDataArray.length,256)}this.lookup=null}evaluateQueryRenderedFeaturePadding(){const c=this.layers[0].modelManager,h=this.layers[0].scope;let g=0;for(const j of this.modelUris){const T=c.getModel(j,h);if(!T)continue;const P=this.instancesPerModel[j];if(P){const R=.5*Me(T.aabb.max,T.aabb.min)*P.maxScale+P.maxXYTranslationDistance,F=Math.min(sr,Math.max(R/this.tileToMeter,256));g=Math.max(F,g)}}return g}update(c,h,g,j){for(const T in this.instancesPerModel){const P=this.instancesPerModel[T];for(const R in c)P.idToFeaturesIndex.hasOwnProperty(R)&&(this.evaluate(P.features[P.idToFeaturesIndex[R]],c[R],P,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let c=!1;for(const h in this.instancesPerModel){const g=this.instancesPerModel[h];for(const j of g.features){const T=this.layers[0],P=j.feature,R=this.canonical,F=T.paint.get("model-rotation").evaluate(P,{},R),H=T.paint.get("model-scale").evaluate(P,{},R),Q=T.paint.get("model-translation").evaluate(P,{},R);tt(j.rotation,F)&&tt(j.scale,H)&&tt(j.translation,Q)||(this.evaluate(j,j.featureStates,g,!0),c=!0)}}return c}updateReplacement(c,h,g,j){if(h.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=h.updateTime;const T=h.getReplacementRegionsForTile(c.toUnwrapped(),!0);if(e7(this.activeReplacements,T))return!1;this.activeReplacements=T;let P=!1;for(const R in this.instancesPerModel){const F=this.instancesPerModel[R],H=F.instancedDataArray;for(const Q of F.features){const se=Q.instancedDataOffset,re=Q.instancedDataCount;for(let le=0;lesr;_e=Ce?_e-sr:_e;const Ee=Math.floor(_e),Ge=Math.floor(H.float32[ue+1]);let Be=!1;for(const nt of this.activeReplacements)if(!H3e(nt,g,t7.Model,j)&&!(nt.min.x>Ee||Ee>nt.max.x||nt.min.y>Ge||Ge>nt.max.y)&&(Be=Y3e(Z3e(Ee,Ge,c.canonical,nt.footprintTileId.canonical),nt.footprint),Be))break;H.float32[ue]=Be?_e+sr:_e,P=P||Be!==Ce}}}return P}isEmpty(){for(const c in this.instancesPerModel)if(this.instancesPerModel[c].instancedDataArray.length!==0)return!1;return!0}uploadPending(){return!this.uploaded}upload(c){if(!this.uploaded)for(const h in this.instancesPerModel){const g=this.instancesPerModel[h];g.instancedDataArray.length<0||g.instancedDataArray.length===0||(g.instancedDataBuffer?g.instancedDataBuffer.updateData(g.instancedDataArray):g.instancedDataBuffer=c.createVertexBuffer(g.instancedDataArray,out.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(c){for(const g in this.instancesPerModel){const j=this.instancesPerModel[g];j.instancedDataArray.length!==0&&j.instancedDataBuffer&&j.instancedDataBuffer.destroy()}const h=this.layers[0].modelManager;if(c&&h&&this.modelUris&&this.modelsRequested)for(const g of this.modelUris)h.removeModel(g,"",!0)}addFeature(c,h,g,j,T){const P=this.layers[0],R=P.layout.get("model-id"),F=P.layout.get("model-allow-density-reduction"),H=R.evaluate(g,{},this.canonical);if(!H)return zr(`modelId is not evaluated for layer ${P.id} and it is not going to get rendered.`),H;(txe(H,!1)||this.styleDefinedModelURLs[H]!==void 0)&&(this.modelUris.includes(H)||this.modelUris.push(H)),this.instancesPerModel[H]||(this.instancesPerModel[H]=new dTe);const Q=this.instancesPerModel[H],se=Q.instancedDataArray,re=new cTe(g,se.length);let le;j&&(le=Ci.getElevationFeature(c,j));for(const ue of h)for(const _e of ue){if(_e.x<0||_e.x>=sr||_e.y<0||_e.y>=sr)continue;if(this.lookupDim!==0&&F){const Ee=(this.lookupDim-1)/sr,Ge=this.lookupDim*(_e.y*Ee|0)+_e.x*Ee|0;if(this.lookup){if(this.lookup[Ge]!==0)continue;this.lookup[Ge]=1}}this.instanceCount++;const Ce=se.length;if(se.resize(Ce+1),j){Q.instancesRoadElevation||(Q.instancesRoadElevation=[]);const Ee=le?le.pointElevation(new as(_e.x,_e.y)):0;Q.instancesRoadElevation.push(Ee)}Q.instancesEvaluatedElevation.push(0),se.float32[16*Ce]=_e.x,se.float32[16*Ce+1]=_e.y}return re.instancedDataCount=Q.instancedDataArray.length-re.instancedDataOffset,re.instancedDataCount>0&&(c.id&&(Q.idToFeaturesIndex[c.id]=Q.features.length),Q.features.push(re),this.evaluate(re,{},Q,!1)),H}getModelUris(){return this.modelUris}evaluate(c,h,g,j){const T=this.layers[0],P=c.feature,R=this.canonical,F=c.rotation=T.paint.get("model-rotation").evaluate(P,h,R),H=c.scale=T.paint.get("model-scale").evaluate(P,h,R),Q=c.translation=T.paint.get("model-translation").evaluate(P,h,R),se=Object.assign({},T.paint.get("model-color").evaluate(P,h,R));se.a=T.paint.get("model-color-mix-intensity").evaluate(P,h,R);const re=[];this.maxVerticalOffset0?Math.sqrt(le):0;g.maxScale=Math.max(Math.max(g.maxScale,H[0]),Math.max(H[1],H[2])),g.maxXYTranslationDistance=Math.max(g.maxXYTranslationDistance,ue),this.maxScale=Math.max(Math.max(this.maxScale,H[0]),Math.max(H[1],H[2])),L5e(re,F,H);const _e=Math.round(100*se.a)+se.b/1.05;for(let Ce=0;Ce10?this.tileToMeter:As(R,it)),Be[Ge+4]=Q[0],Be[Ge+5]=Q[1],Be[Ge+6]=Q[2]+(g.instancesRoadElevation?g.instancesRoadElevation[Ee]:0)+nt,Be[Ge+7]=re[0],Be[Ge+8]=re[1],Be[Ge+9]=re[2],Be[Ge+10]=re[4],Be[Ge+11]=re[5],Be[Ge+12]=re[6],Be[Ge+13]=re[8],Be[Ge+14]=re[9],Be[Ge+15]=re[10],g.instancesEvaluatedElevation[Ee]=Q[2]}}}yr(sxe,"ModelBucket",{omit:["layers"]}),yr(dTe,"PerModelAttributes"),yr(cTe,"ModelFeature");class Z3{constructor(c,h,g){this._demTile=c,this._dem=this._demTile.dem,this._scale=h,this._offset=g}static create(c,h,g){const j=g||c.findDEMTileFor(h);if(!j||!j.dem)return;const T=j.dem,P=j.tileID,R=1<H.fqid),this.stateDependentLayerIds=this.layers.filter(H=>H.isStateDependent()).map(H=>H.id),this.modelTraits|=$3.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,j&&(this.modelTraits|=$3.HasMapboxMeshFeatures),T&&(this.modelTraits|=$3.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=P,this.worldview=F,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const H of h)this.nodesInfo.push(new pTe(H)),hTe(H,R.featureIndexArray.length,R.grid),R.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,R.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null}updateFootprints(c,h){for(const g of this.getNodesInfo()){const j=g.node;j.footprint&&h.push({footprint:j.footprint,id:c})}}updateAppearances(c,h,g,j){return{hasLayoutChanges:!1,hasUboChanges:!1}}update(c){const h=Object.keys(c).length!==0;if(h&&!this.stateDependentLayers.length)return;const g=h?this.stateDependentLayers:this.layers;if(!qn(c,this.states))for(const j of g)this.evaluate(j,c);this.states=structuredClone(c)}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(c){if(!this.needsUpload)return;const h=this.getNodesInfo();for(const g of h){const j=g.node;this.uploaded?this.updatePbrBuffer(j):_fe(j,c,!0)}for(const g of h)p7(g.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(c){let h=!1;if(!c.meshes)return h;for(const g of c.meshes)g.pbrBuffer&&(g.pbrBuffer.updateData(g.featureArray),h=!0);return h}needsReEvaluation(c,h,g){const j=c.transform.projectionOptions,T=c.style.getBrightness(),P=this.brightness!==T;if(!this.uploaded||this.dirty||j.name!==this.projection.name||E6(g.paint.get("model-color").value,P)||E6(g.paint.get("model-color-mix-intensity").value,P)||E6(g.paint.get("model-roughness").value,P)||E6(g.paint.get("model-emissive-strength").value,P)||E6(g.paint.get("model-height-based-emissive-strength-multiplier").value,P)){this.projection=j,this.brightness=T;const R=this.getNodesInfo();for(const F of R)F.state=null;return!0}return!1}evaluateTransform(c,h){if(c.transform.zoom===this.zoom)return;this.zoom=c.transform.zoom;const g=this.getNodesInfo(),j=this.id.canonical;for(const T of g){const P=T.feature;T.evaluatedTranslation=h.paint.get("model-translation").evaluate(P,{},j),T.evaluatedScale=h.paint.get("model-scale").evaluate(P,{},j)}}evaluate(c,h){const g=this.getNodesInfo();for(const j of g){if(!j.node.meshes)continue;const T=j.feature,P=h&&h[T.id];if(qn(P,j.state))continue;j.state=structuredClone(P);const R=j.node.meshes&&j.node.meshes[0].featureData,F=j.evaluatedColor[2],H=j.evaluatedRMEA[2],Q=this.id.canonical;if(j.hasTranslucentParts=!1,R){for(let se=0;se=lt)continue;const Rs=rxe[gs],ts=Math.abs(Rs);ts>Tt&&(Mt=Rs,Tt=ts,rs=Ns,ls=xs)}if(Tt>.1){const xs=1-(lt+.5*Math.abs(rs*ls))/ue;let Ns=h._dem.get(jt,Rt)+Mt*xs;const gs=h._dem.get(jt+rs,Rt+ls),Rs=h._dem.get(jt-rs,Rt-ls,!0);(Ns-gs)*(Ns-Rs)>0&&(Ns=(gs+Rs)/2),rxe[It]=h._dem.set(jt,Rt,Ns),P2[It]=lt}}}}}R&&(h._demTile.needsDEMTextureUpload=!0,h._dem._timestamp=Cd.now())}setFilter(c){this.filter=c?b3(c):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(c=>this.filter.filter(new Ka(this.id.overscaledZ,{worldview:this.worldview}),c.feature,this.id.canonical)):this.nodesInfo}destroy(){const c=this.getNodesInfo();for(const h of c)p7(h.node),bfe(h.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(c,h){if(h.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=h.updateTime;const g=h.getReplacementRegionsForTile(c.toUnwrapped());for(const j of this.getNodesInfo()){const T=j.node.footprint;j.hiddenByReplacement=!!T&&!g.find(P=>P.footprint===T)}}getHeightAtTileCoord(c,h){const g=[],j=[0,0,0],T=w([]);for(const P of this.getNodesInfo()){const R=P.node.meshes[0],F=R.transformedAabb;if(cF.max[0]||h>F.max[1])continue;if(P.node.hidden===!0)return{height:1/0,maxHeight:P.feature.properties.height,hidden:!1,verticalScale:P.evaluatedScale[2]};S(T,P.node.globalMatrix),j[0]=c,j[1]=h,ct(j,j,T);const H=(j[0]-R.aabb.min[0])/(R.aabb.max[0]-R.aabb.min[0])*C2|0,Q=Math.min(63,(j[1]-R.aabb.min[1])/(R.aabb.max[1]-R.aabb.min[1])*C2|0)*C2+Math.min(63,H),se=R.heightmap[Q];if(!(se<0&&P.node.footprint))return P.hiddenByReplacement?void 0:{height:se,maxHeight:P.feature.properties.height,hidden:!1,verticalScale:P.evaluatedScale[2]};if(P.node.footprint.grid.query(new as(c,h),new as(c,h),g),g.length>0)return{height:void 0,maxHeight:P.feature.properties.height,hidden:P.hiddenByReplacement,verticalScale:P.evaluatedScale[2]}}}}function E6(x,c){return x instanceof K1&&!x.isLightConstant&&c}function Uht(x,c,h,g,j,T,P,R){let F=(61440&c|(61440&c)>>4)>>8,H=(3840&c|(3840&c)>>4)>>4,Q=240&c|(240&c)>>4;h[3]>0&&(F=on(F,255*h[0],h[3]),H=on(H,255*h[1],h[3]),Q=on(Q,255*h[2],h[3]));const se=F<<8|H,re=Q<<8|Math.floor(255*g[3]),le=function(lt){const Rt=Fe(lt,0,2);return Math.min(Math.round(.5*Rt*255),255)}(g[2])<<8|15*g[0]<<4|15*g[1],ue=Fe(j[0],0,1),_e=Fe(j[1],0,1),Ce=Fe(j[2],0,1),Ee=Fe(j[3],0,1);let Ge,Be,nt,it;if(ue!==_e&&P!==T&&_e!==ue){const lt=P-T;Be=1/(lt*(_e-ue)),nt=-(T+lt*ue)/(lt*(_e-ue));const Rt=Fe(j[4],-1,1);it=Math.pow(10,Rt),Ge=255*Ce<<8|255*Ee}else Ge=65535,Be=0,nt=1,it=1;if(x.emplaceBack(se,re,le,Ge,Be,nt,it),R){const lt=R.length;R.clear();for(let Rt=0;Rt>16&65535,Q=T?F>>16&65535:65535&F,se=(15&Q)<8?15&Q:0,re=x.evaluatedRMEA[se],le=x.evaluatedColor[se],ue=x.emissionHeightBasedParams[se];let _e;if(R&&se===2&&g.lights&&(_e=new T3,_e.resize(10*g.lights.length)),Uht(P.featureArray,H,le,re,ue,P.aabb.min[2],P.aabb.max[2],_e),_e&&R){R=!1;const Ce=g.meshes[g.lightMeshIndex];Ce.featureArray=_e,Ce.featureArray._trim()}}P.featureArray._trim(),j++}}yr(R7,"Tiled3dModelBucket",{omit:["layers"]}),yr(pTe,"Tiled3dModelFeature");const Hht=["id","tile","layer","source","sourceLayer","state"];class I2{constructor(c,h,g,j,T){this.type="Feature",this._vectorTileFeature=c,this._z=h,this._x=g,this._y=j,this.properties=c?c.properties:{},this.id=T}clone(){const c=new I2(this._vectorTileFeature,this._z,this._x,this._y,this.id);return this.state&&(c.state=Object.assign({},this.state)),this.layer&&(c.layer=Object.assign({},this.layer)),this.source&&(c.source=this.source),this.sourceLayer&&(c.sourceLayer=this.sourceLayer),c}get geometry(){return this._geometry===void 0&&this._vectorTileFeature&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(c){this._geometry=c}toJSON(){const c={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const h of Hht)this[h]!==void 0&&(c[h]=this[h]);return c}}class L2 extends Ei{constructor(c,h,g,j){super(),this.id=c,this.type="model",this.models=[],this._options=h,this._modelsInfo=new Map,this._abortController=null}cancelModelRequests(){this._abortController&&(this._abortController.abort(),this._abortController=null)}loadGLTFFromURI(c,h){return A5e(this.map._requestManager.transformRequest(c,D0.Model).url,h)}async loadModel(c,h,g){try{const j=await this.loadGLTFFromURI(h.uri,g);if(g.aborted)return;const T=this._modelsInfo.get(c);if(!T)return;const P=jfe(j),R=T.modelSpec,F=new D5e(c,R.uri,R.position,R.orientation,P);L2.applyModelSpecification(F,R),F.computeBoundsAndApplyParent(),this.models.push(F),T.model=F}catch(j){if(j instanceof Error&&j.name==="AbortError")return;const T=j instanceof Error?j.message:"Unknown error";this.fire(new xn(new Error(`Could not load model ${c} from ${h.uri}: ${T}`)))}}async load(){this._abortController||(this._abortController=new AbortController);const c=this._abortController.signal,h=[];for(const g in this._options.models){const j=this._options.models[g],T=this._modelsInfo.get(g);if(T&&T.model){T.modelSpec=j;const P=T.model;P.position=j.position!=null?new qt(j.position[0],j.position[1]):new qt(0,0),P.orientation=j.orientation!=null?j.orientation:[0,0,0],L2.applyModelSpecification(P,j),P.computeBoundsAndApplyParent(),this.models.push(P)}else T?T.modelSpec=j:(this._modelsInfo.set(g,{modelSpec:j,model:null}),h.push(this.loadModel(g,j,c)))}h.length!==0?(await Promise.allSettled(h),c.aborted||this.fire(new tn("data",{dataType:"source",sourceDataType:"metadata"}))):this.loaded()&&this.fire(new tn("data",{dataType:"source",sourceDataType:"metadata"}))}static applyModelSpecification(c,h){h.nodeOverrides&&L2.convertNodeOverrides(c,h.nodeOverrides),h.materialOverrides&&L2.convertMaterialOverrides(c,h.materialOverrides),h.nodeOverrideNames&&(c.nodeOverrideNames=[...h.nodeOverrideNames]),h.materialOverrideNames&&(c.materialOverrideNames=[...h.materialOverrideNames]),h.featureProperties&&(c.featureProperties=h.featureProperties)}static convertNodeOverrides(c,h){if(Array.isArray(h)&&h.every(g=>typeof g=="string")){c.nodeOverrideNames=[];for(const g of h)c.nodeOverrideNames.push(g)}else Object.entries(h).forEach(([g,j])=>{const T={orientation:[0,0,0]};if(j.hasOwnProperty("orientation")){const P=j.orientation;P&&(T.orientation=P)}c.nodeOverrides.set(g,T)})}static convertMaterialOverrides(c,h){if(Array.isArray(h)&&h.every(g=>typeof g=="string")){c.materialOverrideNames=[];for(const g of h)c.materialOverrideNames.push(g)}else Object.entries(h).forEach(([g,j])=>{const T={color:new Aa(1,1,1),colorMix:0,emissionStrength:0,opacity:1},P=j["model-color"];P!==void 0&&(T.color.r=P[0],T.color.g=P[1],T.color.b=P[2]);const R=j["model-color-mix-intensity"];R!==void 0&&(T.colorMix=R);const F=j["model-emissive-strength"];F!==void 0&&(T.emissionStrength=F);const H=j["model-opacity"];H!==void 0&&(T.opacity=H),c.materialOverrides.set(g,T)})}onAdd(c){this.map=c,this.load()}hasTransition(){return!1}loaded(){if(this._modelsInfo.size===0)return!0;for(const c of this._modelsInfo.values())if(c.model==null)return!1;return!0}getModels(){return this.models}loadTile(c,h){}serialize(){return this._options}setProperty(c,h){return!1}reload(){this.cancelModelRequests();const c=Q0(this.id,this.scope);this.map.style.clearSource(c),this.models=[],this._modelsInfo.clear(),this.load()}onRemove(c){this.cancelModelRequests()}setModels(c){this.models=[];const h=new Map;for(const g in c){const j=c[g],T=this._modelsInfo.get(g);T&&T.modelSpec.uri===j.uri&&h.set(g,T)}if(this._modelsInfo.size!==h.size){this.cancelModelRequests();for(const[g,j]of h)j.model||h.delete(g)}this._modelsInfo=h,this._options.models=c,this.load()}}function nxe(x,c,h,g){const j=1<F>=it.vertexArrayOffset&&Fnt.polygon).flat());const Ce=le?R:null,[Ee,Ge]=f5e(T,g,se,Q,H,P,Ce,re,ue,T.center.lat,x.tileID.canonical),Be=x.queryGeometry;return p5e(Ee,Ge,Be.isPointQuery()?Be.screenBounds:Be.screenGeometry)}},building:class extends Yd{constructor(x,c,h,g){super(x,{layout:q5e||(q5e=new Qi({visibility:new Xs(Wt.layout_building.visibility),"building-facade":new Gs(Wt.layout_building["building-facade"]),"building-facade-floors":new Gs(Wt.layout_building["building-facade-floors"]),"building-facade-unit-width":new Gs(Wt.layout_building["building-facade-unit-width"]),"building-facade-window":new Gs(Wt.layout_building["building-facade-window"]),"building-roof-shape":new Gs(Wt.layout_building["building-roof-shape"]),"building-height":new Gs(Wt.layout_building["building-height"]),"building-base":new Gs(Wt.layout_building["building-base"]),"building-flood-light-wall-radius":new Gs(Wt.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new Gs(Wt.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new Gs(Wt.layout_building["building-flip-roof-orientation"])})),paint:U5e||(U5e=new Qi({"building-opacity":new Xs(Wt.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new Xs(Wt.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new Xs(Wt.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new Xs(Wt.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new Xs(Wt.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new Xs(Wt.paint_building["building-vertical-scale"]),"building-cast-shadows":new Xs(Wt.paint_building["building-cast-shadows"]),"building-color":new Gs(Wt.paint_building["building-color"]),"building-emissive-strength":new Gs(Wt.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new Xs(Wt.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new Xs(Wt.paint_building["building-cutoff-fade-range"]),"building-front-cutoff":new Xs(Wt.paint_building["building-front-cutoff"]),"building-flood-light-color":new Xs(Wt.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new Xs(Wt.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new Xs(Wt.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new Gs({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new Gs({type:"string",default:"default","property-type":"data-driven"})}))},c,h,g),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(x){return new $5e(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,c,h,g,j,T,P,R,F,H){let Q=this.layout.get("building-height").evaluate(c,h);const se=this.layout.get("building-base").evaluate(c,h),re=x.tile.getBucket(this).getFootprint(c);if(re){if(re.hiddenFlags!==0)return!1;Q=re.height}const[le,ue]=f5e(T,g,se,Q,new as(0,0),P,null,[0,0],1,T.center.lat,x.tileID.canonical),_e=x.queryGeometry;return p5e(le,ue,_e.isPointQuery()?_e.screenBounds:_e.screenGeometry)}},line:class extends Yd{constructor(x,c,h,g){const j=J5e();super(x,j,c,h,g),j.layout&&(this.layout=new Kx(j.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1}_handleSpecialPaintPropertyUpdate(x){if(x==="line-gradient"){const c=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=c._styleExpression&&c._styleExpression.expression instanceof Kw,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,c){super.recalculate(x,c),this.paint._values["line-floorwidth"]=(()=>{if(g6)return g6;const h=J5e();return g6=new zut(h.paint.properties["line-width"].specification),g6.useIntegerZoom=!0,g6})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,x)}createBucket(x){return new x7(x)}getProgramIds(){const x=[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"];return this.paint.get("line-blend-mode")!=="default"&&x.push("lineBlendComposite"),x}getDefaultProgramParams(x,c,h){if(x==="lineBlendComposite")return{};const g=X5e(this);return{config:new be(this,{zoom:c,lut:h}),defines:g,overrideFog:!1}}queryRadius(x){const c=x,h=eMe(r_("line-width",this,c),r_("line-gap-width",this,c)),g=r_("line-offset",this,c);return h/2+Math.abs(g)+BF(this.paint.get("line-translate"))}queryIntersectsFeature(x,c,h,g,j,T){if(x.queryGeometry.isAboveHorizon)return!1;const P=QCe(x.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),T.angle,x.pixelToTileUnitsFactor),R=x.pixelToTileUnitsFactor/2*eMe(this.paint.get("line-width").evaluate(c,h),this.paint.get("line-gap-width").evaluate(c,h)),F=this.paint.get("line-offset").evaluate(c,h);return F&&(g=function(H,Q){const se=[],re=new as(0,0);for(let le=0;le=3){for(let ue=0;ue{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 fTe{constructor(c){this._stringToNumber={},this._numberToString=[];for(let h=0;h=0&&re[3]>=0&&H.insert(F,re[0],re[1],re[2],re[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new $a(new g7(this.rawTileData)).layers,this.sourceLayerCoder=new fTe(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const c in this.vtLayers)this.vtFeatures[c]=[]}return this.vtLayers}query(c,h){const{tilespaceGeometry:g,transform:j,tileTransform:T,pixelPosMatrix:P,availableImages:R,worldview:F}=h;this.loadVTLayers(),this.serializedLayersCache.clear();const H=h.queryRadius?h.queryRadius:0,Q=g.bufferedTilespaceBounds,se=this.grid.query(Q.min.x,Q.min.y,Q.max.x,Q.max.y,(_e,Ce,Ee,Ge)=>hy(g.bufferedTilespaceGeometry,_e-H,Ce-H,Ee+H,Ge+H));se.sort(Zht);let re=null;j.elevation&&se.length>0&&(re=Z3.create(j.elevation,this.tileID));const le={};let ue;for(let _e=0;_e(Ge||(Ge=Vr(Be,this.tileID.canonical,T)),nt.queryIntersectsFeature(g,Be,it,Ge,this.z,j,P,re,lt,h.scope)))}return le}loadMatchingFeature(c,h,g,j,T,P){const{featureIndex:R,bucketIndex:F,sourceLayerIndex:H,layoutVertexArrayOffset:Q}=h,se=this.bucketLayerIDs[F],re=g.layers,le=Object.keys(re);if(le.length&&!Rr(le,se))return;const ue=g.sourceCache,_e=this.sourceLayerCoder.decode(H),Ce=this.vtLayers[_e].feature(R),Ee=this.getId(Ce,_e);for(let Ge=0;Ge`${R.key}: ${R.message}`).join(", ");return void zr(`Failed to create expression for promoteId: ${P}`)}this.promoteIdExpression=T.value}g=this.promoteIdExpression.evaluate({zoom:0},c)}else g=c.properties[j];typeof g=="boolean"&&(g=Number(g))}return g}}function gTe(x,c,h,g,j){return Is(x,(T,P)=>{const R=c instanceof Kx?c.get(P):null;return R&&R.evaluate?R.evaluate(h,g,void 0,j):R})}function Zht(x,c){return c-x}function yTe(x,c){const h={};if(!c)return h;for(const g of x){const j=g.layerIds.map(T=>c.getLayer(T)).filter(Boolean);if(j.length!==0){g.layers=j,g.stateDependentLayerIds&&(g.stateDependentLayers=g.stateDependentLayerIds.map(T=>j.filter(P=>P.id===T)[0]));for(const T of j)h[T.fqid]=g}}return h}yr(xTe,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Ff=32,vy=33,d_=new Uint16Array(8184);for(let x=0;x<2046;x++){let c=x+2,h=0,g=0,j=0,T=0,P=0,R=0;for(1&c?j=T=P=Ff:h=g=R=Ff;(c>>=1)>1;){const H=h+j>>1,Q=g+T>>1;1&c?(j=h,T=g,h=P,g=R):(h=j,g=T,j=P,T=R),P=H,R=Q}const F=4*x;d_[F+0]=h,d_[F+1]=g,d_[F+2]=j,d_[F+3]=T}const _y=new Uint16Array(2178),u_=new Uint8Array(1089),O7=new Uint16Array(1089);function vTe(x){return x===0?-.03125:x===32?.03125:0}const _Te={Other:0,Symbol:1,FillExtrusion:2},bTe={type:2,extent:sr,loadGeometry:()=>[[new as(0,0),new as(8193,0),new as(8193,8193),new as(0,8193),new as(0,0)]]};class Yht{constructor(){this.tasks={},this.taskQueue=[],Xt(["process"],this),this.invoker=new Kht(this.process),this.nextId=0}add(c,h){const g=this.nextId++,j=function({type:T,renderSourceType:P,zoom:R}){R=R||0;const F=P===_Te.Symbol;return T==="message"?0:T!=="maybePrepare"||F?T!=="parseTile"||F?T==="parseTile"&&F?300-R:T==="maybePrepare"&&F?400-R:500:200-R:100-R}(h);if(j===0){try{c()}finally{}return null}return this.tasks[g]={fn:c,metadata:h,priority:j,id:g},this.taskQueue.push(g),this.invoker.trigger(),{cancel:()=>{delete this.tasks[g]}}}process(){try{if(this.taskQueue=this.taskQueue.filter(g=>!!this.tasks[g]),!this.taskQueue.length)return;const c=this.pick();if(c===null)return;const h=this.tasks[c];if(delete this.tasks[c],this.taskQueue.length&&this.invoker.trigger(),!h)return;h.fn()}finally{}}pick(){let c=null,h=1/0;for(let j=0;j>16&255)/255,(x>>8&255)/255,(255&x)/255,1)}function lmt(x,c,h){x===1?(c.rgb_color=B7(h.readVarint()),c.paint="rgb_color"):x===2?(c.linear_gradient_idx=h.readVarint(),c.paint="linear_gradient_idx"):x===3?(c.radial_gradient_idx=h.readVarint(),c.paint="radial_gradient_idx"):x===5?h.readPackedFloat(c.dasharray):x===6?c.dashoffset=h.readFloat():x===7?c.miterlimit=h.readFloat():x===8?c.opacity=h.readVarint():x===9?c.width=h.readFloat():x===10?c.linecap=h.readVarint():x===11&&(c.linejoin=h.readVarint())}function cmt(x,c,h){x===1?c.transform=z7(h,h.readVarint()+h.pos):x===2?c.spread_method=h.readVarint():x===3?c.stops.push(NTe(h,h.readVarint()+h.pos)):x===4?c.x1=h.readFloat():x===5?c.y1=h.readFloat():x===6?c.x2=h.readFloat():x===7&&(c.y2=h.readFloat())}function NTe(x,c){return x.readFields(dmt,{offset:0,opacity:255,rgb_color:axe},c)}function dmt(x,c,h){x===1?c.offset=h.readFloat():x===2?c.opacity=h.readVarint():x===3&&(c.rgb_color=B7(h.readVarint()))}function umt(x,c,h){x===1?c.transform=z7(h,h.readVarint()+h.pos):x===2?c.spread_method=h.readVarint():x===3?c.stops.push(NTe(h,h.readVarint()+h.pos)):x===4?c.cx=h.readFloat():x===5?c.cy=h.readFloat():x===6?c.r=h.readFloat():x===7?c.fx=h.readFloat():x===8?c.fy=h.readFloat():x===9&&(c.fr=h.readFloat())}function hmt(x,c,h){x===1?c.transform=z7(h,h.readVarint()+h.pos):x===2?c.clip_path_idx=h.readVarint():x===3&&c.children.push(F7(h,h.readVarint()+h.pos))}function mmt(x,c,h){x===1?c.left=c.top=h.readFloat():x===2?c.width=c.height=h.readFloat():x===3?c.top=h.readFloat():x===4?c.height=h.readFloat():x===5?c.mask_type=h.readVarint():x===6?c.mask_idx=h.readVarint():x===7&&c.children.push(F7(h,h.readVarint()+h.pos))}class pmt{static calculate(c={},h=[]){const g=new Map,j=new Map;if(Object.keys(c).length===0)return g;h.forEach(T=>{j.set(T.name,T.rgb_color||new Aa(0,0,0))});for(const[T,P]of Object.entries(c))j.has(T)?g.set(j.get(T).toString(),P):console.warn(`Ignoring unknown image variable "${T}"`);return g}}function Y3(x,c=255,h){const g=c/255,j=x.toString(),T=h.has(j)?h.get(j).clone():x.clone();return T.a*=g,T.toString()}function P6(x,c){if(!Sd()){const h=document.createElement("canvas");return h.width=x,h.height=c,h}return new OffscreenCanvas(x,c)}let ixe,I6=null;function oxe(x,c,h,g,j){for(const T of g.children)kTe(x,c,h,T,j)}function kTe(x,c,h,g,j){g.group?(x.save(),function(T,P,R,F,H){const Q=F.mask_idx!=null?R.masks[F.mask_idx]:null,se=F.clip_path_idx!=null?R.clip_paths[F.clip_path_idx]:null;if(F.transform&&(P=X3(F.transform).preMultiplySelf(P)),!function(ue,_e,Ce){return ue.opacity!==255||_e||Ce}(F,se!=null,Q!=null))return void oxe(T,P,R,F,H);const re=P6(T.canvas.width,T.canvas.height),le=re.getContext("2d");oxe(le,P,R,F,H),se&&PTe(le,P,R,se),Q&&ITe(le,P,R,Q,H),T.globalAlpha=F.opacity/255,T.drawImage(re,0,0)}(x,c,h,g.group,j),x.restore()):g.path&&(x.save(),function(T,P,R,F,H){T.setTransform(P),F.paint_order===1?(STe(T,R,F,H),MTe(T,R,F,H)):(MTe(T,R,F,H),STe(T,R,F,H))}(x,c,h,g.path,j),x.restore())}function STe(x,c,h,g){const j=h.fill;if(!j)return;const T=j.opacity/255;switch(x.save(),x.beginPath(),LTe(h,x),j.paint){case"rgb_color":x.fillStyle=Y3(j.rgb_color,j.opacity,g);break;case"linear_gradient_idx":{const P=c.linear_gradients[j.linear_gradient_idx];P.transform&&x.setTransform(X3(P.transform).preMultiplySelf(x.getTransform())),x.fillStyle=TTe(x,P,T,g);break}case"radial_gradient_idx":{const P=c.radial_gradients[j.radial_gradient_idx];P.transform&&x.setTransform(X3(P.transform).preMultiplySelf(x.getTransform())),x.fillStyle=ATe(x,P,T,g)}}x.fill(CTe(h)),x.restore()}function CTe(x){return x.rule===1?"nonzero":x.rule===2?"evenodd":void 0}function MTe(x,c,h,g){const j=h.stroke;if(!j)return;const T=DTe(h);x.lineWidth=j.width,x.miterLimit=j.miterlimit,x.setLineDash(j.dasharray),x.lineDashOffset=j.dashoffset;const P=j.opacity/255;switch(j.paint){case"rgb_color":x.strokeStyle=Y3(j.rgb_color,j.opacity,g);break;case"linear_gradient_idx":x.strokeStyle=TTe(x,c.linear_gradients[j.linear_gradient_idx],P,g,!0);break;case"radial_gradient_idx":x.strokeStyle=ATe(x,c.radial_gradients[j.radial_gradient_idx],P,g,!0)}switch(j.linejoin){case 2:case 1:x.lineJoin="miter";break;case 3:x.lineJoin="round";break;case 4:x.lineJoin="bevel"}switch(j.linecap){case 1:x.lineCap="butt";break;case 2:x.lineCap="round";break;case 3:x.lineCap="square"}x.stroke(T)}function TTe(x,c,h,g,j=!1){if(c.stops.length===1){const re=c.stops[0];return Y3(re.rgb_color,re.opacity*h,g)}const{x1:T,y1:P,x2:R,y2:F}=c;let H=new DOMPoint(T,P),Q=new DOMPoint(R,F);if(j){const re=X3(c.transform);H=re.transformPoint(H),Q=re.transformPoint(Q)}const se=x.createLinearGradient(H.x,H.y,Q.x,Q.y);for(const re of c.stops)se.addColorStop(re.offset,Y3(re.rgb_color,re.opacity*h,g));return se}function ATe(x,c,h,g,j=!1){if(c.stops.length===1){const Ee=c.stops[0];return Y3(Ee.rgb_color,Ee.opacity*h,g)}const T=X3(c.transform),{fx:P,fy:R,fr:F,cx:H,cy:Q,r:se}=c;let re=new DOMPoint(P,R),le=new DOMPoint(H,Q),ue=F,_e=se;if(j){re=T.transformPoint(re),le=T.transformPoint(le);const Ee=(T.a+T.d)/2;ue=F*Ee,_e=c.r*Ee}const Ce=x.createRadialGradient(re.x,re.y,ue,le.x,le.y,_e);for(const Ee of c.stops)Ce.addColorStop(Ee.offset,Y3(Ee.rgb_color,Ee.opacity*h,g));return Ce}function ETe(x,c,h,g){const j=g.transform?X3(g.transform).preMultiplySelf(c):c,T=P6(x.canvas.width,x.canvas.height),P=T.getContext("2d");for(const F of g.children)if(F.group)ETe(P,j,h,F.group);else if(F.path){const H=F.path,Q=new Path2D;Q.addPath(DTe(H),j),P.fill(Q,CTe(H))}const R=g.clip_path_idx!=null?h.clip_paths[g.clip_path_idx]:null;R&&PTe(P,j,h,R),x.globalCompositeOperation="source-over",x.drawImage(T,0,0)}function PTe(x,c,h,g){const j=P6(x.canvas.width,x.canvas.height);ETe(j.getContext("2d"),c,h,g),x.globalCompositeOperation="destination-in",x.drawImage(j,0,0)}function ITe(x,c,h,g,j){if(g.children.length===0)return;const T=g.mask_idx!=null?h.masks[g.mask_idx]:null;T&&ITe(x,c,h,T,j);const P=x.canvas.width,R=x.canvas.height,F=P6(P,R),H=F.getContext("2d"),Q=g.width,se=g.height,re=g.left,le=g.top,ue=new Path2D,_e=new Path2D;_e.rect(re,le,Q,se),ue.addPath(_e,c),H.clip(ue);for(const Ge of g.children)kTe(H,c,h,Ge,j);const Ce=H.getImageData(0,0,P,R),Ee=Ce.data;if(g.mask_type===1)for(let Ge=0;Gec[P])return null}else{const R=1/g[P];let F=(x[P]-h[P])*R,H=(c[P]-h[P])*R;if(F>H){const Q=F;F=H,H=Q}if(F>j&&(j=F),HT)return null}return j}function FTe(x,c,h,g,j,T,P,R,F,H,Q){const se=g-x,re=j-c,le=T-h,ue=P-x,_e=R-c,Ce=F-h,Ee=Q[1]*Ce-Q[2]*_e,Ge=Q[2]*ue-Q[0]*Ce,Be=Q[0]*_e-Q[1]*ue,nt=se*Ee+re*Ge+le*Be;if(Math.abs(nt)<1e-15)return null;const it=1/nt,lt=H[0]-x,Rt=H[1]-c,jt=H[2]-h,It=(lt*Ee+Rt*Ge+jt*Be)*it;if(It<0||It>1)return null;const Mt=Rt*le-jt*re,Tt=jt*se-lt*le,rs=lt*re-Rt*se,ls=(Q[0]*Mt+Q[1]*Tt+Q[2]*rs)*it;return ls<0||It+ls>1?null:(ue*Mt+_e*Tt+Ce*rs)*it}function zTe(x,c,h){return(x-c)/(h-c)}function BTe(x,c,h,g,j,T,P,R,F){const H=1<{const Ge=Ce?1:0,Be=(le+1)*_e-Ge,nt=ue*_e,it=(ue+1)*_e-Ge;Ee[0]=le*_e,Ee[1]=nt,Ee[2]=Be,Ee[3]=it};let se=new RTe(F);const re=[];for(let le=0;le=1;F/=2){const le=R[R.length-1];se=new RTe(F);for(let ue=0;ue0;){const{idx:ue,t:_e,nodex:Ce,nodey:Ee,depth:Ge}=le.pop();if(this.leaves[ue]){BTe(Ce,Ee,Ge,c,h,g,j,se,re);const nt=1<=gs[2])return _e}continue}let Be=0;for(let nt=0;nt=H[Q[jt]]&&(Q.splice(jt,0,nt),Rt=!0);Rt||(Q[Be]=nt),Be++}}for(let nt=0;nt=this.dim+1||h<-1||h>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(h+1)*this.stride+(c+1)}static pack(c,h){const g=[0,0,0,0],j=q7.getUnpackVector(h);let T=Math.floor((c+j[3])/j[2]);return g[2]=T%256,T=Math.floor(T/256),g[1]=T%256,T=Math.floor(T/256),g[0]=T,g}getPixels(){return new j3e({width:this.stride,height:this.stride},this.pixels)}backfillBorder(c,h,g){if(this.dim!==c.dim)throw new Error("dem dimension mismatch");let j=h*this.dim,T=h*this.dim+this.dim,P=g*this.dim,R=g*this.dim+this.dim;switch(h){case-1:j=T-1;break;case 1:T=j+1}switch(g){case-1:P=R-1;break;case 1:R=P+1}const F=-h*this.dim,H=-g*this.dim;for(let Q=P;Q=1;g--){const j=g===1?1:0,T=g===2?1:0;for(let P=0;P>>1^-(1&x[c]);return x}function Mmt(x,c){switch(c){case"uint32":return x;case"uint16":for(let h=0;h>4|(61440&g)>>8|(240&j)<<4|61440&j,x[h+1]=15&g|(3840&g)>>4|(15&j)<<8|(3840&j)<<4}return x;case"uint8":for(let h=0;h>6|(192&j)>>4|(192&T)>>2|192&P,x[h+1]=(48&g)>>4|(48&j)>>2|48&T|(48&P)<<2,x[h+2]=(12&g)>>2|12&j|(12&T)<<2|(12&P)<<4,x[h+3]=3&g|(3&j)<<2|(3&T)<<4|(3&P)<<6}return x;default:throw new Error(`Invalid pixel format, "${c}"`)}}yr(q7,"DEMData"),yr($Te,"DemMinMaxQuadTree",{omit:["dem"]});var Ip=Uint8Array,L6=Uint16Array,Tmt=Int32Array,UTe=new Ip([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]),VTe=new Ip([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]),Amt=new Ip([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),HTe=function(x,c){for(var h=new L6(31),g=0;g<31;++g)h[g]=c+=1<>1|(21845&Ul)<<1;KTe[Ul]=((65280&(Q3=(61680&(Q3=(52428&Q3)>>2|(13107&Q3)<<2))>>4|(3855&Q3)<<4))>>8|(255&Q3)<<8)>>1}var D6=function(x,c,h){for(var g=x.length,j=0,T=new L6(c);j>F]=H;return P},R6=new Ip(288);for(Ul=0;Ul<144;++Ul)R6[Ul]=8;for(Ul=144;Ul<256;++Ul)R6[Ul]=9;for(Ul=256;Ul<280;++Ul)R6[Ul]=7;for(Ul=280;Ul<288;++Ul)R6[Ul]=8;var ZTe=new Ip(32);for(Ul=0;Ul<32;++Ul)ZTe[Ul]=5;var Imt=D6(R6,9),Lmt=D6(ZTe,5),cxe=function(x){for(var c=x[0],h=1;hc&&(c=x[h]);return c},tg=function(x,c,h){var g=c/8|0;return(x[g]|x[g+1]<<8)>>(7&c)&h},dxe=function(x,c){var h=c/8|0;return(x[h]|x[h+1]<<8|x[h+2]<<16)>>(7&c)},Dmt=function(x){return(x+7)/8|0},Rmt=["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"],sg=function(x,c,h){var g=new Error(c||Rmt[x]);if(g.code=x,Error.captureStackTrace&&Error.captureStackTrace(g,sg),!h)throw g;return g},Omt=new Ip(0),Fmt=typeof TextDecoder<"u"&&new TextDecoder;try{Fmt.decode(Omt,{stream:!0})}catch{}const zmt={gzip_data:"gzip"};class zf extends Error{constructor(c){super(c),this.name="MRTError"}}const Bmt={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},YTe={uint32:1,uint16:2,uint8:4},$mt={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let uxe;class U7{constructor(c=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=c}getLayer(c){const h=this.layers[c];if(!h)throw new zf(`Layer '${c}' not found`);return h}getHeaderLength(c){const h=new Uint8Array(c),g=new DataView(c);if(h[0]!==13)throw new zf("File is not a valid MRT.");return g.getUint32(1,!0)}parseHeader(c){const h=new Uint8Array(c),g=this.getHeaderLength(c);if(h.length= ${g} but got buffer of length ${h.length}`);const j=new uxe(h.subarray(0,g)).readFields(ymt,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==j.x||this.y!==j.y||this.z!==j.z))throw new zf(`Invalid attempt to parse header ${j.z}/${j.x}/${j.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=j.x,this.y=j.y,this.z=j.z;for(const T of j.layers)this.layers[T.name]=new XTe(T,{cacheSize:this._cacheSize});return this}createDecodingTask(c){const h=[],g=this.getLayer(c.layerName);for(let j of c.blockIndices){const T=g.dataIndex[j],P=T.firstByte-c.firstByte,R=T.lastByte-c.firstByte;if(g._blocksInProgress.has(j))continue;const F={layerName:g.name,firstByte:P,lastByte:R,pixelFormat:g.pixelFormat,blockIndex:j,blockShape:[T.bands.length].concat(g.bandShape),buffer:g.buffer,codec:T.codec.codec,filters:T.filters.map(H=>H.filter)};g._blocksInProgress.add(j),h.push(F)}return new QTe(h,()=>{h.forEach(j=>g._blocksInProgress.delete(j.blockIndex))},(j,T)=>{if(h.forEach(P=>g._blocksInProgress.delete(P.blockIndex)),j)throw j;T.forEach(P=>{this.getLayer(P.layerName).processDecodedData(P)})})}}class XTe{constructor({version:c,name:h,units:g,tileSize:j,pixelFormat:T,buffer:P,dataIndex:R},F){if(this.version=c,this.version!==1)throw new zf(`Cannot parse raster layer encoded with MRT version ${c}`);this.name=h,this.units=g,this.tileSize=j,this.buffer=P,this.pixelFormat=Bmt[T],this.dataIndex=R,this.bandShape=[j+2*P,j+2*P,YTe[this.pixelFormat]],this._decodedBlocks=new $7(F?F.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return YTe[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map(({bands:c})=>c).flat()}processDecodedData(c){const h=c.blockIndex.toString();this._decodedBlocks.get(h)||this._decodedBlocks.put(h,c.data)}getBlockForBand(c){let h=0;switch(typeof c){case"string":for(const[g,j]of this.dataIndex.entries()){for(const[T,P]of j.bands.entries())if(P===c)return{bandIndex:h+T,blockIndex:g,blockBandIndex:T};h+=j.bands.length}break;case"number":for(const[g,j]of this.dataIndex.entries()){if(c>=h&&cthis.cacheSize)throw new zf(`Number of blocks to decode (${T.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:h,lastByte:g,blockIndices:j}}hasBand(c){const{blockIndex:h}=this.getBlockForBand(c);return h>=0}hasDataForBand(c){const{blockIndex:h}=this.getBlockForBand(c);return h>=0&&!!this._decodedBlocks.get(h.toString())}getBandView(c){const{blockIndex:h,blockBandIndex:g}=this.getBlockForBand(c);if(h<0)throw new zf(`Band not found: ${JSON.stringify(c)}`);const j=this._decodedBlocks.get(h.toString());if(!j)throw new zf(`Data for band ${JSON.stringify(c)} of layer "${this.name}" not decoded.`);const T=this.dataIndex[h],P=this.bandShape.reduce((H,Q)=>H*Q,1),R=g*P,F=j.subarray(R,R+P);return{data:F,bytes:new Uint8Array(F.buffer).subarray(F.byteOffset,F.byteOffset+F.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:T.offset,scale:T.scale}}}U7.setPbf=function(x){uxe=x};class QTe{constructor(c,h,g){this.tasks=c,this._onCancel=h,this._onComplete=g,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(c,h){this._finalized||(this._onComplete(c,h),this._finalized=!0)}}U7.performDecoding=function(x,c){const h=new Uint8Array(x);return Promise.all(c.tasks.map(g=>{const{layerName:j,firstByte:T,lastByte:P,pixelFormat:R,blockShape:F,blockIndex:H,filters:Q,codec:se}=g,re=h.subarray(T,P+1),le=new Uint32Array(F[0]*F[1]*F[2]);let ue;if(se!=="gzip_data")throw new zf(`Unhandled codec: ${se}`);return ue=function(_e,Ce){if(!globalThis.DecompressionStream&&Ce==="gzip_data")return Promise.resolve((it=function(jt){jt[0]==31&&jt[1]==139&&jt[2]==8||sg(6,"invalid gzip data");var It=jt[3],Mt=10;4&It&&(Mt+=2+(jt[10]|jt[11]<<8));for(var Tt=(It>>3&1)+(It>>4&1);Tt>0;Tt-=!jt[Mt++]);return Mt+(2&It)}(Ee=_e),it+8>Ee.length&&sg(6,"invalid gzip data"),function(jt,It,Mt,Tt){var rs=jt.length;if(!rs||It.f&&!It.l)return Mt||new Ip(0);var ls=!Mt,xs=ls||It.i!=2,Ns=It.i;ls&&(Mt=new Ip(3*rs));var gs=function(go){var Xd=Mt.length;if(go>Xd){var Tc=new Ip(Math.max(2*Xd,go));Tc.set(Mt),Mt=Tc}},Rs=It.f||0,ts=It.p||0,ws=It.b||0,Ts=It.l,Os=It.d,Zs=It.m,xr=It.n,er=8*rs;do{if(!Ts){Rs=tg(jt,ts,1);var Js=tg(jt,ts+1,3);if(ts+=3,!Js){var Ys=jt[(Za=Dmt(ts)+4)-4]|jt[Za-3]<<8,ur=Za+Ys;if(ur>rs){Ns&&sg(0);break}xs&&gs(ws+Ys),Mt.set(jt.subarray(Za,ur),ws),It.b=ws+=Ys,It.p=ts=8*ur,It.f=Rs;continue}if(Js==1)Ts=Imt,Os=Lmt,Zs=9,xr=5;else if(Js==2){var Nr=tg(jt,ts,31)+257,Ur=tg(jt,ts+10,15)+4,Er=Nr+tg(jt,ts+5,31)+1;ts+=14;for(var Tn=new Ip(Er),Na=new Ip(19),An=0;An>4)<16)Tn[An++]=Za;else{var Si=0,lo=0;for(Za==16?(lo=3+tg(jt,ts,3),ts+=2,Si=Tn[An-1]):Za==17?(lo=3+tg(jt,ts,7),ts+=3):Za==18&&(lo=11+tg(jt,ts,127),ts+=7);lo--;)Tn[An++]=Si}}var cc=Tn.subarray(0,Nr),co=Tn.subarray(Nr);Zs=cxe(cc),xr=cxe(co),Ts=D6(cc,Zs),Os=D6(co,xr)}else sg(1);if(ts>er){Ns&&sg(0);break}}xs&&gs(ws+131072);for(var Eo=(1<>4;if((ts+=15&Si)>er){Ns&&sg(0);break}if(Si||sg(2),hd<256)Mt[ws++]=hd;else{if(hd==256){Po=ts,Ts=null;break}var dc=hd-254;hd>264&&(dc=tg(jt,ts,(1<<(zo=UTe[An=hd-257]))-1)+WTe[An],ts+=zo);var Kn=Os[dxe(jt,ts)&rl],Su=Kn>>4;if(Kn||sg(3),ts+=15&Kn,co=Pmt[Su],Su>3){var zo=VTe[Su];co+=dxe(jt,ts)&(1<er){Ns&&sg(0);break}xs&&gs(ws+131072);var Mc=ws+dc;if(wsgo.length)&&(Tc=go.length),new Ip(go.subarray(0,Tc))}(Mt,0,ws):Mt.subarray(0,ws)}(Ee.subarray(it,-8),{i:2},new Ip(((Be=Ee)[(nt=Be.length)-4]|Be[nt-3]<<8|Be[nt-2]<<16|Be[nt-1]<<24)>>>0),Ge)));var Ee,Ge,Be,nt,it;const lt=zmt[Ce];if(!lt)throw new Error(`Unhandled codec: ${Ce}`);const Rt=new globalThis.DecompressionStream(lt);return new Response(new Blob([_e]).stream().pipeThrough(Rt)).arrayBuffer().then(jt=>new Uint8Array(jt))}(re,se).then(_e=>(function(Ce,Ee){Ce.readFields(Nmt,Ee)}(new uxe(_e),le),new $mt[R](le.buffer))),ue.then(_e=>{for(let Ce=Q.length-1;Ce>=0;Ce--)switch(Q[Ce]){case"delta_filter":Smt(_e,F);break;case"zigzag_filter":Cmt(_e);break;case"bitshuffle_filter":Mmt(_e,R);break;default:throw new zf(`Unhandled filter "${Q[Ce]}"`)}return{layerName:j,blockIndex:H,data:_e}}).catch(_e=>{throw _e})}))},yr(QTe,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),yr(U7,"MapboxRasterTile"),yr(XTe,"MapboxRasterLayer",{omit:["_blocksInProgress"]});const JTe=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class hxe{static from(c){if(!(c instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[h,g]=new Uint8Array(c,0,2);if(h!==219)throw new Error("Data does not appear to be in a KDBush format.");const j=g>>4;if(j!==1)throw new Error(`Got v${j} data when expected v1.`);const T=JTe[15&g];if(!T)throw new Error("Unrecognized array type.");const[P]=new Uint16Array(c,2,1),[R]=new Uint32Array(c,4,1);return new hxe(R,P,T,c)}constructor(c,h=64,g=Float64Array,j){if(isNaN(c)||c<0)throw new Error(`Unpexpected numItems value: ${c}.`);this.numItems=+c,this.nodeSize=Math.min(Math.max(+h,2),65535),this.ArrayType=g,this.IndexArrayType=c<65536?Uint16Array:Uint32Array;const T=JTe.indexOf(this.ArrayType),P=2*c*this.ArrayType.BYTES_PER_ELEMENT,R=c*this.IndexArrayType.BYTES_PER_ELEMENT,F=(8-R%8)%8;if(T<0)throw new Error(`Unexpected typed array class: ${g}.`);j&&j instanceof ArrayBuffer?(this.data=j,this.ids=new this.IndexArrayType(this.data,8,c),this.coords=new this.ArrayType(this.data,8+R+F,2*c),this._pos=2*c,this._finished=!0):(this.data=new ArrayBuffer(8+P+R+F),this.ids=new this.IndexArrayType(this.data,8,c),this.coords=new this.ArrayType(this.data,8+R+F,2*c),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+T]),new Uint16Array(this.data,2,1)[0]=h,new Uint32Array(this.data,4,1)[0]=c)}add(c,h){const g=this._pos>>1;return this.ids[g]=g,this.coords[this._pos++]=c,this.coords[this._pos++]=h,g}finish(){const c=this._pos>>1;if(c!==this.numItems)throw new Error(`Added ${c} items when expected ${this.numItems}.`);return mxe(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(c,h,g,j){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:T,coords:P,nodeSize:R}=this,F=[0,T.length-1,0],H=[];for(;F.length;){const Q=F.pop()||0,se=F.pop()||0,re=F.pop()||0;if(se-re<=R){for(let Ce=re;Ce<=se;Ce++){const Ee=P[2*Ce],Ge=P[2*Ce+1];Ee>=c&&Ee<=g&&Ge>=h&&Ge<=j&&H.push(T[Ce])}continue}const le=re+se>>1,ue=P[2*le],_e=P[2*le+1];ue>=c&&ue<=g&&_e>=h&&_e<=j&&H.push(T[le]),(Q===0?c<=ue:h<=_e)&&(F.push(re),F.push(le-1),F.push(1-Q)),(Q===0?g>=ue:j>=_e)&&(F.push(le+1),F.push(se),F.push(1-Q))}return H}within(c,h,g){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:j,coords:T,nodeSize:P}=this,R=[0,j.length-1,0],F=[],H=g*g;for(;R.length;){const Q=R.pop()||0,se=R.pop()||0,re=R.pop()||0;if(se-re<=P){for(let Ce=re;Ce<=se;Ce++)tAe(T[2*Ce],T[2*Ce+1],c,h)<=H&&F.push(j[Ce]);continue}const le=re+se>>1,ue=T[2*le],_e=T[2*le+1];tAe(ue,_e,c,h)<=H&&F.push(j[le]),(Q===0?c-g<=ue:h-g<=_e)&&(R.push(re),R.push(le-1),R.push(1-Q)),(Q===0?c+g>=ue:h+g>=_e)&&(R.push(le+1),R.push(se),R.push(1-Q))}return F}}function mxe(x,c,h,g,j,T){if(j-g<=h)return;const P=g+j>>1;eAe(x,c,P,g,j,T),mxe(x,c,h,g,P-1,1-T),mxe(x,c,h,P+1,j,1-T)}function eAe(x,c,h,g,j,T){for(;j>g;){if(j-g>600){const H=j-g+1,Q=h-g+1,se=Math.log(H),re=.5*Math.exp(2*se/3),le=.5*Math.sqrt(se*re*(H-re)/H)*(Q-H/2<0?-1:1);eAe(x,c,h,Math.max(g,Math.floor(h-Q*re/H+le)),Math.min(j,Math.floor(h+(H-Q)*re/H+le)),T)}const P=c[2*h+T];let R=g,F=j;for(O6(x,c,g,h),c[2*j+T]>P&&O6(x,c,g,j);RP;)F--}c[2*g+T]===P?O6(x,c,g,F):(F++,O6(x,c,F,j)),F<=h&&(g=F+1),h<=F&&(j=F-1)}}function O6(x,c,h,g){pxe(x,h,g),pxe(c,2*h,2*g),pxe(c,2*h+1,2*g+1)}function pxe(x,c,h){const g=x[c];x[c]=x[h],x[h]=g}function tAe(x,c,h,g){const j=x-h,T=c-g;return j*j+T*T}i.$=q1,i.A=class{constructor(x,c,h){this.target=x,this.parent=c,this.mapId=h,this.callbacks={},this.cancelCallbacks={},Xt(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.scheduler=new Yht}send(x,c,h,g,j=!1,T){const P=Math.round(1e18*Math.random()).toString(36).substring(0,10);h&&(h.metadata=T,this.callbacks[P]=h);const R=new Set;return this.target.postMessage({id:P,type:x,hasCallback:!!h,targetMapId:g,mustQueue:j,sourceMapId:this.mapId,data:Hx(c,R)},R),{cancel:()=>{h&&delete this.callbacks[P],this.target.postMessage({id:P,type:"",targetMapId:g,sourceMapId:this.mapId})}}}receive(x){const c=x.data;if(!c)return;const h=c.id;if(h&&(!c.targetMapId||this.mapId===c.targetMapId))if(c.type===""){const g=this.cancelCallbacks[h];delete this.cancelCallbacks[h],g&&g.cancel()}else if(c.mustQueue||ua(self)){const g=this.callbacks[h],j=this.scheduler.add(()=>this.processTask(h,c),g&&g.metadata||{type:"message"});j&&(this.cancelCallbacks[h]=j)}else this.processTask(h,c)}processTask(x,c){if(delete this.cancelCallbacks[x],c.type===""){const h=this.callbacks[x];delete this.callbacks[x],h&&(c.error?h(dy(c.error)):h(null,dy(c.data)))}else{const h=new Set,g=c.hasCallback?(T,P)=>{this.target.postMessage({id:x,type:"",sourceMapId:this.mapId,error:T?Hx(T):null,data:Hx(P,h)},h)}:()=>{},j=dy(c.data);if(this.parent[c.type])this.parent[c.type](c.sourceMapId,j,g);else if(this.parent.getWorkerSource){const T=c.type.split("."),{source:P,scope:R}=j;this.parent.getWorkerSource(c.sourceMapId,{type:T[0],source:P,scope:R,uid:0})[T[1]](j,g)}else g(new Error(`Could not find function ${c.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},i.B=xn,i.C=tn,i.D=Um,i.E=Ei,i.F=Q0,i.G=2,i.H=_6,i.I=kc,i.J=vMe,i.K=BC,i.L=NF,i.M=Fw,i.N=zw,i.O=l3,i.P=as,i.Q=o3,i.R=D0,i.S=oP,i.T=yy,i.U=n2,i.V=D7,i.W=_3,i.X=cy,i.Y=cP,i.Z=Ef,i._=H0,i.a=function(x){return ha.API_CDN_URL_REGEX.test(x)},i.a$=g7,i.a0=oc,i.a1=Bw,i.a2=$C,i.a3=O0,i.a4=MP,i.a5=class extends D7{},i.a6=lP,i.a7=oF,i.a8=Wt,i.a9=function(x){const c=x.value;return c?$C(c)?txe(c,!0)?[]:[new D7(x.key,c,`invalid url "${c}"`)]:[new D7(x.key,c,`string expected, "${Fw(c)}" found`)]:[]},i.aA=W5e,i.aB=function(x){let c=1/0,h=1/0,g=-1/0,j=-1/0;for(const T of x)c=Math.min(c,T.x),h=Math.min(h,T.y),g=Math.max(g,T.x),j=Math.max(j,T.y);return{min:new as(c,h),max:new as(g,j)}},i.aC=Fe,i.aD=C,i.aE=mt,i.aF=pt,i.aG=Zu,i.aH=Cs,i.aI=pr,i.aJ=function(x,c){const h={};for(let g=0;g=0?c.slice(h+1):""}catch{return""}},i.aN=class{constructor(x){this.entries={},this.scheduler=x}request(x,c,h,g){const j=this.entries[x]=this.entries[x]||{callbacks:[]};if(j.result){const[T,P]=j.result;return this.scheduler?this.scheduler.add(()=>{g(T,P)},c):g(T,P),()=>{}}return j.callbacks.push(g),j.cancel||(j.cancel=h((T,P)=>{j.result=[T,P];for(const R of j.callbacks)this.scheduler?this.scheduler.add(()=>{R(T,P)},c):R(T,P);setTimeout(()=>delete this.entries[x],3e3)})),()=>{j.result||(j.callbacks=j.callbacks.filter(T=>T!==g),j.callbacks.length||(j.cancel(),delete this.entries[x]))}}},i.aO=function(x,c,h){const g=JSON.stringify(x.request);return x.data&&(this.deduped.entries[g]={result:[null,x.data]}),this.deduped.request(g,{type:"parseTile",renderSourceType:x.renderSourceType,zoom:x.tileZoom},j=>{const T=ey(x.request,(P,R,F)=>{P?P1(P)?j(null,null):j(P):R&&j(null,{rawData:R,vectorTile:h?void 0:new $a(new g7(R)),responseHeaders:new Map(F.entries())})});return()=>{T.cancel(),j(null,null)}},c)},i.aP=function(x){return x?{cacheControl:x.get("cache-control"),expires:x.get("expires")}:{cacheControl:void 0,expires:void 0}},i.aQ=function(x){Md++,Md>Sp&&(x.getActor().send("enforceCacheSizeLimit",kp),Md=0)},i.aR=ku,i.aS=eTe,i.aT=lTe,i.aU=qt,i.aV=JMe,i.aW=function(x,c){const h=document.createElement("video");h.muted=!0,h.onloadstart=function(){c(null,h)};for(let g=0;g{}}},i.aX=f6,i.aY=L2,i.aZ=Xt,i.a_=U7,i.aa=v3,i.ab=Qi,i.ac=Xs,i.ad=class{constructor(x){this.specification=x}possiblyEvaluate(x,c){return sa(x.expression.evaluate(c))}interpolate(x,c,h){return{x:on(x.x,c.x,h),y:on(x.y,c.y,h),z:on(x.z,c.z,h),azimuthal:on(x.azimuthal,c.azimuthal,h),polar:on(x.polar,c.polar,h)}}},i.ae=Ka,i.af=W0,i.ag=jr,i.ah=ct,i.ai=ce,i.aj=Xe,i.ak=Kx,i.al=av,i.am=on,i.an=sr,i.ao=Mp,i.ap=Zr,i.aq=Aa,i.ar=class{constructor(x){this.specification=x}possiblyEvaluate(x,c){return function([h,g]){const j=sa([1,h,g]);return{x:j.x,y:j.y,z:j.z}}(x.expression.evaluate(c))}interpolate(x,c,h){return{x:on(x.x,c.x,h),y:on(x.y,c.y,h),z:on(x.z,c.z,h)}}},i.as=function(x,c,h=0,g=!0){const j=new as(h,h),T=x.sub(j),P=c.add(j),R=[T,new as(P.x,T.y),P,new as(T.x,P.y)];return g&&R.push(T.clone()),R},i.at=function(x,c){const h=[];for(let g=0;gthis.buckets[se].layers.some(re=>P.has(re.fqid))),F=Object.keys(this.buckets).some(se=>this.buckets[se].layers.some(re=>re.hasTransition&&re.hasTransition())),H=this._firstPrepareComplete&&T!==this._lastAvailableImagesCount;this._hasAppearances===null&&(this._hasAppearances=this.hasAppearances(c));const Q=this._lastUpdatedBrightness!==g;this._lastAvailableImagesCount=T,this._firstPrepareComplete=!0,(this._lastUpdatedBrightness||g||this._hasAppearances||R||F||H)&&(!(this._hasAppearances||R||F||H)&&this._lastUpdatedBrightness&&g&&Math.abs(this._lastUpdatedBrightness-g)<.001||(this.updateBuckets(c,Q,void 0,H||R||F,P,j),this._lastUpdatedBrightness=g))}evaluateQueryRenderedFeaturePadding(){let x=0;for(const c in this.buckets){const h=this.buckets[c];h.evaluateQueryRenderedFeaturePadding&&(x=Math.max(x,h.evaluateQueryRenderedFeaturePadding()))}return x}queryRenderedFeatures(x,c,h,g,j,T,P){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile)return{};const R=this.evaluateQueryRenderedFeaturePadding(),F=function(H,Q){const se=q([],[.5*H.width,.5*-H.height,1]);return A(se,se,[1,-1,0]),C(se,se,H.calculateProjMatrix(Q.toUnwrapped())),Float32Array.from(se)}(j,this.tileID);return this.latestFeatureIndex.query(x,{tilespaceGeometry:c,pixelPosMatrix:F,transform:g,availableImages:h,tileTransform:this.tileTransform,worldview:this.worldview,queryRadius:R,scope:P})}querySourceFeatures(x,c){const h=this.latestFeatureIndex;if(!h||!h.rawTileData)return;const g=h.loadVTLayers(),j=c?c.sourceLayer:"",T=g._geojsonTileLayer||g[j];if(!T)return;const P=b3(c&&c.filter),{z:R,x:F,y:H}=this.tileID.canonical,Q={z:R,x:F,y:H};for(let se=0;seh)g=!1;else if(c)if(this.expirationTimeh.appearances&&h.appearances.length>0))return!0;return!1}updateBuckets(x,c,h,g,j,T){if(!this.latestFeatureIndex||!x.style)return;const P=T||x.style.listImages(),R=x.style.getBrightness(),F=j||new Set;for(const H in this.buckets){if(!x.style.hasLayer(H))continue;const Q=this.buckets[H],se=Q.layers[0],re=se.sourceLayer||"_geojsonTileLayer",le=x.style.getLayerSourceCache(se),ue=Q.layers.some(it=>F.has(it.fqid)),_e=(g||ue)&&Q instanceof eg?x.style.getOwnLayer(H):void 0;let Ce=h&&h[re]||{};le&&!h&&(Ce=le._state.getState(re,void 0));const Ee=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},Ge=Object.keys(Ce).length>0&&!c;Q.hasAppearances=Q.layers.some(it=>it.appearances&&it.appearances.length>0);const Be=Ge?Q.stateDependentLayers:Q.layers;if(Ge&&Q.stateDependentLayers.length!==0||c||ue||g){const it=this.latestFeatureIndex.loadVTLayers()[re];if(Q.update(Ce,it,P,Ee,Be,c,R,this.tileID.canonical),(g||ue)&&!c&&Q instanceof eg&&_e&&_e.type==="symbol"){const lt=Q;lt.text&<.text.uboBinder&<.text.uboBinder.updateDynamicExpressions(_e,it,this.tileID.canonical,P,Ce,R),lt.icon&<.icon.uboBinder&<.icon.uboBinder.updateDynamicExpressions(_e,it,this.tileID.canonical,P,Ce,R)}if(Q instanceof eg){const lt=Q,Rt=x.context;lt.text&<.text.uboBinder&<.text.uboBinder.upload(Rt),lt.icon&<.icon.uboBinder&<.icon.uboBinder.upload(Rt)}}if(Ge&&Q.stateDependentLayers.length!==0||c||Q.hasAppearances){const it={zoom:x.transform.zoom,pitch:x.transform.pitch,brightness:x.style.getBrightness()||0,worldview:x.worldview},lt=Q.updateAppearances(this.tileID.canonical,Ce,P,it,x.imageManager,Ge&&Q.stateDependentLayers.length!==0);if(lt&<.hasUboChanges){const Rt=x.context;Q instanceof eg&&Q.text&&Q.text.uboBinder&&Q.text.uboBinder.upload(Rt),Q instanceof eg&&Q.icon&&Q.icon.uboBinder&&Q.icon.uboBinder.upload(Rt)}}(Q instanceof x7||Q instanceof XF)&&x._terrain&&x._terrain.enabled&&le&&Q.uploadPending()&&x._terrain._clearRenderCacheForTile(le.id,this.tileID);const nt=x&&x.style&&x.style.getOwnLayer(H);nt&&(this.queryPadding=Math.max(this.queryPadding,nt.queryRadius(Q)||0))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil=0;_e--){const Ce=4*_e,Ee=d_[Ce+0],Ge=d_[Ce+1],Be=d_[Ce+2],nt=d_[Ce+3],it=Ee+Be>>1,lt=Ge+nt>>1,Rt=it+lt-Ge,jt=lt+Ee-it,It=Ge*vy+Ee,Mt=nt*vy+Be,Tt=lt*vy+it,rs=Math.hypot((_y[2*It+0]+_y[2*Mt+0])/2-_y[2*Tt+0],(_y[2*It+1]+_y[2*Mt+1])/2-_y[2*Tt+1])>=16;u_[Tt]=u_[Tt]||(rs?1:0),_e<1022&&(u_[Tt]=u_[Tt]||u_[(Ge+jt>>1)*vy+(Ee+Rt>>1)]||u_[(nt+jt>>1)*vy+(Be+Rt>>1)])}const Q=new dd,se=new Ao;let re=0;function le(_e,Ce){const Ee=Ce*vy+_e;return O7[Ee]===0&&(Q.emplaceBack(_y[2*Ee+0],_y[2*Ee+1],_e*sr/Ff,Ce*sr/Ff),O7[Ee]=++re),O7[Ee]-1}function ue(_e,Ce,Ee,Ge,Be,nt){const it=_e+Ee>>1,lt=Ce+Ge>>1;if(Math.abs(_e-Be)+Math.abs(Ce-nt)>1&&u_[lt*vy+it])ue(Be,nt,_e,Ce,it,lt),ue(Ee,Ge,Be,nt,it,lt);else{const Rt=le(_e,Ce),jt=le(Ee,Ge),It=le(Be,nt);se.emplaceBack(Rt,jt,It)}}return ue(0,0,Ff,Ff,Ff,0),ue(Ff,Ff,0,0,0,Ff),{vertices:Q,indices:se}}(this.tileID.canonical,c);g=T.vertices,j=T.indices}else{g=new dd,j=new Ao;for(const{x:P,y:R}of h)g.emplaceBack(P,R,0,0);const T=R3(g.int16.subarray(0,4*g.length),void 0,4);for(let P=0;P0&&(P=S(new Float64Array(16),c.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(x,g,c,j,P,T),this._makeGlobeTileDebugTextBuffer(x,g,c,j,P,T)}_globePoint(x,c,h,g,j,T,P){let R=QP(x,c,h);if(T){const F=1<.5?re=-1:se<-.5&&(re=1);let le=(x/sr+h.x)/F+re,ue=(c/sr+h.y)/F;le=(le-H)*g._pixelsPerMercatorPixel+H,ue=(ue-Q)*g._pixelsPerMercatorPixel+Q;const _e=[le*g.worldSize,ue*g.worldSize,0];ct(_e,_e,T),R=nv(R,_e,P)}return ct(R,R,j)}_makeGlobeTileDebugBorderBuffer(x,c,h,g,j,T){const P=new _h,R=new tv,F=new Df,H=(se,re,le,ue,_e)=>{const Ce=(le-se)/(_e-1),Ee=(ue-re)/(_e-1),Ge=P.length;for(let Be=0;Be<_e;Be++){const nt=se+Be*Ce,it=re+Be*Ee;P.emplaceBack(nt,it);const lt=this._globePoint(nt,it,c,h,g,j,T);F.emplaceBack(lt[0],lt[1],lt[2]),R.emplaceBack(Ge+Be)}},Q=sr;H(0,0,Q,0,16),H(Q,0,Q,Q,16),H(Q,Q,0,Q,16),H(0,Q,0,0,16),this._tileDebugIndexBuffer=x.createIndexBuffer(R),this._tileDebugBuffer=x.createVertexBuffer(P,XP.members),this._globeTileDebugBorderBuffer=x.createVertexBuffer(F,r3e.members),this._tileDebugSegments=ji.simpleSegment(0,0,P.length,R.length)}_makeGlobeTileDebugTextBuffer(x,c,h,g,j,T){const P=new _h,R=new Ao,F=new Df,H=25;R.reserve(32),P.reserve(H),F.reserve(H);const Q=(se,re)=>H*se+re;for(let se=0;se1)return!1;const h=c.getSource().maxzoom,g=1<1)return c;const j=g.getSource().maxzoom,T=1<{const R=this.getAtTileOffset(x,j,T,P),F=g.upVector(x.canonical,j.x,j.y);return je(F,F,R*g.upVectorScale(x.canonical,c,h).metersToTile),F}}getForTilePoints(x,c,h,g){if(this.isUsingMockSource())return!1;const j=Z3.create(this,x,g);return!!j&&(c.forEach(T=>{T[2]=this.exaggeration()*j.getElevationAt(T[0],T[1],h)}),!0)}getMinMaxForTile(x){if(this.isUsingMockSource())return null;const c=this.findDEMTileFor(x);if(!c||!c.dem)return null;const h=c.dem.tree,g=c.tileID,j=1<0&&(g+=(x[j]-0)*(x[j]-0)),c[j]<0&&(g+=(0-c[j])*(0-c[j]));return g},i.cL=function(x){return x*x*x*x*x},i.cM=Jt,i.cN=45,i.cO=I3,i.cP=function(x,c,h){const g=Math.sqrt(x*x+c*c+h*h),j=g>0?Math.acos(h/g)*qr:0;let T=x!==0||c!==0?Math.atan2(-c,-x)*qr+90:0;return T<0&&(T+=360),[g,T,j]},i.cQ=ie,i.cR=sa,i.cS=As,i.cT=oe,i.cU=ei,i.cV=me,i.cW=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.cX=A5e,i.cY=jfe,i.cZ=D5e,i.c_=txe,i.ca=2,i.cb=7,i.cc=6,i.cd=ye,i.ce=J,i.cf=X,i.cg=0,i.ch=1,i.ci=4,i.cj=5,i.ck=D3,i.cl=bh,i.cm=P5e,i.cn=N2,i.co=o3e,i.cp=function(x,c,h,g,j,T,P,R,F){if(F.name==="globe")return o3e(x,c,new N2(h,g,j),!1);const H=E2({z:h,x:g,y:j},F);return new ei([(T+H.x/H.scale)*c,c*(H.y/H.scale),P],[(T+H.x2/H.scale)*c,c*(H.y2/H.scale),R])},i.cq=function(x,c,h){return x[0]=Math.min(c[0],h[0]),x[1]=Math.min(c[1],h[1]),x[2]=Math.min(c[2],h[2]),x[3]=Math.min(c[3],h[3]),x},i.cr=function(x,c,h){return x[0]=Math.max(c[0],h[0]),x[1]=Math.max(c[1],h[1]),x[2]=Math.max(c[2],h[2]),x[3]=Math.max(c[3],h[3]),x},i.cs=function(x){const c=Math.round((x+45+360)%360/90)%4;return Yt[c]},i.ct=hs,i.cu=He,i.cv=6,i.cw=function(x){const c=w(new Float64Array(16));C(c,x.pixelMatrix,x.globeMatrix);const h=[0,wt,0],g=[0,Ft,0];return ct(h,h,c),ct(g,g,c),[h[0]>0&&h[0]<=x.width&&h[1]>0&&h[1]<=x.height&&!Vpe(x,new qt(x.center.lat,90)),g[0]>0&&g[0]<=x.width&&g[1]>0&&g[1]<=x.height&&!Vpe(x,new qt(x.center.lat,-90))]},i.cx=function(x,c){const{scale:h}=x.tileTransform,g=h*sr/(x.tileSize*Math.pow(2,c.zoom-x.tileID.overscaledZ+x.tileID.canonical.z));return function(j,T,P){var R=T[1],F=T[2],H=T[3],Q=P[0],se=P[1];return j[0]=T[0]*Q,j[1]=R*Q,j[2]=F*se,j[3]=H*se,j}(new Float32Array(4),c.inverseAdjustmentMatrix,[g,g])},i.cy=d7,i.cz=Y,i.d=function(x){return ha.API_TILEJSON_REGEX.test(x)},i.d$=Yct,i.d0=fo,i.d1=class{static calculate(x,c,h){const g=new Set,j=new Map,T=new Set,P=new Set;for(const F of Object.values(x))for(const[H,Q]of Object.entries(F.floors)){T.add(H),Q.isDefault&&P.add(H),Q.conflicts&&j.set(H,Q.conflicts);const se=H===c,re=Q.connections&&c&&Q.connections.has(c);(se||re)&&g.add(H)}const R=F=>{const H=j.get(F)||new Set;for(const Q of g)if((j.get(Q)||new Set).has(F)||H.has(Q))return!0;return!1};if(h)for(const F of h)T.has(F)&&(R(F)||g.add(F));for(const F of P)g.has(F)||R(F)||g.add(F);return g}},i.d2=b7,i.d3=qfe,i.d4=Sa,i.d5=function(){return{API_URL:ha.API_URL,DRACO_URL:ha.DRACO_URL,MESHOPT_URL:ha.MESHOPT_URL,MESHOPT_SIMD_URL:ha.MESHOPT_SIMD_URL,BUILDING_GEN_URL:ha.BUILDING_GEN_URL}},i.d6=bF,i.d7=Aw,i.d8=ar,i.d9=or,i.dA=qF,i.dB=_h,i.dC=Ao,i.dD=function(x,c){return[Math.pow(x[0],2.2)*c,Math.pow(x[1],2.2)*c,Math.pow(x[2],2.2)*c]},i.dE=f,i.dF=function(x,c){var h=Math.sin(c),g=Math.cos(c);return x[0]=g,x[1]=h,x[2]=0,x[3]=-h,x[4]=g,x[5]=0,x[6]=0,x[7]=0,x[8]=1,x},i.dG=fe,i.dH=c3e,i.dI=ui,i.dJ=qi,i.dK=Jfe,i.dL=function(x,c){const h=[0,0,0];return ct(h,h,JP(fy(c.canonical))),ct(h,h,x),h},i.dM=x=>({u_matrix:new m(x),u_texsize:new Km(x),u_pixels_to_tile_units:new D(x),u_device_pixel_ratio:new Cl(x),u_width_scale:new Cl(x),u_floor_width_scale:new Cl(x),u_image:new w2(x),u_units_to_pixels:new Km(x),u_tile_units_to_pixels:new Cl(x),u_alpha_discard_threshold:new Cl(x),u_trim_offset:new Km(x),u_trim_fade_range:new Km(x),u_trim_gradient_mix_range:new Km(x),u_trim_color:new I3(x),u_zbias_factor:new Cl(x),u_tile_to_meter:new Cl(x),u_ground_shadow_factor:new j2(x),u_pattern_transition:new Cl(x)}),i.dN=x=>({u_matrix:new m(x),u_pixels_to_tile_units:new D(x),u_device_pixel_ratio:new Cl(x),u_width_scale:new Cl(x),u_floor_width_scale:new Cl(x),u_units_to_pixels:new Km(x),u_dash_image:new w2(x),u_gradient_image:new w2(x),u_image_height:new Cl(x),u_texsize:new Km(x),u_tile_units_to_pixels:new Cl(x),u_alpha_discard_threshold:new Cl(x),u_trim_offset:new Km(x),u_trim_fade_range:new Km(x),u_trim_gradient_mix_range:new Km(x),u_trim_color:new I3(x),u_zbias_factor:new Cl(x),u_tile_to_meter:new Cl(x),u_ground_shadow_factor:new j2(x)}),i.dO=x=>({u_camera_to_center_distance:new Cl(x),u_extrude_scale:new D(x),u_device_pixel_ratio:new Cl(x),u_matrix:new m(x),u_inv_rot_matrix:new m(x),u_merc_center:new Km(x),u_tile_id:new j2(x),u_zoom_transition:new Cl(x),u_up_dir:new j2(x),u_emissive_strength:new Cl(x)}),i.dP=BP,i.dQ=Zut,i.dR=class{constructor(x,c,h,g){this.context=x,this.format=g,this.size=h,this.texture=x.gl.createTexture();const[j,T,P]=this.size,{gl:R}=x;R.bindTexture(R.TEXTURE_3D,this.texture),x.pixelStoreUnpackFlipY.set(!1),x.pixelStoreUnpack.set(1),x.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in c&&c.data&&R.texImage3D(R.TEXTURE_3D,0,this.format,j,T,P,0,xfe(this.format),gfe(this.format),c.data)}bind(x,c){const{context:h}=this,{gl:g}=h;g.bindTexture(g.TEXTURE_3D,this.texture),x!==this.minFilter&&(g.texParameteri(g.TEXTURE_3D,g.TEXTURE_MAG_FILTER,x),g.texParameteri(g.TEXTURE_3D,g.TEXTURE_MIN_FILTER,x),this.minFilter=x),c!==this.wrapS&&(g.texParameteri(g.TEXTURE_3D,g.TEXTURE_WRAP_S,c),g.texParameteri(g.TEXTURE_3D,g.TEXTURE_WRAP_T,c),this.wrapS=c)}destroy(){const{gl:x}=this.context;x.deleteTexture(this.texture),this.texture=null}},i.dS=m3e,i.dT=(x,c,h,g,j,T)=>{const P=x.transform,R=P.projection.name==="globe";let F;if(T.paint.get("circle-pitch-alignment")==="map")if(R){const Q=c3e(P.zoom,c.canonical)*P._pixelsPerMercatorPixel;F=Float32Array.from([Q,0,0,Q])}else F=P.calculatePixelsToTileUnitsMatrix(h);else F=new Float32Array([P.pixelsToGLUnits[0],0,0,P.pixelsToGLUnits[1]]);const H={u_camera_to_center_distance:x.transform.getCameraToCenterDistance(P.projection),u_matrix:x.translatePosMatrix(c.projMatrix,h,T.paint.get("circle-translate"),T.paint.get("circle-translate-anchor")),u_device_pixel_ratio:Cd.devicePixelRatio,u_extrude_scale:F,u_inv_rot_matrix:sdt,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:T.paint.get("circle-emissive-strength")};if(R){H.u_inv_rot_matrix=g,H.u_merc_center=j,H.u_tile_id=[c.canonical.x,c.canonical.y,1<{const Q=x.transform,se=Q.pitch<15?K5e(.07,.7,Fe((14-Q.zoom)/5,0,1)):.07,re=h.paint.get("line-trim-color-use-theme").constantOr("default")==="none";return{u_matrix:Y5e(x,c,h,g),u_texsize:c.imageAtlasTexture?c.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:Q.calculatePixelsToTileUnitsMatrix(c),u_device_pixel_ratio:j,u_width_scale:T,u_floor_width_scale:P,u_image:0,u_tile_units_to_pixels:Z5e(c,Q),u_units_to_pixels:[1/Q.pixelsToGLUnits[0],1/Q.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:R,u_trim_fade_range:h.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:h.paint.get("line-trim-color").toPremultipliedRenderColor(re?null:h.lut).toArray01(),u_zbias_factor:se,u_tile_to_meter:As(c.tileID.canonical,0),u_ground_shadow_factor:F,u_pattern_transition:H}},i.dX=(x,c,h,g,j,T,P,R,F,H)=>{const Q=x.transform,se=Q.calculatePixelsToTileUnitsMatrix(c),re=h.paint.get("line-trim-color-use-theme").constantOr("default")==="none",le=Q.pitch<15?K5e(.07,.7,Fe((14-Q.zoom)/5,0,1)):.07;return{u_matrix:Y5e(x,c,h,g),u_pixels_to_tile_units:se,u_device_pixel_ratio:T,u_width_scale:P,u_floor_width_scale:R,u_units_to_pixels:[1/Q.pixelsToGLUnits[0],1/Q.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:j,u_texsize:Q5e(h)&&c.lineAtlasTexture?c.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Z5e(c,x.transform),u_alpha_discard_threshold:0,u_trim_offset:F,u_trim_fade_range:h.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:h.paint.get("line-trim-color").toPremultipliedRenderColor(re?null:h.lut).toArray01(),u_zbias_factor:le,u_tile_to_meter:As(c.tileID.canonical,0),u_ground_shadow_factor:H}},i.dY=Vt,i.dZ=e6,i.d_=is,i.da=function(x){const c=x.indexOf(u2);return c>=0?x.slice(0,c):x},i.db=function(x){return x.indexOf(u2)>=0},i.dc=function(x){const c=x.lastIndexOf(u2);return c>=0?x.slice(c+1):""},i.dd=function(x){const c=[],h=x.id;return h===void 0&&c.push({message:`layers.${h}: missing required property "id"`}),x.render===void 0&&c.push({message:`layers.${h}: missing required method "render"`}),x.renderingMode&&x.renderingMode!=="2d"&&x.renderingMode!=="3d"&&c.push({message:`layers.${h}: property "renderingMode" must be either "2d" or "3d"`}),c},i.de=function(x,c,h,g){return x.type==="custom"?new qht(x,c):new Wht[x.type](x,c,h,g)},i.df=bs,i.dg=b3,i.dh=TF,i.di=class extends I2{constructor(x,c){super(x._vectorTileFeature,x._z,x._x,x._y,x.id),x.state&&(this.state=Object.assign({},x.state)),this.target=c.target,this.namespace=c.namespace,c.properties&&(this.properties=c.properties),this.target&&("featuresetId"in this.target&&!this.target.importId||"layerId"in this.target)&&(this.source=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.dj=NP,i.dk=function(x){return x({pluginStatus:Zd,pluginURL:Qh}),NP.on("pluginStateChange",x),x},i.dl=zpe,i.dm=class extends Wm{constructor(x){super(x),this.current=v}set(x,c,h){if(this.fetchUniformLocation(x,c)){for(let g=0;g<9;g++)if(h[g]!==this.current[g]){this.current=h,this.gl.uniformMatrix3fv(this.location,!1,h);break}}}},i.dn=Lr,i.dp=function(x,c,h){const g=av(h.zoom),j=x.style.map._antialias,T=x.terrain&&x.terrain.exaggeration()>0;return g===0&&!j&&!T},i.dq=function(x){const c=x.pixelsPerMeter,h=c/Zt(1,x.center.lat),g=w(new Float64Array(16));return A(g,g,[x.point.x,x.point.y,0]),I(g,g,[h,h,c]),Float32Array.from(g)},i.dr=UF,i.ds=function(x){const c=80.051129;x=Fe(x,-80.051129,c)/c*90;const h=Math.pow(Math.abs(Math.sin(Zr(x))),3);return Math.round(h*(Bt.length-1))},i.dt=function(x,c,h,g){const j=c.getNorth(),T=c.getSouth(),P=c.getWest(),R=c.getEast(),F=1<0){const ue=180/g;_(le,le,[ue/H+1,0,0,0,ue/Q+1,0,-.5*ue/se,.5*ue/re,1])}return le[2]=F,le[5]=x.x,le[8]=x.y,le},i.du=JP,i.dv=fy,i.dw=function(x,c,h){const g=w(new Float64Array(16)),j=(c/(1<0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(x,c=!1){const h=W3e(new as(0,0),new as(sr,sr),x),g=[];if(c&&!afe(h,this._globalClipBounds))return g;for(const j of this._activeRegions){if(j.hiddenByOverlap||!afe(h,j))continue;const T=Fdt(j.min,j.max,x);g.push({min:T.min,max:T.max,sourceId:this._sourceIds[j.priority],footprint:j.footprint,footprintTileId:j.tileId,order:j.order,clipMask:j.clipMask,clipScope:j.clipScope})}return g}setSources(x){this._setSources(x.map(c=>({getSourceId:()=>c.cache.id,getFootprints:()=>{const h=[];for(const g of c.cache.getVisibleCoordinates()){const j=c.cache.getTile(g).buckets[c.layer];j&&j.updateFootprints(g.toUnwrapped(),h)}return h},getOrder:()=>c.order,getClipMask:()=>c.clipMask,getClipScope:()=>c.clipScope})))}_addSource(x){const c=x.getFootprints();if(c.length===0)return;const h=x.getOrder(),g=x.getClipMask(),j=x.getClipScope();for(const T of c){if(!T.footprint)continue;const P=W3e(T.footprint.min,T.footprint.max,T.id);this._activeRegions.push({min:P.min,max:P.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:T.id,footprint:T.footprint,order:h,clipMask:g,clipScope:j})}this._sourceIds.push(x.getSourceId())}_computeReplacement(){this._activeRegions.sort((c,h)=>c.priority-h.priority||JF(c.min,h.min)||JF(c.max,h.max)||c.order-h.order||c.clipMask-h.clipMask||function(g,j){const T=(P,R)=>P+R;return g.length-j.length||g.reduce(T,"").localeCompare(j.reduce(T,""))}(c.clipScope,h.clipScope));let x=this._activeRegions.length!==this._prevRegions.length;if(!x){let c=0;for(;!x&&c!==this._activeRegions.length;){const h=this._activeRegions[c],g=this._prevRegions[c];x=h.priority!==g.priority||!G3e(h,g)||h.order!==g.order||h.clipMask!==g.clipMask||!qn(h.clipScope,g.clipScope),this._activeRegions[c].hiddenByOverlap=g.hiddenByOverlap,++c}}if(x){++this._updateTime;for(const h of this._activeRegions)h.order!==l6&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,h.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,h.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,h.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,h.max.y));const c=h=>{const g=this._activeRegions;if(h>=g.length)return h;const j=g[h].priority;for(;h1){let h=0,g=c(h);for(;h!==g;){let j=h;const T=h;for(;j!==g;){const P=this._activeRegions[j];P.hiddenByOverlap=!1;for(let R=0;R=0;c--)this._addSource(x[c]);this._computeReplacement()}},i.eH=dd,i.eI=P7,i.eJ=tv,i.eK=l6,i.eL=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,c){const h=new _h,g=new Ao,j=[],T=x+1+2,P=c[0]+1,R=c[0]+1+(1+c.length),F=(H,Q,se)=>{let re=H===T-1?H-2:H===0?H:H-1;return re+=se?24575:0,[re,Q]};for(let H=0;H>>=0,x=Math.imul(2747636419^x,2654435769)>>>0,x=Math.imul(x^x>>>16,2654435769)>>>0,(x=Math.imul(x^x>>>16,2654435769)>>>0)/4294967296},i.ec=a3e,i.ed=qpe,i.ee=Hm,i.ef=O,i.eg=function(x,c){return x[0]=c[0],x[1]=c[1],x[2]=c[2],x[3]=c[4],x[4]=c[5],x[5]=c[6],x[6]=c[8],x[7]=c[9],x[8]=c[10],x},i.eh=J0,i.ei=g2,i.ej=function(x,c,h,g,j){return Fe((x-c)/(h-c)*(j-g)+g,g,j)},i.ek=Ut,i.el=function(x,c){var h=c[0],g=c[1],j=c[2],T=c[3],P=c[4],R=c[5],F=c[6],H=c[7],Q=c[8],se=Q*P-R*H,re=-Q*T+R*F,le=H*T-P*F,ue=h*se+g*re+j*le;return ue?(x[0]=se*(ue=1/ue),x[1]=(-Q*g+j*H)*ue,x[2]=(R*g-j*P)*ue,x[3]=re*ue,x[4]=(Q*h-j*F)*ue,x[5]=(-R*h+j*T)*ue,x[6]=le*ue,x[7]=(-H*h+g*F)*ue,x[8]=(P*h-g*T)*ue,x):null},i.em=rF,i.en=2,i.eo=Ve,i.ep=et,i.eq=U,i.er=function(x,c){var h=new u(3);U(h,c);var g=1/h[0],j=1/h[1],T=1/h[2],P=c[0]*g,R=c[1]*j,F=c[2]*T,H=c[4]*g,Q=c[5]*j,se=c[6]*T,re=c[8]*g,le=c[9]*j,ue=c[10]*T,_e=P+Q+ue,Ce=0;return _e>0?(Ce=2*Math.sqrt(_e+1),x[3]=.25*Ce,x[0]=(se-le)/Ce,x[1]=(re-F)/Ce,x[2]=(R-H)/Ce):P>Q&&P>ue?(Ce=2*Math.sqrt(1+P-Q-ue),x[3]=(se-le)/Ce,x[0]=.25*Ce,x[1]=(R+H)/Ce,x[2]=(re+F)/Ce):Q>ue?(Ce=2*Math.sqrt(1+Q-P-ue),x[3]=(re-F)/Ce,x[0]=(R+H)/Ce,x[1]=.25*Ce,x[2]=(se+le)/Ce):(Ce=2*Math.sqrt(1+ue-P-Q),x[3]=(R-H)/Ce,x[0]=(re+F)/Ce,x[1]=(se+le)/Ce,x[2]=.25*Ce),x},i.es=function(x,c){var h=2*Math.acos(c[3]),g=Math.sin(h/2);return g>d?(x[0]=c[0]/g,x[1]=c[1]/g,x[2]=c[2]/g):(x[0]=1,x[1]=0,x[2]=0),h},i.et=nxe,i.eu=m7,i.ev=h7,i.ew=[1,1,1],i.ex=Z3,i.ey=function(x,c,h,g){var j=c[0],T=c[1],P=c[2],R=c[3];return x[0]=j+g*(h[0]-j),x[1]=T+g*(h[1]-T),x[2]=P+g*(h[2]-P),x[3]=R+g*(h[3]-R),x},i.ez=$3,i.f=bu,i.f0=u3e,i.f1=function(x){const c=[0,0,0],h=w(new Float64Array(16));return C(h,x.pixelMatrix,x.globeMatrix),ct(c,c,h),new as(c[0],c[1])},i.f2=kP,i.f3=function(x,c,h=!1){if(Zd===vh.deferred||Zd===vh.loading||Zd===vh.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");Qh=Cd.resolveURL(x),Zd=vh.deferred,Lf=c,jP(),h||wF()},i.f4=ic,i.f5=ac,i.f6=sl,i.f7=function(x){const c=Cf();if(!c)return;const h=c.delete(gh);x&&h.then(()=>x()).catch(x)},i.f8=yr,i.f9=n_,i.fA=pn,i.fB=function(x){let c=0;if(new Uint32Array(x,0,1)[0]!==k5e){const h=new Uint32Array(x,0,7),[,,g,j,T,P]=h;c=h.byteLength+j+T+P+T,(g!==x.byteLength||c>=x.byteLength)&&zr("Invalid b3dm header information.")}return T5e(x,c)},i.fC=function(x,c){const h=jfe(x);for(const g of h){for(const j of g.meshes)fut(j);g.lights&&(g.lightMeshIndex=g.meshes.length,g.meshes.push(xut(g.lights,c)))}return h},i.fD=R7,i.fE=ua,i.fF=Wx,i.fG=vh,i.fH=function(x){zx(),Kh!=null&&Kh.then(c=>{c.keys().then(h=>{for(let g=0;gzr(j.message))}).catch(h=>zr(h.message))}).catch(c=>zr(c.message))},i.fa=2,i.fb=Vx,i.fc=E2,i.fd=GP,i.fe=fTe,i.ff=xTe,i.fg=V5e,i.fh=Fn,i.fi="hd_road_elevation",i.fj=Ci,i.fk=Is,i.fl=XF,i.fm=iv,i.fn=Bfe,i.fo=1,i.fp=eg,i.fq=function(x,c,h,g,j,T,P,R=1,F,H,Q,se){x.createArrays(),x.tilePixelRatio=sr/(512*x.overscaling),x.compareText={},x.iconsNeedLinear=!1;const re=x.layers[0].layout,le=x.layers[0]._unevaluatedLayout._values,ue={};ue.scaleFactor=R,ue.textSizeScaleRange=re.get("text-size-scale-range"),ue.iconSizeScaleRange=re.get("icon-size-scale-range");const[_e,Ce]=ue.textSizeScaleRange,[Ee,Ge]=ue.iconSizeScaleRange;ue.textScaleFactor=Fe(ue.scaleFactor,_e,Ce),ue.iconScaleFactor=Fe(ue.scaleFactor,Ee,Ge);const Be=le["text-size"],nt=le["icon-size"];if(x.textSizeData.kind==="composite"){const{minZoom:Mt,maxZoom:Tt}=x.textSizeData;ue.compositeTextSizes=[Be.possiblyEvaluate(new Ka(Mt,{worldview:Q}),T),Be.possiblyEvaluate(new Ka(Tt,{worldview:Q}),T)]}if(x.iconSizeData.kind==="composite"){const{minZoom:Mt,maxZoom:Tt}=x.iconSizeData;ue.compositeIconSizes=[nt.possiblyEvaluate(new Ka(Mt,{worldview:Q}),T,se),nt.possiblyEvaluate(new Ka(Tt,{worldview:Q}),T,se)]}ue.layoutTextSize=Be.possiblyEvaluate(new Ka(P+1,{worldview:Q}),T),ue.layoutIconSize=nt.possiblyEvaluate(new Ka(P+1,{worldview:Q}),T,se),ue.textMaxSize=Be.possiblyEvaluate(new Ka(18,{worldview:Q}),T);const it=re.get("symbol-placement"),lt=re.get("text-rotation-alignment")==="map"&&it!=="point",Rt=re.get("text-size");let jt=!1;const It=[];for(const Mt of x.features){const Tt=re.get("text-font").evaluate(Mt,{},T).join(","),rs=Rt.evaluate(Mt,{},T)*ue.textScaleFactor,ls=ue.layoutTextSize.evaluate(Mt,{},T)*ue.textScaleFactor,xs=ue.layoutIconSize.evaluate(Mt,{},T,se)*ue.iconScaleFactor,Ns={horizontal:{},vertical:void 0},gs=Mt.text;let Rs,ts=[0,0];if(gs){const Hn=gs.toString(),xo=re.get("text-letter-spacing").evaluate(Mt,{},T)*lc,Za=re.get("text-line-height").evaluate(Mt,{},T)*lc,Da=kpe(Hn)?xo:0,Si=re.get("text-anchor").evaluate(Mt,{},T),lo=re.get("text-variable-anchor");if(!lo){const Po=re.get("text-radial-offset").evaluate(Mt,{},T);if(Po)ts=TMe(Si,[Po*lc,Vfe]);else{const hd=re.get("text-offset").evaluate(Mt,{},T);ts=[hd[0]*lc,hd[1]*lc]}}let cc=lt?"center":re.get("text-justify").evaluate(Mt,{},T);const co=it==="point",Eo=co?re.get("text-max-width").evaluate(Mt,{},T)*lc:1/0,rl=Po=>{x.allowVerticalPlacement&&_P(Hn)&&(Ns.vertical=Ife(gs,c,h,j,Tt,Eo,Za,Si,Po,Da,ts,am.vertical,!0,ls,rs,F,ue.textScaleFactor))};if(!lt&&lo){const Po=cc==="auto"?lo.map(dc=>Hfe(dc)):[cc];let hd=!1;for(let dc=0;dc=0||!_P(Hn)){const Po=Ife(gs,c,h,j,Tt,Eo,Za,Si,cc,Da,ts,am.horizontal,!1,ls,rs,F,ue.textScaleFactor);Po&&(Ns.horizontal[cc]=Po)}rl(co?"left":cc)}}let ws,Ts,Os,Zs,xr,er,Js=!1;const Ys=re.get("icon-text-fit").evaluate(Mt,{},T);if(Mt.icon&&Mt.icon.hasPrimary()){const Hn=j6(Mt.icon,x.iconSizeData,le["icon-size"],T,x.zoom,Mt,F,ue.iconScaleFactor,Q,se);ws=Hn.iconPrimary,Os=Hn.iconSecondary;const xo=ws.toString();if(Ts=g.get(xo),Ts&&(xr=re.get("icon-offset").evaluate(Mt,{},T),er=re.get("icon-anchor").evaluate(Mt,{},T),Rs=v7(j.get(xo),Os?j.get(Os.toString()):void 0,xr,er),Js=Ts.sdf,x.sdfIcons===void 0?x.sdfIcons=Ts.sdf:x.sdfIcons!==Ts.sdf&&zr("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(Ts.pixelRatio!==x.pixelRatio||re.get("icon-rotate").constantOr(1)!==0)&&(x.iconsNeedLinear=!0)),Os){const Za=Os.toString();Zs=g.get(Za)}}jt=jt||!(!Mt.icon||!Mt.icon.hasSecondary());const ur=S7(Ns.horizontal)||Ns.vertical;x.iconsInText||(x.iconsInText=!!ur&&ur.iconsInText);const Nr=ls*ue.textScaleFactor/lc,{defaultShapedIcon:Ur,verticallyShapedIcon:Er}=Sht(x,Rs,re,Mt,T,Ns,Nr,xr,Ys);Ys!=="none"&&Rs&&(uMe(Rs)||hMe(Rs))&&(k7(0,Ts,ws,Rs,Ur,Ys,H,g,j),k7(0,Zs,Os,Rs,Ur,Ys,H,g,j),Er&&(k7(0,Ts,ws,Rs,Er,Ys,H,g,j),k7(0,Zs,Os,Rs,Er,Ys,H,g,j))),Rs=Ur;const{iconBBox:Tn,iconVerticalBBox:Na,textBBox:An,textVerticalBBox:Ca}=bht(x,Rs,Er,re,Mt,T,xs,xr,ue,j,er,Ns,ls,ts,se);It.push({feature:Mt,shapedTextOrientations:Ns,shapedText:ur,shapedIcon:Rs,iconPrimary:ws,iconSecondary:Os,iconOffset:xr,iconAnchor:er,verticallyShapedIcon:Er,layoutTextSize:ls,layoutIconSize:xs,textOffset:ts,isSDFIcon:Js,iconTextFit:Ys,iconCollisionBounds:Tn,iconVerticalCollisionBounds:Na,textCollisionBounds:An,textVerticalCollisionBounds:Ca})}return{featureData:It,sizes:ue,hasAnySecondaryIcon:jt,textAlongLine:lt,symbolPlacement:it}},i.fr=$fe,i.fs=zfe,i.ft=bMe,i.fu=wMe,i.fv=function(x,c,h,g,j,T,P,R,F,H){x.iconAtlasPositions=H.iconPositions;const{featureData:Q,hasAnySecondaryIcon:se,sizes:re,textAlongLine:le,symbolPlacement:ue}=c;for(const _e of Q){const{shapedIcon:Ce,verticallyShapedIcon:Ee,feature:Ge,shapedTextOrientations:Be,shapedText:nt,layoutTextSize:it,textOffset:lt,isSDFIcon:Rt,iconPrimary:jt,iconSecondary:It,iconTextFit:Mt,iconOffset:Tt,iconCollisionBounds:rs,iconVerticalCollisionBounds:ls,textCollisionBounds:xs}=_e;IMe(Ce,H.iconPositions,jt,It),IMe(Ee,H.iconPositions,jt,It),kht(Be,H.iconPositions),Nht(jt,It,H.iconPositions),(nt||Ce)&&Cht(x,Ge,Be,Ce,Ee,F,re,it,0,lt,Rt,g,j,P,R,se,Mt,Tt,le,ue,rs,ls,xs)}h&&x.generateCollisionDebugBuffers(T,x.collisionBoxArray,re.textScaleFactor)},i.fw=x7,i.fx=$a,i.fy=function(x){return x<=1?1:Math.pow(2,Math.floor(Math.log2(x)))},i.fz=q7,i.g=ha,i.h=function(x,c){return Jg(Object.assign(x,{method:"GET"}),c)},i.i=function(x){return ha.API_STYLE_REGEX.test(x)&&!wu(x)},i.j=function(x){return btoa(encodeURIComponent(x).replace(/%([0-9A-F]{2})/g,(c,h)=>String.fromCharCode(+("0x"+h))))},i.k=Bx,i.l=function(x){return decodeURIComponent(atob(x).split("").map(c=>"%"+("00"+c.charCodeAt(0).toString(16)).slice(-2)).join(""))},i.m=function(x,c){return Jg(Object.assign(x,{type:"json"}),c)},i.n=ty,i.o=Cd,i.p=function(x,c){return Jg(Object.assign(x,{method:"POST"}),c)},i.q=Pd,i.r=Gt,i.s=function(x){try{const c=self[x];return c.setItem("_mapbox_test_",1),c.removeItem("_mapbox_test_"),!0}catch{return!1}},i.t=bt,i.u=function(){return function x(c){return c?(c^Math.random()*(16>>c/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=zr,i.x=class{constructor(x){this.cache=new Map,this.textures=new Map,this.textureAccessTimes=new Map,this.textureMemoryUsed=0,this.maxTextureMemory=1024*(x&&x.maxTextureMemoryMB?x.maxTextureMemoryMB:256)*1024,this.finalizationRegistry=new FinalizationRegistry(c=>{this.cache.delete(c),this.clearExpiredTextures()})}calculateTextureMemory(x){return x.image?Math.ceil(x.image.width*x.image.height*4*(x.patternPositions.size>0?1.33:1)):0}evictTexture(x){const c=this.textures.get(x);if(c){const h=this.calculateTextureMemory(x);c.destroy(),this.textures.delete(x),this.textureAccessTimes.delete(x),this.textureMemoryUsed-=h}}evictTexturesIfNeeded(x){for(;this.textureMemoryUsed+x>this.maxTextureMemory&&this.textures.size>0;){let c=null,h=1/0;for(const[g]of this.textures.entries()){const j=this.textureAccessTimes.get(g)||0;jthis._layers[or.id]),Gt=At[0];if(Gt.visibility==="none")continue;const Vt=Gt.source||"";let Xt=this.familiesBySource[Vt];Xt||(Xt=this.familiesBySource[Vt]=Object.create(null));const Is=Gt.sourceLayer||"_geojsonTileLayer";let bs=Xt[Is];bs||(bs=Xt[Is]=[]),bs.push(At)}}}const b=1*d.fa;class N{constructor(Se){const Fe={},Xe=[];for(const Gt in Se){const Vt=Se[Gt],Xt=Fe[Gt]={};for(const Is in Vt.glyphs){const bs=Vt.glyphs[+Is];if(!bs||bs.bitmap.width===0||bs.bitmap.height===0)continue;const or=bs.metrics.localGlyph?b:1,Rr={x:0,y:0,w:bs.bitmap.width+2*or,h:bs.bitmap.height+2*or};Xe.push(Rr),Xt[Is]=Rr}}const{w:yt,h:bt}=d.J(Xe),At=new d.f9({width:yt||1,height:bt||1});for(const Gt in Se){const Vt=Se[Gt];for(const Xt in Vt.glyphs){const Is=Vt.glyphs[+Xt];if(!Is||Is.bitmap.width===0||Is.bitmap.height===0)continue;const bs=Fe[Gt][Xt],or=Is.metrics.localGlyph?b:1;d.f9.copy(Is.bitmap,At,{x:0,y:0},{x:bs.x+or,y:bs.y+or},Is.bitmap)}}this.image=At,this.positions=Fe}}function w($t,Se,Fe){$t[Se]?Fe&&($t[Se].center=Fe):$t[Se]={floorIds:new Set,center:Fe||[0,0],floors:{}}}function S($t,Se,Fe,Xe){for(const yt of Se)w($t,yt),$t[yt].floors[Fe]=Xe,$t[yt].floorIds.add(Fe)}function C($t){return{id:$t.properties.id.toString(),center:[$t.properties.center_lon||0,$t.properties.center_lat||0]}}function A($t,Se){const Fe=$t.properties.id.toString(),Xe=!!$t.properties.is_default&&$t.properties.is_default,yt=$t.properties.connected_floor_ids?new Set($t.properties.connected_floor_ids.toString().split(";")):new Set,bt=$t.properties.conflicted_floor_ids?new Set($t.properties.conflicted_floor_ids.toString().split(";")):new Set,At=$t.properties.structure_ids?new Set($t.properties.structure_ids.toString().split(";")):new Set,Gt=$t.properties.name.toString(),Vt=$t.properties.z_index,Xt=function(Is,bs){const or=Is.loadGeometry();if(!or||or.length===0)return;const Rr=or.map(Wr=>Wr.map(zr=>d.fb(zr,bs,Is.extent)));return Rr.length===0?void 0:{type:"Polygon",coordinates:[Rr[0]]}}($t,Se);return{id:Fe,isDefault:Xe,connections:yt,conflicts:bt,buildings:At,name:Gt,zIndex:Vt,geometry:Xt}}function I($t,Se){return Se.every(Fe=>$t.properties&&$t.properties[Fe]!=null)}function L($t){return I($t,["type","id","name"])&&$t.properties.type==="structure"}function O($t){return I($t,["type","id","name","z_index"])&&$t.properties.type==="floor"}d.f8(N,"GlyphAtlas");class V{constructor(Se){this.tileID=new d.aR(Se.tileID.overscaledZ,Se.tileID.wrap,Se.tileID.canonical.z,Se.tileID.canonical.x,Se.tileID.canonical.y),this.tileZoom=Se.tileZoom,this.uid=Se.uid,this.zoom=Se.zoom,this.lut=Se.lut,this.canonical=Se.tileID.canonical,this.pixelRatio=Se.pixelRatio,this.tileSize=Se.tileSize,this.source=Se.source,this.scope=Se.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=Se.showCollisionBoxes,this.collectResourceTiming=!!Se.request&&Se.request.collectResourceTiming,this.promoteId=Se.promoteId,this.renderSourceType=Se.renderSourceType,this.tileTransform=d.fc(Se.tileID.canonical,Se.projection),this.projection=Se.projection,this.worldview=Se.worldview,this.localizableLayerIds=Se.localizableLayerIds,this.brightness=Se.brightness,this.extraShadowCaster=!!Se.extraShadowCaster,this.tessellationStep=Se.tessellationStep,this.scaleFactor=Se.scaleFactor,this.worldview=Se.worldview,this.indoor=Se.indoor}parse(Se,Fe,Xe,yt,bt,At){this.status="parsing",this.data=Se,this.collisionBoxArray=new d.fd;const Gt=new d.fe(Object.keys(Se.layers).sort()),Vt=new d.ff(this.tileID,this.promoteId);Vt.bucketLayerIDs=[];const Xt={},Is=new d.fg(256,256),bs={featureIndex:Vt,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:Is,availableImages:Xe,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};this.indoor&&(bs.activeFloors=function(zr,hn,Wn,sa){const ua=hn.indoorState.activeFloorsVisible;if(!hn.sourceLayers)return ua?hn.indoorState.activeFloors:void 0;const To=function(ii,$i){if(!ii)return d.w("No source layers defined in indoor specification"),$i;if(ii.size===0)return $i;const tl=ii.difference($i);for(const ui of tl)d.w(`Missing source layer required in indoor specification: ${ui}`);return $i.intersection($i)}(hn.sourceLayers,new Set(Object.keys(zr.layers))),wo=hn.indoorState,Yi=function(ii,$i,tl,ui,qi){const Xi={};for(const ha of $i){const sl=ii.layers[ha];if(sl)for(let ac=0;ac=ui.maxzoom||ui.visibility==="none")continue;q(tl,this.zoom,bs.brightness,Xe,this.worldview,bs.activeFloors);const qi=Xt[ui.id]=ui.createBucket({index:Vt.bucketLayerIDs.length,layers:tl,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:wo,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:yt,worldview:this.worldview,localizable:ii,availableImages:Xe,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords,disableSymbolUBO:this.disableSymbolUBO});Vt.bucketLayerIDs.push(tl.map(ha=>d.F(ha.id,ha.scope)));let Xi=qi.prepare?qi.prepare():null;Xi!=null?(Xi=Xi.then(()=>qi.populate(Yi,bs,this.tileID.canonical,this.tileTransform)),or.push(Xi)):qi.populate(Yi,bs,this.tileID.canonical,this.tileTransform)}}const Wr=()=>{Is.trim();const zr=!(!bs.elevationFeatures||!bs.elevationFeatures.some(ui=>ui.heightRange.min<0));let hn,Wn,sa,ua,To,wo,Yi;const ii={type:"maybePrepare",renderSourceType:this.renderSourceType,zoom:this.zoom},$i=()=>{if(hn)return this.status="done",At(hn);if(this.extraShadowCaster)this.status="done",At(null,{buckets:Object.values(Xt).filter(ui=>!ui.isEmpty()),featureIndex:Vt,collisionBoxArray:null,hasTunnelGeometry:zr,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:bs.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(Wn&&sa&&ua&&Yi){const qi=new N(Wn),Xi=new Map;for(const[ac,ic]of sa.entries()){const{imagePosition:bu}=d.fn(ac,ic,d.fo);Xi.set(ac,bu)}const ha={};for(const ac in Xt){const ic=Xt[ac];ic instanceof d.fp&&(q(ic.layers,this.zoom,bs.brightness,Xe,this.worldview,bs.activeFloors),ha[ac]=d.fq(ic,Wn,qi.positions,sa,Xi,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,To,this.worldview,Xe))}const sl={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(bt,sa,To,()=>{sl.iconsPending=!1,tl(ha,qi,sl,void 0,Yi)}),this.rasterizeIfNeeded(bt,ua,wo,()=>{sl.patternsPending=!1,tl(ha,qi,sl,void 0,Yi)})}},tl=(ui,qi,Xi,ha,sl)=>{if(Xi.iconsPending||Xi.patternsPending)return;const ac=sa.size>0||ua.size>0,ic=Object.keys(ui).length>0;if(!ac&&!ic)return this.status="done",void At(null,{buckets:Object.values(Xt).filter(wu=>!wu.isEmpty()),featureIndex:Vt,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:zr,glyphAtlasImage:qi.image,lineAtlas:Is,imageAtlas:null,brightness:bs.brightness});const bu=(wu,Fm)=>{for(const kd in Xt){const ju=Xt[kd];if(kd in ui)d.fv(ju,ui[kd],this.showCollisionBoxes,Xe,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,sa,Fm);else if(ju.hasPattern&&(ju instanceof d.fw||ju instanceof d.fl||ju instanceof d.e0)){q(ju.layers,this.zoom,bs.brightness,Xe,this.worldview,bs.activeFloors);const zm=Object.fromEntries(Fm.patternPositions);ju.addFeatures(bs,this.tileID.canonical,zm,Xe,this.tileTransform,this.brightness)}}this.status="done",At(null,{buckets:Object.values(Xt).filter(kd=>!kd.isEmpty()),featureIndex:Vt,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:zr,glyphAtlasImage:qi.image,lineAtlas:Is,imageAtlas:wu,brightness:bs.brightness})};if(ac){const wu=new Map,Fm=d.fr(sa,wu),kd=d.fr(ua,wu),ju=new d.fs(Fm,kd,sl,this.lut,wu);bt.send("checkAtlasCache",{descriptor:ju,scope:this.scope},(zm,Wu)=>{let Bm,Sd;if(zm&&d.w(`[Worker] Error checking atlas cache: ${zm.message}`),Wu)Bm=new d.ft(Wu.sourceHash),Sd=Wu;else{const Cd=new d.fu(sa,ua,this.lut,sl);Bm=Cd,Sd=Cd}bu(Bm,Sd)})}else bu(null,{iconPositions:new Map,patternPositions:new Map})};if(!this.extraShadowCaster){const ui=d.fk(bs.glyphDependencies,ha=>Object.keys(ha).map(Number));Object.keys(ui).length?bt.send("getGlyphs",{uid:this.uid,stacks:ui},(ha,sl)=>{hn||(hn=ha,Wn=sl,$i())},void 0,!1,ii):Wn={},Yi=new Map;const qi=Array.from(bs.iconDependencies.keys()).map(ha=>d.I.parse(ha));qi.length?bt.send("getImages",{images:qi,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(ha,sl)=>{if(!hn){hn=ha,sa=new Map,To=this.updateImageMapAndGetImageTaskQueue(sa,sl.images,bs.iconDependencies);for(const[ac,ic]of sl.versions.entries())Yi.set(ac,ic);$i()}},void 0,!1,ii):(sa=new Map,To=new Map);const Xi=Array.from(bs.patternDependencies.keys()).map(ha=>d.I.parse(ha));Xi.length?bt.send("getImages",{images:Xi,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(ha,sl)=>{if(!hn){hn=ha,ua=new Map,wo=this.updateImageMapAndGetImageTaskQueue(ua,sl.images,bs.patternDependencies);for(const[ac,ic]of sl.versions.entries())Yi.set(ac,ic);$i()}},void 0,!1,ii):(ua=new Map,wo=new Map)}if(bs.elevationFeatures&&bs.elevationFeatures.length>0){const ui=[];for(const Xi of Object.values(Xt))if(Xi instanceof d.fl){const ha=Xi.getUnevaluatedPortalGraph();ha&&ui.push(ha)}const qi=d.fm.evaluate(ui);for(const Xi of Object.values(Xt))if(Xi instanceof d.fl){const ha=Se.layers[Gt.decode(Xi.sourceLayerIndex)];Xi.setEvaluatedPortalGraph(qi,ha,this.tileID.canonical,bs.availableImages,bs.brightness)}}$i()};or.length>0?Promise.allSettled(or).then(Wr).catch(At):Wr()}updateParameters(Se){this.scaleFactor=Se.scaleFactor,this.showCollisionBoxes=Se.showCollisionBoxes,this.projection=Se.projection,this.brightness=Se.brightness,this.tileTransform=d.fc(Se.tileID.canonical,Se.projection),this.extraShadowCaster=Se.extraShadowCaster,this.lut=Se.lut,this.worldview=Se.worldview,this.indoor=Se.indoor}rasterizeIfNeeded(Se,Fe,Xe,yt){Array.from(Fe.values()).some(bt=>bt.usvg)?this.rasterize(Se,Fe,Xe,yt):yt()}updateImageMapAndGetImageTaskQueue(Se,Fe,Xe){const yt=new Map;for(const bt of Fe.keys()){const At=Xe.get(bt)||[];for(const Gt of At){const Vt=Gt.toString(),Xt=Fe.get(Gt.id.toString());Xt.usvg?yt.has(Vt)||(yt.set(Vt,Gt),Se.set(Vt,Object.assign({},Xt))):Se.set(Vt,Xt)}}return yt}rasterize(Se,Fe,Xe,yt){this.rasterizeTask=Se.send("rasterizeImages",{scope:this.scope,tasks:Xe},(bt,At)=>{if(!bt)for(const[Gt,Vt]of At.entries()){const Xt=Object.assign(Fe.get(Gt),{data:Vt});Fe.set(Gt,Xt)}yt()})}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function q($t,Se,Fe,Xe,yt,bt){const At=new d.ae(Se,{brightness:Fe,worldview:yt,activeFloors:bt});for(const Gt of $t)Gt.recalculate(At,Xe)}class B extends d.E{constructor({actor:Se,layerIndex:Fe,availableImages:Xe,availableModels:yt,isSpriteLoaded:bt,tileProvider:At,brightness:Gt,maxUniformBufferBindings:Vt,maxUniformBlockSizeDwords:Xt,disableSymbolUBO:Is}){super(),this.actor=Se,this.layerIndex=Fe,this.availableImages=Xe,this.availableModels=yt,this.loadVectorData=d.aO,this.tileProvider=At,this.loading={},this.loaded={},this.deduped=new d.aN(Se.scheduler),this.isSpriteLoaded=bt,this.scheduler=Se.scheduler,this.brightness=Gt,this.maxUniformBufferBindings=Vt,this.maxUniformBlockSizeDwords=Xt,this.disableSymbolUBO=Is}loadTileData(Se,Fe){if(!this.tileProvider)return this.loadVectorData(Se,Fe);const Xe=new AbortController,{z:yt,x:bt,y:At}=Se.tileID.canonical;return this.tileProvider.loadTile({z:yt,x:bt,y:At},{request:Se.request,signal:Xe.signal}).then(Gt=>{if(Xe.signal.aborted)return;if(Gt==null){const Xt=new Error("Tile not found");return Xt.status=404,Fe(Xt)}if(Gt.data===null)return Fe(null,null);const Vt=new Map;Gt.expires&&Vt.set("expires",Gt.expires),Gt.cacheControl&&Vt.set("cache-control",Gt.cacheControl),Fe(null,{rawData:Gt.data,responseHeaders:Vt})}).catch(Gt=>{Xe.signal.aborted||Fe(Gt instanceof Error?Gt:new Error(String(Gt)))}),()=>Xe.abort()}loadTile(Se,Fe){const Xe=Se.uid,yt=Se&&Se.request,bt=yt&&yt.collectResourceTiming,At=this.loading[Xe]=new V(Se);At.maxUniformBufferBindings=this.maxUniformBufferBindings,At.maxUniformBlockSizeDwords=this.maxUniformBlockSizeDwords,At.disableSymbolUBO=this.disableSymbolUBO,At.abort=this.loadTileData(Se,(Gt,Vt)=>{const Xt=!this.loading[Xe];if(delete this.loading[Xe],At.cancelRasterize(),Xt||Gt||!Vt)return At.status="done",Xt||(this.loaded[Xe]=At),Fe(Gt);const Is=Vt.rawData,bs={},or=d.aP(Vt.responseHeaders);or&&or.expires&&(bs.expires=or.expires),or&&or.cacheControl&&(bs.cacheControl=or.cacheControl),At.vectorTile=Vt.vectorTile||new d.fx(new d.a$(Is));const Rr=()=>{At.parse(At.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(Wr,zr)=>{if(Wr||!zr)return Fe(Wr);const hn={};if(bt){const Wn=u(yt);Wn.length>0&&(hn.resourceTiming=JSON.parse(JSON.stringify(Wn)))}Fe(null,Object.assign({rawTileData:Is.slice(0),responseHeaders:Vt.responseHeaders},zr,bs,hn))})};this.isSpriteLoaded?Rr():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(Rr,{type:"parseTile",renderSourceType:Se.renderSourceType,zoom:Se.tileZoom}):Rr()}),this.loaded=this.loaded||{},this.loaded[Xe]=At})}reloadTile(Se,Fe){const Xe=this.loaded,yt=Se.uid;if(Xe&&Xe[yt]){const bt=Xe[yt];bt.updateParameters(Se);const At=(Gt,Vt)=>{const Xt=bt.reloadCallback;Xt&&(delete bt.reloadCallback,bt.parse(bt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Xt)),Fe(Gt,Vt)};bt.status==="parsing"?bt.reloadCallback=At:bt.status==="done"&&(bt.vectorTile?bt.parse(bt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,At):At())}else Fe(null,void 0)}abortTile(Se,Fe){const Xe=Se.uid,yt=this.loading[Xe];yt&&(yt.abort&&yt.abort(),delete this.loading[Xe]),Fe()}removeTile(Se,Fe){const Xe=this.loaded,yt=Se.uid;Xe&&Xe[yt]&&delete Xe[yt],Fe()}}class U{constructor(Se){this.loading={}}loadTile(Se,Fe){const Xe=Se.uid,{cancel:yt}=d.b1(Se.request,(bt,At,Gt)=>{const Vt=!this.loading[Xe];if(delete this.loading[Xe],Vt||bt||!At)return Fe(bt);this.decodeTile(Xe,At,Se.encoding).then(Xt=>{const{expires:Is,cacheControl:bs}=d.aP(Gt);Fe(null,Object.assign(Xt,{expires:Is,cacheControl:bs}))}).catch(Xt=>Fe(Xt))});this.loading[Xe]={cancel:yt}}async decodeTile(Se,Fe,Xe){const yt=await createImageBitmap(new Blob([new Uint8Array(Fe)],{type:"image/png"})),bt=1-(yt.width-d.fy(yt.width))/2,At=bt<1,Gt=this.getImageData(yt,bt);return yt.close(),{dem:new d.fz(Se,Gt,Xe,At),borderReady:At}}reloadTile(Se,Fe){Fe(null,null)}abortTile(Se,Fe){const Xe=Se.uid,yt=this.loading[Xe];yt&&(yt.cancel(),delete this.loading[Xe]),Fe()}removeTile(Se,Fe){Fe()}getImageData(Se,Fe){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(Se.width,Se.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=Se.width,this.offscreenCanvas.height=Se.height,this.offscreenCanvasContext.drawImage(Se,0,0,Se.width,Se.height);const Xe=this.offscreenCanvasContext.getImageData(-Fe,-Fe,Se.width+2*Fe,Se.height+2*Fe);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),Xe}}d.a_.setPbf(d.a$);class te{constructor(Se){this._mrt=new d.a_(Se.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=Se.uid,this.tileID=Se.tileID,this.source=Se.source}parse(Se,Fe){const Xe=this._mrt;this.status="parsing",this._entireBuffer=Se;try{Xe.parseHeader(Se),this._isHeaderLoaded=!0;const yt=[];for(const bt in Xe.layers){const At=Xe.getLayer(bt),Gt=At.getDataRange(At.getBandList()),Vt=Xe.createDecodingTask(Gt),Xt=Se.slice(Gt.firstByte,Gt.lastByte+1),Is=d.a_.performDecoding(Xt,Vt).then(bs=>Vt.complete(null,bs)).catch(bs=>Vt.complete(bs,null));yt.push(Is)}Promise.allSettled(yt).then(()=>Fe(null,Xe)).catch(bt=>Fe(bt))}catch(yt){Fe(yt)}}}class Y{constructor({actor:Se}){this.actor=Se,this.loading={},this.loaded={}}loadTile(Se,Fe){const Xe=Se.uid,yt=Se.request,bt=this.loading[Xe]=new te(Se),{cancel:At}=d.b1(yt,(Gt,Vt,Xt)=>{const Is=!this.loading[Xe];if(delete this.loading[Xe],Is||Gt||!Vt)return bt.status="done",Is||(this.loaded[Xe]=bt),Fe(Gt);bt.parse(Vt,(bs,or)=>{if(bs||!or)return Fe(bs);Fe(null,or,Xt)}),this.loaded[Xe]=bt});bt.abort=At}reloadTile(Se,Fe){Fe(null,void 0)}abortTile(Se,Fe){const Xe=Se.uid,yt=this.loading[Xe];yt&&(yt.abort&&yt.abort(),delete this.loading[Xe]),Fe()}removeTile(Se,Fe){const Xe=Se.uid;this.loaded[Xe]&&delete this.loaded[Xe],Fe()}decodeRasterArray(Se,Fe){d.a_.performDecoding(Se.buffer,Se.task).then(Xe=>Fe(null,Xe)).catch(Xe=>Fe(Xe))}}const J=d.fA.prototype.toGeoJSON;class X{constructor(Se){this._feature=Se,this.extent=d.an,this.type=Se.type,this.properties=Se.tags,"id"in Se&&!isNaN(Se.id)&&(this.id=parseInt(Se.id,10))}loadGeometry(){if(this._feature.type===1){const Se=[];for(const Fe of this._feature.geometry)Se.push([new d.P(Fe[0],Fe[1])]);return Se}{const Se=[];for(const Fe of this._feature.geometry){const Xe=[];for(const yt of Fe)Xe.push(new d.P(yt[0],yt[1]));Se.push(Xe)}return Se}}toGeoJSON(Se,Fe,Xe){return J.call(this,Se,Fe,Xe)}}class ce{constructor(Se,Fe){this.name=Se,this.extent=d.an,this.length=Fe.length,this._jsonFeatures=Fe}feature(Se){return new X(this._jsonFeatures[Se])}}class ie{constructor(Se){this.layers={},this.extent=d.an;for(const Fe of Object.keys(Se))this.layers[Fe]=new ce(Fe,Se[Fe])}}const ae=64/4096;class oe{constructor(){this.features=new Map}clear(){this.features.clear()}load(Se=[],Fe){for(const Xe of Se){const yt=Xe.id;if(yt==null)continue;let bt=this.features.get(yt);bt&&this.updateCache(bt,Fe),Xe.geometry?(bt=ve(Xe),this.updateCache(bt,Fe),this.features.set(yt,bt)):this.features.delete(yt),this.updateCache(bt,Fe)}}updateCache(Se,Fe){for(const{canonical:Xe,uid:yt}of Object.values(Fe)){const{z:bt,x:At,y:Gt}=Xe;me(Se,Math.pow(2,bt),At,Gt)&&delete Fe[yt]}}getTile(Se,Fe,Xe){const yt=Math.pow(2,Se),bt=[];for(const At of this.features.values())me(At,yt,Fe,Xe)&&bt.push(qe(At,yt,Fe,Xe));return{features:bt}}getFeatures(){return[...this.features.values()]}}function me({minX:$t,minY:Se,maxX:Fe,maxY:Xe},yt,bt,At){return $t<(bt+1+ae)/yt&&Se<(At+1+ae)/yt&&Fe>(bt-ae)/yt&&Xe>(At-ae)/yt}function ve($t){const{id:Se,geometry:Fe,properties:Xe}=$t;if(!Fe)return;if(Fe.type==="GeometryCollection")throw new Error("GeometryCollection not supported in dynamic mode.");const{type:yt,coordinates:bt}=Fe,At={id:Se,type:1,geometry:[],tags:Xe,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},Gt=At.geometry;if(yt==="Point")he(bt,Gt,At);else if(yt==="MultiPoint")for(const Vt of bt)he(Vt,Gt,At);else if(yt==="LineString")At.type=2,ge(bt,Gt,At);else if(yt==="MultiLineString")At.type=2,je(bt,Gt,At);else if(yt==="Polygon")At.type=3,je(bt,Gt,At,!0);else{if(yt!=="MultiPolygon")throw new Error("Input data is not a valid GeoJSON object.");At.type=3;for(const Vt of bt)je(Vt,Gt,At,!0)}return At}function he([$t,Se],Fe,Xe){const yt=d.aH($t);let bt=d.aL(Se);bt=bt<0?0:bt>1?1:bt,Fe.push(yt,bt),Xe.minX=Math.min(Xe.minX,yt),Xe.minY=Math.min(Xe.minY,bt),Xe.maxX=Math.max(Xe.maxX,yt),Xe.maxY=Math.max(Xe.maxY,bt)}function ge($t,Se,Fe,Xe=!1,yt=!1){const bt=[];for(const At of $t)he(At,bt,Fe);Se.push(bt),Xe&&function(At,Gt){let Vt=0;for(let Xt=0,Is=At.length,bs=Is-2;Xt0===Gt)for(let Xt=0,Is=At.length;Xt=At&&bs>=At||(Xt>=At?(Is+=Math.round(Wr*((At-Xt)/Rr)),Xt=At):bs>=At&&(or=Is+Math.round(Wr*((At-Xt)/Rr)),bs=At),Is>=At&&or>=At||(Is>=At?(Xt+=Math.round(Rr*((At-Is)/Wr)),Is=At):or>=At&&(bs=Xt+Math.round(Rr*((At-Is)/Wr)),or=At),Gt&&Xt===Gt[Gt.length-1][0]&&Is===Gt[Gt.length-1][1]||(Gt=[[Xt,Is]],yt.push(Gt)),Gt.push([bs,or])))))}}function ke($t,Se,Fe,Xe,yt){const bt=(Fe-ae)/Se,At=(Xe-ae)/Se,Gt=(Fe+1+ae)/Se,Vt=(Xe+1+ae)/Se;function Xt(or,Rr){let Wr=0;return orGt&&(Wr|=2),RrVt&&(Wr|=8),Wr}let Is=[];for(let or=1;or<=8;or*=2){let Rr=$t[$t.length-2],Wr=$t[$t.length-1],zr=!(Xt(Rr,Wr)&or);for(let hn=0;hn<$t.length;hn+=2){const Wn=$t[hn],sa=$t[hn+1],ua=!(Xt(Wn,sa)&or);ua!==zr&&(8&or?Is.push(Rr+(Wn-Rr)*(Vt-Wr)/(sa-Wr),Vt):4&or?Is.push(Rr+(Wn-Rr)*(At-Wr)/(sa-Wr),At):2&or?Is.push(Gt,Wr+(sa-Wr)*(Gt-Rr)/(Wn-Rr)):1&or&&Is.push(bt,Wr+(sa-Wr)*(bt-Rr)/(Wn-Rr))),ua&&Is.push(Wn,sa),Rr=Wn,Wr=sa,zr=ua}if(!($t=Is).length||or===8)break;Is=[]}const bs=[];for(let or=0;or>31}function ye($t,Se){const{geometry:Fe,type:Xe}=$t;let yt=0,bt=0;if(Xe===1){Se.writeVarint(Ue(1,Fe.length));for(const At of Fe){const Gt=At[0]-yt,Vt=At[1]-bt;Se.writeVarint(Ie(Gt)),Se.writeVarint(Ie(Vt)),yt+=Gt,bt+=Vt}}else for(const At of Fe){if(At.length===0)continue;Se.writeVarint(Ue(1,1));const Gt=At.length-(Xe===3?1:0);for(let Vt=0;Vt$t},$e=Math.fround||(Ye=new Float32Array(1),$t=>(Ye[0]=+$t,Ye[0]));var Ye;class tt{constructor(Se){this.options=Object.assign(Object.create(fe),Se),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(Se){const{log:Fe,minZoom:Xe,maxZoom:yt}=this.options;Fe&&console.time("total time");const bt=`prepare ${Se.length} points`;Fe&&console.time(bt),this.points=Se;const At=[];for(let Vt=0;Vt=Xe;Vt--){const Xt=+Date.now();Gt=this.trees[Vt]=this._createTree(this._cluster(Gt,Vt)),Fe&&console.log("z%d: %d clusters in %dms",Vt,Gt.numItems,+Date.now()-Xt)}return Fe&&console.timeEnd("total time"),this}getClusters(Se,Fe){let Xe=((Se[0]+180)%360+360)%360-180;const yt=Math.max(-90,Math.min(90,Se[1]));let bt=Se[2]===180?180:((Se[2]+180)%360+360)%360-180;const At=Math.max(-90,Math.min(90,Se[3]));if(Se[2]-Se[0]>=360)Xe=-180,bt=180;else if(Xe>bt){const bs=this.getClusters([Xe,yt,180,At],Fe),or=this.getClusters([-180,yt,bt,At],Fe);return bs.concat(or)}const Gt=this.trees[this._limitZoom(Fe)],Vt=Gt.range(Ke(Xe),ot(At),Ke(bt),ot(yt)),Xt=Gt.data,Is=[];for(const bs of Vt){const or=this.stride*bs;Is.push(Xt[or+5]>1?Te(Xt,or,this.clusterProps):this.points[Xt[or+3]])}return Is}getChildren(Se){const Fe=this._getOriginId(Se),Xe=this._getOriginZoom(Se),yt="No cluster with the specified id.",bt=this.trees[Xe];if(!bt)throw new Error(yt);const At=bt.data;if(Fe*this.stride>=At.length)throw new Error(yt);const Gt=this.options.radius/(this.options.extent*Math.pow(2,Xe-1)),Vt=bt.within(At[Fe*this.stride],At[Fe*this.stride+1],Gt),Xt=[];for(const Is of Vt){const bs=Is*this.stride;At[bs+4]===Se&&Xt.push(At[bs+5]>1?Te(At,bs,this.clusterProps):this.points[At[bs+3]])}if(Xt.length===0)throw new Error(yt);return Xt}getLeaves(Se,Fe,Xe){const yt=[];return this._appendLeaves(yt,Se,Fe=Fe||10,Xe=Xe||0,0),yt}getTile(Se,Fe,Xe){const yt=this.trees[this._limitZoom(Se)],bt=Math.pow(2,Se),{extent:At,radius:Gt}=this.options,Vt=Gt/At,Xt=(Xe-Vt)/bt,Is=(Xe+1+Vt)/bt,bs={features:[]};return this._addTileFeatures(yt.range((Fe-Vt)/bt,Xt,(Fe+1+Vt)/bt,Is),yt.data,Fe,Xe,bt,bs),Fe===0&&this._addTileFeatures(yt.range(1-Vt/bt,Xt,1,Is),yt.data,bt,Xe,bt,bs),Fe===bt-1&&this._addTileFeatures(yt.range(0,Xt,Vt/bt,Is),yt.data,-1,Xe,bt,bs),bs.features.length?bs:null}getClusterExpansionZoom(Se){let Fe=this._getOriginZoom(Se)-1;for(;Fe<=this.options.maxZoom;){const Xe=this.getChildren(Se);if(Fe++,Xe.length!==1)break;Se=Xe[0].properties.cluster_id}return Fe}_appendLeaves(Se,Fe,Xe,yt,bt){const At=this.getChildren(Fe);for(const Gt of At){const Vt=Gt.properties;if(Vt&&Vt.cluster?bt+Vt.point_count<=yt?bt+=Vt.point_count:bt=this._appendLeaves(Se,Vt.cluster_id,Xe,yt,bt):bt1;let Is,bs,or;if(Xt)Is=We(Fe,Vt,this.clusterProps),bs=Fe[Vt],or=Fe[Vt+1];else{const zr=this.points[Fe[Vt+3]];Is=zr.properties;const[hn,Wn]=zr.geometry.coordinates;bs=Ke(hn),or=ot(Wn)}const Rr={type:1,geometry:[[Math.round(this.options.extent*(bs*bt-Xe)),Math.round(this.options.extent*(or*bt-yt))]],tags:Is};let Wr;Wr=Xt||this.options.generateId?Fe[Vt+3]:this.points[Fe[Vt+3]].id,Wr!==void 0&&(Rr.id=Wr),At.features.push(Rr)}}_limitZoom(Se){return Math.max(this.options.minZoom,Math.min(Math.floor(+Se),this.options.maxZoom+1))}_cluster(Se,Fe){const{radius:Xe,extent:yt,reduce:bt,minPoints:At}=this.options,Gt=Xe/(yt*Math.pow(2,Fe)),Vt=Se.data,Xt=[],Is=this.stride;for(let bs=0;bsFe&&(hn+=Vt[sa+5])}if(hn>zr&&hn>=At){let Wn,sa=or*zr,ua=Rr*zr,To=-1;const wo=(bs/Is<<5)+(Fe+1)+this.points.length;for(const Yi of Wr){const ii=Yi*Is;if(Vt[ii+2]<=Fe)continue;Vt[ii+2]=Fe;const $i=Vt[ii+5];sa+=Vt[ii]*$i,ua+=Vt[ii+1]*$i,Vt[ii+4]=wo,bt&&(Wn||(Wn=this._map(Vt,bs,!0),To=this.clusterProps.length,this.clusterProps.push(Wn)),bt(Wn,this._map(Vt,ii)))}Vt[bs+4]=wo,Xt.push(sa/hn,ua/hn,1/0,wo,-1,hn),bt&&Xt.push(To)}else{for(let Wn=0;Wn1)for(const Wn of Wr){const sa=Wn*Is;if(!(Vt[sa+2]<=Fe)){Vt[sa+2]=Fe;for(let ua=0;ua>5}_getOriginZoom(Se){return(Se-this.points.length)%32}_map(Se,Fe,Xe){if(Se[Fe+5]>1){const At=this.clusterProps[Se[Fe+6]];return Xe?Object.assign({},At):At}const yt=this.points[Se[Fe+3]].properties,bt=this.options.map(yt);return Xe&&bt===yt?Object.assign({},bt):bt}}function Te($t,Se,Fe){return{type:"Feature",id:$t[Se+3],properties:We($t,Se,Fe),geometry:{type:"Point",coordinates:[(Xe=$t[Se],360*(Xe-.5)),He($t[Se+1])]}};var Xe}function We($t,Se,Fe){const Xe=$t[Se+5],yt=Xe>=1e4?`${Math.round(Xe/1e3)}k`:Xe>=1e3?Math.round(Xe/100)/10+"k":Xe,bt=$t[Se+6],At=bt===-1?{}:Object.assign({},Fe[bt]);return Object.assign(At,{cluster:!0,cluster_id:$t[Se+3],point_count:Xe,point_count_abbreviated:yt})}function Ke($t){return $t/360+.5}function ot($t){const Se=Math.sin($t*Math.PI/180),Fe=.5-.25*Math.log((1+Se)/(1-Se))/Math.PI;return Fe<0?0:Fe>1?1:Fe}function He($t){const Se=(180-360*$t)*Math.PI/180;return 360*Math.atan(Math.exp(Se))/Math.PI-90}function Je($t,Se,Fe,Xe){let yt=Xe;const bt=Se+(Fe-Se>>1);let At,Gt=Fe-Se;const Vt=$t[Se],Xt=$t[Se+1],Is=$t[Fe],bs=$t[Fe+1];for(let or=Se+3;oryt)At=or,yt=Rr;else if(Rr===yt){const Wr=Math.abs(or-bt);WrXe&&(At-Se>3&&Je($t,Se,At,Xe),$t[At+2]=yt,Fe-At>3&&Je($t,At,Fe,Xe))}function ut($t,Se,Fe,Xe,yt,bt){let At=yt-Fe,Gt=bt-Xe;if(At!==0||Gt!==0){const Vt=(($t-Fe)*At+(Se-Xe)*Gt)/(At*At+Gt*Gt);Vt>1?(Fe=yt,Xe=bt):Vt>0&&(Fe+=At*Vt,Xe+=Gt*Vt)}return At=$t-Fe,Gt=Se-Xe,At*At+Gt*Gt}function mt($t,Se,Fe,Xe){const yt={id:$t??null,type:Se,geometry:Fe,tags:Xe,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(Se==="Point"||Se==="MultiPoint"||Se==="LineString")et(yt,Fe);else if(Se==="Polygon")et(yt,Fe[0]);else if(Se==="MultiLineString")for(const bt of Fe)et(yt,bt);else if(Se==="MultiPolygon")for(const bt of Fe)et(yt,bt[0]);return yt}function et($t,Se){for(let Fe=0;Fe0&&(At+=Xe?(yt*Is-Xt*bt)/2:Math.sqrt(Math.pow(Xt-yt,2)+Math.pow(Is-bt,2))),yt=Xt,bt=Is}const Gt=Se.length-3;Se[2]=1,Je(Se,0,Gt,Fe),Se[Gt+2]=1,Se.size=Math.abs(At),Se.start=0,Se.end=Se.size}function Nt($t,Se,Fe,Xe){for(let yt=0;yt<$t.length;yt++){const bt=[];Ut($t[yt],bt,Fe,Xe),Se.push(bt)}}function es($t){return $t/360+.5}function ds($t){const Se=Math.sin($t*Math.PI/180),Fe=.5-.25*Math.log((1+Se)/(1-Se))/Math.PI;return Fe<0?0:Fe>1?1:Fe}function js($t,Se,Fe,Xe,yt,bt,At,Gt){if(Xe/=Se,bt>=(Fe/=Se)&&At=Xe)return null;const Vt=[];for(const Xt of $t){const Is=Xt.geometry;let bs=Xt.type;const or=yt===0?Xt.minX:Xt.minY,Rr=yt===0?Xt.maxX:Xt.maxY;if(or>=Fe&&Rr=Xe)continue;let Wr=[];if(bs==="Point"||bs==="MultiPoint")lr(Is,Wr,Fe,Xe,yt);else if(bs==="LineString")Lt(Is,Wr,Fe,Xe,yt,!1,Gt.lineMetrics);else if(bs==="MultiLineString")fr(Is,Wr,Fe,Xe,yt,!1);else if(bs==="Polygon")fr(Is,Wr,Fe,Xe,yt,!0);else if(bs==="MultiPolygon")for(const zr of Is){const hn=[];fr(zr,hn,Fe,Xe,yt,!0),hn.length&&Wr.push(hn)}if(Wr.length){if(Gt.lineMetrics&&bs==="LineString"){for(const zr of Wr)Vt.push(mt(Xt.id,bs,zr,Xt.tags));continue}bs!=="LineString"&&bs!=="MultiLineString"||(Wr.length===1?(bs="LineString",Wr=Wr[0]):bs="MultiLineString"),bs!=="Point"&&bs!=="MultiPoint"||(bs=Wr.length===3?"Point":"MultiPoint"),Vt.push(mt(Xt.id,bs,Wr,Xt.tags))}}return Vt.length?Vt:null}function lr($t,Se,Fe,Xe,yt){for(let bt=0;bt<$t.length;bt+=3){const At=$t[bt+yt];At>=Fe&&At<=Xe&&Hs(Se,$t[bt],$t[bt+1],$t[bt+2])}}function Lt($t,Se,Fe,Xe,yt,bt,At){let Gt=Es($t);const Vt=yt===0?mr:an;let Xt,Is,bs=$t.start;for(let hn=0;hn<$t.length-3;hn+=3){const Wn=$t[hn],sa=$t[hn+1],ua=$t[hn+2],To=$t[hn+3],wo=$t[hn+4],Yi=yt===0?Wn:sa,ii=yt===0?To:wo;let $i=!1;At&&(Xt=Math.sqrt(Math.pow(Wn-To,2)+Math.pow(sa-wo,2))),YiFe&&(Is=Vt(Gt,Wn,sa,To,wo,Fe),At&&(Gt.start=bs+Xt*Is)):Yi>Xe?ii=Fe&&(Is=Vt(Gt,Wn,sa,To,wo,Fe),$i=!0),ii>Xe&&Yi<=Xe&&(Is=Vt(Gt,Wn,sa,To,wo,Xe),$i=!0),!bt&&$i&&(At&&(Gt.end=bs+Xt*Is),Se.push(Gt),Gt=Es($t)),At&&(bs+=Xt)}let or=$t.length-3;const Rr=$t[or],Wr=$t[or+1],zr=yt===0?Rr:Wr;zr>=Fe&&zr<=Xe&&Hs(Gt,Rr,Wr,$t[or+2]),or=Gt.length-3,bt&&or>=3&&(Gt[or]!==Gt[0]||Gt[or+1]!==Gt[1])&&Hs(Gt,Gt[0],Gt[1],Gt[2]),Gt.length&&Se.push(Gt)}function Es($t){const Se=[];return Se.size=$t.size,Se.start=$t.start,Se.end=$t.end,Se}function fr($t,Se,Fe,Xe,yt,bt){for(const At of $t)Lt(At,Se,Fe,Xe,yt,bt,!1)}function Hs($t,Se,Fe,Xe){$t.push(Se,Fe,Xe)}function mr($t,Se,Fe,Xe,yt,bt){const At=(bt-Se)/(Xe-Se);return Hs($t,bt,Fe+(yt-Fe)*At,1),At}function an($t,Se,Fe,Xe,yt,bt){const At=(bt-Fe)/(yt-Fe);return Hs($t,Se+(Xe-Se)*At,bt,1),At}function Cr($t,Se){const Fe=[];for(let Xe=0;Xe<$t.length;Xe++){const yt=$t[Xe],bt=yt.type;let At;if(bt==="Point"||bt==="MultiPoint"||bt==="LineString")At=Fr(yt.geometry,Se);else if(bt==="MultiLineString"||bt==="Polygon"){At=[];for(const Gt of yt.geometry)At.push(Fr(Gt,Se))}else if(bt==="MultiPolygon"){At=[];for(const Gt of yt.geometry){const Vt=[];for(const Xt of Gt)Vt.push(Fr(Xt,Se));At.push(Vt)}}Fe.push(mt(yt.id,bt,At,yt.tags))}return Fe}function Fr($t,Se){const Fe=[];Fe.size=$t.size,$t.start!==void 0&&(Fe.start=$t.start,Fe.end=$t.end);for(let Xe=0;Xe<$t.length;Xe+=3)Fe.push($t[Xe]+Se,$t[Xe+1],$t[Xe+2]);return Fe}function $r($t,Se){if($t.transformed)return $t;const Fe=1<<$t.z,Xe=$t.x,yt=$t.y;for(const bt of $t.features){const At=bt.geometry,Gt=bt.type;if(bt.geometry=[],Gt===1)for(let Vt=0;Vt0&&Se.size<(yt?At:Xe))return void(Fe.numPoints+=Se.length/3);const Gt=[];for(let Vt=0;VtAt)&&(Fe.numSimplified++,Gt.push(Se[Vt],Se[Vt+1])),Fe.numPoints++;yt&&function(Vt,Xt){let Is=0;for(let bs=0,or=Vt.length,Rr=or-2;bs0===Xt)for(let bs=0,or=Vt.length;bs24)throw new Error("maxZoom should be in the 0-24 range");if(Fe.promoteId&&Fe.generateId)throw new Error("promoteId and generateId cannot be used together.");let yt=function(bt,At){const Gt=[];if(bt.type==="FeatureCollection")for(let Vt=0;Vt1&&console.time("creation"),Rr=this.tiles[or]=cr(Se,Fe,Xe,yt,Xt),this.tileCoords.push({z:Fe,x:Xe,y:yt}),Is)){Is>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",Fe,Xe,yt,Rr.numFeatures,Rr.numPoints,Rr.numSimplified),console.timeEnd("creation"));const $i=`z${Fe}`;this.stats[$i]=(this.stats[$i]||0)+1,this.total++}if(Rr.source=Se,bt==null){if(Fe===Xt.indexMaxZoom||Rr.numPoints<=Xt.indexMaxPoints)continue}else{if(Fe===Xt.maxZoom||Fe===bt)continue;if(bt!=null){const $i=bt-Fe;if(Xe!==At>>$i||yt!==Gt>>$i)continue}}if(Rr.source=null,Se.length===0)continue;Is>1&&console.time("clipping");const Wr=.5*Xt.buffer/Xt.extent,zr=.5-Wr,hn=.5+Wr,Wn=1+Wr;let sa=null,ua=null,To=null,wo=null,Yi=js(Se,bs,Xe-Wr,Xe+hn,0,Rr.minX,Rr.maxX,Xt),ii=js(Se,bs,Xe+zr,Xe+Wn,0,Rr.minX,Rr.maxX,Xt);Se=null,Yi&&(sa=js(Yi,bs,yt-Wr,yt+hn,1,Rr.minY,Rr.maxY,Xt),ua=js(Yi,bs,yt+zr,yt+Wn,1,Rr.minY,Rr.maxY,Xt),Yi=null),ii&&(To=js(ii,bs,yt-Wr,yt+hn,1,Rr.minY,Rr.maxY,Xt),wo=js(ii,bs,yt+zr,yt+Wn,1,Rr.minY,Rr.maxY,Xt),ii=null),Is>1&&console.timeEnd("clipping"),Vt.push(sa||[],Fe+1,2*Xe,2*yt),Vt.push(ua||[],Fe+1,2*Xe,2*yt+1),Vt.push(To||[],Fe+1,2*Xe+1,2*yt),Vt.push(wo||[],Fe+1,2*Xe+1,2*yt+1)}}getTile(Se,Fe,Xe){Se=+Se,Fe=+Fe,Xe=+Xe;const yt=this.options,{extent:bt,debug:At}=yt;if(Se<0||Se>24)return null;const Gt=1<1&&console.log("drilling down to z%d-%d-%d",Se,Fe,Xe);let Xt,Is=Se,bs=Fe,or=Xe;for(;!Xt&&Is>0;)Is--,bs>>=1,or>>=1,Xt=this.tiles[as(Is,bs,or)];return Xt&&Xt.source?(At>1&&(console.log("found parent tile z%d-%d-%d",Is,bs,or),console.time("drilling down")),this.splitTile(Xt.source,Is,bs,or,Se,Fe,Xe),At>1&&console.timeEnd("drilling down"),this.tiles[Vt]?$r(this.tiles[Vt],bt):null):null}}function as($t,Se,Fe){return 32*((1<<$t)*Fe+Se)+$t}function qn($t,Se){const Fe=$t.tileID.canonical;if(!this._geoJSONIndex)return void Se(null,null);const Xe=this._geoJSONIndex.getTile(Fe.z,Fe.x,Fe.y);if(!Xe)return void Se(null,null);const yt=Xt=>Xt.tags&&"3d_elevation_id"in Xt.tags&&"source"in Xt.tags&&Xt.tags.source==="elevation",bt=Xe.features.filter(Xt=>yt(Xt));let At={_geojsonTileLayer:Xe.features};bt.length>0&&(At={_geojsonTileLayer:Xe.features.filter(Xt=>!yt(Xt)),hd_road_elevation:bt});const Gt=new ie(At),Vt=function(Xt){const Is=new d.a$;for(const bs of Object.keys(Xt))Is.writeMessage(3,Re,{name:bs,features:Xt[bs]});return Is.finish()}(At).buffer;Se(null,{vectorTile:Gt,rawData:Vt})}class un extends B{constructor(Se){super(Se),this.loadVectorData=qn,this._dynamicIndex=new oe}loadData(Se,Fe){const Xe=Se&&Se.request,yt=Xe&&Xe.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(Se,(bt,At)=>{if(bt||!At)return Fe(bt);if(typeof At!="object")return Fe(new Error(`Input data given to '${Se.source}' is not a valid GeoJSON object.`));{try{if(Se.filter){const Vt=d.X(Se.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(Vt.result==="error")throw new Error(Vt.value.map(Xt=>`${Xt.key}: ${Xt.message}`).join(", "));At.features=At.features.filter(Xt=>Vt.value.evaluate({zoom:0},Xt))}Se.dynamic?(At.type==="Feature"&&(At={type:"FeatureCollection",features:[At]}),Se.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(At.features,this.loaded),Se.cluster&&(At.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=Se.cluster?new tt(function({superclusterOptions:Vt,clusterProperties:Xt}){if(!Xt||!Vt)return Vt;const Is={},bs={},or={accumulated:null,zoom:0},Rr={properties:null},Wr=Object.keys(Xt);for(const zr of Wr){const[hn,Wn]=Xt[zr],sa=d.X(Wn),ua=d.X(typeof hn=="string"?[hn,["accumulated"],["get",zr]]:hn);Is[zr]=sa.value,bs[zr]=ua.value}return Vt.map=zr=>{Rr.properties=zr;const hn={};for(const Wn of Wr)hn[Wn]=Is[Wn].evaluate(or,Rr);return hn},Vt.reduce=(zr,hn)=>{Rr.properties=hn;for(const Wn of Wr)or.accumulated=zr[Wn],zr[Wn]=bs[Wn].evaluate(or,Rr)},Vt}(Se)).load(At.features):Se.dynamic?this._dynamicIndex:function(Vt,Xt){return new ai(Vt,Xt)}(At,Se.geojsonVtOptions)}catch(Vt){return Fe(Vt)}const Gt={};if(yt){const Vt=u(Xe);Vt&&(Gt.resourceTiming={},Gt.resourceTiming[Se.source]=JSON.parse(JSON.stringify(Vt)))}Fe(null,Gt)}})}reloadTile(Se,Fe){const Xe=this.loaded;return Xe&&Xe[Se.uid]?Se.partial?Fe(null,void 0):super.reloadTile(Se,Fe):this.loadTile(Se,Fe)}loadGeoJSON(Se,Fe){if(Se.request)d.m(Se.request,Fe);else{if(typeof Se.data!="string")return Fe(new Error(`Input data given to '${Se.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return Fe(null,JSON.parse(Se.data))}catch{return Fe(new Error(`Input data given to '${Se.source}' is not a valid GeoJSON object.`))}},0)}}getClusterExpansionZoom(Se,Fe){try{Fe(null,this._geoJSONIndex.getClusterExpansionZoom(Se.clusterId))}catch(Xe){Fe(Xe)}}getClusterChildren(Se,Fe){try{Fe(null,this._geoJSONIndex.getChildren(Se.clusterId))}catch(Xe){Fe(Xe)}}getClusterLeaves(Se,Fe){try{Fe(null,this._geoJSONIndex.getLeaves(Se.clusterId,Se.limit,Se.offset))}catch(Xe){Fe(Xe)}}}class qr{constructor(Se,Fe,Xe){this.tileID=new d.aR(Se.tileID.overscaledZ,Se.tileID.wrap,Se.tileID.canonical.z,Se.tileID.canonical.x,Se.tileID.canonical.y),this.tileZoom=Se.tileZoom,this.uid=Se.uid,this.zoom=Se.zoom,this.canonical=Se.tileID.canonical,this.pixelRatio=Se.pixelRatio,this.tileSize=Se.tileSize,this.source=Se.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=Se.projection,this.brightness=Fe,this.worldview=Xe}parse(Se,Fe,Xe,yt){this.status="parsing";const bt=new d.aR(Xe.tileID.overscaledZ,Xe.tileID.wrap,Xe.tileID.canonical.z,Xe.tileID.canonical.x,Xe.tileID.canonical.y),At=[],Gt=Fe.familiesBySource[Xe.source],Vt=new d.ff(bt,Xe.promoteId);Vt.bucketLayerIDs=[],Vt.is3DTile=!0,d.fB(Se).then(Xt=>{const Is=Xt.json.extensionsUsed&&Xt.json.extensionsUsed.includes("MAPBOX_mesh_features")||Xt.json.asset.extras&&Xt.json.asset.extras.MAPBOX_mesh_features,bs=Xt.json.extensionsUsed&&Xt.json.extensionsUsed.includes("EXT_meshopt_compression"),or=new d.ae(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const Rr in Gt)for(const Wr of Gt[Rr]){const zr=Wr[0];Vt.bucketLayerIDs.push(Wr.map(sa=>d.F(sa.id,sa.scope))),zr.recalculate(or,[]);const hn=d.fC(Xt,1/d.cS(Xe.tileID.canonical)),Wn=new d.fD(Wr,hn,bt,Is,bs,this.brightness,Vt,this.worldview);Is||(Wn.needsUpload=!0),At.push(Wn),Wn.evaluate(zr)}this.status="done",yt(null,{buckets:At,featureIndex:Vt,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(Xt=>yt(new Error(Xt.message)))}}class Zr{constructor({actor:Se,layerIndex:Fe,availableImages:Xe,availableModels:yt,brightness:bt,worldview:At}){this.actor=Se,this.layerIndex=Fe,this.availableImages=Xe,this.availableModels=yt,this.brightness=bt,this.loading={},this.loaded={},this.worldview=At}loadTile(Se,Fe){const Xe=Se.uid,yt=this.loading[Xe]=new qr(Se,this.brightness,this.worldview);d.b1(Se.request,(bt,At)=>{const Gt=!this.loading[Xe];return delete this.loading[Xe],Gt||bt?(yt.status="done",Gt||(this.loaded[Xe]=yt),Fe(bt)):At&&At.byteLength!==0?void yt.parse(At,this.layerIndex,Se,(Vt,Xt)=>{yt.status="done",this.loaded=this.loaded||{},this.loaded[Xe]=yt,Vt||!Xt?Fe(Vt):Fe(null,Xt)}):(yt.status="done",this.loaded[Xe]=yt,Fe())})}reloadTile(Se,Fe){const Xe=this.loaded,yt=Se.uid;if(Xe&&Xe[yt]){const bt=Xe[yt];bt.projection=Se.projection,bt.brightness=Se.brightness;const At=(Gt,Vt)=>{bt.reloadCallback&&(delete bt.reloadCallback,this.loadTile(Se,Fe)),Fe(Gt,Vt)};bt.status==="parsing"?bt.reloadCallback=At:bt.status==="done"&&this.loadTile(Se,Fe)}}abortTile(Se,Fe){const Xe=Se.uid;this.loading[Xe]&&delete this.loading[Xe],Fe()}removeTile(Se,Fe){const Xe=this.loaded,yt=Se.uid;Xe&&Xe[yt]&&delete Xe[yt],Fe()}}const La=new Map,Yt=new Map;class Lr{constructor(Se){this.self=Se,this.actor=new d.A(Se,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.imageRasterizer=new d.z,this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=d.c0({name:"mercator"}),this.workerSourceTypes={vector:B,geojson:un,"raster-dem":U,"raster-array":Y,"batched-model":Zr},this.workerSources={},this.self.registerWorkerSource=(Fe,Xe)=>{if(this.workerSourceTypes[Fe])throw new Error(`Worker source with name "${Fe}" already registered.`);this.workerSourceTypes[Fe]=Xe},this.self.registerRTLTextPlugin=Fe=>{if(d.fF.isParsed())throw new Error("RTL text plugin already registered.");d.fF.setState({pluginStatus:d.fG.parsed,pluginURL:d.fF.getPluginURL()}),d.fF.applyArabicShaping=Fe.applyArabicShaping,d.fF.processBidirectionalText=Fe.processBidirectionalText,d.fF.processStyledBidirectionalText=Fe.processStyledBidirectionalText;for(const Xe of this.rtlPluginParsingListeners)Xe(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(Se,Fe,Xe){delete this.layerIndexes[Se],delete this.availableImages[Se],delete this.availableModels[Se],delete this.workerSources[Se],Xe()}checkIfReady(Se,Fe,Xe){Xe()}setReferrer(Se,Fe){this.referrer=Fe}spriteLoaded(Se,Fe){this.isSpriteLoaded[Se]||(this.isSpriteLoaded[Se]={});const{scope:Xe,isLoaded:yt}=Fe;if(this.isSpriteLoaded[Se][Xe]=yt,this.workerSources[Se]&&this.workerSources[Se][Xe])for(const bt in this.workerSources[Se][Xe]){const At=this.workerSources[Se][Xe][bt];for(const Gt in At){const Vt=At[Gt];Vt instanceof B&&(Vt.isSpriteLoaded=yt,Vt.fire(new d.C("isSpriteLoaded")))}}}setImages(Se,Fe,Xe){this.availableImages[Se]||(this.availableImages[Se]={});const{scope:yt,images:bt}=Fe;if(this.availableImages[Se][yt]=bt,this.workerSources[Se]&&this.workerSources[Se][yt]){for(const At in this.workerSources[Se][yt]){const Gt=this.workerSources[Se][yt][At];for(const Vt in Gt)Gt[Vt].availableImages=bt}Xe()}else Xe()}setModels(Se,{scope:Fe,models:Xe},yt){if(this.availableModels[Se]||(this.availableModels[Se]={}),this.availableModels[Se][Fe]=Xe,this.workerSources[Se]&&this.workerSources[Se][Fe]){for(const bt in this.workerSources[Se][Fe]){const At=this.workerSources[Se][Fe][bt];for(const Gt in At)At[Gt].availableModels=Xe}yt()}else yt()}setProjection(Se,Fe){this.projections[Se]=d.c0(Fe)}setBrightness(Se,Fe,Xe){this.brightness=Fe,Xe()}setContextParams(Se,Fe,Xe){this.maxUniformBufferBindings=Fe.maxBindingPoints,this.maxUniformBlockSizeDwords=Fe.maxUniformBlockSizeDwords,this.disableSymbolUBO=Fe.disableSymbolUBO,Xe()}setWorldview(Se,Fe,Xe){this.worldview=Fe,Xe()}setLayers(Se,Fe,Xe){this.getLayerIndex(Se,Fe.scope).replace(Fe.layers,Fe.options),Xe()}updateLayers(Se,Fe,Xe){this.getLayerIndex(Se,Fe.scope).update(Fe.layers,Fe.removedIds,Fe.options),Xe()}loadTile(Se,Fe,Xe){Fe.projection=this.projections[Se]||this.defaultProjection,this.getWorkerSource(Se,Fe).loadTile(Fe,Xe)}decodeRasterArray(Se,Fe,Xe){this.getWorkerSource(Se,Fe).decodeRasterArray(Fe,Xe)}reloadTile(Se,Fe,Xe){Fe.projection=this.projections[Se]||this.defaultProjection,this.getWorkerSource(Se,Fe).reloadTile(Fe,Xe)}abortTile(Se,Fe,Xe){this.getWorkerSource(Se,Fe).abortTile(Fe,Xe)}removeTile(Se,Fe,Xe){this.getWorkerSource(Se,Fe).removeTile(Fe,Xe)}removeSource(Se,Fe,Xe){if(!(this.workerSources[Se]&&this.workerSources[Se][Fe.scope]&&this.workerSources[Se][Fe.scope][Fe.type]&&this.workerSources[Se][Fe.scope][Fe.type][Fe.source]))return;const yt=this.workerSources[Se][Fe.scope][Fe.type][Fe.source];delete this.workerSources[Se][Fe.scope][Fe.type][Fe.source],yt.removeSource!==void 0?yt.removeSource(Fe,Xe):Xe()}loadTileProvider(Se,Fe,Xe){(async function(yt,bt){const At=Yt.get(yt);if(At)return At;const Gt=La.get(yt);if(Gt!==void 0)return Gt;const Vt=import(bt).then(Xt=>{const Is=Xt.default;if(typeof Is!="function")throw new Error(`TileProvider "${yt}" module must default-export a class`);if(typeof Is.prototype.loadTile!="function")throw new Error(`TileProvider "${yt}" class must have a loadTile method`);return Yt.set(yt,Is),Is}).finally(()=>{La.delete(yt)});return La.set(yt,Vt),Vt})(Fe.name,Fe.url).then(yt=>{const bt=new yt(Fe.options);return this.getWorkerSource(Se,{type:Fe.type,source:Fe.source,scope:Fe.scope},bt),bt.load&&Fe.request?bt.load({request:Fe.request}):null}).then(yt=>Xe(null,yt)).catch(yt=>Xe(yt instanceof Error?yt:new Error(typeof yt=="string"?yt:"Unknown error")))}loadWorkerSource(Se,Fe,Xe){try{this.self.importScripts(Fe.url),Xe()}catch(yt){Xe(yt)}}syncRTLPluginState(Se,Fe,Xe){if(d.fF.isParsed())Xe(null,!0);else if(d.fF.isParsing())this.rtlPluginParsingListeners.push(Xe);else try{d.fF.setState(Fe);const yt=d.fF.getPluginURL();!d.fF.isLoaded()||d.fF.isParsed()||d.fF.isParsing()||yt==null||(d.fF.setState({pluginStatus:d.fG.parsing,pluginURL:d.fF.getPluginURL()}),this.self.importScripts(yt),d.fF.isParsed()?Xe(null,!0):this.rtlPluginParsingListeners.push(Xe))}catch(yt){Xe(yt)}}setConfig(Se,Fe){Object.assign(d.g,Fe)}getAvailableImages(Se,Fe){this.availableImages[Se]||(this.availableImages[Se]={});let Xe=this.availableImages[Se][Fe];return Xe||(Xe=[]),Xe}getAvailableModels(Se,Fe){this.availableModels[Se]||(this.availableModels[Se]={});let Xe=this.availableModels[Se][Fe];return Xe||(Xe={}),Xe}getLayerIndex(Se,Fe){this.layerIndexes[Se]||(this.layerIndexes[Se]={});let Xe=this.layerIndexes[Se][Fe];return Xe||(Xe=this.layerIndexes[Se][Fe]=new _,Xe.scope=Fe),Xe}getWorkerSource(Se,Fe,Xe){const{type:yt,source:bt,scope:At}=Fe,Gt=this.workerSources;if(Gt[Se]||(Gt[Se]={}),Gt[Se][At]||(Gt[Se][At]={}),Gt[Se][At][yt]||(Gt[Se][At][yt]={}),this.isSpriteLoaded[Se]||(this.isSpriteLoaded[Se]={}),!Gt[Se][At][yt][bt]){const Vt={send:(Is,bs,or,Rr,Wr,zr)=>this.actor.send(Is,bs,or,Se,Wr,zr),scheduler:this.actor.scheduler},Xt=this.workerSourceTypes[yt];if(!Xt)throw new Error(`Unknown worker source type "${yt}".`);Gt[Se][At][yt][bt]=new Xt({actor:Vt,layerIndex:this.getLayerIndex(Se,At),availableImages:this.getAvailableImages(Se,At),availableModels:this.getAvailableModels(Se,At),isSpriteLoaded:this.isSpriteLoaded[Se][At],tileProvider:Xe,brightness:this.brightness,worldview:this.worldview,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords,disableSymbolUBO:this.disableSymbolUBO})}return Gt[Se][At][yt][bt]}rasterizeImagesWorker(Se,Fe,Xe){const yt=new Map;for(const[bt,{image:At,imageVariant:Gt}]of Fe.tasks.entries()){const Vt=this.imageRasterizer.rasterize(Gt,At,Fe.scope,Se);yt.set(bt,Vt)}Xe(void 0,yt)}removeRasterizedImages(Se,Fe,Xe){this.imageRasterizer.removeImagesFromCacheByIds(Fe.imageIds,Fe.scope,Se),Xe()}enforceCacheSizeLimit(Se,Fe){d.fH(Fe)}getWorkerPerformanceMetrics(Se,Fe,Xe){Xe(void 0,void 0)}}return d.fE(self)&&(self.worker=new Lr(self)),Lr}),o(["./shared"],function(i){var d="3.22.0";const u={create:"create",load:"load",fullLoad:"fullLoad"},p={mark(M){performance.mark(M)},measure(M,m,v){performance.measure(M,m,v)}};function f(M){const m=M.name.split("?")[0];return i.a(m)&&m.includes("mapbox-gl.js")?"javascript":i.a(m)&&m.includes("mapbox-gl.css")?"css":i.b(m)?"fontRange":i.c(m)?"sprite":i.i(m)?"style":i.d(m)?"tilejson":"other"}var y,_={},b=function(){if(y)return _;function M(E){return!m(E)}function m(E){return typeof window>"u"||typeof document>"u"?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var z,$,K=new Blob([""],{type:"text/javascript"}),ee=URL.createObjectURL(K);try{$=new Worker(ee),z=!0}catch{z=!1}return $&&$.terminate(),URL.revokeObjectURL(ee),z}()?function(){var z=document.createElement("canvas");z.width=z.height=1;var $=z.getContext("2d");if(!$)return!1;var K=$.getImageData(0,0,1,1);return K&&K.width===z.width}()?(v[D=E&&E.failIfMajorPerformanceCaveat]===void 0&&(v[D]=function(z){var $,K=function(ee){var ne=document.createElement("canvas"),de=Object.create(M.webGLContextAttributes);return de.failIfMajorPerformanceCaveat=ee,ne.getContext("webgl2",de)}(z);if(!K)return!1;try{$=K.createShader(K.VERTEX_SHADER)}catch{return!1}return!(!$||K.isContextLost())&&(K.shaderSource($,"void main() {}"),K.compileShader($),K.getShaderParameter($,K.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}y=1,_.supported=M,_.notSupportedReason=m;var v={};return M.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},_}();function N(M,m,v){const E=document.createElement(M);return m!=null&&(E.className=m),v&&v.appendChild(E),E}function w(M,m,v){const E=document.createElementNS("http://www.w3.org/2000/svg",M);for(const D of Object.keys(m))E.setAttributeNS(null,D,String(m[D]));return v&&v.appendChild(E),E}const S=typeof document<"u"?document.documentElement&&document.documentElement.style:null,C=S&&S.userSelect!==void 0?"userSelect":"WebkitUserSelect";let A;function I(){S&&C&&(A=S[C],S[C]="none")}function L(){S&&C&&(S[C]=A)}function O(M){M.preventDefault(),M.stopPropagation(),window.removeEventListener("click",O,!0)}function V(){window.addEventListener("click",O,!0),window.setTimeout(()=>{window.removeEventListener("click",O,!0)},0)}function q(M,m){const v=M.getBoundingClientRect();return te(M,v,m)}function B(M,m){const v=M.getBoundingClientRect(),E=[];for(let D=0;Dthis._skuTokenExpiresAt}transformRequest(m,v){return this._transformRequestFn&&this._transformRequestFn(m,v)||{url:m}}normalizeStyleURL(m,v){if(!i.e(m))return m;const E=ie(m);return E.params.push(`sdk=js-${d}`),E.path=`/styles/v1${E.path}`,this._makeAPIURL(E,this._customAccessToken||v)}normalizeGlyphsURL(m,v){if(!i.e(m))return m;const E=ie(m);return E.path=`/fonts/v1${E.path}`,this._makeAPIURL(E,this._customAccessToken||v)}normalizeModelURL(m,v){if(!i.e(m))return m;const E=ie(m);return E.path=`/models/v1${E.path}`,this._makeAPIURL(E,this._customAccessToken||v)}normalizeSourceURL(m,v,E,D){if(!i.e(m))return m;const z=ie(m);return z.path=`/v4/${z.authority}.json`,z.params.push("secure"),E&&z.params.push(`language=${E}`),D&&z.params.push(`worldview=${D}`),this._makeAPIURL(z,this._customAccessToken||v)}normalizeIconsetURL(m,v){const E=ie(m);return i.e(m)?(E.path=`/styles/v1${E.path}/iconset.pbf`,this._makeAPIURL(E,this._customAccessToken||v)):ae(E)}normalizeSpriteURL(m,v,E,D){const z=ie(m);return i.e(m)?(z.path=`/styles/v1${z.path}/sprite${v}${E}`,this._makeAPIURL(z,this._customAccessToken||D)):(z.path+=`${v}${E}`,ae(z))}normalizeTileURL(m,v,E){if(this._isSkuTokenExpired()&&this._createSkuToken(),m&&!i.e(m))return m;const D=ie(m);D.path=D.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${v||E&&D.authority!=="raster"&&E===512?"@2x":""}${i.k.supported?".webp":"$1"}`),D.authority==="raster"?D.path=`/${i.g.RASTER_URL_PREFIX}${D.path}`:D.authority==="rasterarrays"?D.path=`/${i.g.RASTERARRAYS_URL_PREFIX}${D.path}`:D.authority==="3dtiles"?D.path=`/${i.g.TILES3D_URL_PREFIX}${D.path}`:(D.path=D.path.replace(/^.+\/v4\//,"/"),D.path=`/${i.g.TILE_URL_VERSION}${D.path}`);const z=this._customAccessToken||function($){for(const K of $){const ee=K.match(/^access_token=(.*)$/);if(ee)return ee[1]}return null}(D.params)||i.g.ACCESS_TOKEN;return i.g.REQUIRE_ACCESS_TOKEN&&z&&this._skuToken&&D.params.push(`sku=${this._skuToken}`),this._makeAPIURL(D,z)}canonicalizeTileURL(m,v){const E=ie(m);if(!E.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!E.path.match(/\.[\w]+$/))return m;let D="mapbox://";E.path.match(/^\/raster\/v1\//)?D+=`raster/${E.path.replace(`/${i.g.RASTER_URL_PREFIX}/`,"")}`:E.path.match(/^\/rasterarrays\/v1\//)?D+=`rasterarrays/${E.path.replace(`/${i.g.RASTERARRAYS_URL_PREFIX}/`,"")}`:D+=`tiles/${E.path.replace(`/${i.g.TILE_URL_VERSION}/`,"")}`;let z=E.params;return v&&(z=z.filter($=>!$.match(/^access_token=/))),z.length&&(D+=`?${z.join("&")}`),D}canonicalizeTileset(m,v){const E=!!v&&i.e(v),D=[];for(const z of m.tiles||[])i.f(z)?D.push(this.canonicalizeTileURL(z,E)):D.push(z);return D}_makeAPIURL(m,v){const E="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",D=ie(i.g.API_URL);if(m.protocol=D.protocol,m.authority=D.authority,m.protocol==="http"){const z=m.params.indexOf("secure");z>=0&&m.params.splice(z,1)}if(D.path!=="/"&&(m.path=`${D.path}${m.path}`),!i.g.REQUIRE_ACCESS_TOKEN)return ae(m);if(v=v||i.g.ACCESS_TOKEN,!this._silenceAuthErrors){if(!v)throw new Error(`An API access token is required to use Mapbox GL. ${E}`);if(v[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${E}`)}return m.params=m.params.filter(z=>z.indexOf("access_token")===-1),m.params.push(`access_token=${v||""}`),ae(m)}}const ce=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function ie(M){const m=M.match(ce);if(!m)throw new Error("Unable to parse URL object");return{protocol:m[1],authority:m[2],path:m[3]||"/",params:m[4]?m[4].split("&"):[]}}function ae(M){const m=M.params.length?`?${M.params.join("&")}`:"";return`${M.protocol}://${M.authority}${M.path}${m}`}const oe="mapbox.eventData";function me(M){if(!M)return null;const m=M.split(".");if(!m||m.length!==3)return null;try{return JSON.parse(i.l(m[1]))}catch{return null}}function ve(M){return!(!i.g.EVENTS_URL||!M&&!i.g.ACCESS_TOKEN)}class he{constructor(m){this.type=m,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(m){const v=me(i.g.ACCESS_TOKEN);let E="";return E=v&&v.u?i.j(v.u):i.g.ACCESS_TOKEN||"",m?`${oe}.${m}:${E}`:`${oe}:${E}`}fetchEventData(){const m=i.s("localStorage"),v=this.getStorageKey(),E=this.getStorageKey("uuid"),D=this.getStorageKey("uuidTimestamp");if(m)try{const z=localStorage.getItem(v);z&&(this.eventData=JSON.parse(z));const $=localStorage.getItem(E);$&&(this.anonId=$);const K=localStorage.getItem(D);K&&(this.anonIdTimestamp=Number(K));const ee=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp=1&&localStorage.setItem(v,JSON.stringify(this.eventData)),$&&localStorage.setItem(D,$.toString())}catch{i.w("Unable to write to LocalStorage")}}processRequests(m){}postEvent(m,v,E,D){if(!i.g.EVENTS_URL)return;const z=ie(i.g.EVENTS_URL);z.params.push(`access_token=${D||i.g.ACCESS_TOKEN||""}`);const $={event:this.type,created:new Date(m).toISOString()},K=v?Object.assign($,v):$,ee={url:ae(z),headers:{"Content-Type":"text/plain"},body:JSON.stringify([K])};this.pendingRequest=i.p(ee,ne=>{this.pendingRequest=null,E(ne),this.saveEventData(),this.processRequests(D)})}queueRequest(m,v){this.queue.push(m),this.processRequests(v)}}class ge extends he{constructor(m){super("metrics"),m&&(this.data=m)}postMetricsEvent(m){if(!ve(m))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},m)}processRequests(m){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:v,payload:E}=this.queue.shift();this.postEvent(v,E,()=>{},m)}}const je=new class extends he{constructor(M){super("appUserTurnstile"),this._customAccessToken=M}postTurnstileEvent(M,m){ve(m)&&Array.isArray(M)&&M.some(v=>i.e(v)||i.f(v))&&this.queueRequest(Date.now(),m)}processRequests(M){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const m=me(i.g.ACCESS_TOKEN),v=m?m.u:i.g.ACCESS_TOKEN;let E=v!==this.eventData.tokenU;i.v(this.anonId)||(this.refreshUUID(),E=!0);const D=this.queue.shift();if(this.eventData.lastSuccess){const z=new Date(this.eventData.lastSuccess),$=new Date(D),K=(D-this.eventData.lastSuccess)/864e5;E=E||K>=1||K<-1||z.getDate()!==$.getDate()}else E=!0;E?this.postEvent(D,{sdkIdentifier:"mapbox-gl-js",sdkVersion:d,skuId:Y,"enabled.telemetry":!1,userId:this.anonId},z=>{z||(this.eventData.lastSuccess=D,this.eventData.tokenU=v)},M):this.processRequests()}},qe=je.postTurnstileEvent.bind(je),Me=new class extends he{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(M,m,v,E){this.skuToken=m,this.errorCb=E,i.g.EVENTS_URL&&(v||i.g.ACCESS_TOKEN?this.queueRequest({id:M,timestamp:Date.now()},v):this.errorCb(new Error(J)))}processRequests(M){if(this.pendingRequest||this.queue.length===0)return;const{id:m,timestamp:v}=this.queue.shift();m&&this.success[m]||(this.anonId&&this.anonIdTimestamp||this.fetchEventData(),i.v(this.anonId)||this.refreshUUID(),this.postEvent(v,{sdkIdentifier:"mapbox-gl-js",sdkVersion:d,skuId:Y,skuToken:this.skuToken,userId:this.anonId},E=>{E?this.errorCb(E):m&&(this.success[m]=!0)},M))}remove(){this.errorCb=null}},ke=Me.postMapLoadEvent.bind(Me),Re=new class extends he{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(M){let m=this.mapInstanceIdMap.get(M);return m||(m=i.u(),this.mapInstanceIdMap.set(M,m)),m}getEventId(M){const m=this.eventIdPerMapInstanceMap.get(M)||0;return this.eventIdPerMapInstanceMap.set(M,m+1),m}postStyleLoadEvent(M,m){const{map:v,style:E,importedStyles:D}=m;if(!ve(M))return;const z=this.getMapInstanceId(v),$={mapInstanceId:z,eventId:this.getEventId(z),style:E};D.length&&($.importedStyles=D),this.queueRequest({timestamp:Date.now(),payload:$},M)}processRequests(M){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:m,payload:v}=this.queue.shift();this.postEvent(m,v,()=>{},M)}},Ve=Re.postStyleLoadEvent.bind(Re),Ne=new ge({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),Ue=Ne.postMetricsEvent.bind(Ne),Ie=new ge({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),ye=Ie.postMetricsEvent.bind(Ie),ct=new class extends he{constructor(){super("gljs.performance")}postPerformanceEvent(M,m){ve(M)&&this.queueRequest({timestamp:Date.now(),performanceData:m},M)}processRequests(M){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:m,performanceData:v}=this.queue.shift(),E=function(D){const z=performance.getEntriesByType("resource"),$=performance.getEntriesByType("mark"),K=function(Ae){const ze={};if(Ae){for(const Le in Ae)if(Le!=="other")for(const rt of Ae[Le]){const st=`${Le}ResolveRangeMin`,dt=`${Le}ResolveRangeMax`,pt=`${Le}RequestCount`,at=`${Le}RequestCachedCount`;ze[st]=Math.min(ze[st]||1/0,rt.startTime),ze[dt]=Math.max(ze[dt]||-1/0,rt.responseEnd);const Bt=wt=>{ze[wt]===void 0&&(ze[wt]=0),++ze[wt]};rt.transferSize!==void 0&&rt.transferSize===0&&Bt(at),Bt(pt)}}return ze}(function(Ae,ze){const Le={};if(Ae)for(const rt of Ae){const st=ze(rt);Le[st]===void 0&&(Le[st]=[]),Le[st].push(rt)}return Le}(z,f)),ee=window.devicePixelRatio,ne=navigator.connection||navigator.mozConnection||navigator.webkitConnection,de=ne?ne.effectiveType:void 0,we={counters:[],metadata:[],attributes:[]},be=(Ae,ze,Le)=>{Le!=null&&Ae.push({name:ze,value:Le.toString()})};for(const Ae in K)be(we.counters,Ae,K[Ae]);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])),$)for(const Ae of Object.values(u)){const ze=$.find(Le=>Le.name===Ae);ze&&be(we.counters,Ae,ze.startTime)}return be(we.counters,"visibilityHidden",D.visibilityHidden),be(we.attributes,"style",function(Ae){if(Ae)for(const ze of Ae){const Le=ze.name.split("?")[0];if(i.i(Le)){const rt=Le.split("/").slice(-2);if(rt.length===2)return`mapbox://styles/${rt[0]}/${rt[1]}`}}}(z)),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",de),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",d),be(we.metadata,"sdkIdentifier","mapbox-gl-js"),we}(v);for(const D of E.metadata);for(const D of E.counters);for(const D of E.attributes);this.postEvent(m,E,()=>{},M)}},fe=ct.postPerformanceEvent.bind(ct),$e=new class extends he{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(M,m,v,E){if(!i.g.API_URL||!i.g.SESSION_PATH)return;const D=ie(i.g.API_URL+i.g.SESSION_PATH);D.params.push(`sku=${m||""}`),D.params.push(`access_token=${E||i.g.ACCESS_TOKEN||""}`);const z={url:ae(D),headers:{"Content-Type":"text/plain"}};this.pendingRequest=i.h(z,$=>{this.pendingRequest=null,v($),this.saveEventData(),this.processRequests(E)})}getSessionAPI(M,m,v,E){this.skuToken=m,this.errorCb=E,i.g.EVENTS_URL&&i.g.SESSION_PATH&&i.g.API_URL&&(v||i.g.ACCESS_TOKEN?this.queueRequest({id:M,timestamp:Date.now()},v):this.errorCb(new Error(J)))}processRequests(M){if(this.pendingRequest||this.queue.length===0)return;const{id:m,timestamp:v}=this.queue.shift();m&&this.success[m]||this.getSession(v,this.skuToken,E=>{E?this.errorCb(E):m&&(this.success[m]=!0)},M)}remove(){this.errorCb=null}},Ye=$e.getSessionAPI.bind($e),tt=new Set;function Te(M,m){m?tt.add(M):tt.delete(M)}class We{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(m,v){this._updatedSourceCaches[m]=v,this.setDirty()}discardSourceCacheUpdate(m){delete this._updatedSourceCaches[m]}updateLayer(m){const v=m.scope;this._updatedLayers[v]=this._updatedLayers[v]||new Set,this._updatedLayers[v].add(m.id),this.setDirty()}removeLayer(m){const v=m.scope;this._removedLayers[v]=this._removedLayers[v]||{},this._updatedLayers[v]=this._updatedLayers[v]||new Set,this._removedLayers[v][m.id]=m,this._updatedLayers[v].delete(m.id),this._updatedPaintProps.delete(m.fqid),this.setDirty()}getRemovedLayer(m){return this._removedLayers[m.scope]?this._removedLayers[m.scope][m.id]:null}discardLayerRemoval(m){this._removedLayers[m.scope]&&delete this._removedLayers[m.scope][m.id]}getLayerUpdatesByScope(){const m={};for(const v in this._updatedLayers)m[v]=m[v]||{},m[v].updatedIds=Array.from(this._updatedLayers[v].values());for(const v in this._removedLayers)m[v]=m[v]||{},m[v].removedIds=Object.keys(this._removedLayers[v]);return m}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(m){this._updatedPaintProps.add(m.fqid),this.setDirty()}getUpdatedImages(m){return this._updatedImages[m]?Array.from(this._updatedImages[m].values()):[]}updateImage(m,v){this._updatedImages[v]=this._updatedImages[v]||new Set,this._updatedImages[v].add(i.I.toString(m)),this.setDirty()}resetUpdatedImages(m){this._updatedImages[m]&&this._updatedImages[m].clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages={}}}function Ke(M){const{userImage:m}=M;return!!(m&&m.render&&m.render())&&(M.data.replace(new Uint8Array(m.data.buffer)),!0)}const ot={workerUrl:"",workerClass:null,workerParams:void 0};function He(M){return ot.workerClass!=null?new ot.workerClass:new self.Worker(ot.workerUrl,Object.assign({name:M},ot.workerParams))}const Je="mapboxgl_preloaded_worker_pool";class ut{constructor(m){this.active={},this.name=m}acquire(m,v=ut.workerCount){if(!this.workers)for(this.workers=[];this.workers.length{v.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[Je]}numActive(){return Object.keys(this.active).length}}ut.workerCount=2;class mt{constructor(m,v,E="Worker",D=ut.workerCount){this.workerPool=m,this.actors=[],this.currentActor=0,this.id=i.r();const z=this.workerPool.acquire(this.id,D);for(let $=0;${this.ready=!0})}broadcast(m,v,E){i.t(this.actors,(D,z)=>{D.send(m,v,z)},E=E||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(m=>{m.remove()}),this.actors=[],this.workerPool.release(this.id)}}let et,Ze;function kt(){return et||(et=new ut),et}mt.Actor=i.A;class Ut extends i.E{constructor(m){super(),this.imageProviders=new Map,this.images=new Map,this.updatedImages=new Map,this.callbackDispatchedThisFrame=new Map,this.imageVersions=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.imageAtlasCache=new i.x,this.dirty=!0,this.spriteFormat=m,m!=="raster"&&i.y()&&(this.imageRasterizerDispatcher=new mt((Ze||(Ze=new ut("ImageRasterizer")),Ze),this,"Image Rasterizer Worker",1))}addScope(m){this.loaded.set(m,!1),this.imageProviders.set(m,new Map),this.images.set(m,new Map),this.updatedImages.set(m,new Set),this.callbackDispatchedThisFrame.set(m,new Set),this.imageVersions.set(m,new Map),this.patterns.set(m,new Map),this.atlasImage.set(m,new i.q({width:1,height:1}))}removeScope(m){this.loaded.delete(m),this.imageProviders.delete(m),this.images.delete(m),this.updatedImages.delete(m),this.callbackDispatchedThisFrame.delete(m),this.imageVersions.delete(m),this.patterns.delete(m),this.atlasImage.delete(m);const v=this.atlasTexture.get(m);v&&(v.destroy(),this.atlasTexture.delete(m))}addImageProvider(m,v){this.imageProviders.has(v)||this.imageProviders.set(v,new Map),this.imageProviders.get(v).set(m.id,m)}removeImageProvider(m,v){this.imageProviders.has(v)&&this.imageProviders.get(v).delete(m)}getPendingImageProviders(){const m=[];for(const v of this.imageProviders.values())for(const E of v.values())E.hasPendingRequests()&&m.push(E);return m}get imageRasterizer(){return this._imageRasterizer||(this._imageRasterizer=new i.z),this._imageRasterizer}isLoaded(){for(const m of this.loaded.keys())if(!this.loaded.get(m))return!1;return!0}setLoaded(m,v){if(this.loaded.get(v)!==m&&(this.loaded.set(v,m),m)){for(const{ids:E,callback:D}of this.requestors)this._notify(E,v,D);this.requestors=[]}}hasImage(m,v){return!!this.getImage(m,v)}getImage(m,v){return this.images.get(v).get(m.toString())}addImage(m,v,E){if(this._validate(m,E)){this.images.get(v).set(m.toString(),E);const D=this.imageVersions.get(v),z=D.get(m.toString())||0;D.set(m.toString(),z+1)}}_validate(m,v){let E=!0;return this._validateStretch(v.stretchX,v.data&&v.data.width)||(this.fire(new i.B(new Error(`Image "${m.name}" has invalid "stretchX" value`))),E=!1),this._validateStretch(v.stretchY,v.data&&v.data.height)||(this.fire(new i.B(new Error(`Image "${m.name}" has invalid "stretchY" value`))),E=!1),this._validateContent(v.content,v)||(this.fire(new i.B(new Error(`Image "${m.name}" has invalid "content" value`))),E=!1),E}_validateStretch(m,v){if(!m)return!0;let E=0;for(const D of m){if(D[0]i.I.from(v))}getImageVersions(m){const v=this.imageVersions.get(m);if(v)return v}getImages(m,v,E){const D=[],z=[],$=this.imageProviders.get(v);for(const de of m){if(!de.iconsetId){D.push(de);continue}const we=$.get(de.iconsetId);we&&(this.getImage(de,v)?z.push(de):we.addPendingRequest(de))}if(D.length===0)return void this._notify(z,v,E);let K=!0;const ee=!!this.loaded.get(v),ne=this.images.get(v);if(!ee)for(const de of D)ne.has(de.toString())||(K=!1);ee||K?this._notify(D,v,E):this.requestors.push({ids:D,scope:v,callback:E})}rasterizeImages(m,v){const E=new Map,{tasks:D,scope:z}=m;for(const[$,K]of D.entries()){const ee=this.getImage(K.id,z);ee&&E.set($,{image:ee,imageVariant:K})}this._rasterizeImages(z,E,v)}_rasterizeImages(m,v,E){if(i.y())this.imageRasterizerDispatcher.getActor().send("rasterizeImagesWorker",{tasks:v,scope:m},E);else{const D=new Map;for(const[z,{image:$,imageVariant:K}]of v.entries())D.set(z,this.imageRasterizer.rasterize(K,$,m,0));E(void 0,D)}}getUpdatedImages(m){return this.updatedImages.get(m)||new Set}_notify(m,v,E){const D=this.images.get(v),z=new Map;for(const $ of m){if(!D.get($.toString())){if($.iconsetId)continue;this.fire(new i.C("styleimagemissing",{id:$.name}))}const K=D.get($.toString());if(!K){i.w(`Image "${$.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:K.usvg?null:K.data.clone(),pixelRatio:K.pixelRatio,sdf:K.sdf,usvg:K.usvg,stretchX:K.stretchX,stretchY:K.stretchY,content:K.content,hasRenderCallback:!!(K.userImage&&K.userImage.render)};K.usvg&&Object.assign(ee,{width:K.icon.usvg_tree.width,height:K.icon.usvg_tree.height}),z.set(i.I.toString($),ee)}E(null,{images:z,versions:this.getImageVersions(v)})}getPixelSize(m){const{width:v,height:E}=this.atlasImage.get(m);return{width:v,height:E}}getPattern(m,v,E){const D=m.toString(),z=this.patterns.get(v),$=z.get(D),K=this.getImage(m,v);if(!K)return null;if($){if($.position.version===K.version)return $.position;$.position.version=K.version}else{if(K.usvg&&!K.data){const ee=this.getPatternInFlightId(D,v);if(this.patternsInFlight.has(ee))return null;this.patternsInFlight.add(ee);const ne=new i.D(m).scaleSelf(i.o.devicePixelRatio),de=new Map([[ne.toString(),{image:K,imageVariant:ne}]]);return this._rasterizeImages(v,de,(we,be)=>this.storePatternImage(ne,v,K,E,be)),null}this.storePattern(m,v,K)}return this._updatePatternAtlas(v,E),z.get(D).position}getPatternInFlightId(m,v){return i.F(m,v)}hasPatternsInFlight(){return this.patternsInFlight.size!==0}storePatternImage(m,v,E,D,z){const $=m.toString(),K=z?z.get($):void 0;K&&(E.data=K,this.storePattern(m.id,v,E),this._updatePatternAtlas(v,D),this.patternsInFlight.delete(this.getPatternInFlightId(m.id.toString(),v)))}storePattern(m,v,E){const D={w:E.data.width+2*i.G,h:E.data.height+2*i.G,x:0,y:0},z=new i.H(D,E,i.G);this.patterns.get(v).set(m.toString(),{bin:D,position:z})}destroyAtlasTextures(){for(const m of this.atlasTexture.values())m&&m.destroy();this.atlasTexture.clear()}bind(m,v){const E=m.gl;let D=this.atlasTexture.get(v);D?this.dirty&&(D.update(this.atlasImage.get(v)),this.dirty=!1):(D=new i.T(m,this.atlasImage.get(v),E.RGBA8),this.atlasTexture.set(v,D)),D.bind(E.LINEAR,E.CLAMP_TO_EDGE)}_updatePatternAtlas(m,v){const E=this.patterns.get(m),D=Array.from(E.values()).map(({bin:ne})=>ne),{w:z,h:$}=i.J(D),K=this.atlasImage.get(m);K.resize({width:z||1,height:$||1});const ee=this.images.get(m);for(const[ne,{bin:de,position:we}]of E.entries()){let be=we.padding;const Ae=de.x+be,ze=de.y+be,Le=ee.get(ne).data,rt=Le.width,st=Le.height;be=be>1?be-1:be,i.q.copy(Le,K,{x:0,y:0},{x:Ae,y:ze},{width:rt,height:st},v),i.q.copy(Le,K,{x:0,y:st-be},{x:Ae,y:ze-be},{width:rt,height:be},v),i.q.copy(Le,K,{x:0,y:0},{x:Ae,y:ze+st},{width:rt,height:be},v),i.q.copy(Le,K,{x:rt-be,y:0},{x:Ae-be,y:ze},{width:be,height:st},v),i.q.copy(Le,K,{x:0,y:0},{x:Ae+rt,y:ze},{width:be,height:st},v),i.q.copy(Le,K,{x:rt-be,y:st-be},{x:Ae-be,y:ze-be},{width:be,height:be},v),i.q.copy(Le,K,{x:0,y:st-be},{x:Ae+rt,y:ze-be},{width:be,height:be},v),i.q.copy(Le,K,{x:0,y:0},{x:Ae+rt,y:ze+st},{width:be,height:be},v),i.q.copy(Le,K,{x:rt-be,y:0},{x:Ae-be,y:ze+st},{width:be,height:be},v)}this.dirty=!0}beginFrame(){for(const m of this.images.keys())this.callbackDispatchedThisFrame.set(m,new Set)}dispatchRenderCallbacks(m,v){const E=this.images.get(v);for(const D of m){if(this.callbackDispatchedThisFrame.get(v).has(D.toString()))continue;this.callbackDispatchedThisFrame.get(v).add(D.toString());const z=E.get(D.toString());Ke(z)&&this.updateImage(D,v,z)}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove()}}function Nt(M){const m=M.value,v=M.valueSpec,E=M.style,D=M.styleSpec,z=M.key,$=M.arrayElementValidator||un;if(!Array.isArray(m))return[new i.V(z,m,`array expected, ${i.M(m)} found`)];if(v.length&&m.length!==v.length)return[new i.V(z,m,`array length ${v.length} expected, length ${m.length} found`)];if(v["min-length"]&&m.lengthD)return[new i.V(m,v,`${v} is greater than the maximum value ${D}`)]}return[]}function ds(M){const m=M.key,v=M.value;if(!i.K(v))return[new i.V(m,v,`object expected, ${i.M(v)} found`)];const E=M.valueSpec,D=i.L(v.type);let z,$,K,ee={};const ne=D!=="categorical"&&v.property===void 0,de=!ne,we=function(Le){const rt=Le.stops;return Array.isArray(rt)&&Array.isArray(rt[0])&&i.K(rt[0][0])}(v),be=qr({key:M.key,value:M.value,valueSpec:M.styleSpec.function,style:M.style,styleSpec:M.styleSpec,objectElementValidators:{stops:function(Le){if(D==="identity")return[new i.V(Le.key,Le.value,'identity function may not have a "stops" property')];let rt=[];const st=Le.value;return rt=rt.concat(Nt({key:Le.key,value:st,valueSpec:Le.valueSpec,style:Le.style,styleSpec:Le.styleSpec,arrayElementValidator:Ae})),Array.isArray(st)&&st.length===0&&rt.push(new i.V(Le.key,st,"array must have at least one stop")),rt},default:function(Le){return un({key:Le.key,value:Le.value,valueSpec:E,style:Le.style,styleSpec:Le.styleSpec})}}});return D==="identity"&&ne&&be.push(new i.V(M.key,M.value,'missing required property "property"')),D==="identity"||v.stops||be.push(new i.V(M.key,M.value,'missing required property "stops"')),D==="exponential"&&E.expression&&!i.O(E)&&be.push(new i.V(M.key,M.value,"exponential functions not supported")),M.styleSpec.$version>=8&&(de&&!i.Q(E)?be.push(new i.V(M.key,M.value,"property functions not supported")):ne&&!i.S(E)&&be.push(new i.V(M.key,M.value,"zoom functions not supported"))),D!=="categorical"&&!we||v.property!==void 0||be.push(new i.V(M.key,M.value,'"property" property is required')),be;function Ae(Le){let rt=[];const st=Le.value,dt=Le.key;if(!Array.isArray(st))return[new i.V(dt,st,`array expected, ${i.M(st)} found`)];if(st.length!==2)return[new i.V(dt,st,`array length 2 expected, length ${st.length} found`)];if(we){if(!i.K(st[0]))return[new i.V(dt,st,`object expected, ${i.M(st[0])} found`)];const pt=st[0];if(pt.zoom===void 0)return[new i.V(dt,st,"object stop key must have zoom")];if(pt.value===void 0)return[new i.V(dt,st,"object stop key must have value")];const at=i.L(pt.zoom);if(typeof at!="number")return[new i.V(dt,pt.zoom,"stop zoom values must be numbers")];if(K&&K>at)return[new i.V(dt,pt.zoom,"stop zoom values must appear in ascending order")];at!==K&&(K=at,$=void 0,ee={}),rt=rt.concat(qr({key:`${dt}[0]`,value:st[0],valueSpec:{zoom:{}},style:Le.style,styleSpec:Le.styleSpec,objectElementValidators:{zoom:es,value:ze}}))}else rt=rt.concat(ze({key:`${dt}[0]`,value:st[0],style:Le.style,styleSpec:Le.styleSpec},st));return i.U(i.W(st[1]))?rt.concat([new i.V(`${dt}[1]`,st[1],"expressions are not allowed in function stops.")]):rt.concat(un({key:`${dt}[1]`,value:st[1],valueSpec:E,style:Le.style,styleSpec:Le.styleSpec}))}function ze(Le,rt){const st=i.M(Le.value),dt=i.L(Le.value),pt=Le.value!==null?Le.value:rt;if(z){if(st!==z)return[new i.V(Le.key,pt,`${st} stop domain type must match previous stop domain type ${z}`)]}else z=st;if(st!=="number"&&st!=="string"&&st!=="boolean"&&typeof dt!="number"&&typeof dt!="string"&&typeof dt!="boolean")return[new i.V(Le.key,pt,"stop domain value must be a number, string, or boolean")];if(st!=="number"&&D!=="categorical"){let at=`number expected, ${st} found`;return i.Q(E)&&D===void 0&&(at+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new i.V(Le.key,pt,at)]}return D!=="categorical"||st!=="number"||typeof dt=="number"&&isFinite(dt)&&Math.floor(dt)===dt?D!=="categorical"&&st==="number"&&typeof dt=="number"&&typeof $=="number"&&$!==void 0&&dt<$?[new i.V(Le.key,pt,"stop domain values must appear in ascending order")]:($=dt,D==="categorical"&&dt in ee?[new i.V(Le.key,pt,"stop domain values must be unique")]:(ee[dt]=!0,[])):[new i.V(Le.key,pt,`integer expected, found ${String(dt)}`)]}}function js(M){const m=(M.expressionContext==="property"?i.Y:i.X)(i.W(M.value),M.valueSpec);if(m.result==="error")return m.value.map(E=>new i.V(`${M.key}${E.key}`,M.value,E.message));const v=m.value.expression||m.value._styleExpression.expression;if(M.expressionContext==="property"&&M.propertyKey==="text-font"&&!v.outputDefined())return[new i.V(M.key,M.value,`Invalid data expression for "${M.propertyKey}". Output values must be contained as literals within the expression.`)];if(M.expressionContext==="property"&&M.propertyType==="layout"&&!i.$(v))return[new i.V(M.key,M.value,'"feature-state" data expressions are not supported with layout properties.')];if(M.expressionContext==="filter")return lr(v,M);if(M.expressionContext==="appearance")return Lt(v,M);if(M.expressionContext&&M.expressionContext.indexOf("cluster")===0){if(!i.Z(v,["zoom","feature-state"]))return[new i.V(M.key,M.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(M.expressionContext==="cluster-initial"&&!i._(v))return[new i.V(M.key,M.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function lr(M,m){const v=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(m.valueSpec&&m.valueSpec.expression)for(const D of m.valueSpec.expression.parameters)v.delete(D);if(v.size===0)return[];const E=[];return M instanceof i.a0&&v.has(M.name)?[new i.V(m.key,m.value,`["${M.name}"] expression is not supported in a filter for a ${m.object.type} layer with id: ${m.object.id}`)]:(M.eachChild(D=>{E.push(...lr(D,m))}),E)}function Lt(M,m){const v=new Set;if(m.valueSpec&&m.valueSpec.expression)for(const D of m.valueSpec.expression.parameters)v.add(D);if(v.size===0)return[];const E=[];return M instanceof i.a0&&!v.has(M.name)?[new i.V(m.key,m.value,`["${M.name}"] is not an allowed parameter`)]:(M.eachChild(D=>{E.push(...Lt(D,m))}),E)}function Es(M){const m=M.key,v=M.value,E=M.valueSpec,D=[];return Array.isArray(E.values)?E.values.indexOf(i.L(v))===-1&&D.push(new i.V(m,v,`expected one of [${E.values.join(", ")}], ${JSON.stringify(v)} found`)):Object.keys(E.values).indexOf(i.L(v))===-1&&D.push(new i.V(m,v,`expected one of [${Object.keys(E.values).join(", ")}], ${JSON.stringify(v)} found`)),D}function fr(M){return i.a4(i.W(M.value))?js(Object.assign({},M,{expressionContext:"filter",valueSpec:M.styleSpec[`filter_${M.layerType||"fill"}`]})):Hs(M)}function Hs(M){const m=M.value,v=M.key;if(!Array.isArray(m))return[new i.V(v,m,`array expected, ${i.M(m)} found`)];if(m.length<1)return[new i.V(v,m,"filter array must have at least 1 element")];const E=M.styleSpec;let D=Es({key:`${v}[0]`,value:m[0],valueSpec:E.filter_operator});const z=()=>{m.length>=2&&(i.a2(m[1])||D.push(new i.V(`${v}[1]`,m[1],`string expected, ${i.M(m[1])} found`)));for(let $=2;$":case">=":m.length>=2&&i.L(m[1])==="$type"&&D.push(new i.V(v,m,`"$type" cannot be use with operator "${m[0]}"`)),m.length!==3&&D.push(new i.V(v,m,`filter array for operator "${m[0]}" must have 3 elements`)),z();break;case"==":case"!=":m.length!==3&&D.push(new i.V(v,m,`filter array for operator "${m[0]}" must have 3 elements`)),z();break;case"in":case"!in":z();break;case"any":case"all":case"none":for(let $=1;${ne in v&&m.push(new i.V(E,v[ne],`"${ne}" is prohibited for ref layers`))}),D.layers.forEach(ne=>{i.L(ne.id)===K&&(ee=ne)}),ee?ee.ref?m.push(new i.V(E,v.ref,"ref cannot reference another ref layer")):$=i.L(ee.type):typeof K=="string"&&m.push(new i.V(E,v.ref,`ref layer "${K}" not found`))}else if($!=="background"&&$!=="sky"&&$!=="slot")if(v.source)if(i.a2(v.source)){const ee=D.sources&&D.sources[v.source],ne=ee&&i.L(ee.type);ee?ne==="vector"&&$==="raster"?m.push(new i.V(E,v.source,`layer "${v.id}" requires a raster source`)):ne==="raster"&&$!=="raster"?m.push(new i.V(E,v.source,`layer "${v.id}" requires a vector source`)):ne!=="vector"||v["source-layer"]?ne==="raster-dem"&&$!=="hillshade"?m.push(new i.V(E,v.source,"raster-dem source can only be used with layer type 'hillshade'.")):ne!=="raster-array"||["raster","raster-particle"].includes($)?$==="line"&&v.paint&&(v.paint["line-gradient"]||v.paint["line-trim-offset"])&&ne==="geojson"&&!ee.lineMetrics?m.push(new i.V(E,v,`layer "${v.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):$==="raster-particle"&&ne!=="raster-array"&&m.push(new i.V(E,v.source,`layer "${v.id}" requires a 'raster-array' source.`)):m.push(new i.V(E,v.source,"raster-array source can only be used with layer type 'raster'.")):m.push(new i.V(E,v,`layer "${v.id}" must specify a "source-layer"`)):m.push(new i.V(E,v.source,`source "${v.source}" not found`))}else m.push(new i.V(`${E}.source`,v.source,'"source" must be a string'));else m.push(new i.V(E,v,'missing required property "source"'));return m=m.concat(qr({key:E,value:v,valueSpec:z.layer,style:M.style,styleSpec:M.styleSpec,objectElementValidators:{"*":()=>[],type:()=>un({key:`${E}.type`,value:v.type,valueSpec:z.layer.type,style:M.style,styleSpec:M.styleSpec,object:v,objectKey:"type"}),filter:ee=>fr(Object.assign({layerType:$},ee)),layout:ee=>qr({layer:v,key:ee.key,value:ee.value,valueSpec:{},style:ee.style,styleSpec:ee.styleSpec,objectElementValidators:{"*":ne=>Cr(Object.assign({layerType:$},ne))}}),paint:ee=>qr({layer:v,key:ee.key,value:ee.value,valueSpec:{},style:ee.style,styleSpec:ee.styleSpec,objectElementValidators:{"*":ne=>an(Object.assign({layerType:$,layer:v},ne))}}),appearances(ee){const ne=Nt({key:ee.key,value:ee.value,valueSpec:ee.valueSpec,style:ee.style,styleSpec:ee.styleSpec,arrayElementValidator:be=>function(Ae){const{key:ze,layer:Le,layerType:rt}=Ae,st=i.L(Ae.value),dt=i.L(st.name),pt=i.L(st.condition),at=qr({key:ze,value:st,valueSpec:Ae.styleSpec.appearance,style:Ae.style,styleSpec:Ae.styleSpec,objectElementValidators:{condition:Bt=>function(wt){const Ft=[];return Ft.push(...js({key:wt.key,value:wt.object.condition,valueSpec:i.a8.appearance.condition,expressionContext:"appearance"})),Ft}(Object.assign({layer:Le,layerType:rt},Bt)),properties:Bt=>function(wt){const Ft=[],{styleSpec:ft,layer:_t,layerType:Et}=wt,Kt=ft[`paint_${Et}`],qt=ft[`layout_${Et}`],ns=wt.object[wt.objectKey];for(const Jt in ns){const Cs=Jt in Kt?"paint":Jt in qt?"layout":void 0;if(!Cs){Ft.push(new i.V(wt.key,Jt,`unknown property "${Jt}" for layer type "${Et}"`));continue}const Ls=Object.assign({},wt,{key:`${wt.key}.${Jt}`,object:ns,objectKey:Jt,layer:_t,layerType:Et,value:ns[Jt],valueSpec:Cs==="paint"?Kt[Jt]:qt[Jt]});Ft.push(...mr(Ls,Cs))}return Ft}(Object.assign({layer:Le,layerType:rt},Bt))}});return dt!=="hidden"&&pt===void 0&&at.push(new i.V(Ae.key,"name",'Appearance with name different than "hidden" must have a condition')),at}(Object.assign({layerType:$,layer:v},be))}),de=Array.isArray(ee.value)?ee.value:[],we=new Set;return de.forEach((be,Ae)=>{const ze=i.L(be.name);if(ze)if(we.has(ze)){const Le=i.L(v.id);ne.push(new i.V(ee.key,ze,`Duplicated appearance name "${ze}" for layer "${Le}"`))}else we.add(ze)}),ne}}})),m}function $r({key:M,value:m}){return i.a2(m)?[]:[new i.V(M,m,`string expected, ${i.M(m)} found`)]}const nr={promoteId:function M({key:m,value:v}){if(i.a2(v))return $r({key:m,value:v});if(Array.isArray(v)){const D=[],z=i.W(v),$=i.X(z);return $.result==="error"?($.value.forEach(K=>{D.push(new i.V(`${m}${K.key}`,null,`${K.message}`))}),D):(i.Z($.value.expression,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])||D.push(new i.V(`${m}`,null,"promoteId expression should be only feature dependent")),D)}if(!i.K(v))return[new i.V(m,v,`string, expression or object expected, "${i.M(v)}" found`)];const E=[];for(const D in v)E.push(...M({key:`${m}.${D}`,value:v[D]}));return E}};function cr(M){const m=M.value,v=M.key,E=M.styleSpec,D=M.style;if(!i.K(m))return[new i.V(v,m,`object expected, ${i.M(m)} found`)];if(!("type"in m))return[new i.V(v,m,'"type" is required')];const z=i.L(m.type);let $=[];switch(["vector","raster","raster-dem","raster-array"].includes(z)&&("url"in m||"tiles"in m||$.push(new i.a5(v,m,'Either "url" or "tiles" is required.'))),z){case"vector":case"raster":case"raster-dem":case"raster-array":return $=$.concat(qr({key:v,value:m,valueSpec:E[`source_${z.replace("-","_")}`],style:M.style,styleSpec:E,objectElementValidators:nr})),$;case"geojson":if($=qr({key:v,value:m,valueSpec:E.source_geojson,style:D,styleSpec:E,objectElementValidators:nr}),"cluster"in m&&"clusterProperties"in m){if(!i.K(m.clusterProperties))return[new i.V(`${v}.clusterProperties`,m,`object expected, ${i.M(m)} found`)];for(const K in m.clusterProperties){const ee=m.clusterProperties[K];if(!Array.isArray(ee))return[new i.V(`${v}.clusterProperties.${K}`,ee,"array expected")];const[ne,de]=ee,we=typeof ne=="string"?[ne,["accumulated"],["get",K]]:ne;$.push(...js({key:`${v}.${K}.map`,value:de,expressionContext:"cluster-map"})),$.push(...js({key:`${v}.${K}.reduce`,value:we,expressionContext:"cluster-reduce"}))}}return $;case"video":return qr({key:v,value:m,valueSpec:E.source_video,style:D,styleSpec:E});case"image":return qr({key:v,value:m,valueSpec:E.source_image,style:D,styleSpec:E});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 Es({key:`${v}.type`,value:m.type,valueSpec:{values:Br(E)}})}}function Br(M){return M.source.reduce((m,v)=>{const E=M[v];return E.type.type==="enum"&&(m=m.concat(Object.keys(E.type.values||{}))),m},[])}function Kr(M){const m=M.value,v=M.styleSpec,E=v.light,D=M.style;if(m===void 0)return[];if(!i.K(m))return[new i.V("light",m,`object expected, ${i.M(m)} found`)];let z=[];for(const $ in m){const K=$.match(/^(.*)-transition$/),ee=$.match(/^(.*)-use-theme$/);z=z.concat(ee&&E[ee[1]]?un({key:$,value:m[$],valueSpec:{type:"string"},style:D,styleSpec:v}):K&&E[K[1]]&&E[K[1]].transition?un({key:$,value:m[$],valueSpec:v.transition,style:D,styleSpec:v}):E[$]?un({key:$,value:m[$],valueSpec:E[$],style:D,styleSpec:v}):[new i.V($,m[$],`unknown property "${$}"`)])}return z}function Sn(M){const m=M.value;if(!m)return[];const v=M.key;if(!i.K(m))return[new i.V(v,m,`object expected, ${i.M(m)} found`)];let E=[];const D=M.styleSpec,z=D["light-3d"],$=M.style,K=M.style.lights;for(const de of["type","id"])if(!(de in m))return E=E.concat([new i.V(v,m,`missing property "${de}"`)]),E;if(!i.a2(m.type))return E=E.concat([new i.V(`${v}.type`,m.type,"string expected")]),E;if(K)for(let de=0;de[],array:Nt,boolean:function(M){const m=M.value,v=M.key;return i.a1(m)?[]:[new i.V(v,m,`boolean expected, ${i.M(m)} found`)]},number:es,color:function({key:M,value:m}){return i.a2(m)?i.a3.parseCSSColor(m)===null?[new i.V(M,m,`color expected, "${m}" found`)]:[]:[new i.V(M,m,`color expected, ${i.M(m)} found`)]},enum:Es,filter:fr,function:ds,layer:Fr,object:qr,source:cr,model:i.a9,light:Kr,"light-3d":Sn,terrain:ai,fog:as,string:$r,formatted:function(M){return $r(M).length===0?[]:js(M)},resolvedImage:function(M){return $r(M).length===0?[]:js(M)},projection:function(M){const m=M.value,v=M.styleSpec,E=v.projection,D=M.style;if(i.K(m)){let z=[];for(const $ in m)z=z.concat(un({key:$,value:m[$],valueSpec:E[$],style:D,styleSpec:v}));return z}return i.a2(m)?[]:[new i.V("projection",m,`object or string expected, ${i.M(m)} found`)]},import:function(M){const m=M.key,{value:v,styleSpec:E}=M;if(!i.K(v))return[new i.V(m,v,"import must be an object")];const{data:D,...z}=v;Object.defineProperty(z,"__line__",{value:v.__line__,enumerable:!1});let $=qr(Object.assign({},M,{value:z,valueSpec:E.import}));return i.L(z.id)===""&&$.push(new i.V(`${M.key}.id`,z,"import id can't be an empty string")),D&&($=$.concat(La(D,E,{key:`${M.key}.data`}))),$},iconset:function(M){const m=M.value,v=M.key,E=M.styleSpec,D=M.style;if(!i.K(m))return[new i.V(v,m,"object expected")];if(!m.type)return[new i.V(v,m,'"type" is required')];const z=i.L(m.type);let $=[];if($=$.concat(qr({key:v,value:m,valueSpec:E[`iconset_${z}`],style:D,styleSpec:E})),function(K,ee){return!(K!=="source"||!ee.source)}(z,m)){const K=D.sources&&D.sources[m.source],ee=K&&i.L(K.type);K?ee!=="raster-array"&&$.push(new i.V(v,m.source,`iconset cannot be used with a source of type ${String(ee)}, it only be used with a "raster-array" source type`)):$.push(new i.V(v,m.source,`source "${m.source}" not found`))}return $}};function un(M,m=!1){const v=M.value,E=M.valueSpec,D=M.styleSpec;if(E.expression){if(i.a6(i.L(v)))return ds(M);if(i.U(i.W(v)))return js(M)}if(E.type&&qn[E.type]){const z=qn[E.type](M);return m===!0&&z.length>0&&Array.isArray(M.value)?js(M):z}return qr(Object.assign({},M,{valueSpec:E.type?D[E.type]:E}))}function qr(M){const m=M.key,v=M.value,E=M.valueSpec||{},D=M.objectElementValidators||{},z=M.style,$=M.styleSpec;if(!i.K(v))return[new i.V(m,v,`object expected, ${i.M(v)} found`)];let K=[];for(const ee in v){const ne=ee.split(".")[0];let de;D[ne]?de=D[ne]:E[ne]?de=un:D["*"]?de=D["*"]:E["*"]&&(de=un),de?K=K.concat(de({key:(m&&`${m}.`)+ee,value:v[ee],valueSpec:E[ne]||E["*"],style:z,styleSpec:$,object:v,objectKey:ee},v)):K.push(new i.a5(m,v[ee],`unknown property "${ee}"`))}for(const ee in E){if(D[ee])continue;const ne=E[ee];ne.required&&ne.default===void 0&&v[ee]===void 0&&K.push(new i.V(m,v,`missing required property "${ee}"`))}return K}function Zr({key:M,value:m}){const v=$r({key:M,value:m});if(v.length)return v;const E=m;return E.indexOf("{fontstack}")===-1&&v.push(new i.V(M,m,'"glyphs" url must include a "{fontstack}" token')),E.indexOf("{range}")===-1&&v.push(new i.V(M,m,'"glyphs" url must include a "{range}" token')),v}function La(M,m=i.a8,v={}){return qr({key:v.key||"",value:M,valueSpec:Object.assign(m.$root,{"*":{type:"*"}}),styleSpec:m,style:M,objectElementValidators:{glyphs:Zr}})}function Yt(M,m=i.a8){return bs(La(M,m))}const Lr=M=>bs(cr(M)),$t=M=>bs(Kr(M)),Se=M=>bs(Sn(M)),Fe=M=>bs(ai(M)),Xe=M=>bs(as(M)),yt=M=>bs(function(m){const v=m.value,E=m.style,D=m.styleSpec,z=D.snow;if(v===void 0)return[];if(!i.K(v))return[new i.V("snow",v,`object expected, ${i.M(v)} found`)];let $=[];for(const K in v){const ee=K.match(/^(.*)-transition$/);$=$.concat(ee&&z[ee[1]]&&z[ee[1]].transition?un({key:K,value:v[K],valueSpec:D.transition,style:E,styleSpec:D}):z[K]?un({key:K,value:v[K],valueSpec:z[K],style:E,styleSpec:D}):[new i.a5(K,v[K],`unknown property "${K}"`)])}return $}(M)),bt=M=>bs(function(m){const v=m.value,E=m.style,D=m.styleSpec,z=D.rain;if(v===void 0)return[];if(!i.K(v))return[new i.V("rain",v,`object expected, ${i.M(v)} found`)];let $=[];for(const K in v){const ee=K.match(/^(.*)-transition$/);$=$.concat(ee&&z[ee[1]]&&z[ee[1]].transition?un({key:K,value:v[K],valueSpec:D.transition,style:E,styleSpec:D}):z[K]?un({key:K,value:v[K],valueSpec:z[K],style:E,styleSpec:D}):[new i.a5(K,v[K],`unknown property "${K}"`)])}return $}(M)),At=M=>bs(Fr(M)),Gt=M=>bs(fr(M)),Vt=M=>bs(an(M)),Xt=M=>bs(Cr(M)),Is=M=>bs(i.a9(M));function bs(M){return M.slice().sort((m,v)=>m.line&&v.line?m.line-v.line:0)}function or(M,m){let v=!1;if(m&&m.length)for(const E of m)E instanceof i.a5?i.w(E.message):(M.fire(new i.B(new Error(E.message))),v=!0);return v}const Rr=i.a8.light;let Wr;class zr extends i.E{constructor(m,v="flat"){super(),this._transitionable=new i.aa(Wr||(Wr=new i.ab({anchor:new i.ac(Rr.anchor),position:new i.ad(Rr.position),color:new i.ac(Rr.color),intensity:new i.ac(Rr.intensity)}))),this.setLight(m,v),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(m,v,E={}){this._validate($t,m,E)||(this._transitionable.setTransitionOrValue(m),this.id=v)}updateTransitions(m){this._transitioning=this._transitionable.transitioned(m,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(m){this.properties=this._transitioning.possiblyEvaluate(m)}_validate(m,v,E){return(!E||E.validate!==!1)&&or(this,m.call(Yt,Object.assign({value:v,style:{glyphs:!0,sprite:!0},styleSpec:i.a8})))}}const hn=i.a8.terrain;let Wn=class extends i.E{constructor(M,m,v,E,D){super(),this.scope=v,this._transitionable=new i.aa(new i.ab({source:new i.ac(hn.source),exaggeration:new i.ac(hn.exaggeration)}),v,E),this._transitionable.setTransitionOrValue(M,E),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=m,this.worldview=D}get(){return this._transitionable.serialize()}set(M,m){this._transitionable.setTransitionOrValue(M,m)}updateTransitions(M){this._transitioning=this._transitionable.transitioned(M,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(M){this.properties=this._transitioning.possiblyEvaluate(M)}getExaggeration(M){return this._transitioning.possiblyEvaluate(new i.ae(M,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const M=this._transitionable._values.exaggeration;if(!M)return null;const m=M.value.expression;if(!m)return null;let v=-1,E=-1,D=1;for(const z of m.zoomStops)D=m.evaluate(new i.ae(z,{worldview:this.worldview})),D>.01?(v=z,E=-1):E=z;return D<.01&&v>0&&E>v?[v,E]:null}isZoomDependent(){const M=this._transitionable._values.exaggeration;return M!=null&&M.value!=null&&M.value.expression!=null&&M.value.expression instanceof i.af}};const sa=.05;function ua(M,m,v,E){const D=i.aj(45,65,v),[z,$]=To(M,E);let K=1-Math.min(1,Math.exp((m-z)/($-z)*-6));return K*=K*K,K=Math.min(1,1.00747*K),K*D*M.alpha}function To(M,m){const v=.5/Math.tan(.5*m);return[M.range[0]+v,M.range[1]+v]}function wo(M,m,v,E,D){const z=i.ah([],[m,v,E],D.mercatorFogMatrix);return ua(M,i.ai(z),D.pitch,D._fov)}function Yi(M,m,v,E,D,z,$){const K=[[v,E,0],[D,E,0],[D,z,0],[v,z,0]];let ee=Number.MAX_VALUE,ne=-Number.MAX_VALUE;for(const de of K){const we=i.ah([],de,m),be=i.ai(we);ee=Math.min(ee,be),ne=Math.max(ne,be)}return[ua(M,ee,$.pitch,$._fov),ua(M,ne,$.pitch,$._fov)]}const ii=i.a8.fog;class $i extends i.E{constructor(m,v,E,D){super();const z=new i.ab({range:new i.ac(ii.range),color:new i.ac(ii.color),"color-use-theme":new i.ac({type:"string","property-type":"data-constant",default:"default"}),"high-color":new i.ac(ii["high-color"]),"high-color-use-theme":new i.ac({type:"string","property-type":"data-constant",default:"default"}),"space-color":new i.ac(ii["space-color"]),"space-color-use-theme":new i.ac({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new i.ac(ii["horizon-blend"]),"star-intensity":new i.ac(ii["star-intensity"]),"vertical-range":new i.ac(ii["vertical-range"])});this._transitionable=new i.aa(z,E,new Map(D)),this.set(m,D),this._transitioning=this._transitionable.untransitioned(),this._transform=v,this.properties=new i.ak(z),this.scope=E}get state(){const m=this._transform,v=m.projection.name==="globe",E=i.al(m.zoom),D=this.properties.get("range"),z=[.5,3];return{range:v?[i.am(z[0],D[0],E),i.am(z[1],D[1],E)]:D,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(m,v,E={}){if(this._validate(Xe,m,E))return;const D=Object.assign({},m);for(const z of Object.keys(ii))D[z]===void 0&&(D[z]=ii[z].default);this._options=D,this._transitionable.setTransitionOrValue(this._options,v)}getOpacity(m){if(!this._transform.projection.supportsFog)return 0;const v=this.properties&&this.properties.get("color")||1;return(this._transform.projection.name==="globe"?1:i.aj(45,65,m))*v.a}getOpacityAtLatLng(m,v){return this._transform.projection.supportsFog?function(E,D,z){const $=i.ag.fromLngLat(D),K=z.elevation?z.elevation.getAtPointOrZero($):0;return wo(E,$.x,$.y,K,z)}(this.state,m,v):0}getOpacityForTile(m){if(!this._transform.projection.supportsFog)return[1,1];const v=this._transform.calculateFogTileMatrix(m.toUnwrapped());return Yi(this.state,v,0,0,i.an,i.an,this._transform)}getOpacityForBounds(m,v,E,D,z){return this._transform.projection.supportsFog?Yi(this.state,m,v,E,D,z,this._transform):[1,1]}getFovAdjustedRange(m){return this._transform.projection.supportsFog?To(this.state,m):[0,1]}isVisibleOnFrustum(m){if(!this._transform.projection.supportsFog)return!1;const v=[4,5,6,7];for(const E of v){const D=m.points[E];let z;if(D[2]>=0)z=D;else{const $=m.points[E-4];z=i.ao($,D,$[2]/($[2]-D[2]))}if(wo(this.state,z[0],z[1],0,this._transform)>=sa)return!0}return!1}updateConfig(m){this._transitionable.setTransitionOrValue(this._options,new Map(m))}updateTransitions(m){this._transitioning=this._transitionable.transitioned(m,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(m){this.properties=this._transitioning.possiblyEvaluate(m)}_validate(m,v,E){return(!E||E.validate!==!1)&&or(this,m.call(Yt,Object.assign({value:v,style:{glyphs:!0,sprite:!0},styleSpec:i.a8})))}}let tl,ui,qi,Xi=class extends i.E{constructor(M,m,v,E){super();const D=tl||(tl=new i.ab({density:new i.ac(i.a8.snow.density),intensity:new i.ac(i.a8.snow.intensity),color:new i.ac(i.a8.snow.color),opacity:new i.ac(i.a8.snow.opacity),vignette:new i.ac(i.a8.snow.vignette),"vignette-color":new i.ac(i.a8.snow["vignette-color"]),"center-thinning":new i.ac(i.a8.snow["center-thinning"]),direction:new i.ac(i.a8.snow.direction),"flake-size":new i.ac(i.a8.snow["flake-size"])}));this._transitionable=new i.aa(D,v,new Map(E)),this.set(M,E),this._transitioning=this._transitionable.untransitioned(),this.properties=new i.ak(D),this.scope=v}get state(){const M=this.properties.get("opacity"),m=this.properties.get("color"),v=this.properties.get("direction"),E=i.ap(v[0]),D=-Math.max(i.ap(v[1]),.01),z=[Math.cos(E)*Math.cos(D),Math.sin(E)*Math.cos(D),Math.sin(D)],$=this.properties.get("vignette"),K=this.properties.get("vignette-color");return K.a=$,{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new i.aq(m.r,m.g,m.b,m.a*M),direction:z,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:K}}get(){return this._transitionable.serialize()}set(M,m,v={}){if(this._validate(yt,M,v))return;const E=Object.assign({},M),D=i.a8.snow;for(const z of Object.keys(D))E[z]===void 0&&(E[z]=D[z].default);this._options=E,this._transitionable.setTransitionOrValue(this._options,m)}updateConfig(M){this._transitionable.setTransitionOrValue(this._options,new Map(M))}updateTransitions(M){this._transitioning=this._transitionable.transitioned(M,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(M){this.properties=this._transitioning.possiblyEvaluate(M)}_validate(M,m,v){return(!v||v.validate!==!1)&&or(this,M.call(Yt,Object.assign({value:m,style:{glyphs:!0,sprite:!0},styleSpec:i.a8})))}},ha=class extends i.E{constructor(M,m,v,E){super();const D=ui||(ui=new i.ab({density:new i.ac(i.a8.rain.density),intensity:new i.ac(i.a8.rain.intensity),color:new i.ac(i.a8.rain.color),opacity:new i.ac(i.a8.rain.opacity),vignette:new i.ac(i.a8.rain.vignette),"vignette-color":new i.ac(i.a8.rain["vignette-color"]),"center-thinning":new i.ac(i.a8.rain["center-thinning"]),direction:new i.ac(i.a8.rain.direction),"droplet-size":new i.ac(i.a8.rain["droplet-size"]),"distortion-strength":new i.ac(i.a8.rain["distortion-strength"])}));this._transitionable=new i.aa(D,v,new Map(E)),this.set(M,E),this._transitioning=this._transitionable.untransitioned(),this.properties=new i.ak(D),this.scope=v}get state(){const M=this.properties.get("opacity"),m=this.properties.get("color"),v=this.properties.get("direction"),E=i.ap(v[0]),D=-Math.max(i.ap(v[1]),.01),z=[Math.cos(E)*Math.cos(D),Math.sin(E)*Math.cos(D),Math.sin(D)],$=this.properties.get("vignette-color");return $.a=this.properties.get("vignette"),{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new i.aq(m.r,m.g,m.b,m.a*M),direction:z,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:$}}get(){return this._transitionable.serialize()}set(M,m,v={}){if(this._validate(bt,M,v))return;const E=Object.assign({},M),D=i.a8.rain;for(const z of Object.keys(D))E[z]===void 0&&(E[z]=D[z].default);this._options=E,this._transitionable.setTransitionOrValue(this._options,m)}updateConfig(M){this._transitionable.setTransitionOrValue(this._options,new Map(M))}updateTransitions(M){this._transitioning=this._transitionable.transitioned(M,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(M){this.properties=this._transitioning.possiblyEvaluate(M)}_validate(M,m,v){return(!v||v.validate!==!1)&&or(this,M.call(Yt,Object.assign({value:m,style:{glyphs:!0,sprite:!0},styleSpec:i.a8})))}};class sl extends i.E{constructor(m,v,E,D){super(),this.scope=E,this._options=m,this.properties=new i.ak(v),this._transitionable=new i.aa(v,E,new Map(D)),this._transitionable.setTransitionOrValue(m.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(m){this._transitionable.setTransitionOrValue(this._options.properties,new Map(m))}updateTransitions(m){this._transitioning=this._transitionable.transitioned(m,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(m){this.properties=this._transitioning.possiblyEvaluate(m)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(m,v){this._options=m,this._transitionable.setTransitionOrValue(m.properties,v)}shadowsEnabled(){return!!this.properties&&this.properties.get("cast-shadows")===!0}}const ac=()=>qi||(qi=new i.ab({color:new i.ac(i.a8.properties_light_ambient.color),"color-use-theme":new i.ac({type:"string",default:"default","property-type":"data-constant"}),intensity:new i.ac(i.a8.properties_light_ambient.intensity)}));let ic;const bu=()=>ic||(ic=new i.ab({direction:new i.ar(i.a8.properties_light_directional.direction),color:new i.ac(i.a8.properties_light_directional.color),"color-use-theme":new i.ac({type:"string",default:"default","property-type":"data-constant"}),intensity:new i.ac(i.a8.properties_light_directional.intensity),"cast-shadows":new i.ac(i.a8.properties_light_directional["cast-shadows"]),"shadow-quality":new i.ac(i.a8.properties_light_directional["shadow-quality"]),"shadow-intensity":new i.ac(i.a8.properties_light_directional["shadow-intensity"]),"shadow-draw-before-layer":new i.ac(i.a8.properties_light_directional["shadow-draw-before-layer"])}));class wu{constructor(m,v,E){this.screenBounds=m,this.cameraPoint=E.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=v,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,E)}static createFromScreenPoints(m,v){let E,D;if(m instanceof i.P||typeof m[0]=="number"){const z=i.P.convert(m);E=[z],D=v.isPointAboveHorizon(z)}else{const z=i.P.convert(m[0]),$=i.P.convert(m[1]),K=z.add($)._div(2);E=[z,$],D=i.as(z,$).every(ee=>v.isPointAboveHorizon(ee))&&v.isPointAboveHorizon(K)}return new wu(E,D,v)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(m){return i.as(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],m)}bufferedCameraGeometry(m){const v=this.screenBounds[0],E=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],D=i.as(v,E,0,!1);return this.cameraPoint.y>E.y&&(this.cameraPoint.x>v.x&&this.cameraPoint.x=E.x?D[2]=this.cameraPoint:this.cameraPoint.x<=v.x&&(D[3]=this.cameraPoint)),i.at(D,m)}bufferedCameraGeometryGlobe(m){const v=this.screenBounds[0],E=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],D=i.as(v,E,m),z=this.cameraPoint.clone(),$=+(z.x>v.x)+ +(z.x>E.x);switch(3*(+(z.y>v.y)+ +(z.y>E.y))+$){case 0:D[0]=z,D[4]=z.clone();break;case 1:D.splice(1,0,z);break;case 2:D[1]=z;break;case 3:D.splice(4,0,z);break;case 5:D.splice(2,0,z);break;case 6:D[3]=z;break;case 7:D.splice(3,0,z);break;case 8:D[2]=z}return D}containsTile(m,v,E,D=0){const z=Math.max(m.queryPadding,m.evaluateQueryRenderedFeaturePadding())/v._pixelsPerMercatorPixel+1,$=E?this._bufferedCameraMercator(z,v):this._bufferedScreenMercator(z,v);let K=m.tileID.wrap+($.unwrapped?D:0);const ee=$.polygon.map(rt=>i.au(m.tileTransform,rt,K));if(!i.av(ee,0,0,i.an,i.an))return;K=m.tileID.wrap+(this.screenGeometryMercator.unwrapped?D:0);const ne=this.screenGeometryMercator.polygon.map(rt=>i.aw(m.tileTransform,rt,K)),de=ne.map(rt=>new i.P(rt[0],rt[1])),we=v.getFreeCameraOptions().position||new i.ag(0,0,0),be=i.aw(m.tileTransform,we,K),Ae=ne.map(rt=>{const st=i.ax(rt,rt,be);return i.ay(st,st),new i.az(be,st)}),ze=i.aA(m,1,v.zoom)*v._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:de,tilespaceRays:Ae,bufferedTilespaceGeometry:ee,bufferedTilespaceBounds:(Le=i.aB(ee),Le.min.x=i.aC(Le.min.x,0,i.an),Le.min.y=i.aC(Le.min.y,0,i.an),Le.max.x=i.aC(Le.max.x,0,i.an),Le.max.y=i.aC(Le.max.y,0,i.an),Le),tile:m,tileID:m.tileID,pixelToTileUnitsFactor:ze};var Le}_bufferedScreenMercator(m,v){const E=ju(m);if(this._screenRaycastCache[E])return this._screenRaycastCache[E];{let D;return D=v.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(m),v):{polygon:this.bufferedScreenGeometry(m).map(z=>v.pointCoordinate3D(z)),unwrapped:!0},this._screenRaycastCache[E]=D,D}}_bufferedCameraMercator(m,v){const E=ju(m);if(this._cameraRaycastCache[E])return this._cameraRaycastCache[E];{let D;return D=v.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(m),v):{polygon:this.bufferedCameraGeometry(m).map(z=>v.pointCoordinate3D(z)),unwrapped:!0},this._cameraRaycastCache[E]=D,D}}_projectAndResample(m,v){const E=function(z,$){const K=i.aD([],$.pixelMatrix,$.globeMatrix),ee=[0,-i.aF,0,1],ne=[0,i.aF,0,1],de=[0,0,0,1];i.aE(ee,ee,K),i.aE(ne,ne,K),i.aE(de,de,K);const we=new i.P(ee[0]/ee[3],ee[1]/ee[3]),be=new i.P(ne[0]/ne[3],ne[1]/ne[3]),Ae=i.aG(z,we)&&ee[3]1?Fm(z.slice(0,rt),$):[],pt=rtnew i.P(kd(Ft.x),Ft.y)),pt=pt.map(Ft=>new i.P(kd(Ft.x),Ft.y));const at=[...dt];at.length===0&&at.push(pt[pt.length-1]);const Bt=i.am(at[at.length-1].y,(pt.length===0?dt[0]:pt[0]).y,st);let wt;return wt=Ae?[new i.P(0,Bt),new i.P(0,0),new i.P(1,0),new i.P(1,Bt)]:[new i.P(1,Bt),new i.P(1,1),new i.P(0,1),new i.P(0,Bt)],at.push(...wt),pt.length===0?at.push(dt[0]):at.push(...pt),{polygon:at.map(Ft=>new i.ag(Ft.x,Ft.y)),unwrapped:!1}}(m,v);if(E)return E;const D=function(z,$){let K=!1,ee=-1/0,ne=0;for(let we=0;weee&&(ee=z[we].x,ne=we);for(let we=0;we.5&&(Ae.x{we.x-=1}),{polygon:z,unwrapped:K}}(Fm(m,v).map(z=>new i.P(kd(z.x),z.y)),v);return{polygon:D.polygon.map(z=>new i.ag(z.x,z.y)),unwrapped:D.unwrapped}}}function Fm(M,m){return i.aI(M,v=>{const E=m.pointCoordinate3D(v);v.x=E.x,v.y=E.y},1/256)}function kd(M){return M<0?1+M%1:M%1}function ju(M){return 100*M|0}function zm(M,m,v){try{m=function(D){if(!D.variants)return D;if(!Array.isArray(D.variants))throw new Error("variants must be an array");for(const z of D.variants){if(z==null||typeof z!="object"||z.constructor!==Object)throw new Error("variant must be an object");if(!Array.isArray(z.capabilities))throw new Error("capabilities must be an array");if(z.capabilities.length===1&&z.capabilities[0]==="meshopt")return Object.assign(D,z)}return D}(m)}catch(D){return new Error("Failed to process TileJSON variants",{cause:D})}const E=i.aJ(Object.assign({},m,M),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);return M.url&&m.tiles&&M.tiles&&(E.tiles=m.tiles),E.tiles=v.canonicalizeTileset(E,M.url),E}function Wu(M,m,v,E,D){const z=function(K,ee){if(K)return D(K);if(ee){M.url&&ee.tiles&&M.tiles&&delete M.tiles;const ne=zm(M,ee,m);if(ne instanceof Error)return D(ne);D(null,ne)}},$=function(K,ee,ne){if(!K)return null;if(!ee&&!ne)return K;ne=ne||K.worldview_default;const de=Object.values(K.language||{});if(de.length===0)return null;const we=Object.values(K.worldview||{});if(we.length===0)return null;const be=de.every(ze=>ze===ee),Ae=we.every(ze=>ze===ne);return be&&Ae?K:ee in(K.language_options||{})||ne in(K.worldview_options||{})?null:K.language_options&&K.worldview_options?K:null}(M.data,v,E);return $?i.o.frame(()=>z(null,$)):M.url?i.m(m.transformRequest(m.normalizeSourceURL(M.url,null,v,E),i.R.Source),z):i.o.frame(()=>{const{data:K,...ee}=M;z(null,ee)})}function Bm(M,m){const v=Math.pow(2,m.z),E=Math.floor(i.aH(M.getWest())*v),D=Math.floor(i.aL(M.getNorth())*v),z=Math.ceil(i.aH(M.getEast())*v),$=Math.ceil(i.aL(M.getSouth())*v);return m.x>=E&&m.x=D&&m.y<$}class Sd{constructor(m,v,E){this.bounds=m?i.aK.convert(this.validateBounds(m)):null,this.minzoom=v||0,this.maxzoom=E||24}validateBounds(m){return Array.isArray(m)&&m.length===4?[Math.max(-180,m[0]),Math.max(-90,m[1]),Math.min(180,m[2]),Math.min(90,m[3])]:[-180,-90,180,90]}addExtraBounds(m){if(m){this.extraBounds||(this.extraBounds=[]);for(const v of m)this.extraBounds.push(i.aK.convert(this.validateBounds(v)))}}contains(m){if(m.z>this.maxzoom||m.z{this._tileJSONRequest=null,this._loaded=!0,$?(v&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${v}`),E&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${E}`),this.fire(new i.B($))):K&&(this._setTileJSON(K),qe(K.tiles,this.map._requestManager._customAccessToken),this.fire(new i.C("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.C("data",{dataType:"source",sourceDataType:"content"}))),m&&m($)};this.provider=this._options.provider;const z=function($){if("provider"in $&&!$.provider)return null;let K=$.provider;if(!K&&"url"in $&&$.url&&(K=i.aM($.url)),!K)return null;const ee=i.g.TILE_PROVIDER_URLS[K];if(!ee)return null;let ne;try{ne=new URL(ee,i.g.API_URL).href}catch{return i.w(`TileProvider "${K}" has an invalid URL: "${ee}"`),null}return{name:K,url:ne}}(this._options);if(this.provider&&!z)return this._loaded=!0,this.fire(new i.B(new Error(`TileProvider "${this.provider}" is not registered`))),void(m&&m());this._tileJSONRequest=z?this._loadWithProvider(z,D):Wu(this._options,this.map._requestManager,v,E,D)}_loadWithProvider(m,v){this.provider=m.name;const E=new AbortController,D=this._options.url&&!this._options.tiles?this.map._requestManager.transformRequest(this._options.url,i.R.Source):void 0,z=D?Object.assign({},this._options,{url:D.url}):this._options;return this.dispatcher.broadcast("loadTileProvider",{name:m.name,url:m.url,source:this.id,scope:this.scope,type:this.type,options:z,request:D},($,K)=>{if(E.signal.aborted)return;if($)return void v($);const ee=K?K.find(ne=>ne!=null):null;if(ee){const ne=zm(this._options,ee,this.map._requestManager);ne instanceof Error?v(ne):v(null,ne)}else v(null,{tiles:this._options.tiles})}),{cancel:()=>{E.abort()}}}_setTileJSON(m){if(Object.assign(this,m),this.hasWorldviews=!!m.worldview_options,m.worldview_default&&(this.worldviewDefault=m.worldview_default),m.vector_layers){this.vectorLayers=m.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const v of m.vector_layers)this.vectorLayerIds.push(v.id),m.worldview&&m.worldview[v.source]&&this.localizableLayerIds.add(v.id)}this.tileBounds=Sd.fromTileJSON(m)}loaded(){return this._loaded}hasTile(m){return!this.tileBounds||this.tileBounds.contains(m.canonical)}onAdd(m){this.map=m,this.load()}reload(){this.cancelTileJSONRequest();const m=i.F(this.id,this.scope);this.load(()=>this.map.style.clearSource(m))}setTiles(m){return this._options.tiles=m,this.reload(),this}setUrl(m){return this.url=m,this._options.url=m,this.reload(),this}onRemove(m){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}loadTile(m,v){const E=m.tileID.canonical.url(this.tiles,this.scheme),D=this.map._requestManager.normalizeTileURL(E),z=this.map._requestManager.transformRequest(D,i.R.Tile),$=this.map.style?this.map.style.getLut(this.scope):null,K=$?{image:$.image.clone()}:null,ee={request:z,data:void 0,uid:m.uid,tileID:m.tileID,tileZoom:m.tileZoom,zoom:m.tileID.overscaledZ,maxZoom:this.maxzoom,lut:K,tileSize:this.tileSize*m.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:i.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,renderSourceType:m.renderSourceType,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:m.isExtraShadowCaster,tessellationStep:this.map._tessellationStep,scaleFactor:this.map.getScaleFactor(),worldview:this.map.getWorldview()||this.worldviewDefault,indoor:this.map.getIndoorTileOptions(this.id,this.scope)};if(this.hasWorldviews&&i.e(E)&&(ee.localizableLayerIds=this.localizableLayerIds),ee.request.collectResourceTiming=this._collectResourceTiming,m.actor&&m.state!=="expired")m.state==="loading"?m.reloadCallback=v:m.request=m.actor.send("reloadTile",ee,ne.bind(this));else if(m.actor=this._tileWorkers[D]=this._tileWorkers[D]||this.dispatcher.getActor(),this.dispatcher.ready||this.provider)m.request=m.actor.send("loadTile",ee,ne.bind(this),void 0,!0);else{const de=i.aO.call({deduped:this._deduped},ee,(we,be)=>{if(we||!be)ne.call(this,we);else{const Ae=i.aP(be.responseHeaders);ee.data={rawData:be.rawData.slice(0),expires:Ae.expires,cacheControl:Ae.cacheControl},m.actor&&m.actor.send("loadTile",ee,ne.bind(this),void 0,!0)}},!0);m.request={cancel:de}}function ne(de,we){return delete m.request,m.aborted?v(null):de?v(de):(we&&we.resourceTiming&&(m.resourceTiming=we.resourceTiming),this.map._refreshExpiredTiles&&we&&m.setExpiryData(we),m.loadVectorData(we,this.map.painter),i.aQ(this.dispatcher),v(null,we),void(m.reloadCallback&&(this.loadTile(m,m.reloadCallback),m.reloadCallback=null)))}}abortTile(m){m.request&&(m.request.cancel(),delete m.request),m.actor&&m.actor.send("abortTile",{uid:m.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(m,v){m.actor&&m.actor.send("removeTile",{uid:m.uid,type:this.type,source:this.id,scope:this.scope}),m.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class L0 extends i.E{constructor(m,v,E,D){super(),this.id=m,this.dispatcher=E,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.aJ(v,["url","scheme","tileSize"]))}load(m){this._loaded=!1,this.fire(new i.C("dataloading",{dataType:"source"}));const v=this.map.getWorldview();this._tileJSONRequest=Wu(this._options,this.map._requestManager,null,v,(E,D)=>{this._tileJSONRequest=null,this._loaded=!0,E?this.fire(new i.B(E)):D&&(Object.assign(this,D),D.raster_layers&&(this.rasterLayers=D.raster_layers,this.rasterLayerIds=this.rasterLayers.map(z=>z.id)),this.tileBounds=Sd.fromTileJSON(D),qe(D.tiles),this.fire(new i.C("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.C("data",{dataType:"source",sourceDataType:"content"}))),m&&m(E)})}loaded(){return this._loaded}onAdd(m){this.map=m,this.load()}reload(){this.cancelTileJSONRequest();const m=i.F(this.id,this.scope);this.load(()=>this.map.style.clearSource(m))}setTiles(m){return this._options.tiles=m,this.reload(),this}setUrl(m){return this.url=m,this._options.url=m,this.reload(),this}onRemove(m){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}hasTile(m){return!this.tileBounds||this.tileBounds.contains(m.canonical)}loadTile(m,v){const E=i.o.devicePixelRatio>=2,D=this.map._requestManager.normalizeTileURL(m.tileID.canonical.url(this.tiles,this.scheme),E,this.tileSize);m.request=i.n(this.map._requestManager.transformRequest(D,i.R.Tile),(z,$,K)=>{if(delete m.request,m.aborted)return m.state="unloaded",v(null);if(z)return m.state="errored",v(z);if(!$)return v(null);const ee=i.aP(K);this.map._refreshExpiredTiles&&m.setExpiryData(ee),m.setTexture($,this.map.painter),m.state="loaded",i.aQ(this.dispatcher),v(null)})}abortTile(m,v){m.request&&(m.request.cancel(),delete m.request),v&&v()}unloadTile(m,v){m.texture&&m.texture instanceof i.T?(m.destroy(!1),m.texture&&m.texture instanceof i.T&&this.map.painter.saveTileTexture(m.texture)):m.destroy(),v&&v()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function Aw([M,m],v,E,{scaled:D=!0}={}){const{tileSize:z,buffer:$}=E,{x:K,y:ee,z:ne}=v;if(!isFinite(K)||!isFinite(ee)||!isFinite(ne))throw new Error("Invalid MRT header");const de=2**ne,we=de*i.aH(M),be=de*i.aL(m);return function([Ae,ze],Le,{scaled:rt=!0}={}){if(!Le)throw new Error("bandView is undefined");const{data:st,tileSize:dt,buffer:pt,offset:at,scale:Bt,dimension:wt}=Le;if(Ae<-pt||Ae>dt+pt||ze<-pt||ze>dt+pt)throw new Error(`Point (${Ae}, ${ze}) out of bounds for tileSize=${dt}, buffer=${pt}`);const Ft=(ze+pt)*(dt+2*pt)+(Ae+pt);if(new Uint32Array(st.buffer)[Ft]===4294967295)return null;let ft=[];ft=rt?[]:new Le.data.constructor(wt);for(let _t=0;_t{if(delete m.request,m.aborted)return m.state="unloaded",v(null);if(K)return K.name==="AbortError"?void 0:(m.state="errored",v(K));if(this.map._refreshExpiredTiles&&ee){const de=i.aP(ne);m.setExpiryData(de)}if(this.partial&&m.state!=="expired")m.state="empty";else if(!this.partial){if(!ee)return v(null);m.state="loaded",m._isHeaderLoaded=!0,m._mrt=ee}v(null)};m.request=this.partial?m.fetchHeader(void 0,$.bind(this)):m.actor.send("loadTile",z,$.bind(this),void 0,!0)}abortTile(m){m.request&&(m.request.cancel(),delete m.request),m.actor&&m.actor.send("abortTile",{uid:m.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(m,v){const E=m.texturePerLayer;if(m.flushAllQueues(),E.size){m.destroy(!1);for(const D of E.values())this.map.painter.saveTileTexture(D)}else m.destroy()}prepareTile(m,v,E,D){m._isHeaderLoaded&&(m.state!=="empty"&&(m.state="reloading"),m.fetchBandForRender(v,E,D,(z,$)=>{z?(m.state="errored",this.fire(new i.B(z))):$&&(m._isHeaderLoaded=!0,m.setTexturePerLayer(E,$,this.map.painter),m.state="loaded"),this.triggerRepaint(m)}))}getInitialBand(m){if(!this.rasterLayers)return 0;const v=this.rasterLayers.find(({id:z})=>z===m),E=v&&v.fields,D=E&&E.bands&&E.bands;return D?D[0]:0}getTextureDescriptor(m,v,E){if(!m)return;const D=v.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!D)return;let z=null;v instanceof i.aS?z=v.paint.get("raster-array-band"):v instanceof i.aT&&(z=v.paint.get("raster-particle-array-band"));const $=z||this.getInitialBand(D);if($==null)return;if(!m.textureDescriptorPerLayer.get(v.id))return void this.prepareTile(m,D,v.id,$);if(m.updateNeeded(v.id,$)&&!E)return;const K=m.textureDescriptorPerLayer.get(v.id);return Object.assign({},K,{texture:m.texturePerLayer.get(v.id)})}getImages(m,v){const E=new Map;for(const D of m)for(const z of v){const[$,K]=z.split("/"),ee=D.getLayer($);if(!ee||!ee.hasBand(K)||!ee.hasDataForBand(K))continue;const{bytes:ne,tileSize:de,buffer:we}=ee.getBandView(K),be=de+2*we,Ae={data:new i.q({width:be,height:be},ne),pixelRatio:2,sdf:!1,usvg:!1,version:0};E.set(z,Ae)}return E}queryRasterArrayValueByBandId(m,v,E){const D=v._mrt;return new Promise(z=>{const $={},K=new Set;for(const[ee,ne]of Object.entries(D.layers)){if(E.layerName&&ee!==E.layerName)continue;const de={};$[ee]=de;for(const{bands:we}of ne.dataIndex)for(const be of we)E.bands&&!E.bands.includes(be)||(K.add(i.F(ee,be)),v.fetchBand(ee,null,be,Ae=>{i.o.frame(()=>{de[be]=Ae?null:Aw([m.lng,m.lat],D,ne.getBandView(be)),K.delete(i.F(ee,be)),K.size===0&&z($)})},!1))}K.size===0&&z($)})}_loadTileForQuery(m,v){if(this._loadTileLoaded[m.uid])return void v(null,m._mrt);if(this._loadTilePending[m.uid])return void this._loadTilePending[m.uid].push(v);this._loadTilePending[m.uid]=[v];const E=this.map._requestManager.normalizeTileURL(m.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),D=this.map._requestManager.transformRequest(E,i.R.Tile);m.actor.send("loadTile",{request:D,uid:m.uid,tileID:m.tileID,type:this.type,source:this.id,scope:this.scope,partial:!1},(z,$,K)=>{if(z)return this._loadTilePending[m.uid].forEach(ee=>ee(z,null)),void delete this._loadTilePending[m.uid];if(!$)return this._loadTilePending[m.uid].forEach(ee=>ee(null,null)),void delete this._loadTilePending[m.uid];if(this.map._refreshExpiredTiles&&$){const ee=i.aP(K);m.setExpiryData(ee)}m._mrt=$,m._isHeaderLoaded=!0,m.state="loaded",this._loadTilePending[m.uid].forEach(ee=>ee(null,$)),this._loadTileLoaded[m.uid]=!0,delete this._loadTilePending[m.uid]},void 0,!0)}queryRasterArrayValueByAllBands(m,v,E){return new Promise((D,z)=>{this._loadTileForQuery(v,($,K)=>{$?z($):D(K?this.queryRasterArrayValueByBandId(m,v,E):null)})})}queryRasterArrayValue(m,v){const E=i.aU.convert(m),D=this.findLoadedParent(E);return D&&D._mrt?v.bands||!this.partial?this.queryRasterArrayValueByBandId(E,D,v):this.queryRasterArrayValueByAllBands(E,D,v):Promise.resolve(null)}findLoadedParent(m){const v=i.ag.fromLngLat(m,this.map.transform.tileSize),E=this.maxzoom+1,D=1<0&&(K[new i.aR(M.overscaledZ,D,m.z,E,m.y-1).key]={backfilled:!1},K[new i.aR(M.overscaledZ,M.wrap,m.z,m.x,m.y-1).key]={backfilled:!1},K[new i.aR(M.overscaledZ,$,m.z,z,m.y-1).key]={backfilled:!1}),m.y+1{if(this._loaded=!0,this._pendingLoad=null,E)this.fire(new i.B(E));else{const z={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&D&&D.resourceTiming&&D.resourceTiming[this.id]&&(z.resourceTiming=D.resourceTiming[this.id]),M&&(this._partialReload=!0),this.fire(new i.C("data",z)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(M),this._coalesce=!1)})}loaded(){return this._loaded}reload(){const M=i.F(this.id,this.scope);this.map.style.clearSource(M),this._updateWorkerData()}loadTile(M,m){const v=M.actor?"reloadTile":"loadTile";M.actor=this.actor;const E=this.map.style?this.map.style.getLut(this.scope):null,D=E?{image:E.image.clone()}:null,z=this._partialReload,$={type:this.type,uid:M.uid,tileID:M.tileID,tileZoom:M.tileZoom,zoom:M.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,lut:D,scope:this.scope,pixelRatio:i.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:M.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:z,worldview:this.map.getWorldview(),indoor:this.map.getIndoorTileOptions(this.id,this.scope)};M.request=this.actor.send(v,$,(K,ee)=>z&&!ee?(M.state="loaded",m(null)):(delete M.request,M.destroy(!1),M.aborted?m(null):K?m(K):(M.loadVectorData(ee,this.map.painter,v==="reloadTile"),m(null))),void 0,v==="loadTile")}abortTile(M){M.request&&(M.request.cancel(),delete M.request),M.aborted=!0}unloadTile(M,m){this.actor.send("removeTile",{uid:M.uid,type:this.type,source:this.id,scope:this.scope}),M.destroy()}onRemove(M){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return Object.assign({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends i.aV{constructor(M,m,v,E){super(M,m,v,E),this.roundZoom=!0,this.type="video",this.options=m}load(){this._loaded=!1;const M=this.options;this.urls=[];for(const m of M.urls)this.urls.push(this.map._requestManager.transformRequest(m,i.R.Source).url);i.aW(this.urls,(m,v)=>{this._loaded=!0,m?this.fire(new i.B(m)):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(M){if(this.video){const m=this.video.seekable;Mm.end(0)?this.fire(new i.B(new i.V(`sources.${this.id}`,null,`Playback for this video can be set only between the ${m.start(0)} and ${m.end(0)}-second mark.`))):this.video.currentTime=M}}getVideo(){return this.video}onAdd(M){this.map||(this.map=M,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const M=this.map.painter.context,m=M.gl;this.texture?this.video.paused||(this.texture.bind(m.LINEAR,m.CLAMP_TO_EDGE),m.texSubImage2D(m.TEXTURE_2D,0,0,0,m.RGBA,m.UNSIGNED_BYTE,this.video)):(this.texture=new i.T(M,this.video,m.RGBA8),this.texture.bind(m.LINEAR,m.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(M)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:i.aV,model:i.aY,"batched-model":class extends i.E{constructor(M,m,v,E){super(),this.type="batched-model",this.id=M,this.tileSize=512,this._options=m,this.tiles=this._options.tiles,this.maxzoom=m.maxzoom||19,this.minzoom=m.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=v,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(E)}onAdd(M){this.map=M,this.load()}reload(){this.cancelTileJSONRequest();const M=i.F(this.id,this.scope);this.load(()=>this.map.style.clearSource(M))}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}load(M){this._loaded=!1,this.fire(new i.C("dataloading",{dataType:"source"}));const m=Array.isArray(this.map._language)?this.map._language.join():this.map._language,v=this.map.getWorldview();this._tileJSONRequest=Wu(this._options,this.map._requestManager,m,v,(E,D)=>{this._tileJSONRequest=null,this._loaded=!0,E?(m&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${m}`),v&&v.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${v}`),this.fire(new i.B(E))):D&&(Object.assign(this,D),D.bounds&&(this.tileBounds=new Sd(D.bounds,this.minzoom,this.maxzoom)),qe(D.tiles,this.map._requestManager._customAccessToken),this.fire(new i.C("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.C("data",{dataType:"source",sourceDataType:"content"}))),M&&M(E)})}hasTransition(){return!1}hasTile(M){return!this.tileBounds||this.tileBounds.contains(M.canonical)}loaded(){return this._loaded}loadTile(M,m){const v=this.map._requestManager.normalizeTileURL(M.tileID.canonical.url(this.tiles,this.scheme)),E={request:this.map._requestManager.transformRequest(v,i.R.Tile),data:void 0,uid:M.uid,tileID:M.tileID,tileZoom:M.tileZoom,zoom:M.tileID.overscaledZ,tileSize:this.tileSize*M.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,renderSourceType:M.renderSourceType,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:i.o.devicePixelRatio,promoteId:this.promoteId};if(M.actor&&M.state!=="expired")if(M.state==="loading")M.reloadCallback=m;else{if(M.buckets){const z=Object.values(M.buckets);for(const $ of z)$.dirty=!0;return void(M.state="loaded")}M.request=M.actor.send("reloadTile",E,D.bind(this))}else M.actor=this.dispatcher.getActor(),M.request=M.actor.send("loadTile",E,D.bind(this),void 0,!0);function D(z,$){return M.aborted?m(null):z&&z.status!==404?m(z):(this.map._refreshExpiredTiles&&$&&M.setExpiryData($),M.loadModelData($,this.map.painter),M.state="loaded",void m(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends i.aV{constructor(M,m,v,E){super(M,m,v,E),m.coordinates?Array.isArray(m.coordinates)&&m.coordinates.length===4&&!m.coordinates.some(D=>!Array.isArray(D)||D.length!==2||D.some(z=>typeof z!="number"))||this.fire(new i.B(new i.V(`sources.${M}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.B(new i.V(`sources.${M}`,null,'missing required property "coordinates"'))),m.animate&&typeof m.animate!="boolean"&&this.fire(new i.B(new i.V(`sources.${M}`,null,'optional "animate" property must be a boolean value'))),m.canvas?typeof m.canvas=="string"||m.canvas instanceof HTMLCanvasElement||this.fire(new i.B(new i.V(`sources.${M}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new i.B(new i.V(`sources.${M}`,null,'missing required property "canvas"'))),this.options=m,this.animate=m.animate===void 0||m.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.B(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(M){this.map=M,this.load(),this.canvas&&this.animate&&this.play()}onRemove(M){this.pause()}prepare(){let M=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,M=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,M=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const m=this.map.painter.context;this.texture?!M&&!this._playing||this.texture instanceof i.aX||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new i.T(m,this.canvas,m.gl.RGBA8,{premultiply:!0}),this._prepareData(m)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const M of[this.canvas.width,this.canvas.height])if(isNaN(M)||M<=0)return!0;return!1}},custom:class extends i.E{constructor(M,m,v,E){super(),this.id=M,this.type="custom",this._dataType="raster",this._dispatcher=v,this._implementation=m,this.setEventedParent(E),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new i.B(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new i.B(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new Sd(this._implementation.bounds,this.minzoom,this.maxzoom));const D=m;D.update=this._update.bind(this),D.clearTiles=this._clearTiles.bind(this),D.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,i.aJ(m,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return i.aJ(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new i.C("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.C("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(M){this.map=M,this._loaded=!1,this.fire(new i.C("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(M),this.load()}onRemove(M){this._implementation.onRemove&&this._implementation.onRemove(M)}hasTile(M){if(this._implementation.hasTile){const{x:m,y:v,z:E}=M.canonical;return this._implementation.hasTile({x:m,y:v,z:E})}return!this.tileBounds||this.tileBounds.contains(M.canonical)}loadTile(M,m){const{x:v,y:E,z:D}=M.tileID.canonical,z=new AbortController,$=Promise.resolve(this._implementation.loadTile({x:v,y:E,z:D},{signal:z.signal})).then((function(K){return delete M.request,M.aborted?(M.state="unloaded",m(null)):K===void 0?(M.state="errored",m(null)):K===null?(this.loadTileData(M,{width:this.tileSize,height:this.tileSize,data:null}),M.state="loaded",m(null)):function(ee){return ee instanceof ImageData||ee instanceof HTMLCanvasElement||ee instanceof ImageBitmap||ee instanceof HTMLImageElement}(K)?(this.loadTileData(M,K),M.state="loaded",void m(null)):(M.state="errored",m(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}).bind(this)).catch(K=>{K.name!=="AbortError"&&(M.state="errored",m(K))});$.cancel=()=>z.abort(),M.request=$}loadTileData(M,m){M.setTexture(m,this.map.painter)}unloadTile(M,m){if(M.texture&&M.texture instanceof i.T?(M.destroy(!1),M.texture&&M.texture instanceof i.T&&this.map.painter.saveTileTexture(M.texture)):M.destroy(),this._implementation.unloadTile){const{x:v,y:E,z:D}=M.tileID.canonical;this._implementation.unloadTile({x:v,y:E,z:D})}m&&m()}abortTile(M,m){M.request&&M.request.cancel&&(M.request.cancel(),delete M.request),m&&m()}hasTransition(){return!1}_coveringTiles(){return this.map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(M=>({x:M.canonical.x,y:M.canonical.y,z:M.canonical.z}))}_clearTiles(){const M=i.F(this.id,this.scope);this.map.style.clearSource(M)}_update(){this.fire(new i.C("data",{dataType:"source",sourceDataType:"content"}))}}},Sp=function(M,m,v,E){const D=new kp[m.type](M,m,v,E);if(D.id!==M)throw new Error(`Expected Source id to be ${M} instead of ${D.id}`);return i.aZ(["load","abort","unload","serialize","prepare"],D),D};function Ew(M,m,v=""){return`${v}:${m.id||""}:${m.layer.id}:${function(E){if("layerId"in E)return`layer:${E.layerId}`;{const{featuresetId:D,importId:z}=E;return`featureset:${D}${z?`:import:${z}`:""}`}}(M.target)}`}function Kh(M,m,v,E=""){if(M.uniqueFeatureID){const D=Ew(M,m,E);if(v.has(D))return!0;v.add(D)}return!1}function Cf(M,m,v,E,D=!1,z=void 0){const $=m.sourceCache.transform,K=m.sourceCache.tilesIn(M,m.has3DLayers,D);K.sort(Bx);const ee=[];for(const ne of K){const de=ne.tile.queryRenderedFeatures(m,ne,v,E,$,D,z);Object.keys(de).length&&ee.push({wrappedTileID:ne.tile.tileID.wrapped().key,queryResults:de})}for(const ne in m.layers){const de=m.layers[ne];if(de.styleLayer){const we=de.styleLayer.queryRenderedFeatures(M,m.sourceCache,E);Object.keys(we).length&&ee.push({wrappedTileID:0,queryResults:we})}}return ee.length===0?{}:function(ne){const de={},we={};for(const be of ne){const Ae=be.queryResults,ze=be.wrappedTileID,Le=we[ze]=we[ze]||{};for(const rt in Ae){const st=Ae[rt],dt=Le[rt]=Le[rt]||{},pt=de[rt]=de[rt]||[];for(const at of st)dt[at.featureIndex]||(dt[at.featureIndex]=!0,pt.push(at))}}return de}(ee)}function zx(M,m,v,E,D,z){const $={},K=E.queryRenderedSymbols(M),ee=[];for(const ne of Object.keys(K).map(Number))ee.push(D[ne]);ee.sort(Bx);for(const ne of ee){const de=ne.featureIndex.lookupSymbolFeatures(K[ne.bucketInstanceId],ne.bucketIndex,ne.sourceLayerIndex,m,v,z);for(const we in de){const be=$[we]=$[we]||[],Ae=de[we];Ae.sort((ze,Le)=>{const rt=ne.featureSortOrder;if(rt){const st=rt.indexOf(ze.featureIndex);return rt.indexOf(Le.featureIndex)-st}return Le.featureIndex-ze.featureIndex});for(const ze of Ae)be.push(ze)}}return $}function Md(M,m){const v=M.getRenderableIds().map(z=>M.getTileByID(z)),E=[],D={};for(let z=0;z{if(z)v(z);else try{const ee=E.getHeaderLength($);if(ee>m)return void(this.request=this.fetchHeader(ee,v));E.parseHeader($),this._isHeaderLoaded=!0;let ne=0;for(const de of Object.values(E.layers))ne=Math.max(ne,de.dataIndex[de.dataIndex.length-1].lastByte);$.byteLength>=ne&&(this.entireBuffer=$),v(null,this.entireBuffer||$,K)}catch(ee){v(ee)}}),this.request}fetchBandForRender(m,v,E,D){this.fetchBand(m,v,E,z=>{if(z)return void D(z);this.updateTextureDescriptor(m,v,E);const $=this.textureDescriptorPerLayer.get(v);D(null,$?$.img:null)})}fetchBand(m,v,E,D,z=!0){const $=this._mrt;if(!this._isHeaderLoaded||!$)return void D(new Error("Tile header is not ready"));const K=this.actor;if(!K)return void D(new Error("Can't fetch tile band without an actor"));let ee;const ne=i.F(String(E),i.F(this.tileID.key,m));let de=this._taskQueue.get(ne);de?de.add(D):(de=new Set,de.add(D),this._taskQueue.set(ne,de));const we=(Le,rt)=>{ee.complete(Le,rt),Le?D(Le):(de.forEach(st=>st(null,rt)),this._taskQueue.delete(ne))},be=(Le,rt)=>{if(Le)return D(Le);const st=K.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:rt,task:ee},we,void 0,!0);if(v!==null){const dt=this._workQueuePerLayer.get(v)||[];dt.push(()=>{st&&st.cancel(),ee.cancel()}),this._workQueuePerLayer.has(v)||this._workQueuePerLayer.set(v,dt)}};let Ae;try{Ae=$.getLayer(m)}catch(Le){if(this.state==="reloading")return;throw Le}if(!Ae)return void D(new Error(`Unknown sourceLayer "${m}"`));if(Ae.hasDataForBand(E))return de.forEach(Le=>Le(null,null)),void this._taskQueue.delete(ne);const ze=Ae.getDataRange([E]);if(ee=$.createDecodingTask(ze),!ee||ee.tasks.length)if(v!==null&&this.flushQueues(v),this.entireBuffer)be(null,this.entireBuffer.slice(ze.firstByte,ze.lastByte+1));else{const Le=Object.assign({},this.requestParams,{headers:{Range:`bytes=${ze.firstByte}-${ze.lastByte}`}}),rt=i.b1(Le,be);if(v!==null){const st=this._fetchQueuePerLayer.get(v)||[];st.push(()=>{rt.cancel(),ee.cancel()}),this._fetchQueuePerLayer.has(v)||this._fetchQueuePerLayer.set(v,st)}}}updateNeeded(m,v){return(!this.textureDescriptorPerLayer.get(m)||this.textureDescriptorPerLayer.get(m).band!==v||this.refreshedUponExpiration)&&this.state!=="errored"}updateTextureDescriptor(m,v,E){if(!this._mrt)return;const D=this._mrt.getLayer(m);if(!D||!D.hasBand(E)||!D.hasDataForBand(E))return;const{bytes:z,tileSize:$,buffer:K,offset:ee,scale:ne}=D.getBandView(E),de=$+2*K,we=new i.q({width:de,height:de},z),be=this.texturePerLayer.get(v);be&&be instanceof i.T&&be.update(we,{premultiply:!1}),this.textureDescriptorPerLayer.set(v,{layer:m,band:E,img:we,buffer:K,offset:ee,tileSize:$,format:D.pixelFormat,mix:[ne,256*ne,65536*ne,16777216*ne]})}destroy(m=!1){if(super.destroy(m),delete this._mrt,!m)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 Wd{constructor(m,v){this.max=m,this.onRemove=v,this.reset()}reset(){for(const m in this.data)for(const v of this.data[m])v.timeout&&clearTimeout(v.timeout),this.onRemove(v.value);return this.data={},this.order=[],this}add(m,v,E){const D=m.wrapped().key;this.data[D]===void 0&&(this.data[D]=[]);const z={value:v,timeout:void 0};if(E!==void 0&&(z.timeout=setTimeout(()=>{this.remove(m,z)},E)),this.data[D].push(z),this.order.push(D),this.order.length>this.max){const $=this._getAndRemoveByKey(this.order[0]);$&&this.onRemove($)}return this}has(m){return m.wrapped().key in this.data}getAndRemove(m){return this.has(m)?this._getAndRemoveByKey(m.wrapped().key):null}_getAndRemoveByKey(m){const v=this.data[m].shift();return v.timeout&&clearTimeout(v.timeout),this.data[m].length===0&&delete this.data[m],this.order.splice(this.order.indexOf(m),1),v.value}getByKey(m){const v=this.data[m];return v?v[0].value:null}get(m){return this.has(m)?this.data[m.wrapped().key][0].value:null}remove(m,v){if(!this.has(m))return this;const E=m.wrapped().key,D=v===void 0?0:this.data[E].indexOf(v),z=this.data[E][D];return this.data[E].splice(D,1),z.timeout&&clearTimeout(z.timeout),this.data[E].length===0&&delete this.data[E],this.onRemove(z.value),this.order.splice(this.order.indexOf(E),1),this}setMaxSize(m){for(this.max=m;this.order.length>this.max;){const v=this._getAndRemoveByKey(this.order[0]);v&&this.onRemove(v)}return this}filter(m){const v=[];for(const E in this.data)for(const D of this.data[E])m(D.value)||v.push(D);for(const E of v)this.remove(E.value.tileID,E)}}class Pw{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(m,v,E){const D=String(v);if(this.stateChanges[m]=this.stateChanges[m]||{},this.stateChanges[m][D]=this.stateChanges[m][D]||{},Object.assign(this.stateChanges[m][D],E),this.deletedStates[m]===null){this.deletedStates[m]={};for(const z in this.state[m])z!==D&&(this.deletedStates[m][z]=null)}else if(this.deletedStates[m]&&this.deletedStates[m][D]===null){this.deletedStates[m][D]={};for(const z in this.state[m][D])E[z]||(this.deletedStates[m][D][z]=null)}else for(const z in E)this.deletedStates[m]&&this.deletedStates[m][D]&&this.deletedStates[m][D][z]===null&&delete this.deletedStates[m][D][z]}removeFeatureState(m,v,E){if(this.deletedStates[m]===null)return;const D=String(v);if(this.deletedStates[m]=this.deletedStates[m]||{},E&&v!==void 0)this.deletedStates[m][D]!==null&&(this.deletedStates[m][D]=this.deletedStates[m][D]||{},this.deletedStates[m][D][E]=null);else if(v!==void 0)if(this.stateChanges[m]&&this.stateChanges[m][D])for(E in this.deletedStates[m][D]={},this.stateChanges[m][D])this.deletedStates[m][D][E]=null;else this.deletedStates[m][D]=null;else this.deletedStates[m]=null}getState(m,v){const E=this.state[m]||{},D=this.stateChanges[m]||{},z=this.deletedStates[m];if(z===null)return{};if(v!==void 0){const K=String(v),ee=Object.assign({},E[K],D[K]);if(z){const ne=z[v];if(ne===null)return{};for(const de in ne)delete ee[de]}return ee}const $=Object.assign({},E,D);if(z)for(const K in z)delete $[K];return $}initializeTileState(m,v){m.refreshFeatureState(v)}coalesceChanges(m,v){const E={};for(const D in this.stateChanges){this.state[D]=this.state[D]||{};const z={};for(const $ in this.stateChanges[D])this.state[D][$]||(this.state[D][$]={}),Object.assign(this.state[D][$],this.stateChanges[D][$]),z[$]=this.state[D][$];E[D]=z}for(const D in this.deletedStates){this.state[D]=this.state[D]||{};const z={};if(this.deletedStates[D]===null)for(const $ in this.state[D])z[$]={},this.state[D][$]={};else for(const $ in this.deletedStates[D]){if(this.deletedStates[D][$]===null)this.state[D][$]={};else if(this.state[D][$])for(const K of Object.keys(this.deletedStates[D][$]))delete this.state[D][$][K];z[$]=this.state[D][$]}E[D]=E[D]||{},Object.assign(E[D],z)}if(this.stateChanges={},this.deletedStates={},Object.keys(E).length!==0)for(const D in m)m[D].refreshFeatureState(v,E)}}class yh extends i.E{constructor(m,v,E){super(),this.id=m,this._renderSourceType=E,this._maxzoomOverride=null,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 Wd(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 Pw,this._isRaster=this._source.type==="raster"||this._source.type==="raster-dem"||this._source.type==="raster-array"||this._source.type==="custom"&&"_dataType"in this._source&&this._source._dataType==="raster",this._supportsFading=this._source.type==="raster"||this._source.type==="raster-array"||this._source.type==="image"||this._source.type==="video"||this._source.type==="custom",this._isRasterElevatedOverTerrain=!1}onAdd(m){this.map=m,this._minTileCacheSize=this._minTileCacheSize===void 0&&m?m._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&m?m._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const m in this._tiles)if(!this._tiles[m].loaded())return!1;return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const m=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,m&&this.reload(),this.transform&&this.update(this.transform)}setMaxzoomOverride(m){this._maxzoomOverride=m}_loadTile(m,v){return m.renderSourceType=this._renderSourceType,m.isExtraShadowCaster=this._shadowCasterTiles[m.tileID.key],this._source.loadTile(m,v)}_unloadTile(m){if(this._source.unloadTile)return this._source.unloadTile(m)}_abortTile(m){if(this._source.abortTile)return this._source.abortTile(m)}serialize(){return this._source.serialize()}prepare(m){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const v in this._tiles){const E=this._tiles[v];E.upload(m,this.map?this.map.painter:void 0),E.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return Object.values(this._tiles).map(m=>m.tileID).sort(Qg).map(m=>m.key)}getRenderableIds(m,v){const E=[];for(const D in this._tiles)this._isIdRenderable(+D,m,v)&&E.push(this._tiles[D]);return m?E.sort((D,z)=>{const $=D.tileID,K=z.tileID,ee=new i.P($.canonical.x,$.canonical.y)._rotate(this.transform.angle),ne=new i.P(K.canonical.x,K.canonical.y)._rotate(this.transform.angle);return $.overscaledZ-K.overscaledZ||ne.y-ee.y||ne.x-ee.x}).map(D=>D.tileID.key):E.map(D=>D.tileID).sort(Qg).map(D=>D.key)}hasRenderableParent(m){const v=this.findLoadedParent(m,0);return!!v&&this._isIdRenderable(v.tileID.key)}_isIdRenderable(m,v,E){return this._tiles[m]&&this._tiles[m].hasData()&&!this._coveredTiles[m]&&(v||!this._tiles[m].holdingForFade())&&(E||!this._shadowCasterTiles[m])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const m in this._tiles)this._tiles[m].state!=="errored"&&this._reloadTile(+m,"reloading")}}_reloadTile(m,v){const E=this._tiles[m];E&&(E.state!=="loading"&&(E.state=v),this._loadTile(E,this._tileLoaded.bind(this,E,m,v)))}_tileLoaded(m,v,E,D,z){if(D){if(m.state="errored",i.b2(D)){if(this._source.fire(new i.C("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:m})),!(m.tileID.key in this._loadedParentTiles))return;if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){const K=this.map.painter.terrain;this.update(this.transform,K.getScaledDemTileSize(),!0),K.resetTileLookupCache(this.id)}else this.update(this.transform)}else this._source.fire(new i.B(D,{tile:m}));return}m.timeAdded=i.o.now(),E==="expired"&&(m.refreshedUponExpiration=!0),this._setTileReloadTimer(v,m),this._source.type==="raster-dem"&&m.dem&&this._backfillDEM(m),this._state.initializeTileState(m,this.map?this.map.painter:null);let $=new Map;z&&z.responseHeaders&&($=z.responseHeaders),this._source.fire(new i.C("data",{dataType:"source",tile:m,coord:m.tileID,sourceCacheId:this.id,responseHeaders:$}))}_hasTunnelGeometry(){for(const m in this._tiles){const v=this._tiles[m];if(v&&v.hasTunnelGeometry)return!0}return!1}_backfillDEM(m){const v=this.getRenderableIds();for(let D=0;D1||(Math.abs($)>1&&(Math.abs($+ee)===1?$+=ee:Math.abs($-ee)===1&&($-=ee)),z.dem&&D.dem&&(D.dem.backfillBorder(z.dem,$,K),D.neighboringTiles&&D.neighboringTiles[ne]&&(D.neighboringTiles[ne].backfilled=!0)))}}getTile(m){return this.getTileByID(m.key)}getTileByID(m){return this._tiles[m]}_retainLoadedChildren(m,v,E,D){for(const z in this._tiles){let $=this._tiles[z];if(D[z]||!$.hasData()||$.tileID.overscaledZ<=v||$.tileID.overscaledZ>E)continue;let K=$.tileID;for(;$&&$.tileID.overscaledZ>v+1;){const ne=$.tileID.scaledTo($.tileID.overscaledZ-1);$=this._tiles[ne.key],$&&$.hasData()&&(K=ne)}let ee=K;for(;ee.overscaledZ>v;)if(ee=ee.scaledTo(ee.overscaledZ-1),m[ee.key]){D[K.key]=K;break}}}findLoadedParent(m,v){if(m.key in this._loadedParentTiles){const E=this._loadedParentTiles[m.key];return E&&E.tileID.overscaledZ>=v?E:null}for(let E=m.overscaledZ-1;E>=v;E--){const D=m.scaledTo(E),z=this._getLoadedTile(D);if(z)return z}}_getLoadedTile(m){const v=this._tiles[m.key];return v&&v.hasData()?v:this._cache.getByKey(this._source.reparseOverscaled?m.wrapped().key:m.canonical.key)}updateCacheSize(m,v){v=v||this._source.tileSize;const E=Math.ceil(m.width/v)+1,D=Math.ceil(m.height/v)+1,z=Math.floor(E*D*5),$=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,z):z,K=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,$):$;this._cache.setMaxSize(K)}handleWrapJump(m){const v=Math.round((m-(this._prevLng===void 0?m:this._prevLng))/360);if(this._prevLng=m,v){const E={};for(const D in this._tiles){const z=this._tiles[D];z.tileID=z.tileID.unwrapTo(z.tileID.wrap+v),E[z.tileID.key]=z}this._tiles=E;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(m,v,E,D,z){if(this.transform=m,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!E)return;this.updateCacheSize(m,v),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const $=this._source.type==="batched-model";let K,ee=this._source.maxzoom;this._maxzoomOverride!==null&&(ee=Math.min(ee,this._maxzoomOverride));const ne=this.map&&this.map.painter?this.map.painter._terrain:null;if(ne&&ne.sourceCache===this&&ne.attenuationRange()){const Ae=ne.attenuationRange()[0],ze=Math.floor(Ae)-Math.log2(ne.getDemUpscale());ee>ze&&(ee=ze)}const de=this._maxzoomOverride===null&&this._source.reparseOverscaled;if(this.used||this.usedForTerrain){if(this._source.tileID)K=m.getVisibleUnwrappedCoordinates(this._source.tileID).map(Ae=>new i.aR(Ae.canonical.z,Ae.wrap,Ae.canonical.z,Ae.canonical.x,Ae.canonical.y));else if(this.tileCoverLift!==0){const Ae=m.clone();Ae.tileCoverLift=this.tileCoverLift,K=Ae.coveringTiles({tileSize:v||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:ee,roundZoom:this._source.roundZoom&&!E,reparseOverscaled:de,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:$}),this._source.minzoom<=1&&m.projection.name==="globe"&&(K.push(new i.aR(1,0,1,0,0)),K.push(new i.aR(1,0,1,1,0)),K.push(new i.aR(1,0,1,0,1)),K.push(new i.aR(1,0,1,1,1)))}else if(K=m.coveringTiles({tileSize:v||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:ee,roundZoom:this._source.roundZoom&&!E,reparseOverscaled:de,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:$}),this._source.hasTile){const Ae=this._source.hasTile.bind(this._source);K=K.filter(ze=>Ae(ze))}}else K=[];if(K.length>0&&this.transform.projection.name!=="globe"&&!this.usedForTerrain&&!this._supportsFading){const Ae=m.coveringZoomLevel({tileSize:v||this._source.tileSize,roundZoom:this._source.roundZoom&&!E}),ze=Math.min(Ae,ee);if($){const Le=m.extendTileCover(K,ze);for(const rt of Le)K.push(rt)}else if(z){const Le=this.transform.getFrustum(ze),rt=m.extendTileCoverToNearPlane(K,Le,ze);for(const st of rt)K.push(st);if(ze>=18&&this._hasTunnelGeometry()){const st=m.extendTileCoverForTunnels(K,Le,ze,20);for(const dt of st)K.push(dt)}}else if(this.castsShadows&&D){const Le=m.extendTileCover(K,ze,D,16);for(const rt of Le)this._shadowCasterTiles[rt.key]=!0,K.push(rt)}}const we=this._updateRetainedTiles(K);if(this._supportsFading&&K.length!==0){const Ae={},ze={},Le=i.o.now(),rt=Object.keys(we);for(const dt of rt){const pt=we[dt],at=this._tiles[dt];if(!at||at.fadeEndTime!==void 0&&at.fadeEndTime<=Le)continue;const Bt=this.findLoadedParent(pt,Math.max(pt.overscaledZ-yh.maxOverzooming,this._source.minzoom));Bt&&(this._addTile(Bt.tileID),Ae[Bt.tileID.key]=Bt.tileID),ze[dt]=pt}const st=K[K.length-1].overscaledZ;for(const dt in this._tiles){const pt=this._tiles[dt];if(we[dt]||!pt.hasData())continue;let at=pt.tileID;for(;at.overscaledZ>st;){at=at.scaledTo(at.overscaledZ-1);const Bt=this._tiles[at.key];if(Bt&&Bt.hasData()&&ze[at.key]){we[dt]=pt.tileID;break}}}for(const dt in Ae)we[dt]||(this._coveredTiles[dt]=!0,we[dt]=Ae[dt])}for(const Ae in we)this._tiles[Ae].clearFadeHold();const be=i.b3(this._tiles,we);for(const Ae of be){const ze=this._tiles[Ae];ze.hasSymbolBuckets&&!ze.holdingForFade()?ze.setHoldDuration(this.map._fadeDuration):ze.hasSymbolBuckets&&!ze.symbolFadeFinished()||this._removeTile(+Ae)}this._updateLoadedParentTileCache(),this._renderSourceType===i.b4.Symbol&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const m in this._tiles)this._tiles[m].holdingForFade()&&this._removeTile(+m)}_updateRetainedTiles(m){const v={};if(m.length===0)return v;const E={},D=m.reduce((ne,de)=>Math.min(ne,de.overscaledZ),1/0),z=m[0].overscaledZ,$=Math.max(z-yh.maxOverzooming,this._source.minzoom),K=Math.max(z+yh.maxUnderzooming,this._source.minzoom),ee={};for(const ne of m){const de=this._addTile(ne);v[ne.key]=ne,de.hasData()||D=this._source.maxzoom){const be=ne.children(this._source.maxzoom)[0],Ae=this.getTile(be);if(Ae&&Ae.hasData()){v[be.key]=be;continue}}else{const be=ne.children(this._source.maxzoom);if(v[be[0].key]&&v[be[1].key]&&v[be[2].key]&&v[be[3].key])continue}let we=de.wasRequested();for(let be=ne.overscaledZ-1;be>=$;--be){const Ae=ne.scaledTo(be);if(E[Ae.key]||(E[Ae.key]=!0,de=this.getTile(Ae),!de&&we&&(de=this._addTile(Ae)),de&&(v[Ae.key]=Ae,we=de.wasRequested(),de.hasData())))break}}return v}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const m in this._tiles){const v=[];let E,D=this._tiles[m].tileID;for(;D.overscaledZ>0;){if(D.key in this._loadedParentTiles){E=this._loadedParentTiles[D.key];break}v.push(D.key);const z=D.scaledTo(D.overscaledZ-1);if(E=this._getLoadedTile(z),E)break;D=z}for(const z of v)this._loadedParentTiles[z]=E}}_addTile(m){let v=this._tiles[m.key];if(v)return v.isExtraShadowCaster!==!0||this._shadowCasterTiles[m.key]||this._reloadTile(m.key,"reloading"),v;v=this._cache.getAndRemove(m),v&&(this._setTileReloadTimer(m.key,v),v.tileID=m,this._state.initializeTileState(v,this.map?this.map.painter:null),this._cacheTimers[m.key]&&(clearTimeout(this._cacheTimers[m.key]),delete this._cacheTimers[m.key],this._setTileReloadTimer(m.key,v)));const E=!!v;if(!E){const D=this.map?this.map.painter:null,z=this._source.tileSize*m.overscaleFactor();v=this._source.type==="raster-array"?new Cp(m,z,this.transform.tileZoom,D,this._isRaster):new i.b0(m,z,this.transform.tileZoom,D,this._isRaster,this._source.worldview),this._loadTile(v,this._tileLoaded.bind(this,v,m.key,v.state))}return v.uses++,this._tiles[m.key]=v,E||this._source.fire(new i.C("dataloading",{tile:v,coord:v.tileID,dataType:"source"})),v}_setTileReloadTimer(m,v){m in this._timers&&(clearTimeout(this._timers[m]),delete this._timers[m]);const E=v.getExpiryTimeout();E&&(this._timers[m]=setTimeout(()=>{this._reloadTile(m,"expired"),delete this._timers[m]},E))}_removeTile(m){const v=this._tiles[m];v&&(v.uses--,delete this._tiles[m],this._timers[m]&&(clearTimeout(this._timers[m]),delete this._timers[m]),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 m in this._tiles)this._removeTile(+m);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(m,v,E){const D=[],z=this.transform;if(!z)return D;const $=z.projection.name==="globe",K=i.aH(z.center.lng);for(const ee in this._tiles){const ne=this._tiles[ee];if(E&&ne.clearQueryDebugViz(),ne.holdingForFade())continue;let de;if($){const we=ne.tileID.canonical;if(we.z===0){const be=[Math.abs(i.aC(K,...Mf(we,-1))-K),Math.abs(i.aC(K,...Mf(we,1))-K)];de=[0,2*be.indexOf(Math.min(...be))-1]}else{const be=[Math.abs(i.aC(K,...Mf(we,-1))-K),Math.abs(i.aC(K,...Mf(we,0))-K),Math.abs(i.aC(K,...Mf(we,1))-K)];de=[be.indexOf(Math.min(...be))-1]}}else de=[0];for(const we of de){const be=m.containsTile(ne,z,v,we);be&&D.push(be)}}return D}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(m){return this._getRenderableCoordinates(m)}_getRenderableCoordinates(m,v){const E=this.getRenderableIds(m,v).map(z=>this._tiles[z].tileID),D=this.transform.projection.name==="globe";for(const z of E)z.projMatrix=this.transform.calculateProjMatrix(z.toUnwrapped()),z.expandedProjMatrix=D?this.transform.calculateProjMatrix(z.toUnwrapped(),!1,!0):z.projMatrix;return E}sortCoordinatesByDistance(m){const v=m.slice(),E=this.transform._camera.position,D=this.transform._camera.forward(),z={};for(const $ of v){const K=1/(1<<$.canonical.z);z[$.key]=(($.canonical.x+.5)*K+$.wrap-E[0])*D[0]+(($.canonical.y+.5)*K-E[1])*D[1]-E[2]*D[2]}return v.sort(($,K)=>z[$.key]-z[K.key]),v}hasTransition(){if(this._source.hasTransition())return!0;if(this._supportsFading){const m=i.o.now();for(const v in this._tiles){const E=this._tiles[v];if(E.fadeEndTime!==void 0&&E.fadeEndTime>=m)return!0}}return!1}setFeatureState(m,v,E){this._state.updateState(m=m||"_geojsonTileLayer",v,E)}removeFeatureState(m,v,E){this._state.removeFeatureState(m=m||"_geojsonTileLayer",v,E)}getFeatureState(m,v){return this._state.getState(m=m||"_geojsonTileLayer",v)}setDependencies(m,v,E){const D=this._tiles[m];D&&D.setDependencies(v,E)}reloadTilesForDependencies(m,v){for(const E in this._tiles)this._tiles[E].hasDependency(m,v)&&this._reloadTile(+E,"reloading");this._cache.filter(E=>!E.hasDependency(m,v))}_preloadTiles(m,v){if(!this._sourceLoaded){const ee=()=>{this._sourceLoaded&&(this._source.off("data",ee),this._preloadTiles(m,v))};return void this._source.on("data",ee)}const E=new Map,D=Array.isArray(m)?m:[m],z=this.map.painter.terrain,$=this.usedForTerrain&&z?z.getScaledDemTileSize():this._source.tileSize;for(const ee of D){const ne=ee.coveringTiles({tileSize:$,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const de of ne)E.set(de.key,de);this.usedForTerrain&&ee.updateElevation(!1)}const K=Array.from(E.values());i.t(K,(ee,ne)=>{const de=new i.b0(ee,this._source.tileSize*ee.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(de,we=>{this._source.type==="raster-dem"&&de.dem&&this._backfillDEM(de),ne(we,de)})},v)}}function Qg(M,m){const v=Math.abs(2*M.wrap)-+(M.wrap<0),E=Math.abs(2*m.wrap)-+(m.wrap<0);return M.overscaledZ-m.overscaledZ||E-v||m.canonical.y-M.canonical.y||m.canonical.x-M.canonical.x}function Mf(M,m){const v=1<0:E.type==="building"?D=!E.isHidden(m)&&E.paint.get("building-opacity")>0:E.type==="model"&&(D=!E.isHidden(m)&&E.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!D&&v.visible,v.visible=D}}updateZOffset(m,v){this.currentBuildingBuckets=[];for(const D of this.layers){const z=D.layer,$=this.style.getLayerSourceCache(z);let K=1;z.type==="fill-extrusion"?K=D.visible?z.paint.get("fill-extrusion-vertical-scale"):0:z.type==="building"&&(K=D.visible?z.paint.get("building-vertical-scale"):0);let ee=$?$.getTile(v):null;if(!ee&&$)for(const ne in $._tiles){const de=$._tiles[ne];if(v.canonical.isChildOf(de.tileID.canonical)){ee=de;break}}this.currentBuildingBuckets.push({bucket:ee?ee.getBucket(z):null,tileID:ee?ee.tileID:v,verticalScale:K})}m.hasAnyZOffset=!1;let E=!1;for(let D=0;D{E in m&&(v[E]=m[E])}),v}function P1(M){M=M.slice();const m=Object.create(null);for(const v of M)m[v.id]=v;for(let v=0;v0?(D-$)/K:0;return this.points[z].mult(1-ee).add(this.points[v].mult(ee))}}class Ct{constructor(m,v,E){const D=this.boxCells=[],z=this.circleCells=[];this.xCellCount=Math.ceil(m/E),this.yCellCount=Math.ceil(v/E);for(let $=0;$this.width||D<0||v>this.height)return!z&&[];const K=[];if(m<=0&&v<=0&&this.width<=E&&this.height<=D){if(z)return!0;for(let ee=0;ee0:K}_queryCircle(m,v,E,D,z){const $=m-E,K=m+E,ee=v-E,ne=v+E;if(K<0||$>this.width||ne<0||ee>this.height)return!D&&[];const de=[];return this._forEachCell($,ee,K,ne,this._queryCellCircle,de,{hitTest:D,circle:{x:m,y:v,radius:E},seenUids:{box:{},circle:{}}},z),D?de.length>0:de}query(m,v,E,D,z){return this._query(m,v,E,D,!1,z)}hitTest(m,v,E,D,z){return this._query(m,v,E,D,!0,z)}hitTestCircle(m,v,E,D){return this._queryCircle(m,v,E,!0,D)}_queryCell(m,v,E,D,z,$,K,ee){const ne=K.seenUids,de=this.boxCells[z];if(de!==null){const be=this.bboxes;for(const Ae of de)if(!ne.box[Ae]){ne.box[Ae]=!0;const ze=4*Ae;if(m<=be[ze+2]&&v<=be[ze+3]&&E>=be[ze+0]&&D>=be[ze+1]&&(!ee||ee(this.boxKeys[Ae]))){if(K.hitTest)return $.push(!0),!0;$.push({key:this.boxKeys[Ae],x1:be[ze],y1:be[ze+1],x2:be[ze+2],y2:be[ze+3]})}}}const we=this.circleCells[z];if(we!==null){const be=this.circles;for(const Ae of we)if(!ne.circle[Ae]){ne.circle[Ae]=!0;const ze=3*Ae;if(this._circleAndRectCollide(be[ze],be[ze+1],be[ze+2],m,v,E,D)&&(!ee||ee(this.circleKeys[Ae]))){if(K.hitTest)return $.push(!0),!0;{const Le=be[ze],rt=be[ze+1],st=be[ze+2];$.push({key:this.circleKeys[Ae],x1:Le-st,y1:rt-st,x2:Le+st,y2:rt+st})}}}}}_queryCellCircle(m,v,E,D,z,$,K,ee){const ne=K.circle,de=K.seenUids,we=this.boxCells[z];if(we!==null){const Ae=this.bboxes;for(const ze of we)if(!de.box[ze]){de.box[ze]=!0;const Le=4*ze;if(this._circleAndRectCollide(ne.x,ne.y,ne.radius,Ae[Le+0],Ae[Le+1],Ae[Le+2],Ae[Le+3])&&(!ee||ee(this.boxKeys[ze])))return $.push(!0),!0}}const be=this.circleCells[z];if(be!==null){const Ae=this.circles;for(const ze of be)if(!de.circle[ze]){de.circle[ze]=!0;const Le=3*ze;if(this._circlesCollide(Ae[Le],Ae[Le+1],Ae[Le+2],ne.x,ne.y,ne.radius)&&(!ee||ee(this.circleKeys[ze])))return $.push(!0),!0}}}_forEachCell(m,v,E,D,z,$,K,ee){const ne=this._convertToXCellCoord(m),de=this._convertToYCellCoord(v),we=this._convertToXCellCoord(E),be=this._convertToYCellCoord(D);for(let Ae=ne;Ae<=we;Ae++)for(let ze=de;ze<=be;ze++)if(z.call(this,m,v,E,D,this.xCellCount*ze+Ae,$,K,ee))return}_convertToXCellCoord(m){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(m*this.xScale)))}_convertToYCellCoord(m){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(m*this.yScale)))}_circlesCollide(m,v,E,D,z,$){const K=D-m,ee=z-v,ne=E+$;return ne*ne>K*K+ee*ee}_circleAndRectCollide(m,v,E,D,z,$,K){const ee=($-D)/2,ne=Math.abs(m-(D+ee));if(ne>ee+E)return!1;const de=(K-z)/2,we=Math.abs(v-(z+de));if(we>de+E)return!1;if(ne<=ee||we<=de)return!0;const be=ne-ee,Ae=we-de;return be*be+Ae*Ae<=E*E}}const Fs=Math.tan(85*Math.PI/180);function ar(M,m,v,E,D,z,$){const K=i.bb();if(v)if(z.name==="globe"){const ee=i.bc(D,m);i.aD(K,K,ee)}else{const ee=i.bd([],$);K[0]=ee[0],K[1]=ee[1],K[4]=ee[2],K[5]=ee[3],E||i.ba(K,K,D.angle)}else i.aD(K,D.labelPlaneMatrix,M);return K}function tn(M,m,v,E,D,z,$){const K=ar(M,m,v,E,D,z,$);return z.name==="globe"&&v||(K[2]=K[6]=K[10]=K[14]=0),K}function xn(M,m,v,E,D,z,$){if(v){if(z.name==="globe"){const K=ar(M,m,v,E,D,z,$);return i.b7(K,K),i.aD(K,M,K),K}{const K=i.b8(M),ee=i.b9([]);return ee[0]=$[0],ee[1]=$[1],ee[4]=$[2],ee[5]=$[3],i.aD(K,K,ee),E||i.ba(K,K,-D.angle),K}}return D.glCoordMatrix}function oa(M,m,v,E){const D=[M,m,v,1];v?i.aE(D,D,E):on(D,D,E);const z=D[3];return D[0]/=z,D[1]/=z,D[2]/=z,D}function fa(M,m){return Math.min(.5+M/m*.5,1.5)}function Ei(M,m){const v=M[0]/M[3],E=M[1]/M[3];return v>=-m[0]&&v<=m[0]&&E>=-m[1]&&E<=m[1]}function kc(M,m,v,E,D,z,$,K,ee,ne,de=1){const we=v.transform,be=E?M.textSizeData:M.iconSizeData,Ae=i.bj(be,v.transform.zoom,de),ze=we.projection.name==="globe",Le=[256/v.width*2+1,256/v.height*2+1],rt=E?M.text.dynamicLayoutVertexArray:M.icon.dynamicLayoutVertexArray;rt.clear();let st=null;ze&&(st=E?M.text.globeExtVertexArray:M.icon.globeExtVertexArray);const dt=M.lineVertexArray,pt=E?M.text.placedSymbolArray:M.icon.placedSymbolArray,at=v.transform.width/v.transform.height;let Bt,wt=!1;for(let Ft=0;FtMath.abs(v)?{useVertical:!0}:M===i.bk.vertical?E>0?{needsFlipping:!0}:null:m!==0&&function(D,z){return D===0||Math.abs(z/D)>Fs}(v,E)?m===1?{needsFlipping:!0}:null:v<0?{needsFlipping:!0}:null}function O0(M,m,v,E,D,z,$,K,ee,ne,de,we,be,Ae,ze,Le,rt,st,dt,pt){const at=m/24,Bt=M.lineOffsetX*at,wt=M.lineOffsetY*at,{lineStartIndex:Ft,glyphStartIndex:ft,numGlyphs:_t,segment:Et,writingMode:Kt,flipState:qt}=M,ns=Ft+M.lineLength,Jt=Cs=>{if(de){const[ss,is,hs]=Cs.up,Qs=ne.length;i.bm(de,Qs+0,ss,is,hs),i.bm(de,Qs+1,ss,is,hs),i.bm(de,Qs+2,ss,is,hs),i.bm(de,Qs+3,ss,is,hs)}const[Ls,Zt,Ht]=Cs.point;i.bn(ne,Ls,Zt,Ht,Cs.angle)};if(_t>1){const Cs=$m(at,K,Bt,wt,v,we,be,M,ee,z,Ae,Le,!1,rt,st,dt,pt);if(!Cs)return{notEnoughRoom:!0};if(E&&!v){let[Ls,Zt,Ht]=Cs.first.point,[ss,is,hs]=Cs.last.point;[Ls,Zt]=oa(Ls,Zt,Ht,$),[ss,is]=oa(ss,is,hs,$);const Qs=Zh(Kt,qt,(ss-Ls)*ze,is-Zt);if(M.flipState=Qs&&Qs.needsFlipping?1:2,Qs)return Qs}Jt(Cs.first);for(let Ls=ft+1;Ls0?ss:FE(be,Ht,Ls,1,D,void 0,rt,st.canonical),hs=Zh(Kt,qt,(is[0]-Ls[0])*ze,is[1]-Ls[1]);if(M.flipState=hs&&hs.needsFlipping?1:2,hs)return hs}const Cs=FC(at*K.getoffsetX(ft),Bt,wt,v,we,be,Et,Ft,ns,ee,z,Ae,Le,!1,!1,rt,st,dt,pt);if(!Cs)return{notEnoughRoom:!0};Jt(Cs)}return{}}function Aa(M,m,v,E,D){const{x:z,y:$,z:K}=E.projectTilePoint(M.x,M.y,m);if(!D)return oa(z,$,K,v);const[ee,ne,de]=D.getElevation(M,D.elevation,D.elevationFeature);return oa(z+ee,$+ne,K+de,v)}function FE(M,m,v,E,D,z,$,K){const ee=Aa(M.sub(m)._unit()._add(M),K,D,$,z);return i.ax(ee,v,ee),i.ay(ee,ee),i.bg(ee,v,ee,E)}function FC(M,m,v,E,D,z,$,K,ee,ne,de,we,be,Ae,ze,Le,rt,st,dt){const pt=E?M-m:M+m;let at=pt>0?1:-1,Bt=0;E&&(at*=-1,Bt=Math.PI),at<0&&(Bt+=Math.PI);let wt=K+$+(at>0?0:1)|0,Ft=D,ft=D,_t=0,Et=0;const Kt=Math.abs(pt),qt=[],ns=[];let Jt=z,Cs=Jt,Ls=i.be([]);const Zt=()=>FE(Cs,Jt,ft,Kt-_t+1,de,be,Le,rt.canonical);for(;_t+Et<=Kt;){if(wt+=at,wt=ee)return null;if(ft=Ft,Cs=Jt,qt.push(ft),Ae&&ns.push(Cs),Jt=new i.P(ne.getx(wt),ne.gety(wt)),Ft=we[wt],!Ft){const Pr=Aa(Jt,rt.canonical,de,Le,be);Ft=Pr[3]>0?we[wt]=Pr:Zt()}_t+=Et;const As=i.ax([],Ft,ft),jr=i.bf(ft,Ft);if(v&&jr>0&&Et>0&&i.bi(Ls,As)/(Et*jr)0,pt),Ft=ne*wt.perspectiveRatio,ft=(E.x1*v+K.x-E.padding)*Ft+wt.point.x,_t=(E.y1*v+K.y-E.padding)*Ft+wt.point.y,Et=(E.x2*v+K.x+E.padding)*Ft+wt.point.x,Kt=(E.y2*v+K.y+E.padding)*Ft+wt.point.y,qt=wt.perspectiveRatio<=.55||wt.occluded;return!this.isInsideGrid(ft,_t,Et,Kt)||!ee&&this.grid.hitTest(ft,_t,Et,Kt,we)||qt?{box:[],offscreen:!1,occluded:wt.occluded}:{box:[ft,_t,Et,Kt],offscreen:this.isOffscreen(ft,_t,Et,Kt),occluded:!1}}placeCollisionCircles(m,v,E,D,z,$,K,ee,ne,de,we,be,Ae,ze,Le,rt){const st=[],dt=this.transform.elevation,pt=m.getProjection(),at=m.elevationType==="road",Bt=!!dt||at,wt=i.bu.getAtTileOffsetFunc(rt,this.transform.center.lat,this.transform.worldSize,pt),Ft=new i.P(E.tileAnchorX,E.tileAnchorY),ft=new i.P(E.tileAnchorX,E.tileAnchorY);let{x:_t,y:Et,z:Kt}=pt.projectTilePoint(ft.x,ft.y,rt.canonical),qt=null;if(Bt){const jr=at?m.getElevationFeatureForText(D):null;qt={getElevation:wt,elevation:dt,elevationFeature:jr};const[Pr,pr,br]=wt(Ft,dt,jr);_t+=Pr,Et+=pr,Kt+=br}const ns=pt.name==="globe",Jt=this.projectAndGetPerspectiveRatio(ee,_t,Et,Kt,rt,ns||!!dt||this.transform.pitch>0,pt),{perspectiveRatio:Cs}=Jt,Ls=(be?K/Cs:K*Cs)/i.by,Zt=oa(_t,Et,Kt,ne),Ht=E.lineOffsetX*Ls,ss=E.lineOffsetY*Ls,is=i.ap(m.layers[0].layout.get("text-max-angle")),hs=Math.cos(is),Qs=Jt.signedDistanceFromCamera>0?$m(Ls,$,Ht,ss,at&&E.flipState===1,Zt,ft,E,z,ne,{},Bt&&!be?qt:null,be&&Bt,pt,rt,be,hs):null;let Ws=!1,Ks=!1,As=!0;if(Qs&&!Jt.occluded){const jr=.5*ze*Cs+Le,Pr=new i.P(-100,-100),pr=new i.P(this.screenRightBoundary,this.screenBottomBoundary),br=new OC,{first:Qr,last:bn}=Qs,mn=Qr.path.length;let Un=[];for(let pn=mn-1;pn>=1;pn--)Un.push(Qr.path[pn]);for(let pn=1;pn(Bt&&!ns&&(pi=wt(Wipn[3]<=0)&&(Un=[]));let Vn=[];if(Un.length>0){let pn=1/0,Ea=-1/0,pi=1/0,Wi=-1/0;for(const Ni of Un)pn=Math.min(pn,Ni[0]),pi=Math.min(pi,Ni[1]),Ea=Math.max(Ea,Ni[0]),Wi=Math.max(Wi,Ni[1]);Ea>=Pr.x&&pn<=pr.x&&Wi>=Pr.y&&pi<=pr.y&&(Vn=[Un.map(Ni=>new i.P(Ni[0],Ni[1]))],(pnpr.x||pipr.y)&&(Vn=i.bv(Vn,Pr.x,Pr.y,pr.x,pr.y)))}for(const pn of Vn){br.reset(pn,.25*jr);let Ea=0;Ea=br.length<=.5*jr?1:Math.ceil(br.paddedLength/Vr)+1;for(let pi=0;pi0?(i.aE(ee,ee,m),this.fogState&&z&&K.name!=="globe"&&(ne=function(be,Ae,ze,Le,rt,st){const dt=st.calculateFogTileMatrix(rt),pt=[Ae,ze,Le];return i.ah(pt,pt,dt),ua(be,i.ai(pt),st.pitch,st._fov)}(this.fogState,v,E,D,z.toUnwrapped(),this.transform)>.9)):on(ee,ee,m);const de=ee[3];return{point:new i.P((ee[0]/de+1)/2*this.transform.width+Mp,(-ee[1]/de+1)/2*this.transform.height+Mp),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(K)/de*.5,1.5),signedDistanceFromCamera:de,occluded:$&&ee[2]>de||ne}}isOffscreen(m,v,E,D){return E=this.screenRightBoundary||Dthis.screenBottomBoundary}isInsideGrid(m,v,E,D){return E>=0&&m=0&&vE.collisionGroupID===v}}return this.collisionGroups[m]}}function Nu(M,m,v,E,D){const{horizontalAlign:z,verticalAlign:$}=i.bF(M),K=-(z-.5)*m,ee=-($-.5)*v,ne=i.bG(M,E);return new i.P(K+ne[0]*D,ee+ne[1]*D)}function sy(M,m,v,E,D){const z=new i.P(M,m);return v&&z._rotate(E?D:-D),z}class li{constructor(m,v,E,D,z,$){this.transform=m.clone(),this.projection=m.projection.name,this.collisionIndex=new zC(this.transform,z),this.buildingIndex=$,this.frontCutoffStart=0,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=v,this.retainedQueryData={},this.collisionGroups=new oi(E),this.collisionCircleArrays={},this.prevPlacement=D,D&&(D.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0}getBucketParts(m,v,E,D,z=1){const $=E.getBucket(v),K=E.latestFeatureIndex;if(!$||!K||v.fqid!==$.layerIds[0])return;const ee=$.layers[0].layout,ne=$.layers[0].paint,de=E.collisionBoxArray,we=Math.pow(2,this.transform.zoom-E.tileID.overscaledZ),be=E.tileSize/i.an,Ae=E.tileID.toUnwrapped();this.transform.setProjection($.projection);const ze=(Le=E.tileID,rt=$.getProjection(),st=this.transform,rt.name===this.projection?st.calculateProjMatrix(Le.toUnwrapped()):I1(st,rt,Le));var Le,rt,st;const dt=ee.get("text-pitch-alignment")==="map",pt=ee.get("text-rotation-alignment")==="map";v.compileFilter(v.options);const at=v.dynamicFilter(),Bt=v.dynamicFilterNeedsFeature(),wt=v.dynamicFilterNeedsGeometry(),Ft=this.transform.calculatePixelsToTileUnitsMatrix(E),ft=tn(ze,E.tileID.canonical,dt,pt,this.transform,$.getProjection(),Ft);let _t=null;const Et=$.getProjection().createInversionMatrix(this.transform,E.tileID.canonical);if(dt){const ss=xn(ze,E.tileID.canonical,dt,pt,this.transform,$.getProjection(),Ft);_t=i.aD([],this.transform.labelPlaneMatrix,ss)}let Kt=null;at&&E.latestFeatureIndex&&(Kt={unwrappedTileID:Ae,dynamicFilter:at,dynamicFilterNeedsFeature:Bt,needGeometry:wt}),this.retainedQueryData[$.bucketInstanceId]=new ri($.bucketInstanceId,K,$.sourceLayerIndex,$.index,E.tileID);const[qt,ns]=$.layers[0].layout.get("text-size-scale-range"),Jt=i.aC(z,qt,ns),[Cs,Ls]=ee.get("icon-size-scale-range"),Zt=i.aC(z,Cs,Ls),Ht={bucket:$,layout:ee,paint:ne,posMatrix:ze,invMatrix:Et,mercatorCenter:[i.aH(this.transform.center.lng),i.aL(this.transform.center.lat)],textLabelPlaneMatrix:ft,labelToScreenMatrix:_t,clippingData:Kt,scale:we,textPixelRatio:be,holdingForFade:E.holdingForFade(),collisionBoxArray:de,partiallyEvaluatedTextSize:i.bj($.textSizeData,this.transform.zoom,Jt),partiallyEvaluatedIconSize:i.bj($.iconSizeData,this.transform.zoom,Zt),collisionGroup:this.collisionGroups.get($.sourceID),latestFeatureIndex:E.latestFeatureIndex};if(D)for(const ss of $.sortKeyRanges){const{sortKey:is,symbolInstanceStart:hs,symbolInstanceEnd:Qs}=ss;m.push({sortKey:is,symbolInstanceStart:hs,symbolInstanceEnd:Qs,parameters:Ht})}else m.push({symbolInstanceStart:0,symbolInstanceEnd:$.symbolInstances.length,parameters:Ht})}attemptAnchorPlacement(m,v,E,D,z,$,K,ee,ne,de,we,be,Ae,ze,Le,rt,st,dt,pt,at,Bt){const{textOffset0:wt,textOffset1:Ft,crossTileID:ft}=Le,_t=[wt,Ft],Et=Nu(m,$,K,_t,ee),Kt=this.collisionIndex.placeCollisionBox(st,ee,v,E,D,z,sy(Et.x,Et.y,ne,de,this.transform.angle),ze,we,be,Ae.predicate);if(pt){const qt=st.getSymbolInstanceIconSize(Bt,this.transform.zoom,Le.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(st,qt,pt,E,D,z,sy(Et.x,Et.y,ne,de,this.transform.angle),ze,we,be,Ae.predicate).box.length===0)return}if(Kt.box.length>0){let qt;return this.prevPlacement&&this.prevPlacement.variableOffsets[ft]&&this.prevPlacement.placements[ft]&&this.prevPlacement.placements[ft].text&&(qt=this.prevPlacement.variableOffsets[ft].anchor),this.variableOffsets[ft]={textOffset:_t,width:$,height:K,anchor:m,textScale:ee,prevAnchor:qt},this.markUsedJustification(st,m,Le,dt),st.allowVerticalPlacement&&(this.markUsedOrientation(st,dt,Le),this.placedOrientations[ft]=dt),{shift:Et,placedGlyphBoxes:Kt}}}placeLayerBucketPart(m,v,E,D,z=1){const{bucket:$,layout:K,paint:ee,posMatrix:ne,textLabelPlaneMatrix:de,labelToScreenMatrix:we,clippingData:be,textPixelRatio:Ae,mercatorCenter:ze,invMatrix:Le,holdingForFade:rt,collisionBoxArray:st,partiallyEvaluatedTextSize:dt,partiallyEvaluatedIconSize:pt,collisionGroup:at,latestFeatureIndex:Bt}=m.parameters,wt=K.get("text-optional"),Ft=K.get("icon-optional"),ft=K.get("text-allow-overlap"),_t=K.get("icon-allow-overlap"),Et=K.get("text-rotation-alignment")==="map",Kt=K.get("icon-rotation-alignment")==="map",qt=K.get("text-pitch-alignment")==="map",ns=ee.get("symbol-z-offset"),Jt=K.get("symbol-elevation-reference")==="sea",Cs=K.get("symbol-placement"),[Ls,Zt]=K.get("text-size-scale-range"),[Ht,ss]=K.get("icon-size-scale-range"),is=i.aC(z,Ls,Zt),hs=i.aC(z,Ht,ss),Qs=K.get("text-variable-anchor"),Ws=Et&&Cs!=="point",Ks=Kt&&Cs!=="point",As=Qs&&$.hasTextData(),jr=$.hasIconTextFit()&&As&&$.hasIconData();this.transform.setProjection($.projection);const Pr=As||Ws,pr=Ks||jr;let br=ft&&(_t||!$.hasIconData()||Ft),Qr=_t&&(ft||!$.hasTextData()||wt);const bn=!ns.isConstant();!$.collisionArrays&&st&&$.deserializeCollisionBoxes(st),E&&D&&$.updateCollisionDebugBuffers(this.transform.zoom,st,is,hs);const mn=(Vr,Vn,pn)=>{const{crossTileID:Ea,numVerticalGlyphVertices:pi}=Vr;let Wi=null;if(be&&be.dynamicFilterNeedsFeature||bn){const Ci=this.retainedQueryData[$.bucketInstanceId],Pi=Bt.loadFeature({featureIndex:Vr.featureIndex,bucketIndex:Ci.bucketIndex,sourceLayerIndex:Ci.sourceLayerIndex,layoutVertexArrayOffset:0}),ci=Pi.properties?Pi.properties.worldview:null;if($.localizable&&$.worldview&&typeof ci=="string")if(ci==="all")Pi.properties.$localized=!0;else{if(!ci.split(",").includes($.worldview))return;Pi.properties.$localized=!0,Pi.properties.worldview=$.worldview}Wi=be&&be.needGeometry?i.bD(Pi,!0):Pi}if(be&&!(0,be.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:$.worldview},Wi,this.retainedQueryData[$.bucketInstanceId].tileID.canonical,new i.P(Vr.tileAnchorX,Vr.tileAnchorY),this.transform.calculateDistanceTileData(be.unwrappedTileID)))return this.placements[Ea]=new qx(!1,!1,!1,!0),void v.add(Ea);const Ni=ns.evaluate(Wi,{});if((Vr.zOffset||0)+(Ni||0)>0&&this.frontCutoffStart>0){const Ci=2*this.frontCutoffStart-1,Pi=[Vr.tileAnchorX,Vr.tileAnchorY,0,1],ci=i.aE(i.bE(),Pi,ne);if(ci[1]/ci[3]{Ci.tileID=this.retainedQueryData[$.bucketInstanceId].tileID;const Pi=this.transform.elevation;Ci.elevation=Jt?Ni:Ni+i.bu.getAtTileOffset(Ci.tileID,new i.P(Ci.tileAnchorX,Ci.tileAnchorY),Pi,Ml),Ci.elevation+=Vr.zOffset},bh=pn.textBox;if(bh){Sc(bh);const Ci=ci=>{let Fo=i.bk.horizontal;if($.allowVerticalPlacement&&!ci&&this.prevPlacement){const Ed=this.prevPlacement.placedOrientations[Ea];Ed&&(this.placedOrientations[Ea]=Ed,Fo=Ed,this.markUsedOrientation($,Fo,Vr))}return Fo},Pi=(ci,Fo)=>{if($.allowVerticalPlacement&&pi>0&&pn.verticalTextBox){for(const Ed of $.writingModes)if(Ed===i.bk.vertical?(Cn=Fo(),Ui=Cn):Cn=ci(),Cn&&Cn.box&&Cn.box.length)break}else Cn=ci()};if(Qs){let ci=Qs;if(this.prevPlacement&&this.prevPlacement.variableOffsets[Ea]){const fo=this.prevPlacement.variableOffsets[Ea];ci.indexOf(fo.anchor)>0&&(ci=ci.filter(wh=>wh!==fo.anchor),ci.unshift(fo.anchor))}const Fo=(fo,wh,uy)=>{const sv=$.getSymbolInstanceTextSize(dt,Vr,this.transform.zoom,Vn),rv=(fo.x2-fo.x1)*sv+2*fo.padding,t_=(fo.y2-fo.y1)*sv+2*fo.padding,Xx=Vr.hasIconTextFit&&!_t?wh:null;Xx&&Sc(Xx);let Of={box:[],offscreen:!1,occluded:!1};const s_=ft?2*ci.length:ci.length;for(let Zu=0;Zu=ci.length,Vr,Vn,$,uy,Xx,dt,pt);if(hy&&(Of=hy.placedGlyphBoxes,Of&&Of.box&&Of.box.length)){$a=!0,qa=hy.shift;break}}return Of};Pi(()=>Fo(bh,pn.iconBox,i.bk.horizontal),()=>{const fo=pn.verticalTextBox;return fo&&Sc(fo),$.allowVerticalPlacement&&!(Cn&&Cn.box&&Cn.box.length)&&pi>0&&fo?Fo(fo,pn.verticalIconBox,i.bk.vertical):{box:null,offscreen:null,occluded:null}}),Cn&&($a=Cn.box,Fn=Cn.offscreen,ki=Cn.occluded);const Ed=Ci(!(!Cn||!Cn.box));if(!$a&&this.prevPlacement){const fo=this.prevPlacement.variableOffsets[Ea];fo&&(this.variableOffsets[Ea]=fo,this.markUsedJustification($,fo.anchor,Vr,Ed))}}else{const ci=(Fo,Ed)=>{const fo=$.getSymbolInstanceTextSize(dt,Vr,this.transform.zoom,Vn),wh=this.collisionIndex.placeCollisionBox($,fo,Fo,ze,Le,Pr,new i.P(0,0),ft,Ae,ne,at.predicate);return wh&&wh.box&&wh.box.length&&(this.markUsedOrientation($,Ed,Vr),this.placedOrientations[Ea]=Ed),wh};Pi(()=>ci(bh,i.bk.horizontal),()=>{const Fo=pn.verticalTextBox;return $.allowVerticalPlacement&&pi>0&&Fo?(Sc(Fo),ci(Fo,i.bk.vertical)):{box:null,offscreen:null,occluded:null}}),Ci(!!(Cn&&Cn.box&&Cn.box.length))}}if(fi=Cn,$a=fi&&fi.box&&fi.box.length>0,Fn=fi&&fi.offscreen,ki=fi&&fi.occluded,Vr.useRuntimeCollisionCircles){const Ci=Vr.centerJustifiedTextSymbolIndex>=0?Vr.centerJustifiedTextSymbolIndex:Vr.verticalPlacedTextSymbolIndex,Pi=$.text.placedSymbolArray.get(Ci),ci=i.bl($.textSizeData,dt,Pi),Fo=K.get("text-padding");Vo=this.collisionIndex.placeCollisionCircles($,ft,Pi,Ci,$.lineVertexArray,$.glyphOffsetArray,ci,ne,de,we,E,qt,at.predicate,Vr.collisionCircleDiameter*ci/i.by,Fo,this.retainedQueryData[$.bucketInstanceId].tileID),$a=ft||Vo.circles.length>0&&!Vo.collisionDetected,Fn=Fn&&Vo.offscreen,ki=Vo.occluded}if(pn.iconFeatureIndex&&(ud=pn.iconFeatureIndex),pn.iconBox){const Ci=Pi=>{Sc(Pi);const ci=Vr.hasIconTextFit&&qa?sy(qa.x,qa.y,Et,qt,this.transform.angle):new i.P(0,0),Fo=$.getSymbolInstanceIconSize(pt,this.transform.zoom,Vr.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox($,Fo,Pi,ze,Le,pr,ci,_t,Ae,ne,at.predicate)};Ui&&Ui.box&&Ui.box.length&&pn.verticalIconBox?(ra=Ci(pn.verticalIconBox),On=ra.box.length>0):(ra=Ci(pn.iconBox),On=ra.box.length>0),Fn=Fn&&ra.offscreen,Ji=ra.occluded}const ei=wt||Vr.numHorizontalGlyphVertices===0&&pi===0,tm=Ft||Vr.numIconVertices===0;if(ei||tm?tm?ei||(On=On&&$a):$a=On&&$a:On=$a=On&&$a,$a&&fi&&fi.box&&this.collisionIndex.insertCollisionBox(fi.box,K.get("text-ignore-placement"),$.bucketInstanceId,Ui&&Ui.box&&ul?ul:_i,at.ID),On&&ra&&this.collisionIndex.insertCollisionBox(ra.box,K.get("icon-ignore-placement"),$.bucketInstanceId,ud,at.ID),Vo&&($a&&this.collisionIndex.insertCollisionCircles(Vo.circles,K.get("text-ignore-placement"),$.bucketInstanceId,_i,at.ID),E)){const Ci=$.bucketInstanceId;let Pi=this.collisionCircleArrays[Ci];Pi===void 0&&(Pi=this.collisionCircleArrays[Ci]=new Dr);for(let ci=0;ci=0;--Vn){const pn=Vr[Vn];mn($.symbolInstances.get(pn),pn,$.collisionArrays[pn])}$.hasAnyZOffset&&i.w(`${$.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if($.hasAnyZOffset){const Vr=$.getSortedIndexesByZOffset();for(let Vn=0;Vn=0&&(m.text.placedSymbolArray.get(z).crossTileID=we>=0&&z!==we?0:ne),$>=0&&(m.text.placedSymbolArray.get($).crossTileID=we>=0&&$!==we?0:ne),K>=0&&(m.text.placedSymbolArray.get(K).crossTileID=we>=0&&K!==we?0:ne),ee>=0&&(m.text.placedSymbolArray.get(ee).crossTileID=we>=0&&ee!==we?0:ne)}markUsedOrientation(m,v,E){const D=v===i.bk.horizontal||v===i.bk.horizontalOnly?v:0,z=v===i.bk.vertical?v:0,{leftJustifiedTextSymbolIndex:$,centerJustifiedTextSymbolIndex:K,rightJustifiedTextSymbolIndex:ee,verticalPlacedTextSymbolIndex:ne}=E,de=m.text.placedSymbolArray;$>=0&&(de.get($).placedOrientation=D),K>=0&&(de.get(K).placedOrientation=D),ee>=0&&(de.get(ee).placedOrientation=D),ne>=0&&(de.get(ne).placedOrientation=z)}commit(m){this.commitTime=m,this.zoomAtLastRecencyCheck=this.transform.zoom;const v=this.prevPlacement;let E=!1;this.prevZoomAdjustment=v?v.zoomAdjustment(this.transform.zoom):0;const D=v?v.symbolFadeChange(m):1,z=v?v.opacities:{},$=v?v.variableOffsets:{},K=v?v.placedOrientations:{};for(const ee in this.placements){const ne=this.placements[ee],de=z[ee];de?(this.opacities[ee]=new F0(de,D,ne.text,ne.icon,null,ne.clipped),E=E||ne.text!==de.text.placed||ne.icon!==de.icon.placed):(this.opacities[ee]=new F0(null,D,ne.text,ne.icon,ne.skipFade,ne.clipped),E=E||ne.text||ne.icon)}for(const ee in z){const ne=z[ee];if(!this.opacities[ee]){const de=new F0(ne,D,!1,!1);de.isHidden()||(this.opacities[ee]=de,E=E||ne.text.placed||ne.icon.placed)}}for(const ee in $)this.variableOffsets[ee]||!this.opacities[ee]||this.opacities[ee].isHidden()||(this.variableOffsets[ee]=$[ee]);for(const ee in K)this.placedOrientations[ee]||!this.opacities[ee]||this.opacities[ee].isHidden()||(this.placedOrientations[ee]=K[ee]);E?this.lastPlacementChangeTime=m:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=v?v.lastPlacementChangeTime:m)}updateLayerOpacities(m,v,E,D){D&&(this.lastReplacementSourceUpdateTime=D.updateTime);const z=new Set;for(const $ of v){const K=$.getBucket(m);K&&$.latestFeatureIndex&&m.fqid===K.layerIds[0]&&(this.updateBucketOpacities(K,z,$,$.collisionBoxArray,E,D,$.tileID,m.scope),K.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(K,$.tileID),K.elevationType==="road"&&K.updateRoadElevation($.tileID.canonical),K.updateZOffset())}}updateBucketOpacities(m,v,E,D,z,$,K,ee){m.hasTextData()&&m.text.opacityVertexArray.clear(),m.hasIconData()&&m.icon.opacityVertexArray.clear(),m.hasIconCollisionBoxData()&&m.iconCollisionBox.collisionVertexArray.clear(),m.hasTextCollisionBoxData()&&m.textCollisionBox.collisionVertexArray.clear();const ne=m.layers[0].layout,de=m.layers[0].paint,we=!!m.layers[0].dynamicFilter(),be=new F0(null,0,!1,!1,!0),Ae=ne.get("text-allow-overlap"),ze=ne.get("icon-allow-overlap"),Le=ne.get("text-variable-anchor"),rt=ne.get("text-rotation-alignment")==="map",st=ne.get("text-pitch-alignment")==="map",dt=de.get("symbol-z-offset"),pt=ne.get("symbol-elevation-reference")==="sea",at=!dt.isConstant(),Bt=new F0(null,0,Ae&&(ze||!m.hasIconData()||ne.get("icon-optional")),ze&&(Ae||!m.hasTextData()||ne.get("text-optional")),!0);!m.collisionArrays&&D&&(m.hasIconCollisionBoxData()||m.hasTextCollisionBoxData())&&m.deserializeCollisionBoxes(D);const wt=(ft,_t,Et)=>{for(let Kt=0;Kt<_t/4;Kt++)ft.opacityVertexArray.emplaceBack(Et)};let Ft=0;$&&m.updateReplacement(K,$),this.collisionIndex.clearClippedSymbolsForBucket(m.bucketInstanceId);for(let ft=0;ft0||Kt>0,Qs=ns>0,Ws=this.placedOrientations[qt],Ks=Ws===i.bk.vertical,As=Ws===i.bk.horizontal||Ws===i.bk.horizontalOnly;!hs&&!Qs||is.isHidden()||Ft++;let jr=!1;if((hs||Qs)&&$)for(const Pr of m.activeReplacements){if(i.bz(Pr,z,i.bA.Symbol,ee)||Pr.min.x>Jt||Jt>Pr.max.x||Pr.min.y>Cs||Cs>Pr.max.y)continue;const pr=i.bB(Jt,Cs,K.canonical,Pr.footprintTileId.canonical);if(jr=i.bC(pr,Pr.footprint),jr)break}if(jr&&this.collisionIndex.markSymbolAsClipped(m.bucketInstanceId,_t.featureIndex),hs){const Pr=jr?Ux:D1(is.text);wt(m.text,Et,Ks?Ux:Pr),wt(m.text,Kt,As?Ux:Pr);const pr=is.text.isHidden(),{leftJustifiedTextSymbolIndex:br,centerJustifiedTextSymbolIndex:Qr,rightJustifiedTextSymbolIndex:bn,verticalPlacedTextSymbolIndex:mn}=_t,Un=m.text.placedSymbolArray,Vr=pr||Ks?1:0;br>=0&&(Un.get(br).hidden=Vr),Qr>=0&&(Un.get(Qr).hidden=Vr),bn>=0&&(Un.get(bn).hidden=Vr),mn>=0&&(Un.get(mn).hidden=pr||As?1:0);const Vn=this.variableOffsets[qt];Vn&&this.markUsedJustification(m,Vn.anchor,_t,Ws);const pn=this.placedOrientations[qt];pn&&(this.markUsedJustification(m,"left",_t,pn),this.markUsedOrientation(m,pn,_t))}if(Qs){const Pr=jr?Ux:D1(is.icon),{placedIconSymbolIndex:pr,verticalPlacedIconSymbolIndex:br}=_t,Qr=m.icon.placedSymbolArray,bn=is.icon.isHidden()?1:0;pr>=0&&(wt(m.icon,ns,Ks?Ux:Pr),Qr.get(pr).hidden=bn),br>=0&&(wt(m.icon,_t.numVerticalIconVertices,As?Ux:Pr),Qr.get(br).hidden=bn)}if(m.hasIconCollisionBoxData()||m.hasTextCollisionBoxData()){const Pr=m.collisionArrays[ft];if(Pr){let pr=new i.P(0,0),br=!0;if(Pr.textBox||Pr.verticalTextBox){if(Le){const bn=this.variableOffsets[qt];bn?(pr=Nu(bn.anchor,bn.width,bn.height,bn.textOffset,bn.textScale),rt&&pr._rotate(st?this.transform.angle:-this.transform.angle)):br=!1}we&&(br=!is.clipped),Pr.textBox&&z0(m.textCollisionBox.collisionVertexArray,is.text.placed,!br||Ks,Ht,pt,pr.x,pr.y),Pr.verticalTextBox&&z0(m.textCollisionBox.collisionVertexArray,is.text.placed,!br||As,Ht,pt,pr.x,pr.y)}const Qr=br&&!!(!As&&Pr.verticalIconBox);Pr.iconBox&&z0(m.iconCollisionBox.collisionVertexArray,is.icon.placed,Qr,Ht,pt,_t.hasIconTextFit?pr.x:0,_t.hasIconTextFit?pr.y:0),Pr.verticalIconBox&&z0(m.iconCollisionBox.collisionVertexArray,is.icon.placed,!Qr,Ht,pt,_t.hasIconTextFit?pr.x:0,_t.hasIconTextFit?pr.y:0)}}}if(m.fullyClipped=Ft===0,m.sortFeatures(this.transform.angle),this.retainedQueryData[m.bucketInstanceId]&&(this.retainedQueryData[m.bucketInstanceId].featureSortOrder=m.featureSortOrder),m.hasTextData()&&m.text.opacityVertexBuffer&&m.text.opacityVertexBuffer.updateData(m.text.opacityVertexArray),m.hasIconData()&&m.icon.opacityVertexBuffer&&m.icon.opacityVertexBuffer.updateData(m.icon.opacityVertexArray),m.hasIconCollisionBoxData()&&m.iconCollisionBox.collisionVertexBuffer&&m.iconCollisionBox.collisionVertexBuffer.updateData(m.iconCollisionBox.collisionVertexArray),m.hasTextCollisionBoxData()&&m.textCollisionBox.collisionVertexBuffer&&m.textCollisionBox.collisionVertexBuffer.updateData(m.textCollisionBox.collisionVertexArray),m.bucketInstanceId in this.collisionCircleArrays){const ft=this.collisionCircleArrays[m.bucketInstanceId];m.placementInvProjMatrix=ft.invProjMatrix,m.placementViewportMatrix=ft.viewportMatrix,m.collisionCircleArray=ft.circles,delete this.collisionCircleArrays[m.bucketInstanceId]}}symbolFadeChange(m){return this.fadeDuration===0?1:(m-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(m){return Math.max(0,(this.transform.zoom-m)/1.5)}hasTransitions(m){return m-this.lastPlacementChangeTimem}isStale(){return this.stale}setStale(){this.stale=!0}}function z0(M,m,v,E,D,z,$){M.emplaceBack(m?1:0,v?1:0,z||0,$||0,E,D?1:0),M.emplaceBack(m?1:0,v?1:0,z||0,$||0,E,D?1:0),M.emplaceBack(m?1:0,v?1:0,z||0,$||0,E,D?1:0),M.emplaceBack(m?1:0,v?1:0,z||0,$||0,E,D?1:0)}const Lw=Math.pow(2,25),Dw=Math.pow(2,24),Kd=Math.pow(2,17),Sl=Math.pow(2,16),ipe=Math.pow(2,9),Rw=Math.pow(2,8),zE=Math.pow(2,1);function D1(M){if(M.opacity===0&&!M.placed)return 0;if(M.opacity===1&&M.placed)return 4294967295;const m=M.placed?1:0,v=Math.floor(127*M.opacity);return v*Lw+m*Dw+v*Kd+m*Sl+v*ipe+m*Rw+v*zE+m}const Ux=0;class BE{constructor(m){this._sortAcrossTiles=m.layout.get("symbol-z-order")!=="viewport-y"&&m.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(m,v,E,D,z,$){const K=this._bucketParts;for(;this._currentTileIndexee.sortKey-ne.sortKey));this._currentPartIndex{const ee=i.o.now()-$;return!this.isFullPlacementRequested()&&this._fadeDuration!==0&&ee>2};for(;this._currentPlacementIndex>=0;){const ee=v[m[this._currentPlacementIndex]],ne=this.placement.collisionIndex.transform.zoom;if(ee.type==="symbol"&&ee.visibility!=="none"&&(!ee.minzoom||ee.minzoom<=ne)&&(!ee.maxzoom||ee.maxzoom>ne)){const de=ee,we=de.layout.get("symbol-z-elevate"),be=de.layout.get("symbol-sort-key").constantOr(1)!==void 0,Ae=de.layout.get("symbol-z-order"),ze=Ae==="viewport-y"||Ae==="auto"&&!(Ae!=="viewport-y"&&be),Le=de.layout.get("text-allow-overlap")||de.layout.get("icon-allow-overlap")||de.layout.get("text-ignore-placement")||de.layout.get("icon-ignore-placement"),rt=ze&&Le,st=this._inProgressLayer=this._inProgressLayer||new BE(de),dt=i.F(ee.source,ee.scope);if(st.continuePlacement(we||rt?D[dt]:E[dt],this.placement,this._showCollisionBoxes,ee,K,z))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._forceFullPlacement=!1,this._done=!0}commit(m){return this.placement.commit(m),this.placement}}const Td=512/i.an/2;class Um{constructor(m,v,E){this.tileID=m,this.bucketInstanceId=E,this.index=new i.bI(v.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const D=m.canonical.x*i.an,z=m.canonical.y*i.an;for(let $=0;$rt-st);for(const rt of Le){const st=this.crossTileIDs[rt];if(this.keys[rt]===de&&!E.has(st)){E.add(st),ne.crossTileID=st;break}}}}}class Ku{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class IO{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(m){const v=Math.round((m-this.lng)/360);if(v!==0)for(const E in this.indexes){const D=this.indexes[E],z={};for(const $ in D){const K=D[$];K.tileID=K.tileID.unwrapTo(K.tileID.wrap+v),z[K.tileID.key]=K}this.indexes[E]=z}this.lng=m}addBucket(m,v,E){if(this.indexes[m.overscaledZ]&&this.indexes[m.overscaledZ][m.key]){if(this.indexes[m.overscaledZ][m.key].bucketInstanceId===v.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(m.overscaledZ,this.indexes[m.overscaledZ][m.key])}for(let z=0;zm.overscaledZ)for(const K in $){const ee=$[K];ee.tileID.isChildOf(m)&&ee.findMatches(v.symbolInstances,m,D)}else{const K=$[m.scaledTo(Number(z)).key];K&&K.findMatches(v.symbolInstances,m,D)}}for(let z=0;z{v[E]=!0});for(const E in this.layerIndexes)v[E]||delete this.layerIndexes[E]}}const Oo=771;class rn{constructor(m,v,E,D){this.blendFunction=m,this.blendColor=v.toNonPremultipliedRenderColor(null),this.mask=E,this.blendEquation=D}}rn.Replace=[1,0,1,0],rn.disabled=new rn(rn.Replace,i.aq.transparent,[!1,!1,!1,!1]),rn.unblended=new rn(rn.Replace,i.aq.transparent,[!0,!0,!0,!0]),rn.alphaBlended=new rn([1,Oo,1,Oo],i.aq.transparent,[!0,!0,!0,!0]),rn.alphaBlendedNonPremultiplied=new rn([770,Oo,770,Oo],i.aq.transparent,[!0,!0,!0,!0]),rn.multiply=new rn([774,0,774,0],i.aq.transparent,[!0,!0,!0,!0]),rn.multiplyAccumulateAlpha=new rn([774,0,1,Oo],i.aq.transparent,[!0,!0,!0,!0]),rn.additive=new rn([1,1,1,1],i.aq.transparent,[!0,!0,!0,!0]);class Sr{constructor(m,v,E){this.func=m,this.mask=v,this.range=E}}Sr.ReadOnly=!1,Sr.ReadWrite=!0,Sr.disabled=new Sr(519,Sr.ReadOnly,[0,1]);const dl=7680;class dn{constructor(m,v,E,D,z,$){this.test=m,this.ref=v,this.mask=E,this.fail=D,this.depthFail=z,this.pass=$}}dn.disabled=new dn({func:519,mask:0},0,0,dl,dl,dl);const Yh=1029,B0=2305;class Xr{constructor(m,v,E){this.enable=m,this.mode=v,this.frontFace=E}}function Fw(M,m){const v=i.bO(M,3);i.bR(M,m),i.bW(M,3,v)}function BC(M,m){const v=i.bL([]);return i.bM(v,v,-m),i.bN(v,v,-M),v}function $C(M,m){const v=[M[0],M[1],0],E=[m[0],m[1],0];if(i.ai(v)>=1e-15){const $=i.ay([],v);i.bJ(E,$,i.bi(E,$)),m[0]=E[0],m[1]=E[1]}const D=i.bh([],m,M);if(i.bK(D)<1e-15)return null;const z=Math.atan2(-D[1],D[0]);return BC(Math.atan2(Math.sqrt(M[0]*M[0]+M[1]*M[1]),-M[2]),z)}Xr.disabled=new Xr(!1,Yh,B0),Xr.backCCW=new Xr(!0,Yh,B0),Xr.backCW=new Xr(!0,Yh,2304),Xr.frontCW=new Xr(!0,1028,2304),Xr.frontCCW=new Xr(!0,1028,B0);class zw{constructor(m,v){this.position=m,this.orientation=v}get position(){return this._position}set position(m){if(m){const v=m instanceof i.ag?m:new i.ag(m[0],m[1],m[2]);this._renderWorldCopies&&(v.x=i.bs(v.x,0,1)),this._position=v}else this._position=null}lookAtPoint(m,v,E){if(this.orientation=null,!this.position)return;const D=this.position,z=E||(this._elevation?this._elevation.getAtPointOrZero(i.ag.fromLngLat(m)):0),$=i.ag.fromLngLat(m,z),K=[$.x-D.x,$.y-D.y,$.z-D.z];v||(v=[0,0,1]),v[2]=Math.abs(v[2]),this.orientation=$C(K,v)}setPitchBearing(m,v){this.orientation=BC(i.ap(m),i.ap(-v))}}class Bw{constructor(m,v){this._transform=i.b9([]),this.orientation=v,this.position=m}get mercatorPosition(){const m=this.position;return new i.ag(m[0],m[1],m[2])}get position(){const m=i.bO(this._transform,3);return[m[0],m[1],m[2]]}set position(m){var v;m&&i.bW(this._transform,3,[(v=m)[0],v[1],v[2],1])}get orientation(){return this._orientation}set orientation(m){this._orientation=m||i.bL([]),m&&Fw(this._transform,this._orientation)}getPitchBearing(){const m=this.forward(),v=this.right();return{bearing:Math.atan2(-v[1],v[0]),pitch:Math.atan2(Math.sqrt(m[0]*m[0]+m[1]*m[1]),-m[2])}}setPitchBearing(m,v){this._orientation=BC(m,v),Fw(this._transform,this._orientation)}forward(){const m=i.bO(this._transform,2);return[-m[0],-m[1],-m[2]]}up(){const m=i.bO(this._transform,1);return[-m[0],-m[1],-m[2]]}right(){const m=i.bO(this._transform,0);return[m[0],m[1],m[2]]}getCameraToWorld(m,v){const E=new Float64Array(16);return i.b7(E,this.getWorldToCamera(m,v)),E}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(m,v,E){const D=this.position;i.bJ(D,D,-m);const z=new Float64Array(16);return i.bP(z,[E,E,E]),i.bx(z,z,D),z[10]*=v,z}getWorldToCamera(m,v){const E=new Float64Array(16),D=new Float64Array(4),z=this.position;return i.bQ(D,this._orientation),i.bJ(z,z,-m),i.bR(E,D),i.bx(E,E,z),E[1]*=-1,E[5]*=-1,E[9]*=-1,E[13]*=-1,E[8]*=v,E[9]*=v,E[10]*=v,E[11]*=v,E}getCameraToClipPerspective(m,v,E,D){const z=new Float64Array(16);return i.bS(z,m,v,E,D),z}getCameraToClipOrthographic(m,v,E,D,z,$){const K=new Float64Array(16);return i.bT(K,m,v,E,D,z,$),K}getDistanceToElevation(m,v=!1){const E=m===0?0:i.bU(m,v?i.bV(this.position[1]):this.position[1]),D=this.forward();return(E-this.position[2])/D[2]}clone(){return new Bw([...this.position],[...this.orientation])}}const ope=(M,m)=>({u_matrix:M,u_ground_shadow_factor:m});class Tp{constructor(m=0,v=0,E=0,D=0){if(isNaN(m)||m<0||isNaN(v)||v<0||isNaN(E)||E<0||isNaN(D)||D<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=m,this.bottom=v,this.left=E,this.right=D}interpolate(m,v,E){return v.top!=null&&m.top!=null&&(this.top=i.am(m.top,v.top,E)),v.bottom!=null&&m.bottom!=null&&(this.bottom=i.am(m.bottom,v.bottom,E)),v.left!=null&&m.left!=null&&(this.left=i.am(m.left,v.left,E)),v.right!=null&&m.right!=null&&(this.right=i.am(m.right,v.right,E)),this}getCenter(m,v){const E=i.aC((this.left+m-this.right)/2,0,m),D=i.aC((this.top+v-this.bottom)/2,0,v);return new i.P(E,D)}equals(m){return this.top===m.top&&this.bottom===m.bottom&&this.left===m.left&&this.right===m.right}clone(){return new Tp(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const $0=15;class $w{constructor(m,v,E,D,z,$,K){this.tileSize=512,this._renderWorldCopies=z===void 0||z,this._minZoom=m||0,this._maxZoom=v||22,this._minPitch=E??0,this._maxPitch=D??60,this.setProjection($),this.setMaxBounds(K),this.width=0,this.height=0,this._center=new i.aU(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._nearClipOffset=0,this._unmodified=!0,this._edgeInsets=new Tp,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new Bw,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 m=new $w(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection(),this.maxBounds);return m._elevation=this._elevation,m._centerAltitude=this._centerAltitude,m._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,m.tileSize=this.tileSize,m.mercatorFromTransition=this.mercatorFromTransition,m.width=this.width,m.height=this.height,m.cameraElevationReference=this.cameraElevationReference,m._center=this._center,m._setZoom(this.zoom),m._seaLevelZoom=this._seaLevelZoom,m.angle=this.angle,m._fov=this._fov,m._pitch=this._pitch,m._nearZ=this._nearZ,m._farZ=this._farZ,m._nearClipOffset=this._nearClipOffset,m._averageElevation=this._averageElevation,m._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,m._unmodified=this._unmodified,m._edgeInsets=this._edgeInsets.clone(),m._camera=this._camera.clone(),m._calcMatrices(),m.freezeTileCoverage=this.freezeTileCoverage,m.frustumCorners=this.frustumCorners,m._allowWorldUnderZoom=this._allowWorldUnderZoom,m}get isOrthographic(){return this.projection.name!=="globe"&&this._orthographicProjectionAtLowPitch&&this.pitch<$0}get elevation(){return this._elevation}set elevation(m){this._elevation!==m&&(this._elevation=m,this._updateCameraOnTerrain(),this._calcMatrices())}get nearClipOffset(){return this._nearClipOffset}set nearClipOffset(m){this._nearClipOffset=m,this._calcMatrices()}get depthOcclusionForSymbolsAndCircles(){return this.projection.name!=="globe"&&!this.isOrthographic}updateElevation(m,v=!1){const E=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(this._seaLevelZoom==null||E)&&this._updateCameraOnTerrain(),(m||E)&&this._constrainCamera(v),this._calcMatrices()}getProjection(){return i.aJ(this.projection,["name","center","parallels"])}setProjection(m){this.projectionOptions=m||{name:"mercator"};const v=this.projection?this.getProjection():void 0;this.projection=i.c0(this.projectionOptions);const E=this.getProjection(),D=!i.b6(v,E);return D&&this._calcMatrices(),this.mercatorFromTransition=!1,D}setOrthographicProjectionAtLowPitch(m){return this._orthographicProjectionAtLowPitch!==m&&(this._orthographicProjectionAtLowPitch=m,this._calcMatrices(),!0)}setMercatorFromTransition(){const m=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=i.c0({name:"mercator"});const v=m!==this.projection.name;return v&&this._calcMatrices(),v}get minZoom(){return this._minZoom}set minZoom(m){this._minZoom!==m&&(this._minZoom=m,this.zoom=Math.max(this.zoom,m))}get maxZoom(){return this._maxZoom}set maxZoom(m){this._maxZoom!==m&&(this._maxZoom=m,this.zoom=Math.min(this.zoom,m))}get minPitch(){return this._minPitch}set minPitch(m){this._minPitch!==m&&(this._minPitch=m,this.pitch=Math.max(this.pitch,m))}get maxPitch(){return this._maxPitch}set maxPitch(m){this._maxPitch!==m&&(this._maxPitch=m,this.pitch=Math.min(this.pitch,m))}get renderWorldCopies(){return this._renderWorldCopies&&this.projection.supportsWorldCopies===!0}set renderWorldCopies(m){m===void 0?m=!0:m===null&&(m=!1),this._renderWorldCopies=m}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const m=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(m))}get cameraWorldSize(){const m=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(m))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return i.bU(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.bs(this.rotation,-180,180)}set bearing(m){this.rotation=m}get rotation(){return-this.angle/Math.PI*180}set rotation(m){const v=-m*Math.PI/180;this.angle!==v&&(this._unmodified=!1,this.angle=v,this._calcMatrices(),this.rotationMatrix=i.c1(),i.c2(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(m){const v=i.aC(m,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(m){m=Math.max(.01,Math.min(60,m)),this._fov!==m&&(this._unmodified=!1,this._fov=i.ap(m),this._calcMatrices())}get fovX(){return this._fov}get fovY(){const m=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/m)}get averageElevation(){return this._averageElevation}set averageElevation(m){this._averageElevation=m,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(m){const v=Math.min(Math.max(m,this.minZoom),this.maxZoom);this._zoom!==v&&(this._unmodified=!1,this._setZoom(v),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(m){this._zoom=m,this.scale=this.zoomScale(m),this.tileZoom=Math.floor(m),this.zoomFraction=m-this.tileZoom}get tileCoverLift(){return this._tileCoverLift}set tileCoverLift(m){this._tileCoverLift!==m&&(this._tileCoverLift=m)}_updateCameraOnTerrain(){const m=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,v=this.elevation&&m===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||m===Number.NEGATIVE_INFINITY&&(!v||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const E=this._elevation;v||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&E.exaggeration()&&this._centerAltitudeValidForExaggeration!==E.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*E.exaggeration(),this._centerAltitudeValidForExaggeration=E.exaggeration()):(this._centerAltitude=m||0,this._centerAltitudeValidForExaggeration=E.exaggeration()),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){if(this._centerAltitudeValidForExaggeration===void 0)return;const m=Math.max(0,(this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize);this._seaLevelZoom=this._zoomFromMercatorZ(m)}sampleAverageElevation(){if(!this._elevation)return 0;const m=this._elevation,v=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],E=this.horizonLineFromTop();let D=0,z=0;for(let $=0;${const rt=i.ck(be,we,Ae,ze,Le);ee.has(rt)||(z.push(new i.aR(we,be,Ae,ze,Le)),ee.add(rt))};for(let we=0;webe.canonical.z)continue;const Ae=be.canonical,ze=be.overscaledZ,Le=be.wrap,rt=1<0,pt=Ae.y+10,Bt=be.wrap-(dt?0:1),wt=be.wrap+(st?0:1),Ft=dt?Ae.x-1:rt-1,ft=st?Ae.x+1:0;if($)E[0]<0?(ne(ze,wt,Ae.z,ft,Ae.y),E[1]<0&&pt&&(ne(ze,Le,Ae.z,Ae.x,Ae.y+1),ne(ze,wt,Ae.z,ft,Ae.y+1)),E[1]>0&&at&&(ne(ze,Le,Ae.z,Ae.x,Ae.y-1),ne(ze,wt,Ae.z,ft,Ae.y-1))):E[0]>0?(ne(ze,Bt,Ae.z,Ft,Ae.y),E[1]<0&&pt&&(ne(ze,Le,Ae.z,Ae.x,Ae.y+1),ne(ze,Bt,Ae.z,Ft,Ae.y+1)),E[1]>0&&at&&(ne(ze,Le,Ae.z,Ae.x,Ae.y-1),ne(ze,Bt,Ae.z,Ft,Ae.y-1))):E[1]<0&&pt?ne(ze,Le,Ae.z,Ae.x,Ae.y+1):at&&ne(ze,Le,Ae.z,Ae.x,Ae.y-1);else{const _t=be.visibleQuadrants;1&_t&&(ne(ze,Bt,Ae.z,Ft,Ae.y),at&&(ne(ze,Le,Ae.z,Ae.x,Ae.y-1),ne(ze,Bt,Ae.z,Ft,Ae.y-1))),2&_t&&(ne(ze,wt,Ae.z,ft,Ae.y),at&&(ne(ze,Le,Ae.z,Ae.x,Ae.y-1),ne(ze,wt,Ae.z,ft,Ae.y-1))),4&_t&&(ne(ze,Bt,Ae.z,Ft,Ae.y),pt&&(ne(ze,Le,Ae.z,Ae.x,Ae.y+1),ne(ze,Bt,Ae.z,Ft,Ae.y+1))),8&_t&&(ne(ze,wt,Ae.z,ft,Ae.y),pt&&(ne(ze,Le,Ae.z,Ae.x,Ae.y+1),ne(ze,wt,Ae.z,ft,Ae.y+1)))}}const de=[];for(const we of z)z.some(be=>we.isChildOf(be))||de.push(we);if(z=de.filter(we=>!m.some(be=>!!(we.overscaledZ{const st=rt.canonical.x+.5-Ae[0],dt=rt.canonical.y+.5-Ae[1];return st*st+dt*dt{const Ft=i.ck(pt,dt,at,Bt,wt);z.has(Ft)||(D.push(new i.aR(dt,pt,at,Bt,wt)),z.add(Ft))},K=m.reduce((dt,pt)=>Math.max(dt,pt.overscaledZ),E),ee=1<{const at=Math.floor(dt[0]),Bt=Math.floor(dt[1]),wt=(dt[0]-at)*i.an,Ft=(dt[1]-Bt)*i.an,ft=Math.floor(pt[0]),_t=Math.floor(pt[1]),Et=(pt[0]-ft)*i.an,Kt=(pt[1]-_t)*i.an;for(let qt=-1;qt<=1;qt++){const ns=at+qt;if(!(ns<0||ns>=ee)){de.x=wt-qt*i.an,we.x=Et-(ns-ft)*i.an;for(let Jt=-1;Jt<=1;Jt++){const Cs=Bt+Jt;de.y=Ft-Jt*i.an,we.y=Kt-(Cs-_t)*i.an,i.cI(de,we,ne)&&$(K,0,E,ns,Cs)}}}},Ae=v.points,ze=Ae[i.c9],Le=Ae[i.ca],rt=this._projectToGround(ze,Ae[i.cb]),st=this._projectToGround(Le,Ae[i.cc]);return be(ze,rt),be(Le,st),D}_projectToGround(m,v){return i.cd(i.ce(),m,v,m[2]/(m[2]-v[2]))}_projectToZ(m,v,E){const D=m[2]-v[2];return Math.abs(D)<1e-6?i.cf(m):i.cd(i.ce(),m,v,(m[2]-E)/D)}extendTileCoverForTunnels(m,v,E,D){if(E<18)return[];const z=v.points,$=z[i.cg],K=z[i.ch],ee=z[i.ci],ne=z[i.cj];if(ee[2]>=0&&ne[2]>=0||$[2]<=0||K[2]<=0)return[];const de=ee[2]<0?this._projectToZ($,ee,0):ee,we=ne[2]<0?this._projectToZ(K,ne,0):ne,be=-D,Ae=ee[2]3&&(Le.length=3),Le}_findExtensionTilesInQuad(m,v,E,D){const z=[],$=new Set;for(const ft of m)$.add(ft.key);const K=m.reduce((ft,_t)=>Math.max(ft,_t.overscaledZ),v),ee=1<{const Et=ft.canonical.x+.5-wt,Kt=ft.canonical.y+.5-Ft,qt=_t.canonical.x+.5-wt,ns=_t.canonical.y+.5-Ft;return Et*Et+Kt*Kt-(qt*qt+ns*ns)||ft.canonical.x-_t.canonical.x||ft.canonical.y-_t.canonical.y}),z}coveringTiles(m){let v=this.coveringZoomLevel(m);const E=v,D=this.elevation&&this.elevation.exaggeration(),z=D&&!m.isTerrainDEM,$=this.projection.name==="mercator";if(m.minzoom!==void 0&&vm.maxzoom&&(v=m.maxzoom);const K=this.locationCoordinate(this.center),ee=this.center.lat,ne=1<{const is=new i.ag(Ht.x+25e-6,Ht.y,Ht.z),hs=new i.ag(Ht.x,Ht.y+25e-6,Ht.z),Qs=Ht.toLngLat(),Ws=is.toLngLat(),Ks=hs.toLngLat(),As=this.locationCoordinate(Qs),jr=this.locationCoordinate(Ws),Pr=this.locationCoordinate(Ks),pr=Math.hypot(jr.x-As.x,jr.y-As.y),br=Math.hypot(Pr.x-As.x,Pr.y-As.y);return Math.sqrt(pr*br)*Ft/25e-6},_t=Ht=>{const ss=Bt,is=wt;return{aabb:i.cp(this,ne,0,0,0,Ht,is,ss,this.projection),zoom:0,x:0,y:0,minZ:is,maxZ:ss,wrap:Ht,fullyVisible:!1}},Et=[];let Kt=[];const qt=v,ns=m.reparseOverscaled?E:v,Jt=(rt-this._centerAltitude)*Le,Cs=Ht=>{if(!this._elevation||!Ht.tileID||!$)return;const ss=this._elevation.getMinMaxForTile(Ht.tileID),is=Ht.aabb;ss?(is.min[2]=ss.min,is.max[2]=ss.max,is.center[2]=(is.min[2]+is.max[2])/2):(Ht.shouldSplit=Zt(Ht),Ht.shouldSplit||(is.min[2]=is.max[2]=is.center[2]=this._centerAltitude))},Ls=(Ht,ss)=>{if(.707*ss{if(Ht.zoom=.9)return!0}else if(z&&(hs=Ht.aabb.distanceZ(st)*Le),this.projection.isReprojectedInTileSpace&&E<=5){const br=Math.pow(2,Ht.zoom),Qr=ft(new i.ag((Ht.x+.5)/br,(Ht.y+.5)/br));Qs=Qr>.85?1:Qr}if(!$&&!we){const br=Math.sqrt(ss*ss+is*is+hs*hs);let Qr=(1<0;){const Ht=Et.pop(),ss=Ht.x,is=Ht.y;let hs=Ht.fullyVisible;const Qs=()=>this.projection.name==="globe"&&(Ht.y===0||Ht.y===(1<Ws)continue;let Ks=0;if(!hs){let pr=dt?Ht.aabb.intersectsPrecise(Ae):Ht.aabb.intersectsPreciseFlat(Ae);if(pr===0&&Qs()){const br=new i.cn(Ht.zoom,ss,is);pr=i.co(this,ne,br,!0).intersectsPrecise(Ae)}if(pr===0)continue;if(m.calculateQuadrantVisibility)if(Ae.containsPoint(Ht.aabb.center))Ks=15;else for(let br=0;br<4;br++)Ht.aabb.quadrant(br).intersects(Ae)!==0&&(Ks|=1<>1),jr={aabb:$?Ht.aabb.quadrant(Ws):i.cp(this,ne,Ht.zoom+1,Ks,As,Ht.wrap,Ht.minZ,Ht.maxZ,this.projection),zoom:Ht.zoom+1,x:Ks,y:As,wrap:Ht.wrap,fullyVisible:hs,tileID:void 0,shouldSplit:void 0,minZ:Ht.minZ,maxZ:Ht.maxZ};z&&!we&&(jr.tileID=new i.aR(Ht.zoom+1===qt?ns:Ht.zoom+1,Ht.wrap,Ht.zoom+1,Ks,As),Cs(jr)),Et.push(jr)}}if(this.fogCullDistSq){const Ht=this.fogCullDistSq,ss=this.horizonLineFromTop();Kt=Kt.filter(is=>{const hs=[0,0,0,1],Qs=[i.an,i.an,0,1],Ws=this.calculateFogTileMatrix(is.tileID.toUnwrapped());i.aE(hs,hs,Ws),i.aE(Qs,Qs,Ws);const Ks=i.cq([],hs,Qs),As=i.cr([],hs,Qs),jr=i.cK(Ks,As);if(jr===0)return!0;let Pr=!1;const pr=this._elevation;if(pr&&jr>Ht&&ss!==0){const br=this.calculateProjMatrix(is.tileID.toUnwrapped());let Qr;m.isTerrainDEM||(Qr=pr.getMinMaxForTile(is.tileID)),Qr||(Qr={min:wt,max:Bt});const bn=i.cs(this.rotation),mn=[bn[0]*i.an,bn[1]*i.an,Qr.max];i.ah(mn,mn,br),Pr=(1-mn[1])*this.height*.5Ht.distanceSq-ss.distanceSq).map(Ht=>Ht.tileID)}resize(m,v){this.width=m,this.height=v,this.pixelsToGLUnits=[2/m,-2/v],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(m){return Math.pow(2,m)}scaleZoom(m){return Math.log2(m)}project(m){const v=i.aC(m.lat,-i.ct,i.ct),E=this.projection.project(m.lng,v);return new i.P(E.x*this.worldSize,E.y*this.worldSize)}unproject(m){return this.projection.unproject(m.x/this.worldSize,m.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/i.bU(1,this.center.lat)/this.worldSize}setLocationAtPoint(m,v){let E,D;const z=this.centerPoint;if(this.projection.name==="globe"){const K=this.worldSize;E=(v.x-z.x)/K,D=(v.y-z.y)/K}else{const K=this.pointCoordinate(v),ee=this.pointCoordinate(z);E=K.x-ee.x,D=K.y-ee.y}const $=this.locationCoordinate(m);this.setLocation(new i.ag($.x-E,$.y-D))}setLocation(m){this.center=this.coordinateLocation(m),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(m,v){return this.projection.locationPoint(this,m,v)}locationPoint3D(m,v){return this.projection.locationPoint(this,m,v,!0)}pointLocation(m){return this.coordinateLocation(this.pointCoordinate(m))}pointLocation3D(m,v){return this.coordinateLocation(this.pointCoordinate3D(m,v))}locationCoordinate(m,v){const E=v?i.bU(v,m.lat):void 0,D=this.projection.project(m.lng,m.lat);return new i.ag(D.x,D.y,E)}coordinateLocation(m){return this.projection.unproject(m.x,m.y)}pointRayIntersection(m,v){const E=v??this._centerAltitude,D=[m.x,m.y,0,1],z=[m.x,m.y,1,1];i.aE(D,D,this.pixelMatrixInverse),i.aE(z,z,this.pixelMatrixInverse);const $=z[3];i.cu(D,D,1/D[3]),i.cu(z,z,1/$);const K=D[2],ee=z[2];return{p0:D,p1:z,t:K===ee?0:(E-K)/(ee-K)}}screenPointToMercatorRay(m){const v=[m.x,m.y,0,1],E=[m.x,m.y,1,1];return i.aE(v,v,this.pixelMatrixInverse),i.aE(E,E,this.pixelMatrixInverse),i.cu(v,v,1/v[3]),i.cu(E,E,1/E[3]),v[2]=i.bU(v[2],this._center.lat)*this.worldSize,E[2]=i.bU(E[2],this._center.lat)*this.worldSize,i.cu(v,v,1/this.worldSize),i.cu(E,E,1/this.worldSize),new i.az([v[0],v[1],v[2]],i.ay([],i.ax([],E,v)))}rayIntersectionCoordinate(m){const{p0:v,p1:E,t:D}=m,z=i.bU(v[2],this._center.lat),$=i.bU(E[2],this._center.lat);return new i.ag(i.am(v[0],E[0],D)/this.worldSize,i.am(v[1],E[1],D)/this.worldSize,i.am(z,$,D))}pointCoordinate(m,v=this._centerAltitude){return this.projection.pointCoordinate(this,m.x,m.y,v)}pointCoordinate3D(m,v){if(!this.elevation)return this.pointCoordinate(m,v);let E=this.projection.pointCoordinate3D(this,m.x,m.y);if(E)return new i.ag(E[0],E[1],E[2]);let D=0,z=this.horizonLineFromTop();if(m.y>z)return this.pointCoordinate(m,v);const $=.02*z,K=m.clone();for(let ee=0;ee<10&&z-D>$;ee++){K.y=i.am(D,z,.66);const ne=this.projection.pointCoordinate3D(this,K.x,K.y);ne?(z=K.y,E=ne):D=K.y}return E?new i.ag(E[0],E[1],E[2]):this.pointCoordinate(m)}isPointAboveHorizon(m){return this.projection.isPointAboveHorizon(this,m)}isPointOnSurface(m){if(m.y<0||m.y>this.height||m.x<0||m.x>this.width)return!1;if(this.elevation||this.zoom>=i.cv)return!this.isPointAboveHorizon(m);const v=this.pointCoordinate(m);return v.y>=0&&v.y<=1}_coordinatePoint(m,v){const E=v&&this.elevation?this.elevation.getAtPointOrZero(m,this._centerAltitude):this._centerAltitude,D=[m.x*this.worldSize,m.y*this.worldSize,E+m.toAltitude(),1];return i.aE(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:m,left:v}=this._edgeInsets,E=this.height-this._edgeInsets.bottom,D=this.width-this._edgeInsets.right,z=this.pointLocation3D(new i.P(v,m)),$=this.pointLocation3D(new i.P(D,m)),K=this.pointLocation3D(new i.P(D,E)),ee=this.pointLocation3D(new i.P(v,E));let ne=Math.min(z.lng,$.lng,K.lng,ee.lng),de=Math.max(z.lng,$.lng,K.lng,ee.lng),we=Math.min(z.lat,$.lat,K.lat,ee.lat),be=Math.max(z.lat,$.lat,K.lat,ee.lat);const Ae=Math.pow(2,-this.zoom)/16*270,ze=this.projection.name==="globe"?1:4,Le=(rt,st,dt,pt,at)=>{const Bt=(rt+dt)/2,wt=(st+pt)/2,Ft=new i.P(Bt,wt),{lng:ft,lat:_t}=this.pointLocation3D(Ft),Et=Math.max(0,ne-ft,we-_t,ft-de,_t-be);ne=Math.min(ne,ft),de=Math.max(de,ft),we=Math.min(we,_t),be=Math.max(be,_t),(atAe)&&(Le(rt,st,Bt,wt,at+1),Le(Bt,wt,dt,pt,at+1))};if(Le(v,m,D,m,1),Le(D,m,D,E,1),Le(D,E,v,E,1),Le(v,E,v,m,1),this.projection.name==="globe"){const[rt,st]=i.cw(this);rt?(be=90,de=180,ne=-180):st&&(we=-90,de=180,ne=-180)}return new i.aK(new i.aU(ne,we),new i.aU(de,be))}_getBoundsRectangular(m,v){const{top:E,left:D}=this._edgeInsets,z=this.height-this._edgeInsets.bottom,$=this.width-this._edgeInsets.right,K=new i.P(D,E),ee=new i.P($,E),ne=new i.P($,z),de=new i.P(D,z);let we=this.pointCoordinate(K,m),be=this.pointCoordinate(ee,m);const Ae=this.pointCoordinate(ne,v),ze=this.pointCoordinate(de,v),Le=(rt,st)=>(st.y-rt.y)/(st.x-rt.x);return we.y>1&&be.y>=0?we=new i.ag((1-ze.y)/Le(ze,we)+ze.x,1):we.y<0&&be.y<=1&&(we=new i.ag(-ze.y/Le(ze,we)+ze.x,0)),be.y>1&&we.y>=0?be=new i.ag((1-Ae.y)/Le(Ae,be)+Ae.x,1):be.y<0&&we.y<=1&&(be=new i.ag(-Ae.y/Le(Ae,be)+Ae.x,0)),new i.aK().extend(this.coordinateLocation(we)).extend(this.coordinateLocation(be)).extend(this.coordinateLocation(ze)).extend(this.coordinateLocation(Ae))}_getBoundsRectangularTerrain(){const m=this.elevation;if(!m.visibleDemTiles.length||m.isUsingMockSource())return this._getBoundsRectangular(0,0);const v=m.visibleDemTiles.reduce((E,D)=>{if(D.dem){const z=D.dem.tree;E.min=Math.min(E.min,z.minimums[0]),E.max=Math.max(E.max,z.maximums[0])}return E},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(v.min*m.exaggeration(),v.max*m.exaggeration())}getBounds(){return this.projection.name==="mercator"||this.projection.name==="equirectangular"?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(m=!0){const v=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,E=this.height/2-v*(1-this._horizonShift);return m?Math.max(0,E):E}getMaxBounds(){return this.maxBounds}setMaxBounds(m){this.maxBounds=m,this.minLat=-i.ct,this.maxLat=i.ct,this.minLng=-180,this.maxLng=180,m&&(this.minLat=m.getSouth(),this.maxLat=m.getNorth(),this.minLng=m.getWest(),this.maxLng=m.getEast(),this.maxLngwe&&(K=we-ne),we-deAe&&($=Ae-ee),Ae-be{for(let Zt=0;Zt<16;Zt++)ns[Zt]=i.am(Jt[Zt],Cs[Zt],Ls)})(K,K,ee,i.cL(this.pitch>=$0?1:this.pitch/$0))}else K=ee;const ne=i.cz([],ee,$);let de=i.cz([],K,$);if(this.projection.isReprojectedInTileSpace){const _t=this.locationCoordinate(this.center),Et=i.b9([]);i.bx(Et,Et,[_t.x*this.worldSize,_t.y*this.worldSize,0]),i.aD(Et,Et,i.cA(this)),i.bx(Et,Et,[-_t.x*this.worldSize,-_t.y*this.worldSize,0]),i.aD(de,de,Et),i.aD(ne,ne,Et),this.inverseAdjustmentMatrix=i.cB(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=i.cC([],de,[this.worldSize,this.worldSize,this.worldSize/z,1]),this.projMatrix=de,this.invProjMatrix=i.b7(new Float64Array(16),this.projMatrix),v){const _t=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);_t[8]=2*-m.x/this.width,_t[9]=2*m.y/this.height,this.expandedFarZProjMatrix=i.cz([],_t,$)}else this.expandedFarZProjMatrix=this.projMatrix;const we=i.b7([],K);this.frustumCorners=i.cD.fromInvProjectionMatrix(we,this.horizonLineFromTop(),this.height),this.cameraFrustum=i.cl.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!v);const be=new Float32Array(16);i.b9(be),i.cC(be,be,[1,-1,1]),i.cE(be,be,this._pitch),i.ba(be,be,this.angle);const Ae=i.bS(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=i.b8(Ae);const ze=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;Ae[8]=2*-m.x/this.width,Ae[9]=2*(m.y+ze)/this.height,this.skyboxMatrix=i.aD(be,Ae,be);const Le=this.point,rt=Le.x,st=Le.y,dt=this.width%2/2,pt=this.height%2/2,at=Math.cos(this.angle),Bt=Math.sin(this.angle),wt=rt-Math.round(rt)+at*dt+Bt*pt,Ft=st-Math.round(st)+at*pt+Bt*dt,ft=new Float64Array(de);if(i.bx(ft,ft,[wt>.5?wt-1:wt,Ft>.5?Ft-1:Ft,0]),this.alignedProjMatrix=ft,de=i.bb(),i.cC(de,de,[this.width/2,-this.height/2,1]),i.bx(de,de,[1,-1,0]),this.labelPlaneMatrix=de,de=i.bb(),i.cC(de,de,[1,-1,1]),i.bx(de,de,[-1,-1,0]),i.cC(de,de,[2/this.width,2/this.height,1]),this.glCoordMatrix=de,this.pixelMatrix=i.aD(new Float64Array(16),this.labelPlaneMatrix,ne),this._calcFogMatrices(),this._distanceTileDataCache={},de=i.b7(new Float64Array(16),this.pixelMatrix),!de)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=de,this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=i.cF(this);const _t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=i.ah(_t,_t,$),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=de;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const m=this.cameraWorldSizeForFog,v=this.cameraPixelsPerMeter,E=this._camera.position,D=1/this.height/this._pixelsPerMercatorPixel,z=[m,m,v];i.bJ(z,z,D),i.bJ(E,E,-1),i.cG(E,E,z);const $=i.bb();i.bx($,$,E),i.cC($,$,z),this.mercatorFogMatrix=$,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(m,v,D)}_computeCameraPosition(m){const v=(m=m||this.pixelsPerMeter)/this.pixelsPerMeter,E=this._camera.forward(),D=this.point,z=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*v-m/this.worldSize*this._centerAltitude;return[D.x/this.worldSize-E[0]*z,D.y/this.worldSize-E[1]*z,m/this.worldSize*this._centerAltitude-E[2]*z]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(m){const v=this._maxCameraBoundsDistance()*Math.cos(this._pitch),E=this._camera.position[2],D=m[2];let z=1;this.projection.wrap&&(this.center=this.center.wrap()),D>0&&(z=Math.min((v-E)/D,1)),this._camera.position=i.bg([],this._camera.position,m,z),this._updateStateFromCamera()}_updateStateFromCamera(){const m=this._camera.position,v=this._camera.forward(),{pitch:E,bearing:D}=this._camera.getPitchBearing(),z=i.bU(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,$=this._mercatorZfromZoom(this._maxZoom)*Math.cos(i.ap(this._maxPitch)),K=Math.max((m[2]-z)/Math.cos(E),$),ee=this._zoomFromMercatorZ(K);i.bg(m,m,v,K),this._pitch=i.aC(E,i.ap(this.minPitch),i.ap(this.maxPitch)),this.angle=i.bs(D,-Math.PI,Math.PI),this._setZoom(i.aC(ee,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new i.ag(m[0],m[1],m[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(m){return Math.pow(2,m)*this.tileSize}_mercatorZfromZoom(m){return this.cameraToCenterDistance/this._worldSizeFromZoom(m)}_minimumHeightOverTerrain(){const m=Math.min(this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(m)}_zoomFromMercatorZ(m){return this.scaleZoom(this.cameraToCenterDistance/(Math.max(0,m)*this.tileSize))}zoomFromMercatorZAdjusted(m){let v=0,E=i.cv,D=0,z=1/0;for(;E-v>1e-6&&E>v;){const $=v+.5*(E-v),K=this.tileSize*Math.pow(2,$),ee=this.getCameraToCenterDistance(this.projection,$,K),ne=this.scaleZoom(ee/(Math.max(0,m)*this.tileSize)),de=Math.abs($-ne);dene||be.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+i.cH(this.fovAboveCenter)>88||this.anyCornerOffEdge(new i.P(0,0),new i.P(this.width,this.height))}zoomDeltaToMovement(m,v){const E=i.ai(i.ax([],this._camera.position,m)),D=this._zoomFromMercatorZ(E)+v;return E-this._mercatorZfromZoom(D)}getCameraPoint(){if(this.projection.name==="globe"){const m=function([v,E,D],z){const $=[v,E,D,1];i.aE($,$,z);const K=$[3]=Math.max($[3],1e-6);return $[0]/=K,$[1]/=K,$[2]/=K,$}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new i.P(m[0],m[1])}{const m=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new i.P(0,m))}}getCameraToCenterDistance(m,v=this.zoom,E=this.worldSize){const D=i.cy(m,v,this.width,this.height,1024),z=m.pixelSpaceConversion(this.center.lat,E,D);let $=.5/Math.tan(.5*this._fov)*this.height*z;return this.isOrthographic&&($=i.am(1,$,i.cL(this.pitch>=$0?1:this.pitch/$0))),$}getWorldToCameraMatrix(){const m=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?this.pixelsPerMeter:1);return this.projection.name==="globe"&&i.aD(m,m,this.globeMatrix),m}getFrustum(m){return i.cl.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,m,this.projection.zAxisUnit==="meters")}}const oc=(M,m)=>{if(m>0&&M.terrain&&i.w("Cutoff is currently disabled on terrain"),m<=0||M.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const v=M.transform,E=v.pitch,D=v.isLODDisabled(!1)?60:30;if(E0,uniformValues:{u_cutoff_params:[v._nearZ,v._farZ,(de-v._nearZ)/z,(de-be-v._nearZ)/z]}}},ry=2048;class qC{constructor(m,v){this.aabb=m,this.lastCascade=v}}class LO{add(m,v){const E=this.receivers[m.key];E!==void 0?(E.aabb.min[0]=Math.min(E.aabb.min[0],v.min[0]),E.aabb.min[1]=Math.min(E.aabb.min[1],v.min[1]),E.aabb.min[2]=Math.min(E.aabb.min[2],v.min[2]),E.aabb.max[0]=Math.max(E.aabb.max[0],v.max[0]),E.aabb.max[1]=Math.max(E.aabb.max[1],v.max[1]),E.aabb.max[2]=Math.max(E.aabb.max[2],v.max[2])):this.receivers[m.key]=new qC(v,null)}clear(){this.receivers={}}get(m){return this.receivers[m.key]}computeRequiredCascades(m,v,E){const D=i.cU.fromPoints(m.points);let z=0;for(const $ in this.receivers){const K=this.receivers[$];if(!K||!D.intersectsAabb(K.aabb))continue;K.aabb.min=D.closestPoint(K.aabb.min),K.aabb.max=D.closestPoint(K.aabb.max);const ee=K.aabb.getCorners();for(let ne=0;ne1||be[1]<-1||be[1]>1){de=!1;break}}if(K.lastCascade=ne,z=Math.max(z,ne),de)break}}return z+1}}class qw{constructor(m){this.painter=m,this._enabled=!1,this._drawShadowAfterLayer=-1,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new LO,this._depthMode=new Sr(m.context.gl.LEQUAL,Sr.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 m of this._cascades)m.texture.destroy(),m.framebuffer.destroy();this._cascades=[]}updateShadowParameters(m,v){const E=this.painter;if(this._enabled=!1,this._drawShadowAfterLayer=-1,this._receivers.clear(),!v||!v.properties)return;const D=v.properties.get("shadow-intensity"),z=v.properties.get("shadow-draw-before-layer");if(!v.shadowsEnabled()||D<=0)return;let $=-1,K=0;for(const st of E.style.order){const dt=E.style._mergedLayers[st];dt.hasShadowPass()&&!dt.isHidden(m.zoom)&&($=K),!z||z!==st&&z!==dt.slot||(this._drawShadowAfterLayer=K>0?K-1:0),K+=1}if(this._enabled=$>=0,!this.enabled)return;this._drawShadowAfterLayer<0&&(this._drawShadowAfterLayer=$);const ee=E.context,ne=ry,de=ry;if(this._cascades.length===0||ry!==this._cascades[0].texture.size[0]){this._cascades=[];for(let st=0;st<2;++st){const dt=ee.gl,pt=ee.createFramebuffer(ne,de,0,"texture"),at=new i.T(ee,{width:ne,height:de,data:null},dt.DEPTH_COMPONENT16);pt.depthAttachment.set(at.texture),this._cascades.push({framebuffer:pt,texture:at,matrix:[],far:0,boundingSphereRadius:0,frustum:new i.cl,scale:0})}}this.shadowDirection=DO(v);let we=0;if(m.elevation){const st=m.elevation,dt=[1e4,-1e4];st.visibleDemTiles.filter(pt=>pt.dem).forEach(pt=>{const at=pt.dem.tree;dt[0]=Math.min(dt[0],at.minimums[0]),dt[1]=Math.max(dt[1],at.maximums[0])}),dt[0]!==1e4&&(we=(dt[1]-dt[0])*st.exaggeration())}const be=1.5*m.cameraToCenterDistance,Ae=3*be,ze=new Float64Array(16);for(let st=0;st=0)return{};const z=function(ee,ne,de){const we=de/(1<0&&(i.cT(z[1],z[1],[D[0]*$,0,0]),i.cT(z[2],z[2],[D[0]*$,0,0])),D[1]<0?(i.cT(z[0],z[0],[0,D[1]*$,0]),i.cT(z[1],z[1],[0,D[1]*$,0])):D[1]>0&&(i.cT(z[2],z[2],[0,D[1]*$,0]),i.cT(z[3],z[3],[0,D[1]*$,0]));const K={};return K.vertices=z,K.planes=[UC(z[1],z[0],z[4]),UC(z[2],z[1],z[5]),UC(z[3],z[2],z[6]),UC(z[0],z[3],z[7])],K}addShadowReceiver(m,v,E){this._receivers.add(m,i.cU.fromTileIdAndHeight(m,v,E))}getMaxCascadeForTile(m){const v=this._receivers.get(m);return v&&v.lastCascade?v.lastCascade:0}}function UC(M,m,v){const E=i.ax([],v,m),D=i.ax([],M,m),z=i.bh([],E,D),$=i.ai(z);return $===0?[0,0,1,0]:(i.bJ(z,z,1/$),[z[0],z[1],z[2],-i.bi(z,m)])}function DO(M){const m=M.properties.get("direction"),v=i.cP(m.x,m.y,m.z);v[2]=i.aC(v[2],0,75);const E=i.cR([v[0],v[1],v[2]]);return i.cQ(E.x,E.y,E.z)}function Ap(M,m,v){const E=m.properties.get("color-use-theme")==="none",D=m.properties.get("color"),z=m.properties.get("intensity"),$=m.properties.get("direction"),K=[$.x,$.y,$.z],ee=v.properties.get("color-use-theme")==="none",ne=v.properties.get("color"),de=v.properties.get("intensity"),we=Math.max(i.bi([0,0,1],K),0),be=[0,0,0];i.bJ(be,ne.toPremultipliedRenderColor(ee?null:M.getLut(m.scope)).toArray01Linear().slice(0,3),de);const Ae=[0,0,0];return i.bJ(Ae,D.toPremultipliedRenderColor(E?null:M.getLut(v.scope)).toArray01Linear().slice(0,3),we*z),i.cW([be[0]>0?be[0]/(be[0]+Ae[0]):0,be[1]>0?be[1]/(be[1]+Ae[1]):0,be[2]>0?be[2]/(be[2]+Ae[2]):0])}function Uw(M,m,v,E,D,z){const $=M.zoom,K=M.scale,ee=M.worldSize,ne=1/ee,de=M.aspect,we=Math.sqrt(1+de*de)*Math.tan(.5*M.fovX),be=we*we,Ae=E-v,ze=E+v;let Le,rt;be>Ae/ze?(Le=E,rt=E*we):(Le=.5*ze*(1+be),rt=.5*Math.sqrt(Ae*Ae+2*(E*E+v*v)*be+ze*ze*be*be));const st=M.projection.pixelsPerMeter(M.center.lat,ee),dt=M._camera.getCameraToWorldMercator(),pt=[0,0,-Le*ne];i.ah(pt,pt,dt);let at=rt*ne;const Bt=function(hs){return hs[0]/=K,hs[1]/=K,hs[2]=i.bU(hs[2],M._center.lat),hs},wt=M._edgeInsets;if(!(wt.left===0&&wt.top===0&&wt.right===0&&wt.bottom===0||wt.left===wt.right&&wt.top===wt.bottom)){const hs=M._camera.getWorldToCamera(M.worldSize,M.projection.zAxisUnit==="meters"?st:1),Qs=M._camera.getCameraToClipPerspective(M._fov,M.width/M.height,v,E);Qs[8]=2*-M.centerOffset.x/M.width,Qs[9]=2*M.centerOffset.y/M.height;const Ws=new Float64Array(16);i.cz(Ws,Qs,hs);const Ks=new Float64Array(16);i.b7(Ks,Ws);const As=i.cl.fromInvProjectionMatrix(Ks,ee,$,!0);for(const jr of As.points){const Pr=Bt(jr);at=Math.max(at,i.bK(i.cV([],pt,Pr)))}}at*=D/(D-1);const Ft=Math.acos(m[2]),ft=Math.atan2(-m[0],-m[1]),_t=new Bw;_t.position=pt,_t.setPitchBearing(Ft,ft);const Et=_t.getWorldToCamera(ee,st),Kt=at*ee,qt=Math.min(M._mercatorZfromZoom(17)*ee*-2,-2*Kt),ns=_t.getCameraToClipOrthographic(-Kt,Kt,-Kt,Kt,qt,(Kt+z*st)/m[2]),Jt=new Float64Array(16);i.aD(Jt,ns,Et);const Cs=i.cQ(Math.floor(1e6*pt[0])/1e6*ee,Math.floor(1e6*pt[1])/1e6*ee,0),Ls=.5*D,Zt=[0,0,0];i.ah(Zt,Cs,Jt),i.bJ(Zt,Zt,Ls);const Ht=[Math.floor(Zt[0]),Math.floor(Zt[1]),Math.floor(Zt[2])],ss=[0,0,0];i.ax(ss,Zt,Ht),i.bJ(ss,ss,-1/Ls);const is=new Float64Array(16);return i.b9(is),i.bx(is,is,ss),i.aD(Jt,is,Jt),[Jt,Kt]}class lpe extends i.E{constructor(m){super(),this.requestManager=m,this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}loadModel(m,v){return i.cX(this.requestManager.transformRequest(v,i.R.Model).url).then(E=>{const D=i.cY(E),z=new i.cZ(m,v,void 0,void 0,D);return z.computeBoundsAndApplyParent(),z}).catch(E=>{if(E&&E.status===404)return null;this.fire(new i.B(new Error(`Could not load model ${m} from ${v}: ${E.message}`)))})}load(m,v,E={forceReload:!1}){this.models[v]||(this.models[v]={});const D=Object.keys(m),z=[],$=[];for(const K of D){const ee=m[K];this.hasURLBeenRequested(ee)&&!E.forceReload||(this.modelByURL[ee]={modelId:K,scope:v},z.push(this.loadModel(K,ee)),$.push(K)),this.models[v][K]||(this.models[v][K]={model:null,numReferences:1})}this.numModelsLoading[v]=(this.numModelsLoading[v]||0)+$.length,Promise.allSettled(z).then(K=>{for(let ee=0;ee{this.fire(new i.B(new Error(`Could not load models: ${K.message}`)))})}isLoaded(){for(const m in this.numModelsLoading)if(this.numModelsLoading[m]>0)return!1;return!0}hasModel(m,v,E={exactIdMatch:!1}){return!!(E.exactIdMatch?this.getModel(m,v):this.getModelByURL(this.modelUris[v][m]))}getModel(m,v){return this.models[v]||(this.models[v]={}),this.models[v][m]?this.models[v][m].model:void 0}getModelByURL(m){if(!m)return null;const v=this.modelByURL[m];return v?this.models[v.scope][v.modelId].model:null}hasModelBeenAdded(m,v){return this.models[v]&&this.models[v][m]!==void 0}getModelURIs(m){return this.modelUris[m]||{}}addModel(m,v,E){this.models[E]||(this.models[E]={}),this.modelUris[E]||(this.modelUris[E]={});const D=this.requestManager.normalizeModelURL(v);if((this.hasModel(m,E,{exactIdMatch:!0})||this.hasModelBeenAdded(m,E))&&this.modelUris[E][m]===D)this.models[E][m].numReferences++;else if(this.hasURLBeenRequested(D)){const{scope:z,modelId:$}=this.modelByURL[D];this.models[z][$].numReferences++}else this.modelUris[E][m]=D,this.load({[m]:this.modelUris[E][m]},E)}addModelURLs(m,v){this.models[v]||(this.models[v]={}),this.modelUris[v]||(this.modelUris[v]={});const E=this.modelUris[v];for(const D in m)E[D]=this.requestManager.normalizeModelURL(m[D])}reloadModels(m){this.load(this.modelUris[m],m,{forceReload:!0})}addModelsFromBucket(m,v){this.models[v]||(this.models[v]={}),this.modelUris[v]||(this.modelUris[v]={});const E={};for(const D of m)this.hasModel(D,v,{exactIdMatch:!0})||this.hasURLBeenRequested(D)?this.models[v][D].numReferences++:this.modelUris[v][D]&&!this.hasURLBeenRequested(D)?E[D]=this.modelUris[v][D]:!this.hasURLBeenRequested(D)&&i.c_(D,!1)&&(this.modelUris[v][D]=this.requestManager.normalizeModelURL(D),E[D]=this.modelUris[v][D]);this.load(E,v)}hasURLBeenRequested(m){return this.modelByURL[m]!==void 0}removeModel(m,v,E=!1,D=!1){if(this.models[v]&&this.models[v][m]&&(this.models[v][m].numReferences--,this.models[v][m].numReferences===0||D)){const z=this.modelUris[v][m];E||delete this.modelUris[v][m],delete this.modelByURL[z];const $=this.models[v][m].model;if(!$)return;delete this.models[v][m],$.destroy()}}destroy(){for(const m of Object.keys(this.models))for(const v of Object.keys(this.models[m])){const E=this.models[m][v].model;delete this.models[m][v],E&&E.destroy()}this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}listModels(m){return this.models[m]||(this.models[m]={}),Object.keys(this.models[m])}upload(m,v){this.models[v]||(this.models[v]={});for(const E in this.models[v])this.models[v][E].model&&this.models[v][E].model.upload(m.context)}}const $E=i.a8.colorTheme,O1=new i.ab({data:new i.ac($E.data)});function RO(M){if(!M.metadata||!M.metadata.content_area)return;const m=i.o.devicePixelRatio,{left:v,top:E,width:D,height:z}=M.metadata.content_area,$=v*m,K=E*m;return[$,K,$+D*m,K+z*m]}function Vw(M){if(M)return M.map(([m,v])=>[m*i.o.devicePixelRatio,v*i.o.devicePixelRatio])}class qE{constructor(m,v,E){this.id=m,this.scope=v,this.sourceCache=E,this.pendingRequests=new Set,this.missingRequests=new Set}addPendingRequest(m){this.missingRequests.has(m.name)||this.pendingRequests.has(m.name)||this.pendingRequests.add(m.name)}hasPendingRequests(){return this.pendingRequests.size>0}resolvePendingRequests(){const m=new Map;if(!this.sourceCache.loaded())return m;const v=this.sourceCache.getVisibleCoordinates();if(v.length===0)return m;const E=this.sourceCache.getSource();if(!(E instanceof gh))return m;const D=v.map($=>this.sourceCache.getTile($)),z=E.getImages(D,Array.from(this.pendingRequests));for(const[$,K]of z)m.set(i.I.from({name:$,iconsetId:this.id}),K),this.pendingRequests.delete($);for(const $ of this.pendingRequests)this.missingRequests.add($);return this.pendingRequests.clear(),m}}class ny{constructor(){this._previousClosestBuildingId=null,this._hysteresisRatio=.8,this._indoorMinimumZoom=16}findClosestBuilding(m,v,E,D,z){if(Eee*this._hysteresisRatio&&($=this._previousClosestBuildingId):ne&&!$&&($=this._previousClosestBuildingId),this._previousClosestBuildingId=$,$}_calculateDistance(m,v){if(!v.center)return Number.MAX_VALUE;const E=m.lat-v.center[1],D=m.lng-v.center[0];return E*E+D*D}_isBuildingVisible(m,v,E){if(!E)return!1;for(const D of m.floorIds){const z=m.floors[D];if(!z.geometry)continue;const $=z.geometry;if($.type==="Polygon"){const K=this._convertRingToPoints($.coordinates[0]);if(i.bw(K,E))return!0}else if($.type==="MultiPolygon"){const K=this._convertMultiPolygonToPoints($.coordinates);if(i.d0(E,K))return!0}}return!1}_convertRingToPoints(m){return m.map(v=>new i.P(v[0],v[1]))}_convertMultiPolygonToPoints(m){return m.map(v=>v.length===0?[]:v[0].map(E=>new i.P(E[0],E[1])))}}class cpe extends i.E{constructor(m){super(),this._style=m,this._buildings={},this._activeFloors=new Set,this._closestBuildingId=null,this._indoorState={selectedFloorId:null,activeFloorsVisible:!0,activeFloors:this._activeFloors},this._buildingDetectionStrategy=new ny,this._initialLoadDone=!1,i.aZ(["_updateUI"],this),this._style.on("style.load",()=>{this._style.isIndoorEnabled()&&(this._style.map.on("load",()=>{this._initialLoadDone=!0,this._indoorState&&this._indoorState.needsUpdate&&(this._indoorState.needsUpdate=!1,this._style.updateIndoorDependentLayers()),this._updateUI()}),this._style.map.on("move",this._updateUI),this._style.map.on("idle",this._updateUI))})}destroy(){this._buildings={},this._activeFloors=new Set,this._indoorState=null}selectFloor(m){m===this._selectedFloorId&&this._indoorState&&this._indoorState.activeFloorsVisible||(this._selectedFloorId=m,this._recalculateActiveFloors())}setActiveFloorsVisibility(m){this._updateActiveFloors(m),this._updateIndoorSelector()}setIndoorData(m){let v=!1;for(const[E,D]of Object.entries(m.buildings))if(this._buildings[E])for(const z of D.floorIds)this._buildings[E].floorIds.add(z),this._buildings[E].floors[z]?this._mergeFloors(this._buildings[E].floors[z],D.floors[z]):(this._buildings[E].floors[z]=D.floors[z],v=!0);else this._buildings[E]=D,v=!0;v&&this._recalculateActiveFloors()}getIndoorTileOptions(m,v){return this._indoorState?{sourceLayers:this._style.getIndoorSourceLayers(m,v),indoorState:this._indoorState}:null}getControlState(){const m=this._buildings,v=this._closestBuildingId,E=v&&m?m[v]:void 0;if(!E)return{selectedFloorId:null,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:[]};let D=null;for(const $ of E.floorIds)if(this._activeFloors&&this._activeFloors.has($)){D=$;break}const z=Array.from(E.floorIds).map($=>({id:$,name:E.floors[$].name,zIndex:E.floors[$].zIndex})).sort(($,K)=>K.zIndex-$.zIndex).filter(($,K,ee)=>K===0||$.zIndex!==ee[K-1].zIndex);return{selectedFloorId:D,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:z}}_updateUI(){this._initialLoadDone=!0;const m=this._style.map.transform,v=this._buildingDetectionStrategy.findClosestBuilding(this._buildings,m.center,m.zoom,m.getBounds(),this._makeViewportPolygon());if(v!==this._closestBuildingId){const E=this._closestBuildingId;this._closestBuildingId=v,this._onBuildingTransition(E,v),this._updateIndoorSelector()}}_onBuildingTransition(m,v){if(!this._indoorState)return;!v&&m?(this._indoorState.activeFloors=new Set,this._indoorState.activeFloorsVisible=!1,this._style.updateIndoorDependentLayers()):!!v&&!m&&(this._recalculateActiveFloors(),this._updateActiveFloors(!0))}_updateIndoorSelector(){this.fire(new i.C("selector-update",this.getControlState()))}_updateActiveFloors(m){this._indoorState={selectedFloorId:this._selectedFloorId,activeFloorsVisible:m,activeFloors:this._activeFloors},this._initialLoadDone?this._style.updateIndoorDependentLayers():this._indoorState.needsUpdate=!0}_recalculateActiveFloors(){if(!this._buildings)return;const m=i.d1.calculate(this._buildings,this._selectedFloorId,this._activeFloors);(function(v,E){if(v===E)return!0;if(!v||!E||v.size!==E.size)return!1;for(const D of v)if(!E.has(D))return!1;return!0})(m,this._activeFloors)||(this._activeFloors=m,this._updateActiveFloors(!!this._indoorState&&this._indoorState.activeFloorsVisible),this._updateIndoorSelector())}_mergeFloors(m,v){v.geometry&&(m.geometry?(m.geometry.type==="Polygon"&&(m.geometry={type:"MultiPolygon",coordinates:[m.geometry.coordinates]}),v.geometry.type==="Polygon"?m.geometry.coordinates.push(v.geometry.coordinates):v.geometry.type==="MultiPolygon"&&m.geometry.coordinates.push(...v.geometry.coordinates)):m.geometry=v.geometry)}_makeViewportPolygon(){const m=this._style.map.transform,v=m.width,E=m.height;return[m.pointLocation(new i.P(0,0)),m.pointLocation(new i.P(v,0)),m.pointLocation(new i.P(v,E)),m.pointLocation(new i.P(0,E))].map(D=>new i.P(D.lng,D.lat))}}const q0=(M,m)=>or(M,m&&m.filter(v=>v.identifier!=="source.canvas")),dpe=i.aJ(Sa,["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"]),OO=i.aJ(Sa,["setCenter","setZoom","setBearing","setPitch"]),UE=new Set(["background","sky","slot","custom"]),VC={version:8,layers:[],sources:{}},VE={duration:300,delay:0};class Vm extends i.E{constructor(m,v={}){if(super(),this.map=m,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({},VE),this._buildingIndex=new D0(this),this.crossTileSymbolIndex=new R1,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedIndoor={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._mergedFillExtrusionSourceCaches={},this._clipLayerPresent=!1,this._hasAppearances=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._importedAsBasemap=!1,this._changes=v.styleChanges||new We,this._hasDataDrivenEmissive=!1,this.indoorManager=new cpe(this),this.dispatcher=v.dispatcher?v.dispatcher:new mt(kt(),this),this.map.painter&&this.map.painter.context){const D=this.map.painter.context.maxUniformBufferBindings,z=Math.floor(this.map.painter.context.maxUniformBlockSize/4);this.dispatcher.broadcast("setContextParams",{maxBindingPoints:D,maxUniformBlockSizeDwords:z,disableSymbolUBO:this.map.painter.context.disableSymbolUBO})}v.imageManager?this.imageManager=v.imageManager:(this.imageManager=new Ut(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=v.glyphManager?v.glyphManager:new i.d2(m._requestManager,v.localFontFamily?i.d3.all:v.localIdeographFontFamily?i.d3.ideographs:i.d3.none,v.localFontFamily||v.localIdeographFontFamily,v.useServerFontComposition),v.modelManager?this.modelManager=v.modelManager:(this.modelManager=new lpe(m._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._fillExtrusionSourceCaches={},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.d4()),this.dispatcher.broadcast("setConfig",i.d5());const E=this;this._rtlTextPluginCallback=Vm.registerForPluginStateChange(D=>{E.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:D.pluginStatus,pluginURL:D.pluginURL},(z,$)=>{if(i.d6(z),$&&$.every(K=>K))for(const K in E._sourceCaches){const ee=E._sourceCaches[K],ne=ee.getSource().type;ne!=="vector"&&ne!=="geojson"||ee.reload()}})}),this.on("data",D=>{if(D.dataType!=="source"||D.sourceDataType!=="metadata")return;const z=this.getOwnSource(D.sourceId);if(z&&z.vectorLayerIds)for(const $ in this._layers){const K=this._layers[$];K.source===z.id&&this._validateLayer(K)}})}load(m){return m?(typeof m=="string"?this.loadURL(m):this.loadJSON(m),this):this}_getGlobalId(m){if(!m)return null;if(typeof m=="string"){if(i.e(m))return m;const v=i.d7(m);if(!v.startsWith("http"))try{return new URL(v,location.href).toString()}catch{return v}return v}return`json://${i.d8(JSON.stringify(m))}`}_diffStyle(m,v,E){this.globalId=this._getGlobalId(m);const D=(z,$)=>{try{$(null,this.setState(z,E))}catch(K){$(K,!1)}};if(typeof m=="string"){const z=this.map._requestManager.normalizeStyleURL(m),$=this.map._requestManager.transformRequest(z,i.R.Style);i.m($,(K,ee)=>{K?this.fire(new i.B(K)):ee&&D(ee,v)})}else typeof m=="object"&&D(m,v)}loadURL(m,v={}){this.fire(new i.C("dataloading",{dataType:"style"}));const E=typeof v.validate=="boolean"?v.validate:!i.e(m);this.globalId=this._getGlobalId(m),m=this.map._requestManager.normalizeStyleURL(m,v.accessToken),this.resolvedImports.add(m);const D=this.importsCache.get(m);if(D)return this._load(D,E);const z=this.map._requestManager.transformRequest(m,i.R.Style);this._request=i.m(z,($,K)=>{if(this._request=null,$)this.fire(new i.B($));else if(K)return this.importsCache.set(m,K),this._load(K,E)})}loadJSON(m,v={}){this.fire(new i.C("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(m),this._request=i.o.frame(()=>{this._request=null,this._load(m,v.validate!==!1)})}loadEmpty(){this.fire(new i.C("dataloading",{dataType:"style"})),this._load(VC,!1)}_loadImports(m,v,E){if(this.importDepth>=4)return i.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const D=[];for(const z of m){const $=this._createFragmentStyle(z),K=new Promise(de=>{$.once("style.import.load",de),$.once("error",de)}).then(()=>{this.mergeAll(),this.fire(new i.C("data",{dataType:"style"}))});if(D.push(K),this.resolvedImports.has(z.url)){$.loadEmpty();continue}const ee=z.data||this.importsCache.get(z.url);ee?(z.data?($.fire(new i.C("dataloading",{dataType:"style"})),$.globalId=$._getGlobalId(ee),queueMicrotask(()=>$._load(ee,v))):$.loadJSON(ee,{validate:v}),this._isInternalStyle(ee)&&($.globalId=null)):z.url?$.loadURL(z.url,{validate:v}):$.loadEmpty();const ne={style:$,id:z.id,config:z.config};if(E){const de=this.fragments.findIndex(({id:we})=>we===E);this.fragments=this.fragments.slice(0,de).concat(ne).concat(this.fragments.slice(de))}else this.fragments.push(ne)}return Promise.allSettled(D)}getImportGlobalIds(m=this,v=new Set){for(const E of m.fragments)E.style.globalId&&v.add(E.style.globalId),this.getImportGlobalIds(E.style,v);return[...v.values()]}_createFragmentStyle(m){const v=this.scope?i.F(m.id,this.scope):m.id;let E;const D=this._initialConfig&&this._initialConfig[v];(m.config||D)&&(E=Object.assign({},m.config,D));const z=new Vm(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:E,configOptions:this.options,colorThemeOverride:m["color-theme"],configDependentLayers:this._configDependentLayers,indoorDependentLayers:this._indoorDependentLayers});return z.setEventedParent(this.map,{style:z}),z}_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(m){return this.isRootStyle()&&(m.fragment||!!m.schema&&m.fragment!==!1)}_load(m,v){if(this._isInternalStyle(m)){const z=Object.assign({},VC,{imports:[{id:"basemap",data:m,url:""}]},m.center?{center:m.center}:{},m.bearing?{bearing:m.bearing}:{},m.pitch?{pitch:m.pitch}:{},m.zoom?{zoom:m.zoom}:{},m.light?{light:m.light}:{});return this._importedAsBasemap=!0,void this._load(z,v)}if(this.updateConfig(this._config,m.schema),v&&q0(this,Yt(m)))return;this._loaded=!0;for(const z in m.sources)this.addSource(z,m.sources[z],{validate:!1,isInitialLoad:!0});this.stylesheet=i.d9(m);const E=()=>{if(m.iconsets)for(const ee in m.iconsets)this.addIconset(ee,m.iconsets[ee]);m.sprite?this._loadIconset(m.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),!this.glyphManager.url&&m.glyphs&&this.glyphManager.setURL(m.glyphs);const z=P1(this.stylesheet.layers);if(this._order=z.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 zr(ee.properties,ee.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new zr(this.stylesheet.light)),this._layers={};for(const ee of z){const ne=i.de(ee,this.scope,this._styleColorTheme.lut,this.options);ne.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(ne.fqid),ne.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(ne.fqid),this._hasAppearances=this._hasAppearances||ne.getAppearances().length!==0,ne.setEventedParent(this,{layer:{id:ne.id}}),this._layers[ne.id]=ne;const de=this.getOwnLayerSourceCache(ne),we=!!this.directionalLight&&this.directionalLight.shadowsEnabled();de&&ne.canCastShadows()&&we&&(de.castsShadows=!0)}if(this.glyphManager.url){const ee=new Set;for(const ne in this._layers){const de=this._layers[ne];if(de.type==="symbol"&&de.layout){const we=de.layout.get("text-font");we&&we.value&&we.value.kind==="constant"&&ee.add(we.value.value.join(","))}}for(const ne of ee)this.glyphManager.prefetchRange(ne,0)}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);const $=this.stylesheet.terrain;$&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain($,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.C("data",{dataType:"style"}));const K=this.isRootStyle();m.imports?this._loadImports(m.imports,v).then(()=>{this._reloadImports(),this.fire(new i.C(K?"style.load":"style.import.load"))}).catch(ee=>{this.fire(new i.B(new Error("Failed to load imports",ee))),this.fire(new i.C(K?"style.load":"style.import.load"))}):(this._reloadImports(),this.fire(new i.C(K?"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 z=this._evaluateColorThemeData(D);this._loadColorTheme(z).then(()=>{E()}).catch($=>{i.w(`Couldn't load color theme from the stylesheet: ${$}`),E()})}else this._styleColorTheme.lut=null,E()}isRootStyle(){return this.importDepth===0}hasAppearances(){return this._hasAppearances||this.fragments.some(m=>m.style.hasAppearances())}mergeAll(){let m,v,E,D,z,$,K,ee,ne,de;const we={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(be=>{if(be.stylesheet){if(be.light!=null&&(m=be.light),be.stylesheet.lights)for(const Ae of be.stylesheet.lights)Ae.type==="ambient"&&be.ambientLight!=null&&(v=be.ambientLight),Ae.type==="directional"&&be.directionalLight!=null&&(E=be.directionalLight);D=this._prioritizeTerrain(D,be.terrain,be.stylesheet.terrain),be.stylesheet.fog&&be.fog!=null&&(z=be.fog),be.stylesheet.snow&&be.snow!=null&&($=be.snow),be.stylesheet.rain&&be.rain!=null&&(K=be.rain),be.stylesheet.camera!=null&&(de=be.stylesheet.camera),be.stylesheet.projection!=null&&(ee=be.stylesheet.projection),be.stylesheet.transition!=null&&(ne=be.stylesheet.transition),we[be.scope]=be._styleColorTheme}}),this.light=m,this.ambientLight=v,this.directionalLight=E,this.fog=z,this.snow=$,this.rain=K,this._styleColorThemeForScope=we,D===null?delete this.terrain:this.terrain=D,this.camera=de||{"camera-projection":"perspective"},this.projection=ee||{name:"mercator"},this.transition=Object.assign({},VE,ne),this.mergeSources(),this.mergeLayers(),this.mergeIndoor()}forEachFragmentStyle(m){const v=E=>{for(const D of E.fragments)v(D.style);m(E)};v(this)}_prioritizeTerrain(m,v,E){const D=m&&m.drapeRenderMode===0;return E===null?v&&v.drapeRenderMode===0?v:D?m:null:v!=null&&(!m||D||v&&v.drapeRenderMode===1)?v:m}mergeTerrain(){let m;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(v=>{m=this._prioritizeTerrain(m,v.terrain,v.stylesheet.terrain)}),m===null?delete this.terrain:this.terrain=m}mergeProjection(){let m;this.forEachFragmentStyle(v=>{v.stylesheet.projection!=null&&(m=v.stylesheet.projection)}),this.projection=m||{name:"mercator"}}mergeSources(){const m={},v={},E={},D={};this.forEachFragmentStyle(z=>{for(const $ in z._sourceCaches){const K=i.F($,z.scope);m[K]=z._sourceCaches[$]}for(const $ in z._otherSourceCaches){const K=i.F($,z.scope);v[K]=z._otherSourceCaches[$]}for(const $ in z._symbolSourceCaches){const K=i.F($,z.scope);E[K]=z._symbolSourceCaches[$]}for(const $ in z._fillExtrusionSourceCaches){const K=i.F($,z.scope);D[K]=z._fillExtrusionSourceCaches[$]}}),this._mergedSourceCaches=m,this._mergedOtherSourceCaches=v,this._mergedSymbolSourceCaches=E,this._mergedFillExtrusionSourceCaches=D}mergeIndoor(){this.forEachFragmentStyle(m=>{if(m.stylesheet&&m.stylesheet.indoor)for(const v of Object.values(m.stylesheet.indoor)){const E=v,D=i.F(E.sourceId,m.scope);this._mergedIndoor[D]=new Set(E.sourceLayers||[])}})}mergeLayers(){const m={},v=[],E={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle($=>{for(const K of $._order){const ee=$._layers[K];if(ee.type==="slot"){const ne=i.da(K);if(m[ne])continue;m[ne]=[]}ee.slot&&m[ee.slot]?m[ee.slot].push(ee):v.push(ee)}}),this._mergedOrder=[];let D=-1;const z=($=[])=>{for(const K of $)if(K.type==="slot"){const ee=i.da(K.id);m[ee]&&z(m[ee]),this._mergedSlots.push(ee)}else{const ee=i.F(K.id,K.scope);this._mergedOrder.push(ee),E[ee]=K,K.is3D(!!this.terrain)&&(this._has3DLayers=!0,D=this._mergedOrder.length-1),K.type==="circle"&&(this._hasCircleLayers=!0),K.type==="symbol"&&(this._hasSymbolLayers=!0),K.type==="clip"&&(this._clipLayerPresent=!0)}};if(z(v),this._has3DLayers){const $={};for(let K=0;K$[K]-$[ee])}this._mergedLayers=E,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged(),this._updateDataDrivenEmissiveStrength()}terrainSetForDrapingOnly(){return!!this.terrain&&this.terrain.drapeRenderMode===0}getCamera(){return this.stylesheet.camera}setCamera(m){return this.stylesheet.camera=Object.assign({},this.stylesheet.camera,m),this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(m){return m.data?function(v,E,D){const z=Object.assign({},E);for(const K of Object.keys($E))z[K]===void 0&&(z[K]=$E[K].default);const $=new i.aa(O1,v,new Map(D));return $.setTransitionOrValue(z,D),$.untransitioned().possiblyEvaluate(new i.ae(0,{worldview:void 0}))}(this.scope,m,this.options).get("data"):null}_loadColorTheme(m){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;const v=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((E,D)=>{const z="data:image/png;base64,";if(!m||m.length===0)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void E();let $=m;$.startsWith(z)||($=z+$);const K=i.I.from("mapbox-reserved-lut"),ee=new Image;ee.src=$,ee.onerror=()=>{this._styleColorTheme.lutLoading=!1,D(new Error("Failed to load image data"))},ee.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==v)return void E();this._styleColorTheme.lutLoading=!1;const{width:ne,height:de,data:we}=i.o.getImageData(ee);if(de>32)return void D(new Error("The height of the image must be less than or equal to 32 pixels."));if(ne!==de*de)return void D(new Error("The width of the image must be equal to the height squared."));this.getImage(K)&&this.removeImage(K),this.addImage(K,{data:new i.q({width:ne,height:de},we),pixelRatio:1,sdf:!1,usvg:!1,version:0});const be=this.imageManager.getImage(K,this.scope);be?(this._styleColorTheme.lut={image:be.data,data:m},E()):D(new Error("Missing LUT image."))}})}getLut(m){const v=this._styleColorThemeForScope[m];return v?v.lut:null}setProjection(m){m?this.stylesheet.projection=m: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(m){this._spriteRequest=function(v,E,D){let z,$,K;const ee=i.o.devicePixelRatio>1?"@2x":"";let ne=i.m(E.transformRequest(E.normalizeSpriteURL(v,ee,".json"),i.R.SpriteJSON),(be,Ae)=>{ne=null,K||(K=be,z=Ae,we())}),de=i.n(E.transformRequest(E.normalizeSpriteURL(v,ee,".png"),i.R.SpriteImage),(be,Ae)=>{de=null,K||(K=be,$=Ae,we())});function we(){if(K)D(K);else if(z&&$){const be=i.o.getImageData($),Ae={};for(const ze in z){const{width:Le,height:rt,x:st,y:dt,sdf:pt,pixelRatio:at,stretchX:Bt,stretchY:wt,content:Ft}=z[ze],ft=new i.q({width:Le,height:rt});i.q.copy(be,ft,{x:st,y:dt},{x:0,y:0},{width:Le,height:rt},null),Ae[ze]={data:ft,pixelRatio:at!==void 0?at:1,sdf:pt!==void 0&&pt,stretchX:Bt,stretchY:wt,content:Ft,usvg:!1,version:0}}D(null,Ae)}}return{cancel(){ne&&(ne.cancel(),ne=null),de&&(de.cancel(),de=null)}}}(m,this.map._requestManager,(v,E)=>{if(this._spriteRequest=null,v)this.fire(new i.B(v));else if(E){const D=new Map;for(const z in E)D.set(i.I.from(z),E[z]);this.addImages(D)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new i.C("data",{dataType:"style"}))})}addIconset(m,v){if(v.type==="sprite")return void this._loadSprite(v.url);const E=this.getOwnSourceCache(v.source);if(!E)return void this.fire(new i.B(new Error(`Source "${v.source}" as specified by iconset "${m}" does not exist and cannot be used as an iconset source`)));const D=E.getSource();if(D.type!=="raster-array")return void this.fire(new i.B(new Error(`Source "${v.source}" as specified by iconset "${m}" is not a "raster-array" source and cannot be used as an iconset source`)));D.partial=!1;const z=new qE(m,this.scope,E);this.imageManager.addImageProvider(z,this.scope)}removeIconset(m){this.imageManager.removeImageProvider(m,this.scope)}_loadIconset(m){if(!i.e(m)&&this.map._spriteFormat!=="icon_set"||this.map._spriteFormat==="raster")return void this._loadSprite(m);const v=this.map._spriteFormat==="auto";var E,D;this._spriteRequest=(D=(z,$)=>{if(this._spriteRequest=null,z)v?this._loadSprite(m):this.fire(new i.B(z));else if($){const K=new Map;for(const ee in $)K.set(i.I.from(ee),$[ee]);this.addImages(K)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new i.C("data",{dataType:"style"}))},i.b1((E=this.map._requestManager).transformRequest(E.normalizeIconsetURL(m),i.R.Iconset),(z,$)=>{if(z)return void D(z);const K={},ee=i.c$(new i.a$($));for(const ne of ee.icons){const de={version:1,pixelRatio:i.o.devicePixelRatio,content:RO(ne),stretchX:ne.metadata?Vw(ne.metadata.stretch_x_areas):void 0,stretchY:ne.metadata?Vw(ne.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:ne};K[ne.name]=de}D(null,K)}))}_validateLayer(m){const v=this.getOwnSource(m.source);if(!v)return;const E=m.sourceLayer;E&&(v.type==="geojson"||v.vectorLayerIds&&v.vectorLayerIds.indexOf(E)===-1)&&this.fire(new i.B(new Error(`Source layer "${E}" does not exist on source "${v.id}" as specified by style layer "${m.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(const m in this._sourceCaches)if(!this._sourceCaches[m].loaded())return!1;if(!this.imageManager.isLoaded()||this.imageManager.hasPatternsInFlight()||!this.modelManager.isLoaded()||this._styleColorTheme.lutLoading)return!1;for(const{style:m}of this.fragments)if(!m.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map((m,v)=>{const E=this.fragments[v];return E&&E.style&&(m.data=E.style.serialize()),m})}_serializeSources(){const m={};for(const v in this._sourceCaches){const E=this._sourceCaches[v].getSource();m[E.id]||(m[E.id]=E.serialize())}return m}_serializeLayers(m){const v=[];for(const E of m){const D=this._layers[E];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 m in this._sourceCaches)if(this._sourceCaches[m].hasTransition())return!0;for(const m in this._layers)if(this._layers[m].hasTransition())return!0;return!1}_updateDataDrivenEmissiveStrength(){for(const m in this._mergedLayers){const v=this._mergedLayers[m];if(v._transitionablePaint&&v._transitionablePaint._values){const E=v._transitionablePaint._values["line-emissive-strength"];if(E&&E.value&&E.value.isDataDriven())return void(this._hasDataDrivenEmissive=!0)}}this._hasDataDrivenEmissive=!1}hasDataDrivenEmissiveStrength(){return this._hasDataDrivenEmissive}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}_getOrder(m){return m?this.order:this._mergedOrder}isLayerDraped(m){return!!this.terrain&&m.isDraped(this.getLayerSourceCache(m))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(m){const v=this.getOwnLayer(m);if(v)return v;this.fire(new i.B(new Error(`The layer '${m}' does not exist in the map's style.`)))}_checkSource(m){const v=this.getOwnSource(m);if(v)return v;this.fire(new i.B(new Error(`The source '${m}' does not exist in the map's style.`)))}precompilePrograms(m,v){const E=this.map.painter;if(E)for(let D=m.minzoom||0;D<(m.maxzoom||25.5);D++){const z=m.getProgramIds();if(z)for(const $ of z){const K=m.getDefaultProgramParams($,v.zoom,this._styleColorTheme.lut);K&&(E.style=this,this.fog&&(E._fogVisible=!0,K.overrideFog=!0,E.getOrCreateProgram($,K)),E._fogVisible=!1,K.overrideFog=!1,E.getOrCreateProgram($,K),(this.stylesheet.terrain||this.stylesheet.projection&&this.stylesheet.projection.name==="globe")&&(K.overrideRtt=!0,E.getOrCreateProgram($,K)))}}}update(m){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(m),this.directionalLight&&this.directionalLight.recalculate(m);const v=this.calculateLightsBrightness();m.brightness=v||0,v!==this._brightness&&(this._brightness=v,this.dispatcher.broadcast("setBrightness",v)),m.worldview!==this._worldview&&(this._worldview=m.worldview,this.dispatcher.broadcast("setWorldview",this._worldview));const E=this._changes.isDirty();let D=!1;if(this._changes.isDirty()){const ee=this._changes.getLayerUpdatesByScope();for(const ne in ee){const{updatedIds:de,removedIds:we}=ee[ne];(de||we)&&(this._updateWorkerLayers(ne,de,we),D=!0)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(m),this.light&&this.light.updateTransitions(m),this.ambientLight&&this.ambientLight.updateTransitions(m),this.directionalLight&&this.directionalLight.updateTransitions(m),this.fog&&this.fog.updateTransitions(m),this.snow&&this.snow.updateTransitions(m),this.rain&&this.rain.updateTransitions(m),this._changes.reset()}const z={};for(const ee in this._mergedSourceCaches){const ne=this._mergedSourceCaches[ee];z[ee]=ne.used,ne.used=!1,ne.tileCoverLift=0}const $={};for(const ee of this._mergedOrder){const ne=this._mergedLayers[ee];if((ne.visibility!=="none"||ne.hasTransition())&&ne.recalculate(m,this._availableImages),!ne.isHidden(m.zoom)){const de=this.getLayerSourceCache(ne);de&&(de.used=!0,de.tileCoverLift=Math.max(de.tileCoverLift,ne.tileCoverLift()))}if(ne.type==="fill-extrusion"){const de=i.F(ne.source,ne.scope);if(de in this._mergedFillExtrusionSourceCaches){const we=ne.layout&&ne.layout.get("source-max-zoom");if(we!=null){const be=$[de];$[de]=be==null?we:Math.min(be,we)}}}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback(()=>{this.precompilePrograms(ne,m)}):this.precompilePrograms(ne,m))}this._shouldPrecompile&&(this._precompileDone=!0);for(const ee in this._mergedFillExtrusionSourceCaches)this._mergedFillExtrusionSourceCaches[ee].setMaxzoomOverride($[ee]!=null?$[ee]:null);this.terrain&&D&&this.mergeLayers();const K=this.imageManager.getPendingImageProviders();for(const ee of K)ee.sourceCache.used=!0;for(const ee in z){const ne=this._mergedSourceCaches[ee];z[ee]!==ne.used&&ne.getSource().fire(new i.C("data",{sourceDataType:"visibility",dataType:"source",sourceId:ne.getSource().id}))}this.light&&this.light.recalculate(m),this.terrain&&this.terrain.recalculate(m),this.fog&&this.fog.recalculate(m),this.snow&&this.snow.recalculate(m),this.rain&&this.rain.recalculate(m),this.z=m.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),this.imageManager.clearUpdatedImages(this.scope),E&&this.fire(new i.C("data",{dataType:"style"}))}updateImageProviders(){const m=this.imageManager.getPendingImageProviders();for(const v of m){const E=v.resolvePendingRequests(),D=this.getFragmentStyle(v.scope);D&&D.addImages(E)}}_updateTilesForChangedImages(){const m={};for(const v in this._mergedSourceCaches){const E=this._mergedSourceCaches[v].getSource().scope;m[E]=m[E]||this._changes.getUpdatedImages(E),m[E].length!==0&&this._mergedSourceCaches[v].reloadTilesForDependencies(["icons","patterns"],m[E])}for(const v in m)this._changes.resetUpdatedImages(v)}_updateWorkerLayers(m,v,E){const D=this.getFragmentStyle(m);D&&this.dispatcher.broadcast("updateLayers",{layers:v?D._serializeLayers(v):[],scope:m,removedIds:E||[],options:D.options})}setState(m,v){if(this._checkLoaded(),q0(this,Yt(m)))return!1;(m=i.d9(m)).layers=P1(m.layers);const E=function($,K){if(!$)return[{command:Sa.setStyle,args:[K]}];let ee=[];try{if(!i.b6($.version,K.version))return[{command:Sa.setStyle,args:[K]}];if(i.b6($.center,K.center)||ee.push({command:Sa.setCenter,args:[K.center]}),i.b6($.zoom,K.zoom)||ee.push({command:Sa.setZoom,args:[K.zoom]}),i.b6($.bearing,K.bearing)||ee.push({command:Sa.setBearing,args:[K.bearing]}),i.b6($.pitch,K.pitch)||ee.push({command:Sa.setPitch,args:[K.pitch]}),i.b6($.sprite,K.sprite)||ee.push({command:Sa.setSprite,args:[K.sprite]}),i.b6($.glyphs,K.glyphs)||ee.push({command:Sa.setGlyphs,args:[K.glyphs]}),i.b6($.imports,K.imports)||function(Ae=[],ze=[],Le){ze=ze||[];const rt=(Ae=Ae||[]).map(ty),st=ze.map(ty),dt=Ae.reduce(R0,{}),pt=ze.reduce(R0,{}),at=rt.slice();let Bt,wt,Ft,ft;for(Bt=0,wt=0;Bt{Ae.source&&ne[Ae.source]?ee.push({command:Sa.removeLayer,args:[Ae.id]}):we.push(Ae)});let be=$.terrain;be&&ne[be.source]&&(ee.push({command:Sa.setTerrain,args:[void 0]}),be=void 0),ee=ee.concat(de),i.b6(be,K.terrain)||ee.push({command:Sa.setTerrain,args:[K.terrain]}),function(Ae,ze,Le){ze=ze||[];const rt=(Ae=Ae||[]).map(ty),st=ze.map(ty),dt=Ae.reduce(R0,{}),pt=ze.reduce(R0,{}),at=rt.slice(),Bt=Object.create(null);let wt,Ft,ft,_t,Et,Kt,qt;for(wt=0,Ft=0;wt!($.command in OO));if(E.length===0)return!1;const D=E.filter($=>!($.command in dpe));if(D.length>0)throw new Error(`Unimplemented: ${D.map($=>$.command).join(", ")}.`);const z=[];return E.forEach($=>{z.push(this[$.command](...$.args))}),v&&Promise.all(z).then(v).catch(v),this.stylesheet=m,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(m){if(m.size===0)return this;for(const[v,E]of m.entries()){if(this.getImage(v))return this.fire(new i.B(new Error(`An image with the name "${v.name}" already exists.`)));this.imageManager.addImage(v,this.scope,E),this._changes.updateImage(v,this.scope)}return this._updateWorkerImages(),this.fire(new i.C("data",{dataType:"style"})),this}addImage(m,v){return this.getImage(m)?this.fire(new i.B(new Error(`An image with the name "${m.name}" already exists.`))):(this.imageManager.addImage(m,this.scope,v),this._changes.updateImage(m,this.scope),this._updateWorkerImages(),this.fire(new i.C("data",{dataType:"style"})),this)}updateImage(m,v,E=!1){this.imageManager.updateImage(m,this.scope,v),E&&(this._changes.updateImage(m,this.scope),this._updateWorkerImages(),this.fire(new i.C("data",{dataType:"style"})))}getImage(m){return this.imageManager.getImage(m,this.scope)}removeImage(m){return this.getImage(m)?(this.imageManager.removeImage(m,this.scope),this._changes.updateImage(m,this.scope),this._updateWorkerImages(),this.fire(new i.C("data",{dataType:"style"})),this):this.fire(new i.B(new Error("No image with this name exists.")))}listImages(){return this._checkLoaded(),this._availableImages.slice()}getActualScope(){return this._importedAsBasemap?"basemap":this.scope}addModelURLs(m){return this.modelManager.addModelURLs(m,this.getActualScope()),this._updateWorkerModels(),this.fire(new i.C("data",{dataType:"style"})),this}addModel(m,v,E={}){return this._checkLoaded(),this._validate(Is,`models.${m}`,v,null,E)||(this.modelManager.addModel(m,v,this.getActualScope()),this.fire(new i.C("data",{dataType:"style"}))),this}hasModel(m){return this.modelManager.hasModel(m,this.getActualScope())}removeModel(m){return this.hasModel(m)?(this.modelManager.removeModel(m,this.getActualScope(),!1,!0),this.fire(new i.C("data",{dataType:"style"})),this):this.fire(new i.B(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.getActualScope())}addSource(m,v,E={}){if(this._checkLoaded(),this.getOwnSource(m)!==void 0)throw new Error(`There is already a source with ID "${m}".`);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(Lr,`sources.${m}`,v,null,E))return;this.map&&this.map._collectResourceTiming&&(v.collectResourceTiming=!0);const D=Sp(m,v,this.dispatcher,this);D.scope=this.scope,D.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(D.id),source:D.serialize(),sourceId:D.id}));const z=$=>{const K=($===i.b4.Symbol?"symbol:":$===i.b4.FillExtrusion?"fill-extrusion:":"other:")+D.id,ee=i.F(K,this.scope),ne=this._sourceCaches[K]=new yh(ee,D,$);$===i.b4.Symbol?this._symbolSourceCaches[D.id]=ne:$===i.b4.FillExtrusion?this._fillExtrusionSourceCaches[D.id]=ne:this._otherSourceCaches[D.id]=ne,ne.onAdd(this.map)};z(i.b4.Other),v.type!=="vector"&&v.type!=="geojson"||(z(i.b4.Symbol),v.type==="vector"&&z(i.b4.FillExtrusion)),D.onAdd&&D.onAdd(this.map),E.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(m){this._checkLoaded();const v=this.getOwnSource(m);if(!v)throw new Error("There is no source with this ID");for(const D in this._layers)if(this._layers[D].source===m)return this.fire(new i.B(new Error(`Source "${m}" cannot be removed while layer "${D}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===m)return this.fire(new i.B(new Error(`Source "${m}" cannot be removed while terrain is using it.`)));if(this.stylesheet.iconsets){const D=Object.entries(this.stylesheet.iconsets).find(([z,$])=>$.type==="source"&&$.source===m);if(D)return this.fire(new i.B(new Error(`Source "${m}" cannot be removed while iconset "${D[0]}" is using it.`)))}const E=this.getOwnSourceCaches(m);for(const D of E){const z=i.da(D.id);delete this._sourceCaches[z],this._changes.discardSourceCacheUpdate(D.id),D.fire(new i.C("data",{sourceDataType:"metadata",dataType:"source",sourceId:D.getSource().id})),D.setEventedParent(null),D.clearTiles()}return delete this._otherSourceCaches[m],delete this._symbolSourceCaches[m],delete this._fillExtrusionSourceCaches[m],this.mergeSources(),v.setEventedParent(null),v.onRemove&&v.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(m,v){this._checkLoaded(),this.getOwnSource(m).setData(v),this._changes.setDirty()}getOwnSource(m){const v=this.getOwnSourceCache(m);return v&&v.getSource()}getOwnSources(){const m=[];for(const v in this._otherSourceCaches){const E=this.getOwnSourceCache(v);E&&m.push(E.getSource())}return m}areTilesLoaded(){const m=this._mergedSourceCaches;for(const v in m){const E=m[v]._tiles;for(const D in E){const z=E[D];if(z.state!=="loaded"&&z.state!=="errored")return!1}}return!0}setLights(m){if(this._checkLoaded(),!m)return delete this.ambientLight,void delete this.directionalLight;const v=this._getTransitionParameters();for(const z of m){if(this._validate(Se,"lights",z))return;switch(z.type){case"ambient":if(this.ambientLight){const $=this.ambientLight;$.set(z),$.updateTransitions(v)}else this.ambientLight=new sl(z,ac(),this.scope,this.options);break;case"directional":if(this.directionalLight){const $=this.directionalLight;$.set(z),$.updateTransitions(v)}else this.directionalLight=new sl(z,bu(),this.scope,this.options)}}const E=Object.assign(v,{worldview:this.map.getWorldview()}),D=new i.ae(this.z||0,E);this.ambientLight&&this.ambientLight.recalculate(D),this.directionalLight&&this.directionalLight.recalculate(D),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const m=this.directionalLight,v=this.ambientLight;if(!m||!v)return;const E=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=m.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),z=m.properties.get("intensity"),$=m.properties.get("direction"),K=1-i.cP($.x,$.y,$.z)[2]/90,ee=E(D)*z*K,ne=v.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),de=v.properties.get("intensity"),we=E(ne)*de;return Number(((ee+we)/2).toFixed(6))}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const m=[];return this.directionalLight&&m.push(this.directionalLight.get()),this.ambientLight&&m.push(this.ambientLight.get()),m}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(m){if(m==null||m===""&&this.isRootStyle())return this;if(i.db(m)){const v=i.dc(m),E=this.fragments.find(({id:z})=>z===v);if(!E)return;const D=i.da(m);return E.style.getFragmentStyle(D)}{const v=this.fragments.find(({id:E})=>E===m);return v?v.style:void 0}}setFeaturesetSelectors(m){if(!m)return;const v=(E,D="")=>`${E}::${D}`;this._featuresetSelectors={};for(const E in m){const D={},z=this._featuresetSelectors[E]=[];for(const $ of m[E].selectors){if($.featureNamespace){const ee=this.getOwnLayer($.layer);if(!ee){i.w(`Layer is undefined for selector: ${$.layer}`);continue}const ne=v(ee.source,ee.sourceLayer);if(ne in D&&D[ne]!==$.featureNamespace){i.w(`"featureNamespace ${$.featureNamespace} of featureset ${E}'s selector is not associated to the same source, skip this selector`);continue}D[ne]=$.featureNamespace}let K;if($.properties)for(const ee in $.properties){const ne=i.X($.properties[ee]);ne.result==="success"&&(K=K||{},K[ee]=ne.value)}z.push({layerId:$.layer,namespace:$.featureNamespace,properties:K,uniqueFeatureID:$._uniqueFeatureID})}}}getFeaturesetDescriptors(m){const v=this.getFragmentStyle(m);if(!v||!v.stylesheet.featuresets)return[];const E=[];for(const D in v.stylesheet.featuresets)E.push({featuresetId:D,importId:v.scope?v.scope:void 0});return E}getFeaturesetLayers(m,v){const E=this.getFragmentStyle(v),D=E.stylesheet.featuresets;if(!D||!D[m])return this.fire(new i.B(new Error(`The featureset '${m}' does not exist in the map's style and cannot be queried.`))),[];const z=[];for(const $ of D[m].selectors){const K=E.getOwnLayer($.layer);K&&z.push(K)}return z}getConfigProperty(m,v){const E=this.getFragmentStyle(m);if(!E)return null;const D=i.F(v,E.scope),z=E.options.get(D),$=z?z.value||z.default:null;return $?$.serialize():null}isIndoorEnabled(){return Object.keys(this._mergedIndoor).length>0}getIndoorSourceLayers(m,v){const E=i.F(m,v);return this._mergedIndoor[E]}setIndoorData(m,v){this.indoorManager.setIndoorData(v)}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(m,v,E){const D=this.getFragmentStyle(m);if(!D)return;const z=D.stylesheet.schema;if(!z||!z[v])return;const $=i.X(E);if($.result!=="success")return void q0(this,$.value);const K=$.value.expression,ee=i.F(v,D.scope),ne=D.options.get(ee);if(!ne)return;let de;const{minValue:we,maxValue:be,stepValue:Ae,type:ze,values:Le}=z[v],rt=i.X(z[v].default);rt.result==="success"&&(de=rt.value.expression),de?(this.options.set(ee,Object.assign({},ne,{value:K,default:de,minValue:we,maxValue:be,stepValue:Ae,type:ze,values:Le})),this.updateConfigDependencies(v)):this.fire(new i.B(new Error(`No schema defined for the config option "${v}" in the "${m}" fragment.`)))}getConfig(m){const v=this.getFragmentStyle(m);if(!v)return null;const E=v.stylesheet.schema;if(!E)return null;const D={};for(const z in E){const $=i.F(z,v.scope),K=v.options.get($),ee=K?K.value||K.default:null;D[z]=ee?ee.serialize():null}return D}setConfig(m,v){const E=this.getFragmentStyle(m);E&&(E.updateConfig(v,E.stylesheet.schema),this.updateConfigDependencies())}getSchema(m){const v=this.getFragmentStyle(m);return v?v.stylesheet.schema:null}setSchema(m,v){const E=this.getFragmentStyle(m);E&&(E.stylesheet.schema=v,E.updateConfig(E._config,v),this.updateConfigDependencies())}updateConfig(m,v){if(this._config=m,m||v)if(v)for(const E in v){let D,z;const $=i.X(v[E].default);if($.result==="success"&&(D=$.value.expression),m&&m[E]!==void 0){const be=i.X(m[E]);be.result==="success"&&(z=be.value.expression)}const{minValue:K,maxValue:ee,stepValue:ne,type:de,values:we}=v[E];if(D){const be=i.F(E,this.scope);this.options.set(be,{default:D,value:z,minValue:K,maxValue:ee,stepValue:ne,type:de,values:we})}else this.fire(new i.B(new Error(`No schema defined for config option "${E}".`)))}else this.fire(new i.B(new Error("Attempting to set config for a style without schema.")))}_updateLayers(m,v=()=>!0){for(const E of m){const D=this.getLayer(E);D&&v(D)&&(D.possiblyEvaluateVisibility(),this._updateLayer(D),this._changes.setDirty())}}updateConfigDependencies(m){this._updateLayers(this._configDependentLayers,v=>!m||v.expressionDependencies.configDependencies.has(m)),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 E=v._styleColorTheme.colorThemeOverride?v._styleColorTheme.colorThemeOverride:v._styleColorTheme.colorTheme;if(E){const D=v._evaluateColorThemeData(E);(!v._styleColorTheme.lut&&D!==""||v._styleColorTheme.lut&&D!==v._styleColorTheme.lut.data)&&v.setColorTheme(E)}}),this._changes.setDirty()}addLayer(m,v,E={}){this._checkLoaded();const D=m.id;if(this._layers[D])return void this.fire(new i.B(new Error(`Layer with id "${D}" already exists on this map`)));let z;if(m.type==="custom"){if(q0(this,i.dd(m)))return;z=i.de(m,this.scope,this._styleColorTheme.lut,this.options)}else{if(typeof m.source=="object"&&(this.addSource(D,m.source),m=i.d9(m),m=Object.assign(m,{source:D})),this._validate(At,`layers.${D}`,m,{arrayIndex:-1},E))return;z=i.de(m,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(z),z.setEventedParent(this,{layer:{id:D}})}const $=i.F(z.source,z.scope);z.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add($),z.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add($);let K=this._order.length;if(v){const we=this._order.indexOf(v);if(we===-1)return void this.fire(new i.B(new Error(`Layer with id "${v}" does not exist on this map.`)));z.slot&&z.slot!==this._layers[v].slot?i.w(`Layer with id "${v}" has a different slot. Layers can only be rearranged within the same slot.`):K=we}this._order.splice(K,0,D),this._handleLayerOrderChange(),this._layers[D]=z;const ee=this.getOwnLayerSourceCache(z),ne=!!this.directionalLight&&this.directionalLight.shadowsEnabled();ee&&z.canCastShadows()&&ne&&(ee.castsShadows=!0);const de=this._changes.getRemovedLayer(z);if(de&&z.source&&ee&&z.type!=="custom"){this._changes.discardLayerRemoval(z);const we=i.F(z.source,z.scope);de.type!==z.type?this._changes.updateSourceCache(we,"clear"):(this._changes.updateSourceCache(we,"reload"),ee.pause())}this._updateLayer(z),z.onAdd&&z.onAdd(this.map),z.scope=this.scope,this.mergeLayers()}moveLayer(m,v){this._checkLoaded();const E=this._checkLayer(m);if(!E||m===v)return;const D=this._order.indexOf(m);this._order.splice(D,1);let z=this._order.length;if(v){const $=this._order.indexOf(v);if($===-1)return void this.fire(new i.B(new Error(`Layer with id "${v}" does not exist on this map.`)));E.slot&&E.slot!==this._layers[v].slot?i.w(`Layer with id "${v}" has a different slot. Layers can only be rearranged within the same slot.`):z=$}this._order.splice(z,0,m),this._changes.setDirty(),this._handleLayerOrderChange(),this.mergeLayers()}removeLayer(m){this._checkLoaded();const v=this._checkLayer(m);if(!v)return;v.setEventedParent(null);const E=this._order.indexOf(m);this._order.splice(E,1),delete this._layers[m],this._changes.setDirty(),this._handleLayerOrderChange(),this._configDependentLayers.delete(v.fqid),this._indoorDependentLayers.delete(v.fqid),this._changes.removeLayer(v);const D=this.getOwnLayerSourceCache(v);if(D&&D.castsShadows){let z=!1;for(const $ in this._layers)if(this._layers[$].source===v.source&&this._layers[$].canCastShadows()){z=!0;break}D.castsShadows=z}v.onRemove&&v.onRemove(this.map),this.mergeLayers()}getOwnLayer(m){return this._layers[m]}hasLayer(m){return m in this._mergedLayers}hasLayerType(m){for(const v in this._layers)if(this._layers[v].type===m)return!0;return!1}setLayerZoomRange(m,v,E){this._checkLoaded();const D=this._checkLayer(m);D&&(D.minzoom===v&&D.maxzoom===E||(v!=null&&(D.minzoom=v),E!=null&&(D.maxzoom=E),this._updateLayer(D)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(m,v){this._checkLoaded();const E=this._checkLayer(m);E&&E.slot!==v&&(E.slot=v,this._updateLayer(E))}setFilter(m,v,E={}){this._checkLoaded();const D=this._checkLayer(m);if(D&&!i.b6(D.filter,v))return v==null?(D.filter=void 0,void this._updateLayer(D)):void(this._validate(Gt,`layers.${D.id}.filter`,v,{layerType:D.type},E)||(D.filter=i.d9(v),this._updateLayer(D)))}getFilter(m){const v=this._checkLayer(m);if(v)return i.d9(v.filter)}setLayoutProperty(m,v,E,D={}){this._checkLoaded();const z=this._checkLayer(m);if(z&&!i.b6(z.getLayoutProperty(v),E)){if(E!=null&&(!D||D.validate!==!1)&&q0(z,Xt.call(Yt,{key:`layers.${m}.layout.${v}`,layerType:z.type,objectKey:v,value:E,styleSpec:i.a8,style:{glyphs:!0,sprite:!0}})))return;z.setLayoutProperty(v,E),z.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(z.fqid),z.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(z.fqid),this._updateLayer(z)}}setLayerProperty(m,v,E,D={}){this._checkLoaded();const z=this._checkLayer(m);z&&(v==="appearances"?(z.setAppearances(E),this._updateLayer(z)):z.isPaintProperty(v)?this.setPaintProperty(m,v,E,D):this.setLayoutProperty(m,v,E,D))}getLayoutProperty(m,v){const E=this._checkLayer(m);if(E)return E.getLayoutProperty(v)}setPaintProperty(m,v,E,D={}){this._checkLoaded();const z=this._checkLayer(m);if(!z||i.b6(z.getPaintProperty(v),E)||E!=null&&(!D||D.validate!==!1)&&q0(z,Vt.call(Yt,{key:`layers.${m}.paint.${v}`,layerType:z.type,objectKey:v,value:E,styleSpec:i.a8})))return;const $=z.setPaintProperty(v,E);z.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(z.fqid),z.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(z.fqid),$&&this._updateLayer(z),this._changes.updatePaintProperties(z)}getPaintProperty(m,v){const E=this._checkLayer(m);if(E)return E.getPaintProperty(v)}setFeatureState(m,v){if(this._checkLoaded(),"target"in m){if("featuresetId"in m.target){const{featuresetId:ee,importId:ne}=m.target,de=this.getFragmentStyle(ne),we=de.getFeaturesetLayers(ee);for(const{source:be,sourceLayer:Ae}of we)de.setFeatureState({id:m.id,source:be,sourceLayer:Ae},v)}else if("layerId"in m.target){const{layerId:ee}=m.target,ne=this.getLayer(ee);this.setFeatureState({id:m.id,source:ne.source,sourceLayer:ne.sourceLayer},v)}return}const E=m.source,D=m.sourceLayer,z=this._checkSource(E);if(!z)return;const $=z.type;if($==="geojson"&&D)return void this.fire(new i.B(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if($==="vector"&&!D)return void this.fire(new i.B(new Error("The sourceLayer parameter must be provided for vector source types.")));m.id===void 0&&this.fire(new i.B(new Error("The feature id parameter must be provided.")));const K=this.getOwnSourceCaches(E);for(const ee of K)ee.setFeatureState(D,m.id,v)}removeFeatureState(m,v){if(this._checkLoaded(),"target"in m){if("featuresetId"in m.target){const{featuresetId:ee,importId:ne}=m.target,de=this.getFragmentStyle(ne),we=de.getFeaturesetLayers(ee);for(const{source:be,sourceLayer:Ae}of we)de.removeFeatureState({id:m.id,source:be,sourceLayer:Ae},v)}else if("layerId"in m.target){const{layerId:ee}=m.target,ne=this.getLayer(ee);this.removeFeatureState({id:m.id,source:ne.source,sourceLayer:ne.sourceLayer},v)}return}const E=m.source,D=this._checkSource(E);if(!D)return;const z=D.type,$=z==="vector"?m.sourceLayer:void 0;if(z==="vector"&&!$)return void this.fire(new i.B(new Error("The sourceLayer parameter must be provided for vector source types.")));if(v&&typeof m.id!="string"&&typeof m.id!="number")return void this.fire(new i.B(new Error("A feature id is required to remove its specific state property.")));const K=this.getOwnSourceCaches(E);for(const ee of K)ee.removeFeatureState($,m.id,v)}getFeatureState(m){if(this._checkLoaded(),"target"in m){let z;if("featuresetId"in m.target){const{featuresetId:$,importId:K}=m.target,ee=this.getFragmentStyle(K),ne=ee.getFeaturesetLayers($);for(const{source:de,sourceLayer:we}of ne){const be=ee.getFeatureState({id:m.id,source:de,sourceLayer:we});if(be&&!z)z=be;else if(!i.b6(z,be))return void this.fire(new i.B(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 m.target){const{layerId:$}=m.target,K=this.getLayer($);z=this.getFeatureState({id:m.id,source:K.source,sourceLayer:K.sourceLayer})}return z}const v=m.source,E=m.sourceLayer,D=this._checkSource(v);if(D){if(D.type!=="vector"||E)return m.id===void 0&&this.fire(new i.B(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(v)[0].getFeatureState(E,m.id);this.fire(new i.B(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(m){return this.stylesheet.transition=Object.assign({},this.stylesheet.transition,m),this.transition=this.stylesheet.transition,this}getTransition(){return Object.assign({},this.stylesheet.transition)}setWorldview(m){m!==this._worldview&&(this._worldview=m,this.dispatcher.broadcast("setWorldview",this._worldview),this.reloadSources())}serialize(){this._checkLoaded();const m=this.getTerrain(),v=m&&this.terrain&&this.terrain.scope===this.scope?m:this.stylesheet.terrain;return i.df({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,iconsets:this.stylesheet.iconsets,featuresets:this.stylesheet.featuresets,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,indoor:this.stylesheet.indoor,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)},E=>E!==void 0)}_updateFilteredLayers(m){for(const v of Object.values(this._mergedLayers))m(v)&&this._updateLayer(v)}_updateLayer(m){this._changes.updateLayer(m);const v=this.getLayerSourceCache(m),E=i.F(m.source,m.scope),D=this._changes.getUpdatedSourceCaches();m.source&&!D[E]&&v&&v.getSource().type!=="raster"&&(this._changes.updateSourceCache(E,"reload"),v.pause()),m.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(m){const v=K=>this._mergedLayers[K].is3D(!!this.terrain),E=this.order,D={},z=[];for(let K=E.length-1;K>=0;K--){const ee=E[K];if(v(ee)){D[ee]=K;for(const ne of m){const de=ne[ee];if(de)for(const we of de)z.push(we)}}}z.sort((K,ee)=>ee.intersectionZ-K.intersectionZ);const $=[];for(let K=E.length-1;K>=0;K--){const ee=E[K];if(v(ee))for(let ne=z.length-1;ne>=0;ne--){const de=z[ne].feature;if(de.layer&&D[de.layer.id]{if(UE.has(de.type))return;const we=this.getOwnLayerSourceCache(de),be=z[we.id]=z[we.id]||{sourceCache:we,layers:{},has3DLayers:!1};de.is3D(!!this.terrain)&&(be.has3DLayers=!0),be.layers[de.fqid]=be.layers[de.fqid]||{styleLayer:de,targets:[]},be.layers[de.fqid].targets.push({filter:D})};if(v&&v.layers){if(!Array.isArray(v.layers))return this.fire(new i.B(new Error("parameters.layers must be an Array."))),[];for(const de of v.layers){const we=this._layers[de];if(!we)return this.fire(new i.B(new Error(`The layer '${de}' does not exist in the map's style and cannot be queried for features.`))),[];$(we)}}else for(const de in this._layers)$(this._layers[de]);const K=this._queryRenderedFeatures(m,z,E),ee=this._flattenAndSortRenderedFeatures(K),ne=[];for(const de of ee)i.dh(de.layer.id)===this.scope&&ne.push(de);return ne}queryRenderedFeatureset(m,v,E){let D;v&&!Array.isArray(v)&&v.filter&&(this._validate(Gt,"queryRenderedFeatures.filter",v.filter,null,v),D=i.dg(v.filter));const z="mock",$=[];if(v&&v.target)$.push(Object.assign({},v,{targetId:z,filter:D}));else{const de=this.getFeaturesetDescriptors();for(const we of de)$.push({targetId:z,filter:D,target:we});for(const{style:we}of this.fragments){const be=we.getFeaturesetDescriptors();for(const Ae of be)$.push({targetId:z,filter:D,target:Ae})}}const K=this.queryRenderedTargets(m,$,E),ee=[],ne=new Set;for(const de of K)for(const we of de.variants[z])Kh(we,de,ne)||ee.push(new i.di(de,we));return ee}queryRenderedTargets(m,v,E){const D={},z=(K,ee,ne,de)=>{const we=D[ee.id]=D[ee.id]||{sourceCache:ee,layers:{},has3DLayers:!1};if(we.layers[K.fqid]=we.layers[K.fqid]||{styleLayer:K,targets:[]},K.is3D(!!this.terrain)&&(we.has3DLayers=!0),!de)return ne.uniqueFeatureID=!1,void we.layers[K.fqid].targets.push(ne);we.layers[K.fqid].targets.push(Object.assign({},ne,{namespace:de.namespace,properties:de.properties,uniqueFeatureID:de.uniqueFeatureID}))};for(const K of v)if("featuresetId"in K.target){const{featuresetId:ee,importId:ne}=K.target,de=this.getFragmentStyle(ne);if(!de||!de._featuresetSelectors)continue;const we=de._featuresetSelectors[ee];if(!we){this.fire(new i.B(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 Ae=de.getOwnLayer(be.layerId);Ae&&!UE.has(Ae.type)&&z(Ae,de.getOwnLayerSourceCache(Ae),K,be)}}else if("layerId"in K.target){const{layerId:ee}=K.target,ne=this.getLayer(ee);if(!ne||UE.has(ne.type))continue;z(ne,this.getLayerSourceCache(ne),K)}const $=this._queryRenderedFeatures(m,D,E);return this._flattenAndSortRenderedFeatures($)}_queryRenderedFeatures(m,v,E){const D=[],z=!!this.map._showQueryGeometry,$=wu.createFromScreenPoints(m,E);for(const K in v){const ee=Cf($,v[K],this._availableImages,E,z,this.getActualScope());Object.keys(ee).length&&D.push(ee)}if(this.placement)for(const K in v){if(v[K].sourceCache._renderSourceType!==i.b4.Symbol)continue;const ee=zx($.screenGeometry,v[K],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(ee).length&&D.push(ee)}return D}querySourceFeatures(m,v){const E=v&&v.filter;E&&this._validate(Gt,"querySourceFeatures.filter",E,null,v);let D=[];const z=this.getOwnSourceCaches(m);for(const $ of z)D=D.concat(Md($,v));return D}addSourceType(m,v,E){return Vm.getSourceType(m)?E(new Error(`A source type called "${m}" already exists.`)):(Vm.setSourceType(m,v),v.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:m,url:v.workerSourceURL},E):E(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(m,v,E={}){this._checkLoaded();const D=this.light.getLight();let z=!1;for(const K in m)if(!i.b6(m[K],D[K])){z=!0;break}if(!z)return;const $=this._getTransitionParameters();this.light.setLight(m,v,E),this.light.updateTransitions($)}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(m,v=1){if(this._checkLoaded(),!m)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),v===0&&delete this.terrain,m===null?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let E=m;const D=!("source"in m)||m.source==null;if(v===1){if(this.disableElevatedTerrain)return;if("source"in E&&typeof E.source=="object"){const K="terrain-dem-src";this.addSource(K,E.source),E=i.d9(E),E=Object.assign(E,{source:K})}const z=Object.assign({},E),$={};if(this.terrain&&D){z.source=this.terrain.get().source;const K=this.terrain?this.getFragmentStyle(this.terrain.scope):null;K&&($.style=K.serialize())}if(this._validate(Fe,"terrain",z,$))return}if(!this.terrain||this.terrain.scope!==this.scope&&!D||this.terrain&&v!==this.terrain.drapeRenderMode){if(!E)return;this._createTerrain(E,v),this.fire(new i.C("data",{dataType:"style"}))}else{const z=this.terrain,$=z.get();for(const K of Object.keys(i.a8.terrain))!E.hasOwnProperty(K)&&i.a8.terrain[K].default&&(E[K]=i.a8.terrain[K].default);for(const K in m)if(!i.b6(m[K],$[K])){z.set(m,this.options),this.stylesheet.terrain=m;const ee=this._getTransitionParameters({duration:0});z.updateTransitions(ee),this.fire(new i.C("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(m){const v=this.fog=new $i(m,this.map.transform,this.scope,this.options);this.stylesheet.fog=v.get();const E=this._getTransitionParameters({duration:0});v.updateTransitions(E)}_createSnow(m){const v=this.snow=new Xi(m,this.map.transform,this.scope,this.options);this.stylesheet.snow=v.get();const E=this._getTransitionParameters({duration:0});v.updateTransitions(E)}_createRain(m){const v=this.rain=new ha(m,this.map.transform,this.scope,this.options);this.stylesheet.rain=v.get();const E=this._getTransitionParameters({duration:0});v.updateTransitions(E)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(const m of this.map._markers)m._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(m){if(this._checkLoaded(),!m)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const v=this.fog;if(!i.b6(v.get(),m)){v.set(m,this.options),this.stylesheet.fog=v.get();const E=this._getTransitionParameters({duration:0});v.updateTransitions(E)}}else this._createFog(m);this._markersNeedUpdate=!0}getSnow(){return this.snow?this.snow.get():null}setSnow(m){if(this._checkLoaded(),!m)return delete this.snow,void delete this.stylesheet.snow;if(this.snow){const v=this.snow;if(!i.b6(v.get(),m)){v.set(m,this.options),this.stylesheet.snow=v.get();const E=this._getTransitionParameters({duration:0});v.updateTransitions(E)}}else this._createSnow(m);this._markersNeedUpdate=!0}getRain(){return this.rain?this.rain.get():null}setRain(m){if(this._checkLoaded(),!m)return delete this.rain,void delete this.stylesheet.rain;if(this.rain){const v=this.rain;if(!i.b6(v.get(),m)){v.set(m,this.options),this.stylesheet.rain=v.get();const E=this._getTransitionParameters({duration:0});v.updateTransitions(E)}}else this._createRain(m);this._markersNeedUpdate=!0}_reloadColorTheme(){const m=()=>{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 m();const E=this._evaluateColorThemeData(v);this._loadColorTheme(E).then(()=>{this.fire(new i.C("colorthemeset")),m()}).catch(D=>{i.w(`Couldn't set color theme: ${D}`)})}setColorTheme(m){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=m,this._reloadColorTheme()}setImportColorTheme(m,v){const E=this.getFragmentStyle(m);E&&(E._styleColorTheme.colorThemeOverride=v,E._reloadColorTheme())}_getTransitionParameters(m){return{now:i.o.now(),transition:Object.assign(this.transition,m)}}updateDrapeFirstLayers(){if(!this.terrain)return;const m=[],v=[];for(const E of this._mergedOrder)this.isLayerDraped(this._mergedLayers[E])?m.push(E):v.push(E);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...m),this._drapedFirstOrder.push(...v)}_createTerrain(m,v){const E=this.terrain=new Wn(m,v,this.scope,this.options,this.map.getWorldview());v===1&&(this.stylesheet.terrain=m),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const D=this._getTransitionParameters({duration:0});E.updateTransitions(D)}_force3DLayerUpdate(){for(const m in this._layers){const v=this._layers[m];v.type==="fill-extrusion"&&this._updateLayer(v)}}_forceSymbolLayerUpdate(){for(const m in this._layers){const v=this._layers[m];v.type==="symbol"&&this._updateLayer(v)}}_validate(m,v,E,D,z={}){if(z&&z.validate===!1)return!1;const $=Object.assign({},this.serialize());return q0(this,m.call(Yt,Object.assign({key:v,style:$,value:E,styleSpec:i.a8},D)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),i.dj.off("pluginStateChange",this._rtlTextPluginCallback);for(const m in this._mergedLayers)this._mergedLayers[m].setEventedParent(null);for(const m in this._mergedSourceCaches)this._mergedSourceCaches[m].clearTiles(),this._mergedSourceCaches[m].setEventedParent(null);this.imageManager.removeScope(this.scope),this.imageManager.imageAtlasCache.clear(),this.setEventedParent(null),delete this.fog,delete this.snow,delete this.rain,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.indoorManager.destroy(),this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this.modelManager.setEventedParent(null),this.modelManager.destroy(),this.dispatcher.remove())}clearSource(m){const v=this.getSourceCaches(m);for(const E of v)E.clearTiles()}clearSources(){for(const m in this._mergedSourceCaches)this._mergedSourceCaches[m].clearTiles()}clearLayers(){for(const m in this._mergedLayers){const v=this._mergedLayers[m];v._clear&&v._clear()}}reloadSource(m){const v=this.getSourceCaches(m);for(const E of v)E.resume(),E.reload()}reloadSources(){for(const m of this.getSources())m.reload&&m.reload()}reloadModels(){this.modelManager.reloadModels(""),this.forEachFragmentStyle(m=>{m.modelManager.reloadModels(m.scope)})}updateSources(m){let v;this.directionalLight&&(v=DO(this.directionalLight));const E=new Set,D=new Set,z=new Set;for(const $ in this._mergedLayers){const K=this._mergedLayers[$];K.type==="building"?E.add(K.source):K.type==="raster"&&K.paint&&K.paint.get("raster-elevation-reference")==="ground"&&z.add(K.source),K.hasElevation()&&!D.has(K.source)&&D.add(K.source)}for(const $ in this._mergedSourceCaches){const K=this._mergedSourceCaches[$],ee=D.has(K._source.id);K._isRasterElevatedOverTerrain=z.has(K._source.id),E.has(K._source.id)&&(K._source.reparseOverscaled=!1),K.update(m,void 0,void 0,v,ee)}}_generateCollisionBoxes(){for(const m in this._sourceCaches){const v=this._sourceCaches[m];v.resume(),v.reload()}}_handleLayerOrderChange(){this._requestFullLabelPlacement(),this.fire(new i.C("neworder"))}_requestFullLabelPlacement(){this.pauseablePlacement||(this.pauseablePlacement=new Ow),this.pauseablePlacement.requestFullPlacement()}_setLabelPlacementStale(){this.placement&&this.placement.setStale()}_updatePlacement(m,v,E,D,z){this.pauseablePlacement||(this.pauseablePlacement=new Ow);let $=!1,K=!1;const ee={},ne={};for(const Le of this._mergedOrder){const rt=this._mergedLayers[Le];if(rt.type!=="symbol")continue;const st=i.F(rt.source,rt.scope);let dt=ee[st];if(!dt){const at=this.getLayerSourceCache(rt);if(!at)continue;const Bt=at.getRenderableIds(!0).map(wt=>at.getTileByID(wt));ne[st]=Bt.slice(),dt=ee[st]=Bt.sort((wt,Ft)=>Ft.tileID.overscaledZ-wt.tileID.overscaledZ||(wt.tileID.isLessThan(Ft.tileID)?-1:1))}const pt=this.crossTileSymbolIndex.addLayer(rt,dt,m.center.lng,m.projection);$=$||pt}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder);const de=!!(this.placement&&!m.equals(this.placement.transform)),we=!!(this.placement&&(this.placement.lastReplacementSourceUpdateTime!==0&&!z||this.placement.lastReplacementSourceUpdateTime!==z.updateTime)),be=de||we||$,Ae=(be||this.pauseablePlacement.isStale())&&E===0,ze=this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.o.now(),m.zoom)&&E!==0;if((this.pauseablePlacement.isFullPlacementRequested()||!this.pauseablePlacement.placement||Ae||ze)&&(this.pauseablePlacement=this.pauseablePlacement.startNewPlacement(m,this._mergedOrder,v,E,D,this.placement,this.fog&&m.projection.supportsFog?this.fog.state:null,this._buildingIndex),this.map.painter)){const Le=this.map.painter.maxFrontCutoffRawStart;if(Le>0){const rt=180*m.pitch/Math.PI;if(rt>=15){const st=Math.min(1,Math.max(0,(rt-15)/5)),dt=st*st*(3-2*st);this.pauseablePlacement.placement.frontCutoffStart=-.5*(1-dt)+Le*dt}}}if(this.pauseablePlacement.isDone()?be&&E!==0&&this.pauseablePlacement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,ee,ne,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.o.now()),K=!0),$&&this.pauseablePlacement.setStale()),K||$){this._buildingIndex.onNewFrame(m.zoom);for(let Le=0;Lez===m.id)!==-1)return void this.fire(new i.B(new Error(`Import with id '${m.id}' already exists in the map's style.`)));if(!v)return E.push(m),this._loadImports([m],!0);const D=E.findIndex(({id:z})=>z===v);return D===-1&&this.fire(new i.B(new Error(`Import with id "${v}" does not exist on this map.`))),this.stylesheet.imports=E.slice(0,D).concat(m).concat(E.slice(D)),this._loadImports([m],!0,v)}updateImport(m,v){this._checkLoaded();const E=this.stylesheet.imports||[],D=this.getImportIndex(m);return D===-1?this:typeof v=="string"?(this.setImportUrl(m,v),this):(v.url&&v.url!==E[D].url&&this.setImportUrl(m,v.url),i.b6(v.config,E[D].config)||this.setImportConfig(m,v.config,v.data.schema),i.b6(v.data,E[D].data)||this.setImportData(m,v.data),this)}moveImport(m,v){this._checkLoaded();let E=this.stylesheet.imports||[];const D=this.getImportIndex(m);if(D===-1)return this;const z=this.getImportIndex(v);if(z===-1)return this;const $=E[D],K=this.fragments[D];return E=E.filter(({id:ee})=>ee!==m),this.fragments=this.fragments.filter(({id:ee})=>ee!==m),this.stylesheet.imports=E.slice(0,z).concat($).concat(E.slice(z)),this.fragments=this.fragments.slice(0,z).concat(K).concat(this.fragments.slice(z)),this.mergeLayers(),this}setImportUrl(m,v){this._checkLoaded();const E=this.stylesheet.imports||[],D=this.getImportIndex(m);if(D===-1)return this;E[D].url=v;const z=this.fragments[D];return z.style=this._createFragmentStyle(E[D]),z.style.on("style.import.load",()=>this.mergeAll()),z.style.loadURL(v),this}setImportData(m,v){this._checkLoaded();const E=this.getImportIndex(m),D=this.stylesheet.imports||[];return E===-1?this:v?(this.fragments[E].style.setState(v),this._reloadImports(),this):(delete D[E].data,this.setImportUrl(m,D[E].url))}setImportConfig(m,v,E){this._checkLoaded();const D=this.getImportIndex(m),z=this.stylesheet.imports||[];if(D===-1)return this;v?z[D].config=v:delete z[D].config;const $=this.fragments[D];E&&$.style.stylesheet&&($.style.stylesheet.schema=E);const K=$.style.stylesheet&&$.style.stylesheet.schema;return $.config=v,$.style.updateConfig(v,K),this.updateConfigDependencies(),this}removeImport(m){this._checkLoaded();const v=this.stylesheet.imports||[],E=this.getImportIndex(m);E!==-1&&(v.splice(E,1),this.fragments[E].style._remove(),this.fragments.splice(E,1),this._reloadImports())}getImportIndex(m){const v=(this.stylesheet.imports||[]).findIndex(E=>E.id===m);return v===-1&&this.fire(new i.B(new Error(`Import '${m}' does not exist in the map's style and cannot be updated.`))),v}getLayer(m){return this._mergedLayers[m]}getSources(){const m=[];for(const v in this._mergedOtherSourceCaches){const E=this._mergedOtherSourceCaches[v];E&&m.push(E.getSource())}return m}getSource(m,v){const E=this.getSourceCache(m,v);return E&&E.getSource()}getLayerSource(m){const v=this.getLayerSourceCache(m);return v&&v.getSource()}getSourceCache(m,v){const E=i.F(m,v);return this._mergedOtherSourceCaches[E]}getLayerSourceCache(m){const v=i.F(m.source,m.scope);return m.type==="symbol"?this._mergedSymbolSourceCaches[v]:m.type==="fill-extrusion"&&this._mergedFillExtrusionSourceCaches[v]||this._mergedOtherSourceCaches[v]}getSourceCaches(m){if(m==null)return Object.values(this._mergedSourceCaches);const v=[];return this._mergedOtherSourceCaches[m]&&v.push(this._mergedOtherSourceCaches[m]),this._mergedSymbolSourceCaches[m]&&v.push(this._mergedSymbolSourceCaches[m]),this._mergedFillExtrusionSourceCaches[m]&&v.push(this._mergedFillExtrusionSourceCaches[m]),v}updateSourceCaches(){const m=this._changes.getUpdatedSourceCaches();for(const v in m){const E=m[v];E==="reload"?this.reloadSource(v):E==="clear"&&this.clearSource(v)}}updateLayers(m){const v=this._changes.getUpdatedPaintProperties();for(const E of v){const D=this.getLayer(E);D&&D.updateTransitions(m)}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(m){this.stylesheet.glyphs=m,this.glyphManager.setURL(m)}getImages(m,v,E){this.imageManager.getImages(v.images,v.scope,E),this._updateTilesForChangedImages();const D=$=>{if($){const K=v.images.map(ee=>i.I.toString(ee));$.setDependencies(v.tileID.key,v.type,K)}},z=i.F(v.source,v.scope);D(this._mergedOtherSourceCaches[z]),D(this._mergedSymbolSourceCaches[z]),v.images.some($=>$.iconsetId)&&this.fire(new i.C("data",{dataType:"style"}))}rasterizeImages(m,v,E){this.imageManager.rasterizeImages(v,E)}checkAtlasCache(m,v,E){const D=this.imageManager.imageAtlasCache.findCachedAtlas(v.descriptor);E(null,D&&D.contentDescriptor?{iconPositions:D.iconPositions,patternPositions:D.patternPositions,sourceHash:D.contentDescriptor.hash}:null)}getGlyphs(m,v,E){this.glyphManager.getGlyphs(v.stacks,E)}getOwnSourceCache(m){return this._otherSourceCaches[m]}getOwnLayerSourceCache(m){return m.type==="symbol"?this._symbolSourceCaches[m.source]:m.type==="fill-extrusion"&&this._fillExtrusionSourceCaches[m.source]||this._otherSourceCaches[m.source]}getOwnSourceCaches(m){const v=[];return this._otherSourceCaches[m]&&v.push(this._otherSourceCaches[m]),this._symbolSourceCaches[m]&&v.push(this._symbolSourceCaches[m]),this._fillExtrusionSourceCaches[m]&&v.push(this._fillExtrusionSourceCaches[m]),v}_isSourceCacheLoaded(m){const v=this.getOwnSourceCaches(m);return v.length===0?(this.fire(new i.B(new Error(`There is no source with ID '${m}'`))),!1):v.every(E=>E.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(m,v){if(!this._clipLayerPresent&&m.type!=="fill-extrusion"&&m.type!=="building")return!1;const E=m.type==="fill-extrusion"&&(m.sourceLayer==="building"||m.sourceLayer==="procedural_buildings"),D=m.type==="building";if(m.is3D(!!this.terrain)){if(E||D||v&&v.type==="batched-model"||m.type==="model")return!0}else if(m.type==="symbol")return!0;return!1}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}getBOMObject(){}destroy(){this._clearWorkerCaches(),this.imageManager.imageAtlasCache.clear(),this.fragments.forEach(m=>{m.style._remove()}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}Vm.getSourceType=function(M){return kp[M]},Vm.setSourceType=function(M,m){kp[M]=m},Vm.registerForPluginStateChange=i.dk;var HE=` #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`,GE=` #ifdef DUAL_SOURCE_BLENDING layout(location=0,index=0) out vec4 glFragColor;layout(location=0,index=1) out vec4 glFragColorSrc1; #elif defined(FLOAT_RENDER_TARGET) layout(location=0) out highp vec4 glFragColor; #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 const float DITHER_THRESHOLDS[16]=float[16]( 1.0/17.0, 9.0/17.0, 3.0/17.0,11.0/17.0,13.0/17.0, 5.0/17.0,15.0/17.0, 7.0/17.0,4.0/17.0,12.0/17.0, 2.0/17.0,10.0/17.0,16.0/17.0, 8.0/17.0,14.0/17.0, 6.0/17.0 );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 }float cutoutGroundRoofOpacity(vec4 groundRoof) { #ifdef INDICATOR_CUTOUT float fadeStartX=u_indicator_cutout_params.w;float holeRadius=u_indicator_cutout_params.y;float holeMinOpacity=mix(u_indicator_cutout_params.x,1.0,smoothstep(u_indicator_cutout_params.z,u_indicator_cutout_centers.z,groundRoof.y));float distX=abs(u_indicator_cutout_centers.x-groundRoof.x);float roofOpacity=mix(holeMinOpacity,1.0,smoothstep(fadeStartX,holeRadius,u_indicator_cutout_centers.y-groundRoof.w));float groundOpacity=min(smoothstep(fadeStartX,holeRadius,distX)+holeMinOpacity,1.0);return max(roofOpacity,groundOpacity); #else return 1.0; #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;}`,ay=` #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);}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(ivec2 posWithComposedSkirt) {float skirt=float(float(posWithComposedSkirt.x) >=skirtOffset);vec2 pos=vec2(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`,Hw="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;}",WE=` #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`,KE=`#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`,F1=`#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`,z1=`#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`,ZE=`#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;}`,HC=`#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`,Xh=`#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 Gw=/#include\s+"([^"]+)"/g,sr=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,FO=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,zO=new Set(["ifdef","ifndef","elif","if","defined"]),U0=new Set;Vx(HE,U0),Vx(ay,U0),Vx(GE,U0);const Ep={"_prelude_fog.vertex.glsl":KE,"_prelude_terrain.vertex.glsl":WE,"_prelude_shadow.vertex.glsl":HC,"_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":F1,"_prelude_shadow.fragment.glsl":Xh,"_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":z1,"_prelude_raster_particle.glsl":ZE},B1={};va("",WE),va(F1,KE),va(Xh,HC),va(z1,""),va(ZE,"");const iy=va(GE,ay),Ww=HE,$1=[` #if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING) #extension GL_EXT_blend_func_extended : require #endif`,"precision mediump float;",Ww,iy.fragmentSource].join(` `),upe=["precision highp float;",Ww,iy.vertexSource].join(` `);var BO={background:va(`#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 FEATURE_CUTOUT vec2 uv=gl_FragCoord.xy*u_inv_viewport_size.xy; #ifdef FLIP_Y uv.y=1.0-uv.y; #endif float factorTex=min(texture(u_cutout_factor_image,uv).r,1.0);float cutoutFactor=(1.0-u_feature_cutout_params.x)*factorTex;out_color=u_color*(1.0-cutoutFactor); #else #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 #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 ivec2 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); #ifndef FEATURE_CUTOUT #ifdef LIGHTING_3D_MODE v_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength); #endif #ifdef FOG v_fog_pos=fog_position(vec2(a_pos)); #endif #endif }`),backgroundPattern:va(`#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 ivec2 a_pos;out highp vec2 v_pos;void main() {vec2 pos=vec2(a_pos);gl_Position=u_matrix*vec4(pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_pattern_units_to_pixels,pos); #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),building:va(`#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 RENDER_FRONT_CUTOFF in float v_front_cutoff_opacity; #endif #ifdef INDICATOR_CUTOUT #ifdef FEATURE_CUTOUT in vec4 v_ground_roof; #endif #endif #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 highp float hash12(in highp vec2 p) {highp 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);}highp vec2 get_uv_mask_id(in highp vec2 q,out highp float mask,out highp vec2 id) {highp 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;highp vec2 uv=modf(p/v_faux_facade_floor,id);highp vec4 d=(v_faux_facade_floor.xyxy+vec4(-v_faux_facade_window,v_faux_facade_window))*0.5;highp vec4 edge=d/v_faux_facade_floor.xyxy;highp 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;}highp float ray_unit_box(in highp vec3 ray_o,in highp vec3 ray_d,in highp vec3 bmin,in highp vec3 bmax) {highp vec3 planes=mix(bmin,bmax,step(0.0,ray_d));highp 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 highp vec3 v,in highp vec3 v_normalized,in vec3 color,in vec2 id,in mat3 tbn,inout vec3 out_normal,inout float out_emissive) {vec3 out_color=color;highp 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) {highp mat3 tbn=mat3(v_tbn_0,v_tbn_1,v_tbn_2);highp vec3 v=vec3(v_pos.xy,v_pos.z/u_tile_to_meter)-u_camera_pos;highp vec3 view_tangent=transpose(tbn)*v;highp vec2 q=vec2(v_faux_facade_ed,v_pos.z);float mask=0.0;vec2 id=vec2(0.0);highp vec2 uv=get_uv_mask_id(q,mask,id);uv*=v_faux_facade_window;highp vec3 bmin=vec3(0.0,0.0,-window_depth);highp vec3 bmax=bmin+vec3(v_faux_facade_window,window_depth);highp vec3 ray_o=vec3(uv,0.0);highp vec3 ray_d=normalize(view_tangent);highp float t_min=ray_unit_box(ray_o,ray_d,bmin,bmax);highp vec3 hit=ray_o+t_min*ray_d;highp vec3 r=vec3(v_faux_facade_window,-window_depth);hit-=r*0.5;highp 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=max(0.0,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 #ifdef FEATURE_CUTOUT {float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}} #else color=applyCutout(color,v_pos.z); #endif #endif #ifdef RENDER_FRONT_CUTOFF if (v_front_cutoff_opacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}} #endif #ifdef FEATURE_CUTOUT color=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x); #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 ivec4 a_normal_3;in ivec4 a_centroid_3; #ifdef FLOOD_LIGHT in int a_flood_light_wall_radius_1i16; #endif #ifdef BUILDING_FAUX_FACADE in uvec4 a_faux_facade_data;in uvec2 a_faux_facade_vertical_range; #endif uniform mat4 u_matrix;uniform mat4 u_normal_matrix;uniform highp float u_tile_to_meter; #ifdef RENDER_FRONT_CUTOFF uniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity; #endif #ifdef INDICATOR_CUTOUT #ifdef FEATURE_CUTOUT out vec4 v_ground_roof; #endif #endif 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 uvec2 part_color_emissive #pragma mapbox: define-attribute-vertex-shader-only highp uvec2 faux_facade_color_emissive void main() { #pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive #pragma mapbox: initialize-attribute-custom highp uvec2 faux_facade_color_emissive #ifdef FLOOD_LIGHT v_flood_radius=(float(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(vec2(part_color_emissive));v_color=vec4(sRGBToLinear(color_emissive.rgb),color_emissive.a);vec3 a_normal_3f=vec3(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;vec2 centroid_xy=vec2(a_centroid_3.xy >> 2);vec2 spanBits=vec2(a_centroid_3.xy & 3); #ifdef BUILDING_FAUX_FACADE vec4 faux_facade_data=vec4(a_faux_facade_data);v_faux_facade=faux_facade_data.x;if (v_faux_facade > 0.0) {v_faux_facade_ed=faux_facade_data.x *u_tile_to_meter;float window_x_perc=floor(faux_facade_data.y/TWO_POW_8);float window_y_perc=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=(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=(vec2(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(vec2(faux_facade_color_emissive));v_faux_color_emissive.rgb=sRGBToLinear(v_faux_color_emissive.rgb);depth_offset=min(1000.0,float(a_centroid_3.z))*0.0000002;} #endif v_pos=a_pos_3f; #if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF) float halfSpanX=spanBits.x*10.0/u_tile_to_meter;float halfSpanY=spanBits.y*10.0/u_tile_to_meter;vec2 screenUpInTile=vec2(u_matrix[0][1],u_matrix[1][1]);vec2 spanOffset=vec2(halfSpanX,halfSpanY)*sign(screenUpInTile);vec2 cutoff_highestCorner=centroid_xy+spanOffset;vec2 cutoff_lowestCorner=centroid_xy-spanOffset; #endif #if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF) vec4 ground=u_matrix*vec4(centroid_xy,0.0,1.0); #endif #ifdef RENDER_CUTOFF 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 #ifdef RENDER_FRONT_CUTOFF v_front_cutoff_opacity=1.0;{hidden=max(hidden,float(ground.w <=0.0));float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;hidden=max(hidden,float(ndc_y < threshold-range_ndc));float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);} #endif gl_Position=mix(u_matrix*vec4(v_pos,1),AWAY,hidden);gl_Position.z-=depth_offset*gl_Position.w; #ifdef INDICATOR_CUTOUT #ifdef FEATURE_CUTOUT vec4 ic_ground=u_matrix*vec4(v_pos.xy,0.0,1.0);vec4 ic_roof=u_matrix*vec4(v_pos.xy,v_pos.z,1.0);v_ground_roof=vec4(ic_ground.xy/ic_ground.w,ic_roof.xy/ic_roof.w); #endif #endif }`),buildingBloom:va(`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 uvec2 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 uvec2 part_color_emissive #pragma mapbox: initialize-attribute highp vec4 bloom_attenuation #ifdef HAS_ATTRIBUTE_a_part_color_emissive vec4 color_emissive=decode_color(vec2(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:va("void main() {}","in vec3 a_pos_3f;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);}"),circle:va(`#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 ivec2 a_pos; #ifdef PROJECTION_GLOBE_VIEW in ivec4 a_pos_3;in ivec4 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.0,-1.0),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1.0,-1.0),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1.0,1.0),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1.0,1.0),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 pos2=vec2(a_pos);vec2 extrude=vec2(mod(pos2,2.0)*2.0-1.0);vec2 circle_center=floor(pos2*0.5);float height=circle_elevation(circle_center);vec4 world_center;mat3 surface_vectors; #ifdef PROJECTION_GLOBE_VIEW surface_vectors=globe_mercator_surface_vectors(vec3(a_pos_normal_3)/16384.0,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)*height;vec3 globe_pos=vec3(a_pos_3)+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*height;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);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:va("void main() {glFragColor=vec4(1.0);}","in ivec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:va(`#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 ivec2 a_pos; #ifdef PROJECTION_GLOBE_VIEW in ivec4 a_pos_3;in ivec4 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(vec2(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(vec2(a_pos)*0.5);vec3 pos; #ifdef PROJECTION_GLOBE_VIEW vec3 pos_normal_3=vec3(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=vec3(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:va(`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 ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),collisionBox:va("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 ivec4 a_pos;in ivec2 a_anchor_pos;in ivec2 a_extrude;in uvec2 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() {vec2 anchor_pos=vec2(a_anchor_pos);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(anchor_pos));vec3 proj_pos=vec3(a_pos)+elevationVector(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,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+=(vec2(a_extrude)*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=float(a_placed.x);v_notUsed=float(a_placed.y);}`),collisionCircle:va("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 ivec2 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;int vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2( mix(-1.0,1.0,float(vertexIdx >=2)),mix(-1.0,1.0,float(vertexIdx >=1 && vertexIdx <=2)));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=float(a_flags.x);gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}`),debug:va("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 ivec2 a_pos; #ifdef PROJECTION_GLOBE_VIEW in ivec4 a_pos_3; #endif out vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {vec2 pos=vec2(a_pos);float h=elevation(pos);v_uv=pos/8192.0; #ifdef PROJECTION_GLOBE_VIEW gl_Position=u_matrix*vec4(vec3(a_pos_3)+elevationVector(pos)*h,1); #else gl_Position=u_matrix*vec4(pos*u_overlay_scale,h,1); #endif }`),elevatedStructuresDepth:va("void main() {}","in ivec2 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:va(`#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,get_cutout_factors(gl_FragCoord).x); #endif #endif glFragColor=vec4(1.0,0.0,0.0,1.0);}`,`in ivec2 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:va(`#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;vec2 cutout_factors=vec2(0.0); #ifdef FEATURE_CUTOUT cutout_factors=get_cutout_factors(gl_FragCoord); #endif #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 light=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);color.rgb=apply_lighting(color.rgb,transformed_normal,light); #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,cutout_factors.x); #endif glFragColor=out_color;HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" in ivec2 a_pos;in float a_height;in ivec4 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=vec3(a_pos_normal_3)/16384.0;v_height=a_height;vec3 pos=vec3(vec2(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(vec2(a_pos)); #endif }`),fill:va(`#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 vec2 cutout_factors=vec2(0.0); #ifdef FEATURE_CUTOUT cutout_factors=get_cutout_factors(gl_FragCoord); #endif 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);light=mix(light,1.0,cutout_factors.y);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,cutout_factors.x); #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 ivec2 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(vec2(a_pos)); #endif #ifdef INDICATOR_CUTOUT v_z_offset=z_offset; #endif }`),fillOutline:va(`#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;vec2 cutout_factors=vec2(0.0); #ifdef FEATURE_CUTOUT cutout_factors=get_cutout_factors(gl_FragCoord); #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);light=mix(light,1.0,cutout_factors.y);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,cutout_factors.x); #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 ivec2 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(vec2(a_pos)); #endif }`),fillOutlinePattern:va(`#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 uvec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: define mediump uvec4 pattern_b #endif void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump uvec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: initialize mediump uvec4 pattern_b #endif vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(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 vec2 cutout_factors=vec2(0.0); #ifdef FEATURE_CUTOUT cutout_factors=get_cutout_factors(gl_FragCoord); #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);light=mix(light,1.0,cutout_factors.y);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,cutout_factors.x); #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 ivec2 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 uvec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: define mediump uvec4 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 uvec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: initialize mediump uvec4 pattern_b #endif #pragma mapbox: initialize lowp float pixel_ratio #pragma mapbox: initialize highp float z_offset vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw); #ifdef ELEVATED_ROADS z_offset+=a_road_z_offset; #endif float hidden=float(opacity==0.0);vec2 pos=vec2(a_pos);gl_Position=mix(u_matrix*vec4(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,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(pos,z_offset);vec3 shd_pos1=vec3(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(pos); #endif }`),fillPattern:va(`#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 uvec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: define mediump uvec4 pattern_b #endif void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump uvec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: initialize mediump uvec4 pattern_b #endif vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(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=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(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 vec2 cutout_factors=vec2(0.0); #ifdef FEATURE_CUTOUT cutout_factors=get_cutout_factors(gl_FragCoord); #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);light=mix(light,1.0,cutout_factors.y); #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,cutout_factors.x); #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 ivec2 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 uvec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: define mediump uvec4 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 uvec4 pattern #pragma mapbox: initialize lowp float pixel_ratio #pragma mapbox: initialize highp float z_offset #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: initialize mediump uvec4 pattern_b #endif vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(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);vec2 pos=vec2(a_pos);gl_Position=mix(u_matrix*vec4(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,pos); #ifdef RENDER_SHADOWS vec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(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(pos); #endif }`),lineBlendComposite:va(`uniform sampler2D u_image;uniform float u_opacity;uniform int u_blend_mode;in vec2 v_pos; #define ADDITIVE 1 void main() {vec4 color=texture(u_image,v_pos);if (u_blend_mode==ADDITIVE) {if (color.a <=0.0) {discard;}float density=color.a;vec3 avgColor=color.rgb/max(density,0.001);float t=density/(1.0+density);glFragColor=vec4(avgColor*t*u_opacity,t*u_opacity);} else {vec3 multiplyFactor=color.rgb*u_opacity+(1.0-u_opacity);glFragColor=vec4(multiplyFactor,1.0);} #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(0.0); #endif HANDLE_WIREFRAME_DEBUG;}`,"in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),fillExtrusion:va(`#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 RENDER_FRONT_CUTOFF in float v_front_cutoff_opacity; #endif #ifdef INDICATOR_CUTOUT #ifdef FEATURE_CUTOUT in vec4 v_ground_roof; #endif #endif #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 #ifdef FEATURE_CUTOUT {float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}} #else color=applyCutout(color,h); #endif #endif #ifdef RENDER_FRONT_CUTOFF if (v_front_cutoff_opacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}} #endif #ifdef FEATURE_CUTOUT color=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x); #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 ivec4 a_pos_normal_ed; #if defined(HAS_CENTROID) || defined(TERRAIN) in uvec2 a_centroid_pos; #endif #ifdef RENDER_WALL_MODE in ivec4 a_join_normal_inside; #endif #ifdef PROJECTION_GLOBE_VIEW in ivec4 a_pos_3;in ivec4 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; #ifdef RENDER_FRONT_CUTOFF uniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity; #endif 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; #ifdef INDICATOR_CUTOUT #ifdef FEATURE_CUTOUT out vec4 v_ground_roof; #endif #endif 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 top_up_ny_start=vec4(a_pos_normal_ed & 1);vec4 pos_nx=vec4(a_pos_normal_ed >> 1);float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny_start.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny_start.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_start.y==0.0 && top_up_ny_start.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny_start.x;vec2 centroid_pos=vec2(0.0); #if defined(HAS_CENTROID) || defined(TERRAIN) centroid_pos=vec2(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);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && (int(centroid_pos.y) & 7)==7);c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? 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; #else h=t > 0.0 ? height : base; #endif pos=vec3(pos_nx.xy,h); #ifdef PROJECTION_GLOBE_VIEW float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=vec3(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; #if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF) vec2 centroid_decoded=pos.xy;bool isBorderCentroid=false;if (centroid_pos.x > 0.0 && centroid_pos.y > 0.0) {int iy=int(centroid_pos.y);int spanYbits=iy & 7;if (spanYbits==7) {isBorderCentroid=true;int borderID=(iy >> 3) & 3;float coordAlongBorder=float(iy >> 5)*4.0;if (borderID==0) centroid_decoded=vec2(0.0,coordAlongBorder);else if (borderID==1) centroid_decoded=vec2(EXTENT,coordAlongBorder);else if (borderID==2) centroid_decoded=vec2(coordAlongBorder,0.0);else centroid_decoded=vec2(coordAlongBorder,EXTENT);} else {centroid_decoded=floor(centroid_pos/8.0);}} #endif #if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF) vec4 ground=u_matrix*vec4(centroid_decoded,ele,1.0); #endif #ifdef RENDER_CUTOFF #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 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_random/8.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_FRONT_CUTOFF v_front_cutoff_opacity=1.0;if (centroid_pos.x > 0.0 && centroid_pos.y > 0.0) {hidden=max(hidden,float(ground.w <=0.0));float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;if (!isBorderCentroid) {hidden=max(hidden,float(ndc_y < threshold-range_ndc));}float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);} #endif #ifdef RENDER_WALL_MODE vec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);scaled_pos.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;scaled_pos.xy-=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_start.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_start.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 #ifdef INDICATOR_CUTOUT #ifdef FEATURE_CUTOUT vec4 pos_ground=u_matrix*vec4(pos.xy,ele,1.0);vec4 pos_roof=u_matrix*vec4(pos.xy,ele+height,1.0);v_ground_roof=vec4(pos_ground.xy/pos_ground.w,pos_roof.xy/pos_roof.w); #endif #endif }`),fillExtrusionDepth:va("void main() {}",`#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 ivec4 a_pos_normal_ed; #if defined(HAS_CENTROID) || defined(TERRAIN) in uvec2 a_centroid_pos; #endif #ifdef RENDER_WALL_MODE in ivec4 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 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 top_up_ny=vec3(a_pos_normal_ed.xyz & 1);vec3 pos_nx=vec3(a_pos_normal_ed.xyz >> 1);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=vec2(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);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && int(centroid_pos.y)-(int(centroid_pos.y)/8)*8==7);float c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? 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 vec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);pos.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;pos.xy-=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);}`),fillExtrusionPattern:va(`#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 uvec4 pattern #ifdef FILL_EXTRUSION_PATTERN_TRANSITION #pragma mapbox: define mediump uvec4 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 uvec4 pattern #ifdef FILL_EXTRUSION_PATTERN_TRANSITION #pragma mapbox: initialize mediump uvec4 pattern_b #endif #pragma mapbox: initialize highp float pixel_ratio vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(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=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(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 ivec4 a_pos_normal_ed; #if defined(HAS_CENTROID) || defined(TERRAIN) in uvec2 a_centroid_pos; #endif #ifdef RENDER_WALL_MODE in ivec4 a_join_normal_inside; #endif #ifdef PROJECTION_GLOBE_VIEW in ivec4 a_pos_3;in ivec4 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 uvec4 pattern #ifdef FILL_EXTRUSION_PATTERN_TRANSITION #pragma mapbox: define mediump uvec4 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 uvec4 pattern #ifdef FILL_EXTRUSION_PATTERN_TRANSITION #pragma mapbox: initialize mediump uvec4 pattern_b #endif #pragma mapbox: initialize highp float pixel_ratio #pragma mapbox: initialize highp float line_width vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec4 top_up_ny_start=vec4(a_pos_normal_ed & 1);vec4 pos_nx=vec4(a_pos_normal_ed >> 1);float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny_start.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny_start.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=float(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_start.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0); #if defined(HAS_CENTROID) || defined(TERRAIN) centroid_pos=vec2(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);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && int(centroid_pos.y)-(int(centroid_pos.y)/8)*8==7);c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? 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(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=vec3(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 vec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);p.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;p.xy-=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_start.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:va(`#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 #ifdef FEATURE_CUTOUT shadow=mix(shadow,vec3(1.0),get_cutout_factors(gl_FragCoord).y); #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 ivec2 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(vec2(a_pos));v_fog_opacity=fog(v_fog_pos); #endif }`),fillExtrusionGroundEffect:va(`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 ivec4 a_pos_end;in highp int a_angular_offset_factor;in highp uint 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 vec4 pos_end=vec4(a_pos_end);vec2 p=pos_end.xy;vec2 q=floor(pos_end.zw*0.5);vec2 start_bottom=pos_end.zw-q*2.0;float 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=float(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=float(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:va(`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 ivec2 a_pos;in uvec2 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=(vec2(a_texture_pos)/8192.0)*scale+epsilon;}"),hillshade:va(`#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 ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=vec2(a_texture_pos)/8192.0; #ifdef FOG v_fog_pos=fog_position(vec2(a_pos)); #endif }`),line:va(`#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 highp vec2 u_trim_gradient_mix_range;uniform lowp vec4 u_trim_color;uniform bool u_emissive_in_shadows;in vec4 v_width2_dilute;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 VARIABLE_LINE_WIDTH in float stub_side; #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 mediump uvec4 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 mediump uvec4 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_dilute.x; #ifdef VARIABLE_LINE_WIDTH blur=mix(blur,0.0,stub_side); #endif float diluted_opacity=opacity*v_width2_dilute.z;float blur2=(u_width_scale*blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2_dilute.y-blur2),v_width2_dilute.x-dist)/blur2,0.0,1.0); #ifdef VARIABLE_LINE_WIDTH alpha=mix(alpha,1.0,stub_side); #endif 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)/(float(dash.z)+float(dash.w)/65535.0);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); #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);highp float gradient_trim_color_mix_factor=0.0; #ifdef RENDER_LINE_GRADIENT gradient_trim_color_mix_factor=smoothstep(u_trim_gradient_mix_range.x,u_trim_gradient_mix_range.y,line_progress); #endif highp vec4 trim_color=mix(u_trim_color,out_color,gradient_trim_color_mix_factor);out_color=mix(u_trim_gradient_mix_range.x < 1.0 ? color : out_color,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 #ifndef VARIABLE_LINE_WIDTH float edgeBlur=((border_width*u_width_scale)+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2_dilute.y-edgeBlur),v_width2_dilute.x-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);}out_color*=v_width2_dilute.w;} #endif #endif vec2 cutout_factors=vec2(0.0); #ifdef FEATURE_CUTOUT cutout_factors=get_cutout_factors(gl_FragCoord); #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);light=mix(light,1.0,cutout_factors.y);light=u_emissive_in_shadows ? mix(light,1.0,emissive_strength) : light; #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*diluted_opacity); #ifdef LINE_BLEND_MULTIPLY glFragColor=vec4(out_color.rgb+(1.0-out_color.a),1.0);HANDLE_WIREFRAME_DEBUG;return; #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,cutout_factors.x); #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 ivec2 a_pos_normal;in uvec4 a_data; #if defined(ELEVATED) || defined(ELEVATED_ROADS) || defined(VARIABLE_LINE_WIDTH) in vec3 a_z_offset_width; #endif #ifdef ELEVATION_GROUND_SCALE in float a_elevation_ground_scale; #endif #if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE) 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 RENDER_LINE_CURVE uniform mat3 u_curve_points_x;uniform mat3 u_curve_points_y;uniform mat3 u_curve_points_z;uniform float u_curve_point_count; #endif #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 vec4 v_width2_dilute;out float v_gamma_scale;out highp vec3 v_uv; #ifdef ELEVATED_ROADS out highp float v_road_z_offset; #endif #ifdef VARIABLE_LINE_WIDTH out float stub_side; #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 mediump uvec4 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 #ifdef RENDER_LINE_CURVE vec3 getCurvePoint(int index) {int row=index/3;int col=index-row*3;float x=u_curve_points_x[row][col];float y=u_curve_points_y[row][col];float z=u_curve_points_z[row][col];return vec3(x,y,z);}vec3 catmullRom(vec3 p0,vec3 p1,vec3 p2,vec3 p3,float t) {float t2=t*t;float t3=t2*t;return 0.5*( 2.0*p1+(-p0+p2)*t+(2.0*p0-5.0*p1+4.0*p2-p3)*t2+(-p0+3.0*p1-3.0*p2+p3)*t3 );}vec2 catmullRomTangent(vec2 p0,vec2 p1,vec2 p2,vec2 p3,float t) {float t2=t*t;return 0.5*( (-p0+p2)+(2.0*p0-5.0*p1+4.0*p2-p3)*2.0*t+(-p0+3.0*p1-3.0*p2+p3)*3.0*t2 );}struct CurveResult {vec3 point;vec2 tangent;};CurveResult calculateCurve(float line_progress) {float curve_progress=line_progress*(u_curve_point_count-1.0);float curve_progress_local=fract(curve_progress);float curve_segment=floor(curve_progress);int seg=int(curve_segment);vec3 p1=getCurvePoint(seg);vec3 p2=getCurvePoint(seg+1);float is_first_seg=step(curve_segment,0.5);vec3 p0_extrapolated=p1-(p2-p1);vec3 p0_fetched=getCurvePoint(max(seg-1,0));vec3 p0=mix(p0_fetched,p0_extrapolated,is_first_seg);int last_seg=int(u_curve_point_count)-2;float is_last_seg=step(float(last_seg)-0.5,curve_segment);vec3 p3_extrapolated=p2+(p2-p1);vec3 p3_fetched=getCurvePoint(min(seg+2,int(u_curve_point_count)-1));vec3 p3=mix(p3_fetched,p3_extrapolated,is_last_seg);vec3 point=catmullRom(p0,p1,p2,p3,curve_progress_local);vec2 tangent=catmullRomTangent(p0.xy,p1.xy,p2.xy,p3.xy,curve_progress_local)*(u_curve_point_count-1.0);CurveResult result;result.point=point;result.tangent=tangent;return result;} #endif void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float floorwidth #pragma mapbox: initialize mediump uvec4 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 highp float line_progress=0.0; #if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE) line_progress=a_packed[2]; #endif float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(a_data.xy)-128.0;float a_direction=float(a_data.z & 3u)-1.0;vec2 pos_normal=vec2(a_pos_normal);vec2 pos=floor(pos_normal*0.5);mediump vec2 normal=pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;offset=-1.0*offset*u_width_scale;bool left=normal.y==1.0; #ifdef RENDER_LINE_CURVE CurveResult curve=calculateCurve(line_progress);pos=curve.point.xy*8192.0;a_extrude=length(a_extrude)*normalize(curve.tangent);a_extrude=left ? vec2(-a_extrude.y,a_extrude.x) : vec2(a_extrude.y,-a_extrude.x);a_z_offset+=curve.point.z; #endif gapwidth=gapwidth/2.0;float halfwidth;float dilute_scale=1.0;float dilute_border_scale=1.0; #ifdef VARIABLE_LINE_WIDTH float left_width=a_z_offset_width.y;float right_width=a_z_offset_width.z;halfwidth=(u_width_scale*(left ? left_width : right_width))/2.0;if (side_z_offset !=0.0) {float left_f=step(1.0,normal.y);float is_negative=step(side_z_offset,0.0);float apply=mix(1.0-left_f,left_f,is_negative);a_extrude*=apply;a_z_offset+=abs(side_z_offset)*apply;v_normal*=left_f;}offset=border_width > 0.0 ? (left_width+right_width)*u_width_scale*0.5 : offset;halfwidth=border_width > 0.0 ? border_width*u_width_scale*0.5 : halfwidth;bool zero_right_width=border_width==0.0 && right_width==0.0;stub_side=zero_right_width ?-normal.y : 0.0;v_normal=!left && zero_right_width ? vec2(0.0) : v_normal;ANTIALIASING=!left && zero_right_width ? 0.0 : ANTIALIASING; #else halfwidth=(u_width_scale*width)/2.0; #endif 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); #else #ifdef ELEVATED vec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset; #ifdef ELEVATION_GROUND_SCALE scaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale); #endif #ifdef CROSS_SLOPE_VERTICAL float top=pos_normal.y-2.0*floor(pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_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+scaled_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+scaled_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=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0); #endif #endif #ifndef ELEVATED #ifndef VARIABLE_LINE_WIDTH #ifndef RENDER_TO_TEXTURE float base_w=gl_Position.w;vec2 screen_width=abs(projected_extrude.xy/base_w*u_units_to_pixels);float max_extrude_component=max(screen_width.x,screen_width.y);if (width >=1.0 && base_w > 0.0 && max_extrude_component > 0.0001) {float min_pixel=1.05;if (max_extrude_component < min_pixel) {vec2 abs_pos=abs(gl_Position.xy);float is_out=max(abs_pos.x,abs_pos.y)/base_w;dilute_scale=mix(max_extrude_component/min_pixel,1.0,smoothstep(2.5,4.5,is_out));projected_extrude/=dilute_scale;}else { #ifdef RENDER_LINE_BORDER float border_ratio=(border_width*u_width_scale+ANTIALIASING)/outset;screen_width*=border_ratio;float max_border_component=max(screen_width.x,screen_width.y);dilute_border_scale=min(1.0,max_border_component/min_pixel); #endif }} #endif #endif #ifdef ELEVATED_ROADS gl_Position=gl_Position+projected_extrude; #else gl_Position=mix(gl_Position+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]; #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 vec4 dashf=vec4(dash);float totalLength=dashf.z+dashf.w/65535.0;float scale=totalLength==0.0 ? 0.0 : u_tile_units_to_pixels/totalLength;v_tex=vec2(a_linesofar*scale/(floorwidth*u_floor_width_scale),(-normal.y*dashf.y+dashf.x+0.5)/u_texsize.y); #endif v_width2_dilute=vec4(outset,inset,dilute_scale,dilute_border_scale); #ifdef FOG v_fog_pos=fog_position(pos); #endif #ifdef INDICATOR_CUTOUT v_z_offset=a_z_offset; #endif }`),linePattern:va(`#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 uvec4 pattern #ifdef LINE_PATTERN_TRANSITION #pragma mapbox: define mediump uvec4 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 uvec4 pattern #ifdef LINE_PATTERN_TRANSITION #pragma mapbox: initialize mediump uvec4 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=vec2(pattern.xy);vec2 pattern_br=vec2(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=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(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 ivec2 a_pos_normal;in uvec4 a_data; #if defined(ELEVATED) || defined(ELEVATED_ROADS) in vec3 a_z_offset_width; #endif #ifdef ELEVATION_GROUND_SCALE in float a_elevation_ground_scale; #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 uvec4 pattern #ifdef LINE_PATTERN_TRANSITION #pragma mapbox: define mediump uvec4 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 uvec4 pattern #ifdef LINE_PATTERN_TRANSITION #pragma mapbox: initialize mediump uvec4 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=vec2(a_data.xy)-128.0;float a_direction=float(a_data.z & 3u)-1.0;vec2 pos_normal=vec2(a_pos_normal);vec2 pos=floor(pos_normal*0.5);vec2 normal=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;float scaled_z_offset=a_z_offset; #ifdef ELEVATION_GROUND_SCALE scaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale); #endif #ifdef CROSS_SLOPE_VERTICAL float top=pos_normal.y-2.0*floor(pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_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+scaled_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+scaled_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/(float(pattern.w-pattern.y)*pixel_ratio_inverse);highp float subt_multiple=float(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:va(`#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" #include "_prelude_terrain.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; #ifdef ELEVATED uniform lowp float u_zbias_factor; #endif #define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8 #ifdef GLOBE_POLES in vec3 a_globe_pos;in vec2 a_uv; #else in ivec2 a_pos;in uvec2 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;uv=a_uv;float ele=u_raster_elevation; #ifdef ELEVATION_REFERENCE_GROUND ele+=elevation(uv*EXTENT); #endif globe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos,1.0); #ifdef FOG v_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz); #endif #else vec4 world_pos; #ifdef PROJECTION_GLOBE_VIEW vec2 texture_pos=vec2(a_texture_pos);uv=texture_pos/8192.0;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];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);}float ele=u_raster_elevation; #ifdef ELEVATION_REFERENCE_GROUND ele+=elevation(uv*EXTENT)-decomposed_pos_and_skirt.z; #endif vec4 merc_world_pos=vec4(0.0); v_split_fade=0.0;if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,ele,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)));}vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);world_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0); #ifdef FOG v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz); #endif #else float ele=0.0;vec2 decodedPos=vec2(a_pos); #ifdef ELEVATION_REFERENCE_GROUND vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;decodedPos=decomposedPosAndSkirt.xy;uv=decodedPos/8192.0;ele=elevation(decodedPos)-skirt; #else uv=vec2(a_texture_pos)/8192.0; #endif world_pos=vec4(decodedPos,(u_raster_elevation+ele),1.0); #ifdef FOG v_fog_pos=fog_position(decodedPos); #endif #endif float w=1.0+dot(uv*EXTENT,u_perspective_transform);gl_Position=u_matrix*world_pos*w; #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 ELEVATED 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);gl_Position.z-=(gl_Position.w*zbias); #endif #ifdef RENDER_CUTOFF v_depth=gl_Position.z; #endif }`),rasterParticle:va(`#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 ivec2 a_pos;in uvec2 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=vec2(a_texture_pos)/8192.0;gl_Position=u_matrix*vec4(vec2(a_pos)*w,u_raster_elevation*w,w); #ifdef FOG v_fog_pos=fog_position(vec2(a_pos)); #endif #endif v_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}`),rasterParticleDraw:va("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 int 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(float(a_index),u_particle_texture_side_len),float(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:va("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 ivec2 a_pos;out vec2 v_tex_pos;void main() {vec2 uv=0.5*vec2(a_pos)+vec2(0.5);v_tex_pos=uv;gl_Position=vec4(a_pos,0.0,1.0);}"),rasterParticleUpdate:va(`#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 ivec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*vec2(a_pos+ivec2(1));gl_Position=vec4(a_pos,0.0,1.0);}"),symbol:va(`#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 #ifdef USE_PAINT_PROPERTIES_UBO in lowp float v_opacity; #ifdef RENDER_SDF in lowp vec4 v_fill_np_color;in lowp vec4 v_halo_np_color;in lowp float v_halo_width;in lowp float v_halo_blur; #endif #ifdef LIGHTING_3D_MODE in lowp float v_emissive_strength; #endif #else #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 #endif void main() { #ifdef USE_PAINT_PROPERTIES_UBO lowp float opacity=v_opacity;lowp vec4 fill_color=vec4(0.0);lowp vec4 halo_color=vec4(0.0);lowp float halo_width=0.0;lowp float halo_blur=0.0; #ifdef RENDER_SDF fill_color=vec4(v_fill_np_color.rgb*v_fill_np_color.a,v_fill_np_color.a);halo_color=vec4(v_halo_np_color.rgb*v_halo_np_color.a,v_halo_np_color.a);halo_width=v_halo_width;halo_blur=v_halo_blur; #endif lowp float emissive_strength=0.0; #ifdef LIGHTING_3D_MODE emissive_strength=v_emissive_strength; #endif #else #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 #endif 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 vec2 cutout_factors=vec2(0.0); #ifdef FEATURE_CUTOUT cutout_factors=get_cutout_factors(gl_FragCoord); #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);light=mix(light,1.0,cutout_factors.y); #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,cutout_factors.x); #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 USING_APPEARANCE 1.0 in ivec4 a_pos_offset;in uvec4 a_tex_size;in ivec4 a_pixeloffset;in vec4 a_projected_pos;in uint a_fade_opacity; #ifdef Z_OFFSET in float a_auto_z_offset; #endif #ifdef PROJECTION_GLOBE_VIEW in ivec4 a_globe_anchor;in vec3 a_globe_normal; #endif #ifdef ICON_TRANSITION in uvec2 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 #ifdef USE_PAINT_PROPERTIES_UBO #ifndef MAX_UBO_SIZE_VEC4 #define MAX_UBO_SIZE_VEC4 1024u #endif #define SPP_HEADER_SIZE_VEC4 3u #define DWORDS_PER_VEC4 4u struct SymbolPaintProperties {vec4 fill_np_color;vec4 halo_np_color;float opacity;float halo_width;float halo_blur;float emissive_strength;float occlusion_opacity;float z_offset;vec2 translate;};struct PropertyType {bool isDataDriven;bool isZoomDependent;uint offsetDwords;};struct SymbolPropertyHeader {uint dataDrivenBlockSizeVec4;PropertyType fill_np_color;PropertyType halo_np_color;PropertyType opacity;PropertyType halo_width;PropertyType halo_blur;PropertyType emissive_strength;PropertyType occlusion_opacity;PropertyType z_offset;PropertyType translate;};uniform float u_zoom;uniform lowp vec4 u_spp_fill_np_color;uniform lowp vec4 u_spp_halo_np_color;uniform lowp float u_spp_opacity;uniform lowp float u_spp_halo_width;uniform lowp float u_spp_halo_blur;uniform lowp float u_spp_emissive_strength;uniform lowp float u_spp_occlusion_opacity;uniform lowp float u_spp_z_offset;uniform lowp vec2 u_spp_translate_rotation;in float a_feature_index;layout(std140) uniform SymbolPaintPropertiesHeaderUniform {uvec4 header[SPP_HEADER_SIZE_VEC4];} u_spp_header;layout(std140) uniform SymbolPaintPropertiesUniform {vec4 properties[MAX_UBO_SIZE_VEC4];} u_spp_properties;layout(std140) uniform SymbolPaintPropertiesIndexUniform {uvec4 block_indices[MAX_UBO_SIZE_VEC4];} u_spp_index;out lowp float v_opacity; #ifdef RENDER_SDF out lowp vec4 v_fill_np_color;out lowp vec4 v_halo_np_color;out lowp float v_halo_width;out lowp float v_halo_blur; #endif #ifdef LIGHTING_3D_MODE out lowp float v_emissive_strength; #endif PropertyType getPropertyType(uint propertyIndex,uint dataDrivenMask,uint zoomDependentMask,uint offsetDwords) {PropertyType type;type.isDataDriven=(dataDrivenMask & (1u << propertyIndex)) !=0u;type.isZoomDependent=(zoomDependentMask & (1u << propertyIndex)) !=0u;type.offsetDwords=offsetDwords;return type;}SymbolPropertyHeader readSymbolPropertiesHeader() {SymbolPropertyHeader header;uint dataDrivenMask=u_spp_header.header[0][0];uint zoomDependentMask=u_spp_header.header[0][1];header.dataDrivenBlockSizeVec4=u_spp_header.header[0][2];header.fill_np_color =getPropertyType(0u,dataDrivenMask,zoomDependentMask,u_spp_header.header[0][3]);header.halo_np_color =getPropertyType(1u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][0]);header.opacity =getPropertyType(2u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][1]);header.halo_width =getPropertyType(3u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][2]);header.halo_blur =getPropertyType(4u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][3]);header.emissive_strength =getPropertyType(5u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][0]);header.occlusion_opacity =getPropertyType(6u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][1]);header.z_offset =getPropertyType(7u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][2]);header.translate =getPropertyType(8u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][3]);return header;}uint uvec4At(uvec4 v,uint index) {return (index==0u) ? v.x : (index==1u) ? v.y : (index==2u) ? v.z : v.w;}float vec4At(vec4 v,uint index) {return (index==0u) ? v.x : (index==1u) ? v.y : (index==2u) ? v.z : v.w;}vec4 readVec4(uint baseOffsetVec4,uint propertyOffsetDwords) {return u_spp_properties.properties[baseOffsetVec4+propertyOffsetDwords/DWORDS_PER_VEC4];}float readFloat(vec4 slot,uint propertyOffsetDwords) {return slot[propertyOffsetDwords % DWORDS_PER_VEC4];}uint readUint(uvec4 slot,uint offset) {return slot[offset % DWORDS_PER_VEC4];}vec2 readVec2(vec4 slot,uint propertyOffsetDwords) {float x=vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4);float y=vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4+1u);return vec2(x,y);}uint getDataDrivenBlockOffsetVec4(uint dataDrivenBlockSizeVec4) {uint featureIndex=uint(a_feature_index);uvec4 slot=u_spp_index.block_indices[featureIndex/DWORDS_PER_VEC4];uint blockIndex=uvec4At(slot,featureIndex % DWORDS_PER_VEC4);return blockIndex*dataDrivenBlockSizeVec4;}vec4 readColorProperty(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 color=readVec4(blockOffsetVec4,propertyType.offsetDwords);if (propertyType.isZoomDependent) {color=unpack_mix_color(color,u_zoom);} else {vec2 packedColor=readVec2(color,propertyType.offsetDwords);color=decode_color(packedColor);}return color;}vec2 readVec2Property(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 slot=readVec4(blockOffsetVec4,propertyType.offsetDwords);if (propertyType.isZoomDependent) {vec2 minVal=slot.xy;vec2 maxVal=slot.zw;return mix(minVal,maxVal,u_zoom);}return readVec2(slot,propertyType.offsetDwords);}float readFloatProperty(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 slot=readVec4(blockOffsetVec4,propertyType.offsetDwords);float value;if (propertyType.isZoomDependent) {vec2 packedValues=readVec2(slot,propertyType.offsetDwords);value=unpack_mix_vec2(packedValues,u_zoom);} else {value=readFloat(slot,propertyType.offsetDwords);}return value;}SymbolPaintProperties readSymbolPaintProperties() {SymbolPropertyHeader header=readSymbolPropertiesHeader();uint sizeVec4=header.dataDrivenBlockSizeVec4;SymbolPaintProperties props;props.fill_np_color =header.fill_np_color.isDataDriven ? readColorProperty(header.fill_np_color,sizeVec4) : u_spp_fill_np_color;props.halo_np_color =header.halo_np_color.isDataDriven ? readColorProperty(header.halo_np_color,sizeVec4) : u_spp_halo_np_color;props.opacity =header.opacity.isDataDriven ? readFloatProperty(header.opacity,sizeVec4) : u_spp_opacity;props.halo_width =header.halo_width.isDataDriven ? readFloatProperty(header.halo_width,sizeVec4) : u_spp_halo_width;props.halo_blur =header.halo_blur.isDataDriven ? readFloatProperty(header.halo_blur,sizeVec4) : u_spp_halo_blur;props.emissive_strength =header.emissive_strength.isDataDriven ? readFloatProperty(header.emissive_strength,sizeVec4) : u_spp_emissive_strength;props.occlusion_opacity =header.occlusion_opacity.isDataDriven ? readFloatProperty(header.occlusion_opacity,sizeVec4) : u_spp_occlusion_opacity;props.z_offset =header.z_offset.isDataDriven ? readFloatProperty(header.z_offset,sizeVec4) : u_spp_z_offset;props.translate =header.translate.isDataDriven ? readVec2Property(header.translate,sizeVec4) : vec2(0.0);return props;} #else #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 #endif vec2 unpack_opacity(uint packedOpacity) {return vec2(float(packedOpacity/2u)/127.0,float(packedOpacity & 1u));}void main() { #ifdef USE_PAINT_PROPERTIES_UBO SymbolPaintProperties paint_properties=readSymbolPaintProperties();lowp float opacity=paint_properties.opacity;v_opacity=opacity; #ifdef RENDER_SDF v_fill_np_color=paint_properties.fill_np_color;v_halo_np_color=paint_properties.halo_np_color;v_halo_width=paint_properties.halo_width;v_halo_blur=paint_properties.halo_blur; #endif #ifdef LIGHTING_3D_MODE v_emissive_strength=paint_properties.emissive_strength; #endif lowp float occlusion_opacity=paint_properties.occlusion_opacity;lowp float z_offset=paint_properties.z_offset; #else #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 #endif vec2 a_pos=vec2(a_pos_offset.xy);vec2 a_offset=vec2(a_pos_offset.zw);vec2 a_tex=vec2(a_tex_size.xy);vec2 a_size=vec2(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=a_size[1]-2.0*a_size_max;vec2 a_pxoffset=vec2(a_pixeloffset.xy);vec2 a_min_font_scale=vec2(a_pixeloffset.zw)/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (a_apperance==USING_APPEARANCE) {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=vec3(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(vec3(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); #ifdef USE_PAINT_PROPERTIES_UBO {vec2 tr=paint_properties.translate;vec2 rotated_tr=vec2( u_spp_translate_rotation.x*tr.x-u_spp_translate_rotation.y*tr.y,u_spp_translate_rotation.y*tr.x+u_spp_translate_rotation.x*tr.y );gl_Position.xy+=(u_coord_matrix*vec4(rotated_tr,0.0,0.0)).xy;} #endif 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=vec2(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:va(`#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 ivec2 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:va("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",`#include "_prelude_terrain.vertex.glsl" uniform mat4 u_matrix;in ivec2 a_pos;out float v_depth;void main() {float elevation=elevation(vec2(a_pos));gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}`),skybox:va(`#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 }`,Hw),skyboxGradient:va(`#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 }`,Hw),skyboxCapture:va(` 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:va(`#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 ivec2 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:va(`#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:va(`#include "_prelude_fog.fragment.glsl" #include "_prelude_shadow.fragment.glsl" #include "_prelude_lighting.glsl" uniform float u_opacity; #ifdef DITHERED_DISCARD uniform float u_dithered_discard_threshold; #endif 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 DITHERED_DISCARD if (abs(u_dithered_discard_threshold) < 1.0) {float ditherValue=fract(52.9829189*fract(0.06711056*gl_FragCoord.x+0.00583715*gl_FragCoord.y));float compareValue=mix(1.0-ditherValue,ditherValue,step(0.0,u_dithered_discard_threshold));if (abs(u_dithered_discard_threshold) < compareValue) {discard;}} #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,get_cutout_factors(gl_FragCoord).x); #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 uvec4 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 uvec4 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(vec2(pbr.xy));vec2 e_r_m=unpack_float(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(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:va("void main() {}",`in vec3 a_pos_3f;uniform mat4 u_matrix; #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 }`),stars:va(`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_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_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:va("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:va("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:va("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:va("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 Vx(M,m){const v=M.split(` `);for(let E of v){if(E=E.trimStart(),E[0]!=="#"||!E.includes("if")||E.startsWith("#endif"))continue;const D=E.match(FO);if(D)for(const z of D)zO.has(z)||m.add(z)}}function $O(M){return new Set(["uint","int","uvec2","ivec2","uvec3","ivec3","uvec4","ivec4"]).has(M)}function va(M,m){const v=new Set,E=[],D=[];M=M.replace(Gw,($,K)=>(D.push(K),"")),m=m.replace(Gw,($,K)=>(E.push(K),""));let z=new Set(U0);Vx(M,z),Vx(m,z);for(const $ of[...E,...D])B1[$]||(B1[$]=new Set,Vx(Ep[$],B1[$])),z=new Set([...z,...B1[$]]);return{fragmentSource:M=M.replace(sr,($,K,ee,ne,de)=>(v.add(de),K==="define"?` #ifndef HAS_UNIFORM_u_${de} ${$O(ne)?"flat ":""}in ${ee} ${ne} ${de}; #else uniform ${ee} ${ne} u_${de}; #endif `:K==="initialize"?` #ifdef HAS_UNIFORM_u_${de} ${ee} ${ne} ${de} = u_${de}; #endif `:K==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${de} in ${ee} ${ne} ${de}; #endif `:K==="initialize-attribute"?"":void 0)),vertexSource:m=m.replace(sr,($,K,ee,ne,de)=>{const we=`MATERIAL_ATTRIBUTE_OFFSET_${de}`,be=ne==="float"?"vec2":ne,Ae=`GET_ATTRIBUTE_${be}(a_${de}, materialInfo, ${we})`,ze=de.match(/color/)?"color":be;return K==="define-attribute-vertex-shader-only"?` #ifdef HAS_ATTRIBUTE_a_${de} in ${ee} ${ne} a_${de}; #endif `:v.has(de)?K==="define"?` #ifndef HAS_UNIFORM_u_${de} uniform lowp float u_${de}_t; #if !defined(${we}) in ${ee} ${be} a_${de}; #endif ${$O(ne)?"flat ":""}out ${ee} ${ne} ${de}; #else uniform ${ee} ${ne} u_${de}; #endif `:K==="initialize"?ze==="vec4"||ze==="uvec4"?` #ifndef HAS_UNIFORM_u_${de} ${de} = a_${de}; #else ${ee} ${ne} ${de} = u_${de}; #endif `:` #if !defined(HAS_UNIFORM_u_${de}) #ifdef ${we} ${de} = unpack_mix_${ze}(${Ae}, u_${de}_t); #else ${de} = unpack_mix_${ze}(a_${de}, u_${de}_t); #endif #else ${ee} ${ne} ${de} = u_${de}; #endif `:K==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${de} in ${ee} ${ne} a_${de}; out ${ee} ${ne} ${de}; #endif `:K==="initialize-attribute"?` #ifdef HAS_ATTRIBUTE_a_${de} ${de} = a_${de}; #endif `:void 0:K==="define"?` #ifndef HAS_UNIFORM_u_${de} uniform lowp float u_${de}_t; #if !defined(${we}) in ${ee} ${be} a_${de}; #endif #else uniform ${ee} ${ne} u_${de}; #endif `:K==="define-instanced"?ze==="mat4"?` #ifdef INSTANCED_ARRAYS in vec4 a_${de}0; in vec4 a_${de}1; in vec4 a_${de}2; in vec4 a_${de}3; #else uniform ${ee} ${ne} u_${de}; #endif `:` #ifdef INSTANCED_ARRAYS in ${ee} ${be} a_${de}; #else uniform ${ee} ${ne} u_${de}; #endif `:K==="initialize-attribute-custom"?` #ifdef HAS_ATTRIBUTE_a_${de} ${ee} ${ne} ${de} = a_${de}; #endif `:ze==="vec4"||ze==="uvec4"?` #ifndef HAS_UNIFORM_u_${de} #ifdef ${we} ${ee} ${ne} ${de} = ${Ae}; #else ${ee} ${ne} ${de} = a_${de}; #endif #else ${ee} ${ne} ${de} = u_${de}; #endif `:` #ifndef HAS_UNIFORM_u_${de} #ifdef ${we} ${ee} ${ne} ${de} = unpack_mix_${ze}(${Ae}, u_${de}_t); #else ${ee} ${ne} ${de} = unpack_mix_${ze}(a_${de}, u_${de}_t); #endif #else ${ee} ${ne} ${de} = u_${de}; #endif `}),usedDefines:z,vertexIncludes:E,fragmentIncludes:D}}class qO{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(m,v,E,D,z,$,K,ee){this.context=m;let ne=this.boundPaintVertexBuffers.length!==D.length;for(let we=0;!ne&&we{const Bt=pt.paint.get("hillshade-shadow-color"),wt=pt.paint.get("hillshade-shadow-color-use-theme").constantOr("default")==="none",Ft=pt.paint.get("hillshade-highlight-color"),ft=pt.paint.get("hillshade-highlight-color-use-theme").constantOr("default")==="none",_t=pt.paint.get("hillshade-accent-color"),Et=pt.paint.get("hillshade-accent-color-use-theme").constantOr("default")==="none",Kt=pt.paint.get("hillshade-emissive-strength");let qt=i.ap(pt.paint.get("hillshade-illumination-direction"));if(pt.paint.get("hillshade-illumination-anchor")==="viewport")qt-=st.transform.angle;else if(st.style&&st.style.enable3dLights()&&st.style.directionalLight){const Jt=st.style.directionalLight.properties.get("direction"),Cs=i.cP(Jt.x,Jt.y,Jt.z);qt=i.ap(Cs[1])}const ns=!st.options.moving;return{u_matrix:at||st.transform.calculateProjMatrix(dt.tileID.toUnwrapped(),ns),u_image:0,u_latrange:YE(0,dt.tileID),u_light:[pt.paint.get("hillshade-exaggeration"),qt],u_shadow:Bt.toPremultipliedRenderColor(wt?null:pt.lut),u_highlight:Ft.toPremultipliedRenderColor(ft?null:pt.lut),u_emissive_strength:Kt,u_accent:_t.toPremultipliedRenderColor(Et?null:pt.lut)}})(M,v,E,M.terrain?m.projMatrix:null);M.uploadCommonUniforms(K,be,m.toUnwrapped());const{tileBoundsBuffer:ze,tileBoundsIndexBuffer:Le,tileBoundsSegments:rt}=M.getTileBoundsBuffers(v);be.draw(M,ee.TRIANGLES,D,z,$,Xr.disabled,Ae,E.id,ze,Le,rt)}function UO(M,m,v){if(!m.needsDEMTextureUpload)return;const E=M.context,D=E.gl;E.pixelStoreUnpackPremultiplyAlpha.set(!1),m.demTexture=m.demTexture||M.getTileTexture(v.stride);const z=v.getPixels();m.demTexture?m.demTexture.update(z,{premultiply:!1}):m.demTexture=new i.T(E,z,D.R32F,{premultiply:!1}),m.needsDEMTextureUpload=!1}function mpe(M,m,v){const E=M.context,D=E.gl;if(!m.dem)return;const z=m.dem;if(E.activeTexture.set(D.TEXTURE1),UO(M,m,z),!m.demTexture)return;m.demTexture.bind(D.NEAREST,D.CLAMP_TO_EDGE);const $=z.dim;E.activeTexture.set(D.TEXTURE0);let K=m.hillshadeFBO;if(!K){const be=new i.T(E,{width:$,height:$,data:null},D.RGBA8);be.bind(D.LINEAR,D.CLAMP_TO_EDGE),K=m.hillshadeFBO=E.createFramebuffer($,$,1,"renderbuffer"),K.colorAttachment0.set(be.texture)}E.bindFramebuffer.set(K.framebuffer),E.viewport.set([0,0,$,$]);const{tileBoundsBuffer:ee,tileBoundsIndexBuffer:ne,tileBoundsSegments:de}=M.getMercatorTileBoundsBuffers(),we=[];M.linearFloatFilteringSupported()&&we.push("TERRAIN_DEM_FLOAT_FORMAT"),M.terrain&&M.terrain.renderingToTexture&&M.emissiveMode==="mrt-fallback"&&we.push("USE_MRT1"),M.getOrCreateProgram("hillshadePrepare",{defines:we}).draw(M,D.TRIANGLES,Sr.disabled,dn.disabled,rn.unblended,Xr.disabled,((be,Ae)=>{const ze=Ae.stride,Le=i.bb();return i.bT(Le,0,i.an,-i.an,0,0,1),i.bx(Le,Le,[0,-i.an,0]),{u_matrix:Le,u_image:1,u_dimension:[ze,ze],u_zoom:be.overscaledZ}})(m.tileID,z),v.id,ee,ne,de),m.needsHillshadePrepare=!1}class oo{constructor(m){this.gl=m.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(m){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class VO extends oo{getDefault(){return i.aq.transparent.toNonPremultipliedRenderColor(null)}set(m){const v=this.current;(m.r!==v.r||m.g!==v.g||m.b!==v.b||m.a!==v.a||this.dirty)&&(this.gl.clearColor(m.r,m.g,m.b,m.a),this.current=m,this.dirty=!1)}}class ppe extends oo{getDefault(){return 1}set(m){(m!==this.current||this.dirty)&&(this.gl.clearDepth(m),this.current=m,this.dirty=!1)}}class GC extends oo{getDefault(){return 0}set(m){(m!==this.current||this.dirty)&&(this.gl.clearStencil(m),this.current=m,this.dirty=!1)}}class fpe extends oo{getDefault(){return[!0,!0,!0,!0]}set(m){const v=this.current;(m[0]!==v[0]||m[1]!==v[1]||m[2]!==v[2]||m[3]!==v[3]||this.dirty)&&(this.gl.colorMask(m[0],m[1],m[2],m[3]),this.current=m,this.dirty=!1)}}class HO extends oo{getDefault(){return!0}set(m){(m!==this.current||this.dirty)&&(this.gl.depthMask(m),this.current=m,this.dirty=!1)}}class XE extends oo{getDefault(){return 255}set(m){(m!==this.current||this.dirty)&&(this.gl.stencilMask(m),this.current=m,this.dirty=!1)}}class WC extends oo{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(m){const v=this.current;(m.func!==v.func||m.ref!==v.ref||m.mask!==v.mask||this.dirty)&&(this.gl.stencilFunc(m.func,m.ref,m.mask),this.current=m,this.dirty=!1)}}class QE extends oo{getDefault(){const m=this.gl;return[m.KEEP,m.KEEP,m.KEEP]}set(m){const v=this.current;(m[0]!==v[0]||m[1]!==v[1]||m[2]!==v[2]||this.dirty)&&(this.gl.stencilOp(m[0],m[1],m[2]),this.current=m,this.dirty=!1)}}class V0 extends oo{getDefault(){return!1}set(m){if(m===this.current&&!this.dirty)return;const v=this.gl;m?v.enable(v.STENCIL_TEST):v.disable(v.STENCIL_TEST),this.current=m,this.dirty=!1}}class H0 extends oo{getDefault(){return[0,1]}set(m){const v=this.current;(m[0]!==v[0]||m[1]!==v[1]||this.dirty)&&(this.gl.depthRange(m[0],m[1]),this.current=m,this.dirty=!1)}}class q1 extends oo{getDefault(){return!1}set(m){if(m===this.current&&!this.dirty)return;const v=this.gl;m?v.enable(v.DEPTH_TEST):v.disable(v.DEPTH_TEST),this.current=m,this.dirty=!1}}class Ef extends oo{getDefault(){return this.gl.LESS}set(m){(m!==this.current||this.dirty)&&(this.gl.depthFunc(m),this.current=m,this.dirty=!1)}}class GO extends oo{getDefault(){return!1}set(m){if(m===this.current&&!this.dirty)return;const v=this.gl;m?v.enable(v.BLEND):v.disable(v.BLEND),this.current=m,this.dirty=!1}}class JE extends oo{getDefault(){const m=this.gl;return[m.ONE,m.ZERO,m.ONE,m.ZERO]}set(m){const v=this.current;(m[0]!==v[0]||m[1]!==v[1]||m[2]!==v[2]||m[3]!==v[3]||this.dirty)&&(this.gl.blendFuncSeparate(m[0],m[1],m[2],m[3]),this.current=m,this.dirty=!1)}}class WO extends oo{getDefault(){return i.aq.transparent.toNonPremultipliedRenderColor(null)}set(m){const v=this.current;(m.r!==v.r||m.g!==v.g||m.b!==v.b||m.a!==v.a||this.dirty)&&(this.gl.blendColor(m.r,m.g,m.b,m.a),this.current=m,this.dirty=!1)}}class U1 extends oo{getDefault(){return this.gl.FUNC_ADD}set(m){(m!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(m,m),this.current=m,this.dirty=!1)}}class KC extends oo{getDefault(){return!1}set(m){if(m===this.current&&!this.dirty)return;const v=this.gl;m?v.enable(v.CULL_FACE):v.disable(v.CULL_FACE),this.current=m,this.dirty=!1}}class ZC extends oo{getDefault(){return this.gl.BACK}set(m){(m!==this.current||this.dirty)&&(this.gl.cullFace(m),this.current=m,this.dirty=!1)}}class eP extends oo{getDefault(){return this.gl.CCW}set(m){(m!==this.current||this.dirty)&&(this.gl.frontFace(m),this.current=m,this.dirty=!1)}}let YC=class extends oo{getDefault(){return null}set(M){(M!==this.current||this.dirty)&&(this.gl.useProgram(M),this.current=M,this.dirty=!1)}};class Kw extends oo{getDefault(){return this.gl.TEXTURE0}set(m){(m!==this.current||this.dirty)&&(this.gl.activeTexture(m),this.current=m,this.dirty=!1)}}class KO extends oo{getDefault(){const m=this.gl;return[0,0,m.drawingBufferWidth,m.drawingBufferHeight]}set(m){const v=this.current;(m[0]!==v[0]||m[1]!==v[1]||m[2]!==v[2]||m[3]!==v[3]||this.dirty)&&(this.gl.viewport(m[0],m[1],m[2],m[3]),this.current=m,this.dirty=!1)}}class ZO extends oo{getDefault(){return null}set(m){if(m===this.current&&!this.dirty)return;const v=this.gl;v.bindFramebuffer(v.FRAMEBUFFER,m),this.current=m,this.dirty=!1}}class YO extends oo{getDefault(){return null}set(m){if(m===this.current&&!this.dirty)return;const v=this.gl;v.bindRenderbuffer(v.RENDERBUFFER,m),this.current=m,this.dirty=!1}}class V1 extends oo{getDefault(){return null}set(m){if(m===this.current&&!this.dirty)return;const v=this.gl;v.bindTexture(v.TEXTURE_2D,m),this.current=m,this.dirty=!1}}class XO extends oo{getDefault(){return null}set(m){if(m===this.current&&!this.dirty)return;const v=this.gl;v.bindBuffer(v.ARRAY_BUFFER,m),this.current=m,this.dirty=!1}}class xpe extends oo{getDefault(){return null}set(m){const v=this.gl;v.bindBuffer(v.ELEMENT_ARRAY_BUFFER,m),this.current=m,this.dirty=!1}}class gpe extends oo{getDefault(){return null}set(m){this.gl&&(m!==this.current||this.dirty)&&(this.gl.bindVertexArray(m),this.current=m,this.dirty=!1)}}class ype extends oo{getDefault(){return 4}set(m){if(m===this.current&&!this.dirty)return;const v=this.gl;v.pixelStorei(v.UNPACK_ALIGNMENT,m),this.current=m,this.dirty=!1}}class tP extends oo{getDefault(){return!1}set(m){if(m===this.current&&!this.dirty)return;const v=this.gl;v.pixelStorei(v.UNPACK_PREMULTIPLY_ALPHA_WEBGL,m),this.current=m,this.dirty=!1}}class sP extends oo{getDefault(){return!1}set(m){if(m===this.current&&!this.dirty)return;const v=this.gl;v.pixelStorei(v.UNPACK_FLIP_Y_WEBGL,m),this.current=m,this.dirty=!1}}class Zw extends oo{constructor(m,v){super(m),this.context=m,this.parent=v}getDefault(){return null}}class H1 extends Zw{constructor(m,v,E=0){super(m,v),this.attachmentPoint=m.gl.COLOR_ATTACHMENT0+E}setDirty(){this.dirty=!0}set(m){if(m===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const v=this.gl;v.framebufferTexture2D(v.FRAMEBUFFER,this.attachmentPoint,v.TEXTURE_2D,m,0),this.current=m,this.dirty=!1}}class rP extends Zw{attachment(){return this.gl.DEPTH_ATTACHMENT}set(m){if(m===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const v=this.gl;v.framebufferRenderbuffer(v.FRAMEBUFFER,this.attachment(),v.RENDERBUFFER,m),this.current=m,this.dirty=!1}}class QO extends Zw{attachment(){return this.gl.DEPTH_ATTACHMENT}set(m){if(m===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const v=this.gl;v.framebufferTexture2D(v.FRAMEBUFFER,this.attachment(),v.TEXTURE_2D,m,0),this.current=m,this.dirty=!1}}class vpe extends rP{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const Yw=(M,m,v,E)=>({u_matrix:M,u_image0:0,u_image1:1,u_skirt_height:m,u_ground_shadow_factor:v,u_emissive_texture_available:E}),G1=(M,m,v,E,D,z,$,K,ee,ne,de,we,be,Ae,ze,Le,rt)=>({u_proj_matrix:Float32Array.from(M),u_globe_matrix:m,u_normalize_matrix:Float32Array.from(E),u_merc_matrix:v,u_zoom_transition:D,u_merc_center:z,u_image0:0,u_image1:1,u_frustum_tl:$,u_frustum_tr:K,u_frustum_br:ee,u_frustum_bl:ne,u_globe_pos:de,u_globe_radius:we,u_viewport:be,u_grid_matrix:rt?Float32Array.from(rt):new Float32Array(9),u_skirt_height:Ae,u_far_z_cutoff:ze,u_emissive_texture_available:Le});function nP(M,m){return M!=null&&m!=null&&!(!M.hasData()||!m.hasData())&&M.demTexture!=null&&m.demTexture!=null&&M.tileID.key!==m.tileID.key}const Ad=new class{constructor(){this.operations={}}newMorphing(M,m,v,E,D){if(M in this.operations){const z=this.operations[M];z.to.tileID.key!==v.tileID.key&&(z.queued=v)}else this.operations[M]={startTime:E,phase:0,duration:D,from:m,to:v,queued:null}}getMorphValuesForProxy(M){if(!(M in this.operations))return null;const m=this.operations[M];return{from:m.from,to:m.to,phase:m.phase}}update(M){for(const m in this.operations){const v=this.operations[m];for(v.phase=(M-v.startTime)/v.duration;v.phase>=1||!this._validOp(v);)if(!this._nextOp(v,M)){delete this.operations[m];break}}}_nextOp(M,m){return!!M.queued&&(M.from=M.to,M.to=M.queued,M.queued=null,M.phase=0,M.startTime=m,!0)}_validOp(M){return M.from.hasData()&&M.to.hasData()}},XC={0:null,1:"TERRAIN_VERTEX_MORPHING"};function Xw(M,m,v){if(m===0)return 0;const E=m<1&&v===514?.25/m:1;return 6*Math.pow(1.5,22-M)*Math.max(m,1)*E}function QC(M,m){const v=1<({u_matrix:M});function e2(M,m,v,E,D){if(D>0){const z=i.o.now(),$=(z-M.timeAdded)/D,K=m?(z-m.timeAdded)/D:-1,ee=v.getSource(),ne=E.coveringZoomLevel({tileSize:ee.tileSize,roundZoom:ee.roundZoom}),de=!m||Math.abs(m.tileID.overscaledZ-ne)>Math.abs(M.tileID.overscaledZ-ne),we=de&&M.refreshedUponExpiration?1:i.aC(de?$:1-K,0,1);return m?{opacity:1,mix:1-we,isFading:$<1}:{opacity:we,mix:0,isFading:$<1}}return{opacity:1,mix:0,isFading:!1}}class JC extends yh{constructor(m){const v={type:"raster-dem",maxzoom:Math.ceil(m.transform.maxZoom)},E=Sp("mock-dem",v,m.style.dispatcher,m.style);super("mock-dem",E,null),E.setEventedParent(this),this._sourceLoaded=!0}_loadTile(m,v){m.state="loaded",v(null)}}class aP extends yh{constructor(m){const v=Sp("proxy",{type:"geojson",maxzoom:Math.ceil(m.transform.maxZoom)},m.style.dispatcher,m.style);super("proxy",v,null),v.setEventedParent(this),this.map=this.getSource().map=m,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(m,v,E){if(m.freezeTileCoverage)return;this.transform=m;const D=m.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((z,$)=>{if(z[$.key]="",!this._tiles[$.key]){const K=new i.b0($,this._source.tileSize*$.overscaleFactor(),m.tileZoom,void 0,void 0,this._source.worldview);K.state="loaded",this._tiles[$.key]=K}return z},{});for(const z in this._tiles)z in D||(this.freeFBO(z),this._tiles[z].unloadVectorData(),delete this._tiles[z])}freeFBO(m){const v=this.proxyCachedFBO[m];if(v!==void 0){const E=Object.values(v);this.renderCachePool.push(...E),delete this.proxyCachedFBO[m]}}deallocRenderCache(){this.renderCache.forEach(m=>m.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class e3 extends i.aR{constructor(m,v,E){super(m.overscaledZ,m.wrap,m.canonical.z,m.canonical.x,m.canonical.y),this.proxyTileKey=v,this.projMatrix=E}}class t2 extends i.bu{constructor(m,v){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},this.painter=m,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[E,D,z]=function(){const ee=new i.dB,ne=new i.dC,de=131;ee.reserve(17161),ne.reserve(33800);const we=i.an/128,be=i.an+we/2,Ae=be+we;for(let Le=-we;Lebe||Le<0||Le>be?24575:0,dt=i.aC(Math.round(rt),0,i.an),pt=i.aC(Math.round(Le),0,i.an);ee.emplaceBack(dt+st,pt)}const ze=(Le,rt)=>{const st=rt*de+Le;ne.emplaceBack(st+1,st,st+de),ne.emplaceBack(st+de,st+de+1,st+1)};for(let Le=1;Le<129;Le++)for(let rt=1;rt<129;rt++)ze(rt,Le);return[0,129].forEach(Le=>{for(let rt=0;rt<130;rt++)ze(rt,Le),ze(Le,rt)}),[ee,ne,32768]}(),$=m.context;this.gridBuffer=$.createVertexBuffer(E,i.dx.members),this.gridIndexBuffer=$.createIndexBuffer(D),this.gridSegments=i.dy.simpleSegment(0,0,E.length,D.length),this.gridNoSkirtSegments=i.dy.simpleSegment(0,0,E.length,z),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new aP(v.map),this.orthoMatrix=i.bb(),i.bT(this.orthoMatrix,this.painter.transform.projection.name==="globe"?.015:0,i.an,0,i.an,0,1);const K=$.gl;this._overlapStencilMode=new dn({func:K.GEQUAL,mask:255},0,255,K.KEEP,K.KEEP,K.REPLACE),this._previousZoom=m.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=v,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new JC(v.map),this._pendingGroundEffectLayers=[],this._emissiveTexture=!1}set style(m){m.on("data",this._onStyleDataEvent.bind(this)),this._style=m,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(m,v,E){if(m&&m.terrain){this._style!==m&&(this.style=m,this._evaluationZoom=void 0);const D=m.terrain.properties,z=m.terrain.drapeRenderMode===0,$=m.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=i.o.now();const K=m.terrain&&m.terrain.scope,ee=D.get("source"),ne=z?this._mockSourceCache:m.getSourceCache(ee,K);if(!ne)return void i.w(`Couldn't find terrain source "${ee}".`);if(this.sourceCache=ne,this._attenuationRange=m.terrain.getAttenuationRange(),this._exaggeration=$?this.calculateExaggeration(v):D.get("exaggeration"),!v.projection.requiresDraping&&$&&this._exaggeration===0)return void this._disable();this.enabled=!0;const de=()=>{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,de(),this._initializing=!0),de(),v.updateElevation(!0,E),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(v),this._emptyDEMTextureDirty=!0,this._previousZoom=v.zoom}else this._disable()}calculateExaggeration(m){if(this._attenuationRange&&m.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(m.zoom);const v=this._previousCameraAltitude,E=m.getFreeCameraOptions().position.z/m.pixelsPerMeter*m.worldSize;this._previousCameraAltitude=E;const D=v!=null?E-v:Number.MAX_VALUE;if(Math.abs(D)<2)return this._exaggeration;const z=m.zoom,$=this._style.terrain;if(!this._previousUpdateTimestamp)return $.getExaggeration(z);let K=z-this._previousZoom;const ee=this._previousUpdateTimestamp;let ne=z;this._evaluationZoom!=null&&(ne=this._evaluationZoom,Math.abs(z-ne)>.5&&(K=.5*(z-ne+K)),K*D<0&&(ne+=K)),this._evaluationZoom=ne;const de=$.getExaggeration(ne),we=de===$.getExaggeration(Math.max(0,ne-.1));if(we&&Math.abs(de-this._exaggeration)<.01)return de;let be=Math.min(.1,.00375*(this._updateTimestamp-ee));return(we||de<.1||Math.abs(K)<1e-4)&&(be=Math.min(.2,4*be)),i.am(this._exaggeration,de,be)}resetTileLookupCache(m){this._findCoveringTileCache[m]={}}attenuationRange(){return this._attenuationRange}getDemUpscale(){return this.proxySourceCache.getSource().tileSize/128}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(m){m.dataType==="source"&&m.coord?this._clearRenderCacheForTile(m.sourceCacheId,m.coord):m.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 m in this._style._mergedSourceCaches)this._style._mergedSourceCaches[m].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this.pool.forEach(m=>m.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 m=2*this.proxySourceCache.getSource().tileSize;return[m,m]}set useVertexMorphing(m){this._useVertexMorphing=m}updateTileBinding(m){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const v=this.proxySourceCache,E=this.painter.transform;this._initializing&&(this._initializing=E._centerAltitude===0&&this.getAtPointOrZero(i.ag.fromLngLat(E.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const D=this.proxyCoords=v.getIds().map(ee=>{const ne=v.getTileByID(ee).tileID;return ne.projMatrix=E.calculateProjMatrix(ne.toUnwrapped()),ne});(function(ee,ne){const de=ne.transform.pointCoordinate(ne.transform.getCameraPoint()),we=new i.P(de.x,de.y);ee.sort((be,Ae)=>{if(Ae.overscaledZ-be.overscaledZ)return Ae.overscaledZ-be.overscaledZ;const ze=new i.P(be.canonical.x+(1<{this.proxyToSource[ee.key]={}}),this.terrainTileForTile={};const $=this._style._mergedSourceCaches;for(const ee in $){const ne=$[ee];if(!ne.used||(ne!==this.sourceCache&&this.resetTileLookupCache(ne.id),this._setupProxiedCoordsForOrtho(ne,m[ee],z),ne.usedForTerrain))continue;const de=m[ee];(ne.getSource().reparseOverscaled||ne._isRasterElevatedOverTerrain)&&this._assignTerrainTiles(de)}this.proxiedCoords[v.id]=D.map(ee=>new e3(ee,ee.key,this.orthoMatrix)),this._assignTerrainTiles(D),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(z),this.renderingToTexture=!1;const K={};this._visibleDemTiles=[];for(const ee of this.proxyCoords){const ne=this.terrainTileForTile[ee.key];if(!ne)continue;const de=ne.tileID.key;de in K||(this._visibleDemTiles.push(ne),K[de]=de)}}_assignTerrainTiles(m){this._initializing||m.forEach(v=>{if(this.terrainTileForTile[v.key])return;const E=this._findTileCoveringTileID(v,this.sourceCache);E&&(this.terrainTileForTile[v.key]=E)})}_prepareDEMTextures(){const m=this.painter.context,v=m.gl;for(const E in this.terrainTileForTile){const D=this.terrainTileForTile[E],z=D.dem;!z||D.demTexture&&!D.needsDEMTextureUpload||(m.activeTexture.set(v.TEXTURE1),UO(this.painter,D,z))}}_prepareDemTileUniforms(m,v,E,D){if(!v||v.demTexture==null)return!1;const z=m.tileID.canonical,$=Math.pow(2,v.tileID.canonical.z-z.z),K=D||"";return E[`u_dem_tl${K}`]=[z.x*$%1,z.y*$%1],E[`u_dem_scale${K}`]=$,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let m=0;const v=this._visibleDemTiles.reduce((E,D)=>{if(!D.dem)return E;const z=D.dem.tree.minimums[0];return z>0&&m++,E+z},0);return m?v/m:0}_updateEmptyDEMTexture(){const m=this.painter.context,v=m.gl;m.activeTexture.set(v.TEXTURE2);const E=this._getLoadedAreaMinimum(),D=new i.dz({width:1,height:1},new Float32Array([E]));this._emptyDEMTextureDirty=!1;let z=this._emptyDEMTexture;return z?z.update(D,{premultiply:!1}):z=this._emptyDEMTexture=new i.T(m,D,v.R32F,{premultiply:!1}),z}setupElevationDraw(m,v,E){const D=this.painter.context,z=D.gl,$={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};$.u_exaggeration=this.exaggeration();let K=null,ee=null,ne=1;if(E&&E.morphing&&this._useVertexMorphing){const Ae=E.morphing.srcDemTile,ze=E.morphing.dstDemTile;ne=E.morphing.phase,Ae&&ze&&(this._prepareDemTileUniforms(m,Ae,$,"_prev")&&(ee=Ae),this._prepareDemTileUniforms(m,ze,$)&&(K=ze))}const de=Ae=>Ae&&Ae.demTexture&&this.painter.linearFloatFilteringSupported()?z.LINEAR:z.NEAREST;let we=null;var be;if(this.enabled?ee&&K?(we=K.demTexture,D.activeTexture.set(z.TEXTURE4),ee.demTexture.bind(de(ee),z.CLAMP_TO_EDGE),$.u_dem_lerp=ne):(K=this.terrainTileForTile[m.tileID.key],we=this._prepareDemTileUniforms(m,K,$)?K.demTexture:this.emptyDEMTexture):we=this.emptyDEMTexture,D.activeTexture.set(z.TEXTURE2),we&&($.u_dem_size=(be=we).size[0]===1?1:be.size[0]-2,we.bind(de(K),z.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(E&&E.useDepthForOcclusion,v,$),E&&E.useMeterToDem&&K){const Ae=(1<{if(st===Jt)return;const Cs=[XC[Jt],"PROJECTION_GLOBE_VIEW"];pt&&Cs.push("CUSTOM_ANTIALIASING");const Ls=ne.isTileAffectedByFog(ns);rt=ne.getOrCreateProgram("globeRaster",{defines:Cs,overrideFog:Ls}),st=Jt},Bt=ne.colorModeForRenderPass(),wt=new Sr(Le.LEQUAL,Sr.ReadWrite,ne.depthRangeFor3D);Ad.update(Ae);const Ft=i.dq(dt),ft=[i.aH(dt.center.lng),i.aL(dt.center.lat)],_t=ne.globeSharedBuffers,Et=[dt.width*i.o.devicePixelRatio,dt.height*i.o.devicePixelRatio],Kt=Float32Array.from(dt.globeMatrix),qt={useDenormalizedUpVectorScale:!0};{const ns=ne.transform,Jt=Xw(ns.zoom,de.exaggeration(),de.sourceCache._source.tileSize);st=-1;const Cs=Le.TRIANGLES;for(const Ls of be){const Zt=we.getTile(Ls),Ht=dn.disabled,ss=de.prevTerrainTileForTile[Ls.key],is=de.terrainTileForTile[Ls.key];nP(ss,is)&&Ad.newMorphing(Ls.key,ss,is,Ae,250),Qw(ne,Zt.emissiveTexture),ze.activeTexture.set(Le.TEXTURE0),Zt.texture&&Zt.texture.bind(Le.LINEAR,Le.CLAMP_TO_EDGE);const hs=Ad.getMorphValuesForProxy(Ls.key),Qs=hs?1:0;hs&&Object.assign(qt,{morphing:{srcDemTile:hs.from,dstDemTile:hs.to,phase:i.dn(hs.phase)}});const Ws=i.dr(Ls.canonical),Ks=i.ds(Ws.getCenter().lat),As=i.dt(Ls.canonical,Ws,Ks,ns.worldSize/ns._pixelsPerMercatorPixel),jr=i.du(i.dv(Ls.canonical)),Pr=ne.emissiveMode==="mrt-fallback"?1:0,pr=G1(ns.expandedFarZProjMatrix,Kt,Ft,jr,i.al(ns.zoom),ft,ns.frustumCorners.TL,ns.frustumCorners.TR,ns.frustumCorners.BR,ns.frustumCorners.BL,ns.globeCenterInViewSpace,ns.globeRadius,Et,Jt,ns._farZ,Pr,As);if(at(Ls,Qs),rt&&(de.setupElevationDraw(Zt,rt,qt),ne.uploadCommonUniforms(ze,rt,Ls.toUnwrapped()),_t)){const[br,Qr,bn]=_t.getGridBuffers(Ks,Jt!==0);rt.draw(ne,Cs,wt,Ht,Bt,Xr.backCCW,pr,"globe_raster",br,Qr,bn)}}}if(_t&&(ne.renderDefaultNorthPole||ne.renderDefaultSouthPole)){const ns=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];pt&&ns.push("CUSTOM_ANTIALIASING"),rt=ne.getOrCreateProgram("globeRaster",{defines:ns});for(const Jt of be){const{x:Cs,y:Ls,z:Zt}=Jt.canonical,Ht=Ls===0,ss=Ls===(1<br.draw(ne,Le.TRIANGLES,wt,dn.disabled,Bt,Xr.disabled,G1(dt.expandedFarZProjMatrix,As,As,jr,0,ft,dt.frustumCorners.TL,dt.frustumCorners.TR,dt.frustumCorners.BR,dt.frustumCorners.BL,dt.globeCenterInViewSpace,dt.globeRadius,Et,0,dt._farZ,Pr),"globe_pole_raster",Qr,Qs,Ws);de.setupElevationDraw(Ks,rt,qt),ne.uploadCommonUniforms(ze,rt,Jt.toUnwrapped()),Ht&&ne.renderDefaultNorthPole&&pr(rt,is),ss&&ne.renderDefaultSouthPole&&(As=i.cC(i.bb(),As,[1,-1,1]),pr(rt,hs))}}}})(D,z,$,K,ee);else{const ne=D.context,de=ne.gl;let we,be;const Ae=D.shadowRenderer,ze=oc(D,D.longestCutoffRange),Le=Bt=>{if(be===Bt)return;const wt=[];wt.push(XC[Bt]),ze.shouldRenderCutoff&&wt.push("RENDER_CUTOFF"),Ae&&(wt.push("RENDER_SHADOWS"),Ae.useNormalOffset&&wt.push("NORMAL_OFFSET")),we=D.getOrCreateProgram("terrainRaster",{defines:wt}),be=Bt},rt=D.colorModeForRenderPass(),st=new Sr(de.LEQUAL,Sr.ReadWrite,D.depthRangeFor3D);Ad.update(ee);const dt=D.transform,pt=Xw(dt.zoom,z.exaggeration(),z.sourceCache._source.tileSize);let at=[0,0,0];if(Ae){const Bt=D.style.directionalLight,wt=D.style.ambientLight;Bt&&wt&&(at=Ap(D.style,Bt,wt))}{be=-1;const Bt=de.TRIANGLES,[wt,Ft]=[z.gridIndexBuffer,z.gridSegments];for(const ft of K){const _t=$.getTile(ft),Et=dn.disabled,Kt=z.prevTerrainTileForTile[ft.key],qt=z.terrainTileForTile[ft.key];nP(Kt,qt)&&Ad.newMorphing(ft.key,Kt,qt,ee,250),Qw(D,_t.emissiveTexture),ne.activeTexture.set(de.TEXTURE0),_t.texture&&_t.texture.bind(de.LINEAR,de.CLAMP_TO_EDGE);const ns=Ad.getMorphValuesForProxy(ft.key),Jt=ns?1:0;let Cs;ns&&(Cs={morphing:{srcDemTile:ns.from,dstDemTile:ns.to,phase:i.dn(ns.phase)}});const Ls=D.emissiveMode==="mrt-fallback"?1:0,Zt=Yw(ft.projMatrix,QC(ft.canonical,dt.renderWorldCopies)?pt/10:pt,at,Ls);if(Le(Jt),!we)continue;z.setupElevationDraw(_t,we,Cs);const Ht=ft.toUnwrapped();Ae&&Ae.setupShadows(Ht,we),D.uploadCommonUniforms(ne,we,Ht,null,ze),we.draw(D,Bt,st,Et,rt,Xr.backCCW,Zt,"terrain_raster",z.gridBuffer,wt,Ft)}}}}(v,this,this.proxySourceCache,m,this._updateTimestamp),this.renderingToTexture=!0,v.gpuTimingDeferredRenderEnd(),m.splice(0,m.length))}renderBatch(m){if(this._drapedRenderBatches.length===0)return m+1;this.renderingToTexture=!0;const v=this.painter,E=this.painter.context,D=this.proxySourceCache,z=this.proxiedCoords[D.id],$=this._drapedRenderBatches.shift(),K=v.style.order,ee=[];this._updateFBOs(v.emissiveMode==="mrt-fallback");let ne=0;for(const de of z){const we=D.getTileByID(de.proxyTileKey),be=D.proxyCachedFBO[de.key]?D.proxyCachedFBO[de.key][m]:void 0,Ae=be!==void 0?D.renderCache[be]:this.pool[ne++],ze=be!==void 0;if(we.texture=Ae.tex,we.emissiveTexture=Ae.emissiveTex,ze&&!Ae.dirty){ee.push(we.tileID);continue}E.bindFramebuffer.set(Ae.fb.framebuffer);const Le=E.gl;let rt;Le.drawBuffers(v.emissiveMode==="mrt-fallback"?[Le.COLOR_ATTACHMENT0,Le.COLOR_ATTACHMENT1]:[Le.COLOR_ATTACHMENT0]),this.renderedToTile=!1,Ae.dirty&&(E.clear({color:i.aq.transparent,stencil:0}),Ae.dirty=!1);for(let st=$.start;st<=$.end;++st){const dt=v.style._mergedLayers[K[st]];if(dt.isHidden(v.transform.zoom))continue;const pt=v.style.getLayerSourceCache(dt),at=pt?this.proxyToSource[de.key][pt.id]:[de];if(!at)continue;const Bt=at;E.viewport.set([0,0,Ae.fb.width,Ae.fb.height]),rt!==(pt?pt.id:null)&&(this._setupStencil(Ae,at,dt,pt),rt=pt?pt.id:null),v.renderLayer(v,pt,dt,Bt)}if(Le.drawBuffers([Le.COLOR_ATTACHMENT0]),this._drapedRenderBatches.length===0)for(const st of this._pendingGroundEffectLayers){const dt=v.style._mergedLayers[K[st]];if(dt.isHidden(v.transform.zoom))continue;const pt=v.style.getLayerSourceCache(dt),at=pt?this.proxyToSource[de.key][pt.id]:[de];if(!at)continue;const Bt=at;E.viewport.set([0,0,Ae.fb.width,Ae.fb.height]),rt!==(pt?pt.id:null)&&(this._setupStencil(Ae,at,dt,pt),rt=pt?pt.id:null),v.renderLayer(v,pt,dt,Bt)}this.renderedToTile?(Ae.dirty=!0,ee.push(we.tileID)):ze||--ne,ne===5&&(ne=0,this.renderToBackBuffer(ee))}return this.renderToBackBuffer(ee),this.renderingToTexture=!1,E.bindFramebuffer.set(null),E.viewport.set([0,0,v.width,v.height]),$.end+1}postRender(){}isLayerOrderingCorrect(m){const v=m.order.length;let E=-1,D=v;for(let z=0;zE}getMinElevationBelowMSL(){let m=0;return this._visibleDemTiles.filter(v=>v.dem).forEach(v=>{m=Math.min(m,v.dem.tree.minimums[0])}),m===0?m:(m-30)*this._exaggeration}raycast(m,v,E){if(!this._visibleDemTiles)return null;const D=this._visibleDemTiles.filter(z=>z.dem).map(z=>{const $=z.tileID,K=1<<$.overscaledZ,{x:ee,y:ne}=$.canonical,de=ee/K,we=(ee+1)/K,be=ne/K,Ae=(ne+1)/K;return{minx:de,miny:be,maxx:we,maxy:Ae,t:z.dem.tree.raycastRoot(de,be,we,Ae,m,v,E),tile:z}});D.sort((z,$)=>(z.t!==null?z.t:Number.MAX_VALUE)-($.t!==null?$.t:Number.MAX_VALUE));for(const z of D){if(z.t==null)return null;const $=z.tile.dem.tree.raycast(z.minx,z.miny,z.maxx,z.maxy,m,v,E);if($!=null)return $}return null}_createFBO(){const m=this.painter.context,v=m.gl,E=this.drapeBufferSize;m.activeTexture.set(v.TEXTURE0);const D=new i.T(m,{width:E[0],height:E[1],data:null},v.RGBA8);D.bind(v.LINEAR,v.CLAMP_TO_EDGE);const z=m.createFramebuffer(E[0],E[1],1,null);let $;return z.colorAttachment0.set(D.texture),this._emissiveTexture&&($=new i.T(m,{width:E[0],height:E[1],data:null},v.R8),$.bind(v.LINEAR,v.CLAMP_TO_EDGE),z.createColorAttachment(m,1),z.colorAttachment1.set($.texture)),z.depthAttachment=new vpe(m,z.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=m.createRenderbuffer(m.gl.DEPTH_STENCIL,E[0],E[1]),this._stencilRef=0,z.depthAttachment.set(this._sharedDepthStencil),m.clear({stencil:0})):z.depthAttachment.set(this._sharedDepthStencil),m.extTextureFilterAnisotropic&&v.texParameterf(v.TEXTURE_2D,m.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,m.extTextureFilterAnisotropicMax),{fb:z,tex:D,emissiveTex:$,dirty:!1}}_updateFBOs(m){if(this._emissiveTexture!==m){for(const v of this.pool)this._updateFBO(v,m);for(const v of this.proxySourceCache.renderCache)this._updateFBO(v,m);this._emissiveTexture=m}}_updateFBO(m,v){const E=m.fb,D=this.painter.context,z=D.gl,$=this.drapeBufferSize;if(v){const K=new i.T(D,{width:$[0],height:$[1],data:null},z.R8);K.bind(z.LINEAR,z.CLAMP_TO_EDGE),m.emissiveTex=K,E.createColorAttachment(D,1),E.colorAttachment1.set(K.texture)}else m.emissiveTex=void 0,E.removeColorAttachment(D,1);m.dirty=!0}_initFBOPool(){for(;this.pool.length{const v=this._style._mergedLayers[m],E=v.isHidden(this.painter.transform.zoom);return v.type==="hillshade"||v.type==="custom"?!E&&v.shouldRedrape():!E&&v.hasTransition()})}_clearLineLayersFromRenderCache(){let m=!1;for(const E of this._style.getSources())if(E instanceof Cd){m=!0;break}if(!m)return;const v={};for(let E=0;Eee>K.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=E}_setupRenderCache(m){const v=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,v.renderCache.length>v.renderCachePool.length){const $=Object.values(v.proxyCachedFBO);v.proxyCachedFBO={};for(let K=0;K<$.length;++K){const ee=Object.values($[K]);v.renderCachePool.push(...ee)}}return}this._clearRasterLayersFromRenderCache();const E=this.proxyCoords,D=this._tilesDirty;for(let $=E.length-1;$>=0;$--){const K=E[$];if(v.getTileByID(K.key),v.proxyCachedFBO[K.key]!==void 0){const ee=m[K.key],ne=this.proxyToSource[K.key];let de=0;for(const we in ne){const be=ne[we],Ae=ee[we];if(!Ae||Ae.length!==be.length||be.some((ze,Le)=>ze!==Ae[Le]||D[we]&&D[we].hasOwnProperty(ze.key))){de=-1;break}++de}for(const we in v.proxyCachedFBO[K.key])v.renderCache[v.proxyCachedFBO[K.key][we]].dirty=de<0||de!==Object.values(ee).length}}const z=[...this._drapedRenderBatches];z.sort(($,K)=>K.end-K.start-($.end-$.start));for(const $ of z)for(const K of E){if(v.proxyCachedFBO[K.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[K.key]={},v.proxyCachedFBO[K.key][$.start]=ee,v.renderCache[ee].dirty=!0)}this._tilesDirty={}}_setupStencil(m,v,E,D){if(!D||!this._sourceTilesOverlap[D.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const z=this.painter.context,$=z.gl;if(v.length<=1)return void(this._overlapStencilType=!1);let K;if(E.isTileClipped())K=v.length,this._overlapStencilMode.test={func:$.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(v[0].overscaledZ>v[v.length-1].overscaledZ))return void(this._overlapStencilType=!1);K=1,this._overlapStencilMode.test={func:$.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+K>255&&(z.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=K,this._overlapStencilMode.ref=this._stencilRef,E.isTileClipped()&&this._renderTileClippingMasks(v,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(m){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[m.key]),this._overlapStencilMode):dn.disabled}_renderTileClippingMasks(m,v){const E=this.painter,D=this.painter.context,z=D.gl;E._tileClippingMaskIDs={},D.setColorMode(rn.disabled),D.setDepthMode(Sr.disabled);const $=E.getOrCreateProgram("clippingMask");for(const K of m){const ee=E._tileClippingMaskIDs[K.key]=--v;$.draw(E,z.TRIANGLES,Sr.disabled,new dn({func:z.ALWAYS,mask:0},ee,255,z.KEEP,z.KEEP,z.REPLACE),rn.disabled,Xr.disabled,Jw(K.projMatrix),"$clipping",E.tileExtentBuffer,E.quadTriangleIndexBuffer,E.tileExtentSegments)}}pointCoordinate(m){const v=this.painter.transform;if(m.x<0||m.x>v.width||m.y<0||m.y>v.height)return null;const E=[m.x,m.y,1,1];i.aE(E,E,v.pixelMatrixInverse),i.cu(E,E,1/E[3]),E[0]/=v.worldSize,E[1]/=v.worldSize;const D=v._camera.position,z=i.bU(1,v.center.lat),$=[D[0],D[1],D[2]/z,0],K=i.cV([],E.slice(0,3),$);i.ay(K,K);const ee=this.raycast($,K,this._exaggeration);return ee!==null&&ee?(i.bg($,$,K,ee),$[3]=$[2],$[2]*=z,$):null}_setupProxiedCoordsForOrtho(m,v,E){if(m.getSource()instanceof i.aV)return this._setupProxiedCoordsForImageSource(m,v,E);this._findCoveringTileCache[m.id]=this._findCoveringTileCache[m.id]||{};const D=this.proxiedCoords[m.id]=[],z=this.proxyCoords;for(let ee=0;eede.overscaledZ-ne.overscaledZ)}_setupProxiedCoordsForImageSource(m,v,E){if(!m.getSource().loaded())return;const D=this.proxiedCoords[m.id]=[],z=this.proxyCoords,$=m.getSource(),K=$.tileID;if(!K)return;const ee=new i.P(K.x,K.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)}),de=(we,be)=>{const Ae=we.wrap+we.canonical.x/(1<rt+ne.max.x||ze+Lest+ne.max.y};for(let we=0;we$.key===v.tileID.key);if(z)return z}if(v.tileID.key!==m.key){const z=m.canonical.z-v.tileID.canonical.z;let $,K,ee;D=i.bb();const ne=v.tileID.wrap-m.wrap<0?($=i.an>>z,K=$*((v.tileID.canonical.x<=we){const be=m.canonical.z-we;v.getSource().reparseOverscaled?(K=Math.max(m.canonical.z+2,v.transform.tileZoom),$=new i.aR(K,m.wrap,we,m.canonical.x>>be,m.canonical.y>>be)):be!==0&&(K=we,$=new i.aR(K,m.wrap,we,m.canonical.x>>be,m.canonical.y>>be))}$.key!==m.key&&(ne.push($.key),E=v.getTile($))}const de=we=>{ne.forEach(be=>{D[be]=we}),ne.length=0};for(K-=1;K>=ee&&(!E||!E.hasData());K--){E&&de(E.tileID.key);const we=$.calculateScaledKey(K);if(E=v.getTileByID(we),E&&E.hasData())break;const be=D[we];if(be===null)break;be===void 0?ne.push(we):E=v.getTileByID(be)}return de(E?E.tileID.key:null),E&&E.hasData()?E:null}findDEMTileFor(m){return this.enabled?this._findTileCoveringTileID(m,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(m,v){let E=this._tilesDirty[m];E||(E=this._tilesDirty[m]={}),E[v.key]=!0}}function iP(M,m,v){const E=function(K,ee,ne){const de=i.bi(ee,K),we=i.bi(ne,[.2126,.7152,.0722]),be=(ze,Le,rt)=>(1-rt)*ze+rt*Le,Ae=be(1-.3*Math.min(we,1),1,Math.min(de+1,1));return be(.92,1,Math.asin(i.aC(ee[2],-1,1))/Math.PI+.5)*Ae}(M,[0,0,1],m),D=[0,0,0];i.bJ(D,v.slice(0,3),E);const z=[0,0,0];i.bJ(z,m.slice(0,3),M[2]);const $=[0,0,0];return i.cT($,D,z),i.cW($)}const JO=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],eF=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class G0{static cacheKey(m,v,E,D){const z=[v];D&&z.push(D.cacheKey);for(const $ of E)(typeof $=="string"&&$.includes(" ")||m.usedDefines.has($))&&z.push($);return z.join("/")}constructor(m,v,E,D,z,$){const K=m.gl;this.program=K.createProgram(),this.configuration=D,this.name=v,this.fixedDefines=[...$];const ee=`#version 300 es ${(D?D.defines():[]).concat($.map(Le=>`#define ${Le}`)).join(` `)}`,ne=[ee,$1];for(const Le of E.fragmentIncludes)ne.push(Ep[Le]);ne.push(E.fragmentSource);const de=ne.join(` `),we=[ee,upe];for(const Le of E.vertexIncludes)we.push(Ep[Le]);this.forceManualRenderingForInstanceIDShaders=m.forceManualRenderingForInstanceIDShaders&&E.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&we.push("uniform int u_instanceID;"),we.push(E.vertexSource);let be=we.join(` `);this.forceManualRenderingForInstanceIDShaders&&(be=be.replaceAll("gl_InstanceID","u_instanceID"));const Ae=K.createShader(K.FRAGMENT_SHADER);if(K.isContextLost())return void(this.failedToCreate=!0);K.shaderSource(Ae,de),K.compileShader(Ae),K.attachShader(this.program,Ae);const ze=K.createShader(K.VERTEX_SHADER);K.isContextLost()?this.failedToCreate=!0:(K.shaderSource(ze,be),K.compileShader(ze),K.attachShader(this.program,ze),this.attributes={},K.linkProgram(this.program),K.deleteShader(ze),K.deleteShader(Ae),this.fixedUniforms=z(m),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=D?D.getUniforms(m):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(Le=>({u_instanceID:new i.bX(Le)}))(m)),($.includes("TERRAIN")||$.includes("ELEVATED")||v.includes("symbol")||v.includes("circle"))&&(this.terrainUniforms=(Le=>({u_dem:new i.bX(Le),u_dem_prev:new i.bX(Le),u_dem_tl:new i.b_(Le),u_dem_scale:new i.bZ(Le),u_dem_tl_prev:new i.b_(Le),u_dem_scale_prev:new i.bZ(Le),u_dem_size:new i.bZ(Le),u_dem_lerp:new i.bZ(Le),u_exaggeration:new i.bZ(Le),u_depth:new i.bX(Le),u_depth_size_inv:new i.b_(Le),u_depth_range_unpack:new i.b_(Le),u_occluder_half_size:new i.bZ(Le),u_occlusion_depth_offset:new i.bZ(Le),u_meter_to_dem:new i.bZ(Le),u_label_plane_matrix_inv:new i.b$(Le)}))(m)),$.includes("GLOBE")&&(this.globeUniforms=(Le=>({u_tile_tl_up:new i.bY(Le),u_tile_tr_up:new i.bY(Le),u_tile_br_up:new i.bY(Le),u_tile_bl_up:new i.bY(Le),u_tile_up_scale:new i.bZ(Le)}))(m)),$.includes("FOG")&&(this.fogUniforms=(Le=>({u_fog_matrix:new i.b$(Le),u_fog_range:new i.b_(Le),u_fog_color:new i.cO(Le),u_fog_horizon_blend:new i.bZ(Le),u_fog_vertical_limit:new i.b_(Le),u_fog_temporal_offset:new i.bZ(Le),u_frustum_tl:new i.bY(Le),u_frustum_tr:new i.bY(Le),u_frustum_br:new i.bY(Le),u_frustum_bl:new i.bY(Le),u_globe_pos:new i.bY(Le),u_globe_radius:new i.bZ(Le),u_globe_transition:new i.bZ(Le),u_is_globe:new i.bX(Le),u_viewport:new i.b_(Le)}))(m)),$.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(Le=>({u_cutoff_params:new i.cO(Le)}))(m)),$.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(Le=>({u_lighting_ambient_color:new i.bY(Le),u_lighting_directional_dir:new i.bY(Le),u_lighting_directional_color:new i.bY(Le),u_ground_radiance:new i.bY(Le)}))(m)),$.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(Le=>({u_light_matrix_0:new i.b$(Le),u_light_matrix_1:new i.b$(Le),u_fade_range:new i.b_(Le),u_shadow_normal_offset:new i.bY(Le),u_shadow_intensity:new i.bZ(Le),u_shadow_texel_size:new i.bZ(Le),u_shadow_map_resolution:new i.bZ(Le),u_shadow_direction:new i.bY(Le),u_shadow_bias:new i.bY(Le),u_shadowmap_0:new i.bX(Le),u_shadowmap_1:new i.bX(Le)}))(m)))}getAttributeLocation(m,v){let E=this.attributes[v];return E===void 0&&(E=this.attributes[v]=m.getAttribLocation(this.program,v)),E}setTerrainUniformValues(m,v){if(!this.terrainUniforms)return;const E=this.terrainUniforms;if(!this.failedToCreate){m.program.set(this.program);for(const D in v)E[D]&&E[D].set(this.program,D,v[D])}}setGlobeUniformValues(m,v){if(!this.globeUniforms)return;const E=this.globeUniforms;if(!this.failedToCreate){m.program.set(this.program);for(const D in v)E[D]&&E[D].set(this.program,D,v[D])}}setFogUniformValues(m,v){if(!this.fogUniforms)return;const E=this.fogUniforms;if(!this.failedToCreate){m.program.set(this.program);for(const D in v)E[D].set(this.program,D,v[D])}}setCutoffUniformValues(m,v){if(!this.cutoffUniforms)return;const E=this.cutoffUniforms;if(!this.failedToCreate){m.program.set(this.program);for(const D in v)E[D].set(this.program,D,v[D])}}setLightsUniformValues(m,v){if(!this.lightsUniforms)return;const E=this.lightsUniforms;if(!this.failedToCreate){m.program.set(this.program);for(const D in v)E[D].set(this.program,D,v[D])}}setShadowUniformValues(m,v){if(this.failedToCreate||!this.shadowUniforms)return;const E=this.shadowUniforms;m.program.set(this.program);for(const D in v)E[D].set(this.program,D,v[D])}_drawDebugWireframe(m,v,E,D,z,$,K,ee,ne,de){const we=m.options.wireframe;if(we.terrain===!1&&we.layers2D===!1&&we.layers3D===!1)return;const be=m.context;if(!(!(!we.terrain||this.name!=="terrainRaster"&&this.name!=="globeRaster")||!(!we.layers2D||m._terrain&&m._terrain.renderingToTexture||!JO.includes(this.name))||!(!we.layers3D||!eF.includes(this.name))))return;const Ae=be.gl,ze=m.wireframeDebugCache.getLinesFromTrianglesBuffer(m.frameCounter,z,be);if(!ze)return;const Le=[...this.fixedDefines,"DEBUG_WIREFRAME"],rt=m.getOrCreateProgram(this.name,{config:this.configuration,defines:Le});be.program.set(rt.program);const st=(at,Bt,wt)=>{if(Bt[at]&&wt[at])for(const Ft in Bt[at])wt[at][Ft]&&wt[at][Ft].set(wt.program,Ft,Bt[at][Ft].current)};ne&&ne.setUniforms(rt.program,be,rt.binderUniforms,K,{zoom:ee}),st("fixedUniforms",this,rt),st("terrainUniforms",this,rt),st("globeUniforms",this,rt),st("fogUniforms",this,rt),st("lightsUniforms",this,rt),st("shadowUniforms",this,rt),ze.bind(),be.setColorMode(new rn([Ae.ONE,Ae.ONE_MINUS_SRC_ALPHA,Ae.ZERO,Ae.ONE],i.aq.transparent,[!0,!0,!0,!1])),be.setDepthMode(new Sr(v.func===Ae.LESS?Ae.LEQUAL:v.func,Sr.ReadOnly,v.range)),be.setStencilMode(dn.disabled);const dt=3*$.primitiveLength*2,pt=3*$.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const at=de||1;for(let Bt=0;Bt1?Ae.drawElementsInstanced(Ae.LINES,dt,Ae.UNSIGNED_SHORT,pt,de):Ae.drawElements(Ae.LINES,dt,Ae.UNSIGNED_SHORT,pt);z.bind(),be.program.set(this.program),be.setDepthMode(v),be.setStencilMode(E),be.setColorMode(D)}checkUniforms(m,v,E){if(this.fixedDefines.includes(v)){for(const D of Object.keys(E))if(!E[D].initialized)throw new Error(`Program '${this.name}', from draw '${m}': uniform ${D} not set but required by ${v} being defined`)}}draw(m,v,E,D,z,$,K,ee,ne,de,we,be,Ae,ze,Le,rt){const st=m.context,dt=st.gl;if(this.failedToCreate)return;st.program.set(this.program),st.setDepthMode(E),st.setStencilMode(D),st.setColorMode(z),st.setCullFace($);for(const[ft,_t]of this.fixedUniformsEntries)_t.set(this.program,ft,K[ft]);ze&&ze.setUniforms(this.program,st,this.binderUniforms,be,{zoom:Ae});const pt={[dt.POINTS]:1,[dt.LINES]:2,[dt.TRIANGLES]:3,[dt.LINE_STRIP]:1}[v];this.checkUniforms(ee,"RENDER_SHADOWS",this.shadowUniforms);const at=Le||[],Bt=ze?ze.getPaintVertexBuffers():[],wt=v===dt.TRIANGLES&&de,Ft=rt&&rt>0?1:void 0;for(const ft of we.get()){const _t=ft.vaos||(ft.vaos={});if((_t[ee]||(_t[ee]=new qO)).bind(st,this,ne,Bt,de,ft.vertexOffset,at,Ft),this.forceManualRenderingForInstanceIDShaders){const Et=rt||1;for(let Kt=0;Kt1?dt.drawElementsInstanced(v,ft.primitiveLength*pt,dt.UNSIGNED_SHORT,ft.primitiveOffset*pt*2,rt):de?dt.drawElements(v,ft.primitiveLength*pt,dt.UNSIGNED_SHORT,ft.primitiveOffset*pt*2):dt.drawArrays(v,ft.vertexOffset,ft.vertexLength);wt&&this._drawDebugWireframe(m,E,D,z,de,ft,be,Ae,ze,rt)}}}function tF(M,m,v=0){const E=Math.pow(2,m.tileID.overscaledZ),D=m.tileSize*Math.pow(2,M.transform.tileZoom)/E,z=D*(m.tileID.canonical.x+m.tileID.wrap*E),$=D*m.tileID.canonical.y;return{u_image:0,u_texsize:m.imageAtlasTexture?m.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/i.aA(m,1,M.transform.tileZoom),u_pixel_coord_upper:[z>>16,$>>16],u_pixel_coord_lower:[65535&z,65535&$],u_pattern_transition:v}}const t3={terrain:0,flat:1},_pe=i.bb(),sF=(M,m,v,E,D,z,$,K,ee,ne,de,we,be,Ae,ze,Le,rt,st,dt=[0,0,1])=>{const pt=m.style.light,at=pt.properties.get("position"),Bt=[at.x,at.y,at.z],wt=i.dE();pt.properties.get("anchor")==="viewport"&&(i.dF(wt,-m.transform.angle),i.dG(Bt,Bt,wt));const Ft=pt.properties.get("color").toPremultipliedRenderColor(null),ft=m.transform,_t={u_matrix:M,u_lightpos:Bt,u_lightintensity:pt.properties.get("intensity"),u_lightcolor:[Ft.r,Ft.g,Ft.b],u_vertical_gradient:+v,u_opacity:E,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:_pe,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:t3[ne],u_base_type:t3[de],u_ao:D,u_edge_radius:z,u_width_scale:$,u_flood_light_color:ze,u_vertical_scale:Le,u_flood_light_intensity:rt,u_ground_shadow_factor:st,u_front_cutoff_params:dt};return ft.projection.name==="globe"&&(_t.u_tile_id=[K.canonical.x,K.canonical.y,1<({u_matrix:M,u_edge_radius:m,u_width_scale:v,u_vertical_scale:E,u_height_type:t3[D],u_base_type:t3[z]}),wpe=(M,m,v,E,D,z,$,K,ee,ne,de,we,be,Ae,ze,Le,rt,st)=>{const dt=sF(M,m,v,E,D,z,$,K,ne,de,we,be,Ae,ze,Le,rt,1,[0,0,0]),pt={u_height_factor:-Math.pow(2,K.overscaledZ)/ee.tileSize/8};return Object.assign(dt,tF(m,ee,st),pt)},s3=(M,m,v)=>({u_matrix:M,u_emissive_strength:m,u_ground_shadow_factor:v}),r3=(M,m,v,E,D,z=0)=>Object.assign(s3(M,m,D),tF(v,E,z)),rF=(M,m,v,E)=>({u_matrix:M,u_world:v,u_emissive_strength:m,u_ground_shadow_factor:E}),W1=(M,m,v,E,D,z,$=0)=>Object.assign(r3(M,m,v,E,z,$),{u_world:D}),nF=(M,m)=>({u_matrix:M,u_depth_bias:m}),aF=(M,m)=>({u_matrix:M,u_ground_shadow_factor:m}),s2=(M,m,v,E,D)=>({u_matrix:M,u_camera_pos:[m[0],m[1],m[2]],u_depth_bias:v,u_height_scale:E,u_reset_depth:D}),n3=(M,m,v)=>({u_image:M,u_opacity:m,u_blend_mode:v}),oy=(M,m,v,E,D,z,$,K,ee,ne=[0,0,1])=>({u_matrix:M,u_normal_matrix:m,u_opacity:v,u_faux_facade_ao_intensity:E,u_camera_pos:D,u_tile_to_meter:z,u_facade_emissive_chance:$,u_flood_light_color:K,u_flood_light_intensity:ee,u_front_cutoff_params:ne}),a3=M=>({u_matrix:M}),i3=M=>({u_matrix:M}),iF=(M,m,v,E,D,z,$,K)=>{const ee=i.an/z.tileSize;return{u_matrix:M,u_inv_rot_matrix:m,u_camera_to_center_distance:v.getCameraToCenterDistance(K),u_extrude_scale:[v.pixelsToGLUnits[0]/ee,v.pixelsToGLUnits[1]/ee],u_zoom_transition:E,u_tile_id:$,u_merc_center:D}},ly=(M,m,v,E)=>({u_matrix:M,u_inv_matrix:m,u_camera_to_center_distance:v.getCameraToCenterDistance(E),u_viewport_size:[v.width,v.height]}),r2=(M,m,v=1)=>({u_matrix:M,u_color:m,u_overlay:0,u_overlay_scale:v}),o3=i.bb(),oF=(M,m,v,E,D,z,$)=>{const K=M.transform,ee=K.projection.name==="globe",ne=ee?i.dH(K.zoom,m.canonical)*K._pixelsPerMercatorPixel:i.aA(v,1,z),de={u_matrix:m.projMatrix,u_extrude_scale:ne,u_intensity:$,u_inv_rot_matrix:o3,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(ee){de.u_inv_rot_matrix=E,de.u_merc_center=D,de.u_tile_id=[m.canonical.x,m.canonical.y,1<({u_matrix:m,u_normalize_matrix:v,u_globe_matrix:E,u_merc_matrix:D,u_grid_matrix:z,u_tl_parent:$,u_scale_parent:de,u_fade_t:we.mix,u_opacity:we.opacity*be.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:be.paint.get("raster-brightness-min"),u_brightness_high:be.paint.get("raster-brightness-max"),u_saturation_factor:i.dJ(be.paint.get("raster-saturation")),u_contrast_factor:i.dI(be.paint.get("raster-contrast")),u_spin_weights:cF(be.paint.get("raster-hue-rotate")),u_perspective_transform:Ae,u_raster_elevation:ze,u_zoom_transition:K,u_merc_center:ee,u_cutoff_params:ne,u_colorization_mix:oP(i.dK,rt,dt),u_colorization_offset:l3(i.dK,st,dt),u_color_ramp:Le,u_texture_offset:[at/(pt+2*at),pt/(pt+2*at)],u_texture_res:[pt+2*at,pt+2*at],u_emissive_strength:Bt,u_zbias_factor:lP(M)});function cF(M){M*=Math.PI/180;const m=Math.sin(M),v=Math.cos(M);return[(2*v+1)/3,(-Math.sqrt(3)*m-v+1)/3,(Math.sqrt(3)*m-v+1)/3]}const Pf=.05,jpe=(M,m,v,E,D,z,$,K,ee,ne,de,we)=>({u_matrix:M,u_normalize_matrix:m,u_globe_matrix:v,u_merc_matrix:E,u_grid_matrix:D,u_tl_parent:z,u_scale_parent:ne,u_fade_t:de.mix,u_opacity:de.opacity,u_image0:0,u_image1:1,u_raster_elevation:we,u_zoom_transition:$,u_merc_center:K,u_cutoff_params:ee}),Npe=(M,m,v,E,D,z,$,K,ee,ne)=>({u_particle_texture:M,u_particle_texture_side_len:m,u_tile_offset:v,u_velocity:E,u_color_ramp:z,u_velocity_res:D,u_max_speed:$,u_uv_offset:K,u_data_scale:[255*ee[0],255*ee[1]],u_data_offset:ne,u_particle_pos_scale:1.1,u_particle_pos_offset:[Pf,Pf]}),dF=(M,m,v,E,D,z,$,K,ee,ne)=>({u_particle_texture:M,u_particle_texture_side_len:m,u_velocity:v,u_velocity_res:E,u_max_speed:D,u_speed_factor:z,u_reset_rate:$,u_rand_seed:Math.random(),u_uv_offset:K,u_data_scale:[255*ee[0],255*ee[1]],u_data_offset:ne,u_particle_pos_scale:1.1,u_particle_pos_offset:[Pf,Pf]}),uF=i.bb(),c3=(M,m,v,E,D,z,$,K,ee,ne,de,we,be,Ae,ze,Le,rt,st,dt,pt,at,Bt,wt,Ft)=>{const ft=D.transform,_t={u_is_size_zoom_constant:+(M==="constant"||M==="source"),u_is_size_feature_constant:+(M==="constant"||M==="camera"),u_size_t:m?m.uSizeT:0,u_size:m?m.uSize:0,u_camera_to_center_distance:ft.getCameraToCenterDistance(dt),u_rotate_symbol:+v,u_aspect_ratio:ft.width/ft.height,u_fade_change:D.options.fadeDuration?D.symbolFadeChange:1,u_matrix:z,u_label_plane_matrix:$,u_coord_matrix:K,u_is_text:+ne,u_elevation_from_sea:ee?1:0,u_pitch_with_map:+E,u_texsize:de,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:uF,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:uF,u_up_vector:[0,-1,0],u_color_adj_mat:Bt,u_icon_transition:wt||0,u_gamma_scale:E?D.transform.getCameraToCenterDistance(dt)*Math.cos(D.terrain?0:D.transform._pitch):1,u_device_pixel_ratio:i.o.devicePixelRatio,u_is_halo:1,u_scale_factor:Ft||1,u_ground_shadow_factor:pt,u_inv_matrix:i.b7(i.bb(),$),u_normal_scale:at,u_lutTexture:10,u_zoom:ft.zoom-Math.floor(ft.zoom),u_spp_fill_np_color:[0,0,0,1],u_spp_halo_np_color:[0,0,0,0],u_spp_opacity:1,u_spp_halo_width:0,u_spp_halo_blur:0,u_spp_emissive_strength:0,u_spp_occlusion_opacity:1,u_spp_z_offset:0,u_spp_translate_rotation:[1,0]};return dt.name==="globe"&&(_t.u_tile_id=[Ae.canonical.x,Ae.canonical.y,1<({u_matrix:M,u_emissive_strength:m,u_opacity:v,u_color:E}),cy=(M,m,v,E,D,z,$,K,ee)=>Object.assign(function(ne,de,we,be,Ae,ze){const{width:Le,height:rt}=be.imageManager.getPixelSize(de),st=Math.pow(2,ze.tileID.overscaledZ),dt=ze.tileSize*Math.pow(2,be.transform.tileZoom)/st,pt=dt*(ze.tileID.canonical.x+ze.tileID.wrap*st),at=dt*ze.tileID.canonical.y;return{u_image:0,u_pattern_tl:we.tl,u_pattern_br:we.br,u_texsize:[Le,rt],u_pattern_size:we.displaySize,u_pattern_units_to_pixels:Ae?[be.transform.width,-1*be.transform.height]:[1/i.aA(ze,1,be.transform.tileZoom),1/i.aA(ze,1,be.transform.tileZoom)],u_pixel_coord_upper:[pt>>16,at>>16],u_pixel_coord_lower:[65535&pt,65535&at]}}(0,z,$,E,K,ee),{u_matrix:M,u_emissive_strength:m,u_opacity:v}),K1=new Float32Array(i.b9([])),W0=(M,m,v,E,D,z,$,K,ee,ne,de,we,be,Ae=[0,0,0],ze,Le,rt)=>{const st=D.style.light,dt=st.properties.get("position"),pt=[-dt.x,-dt.y,dt.z],at=i.dE();st.properties.get("anchor")==="viewport"&&(i.dF(at,-D.transform.angle),i.dG(pt,pt,at));const Bt=de.alphaMode==="MASK",wt=st.properties.get("color").toNonPremultipliedRenderColor(null),Ft=be.paint.get("model-ambient-occlusion-intensity"),ft=be.paint.get("model-color").constantOr(i.aq.white).toNonPremultipliedRenderColor(null);return ft.a=be.paint.get("model-color-mix-intensity").constantOr(0),rt&&(ft.r=rt[0],ft.g=rt[1],ft.b=rt[2],ft.a=rt[3]),Le&&(ft.r=Le.color.r,ft.g=Le.color.g,ft.b=Le.color.b,ft.a=Le.colorMix,we=Le.emissionStrength,z*=Le.opacity),{u_matrix:M,u_lighting_matrix:m,u_normal_matrix:v,u_node_matrix:E||K1,u_lightpos:pt,u_lightintensity:st.properties.get("intensity"),u_lightcolor:[wt.r,wt.g,wt.b],u_camera_pos:Ae,u_opacity:z,u_baseTextureIsAlpha:0,u_alphaMask:+Bt,u_alphaCutoff:de.alphaCutoff,u_baseColorFactor:$.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:K.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:ee,u_roughnessFactor:ne,u_baseColorTexture:5,u_metallicRoughnessTexture:6,u_normalTexture:7,u_occlusionTexture:8,u_emissionTexture:9,u_lutTexture:10,u_color_mix:ft.toArray01(),u_aoIntensity:Ft,u_emissive_strength:we,u_occlusionTextureTransform:ze||[0,0,0,0]}},cP=(M,m=K1,v=K1)=>({u_matrix:M,u_instance:m,u_node_matrix:v}),d3={fillExtrusion:M=>({u_matrix:new i.b$(M),u_lightpos:new i.bY(M),u_lightintensity:new i.bZ(M),u_lightcolor:new i.bY(M),u_vertical_gradient:new i.bZ(M),u_opacity:new i.bZ(M),u_edge_radius:new i.bZ(M),u_width_scale:new i.bZ(M),u_ao:new i.b_(M),u_height_type:new i.bX(M),u_base_type:new i.bX(M),u_tile_id:new i.bY(M),u_zoom_transition:new i.bZ(M),u_inv_rot_matrix:new i.b$(M),u_merc_center:new i.b_(M),u_up_dir:new i.bY(M),u_height_lift:new i.bZ(M),u_flood_light_color:new i.bY(M),u_vertical_scale:new i.bZ(M),u_flood_light_intensity:new i.bZ(M),u_ground_shadow_factor:new i.bY(M),u_front_cutoff_params:new i.bY(M)}),fillExtrusionDepth:M=>({u_matrix:new i.b$(M),u_edge_radius:new i.bZ(M),u_width_scale:new i.bZ(M),u_vertical_scale:new i.bZ(M),u_height_type:new i.bX(M),u_base_type:new i.bX(M)}),fillExtrusionPattern:M=>({u_matrix:new i.b$(M),u_lightpos:new i.bY(M),u_lightintensity:new i.bZ(M),u_lightcolor:new i.bY(M),u_vertical_gradient:new i.bZ(M),u_height_factor:new i.bZ(M),u_edge_radius:new i.bZ(M),u_width_scale:new i.bZ(M),u_ao:new i.b_(M),u_height_type:new i.bX(M),u_base_type:new i.bX(M),u_tile_id:new i.bY(M),u_zoom_transition:new i.bZ(M),u_inv_rot_matrix:new i.b$(M),u_merc_center:new i.b_(M),u_up_dir:new i.bY(M),u_height_lift:new i.bZ(M),u_image:new i.bX(M),u_texsize:new i.b_(M),u_pixel_coord_upper:new i.b_(M),u_pixel_coord_lower:new i.b_(M),u_tile_units_to_pixels:new i.bZ(M),u_opacity:new i.bZ(M),u_pattern_transition:new i.bZ(M)}),fillExtrusionGroundEffect:M=>({u_matrix:new i.b$(M),u_opacity:new i.bZ(M),u_ao_pass:new i.bZ(M),u_meter_to_tile:new i.bZ(M),u_ao:new i.b_(M),u_flood_light_intensity:new i.bZ(M),u_flood_light_color:new i.bY(M),u_attenuation:new i.bZ(M),u_edge_radius:new i.bZ(M),u_fb:new i.bX(M),u_fb_size:new i.bZ(M),u_dynamic_offset:new i.bZ(M)}),fill:M=>({u_matrix:new i.b$(M),u_emissive_strength:new i.bZ(M),u_ground_shadow_factor:new i.bY(M)}),fillPattern:M=>({u_matrix:new i.b$(M),u_emissive_strength:new i.bZ(M),u_image:new i.bX(M),u_texsize:new i.b_(M),u_pixel_coord_upper:new i.b_(M),u_pixel_coord_lower:new i.b_(M),u_tile_units_to_pixels:new i.bZ(M),u_ground_shadow_factor:new i.bY(M),u_pattern_transition:new i.bZ(M)}),fillOutline:M=>({u_matrix:new i.b$(M),u_emissive_strength:new i.bZ(M),u_world:new i.b_(M),u_ground_shadow_factor:new i.bY(M)}),fillOutlinePattern:M=>({u_matrix:new i.b$(M),u_emissive_strength:new i.bZ(M),u_world:new i.b_(M),u_image:new i.bX(M),u_texsize:new i.b_(M),u_pixel_coord_upper:new i.b_(M),u_pixel_coord_lower:new i.b_(M),u_tile_units_to_pixels:new i.bZ(M),u_ground_shadow_factor:new i.bY(M),u_pattern_transition:new i.bZ(M)}),lineBlendComposite:M=>({u_image:new i.bX(M),u_opacity:new i.bZ(M),u_blend_mode:new i.bX(M)}),building:M=>({u_matrix:new i.b$(M),u_normal_matrix:new i.b$(M),u_opacity:new i.bZ(M),u_faux_facade_ao_intensity:new i.bZ(M),u_camera_pos:new i.bY(M),u_tile_to_meter:new i.bZ(M),u_facade_emissive_chance:new i.bZ(M),u_flood_light_color:new i.bY(M),u_flood_light_intensity:new i.bZ(M),u_front_cutoff_params:new i.bY(M)}),buildingBloom:M=>({u_matrix:new i.b$(M)}),buildingDepth:M=>({u_matrix:new i.b$(M)}),elevatedStructuresDepth:M=>({u_matrix:new i.b$(M),u_depth_bias:new i.bZ(M)}),elevatedStructures:M=>({u_matrix:new i.b$(M),u_ground_shadow_factor:new i.bY(M)}),elevatedStructuresDepthReconstruct:M=>({u_matrix:new i.b$(M),u_camera_pos:new i.bY(M),u_depth_bias:new i.bZ(M),u_height_scale:new i.bZ(M),u_reset_depth:new i.bZ(M)}),circle:i.dO,collisionBox:M=>({u_matrix:new i.b$(M),u_inv_rot_matrix:new i.b$(M),u_camera_to_center_distance:new i.bZ(M),u_extrude_scale:new i.b_(M),u_zoom_transition:new i.bZ(M),u_merc_center:new i.b_(M),u_tile_id:new i.bY(M)}),collisionCircle:M=>({u_matrix:new i.b$(M),u_inv_matrix:new i.b$(M),u_camera_to_center_distance:new i.bZ(M),u_viewport_size:new i.b_(M)}),debug:M=>({u_color:new i.dl(M),u_matrix:new i.b$(M),u_overlay:new i.bX(M),u_overlay_scale:new i.bZ(M)}),clippingMask:M=>({u_matrix:new i.b$(M)}),heatmap:M=>({u_extrude_scale:new i.bZ(M),u_intensity:new i.bZ(M),u_matrix:new i.b$(M),u_inv_rot_matrix:new i.b$(M),u_merc_center:new i.b_(M),u_tile_id:new i.bY(M),u_zoom_transition:new i.bZ(M),u_up_dir:new i.bY(M)}),heatmapTexture:M=>({u_image:new i.bX(M),u_color_ramp:new i.bX(M),u_opacity:new i.bZ(M)}),hillshade:M=>({u_matrix:new i.b$(M),u_image:new i.bX(M),u_latrange:new i.b_(M),u_light:new i.b_(M),u_shadow:new i.dl(M),u_highlight:new i.dl(M),u_emissive_strength:new i.bZ(M),u_accent:new i.dl(M)}),hillshadePrepare:M=>({u_matrix:new i.b$(M),u_image:new i.bX(M),u_dimension:new i.b_(M),u_zoom:new i.bZ(M)}),line:i.dN,linePattern:i.dM,raster:M=>({u_matrix:new i.b$(M),u_normalize_matrix:new i.b$(M),u_globe_matrix:new i.b$(M),u_merc_matrix:new i.b$(M),u_grid_matrix:new i.dm(M),u_tl_parent:new i.b_(M),u_scale_parent:new i.bZ(M),u_fade_t:new i.bZ(M),u_opacity:new i.bZ(M),u_image0:new i.bX(M),u_image1:new i.bX(M),u_brightness_low:new i.bZ(M),u_brightness_high:new i.bZ(M),u_saturation_factor:new i.bZ(M),u_contrast_factor:new i.bZ(M),u_spin_weights:new i.bY(M),u_perspective_transform:new i.b_(M),u_raster_elevation:new i.bZ(M),u_zoom_transition:new i.bZ(M),u_merc_center:new i.b_(M),u_cutoff_params:new i.cO(M),u_colorization_mix:new i.cO(M),u_colorization_offset:new i.bZ(M),u_color_ramp:new i.bX(M),u_texture_offset:new i.b_(M),u_texture_res:new i.b_(M),u_emissive_strength:new i.bZ(M),u_zbias_factor:new i.bZ(M)}),rasterParticle:M=>({u_matrix:new i.b$(M),u_normalize_matrix:new i.b$(M),u_globe_matrix:new i.b$(M),u_merc_matrix:new i.b$(M),u_grid_matrix:new i.dm(M),u_tl_parent:new i.b_(M),u_scale_parent:new i.bZ(M),u_fade_t:new i.bZ(M),u_opacity:new i.bZ(M),u_image0:new i.bX(M),u_image1:new i.bX(M),u_raster_elevation:new i.bZ(M),u_zoom_transition:new i.bZ(M),u_merc_center:new i.b_(M),u_cutoff_params:new i.cO(M)}),rasterParticleTexture:M=>({u_texture:new i.bX(M),u_opacity:new i.bZ(M)}),rasterParticleDraw:M=>({u_particle_texture:new i.bX(M),u_particle_texture_side_len:new i.bZ(M),u_tile_offset:new i.b_(M),u_velocity:new i.bX(M),u_color_ramp:new i.bX(M),u_velocity_res:new i.b_(M),u_max_speed:new i.bZ(M),u_uv_offset:new i.b_(M),u_data_scale:new i.b_(M),u_data_offset:new i.bZ(M),u_particle_pos_scale:new i.bZ(M),u_particle_pos_offset:new i.b_(M)}),rasterParticleUpdate:M=>({u_particle_texture:new i.bX(M),u_particle_texture_side_len:new i.bZ(M),u_velocity:new i.bX(M),u_velocity_res:new i.b_(M),u_max_speed:new i.bZ(M),u_speed_factor:new i.bZ(M),u_reset_rate:new i.bZ(M),u_rand_seed:new i.bZ(M),u_uv_offset:new i.b_(M),u_data_scale:new i.b_(M),u_data_offset:new i.bZ(M),u_particle_pos_scale:new i.bZ(M),u_particle_pos_offset:new i.b_(M)}),symbol:M=>({u_is_size_zoom_constant:new i.bX(M),u_is_size_feature_constant:new i.bX(M),u_size_t:new i.bZ(M),u_size:new i.bZ(M),u_camera_to_center_distance:new i.bZ(M),u_rotate_symbol:new i.bX(M),u_aspect_ratio:new i.bZ(M),u_fade_change:new i.bZ(M),u_matrix:new i.b$(M),u_label_plane_matrix:new i.b$(M),u_coord_matrix:new i.b$(M),u_is_text:new i.bX(M),u_elevation_from_sea:new i.bX(M),u_pitch_with_map:new i.bX(M),u_texsize:new i.b_(M),u_texsize_icon:new i.b_(M),u_texture:new i.bX(M),u_texture_icon:new i.bX(M),u_gamma_scale:new i.bZ(M),u_device_pixel_ratio:new i.bZ(M),u_tile_id:new i.bY(M),u_zoom_transition:new i.bZ(M),u_inv_rot_matrix:new i.b$(M),u_merc_center:new i.b_(M),u_camera_forward:new i.bY(M),u_tile_matrix:new i.b$(M),u_up_vector:new i.bY(M),u_ecef_origin:new i.bY(M),u_is_halo:new i.bX(M),u_icon_transition:new i.bZ(M),u_color_adj_mat:new i.b$(M),u_scale_factor:new i.bZ(M),u_ground_shadow_factor:new i.bY(M),u_inv_matrix:new i.b$(M),u_normal_scale:new i.bZ(M),u_lutTexture:new i.bX(M),u_zoom:new i.bZ(M),u_spp_fill_np_color:new i.cO(M),u_spp_halo_np_color:new i.cO(M),u_spp_opacity:new i.bZ(M),u_spp_halo_width:new i.bZ(M),u_spp_halo_blur:new i.bZ(M),u_spp_emissive_strength:new i.bZ(M),u_spp_occlusion_opacity:new i.bZ(M),u_spp_z_offset:new i.bZ(M),u_spp_translate_rotation:new i.b_(M)}),background:M=>({u_matrix:new i.b$(M),u_emissive_strength:new i.bZ(M),u_opacity:new i.bZ(M),u_color:new i.dl(M)}),backgroundPattern:M=>({u_matrix:new i.b$(M),u_emissive_strength:new i.bZ(M),u_opacity:new i.bZ(M),u_image:new i.bX(M),u_pattern_tl:new i.b_(M),u_pattern_br:new i.b_(M),u_texsize:new i.b_(M),u_pattern_size:new i.b_(M),u_pixel_coord_upper:new i.b_(M),u_pixel_coord_lower:new i.b_(M),u_pattern_units_to_pixels:new i.b_(M)}),terrainRaster:M=>({u_matrix:new i.b$(M),u_image0:new i.bX(M),u_image1:new i.bX(M),u_skirt_height:new i.bZ(M),u_ground_shadow_factor:new i.bY(M),u_emissive_texture_available:new i.bZ(M)}),skybox:M=>({u_matrix:new i.b$(M),u_sun_direction:new i.bY(M),u_cubemap:new i.bX(M),u_opacity:new i.bZ(M),u_temporal_offset:new i.bZ(M)}),skyboxGradient:M=>({u_matrix:new i.b$(M),u_color_ramp:new i.bX(M),u_center_direction:new i.bY(M),u_radius:new i.bZ(M),u_opacity:new i.bZ(M),u_temporal_offset:new i.bZ(M)}),skyboxCapture:M=>({u_matrix_3f:new i.dm(M),u_sun_direction:new i.bY(M),u_sun_intensity:new i.bZ(M),u_color_tint_r:new i.cO(M),u_color_tint_m:new i.cO(M),u_luminance:new i.bZ(M)}),globeRaster:M=>({u_proj_matrix:new i.b$(M),u_globe_matrix:new i.b$(M),u_normalize_matrix:new i.b$(M),u_merc_matrix:new i.b$(M),u_zoom_transition:new i.bZ(M),u_merc_center:new i.b_(M),u_image0:new i.bX(M),u_image1:new i.bX(M),u_grid_matrix:new i.dm(M),u_skirt_height:new i.bZ(M),u_far_z_cutoff:new i.bZ(M),u_frustum_tl:new i.bY(M),u_frustum_tr:new i.bY(M),u_frustum_br:new i.bY(M),u_frustum_bl:new i.bY(M),u_globe_pos:new i.bY(M),u_globe_radius:new i.bZ(M),u_viewport:new i.b_(M),u_emissive_texture_available:new i.bZ(M)}),globeAtmosphere:M=>({u_frustum_tl:new i.bY(M),u_frustum_tr:new i.bY(M),u_frustum_br:new i.bY(M),u_frustum_bl:new i.bY(M),u_horizon:new i.bZ(M),u_transition:new i.bZ(M),u_fadeout_range:new i.bZ(M),u_atmosphere_fog_color:new i.cO(M),u_high_color:new i.cO(M),u_space_color:new i.cO(M),u_temporal_offset:new i.bZ(M),u_horizon_angle:new i.bZ(M)}),model:M=>({u_matrix:new i.b$(M),u_lighting_matrix:new i.b$(M),u_normal_matrix:new i.b$(M),u_node_matrix:new i.b$(M),u_lightpos:new i.bY(M),u_lightintensity:new i.bZ(M),u_lightcolor:new i.bY(M),u_camera_pos:new i.bY(M),u_opacity:new i.bZ(M),u_baseColorFactor:new i.cO(M),u_emissiveFactor:new i.cO(M),u_metallicFactor:new i.bZ(M),u_roughnessFactor:new i.bZ(M),u_baseTextureIsAlpha:new i.bX(M),u_alphaMask:new i.bX(M),u_alphaCutoff:new i.bZ(M),u_baseColorTexture:new i.bX(M),u_metallicRoughnessTexture:new i.bX(M),u_normalTexture:new i.bX(M),u_occlusionTexture:new i.bX(M),u_emissionTexture:new i.bX(M),u_lutTexture:new i.bX(M),u_color_mix:new i.cO(M),u_aoIntensity:new i.bZ(M),u_emissive_strength:new i.bZ(M),u_occlusionTextureTransform:new i.cO(M)}),modelDepth:M=>({u_matrix:new i.b$(M),u_instance:new i.b$(M),u_node_matrix:new i.b$(M)}),groundShadow:M=>({u_matrix:new i.b$(M),u_ground_shadow_factor:new i.bY(M)}),stars:M=>({u_matrix:new i.b$(M),u_up:new i.bY(M),u_right:new i.bY(M),u_intensity_multiplier:new i.bZ(M)}),snowParticle:M=>({u_modelview:new i.b$(M),u_projection:new i.b$(M),u_time:new i.bZ(M),u_cam_pos:new i.bY(M),u_velocityConeAperture:new i.bZ(M),u_velocity:new i.bZ(M),u_horizontalOscillationRadius:new i.bZ(M),u_horizontalOscillationRate:new i.bZ(M),u_boxSize:new i.bZ(M),u_billboardSize:new i.bZ(M),u_simpleShapeParameters:new i.b_(M),u_screenSize:new i.b_(M),u_thinningCenterPos:new i.b_(M),u_thinningShape:new i.bY(M),u_thinningAffectedRatio:new i.bZ(M),u_thinningParticleOffset:new i.bZ(M),u_particleColor:new i.cO(M),u_direction:new i.bY(M)}),rainParticle:M=>({u_modelview:new i.b$(M),u_projection:new i.b$(M),u_time:new i.bZ(M),u_cam_pos:new i.bY(M),u_texScreen:new i.bX(M),u_velocityConeAperture:new i.bZ(M),u_velocity:new i.bZ(M),u_boxSize:new i.bZ(M),u_rainDropletSize:new i.b_(M),u_distortionStrength:new i.bZ(M),u_rainDirection:new i.bY(M),u_color:new i.cO(M),u_screenSize:new i.b_(M),u_thinningCenterPos:new i.b_(M),u_thinningShape:new i.bY(M),u_thinningAffectedRatio:new i.bZ(M),u_thinningParticleOffset:new i.bZ(M),u_shapeDirectionalPower:new i.bZ(M),u_shapeNormalPower:new i.bZ(M),u_mode:new i.bZ(M)}),vignette:M=>({u_vignetteShape:new i.bY(M),u_vignetteColor:new i.cO(M)}),occlusion:M=>({u_matrix:new i.b$(M),u_anchorPos:new i.bY(M),u_screenSizePx:new i.b_(M),u_occluderSizePx:new i.b_(M),u_color:new i.cO(M)})};class Pp{constructor(m,v,E,D){this.id=Pp.uniqueIdxCounter,Pp.uniqueIdxCounter++,this.context=m;const z=m.gl;this.buffer=z.createBuffer(),this.dynamicDraw=!!E,this.context.unbindVAO(),m.bindElementBuffer.set(this.buffer),z.bufferData(z.ELEMENT_ARRAY_BUFFER,v.arrayBuffer,this.dynamicDraw?z.DYNAMIC_DRAW:z.STATIC_DRAW),this.dynamicDraw||D||v.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(m){this.id=Pp.uniqueIdxCounter,Pp.uniqueIdxCounter++;const v=this.context.gl;this.context.unbindVAO(),this.bind(),v.bufferSubData(v.ELEMENT_ARRAY_BUFFER,0,m.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}Pp.uniqueIdxCounter=0;const dP={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class hF{constructor(m,v,E,D,z,$){this.length=v.length,this.attributes=E,this.itemSize=v.bytesPerElement,this.dynamicDraw=D,this.instanceCount=$,this.context=m;const K=m.gl;this.buffer=K.createBuffer(),m.bindVertexBuffer.set(this.buffer),K.bufferData(K.ARRAY_BUFFER,v.arrayBuffer,this.dynamicDraw?K.DYNAMIC_DRAW:K.STATIC_DRAW),this.dynamicDraw||z||v.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(m){const v=this.context.gl;this.bind(),v.bufferSubData(v.ARRAY_BUFFER,0,m.arrayBuffer)}enableAttributes(m,v){for(const E of this.attributes){const D=v.getAttributeLocation(m,E.name);D!==-1&&m.enableVertexAttribArray(D)}}setVertexAttribPointers(m,v,E){for(const D of this.attributes){const z=v.getAttributeLocation(m,D.name);if(z!==-1){const $=D.offset+this.itemSize*(E||0);D.type==="Float32"?m.vertexAttribPointer(z,D.components,m.FLOAT,!1,this.itemSize,$):m.vertexAttribIPointer(z,D.components,m[dP[D.type]],this.itemSize,$)}}}setVertexAttribDivisor(m,v,E){for(let D=0;D0&&m.vertexAttribDivisor(z,E)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class a2{constructor(m,v,E,D,z){this.context=m,this.width=v,this.height=E;const $=this.framebuffer=m.gl.createFramebuffer();D>0&&(this.colorAttachment0=new H1(m,$,0)),D>1&&(this.colorAttachment1=new H1(m,$,1)),z&&(this.depthAttachmentType=z,this.depthAttachment=z==="renderbuffer"?new rP(m,$):new QO(m,$))}static createWithTexture(m,v,E,D,z){const $=m.gl;if(m.activeTexture.set($.TEXTURE1),m.viewport.set([0,0,E,D]),v&&v.width===E&&v.height===D)return $.bindTexture($.TEXTURE_2D,v.colorAttachment0.get()),m.bindFramebuffer.set(v.framebuffer),v;v&&v.destroy();const K=new i.T(m,{width:E,height:D,data:null},m.extRenderToTextureHalfFloat?m.gl.RGBA16F:m.gl.RGBA8);K.bind($.LINEAR,$.CLAMP_TO_EDGE);const ee=m.createFramebuffer(E,D,1,null);if(ee.colorAttachment0.set(K.texture),z){const ne=m.createRenderbuffer($.DEPTH24_STENCIL8,E,D);m.bindFramebuffer.set(ee.framebuffer),$.framebufferRenderbuffer($.FRAMEBUFFER,$.DEPTH_STENCIL_ATTACHMENT,$.RENDERBUFFER,ne),ee._stencilRbo=ne}return ee}createColorAttachment(m,v){v===0?this.colorAttachment0=new H1(m,this.framebuffer,0):v===1&&(this.colorAttachment1=new H1(m,this.framebuffer,1))}removeColorAttachment(m,v){const E=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&&E.deleteTexture(D)}destroy(){const m=this.context.gl;if(this.colorAttachment0){const v=this.colorAttachment0.get();v&&m.deleteTexture(v)}if(this.colorAttachment1){const v=this.colorAttachment1.get();v&&m.deleteTexture(v)}if(this.depthAttachment&&this.depthAttachmentType)if(this.depthAttachmentType==="renderbuffer"){const v=this.depthAttachment.get();v&&m.deleteRenderbuffer(v)}else{const v=this.depthAttachment.get();v&&m.deleteTexture(v)}this._stencilRbo&&(m.deleteRenderbuffer(this._stencilRbo),this._stencilRbo=null),m.deleteFramebuffer(this.framebuffer)}}class Z1{constructor(m,v){this.gl=m,this.clearColor=new VO(this),this.clearDepth=new ppe(this),this.clearStencil=new GC(this),this.colorMask=new fpe(this),this.depthMask=new HO(this),this.stencilMask=new XE(this),this.stencilFunc=new WC(this),this.stencilOp=new QE(this),this.stencilTest=new V0(this),this.depthRange=new H0(this),this.depthTest=new q1(this),this.depthFunc=new Ef(this),this.blend=new GO(this),this.blendFunc=new JE(this),this.blendColor=new WO(this),this.blendEquation=new U1(this),this.cullFace=new KC(this),this.cullFaceSide=new ZC(this),this.frontFace=new eP(this),this.program=new YC(this),this.activeTexture=new Kw(this),this.viewport=new KO(this),this.bindFramebuffer=new ZO(this),this.bindRenderbuffer=new YO(this),this.bindTexture=new V1(this),this.bindVertexBuffer=new XO(this),this.bindElementBuffer=new xpe(this),this.bindVertexArrayOES=new gpe(this),this.pixelStoreUnpack=new ype(this),this.pixelStoreUnpackPremultiplyAlpha=new tP(this),this.pixelStoreUnpackFlipY=new sP(this),this.options=v?Object.assign({},v):{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=m.getExtension("EXT_texture_filter_anisotropic")||m.getExtension("MOZ_EXT_texture_filter_anisotropic")||m.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=m.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=m.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=m.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=m.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.forceManualRenderingForInstanceIDShaders=v&&!!v.forceManualRenderingForInstanceIDShaders||this.renderer&&this.renderer.indexOf("PowerVR")!==-1,this.disableSymbolUBO=v&&!!v.forceDisableSymbolUBO,this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=m.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=m.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=m.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=m.getParameter(m.MAX_TEXTURE_SIZE),this.maxUniformBlockSize=Math.min(m.getParameter(m.MAX_UNIFORM_BLOCK_SIZE),32768),this.maxUniformBufferBindings=m.getParameter(m.MAX_UNIFORM_BUFFER_BINDINGS),this.extBlendFuncExtended=m.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(m,v,E){return new Pp(this,m,v,E)}createVertexBuffer(m,v,E,D,z){return new hF(this,m,v,E,D,z)}createRenderbuffer(m,v,E){const D=this.gl,z=D.createRenderbuffer();return this.bindRenderbuffer.set(z),D.renderbufferStorage(D.RENDERBUFFER,m,v,E),this.bindRenderbuffer.set(null),z}createFramebuffer(m,v,E,D){return new a2(this,m,v,E,D)}clear({color:m,depth:v,stencil:E,colorMask:D}){const z=this.gl;let $=0;m&&($|=z.COLOR_BUFFER_BIT,this.clearColor.set(m.toNonPremultipliedRenderColor(null)),this.colorMask.set(D||[!0,!0,!0,!0])),v!==void 0&&($|=z.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(v),this.depthMask.set(!0)),E!==void 0&&($|=z.STENCIL_BUFFER_BIT,this.clearStencil.set(E),this.stencilMask.set(255)),z.clear($)}setCullFace(m){m.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(m.mode),this.frontFace.set(m.frontFace))}setDepthMode(m){m.func!==this.gl.ALWAYS||m.mask?(this.depthTest.set(!0),this.depthFunc.set(m.func),this.depthMask.set(m.mask),this.depthRange.set(m.range)):this.depthTest.set(!1)}setStencilMode(m){m.test.func!==this.gl.ALWAYS||m.mask?(this.stencilTest.set(!0),this.stencilMask.set(m.mask),this.stencilOp.set([m.fail,m.depthFail,m.pass]),this.stencilFunc.set({func:m.test.func,ref:m.ref,mask:m.test.mask})):this.stencilTest.set(!1)}setColorMode(m){i.b6(m.blendFunction,rn.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(m.blendFunction),this.blendColor.set(m.blendColor),m.blendEquation?this.blendEquation.set(m.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(m.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}let K0;function yr(M,m,v,E,D,z,$){const K=M.context,ee=K.gl,ne=M.transform,de=[i.aH(ne.center.lng),i.aL(ne.center.lat)],we=v.layout.get("symbol-placement"),be=v.layout.get("text-variable-anchor"),Ae=v.layout.get("icon-rotation-alignment")==="map",ze=v.layout.get("text-rotation-alignment")==="map",Le=we!=="point",rt=[];let st=0,dt=0;for(let ft=0;ft0){const Pr=i.bb(),pr=Ws;i.cz(Pr,Kt.placementInvProjMatrix,ne.glCoordMatrix),i.cz(Pr,Pr,Kt.placementViewportMatrix),rt.push({circleArray:As,circleOffset:dt,transform:pr,invTransform:Pr,projection:Kt.getProjection()}),st+=As.length/4,dt=st}if(!Ks)continue;M.terrain&&M.terrain.setupElevationDraw(Et,Qs);const jr=is?[_t.canonical.x,_t.canonical.y,1<<_t.canonical.z]:[0,0,0];Qs.draw(M,ee.LINES,Sr.disabled,dn.disabled,M.colorModeForRenderPass(),Xr.disabled,iF(Ws,qt,ne,hs,de,Et,jr,Kt.getProjection()),v.id,Ks.layoutVertexBuffer,Ks.indexBuffer,Ks.segments,null,ne.zoom,null,[Ks.collisionVertexBuffer,Ks.collisionVertexBufferExt])}if(!$||!rt.length)return;const pt=M.getOrCreateProgram("collisionCircle"),at=new i.dP;at.resize(4*st),at._trim();let Bt=0;for(const ft of rt)for(let _t=0;_t=0&&(Ae[pt.associatedIconIndex]={x:qt,y:ns,z:Jt,angle:ss})}else L1(wt,we)}if(ne){be.clear();const dt=M.icon.placedSymbolArray;for(let pt=0;pt{let Cn=[0,0,0];if(qa){const Ui=M.style.directionalLight,fi=M.style.ambientLight;Ui&&fi&&(Cn=Ap(M.style,Ui,fi))}return Cn},Vn=qa=>{if(M.context.disableSymbolUBO)return;qa.push("USE_PAINT_PROPERTIES_UBO");const Cn=Math.floor(M.context.maxUniformBlockSize/4),Ui=Math.floor(Cn/4);qa.push(`MAX_UBO_SIZE_VEC4 ${Ui}u`)},pn=qa=>{_t.depthOcclusionForSymbolsAndCircles&&(v.hasOcclusionOpacityProperties||M.terrain)&&(qa.push("DEPTH_D24"),qa.push("DEPTH_OCCLUSION"))},Ea=qa=>{v.lut&&!wt&&(v.lut.texture||(v.lut.texture=new i.dR(M.context,v.lut.image,[v.lut.image.height,v.lut.image.height,v.lut.image.height],Ft.gl.RGBA8)),Ft.activeTexture.set(Ft.gl.TEXTURE0+10),v.lut.texture&&v.lut.texture.bind(Ft.gl.LINEAR,Ft.gl.CLAMP_TO_EDGE),qa.push("APPLY_LUT_ON_GPU"))},pi=()=>{const qa=Et&&v.layout.get("symbol-placement")!=="point",Cn=[];pn(Cn),Ea(Cn);const Ui=qa||bn,fi=As.elevationType==="road",Vo=M.shadowRenderer,ra=fi&&qt&&!!Vo&&Vo.enabled,_i=Vr(ra),ul=fi&&qt&&!M.terrain?Zt:Ls,ud=v.paint.get("icon-image-cross-fade");M.terrainRenderModeElevated()&&qt&&Cn.push("PITCH_WITH_MAP_TERRAIN"),jr&&(Cn.push("PROJECTION_GLOBE_VIEW"),Ui&&Cn.push("PROJECTED_POS_ON_VIEWPORT")),ud>0&&As.hasAnySecondaryIcon&&Cn.push("ICON_TRANSITION"),!As.icon.zOffsetVertexBuffer||fi&&M.terrain||Cn.push("Z_OFFSET"),st===0&&dt===0&&pt===0&&at===1||Cn.push("COLOR_ADJUSTMENT"),As.sdfIcons&&Cn.push("RENDER_SDF"),ra&&Cn.push("RENDER_SHADOWS","NORMAL_OFFSET"),fi&&qt&&!M.terrain&&As.icon.orientationVertexBuffer&&Cn.push("ELEVATED_ROADS"),Vn(Cn);const Ml=Ft.disableSymbolUBO?As.icon.programConfigurations.get(v.id):null,Sc=M.getOrCreateProgram("symbol",{config:Ml,defines:Cn}),bh=Ks.imageAtlasTexture?Ks.imageAtlasTexture.size:[0,0],ei=As.iconSizeData,tm=i.bj(ei,_t.zoom),sm=qt||!_t.isOrthographic,Ci=ar(pr,Ks.tileID.canonical,qt,Et,_t,As.getProjection(),br),Pi=xn(pr,Ks.tileID.canonical,qt,Et,_t,As.getProjection(),br),ci=As.icon.uboBinder&&As.icon.uboBinder.cachedHeader&&256&As.icon.uboBinder.cachedHeader.dataDrivenMask?[0,0]:K,Fo=M.translatePosMatrix(Pi,Ks,ci,ne,!0),Ed=M.translatePosMatrix(pr,Ks,ci,ne),fo=Ui?i2:Ci,wh=Et&&!qt&&!qa;let uy=Qs;!is&&!_t.mercatorFromTransition||Et||(uy=Hx(_t));const sv=jr?uy:Qs,rv=v.getColorAdjustmentMatrix(st,dt,pt,at),t_=c3(ei.kind,tm,wh,qt,M,Ed,fo,Fo,Bt,!1,bh,[0,0],0,Ws,Pr,Ht,mn,sv,As.getProjection(),_i,Un,rv,ud,null),Xx=Ks.imageAtlasTexture?Ks.imageAtlasTexture:null,Of=v.layout.get("icon-size").constantOr(0)!==1||As.iconsNeedLinear,s_=As.sdfIcons||M.options.rotating||M.options.zooming||Of||sm?ft.LINEAR:ft.NEAREST,Zu=As.sdfIcons&&v.paint.get("icon-halo-width").constantOr(1)!==0,hy=M.terrain&&qt&&qa?i.b7(i.bb(),Ci):i2;if(qa&&As.icon){const my=i.bu.getAtTileOffsetFunc(Ws,_t.center.lat,_t.worldSize,As.getProjection()),py=tn(pr,Ks.tileID.canonical,qt,Et,_t,As.getProjection(),br),L3=v.layout.get("icon-size-scale-range"),r_=i.aC(M.scaleFactor,L3[0],L3[1]);kc(As,pr,M,!1,py,Pi,qt,Le,my,Ws,r_)}return{program:Sc,buffers:As.icon,uniformValues:t_,atlasTexture:Xx,atlasTextureIcon:null,atlasInterpolation:s_,atlasInterpolationIcon:null,isSDF:As.sdfIcons,hasHalo:Zu,depthMode:ul,tile:Ks,renderWithShadows:ra,labelPlaneMatrixInv:hy}},Wi=()=>{const qa=Kt&&v.layout.get("symbol-placement")!=="point",Cn=[],Ui=qa||ss||bn,fi=As.elevationType==="road",Vo=M.shadowRenderer,ra=fi&&ns&&!!Vo&&Vo.enabled,_i=Vr(ra),ul=fi&&ns&&!M.terrain?Zt:Ls;M.terrainRenderModeElevated()&&ns&&Cn.push("PITCH_WITH_MAP_TERRAIN"),jr&&(Cn.push("PROJECTION_GLOBE_VIEW"),Ui&&Cn.push("PROJECTED_POS_ON_VIEWPORT")),!As.text.zOffsetVertexBuffer||fi&&M.terrain||Cn.push("Z_OFFSET"),As.iconsInText&&Cn.push("RENDER_TEXT_AND_SYMBOL"),Cn.push("RENDER_SDF"),ra&&Cn.push("RENDER_SHADOWS","NORMAL_OFFSET"),fi&&ns&&!M.terrain&&As.text.orientationVertexBuffer&&Cn.push("ELEVATED_ROADS"),pn(Cn),Vn(Cn);const ud=Ft.disableSymbolUBO?As.text.programConfigurations.get(v.id):null,Ml=M.getOrCreateProgram("symbol",{config:ud,defines:Cn});let Sc,bh=[0,0],ei=null;const tm=As.textSizeData;As.iconsInText&&(bh=Ks.imageAtlasTexture?Ks.imageAtlasTexture.size:[0,0],ei=Ks.imageAtlasTexture?Ks.imageAtlasTexture:null,Sc=ns||!_t.isOrthographic||M.options.rotating||M.options.zooming||tm.kind==="composite"||tm.kind==="camera"?ft.LINEAR:ft.NEAREST);const sm=Ks.glyphAtlasTexture?Ks.glyphAtlasTexture.size:[0,0],Ci=v.layout.get("text-size-scale-range"),Pi=i.aC(M.scaleFactor,Ci[0],Ci[1]),ci=i.bj(tm,_t.zoom,Pi),Fo=ar(pr,Ks.tileID.canonical,ns,Kt,_t,As.getProjection(),br),Ed=xn(pr,Ks.tileID.canonical,ns,Kt,_t,As.getProjection(),br),fo=As.text.uboBinder&&As.text.uboBinder.cachedHeader&&256&As.text.uboBinder.cachedHeader.dataDrivenMask?[0,0]:ee,wh=M.translatePosMatrix(Ed,Ks,fo,de,!0),uy=M.translatePosMatrix(pr,Ks,fo,de),sv=Ui?i2:Fo,rv=Kt&&!ns&&!qa;let t_=Qs;!is&&!_t.mercatorFromTransition||Kt||(t_=Hx(_t));const Xx=c3(tm.kind,ci,rv,ns,M,uy,sv,wh,Bt,!0,sm,bh,0,Ws,Pr,Ht,mn,jr?t_:Qs,As.getProjection(),_i,Un,null,null,Pi),Of=Ks.glyphAtlasTexture?Ks.glyphAtlasTexture:null,s_=ft.LINEAR,Zu=v.paint.get("text-halo-width").constantOr(1)!==0,hy=M.terrain&&ns&&qa?i.b7(i.bb(),Fo):i2;if(qa&&As.text){const my=i.bu.getAtTileOffsetFunc(Ws,_t.center.lat,_t.worldSize,As.getProjection()),py=tn(pr,Ks.tileID.canonical,ns,Kt,_t,As.getProjection(),br);kc(As,pr,M,!0,py,Ed,ns,rt,my,Ws,Pi)}return{program:Ml,buffers:As.text,uniformValues:Xx,atlasTexture:Of,atlasTextureIcon:ei,atlasInterpolation:s_,atlasInterpolationIcon:Sc,isSDF:!0,hasHalo:Zu,depthMode:ul,tile:Ks,renderWithShadows:ra,labelPlaneMatrixInv:hy}},Ni=As.icon.segments.get().length,$a=As.text.segments.get().length,On=Ni&&!$.onlyText?pi():null,Fn=$a&&!$.onlyIcons?Wi():null,ki=v.paint.get("icon-opacity").constantOr(1),Ji=v.paint.get("text-opacity").constantOr(1);if(Jt&&As.canOverlap){Cs=!0;const qa=ki&&!$.onlyText?As.icon.segments.get():[],Cn=Ji&&!$.onlyIcons?As.text.segments.get():[];for(const Ui of qa)hs.push({segments:new i.dy([Ui]),sortKey:Ui.sortKey,state:On});for(const Ui of Cn)hs.push({segments:new i.dy([Ui]),sortKey:Ui.sortKey,state:Fn})}else $.onlyText||hs.push({segments:ki?As.icon.segments:new i.dy([]),sortKey:0,state:On}),$.onlyIcons||hs.push({segments:Ji?As.text.segments:new i.dy([]),sortKey:0,state:Fn})}Cs&&hs.sort((Ws,Ks)=>Ws.sortKey-Ks.sortKey);for(const Ws of hs){const Ks=Ws.state;if(Ks)if(M.terrain?M.terrain.setupElevationDraw(Ks.tile,Ks.program,{useDepthForOcclusion:_t.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:Ks.labelPlaneMatrixInv}):M.setupDepthForOcclusion(_t.depthOcclusionForSymbolsAndCircles,Ks.program),Ft.activeTexture.set(ft.TEXTURE0),Ks.atlasTexture&&Ks.atlasTexture.bind(Ks.atlasInterpolation,ft.CLAMP_TO_EDGE,!0),Ks.atlasTextureIcon&&(Ft.activeTexture.set(ft.TEXTURE1),Ks.atlasTextureIcon&&Ks.atlasTextureIcon.bind(Ks.atlasInterpolationIcon,ft.CLAMP_TO_EDGE,!0)),Ks.renderWithShadows&&M.shadowRenderer.setupShadows(Ks.tile.tileID.toUnwrapped(),Ks.program,"vector-tile"),M.uploadCommonLightUniforms(M.context,Ks.program),Ks.hasHalo){const As=Ks.uniformValues;As.u_is_halo=1,h3(Ks.buffers,Ws.segments,v,M,Ks.program,Ks.depthMode,D,z,As,2),As.u_is_halo=0}else{if(Ks.isSDF){const As=Ks.uniformValues;Ks.hasHalo&&(As.u_is_halo=1,h3(Ks.buffers,Ws.segments,v,M,Ks.program,Ks.depthMode,D,z,As,1)),As.u_is_halo=0}h3(Ks.buffers,Ws.segments,v,M,Ks.program,Ks.depthMode,D,z,Ks.uniformValues,1)}}}function h3(M,m,v,E,D,z,$,K,ee,ne){const de=E.context,we=de.gl,be=[M.dynamicLayoutVertexBuffer,M.opacityVertexBuffer,M.iconTransitioningVertexBuffer,M.globeExtVertexBuffer,M.zOffsetVertexBuffer,M.orientationVertexBuffer];M.featureIdBuffer&&be.push(M.featureIdBuffer);const Ae=M.uboBinder?null:M.programConfigurations.get(v.id);if(M.uboBinder){M.uboBinder.layer=v;const rt=E.transform.zoom,st=E.style.getBrightness?E.style.getBrightness():null,dt=M.uboBinder.getConstantUniformValues(rt,st);ee.u_spp_fill_np_color=dt.fill_np_color,ee.u_spp_halo_np_color=dt.halo_np_color,ee.u_spp_opacity=dt.opacity,ee.u_spp_halo_width=dt.halo_width,ee.u_spp_halo_blur=dt.halo_blur,ee.u_spp_emissive_strength=dt.emissive_strength,ee.u_spp_occlusion_opacity=dt.occlusion_opacity,ee.u_spp_z_offset=dt.z_offset;const pt=v.paint.get(M.uboBinder.isText?"text-translate-anchor":"icon-translate-anchor"),at=M.uboBinder.cachedHeader&&256&M.uboBinder.cachedHeader.dataDrivenMask&&pt==="map"?E.transform.angle:0;ee.u_spp_translate_rotation=[Math.cos(at),Math.sin(at)]}const{batchIndices:ze,batchSegments:Le}=M.getBatchGrouping(m);for(const rt of ze){const st=Le.get(rt);M.uboBinder&&M.uboBinder.bind(de,D.program,rt),D.draw(E,we.TRIANGLES,z,$,K,Xr.disabled,ee,v.id,M.layoutVertexBuffer,M.indexBuffer,st,v.paint,E.transform.zoom,Ae,be,ne)}}function m3(M,m,v,E,D,z){const $=v.paint.get("line-width"),K=v.paint.get("line-emissive-strength").isConstant(),ee=v.paint.get("line-emissive-strength").constantOr(0),ne=v.paint.get("line-occlusion-opacity"),de=v.layout.get("line-elevation-reference"),we=v.layout.get("line-width-unit")==="meters",be=de==="sea",Ae=!(!M.terrain||!M.terrain.enabled),ze=M.context,Le=ze.gl;if(v.hasElevatedBuckets&&M.transform.projection.name==="globe")return;const rt=v.layout.get("line-cross-slope"),st=rt!==void 0,dt=rt<1,pt=D||M.colorModeForDrapableLayerRenderPass(K?ee:null),at=M.terrain&&M.terrain.renderingToTexture||z,Bt=at?1:i.o.devicePixelRatio,wt=v.paint.get("line-dasharray"),Ft=wt.constantOr(1),ft=v.layout.get("line-cap"),_t=wt.constantOr(null),Et=ft.constantOr(null),Kt=v.paint.get("line-pattern"),qt=Kt.constantOr(1),ns=v.paint.get("line-pattern-cross-fade"),Jt=Kt.constantOr(null),Cs=v.paint.get("line-opacity").constantOr(1);let Ls=!qt&&Cs!==1||M.depthOcclusion&&ne>0&&ne<1;const Zt=v.paint.get("line-gradient"),Ht=qt?"linePattern":"line",ss=i.dU(v);let is;if(at&&M.terrain&&M.terrain.clipOrMaskOverlapStencilType()&&(Ls=!1),ne!==0&&M.depthOcclusion){const As=v.paint._values["line-opacity"];As&&As.value&&As.value.kind==="constant"?is=As.value:i.w(`Occlusion opacity for layer ${v.id} is supported only when line-opacity isn't data-driven.`)}$.value.kind!=="constant"&&$.value.isLineProgressConstant===!1&&ss.push("VARIABLE_LINE_WIDTH"),at&&(M.emissiveMode!=="dual-source-blending"||K?M.emissiveMode==="mrt-fallback"&&ss.push("USE_MRT1"):ss.push("DUAL_SOURCE_BLENDING"));const hs={},Qs=(As,jr,Pr,pr,br,Qr)=>{for(const bn of As){const mn=m.getTile(bn);if(qt&&!mn.patternsLoaded())continue;const Un=mn.getBucket(v);if(!Un||Un.elevationType!=="none"&&!br||Un.elevationType==="none"&&br)continue;M.prepareDrawTile();const Vr=[...jr],Vn=M.shadowRenderer,pn=Un.elevationType==="road"&&!!Vn&&Vn.enabled;let Ea=[0,0,0];if(pn){const ra=M.style.directionalLight,_i=M.style.ambientLight;ra&&_i&&(Ea=Ap(M.style,ra,_i)),Vr.push("RENDER_SHADOWS","NORMAL_OFFSET")}const pi=Un.programConfigurations.get(v.id);let Wi=!1;if(Jt&&mn.imageAtlas){const ra=i.dV.from(Jt),_i=ra.getPrimary().scaleSelf(Bt).toString(),ul=mn.imageAtlas.patternPositions.get(_i),ud=ra.getSecondary(),Ml=ud?mn.imageAtlas.patternPositions.get(ud.scaleSelf(Bt).toString()):null;Wi=!!ul&&!!Ml,ul&&pi.setConstantPatternPositions(ul,Ml)}ns>0&&(Wi||pi.getPatternTransitionVertexBuffer("line-pattern"))&&Vr.push("LINE_PATTERN_TRANSITION"),Un.elevationGroundScaleVertexBuffer&&Vr.push("ELEVATION_GROUND_SCALE");const Ni=M.isTileAffectedByFog(bn),$a=M.getOrCreateProgram(Ht,{config:pi,defines:Vr,overrideFog:Ni});if(!qt&&_t&&Et&&mn.lineAtlas){const ra=mn.lineAtlas.getDash(_t,Et);ra&&pi.setConstantPatternPositions(ra)}pn&&Vn.setupShadows(mn.tileID.toUnwrapped(),$a,"vector-tile");let[On,Fn]=v.paint.get("line-trim-offset");(Et==="round"||Et==="square")&&On!==Fn&&(On===0&&(On-=1),Fn===1&&(Fn+=1));const ki=at?bn.projMatrix:null,Ji=we?1/Un.tileToMeter/i.aA(mn,1,M.transform.zoom):1,qa=we?1/Un.tileToMeter/i.aA(mn,1,Math.floor(M.transform.zoom)):1,Cn=Ft?v.paint._values["line-floorwidth"]:null;let Ui;if(Cn&&Cn.value.kind==="constant"){const ra=Un.zoom;ra in hs||(hs[ra]=Math.max(.01,v.widthExpression().evaluate({zoom:ra}))),Ui=Cn.value.value;const _i=Math.floor(M.transform.zoom);Cn.value.value=hs[ra]*Math.pow(2,_i-mn.tileID.overscaledZ)}const fi=qt?i.dW(M,mn,v,ki,Bt,Ji,qa,[On,Fn],Ea,ns):i.dX(M,mn,v,ki,Un.lineClipsArray.length,Bt,Ji,qa,[On,Fn],Ea);if(Zt){const ra=Un.gradients[v.id];let _i=ra.texture;if(v.gradientVersion!==ra.version){let ul=256;if(v.stepInterpolant){const ud=m.getSource().maxzoom,Ml=bn.canonical.z===ud?Math.ceil(1<{is!=null&&(is.value=Cs*ne),$a.draw(M,Le.TRIANGLES,Pr,ra,pt,Xr.disabled,fi,v.id,Un.layoutVertexBuffer,Un.indexBuffer,Un.segments,v.paint,M.transform.zoom,pi,[Un.layoutVertexBuffer2,Un.patternVertexBuffer,Un.zOffsetVertexBuffer,Un.elevationGroundScaleVertexBuffer]),is!=null&&(is.value=Cs)};if(Ls&&!br){const ra=M.stencilModeForClipping(bn).ref;ra===0&&at&&ze.clear({stencil:0});const _i={func:Le.EQUAL,mask:255};fi.u_alpha_discard_threshold=.8,Vo(new dn(_i,ra,255,Le.KEEP,Le.KEEP,Le.INVERT)),fi.u_alpha_discard_threshold=0,Vo(new dn(_i,ra,255,Le.KEEP,Le.KEEP,Le.KEEP))}else fi.u_alpha_discard_threshold=Ls&&br&&Qr?.8:0,Vo(br?pr:M.stencilModeForClipping(bn));Ui!==void 0&&(Cn.value.value=Ui)}};let Ws=M.depthModeForSublayer(0,Sr.ReadOnly);const Ks=new Sr(M.depthOcclusion?Le.GREATER:Le.LEQUAL,Sr.ReadOnly,M.depthRangeFor3D);if(v.hasNonElevatedBuckets){const As=!at&&M.terrain;ne!==0&&As?i.w(`Occlusion opacity for layer ${v.id} is supported on terrain only if the layer has line-z-offset enabled.`):As?i.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${v.id}.`):Qs(E,ss,Ws,dn.disabled,!1,!0)}if(v.hasElevatedBuckets){de==="hd-road-markup"?Ae||(Ws=Ks,ss.push("ELEVATED_ROADS")):(ss.push("ELEVATED"),Ws=Ks,st&&ss.push(dt?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),be&&ss.push("ELEVATION_REFERENCE_SEA"));const As=Ls?M.stencilModeFor3D():dn.disabled;M.forceTerrainMode=!0,Qs(E,ss,Ws,As,!0,!0),Ls&&Qs(E,ss,Ws,As,!0,!1),M.forceTerrainMode=!1}Ls&&(M.resetStencilClippingMasks(),at&&ze.clear({stencil:0})),ne===0||M.depthOcclusion||at||M.layersWithOcclusionOpacity.push(M.currentLayer)}const Gx={additive:{clearColor:new i.aq(0,0,0,0),colorMode:rn.additive,compositeUniformValue:1},multiply:{clearColor:new i.aq(1,1,1,1),colorMode:rn.multiply,compositeUniformValue:0}};function uP(M,m){const v=1<=$0?1:Ae.pitch/$0))),2*ze}(M.transform),ne=M.transform.getFreeCameraOptions().position,de="elevatedStructuresDepthReconstruct",we=M.getOrCreateProgram(de,{defines:["DEPTH_RECONSTRUCTION"]}),be=M.getOrCreateProgram(de);for(const Ae of E){const ze=m.getTile(Ae),Le=ze.getBucket(v);if(!Le)continue;const rt=Le.elevatedStructures;if(!rt)continue;const st=Le.elevationBufferData.heightRange,dt=uP(Ae.toUnwrapped(),ne),pt=M.translatePosMatrix(Ae.projMatrix,ze,v.paint.get("fill-translate"),v.paint.get("fill-translate-anchor"));let at,Bt,wt,Ft;if(D==="initialize"){if(!st||st.min>=1||rt.depthSegments.segments[0].primitiveLength===0)continue;at=s2(pt,dt,ee,1,0),Bt=$,wt=rt.depthSegments,Ft=we}else if(D==="reset"){if(!st||st.min>=0||rt.maskSegments.segments[0].primitiveLength===0)continue;at=s2(pt,dt,0,0,1),Bt=K,wt=rt.maskSegments,Ft=we}else if(D==="geometry"){if(rt.depthSegments.segments[0].primitiveLength===0)continue;at=s2(pt,dt,ee,1,0),Bt=$,wt=rt.depthSegments,Ft=be}Ft.draw(M,z.TRIANGLES,Bt,dn.disabled,rn.disabled,Xr.disabled,at,v.id,rt.vertexBuffer,rt.indexBuffer,wt,v.paint,M.transform.zoom)}}function l2(M,m,v,E){const{painter:D,sourceCache:z,layer:$,coords:K,colorMode:ee,elevationType:ne,terrainEnabled:de,pass:we}=M,be=D.context.gl,Ae=$.paint.get("fill-pattern"),ze=$.paint.get("fill-pattern-cross-fade"),Le=Ae.constantOr(null);let rt=ne;ne!=="road"||m&&!de||(rt="none");const st=rt==="road",dt=M.painter.shadowRenderer,pt=st&&!!dt&&dt.enabled,at=new Sr(D.context.gl.LEQUAL,Sr.ReadOnly,D.depthRangeFor3D);let Bt=[0,0,0];if(pt){const _t=D.style.directionalLight,Et=D.style.ambientLight;_t&&Et&&(Bt=Ap(D.style,_t,Et))}const wt=Ae&&Ae.constantOr(1),Ft=D.terrain&&D.terrain.renderingToTexture,ft=(_t,Et)=>{let Kt,qt,ns,Jt,Cs;Et?(Kt=wt&&!$.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",ns=be.LINES):(Kt=wt?"fillPattern":"fill",ns=be.TRIANGLES);for(const Ls of K){const Zt=z.getTile(Ls);if(wt&&!Zt.patternsLoaded())continue;const Ht=Zt.getBucket($);if(!Ht)continue;const ss=m?Ht.elevationBufferData:Ht.bufferData;if(ss.isEmpty())continue;D.prepareDrawTile();const is=ss.programConfigurations.get($.id),hs=D.isTileAffectedByFog(Ls),Qs=[],Ws=[];st&&(Qs.push("ELEVATED_ROADS"),Ws.push(ss.elevatedLayoutVertexBuffer)),pt&&Qs.push("RENDER_SHADOWS","NORMAL_OFFSET"),Ft&&v&&Qs.push("USE_MRT1"),wt&&(D.context.activeTexture.set(be.TEXTURE0),Zt.imageAtlasTexture&&Zt.imageAtlasTexture.bind(be.LINEAR,be.CLAMP_TO_EDGE),is.updatePaintBuffers());let Ks=!1;if(Le&&Zt.imageAtlas){const br=Zt.imageAtlas,Qr=i.dV.from(Le),bn=Qr.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),mn=Qr.getSecondary(),Un=br.patternPositions.get(bn),Vr=mn?br.patternPositions.get(mn.scaleSelf(i.o.devicePixelRatio).toString()):null;Ks=!!Un&&!!Vr,Un&&is.setConstantPatternPositions(Un,Vr)}ze>0&&(Ks||is.getPatternTransitionVertexBuffer("fill-pattern"))&&Qs.push("FILL_PATTERN_TRANSITION");const As=D.getOrCreateProgram(Kt,{config:is,overrideFog:hs,defines:Qs}),jr=D.translatePosMatrix(Ls.projMatrix,Zt,$.paint.get("fill-translate"),$.paint.get("fill-translate-anchor"));pt&&dt.setupShadows(Zt.tileID.toUnwrapped(),As,"vector-tile");const Pr=$.paint.get("fill-emissive-strength");if(Et){Jt=ss.lineIndexBuffer,Cs=ss.lineSegments;const br=D.terrain&&D.terrain.renderingToTexture?D.terrain.drapeBufferSize:[be.drawingBufferWidth,be.drawingBufferHeight];qt=Kt==="fillOutlinePattern"&&wt?W1(jr,Pr,D,Zt,br,Bt,ze):rF(jr,Pr,br,Bt)}else Jt=ss.indexBuffer,Cs=ss.triangleSegments,qt=wt?r3(jr,Pr,D,Zt,Bt,ze):s3(jr,Pr,Bt);D.uploadCommonUniforms(D.context,As,Ls.toUnwrapped());let pr=_t;(ne==="road"&&!de||ne==="offset")&&(pr=at),As.draw(D,ns,pr,E||D.stencilModeForClipping(Ls),ee,Xr.disabled,qt,$.id,ss.layoutVertexBuffer,Jt,Cs,$.paint,D.transform.zoom,is,Ws)}};D.renderPass===we&&ft(D.depthModeForSublayer(1,D.renderPass==="opaque"?Sr.ReadWrite:Sr.ReadOnly),!1),rt==="none"&&D.renderPass==="translucent"&&$.paint.get("fill-antialias")&&ft(D.depthModeForSublayer($.getPaintProperty("fill-outline-color")?2:0,Sr.ReadOnly),!0)}function Z0(M,m,v,E,D,z,$,K){v.resetLayerRenderingStats(M);const ee=M.context,ne=ee.gl,de=M.transform,we=v.paint.get("fill-extrusion-pattern"),be=v.paint.get("fill-extrusion-pattern-cross-fade"),Ae=we.constantOr(null),ze=we.constantOr(1),Le=v.paint.get("fill-extrusion-opacity"),rt=M.style.enable3dLights(),st=v.paint.get(rt&&!ze?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),dt=[v.paint.get("fill-extrusion-ambient-occlusion-intensity"),st],pt=v.layout.get("fill-extrusion-edge-radius"),at=pt>0&&!v.paint.get("fill-extrusion-rounded-roof"),Bt=at?0:pt,wt=de.projection.name==="globe"?i.e1():0,Ft=de.projection.name==="globe",ft=Ft?i.al(de.zoom):0,_t=[i.aH(de.center.lng),i.aL(de.center.lat)],Et=v.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",Kt=v.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(Et?null:v.lut).toArray01().slice(0,3),qt=v.paint.get("fill-extrusion-flood-light-intensity"),ns=v.paint.get("fill-extrusion-vertical-scale"),Jt=v.paint.get("fill-extrusion-line-width").constantOr(1)!==0,Cs=v.paint.get("fill-extrusion-height-alignment"),Ls=v.paint.get("fill-extrusion-base-alignment"),Zt=oc(M,v.paint.get("fill-extrusion-cutoff-fade-range")),Ht=v.paint.get("fill-extrusion-front-cutoff"),ss=p3(de.pitch,Ht,!!M.terrain),is=ss[2]<1;is&&(M.maxFrontCutoffRawStart=Math.max(M.maxFrontCutoffRawStart,Ht[0]));const hs=[];let Qs;Ft&&hs.push("PROJECTION_GLOBE_VIEW"),dt[0]>0&&hs.push("FAUX_AO"),at&&hs.push("ZERO_ROOF_RADIUS"),K&&hs.push("HAS_CENTROID"),qt>0&&hs.push("FLOOD_LIGHT"),Zt.shouldRenderCutoff&&hs.push("RENDER_CUTOFF"),is&&hs.push("RENDER_FRONT_CUTOFF"),Jt&&hs.push("RENDER_WALL_MODE");const Ws=M.renderPass==="shadow",Ks=M.shadowRenderer,As=Ws&&!!Ks,jr=Ws?Xr.disabled:Xr.backCCW;M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!0);let Pr=[0,0,0];if(Ks){const Qr=M.style.directionalLight,bn=M.style.ambientLight;Qr&&bn&&(Pr=Ap(M.style,Qr,bn)),Ws||(hs.push("RENDER_SHADOWS"),Ks.useNormalOffset&&hs.push("NORMAL_OFFSET")),Qs=hs.concat(["SHADOWS_SINGLE_CASCADE"])}const pr=As?"fillExtrusionDepth":ze?"fillExtrusionPattern":"fillExtrusion",br=v.getLayerRenderingStats();for(const Qr of E){const bn=m.getTile(Qr),mn=bn.getBucket(v);if(!mn||mn.projection.name!==de.projection.name)continue;let Un=!1;Ks&&(Un=Ks.getMaxCascadeForTile(Qr.toUnwrapped())===0);const Vr=M.isTileAffectedByFog(Qr),Vn=mn.programConfigurations.get(v.id);let pn=!1;if(Ae&&bn.imageAtlas){const Fn=bn.imageAtlas,ki=i.dV.from(Ae),Ji=ki.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),qa=ki.getSecondary(),Cn=Fn.patternPositions.get(Ji),Ui=qa?Fn.patternPositions.get(qa.scaleSelf(i.o.devicePixelRatio).toString()):null;pn=!!Cn&&!!Ui,Cn&&Vn.setConstantPatternPositions(Cn,Ui)}be>0&&(pn||Vn.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&hs.push("FILL_EXTRUSION_PATTERN_TRANSITION");const Ea=M.getOrCreateProgram(pr,{config:Vn,defines:Un?Qs:hs,overrideFog:Vr});if(M.terrain&&M.terrain.setupElevationDraw(bn,Ea,{useMeterToDem:!0}),!mn.centroidVertexBuffer){const Fn=Ea.getAttributeLocation(ne,"a_centroid_pos");Fn!==-1&&ne.vertexAttribI4ui(Fn,0,0,0,0)}!Ws&&Ks&&Ks.setupShadows(bn.tileID.toUnwrapped(),Ea,"vector-tile"),ze&&(M.context.activeTexture.set(ne.TEXTURE0),bn.imageAtlasTexture&&bn.imageAtlasTexture.bind(ne.LINEAR,ne.CLAMP_TO_EDGE),Vn.updatePaintBuffers());const pi=v.paint.get("fill-extrusion-vertical-gradient"),Wi=1/mn.tileToMeter;let Ni;if(Ws&&Ks){if(f3(bn.tileID,mn.maxHeight,M))continue;const Fn=Ks.calculateShadowPassMatrixFromTile(bn.tileID.toUnwrapped());Ni=bpe(Fn,Bt,Wi,ns,Cs,Ls)}else{const Fn=M.translatePosMatrix(Qr.expandedProjMatrix,bn,v.paint.get("fill-extrusion-translate"),v.paint.get("fill-extrusion-translate-anchor")),ki=de.projection.createInversionMatrix(de,Qr.canonical);Ni=ze?wpe(Fn,M,pi,Le,dt,Bt,Wi,Qr,bn,wt,Cs,Ls,ft,_t,ki,Kt,ns,be):sF(Fn,M,pi,Le,dt,Bt,Wi,Qr,wt,Cs,Ls,ft,_t,ki,Kt,ns,qt,Pr,ss)}M.uploadCommonUniforms(ee,Ea,Qr.toUnwrapped(),null,Zt);let $a=mn.segments;if(de.projection.name==="mercator"&&!Ws&&($a=mn.getVisibleSegments(bn.tileID,M.terrain,M.transform.getFrustum(0)),!$a.get().length))continue;if(br)if(Ws)for(const Fn of $a.get())br.numRenderedVerticesInShadowPass+=Fn.primitiveLength;else for(const Fn of $a.get())br.numRenderedVerticesInTransparentPass+=Fn.primitiveLength;const On=[];(M.terrain||K)&&On.push(mn.centroidVertexBuffer),Ft&&On.push(mn.layoutVertexExtBuffer),Jt&&On.push(mn.wallVertexBuffer),Ea.draw(M,ee.gl.TRIANGLES,D,z,$,jr,Ni,v.id,mn.layoutVertexBuffer,mn.indexBuffer,$a,v.paint,M.transform.zoom,Vn,On)}M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!1)}class hP{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function p3(M,m,v){if(!(m[2]<1)||v)return[0,0,1];const E=180*M/Math.PI;if(E<15)return[-.5,m[1],m[2]];const D=Math.min(1,Math.max(0,(E-15)/5)),z=D*D*(3-2*D);return[-.5*(1-z)+m[0]*z,m[1],m[2]]}function If(M,m,v,E,D,z,$,K,ee,ne,de,we,be,Ae,ze,Le,rt,st,dt,pt,at){const Bt=m.context,wt=Bt.gl,Ft=m.transform,ft=m.transform.zoom,_t=[],Et=M.translate,Kt=M.translateAnchor,qt=M.edgeRadius,ns=oc(m,M.cutoffFadeRange);de==="clear"?(_t.push("CLEAR_SUBPASS"),pt&&(_t.push("CLEAR_FROM_TEXTURE"),Bt.activeTexture.set(wt.TEXTURE0),pt.bind(wt.LINEAR,wt.CLAMP_TO_EDGE))):de==="sdf"?_t.push("SDF_SUBPASS"):de==="emissive"&&(_t.push("USE_MRT1"),Bt.activeTexture.set(wt.TEXTURE0),pt.bind(wt.LINEAR,wt.CLAMP_TO_EDGE)),st&&_t.push("HAS_CENTROID"),ns.shouldRenderCutoff&&_t.push("RENDER_CUTOFF");const Jt=(Cs,Ls,Zt,Ht,ss)=>{let is=_t;Ls.groundRadiusBuffer!=null&&(is=_t.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const hs=Ls.programConfigurations.get(E.id),Qs=m.isTileAffectedByFog(Cs),Ws=m.getOrCreateProgram("fillExtrusionGroundEffect",{config:hs,defines:is,overrideFog:Qs}),Ks=((jr,Pr,pr,br,Qr,bn,mn,Un,Vr,Vn,pn)=>({u_matrix:Pr,u_opacity:pr,u_ao_pass:br?1:0,u_meter_to_tile:Qr,u_ao:bn,u_flood_light_intensity:mn,u_flood_light_color:Un,u_attenuation:Vr,u_edge_radius:Vn,u_fb:0,u_fb_size:pn,u_dynamic_offset:1}))(0,Ht,we,ne,ss,[be,Ae*ss],ze,Le,rt,ft>=17?0:qt*ss,pt?pt.size[0]:0),As=[];st&&As.push(Ls.hiddenByLandmarkVertexBuffer),Ls.groundRadiusBuffer!=null&&As.push(Ls.groundRadiusBuffer),m.uploadCommonUniforms(Bt,Ws,Cs.toUnwrapped(),null,ns),Ws.draw(m,Bt.gl.TRIANGLES,z,$,K,ee,Ks,E.id,Ls.vertexBuffer,Ls.indexBuffer,Zt,E.paint,ft,hs,As)};for(const Cs of D){const Ls=v.getTile(Cs),Zt=Ls.getBucket(E);if(!Zt||Zt.projection.name!==Ft.projection.name||!Zt.groundEffect||Zt.groundEffect&&!Zt.groundEffect.hasData())continue;const Ht=Zt.groundEffect,ss=1/Zt.tileToMeter;{const is=m.translatePosMatrix(Cs.projMatrix,Ls,Et,Kt),hs=Ht.getDefaultSegment();Jt(Cs,Ht,hs,is,ss)}if(dt)for(let is=0;is<4;is++){const hs=i.d$[is](Cs),Qs=v.getTile(hs);if(!Qs)continue;const Ws=Qs.getBucket(E);if(!Ws||Ws.projection.name!==Ft.projection.name||!Ws.groundEffect||Ws.groundEffect&&!Ws.groundEffect.hasData())continue;const Ks=Ws.groundEffect;let As,jr;is===0?(As=[-i.an,0,0],jr=1):is===1?(As=[i.an,0,0],jr=0):is===2?(As=[0,-i.an,0],jr=3):(As=[0,i.an,0],jr=2);const Pr=Ks.regionSegments[jr];if(!Pr)continue;const pr=new Float32Array(16);i.bx(pr,Cs.projMatrix,As),Jt(Cs,Ks,Pr,m.translatePosMatrix(pr,Ls,Et,Kt),ss)}}}function pF(M,m,v,E,D,z,$){E.centroidVertexArray.length===0&&E.createCentroidsBuffer();const K=z?z.findDEMTileFor(v):null;if(!(K&&K.dem||$))return;z&&K&&K.dem&&E.selfDEMTileTimestamp!==K.dem._timestamp&&(E.borderDoneWithNeighborZ=[-1,-1,-1,-1],E.selfDEMTileTimestamp=K.dem._timestamp);const ee=(st,dt)=>{(st.flags|dt.flags)&i.e3?(st.flags|=i.e3,dt.flags|=i.e3):(st.flags&=~i.e3,dt.flags&=~i.e3)},ne=st=>new i.P(Math.ceil((st+i.e4)*i.e5),0),de=(st,dt,pt)=>{const at=Math.ceil((st+i.e4)*i.e5),Bt=Math.floor(Math.max(0,Math.min(i.an-1,pt))/4);return new i.P(at,Bt<<5|(3&dt)<<3|7)},we=st=>{const dt=m.getSource().minzoom,pt=Bt=>{const wt=m.getTileByID(Bt);if(wt&&wt.hasData())return wt.getBucket(D)},at=[0,-1,1];for(const Bt of at){if(st.overscaledZ+Bt(be[0]=Math.min(st.min.y,dt.min.y),be[1]=Math.max(st.max.y,dt.max.y),be[2]=i.an-dt.min.x>st.max.x?dt.min.x-i.an:st.max.x,be),ze=(st,dt)=>(be[0]=Math.min(st.min.x,dt.min.x),be[1]=Math.max(st.max.x,dt.max.x),be[2]=i.an-dt.min.y>st.max.y?dt.min.y-i.an:st.max.y,be),Le=[(st,dt)=>Ae(st,dt),(st,dt)=>Ae(dt,st),(st,dt)=>ze(st,dt),(st,dt)=>ze(dt,st)],rt=(st,dt,pt,at,Bt,wt,Ft)=>{if(!z)return 0;const ft=[[wt?pt:st,wt?st:pt,0],[wt?pt:dt,wt?dt:pt,0]],_t=Ft<0?i.an+Ft:Ft,Et=[wt?_t:(st+dt)/2,wt?(st+dt)/2:_t,0];return pt===0&&Ft<0||pt!==0&&Ft>0?z.getForTilePoints(Bt,[Et],!0,at):ft.push(Et),z.getForTilePoints(v,ft,!0,K),Math.max(ft[0][2],ft[1][2],Et[2])/z.exaggeration()};for(let st=0;st<4;st++){const dt=E.borderFeatureIndices[st];if(dt.length===0)continue;const pt=i.d$[st](v),at=we(pt);if(!(at&&at instanceof i.e0))continue;const Bt=z?z.findDEMTileFor(pt):null;if(!(Bt&&Bt.dem||$)||(z&&Bt&&Bt.dem&&E.borderDEMTileTimestamp[st]!==Bt.dem._timestamp&&(E.borderDoneWithNeighborZ[st]=-1,E.borderDEMTileTimestamp[st]=Bt.dem._timestamp),E.borderDoneWithNeighborZ[st]===at.canonical.z))continue;at.centroidVertexArray.length===0&&at.createCentroidsBuffer();const wt=(st<2?1:5)-st,Ft=at.borderDoneWithNeighborZ[wt]!==E.canonical.z,ft=at.borderFeatureIndices[wt];let _t=0;if(E.canonical.z!==at.canonical.z){for(const ns of dt)E.showCentroid(E.featuresOnBorder[ns]);if(Ft)for(const ns of ft)at.showCentroid(at.featuresOnBorder[ns]);E.borderDoneWithNeighborZ[st]=at.canonical.z,at.borderDoneWithNeighborZ[wt]=E.canonical.z;continue}const Et=new Map,Kt=new Set,qt=new Set;for(let ns=0;ns1||Zt.intersectsCount()>1;{let Ws=0;if(Bt&&Bt.dem&&!Qs){const Ks=Le[st](Cs,Ht),As=st%2?i.an-1:0;Ws=rt(Ks[0],Math.min(i.an-1,Ks[1]),As,Bt,pt,st<2,Ks[2])}Cs.centroidXY=de(Ws,st,hs),Ht.centroidXY=de(Ws,wt,hs)}if(E.writeCentroidToBuffer(Cs),at.writeCentroidToBuffer(Ht),Jt.buildingId!==void 0){for(const Ws of E.centroidData)Ws.buildingId===Jt.buildingId&&Ws!==Cs&&(Ws.centroidXY=Cs.centroidXY,E.writeCentroidToBuffer(Ws));for(const Ws of at.centroidData)Ws.buildingId===Jt.buildingId&&Ws!==Ht&&(Ws.centroidXY=Ht.centroidXY,at.writeCentroidToBuffer(Ws))}}for(const ns of dt){if(Kt.has(ns))continue;const Jt=E.featuresOnBorder[ns],Cs=E.centroidData[Jt.centroidDataIndex],Ls=Jt.borders[st];let Zt;for(;_tLs[0]+3||Ht[0]>Ls[0]-3)break;at.showCentroid(Zt),_t++}if(Zt&&_tLs[1]-3||(ss++,++_t===ft.length))break;Zt=at.featuresOnBorder[ft[_t]]}for(;Ht=ft.length){E.showCentroid(Jt);continue}Zt=at.featuresOnBorder[ft[Ht]];let is=!1;if(ss>=1){const Ws=Zt.borders[wt];Math.abs(Ls[0]-Ws[0])<3&&Math.abs(Ls[1]-Ws[1])<3&&(ss=1,is=!0,_t=Ht+1)}else if(ss===0){E.showCentroid(Jt);continue}const hs=at.centroidData[Zt.centroidDataIndex];$&&is&&ee(Cs,hs);const Qs=Jt.intersectsCount()>1||Zt.intersectsCount()>1;if(ss>1)_t=Ht,Cs.centroidXY=hs.centroidXY=new i.P(0,0);else if(Bt&&Bt.dem&&!Qs){const Ws=Le[st](Cs,hs),Ks=st%2?i.an-1:0,As=rt(Ws[0],Math.min(i.an-1,Ws[1]),Ks,Bt,pt,st<2,Ws[2]);Cs.centroidXY=hs.centroidXY=ne(As)}else Qs?Cs.centroidXY=hs.centroidXY=new i.P(0,0):(Cs.centroidXY=E.encodeBorderCentroid(Jt),hs.centroidXY=at.encodeBorderCentroid(Zt));E.writeCentroidToBuffer(Cs),at.writeCentroidToBuffer(hs)}else E.showCentroid(Jt)}E.borderDoneWithNeighborZ[st]=at.canonical.z,at.borderDoneWithNeighborZ[wt]=E.canonical.z}(E.needsCentroidUpdate||!E.centroidVertexBuffer&&E.centroidVertexArray.length!==0)&&E.uploadCentroid(M)}const fF=[1,0,0],xF=[0,1,0],mP=[0,0,1];function f3(M,m,v){const E=v.transform,D=v.shadowRenderer;if(!D)return!0;const z=M.toUnwrapped(),$=E.tileSize*D._cascades[v.currentShadowCascade].scale;let K=m;if(E.elevation){const ze=E.elevation.getMinMaxForTile(M);ze&&(K+=ze.max)}const ee=E.scaleZoom($);K/=i.e2(E.center.lat,ee);const ne=[...D.shadowDirection];ne[2]=-ne[2];const de=D.computeSimplifiedTileShadowVolume(z,K,$,ne);if(!de)return!1;const we=[fF,xF,mP,ne,[ne[0],0,ne[2]],[0,ne[1],ne[2]]],be=i.cl.fromInvProjectionMatrix(E.invProjMatrix,E.worldSize,ee,E.projection.name!=="globe"),Ae=D.getCurrentCascadeFrustum();return be.intersectsPrecise(de.vertices,de.planes,we)===0||Ae.intersectsPrecise(de.vertices,de.planes,we)===0}function c2(M){const{painter:m,source:v,layer:E,coords:D}=M;let z=M.defines;const $=m.context,K=m.renderPass==="shadow",ee=m.renderPass==="light-beam",ne=m.shadowRenderer,de=i.e2(m.transform.center.lat,m.transform.zoom),we=oc(m,E.paint.get("building-cutoff-fade-range"));we.shouldRenderCutoff&&(z=z.concat("RENDER_CUTOFF"));const be=E.paint.get("building-front-cutoff"),Ae=be[2]<1&&!m.terrain,ze=p3(m.transform.pitch,be,!!m.terrain);Ae&&(z=z.concat("RENDER_FRONT_CUTOFF"),m.maxFrontCutoffRawStart=Math.max(m.maxFrontCutoffRawStart,be[0])),M.floodLightIntensity>0&&(z=z.concat("FLOOD_LIGHT"));for(const Le of D){const rt=v.getTile(Le),st=rt.getBucket(E);if(!st)continue;ne&&ne.getMaxCascadeForTile(Le.toUnwrapped())===0&&(z=z.concat("SHADOWS_SINGLE_CASCADE"));const dt=st.programConfigurations.get(E.id);let pt,at,Bt,wt=m.translatePosMatrix(Le.expandedProjMatrix,rt,[0,0],"map");if(wt=i.cC(i.bb(),wt,[1,1,M.verticalScale]),K&&ne){if(f3(rt.tileID,st.maxHeight*de,m))continue;let ft=ne.calculateShadowPassMatrixFromTile(rt.tileID.toUnwrapped());ft=i.cC(i.bb(),ft,[1,1,M.verticalScale]),Bt=i3(ft),pt=at=m.getOrCreateProgram("buildingDepth",{config:dt,defines:z,overrideFog:!1})}else if(ee)pt=at=m.getOrCreateProgram("buildingBloom",{config:dt,defines:z,overrideFog:!1}),Bt=a3(wt);else{const ft=m.transform.calculatePosMatrix(Le.toUnwrapped(),m.transform.worldSize);i.cC(ft,ft,[1,1,M.verticalScale]);const _t=i.bb();i.cC(_t,ft,[1,-1,1/de]),i.b7(_t,_t),i.e6(_t,_t);const Et=m.transform.getFreeCameraOptions().position,Kt=1<{if(ee){const Et=ft.entranceBloom;_t.draw(m,$.gl.TRIANGLES,M.depthMode,dn.disabled,M.blendMode,Xr.disabled,Bt,E.id,Et.layoutVertexBuffer,Et.indexBuffer,Et.segmentsBucket,E.paint,m.transform.zoom,dt,[Et.layoutAttenuationBuffer,Et.layoutColorBuffer])}else{const Et=ft.segmentsBucket;let Kt=[ft.layoutNormalBuffer,ft.layoutCentroidBuffer,ft.layoutColorBuffer,ft.layoutFloodLightDataBuffer];ft.layoutFacadePaintBuffer&&(Kt=Kt.concat([ft.layoutFacadeDataBuffer,ft.layoutFacadeVerticalRangeBuffer,ft.layoutFacadePaintBuffer])),_t.draw(m,$.gl.TRIANGLES,M.depthMode,dn.disabled,M.blendMode,K?Xr.disabled:Xr.backCW,Bt,E.id,ft.layoutVertexBuffer,ft.indexBuffer,Et,E.paint,m.transform.zoom,dt,Kt)}};m.uploadCommonUniforms($,at,Le.toUnwrapped(),null,we),st.buildingWithoutFacade&&Ft(st.buildingWithoutFacade,at),st.buildingWithFacade&&(pt!==at&&m.uploadCommonUniforms($,pt,Le.toUnwrapped(),null,we),Ft(st.buildingWithFacade,pt))}}function pP(M,m,v,E,D,z,$,K,ee,ne,de,we,be,Ae){const ze=M.context.gl,Le=M.depthModeForSublayer(1,Sr.ReadOnly,ze.LEQUAL,!0),rt=.1*(1-(st=de))+3*st;var st;const dt=M._showOverdrawInspector,pt=we,at=new hP;dt||If(at,M,m,v,E,Le,new dn({func:ze.ALWAYS,mask:255},255,255,ze.KEEP,ze.KEEP,ze.REPLACE),new rn([ze.ONE,ze.ONE,ze.ONE,ze.ONE],i.aq.transparent,[!1,!1,!1,!0],ze.MIN),Xr.disabled,D,"sdf",z,$,K,ee,ne,rt,pt,!1,void 0);{const Bt=dt?dn.disabled:new dn({func:ze.EQUAL,mask:255},255,255,ze.KEEP,ze.DECR,ze.DECR),wt=dt?M.colorModeForRenderPass():new rn([ze.ONE_MINUS_DST_ALPHA,ze.DST_ALPHA,ze.ONE,ze.ONE],i.aq.transparent,[!0,!0,!0,!0]);If(at,M,m,v,E,Le,Bt,wt,Xr.disabled,D,"color",z,$,K,ee,ne,rt,pt,!1,void 0)}}function fP(M){return[M[0]*i.e7,M[1]*i.e7,M[2]*i.e7,0]}function x3(M,m,v,E,D,z,$,K,ee){const ne=E.getSource(),de=v.globeSharedBuffers;if(!de)return;let we,be,Ae;if(m&&(we=E.getTile(m)),ne instanceof i.aV?(be=ne.texture,Ae=i.dw(0,0,v.transform)):we&&m&&(be=we.texture,Ae=i.dw(m.canonical.z,m.canonical.x,v.transform)),!be||!Ae)return;M||(Ae=i.cC(i.bb(),Ae,[1,-1,1]));const ze=v.context,Le=ze.gl,rt=D.paint.get("raster-resampling")==="nearest"?Le.NEAREST:Le.LINEAR,st=v.colorModeForDrapableLayerRenderPass(z),dt=$.defines;dt.push("GLOBE_POLES");const pt=new Sr(Le.LEQUAL,Sr.ReadWrite,v.depthRangeFor3D),at=Float32Array.from(v.transform.expandedFarZProjMatrix),Bt=Float32Array.from(i.du(i.dv(new i.cn(0,0,0))));v.terrain&&v.terrain.prepareDrawTile(),ze.activeTexture.set(Le.TEXTURE0),be.bind(rt,Le.CLAMP_TO_EDGE),ze.activeTexture.set(Le.TEXTURE1),be.bind(rt,Le.CLAMP_TO_EDGE),"useMipmap"in be&&ze.extTextureFilterAnisotropic&&v.transform.pitch>20&&Le.texParameterf(Le.TEXTURE_2D,ze.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,ze.extTextureFilterAnisotropicMax);const[wt,Ft,ft,_t]=m?de.getPoleBuffers(m.canonical.z,!1):de.getPoleBuffers(0,!0),Et=D.paint.get("raster-elevation");let Kt;M?(Kt=wt,v.renderDefaultNorthPole=Et!==0):(Kt=Ft,v.renderDefaultSouthPole=Et!==0);const qt=fP($.mix),ns=((Cs,Ls,Zt,Ht,ss,is,hs,Qs,Ws,Ks,As,jr,Pr,pr)=>lF(Cs,Ls,Zt,Ht,new Float32Array(16),new Float32Array(9),[0,0],ss,[0,0],[0,0,0,0],1,{opacity:1,mix:0},hs,[0,0],Ws,2,As,jr,Pr,1,0,pr))(v,at,Bt,Ae,i.al(v.transform.zoom),0,D,0,Et,0,qt,$.offset,$.range,z),Jt=v.getOrCreateProgram("raster",{defines:dt});v.uploadCommonUniforms(ze,Jt,null),Jt.draw(v,Le.TRIANGLES,pt,ee,st,K,ns,D.id,Kt,ft,_t)}function xP(M){if(M.isOrthographic)return[0,0,0,0];const m=M._nearZ,v=M.projection.farthestPixelDistance(M),E=v-m,D=.2*M.height,z=m+D;return[m,v,(z-D-m)/E,(z-m)/E]}function gF(M,m,v,E){if(M)return m instanceof gh&&M instanceof Cp?m.getTextureDescriptor(M,v,!0):{texture:M.texture,mix:fP(E.mix),offset:E.offset,buffer:0,tileSize:1}}var gP=i.e8([{name:"a_index",type:"Int16",components:1}]);class yF{constructor(m,v,E,D){const z={width:E[0],height:E[1],data:null},$=m.gl;this.targetColorTexture=new i.T(m,z,$.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new i.T(m,z,$.RGBA8,{useMipmap:!1}),this.context=m,this.updateParticleTexture(v,D),this.lastInvalidatedAt=0}updateParticleTexture(m,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 E=this.context.gl,D=v.width*v.height;this.particleTexture0=new i.T(this.context,v,E.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new i.T(this.context,v,E.RGBA8,{premultiply:!1,useMipmap:!1});const z=new i.e9;z.reserve(D);for(let $=0;$0){const qt=i.ec(v.canonical,ee),ns=i.ed(qt);be=i.aD(new Float32Array(16),ee.globeMatrix,ns),i.aD(be,ee.projMatrix,be)}const Ae=i.bb();Ae[12]+=2*D/(i.o.devicePixelRatio*ee.width),Ae[13]+=2*z/(i.o.devicePixelRatio*ee.height),i.aD(be,Ae,be);const ze=M.getOrCreateProgram("debug",{defines:we}),Le=m.getTileByID(v.key);M.terrain&&M.terrain.setupElevationDraw(Le,ze);const rt=Sr.disabled,st=dn.disabled,dt=M.colorModeForRenderPass(),pt="$debug";K.activeTexture.set(ne.TEXTURE0),M.emptyTexture.bind(ne.LINEAR,ne.CLAMP_TO_EDGE),de?Le._makeGlobeTileDebugBuffers(M.context,ee):Le._makeDebugTileBoundsBuffers(M.context,ee.projection);const at=Le._tileDebugBuffer||M.debugBuffer,Bt=Le._tileDebugIndexBuffer||M.debugIndexBuffer,wt=Le._tileDebugSegments||M.debugSegments;if(ze.draw(M,ne.LINE_STRIP,rt,st,dt,Xr.disabled,r2(be,E.toPremultipliedRenderColor(null)),pt,at,Bt,wt,null,null,null,[Le._globeTileDebugBorderBuffer]),$){const qt=Le.latestRawTileData,ns=Math.floor((qt&&qt.byteLength||0)/1024);let Jt=v.canonical.toString();v.overscaledZ!==v.canonical.z&&(Jt+=` => ${v.overscaledZ}`),Jt+=` ${Le.state}`,Jt+=` ${ns}kb`,function(Cs,Ls){Cs.initDebugOverlayCanvas();const Zt=Cs.debugOverlayCanvas,Ht=Cs.context.gl,ss=Cs.debugOverlayCanvas.getContext("2d");ss.clearRect(0,0,Zt.width,Zt.height),ss.shadowColor="white",ss.shadowBlur=2,ss.lineWidth=1.5,ss.strokeStyle="white",ss.textBaseline="top",ss.font="bold 36px Open Sans, sans-serif",ss.fillText(Ls,5,5),ss.strokeText(Ls,5,5),Cs.debugOverlayTexture.update(Zt),Cs.debugOverlayTexture.bind(Ht.LINEAR,Ht.CLAMP_TO_EDGE)}(M,Jt)}const Ft=m.getTile(v).tileSize,ft=512/Math.min(Ft,512)*(v.overscaledZ/ee.zoom)*.5,_t=Le._tileDebugTextBuffer||M.debugBuffer,Et=Le._tileDebugTextIndexBuffer||M.quadTriangleIndexBuffer,Kt=Le._tileDebugTextSegments||M.debugSegments;ze.draw(M,ne.TRIANGLES,rt,st,rn.alphaBlended,Xr.disabled,r2(be,i.aq.transparent.toPremultipliedRenderColor(null),ft),pt,_t,Et,Kt,null,null,null,[Le._globeTileDebugTextBuffer])}function _F(M,m,v,E){g3(M,0,m+v/2,M.transform.width,v,E)}function wP(M,m,v,E){g3(M,m-v/2,0,v,M.transform.height,E)}function g3(M,m,v,E,D,z){const $=M.context,K=$.gl;K.enable(K.SCISSOR_TEST),K.scissor(m*i.o.devicePixelRatio,v*i.o.devicePixelRatio,E*i.o.devicePixelRatio,D*i.o.devicePixelRatio),$.clear({color:z}),K.disable(K.SCISSOR_TEST)}const Mpe=i.e8([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:vh}=Mpe;function Lf(M,m,v,E){M.emplaceBack(m,v,E)}class Zd{constructor(m){this.vertexArray=new i.ee,this.indices=new i.dC,Lf(this.vertexArray,-1,-1,1),Lf(this.vertexArray,1,-1,1),Lf(this.vertexArray,-1,1,1),Lf(this.vertexArray,1,1,1),Lf(this.vertexArray,-1,-1,-1),Lf(this.vertexArray,1,-1,-1),Lf(this.vertexArray,-1,1,-1),Lf(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=m.createVertexBuffer(this.vertexArray,vh),this.indexBuffer=m.createIndexBuffer(this.indices),this.segment=i.dy.simpleSegment(0,0,36,12)}}function Qh(M,m,v,E,D,z){const $=M.context.gl,K=m.paint.get("sky-atmosphere-color"),ee=m.paint.get("sky-atmosphere-halo-color"),ne=m.paint.get("sky-atmosphere-sun-intensity"),de=((we,be,Ae,ze,Le)=>({u_matrix_3f:we,u_sun_direction:be,u_sun_intensity:Ae,u_color_tint_r:[ze.r,ze.g,ze.b,ze.a],u_color_tint_m:[Le.r,Le.g,Le.b,Le.a],u_luminance:5e-5}))(i.eg(i.dE(),E),D,ne,K.toPremultipliedRenderColor(null),ee.toPremultipliedRenderColor(null));$.framebufferTexture2D($.FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_CUBE_MAP_POSITIVE_X+z,m.skyboxTexture,0),v.draw(M,$.TRIANGLES,Sr.disabled,dn.disabled,rn.unblended,Xr.frontCW,de,"skyboxCapture",m.skyboxGeometry.vertexBuffer,m.skyboxGeometry.indexBuffer,m.skyboxGeometry.segment)}const bF=i.e8([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class jP{constructor(m){const v=new i.eh;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 E=new i.dC;E.emplaceBack(0,1,2),E.emplaceBack(2,3,0),this.vertexBuffer=m.createVertexBuffer(v,bF.members),this.indexBuffer=m.createIndexBuffer(E),this.segments=i.dy.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const NP=i.e8([{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_opacity",components:1}]);class kP{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class wF{constructor(m){this.colorModeAlphaBlendedWriteRGB=new rn([1,Oo,1,Oo],i.aq.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new rn([1,0,1,0],i.aq.transparent,[!1,!1,!1,!0]),this.params=new kP,this.updateNeeded=!0}update(m){const v=m.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new jP(v);const E=this.params.sizeRange,D=this.params.intensityRange,z=function(de){const we=i.em(30),be=[];for(let Ae=0;Ae{const ft=z.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];Ft&&ft.push("ALPHA_PASS");const _t=m.getOrCreateProgram("globeAtmosphere",{defines:ft}),Et=((qt,ns,Jt,Cs,Ls,Zt,Ht,ss,is,hs,Qs,Ws)=>({u_frustum_tl:qt,u_frustum_tr:ns,u_frustum_br:Jt,u_frustum_bl:Cs,u_horizon:Ls,u_transition:Zt,u_fadeout_range:Ht,u_atmosphere_fog_color:ss.toArray01(),u_high_color:is.toArray01(),u_space_color:hs.toArray01(),u_temporal_offset:Qs,u_horizon_angle:Ws}))(z.frustumCorners.TL,z.frustumCorners.TR,z.frustumCorners.BR,z.frustumCorners.BL,z.frustumCorners.horizon,K,rt,de,be,ze,dt,Bt);m.uploadCommonUniforms(E,_t);const Kt=this.atmosphereBuffer;Kt&&_t.draw(m,D.TRIANGLES,$,dn.disabled,Ft?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Xr.backCW,Et,Ft?"atmosphere_glow_alpha":"atmosphere_glow",Kt.vertexBuffer,Kt.indexBuffer,Kt.segments)};wt(!1),wt(!0)}drawStars(m,v){const E=i.aC(v.properties.get("star-intensity"),0,1);if(E===0)return;const D=m.context,z=D.gl,$=m.transform,K=m.getOrCreateProgram("stars"),ee=i.bL([]);i.bN(ee,ee,-$._pitch),i.bM(ee,ee,-$.angle),i.bN(ee,ee,i.ap($._center.lat)),i.ek(ee,ee,-i.ap($._center.lng));const ne=i.bR(new Float32Array(16),ee),de=i.aD([],$.starsProjMatrix,ne),we=i.eg([],ne),be=i.el([],we),Ae=[0,1,0];i.dG(Ae,Ae,be),i.bJ(Ae,Ae,this.params.sizeMultiplier);const ze=[1,0,0];i.dG(ze,ze,be),i.bJ(ze,ze,this.params.sizeMultiplier);const Le=(rt=Ae,st=ze,dt=E,{u_matrix:Float32Array.from(de),u_up:rt,u_right:st,u_intensity_multiplier:dt});var rt,st,dt;m.uploadCommonUniforms(D,K),this.starsVx&&this.starsIdx&&K.draw(m,z.TRIANGLES,Sr.disabled,dn.disabled,this.colorModeAlphaBlendedWriteRGB,Xr.disabled,Le,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class Wx{constructor(){this.visibleTiles=[]}updateBorders(m,v){const E=[],D=[],z=m._getRenderableCoordinates(!1,!0);for(const ee of z){const ne=m.getTile(ee);if(!ne.hasData())continue;const de=ne.getBucket(v);de&&(de.isEmpty()||(E.push(ee.key),D.push({bucket:de,tileID:ee.canonical})))}let $=E.length!==this.visibleTiles.length;if(!$){E.sort();for(let ee=0;eeee.tileID.z-ne.tileID.z||ee.tileID.x-ne.tileID.x||ee.tileID.y-ne.tileID.y);for(const ee of D){const ne=new Array,de=new Array,we=ee.bucket;for(const be of we.featuresOnBorder)K.has(be.featureId)?de.push(be.footprintIndex):(K.add(be.featureId),ne.push(be.footprintIndex));we.updateFootprintHiddenFlags(ne,i.en,!1),we.updateFootprintHiddenFlags(de,i.en,!0)}}}function jF(M,m){const v=[...M],E=m.cameraWorldSizeForFog/m.worldSize,D=i.b9([]);return i.cC(D,D,[E,E,1]),i.aD(v,D,v),i.aD(v,m.worldToFogMatrix,v),v}function Ka(M,m,v,E,D){const z=v.material,$=E.context,{baseColorTexture:K,metallicRoughnessTexture:ee}=z.pbrMetallicRoughness,{normalTexture:ne,occlusionTexture:de,emissionTexture:we}=z;function be(ze,Le,rt){if(ze&&(M.push(Le),$.activeTexture.set($.gl.TEXTURE0+rt),ze.gfxTexture)){const{minFilter:st,magFilter:dt,wrapS:pt,wrapT:at}=ze.sampler;ze.gfxTexture.bindExtraParam(st,dt,pt,at)}}be(K,"HAS_TEXTURE_u_baseColorTexture",5),be(ee,"HAS_TEXTURE_u_metallicRoughnessTexture",6),be(ne,"HAS_TEXTURE_u_normalTexture",7),be(de,"HAS_TEXTURE_u_occlusionTexture",8),be(we,"HAS_TEXTURE_u_emissionTexture",9),D&&(D.texture||(D.texture=new i.dR(E.context,D.image,[D.image.height,D.image.height,D.image.height],$.gl.RGBA8)),$.activeTexture.set($.gl.TEXTURE0+10),D.texture&&D.texture.bind($.gl.LINEAR,$.gl.CLAMP_TO_EDGE),M.push("APPLY_LUT_ON_GPU")),v.texcoordBuffer&&(M.push("HAS_ATTRIBUTE_a_uv_2f"),m.push(v.texcoordBuffer)),v.colorBuffer&&(M.push(v.colorBuffer.itemSize===12?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),m.push(v.colorBuffer)),v.normalBuffer&&(M.push("HAS_ATTRIBUTE_a_normal_3f"),m.push(v.normalBuffer)),v.pbrBuffer&&(M.push("HAS_ATTRIBUTE_a_pbr"),M.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),m.push(v.pbrBuffer)),z.alphaMode!=="OPAQUE"&&z.alphaMode!=="MASK"||M.push("UNPREMULT_TEXTURE_IN_SHADER"),z.defined||M.push("DIFFUSE_SHADED");const Ae=E.shadowRenderer;Ae&&(M.push("RENDER_SHADOWS"),Ae.useNormalOffset&&M.push("NORMAL_OFFSET"))}function Y1(M,m,v,E,D,z){const $=M.modelOpacity,K=m.context,ee=new Sr(m.context.gl.LEQUAL,M.isLightMesh?Sr.ReadOnly:Sr.ReadWrite,m.depthRangeFor3D),ne=m.transform,de=M.mesh,we=de.material,be=we.pbrMetallicRoughness,Ae=m.style.fog;let ze;ze=m.transform.projection.zAxisUnit==="pixels"?[...M.nodeModelMatrix]:i.aD([],E.zScaleMatrix,M.nodeModelMatrix),i.aD(ze,E.negCameraPosMatrix,ze);const Le=i.b7([],ze);i.e6(Le,Le);const rt=v.paint.get("model-color-use-theme").constantOr("default")==="none",st=v.paint.get("model-emissive-strength").constantOr(0),dt=W0(new Float32Array(M.worldViewProjection),new Float32Array(ze),new Float32Array(Le),null,m,$,be.baseColorFactor,we.emissiveFactor,be.metallicFactor,be.roughnessFactor,we,st,v,void 0,void 0,M.materialOverride,M.modelColor),pt={defines:[]},at=[],Bt=m.shadowRenderer;Bt&&(Bt.useNormalOffset=!1),Ka(pt.defines,at,de,m,rt?null:v.lut);let wt=null;if(Ae){const _t=jF(M.nodeModelMatrix,m.transform);if(wt=new Float32Array(_t),ne.projection.name!=="globe"){const Et=de.aabb.min,Kt=de.aabb.max,[qt,ns]=Ae.getOpacityForBounds(_t,Et[0],Et[1],Kt[0],Kt[1]);pt.overrideFog=qt>=sa||ns>=sa}}const Ft=oc(m,v.paint.get("model-cutoff-fade-range"));Ft.shouldRenderCutoff&&pt.defines.push("RENDER_CUTOFF");const ft=m.getOrCreateProgram("model",pt);m.uploadCommonUniforms(K,ft,null,wt,Ft),m.renderPass!=="shadow"&&Bt&&Bt.setupShadowsFromMatrix(M.nodeModelMatrix,ft),ft.draw(m,K.gl.TRIANGLES,ee,D,z,de.material.doubleSided?Xr.disabled:Xr.backCCW,dt,v.id,de.vertexBuffer,de.indexBuffer,de.segments,v.paint,m.transform.zoom,void 0,at)}function y3(M,m){return M.style._importedAsBasemap?"basemap":m.scope}function v3(M,m,v,E,D,z,$,K,ee,ne){const de=M.transform,we=!!m.isGeometryBloom&&m.isGeometryBloom;if(we&&M.renderPass==="shadow")return;const be=de.projection.name==="globe"?i.ev(v,de):[...v];i.aD(be,be,m.globalMatrix);const Ae=i.aD([],E,be);if(m.meshes)for(const ze of m.meshes){const Le=K.get(ze.material.name);if(Le&&Le.opacity<=0)continue;if(ze.material.alphaMode!=="BLEND"){$.push({mesh:ze,depth:0,modelIndex:D,worldViewProjection:Ae,nodeModelMatrix:be,isLightMesh:we,materialOverride:Le,modelOpacity:ee,modelColor:ne,node:m,modelMatrix:v});continue}const rt=i.ah([],ze.centroid,Ae);!de.isOrthographic&&rt[2]<=0||z.push({mesh:ze,depth:rt[2],modelIndex:D,worldViewProjection:Ae,nodeModelMatrix:be,isLightMesh:we,materialOverride:Le,modelOpacity:ee,modelColor:ne,node:m,modelMatrix:v})}if(m.children)for(const ze of m.children)v3(M,ze,v,E,D,z,$,K,ee,ne)}function X1(M,m,v,E){const D=v.shadowRenderer;if(!D)return;const z=D.getShadowPassDepthMode(),$=D.calculateShadowPassMatrixFromMatrix(m),K=cP($);v.getOrCreateProgram("modelDepth").draw(v,v.context.gl.TRIANGLES,z,dn.disabled,rn.disabled,Xr.disabled,K,E.id,M.vertexBuffer,M.indexBuffer,M.segments,E.paint,v.transform.zoom,void 0,void 0)}function SP(M,m,v,E){const D=function(de,we){if(we.footprintDebugMesh)return we.footprintDebugMesh;if(!we.footprint)return null;const be=de.context,Ae=we.footprint.vertices,ze=we.footprint.indices,Le=new i.dB;Le.reserve(Ae.length);for(const Et of Ae)Le.emplaceBack(Et.x,Et.y);const rt=new i.dC;rt.reserve(ze.length);for(let Et=0;Et0){const be=z.terrain,Ae=be.findDEMTileFor(K);Ae&&Ae.dem?ee=i.ex.create(be,K,Ae):we=0}if(we===0&&($.terrainElevationMin=0,$.terrainElevationMax=0),we===$.validForExaggeration&&(we===0||ee&&ee._demTile&&ee._demTile.tileID===$.validForDEMTile.id&&ee._dem._timestamp===$.validForDEMTile.timestamp))return!1;for(const be in $.instancesPerModel){const Ae=$.instancesPerModel[be];for(let ze=0;zene&&(ne=Ae.max)}const de=i.aC(E.x,z,$)-E.x,we=i.aC(E.y,K,ee)-E.y,be=i.bU(ne,m.center.lat)-E.z;return m._zoomFromMercatorZ(Math.sqrt(de*de+we*we+be*be))}function Qi(M,m,v,E,D,z,$){const K=M.context,ee=M.renderPass==="shadow",ne=M.shadowRenderer,de=ee&&ne?ne.getShadowPassDepthMode():new Sr(K.gl.LEQUAL,Sr.ReadWrite,M.depthRangeFor3D),we=M.isTileAffectedByFog(z),be=M.transform.projection.name==="globe";if(v.meshes)for(const Ae of v.meshes){const ze=be?[]:["MODEL_POSITION_ON_GPU"],Le=[];let rt,st,dt;const pt=!be&&E.instancedDataArray.length>20;pt&&ze.push("INSTANCED_ARRAYS");const at=oc(M,m.paint.get("model-cutoff-fade-range"));if(at.shouldRenderCutoff&&ze.push("RENDER_CUTOFF"),ee&&ne)rt=M.getOrCreateProgram("modelDepth",{defines:ze}),st=cP($.shadowTileMatrix,$.shadowTileMatrix,Float32Array.from(v.globalMatrix)),dt=rn.disabled;else{Ka(ze,Le,Ae,M,m.paint.get("model-color-use-theme").constantOr("default")==="none"?null:m.lut),rt=M.getOrCreateProgram("model",{defines:ze,overrideFog:we});const wt=Ae.material,Ft=wt.pbrMetallicRoughness,ft=m.paint.get("model-opacity").constantOr(1),_t=m.paint.get("model-emissive-strength").constantOr(0);st=W0(z.expandedProjMatrix,Float32Array.from(v.globalMatrix),new Float32Array(16),null,M,ft,Ft.baseColorFactor,wt.emissiveFactor,Ft.metallicFactor,Ft.roughnessFactor,wt,_t,m,D),ne&&($.shadowUniformsInitialized?rt.setShadowUniformValues(K,ne.getShadowUniformValues()):(ne.setupShadows(z.toUnwrapped(),rt,"model-tile"),$.shadowUniformsInitialized=!0)),dt=at.shouldRenderCutoff||ft<1||wt.alphaMode!=="OPAQUE"?rn.alphaBlended:rn.unblended}M.uploadCommonUniforms(K,rt,z.toUnwrapped(),null,at);const Bt=Ae.material.doubleSided?Xr.disabled:Xr.backCCW;if(pt)Le.push(E.instancedDataBuffer),rt.draw(M,K.gl.TRIANGLES,de,dn.disabled,dt,Bt,st,m.id,Ae.vertexBuffer,Ae.indexBuffer,Ae.segments,m.paint,M.transform.zoom,void 0,Le,E.instancedDataArray.length);else{const wt=ee?"u_instance":"u_normal_matrix";for(let Ft=0;Ftee[1]?$:ee,z[0]=v.max[0],$=i.aE(i.bE(),z,D),K=$[1]ee[1]?$:ee,z[1]=v.min[1],$=i.aE(i.bE(),z,D),K=$[1]ee[1]?$:ee;const ne=i.aC(E[0],0,1),de=100*m.pixelsPerMeter*i.aC(E[1],0,1),we=i.aC(E[2],0,1),be=i.ey(i.bE(),K,ee,ne),Ae=Math.tan(.5*m.fovX),ze=-be[2]*Ae;if(de===0)return be[1]<-Math.abs(ze)?we:1;const Le=(-Math.abs(ze)-be[1])/de,rt=(dt,pt,at)=>(1-at)*dt+at*pt,st=i.aC(rt(1,we,Le),we,1);return rt(1,st,i.aC((m.pitch-20)/20,0,1))}class b3{}class kF{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(m,v,E){{const we=this._storage.get(v.id);if(we)return we.lastUsedFrameIdx=m,we.buf}const D=E.gl,z=D.getBufferParameter(D.ELEMENT_ARRAY_BUFFER,D.BUFFER_SIZE),$=new ArrayBuffer(z),K=new Int16Array($);D.getBufferSubData(D.ELEMENT_ARRAY_BUFFER,0,new Int16Array($));const ee=new i.eA;for(let we=0;we30&&(E.buf.destroy(),this._storage.delete(v))}destroy(){for(const[m,v]of this._storage)v.buf.destroy(),this._storage.delete(m)}}class SF{constructor(){this.occluderSize=30,this.depthOffset=-1e-4}}const J1=i.e8([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]);class CF{constructor(m){this.revealStart=11,this.revealRange=2}}const Tpe=i.e8([{type:"Float32",name:"a_pos_2f",components:2}]);class MF{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(m,v){const E=m.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const $=new i.eB,K=new i.dC;$.emplaceBack(-1,-1),$.emplaceBack(1,-1),$.emplaceBack(1,1),$.emplaceBack(-1,1),K.emplaceBack(0,1,2),K.emplaceBack(0,2,3),this.vignetteVx=m.context.createVertexBuffer($,Tpe.members),this.vignetteIdx=m.context.createIndexBuffer(K)}const D=i.dy.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){m.uploadCommonUniforms(m.context,E);const $={u_vignetteShape:(z={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:z.vignetteColor};E.draw(m,m.context.gl.TRIANGLES,Sr.disabled,dn.disabled,rn.alphaBlended,Xr.disabled,$,"vignette",this.vignetteVx,this.vignetteIdx,D)}var z}}class w3{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(m,v){const E=m.getFreeCameraOptions().position,D=E.toAltitude(),z=E.toLngLat(),$=i.ap(z.lng),K=i.ap(z.lat),ee=m.pixelsPerMeter/v,ne=$*i.eD,de=i.eD*Math.log(Math.tan(Math.PI/4+K/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+de,be=-this._elevationPrev+D;this._accumulatedOffsetX+=(-this._offsetXPrev+ne)*ee,this._accumulatedOffsetY+=we*ee,this._accumulatedElevation+=be*ee,this._offsetXPrev=ne,this._offsetYPrev=de,this._elevationPrev=D}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function j3(M,m){return[-(M[0]-Math.floor(M[0]/m)*m),-(M[1]-Math.floor(M[1]/m)*m),-(M[2]-Math.floor(M[2]/m)*m)]}function TP(M){const m=i.em(1323123451230),v=[];for(let E=0;E Rain"),this._vignetteParams={strength:1,start:.7,range:1,fadePower:.4,color:{r:.27,g:.27,b:.27,a:1}},this.particlesCount=16e3}update(m){const v=m.context;if(!this.particlesVx){const E=TP(this.particlesCount),D=new i.eE,z=new i.dC;let $=0;const K=i.em(1323123451230);for(let ee=0;eeE)return;const D=Zx(0,1,v.revealStart,v.revealStart+v.revealRange,E);if(!this.particlesVx||!this.particlesIdx)return;const z=structuredClone(this._params);let $=[-z.direction.x,z.direction.y,-100];i.ay($,$);const K=structuredClone(this._vignetteParams);K.strength*=D,z.overrideStyleParameters||(z.intensity=m.style.rain.state.density,z.timeFactor=m.style.rain.state.intensity,z.color=structuredClone(m.style.rain.state.color),$=structuredClone(m.style.rain.state.direction),z.screenThinning.intensity=m.style.rain.state.centerThinning,z.dropletSizeX=m.style.rain.state.dropletSize[0],z.dropletSizeYScale=m.style.rain.state.dropletSize[1]/m.style.rain.state.dropletSize[0],z.distortionStrength=100*m.style.rain.state.distortionStrength,K.strength=1,K.color=structuredClone(m.style.rain.state.vignetteColor));const ee=this.updateOnRender(m,z.timeFactor),ne=m.context,de=ne.gl,we=m.transform;this.screenTexture&&this.screenTexture.size[0]===m.width&&this.screenTexture.size[1]===m.height||(this.screenTexture=new i.T(ne,{width:m.width,height:m.height,data:null},de.RGBA8)),z.distortionStrength>0&&(ne.activeTexture.set(de.TEXTURE0),this.screenTexture.bind(de.LINEAR,de.CLAMP_TO_EDGE),de.copyTexSubImage2D(de.TEXTURE_2D,0,0,0,0,0,m.width,m.height));const be=m.getOrCreateProgram("rainParticle");m.uploadCommonUniforms(ne,be),ne.activeTexture.set(de.TEXTURE0),this.screenTexture.bind(de.LINEAR,de.CLAMP_TO_EDGE);const Ae=[z.color.r,z.color.g,z.color.b,z.color.a],ze=(Le,rt)=>{const st=j3(this._movement.getPosition(),Le),dt=z.dropletSizeX,pt=z.dropletSizeX*z.dropletSizeYScale,at=m.width/2,Bt=m.height/2,wt=Zx(0,z.screenThinning.start,0,1,z.screenThinning.intensity),Ft=Zx(.001,z.screenThinning.range,0,1,z.screenThinning.intensity),ft=Zx(0,z.screenThinning.particleOffset,0,1,z.screenThinning.intensity),_t=(Et={modelview:ee.modelviewMatrix,projection:ee.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:st,velocityConeAperture:z.velocityConeAperture,velocity:z.velocity,boxSize:Le,rainDropletSize:[dt,pt],distortionStrength:z.distortionStrength,rainDirection:$,color:Ae,screenSize:[we.width,we.height],thinningCenterPos:[at,Bt],thinningShape:[wt,Ft,Math.pow(10,z.screenThinning.fadePower)],thinningAffectedRatio:z.screenThinning.affectedRatio,thinningParticleOffset:ft,shapeDirectionalPower:z.shapeDirPower,shapeNormalPower:z.shapeNormalPower,mode:rt?0:1},{u_modelview:Float32Array.from(Et.modelview),u_projection:Float32Array.from(Et.projection),u_time:Et.time,u_cam_pos:Et.camPos,u_texScreen:0,u_velocityConeAperture:Et.velocityConeAperture,u_velocity:Et.velocity,u_boxSize:Et.boxSize,u_rainDropletSize:Et.rainDropletSize,u_distortionStrength:Et.distortionStrength,u_rainDirection:Et.rainDirection,u_color:Et.color,u_screenSize:Et.screenSize,u_thinningCenterPos:Et.thinningCenterPos,u_thinningShape:Et.thinningShape,u_thinningAffectedRatio:Et.thinningAffectedRatio,u_thinningParticleOffset:Et.thinningParticleOffset,u_shapeDirectionalPower:Et.shapeDirectionalPower,u_shapeNormalPower:Et.shapeNormalPower,u_mode:Et.mode});var Et;const Kt=Math.round(z.intensity*this.particlesCount),qt=i.dy.simpleSegment(0,0,4*Kt,2*Kt);be.draw(m,de.TRIANGLES,Sr.disabled,dn.disabled,rn.alphaBlended,Xr.disabled,_t,"rain_particles",this.particlesVx,this.particlesIdx,qt)};z.distortionStrength>0&&ze(z.boxSize,!0),ze(z.boxSize,!1),this._vignette.draw(m,K)}}const Q0=i.e8([{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 TF extends d2{constructor(m){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 CF("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(m){const v=m.context;if(!this.particlesVx){const E=TP(this.particlesCount),D=new i.eF,z=new i.dC;let $=0;const K=i.em(1323123451230);for(let ee=0;ee$)return;const K=Zx(0,1,z.revealStart,z.revealStart+z.revealRange,$);D.strength*=K,v.overrideStyleParameters||(v.intensity=m.style.snow.state.density,v.timeFactor=m.style.snow.state.intensity,v.color=structuredClone(m.style.snow.state.color),E=structuredClone(m.style.snow.state.direction),v.screenThinning.intensity=m.style.snow.state.centerThinning,v.billboardSize=2.79*m.style.snow.state.flakeSize,D.strength=1,D.color=structuredClone(m.style.snow.state.vignetteColor));const ee=this.updateOnRender(m,v.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const ne=m.context,de=ne.gl,we=m.transform,be=m.getOrCreateProgram("snowParticle");m.uploadCommonUniforms(ne,be),((Ae,ze,Le)=>{const rt=j3(this._movement.getPosition(),Ae),st=we.width/2,dt=we.height/2,pt=Zx(0,Le.screenThinning.start,0,1,Le.screenThinning.intensity),at=Zx(.001,Le.screenThinning.range,0,1,Le.screenThinning.intensity),Bt=Zx(0,Le.screenThinning.particleOffset,0,1,Le.screenThinning.intensity),wt=(Ft={modelview:ee.modelviewMatrix,projection:ee.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:rt,velocityConeAperture:Le.velocityConeAperture,velocity:Le.velocity,horizontalOscillationRadius:Le.horizontalOscillationRadius,horizontalOscillationRate:Le.horizontalOscillationRate,boxSize:Ae,billboardSize:1*Le.billboardSize,simpleShapeParameters:[Le.shapeFadeStart,Le.shapeFadePower],screenSize:[we.width,we.height],thinningCenterPos:[st,dt],thinningShape:[pt,at,Math.pow(10,Le.screenThinning.fadePower)],thinningAffectedRatio:Le.screenThinning.affectedRatio,thinningParticleOffset:Bt,color:[Le.color.r,Le.color.g,Le.color.b,Le.color.a],direction:E},{u_modelview:Float32Array.from(Ft.modelview),u_projection:Float32Array.from(Ft.projection),u_time:Ft.time,u_cam_pos:Ft.camPos,u_velocityConeAperture:Ft.velocityConeAperture,u_velocity:Ft.velocity,u_horizontalOscillationRadius:Ft.horizontalOscillationRadius,u_horizontalOscillationRate:Ft.horizontalOscillationRate,u_boxSize:Ft.boxSize,u_billboardSize:Ft.billboardSize,u_simpleShapeParameters:Ft.simpleShapeParameters,u_screenSize:Ft.screenSize,u_thinningCenterPos:Ft.thinningCenterPos,u_thinningShape:Ft.thinningShape,u_thinningAffectedRatio:Ft.thinningAffectedRatio,u_thinningParticleOffset:Ft.thinningParticleOffset,u_particleColor:Ft.color,u_direction:Ft.direction});var Ft;const ft=Math.round(Le.intensity*this.particlesCount),_t=i.dy.simpleSegment(0,0,4*ft,2*ft);this.particlesVx&&this.particlesIdx&&be.draw(m,de.TRIANGLES,Sr.disabled,dn.disabled,rn.alphaBlended,Xr.disabled,wt,"snow_particles",this.particlesVx,this.particlesIdx,_t)})(v.boxSize,0,v),this._vignette.draw(m,D)}}const AF={symbol:function(M,m,v,E,D){if(M.renderPass!=="translucent")return;const z=dn.disabled,$=M.colorModeForRenderPass(),K=v.layout.get("text-variable-anchor"),ee=v.layout.get("text-size-scale-range"),ne=i.aC(M.scaleFactor,ee[0],ee[1]);K&&function(be,Ae,ze,Le,rt,st,dt,pt){const at=Ae.transform,Bt=rt==="map",wt=st==="map";for(const Ft of be){const ft=Le.getTile(Ft),_t=ft.getBucket(ze);if(!_t||!_t.text||!_t.text.segments.get().length)continue;const Et=i.bj(_t.textSizeData,at.zoom,pt),Kt=Af(Ft,_t.getProjection(),at),qt=at.calculatePixelsToTileUnitsMatrix(ft),ns=ar(Kt,ft.tileID.canonical,wt,Bt,at,_t.getProjection(),qt),Jt=_t.hasIconTextFit()&&_t.hasIconData();Et&&mF(_t,Bt,wt,dt,at,ns,Ft,Math.pow(2,at.zoom-ft.tileID.overscaledZ),Et,Jt)}}(E,M,v,m,v.layout.get("text-rotation-alignment"),v.layout.get("text-pitch-alignment"),D,ne);const de=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&&(de||we)?u3(M,m,v,E,z,$):(de&&u3(M,m,v,E,z,$,{onlyIcons:!0}),we&&u3(M,m,v,E,z,$,{onlyText:!0})),m.map.showCollisionBoxes&&(yr(M,m,v,E,v.paint.get("text-translate"),v.paint.get("text-translate-anchor"),!0),yr(M,m,v,E,v.paint.get("icon-translate"),v.paint.get("icon-translate-anchor"),!1))},circle:function(M,m,v,E){if(M.renderPass!=="translucent")return;const D=v.paint.get("circle-opacity"),z=v.paint.get("circle-stroke-width"),$=v.paint.get("circle-stroke-opacity"),K=v.layout.get("circle-sort-key").constantOr(1)!==void 0,ee=v.paint.get("circle-emissive-strength");if(D.constantOr(1)===0&&(z.constantOr(1)===0||$.constantOr(1)===0))return;const ne=M.context,de=ne.gl,we=M.transform,be=!(!M.terrain||!M.terrain.enabled),Ae=v.layout.get("circle-elevation-reference"),ze=M.depthModeForSublayer(0,Sr.ReadOnly),Le=new Sr(M.context.gl.LEQUAL,Sr.ReadOnly,M.depthRangeFor3D),rt=Ae==="none"||be?ze:Le,st=dn.disabled,dt=M.colorModeForDrapableLayerRenderPass(ee),pt=we.projection.name==="globe",at=[i.aH(we.center.lng),i.aL(we.center.lat)],Bt=[];for(let Ft=0;FtFt.sortKey-ft.sortKey);const wt={useDepthForOcclusion:we.depthOcclusionForSymbolsAndCircles};for(const Ft of Bt){const{programConfiguration:ft,program:_t,layoutVertexBuffer:Et,dynamicBuffers:Kt,indexBuffer:qt,uniformValues:ns,tile:Jt}=Ft.state,Cs=Ft.segments;M.terrain&&M.terrain.setupElevationDraw(Jt,_t,wt),M.uploadCommonUniforms(ne,_t,Jt.tileID.toUnwrapped()),_t.draw(M,de.TRIANGLES,rt,st,dt,Xr.disabled,ns,v.id,Et,qt,Cs,v.paint,we.zoom,ft,Kt)}},heatmap:function(M,m,v,E){if(v.paint.get("heatmap-opacity")!==0)if(M.renderPass==="offscreen"){const D=M.context,z=D.gl,$=dn.disabled,K=new rn([z.ONE,z.ONE,z.ONE,z.ONE],i.aq.transparent,[!0,!0,!0,!0]),ee=M.transform.projection.name==="globe"?.5:.25;v.heatmapFbo=a2.createWithTexture(D,v.heatmapFbo,M.width*ee,M.height*ee),D.clear({color:i.aq.transparent});const ne=M.transform,de=ne.projection.name==="globe",we=de?["PROJECTION_GLOBE_VIEW"]:[],be=de?Xr.frontCCW:Xr.disabled,Ae=[i.aH(ne.center.lng),i.aL(ne.center.lat)];for(let ze=0;ze({u_image:0,u_color_ramp:1,u_opacity:we.paint.get("heatmap-opacity")}))(0,z),z.id,D.viewportBuffer,D.quadTriangleIndexBuffer,D.viewportSegments,z.paint,D.transform.zoom)}(M,v))},line:function(M,m,v,E){const D=v.paint.get("line-opacity"),z=v.paint.get("line-width");if(D.constantOr(1)===0||z.constantOr(1)===0)return;const $=v.paint.get("line-blend-mode");if($!=="default"&&M.transform.projection.name!=="globe")return M.terrain&&M.terrain.renderingToTexture?void function(K,ee,ne,de,we){if(K.renderPass!=="translucent")return;const be=K.context,Ae=be.gl,ze=K.terrain;if(!ze)return;const Le=be.bindFramebuffer.current,rt=K.emissiveMode==="mrt-fallback";ne.lineBlendDrapeFbo=a2.createWithTexture(be,ne.lineBlendDrapeFbo,ze.drapeBufferSize[0],ze.drapeBufferSize[1],!0),ne.lineBlendDrapeStencil=ne.lineBlendDrapeFbo._stencilRbo,rt&&Ae.drawBuffers([Ae.COLOR_ATTACHMENT0]),be.clear({color:Gx[we].clearColor,depth:1,stencil:0});const st=K.currentStencilSource,dt=K._tileClippingMaskIDs,pt=K.nextStencilID;K.currentStencilSource=void 0,K._tileClippingMaskIDs={},K.nextStencilID=1;const at=K._terrain;K._terrain=null,K._renderTileClippingMasks(ne,ee,de),m3(K,ee,ne,de,Gx[we].colorMode,!0),K._terrain=at,K.currentStencilSource=st,K._tileClippingMaskIDs=dt,K.nextStencilID=pt,be.bindFramebuffer.set(Le),rt&&Ae.drawBuffers([Ae.COLOR_ATTACHMENT0,Ae.COLOR_ATTACHMENT1]);const Bt=ze.drapeBufferSize;be.viewport.set([0,0,Bt[0],Bt[1]]);const wt=ne.lineBlendDrapeFbo;if(!wt)return;be.activeTexture.set(Ae.TEXTURE0),Ae.bindTexture(Ae.TEXTURE_2D,wt.colorAttachment0.get());const Ft=we==="additive"?1:ne.paint.get("line-opacity").constantOr(1),ft=ne.paint.get("line-emissive-strength").constantOr(0),_t=we==="additive"?K.colorModeForDrapableLayerRenderPass(ft):Gx[we].colorMode;K.getOrCreateProgram("lineBlendComposite").draw(K,Ae.TRIANGLES,Sr.disabled,dn.disabled,_t,Xr.disabled,n3(0,Ft,Gx[we].compositeUniformValue),ne.id,K.viewportBuffer,K.quadTriangleIndexBuffer,K.viewportSegments,ne.paint,K.transform.zoom)}(M,m,v,E,$):M.renderPass==="offscreen"?void function(K,ee,ne,de,we){const be=K.context,Ae=Math.ceil(K.width),ze=Math.ceil(K.height);ne.lineBlendFbo=a2.createWithTexture(be,ne.lineBlendFbo,Ae,ze,!0),ne.lineBlendStencil=ne.lineBlendFbo._stencilRbo,be.clear({color:Gx[we].clearColor,depth:1,stencil:0});const Le=K.currentStencilSource,rt=K._tileClippingMaskIDs,st=K.nextStencilID;K.currentStencilSource=void 0,K._tileClippingMaskIDs={},K.nextStencilID=1,K._renderTileClippingMasks(ne,ee,de);const dt=K.renderPass;K.renderPass="translucent",m3(K,ee,ne,de,Gx[we].colorMode),K.renderPass=dt,K.currentStencilSource=Le,K._tileClippingMaskIDs=rt,K.nextStencilID=st,be.viewport.set([0,0,K.width,K.height])}(M,m,v,E,$):M.renderPass==="translucent"?void function(K,ee,ne){const de=K.context,we=de.gl,be=ee.lineBlendFbo;if(!be)return;de.activeTexture.set(we.TEXTURE0),we.bindTexture(we.TEXTURE_2D,be.colorAttachment0.get());const Ae=ne==="additive"?1:ee.paint.get("line-opacity").constantOr(1),ze=ne==="additive"?K.colorModeForDrapableLayerRenderPass(ee.paint.get("line-emissive-strength").constantOr(0)):Gx[ne].colorMode;K.getOrCreateProgram("lineBlendComposite").draw(K,we.TRIANGLES,Sr.disabled,dn.disabled,ze,Xr.disabled,n3(0,Ae,Gx[ne].compositeUniformValue),ee.id,K.viewportBuffer,K.quadTriangleIndexBuffer,K.viewportSegments,ee.paint,K.transform.zoom)}(M,v,$):void 0;M.renderPass==="translucent"&&m3(M,m,v,E)},fill:function(M,m,v,E){const D=v.paint.get("fill-color"),z=v.paint.get("fill-opacity");if(z.constantOr(1)===0)return;const $=v.paint.get("fill-emissive-strength"),K=M.colorModeForDrapableLayerRenderPass($),ee=v.paint.get("fill-pattern"),ne=M.opaquePassEnabledForLayer()&&!ee.constantOr(1)&&D.constantOr(i.aq.transparent).a===1&&z.constantOr(0)===1?"opaque":"translucent";let de="none";v.layout.get("fill-elevation-reference")!=="none"?de="road":v.paint.get("fill-z-offset").constantOr(1)!==0&&(de="offset");const we=!(!M.terrain||!M.terrain.enabled),be={painter:M,sourceCache:m,layer:v,coords:E,colorMode:K,elevationType:de,terrainEnabled:we,pass:ne};if(M.renderPass==="shadow")return void(M.shadowRenderer&&de==="road"&&!we&&function(ze){const{painter:Le,sourceCache:rt,layer:st,coords:dt}=ze,pt=Le.context.gl,at=ze.painter.shadowRenderer;for(const Bt of dt){const wt=rt.getTile(Bt),Ft=wt.getBucket(st);if(!Ft)continue;const ft=Ft.elevatedStructures;if(!ft||!ft.shadowCasterSegments||ft.shadowCasterSegments.segments[0].primitiveLength===0)continue;Le.prepareDrawTile();const _t=Ft.bufferData.programConfigurations.get(st.id),Et=Le.isTileAffectedByFog(Bt),Kt=Le.getOrCreateProgram("elevatedStructuresDepth",{config:_t,overrideFog:Et}),qt=at.calculateShadowPassMatrixFromTile(wt.tileID.toUnwrapped());Le.uploadCommonUniforms(Le.context,Kt,Bt.toUnwrapped());const ns=nF(qt,0);Kt.draw(Le,pt.TRIANGLES,at.getShadowPassDepthMode(),dn.disabled,rn.disabled,Xr.disabled,ns,st.id,ft.vertexBuffer,ft.indexBuffer,ft.shadowCasterSegments,st.paint,Le.transform.zoom,_t)}}(be));const Ae=M.emissiveMode==="mrt-fallback";if(de!=="offset"){if(l2(be,!1,Ae),de==="road"){const ze=!we&&M.renderPass==="translucent";ze&&o2(M,m,v,E,"geometry"),l2(be,!0,Ae,dn.disabled),ze&&function(Le){const{painter:rt,sourceCache:st,layer:dt,coords:pt,colorMode:at}=Le,Bt=rt.context.gl,wt=Le.painter.shadowRenderer,Ft=!!wt&&wt.enabled,ft=new Sr(rt.context.gl.LEQUAL,Sr.ReadOnly,rt.depthRangeFor3D);let _t=[0,0,0];if(Ft){const Kt=rt.style.directionalLight,qt=rt.style.ambientLight;Kt&&qt&&(_t=Ap(rt.style,Kt,qt))}const Et=Kt=>{for(const qt of pt){const ns=st.getTile(qt),Jt=ns.getBucket(dt);if(!Jt)continue;const Cs=Jt.elevatedStructures;if(!Cs)continue;let Ls,Zt;if(Kt?(Ls=Cs.renderableBridgeSegments,Zt=Cs.bridgeProgramConfigurations.get(dt.id)):(Ls=Cs.renderableTunnelSegments,Zt=Cs.tunnelProgramConfigurations.get(dt.id)),!Ls||Ls.segments[0].primitiveLength===0)continue;Zt.updatePaintBuffers(),rt.prepareDrawTile();const Ht=rt.isTileAffectedByFog(qt),ss=[];Ft&&ss.push("RENDER_SHADOWS","NORMAL_OFFSET");const is=rt.getOrCreateProgram("elevatedStructures",{config:Zt,overrideFog:Ht,defines:ss}),hs=rt.translatePosMatrix(qt.projMatrix,ns,dt.paint.get("fill-translate"),dt.paint.get("fill-translate-anchor"));Ft&&wt.setupShadows(ns.tileID.toUnwrapped(),is,"vector-tile");const Qs=aF(hs,_t);rt.uploadCommonUniforms(rt.context,is,qt.toUnwrapped()),is.draw(rt,Bt.TRIANGLES,ft,dn.disabled,at,Xr.backCCW,Qs,dt.id,Cs.vertexBuffer,Cs.indexBuffer,Ls,dt.paint,rt.transform.zoom,Zt,[Cs.vertexBufferNormal])}};Et(!0),Et(!1)}(be)}}else l2(be,!1,Ae,M.stencilModeFor3D())},"fill-extrusion":function(M,m,v,E){const D=v.paint.get("fill-extrusion-opacity"),z=M.context,$=z.gl,K=M.terrain,ee=K&&K.renderingToTexture;if(D===0)return;const ne=M.emissiveMode==="mrt-fallback",de=M.conflationActive&&M.style.isLayerClipped(v,m.getSource()),we=M.style.order.indexOf(v.fqid);if(de&&function(be,Ae,ze,Le,rt){for(const st of Le){const dt=Ae.getTile(st).getBucket(ze);dt&&(dt.updateReplacement(st,be.replacementSource,rt),dt.uploadCentroid(be.context))}}(M,m,v,E,we),K||de)for(const be of E){const Ae=m.getTile(be).getBucket(v);Ae&&pF(M.context,m,be,Ae,v,K,de)}if(M.renderPass==="shadow"&&M.shadowRenderer){if(K&&D<.65&&v._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof i.af)return;const be=M.shadowRenderer.getShadowPassDepthMode();Z0(M,m,v,E,be,dn.disabled,rn.disabled,de)}else if(M.renderPass==="translucent"){const be=!v.paint.get("fill-extrusion-pattern").constantOr(1),Ae=v.paint.get("fill-extrusion-color").constantOr(i.aq.white);if(!ee&&Ae.a!==0){const ze=new Sr(M.context.gl.LEQUAL,Sr.ReadWrite,M.depthRangeFor3D);D===1&&be?Z0(M,m,v,E,ze,dn.disabled,rn.unblended,de):(Z0(M,m,v,E,ze,dn.disabled,rn.disabled,de),Z0(M,m,v,E,ze,M.stencilModeFor3D(),M.colorModeForRenderPass(),de),M.resetStencilClippingMasks())}if(M.style.enable3dLights()&&be&&(!K&&M.transform.projection.name!=="globe"||ee)){const ze=v.paint.get("fill-extrusion-opacity"),Le=v.paint.get("fill-extrusion-ambient-occlusion-intensity"),rt=v.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),st=v.paint.get("fill-extrusion-flood-light-intensity"),dt=v.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",pt=v.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(dt?null:v.lut).toArray01().slice(0,3),at=Le>0&&rt>0,Bt=st>0,wt=(_t,Et,Kt)=>(1-Kt)*_t+Kt*Et,Ft=new hP;Ft.translate=v.paint.get("fill-extrusion-translate"),Ft.translateAnchor=v.paint.get("fill-extrusion-translate-anchor"),Ft.edgeRadius=v.layout.get("fill-extrusion-edge-radius"),Ft.cutoffFadeRange=v.paint.get("fill-extrusion-cutoff-fade-range");const ft=_t=>{const Et=M.depthModeForSublayer(1,Sr.ReadOnly,$.LEQUAL,!0),Kt=v.paint.get(_t?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),qt=wt(.1,3,Kt),ns=M._showOverdrawInspector;if(!ns){const Jt=new dn({func:$.ALWAYS,mask:255},255,255,$.KEEP,$.KEEP,$.REPLACE),Cs=new rn([$.ONE,$.ONE,$.ONE,$.ONE],i.aq.transparent,[!1,!1,!1,!0],$.MIN);If(Ft,M,m,v,E,Et,Jt,Cs,Xr.disabled,_t,"sdf",ze,Le,rt,st,pt,qt,de,!1)}{const Jt=ns?dn.disabled:new dn({func:$.EQUAL,mask:255},255,255,$.KEEP,$.DECR,$.DECR),Cs=ns?M.colorModeForRenderPass():new rn([$.ONE_MINUS_DST_ALPHA,$.DST_ALPHA,$.ONE,$.ONE],i.aq.transparent,[!0,!0,!0,!0]);If(Ft,M,m,v,E,Et,Jt,Cs,Xr.disabled,_t,"color",ze,Le,rt,st,pt,qt,de,!1)}};if(ee){const _t=()=>{const Kt=K.drapeBufferSize[0],qt=K.drapeBufferSize[1];let ns=K.framebufferCopyTexture;return ns&&(!ns||ns.size[0]===Kt&&ns.size[1]===qt)||(ns&&ns.destroy(),ns=K.framebufferCopyTexture=new i.T(z,new i.q({width:Kt,height:qt}),$.RGBA8)),ns.bind($.LINEAR,$.CLAMP_TO_EDGE),$.copyTexSubImage2D($.TEXTURE_2D,0,0,0,0,0,Kt,qt),ns},Et=(Kt,qt,ns)=>{const Jt=M.depthModeForSublayer(1,Sr.ReadOnly,$.LEQUAL,!1),Cs=v.paint.get(Kt?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Ls=wt(.1,3,Cs);{const Zt=new rn([$.ONE,$.ONE,$.ONE,$.ONE],i.aq.transparent,[!1,!1,!1,!0]);If(Ft,M,m,v,E,Jt,dn.disabled,Zt,Xr.disabled,Kt,"clear",ze,Le,rt,st,pt,Ls,de,qt)}{const Zt=new dn({func:$.ALWAYS,mask:255},255,255,$.KEEP,$.KEEP,$.REPLACE),Ht=new rn([$.ONE,$.ONE,$.ONE,$.ONE],i.aq.transparent,[!1,!1,!1,!0],$.MIN);If(Ft,M,m,v,E,Jt,Zt,Ht,Xr.disabled,Kt,"sdf",ze,Le,rt,st,pt,Ls,de,qt)}ne&&!Kt&&(ns=_t());{const Zt=Kt?$.ZERO:$.ONE_MINUS_DST_ALPHA,Ht=new dn({func:$.EQUAL,mask:255},255,255,$.KEEP,$.DECR,$.DECR),ss=new rn([Zt,$.DST_ALPHA,$.ONE_MINUS_DST_ALPHA,$.ZERO],i.aq.transparent,[!0,!0,!0,!0]);If(Ft,M,m,v,E,Jt,Ht,ss,Xr.disabled,Kt,"color",ze,Le,rt,st,pt,Ls,de,qt)}if(!ne||Kt){const Zt=new rn([$.ONE,$.ONE,$.ONE,Kt?$.ZERO:$.ONE],i.aq.transparent,[!1,!1,!1,!0],Kt?$.FUNC_ADD:$.MAX);If(Ft,M,m,v,E,Jt,dn.disabled,Zt,Xr.disabled,Kt,"clear",ze,Le,rt,st,pt,Ls,de,qt,ns)}else{$.drawBuffers([$.NONE,$.COLOR_ATTACHMENT1]);const Zt=new dn({func:$.EQUAL,mask:255},254,255,$.KEEP,$.DECR,$.DECR),Ht=new rn([$.ONE,$.ONE,$.ONE,$.ONE],i.aq.transparent,[!0,!1,!1,!1],$.MAX);If(Ft,M,m,v,E,Jt,Zt,Ht,Xr.disabled,Kt,"emissive",ze,Le,rt,st,pt,Ls,de,qt,ns),$.drawBuffers([$.COLOR_ATTACHMENT0])}};if(at||Bt){let Kt;M.prepareDrawTile(),ne&&!at||(Kt=_t()),at&&Et(!0,!1,Kt),Bt&&Et(!1,!0,Kt)}}else at&&ft(!0),Bt&&ft(!1),(at||Bt)&&M.resetStencilClippingMasks()}}},building:function(M,m,v,E){M.currentLayer0&&z>0,ne=!0;const de=v.paint.get("building-vertical-scale");if(de<=0)return;M.shadowRenderer||(ne=!1);const we=M.conflationActive&&M.style.isLayerClipped(v,m.getSource()),be=M.style.order.indexOf(v.fqid);if(function(Ae,ze,Le,rt,st,dt){for(const pt of dt){const at=ze.getTile(pt).getBucket(Le);at&&(st&&at.updateReplacement(pt,Ae.replacementSource,rt),at.uploadUpdatedIndexBuffer(Ae.context))}}(M,m,v,be,we,E),function(Ae,ze,Le,rt){for(const st of rt){const dt=ze.getTile(st).getBucket(Le);dt&&dt.needsEvaluation()&&dt.uploadUpdatedColorBuffer(Ae.context)}}(M,m,v,E),v.resetLayerRenderingStats(M),M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!0),M.renderPass==="shadow"&&M.shadowRenderer){const Ae=[],ze=M.shadowRenderer.getShadowPassDepthMode();c2({painter:M,source:m,layer:v,coords:E,defines:Ae,blendMode:rn.disabled,depthMode:ze,opacity:K,verticalScale:de,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if(M.renderPass==="translucent"){let Ae=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];ne&&(Ae=Ae.concat("RENDER_SHADOWS")),M.shadowRenderer&&M.shadowRenderer.useNormalOffset&&(Ae=Ae.concat("NORMAL_OFFSET"));const ze=v.paint.get("building-facade-emissive-chance"),Le=v.paint.get("building-ambient-occlusion-intensity"),rt=v.paint.get("building-flood-light-intensity"),st=v.paint.get("building-flood-light-color-use-theme").constantOr("default")==="none",dt=v.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(st?null:v.lut).toArray01().slice(0,3),pt=v.paint.get("building-flood-light-ground-attenuation"),at=rt>0,Bt=new Sr(M.context.gl.LEQUAL,Sr.ReadWrite,M.depthRangeFor3D);K<1&&c2({painter:M,source:m,layer:v,coords:E,defines:Ae,blendMode:rn.disabled,depthMode:Bt,opacity:K,verticalScale:de,facadeEmissiveChance:ze,facadeAOIntensity:Le,floodLightIntensity:rt,floodLightColor:dt,depthOnly:!0});const wt=M.colorModeForRenderPass();c2({painter:M,source:m,layer:v,coords:E,defines:Ae,blendMode:wt,depthMode:Bt,opacity:K,verticalScale:de,facadeEmissiveChance:ze,facadeAOIntensity:Le,floodLightIntensity:rt,floodLightColor:dt});const Ft=v.paint.get("building-front-cutoff");p3(M.transform.pitch,Ft,!!M.terrain),ee&&pP(M,m,v,E,!0,K,D,z,rt,dt,$,we),at&&pP(M,m,v,E,!1,K,D,z,rt,dt,pt,we)}else if(M.renderPass==="light-beam"){const Ae=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],ze=new Sr(M.context.gl.LEQUAL,Sr.ReadOnly,M.depthRangeFor3D);c2({painter:M,source:m,layer:v,coords:E,defines:Ae,blendMode:rn.alphaBlended,depthMode:ze,opacity:K,verticalScale:de,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!1),M.resetStencilClippingMasks()},hillshade:function(M,m,v,E){if(M.renderPass!=="offscreen"&&M.renderPass!=="translucent"||M.style.disableElevatedTerrain)return;const D=M.context,z=M.terrain&&M.terrain.renderingToTexture,[$,K]=M.renderPass!=="translucent"||z?[{},E]:M.stencilConfigForOverlap(E);for(const ee of K){const ne=m.getTile(ee);if(ne.needsHillshadePrepare&&M.renderPass==="offscreen")mpe(M,ne,v);else if(M.renderPass==="translucent"){const de=M.depthModeForSublayer(0,Sr.ReadOnly),we=v.paint.get("hillshade-emissive-strength"),be=M.colorModeForDrapableLayerRenderPass(we),Ae=z&&M.terrain?M.terrain.stencilModeForRTTOverlap(ee):$[ee.overscaledZ];hpe(M,ee,ne,v,de,Ae,be)}}D.viewport.set([0,0,M.width,M.height]),M.resetStencilClippingMasks()},raster:function(M,m,v,E,D,z){if(M.renderPass!=="translucent")return;const $=v.paint.get("raster-opacity");if($===0)return;const K=M.transform.projection.name==="globe",ee=v.paint.get("raster-elevation")!==0,ne=ee&&K,de=M.terrain&&M.terrain.exaggeration()>0&&ee&&v.paint.get("raster-elevation-reference")==="ground",we=!K&&de;if(M.renderElevatedRasterBackface&&!ne)return;const be=M.context,Ae=be.gl,ze=m.getSource(),Le=function(_t,Et,Kt,qt,ns){const Jt=Et.paint.get("raster-color"),Cs=_t.type==="raster-array",Ls=[],Zt=Et.paint.get("raster-resampling"),Ht=Et.paint.get("raster-color-mix");let ss=Et.paint.get("raster-color-range");const is=[Ht[0],Ht[1],Ht[2],0],hs=Ht[3];let Qs=Zt==="nearest"?qt.NEAREST:qt.LINEAR;if(Cs&&(Ls.push("RASTER_ARRAY"),Jt||Ls.push("RASTER_COLOR"),Zt==="linear"&&Ls.push("RASTER_ARRAY_LINEAR"),Qs=qt.NEAREST,!ss&&_t.rasterLayers)){const Ws=_t.rasterLayers.find(({id:Ks})=>Ks===Et.sourceLayer);Ws&&Ws.fields&&Ws.fields.range&&(ss=Ws.fields.range)}if(ss=ss||[0,1],Jt){Ls.push("RASTER_COLOR"),Kt.activeTexture.set(qt.TEXTURE2),Et.updateColorRamp(ss);let Ws=Et.colorRampTexture;Ws||(Ws=Et.colorRampTexture=new i.T(Kt,Et.colorRamp,qt.RGBA8)),Ws.bind(Qs,qt.CLAMP_TO_EDGE)}return ns&&Ls.push("USE_MRT1"),{mix:is,range:ss,offset:hs,defines:Ls,resampling:Qs}}(ze,v,be,Ae,M.terrain&&M.terrain.renderingToTexture&&M.emissiveMode==="mrt-fallback");if(ze instanceof i.aV&&!E.length&&!K)return;const rt=v.paint.get("raster-emissive-strength"),st=M.colorModeForDrapableLayerRenderPass(rt),dt=M.terrain&&M.terrain.renderingToTexture,pt=!M.options.moving,at=v.paint.get("raster-resampling")==="nearest"?Ae.NEAREST:Ae.LINEAR;if(ze instanceof i.aV&&!E.length&&(ze.onNorthPole||ze.onSouthPole)){const _t=ee?M.stencilModeFor3D():dn.disabled;return void x3(!!ze.onNorthPole,null,M,m,v,rt,Le,Xr.disabled,_t)}if(!E.length)return;const[Bt,wt]=ze instanceof i.aV||dt?[{},E]:M.stencilConfigForOverlap(E),Ft=wt[wt.length-1].overscaledZ;ne&&Le.defines.push("PROJECTION_GLOBE_VIEW"),ee&&Le.defines.push("RENDER_CUTOFF","ELEVATED"),de&&Le.defines.push("ELEVATION_REFERENCE_GROUND");const ft=(_t,Et,Kt)=>{for(const qt of _t){const ns=qt.toUnwrapped(),Jt=m.getTile(qt);if(dt&&(!Jt||!Jt.hasData()))continue;be.activeTexture.set(Ae.TEXTURE0);const Cs=gF(Jt,ze,v,Le);if(!Cs||!Cs.texture)continue;const{texture:Ls,mix:Zt,offset:Ht,tileSize:ss,buffer:is}=Cs;let hs,Qs;dt?(hs=Sr.disabled,Qs=qt.projMatrix):ee?(hs=new Sr(Ae.LEQUAL,Sr.ReadWrite,M.depthRangeFor3D),Qs=K?Float32Array.from(M.transform.expandedFarZProjMatrix):M.transform.calculateProjMatrix(ns,pt)):(hs=M.depthModeForSublayer(qt.overscaledZ-Ft,$===1?Sr.ReadWrite:Sr.ReadOnly,Ae.LESS),Qs=M.transform.calculateProjMatrix(ns,pt));const Ws=M.terrain&&dt?M.terrain.stencilModeForRTTOverlap(qt):Bt[qt.overscaledZ],Ks=z?0:v.paint.get("raster-fade-duration");Jt.registerFadeDuration(Ks);const As=m.findLoadedParent(qt,0),jr=e2(Jt,As,m,M.transform,Ks);let Pr,pr;!jr.isFading&&Jt.refreshedUponExpiration&&(Jt.refreshedUponExpiration=!1),M.terrain&&M.terrain.prepareDrawTile(),be.activeTexture.set(Ae.TEXTURE0),Ls.bind(at,Ae.CLAMP_TO_EDGE),be.activeTexture.set(Ae.TEXTURE1),As?(As.texture&&As.texture.bind(at,Ae.CLAMP_TO_EDGE),Pr=Math.pow(2,As.tileID.overscaledZ-Jt.tileID.overscaledZ),pr=[Jt.tileID.canonical.x*Pr%1,Jt.tileID.canonical.y*Pr%1]):Ls.bind(at,Ae.CLAMP_TO_EDGE),"useMipmap"in Ls&&be.extTextureFilterAnisotropic&&M.transform.pitch>20&&Ae.texParameterf(Ae.TEXTURE_2D,be.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,be.extTextureFilterAnisotropicMax);const br=M.transform;let Qr;const bn=ee?xP(br):[0,0,0,0];let mn,Un,Vr,Vn,pn,Ea=0;if(ne&&ze instanceof i.aV&&ze.coordinates.length>3)mn=Float32Array.from(i.du(i.dv(new i.cn(0,0,0)))),Un=Float32Array.from(br.globeMatrix),Vr=Float32Array.from(i.dq(br)),Vn=[i.aH(br.center.lng),i.aL(br.center.lat)],Qr=ze.elevatedGlobePerspectiveTransform,pn=ze.elevatedGlobeGridMatrix||new Float32Array(9);else if(ne){const $a=i.dr(qt.canonical);Ea=i.ds($a.getCenter().lat),mn=Float32Array.from(i.du(i.dv(qt.canonical))),Un=Float32Array.from(br.globeMatrix),Vr=Float32Array.from(i.dq(br)),Vn=[i.aH(br.center.lng),i.aL(br.center.lat)],Qr=[0,0],pn=Float32Array.from(i.dt(qt.canonical,$a,Ea,br.worldSize/br._pixelsPerMercatorPixel))}else Qr=ze instanceof i.aV?ze.perspectiveTransform:[0,0],mn=new Float32Array(16),Un=new Float32Array(9),Vr=new Float32Array(16),Vn=[0,0],pn=new Float32Array(9);const pi=lF(M,Qs,mn,Un,Vr,pn,pr||[0,0],i.al(M.transform.zoom),Vn,bn,Pr||1,jr,v,Qr,ee?v.paint.get("raster-elevation"):0,2,Zt,Ht,Le.range,ss,is,rt),Wi=M.isTileAffectedByFog(qt),Ni=M.getOrCreateProgram("raster",{defines:Le.defines,overrideFog:Wi});if(M.uploadCommonUniforms(be,Ni,ns),ze instanceof i.aV){const $a=ze.elevatedGlobeVertexBuffer,On=ze.elevatedGlobeIndexBuffer;if(dt||!K)ze.boundsBuffer&&ze.boundsSegments&&Ni.draw(M,Ae.TRIANGLES,hs,dn.disabled,st,Xr.disabled,pi,v.id,ze.boundsBuffer,M.quadTriangleIndexBuffer,ze.boundsSegments);else if($a&&On){const Fn=br.zoom<=i.cJ?ze.elevatedGlobeSegments:ze.getSegmentsForLongitude(br.center.lng);Fn&&Ni.draw(M,Ae.TRIANGLES,hs,dn.disabled,st,Et,pi,v.id,$a,On,Fn)}}else if(ne){hs=new Sr(Ae.LEQUAL,Sr.ReadOnly,M.depthRangeFor3D);const $a=M.globeSharedBuffers;if($a){de&&(M.terrain.setupElevationDraw(Jt,Ni),M.uploadCommonUniforms(be,Ni,Jt.tileID.toUnwrapped()));const[On,Fn,ki]=$a.getGridBuffers(Ea,!1),Ji=Ni.getAttributeLocation(Ae,"a_texture_pos");Ji!==-1&&Ae.vertexAttribI4ui(Ji,0,0,0,0),Ni.draw(M,Ae.TRIANGLES,hs,Kt||Ws,M.colorModeForRenderPass(),Et,pi,v.id,On,Fn,ki)}}else if(we)hs=new Sr(Ae.LEQUAL,Sr.ReadWrite,M.depthRangeFor3D),M.terrain.setupElevationDraw(Jt,Ni),M.uploadCommonUniforms(be,Ni,Jt.tileID.toUnwrapped()),br.pitch>20&&Ni.draw(M,Ae.TRIANGLES,hs,dn.disabled,rn.disabled,Xr.frontCCW,pi,v.id,M.terrain.gridBuffer,M.terrain.gridIndexBuffer,M.terrain.gridSegments),Ni.draw(M,Ae.TRIANGLES,hs,Ws,st,Xr.backCCW,pi,v.id,M.terrain.gridBuffer,M.terrain.gridIndexBuffer,M.terrain.gridSegments);else{const{tileBoundsBuffer:$a,tileBoundsIndexBuffer:On,tileBoundsSegments:Fn}=M.getTileBoundsBuffers(Jt);Ni.draw(M,Ae.TRIANGLES,hs,Ws,st,Xr.disabled,pi,v.id,$a,On,Fn)}}if(!(ze instanceof i.aV)&&ne)for(const qt of _t){const ns=qt.canonical.y===(1<i.d$[is](ns));Zt.push(ns);const Ht=ns.canonical.x,ss=ns.canonical.y;for(const is of Zt){const hs=at.getTile(Et?is.wrapped():is);if(!hs)continue;const Qs=hs.rasterParticleState;if(!Qs)continue;const Ws=is.canonical.x+(1<Ft.tileID)),Ae&&(ne.activeTexture.set(de.TEXTURE0),M.imageManager.bind(M.context,v.scope));const wt=[];if(M.terrain&&M.terrain.renderingToTexture&&M.emissiveMode==="mrt-fallback"&&wt.push("USE_MRT1"),ee){const Ft=M.getOrCreateProgram(pt,{overrideFog:!1,overrideRtt:!0,defines:wt}),ft=new Float32Array(i.b9([])),_t=new i.aR(0,0,0,0,0),Et=Ae?cy(ft,K,$,M,0,v.scope,ze,ee,{tileID:_t,tileSize:be}):n2(ft,K,$,D.toPremultipliedRenderColor(z?null:v.lut));return void Ft.draw(M,de.TRIANGLES,st,rt,dt,Xr.disabled,Et,v.id,M.viewportBuffer,M.quadTriangleIndexBuffer,M.viewportSegments)}for(const Ft of Bt){const ft=M.isTileAffectedByFog(Ft),_t=M.getOrCreateProgram(pt,{overrideFog:ft,defines:wt}),Et=Ft.toUnwrapped(),Kt=E?Ft.projMatrix:M.transform.calculateProjMatrix(Et);M.prepareDrawTile();const qt=m?m.getTile(Ft):at?at[Ft.key]:new i.b0(Ft,be,we.zoom,M),ns=Ae?cy(Kt,K,$,M,0,v.scope,ze,ee,{tileID:Ft,tileSize:be}):n2(Kt,K,$,D.toPremultipliedRenderColor(z?null:v.lut));M.uploadCommonUniforms(ne,_t,Et);const{tileBoundsBuffer:Jt,tileBoundsIndexBuffer:Cs,tileBoundsSegments:Ls}=M.getTileBoundsBuffers(qt);_t.draw(M,de.TRIANGLES,st,rt,dt,Xr.disabled,ns,v.id,Jt,Cs,Ls)}},sky:function(M,m,v){const E=M._atmosphere?i.al(M.transform.zoom):1,D=v.paint.get("sky-opacity")*E;if(D===0)return;const z=M.context,$=v.paint.get("sky-type"),K=new Sr(z.gl.LEQUAL,Sr.ReadOnly,[0,1]),ee=M.frameCounter/1e3%1;$==="atmosphere"?M.renderPass==="offscreen"?v.needsSkyboxCapture(M)&&(function(ne,de){const we=ne.context,be=we.gl;let Ae=de.skyboxFbo;if(!Ae){Ae=de.skyboxFbo=we.createFramebuffer(32,32,1,null),de.skyboxGeometry=new Zd(we),de.skyboxTexture=we.gl.createTexture(),be.bindTexture(be.TEXTURE_CUBE_MAP,de.skyboxTexture),be.texParameteri(be.TEXTURE_CUBE_MAP,be.TEXTURE_WRAP_S,be.CLAMP_TO_EDGE),be.texParameteri(be.TEXTURE_CUBE_MAP,be.TEXTURE_WRAP_T,be.CLAMP_TO_EDGE),be.texParameteri(be.TEXTURE_CUBE_MAP,be.TEXTURE_MIN_FILTER,be.LINEAR),be.texParameteri(be.TEXTURE_CUBE_MAP,be.TEXTURE_MAG_FILTER,be.LINEAR);for(let st=0;st<6;++st)be.texImage2D(be.TEXTURE_CUBE_MAP_POSITIVE_X+st,0,be.RGBA,32,32,0,be.RGBA,be.UNSIGNED_BYTE,null)}we.bindFramebuffer.set(Ae.framebuffer),we.viewport.set([0,0,32,32]);const ze=de.getCenter(ne,!0),Le=ne.getOrCreateProgram("skyboxCapture"),rt=new Float64Array(16);i.b9(rt),i.ef(rt,rt,.5*-Math.PI),Qh(ne,de,Le,rt,ze,0),i.b9(rt),i.ef(rt,rt,.5*Math.PI),Qh(ne,de,Le,rt,ze,1),i.b9(rt),i.cE(rt,rt,.5*-Math.PI),Qh(ne,de,Le,rt,ze,2),i.b9(rt),i.cE(rt,rt,.5*Math.PI),Qh(ne,de,Le,rt,ze,3),i.b9(rt),Qh(ne,de,Le,rt,ze,4),i.b9(rt),i.ef(rt,rt,Math.PI),Qh(ne,de,Le,rt,ze,5),we.viewport.set([0,0,ne.width,ne.height])}(M,v),v.markSkyboxValid(M)):M.renderPass==="sky"&&function(ne,de,we,be,Ae){const ze=ne.context,Le=ze.gl,rt=ne.transform,st=ne.getOrCreateProgram("skybox");ze.activeTexture.set(Le.TEXTURE0),Le.bindTexture(Le.TEXTURE_CUBE_MAP,de.skyboxTexture);const dt=((pt,at,Bt,wt,Ft)=>({u_matrix:pt,u_sun_direction:at,u_cubemap:0,u_opacity:wt,u_temporal_offset:Ft}))(rt.skyboxMatrix,de.getCenter(ne,!1),0,be,Ae);ne.uploadCommonUniforms(ze,st),st.draw(ne,Le.TRIANGLES,we,dn.disabled,ne.colorModeForRenderPass(),Xr.backCW,dt,"skybox",de.skyboxGeometry.vertexBuffer,de.skyboxGeometry.indexBuffer,de.skyboxGeometry.segment)}(M,v,K,D,ee):$==="gradient"&&M.renderPass==="sky"&&function(ne,de,we,be,Ae){const ze=ne.context,Le=ze.gl,rt=ne.transform,st=ne.getOrCreateProgram("skyboxGradient");de.skyboxGeometry||(de.skyboxGeometry=new Zd(ze)),ze.activeTexture.set(Le.TEXTURE0);let dt=de.colorRampTexture;dt||(dt=de.colorRampTexture=new i.T(ze,de.colorRamp,Le.RGBA8)),dt.bind(Le.LINEAR,Le.CLAMP_TO_EDGE);const pt=((at,Bt,wt,Ft,ft)=>({u_matrix:at,u_color_ramp:0,u_center_direction:Bt,u_radius:i.ap(wt),u_opacity:Ft,u_temporal_offset:ft}))(rt.skyboxMatrix,de.getCenter(ne,!1),de.paint.get("sky-gradient-radius"),be,Ae);ne.uploadCommonUniforms(ze,st),st.draw(ne,Le.TRIANGLES,we,dn.disabled,ne.colorModeForRenderPass(),Xr.backCW,pt,"skyboxGradient",de.skyboxGeometry.vertexBuffer,de.skyboxGeometry.indexBuffer,de.skyboxGeometry.segment)}(M,v,K,D,ee)},custom:function(M,m,v,E){const D=M.context,z=v.implementation;if(!M.transform.projection.unsupportedLayers||!M.transform.projection.unsupportedLayers.includes("custom")||M.terrain&&(M.terrain.renderingToTexture||M.renderPass==="offscreen")&&v.isDraped(m)){if(M.renderPass==="offscreen"){const $=z.prerender;if($){if(M.setCustomLayerDefaults(),D.setColorMode(M.colorModeForRenderPass()),M.transform.projection.name==="globe"){const K=M.transform.pointMerc;$.call(z,D.gl,M.transform.customLayerMatrix(),M.transform.getProjection(),M.transform.globeToMercatorMatrix(),i.al(M.transform.zoom),[K.x,K.y],M.transform.pixelsPerMeterRatio)}else $.call(z,D.gl,M.transform.customLayerMatrix());D.setDirty(),M.setBaseState()}}else if(M.renderPass==="translucent"){if(M.terrain&&M.terrain.renderingToTexture){const K=z.renderToTile;if(K){const ee=E[0].canonical,ne={x:ee.x+E[0].wrap*(z.wrapTileId?0:1<{ne&&(ne.useNormalOffset=!0,de||(ne.enabled=!0))},be=m.getSource();if(M.renderPass==="light-beam"&&be.type!=="batched-model")return;if(be.type==="vector"||be.type==="geojson")return function(at,Bt,wt,Ft,ft){const _t=at.transform,Et=_t.projection.name==="globe",Kt=_t.getFreeCameraOptions().position;if(!at.modelManager)return;const qt=at.modelManager;wt.modelManager=qt;const ns=at.shadowRenderer;if(!wt._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const Jt=wt._unevaluatedLayout._values["model-id"],Cs=Object.assign({},wt.layout.get("model-id").parameters),Ls=at.style.order.indexOf(wt.fqid),Zt=wt.paint.get("model-opacity").constantOr(1);for(const Ht of Ft){const ss=Bt.getTile(Ht).getBucket(wt);if(!ss||ss.projection.name!==_t.projection.name)continue;const is=ss.getModelUris();if(is&&!ss.modelsRequested&&(qt.addModelsFromBucket(is,ft),ss.modelsRequested=!0),Et)Cs.zoom=Ht.overscaledZ;else{const pr=Q1(Ht,_t);Cs.zoom=pr}const hs=Jt.possiblyEvaluate(Cs);if(Xs(at,ss,Ht),Gs.shadowUniformsInitialized=!1,Gs.useSingleShadowCascade=!!ns&&ns.getMaxCascadeForTile(Ht.toUnwrapped())===0,at.renderPass==="shadow"&&ns){if(at.currentShadowCascade===1&&ss.isInsideFirstShadowMapFrustum)continue;const pr=_t.calculatePosMatrix(Ht.toUnwrapped(),_t.worldSize);if(Gs.tileMatrix.set(pr),Gs.shadowTileMatrix=Float32Array.from(ns.calculateShadowPassMatrixFromMatrix(pr)),Gs.aabb.min=[0,0,0],Gs.aabb.max[0]=Gs.aabb.max[1]=i.an,Gs.aabb.max[2]=0,NF(ss,Gs,at,wt.scope))continue}const Qs=1<0&&at.style.isLayerClipped(wt,Bt.getSource())&&ss.updateReplacement(Ht,at.replacementSource,Ls,wt.scope)&&(ss.uploaded=!1,ss.upload(at.context));let Ks=0;const As=new Array,jr=new Array,Pr=new Array;for(let pr in ss.instancesPerModel){const br=ss.instancesPerModel[pr];br.features.length>0&&!Et&&(pr=hs.evaluate(br.features[0].feature,{}));const Qr=qt.getModel(pr,ft);if(Qr||qt.hasURLBeenRequested(pr)||ss.modelUris.includes(pr)||(ss.modelUris.push(pr),ss.modelsRequested=!1),Qr&&Qr.uploaded)if(Et){const bn=i.bJ([],[Kt.x,Kt.y,Kt.z],at.transform.worldSize);i.eo(bn,bn);for(let mn=0;mn0&&Vn.elevationUpdate(pr.terrain,mn,Vr,Qr.source),Vn.needsReEvaluation(pr,Un,Qr)&&Vn.evaluate(Qr))}})(at,Bt,wt,Ft),function(){const pr=new Map;let br,Qr,bn;As?(br=Ft.length-1,Qr=-1,bn=-1):(br=0,Qr=Ft.length,bn=1);const mn=new Float64Array(16),Un=i.ce(),Vr=new i.P(0,0);for(let Vn=br;Vn!==Qr;Vn+=bn){const pn=Ft[Vn],Ea=Bt.getTile(pn).getBucket(wt);if(!Ea||!Ea.uploaded)continue;let pi=!1;Kt&&(pi=Kt.getMaxCascadeForTile(pn.toUnwrapped())===0);const Wi=_t.calculatePosMatrix(pn.toUnwrapped(),_t.worldSize),Ni=Ea.modelTraits;!Qs&&As&&(i.b7(mn,Wi),i.ah(Un,ns,mn),Vr.x=Un[0],Vr.y=Un[1]);const $a=[];Ea.setFilter(wt.filter);for(const On of Ea.getNodesInfo()){if(On.hiddenByReplacement||!On.node.meshes)continue;const Fn=On.node;let ki=0;at.terrain&&Fn.elevation&&(ki=Fn.elevation*at.terrain.exaggeration());const Ji=(()=>{const Sc=On.aabb;return hs.min=[...Sc.min],hs.max=[...Sc.max],hs.min[2]+=ki,hs.max[2]+=ki,i.ah(hs.min,hs.min,Wi),i.ah(hs.max,hs.max,Wi),hs})(),qa=On.evaluatedScale;if(qa[0]<=1&&qa[1]<=1&&qa[2]<=1&&Ji.intersects(Ws)===0)continue;if(!Qs&&As){const Sc=.16666666666666666;On.cameraCollisionOpacity=ns[0]>Ji.min[0]&&ns[0]Ji.min[1]&&ns[1]!As||On.opacity===1&&Fn.opacity===1?On.depthFn.depth?-1:1);for(const On of $a){const Fn=On.nodeInfo,ki=Fn.node;if(at._debugParams.show3DModelFootprints&&ki.footprint){const ra=ki.id||ki.name||"footprint";pr.has(ra)||pr.set(ra,{node:ki,mvp:On.wvpForTile})}let Ji=i.aD([],Zt,On.tileModelMatrix);i.aD(Ji,Cs,Ji);const qa=i.b7([],Ji);i.e6(qa,qa),i.cC(qa,qa,Wt),Ji=i.aD(Ji,Ji,ki.globalMatrix);const Cn=at.renderPass==="light-beam",Ui=wt.paint.get("model-color-use-theme").constantOr("default")==="none",fi=Ni&i.ez.HasMapboxMeshFeatures,Vo=fi?0:Fn.evaluatedRMEA[0][2];for(let ra=0;ra=sa||wh>=sa}}const ei=_i.material;let tm;ei.occlusionTexture&&ei.occlusionTexture.offsetScale&&(tm=ei.occlusionTexture.offsetScale,Ml.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const sm=at.getOrCreateProgram("model",Ml);!Qs&&Kt&&Kt.setupShadowsFromMatrix(On.tileModelMatrix,sm,Kt.useNormalOffset),at.uploadCommonUniforms(ft,sm,null,bh);const Ci=ei.pbrMetallicRoughness;Ci.metallicFactor=.9,Ci.roughnessFactor=.5;const Pi=W0(new Float32Array(ud),new Float32Array(Ji),new Float32Array(qa),new Float32Array(ki.globalMatrix),at,On.opacity,Ci.baseColorFactor,ei.emissiveFactor,Ci.metallicFactor,Ci.roughnessFactor,ei,Vo,wt,[0,0,0],tm);!ul&&(Fn.hasTranslucentParts||On.opacity<1)&&sm.draw(at,ft.gl.TRIANGLES,ss,dn.disabled,rn.disabled,Xr.backCCW,Pi,wt.id,_i.vertexBuffer,_i.indexBuffer,_i.segments,wt.paint,at.transform.zoom,void 0,Sc),sm.draw(at,ft.gl.TRIANGLES,ul?is:ss,dn.disabled,ul||On.opacity<1||Fn.hasTranslucentParts?rn.alphaBlended:rn.unblended,Xr.backCCW,Pi,wt.id,_i.vertexBuffer,_i.indexBuffer,_i.segments,wt.paint,at.transform.zoom,void 0,Sc)}}}if(at._debugParams.show3DModelFootprints&&pr.size>0){const Vn=Array.from(pr.keys()).sort();for(const pn of Vn){const{node:Ea,mvp:pi}=pr.get(pn);SP(at,0,Ea,pi)}}}()}(M,m,v,E),void we();if(be.type!=="model")return;const Ae=be.getModels(),ze=[],Le=M.transform.getFreeCameraOptions().position,rt=i.bJ([],[Le.x,Le.y,Le.z],M.transform.worldSize);i.eo(rt,rt);const st=[],dt=[];let pt=0;for(const at of Ae){const Bt=m.getFeatureState("",at.id),wt={type:"Unknown",id:at.id,properties:at.featureProperties},Ft=v.paint.get("model-rotation").evaluate(wt,Bt),ft=v.paint.get("model-scale").evaluate(wt,Bt),_t=v.paint.get("model-translation").evaluate(wt,Bt),Et=v.paint.get("model-opacity").evaluate(wt,Bt);CP(v,at.id,Bt,at.featureProperties,at.nodeOverrideNames,at.nodeOverrides),X0(v,at.id,Bt,at.featureProperties,at.materialOverrideNames,at.materialOverrides),at.nodeOverrides.size>0&&at.computeBoundsAndApplyParent(),at.computeModelMatrix(M,Ft,ft,_t,K,$,!1);const Kt=i.b9([]),qt=i.e2(at.position.lat,M.transform.zoom),ns=i.bP([],[1,1,1/qt]);i.bx(Kt,Kt,rt),ze.push({zScaleMatrix:ns,negCameraPosMatrix:Kt});for(const Jt of at.nodes)v3(M,Jt,at.matrix,M.transform.expandedFarZProjMatrix,pt,st,dt,at.materialOverrides,Et);pt++}if(st.sort((at,Bt)=>Bt.depth-at.depth),M.renderPass!=="shadow"){if(M._debugParams.show3DModelFootprints){const at=M.transform.projMatrix,Bt=new Map,wt=(ft,_t)=>{if(ft.footprint){const Et=ft.id||ft.name||"footprint";if(!Bt.has(Et)){const Kt=i.aD([],at,_t);Bt.set(Et,{node:ft,mvp:Kt})}}};for(const ft of dt)wt(ft.node,ft.modelMatrix);for(const ft of st)wt(ft.node,ft.modelMatrix);const Ft=Array.from(Bt.keys()).sort();for(const ft of Ft){const{node:_t,mvp:Et}=Bt.get(ft);SP(M,0,_t,Et)}}Kx(M,v,st,dt,ze),we()}else{for(const at of dt)X1(at.mesh,at.nodeModelMatrix,M,v);for(const at of st)X1(at.mesh,at.nodeModelMatrix,M,v);we()}}},AP={line:function(M,m,v){if(M.hasElevatedBuckets=!1,M.hasNonElevatedBuckets=!1,M._unevaluatedLayout.getValue("line-elevation-reference")!==void 0||M._unevaluatedLayout.getValue("line-z-offset")!==void 0){if(m){const E=m.getVisibleCoordinates();for(const D of E){const z=m.getTile(D).getBucket(M);if(z&&(z.elevationType!=="none"?M.hasElevatedBuckets=!0:M.hasNonElevatedBuckets=!0,M.hasElevatedBuckets&&M.hasNonElevatedBuckets))break}}}else M.hasNonElevatedBuckets=!0},model:function(M,m,v){const E=m.getSource();if(!E.loaded())return;if(E.type==="vector"||E.type==="geojson")return void(v.modelManager&&v.modelManager.upload(v,y3(v,M)));if(E.type==="batched-model"||E.type!=="model")return;const D=E.getModels();for(const z of D)z.upload(v.context)},raster:function(M,m,v){const E=m.getSource();if(!(E instanceof gh&&E.loaded()))return;const D=M.sourceLayer||E.rasterLayerIds&&E.rasterLayerIds[0];if(!D)return;const z=M.paint.get("raster-array-band")||E.getInitialBand(D);if(z==null)return;const $=m.getIds().map(K=>m.getTileByID(K));for(const K of $)K.updateNeeded(M.id,z)&&E.prepareTile(K,D,M.id,z)},"raster-particle":function(M,m,v){const E=m.getSource();if(!(E instanceof gh&&E.loaded()))return;const D=M.sourceLayer||E.rasterLayerIds&&E.rasterLayerIds[0];if(!D)return;const z=M.paint.get("raster-particle-array-band")||E.getInitialBand(D);if(z==null)return;const $=m.getIds().map(K=>m.getTileByID(K));for(const K of $)K.updateNeeded(M.id,z)&&E.prepareTile(K,D,M.id,z)}},EP={fill:o2},PP={fill:function(M,m,v,E){if(!v.layout||v.layout.get("fill-elevation-reference")==="none"||v.paint.get("fill-opacity").constantOr(1)===0)return;const D=M.context.gl,z=new Sr(D.LEQUAL,Sr.ReadOnly,M.depthRangeFor3D),$=new dn({func:D.ALWAYS,mask:255},255,255,D.KEEP,D.KEEP,D.REPLACE),K=M.transform.getFreeCameraOptions().position,ee=M.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const ne of E){const de=m.getTile(ne),we=de.getBucket(v);if(!we)continue;const be=we.elevatedStructures;if(!be||be.depthSegments.segments[0].primitiveLength===0)continue;const Ae=uP(ne.toUnwrapped(),K),ze=M.translatePosMatrix(ne.projMatrix,de,v.paint.get("fill-translate"),v.paint.get("fill-translate-anchor")),Le=s2(ze,Ae,0,1,0);ee.draw(M,D.TRIANGLES,z,$,rn.disabled,Xr.disabled,Le,v.id,be.vertexBuffer,be.indexBuffer,be.depthSegments,v.paint,M.transform.zoom)}}};class Ape{constructor(m,v,E,D,z){this.context=new Z1(m,v),this.transform=E,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,show3DModelFootprints:!1,enabledLayers:{}};const $=["fill","line","symbol","circle","heatmap","fill-extrusion","building","raster","raster-particle","hillshade","model","background","sky"];for(const ee of $)this._debugParams.enabledLayers[ee]=!0;for(const ee of $);this.occlusionParams=new SF,this.setup(),this.numSublayers=yh.maxUnderzooming+yh.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.eG,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new qw(this),this._wireframeDebugCache=new kF,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const K=new i.q({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new i.T(this.context,K,m.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=D,this.maxFrontCutoffRawStart=0,this.worldview=z,this._forceEmissiveMode=!1,this.emissiveMode="constant"}updateTerrain(m,v){const E=!!m&&!!m.terrain&&this.transform.projection.supportsTerrain;if(!(E||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new t2(this,m));const D=this._terrain;this.transform.elevation=E?D:null,D.update(m,this.transform,v),this.transform.elevation&&!D.enabled&&(this.transform.elevation=null)}_updateFog(m){const v=m.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[E,D]=v.getFovAdjustedRange(this.transform._fov);if(E>D)return void(this.transform.fogCullDistSq=null);const z=E+.78*(D-E);this.transform.fogCullDistSq=z*z}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}get forceTerrainMode(){return this._forceTerrainMode}set forceTerrainMode(m){m&&!this._terrain&&(this._terrain=new t2(this,this.style)),this._forceTerrainMode=m}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(m,v){if(this.width=m*i.o.devicePixelRatio,this.height=v*i.o.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const E of this.style.order)this.style._mergedLayers[E].resize()}setup(){const m=this.context,v=new i.dB;v.emplaceBack(0,0),v.emplaceBack(i.an,0),v.emplaceBack(0,i.an),v.emplaceBack(i.an,i.an),this.tileExtentBuffer=m.createVertexBuffer(v,i.dx.members),this.tileExtentSegments=i.dy.simpleSegment(0,0,4,2);const E=new i.dB;E.emplaceBack(0,0),E.emplaceBack(i.an,0),E.emplaceBack(0,i.an),E.emplaceBack(i.an,i.an),this.debugBuffer=m.createVertexBuffer(E,i.dx.members),this.debugSegments=i.dy.simpleSegment(0,0,4,5);const D=new i.dB;D.emplaceBack(-1,-1),D.emplaceBack(1,-1),D.emplaceBack(-1,1),D.emplaceBack(1,1),this.viewportBuffer=m.createVertexBuffer(D,i.dx.members),this.viewportSegments=i.dy.simpleSegment(0,0,4,2);const z=new i.eH;z.emplaceBack(0,0,0,0),z.emplaceBack(i.an,0,i.an,0),z.emplaceBack(0,i.an,0,i.an),z.emplaceBack(i.an,i.an,i.an,i.an),this.mercatorBoundsBuffer=m.createVertexBuffer(z,i.eI.members),this.mercatorBoundsSegments=i.dy.simpleSegment(0,0,4,2);const $=new i.dC;$.emplaceBack(0,1,2),$.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=m.createIndexBuffer($);const K=new i.eJ;for(const ne of[0,1,3,2,0])K.emplaceBack(ne);this.debugIndexBuffer=m.createIndexBuffer(K),this.emptyTexture=new i.T(m,new i.q({width:1,height:1},Uint8Array.of(0,0,0,0)),m.gl.RGBA8),this.identityMat=i.bb();const ee=this.context.gl;this.stencilClearMode=new dn({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(m){return m._makeTileBoundsBuffers(this.context,this.transform.projection),m._tileBoundsBuffer?{tileBoundsBuffer:m._tileBoundsBuffer,tileBoundsIndexBuffer:m._tileBoundsIndexBuffer,tileBoundsSegments:m._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const m=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,m.TRIANGLES,Sr.disabled,this.stencilClearMode,rn.disabled,Xr.disabled,Jw(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(m,v,E){if(!v||this.currentStencilSource===v.id||!m.isTileClipped()||!E||E.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let K=!1;for(const ee of E)if(this._tileClippingMaskIDs[ee.key]===void 0){K=!0;break}if(!K)return}this.currentStencilSource=v.id;const D=this.context,z=D.gl;this.nextStencilID+E.length>256&&this.clearStencil(),D.setColorMode(rn.disabled),D.setDepthMode(Sr.disabled);const $=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const K of E){const ee=v.getTile(K),ne=this._tileClippingMaskIDs[K.key]=this.nextStencilID++,{tileBoundsBuffer:de,tileBoundsIndexBuffer:we,tileBoundsSegments:be}=this.getTileBoundsBuffers(ee);$.draw(this,z.TRIANGLES,Sr.disabled,new dn({func:z.ALWAYS,mask:0},ne,255,z.KEEP,z.KEEP,z.REPLACE),rn.disabled,Xr.disabled,Jw(K.projMatrix),"$clipping",de,we,be)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const m=this.nextStencilID++,v=this.context.gl;return new dn({func:v.NOTEQUAL,mask:255},m,255,v.KEEP,v.KEEP,v.REPLACE)}stencilModeForClipping(m){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(m);const v=this.context.gl;return new dn({func:v.EQUAL,mask:255},this._tileClippingMaskIDs[m.key],0,v.KEEP,v.KEEP,v.REPLACE)}stencilConfigForOverlap(m){const v=this.context.gl,E=m.sort(($,K)=>K.overscaledZ-$.overscaledZ),D=E[E.length-1].overscaledZ,z=E[0].overscaledZ-D+1;if(z>1){this.currentStencilSource=void 0,this.nextStencilID+z>256&&this.clearStencil();const $={};for(let K=0;Kthis._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce((m,v)=>m+v/this._fpsHistory.length,0))}render(m,v){const E=i.o.now();this._dt=E-this._timeStamp,this._timeStamp=E,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=m.map.repaint,this.style=m,this.options=v;const D=this.style._mergedLayers,z=!(!this.terrain||!this.terrain.enabled),$=()=>this.style._getOrder(z).filter(Zt=>{const Ht=D[Zt];return!(Ht.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[Ht.type]});let K=$(),ee=!1,ne=!1,de=null,we=0,be=!1;for(const Zt of K){const Ht=D[Zt];Ht.visibility!=="none"&&(Ht.type==="circle"?ee=!0:Ht.type==="building"?(de=Ht,++we):Ht.type==="symbol"&&(Ht.hasOcclusionOpacityProperties?ne=!0:ee=!0))}this.updateEmissiveMode();let Ae=K.map(Zt=>D[Zt]);const ze=this.style._mergedSourceCaches;this.imageManager=m.imageManager,this.modelManager=m.modelManager,this.symbolFadeChange=m.placement.symbolFadeChange(i.o.now()),this.imageManager.beginFrame();for(const Zt in ze){const Ht=ze[Zt];Ht.used&&(Ht.prepare(this.context),Ht.getSource().usedInConflation&&++we)}let Le=!1;for(const Zt of Ae)Zt.isHidden(this.transform.zoom)||(Zt.type==="clip"&&(Le=!0),this.prepareLayer(Zt));const rt={},st={},dt={},pt={},at={};for(const Zt in ze){const Ht=ze[Zt];rt[Zt]=Ht.getVisibleCoordinates(),st[Zt]=rt[Zt].slice().reverse(),dt[Zt]=Ht.getVisibleCoordinates(!0).reverse(),pt[Zt]=Ht.getShadowCasterCoordinates(),at[Zt]=Ht.sortCoordinatesByDistance(rt[Zt])}const Bt=Zt=>{const Ht=this.style.getLayerSourceCache(Zt);return Ht&&Ht.used?Ht.getSource():null};if(we||Le||this._clippingActiveLastFrame){const Zt=[],Ht=[];let ss=0;for(const is of Ae)this.isSourceForClippingOrConflation(is,Bt(is))&&(Zt.push(is),Ht.push(ss)),ss++;if(Zt&&(Le||Zt.length>1)||this._clippingActiveLastFrame){Le=!1;const is=[];for(let hs=0;hs0){const is=Bt(Ht);is&&(this.minCutoffZoom=Math.max(is.minzoom,this.minCutoffZoom)),Ht.minzoom&&(this.minCutoffZoom=Math.max(Ht.minzoom,this.minCutoffZoom))}Ht.is3D(z)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=Zt),this._lastOcclusionLayer=Zt)}const wt=this.style&&this.style.fog;wt?(this._fogVisible=wt.getOpacity(this.transform.pitch)!==0,this._fogVisible&&this.transform.projection.name!=="globe"&&(this._fogVisible=wt.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(dt),this.opaquePassCutoff=0,K=$(),Ae=K.map(Zt=>D[Zt]));const Ft=this._shadowRenderer;if(Ft){Ft.updateShadowParameters(this.transform,this.style.directionalLight);for(const Zt in ze)for(const Ht of rt[Zt]){let ss={min:0,max:0};this.terrain&&(ss=this.terrain.getMinMaxForTile(Ht)||ss),Ft.addShadowReceiver(Ht.toUnwrapped(),ss.min,ss.max)}}this.transform.projection.name!=="globe"||this.globeSharedBuffers||(this.globeSharedBuffers=new i.eL(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new wF(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);const ft=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.snow),_t=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.rain);if(ft&&!this._snow&&(this._snow=new TF(this)),!ft&&this._snow&&(this._snow.destroy(),delete this._snow),_t&&!this._rain&&(this._rain=new u2(this)),!_t&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),de){this.buildingTileBorderManager||(this.buildingTileBorderManager=new Wx);const Zt=this.style.getLayerSourceCache(de);this.buildingTileBorderManager.updateBorders(Zt,de)}if(!tt.has(this.context.gl))return;this.renderPass="offscreen";for(const Zt of Ae){const Ht=m.getLayerSourceCache(Zt);if(!Zt.hasOffscreenPass()||Zt.isHidden(this.transform.zoom))continue;const ss=Ht?st[Ht.id]:void 0;(Zt.type==="custom"||Zt.type==="raster"||Zt.type==="raster-particle"||Zt.isSky()||ss&&ss.length)&&this.renderLayer(this,Ht,Zt,ss)}this.depthRangeFor3D=[0,1-(Ae.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,pt)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const Et=this.transform.projection.name==="globe"||this.transform.isHorizonVisible(),Kt=(()=>{if(v.showOverdrawInspector)return i.aq.black;const Zt=this.style.fog;if(Zt&&this.transform.projection.supportsFog){const Ht=this.style.getLut(Zt.scope);if(!Et){const ss=Zt.properties.get("color-use-theme")==="none",is=Zt.properties.get("color").toNonPremultipliedRenderColor(ss?null:Ht).toArray01();return new i.aq(...is)}if(Et){const ss=Zt.properties.get("space-color-use-theme")==="none",is=Zt.properties.get("space-color").toNonPremultipliedRenderColor(ss?null:Ht).toArray01();return new i.aq(...is)}}return i.aq.transparent})();if(this.context.clear({color:Kt,depth:1}),this.clearStencil(),this._showOverdrawInspector=v.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&Et&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=K.length-1;this.currentLayer>=0;this.currentLayer--){const Zt=Ae[this.currentLayer],Ht=m.getLayerSourceCache(Zt);if(Zt.isSky())continue;const ss=Ht?(Zt.is3D(z)?at:st)[Ht.id]:void 0;this._renderTileClippingMasks(Zt,Ht,ss),this.renderLayer(this,Ht,Zt,ss)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&Et&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||i.al(this.transform.zoom)>0)&&(this.transform.projection.name==="globe"||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer{for(this.currentLayer=0;this.currentLayer=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const ss=this.currentLayer;this.depthOcclusion=!0;for(const is of this.layersWithOcclusionOpacity){this.currentLayer=is;const hs=Ae[this.currentLayer],Qs=m.getLayerSourceCache(hs),Ws=Qs?st[Qs.id]:void 0;this.terrain||this._renderTileClippingMasks(hs,Qs,Qs?rt[Qs.id]:void 0),this.renderLayer(this,Qs,hs,Ws)}this.depthOcclusion=!1,this.currentLayer=ss,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 Zt=null;Ae.forEach(Ht=>{const ss=m.getLayerSourceCache(Ht);ss&&!Ht.isHidden(this.transform.zoom)&&ss.getVisibleCoordinates().length&&(!Zt||Zt.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(m,v,E){const D=E===void 0?this.terrain&&this.terrain.renderingToTexture:E,z=[];return this.style&&this.style.enable3dLights()&&(m==="globeRaster"||m==="terrainRaster"?(z.push("LIGHTING_3D_MODE"),z.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):D||z.push("LIGHTING_3D_MODE")),this.terrainRenderModeElevated()&&(z.push("TERRAIN"),this.linearFloatFilteringSupported()&&z.push("TERRAIN_DEM_FLOAT_FORMAT")),this.transform.projection.name==="globe"&&z.push("GLOBE"),!this._fogVisible||D||v!==void 0&&!v||z.push("FOG"),D&&z.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&z.push("OVERDRAW_INSPECTOR"),z}getOrCreateProgram(m,v){this.cache=this.cache||{};const E=v&&v.defines||[],D=v&&v.config,z=this.currentGlobalDefines(m,v&&v.overrideFog,v&&v.overrideRtt).concat(E),$=G0.cacheKey(BO[m],m,z,D);return this.cache[$]||(this.cache[$]=new G0(this.context,m,BO[m],D,d3[m],z)),this.cache[$]}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 m=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(m.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(m,v){if(this.style.enable3dLights()){const E=this.style.directionalLight,D=this.style.ambientLight;if(E&&D){const z=(($,K,ee)=>{const ne=$.properties.get("direction"),de=$.properties.get("color-use-theme")==="none",we=$.properties.get("color").toNonPremultipliedRenderColor(de?null:ee.getLut($.scope)).toArray01(),be=$.properties.get("intensity"),Ae=K.properties.get("color-use-theme")==="none",ze=K.properties.get("color").toNonPremultipliedRenderColor(Ae?null:ee.getLut(K.scope)).toArray01(),Le=K.properties.get("intensity"),rt=[ne.x,ne.y,ne.z],st=i.dD(ze,Le),dt=i.dD(we,be);return{u_lighting_ambient_color:st,u_lighting_directional_dir:rt,u_lighting_directional_color:dt,u_ground_radiance:iP(rt,dt,st)}})(E,D,this.style);v.setLightsUniformValues(m,z)}}}uploadCommonUniforms(m,v,E,D,z){if(this.uploadCommonLightUniforms(m,v),this.terrain&&this.terrain.renderingToTexture)return;const $=this.style.fog;if($){const K=$.getOpacity(this.transform.pitch),ee=((ne,de,we,be,Ae,ze,Le,rt,st,dt,pt,at)=>{const Bt=ne.transform,wt=de.properties.get("color-use-theme")==="none",Ft=de.properties.get("color").toNonPremultipliedRenderColor(wt?null:ne.style.getLut(de.scope)).toArray01();Ft[3]=be;const ft=ne.frameCounter/1e3%1,[_t,Et]=de.properties.get("vertical-range");return{u_fog_matrix:we?Bt.calculateFogTileMatrix(we):at||ne.identityMat,u_fog_range:de.getFovAdjustedRange(Bt._fov),u_fog_color:Ft,u_fog_horizon_blend:de.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(_t,Et),Et],u_fog_temporal_offset:ft,u_frustum_tl:Ae,u_frustum_tr:ze,u_frustum_br:Le,u_frustum_bl:rt,u_globe_pos:st,u_globe_radius:dt,u_viewport:pt,u_globe_transition:i.al(Bt.zoom),u_is_globe:+(Bt.projection.name==="globe")}})(this,$,E,K,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(m,ee)}z&&v.setCutoffUniformValues(m,z.uniformValues)}setTileLoadedFlag(m){this.tileLoaded=m}saveCanvasCopy(){const m=this.canvasCopy();m&&(this.frameCopies.push(m),this.tileLoaded=!1)}canvasCopy(){const m=this.context.gl,v=m.createTexture();return m.bindTexture(m.TEXTURE_2D,v),m.copyTexImage2D(m.TEXTURE_2D,0,m.RGBA,0,0,m.drawingBufferWidth,m.drawingBufferHeight,0),v}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const m=this.style&&this.style.fog;return!!m&&m.getOpacity(this.transform.pitch)!==0}getBackgroundTiles(){const m=this._backgroundTiles,v=this._backgroundTiles={},E=this.transform.coveringTiles({tileSize:512});for(const D of E)v[D.key]=m[D.key]||new i.b0(D,512,this.transform.tileZoom,this,void 0,this.worldview);return v}clearBackgroundTiles(){this._backgroundTiles={}}isSourceForClippingOrConflation(m,v){return!(!m.is3D(!(!this.terrain||!this.terrain.enabled))||m.type!=="clip"&&m.type!=="building"&&(m.minzoom&&m.minzoom>this.transform.zoom||(this.style._clipLayerPresent||m.sourceLayer!=="building"&&m.sourceLayer!=="procedural_buildings")&&(!v||v.type!=="batched-model")))}isTileAffectedByFog(m){if(!this.style||!this.style.fog)return!1;if(this.transform.projection.name==="globe")return!0;let v=this._cachedTileFogOpacities[m.key];return v||(this._cachedTileFogOpacities[m.key]=v=this.style.fog.getOpacityForTile(m)),v[0]>=sa||v[1]>=sa}setupDepthForOcclusion(m,v,E){const D=this.context,z=D.gl,$=!!E;var K;E||(E={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(z.TEXTURE3),m&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(z.NEAREST,z.CLAMP_TO_EDGE),E.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],E.u_depth_range_unpack=[2/((K=this.depthRangeFor3D)[1]-K[0]),-1-2*K[0]/(K[1]-K[0])],E.u_occluder_half_size=.5*this.occlusionParams.occluderSize,E.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(z.NEAREST,z.CLAMP_TO_EDGE),D.activeTexture.set(z.TEXTURE0),$||v.setTerrainUniformValues(D,E)}updateEmissiveMode(){if(this._forceEmissiveMode)return;const m=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=m?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant"}}function IP(M,m){let v=!1,E=null;const D=()=>{E=null,v&&(M(),E=setTimeout(D,m),v=!1)};return()=>(v=!0,E||D(),E)}class Epe{constructor(m){this._hashName=m&&encodeURIComponent(m),i.aZ(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=IP(this._updateHashUnthrottled.bind(this),300)}addTo(m){return this._map=m,window.addEventListener("hashchange",this._onHashChange,!1),m.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 m=this._map;if(!m)return"";const v=Yd(m);if(this._hashName){const E=this._hashName;let D=!1;const z=location.hash.slice(1).split("&").map($=>{const K=$.split("=")[0];return K===E?(D=!0,`${K}=${v}`):$}).filter($=>$);return D||z.push(`${E}=${v}`),`#${z.join("&")}`}return`#${v}`}_getCurrentHash(){const m=location.hash.replace("#","");if(this._hashName){let v;return m.split("&").map(E=>E.split("=")).forEach(E=>{E[0]===this._hashName&&(v=E)}),(v&&v[1]||"").split("/")}return m.split("/")}_onHashChange(){const m=this._map;if(!m)return!1;const v=this._getCurrentHash();if(v.length>=3&&!v.some(E=>isNaN(Number(E)))){const E=m.dragRotate.isEnabled()&&m.touchZoomRotate.isEnabled()?+(v[3]||0):m.getBearing();return m.jumpTo({center:[+v[2],+v[1]],zoom:+v[0],bearing:E,pitch:+(v[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function Yd(M,m){const v=M.getCenter(),E=Math.round(100*M.getZoom())/100,D=Math.ceil((E*Math.LN2+Math.log(512/360/.5))/Math.LN10),z=Math.pow(10,D),$=Math.round(v.lng*z)/z,K=Math.round(v.lat*z)/z,ee=M.getBearing(),ne=M.getPitch();let de=m?`/${$}/${K}/${E}`:`${E}/${K}/${$}`;return(ee||ne)&&(de+="/"+Math.round(10*ee)/10),ne&&(de+=`/${Math.round(ne)}`),de}const N3={linearity:.3,easing:i.eN(0,0,.3,1)},h2=Object.assign({deceleration:2500,maxSpeed:1400},N3),Ppe=Object.assign({deceleration:20,maxSpeed:1400},N3),Oi=Object.assign({deceleration:1e3,maxSpeed:360},N3),la=Object.assign({deceleration:1e3,maxSpeed:90},N3);class EF{constructor(m){this._map=m,this.clear()}clear(){this._inertiaBuffer=[]}record(m){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:i.o.now(),settings:m})}_drainInertiaBuffer(){const m=this._inertiaBuffer,v=i.o.now();for(;m.length>0&&v-m[0].time>160;)m.shift()}_onMoveEnd(m){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:z}of this._inertiaBuffer)v.zoom+=z.zoomDelta||0,v.bearing+=z.bearingDelta||0,v.pitch+=z.pitchDelta||0,z.panDelta&&v.pan._add(z.panDelta),z.around&&(v.around=z.around),z.pinchAround&&(v.pinchAround=z.pinchAround);const E=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,D={};if(v.pan.mag()){const z=Df(v.pan.mag(),E,Object.assign({},h2,m||{}));D.offset=v.pan.mult(z.amount/v.pan.mag()),D.center=this._map.transform.center,_h(D,z)}if(v.zoom){const z=Df(v.zoom,E,Ppe);D.zoom=this._map.transform.zoom+z.amount,_h(D,z)}if(v.bearing){const z=Df(v.bearing,E,Oi);D.bearing=this._map.transform.bearing+i.aC(z.amount,-179,179),_h(D,z)}if(v.pitch){const z=Df(v.pitch,E,la);D.pitch=this._map.transform.pitch+z.amount,_h(D,z)}if(D.zoom||D.bearing){const z=v.pinchAround===void 0?v.around:v.pinchAround;D.around=z?this._map.unproject(z):this._map.getCenter()}return this.clear(),D.noMoveStart=!0,D}}function _h(M,m){(!M.duration||M.durationv.unproject(ee)),K=z.reduce((ee,ne,de,we)=>ee.add(ne.div(we.length)),new i.P(0,0));super(m,{points:z,point:K,lngLats:$,lngLat:v.unproject(K),originalEvent:E}),this._defaultPrevented=!1}}class LP extends i.C{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(m,v){super("wheel",{originalEvent:v}),this._defaultPrevented=!1}}class DP{constructor(m,v){this._map=m,this._clickTolerance=v.clickTolerance}reset(){this._mousedownPos=void 0}wheel(m){return this._firePreventable(new LP(this._map,m))}mousedown(m,v){return this._mousedownPos=v,this._firePreventable(new dd(m.type,this._map,m))}mouseup(m){this._map.fire(new dd(m.type,this._map,m))}preclick(m){const v=new MouseEvent("preclick",m);this._map.fire(new dd(v.type,this._map,v))}click(m,v){this._mousedownPos&&this._mousedownPos.dist(v)>=this._clickTolerance||(this.preclick(m),this._map.fire(new dd(m.type,this._map,m)))}dblclick(m){return this._firePreventable(new dd(m.type,this._map,m))}mouseover(m){this._map.fire(new dd(m.type,this._map,m))}mouseout(m){this._map.fire(new dd(m.type,this._map,m))}touchstart(m){return this._firePreventable(new Jh(m.type,this._map,m))}touchmove(m){this._map.fire(new Jh(m.type,this._map,m))}touchend(m){this._map.fire(new Jh(m.type,this._map,m))}touchcancel(m){this._map.fire(new Jh(m.type,this._map,m))}_firePreventable(m){if(this._map.fire(m),m.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class RP{constructor(m){this._map=m}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(m){this._map.fire(new dd(m.type,this._map,m))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new dd("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(m){this._delayContextMenu?this._contextMenuEvent=m:this._map.fire(new dd(m.type,this._map,m)),this._map.listens("contextmenu")&&m.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class OP{constructor(m,v){this._map=m,this._el=m.getCanvasContainer(),this._container=m.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(m,v){this.isEnabled()&&m.shiftKey&&m.button===0&&(I(),this._startPos=this._lastPos=v,this._active=!0)}mousemoveWindow(m,v){if(!this._active)return;const E=v,D=this._startPos,z=this._lastPos;if(!D||!z||z.equals(E)||!this._box&&E.dist(D){this._box&&(this._box.style.transform=`translate(${$}px,${ee}px)`,this._box.style.width=K-$+"px",this._box.style.height=ne-ee+"px")})}mouseupWindow(m,v){if(!this._active)return;const E=this._startPos,D=v;if(E&&m.button===0){if(this.reset(),V(),E.x!==D.x||E.y!==D.y)return this._map.fire(new i.C("boxzoomend",{originalEvent:m})),{cameraAnimation:z=>z.fitScreenCoordinates(E,D,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",m)}}keydown(m){this._active&&m.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",m))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),L(),delete this._startPos,delete this._lastPos}_fireEvent(m,v){return this._map.fire(new i.C(m,{originalEvent:v}))}}function m2(M,m){const v={};for(let E=0;Ethis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=m.timeStamp),E.length===this.numTouches&&(this.centroid=function(D){const z=new i.P(0,0);for(const $ of D)z._add($);return z.div(D.length)}(v),this.touches=m2(E,v)))}touchmove(m,v,E){if(this.aborted||!this.centroid)return;const D=m2(E,v);for(const z in this.touches){const $=D[z];(!$||$.dist(this.touches[z])>30)&&(this.aborted=!0)}}touchend(m,v,E){if((!this.centroid||m.timeStamp-this.startTime>500)&&(this.aborted=!0),E.length===0){const D=!this.aborted&&this.centroid;if(this.reset(),D)return D}}}class Rf{constructor(m){this.singleTap=new Hm(m),this.numTaps=m.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(m,v,E){this.singleTap.touchstart(m,v,E)}touchmove(m,v,E){this.singleTap.touchmove(m,v,E)}touchend(m,v,E){const D=this.singleTap.touchend(m,v,E);if(D){const z=m.timeStamp-this.lastTime<500,$=!this.lastTap||this.lastTap.dist(D)<30;if(z&&$||this.reset(),this.count++,this.lastTime=m.timeStamp,this.lastTap=D,this.count===this.numTaps)return this.reset(),D}}}class e_{constructor(){this._zoomIn=new Rf({numTouches:1,numTaps:2}),this._zoomOut=new Rf({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(m,v,E){this._zoomIn.touchstart(m,v,E),this._zoomOut.touchstart(m,v,E)}touchmove(m,v,E){this._zoomIn.touchmove(m,v,E),this._zoomOut.touchmove(m,v,E)}touchend(m,v,E){const D=this._zoomIn.touchend(m,v,E),z=this._zoomOut.touchend(m,v,E);return D?(this._active=!0,m.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:$=>$.easeTo({duration:300,zoom:$.getZoom()+1,around:$.unproject(D)},{originalEvent:m})}):z?(this._active=!0,m.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:$=>$.easeTo({duration:300,zoom:$.getZoom()-1,around:$.unproject(z)},{originalEvent:m})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const k3=0,FP=2,zP={[k3]:1,[FP]:2},Yx={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class p2{constructor(m){this.reset(),this._clickTolerance=m.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(m,v){return!1}_move(m,v){return{}}mousedown(m,v){if(this._lastPoint)return;const E=U(m);this._correctButton(m,E)&&(this._lastPoint=v,this._eventButton=E)}mousemoveWindow(m,v){const E=this._lastPoint;if(E){if(m.preventDefault(),this._eventButton!=null&&function(D,z){const $=zP[z];return D.buttons===void 0||(D.buttons&$)!==$}(m,this._eventButton))this.reset();else if(this._moved||!(v.dist(E)0&&(this._active=!0);const D=m2(E,v),z=new i.P(0,0),$=new i.P(0,0);let K=0;for(const ne in D){const de=D[ne],we=this._touches[ne];we&&(z._add(de),$._add(de.sub(we)),K++,D[ne]=de)}if(this._touches=D,K{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class x2{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(m){}_move(m,v,E){return{}}touchstart(m,v,E){this._firstTwoTouches||E.length<2||(this._firstTwoTouches=[E[0].identifier,E[1].identifier],this._start([v[0],v[1]]))}touchmove(m,v,E){const D=this._firstTwoTouches;if(!D)return;m.preventDefault();const[z,$]=D,K=Ao(E,v,z),ee=Ao(E,v,$);if(!K||!ee)return;const ne=this._aroundCenter?null:K.add(ee).div(2);return this._move([K,ee],ne,m)}touchend(m,v,E){if(!this._firstTwoTouches)return;const[D,z]=this._firstTwoTouches,$=Ao(E,v,D),K=Ao(E,v,z);$&&K||(this._active&&V(),this.reset())}touchcancel(){this.reset()}enable(m){this._enabled=!0,this._aroundCenter=!!m&&m.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Ao(M,m,v){for(let E=0;EMath.abs(M.x)}class qP extends x2{constructor(m){super(),this._map=m}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(m){this._lastPoints=m,g2(m[0].sub(m[1]))&&(this._valid=!1)}_move(m,v,E){const D=this._lastPoints;if(!D)return;const z=m[0].sub(D[0]),$=m[1].sub(D[1]);return this._map._cooperativeGestures&&!i.eO()&&E.touches.length<3||(this._valid=this.gestureBeginsVertically(z,$,E.timeStamp),!this._valid)?void 0:(this._lastPoints=m,this._active=!0,{pitchDelta:(z.y+$.y)/2*-.5})}gestureBeginsVertically(m,v,E){if(this._valid!==void 0)return this._valid;const D=m.mag()>=2,z=v.mag()>=2;if(!D&&!z)return;if(!D||!z)return this._firstMove==null&&(this._firstMove=E),E-this._firstMove<100&&void 0;const $=m.y>0==v.y>0;return g2(m)&&g2(v)&&$}}const UP={panStep:100,bearingStep:15,pitchStep:10};class ev{constructor(){const m=UP;this._panStep=m.panStep,this._bearingStep=m.bearingStep,this._pitchStep=m.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(m){if(m.altKey||m.ctrlKey||m.metaKey)return;let v=0,E=0,D=0,z=0,$=0;switch(m.keyCode){case 61:case 107:case 171:case 187:v=1;break;case 189:case 109:case 173:v=-1;break;case 37:m.shiftKey?E=-1:(m.preventDefault(),z=-1);break;case 39:m.shiftKey?E=1:(m.preventDefault(),z=1);break;case 38:m.shiftKey?D=1:(m.preventDefault(),$=-1);break;case 40:m.shiftKey?D=-1:(m.preventDefault(),$=1);break;default:return}return this._rotationDisabled&&(E=0,D=0),{cameraAnimation:K=>{const ee=K.getZoom();K.easeTo({duration:300,easeId:"keyboardHandler",easing:VP,zoom:v?Math.round(ee)+v*(m.shiftKey?2:1):ee,bearing:K.getBearing()+E*this._bearingStep,pitch:K.getPitch()+D*this._pitchStep,offset:[-z*this._panStep,-$*this._panStep],center:K.getCenter()},{originalEvent:m})}}}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 VP(M){return M*(2-M)}const tv=4.000244140625,HP=1/450;class T3{constructor(m,v){this._map=m,this._el=m.getCanvasContainer(),this._handler=v,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=HP,i.aZ(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(m){this._defaultZoomRate=m}setWheelZoomRate(m){this._wheelZoomRate=m}isEnabled(){return!!this._enabled}isActive(){return this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(m){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!m&&m.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(m){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(m.ctrlKey||m.metaKey||this.isZooming()||i.eO()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let v=m.deltaMode===WheelEvent.DOM_DELTA_LINE?40*m.deltaY:m.deltaY;const E=i.o.now(),D=E-(this._lastWheelEventTime||0);this._lastWheelEventTime=E,v!==0&&v%tv===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,m)):this._type||(this._type=Math.abs(D*v)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,v+=this._lastValue)),m.shiftKey&&v&&(v/=4),this._type&&(this._lastWheelEvent=m,this._delta-=v,this._active||this._start(m)),m.preventDefault()}_onTimeout(m){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(m)}_start(m){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=q(this._el,m);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 m=this._map.transform;this._type==="wheel"&&m.projection.wrap&&(m._center.lng>=180||m._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const v=()=>m._terrainEnabled()&&this._aroundCoord?m.computeZoomRelativeTo(this._aroundCoord):m.zoom;if(this._delta!==0){const ne=this._type==="wheel"&&Math.abs(this._delta)>tv?this._wheelZoomRate:this._defaultZoomRate;let de=2/(1+Math.exp(-Math.abs(this._delta*ne)));this._delta<0&&de!==0&&(de=1/de);const we=v(),be=Math.pow(2,we),Ae=typeof this._targetZoom=="number"?m.zoomScale(this._targetZoom):be;this._targetZoom=Math.min(m.maxZoom,Math.max(m.minZoom,m.scaleZoom(Ae*de))),this._type==="wheel"&&(this._startZoom=we,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const E=typeof this._targetZoom=="number"?this._targetZoom:v(),D=this._startZoom,z=this._easing;let $,K=!1;if(this._type==="wheel"&&D&&z){const ne=Math.min((i.o.now()-this._lastWheelEventTime)/200,1),de=z(ne);$=i.am(D,E,de),ne<1?this._frameId||(this._frameId=!0):K=!0}else $=E,K=!0;this._active=!0,K&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let ee=$-v();return ee*this._lastDelta<0&&(ee=0),{noInertia:!0,needsRenderFrame:!K,zoomDelta:ee,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(m){let v=i.eP;if(this._prevEase){const E=this._prevEase,D=(i.o.now()-E.start)/E.duration,z=E.easing(D+.01)-E.easing(D),$=.27/Math.sqrt(z*z+1e-4)*.01,K=Math.sqrt(.0729-$*$);v=i.eN($,K,.25,1)}return this._prevEase={start:i.o.now(),duration:m,easing:v},v}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=N("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 A3{constructor(m,v){this._clickZoom=m,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 E3{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(m,v){return m.preventDefault(),{cameraAnimation:E=>{E.easeTo({duration:300,zoom:E.getZoom()+(m.shiftKey?-1:1),around:E.unproject(v)},{originalEvent:m})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class PF{constructor(){this._tap=new Rf({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(m,v,E){this._swipePoint||(this._tapTime&&m.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?E.length>0&&(this._swipePoint=v[0],this._swipeTouch=E[0].identifier):this._tap.touchstart(m,v,E))}touchmove(m,v,E){if(this._tapTime){if(this._swipePoint){if(E[0].identifier!==this._swipeTouch)return;const D=v[0],z=D.y-this._swipePoint.y;return this._swipePoint=D,m.preventDefault(),this._active=!0,{zoomDelta:z/128}}}else this._tap.touchmove(m,v,E)}touchend(m,v,E){this._tapTime?this._swipePoint&&E.length===0&&this.reset():this._tap.touchend(m,v,E)&&(this._tapTime=m.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class GP{constructor(m,v,E){this._el=m,this._mousePan=v,this._touchPan=E}enable(m){this._inertiaOptions=m||{},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 IF{constructor(m,v,E){this._pitchWithRotate=m.pitchWithRotate,this._mouseRotate=v,this._mousePitch=E}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 LF{constructor(m,v,E,D){this._el=m,this._touchZoom=v,this._touchRotate=E,this._tapDragZoom=D,this._rotationDisabled=!1,this._enabled=!0}enable(m){this._touchZoom.enable(m),this._rotationDisabled||this._touchRotate.enable(m),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 y2=M=>M.zoom||M.drag||M.pitch||M.rotate;class DF extends i.C{}class RF{constructor(){this.constants=[1,1,.01],this.radius=0}setup(m,v){const E=i.ax([],v,m);this.radius=i.ai(E[2]<0?i.eR([],E,this.constants):[E[0],E[1],0])}projectRay(m){i.eR(m,m,this.constants),i.ay(m,m),i.eS(m,m,this.constants);const v=i.bJ([],m,this.radius);if(v[2]>0){const E=i.bJ([],[0,0,1],i.bi(v,[0,0,1])),D=i.bJ([],i.ay([],[v[0],v[1],0]),this.radius),z=i.cT([],v,i.bJ([],i.ax([],i.cT([],D,E),v),2));v[0]=z[0],v[1]=z[1]}return v}}function v2(M){return M.panDelta&&M.panDelta.mag()||M.zoomDelta||M.bearingDelta||M.pitchDelta}class OF{constructor(m,v){this._map=m,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new EF(m),this._bearingSnap=v.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new RF,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(v),i.aZ(["handleEvent","handleWindowEvent"],this);const E=this._el;this._listeners=[[E,"touchstart",{passive:!0}],[E,"touchmove",{passive:!1}],[E,"touchend",void 0],[E,"touchcancel",void 0],[E,"mousedown",void 0],[E,"mousemove",void 0],[E,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[E,"mouseover",void 0],[E,"mouseout",void 0],[E,"dblclick",void 0],[E,"click",void 0],[E,"keydown",{capture:!1}],[E,"keyup",void 0],[E,"wheel",{passive:!1}],[E,"contextmenu",void 0],[window,"blur",void 0]];for(const[D,z,$]of this._listeners){const K=D===document?this.handleWindowEvent:this.handleEvent;D.addEventListener(z,K,$)}}destroy(){for(const[m,v,E]of this._listeners){const D=m===document?this.handleWindowEvent:this.handleEvent;m.removeEventListener(v,D,E)}}_addDefaultHandlers(m){const v=this._map,E=v.getCanvasContainer();this._add("mapEvent",new DP(v,m));const D=v.boxZoom=new OP(v,m);this._add("boxZoom",D);const z=new e_,$=new E3;v.doubleClickZoom=new A3($,z),this._add("tapZoom",z),this._add("clickZoom",$);const K=new PF;this._add("tapDragZoom",K);const ee=v.touchPitch=new qP(v);this._add("touchPitch",ee);const ne=new S3(m),de=new f2(m);v.dragRotate=new IF(m,ne,de),this._add("mouseRotate",ne,["mousePitch"]),this._add("mousePitch",de,["mouseRotate"]);const we=new Gm(m),be=new BP(v,m);v.dragPan=new GP(E,we,be),this._add("mousePan",we),this._add("touchPan",be,["touchZoom","touchRotate"]);const Ae=new J0,ze=new $P;v.touchZoomRotate=new LF(E,ze,Ae,K),this._add("touchRotate",Ae,["touchPan","touchZoom"]),this._add("touchZoom",ze,["touchPan","touchRotate"]),this._add("blockableMapEvent",new RP(v));const Le=v.scrollZoom=new T3(v,this);this._add("scrollZoom",Le,["mousePan"]);const rt=v.keyboard=new ev;this._add("keyboard",rt);for(const st of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])m.interactive&&m[st]&&v[st].enable(m[st])}_add(m,v,E){this._handlers.push({handlerName:m,handler:v,allowed:E}),this._handlersById[m]=v}stop(m){if(!this._updatingCamera){for(const{handler:v}of this._handlers)v.reset();this._inertia.clear(),this._fireEvents({},{},m),this._changes=[],this._originalZoom=void 0}}isActive(){for(const{handler:m}of this._handlers)if(m.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!y2(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(m,v,E){for(const D in m)if(D!==E&&(!v||v.indexOf(D)<0))return!0;return!1}handleWindowEvent(m){this.handleEvent(m,`${m.type}Window`)}_getMapTouches(m){const v=[];for(const E of m)this._el.contains(E.target)&&v.push(E);return v}handleEvent(m,v){this._updatingCamera=!0;const E=m.type==="renderFrame",D=E?void 0:m,z={needsRenderFrame:!1},$={},K={},ee=m.touches?this._getMapTouches(m.touches):void 0,ne=ee?B(this._el,ee):E?void 0:q(this._el,m);for(const{handlerName:be,handler:Ae,allowed:ze}of this._handlers){if(!Ae.isEnabled())continue;let Le;this._blockedByActive(K,ze,be)?Ae.reset():Ae[v||m.type]&&(Le=Ae[v||m.type](m,ne,ee),this.mergeHandlerResult(z,$,Le,be,D),Le&&Le.needsRenderFrame&&this._triggerRenderFrame()),(Le||Ae.isActive())&&(K[be]=Ae)}const de={};for(const be in this._previousActiveHandlers)K[be]||(de[be]=D);this._previousActiveHandlers=K,(Object.keys(de).length||v2(z))&&(this._changes.push([z,$,de]),this._triggerRenderFrame()),(Object.keys(K).length||v2(z))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:we}=z;we&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],we(this._map))}mergeHandlerResult(m,v,E,D,z){if(!E)return;Object.assign(m,E);const $={handlerName:D,originalEvent:E.originalEvent||z};E.zoomDelta!==void 0&&(v.zoom=$),E.panDelta!==void 0&&(v.drag=$),E.pitchDelta!==void 0&&(v.pitch=$),E.bearingDelta!==void 0&&(v.rotate=$)}_applyChanges(){const m={},v={},E={};for(const[D,z,$]of this._changes)D.panDelta&&(m.panDelta=(m.panDelta||new i.P(0,0))._add(D.panDelta)),D.zoomDelta&&(m.zoomDelta=(m.zoomDelta||0)+D.zoomDelta),D.bearingDelta&&(m.bearingDelta=(m.bearingDelta||0)+D.bearingDelta),D.pitchDelta&&(m.pitchDelta=(m.pitchDelta||0)+D.pitchDelta),D.around!==void 0&&(m.around=D.around),D.aroundCoord!==void 0&&(m.aroundCoord=D.aroundCoord),D.pinchAround!==void 0&&(m.pinchAround=D.pinchAround),D.noInertia&&(m.noInertia=D.noInertia),Object.assign(v,z),Object.assign(E,$);this._updateMapTransform(m,v,E),this._changes=[]}_updateMapTransform(m,v,E){const D=this._map,z=D.transform,$=dt=>[dt.x,dt.y,dt.z];if((()=>{const dt=this._eventsInProgress.drag;return dt&&!this._handlersById[dt.handlerName].isActive()})()&&!v2(m)){const dt=z.zoom;z.cameraElevationReference="sea",this._originalZoom!=null&&z._orthographicProjectionAtLowPitch&&z.projection.name!=="globe"&&z.pitch===0?(z.cameraElevationReference="ground",z.zoom=this._originalZoom):(z.recenterOnTerrain(),z.cameraElevationReference="ground"),dt!==z.zoom&&this._map._update(!0)}if(z._isCameraConstrained&&D._stop(!0),!v2(m))return void this._fireEvents(v,E,!0);let{panDelta:K,zoomDelta:ee,bearingDelta:ne,pitchDelta:de,around:we,aroundCoord:be,pinchAround:Ae}=m;z._isCameraConstrained&&(ee>0&&(ee=0),z._isCameraConstrained=!1),Ae!==void 0&&(we=Ae),(ee||(dt=>v[dt]&&!this._eventsInProgress[dt])("drag"))&&we&&(this._dragOrigin=$(z.pointCoordinate3D(we)),this._originalZoom=z.zoom,this._trackingEllipsoid.setup(z._camera.position,this._dragOrigin)),z.cameraElevationReference="sea",D._stop(!0),we=we||D.transform.centerPoint,ne&&(z.bearing+=ne),de&&(z.pitch+=de),z._updateCameraState();const ze=[0,0,0];if(K)if(z.projection.name==="mercator"){const dt=this._trackingEllipsoid.projectRay(z.screenPointToMercatorRay(we).dir),pt=this._trackingEllipsoid.projectRay(z.screenPointToMercatorRay(we.sub(K)).dir);ze[0]=pt[0]-dt[0],ze[1]=pt[1]-dt[1]}else{const dt=z.pointCoordinate(we);if(z.projection.name==="globe"){K=K.rotate(-z.angle);const pt=z._pixelsPerMercatorPixel/z.worldSize;ze[0]=-K.x*i.eQ(i.bV(dt.y))*pt,ze[1]=-K.y*i.eQ(z.center.lat)*pt}else{const pt=z.pointCoordinate(we.sub(K));dt&&pt&&(ze[0]=pt.x-dt.x,ze[1]=pt.y-dt.y)}}const Le=z.zoom,rt=[0,0,0];if(ee){const dt=$(be||z.pointCoordinate3D(we)),pt={dir:i.ay([],i.ax([],dt,z._camera.position))};if(pt.dir[2]<0){const at=z.zoomDeltaToMovement(dt,ee);i.bJ(rt,pt.dir,at)}}const st=i.cT(ze,ze,rt);z._translateCameraConstrained(st),ee&&Math.abs(z.zoom-Le)>1e-4&&z.recenterOnTerrain(),z.cameraElevationReference="ground",this._map._update(),m.noInertia||this._inertia.record(m),this._fireEvents(v,E,!0)}_fireEvents(m,v,E){const D=y2(this._eventsInProgress),z=y2(m),$={};for(const de in m){const{originalEvent:we}=m[de];this._eventsInProgress[de]||($[`${de}start`]=we),this._eventsInProgress[de]=m[de]}!D&&z&&this._fireEvent("movestart",z.originalEvent);for(const de in $)this._fireEvent(de,$[de]);z&&this._fireEvent("move",z.originalEvent);for(const de in m){const{originalEvent:we}=m[de];this._fireEvent(de,we)}const K={};let ee;for(const de in this._eventsInProgress){const{handlerName:we,originalEvent:be}=this._eventsInProgress[de];this._handlersById[we].isActive()||(delete this._eventsInProgress[de],ee=v[we]||be,K[`${de}end`]=ee)}for(const de in K)this._fireEvent(de,K[de]);const ne=y2(this._eventsInProgress);if(E&&(D||z)&&!ne){this._updatingCamera=!0;const de=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),we=be=>be!==0&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new DF("renderFrame",{timeStamp:m})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const WP="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class FF extends i.E{constructor(m,v){super(),this._moving=!1,this._zooming=!1,this.transform=m,this._bearingSnap=v.bearingSnap,this._respectPrefersReducedMotion=v.respectPrefersReducedMotion!==!1,i.aZ(["_renderFrameCallback"],this)}getCenter(){return new i.aU(this.transform.center.lng,this.transform.center.lat)}setCenter(m,v){return this.jumpTo({center:m},v)}panBy(m,v,E){return m=i.P.convert(m).mult(-1),this.panTo(this.transform.center,Object.assign({offset:m},v),E)}panTo(m,v,E){return this.easeTo(Object.assign({center:m},v),E)}getZoom(){return this.transform.zoom}setZoom(m,v){return this.jumpTo({zoom:m},v),this}zoomTo(m,v,E){return this.easeTo(Object.assign({zoom:m},v),E)}zoomIn(m,v){return this.zoomTo(this.getZoom()+1,m,v),this}zoomOut(m,v){return this.zoomTo(this.getZoom()-1,m,v),this}getBearing(){return this.transform.bearing}setBearing(m,v){return this.jumpTo({bearing:m},v),this}getPadding(){return this.transform.padding}setPadding(m,v){return this.jumpTo({padding:m},v),this}rotateTo(m,v,E){return this.easeTo(Object.assign({bearing:m},v),E)}resetNorth(m,v){return this.rotateTo(0,Object.assign({duration:1e3},m),v),this}resetNorthPitch(m,v){return this.easeTo(Object.assign({bearing:0,pitch:0,duration:1e3},m),v),this}snapToNorth(m,v){return Math.abs(this.getBearing())m.aspect?E/(2*Math.tan(.5*m.fovX)*m.aspect):D/(2*Math.tan(.5*m.fovY)*m.aspect)}_cameraForBoundsOnGlobe(m,v,E,D,z,$){const K=m.clone(),ee=this._extendCameraOptions($);K.bearing=D,K.pitch=z;const ne=i.aU.convert(v),de=i.aU.convert(E),we=.5*(ne.lat+de.lat),be=.5*(ne.lng+de.lng),Ae=i.eT(we,be),ze=i.ay([],Ae),Le=i.ay([],i.bh([],ze,[0,1,0])),rt=i.bh([],Le,ze),st=[Le[0],Le[1],Le[2],0,rt[0],rt[1],rt[2],0,ze[0],ze[1],ze[2],0,0,0,0,1],dt=[Ae,i.eT(ne.lat,ne.lng),i.eT(de.lat,ne.lng),i.eT(de.lat,de.lng),i.eT(ne.lat,de.lng),i.eT(we,ne.lng),i.eT(we,de.lng),i.eT(ne.lat,be),i.eT(de.lat,be)];let pt=i.cU.fromPoints(dt.map(is=>[i.bi(Le,is),i.bi(rt,is),i.bi(ze,is)]));const at=i.ah([],pt.center,st);i.eU(at)===0&&i.eV(at,0,0,1),i.ay(at,at),i.bJ(at,at,i.aF),K.center=i.eW(at);const Bt=K.getWorldToCameraMatrix(),wt=i.b7(new Float64Array(16),Bt);pt=i.cU.applyTransform(pt,i.aD([],Bt,st));const Ft=this._extendAABB(pt,K,ee,D);if(!Ft)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");pt=Ft,i.ah(at,at,Bt);const ft=.5*(pt.max[2]-pt.min[2]),_t=this._minimumAABBFrustumDistance(K,pt),Et=i.bJ([],[0,0,1],ft),Kt=i.cT(Et,at,Et),qt=_t+(K.pitch===0?0:i.bf(at,Kt)),ns=K.globeCenterInViewSpace,Jt=i.ax([],at,[ns[0],ns[1],ns[2]]);i.ay(Jt,Jt),i.bJ(Jt,Jt,qt);const Cs=i.cT([],at,Jt);i.ah(Cs,Cs,wt);const Ls=i.eD/i.aF,Zt=i.ai(Cs),Ht=i.bU(Math.max(Zt*Ls-i.eD,Number.EPSILON),0),ss=Math.min(K.zoomFromMercatorZAdjusted(Ht),ee.maxZoom);return ss>.5*(i.cJ+i.cv)?(K.setProjection({name:"mercator"}),K.zoom=ss,this._cameraForBounds(K,v,E,D,z,$)):{center:K.center,zoom:ss,bearing:D,pitch:z}}_extendAABB(m,v,E,D){const z=.5*((E.padding.left||0)+(E.padding.right||0)),$=.5*((E.padding.top||0)+(E.padding.bottom||0)),K=$,ee=z,ne=z,de=$,we=v.width-(ee+ne),be=v.height-(K+de),Ae=i.ax([],m.max,m.min),ze=Math.min(we/Ae[0],be/Ae[1]),Le=Math.min(v.scaleZoom(v.scale*ze),E.maxZoom);if(isNaN(Le))return null;const rt=v.scale/v.zoomScale(Le),st=new i.cU([m.min[0]-ee*rt,m.min[1]-de*rt,m.min[2]],[m.max[0]+ne*rt,m.max[1]+K*rt,m.max[2]]),dt=(typeof E.offset.x=="number"&&typeof E.offset.y=="number"?new i.P(E.offset.x,E.offset.y):i.P.convert(E.offset)).rotate(-i.ap(D));return st.center[0]-=dt.x*rt,st.center[1]+=dt.y*rt,st}queryTerrainElevation(m,v){const E=this.transform.elevation;return E?(v=Object.assign({},{exaggerated:!0},v),E.getAtPoint(i.ag.fromLngLat(m),null,v.exaggerated)):null}_cameraForBounds(m,v,E,D,z,$){if(m.projection.name==="globe")return this._cameraForBoundsOnGlobe(m,v,E,D,z,$);const K=m.clone(),ee=this._extendCameraOptions($);K.bearing=D,K.pitch=z;const ne=i.aU.convert(v),de=i.aU.convert(E),we=new i.aU(ne.lng,de.lat),be=new i.aU(de.lng,ne.lat),Ae=K.project(ne),ze=K.project(de),Le=this.queryTerrainElevation(ne),rt=this.queryTerrainElevation(de),st=this.queryTerrainElevation(we),dt=this.queryTerrainElevation(be),pt=[[Ae.x,Ae.y,Math.min(Le||0,rt||0,st||0,dt||0)],[ze.x,ze.y,Math.max(Le||0,rt||0,st||0,dt||0)]];let at=i.cU.fromPoints(pt);const Bt=K.getWorldToCameraMatrix(),wt=i.b7(new Float64Array(16),Bt);at=i.cU.applyTransform(at,Bt);const Ft=this._extendAABB(at,K,ee,D);if(!Ft)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");at=Ft;const ft=.5*i.ax([],at.max,at.min)[2],_t=this._minimumAABBFrustumDistance(K,at),Et=[0,0,1,0];i.aE(Et,Et,Bt),i.eX(Et,Et);const Kt=i.bJ([],Et,_t+ft),qt=i.cT([],at.center,Kt);i.ah(at.center,at.center,wt),i.ah(qt,qt,wt);const ns=K.unproject(new i.P(at.center[0],at.center[1])),Jt=i.eY(K.projection,ns),Cs=Math.pow(2,Jt),Ls=Math.min(K._zoomFromMercatorZ(qt[2]*K.pixelsPerMeter*Cs/K.worldSize),ee.maxZoom);return K.mercatorFromTransition&&Ls<.5*(i.cJ+i.cv)?(K.setProjection({name:"globe"}),K.zoom=Ls,this._cameraForBounds(K,v,E,D,z,$)):{center:ns,zoom:Ls,bearing:D,pitch:z}}fitBounds(m,v,E){const D=this.cameraForBounds(m,v);return this._fitInternal(D,v,E)}fitScreenCoordinates(m,v,E,D,z){const $=i.P.convert(m),K=i.P.convert(v),ee=new i.P(Math.min($.x,K.x),Math.min($.y,K.y)),ne=new i.P(Math.max($.x,K.x),Math.max($.y,K.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge($,K))return this;const de=this.transform.pointLocation3D(ee),we=this.transform.pointLocation3D(ne),be=this.transform.pointLocation3D(new i.P(ee.x,ne.y)),Ae=this.transform.pointLocation3D(new i.P(ne.x,ee.y)),ze=[Math.min(de.lng,we.lng,be.lng,Ae.lng),Math.min(de.lat,we.lat,be.lat,Ae.lat)],Le=[Math.max(de.lng,we.lng,be.lng,Ae.lng),Math.max(de.lat,we.lat,be.lat,Ae.lat)],rt=D&&D.pitch?D.pitch:this.getPitch(),st=this._cameraForBounds(this.transform,ze,Le,E,rt,D);return this._fitInternal(st,D,z)}_fitInternal(m,v,E){return m?(v=Object.assign(m,v)).linear?this.easeTo(v,E):this.flyTo(v,E):this}jumpTo(m,v){this.stop();const E=m.preloadOnly?this.transform.clone():this.transform;let D=!1,z=!1,$=!1;"zoom"in m&&E.zoom!==+m.zoom&&(D=!0,E.zoom=+m.zoom),m.center!==void 0&&(E.center=i.aU.convert(m.center)),"bearing"in m&&E.bearing!==+m.bearing&&(z=!0,E.bearing=+m.bearing),"pitch"in m&&E.pitch!==+m.pitch&&($=!0,E.pitch=+m.pitch);const K=typeof m.padding=="number"?this._extendPadding(m.padding):m.padding;if(m.padding!=null&&!E.isPaddingEqual(K))if(m.retainPadding===!1){const ee=E.clone();ee.padding=K,E.setLocationAtPoint(E.center,ee.centerPoint)}else E.padding=K;return m.preloadOnly?(this._preloadTiles(E),this):(this.fire(new i.C("movestart",v)).fire(new i.C("move",v)),D&&this.fire(new i.C("zoomstart",v)).fire(new i.C("zoom",v)).fire(new i.C("zoomend",v)),z&&this.fire(new i.C("rotatestart",v)).fire(new i.C("rotate",v)).fire(new i.C("rotateend",v)),$&&this.fire(new i.C("pitchstart",v)).fire(new i.C("pitch",v)).fire(new i.C("pitchend",v)),this.fire(new i.C("moveend",v)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||i.w(WP),this.transform.getFreeCameraOptions()}setFreeCameraOptions(m,v){const E=this.transform;if(!E.projection.supportsFreeCamera)return i.w(WP),this;this.stop();const D=E.zoom,z=E.pitch,$=E.bearing;E.setFreeCameraOptions(m);const K=D!==E.zoom,ee=z!==E.pitch,ne=$!==E.bearing;return this.fire(new i.C("movestart",v)).fire(new i.C("move",v)),K&&this.fire(new i.C("zoomstart",v)).fire(new i.C("zoom",v)).fire(new i.C("zoomend",v)),ne&&this.fire(new i.C("rotatestart",v)).fire(new i.C("rotate",v)).fire(new i.C("rotateend",v)),ee&&this.fire(new i.C("pitchstart",v)).fire(new i.C("pitch",v)).fire(new i.C("pitchend",v)),this.fire(new i.C("moveend",v)),this}easeTo(m,v){this._stop(!1,m.easeId),((m=Object.assign({offset:[0,0],duration:500,easing:i.eP},m)).animate===!1||this._prefersReducedMotion(m))&&(m.duration=0);const E=this.transform,D=this.getZoom(),z=this.getBearing(),$=this.getPitch(),K=this.getPadding(),ee="zoom"in m?+m.zoom:D,ne="bearing"in m?this._normalizeBearing(m.bearing,z):z,de="pitch"in m?+m.pitch:$,we=this._extendPadding(m.padding),be=i.P.convert(m.offset);let Ae,ze,Le;if(E.projection.name==="globe"){const Et=i.ag.fromLngLat(E.center),Kt=be.rotate(-E.angle);Et.x+=Kt.x/E.worldSize,Et.y+=Kt.y/E.worldSize;const qt=Et.toLngLat(),ns=i.aU.convert(m.center||qt);this._normalizeCenter(ns),Ae=E.centerPoint.add(Kt),ze=new i.P(Et.x,Et.y).mult(E.worldSize),Le=new i.P(i.aH(ns.lng),i.aL(ns.lat)).mult(E.worldSize).sub(ze)}else{Ae=E.centerPoint.add(be);const Et=E.pointLocation(Ae),Kt=i.aU.convert(m.center||Et);this._normalizeCenter(Kt),ze=E.project(Et),Le=E.project(Kt).sub(ze)}const rt=E.zoomScale(ee-D);let st,dt;m.around&&(st=i.aU.convert(m.around),dt=E.locationPoint(st));const pt=this._zooming||ee!==D,at=this._rotating||z!==ne,Bt=this._pitching||de!==$,wt=!E.isPaddingEqual(we),Ft=m.retainPadding===!1?E.clone():E,ft=Et=>Kt=>{if(pt&&(Et.zoom=i.am(D,ee,Kt)),at&&(Et.bearing=i.am(z,ne,Kt)),Bt&&(Et.pitch=i.am($,de,Kt)),wt&&(Ft.interpolatePadding(K,we,Kt),Ae=Ft.centerPoint.add(be)),st)Et.setLocationAtPoint(st,dt);else{const qt=Et.zoomScale(Et.zoom-D),ns=ee>D?Math.min(2,rt):Math.max(.5,rt),Jt=Math.pow(ns,1-Kt),Cs=Et.unproject(ze.add(Le.mult(Kt*Jt)).mult(qt));Et.setLocationAtPoint(Et.renderWorldCopies?Cs.wrap():Cs,Ae)}return m.preloadOnly||this._fireMoveEvents(v),Et};if(m.preloadOnly){const Et=this._emulate(ft,m.duration,E);return this._preloadTiles(Et),this}const _t={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=pt,this._rotating=at,this._pitching=Bt,this._padding=wt,this._easeId=m.easeId,this._prepareEase(v,m.noMoveStart,_t),this._ease(ft(E),Et=>{E.cameraElevationReference==="sea"&&E.recenterOnTerrain(),this._afterEase(v,Et)},m),this}_prepareEase(m,v,E={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&this.transform.pitch===0&&this.transform.projection.name!=="globe"&&(this.transform.cameraElevationReference="ground"),v||E.moving||this.fire(new i.C("movestart",m)),this._zooming&&!E.zooming&&this.fire(new i.C("zoomstart",m)),this._rotating&&!E.rotating&&this.fire(new i.C("rotatestart",m)),this._pitching&&!E.pitching&&this.fire(new i.C("pitchstart",m))}_fireMoveEvents(m){this.fire(new i.C("move",m)),this._zooming&&this.fire(new i.C("zoom",m)),this._rotating&&this.fire(new i.C("rotate",m)),this._pitching&&this.fire(new i.C("pitch",m))}_afterEase(m,v){if(this._easeId&&v&&this._easeId===v)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const E=this._zooming,D=this._rotating,z=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,E&&this.fire(new i.C("zoomend",m)),D&&this.fire(new i.C("rotateend",m)),z&&this.fire(new i.C("pitchend",m)),this.fire(new i.C("moveend",m))}flyTo(m,v){if(this._prefersReducedMotion(m)){const is=i.aJ(m,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(is,v)}this.stop(),m=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:i.eP},m);const E=this.transform,D=this.getZoom(),z=this.getBearing(),$=this.getPitch(),K=this.getPadding(),ee="zoom"in m?i.aC(+m.zoom,E.minZoom,E.maxZoom):D,ne="bearing"in m?this._normalizeBearing(m.bearing,z):z,de="pitch"in m?+m.pitch:$,we=this._extendPadding(m.padding),be=E.zoomScale(ee-D),Ae=i.P.convert(m.offset);let ze=E.centerPoint.add(Ae);const Le=E.pointLocation(ze),rt=i.aU.convert(m.center||Le);this._normalizeCenter(rt);const st=E.project(Le),dt=E.project(rt).sub(st);let pt=m.curve;const at=Math.max(E.width,E.height),Bt=at/be,wt=dt.mag();if("minZoom"in m){const is=i.aC(Math.min(m.minZoom,D,ee),E.minZoom,E.maxZoom),hs=at/E.zoomScale(is-D);pt=Math.sqrt(hs/wt*2)}const Ft=pt*pt;function ft(is){const hs=(Bt*Bt-at*at+(is?-1:1)*Ft*Ft*wt*wt)/(2*(is?Bt:at)*Ft*wt);return Math.log(Math.sqrt(hs*hs+1)-hs)}function _t(is){return(Math.exp(is)-Math.exp(-is))/2}function Et(is){return(Math.exp(is)+Math.exp(-is))/2}const Kt=ft(0);let qt=function(is){return Et(Kt)/Et(Kt+pt*is)},ns=function(is){return at*((Et(Kt)*(_t(hs=Kt+pt*is)/Et(hs))-_t(Kt))/Ft)/wt;var hs},Jt=(ft(1)-Kt)/pt;if(Math.abs(wt)<1e-6||!isFinite(Jt)){if(Math.abs(at-Bt)<1e-6)return this.easeTo(m,v);const is=Btm.maxDuration&&(m.duration=0);const Cs=z!==ne,Ls=de!==$,Zt=!E.isPaddingEqual(we),Ht=m.retainPadding===!1?E.clone():E,ss=is=>hs=>{const Qs=hs*Jt,Ws=1/qt(Qs);is.zoom=hs===1?ee:D+is.scaleZoom(Ws),Cs&&(is.bearing=i.am(z,ne,hs)),Ls&&(is.pitch=i.am($,de,hs)),Zt&&(Ht.interpolatePadding(K,we,hs),ze=Ht.centerPoint.add(Ae));const Ks=hs===1?rt:is.unproject(st.add(dt.mult(ns(Qs))).mult(Ws));return is.setLocationAtPoint(is.renderWorldCopies?Ks.wrap():Ks,ze),is._updateCameraOnTerrain(),m.preloadOnly||this._fireMoveEvents(v),is};if(m.preloadOnly){const is=this._emulate(ss,m.duration,E);return this._preloadTiles(is),this}return this._zooming=!0,this._rotating=Cs,this._pitching=Ls,this._padding=Zt,this._prepareEase(v,!1),this._ease(ss(E),()=>this._afterEase(v),m),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(m){}_cancelRenderFrame(m){}_stop(m,v){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const E=this._onEaseEnd;this._onEaseEnd=void 0,E.call(this,v)}if(!m){const E=this.handlers;E&&E.stop(!1)}return this}_ease(m,v,E){E.animate===!1||E.duration===0?(m(1),v()):(this._easeStart=i.o.now(),this._easeOptions=E,this._onEaseFrame=m,this._onEaseEnd=v,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const m=Math.min((i.o.now()-this._easeStart)/this._easeOptions.duration,1),v=this._onEaseFrame;v&&v(this._easeOptions.easing(m)),m<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(m,v){m=i.bs(m,-180,180);const E=Math.abs(m-v);return Math.abs(m-360-v)180?-360:E<-180?360:0}_prefersReducedMotion(m){return this._respectPrefersReducedMotion&&i.o.prefersReducedMotion&&!(m&&m.essential)}_emulate(m,v,E){const D=Math.ceil(15*v/1e3),z=[],$=m(E.clone());for(let K=0;K<=D;K++){const ee=$(K/D);z.push(ee.clone())}return z}_preloadTiles(m,v){}}class KP{constructor(m={}){this.options=m,i.aZ(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(m){const v=this.options&&this.options.compact,E=m._getUIString("AttributionControl.ToggleAttribution");this._map=m,this._container=N("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=N("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",E);const D=N("span","mapboxgl-ctrl-icon",this._compactButton);return D.setAttribute("aria-hidden","true"),D.setAttribute("title",E),this._innerContainer=N("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 m=this._editLink;m||(m=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.g.ACCESS_TOKEN}];if(m){const E=v.reduce((D,z,$)=>(z.value&&(D+=`${z.key}=${z.value}${$D.length-z.length),m=m.filter((D,z)=>{for(let $=z+1;$=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?m=[...this.options.customAttribution,...m]:m.unshift(this.options.customAttribution));const E=m.map(D=>function(z){const $=new DOMParser().parseFromString(z,"text/html");return Array.from($.body.querySelectorAll("*")).reverse().forEach(K=>{const ee=K.textContent||"";if(K.tagName!=="A")return void K.replaceWith(...K.childNodes);const ne=K.getAttribute("href");if(!ne||!/^(https?:|mailto:)/i.test(ne))return void K.replaceWith($.createTextNode(ee));const de=$.createElement("a");de.href=ne,de.textContent=ee,de.rel="noopener nofollow";const we=K.getAttribute("class");we&&(de.className=we),K.replaceWith(de)}),$.body.innerHTML}(D)).join(" | ");E!==this._attribHTML&&(this._attribHTML=E,m.length?(this._innerContainer.innerHTML=E,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 ZP{constructor(){i.aZ(["_updateLogo","_updateCompact"],this)}onAdd(m){this._map=m,this._container=N("div","mapboxgl-ctrl");const v=N("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(m){m&&m.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const m=this._map.style._sourceCaches;if(Object.entries(m).length===0)return!0;for(const v in m){const E=m[v].getSource();if(E.hasOwnProperty("mapbox_logo")&&!E.mapbox_logo)return!1}return!0}_updateCompact(){const m=this._container.children;if(m.length){const v=m[0];this._map.getCanvasContainer().offsetWidth<250?v.classList.add("mapboxgl-compact"):v.classList.remove("mapboxgl-compact")}}}class zF{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(m){const v=++this._id;return this._queue.push({callback:m,id:v,cancelled:!1}),v}remove(m){const v=this._currentlyRunning,E=v?this._queue.concat(v):this._queue;for(const D of E)if(D.id===m)return void(D.cancelled=!0)}run(m=0){const v=this._currentlyRunning=this._queue;this._queue=[];for(const E of v)if(!E.cancelled&&(E.callback(m),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}class Ipe{constructor(m){this.jumpTo(m)}getValue(m){if(m<=this._startTime)return this._start;if(m>=this._endTime)return this._end;const v=i.dn((m-this._startTime)/(this._endTime-this._startTime));return this._start*(1-v)+this._end*v}isEasing(m){return m>=this._startTime&&m<=this._endTime}jumpTo(m){this._startTime=-1/0,this._endTime=-1/0,this._start=m,this._end=m}easeTo(m,v,E){this._start=this.getValue(v),this._end=m,this._startTime=v,this._endTime=v+E}}const Lpe={"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 ji extends i.C{constructor(m,v,E,D){const{point:z,lngLat:$,originalEvent:K,target:ee}=m;super(m.type,{point:z,lngLat:$,originalEvent:K,target:ee}),this.preventDefault=()=>{m.preventDefault()},this.id=v,this.interaction=E,this.feature=D}}class P3{constructor(m){this.map=m,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(m,v){if(this.typeById.has(m))throw new Error(`Interaction id "${m}" already exists.`);const E=v.filter;let D=v.type;E&&this.filters.set(m,i.dg(E)),D==="mouseover"&&(D="mouseenter"),D==="mouseout"&&(D="mouseleave");const z=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(m,v)):z.size===0&&this.map.on(D,this.handleType),z.size===0&&this.interactionsByType.set(D,z),z.set(m,v),this.typeById.set(m,D)}get(m){const v=this.typeById.get(m);if(!v)return;const E=this.interactionsByType.get(v);return E?E.get(m):void 0}remove(m){const v=this.typeById.get(m);if(!v)return;this.typeById.delete(m),this.filters.delete(m);const E=this.interactionsByType.get(v);E&&(E.delete(m),v==="mouseenter"||v==="mouseleave"?(this.delegatedInteractions.delete(m),this.delegatedInteractions.size===0&&(this.map.off("mousemove",this.handleMove),this.map.off("mouseout",this.handleOut))):E.size===0&&this.map.off(v,this.handleType))}queryTargets(m,v){const E=[];for(const[D,z]of v)z.target&&E.push({targetId:D,target:z.target,filter:this.filters.get(D)});return this.map.style.queryRenderedTargets(m,E,this.map.transform)}handleMove(m){this.prevHoveredFeatures=this.hoveredFeatures,this.hoveredFeatures=new Map;const v=this.queryTargets(m.point,Array.from(this.delegatedInteractions).reverse());v.length&&(m.type="mouseenter",this.handleType(m,v));const E=new Map;for(const[D,{feature:z}]of this.prevHoveredFeatures)this.hoveredFeatures.has(D)||E.set(z.id,z);E.size&&(m.type="mouseleave",this.handleType(m,Array.from(E.values())))}handleOut(m){const v=Array.from(this.hoveredFeatures.values()).map(({feature:E})=>E);v.length&&(m.type="mouseleave",this.handleType(m,v)),this.hoveredFeatures.clear()}handleType(m,v){const E=m.type==="mouseenter";if(E&&!this.interactionsByType.has(m.type))return void i.w("mouseenter interaction required for mouseleave to work.");const D=Array.from(this.interactionsByType.get(m.type)).reverse(),z=!!v;v=v||this.queryTargets(m.point,D);let $=!1;const K=new Set;for(const ee of v){for(const[ne,de]of D){if(!de.target)continue;const we=ee.variants?ee.variants[ne]:null;if(we){for(const be of we){if(Kh(be,ee,K,ne))continue;const Ae=new i.di(ee,be),ze=Ew(be,ee,ne);z&&Ae.id!==void 0&&(Ae.state=this.map.getFeatureState(Ae));const Le=E?this.prevHoveredFeatures.get(ze):null,rt=new ji(m,ne,de,Ae),st=Le?Le.stop:de.handler(rt);if(E&&this.hoveredFeatures.set(ze,{feature:ee,stop:st}),st!==!1){$=!0;break}}if($)break}}if($)break}if(!$)for(const[ee,ne]of D){const{handler:de,target:we}=ne;if(!we&&de(new ji(m,ee,ne,null))!==!1)break}}}function Dpe(M,m){if(Array.isArray(M)&&Array.isArray(m)){const v=new Set(M),E=new Set(m);return v.size===E.size&&M.every(D=>E.has(D))}return i.b6(M,m)}const Rpe={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,useServerFontComposition:!0,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1,precompilePrograms:!0,scaleFactor:1},Ope={showCompass:!0,showZoom:!0,visualizePitch:!1};class _2{constructor(m,v,E=!1){this._clickTolerance=10,this.element=v,this.mouseRotate=new S3({clickTolerance:m.dragRotate._mouseRotate._clickTolerance}),this.map=m,E&&(this.mousePitch=new f2({clickTolerance:m.dragRotate._mousePitch._clickTolerance})),i.aZ(["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(m,v){this.mouseRotate.mousedown(m,v),this.mousePitch&&this.mousePitch.mousedown(m,v),I()}move(m,v){const E=this.map,D=this.mouseRotate.mousemoveWindow(m,v),z=D&&D.bearingDelta;if(z&&E.setBearing(E.getBearing()+z),this.mousePitch){const $=this.mousePitch.mousemoveWindow(m,v),K=$&&$.pitchDelta;K&&E.setPitch(E.getPitch()+K)}}off(){const m=this.element;m.removeEventListener("mousedown",this.mousedown),m.removeEventListener("touchstart",this.touchstart),m.removeEventListener("touchmove",this.touchmove),m.removeEventListener("touchend",this.touchend),m.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){L(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(m){this.down(Object.assign({},m,{button:m.button,type:m.type,ctrlKey:!0,preventDefault:()=>m.preventDefault()}),q(this.element,m)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(m){this.move(m,q(this.element,m))}mouseup(m){this.mouseRotate.mouseupWindow(m),this.mousePitch&&this.mousePitch.mouseupWindow(m),this.offTemp()}touchstart(m){m.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=B(this.element,m.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>m.preventDefault()},this._startPos))}touchmove(m){m.targetTouches.length!==1?this.reset():(this._lastPos=B(this.element,m.targetTouches)[0],this.move({buttons:1,preventDefault:()=>m.preventDefault()},this._lastPos))}touchend(m){m.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)v.width||m.y>v.height;v.locationPoint3D(E).distSqr(m)<$&&(K||Math.abs(E.lng-v.center.lng)180;){const E=v.locationPoint3D(M);if(E.x>=0&&E.y>=0&&E.x<=v.width&&E.y<=v.height)break;M.lng>v.center.lng?M.lng-=360:M.lng+=360}return M}const b2={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%)"},em={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class Wm extends i.E{constructor(m,v){super(),(m instanceof HTMLElement||v)&&(m=Object.assign({element:m},v)),i.aZ(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);const{anchor:E="center",color:D="#3FB1CE",scale:z=1,draggable:$=!1,clickTolerance:K=0,rotation:ee=em.rotation,rotationAlignment:ne=em.rotationAlignment,pitchAlignment:de=em.pitchAlignment,occludedOpacity:we=em.occludedOpacity,altitude:be=em.altitude}=m||{};this._anchor=E,this._color=D,this._scale=z,this._draggable=$,this._clickTolerance=K,this._rotation=ee,this._rotationAlignment=ne,this._pitchAlignment=de,this._occludedOpacity=we,this._altitude=be,this._state="inactive",this._isDragging=!1,this._updateMoving=()=>this._update(!0),m&&m.element?(this._element=m.element,this._offset=i.P.convert(m&&m.offset||[0,0])):(this._defaultMarker=!0,this._element=this._createDefaultMarker(),this._offset=i.P.convert(m&&m.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",Le=>{Le.preventDefault()}),this._element.addEventListener("mousedown",Le=>{Le.preventDefault()});const Ae=this._element.classList;for(const Le in b2)Ae.remove(`mapboxgl-marker-anchor-${Le}`);Ae.add(`mapboxgl-marker-anchor-${this._anchor}`);const ze=m&&m.className?m.className.trim().split(/\s+/):[];Ae.add(...ze),this._popup=null}_createDefaultMarker(){const m=N("div"),v=w("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},m);if(this._altitude===0){const E=w("radialGradient",{id:"shadowGradient"},w("defs",{},v));w("stop",{offset:"10%","stop-opacity":.4},E),w("stop",{offset:"100%","stop-opacity":.05},E),w("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},v)}return w("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},v),w("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},v),w("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},v),m}addTo(m){return m===this._map||(this.remove(),this._map=m,m.getCanvasContainer().appendChild(this._element),m.on("move",this._updateMoving),m.on("moveend",this._update),m.on("remove",this._clearFadeTimer),m._addMarker(this),this.setDraggable(this._draggable),this._update(),m.on("click",this._onMapClick)),this}remove(){const m=this._map;return m&&(m.off("click",this._onMapClick),m.off("move",this._updateMoving),m.off("moveend",this._update),m.off("mousedown",this._addDragHandler),m.off("touchstart",this._addDragHandler),m.off("mouseup",this._onUp),m.off("touchend",this._onUp),m.off("mousemove",this._onMove),m.off("touchmove",this._onMove),m.off("remove",this._clearFadeTimer),m._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(m){return this._lngLat=i.aU.convert(m),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}setAltitude(m){return m===this._altitude||(this._defaultMarker&&(this._altitude===0&&m!==0||this._altitude!==0&&m===0)&&(this._element=this._createDefaultMarker()),this._altitude=m||em.altitude,this._update()),this}getAltitude(){return this._altitude}getElement(){return this._element}setPopup(m){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")),m){if(!("offset"in m.options)){const D=Math.sqrt(Math.pow(13.5,2)/2);m.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=m,m._marker=this,m._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(m){const v=m.code,E=m.charCode||m.keyCode;v!=="Space"&&v!=="Enter"&&E!==32&&E!==13||this.togglePopup()}_onMapClick(m){const v=m.originalEvent.target,E=this._element;this._popup&&(v===E||E.contains(v))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const m=this._popup;return m?(m.isOpen()?(m.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(m.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const m=this._map,v=this._pos;if(!m||!v)return!1;const E=m.unproject(v,this._altitude),D=m.getFreeCameraOptions();if(!D.position)return!1;const z=D.position.toLngLat();return z.distanceTo(E)<.9*z.distanceTo(this._lngLat)}_evaluateOpacity(){const m=this._map;if(!m)return;const v=this._pos;if(!v||v.x<0||v.x>m.transform.width||v.y<0||v.y>m.transform.height)return void this._clearFadeTimer();const E=m.unproject(v,this._altitude);let D;m._showingGlobe()&&i.e$(m.transform,this._lngLat)?D=0:(D=1-m._queryFogOpacity(E),m.transform._terrainEnabled()&&m.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 m=this._pos;if(!m||!this._map)return;const v=this._offset.mult(this._scale);this._element.style.transform=` translate(${m.x}px,${m.y}px) ${b2[this._anchor]} ${this._calculateXYTransform()} ${this._calculateZTransform()} translate(${v.x}px,${v.y}px) `}_calculateXYTransform(){const m=this._pos,v=this._map,E=this.getPitchAlignment();if(!v||!m||E!=="map")return"";if(!v._showingGlobe()){const ee=v.getPitch();return ee?`rotateX(${ee}deg)`:""}const D=i.cH(i.f0(v.transform,this._lngLat)),z=m.sub(i.f1(v.transform)),$=Math.abs(z.x)+Math.abs(z.y);if($===0)return"";const K=D/$;return`rotateX(${-z.y*K}deg) rotateY(${z.x*K}deg)`}_calculateZTransform(){const m=this._pos,v=this._map;if(!v||!m)return"";let E=0;const D=this.getRotationAlignment();if(D==="map")if(v._showingGlobe()){const z=v.project(new i.aU(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),$=v.project(new i.aU(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(z);E=i.cH(Math.atan2($.y,$.x))-90}else E=-v.getBearing();else if(D==="horizon"){const z=i.aj(4,6,v.getZoom()),$=i.f1(v.transform);$.y+=z*v.transform.height;const K=m.sub($),ee=i.cH(Math.atan2(K.y,K.x));E=(ee>90?ee-270:ee+90)*(1-z)}return E+=this._rotation,E?`rotateZ(${E}deg)`:""}_update(m){cancelAnimationFrame(this._updateFrameId);const v=this._map;v&&(v.transform.renderWorldCopies&&(this._lngLat=YP(this._lngLat,this._pos,v.transform)),this._pos=v.project(this._lngLat,this._altitude),m===!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(m){return this._offset=i.P.convert(m),this._update(),this}addClassName(m){return this._element.classList.add(m),this}removeClassName(m){return this._element.classList.remove(m),this}toggleClassName(m){return this._element.classList.toggle(m)}_onMove(m){const v=this._map;if(!v)return;const E=this._pointerdownPos,D=this._positionDelta;if(E&&D){if(!this._isDragging){const z=this._clickTolerance||v._clickTolerance;if(m.point.dist(E)M.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(M.minPitch!=null&&M.maxPitch!=null&&M.minPitch>M.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(M.minPitch!=null&&M.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(M.maxPitch!=null&&M.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");M.antialias&&i.eZ(window)&&(M.antialias=!1,i.w("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new $w(M.minZoom,M.maxZoom,M.minPitch,M.maxPitch,M.renderWorldCopies,null,null),M),this._repaint=!!M.repaint,this._interactive=M.interactive,this._minTileCacheSize=M.minTileCacheSize,this._maxTileCacheSize=M.maxTileCacheSize,this._failIfMajorPerformanceCaveat=M.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=M.preserveDrawingBuffer,this._antialias=M.antialias,this._trackResize=M.trackResize,this._bearingSnap=M.bearingSnap,this._refreshExpiredTiles=M.refreshExpiredTiles,this._fadeDuration=M.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=M.crossSourceCollisions,this._collectResourceTiming=M.collectResourceTiming,this._language=this._parseLanguage(M.language),this._worldview=M.worldview,this._renderTaskQueue=new zF,this._domRenderTaskQueue=new zF,this._controls=[],this._markers=[],this._popups=[],this._mapId=i.r(),this._locale=Object.assign({},Lpe,M.locale),this._clickTolerance=M.clickTolerance,this._cooperativeGestures=M.cooperativeGestures,this._performanceMetricsCollection=M.performanceMetricsCollection,this._tessellationStep=M.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=M.precompilePrograms,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new Ipe(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=M.scaleFactor,this._requestManager=new X(M.transformRequest,M.accessToken,M.testMode);const v=me(M.accessToken||i.g.ACCESS_TOKEN);if(v&&"atlas"in v&&typeof v.atlas=="number"&&(this._tokenExpiration=v.atlas),this._silenceAuthErrors=!!M.testMode,this._contextCreateOptions=M.contextCreateOptions?Object.assign({},M.contextCreateOptions):{},typeof M.container=="string"){const E=document.getElementById(M.container);if(!E)throw new Error(`Container '${M.container.toString()}' not found.`);this._container=E}else{if(!(M.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=M.container}if(this._container.childNodes.length>0&&i.w("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),M.maxBounds&&this.setMaxBounds(M.maxBounds),this._spriteFormat="auto",i.aZ(["_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 OF(this,M),this._localFontFamily=M.localFontFamily,this._localIdeographFontFamily=M.localIdeographFontFamily,this._useServerFontComposition=M.useServerFontComposition,(M.style||!M.testMode)&&this.setStyle(M.style||i.g.DEFAULT_STYLE,{config:M.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily,useServerFontComposition:this._useServerFontComposition}),M.projection&&this.setProjection(M.projection),M.hash&&(this._hash=new Epe(typeof M.hash=="string"&&M.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){m.center==null&&m.zoom==null||(this.transform._unmodified=!1),this.jumpTo({center:M.center,zoom:M.zoom,bearing:M.bearing,pitch:M.pitch});const E=M.bounds;E&&(this.resize(),this.fitBounds(E,Object.assign({},M.fitBoundsOptions,{duration:0})))}this.resize(),M.attributionControl&&this.addControl(new KP({customAttribution:M.customAttribution})),this._logoControl=new ZP,this.addControl(this._logoControl,M.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent()}),this.on("data",E=>{this._update(E.dataType==="style"),this.fire(new i.C(`${E.dataType}data`,E))}),this.on("dataloading",E=>{this.fire(new i.C(`${E.dataType}dataloading`,E))}),this._interactions=new P3(this)}_getMapId(){return this._mapId}addControl(M,m){if(m===void 0&&(m=M.getDefaultPosition?M.getDefaultPosition():"top-right"),!M||!M.onAdd)return this.fire(new i.B(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const v=M.onAdd(this);this._controls.push(M);const E=this._controlPositions[m];return m.indexOf("bottom")!==-1?E.insertBefore(v,E.firstChild):E.appendChild(v),this}removeControl(M){if(!M||!M.onRemove)return this.fire(new i.B(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const m=this._controls.indexOf(M);return m>-1&&this._controls.splice(m,1),M.onRemove(this),this}hasControl(M){return this._controls.indexOf(M)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(M){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const m=!this._moving;return m&&this.fire(new i.C("movestart",M)).fire(new i.C("move",M)),this.fire(new i.C("resize",M)),m&&this.fire(new i.C("moveend",M)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(M){return this.transform.setMaxBounds(i.aK.convert(M)),this._update()}setMinZoom(M){if((M=M??-2)>=-2&&M<=this.transform.maxZoom)return this.transform.minZoom=M,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=M,this._update(),this.getZoom()>M?this.setZoom(M):this.fire(new i.C("zoomstart")).fire(new i.C("zoom")).fire(new i.C("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(M){if((M=M??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(M>=0&&M<=this.transform.maxPitch)return this.transform.minPitch=M,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(M>=this.transform.minPitch)return this.transform.maxPitch=M,this._update(),this.getPitch()>M?this.setPitch(M):this.fire(new i.C("pitchstart")).fire(new i.C("pitch")).fire(new i.C("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getScaleFactor(){return this._scaleFactor}setScaleFactor(M){return this._scaleFactor=M,this.painter.scaleFactor=M,this.style&&this.style._setLabelPlacementStale(),this.style._updateFilteredLayers(m=>m.type==="symbol"),this._update(!0),this}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(M){return this.transform.renderWorldCopies=M,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(M){return M==="auto"?navigator.language:Array.isArray(M)?M.length===0?void 0:M.map(m=>m==="auto"?navigator.language:m):M}setLanguage(M){const m=this._parseLanguage(M);if(!this.style||m===this._language)return this;this._language=m,this.style.reloadSources();for(const v of this._controls)v._setLanguage&&v._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(M){return this.style&&M!==this._worldview?(this._worldview=M,this._styleDirty=!0,this.style.setWorldview(M),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return this.transform.projection.name==="globe"}setProjection(M){return this._lazyInitEmptyStyle(),M?typeof M=="string"&&(M={name:M}):M=null,this._useExplicitProjection=!!M,this._prioritizeAndUpdateProjection(M,this.style.projection)}_updateProjectionTransition(){if(this.getProjection().name!=="globe")return;const M=this.transform,m=M.projection.name;let v;m==="globe"&&M.zoom>=i.cv?(M.setMercatorFromTransition(),v=!0):m==="mercator"&&M.zoom=i.cv?this.transform.setMercatorFromTransition():this.transform.setProjection(M),this.style.applyProjectionUpdate();const E=this.transform.getProjection().name==="mercator"&&v!==this.transform.mercatorFromTransition;return(m||E)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(M,m){return this.transform.locationPoint3D(i.aU.convert(M),m)}unproject(M,m){return this.transform.pointLocation3D(i.P.convert(M),m)}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(M,m,v){const E=D=>{let z=[];if(Array.isArray(m)){const $=m.filter(K=>this.getLayer(K));z=$.length?this.queryRenderedFeatures(D,{layers:$}):[]}else z=this.queryRenderedFeatures(D,{target:m});return z};if(M==="mouseenter"||M==="mouseover"){let D=!1;return{listener:v,targets:m,delegates:{mousemove:$=>{const K=E($.point);K.length?D||(D=!0,v.call(this,new dd(M,this,$.originalEvent,{features:K}))):D=!1},mouseout:()=>{D=!1}}}}if(M==="mouseleave"||M==="mouseout"){let D=!1;return{listener:v,targets:m,delegates:{mousemove:K=>{E(K.point).length?D=!0:D&&(D=!1,v.call(this,new dd(M,this,K.originalEvent)))},mouseout:K=>{D&&(D=!1,v.call(this,new dd(M,this,K.originalEvent)))}}}}{const D=z=>{const $=E(z.point);$.length&&(z.features=$,v.call(this,z),delete z.features)};return{listener:v,targets:m,delegates:{[M]:D}}}}on(M,m,v){if(typeof m=="function"||v===void 0)return super.on(M,m);if(typeof m=="string"&&(m=[m]),!this._areTargetsValid(m))return this;const E=this._createDelegatedListener(M,m,v);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[M]=this._delegatedListeners[M]||[],this._delegatedListeners[M].push(E);for(const D in E.delegates)this.on(D,E.delegates[D]);return this}once(M,m,v){if(typeof m=="function"||v===void 0)return super.once(M,m);if(typeof m=="string"&&(m=[m]),!this._areTargetsValid(m))return this;const E=this._createDelegatedListener(M,m,v);for(const D in E.delegates)this.once(D,E.delegates[D]);return this}off(M,m,v){if(typeof m=="function"||v===void 0)return super.off(M,m);if(typeof m=="string"&&(m=[m]),!this._areTargetsValid(m))return this;const E=this._delegatedListeners?this._delegatedListeners[M]:void 0;return E&&(D=>{for(let z=0;z{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(M,m)}else E&&this._update(!0)},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=m.localIdeographFontFamily,this._localFontFamily=m.localFontFamily,this._updateStyle(M,m))}_getUIString(M){const m=this._locale[M];if(m==null)throw new Error(`Missing UI string '${M}'`);return m}_updateStyle(M,m){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),M){const v=Object.assign({},m);m&&m.config&&(v.initialConfig=m.config,delete v.config),this.style=new Vm(this,v).load(M),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Vm(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(i.w("There is no style added to the map."),!1)}_isValidId(M){return M==null?(this.fire(new i.B(new Error("IDs can't be empty."))),!1):!i.db(M)||(this.fire(new i.B(new Error(`IDs can't contain special symbols: "${M}".`))),!1)}_isTargetValid(M){return"featuresetId"in M?this._isValidId("importId"in M?M.importId:M.featuresetId):"layerId"in M&&this._isValidId(M.layerId)}_areTargetsValid(M){if(Array.isArray(M)){for(const m of M)if(!this._isValidId(m))return!1;return!0}return this._isTargetValid(M)}addSource(M,m){return this._isValidId(M)?(this._lazyInitEmptyStyle(),this.style.addSource(M,m),this._update(!0)):this}isSourceLoaded(M){return!!this._isValidId(M)&&!!this.style&&this.style._isSourceCacheLoaded(M)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(M,m,v){this._lazyInitEmptyStyle(),this.style.addSourceType(M,m,v)}removeSource(M){return this._isValidId(M)?(this.style.removeSource(M),this._updateTerrain(),this._update(!0)):this}getSource(M){return this._isValidId(M)?this.style.getOwnSource(M):null}addImage(M,m,{pixelRatio:v=1,sdf:E=!1,stretchX:D,stretchY:z,content:$}={}){this._lazyInitEmptyStyle();const K=i.I.from(M);if(m instanceof HTMLImageElement||ImageBitmap&&m instanceof ImageBitmap){const{width:ee,height:ne,data:de}=i.o.getImageData(m);this.style.addImage(K,{data:new i.q({width:ee,height:ne},de),pixelRatio:v,stretchX:D,stretchY:z,content:$,sdf:E,version:0,usvg:!1})}else if(m.width===void 0||m.height===void 0)this.fire(new i.B(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:ne}=m,de=m;this.style.addImage(K,{data:new i.q({width:ee,height:ne},new Uint8Array(de.data)),pixelRatio:v,stretchX:D,stretchY:z,content:$,sdf:E,usvg:!1,version:0,userImage:de}),de.onAdd&&de.onAdd(this,M)}}updateImage(M,m){this._lazyInitEmptyStyle();const v=i.I.from(M),E=this.style.getImage(v);if(!E)return void this.fire(new i.B(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const D=m instanceof HTMLImageElement||ImageBitmap&&m instanceof ImageBitmap?i.o.getImageData(m):m,{width:z,height:$,data:K}=D;if(z===void 0||$===void 0)return void this.fire(new i.B(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(z!==(E.usvg?E.icon.usvg_tree.width:E.data.width)||$!==(E.usvg?E.icon.usvg_tree.height:E.data.height))return void this.fire(new i.B(new Error(`The width and height of the updated image (${z}, ${$}) must be that same as the previous version of the image (${E.data.width}, ${E.data.height})`)));const ee=!(m instanceof HTMLImageElement||ImageBitmap&&m instanceof ImageBitmap);let ne=!1;E.usvg?(E.data=new i.q({width:z,height:$},new Uint8Array(K)),E.usvg=!1,E.icon=void 0,ne=!0):E.data.replace(K,ee),this.style.updateImage(v,E,ne)}hasImage(M){return M?!!this.style&&!!this.style.getImage(i.I.from(M)):(this.fire(new i.B(new Error("Missing required image id"))),!1)}removeImage(M){this.style.removeImage(i.I.from(M))}loadImage(M,m){i.n(this._requestManager.transformRequest(M,i.R.Image),(v,E)=>{m(v,E)})}listImages(){return this.style.listImages().map(M=>M.name)}addModel(M,m){this._lazyInitEmptyStyle(),this.style.addModel(M,m)}hasModel(M){return M?this.style.hasModel(M):(this.fire(new i.B(new Error("Missing required model id"))),!1)}removeModel(M){this.style.removeModel(M)}listModels(){return this.style.listModels()}addLayer(M,m){return this._isValidId(M.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(M,m),this._update(!0)):this}getSlot(M){const m=this.getLayer(M);return m&&m.slot||null}setSlot(M,m){return this.style.setSlot(M,m),this.style.mergeLayers(),this._update(!0)}addImport(M,m){return this.style.addImport(M,m).catch(v=>this.fire(new i.B(new Error("Failed to add import",v)))),this}updateImport(M,m){return typeof m!="string"&&m.id!==M?(this.removeImport(M),this.addImport(m)):(this.style.updateImport(M,m),this._update(!0))}removeImport(M){return this.style.removeImport(M),this}moveImport(M,m){return this.style.moveImport(M,m),this._update(!0)}moveLayer(M,m){return this._isValidId(M)?(this.style.moveLayer(M,m),this._update(!0)):this}removeLayer(M){return this._isValidId(M)?(this.style.removeLayer(M),this._update(!0)):this}getLayer(M){if(!this._isValidId(M))return null;const m=this.style.getOwnLayer(M);return m?m.type==="custom"?m.implementation:m.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(M,m,v){return this._isValidId(M)?(this.style.setLayerZoomRange(M,m,v),this._update(!0)):this}setFilter(M,m,v={}){return this._isValidId(M)?(this.style.setFilter(M,m,v),this._update(!0)):this}getFilter(M){return this._isValidId(M)?this.style.getFilter(M):null}setPaintProperty(M,m,v,E={}){return this._isValidId(M)?(this.style.setPaintProperty(M,m,v,E),this._update(!0)):this}getPaintProperty(M,m){return this._isValidId(M)?this.style.getPaintProperty(M,m):null}setLayoutProperty(M,m,v,E={}){return this._isValidId(M)?(this.style.setLayoutProperty(M,m,v,E),this._update(!0)):this}getLayoutProperty(M,m){return this._isValidId(M)?this.style.getLayoutProperty(M,m):null}setLayerProperty(M,m,v,E={}){return this._isValidId(M)?(m==="appearances"&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(M,m,v,E),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(M){return this.style.setGlyphsUrl(M),this._update(!0)}getSchema(M){return this.style.getSchema(M)}setSchema(M,m){return this.style.setSchema(M,m),this._update(!0)}getConfig(M){return this.style.getConfig(M)}setConfig(M,m){return this.style.setConfig(M,m),this._update(!0)}getConfigProperty(M,m){return this.style.getConfigProperty(M,m)}setConfigProperty(M,m,v){return this.style.setConfigProperty(M,m,v),this._update(!0)}getFeaturesetDescriptors(M){return this.style.getFeaturesetDescriptors(M)}setLights(M){if(this._lazyInitEmptyStyle(),M&&M.length===1&&M[0].type==="flat"){const m=M[0];m.properties?this.style.setFlatLight(m.properties,m.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(M),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const M=this.style.getLights()||[];return M.length===0&&M.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),M}setLight(M,m={}){return console.log("The `map.setLight` function is deprecated, prefer using `map.setLights` with `flat` light type instead."),this.setLights([{id:"flat",type:"flat",properties:M}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(M){return this._lazyInitEmptyStyle(),!M&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(M),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(M){return this._lazyInitEmptyStyle(),this.style.setFog(M),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setSnow(M){return this._lazyInitEmptyStyle(),this.style.setSnow(M),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(M){return this._lazyInitEmptyStyle(),this.style.setRain(M),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(M){return this._lazyInitEmptyStyle(),this.style.setColorTheme(M),this._update(!0)}setImportColorTheme(M,m){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(M,m),this._update(!0)}setCamera(M){return this.style.setCamera(M),this._triggerCameraUpdate(M)}getNearClipOffset(){return this.transform.nearClipOffset}setNearClipOffset(M){const m=this.transform.nearClipOffset!==M;return this.transform.nearClipOffset=M,this._update(m)}_triggerCameraUpdate(M){return this._update(this.transform.setOrthographicProjectionAtLowPitch(M["camera-projection"]==="orthographic"))}getCamera(){return this.style.camera}_queryFogOpacity(M){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(i.aU.convert(M),this.transform):0}setFeatureState(M,m){return M.source&&!this._isValidId(M.source)?this:(this.style.setFeatureState(M,m),this._update())}removeFeatureState(M,m){return M.source&&!this._isValidId(M.source)?this:(this.style.removeFeatureState(M,m),this._update())}getFeatureState(M){return M.source&&!this._isValidId(M.source)?null:this.style.getFeatureState(M)}_selectIndoorFloor(M){this.style.indoorManager.selectFloor(M)}_setIndoorActiveFloorsVisibility(M){this.style.indoorManager.setActiveFloorsVisibility(M)}getIndoorTileOptions(M,m){return this.style.isIndoorEnabled()?this.style.indoorManager.getIndoorTileOptions(M,m):null}_updateContainerDimensions(){if(!this._container)return;const M=this._container.getBoundingClientRect().width||400,m=this._container.getBoundingClientRect().height||300;let v,E,D,z=this._container;for(;z&&(!E||!D);){const $=window.getComputedStyle(z).transform;$&&$!=="none"&&(v=$.match(/matrix.*\((.+)\)/)[1].split(", "),v[0]&&v[0]!=="0"&&v[0]!=="1"&&(E=v[0]),v[3]&&v[3]!=="0"&&v[3]!=="1"&&(D=v[3])),z=z.parentElement}this._containerWidth=E?Math.abs(M/E):M,this._containerHeight=D?Math.abs(m/D):m}_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/.")}_setupContainer(){const M=this._container;M.classList.add("mapboxgl-map"),(this._missingCSSCanary=N("div","mapboxgl-canary",M)).style.visibility="hidden",this._detectMissingCSS();const m=this._canvasContainer=N("div","mapboxgl-canvas-container",M);this._canvas=N("canvas","mapboxgl-canvas",m),this._interactive&&(m.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=N("div","mapboxgl-control-container",M),E=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(D=>{E[D]=N("div",`mapboxgl-ctrl-${D}`,v)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(M,m){const v=i.o.devicePixelRatio||1;this._canvas.width=v*Math.ceil(M),this._canvas.height=v*Math.ceil(m),this._canvas.style.width=`${M}px`,this._canvas.style.height=`${m}px`}_addMarker(M){this._markers.push(M)}_removeMarker(M){const m=this._markers.indexOf(M);m!==-1&&this._markers.splice(m,1)}_addPopup(M){this._popups.push(M)}_removePopup(M){const m=this._popups.indexOf(M);m!==-1&&this._popups.splice(m,1)}_setupPainter(){const M=Object.assign({},b.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),m=this._canvas.getContext("webgl2",M);m?(Te(m,!0),this.painter=new Ape(m,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",v=>{if(v.dataType==="source"){const E=this.transform.elevation?this.transform.elevation._source():null;E&&v.sourceCacheId===E.id&&this.style&&this.style._setLabelPlacementStale(),this.painter.setTileLoadedFlag(!0)}}),i.k.testSupport(m)):this.fire(new i.B(new Error("Failed to initialize WebGL")))}_contextLost(M){M.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new i.C("webglcontextlost",{originalEvent:M}))}_contextRestored(M){this._setupPainter(),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight)),this._updateTerrain(),this.style&&(this.style.clearLayers(),this.style.imageManager.destroyAtlasTextures(),this.style.imageManager.imageAtlasCache.destroyTextures(),this.style.reloadModels(),this.style.clearSources()),this._update(),this.fire(new i.C("webglcontextrestored",{originalEvent:M}))}_onMapScroll(M){if(M.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}idle(){return!this.isMoving()&&this.loaded()}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}frameReady(){return this.loaded()&&!this._placementDirty}_update(M){return this.style?(this._styleDirty=this._styleDirty||M,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(M){return this._update(),this._renderTaskQueue.add(M)}_cancelRenderFrame(M){this._renderTaskQueue.remove(M)}_requestDomTask(M){!this.loaded()||this.loaded()&&!this.isMoving()?M():this._domRenderTaskQueue.add(M)}_render(M){let m;this.fire(new i.C("renderstart")),++this._frameId;const v=this.painter.context.extTimerQuery,E=i.o.now(),D=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(m=D.createQuery(),D.beginQuery(v.TIME_ELAPSED_EXT,m)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],performance.now())),this._renderTaskQueue.run(M),this._domRenderTaskQueue.run(M),this._removed)return;this._updateProjectionTransition();const z=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const ee=this.transform.zoom,ne=this.transform.pitch,de=i.o.now(),we=new i.ae(ee,{now:de,fadeDuration:z,pitch:ne,transition:this.style.transition,worldview:this._worldview});this.style.update(we)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let $=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),$=this._updateAverageElevation(E),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):$=this._updateAverageElevation(E),this.style&&(this._placementDirty=this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,z,this._crossSourceCollisions,this.painter.replacementSource)),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:z,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.C("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,p.mark(u.load),this.fire(new i.C("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(),m){const ee=i.o.now()-E;D.endQuery(v.TIME_ELAPSED_EXT),setTimeout(()=>{const ne=D.getQueryParameter(m,D.QUERY_RESULT)/1e6;D.deleteQuery(m),this.fire(new i.C("gpu-timing-frame",{cpuTime:ee,gpuTime:ne}))},50)}if(this.listens("gpu-timing-layer")){const ee=this.painter.collectGpuTimers();setTimeout(()=>{const ne=this.painter.queryGpuTimers(ee);this.fire(new i.C("gpu-timing-layer",{layerTimes:ne}))},50)}if(this.listens("gpu-timing-deferred-render")){const ee=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const ne=this.painter.queryGpuTimeDeferredRender(ee);this.fire(new i.C("gpu-timing-deferred-render",{gpuTime:ne}))},50)}const K=this._sourcesDirty||this._styleDirty||this._placementDirty||$;if(K||this._repaint)this.triggerRepaint();else{const ee=this.idle();if(ee&&($=this._updateAverageElevation(E,!0)),$)this.triggerRepaint();else if(this._triggerFrame(!1),ee&&(this.fire(new i.C("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const ne=this._calculateSpeedIndex();this.fire(new i.C("speedindexcompleted",{speedIndex:ne})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||K||(this._fullyLoaded=!0,p.mark(u.fullLoad),this._performanceMetricsCollection&&fe(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(M){for(const m of this._markers)M&&!this.getRenderWorldCopies()&&(m._lngLat=m._lngLat.wrap()),m._update();for(const m of this._popups)!M||this.getRenderWorldCopies()||m._trackPointer||(m._lngLat=m._lngLat.wrap()),m._update()}_updateAverageElevation(M,m=!1){const v=D=>(this.transform.averageElevation=D,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&v(0);const E=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(E||(m||M-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(M)){const D=this.transform.averageElevation;let z=this.transform.sampleAverageElevation();this.transform.elevation!=null&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(z)?z=0:this._averageElevationLastSampledAt=M;const $=Math.abs(D-z);if($>1){if(this._isInitialLoad||E)return this._averageElevation.jumpTo(z),v(z);this._averageElevation.easeTo(z,M,300)}else if($>1e-4)return this._averageElevation.jumpTo(z),v(z)}return!!this._averageElevation.isEasing(M)&&v(this._averageElevation.getValue(M))}_isTokenExpired(){return this._tokenExpiration!=null&&Date.now()>this._tokenExpiration}_revokeAuth(){const M=this.painter.context.gl;Te(M,!1),this._logoControl instanceof ZP&&this._logoControl._updateLogo(),M&&M.clear(M.DEPTH_BUFFER_BIT|M.COLOR_BUFFER_BIT|M.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new i.B(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/")))}_authenticate(){Ye(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,M=>{M&&(M.message!==J&&M.status!==401||this._revokeAuth())}),this._isTokenExpired()&&this._revokeAuth(),ke(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&Ve(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&Ue(this._requestManager._customAccessToken)}_postAddingAppearancesToStyleEvent(){ye(this._requestManager._customAccessToken)}_updateTerrain(){const M=this._isDragging();this.painter.updateTerrain(this.style,M)}_calculateSpeedIndex(){const M=this.painter.canvasCopy(),m=this.painter.getCanvasCopiesAndTimestamps();m.timeStamps.push(performance.now());const v=this.painter.context.gl,E=v.createFramebuffer();function D(z){v.framebufferTexture2D(v.FRAMEBUFFER,v.COLOR_ATTACHMENT0,v.TEXTURE_2D,z,0);const $=new Uint8Array(v.drawingBufferWidth*v.drawingBufferHeight*4);return v.readPixels(0,0,v.drawingBufferWidth,v.drawingBufferHeight,v.RGBA,v.UNSIGNED_BYTE,$),$}return v.bindFramebuffer(v.FRAMEBUFFER,E),this._canvasPixelComparison(D(M),m.canvasCopies.map(D),m.timeStamps)}_canvasPixelComparison(M,m,v){let E=v[1]-v[0];const D=M.length/4;for(let z=0;z{const v=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,v&&this._render(m)}))}_preloadTiles(M){const m=this.style?this.style.getSourceCaches():[];return i.t(m,(v,E)=>v._preloadTiles(M,E),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(M){this._trackResize&&this.resize({originalEvent:M})._update()}_onVisibilityChange(){document.visibilityState==="hidden"&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(M){this._showTileBoundaries!==M&&(this._showTileBoundaries=M,this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(M){this._showParseStatus!==M&&(this._showParseStatus=M,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(M){this._showTerrainWireframe!==M&&(this._showTerrainWireframe=M,this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(M){this._showLayers2DWireframe!==M&&(this._showLayers2DWireframe=M,this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(M){this._showLayers3DWireframe!==M&&(this._showLayers3DWireframe=M,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(M){this._speedIndexTiming!==M&&(this._speedIndexTiming=M,this._update())}get showPadding(){return!!this._showPadding}set showPadding(M){this._showPadding!==M&&(this._showPadding=M,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(M){this._showCollisionBoxes!==M&&(this._showCollisionBoxes=M,this.style&&M?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(M){this._showOverdrawInspector!==M&&(this._showOverdrawInspector=M,this._update())}get repaint(){return!!this._repaint}set repaint(M){this._repaint!==M&&(this._repaint=M,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(M){this._vertices=M,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(M){this._showTileAABBs!==M&&(this._showTileAABBs=M,M&&this._update())}_setCacheLimits(M,m){i.e_(M,m)}get version(){return d}},NavigationControl:class{constructor(M={}){this.options=Object.assign({},Ope,M),this._container=N("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",m=>m.preventDefault()),this.options.showZoom&&(i.aZ(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",m=>{this._map&&this._map.zoomIn({},{originalEvent:m})}),N("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",m=>{this._map&&this._map.zoomOut({},{originalEvent:m})}),N("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(i.aZ(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",m=>{const v=this._map;v&&(this.options.visualizePitch?v.resetNorthPitch({},{originalEvent:m}):v.resetNorth({},{originalEvent:m}))}),this._compassIcon=N("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const M=this._map;if(!M)return;const m=M.getZoom(),v=m===M.getMaxZoom(),E=m===M.getMinZoom();this._zoomInButton.disabled=v,this._zoomOutButton.disabled=E,this._zoomInButton.setAttribute("aria-disabled",v.toString()),this._zoomOutButton.setAttribute("aria-disabled",E.toString())}_rotateCompassArrow(){const M=this._map;if(!M)return;const m=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(M.transform.pitch*(Math.PI/180)),.5)}) rotateX(${M.transform.pitch}deg) rotateZ(${M.transform.angle*(180/Math.PI)}deg)`:`rotate(${M.transform.angle*(180/Math.PI)}deg)`;M._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=m)})}onAdd(M){return this._map=M,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),M.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&M.on("pitch",this._rotateCompassArrow),M.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new _2(M,this._compass,this.options.visualizePitch)),this._container}onRemove(){const M=this._map;M&&(this._container.remove(),this.options.showZoom&&M.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&M.off("pitch",this._rotateCompassArrow),M.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(M,m){const v=N("button",M,this._container);return v.type="button",v.addEventListener("click",m),v}_setButtonTitle(M,m){if(!this._map)return;const v=this._map._getUIString(`NavigationControl.${m}`);M.setAttribute("aria-label",v),M.firstElementChild&&M.firstElementChild.setAttribute("title",v)}},GeolocateControl:class extends i.E{constructor(M={}){super();const m=navigator.geolocation;this.options=Object.assign({geolocation:m},w2,M),i.aZ(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=IP(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(M){return this._map=M,this._container=N("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._clearRequestTimeout(),this._geolocationWatchID!==void 0&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(M){const m=(v=!!this.options.geolocation)=>{this._supportsGeolocation=v,M(v)};this._supportsGeolocation!==void 0?M(this._supportsGeolocation):navigator.permissions!==void 0?navigator.permissions.query({name:"geolocation"}).then(v=>m(v.state!=="denied")).catch(()=>m()):m()}_isOutOfMapMaxBounds(M){const m=this._map.getMaxBounds(),v=M.coords;return!!m&&(v.longitudem.getEast()||v.latitudem.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(M){if(this._map){if(this._clearRequestTimeout(),this._isOutOfMapMaxBounds(M))return this._setErrorState(),this.fire(new i.C("outofmaxbounds",M)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=M,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this.options.followUserLocation?(this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active")):(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"));break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(M),this.options.followUserLocation&&(!this.options.trackUserLocation||this._watchState==="ACTIVE_LOCK")&&this._updateCamera(M),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new i.C("geolocate",Object.assign({coords:M.coords,timestamp:M.timestamp},M.toJSON?{toJSON:M.toJSON.bind(M)}:{}))),this._finish()}}_updateCamera(M){const m=new i.aU(M.coords.longitude,M.coords.latitude),v=M.coords.accuracy,E=this._map.getBearing(),D=Object.assign({bearing:E},this.options.fitBoundsOptions);this._map.fitBounds(m.toBounds(v),D,{geolocateSource:!0})}_updateMarker(M){if(M){const m=new i.aU(M.coords.longitude,M.coords.latitude);this._accuracyCircleMarker.setLngLat(m).addTo(this._map),this._userLocationDotMarker.setLngLat(m).addTo(this._map),this._accuracy=M.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const M=this._map.transform,m=i.bU(1,M._center.lat)*M.worldSize,v=Math.ceil(2*this._accuracy*m);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(M){if(this._map){if(this._clearRequestTimeout(),this.options.trackUserLocation)if(M.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const m=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",m),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",m),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(M.code===3&&this._noTimeout)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new i.C("error",{code:M.code,message:M.message,PERMISSION_DENIED:M.PERMISSION_DENIED,POSITION_UNAVAILABLE:M.POSITION_UNAVAILABLE,TIMEOUT:M.TIMEOUT})),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_startRequestTimeout(){this._clearRequestTimeout();const M=this.options.positionOptions.timeout;M&&(this._requestTimeoutId=window.setTimeout(()=>{this._onError({code:3,message:"Geolocation request timed out"})},M))}_clearRequestTimeout(){this._requestTimeoutId!==void 0&&(clearTimeout(this._requestTimeoutId),this._requestTimeoutId=void 0)}_setupUI(M){if(this._map!==void 0){if(this._container.addEventListener("contextmenu",m=>m.preventDefault()),this._geolocateButton=N("button","mapboxgl-ctrl-geolocate",this._container),N("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",M===!1){i.w("Geolocation support is not available so the GeolocateControl will be disabled.");const m=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",m),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",m)}else{const m=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",m),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",m)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=N("div","mapboxgl-user-location"),this._dotElement.appendChild(N("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(N("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Wm({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=N("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Wm({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.showButton||(this._container.style.display="none"),this.options.trackUserLocation&&this._map.on("movestart",m=>{m.geolocateSource||this._watchState!=="ACTIVE_LOCK"||m.originalEvent&&m.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.C("trackuserlocationend")))})}}_onDeviceOrientation(M){this._userLocationDotMarker&&(M.webkitCompassHeading?this._heading=M.webkitCompassHeading:M.absolute===!0&&(this._heading=-1*M.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return i.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new i.C("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.C("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.C("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let M;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(M={maximumAge:6e5,timeout:0},this._noTimeout=!0):(M=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,M),this._startRequestTimeout(),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._startRequestTimeout(),this._timeoutId=window.setTimeout(this._finish,1e4);return!0}setFollowUserLocation(M){return this.options.followUserLocation=M??w2.followUserLocation,this.options.trackUserLocation&&this._watchState!=="OFF"&&(this.options.followUserLocation?this._watchState!=="BACKGROUND"&&this._watchState!=="BACKGROUND_ERROR"||(this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new i.C("trackuserlocationstart"))):this._watchState!=="ACTIVE_LOCK"&&this._watchState!=="ACTIVE_ERROR"||(this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this.fire(new i.C("trackuserlocationend")))),this}_addDeviceOrientationListener(){const M=()=>{const m="ondeviceorientationabsolute"in window?"deviceorientationabsolute":"deviceorientation";window.addEventListener(m,this._onDeviceOrientation)};typeof DeviceOrientationEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(m=>{m==="granted"&&M()}).catch(console.error):M()}_clearWatch(){this._clearRequestTimeout(),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:KP,ScaleControl:class{constructor(M={}){this.options=Object.assign({},Cl,M),i.aZ(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const M=this.options.maxWidth||100,m=this._map,v=m._containerHeight/2,E=m._containerWidth/2-M/2,D=m.unproject([E,v]),z=m.unproject([E+M,v]),$=D.distanceTo(z);if(this.options.unit==="imperial"){const K=3.2808*$;K>5280?this._setScale(M,K/5280,"mile"):this._setScale(M,K,"foot")}else this.options.unit==="nautical"?this._setScale(M,$/1852,"nautical-mile"):$>=1e3?this._setScale(M,$/1e3,"kilometer"):this._setScale(M,$,"meter")}_setScale(M,m,v){this._map._requestDomTask(()=>{const E=function(z){const $=Math.pow(10,`${Math.floor(z)}`.length-1);let K=z/$;return K=K>=10?10:K>=5?5:K>=3?3:K>=2?2:K>=1?1:function(ee){const ne=Math.pow(10,Math.ceil(-Math.log(ee)/Math.LN10));return Math.round(ee*ne)/ne}(K),$*K}(m),D=E/m;this._container.innerHTML=v!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:v}).format(E):`${E} ${Km[v]}`,this._container.style.width=M*D+"px"})}onAdd(M){return this._map=M,this._language=M.getLanguage(),this._container=N("div","mapboxgl-ctrl mapboxgl-ctrl-scale",M.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(M){this._language=M,this._update()}setUnit(M){this.options.unit=M,this._update()}},FullscreenControl:class{constructor(M={}){this._fullscreen=!1,M&&M.container&&(M.container instanceof HTMLElement?this._container=M.container:i.w("Full screen control 'container' must be a DOM element.")),i.aZ(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(M){return this._map=M,this._container||(this._container=this._map.getContainer()),this._controlContainer=N("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",i.w("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){const M=this._fullscreenButton=N("button","mapboxgl-ctrl-fullscreen",this._controlContainer);N("span","mapboxgl-ctrl-icon",M).setAttribute("aria-hidden","true"),M.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const M=this._getTitle();this._fullscreenButton.setAttribute("aria-label",M),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",M)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(document.fullscreenElement||document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},IndoorControl:class{constructor(){i.aZ(["_onIndoorUpdate","_onStyleData","_scrollUp","_scrollDown","_toggleIndoor"],this),this._visibleFloorStart=0,this._lastSelectedFloorId=null}onAdd(M){return this._map=M,this._container=N("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.style.display="none",this._map.on("styledata",this._onStyleData),this._updateConnection(),this._container}_onStyleData(){this._updateConnection()}_updateConnection(){if(this._map&&this._map.style&&this._map.style.indoorManager){const M=this._map.style.indoorManager;M.off("selector-update",this._onIndoorUpdate),M.on("selector-update",this._onIndoorUpdate),this._onIndoorUpdate(M.getControlState())}}_createButton(M,m){const v=N("button",M,this._container);return v.type="button",v.addEventListener("click",m),v}_setButtonTitle(M,m){M.setAttribute("aria-label",m),M.textContent=m}onRemove(){this._container&&this._container.remove(),this._map&&(this._map.off("styledata",this._onStyleData),this._map.style&&this._map.style.indoorManager.off("selector-update",this._onIndoorUpdate),this._map=null)}getDefaultPosition(){return"top-right"}_onIndoorUpdate(M){if(!M||!M.floors||M.floors.length===0)return this._model=M,void(this._container.style.display="none");const m=this._model;this._model=M,this._container.style.display="inline-block";const v=!m||m.floors.length!==M.floors.length||m.floors.some((E,D)=>E.id!==M.floors[D].id);if(v&&(this._visibleFloorStart=0,this._lastSelectedFloorId=null),M.selectedFloorId){if(M.selectedFloorId!==this._lastSelectedFloorId||v){const E=M.floors.findIndex(D=>D.id===M.selectedFloorId);if(E!==-1){const D=M.floors.length;let z,$;D<=5?(z=0,$=D-1):this._visibleFloorStart===0?(z=0,$=3):this._visibleFloorStart>=D-3?(z=D-3-1,$=D-1):(z=this._visibleFloorStart,$=this._visibleFloorStart+3-1),E$&&(this._visibleFloorStart=E-2)}}this._lastSelectedFloorId=M.selectedFloorId}this._render()}_render(){if(!this._container||!this._model||!this._model.floors)return;this._container.innerHTML="";const M=this._createButton("mapboxgl-ctrl-indoor-toggle",this._toggleIndoor);N("span","mapboxgl-ctrl-icon",M).setAttribute("aria-hidden","true"),this._model.activeFloorsVisible||M.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.appendChild(M);const m=this._model.floors,v=m.length;if(v<=5)return void m.forEach($=>this._createFloorButton($));const E=this._visibleFloorStart===0,D=this._visibleFloorStart>=v-3;if(E)this._createFloorButton(m[0]);else{const $=this._createButton("mapboxgl-ctrl-arrow-up",this._scrollUp);N("span","mapboxgl-ctrl-icon",$).setAttribute("aria-hidden","true"),this._container.appendChild($)}let z=[];if(z=E?m.slice(1,4):D?m.slice(this._visibleFloorStart-1,this._visibleFloorStart+3-1):m.slice(this._visibleFloorStart,this._visibleFloorStart+3),z.forEach($=>this._createFloorButton($)),D)this._createFloorButton(m[v-1]);else{const $=this._createButton("mapboxgl-ctrl-arrow-down",this._scrollDown);N("span","mapboxgl-ctrl-icon",$).setAttribute("aria-hidden","true"),this._container.appendChild($)}}_createFloorButton(M){const m=this._createButton("mapboxgl-ctrl-level-button",()=>{const z=M.id;this._model&&this._model.selectedFloorId===z&&this._model.activeFloorsVisible||this._map&&(this._model&&!this._model.activeFloorsVisible&&this._map.style&&this._map.style.indoorManager&&this._map.style.indoorManager.setActiveFloorsVisibility(!0),this._map._selectIndoorFloor(z))}),v=(M.name||"").trim(),E=M.zIndex.toString(),D=v?Array.from(v).slice(0,3).join(""):E;this._setButtonTitle(m,D),this._model&&this._model.activeFloorsVisible&&M.id===this._model.selectedFloorId&&m.classList.add("mapboxgl-ctrl-level-button-selected"),this._container&&this._container.appendChild(m)}_toggleIndoor(){this._map&&this._map.style&&this._map.style.indoorManager&&this._model&&this._model.activeFloorsVisible&&this._map.style.indoorManager.setActiveFloorsVisibility(!1)}_scrollUp(){if(this._visibleFloorStart>0){this._visibleFloorStart--,this._visibleFloorStart===1&&(this._visibleFloorStart=0);const M=this._model&&this._model.floors||[];if(M.length>3){const m=M.length-3;this._visibleFloorStart===m-1&&(this._visibleFloorStart=m-2)}this._render()}}_scrollDown(){if(this._model&&this._model.floors){const M=this._model.floors.length-3;this._visibleFloorStartM&&(this._visibleFloorStart=M),this._render())}}},Popup:class extends i.E{constructor(M){super(),this.options=Object.assign(Object.create(j2),M),this._altitude=this.options.altitude,i.aZ(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(M&&M.className?M.className.trim().split(/\s+/):[])}addTo(M){return this._map&&this.remove(),this._map=M,this.options.closeOnClick&&M.on("preclick",this._onClose),this.options.closeOnMove&&M.on("move",this._onClose),M.on("remove",this.remove),this._update(),M._addPopup(this),this._focusFirstElement(),this._trackPointer?(M.on("mousemove",this._onMouseEvent),M.on("mouseup",this._onMouseEvent),M._canvasContainer.classList.add("mapboxgl-track-pointer")):M.on("move",this._update),this.fire(new i.C("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const M=this._map;return M&&(M.off("move",this._update),M.off("move",this._onClose),M.off("preclick",this._onClose),M.off("click",this._onClose),M.off("remove",this.remove),M.off("mousemove",this._onMouseEvent),M.off("mouseup",this._onMouseEvent),M.off("drag",this._onMouseEvent),M._canvasContainer&&M._canvasContainer.classList.remove("mapboxgl-track-pointer"),M._removePopup(this),this._map=void 0),this.fire(new i.C("close")),this}getLngLat(){return this._lngLat}setLngLat(M){this._lngLat=i.aU.convert(M),this._pos=null,this._trackPointer=!1,this._update();const m=this._map;return m&&(m.on("move",this._update),m.off("mousemove",this._onMouseEvent),m._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}getAltitude(){return this._altitude}setAltitude(M){return this._altitude=M,this._update(),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const M=this._map;return M&&(M.off("move",this._update),M.on("mousemove",this._onMouseEvent),M.on("drag",this._onMouseEvent),M._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(M){return this.setDOMContent(document.createTextNode(M))}setHTML(M){const m=document.createDocumentFragment(),v=document.createElement("body");let E;for(v.innerHTML=M;E=v.firstChild,E;)m.appendChild(E);return this.setDOMContent(m)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(M){return this.options.maxWidth=M,this._update(),this}setDOMContent(M){let m=this._content;if(m)for(;m.hasChildNodes();)m.firstChild&&m.removeChild(m.firstChild);else m=this._content=N("div","mapboxgl-popup-content",this._container||void 0);if(m.appendChild(M),this.options.closeButton){const v=this._closeButton=N("button","mapboxgl-popup-close-button",m);v.type="button",v.setAttribute("aria-label","Close popup"),v.innerHTML='',v.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(M){return this._classList.add(M),this._updateClassList(),this}removeClassName(M){return this._classList.delete(M),this._updateClassList(),this}setOffset(M){return this.options.offset=M,this._update(),this}toggleClassName(M){let m;return this._classList.delete(M)?m=!1:(this._classList.add(M),m=!0),this._updateClassList(),m}_onMouseEvent(M){this._update(M.point)}_getAnchor(M){if(this.options.anchor)return this.options.anchor;const m=this._map,v=this._container,E=this._pos;if(!m||!v||!E)return"bottom";const D=v.offsetWidth,z=v.offsetHeight,$=E.xm.transform.width-D/2;if(E.y+Mm.transform.height-z){if($)return"bottom-left";if(K)return"bottom-right"}return $?"left":K?"right":"bottom"}_updateClassList(){const M=this._container;if(!M)return;const m=[...this._classList];m.push("mapboxgl-popup"),this._anchor&&m.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&m.push("mapboxgl-popup-track-pointer"),M.className=m.join(" ")}_update(M){const m=this._map,v=this._content;if(!m||!this._lngLat&&!this._trackPointer||!v)return;let E=this._container;if(E||(E=this._container=N("div","mapboxgl-popup",m.getContainer()),this._tip=N("div","mapboxgl-popup-tip",E),E.appendChild(v)),this.options.maxWidth&&E.style.maxWidth!==this.options.maxWidth&&(E.style.maxWidth=this.options.maxWidth),m.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=YP(this._lngLat,this._pos,m.transform)),!this._trackPointer||M){const D=this._pos=this._trackPointer&&M instanceof i.P?M:m.project(this._lngLat,this._altitude),z=I3(this.options.offset),$=this._anchor=this._getAnchor(z.y),K=I3(this.options.offset,$),ee=D.add(K).round();m._requestDomTask(()=>{this._container&&$&&(this._container.style.transform=`${b2[$]} translate(${ee.x}px,${ee.y}px)`)})}if(!this._marker&&m._showingGlobe()){const D=i.e$(m.transform,this._lngLat)?0:1;this._setOpacity(D)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const M=this._container.querySelector(Fpe);M&&M.focus()}_onClose(){this.remove()}_setOpacity(M){this._container&&(this._container.style.opacity=`${M}`),this._content&&(this._content.style.pointerEvents=M?"auto":"none")}},Marker:Wm,Style:Vm,LngLat:i.aU,LngLatBounds:i.aK,Point:i.P,MercatorCoordinate:i.ag,FreeCameraOptions:zw,Evented:i.E,config:i.g,prewarm:function(){kt().acquire(Je)},clearPrewarmedResources:function(){const M=et;M&&(M.isPreloaded()&&M.numActive()===1?(M.release(Je),et=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()"))},get accessToken(){return i.g.ACCESS_TOKEN},set accessToken(M){i.g.ACCESS_TOKEN=M},get baseApiUrl(){return i.g.API_URL},set baseApiUrl(M){i.g.API_URL=M},get workerCount(){return ut.workerCount},set workerCount(M){ut.workerCount=M},get maxParallelImageRequests(){return i.g.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(M){i.g.MAX_PARALLEL_IMAGE_REQUESTS=M},clearStorage(M){i.f7(M)},get workerUrl(){return ot.workerUrl},set workerUrl(M){ot.workerUrl=M},get workerClass(){return ot.workerClass},set workerClass(M){ot.workerClass=M},get workerParams(){return ot.workerParams},set workerParams(M){ot.workerParams=M},get dracoUrl(){return i.f6()},set dracoUrl(M){i.g.DRACO_URL=i.o.resolveURL(M)},get meshoptUrl(){return i.f5()},set meshoptUrl(M){const m=i.o.resolveURL(M);i.g.MESHOPT_URL=m,i.g.MESHOPT_SIMD_URL=m},get buildingGenUrl(){return i.f4()},set buildingGenUrl(M){i.g.BUILDING_GEN_URL=i.o.resolveURL(M)},setNow:i.o.setNow,restoreNow:i.o.restoreNow}});var l=a;return l})})(TGe);var ENt=TGe.exports;const Ko=ao(ENt);function Ms({className:t,...s}){return e.jsx("div",{className:Ot("animate-pulse rounded-md bg-muted",t),...s})}const FPe={coming_soon:"#3B82F6",active:"#10B981",price_improvement:"#F97316",under_contract:"#8B5CF6",sold:"#6B7280"},zPe={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function PNt(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function INt({listings:t,isLoading:s}){const r=wr(),n=k.useRef(null),a=k.useRef(null),o=k.useRef([]),[l,i]=k.useState(""),[d,u]=k.useState(!0);return k.useEffect(()=>{(async()=>{u(!0);try{const{data:y}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();y!=null&&y.value&&i(y.value)}catch(y){console.error("Error fetching mapbox token:",y)}u(!1)})()},[]),k.useEffect(()=>{if(!n.current||!l||a.current)return;Ko.accessToken=l;const f=t.filter(b=>b.latitude!=null&&b.longitude!=null);let y=[-98.5795,39.8283],_=4;if(f.length>0){const b=f.reduce((w,S)=>w+S.longitude,0)/f.length,N=f.reduce((w,S)=>w+S.latitude,0)/f.length;y=[b,N],_=f.length===1?12:10}return a.current=new Ko.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:_,center:y}),a.current.addControl(new Ko.NavigationControl,"top-right"),()=>{var b;(b=a.current)==null||b.remove(),a.current=null}},[l]),k.useEffect(()=>{if(!a.current||!l)return;o.current.forEach(y=>y.remove()),o.current=[];const f=t.filter(y=>y.latitude!=null&&y.longitude!=null);if(f.forEach(y=>{var I,L,O;const _=FPe[y.status]||"#10B981",b=((I=y.photos)==null?void 0:I.find(V=>V.is_primary))||((L=y.photos)==null?void 0:L[0]),w=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${y.slug||y.id}`:`/public/listing/${y.slug||y.id}`,S=document.createElement("div");S.className="cursor-pointer",S.innerHTML=`
`;const C=new Ko.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${b!=null&&b.photo_url?``:""}
${PNt(y.price)}
${y.property_address||""}
${y.city}, ${y.state}
${zPe[y.status]||y.status} ${y.bedrooms?`${y.bedrooms} bed`:""} ${y.bathrooms?`${y.bathrooms} bath`:""}
${(O=y.agent)!=null&&O.name?`
Listed by ${y.agent.name}
`:""}
Click to view details →
`),A=new Ko.Marker(S).setLngLat([y.longitude,y.latitude]).setPopup(C).addTo(a.current);o.current.push(A)}),f.length>1){const y=new Ko.LngLatBounds;f.forEach(_=>y.extend([_.longitude,_.latitude])),a.current.fitBounds(y,{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]),d||s?e.jsx(Ms,{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(FPe).map(([f,y])=>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:y}}),e.jsx("span",{className:"text-xs text-gray-600",children:zPe[f]})]},f))}),e.jsx("div",{ref:n,className:"w-full h-[500px] rounded-lg shadow-lg border border-gray-200"})]})}function nD(t,[s,r]){return Math.min(r,Math.max(s,t))}function zR(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 LNt=[" ","Enter","ArrowUp","ArrowDown"],DNt=[" ","Enter"],WS="Select",[kue,Sue,RNt]=wR(WS),[HA,tAs]=qc(WS,[RNt,w0]),Cue=w0(),[ONt,fw]=HA(WS),[FNt,zNt]=HA(WS),EGe=t=>{const{__scopeSelect:s,children:r,open:n,defaultOpen:a,onOpenChange:o,value:l,defaultValue:i,onValueChange:d,dir:u,name:p,autoComplete:f,disabled:y,required:_,form:b}=t,N=Cue(s),[w,S]=k.useState(null),[C,A]=k.useState(null),[I,L]=k.useState(!1),O=mw(u),[V,q]=Uu({prop:n,defaultProp:a??!1,onChange:o,caller:WS}),[B,U]=Uu({prop:l,defaultProp:i,onChange:d,caller:WS}),te=k.useRef(null),Y=w?b||!!w.closest("form"):!0,[J,X]=k.useState(new Set),ce=Array.from(J).map(ie=>ie.props.value).join(";");return e.jsx(SR,{...N,children:e.jsxs(ONt,{required:_,scope:s,trigger:w,onTriggerChange:S,valueNode:C,onValueNodeChange:A,valueNodeHasChildren:I,onValueNodeHasChildrenChange:L,contentId:fu(),value:B,onValueChange:U,open:V,onOpenChange:q,dir:O,triggerPointerDownPosRef:te,disabled:y,children:[e.jsx(kue.Provider,{scope:s,children:e.jsx(FNt,{scope:t.__scopeSelect,onNativeOptionAdd:k.useCallback(ie=>{X(ae=>new Set(ae).add(ie))},[]),onNativeOptionRemove:k.useCallback(ie=>{X(ae=>{const oe=new Set(ae);return oe.delete(ie),oe})},[]),children:r})}),Y?e.jsxs(tWe,{"aria-hidden":!0,required:_,tabIndex:-1,name:p,autoComplete:f,value:B,onChange:ie=>U(ie.target.value),disabled:y,form:b,children:[B===void 0?e.jsx("option",{value:""}):null,Array.from(J)]},ce):null]})})};EGe.displayName=WS;var PGe="SelectTrigger",IGe=k.forwardRef((t,s)=>{const{__scopeSelect:r,disabled:n=!1,...a}=t,o=Cue(r),l=fw(PGe,r),i=l.disabled||n,d=Ta(s,l.onTriggerChange),u=Sue(r),p=k.useRef("touch"),[f,y,_]=rWe(N=>{const w=u().filter(A=>!A.disabled),S=w.find(A=>A.value===l.value),C=nWe(w,N,S);C!==void 0&&l.onValueChange(C.value)}),b=N=>{i||(l.onOpenChange(!0),_()),N&&(l.triggerPointerDownPosRef.current={x:Math.round(N.pageX),y:Math.round(N.pageY)})};return e.jsx(OA,{asChild:!0,...o,children:e.jsx(Jr.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":sWe(l.value)?"":void 0,...a,ref:d,onClick:Mr(a.onClick,N=>{N.currentTarget.focus(),p.current!=="mouse"&&b(N)}),onPointerDown:Mr(a.onPointerDown,N=>{p.current=N.pointerType;const w=N.target;w.hasPointerCapture(N.pointerId)&&w.releasePointerCapture(N.pointerId),N.button===0&&N.ctrlKey===!1&&N.pointerType==="mouse"&&(b(N),N.preventDefault())}),onKeyDown:Mr(a.onKeyDown,N=>{const w=f.current!=="";!(N.ctrlKey||N.altKey||N.metaKey)&&N.key.length===1&&y(N.key),!(w&&N.key===" ")&&LNt.includes(N.key)&&(b(),N.preventDefault())})})})});IGe.displayName=PGe;var LGe="SelectValue",DGe=k.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,children:o,placeholder:l="",...i}=t,d=fw(LGe,r),{onValueNodeHasChildrenChange:u}=d,p=o!==void 0,f=Ta(s,d.onValueNodeChange);return od(()=>{u(p)},[u,p]),e.jsx(Jr.span,{...i,ref:f,style:{pointerEvents:"none"},children:sWe(d.value)?e.jsx(e.Fragment,{children:l}):o})});DGe.displayName=LGe;var BNt="SelectIcon",RGe=k.forwardRef((t,s)=>{const{__scopeSelect:r,children:n,...a}=t;return e.jsx(Jr.span,{"aria-hidden":!0,...a,ref:s,children:n||"▼"})});RGe.displayName=BNt;var $Nt="SelectPortal",OGe=t=>e.jsx(IA,{asChild:!0,...t});OGe.displayName=$Nt;var KS="SelectContent",FGe=k.forwardRef((t,s)=>{const r=fw(KS,t.__scopeSelect),[n,a]=k.useState();if(od(()=>{a(new DocumentFragment)},[]),!r.open){const o=n;return o?op.createPortal(e.jsx(zGe,{scope:t.__scopeSelect,children:e.jsx(kue.Slot,{scope:t.__scopeSelect,children:e.jsx("div",{children:t.children})})}),o):null}return e.jsx(BGe,{...t,ref:s})});FGe.displayName=KS;var dg=10,[zGe,xw]=HA(KS),qNt="SelectContentImpl",UNt=Hb("SelectContent.RemoveScroll"),BGe=k.forwardRef((t,s)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:l,side:i,sideOffset:d,align:u,alignOffset:p,arrowPadding:f,collisionBoundary:y,collisionPadding:_,sticky:b,hideWhenDetached:N,avoidCollisions:w,...S}=t,C=fw(KS,r),[A,I]=k.useState(null),[L,O]=k.useState(null),V=Ta(s,Re=>I(Re)),[q,B]=k.useState(null),[U,te]=k.useState(null),Y=Sue(r),[J,X]=k.useState(!1),ce=k.useRef(!1);k.useEffect(()=>{if(A)return gue(A)},[A]),pue();const ie=k.useCallback(Re=>{const[Ve,...Ne]=Y().map(ye=>ye.ref.current),[Ue]=Ne.slice(-1),Ie=document.activeElement;for(const ye of Re)if(ye===Ie||(ye==null||ye.scrollIntoView({block:"nearest"}),ye===Ve&&L&&(L.scrollTop=0),ye===Ue&&L&&(L.scrollTop=L.scrollHeight),ye==null||ye.focus(),document.activeElement!==Ie))return},[Y,L]),ae=k.useCallback(()=>ie([q,A]),[ie,q,A]);k.useEffect(()=>{J&&ae()},[J,ae]);const{onOpenChange:oe,triggerPointerDownPosRef:me}=C;k.useEffect(()=>{if(A){let Re={x:0,y:0};const Ve=Ue=>{var Ie,ye;Re={x:Math.abs(Math.round(Ue.pageX)-(((Ie=me.current)==null?void 0:Ie.x)??0)),y:Math.abs(Math.round(Ue.pageY)-(((ye=me.current)==null?void 0:ye.y)??0))}},Ne=Ue=>{Re.x<=10&&Re.y<=10?Ue.preventDefault():A.contains(Ue.target)||oe(!1),document.removeEventListener("pointermove",Ve),me.current=null};return me.current!==null&&(document.addEventListener("pointermove",Ve),document.addEventListener("pointerup",Ne,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Ve),document.removeEventListener("pointerup",Ne,{capture:!0})}}},[A,oe,me]),k.useEffect(()=>{const Re=()=>oe(!1);return window.addEventListener("blur",Re),window.addEventListener("resize",Re),()=>{window.removeEventListener("blur",Re),window.removeEventListener("resize",Re)}},[oe]);const[ve,he]=rWe(Re=>{const Ve=Y().filter(Ie=>!Ie.disabled),Ne=Ve.find(Ie=>Ie.ref.current===document.activeElement),Ue=nWe(Ve,Re,Ne);Ue&&setTimeout(()=>Ue.ref.current.focus())}),ge=k.useCallback((Re,Ve,Ne)=>{const Ue=!ce.current&&!Ne;(C.value!==void 0&&C.value===Ve||Ue)&&(B(Re),Ue&&(ce.current=!0))},[C.value]),je=k.useCallback(()=>A==null?void 0:A.focus(),[A]),qe=k.useCallback((Re,Ve,Ne)=>{const Ue=!ce.current&&!Ne;(C.value!==void 0&&C.value===Ve||Ue)&&te(Re)},[C.value]),Me=n==="popper"?x1e:$Ge,ke=Me===x1e?{side:i,sideOffset:d,align:u,alignOffset:p,arrowPadding:f,collisionBoundary:y,collisionPadding:_,sticky:b,hideWhenDetached:N,avoidCollisions:w}:{};return e.jsx(zGe,{scope:r,content:A,viewport:L,onViewportChange:O,itemRefCallback:ge,selectedItem:q,onItemLeave:je,itemTextRefCallback:qe,focusSelectedItem:ae,selectedItemText:U,position:n,isPositioned:J,searchRef:ve,children:e.jsx(IR,{as:UNt,allowPinchZoom:!0,children:e.jsx(ER,{asChild:!0,trapped:C.open,onMountAutoFocus:Re=>{Re.preventDefault()},onUnmountAutoFocus:Mr(a,Re=>{var Ve;(Ve=C.trigger)==null||Ve.focus({preventScroll:!0}),Re.preventDefault()}),children:e.jsx(dw,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:Re=>Re.preventDefault(),onDismiss:()=>C.onOpenChange(!1),children:e.jsx(Me,{role:"listbox",id:C.contentId,"data-state":C.open?"open":"closed",dir:C.dir,onContextMenu:Re=>Re.preventDefault(),...S,...ke,onPlaced:()=>X(!0),ref:V,style:{display:"flex",flexDirection:"column",outline:"none",...S.style},onKeyDown:Mr(S.onKeyDown,Re=>{const Ve=Re.ctrlKey||Re.altKey||Re.metaKey;if(Re.key==="Tab"&&Re.preventDefault(),!Ve&&Re.key.length===1&&he(Re.key),["ArrowUp","ArrowDown","Home","End"].includes(Re.key)){let Ue=Y().filter(Ie=>!Ie.disabled).map(Ie=>Ie.ref.current);if(["ArrowUp","End"].includes(Re.key)&&(Ue=Ue.slice().reverse()),["ArrowUp","ArrowDown"].includes(Re.key)){const Ie=Re.target,ye=Ue.indexOf(Ie);Ue=Ue.slice(ye+1)}setTimeout(()=>ie(Ue)),Re.preventDefault()}})})})})})})});BGe.displayName=qNt;var VNt="SelectItemAlignedPosition",$Ge=k.forwardRef((t,s)=>{const{__scopeSelect:r,onPlaced:n,...a}=t,o=fw(KS,r),l=xw(KS,r),[i,d]=k.useState(null),[u,p]=k.useState(null),f=Ta(s,V=>p(V)),y=Sue(r),_=k.useRef(!1),b=k.useRef(!0),{viewport:N,selectedItem:w,selectedItemText:S,focusSelectedItem:C}=l,A=k.useCallback(()=>{if(o.trigger&&o.valueNode&&i&&u&&N&&w&&S){const V=o.trigger.getBoundingClientRect(),q=u.getBoundingClientRect(),B=o.valueNode.getBoundingClientRect(),U=S.getBoundingClientRect();if(o.dir!=="rtl"){const Ie=U.left-q.left,ye=B.left-Ie,ct=V.left-ye,fe=V.width+ct,$e=Math.max(fe,q.width),Ye=window.innerWidth-dg,tt=nD(ye,[dg,Math.max(dg,Ye-$e)]);i.style.minWidth=fe+"px",i.style.left=tt+"px"}else{const Ie=q.right-U.right,ye=window.innerWidth-B.right-Ie,ct=window.innerWidth-V.right-ye,fe=V.width+ct,$e=Math.max(fe,q.width),Ye=window.innerWidth-dg,tt=nD(ye,[dg,Math.max(dg,Ye-$e)]);i.style.minWidth=fe+"px",i.style.right=tt+"px"}const te=y(),Y=window.innerHeight-dg*2,J=N.scrollHeight,X=window.getComputedStyle(u),ce=parseInt(X.borderTopWidth,10),ie=parseInt(X.paddingTop,10),ae=parseInt(X.borderBottomWidth,10),oe=parseInt(X.paddingBottom,10),me=ce+ie+J+oe+ae,ve=Math.min(w.offsetHeight*5,me),he=window.getComputedStyle(N),ge=parseInt(he.paddingTop,10),je=parseInt(he.paddingBottom,10),qe=V.top+V.height/2-dg,Me=Y-qe,ke=w.offsetHeight/2,Re=w.offsetTop+ke,Ve=ce+ie+Re,Ne=me-Ve;if(Ve<=qe){const Ie=te.length>0&&w===te[te.length-1].ref.current;i.style.bottom="0px";const ye=u.clientHeight-N.offsetTop-N.offsetHeight,ct=Math.max(Me,ke+(Ie?je:0)+ye+ae),fe=Ve+ct;i.style.height=fe+"px"}else{const Ie=te.length>0&&w===te[0].ref.current;i.style.top="0px";const ct=Math.max(qe,ce+N.offsetTop+(Ie?ge:0)+ke)+Ne;i.style.height=ct+"px",N.scrollTop=Ve-qe+N.offsetTop}i.style.margin=`${dg}px 0`,i.style.minHeight=ve+"px",i.style.maxHeight=Y+"px",n==null||n(),requestAnimationFrame(()=>_.current=!0)}},[y,o.trigger,o.valueNode,i,u,N,w,S,o.dir,n]);od(()=>A(),[A]);const[I,L]=k.useState();od(()=>{u&&L(window.getComputedStyle(u).zIndex)},[u]);const O=k.useCallback(V=>{V&&b.current===!0&&(A(),C==null||C(),b.current=!1)},[A,C]);return e.jsx(GNt,{scope:r,contentWrapper:i,shouldExpandOnScrollRef:_,onScrollButtonChange:O,children:e.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:I},children:e.jsx(Jr.div,{...a,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});$Ge.displayName=VNt;var HNt="SelectPopperPosition",x1e=k.forwardRef((t,s)=>{const{__scopeSelect:r,align:n="start",collisionPadding:a=dg,...o}=t,l=Cue(r);return e.jsx(CR,{...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)"}})});x1e.displayName=HNt;var[GNt,Gje]=HA(KS,{}),g1e="SelectViewport",qGe=k.forwardRef((t,s)=>{const{__scopeSelect:r,nonce:n,...a}=t,o=xw(g1e,r),l=Gje(g1e,r),i=Ta(s,o.onViewportChange),d=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(kue.Slot,{scope:r,children:e.jsx(Jr.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:i,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Mr(a.onScroll,u=>{const p=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:y}=l;if(y!=null&&y.current&&f){const _=Math.abs(d.current-p.scrollTop);if(_>0){const b=window.innerHeight-dg*2,N=parseFloat(f.style.minHeight),w=parseFloat(f.style.height),S=Math.max(N,w);if(S0?I:0,f.style.justifyContent="flex-end")}}}d.current=p.scrollTop})})})]})});qGe.displayName=g1e;var UGe="SelectGroup",[WNt,KNt]=HA(UGe),ZNt=k.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=fu();return e.jsx(WNt,{scope:r,id:a,children:e.jsx(Jr.div,{role:"group","aria-labelledby":a,...n,ref:s})})});ZNt.displayName=UGe;var VGe="SelectLabel",HGe=k.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=KNt(VGe,r);return e.jsx(Jr.div,{id:a.id,...n,ref:s})});HGe.displayName=VGe;var Yoe="SelectItem",[YNt,GGe]=HA(Yoe),WGe=k.forwardRef((t,s)=>{const{__scopeSelect:r,value:n,disabled:a=!1,textValue:o,...l}=t,i=fw(Yoe,r),d=xw(Yoe,r),u=i.value===n,[p,f]=k.useState(o??""),[y,_]=k.useState(!1),b=Ta(s,C=>{var A;return(A=d.itemRefCallback)==null?void 0:A.call(d,C,n,a)}),N=fu(),w=k.useRef("touch"),S=()=>{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(YNt,{scope:r,value:n,disabled:a,textId:N,isSelected:u,onItemTextChange:k.useCallback(C=>{f(A=>A||((C==null?void 0:C.textContent)??"").trim())},[]),children:e.jsx(kue.ItemSlot,{scope:r,value:n,disabled:a,textValue:p,children:e.jsx(Jr.div,{role:"option","aria-labelledby":N,"data-highlighted":y?"":void 0,"aria-selected":u&&y,"data-state":u?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...l,ref:b,onFocus:Mr(l.onFocus,()=>_(!0)),onBlur:Mr(l.onBlur,()=>_(!1)),onClick:Mr(l.onClick,()=>{w.current!=="mouse"&&S()}),onPointerUp:Mr(l.onPointerUp,()=>{w.current==="mouse"&&S()}),onPointerDown:Mr(l.onPointerDown,C=>{w.current=C.pointerType}),onPointerMove:Mr(l.onPointerMove,C=>{var A;w.current=C.pointerType,a?(A=d.onItemLeave)==null||A.call(d):w.current==="mouse"&&C.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Mr(l.onPointerLeave,C=>{var A;C.currentTarget===document.activeElement&&((A=d.onItemLeave)==null||A.call(d))}),onKeyDown:Mr(l.onKeyDown,C=>{var I;((I=d.searchRef)==null?void 0:I.current)!==""&&C.key===" "||(DNt.includes(C.key)&&S(),C.key===" "&&C.preventDefault())})})})})});WGe.displayName=Yoe;var II="SelectItemText",KGe=k.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,...o}=t,l=fw(II,r),i=xw(II,r),d=GGe(II,r),u=zNt(II,r),[p,f]=k.useState(null),y=Ta(s,S=>f(S),d.onItemTextChange,S=>{var C;return(C=i.itemTextRefCallback)==null?void 0:C.call(i,S,d.value,d.disabled)}),_=p==null?void 0:p.textContent,b=k.useMemo(()=>e.jsx("option",{value:d.value,disabled:d.disabled,children:_},d.value),[d.disabled,d.value,_]),{onNativeOptionAdd:N,onNativeOptionRemove:w}=u;return od(()=>(N(b),()=>w(b)),[N,w,b]),e.jsxs(e.Fragment,{children:[e.jsx(Jr.span,{id:d.textId,...o,ref:y}),d.isSelected&&l.valueNode&&!l.valueNodeHasChildren?op.createPortal(o.children,l.valueNode):null]})});KGe.displayName=II;var ZGe="SelectItemIndicator",YGe=k.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return GGe(ZGe,r).isSelected?e.jsx(Jr.span,{"aria-hidden":!0,...n,ref:s}):null});YGe.displayName=ZGe;var y1e="SelectScrollUpButton",XGe=k.forwardRef((t,s)=>{const r=xw(y1e,t.__scopeSelect),n=Gje(y1e,t.__scopeSelect),[a,o]=k.useState(!1),l=Ta(s,n.onScrollButtonChange);return od(()=>{if(r.viewport&&r.isPositioned){let i=function(){const u=d.scrollTop>0;o(u)};const d=r.viewport;return i(),d.addEventListener("scroll",i),()=>d.removeEventListener("scroll",i)}},[r.viewport,r.isPositioned]),a?e.jsx(JGe,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:d}=r;i&&d&&(i.scrollTop=i.scrollTop-d.offsetHeight)}}):null});XGe.displayName=y1e;var v1e="SelectScrollDownButton",QGe=k.forwardRef((t,s)=>{const r=xw(v1e,t.__scopeSelect),n=Gje(v1e,t.__scopeSelect),[a,o]=k.useState(!1),l=Ta(s,n.onScrollButtonChange);return od(()=>{if(r.viewport&&r.isPositioned){let i=function(){const u=d.scrollHeight-d.clientHeight,p=Math.ceil(d.scrollTop)d.removeEventListener("scroll",i)}},[r.viewport,r.isPositioned]),a?e.jsx(JGe,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:d}=r;i&&d&&(i.scrollTop=i.scrollTop+d.offsetHeight)}}):null});QGe.displayName=v1e;var JGe=k.forwardRef((t,s)=>{const{__scopeSelect:r,onAutoScroll:n,...a}=t,o=xw("SelectScrollButton",r),l=k.useRef(null),i=Sue(r),d=k.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return k.useEffect(()=>()=>d(),[d]),od(()=>{var p;const u=i().find(f=>f.ref.current===document.activeElement);(p=u==null?void 0:u.ref.current)==null||p.scrollIntoView({block:"nearest"})},[i]),e.jsx(Jr.div,{"aria-hidden":!0,...a,ref:s,style:{flexShrink:0,...a.style},onPointerDown:Mr(a.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(n,50))}),onPointerMove:Mr(a.onPointerMove,()=>{var u;(u=o.onItemLeave)==null||u.call(o),l.current===null&&(l.current=window.setInterval(n,50))}),onPointerLeave:Mr(a.onPointerLeave,()=>{d()})})}),XNt="SelectSeparator",eWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return e.jsx(Jr.div,{"aria-hidden":!0,...n,ref:s})});eWe.displayName=XNt;var _1e="SelectArrow",QNt=k.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=Cue(r),o=fw(_1e,r),l=xw(_1e,r);return o.open&&l.position==="popper"?e.jsx(MR,{...a,...n,ref:s}):null});QNt.displayName=_1e;var JNt="SelectBubbleInput",tWe=k.forwardRef(({__scopeSelect:t,value:s,...r},n)=>{const a=k.useRef(null),o=Ta(n,a),l=zR(s);return k.useEffect(()=>{const i=a.current;if(!i)return;const d=window.HTMLSelectElement.prototype,p=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==s&&p){const f=new Event("change",{bubbles:!0});p.call(i,s),i.dispatchEvent(f)}},[l,s]),e.jsx(Jr.select,{...r,style:{...Rqe,...r.style},ref:o,defaultValue:s})});tWe.displayName=JNt;function sWe(t){return t===""||t===void 0}function rWe(t){const s=ed(t),r=k.useRef(""),n=k.useRef(0),a=k.useCallback(l=>{const i=r.current+l;s(i),function d(u){r.current=u,window.clearTimeout(n.current),u!==""&&(n.current=window.setTimeout(()=>d(""),1e3))}(i)},[s]),o=k.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return k.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,a,o]}function nWe(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=ekt(t,Math.max(o,0));a.length===1&&(l=l.filter(u=>u!==r));const d=l.find(u=>u.textValue.toLowerCase().startsWith(a.toLowerCase()));return d!==r?d:void 0}function ekt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var tkt=EGe,aWe=IGe,skt=DGe,rkt=RGe,nkt=OGe,iWe=FGe,akt=qGe,oWe=HGe,lWe=WGe,ikt=KGe,okt=YGe,cWe=XGe,dWe=QGe,uWe=eWe;const $s=tkt,Vs=skt,zs=k.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(aWe,{ref:n,className:Ot("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(rkt,{asChild:!0,children:e.jsx(Bi,{className:"h-4 w-4 opacity-50"})})]}));zs.displayName=aWe.displayName;const hWe=k.forwardRef(({className:t,...s},r)=>e.jsx(cWe,{ref:r,className:Ot("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(af,{className:"h-4 w-4"})}));hWe.displayName=cWe.displayName;const mWe=k.forwardRef(({className:t,...s},r)=>e.jsx(dWe,{ref:r,className:Ot("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(Bi,{className:"h-4 w-4"})}));mWe.displayName=dWe.displayName;const Bs=k.forwardRef(({className:t,children:s,position:r="popper",...n},a)=>e.jsx(nkt,{children:e.jsxs(iWe,{ref:a,className:Ot("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(hWe,{}),e.jsx(akt,{className:Ot("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(mWe,{})]})}));Bs.displayName=iWe.displayName;const lkt=k.forwardRef(({className:t,...s},r)=>e.jsx(oWe,{ref:r,className:Ot("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));lkt.displayName=oWe.displayName;const vt=k.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(lWe,{ref:n,className:Ot("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(okt,{children:e.jsx(Zn,{className:"h-4 w-4"})})}),e.jsx(ikt,{children:s})]}));vt.displayName=lWe.displayName;const ckt=k.forwardRef(({className:t,...s},r)=>e.jsx(uWe,{ref:r,className:Ot("-mx-1 my-1 h-px bg-muted",t),...s}));ckt.displayName=uWe.displayName;const dkt=t=>gt({queryKey:["public-listings",t],queryFn:async()=>{let s=G.from("listings").select(` id, slug, agent_id, property_address, city, state, neighborhood, price, property_type, status, bedrooms, bathrooms, square_footage, lot_size, year_built, has_hoa, description, latitude, longitude, created_at, updated_at, photos:listing_photos(id, photo_url, is_primary), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage:brokerages(name)) `).eq("is_approved",!0).eq("is_public",!0).order("created_at",{ascending:!1});t!=null&&t.status&&(s=s.eq("status",t.status)),t!=null&&t.propertyType&&(s=s.eq("property_type",t.propertyType)),t!=null&&t.city&&(s=s.ilike("city",`%${t.city}%`)),t!=null&&t.minPrice&&(s=s.gte("price",t.minPrice)),t!=null&&t.maxPrice&&(s=s.lte("price",t.maxPrice));const{data:r,error:n}=await s;if(n)throw n;return r}}),pWe=t=>gt({queryKey:["public-listing",t],queryFn:async()=>{const s=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t);let r=G.from("listings").select(` id, slug, agent_id, property_address, city, state, neighborhood, price, property_type, status, bedrooms, bathrooms, square_footage, lot_size, year_built, has_hoa, description, agent_notes, agent_notes_public, mls_link, video_link, video_id, latitude, longitude, created_at, updated_at, photos:listing_photos(id, photo_url, is_primary, sort_order), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage:brokerages(name)), video:agent_videos!listings_video_id_fkey(id, playback_url, thumbnail_url, title, duration_seconds, bunny_video_id) `).eq("is_approved",!0).eq("is_public",!0);s?r=r.eq("id",t):r=r.eq("slug",t);const{data:n,error:a}=await r.single();if(a)throw a;return n},enabled:!!t}),fWe=()=>Pt({mutationFn:async({listingId:t,agentId:s,firstName:r,lastName:n,email:a,phone:o,shareToken:l,leadType:i="info_request",preferredDate:d,preferredTime:u,showingMode:p,message:f})=>{let y=null,_=null;if(l){const{data:S}=await G.from("listing_shares").select("id, sharing_agent_id").eq("share_token",l).eq("listing_id",t).maybeSingle();S&&(y=S.id,_=S.sharing_agent_id)}const{data:b,error:N}=await G.from("listing_leads").insert({listing_id:t,agent_id:_||s,first_name:r,last_name:n,email:a,phone:o,share_id:y,referred_by_agent_id:_,lead_type:i,preferred_date:d||null,preferred_time:u||null,showing_mode:p||null,message:f||null}).select().single();if(N)throw N;const{error:w}=await G.functions.invoke("process-listing-lead",{body:{leadId:b.id}});return w&&console.error("Error processing lead:",w),b}}),ukt=()=>Pt({mutationFn:async t=>{const{error:s}=await G.rpc("increment_listing_share_click",{p_share_token:t});if(s)throw s}}),hkt={active:"bg-emerald-500",coming_soon:"bg-blue-600",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},BPe={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},mkt={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function xWe(){const[t,s]=k.useState(""),[r,n]=k.useState(!1),[a,o]=k.useState({status:"",propertyType:"",minPrice:"",maxPrice:""}),{data:l,isLoading:i}=dkt({city:t||void 0,status:a.status||void 0,propertyType:a.propertyType||void 0,minPrice:a.minPrice?Number(a.minPrice):void 0,maxPrice:a.maxPrice?Number(a.maxPrice):void 0}),d=f=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(f),u=()=>{o({status:"",propertyType:"",minPrice:"",maxPrice:""}),s("")},p=t||a.status||a.propertyType||a.minPrice||a.maxPrice;return e.jsxs(e.Fragment,{children:[e.jsxs(kl,{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(da,{to:"/public/listings",className:"flex items-center",children:e.jsx("img",{src:MGe,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(${ANt})`},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(ln,{className:"absolute left-4 top-1/2 -translate-y-1/2 h-5 w-5 text-gray-400"}),e.jsx(De,{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(W,{className:"h-14 md:h-16 px-6 md:px-8 rounded-none bg-blue-600 hover:bg-blue-700",children:e.jsx(ln,{className:"h-5 w-5 md:h-6 md:w-6"})})]}),e.jsx("div",{className:"flex justify-center mt-6",children:e.jsxs(W,{variant:"secondary",size:"sm",onClick:()=>n(!r),className:"gap-2 bg-white/90 hover:bg-white text-gray-700 shadow-lg",children:[e.jsx(vS,{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($s,{value:a.status||"all",onValueChange:f=>o({...a,status:f==="all"?"":f}),children:[e.jsx(zs,{className:"bg-white",children:e.jsx(Vs,{placeholder:"Any status"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"Any status"}),Object.entries(BPe).map(([f,y])=>e.jsx(vt,{value:f,children:y},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($s,{value:a.propertyType||"all",onValueChange:f=>o({...a,propertyType:f==="all"?"":f}),children:[e.jsx(zs,{className:"bg-white",children:e.jsx(Vs,{placeholder:"Any type"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"Any type"}),Object.entries(mkt).map(([f,y])=>e.jsx(vt,{value:f,children:y},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(De,{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(De,{type:"number",placeholder:"No max",value:a.maxPrice,onChange:f=>o({...a,maxPrice:f.target.value}),className:"bg-white"})]})]}),p&&e.jsx("div",{className:"flex justify-end mt-4",children:e.jsxs(W,{variant:"ghost",size:"sm",onClick:u,className:"gap-1 text-gray-500",children:[e.jsx(kr,{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(INt,{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,y)=>e.jsxs("div",{className:"bg-white rounded-lg overflow-hidden shadow-sm",children:[e.jsx(Ms,{className:"aspect-[4/3]"}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx(Ms,{className:"h-7 w-28"}),e.jsx(Ms,{className:"h-4 w-full"}),e.jsx(Ms,{className:"h-4 w-3/4"})]})]},y))}):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 N,w,S;const y=((N=f.photos)==null?void 0:N.find(C=>C.is_primary))||((w=f.photos)==null?void 0:w[0]),b=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${f.slug||f.id}`:`/public/listing/${f.slug||f.id}`;return e.jsx(da,{to:b,children:e.jsxs("div",{className:"bg-white rounded-lg overflow-hidden shadow-sm hover:shadow-lg transition-shadow cursor-pointer group border border-gray-100",children:[e.jsxs("div",{className:"aspect-[4/3] relative overflow-hidden bg-gray-100",children:[y?e.jsx("img",{src:y.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(Mn,{className:"h-12 w-12 text-gray-300"})}),e.jsx(Qe,{className:`absolute top-2 left-2 ${hkt[f.status]} text-white border-0 text-xs font-medium px-2 py-0.5`,children:BPe[f.status]}),e.jsx("button",{className:"absolute top-2 right-2 p-2 rounded-full bg-white/80 hover:bg-white transition-colors",onClick:C=>C.preventDefault(),children:e.jsx(Xa,{className:"h-5 w-5 text-gray-600"})})]}),e.jsxs("div",{className:"p-4",children:[e.jsx("p",{className:"text-xl font-bold text-gray-900 mb-1",children:d(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}),((S=f.agent.brokerage)==null?void 0:S.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(Mn,{className:"h-10 w-10 text-gray-400"})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"No listings found"}),e.jsx("p",{className:"text-gray-500 mb-6",children:p?"Try adjusting your search or filters":"Check back soon for new listings"}),p&&e.jsx(W,{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:Hje,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:Ot("rounded-lg border bg-card text-card-foreground shadow-sm",t),...s}));Pe.displayName="Card";const Dt=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Ot("flex flex-col space-y-1.5 p-6",t),...s}));Dt.displayName="CardHeader";const zt=k.forwardRef(({className:t,...s},r)=>e.jsx("h3",{ref:r,className:Ot("text-2xl font-semibold leading-none tracking-tight",t),...s}));zt.displayName="CardTitle";const dr=k.forwardRef(({className:t,...s},r)=>e.jsx("p",{ref:r,className:Ot("text-sm text-muted-foreground",t),...s}));dr.displayName="CardDescription";const Oe=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Ot("p-6 pt-0",t),...s}));Oe.displayName="CardContent";const XL=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Ot("flex items-center p-6 pt-0",t),...s}));XL.displayName="CardFooter";var pkt="Label",gWe=k.forwardRef((t,s)=>e.jsx(Jr.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())}}));gWe.displayName=pkt;var yWe=gWe;const fkt=bC("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),xe=k.forwardRef(({className:t,...s},r)=>e.jsx(yWe,{ref:r,className:Ot(fkt(),t),...s}));xe.displayName=yWe.displayName;const Xoe="/assets/levelup-logo-color-D3mY9gCJ.png";function xkt(){const t=$l(),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(xWe,{}):n.startsWith("public/")?null:e.jsx(gkt,{slug:n})}function gkt({slug:t}){return e.jsx(_kt,{slug:t})}const ykt={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},vkt={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},$Pe={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function _kt({slug:t}){var B,U;const{data:s,isLoading:r}=pWe(t),n=fWe(),[a,o]=k.useState(""),[l,i]=k.useState(""),[d,u]=k.useState(""),[p,f]=k.useState(""),[y,_]=k.useState(!1),[b,N]=k.useState(!1),[w,S]=k.useState(null),C=te=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(te),A=async te=>{if(te.preventDefault(),!(!a.trim()||!d.trim()||!s)){_(!0);try{await n.mutateAsync({listingId:s.id,agentId:s.agent_id,firstName:a.trim(),lastName:l.trim(),email:d.trim(),phone:p.trim()}),N(!0),pe.success("Thanks! The agent will be in touch soon.")}catch(Y){console.error("Lead submission error:",Y),pe.error(`Failed to submit: ${Y.message||"Please try again"}`)}finally{_(!1)}}},I=(s==null?void 0:s.photos)||[],L=I.find(te=>te.is_primary)||I[0],O=()=>{w!==null&&S(w===0?I.length-1:w-1)},V=()=>{w!==null&&S(w===I.length-1?0:w+1)};if(r)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx(Ms,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(Ms,{className:"h-10 w-48 mb-6"}),e.jsx(Ms,{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(Ms,{className:"h-12 w-48"}),e.jsx(Ms,{className:"h-6 w-full"}),e.jsx(Ms,{className:"h-6 w-3/4"})]}),e.jsx(Ms,{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:Xoe,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(Mn,{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(W,{asChild:!0,children:e.jsx("a",{href:"/",children:"Browse All Listings"})})]})]});const q=s.property_address?`${s.property_address} - ${s.city}, ${s.state}`:`${s.city}, ${s.state} Home for Sale`;return e.jsxs(e.Fragment,{children:[e.jsxs(kl,{children:[e.jsxs("title",{children:[q," | LevelUp Listings"]}),e.jsx("meta",{name:"description",content:`${C(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA ${s.square_footage?s.square_footage.toLocaleString()+" sqft":""} ${$Pe[s.property_type]} in ${s.city}, ${s.state}. ${((B=s.description)==null?void 0:B.slice(0,150))||""}`}),e.jsx("meta",{property:"og:title",content:q}),e.jsx("meta",{property:"og:description",content:`${C(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA in ${s.city}, ${s.state}`}),e.jsx("meta",{property:"og:type",content:"website"}),L&&e.jsx("meta",{property:"og:image",content:L.photo_url})]}),e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card sticky top-0 z-50",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("a",{href:"/",className:"flex items-center gap-2",children:e.jsx("img",{src:Xoe,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(Oa,{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:()=>S(0),children:e.jsx("img",{src:L==null?void 0:L.photo_url,alt:"Primary",className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"})})}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:I.slice(1,5).map((te,Y)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>S(Y+1),children:[e.jsx("img",{src:te.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"]})]},te.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(Qe,{className:`${ykt[s.status]} text-white border-0`,children:vkt[s.status]})}),e.jsx("h1",{className:"text-4xl font-bold text-primary mb-2",children:C(s.price)}),s.property_address&&e.jsx("p",{className:"text-xl font-medium",children:s.property_address}),e.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(Ia,{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(Zy,{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(nf,{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(r0,{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(cn,{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(Qe,{variant:"secondary",children:[e.jsx(pa,{className:"h-3 w-3 mr-1"}),$Pe[s.property_type]]}),s.lot_size&&e.jsxs(Qe,{variant:"secondary",children:["Lot: ",s.lot_size]}),s.has_hoa&&e.jsx(Qe,{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(W,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:s.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Yr,{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(Dt,{children:e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Ai,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"font-semibold text-lg",children:s.agent.name}),((U=s.agent.brokerage)==null?void 0:U.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:s.agent.brokerage.name})]})]}),e.jsxs(Pe,{className:"border-primary",children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"Interested in this property?"})}),e.jsx(Oe,{children:b?e.jsxs("div",{className:"text-center py-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center mx-auto mb-3",children:e.jsx(tr,{className:"h-6 w-6 text-primary"})}),e.jsx("p",{className:"font-medium",children:"Thanks for your interest!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"The listing agent will contact you soon."})]}):e.jsxs("form",{onSubmit:A,className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"firstName",children:"First Name *"}),e.jsx(De,{id:"firstName",type:"text",placeholder:"John",value:a,onChange:te=>o(te.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"lastName",children:"Last Name"}),e.jsx(De,{id:"lastName",type:"text",placeholder:"Doe",value:l,onChange:te=>i(te.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"email",children:"Email *"}),e.jsx(De,{id:"email",type:"email",placeholder:"you@example.com",value:d,onChange:te=>u(te.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"phone",children:"Phone"}),e.jsx(De,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:p,onChange:te=>f(te.target.value)})]}),e.jsx(W,{type:"submit",className:"w-full",disabled:y,children:y?"Submitting...":"Get More Info"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"The listing agent will reach out to you directly."})]})})]})]})]})]}),e.jsx(fs,{open:w!==null,onOpenChange:()=>S(null),children:e.jsxs(ps,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(ks,{className:"sr-only",children:e.jsx(_s,{children:"Photo Gallery"})}),e.jsx("button",{onClick:()=>S(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(kr,{className:"h-5 w-5"})}),w!==null&&I[w]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:I[w].photo_url,alt:`Photo ${w+1}`,className:"w-full max-h-[80vh] object-contain"}),I.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick: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(Xo,{className:"h-6 w-6"})}),e.jsx("button",{onClick:V,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(xa,{className:"h-6 w-6"})}),e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 text-white bg-black/50 px-3 py-1 rounded-full text-sm",children:[w+1," / ",I.length]})]})]})]})}),e.jsx("footer",{className:"border-t py-8 mt-16",children:e.jsxs("div",{className:"container mx-auto px-4 text-center text-sm text-muted-foreground",children:[e.jsxs("p",{children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),e.jsx("p",{className:"mt-2",children:e.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"hover:text-foreground",children:"relevelup.com"})})]})})]})]})}function Mue({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 vWe=t=>gt({queryKey:["agent-card-public",t],queryFn:async()=>{if(!t)throw new Error("No slug provided");const{data:s,error:r}=await G.from("agent_cards").select("*").eq("slug",t).eq("is_published",!0).single();if(r)throw r;const{data:n}=await G.from("profiles").select("name, email, phone, brokerage_id").eq("id",s.user_id).single();let a=null;if(n!=null&&n.brokerage_id){const{data:i}=await G.from("brokerages").select("name").eq("id",n.brokerage_id).single();a=(i==null?void 0:i.name)||null}let o=null;try{const{data:i}=await G.from("profiles").select("avatar_url").eq("id",s.user_id).single();if(i!=null&&i.avatar_url)o=i.avatar_url;else{const{data:d}=await G.storage.from("avatars").list(`${s.user_id}`);if(d&&d.length>0){const{data:u}=G.storage.from("avatars").getPublicUrl(`${s.user_id}/${d[0].name}`);o=`${u.publicUrl}?t=${Date.now()}`}}}catch{}const l={...n||{name:null,email:null,phone:null,brokerage_id:null},email:s.display_email||(n==null?void 0:n.email)||null};return{...s,social_links:s.social_links||[],profile:l,brokerage_name:s.brokerage_display_name||a,avatar_url:o}},enabled:!!t}),bkt=()=>gt({queryKey:["agent-cards-admin"],queryFn:async()=>{const{data:t,error:s}=await G.from("agent_cards").select("*").order("created_at",{ascending:!1});if(s)throw s;return t}}),wkt=t=>gt({queryKey:["agent-card",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("agent_cards").select("*").eq("user_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t}),_We=()=>{const t=Qt();return Pt({mutationFn:async s=>{const{data:r,error:n}=await G.from("agent_cards").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-cards-admin"]}),t.invalidateQueries({queryKey:["agent-card"]}),pe.success("Agent card created")},onError:s=>pe.error(s.message)})},bWe=()=>{const t=Qt();return Pt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("agent_cards").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["agent-cards-admin"]}),t.invalidateQueries({queryKey:["agent-card"]}),pe.success("Agent card updated")},onError:s=>pe.error(s.message)})},Hi=async(t,s,r,n)=>{const a=new URLSearchParams(window.location.search);await G.from("agent_card_interactions").insert({card_id:t,interaction_type:s,interaction_detail:r||null,referrer:document.referrer||null,user_agent:navigator.userAgent||null,utm_source:a.get("utm_source")||null,utm_medium:a.get("utm_medium")||null,utm_campaign:a.get("utm_campaign")||null,metadata:{}})},jkt=async(t,s)=>{const{error:r}=await G.from("agent_card_leads").insert({card_id:t,...s});if(r)throw r},wWe=t=>gt({queryKey:["agent-card-analytics",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("agent_card_interactions").select("interaction_type, interaction_detail, created_at").eq("card_id",t).order("created_at",{ascending:!1}).limit(500);if(r)throw r;const{data:n,error:a}=await G.from("agent_card_leads").select("*").eq("card_id",t).order("created_at",{ascending:!1});if(a)throw a;const o=(s==null?void 0:s.filter(d=>d.interaction_type==="card_view").length)||0,l=(s==null?void 0:s.filter(d=>d.interaction_type==="button_click").length)||0,i=(s==null?void 0:s.filter(d=>d.interaction_type==="contact_saved").length)||0;return{views:o,clicks:l,saves:i,leads:n||[],interactions:s||[]}},enabled:!!t});function Tue({open:t,onOpenChange:s,cardId:r,type:n,agentName:a}){const[o,l]=k.useState(""),[i,d]=k.useState(""),[u,p]=k.useState(""),[f,y]=k.useState(""),[_,b]=k.useState(""),[N,w]=k.useState(!1),S=async C=>{if(C.preventDefault(),!o.trim()){pe.error("Please enter your name");return}w(!0);try{await jkt(r,{lead_type:n,name:o.trim(),email:i.trim()||void 0,phone:u.trim()||void 0,message:_.trim()||void 0,intent:f||void 0}),Hi(r,"lead_submitted",n),G.functions.invoke("card-lead-notify",{body:{cardId:r,leadType:n,name:o.trim(),email:i.trim()||void 0,phone:u.trim()||void 0,message:_.trim()||void 0,intent:f||void 0}}).catch(A=>console.error("Card lead notify failed:",A)),pe.success(n==="booking"?"Request sent! They'll be in touch soon.":n==="connect"?"Info shared! They'll be in touch soon.":"Referral submitted! Thank you."),s(!1),l(""),d(""),p(""),y(""),b("")}catch{pe.error("Something went wrong. Please try again.")}finally{w(!1)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-md rounded-2xl",children:[e.jsxs(ks,{children:[e.jsx(_s,{children:n==="booking"?"Book a Call":n==="connect"?"Connect with Me":"Refer a Friend"}),e.jsx(Ir,{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:S,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"lead-name",children:"Name *"}),e.jsx(De,{id:"lead-name",value:o,onChange:C=>l(C.target.value),placeholder:"Your name",required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"lead-phone",children:"Phone"}),e.jsx(De,{id:"lead-phone",type:"tel",value:u,onChange:C=>p(C.target.value),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"lead-email",children:"Email"}),e.jsx(De,{id:"lead-email",type:"email",value:i,onChange:C=>d(C.target.value),placeholder:"you@example.com"})]}),n==="booking"&&e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"lead-intent",children:"I'm looking to..."}),e.jsxs($s,{value:f,onValueChange:y,children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select one"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"buy",children:"Buy a home"}),e.jsx(vt,{value:"sell",children:"Sell my home"}),e.jsx(vt,{value:"both",children:"Buy & Sell"}),e.jsx(vt,{value:"other",children:"Something else"})]})]})]}),n!=="connect"&&e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"lead-message",children:n==="referral"?"Tell us about them":"Message (optional)"}),e.jsx(De,{id:"lead-message",value:_,onChange:C=>b(C.target.value),placeholder:n==="referral"?"Their name, phone, situation...":"Anything you'd like us to know"})]}),e.jsx(W,{type:"submit",className:"w-full rounded-2xl",disabled:N,children:N?"Sending...":"Submit"})]})]})})}const Nkt=t=>gt({queryKey:["card-blocks",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("card_blocks").select("*").eq("card_id",t).eq("is_visible",!0).order("sort_order",{ascending:!0});if(r)throw r;return s||[]},enabled:!!t}),kkt=t=>gt({queryKey:["card-blocks-all",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("card_blocks").select("*").eq("card_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s||[]},enabled:!!t}),Skt=()=>{const t=Qt();return Pt({mutationFn:async s=>{const{data:r,error:n}=await G.from("card_blocks").insert(s).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["card-blocks",r.card_id]}),t.invalidateQueries({queryKey:["card-blocks-all",r.card_id]}),pe.success("Block added")},onError:s=>pe.error(s.message)})},Ckt=()=>{const t=Qt();return Pt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("card_blocks").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["card-blocks"]}),t.invalidateQueries({queryKey:["card-blocks-all"]}),pe.success("Block updated")},onError:s=>pe.error(s.message)})},Mkt=()=>{const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("card_blocks").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["card-blocks"]}),t.invalidateQueries({queryKey:["card-blocks-all"]}),pe.success("Block removed")},onError:s=>pe.error(s.message)})};function Tkt(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 Akt(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 Ekt={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 Pkt({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=Akt(r.video_url),o=n||!!a,l=n?Tkt(r.video_url):a||r.video_url;return e.jsx("div",{className:Ekt[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 Ikt={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 Lkt({block:t,variant:s}){const n=t.config.testimonials||[],[a,o]=k.useState(0);if(n.length===0)return null;const l=Ikt[s],i=n[a];return e.jsxs("div",{className:l.container,children:[e.jsxs("div",{className:l.card,children:[e.jsx(pS,{className:"h-4 w-4 mb-2 opacity-30"}),e.jsxs("p",{className:`${l.quote} mb-3`,children:['"',i.quote,'"']}),e.jsxs("div",{children:[e.jsx("p",{className:l.name,children:i.name}),i.role&&e.jsx("p",{className:l.role,children:i.role})]})]}),n.length>1&&e.jsxs("div",{className:"flex items-center justify-center gap-3 mt-3",children:[e.jsx("button",{onClick:()=>o(d=>(d-1+n.length)%n.length),className:l.nav,children:e.jsx(Xo,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex gap-1.5",children:n.map((d,u)=>e.jsx("div",{className:`h-1.5 w-1.5 rounded-full transition-colors cursor-pointer ${u===a?l.dot:l.dotInactive}`,onClick:()=>o(u)},u))}),e.jsx("button",{onClick:()=>o(d=>(d+1)%n.length),className:l.nav,children:e.jsx(xa,{className:"h-4 w-4"})})]})]})}const Dkt={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 Rkt({block:t,variant:s}){const n=t.config.tags||[];if(n.length===0)return null;const a=Dkt[s];return e.jsx("div",{className:a.container,children:n.map((o,l)=>e.jsx("span",{className:a.tag,children:o},l))})}const Okt={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 Fkt({block:t,cardId:s,variant:r}){const a=t.config.links||[];if(a.length===0)return null;const o=Okt[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:()=>Hi(s,"button_click",`custom_link_${l.label}`),className:o.link,children:[e.jsx("span",{children:l.label}),e.jsx(Yr,{className:`h-4 w-4 ${o.icon}`})]},i))})}const b1e={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 zkt({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 Bkt={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 $kt({block:t,cardId:s,variant:r}){const a=t.config.platforms||[],o=Bkt[r];return a.length===0?null:e.jsxs("div",{className:o.container,children:[e.jsx("h3",{className:o.title,children:"Follow Me"}),e.jsx("div",{className:"flex flex-wrap gap-3 justify-center",children:a.map((l,i)=>{const d=b1e[l.platform.toLowerCase()];return!d||!l.url?null:e.jsx("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>Hi(s,"button_click",`social_${l.platform}`),className:o.linkClass,title:d.label,children:e.jsx(zkt,{path:d.icon,color:d.color})},i)})})]})}function Aue({cardId:t,variant:s}){const{data:r}=Nkt(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(Pkt,{block:l,variant:s},l.id);case"testimonials":return e.jsx(Lkt,{block:l,variant:s},l.id);case"specialties":return e.jsx(Rkt,{block:l,variant:s},l.id);case"custom_links":return e.jsx(Fkt,{block:l,cardId:t,variant:s},l.id);default:return null}}),o&&e.jsx($kt,{block:o,cardId:t,variant:s})]})}async function qkt(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 Ukt(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 Eue(t){const{first:s,last:r}=Ukt(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 qkt(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),pe.success("Contact saved!")}function Vkt({card:t}){var S;const[s,r]=k.useState(!1),[n,a]=k.useState("booking"),o=((S=t.profile)==null?void 0:S.name)||"Agent",l=o.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),i=(C,A)=>{Hi(t.id,"button_click",C),A()},d=()=>i("call",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`tel:${t.profile.phone}`:pe.error("Phone number not available")}),u=()=>i("text",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`sms:${t.profile.phone}`:pe.error("Phone number not available")}),p=()=>i("email",()=>{var C;(C=t.profile)!=null&&C.email?window.location.href=`mailto:${t.profile.email}`:pe.error("Email not available")}),f=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),Hi(t.id,"button_click","book"))},y=()=>{var C,A;Hi(t.id,"contact_saved"),Eue({name:o,phone:(C=t.profile)==null?void 0:C.phone,email:(A=t.profile)==null?void 0:A.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},_=async()=>{Hi(t.id,"share_event");const C=`https://cards.relevelup.com/${t.slug}`,A="Here's my contact card — save it so we can stay in touch.";if(navigator.share)try{await navigator.share({title:`${o}`,text:A,url:C})}catch{}else await navigator.clipboard.writeText(C),pe.success("Link copied!")},b=()=>{a("referral"),r(!0),Hi(t.id,"button_click","refer")},N=()=>{a("connect"),r(!0),Hi(t.id,"button_click","connect")},w={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 via-white to-slate-50",children:[e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(Nn,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[e.jsx(Ma,{src:t.avatar_url||void 0,alt:o}),e.jsx(kn,{className:"text-2xl font-semibold bg-primary text-primary-foreground",children:l})]}),e.jsx("h1",{className:"text-2xl font-bold text-slate-900 mb-0.5",children:o}),t.title&&e.jsx("p",{className:"text-sm font-medium text-primary mb-1",children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&e.jsx("p",{className:"text-sm font-medium text-slate-500 mb-1",children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:"text-xs font-medium text-slate-400 mb-3",children:t.team_name}),t.positioning_statement&&e.jsxs("p",{className:"text-base text-slate-600 italic leading-relaxed max-w-xs mx-auto",children:['"',t.positioning_statement,'"']})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[e.jsxs(W,{onClick:d,className:"flex flex-col items-center gap-1.5 h-auto py-4 bg-primary hover:bg-primary/90 text-primary-foreground rounded-2xl shadow-sm",children:[e.jsx(In,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Call"})]}),e.jsxs(W,{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(wi,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Text"})]}),e.jsxs(W,{onClick:p,className:"flex flex-col items-center gap-1.5 h-auto py-4 bg-primary hover:bg-primary/90 text-primary-foreground rounded-2xl shadow-sm",children:[e.jsx(tr,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Email"})]})]}),e.jsxs(W,{onClick:f,className:"w-full h-12 text-base font-semibold rounded-2xl shadow-sm mb-6",variant:"outline",children:[e.jsx(cn,{className:"h-5 w-5 mr-2"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"flex items-center justify-center gap-4 mb-6 text-sm text-slate-600",children:e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Gn,{className:"h-4 w-4 text-amber-500 fill-amber-500"}),e.jsx("span",{className:"font-bold text-slate-900",children:"5.0"})]})}),t.review_snippet&&e.jsx("div",{className:"bg-slate-50 rounded-2xl p-4 mb-6 border border-slate-100",children:e.jsxs("p",{className:"text-sm text-slate-600 italic text-center",children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-800 mb-2",children:"About Me"}),e.jsx("p",{className:"text-sm text-slate-600 leading-relaxed",children:t.bio})]}),e.jsx(Mue,{card:t,variant:"standard"}),e.jsx(Aue,{cardId:t.id,variant:"standard"}),e.jsxs("div",{className:"space-y-2 mb-6",children:[t.show_save_contact&&e.jsxs(W,{variant:"ghost",onClick:y,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(Qa,{className:"h-4 w-4 mr-3 text-primary"}),"Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs(W,{variant:"ghost",onClick:()=>{Hi(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(Gn,{className:"h-4 w-4 mr-3 text-amber-500"}),"Leave a Review"]}),t.show_refer_friend&&e.jsxs(W,{variant:"ghost",onClick:b,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(ir,{className:"h-4 w-4 mr-3 text-primary"}),"Refer a Friend"]}),e.jsxs(W,{variant:"ghost",onClick:N,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(Jo,{className:"h-4 w-4 mr-3 text-primary"}),"Connect with Me"]}),e.jsxs(W,{variant:"ghost",onClick:_,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(id,{className:"h-4 w-4 mr-3 text-primary"}),"Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((C,A)=>e.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>Hi(t.id,"button_click",`social_${C.platform}`),className:"h-10 w-10 rounded-full bg-slate-100 hover:bg-slate-200 flex items-center justify-center text-lg transition-colors",children:w[C.platform.toLowerCase()]||"🔗"},A))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-slate-400",children:"Powered by LevelUp"})})]}),e.jsx(Tue,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Hkt({card:t}){var S;const[s,r]=k.useState(!1),[n,a]=k.useState("booking"),o=((S=t.profile)==null?void 0:S.name)||"Agent",l=o.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),i=(C,A)=>{Hi(t.id,"button_click",C),A()},d=()=>i("call",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`tel:${t.profile.phone}`:pe.error("Phone number not available")}),u=()=>i("text",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`sms:${t.profile.phone}`:pe.error("Phone number not available")}),p=()=>i("email",()=>{var C;(C=t.profile)!=null&&C.email?window.location.href=`mailto:${t.profile.email}`:pe.error("Email not available")}),f=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),Hi(t.id,"button_click","book"))},y=()=>{var C,A;Hi(t.id,"contact_saved"),Eue({name:o,phone:(C=t.profile)==null?void 0:C.phone,email:(A=t.profile)==null?void 0:A.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},_=async()=>{Hi(t.id,"share_event");const C=`https://cards.relevelup.com/${t.slug}`,A="Here's my contact card — save it so we can stay in touch.";if(navigator.share)try{await navigator.share({title:`${o}`,text:A,url:C})}catch{}else await navigator.clipboard.writeText(C),pe.success("Link copied!")},b=()=>{a("referral"),r(!0),Hi(t.id,"button_click","refer")},N=()=>{a("connect"),r(!0),Hi(t.id,"button_click","connect")},w={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-[#0f1419] via-[#1a1f2e] to-[#0f1419]",children:[e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsx("div",{className:"w-16 h-0.5 bg-gradient-to-r from-[#c9a84c] to-[#e8d48b] mx-auto mb-8"}),e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(Nn,{className:"h-32 w-32 mx-auto mb-5 ring-2 ring-[#c9a84c]/40 shadow-2xl",children:[e.jsx(Ma,{src:t.avatar_url||void 0,alt:o}),e.jsx(kn,{className:"text-2xl font-serif bg-[#c9a84c]/20 text-[#e8d48b]",children:l})]}),e.jsx("h1",{className:"text-2xl font-serif font-bold text-white tracking-wide mb-0.5",children:o}),t.title&&e.jsx("p",{className:"text-sm font-medium text-[#e8d48b] mb-1",children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&e.jsx("p",{className:"text-sm font-medium text-[#c9a84c] tracking-widest uppercase mb-1",children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:"text-xs font-medium text-[#a0aec0] mb-3",children:t.team_name}),t.positioning_statement&&e.jsxs("p",{className:"text-base text-[#a0aec0] italic leading-relaxed max-w-xs mx-auto font-serif",children:['"',t.positioning_statement,'"']})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[{icon:In,label:"Call",handler:d},{icon:wi,label:"Text",handler:u},{icon:tr,label:"Email",handler:p}].map(({icon:C,label:A,handler:I})=>e.jsxs("button",{onClick:I,className:"flex flex-col items-center gap-1.5 py-4 bg-[#1e2636] hover:bg-[#252d3f] border border-[#c9a84c]/20 rounded-xl transition-colors",children:[e.jsx(C,{className:"h-5 w-5 text-[#c9a84c]"}),e.jsx("span",{className:"text-xs font-medium text-[#e2e8f0]",children:A})]},A))}),e.jsxs("button",{onClick: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(cn,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"flex items-center justify-center gap-4 mb-6 text-sm",children:e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Gn,{className:"h-4 w-4 text-[#c9a84c] fill-[#c9a84c]"}),e.jsx("span",{className:"font-bold text-white",children:"5.0"})]})}),t.review_snippet&&e.jsx("div",{className:"bg-[#1e2636] rounded-xl p-4 mb-6 border border-[#c9a84c]/10",children:e.jsxs("p",{className:"text-sm text-[#a0aec0] italic text-center font-serif",children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-sm font-semibold text-[#c9a84c] mb-2 tracking-wide uppercase",children:"About"}),e.jsx("p",{className:"text-sm text-[#a0aec0] leading-relaxed",children:t.bio})]}),e.jsx(Mue,{card:t,variant:"luxury"}),e.jsx(Aue,{cardId:t.id,variant:"luxury"}),e.jsxs("div",{className:"space-y-1 mb-6",children:[t.show_save_contact&&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(Qa,{className:"h-4 w-4 text-[#c9a84c]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{Hi(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(Gn,{className:"h-4 w-4 text-[#c9a84c]"})," Leave a Review"]}),t.show_refer_friend&&e.jsxs("button",{onClick:b,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(ir,{className:"h-4 w-4 text-[#c9a84c]"})," Refer a Friend"]}),e.jsxs("button",{onClick:N,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(Jo,{className:"h-4 w-4 text-[#c9a84c]"})," Connect with Me"]}),e.jsxs("button",{onClick:_,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(id,{className:"h-4 w-4 text-[#c9a84c]"})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((C,A)=>e.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>Hi(t.id,"button_click",`social_${C.platform}`),className:"h-10 w-10 rounded-full bg-[#1e2636] border border-[#c9a84c]/20 hover:border-[#c9a84c]/50 flex items-center justify-center text-lg transition-colors",children:w[C.platform.toLowerCase()]||"🔗"},A))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#4a5568]",children:"Powered by LevelUp"})})]}),e.jsx(Tue,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Gkt({card:t}){var A,I,L,O;const[s,r]=k.useState(!1),[n,a]=k.useState("booking"),o=((A=t.profile)==null?void 0:A.name)||"Agent",l=o.split(" ").map(V=>V[0]).join("").toUpperCase().slice(0,2),i={accent:((I=t.bold_theme_colors)==null?void 0:I.accent)||"#ff5722",dark:((L=t.bold_theme_colors)==null?void 0:L.dark)||"#1a1a2e",button:((O=t.bold_theme_colors)==null?void 0:O.button)||"#ff5722"},d=(V,q)=>{const B=parseInt(V.replace("#",""),16),U=Math.max(0,(B>>16)-q),te=Math.max(0,(B>>8&255)-q),Y=Math.max(0,(B&255)-q);return`#${(U<<16|te<<8|Y).toString(16).padStart(6,"0")}`};d(i.accent,25),d(i.dark,-20),d(i.button,25);const u=(V,q)=>{Hi(t.id,"button_click",V),q()},p=()=>u("call",()=>{var V;(V=t.profile)!=null&&V.phone?window.location.href=`tel:${t.profile.phone}`:pe.error("Phone number not available")}),f=()=>u("text",()=>{var V;(V=t.profile)!=null&&V.phone?window.location.href=`sms:${t.profile.phone}`:pe.error("Phone number not available")}),y=()=>u("email",()=>{var V;(V=t.profile)!=null&&V.email?window.location.href=`mailto:${t.profile.email}`:pe.error("Email not available")}),_=()=>{t.booking_url?u("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),Hi(t.id,"button_click","book"))},b=()=>{var V,q;Hi(t.id,"contact_saved"),Eue({name:o,phone:(V=t.profile)==null?void 0:V.phone,email:(q=t.profile)==null?void 0:q.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},N=async()=>{Hi(t.id,"share_event");const V=`https://cards.relevelup.com/${t.slug}`,q="Here's my contact card — save it so we can stay in touch.";if(navigator.share)try{await navigator.share({title:`${o}`,text:q,url:V})}catch{}else await navigator.clipboard.writeText(V),pe.success("Link copied!")},w=()=>{a("referral"),r(!0),Hi(t.id,"button_click","refer")},S=()=>{a("connect"),r(!0),Hi(t.id,"button_click","connect")},C={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen",style:{backgroundColor:i.accent},children:[e.jsxs("div",{className:"px-5 pt-10 pb-14 text-center relative",style:{backgroundColor:i.dark},children:[t.show_photo&&e.jsxs(Nn,{className:"h-28 w-28 mx-auto mb-4 shadow-2xl",style:{boxShadow:`0 0 0 4px ${i.accent}`},children:[e.jsx(Ma,{src:t.avatar_url||void 0,alt:o}),e.jsx(kn,{className:"text-2xl font-black text-white",style:{backgroundColor:i.accent},children:l})]}),e.jsx("h1",{className:"text-3xl font-black text-white tracking-tight mb-0.5",children:o}),t.title&&e.jsx("p",{className:"text-sm font-bold mb-1",style:{color:`${i.accent}cc`},children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&e.jsx("p",{className:"text-sm font-bold uppercase tracking-wider mb-1",style:{color:i.accent},children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:"text-xs font-bold text-white/60 uppercase tracking-wider",children:t.team_name})]}),e.jsxs("div",{className:"max-w-md mx-auto px-5 -mt-6",children:[e.jsxs("div",{className:"bg-white rounded-3xl shadow-2xl px-5 py-8",children:[t.positioning_statement&&e.jsx("p",{className:"text-center font-bold text-lg leading-snug mb-6 max-w-xs mx-auto",style:{color:i.dark},children:t.positioning_statement}),e.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[{icon:In,label:"Call",handler:p},{icon:wi,label:"Text",handler:f},{icon:tr,label:"Email",handler:y}].map(({icon:V,label:q,handler:B})=>e.jsxs("button",{onClick:B,className:"flex flex-col items-center gap-1.5 py-4 text-white rounded-2xl transition-opacity font-bold hover:opacity-85",style:{backgroundColor:i.dark},children:[e.jsx(V,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:q})]},q))}),e.jsxs("button",{onClick:_,className:"w-full h-14 text-base font-black rounded-2xl mb-6 text-white transition-opacity hover:opacity-90 flex items-center justify-center gap-2 uppercase tracking-wide",style:{backgroundColor:i.button},children:[e.jsx(cn,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"flex items-center justify-center gap-5 mb-6",children:t.review_snippet&&e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Gn,{className:"h-5 w-5",style:{color:i.accent,fill:i.accent}}),e.jsx("span",{className:"font-black text-2xl",style:{color:i.dark},children:"5.0"})]})}),t.review_snippet&&e.jsx("div",{className:"rounded-2xl p-4 mb-6",style:{backgroundColor:`${i.accent}15`},children:e.jsxs("p",{className:"text-sm font-medium text-center",style:{color:i.dark},children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-xs font-black mb-2 uppercase tracking-wider",style:{color:i.accent},children:"About Me"}),e.jsx("p",{className:"text-sm text-gray-600 leading-relaxed",children:t.bio})]}),e.jsx(Mue,{card:t,variant:"bold"}),e.jsx(Aue,{cardId:t.id,variant:"bold"}),e.jsxs("div",{className:"space-y-1 mb-6",children:[t.show_save_contact&&e.jsxs("button",{onClick:b,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(Qa,{className:"h-4 w-4",style:{color:i.accent}})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{Hi(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(Gn,{className:"h-4 w-4",style:{color:i.accent}})," Leave a Review"]}),t.show_refer_friend&&e.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(ir,{className:"h-4 w-4",style:{color:i.accent}})," Refer a Friend"]}),e.jsxs("button",{onClick:S,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(Jo,{className:"h-4 w-4",style:{color:i.accent}})," Connect with Me"]}),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(id,{className:"h-4 w-4",style:{color:i.accent}})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-6",children:t.social_links.slice(0,3).map((V,q)=>e.jsx("a",{href:V.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>Hi(t.id,"button_click",`social_${V.platform}`),className:"h-10 w-10 rounded-full flex items-center justify-center text-lg transition-opacity hover:opacity-85",style:{backgroundColor:i.dark},children:C[V.platform.toLowerCase()]||"🔗"},q))})]}),e.jsx("div",{className:"text-center py-6",children:e.jsx("p",{className:"text-xs text-white/50",children:"Powered by LevelUp"})})]}),e.jsx(Tue,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Wkt({card:t}){var S;const[s,r]=k.useState(!1),[n,a]=k.useState("booking"),o=((S=t.profile)==null?void 0:S.name)||"Agent",l=o.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),i=(C,A)=>{Hi(t.id,"button_click",C),A()},d=()=>i("call",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`tel:${t.profile.phone}`:pe.error("Phone number not available")}),u=()=>i("text",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`sms:${t.profile.phone}`:pe.error("Phone number not available")}),p=()=>i("email",()=>{var C;(C=t.profile)!=null&&C.email?window.location.href=`mailto:${t.profile.email}`:pe.error("Email not available")}),f=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),Hi(t.id,"button_click","book"))},y=()=>{var C,A;Hi(t.id,"contact_saved"),Eue({name:o,phone:(C=t.profile)==null?void 0:C.phone,email:(A=t.profile)==null?void 0:A.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},_=async()=>{Hi(t.id,"share_event");const C=`https://cards.relevelup.com/${t.slug}`,A="Here's my contact card — save it so we can stay in touch.";if(navigator.share)try{await navigator.share({title:`${o}`,text:A,url:C})}catch{}else await navigator.clipboard.writeText(C),pe.success("Link copied!")},b=()=>{a("referral"),r(!0),Hi(t.id,"button_click","refer")},N=()=>{a("connect"),r(!0),Hi(t.id,"button_click","connect")},w={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-[#f5f1eb]",children:[e.jsx("div",{className:"bg-[#1b3a4b] h-2"}),e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(Nn,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[e.jsx(Ma,{src:t.avatar_url||void 0,alt:o}),e.jsx(kn,{className:"text-2xl font-serif bg-[#1b3a4b] text-white",children:l})]}),e.jsx("h1",{className:"text-2xl font-serif font-bold text-[#1b3a4b] mb-0.5",children:o}),t.title&&e.jsx("p",{className:"text-sm font-medium text-[#5a7a6f] mb-1",children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&e.jsx("p",{className:"text-sm font-medium text-[#5a7a6f] mb-1",children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:"text-xs font-medium text-[#a0aec0] mb-3",children:t.team_name}),t.positioning_statement&&e.jsxs("p",{className:"text-base text-[#4a5568] italic leading-relaxed max-w-xs mx-auto font-serif",children:['"',t.positioning_statement,'"']})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[{icon:In,label:"Call",handler:d},{icon:wi,label:"Text",handler:u},{icon:tr,label:"Email",handler:p}].map(({icon:C,label:A,handler:I})=>e.jsxs("button",{onClick:I,className:"flex flex-col items-center gap-1.5 py-4 bg-white hover:bg-[#e8e3db] border border-[#d4cfc5] rounded-lg transition-colors shadow-sm",children:[e.jsx(C,{className:"h-5 w-5 text-[#1b3a4b]"}),e.jsx("span",{className:"text-xs font-semibold text-[#1b3a4b]",children:A})]},A))}),e.jsxs("button",{onClick: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(cn,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"bg-white rounded-lg border border-[#d4cfc5] p-4 mb-6 shadow-sm",children:e.jsx("div",{className:"flex items-center justify-center gap-6",children:e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Gn,{className:"h-4 w-4 text-[#d4a843] fill-[#d4a843]"}),e.jsx("span",{className:"font-bold text-[#1b3a4b] font-serif",children:"5.0"})]})})}),t.review_snippet&&e.jsx("div",{className:"bg-white rounded-lg border border-[#d4cfc5] p-4 mb-6 shadow-sm",children:e.jsxs("p",{className:"text-sm text-[#4a5568] italic text-center font-serif",children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-sm font-semibold text-[#1b3a4b] mb-2 font-serif",children:"About"}),e.jsx("p",{className:"text-sm text-[#4a5568] leading-relaxed",children:t.bio})]}),e.jsx(Mue,{card:t,variant:"classic"}),e.jsx(Aue,{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: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(Qa,{className:"h-4 w-4 text-[#5a7a6f]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{Hi(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(Gn,{className:"h-4 w-4 text-[#d4a843]"})," Leave a Review"]}),t.show_refer_friend&&e.jsxs("button",{onClick:b,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(ir,{className:"h-4 w-4 text-[#5a7a6f]"})," Refer a Friend"]}),e.jsxs("button",{onClick:N,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(Jo,{className:"h-4 w-4 text-[#5a7a6f]"})," Connect with Me"]}),e.jsxs("button",{onClick:_,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(id,{className:"h-4 w-4 text-[#5a7a6f]"})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((C,A)=>e.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>Hi(t.id,"button_click",`social_${C.platform}`),className:"h-10 w-10 rounded-full bg-white border border-[#d4cfc5] hover:bg-[#e8e3db] flex items-center justify-center text-lg transition-colors shadow-sm",children:w[C.platform.toLowerCase()]||"🔗"},A))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#a0aec0]",children:"Powered by LevelUp"})})]}),e.jsx(Tue,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Wje({card:t}){switch(t.theme){case"luxury":return e.jsx(Hkt,{card:t});case"bold":return e.jsx(Gkt,{card:t});case"classic":return e.jsx(Wkt,{card:t});case"standard":default:return e.jsx(Vkt,{card:t})}}function Kkt(){const t=$l();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(Zkt,{slug:s})}function Zkt({slug:t}){return e.jsx(Ykt,{slug:t})}function Ykt({slug:t}){var o;const{data:s,isLoading:r,error:n}=vWe(t);if(k.useEffect(()=>{s!=null&&s.id&&Hi(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(Ms,{className:"h-28 w-28 rounded-full"}),e.jsx(Ms,{className:"h-6 w-48"}),e.jsx(Ms,{className:"h-4 w-36"})]}),e.jsx(Ms,{className:"h-12 w-full"}),e.jsx(Ms,{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(kl,{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(Wje,{card:s})]})}function jWe({presentationId:t,ctaLabel:s,agentName:r,prefillName:n,prefillEmail:a,prefillPhone:o}){const[l,i]=k.useState(n||""),[d,u]=k.useState(a||""),[p,f]=k.useState(o||""),[y,_]=k.useState(""),[b,N]=k.useState(""),[w,S]=k.useState(!1),[C,A]=k.useState(!1),I=async L=>{if(L.preventDefault(),!l.trim()){pe.error("Please enter your name");return}S(!0);try{const{error:O}=await G.from("smart_presentation_leads").insert({presentation_id:t,name:l.trim(),email:d.trim()||null,phone:p.trim()||null,intent:y||null,message:b.trim()||null});if(O)throw O;try{await G.rpc("log_presentation_view",{p_presentation_id:t,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}G.functions.invoke("presentation-lead-notify",{body:{presentationId:t,name:l.trim(),email:d.trim()||void 0,phone:p.trim()||void 0,intent:y||void 0,message:b.trim()||void 0}}).catch(V=>console.error("Presentation lead notify failed:",V)),A(!0)}catch{pe.error("Something went wrong. Please try again.")}finally{S(!1)}};return C?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-emerald-100 flex items-center justify-center mx-auto mb-4",children:e.jsx(Zn,{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(xe,{htmlFor:"pres-lead-name",children:"Name *"}),e.jsx(De,{id:"pres-lead-name",value:l,onChange:L=>i(L.target.value),placeholder:"Your name",required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"pres-lead-phone",children:"Phone"}),e.jsx(De,{id:"pres-lead-phone",type:"tel",value:p,onChange:L=>f(L.target.value),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"pres-lead-email",children:"Email"}),e.jsx(De,{id:"pres-lead-email",type:"email",value:d,onChange:L=>u(L.target.value),placeholder:"you@example.com"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"pres-lead-intent",children:"I'm looking to..."}),e.jsxs($s,{value:y,onValueChange:_,children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select one"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"buy",children:"Buy a home"}),e.jsx(vt,{value:"sell",children:"Sell my home"}),e.jsx(vt,{value:"both",children:"Buy & Sell"}),e.jsx(vt,{value:"other",children:"Something else"})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"pres-lead-message",children:"Message (optional)"}),e.jsx(De,{id:"pres-lead-message",value:b,onChange:L=>N(L.target.value),placeholder:"Anything you'd like us to know"})]}),e.jsx(W,{type:"submit",className:"w-full text-lg py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",disabled:w,children:w?"Sending...":s})]})}function Xkt(){const t=$l();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(Qkt,{shareToken:s})}function Qkt({shareToken:t}){var b;const[s,r]=k.useState(null),[n,a]=k.useState(!0),[o,l]=k.useState(0),[i,d]=k.useState(!1);k.useEffect(()=>{u()},[t]);const u=async()=>{const{data:N,error:w}=await G.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(w||!N){d(!0),a(!1);return}const{data:S}=await G.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",N.owner_user_id).single();let C;if(S!=null&&S.brokerage_id){const{data:I}=await G.from("brokerages").select("name").eq("id",S.brokerage_id).single();C=(I==null?void 0:I.name)||void 0}let A=null;if(N.contact_id){const{data:I}=await G.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",N.contact_id).single();A=I}r({...N,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:C,contact_name:A?[A.first_name,A.last_name].filter(Boolean).join(" "):void 0,contact_email:(A==null?void 0:A.email)||void 0,contact_phone:(A==null?void 0:A.phone)||void 0}),a(!1);try{await G.rpc("log_presentation_view",{p_presentation_id:N.id,p_section_index:0,p_cta_clicked:!1,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch{}},p=async()=>{if(s){try{await G.rpc("log_presentation_view",{p_presentation_id:s.id,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}s.cta_url&&window.open(s.cta_url,"_blank")}},f=N=>{const w=N.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(w)return`https://www.youtube.com/embed/${w[1]}?rel=0`;if(N.includes("iframe.mediadelivery.net/play/")){const A=N.replace("/play/","/embed/"),I=A.includes("?")?"&":"?";return`${A}${I}responsive=true`}if(N.includes("iframe.mediadelivery.net")){const A=N.includes("?")?"&":"?";return`${N}${A}responsive=true`}const S=N.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(S)return`https://www.loom.com/embed/${S[1]}`;const C=N.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return C?`https://iframe.mediadelivery.net/embed/${C[1]}/${C[2]}?responsive=true`:N};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(Ms,{className:"h-12 w-3/4 mx-auto"}),e.jsx(Ms,{className:"h-64 w-full"}),e.jsx(Ms,{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 y=s.sections.filter(N=>N.is_visible!==!1),_=y[o];return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:[e.jsx("header",{className:"bg-white border-b border-gray-100 sticky top-0 z-10",children:e.jsx("div",{className:"max-w-5xl mx-auto px-4 py-3 flex items-center justify-end",children:e.jsxs("div",{className:"flex items-center gap-3",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-10 w-10 rounded-full object-cover border border-gray-200"}),e.jsxs("div",{className:"text-right text-sm",children:[e.jsx("p",{className:"font-semibold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.owner_title}),s.brokerage_name&&!s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.brokerage_name})]})]})})}),e.jsxs("main",{className:"max-w-5xl mx-auto px-4 py-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-gray-900 mb-2",children:s.heading||(s.client_name?`Welcome, ${s.client_name}!`:s.title)}),s.property_address&&e.jsxs("p",{className:"text-lg text-gray-600",children:["Here's the plan for your home at ",e.jsx("strong",{children:s.property_address}),"."]})]}),e.jsxs("div",{className:"grid md:grid-cols-5 gap-8",children:[e.jsxs("div",{className:"md:col-span-3",children:[_!=null&&_.video_url?e.jsx("div",{className:"relative w-full rounded-xl overflow-hidden shadow-lg bg-gray-900",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src:f(_.video_url),className:"absolute inset-0 w-full h-full border-0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,loading:"lazy"})}):_!=null&&_.image_url?e.jsx("div",{className:"rounded-xl overflow-hidden shadow-lg",children:e.jsx("img",{src:_.image_url,alt:_.title,className:"w-full h-auto object-cover",loading:"lazy"})}):e.jsxs("div",{className:"aspect-video bg-gradient-to-br from-blue-50 to-slate-100 rounded-xl flex flex-col items-center justify-center shadow-lg",children:[e.jsx("span",{className:"text-5xl mb-3",children:_==null?void 0:_.icon}),e.jsx("h3",{className:"text-xl font-semibold text-gray-800",children:_==null?void 0:_.title}),e.jsx("p",{className:"text-gray-500 mt-1 text-sm",children:_==null?void 0:_.description})]}),(_==null?void 0:_.text)&&e.jsx("div",{className:"mt-4 p-4 bg-white rounded-lg border text-gray-700 text-sm leading-relaxed prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:_.text}})]}),e.jsx("div",{className:"md:col-span-2 space-y-3",children:y.map((N,w)=>e.jsx("button",{onClick:()=>l(w),className:Ot("w-full text-left p-4 rounded-xl border transition-all",o===w?"border-blue-500 bg-blue-50 shadow-sm":"border-gray-200 bg-white hover:border-blue-200 hover:bg-blue-50/50"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("span",{className:"text-blue-600 font-bold text-sm mt-0.5",children:[String(w+1).padStart(2,"0"),"."]}),e.jsxs("div",{children:[e.jsx("span",{className:"mr-2",children:N.icon}),e.jsx("span",{className:"font-semibold text-gray-900",children:N.title}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:N.description})]})]})},w))})]}),e.jsxs("div",{className:"mt-12 max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6 text-center",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-20 w-20 rounded-full object-cover mx-auto mb-3 border-2 border-gray-100"}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-sm text-gray-500",children:s.owner_title}),s.brokerage_name&&e.jsx("p",{className:"text-sm text-gray-500",children:s.brokerage_name}),e.jsxs("div",{className:"mt-3 flex flex-col items-center gap-1 text-sm text-gray-600",children:[s.owner_phone&&e.jsx("a",{href:`tel:${s.owner_phone}`,className:"hover:text-blue-600 transition-colors",children:s.owner_phone}),s.owner_email&&e.jsx("a",{href:`mailto:${s.owner_email}`,className:"hover:text-blue-600 transition-colors",children:s.owner_email})]})]}),s.cta_label&&e.jsxs("div",{className:"text-center mt-8 py-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Ready to Get Started?"}),(b=s.cta_url)!=null&&b.trim()?e.jsxs(W,{size:"lg",onClick:p,className:"text-lg px-8 py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",children:[s.cta_label,e.jsx(Yr,{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(jWe,{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 Px=()=>{const t=ya();return gt({queryKey:["user-team",t],queryFn:async()=>{const{data:s,error:r}=await G.from("team_members").select("id, team_id, role").eq("user_id",t).maybeSingle();if(console.log("[useUserTeam] membership query:",{userId:t,membership:s,error:r}),r)throw r;if(!s)return null;const{data:n,error:a}=await G.from("teams").select("*").eq("id",s.team_id).single();if(a)throw a;return{membershipId:s.id,teamId:s.team_id,role:s.role,team:n}},enabled:!!t,staleTime:5*60*1e3})};function Jkt(){const{user:t}=Us(),s=ya(),{data:r}=Px();return gt({queryKey:["open-houses",s,r==null?void 0:r.teamId,r==null?void 0:r.role],queryFn:async()=>{const{data:n,error:a}=await G.from("open_houses").select("*").eq("agent_id",s).order("event_date",{ascending:!1});if(a)throw a;let o=n||[];if((r==null?void 0:r.role)==="team_leader"&&r.teamId){const{data:l,error:i}=await G.rpc("get_team_open_houses",{_user_id:s});if(!i&&l){const d=[...new Set(l.map(f=>f.agent_id))],u={};if(d.length>0){const{data:f}=await G.from("profiles").select("id, name").in("id",d);f==null||f.forEach(y=>{y.name&&(u[y.id]=y.name)})}const p=l.map(f=>({...f,agent_name:u[f.agent_id]||void 0}));o=[...o,...p]}}return o.sort((l,i)=>i.event_date.localeCompare(l.event_date)),o},enabled:!!t&&!!s})}function sAs(t){const{user:s}=Us();return gt({queryKey:["open-house",t],queryFn:async()=>{const{data:r,error:n}=await G.from("open_houses").select("*").eq("id",t).single();if(n)throw n;return r},enabled:!!s&&!!t})}function NWe(t){const{user:s}=Us(),r=Qt();return k.useEffect(()=>{if(!t)return;const n=`visitors-${t}-${Math.random().toString(36).slice(2,10)}`,a=G.channel(n).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()=>{G.removeChannel(a)}},[t,r]),gt({queryKey:["open-house-visitors",t],queryFn:async()=>{const{data:n,error:a}=await G.from("open_house_visitors").select("*").eq("open_house_id",t).order("created_at",{ascending:!1});if(a)throw a;return n},enabled:!!s&&!!t})}function e4t(){const t=Qt(),s=ya();return Pt({mutationFn:async r=>{const{data:n,error:a}=await G.from("open_houses").insert({...r,agent_id:s}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["open-houses"]}),fn({title:"Open house created!"})},onError:r=>{fn({title:"Error",description:r.message,variant:"destructive"})}})}function kWe(){const t=Qt();return Pt({mutationFn:async({id:s,...r})=>{const{error:n}=await G.from("open_houses").update(r).eq("id",s);if(n)throw n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["open-houses"]}),t.invalidateQueries({queryKey:["open-house",r.id]})}})}function t4t(){const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("open_houses").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["open-houses"]}),fn({title:"Open house deleted"})}})}function s4t(t){return gt({queryKey:["public-open-house",t],queryFn:async()=>{const{data:s,error:r}=await G.from("open_houses").select("*, profiles:agent_id(name, avatar_url, title)").eq("slug",t).eq("is_active",!0).single();if(r)throw r;let n=null;if(s.agent_id){const{data:a}=await G.from("agent_cards").select("slug").eq("user_id",s.agent_id).eq("is_published",!0).maybeSingle();a&&(n=a.slug)}return{...s,agent_card_slug:n}},enabled:!!t})}function r4t(t){const{user:s}=Us();return gt({queryKey:["survey-questions",t],queryFn:async()=>{const{data:r,error:n}=await G.from("open_house_survey_questions").select("*").eq("open_house_id",t).order("sort_order");if(n)throw n;return r},enabled:!!s&&!!t})}function n4t(t){return gt({queryKey:["public-survey-questions",t],queryFn:async()=>{const{data:s,error:r}=await G.from("open_house_survey_questions").select("*").eq("open_house_id",t).eq("is_active",!0).order("sort_order");if(r)throw r;return s},enabled:!!t})}function a4t(){return Pt({mutationFn:async t=>{const{error:s}=await G.from("open_house_survey_responses").insert(t);if(s)throw s}})}function i4t(t){const{user:s}=Us();return gt({queryKey:["survey-responses",t],queryFn:async()=>{const{data:r,error:n}=await G.from("open_house_survey_questions").select("*").eq("open_house_id",t).order("sort_order");if(n)throw n;const a=(r||[]).map(i=>i.id);if(a.length===0)return{questions:[],responses:[]};const{data:o,error:l}=await G.from("open_house_survey_responses").select("*").in("question_id",a).order("created_at",{ascending:!1});if(l)throw l;return{questions:r,responses:o||[]}},enabled:!!s&&!!t})}function o4t(){const t=Qt();return Pt({mutationFn:async s=>{const{data:r,error:n}=await G.from("open_house_survey_questions").insert(s).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r.open_house_id]})}})}function l4t(){const t=Qt();return Pt({mutationFn:async({id:s,open_house_id:r,...n})=>{const{error:a}=await G.from("open_house_survey_questions").update(n).eq("id",s);if(a)throw a},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r.open_house_id]})}})}function c4t(){const t=Qt();return Pt({mutationFn:async({id:s,open_house_id:r})=>{const{error:n}=await G.from("open_house_survey_questions").delete().eq("id",s);if(n)throw n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r.open_house_id]})}})}function d4t(){const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.rpc("seed_default_survey_questions",{_open_house_id:s});if(r)throw r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r]})}})}function u4t(){return Pt({mutationFn:async t=>{const{data:s,error:r}=await G.from("open_house_visitors").insert(t).select("id").single();if(r)throw r;return s}})}function h4t(){return Pt({mutationFn:async({visitor_id:t,...s})=>{const{error:r}=await G.from("open_house_visitors").update(s).eq("id",t);if(r)throw r}})}function m4t(){return Pt({mutationFn:async t=>{await G.rpc("increment_open_house_scan",{_slug:t})}})}var Pue="Switch",[p4t,rAs]=qc(Pue),[f4t,x4t]=p4t(Pue),SWe=k.forwardRef((t,s)=>{const{__scopeSwitch:r,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:d="on",onCheckedChange:u,form:p,...f}=t,[y,_]=k.useState(null),b=Ta(s,A=>_(A)),N=k.useRef(!1),w=y?p||!!y.closest("form"):!0,[S,C]=Uu({prop:a,defaultProp:o??!1,onChange:u,caller:Pue});return e.jsxs(f4t,{scope:r,checked:S,disabled:i,children:[e.jsx(Jr.button,{type:"button",role:"switch","aria-checked":S,"aria-required":l,"data-state":AWe(S),"data-disabled":i?"":void 0,disabled:i,value:d,...f,ref:b,onClick:Mr(t.onClick,A=>{C(I=>!I),w&&(N.current=A.isPropagationStopped(),N.current||A.stopPropagation())})}),w&&e.jsx(TWe,{control:y,bubbles:!N.current,name:n,value:d,checked:S,required:l,disabled:i,form:p,style:{transform:"translateX(-100%)"}})]})});SWe.displayName=Pue;var CWe="SwitchThumb",MWe=k.forwardRef((t,s)=>{const{__scopeSwitch:r,...n}=t,a=x4t(CWe,r);return e.jsx(Jr.span,{"data-state":AWe(a.checked),"data-disabled":a.disabled?"":void 0,...n,ref:s})});MWe.displayName=CWe;var g4t="SwitchBubbleInput",TWe=k.forwardRef(({__scopeSwitch:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=k.useRef(null),i=Ta(l,o),d=zR(r),u=kR(s);return k.useEffect(()=>{const p=l.current;if(!p)return;const f=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(f,"checked").set;if(d!==r&&_){const b=new Event("click",{bubbles:n});_.call(p,r),p.dispatchEvent(b)}},[d,r,n]),e.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...a,tabIndex:-1,ref:i,style:{...a.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});TWe.displayName=g4t;function AWe(t){return t?"checked":"unchecked"}var EWe=SWe,y4t=MWe;const Ar=k.forwardRef(({className:t,...s},r)=>e.jsx(EWe,{className:Ot("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(y4t,{className:Ot("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")})}));Ar.displayName=EWe.displayName;function Yn(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 Wo(t,s){return t instanceof Date?new t.constructor(s):new Date(s)}function ml(t,s){const r=Yn(t);return isNaN(s)?Wo(t,NaN):(s&&r.setDate(r.getDate()+s),r)}function Am(t,s){const r=Yn(t);if(isNaN(s))return Wo(t,NaN);if(!s)return r;const n=r.getDate(),a=Wo(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 PWe(t,s){const r=+Yn(t);return Wo(t,r+s)}const Kje=6048e5,v4t=864e5,Iue=6e4,BR=36e5,_4t=1e3,Tz=43200,qPe=1440;function UPe(t,s){return PWe(t,s*BR)}let b4t={};function gw(){return b4t}function zh(t,s){var i,d,u,p;const r=gw(),n=(s==null?void 0:s.weekStartsOn)??((d=(i=s==null?void 0:s.locale)==null?void 0:i.options)==null?void 0:d.weekStartsOn)??r.weekStartsOn??((p=(u=r.locale)==null?void 0:u.options)==null?void 0:p.weekStartsOn)??0,a=Yn(t),o=a.getDay(),l=(o=a.getTime()?r+1:s.getTime()>=l.getTime()?r:r-1}function Em(t){const s=Yn(t);return s.setHours(0,0,0,0),s}function Xb(t){const s=Yn(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 sf(t,s){const r=Em(t),n=Em(s),a=+r-Xb(r),o=+n-Xb(n);return Math.round((a-o)/v4t)}function w4t(t){const s=IWe(t),r=Wo(t,0);return r.setFullYear(s,0,4),r.setHours(0,0,0,0),x1(r)}function J5(t,s){return PWe(t,s*Iue)}function x4(t,s){const r=s*7;return ml(t,r)}function j4t(t,s){return Am(t,s*12)}function N4t(t){let s;return t.forEach(function(r){const n=Yn(r);(s===void 0||s{const n=Yn(r);(!s||s>n||isNaN(+n))&&(s=n)}),s||new Date(NaN)}function $ie(t,s){const r=Yn(t),n=Yn(s),a=r.getTime()-n.getTime();return a<0?-1:a>0?1:a}function Zje(t){return Wo(t,Date.now())}function il(t,s){const r=Em(t),n=Em(s);return+r==+n}function Yje(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function w1e(t){if(!Yje(t)&&typeof t!="number")return!1;const s=Yn(t);return!isNaN(Number(s))}function ET(t,s){const r=Yn(t),n=Yn(s),a=r.getFullYear()-n.getFullYear(),o=r.getMonth()-n.getMonth();return a*12+o}function S4t(t,s,r){const n=zh(t,r),a=zh(s,r),o=+n-Xb(n),l=+a-Xb(a);return Math.round((o-l)/Kje)}function $g(t,s){const r=Yn(t),n=Yn(s),a=VPe(r,n),o=Math.abs(sf(r,n));r.setDate(r.getDate()-a*o);const l=+(VPe(r,n)===-a),i=a*(o-l);return i===0?0:i}function VPe(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 LWe(t){return s=>{const n=(t?Math[t]:Math.trunc)(s);return n===0?0:n}}function DWe(t,s){return+Yn(t)-+Yn(s)}function C4t(t,s,r){const n=DWe(t,s)/BR;return LWe(r==null?void 0:r.roundingMethod)(n)}function M4t(t){const s=Yn(t);return s.setHours(23,59,59,999),s}function tx(t){const s=Yn(t),r=s.getMonth();return s.setFullYear(s.getFullYear(),r+1,0),s.setHours(23,59,59,999),s}function T4t(t){const s=Yn(t);return+M4t(s)==+tx(s)}function A4t(t,s){const r=Yn(t),n=Yn(s),a=$ie(r,n),o=Math.abs(ET(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=$ie(r,n)===-a;T4t(Yn(t))&&o===1&&$ie(t,n)===1&&(i=!1),l=a*(o-Number(i))}return l===0?0:l}function E4t(t,s,r){const n=DWe(t,s)/1e3;return LWe(r==null?void 0:r.roundingMethod)(n)}function P4t(t,s){const r=Yn(t.start),n=Yn(t.end);let a=+r>+n;const o=a?+r:+n,l=a?n:r;l.setHours(0,0,0,0);let i=1;const d=[];for(;+l<=o;)d.push(Yn(l)),l.setDate(l.getDate()+i),l.setHours(0,0,0,0);return a?d.reverse():d}function gc(t){const s=Yn(t);return s.setDate(1),s.setHours(0,0,0,0),s}function RWe(t){const s=Yn(t),r=Wo(t,0);return r.setFullYear(s.getFullYear(),0,1),r.setHours(0,0,0,0),r}function Lue(t,s){var i,d,u,p;const r=gw(),n=(s==null?void 0:s.weekStartsOn)??((d=(i=s==null?void 0:s.locale)==null?void 0:i.options)==null?void 0:d.weekStartsOn)??r.weekStartsOn??((p=(u=r.locale)==null?void 0:u.options)==null?void 0:p.weekStartsOn)??0,a=Yn(t),o=a.getDay(),l=(o{let n;const a=I4t[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 vge(t){return(s={})=>{const r=s.width?String(s.width):t.defaultWidth;return t.formats[r]||t.formats[t.defaultWidth]}}const D4t={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},R4t={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},O4t={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},F4t={date:vge({formats:D4t,defaultWidth:"full"}),time:vge({formats:R4t,defaultWidth:"full"}),dateTime:vge({formats:O4t,defaultWidth:"full"})},z4t={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},B4t=(t,s,r,n)=>z4t[t];function Q6(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 $4t={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},q4t={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},U4t={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"]},V4t={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"]},H4t={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"}},G4t={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"}},W4t=(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"},K4t={ordinalNumber:W4t,era:Q6({values:$4t,defaultWidth:"wide"}),quarter:Q6({values:q4t,defaultWidth:"wide",argumentCallback:t=>t-1}),month:Q6({values:U4t,defaultWidth:"wide"}),day:Q6({values:V4t,defaultWidth:"wide"}),dayPeriod:Q6({values:H4t,defaultWidth:"wide",formattingValues:G4t,defaultFormattingWidth:"wide"})};function J6(t){return(s,r={})=>{const n=r.width,a=n&&t.matchPatterns[n]||t.matchPatterns[t.defaultMatchWidth],o=s.match(a);if(!o)return null;const l=o[0],i=n&&t.parsePatterns[n]||t.parsePatterns[t.defaultParseWidth],d=Array.isArray(i)?Y4t(i,f=>f.test(l)):Z4t(i,f=>f.test(l));let u;u=t.valueCallback?t.valueCallback(d):d,u=r.valueCallback?r.valueCallback(u):u;const p=s.slice(l.length);return{value:u,rest:p}}}function Z4t(t,s){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&s(t[r]))return r}function Y4t(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 Q4t=/^(\d+)(th|st|nd|rd)?/i,J4t=/\d+/i,eSt={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]},sSt={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},rSt={any:[/1/i,/2/i,/3/i,/4/i]},nSt={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},aSt={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]},iSt={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},oSt={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]},lSt={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},cSt={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}},dSt={ordinalNumber:X4t({matchPattern:Q4t,parsePattern:J4t,valueCallback:t=>parseInt(t,10)}),era:J6({matchPatterns:eSt,defaultMatchWidth:"wide",parsePatterns:tSt,defaultParseWidth:"any"}),quarter:J6({matchPatterns:sSt,defaultMatchWidth:"wide",parsePatterns:rSt,defaultParseWidth:"any",valueCallback:t=>t+1}),month:J6({matchPatterns:nSt,defaultMatchWidth:"wide",parsePatterns:aSt,defaultParseWidth:"any"}),day:J6({matchPatterns:iSt,defaultMatchWidth:"wide",parsePatterns:oSt,defaultParseWidth:"any"}),dayPeriod:J6({matchPatterns:lSt,defaultMatchWidth:"any",parsePatterns:cSt,defaultParseWidth:"any"})},Due={code:"en-US",formatDistance:L4t,formatLong:F4t,formatRelative:B4t,localize:K4t,match:dSt,options:{weekStartsOn:0,firstWeekContainsDate:1}};function uSt(t){const s=Yn(t);return sf(s,RWe(s))+1}function Xje(t){const s=Yn(t),r=+x1(s)-+w4t(s);return Math.round(r/Kje)+1}function Qje(t,s){var p,f,y,_;const r=Yn(t),n=r.getFullYear(),a=gw(),o=(s==null?void 0:s.firstWeekContainsDate)??((f=(p=s==null?void 0:s.locale)==null?void 0:p.options)==null?void 0:f.firstWeekContainsDate)??a.firstWeekContainsDate??((_=(y=a.locale)==null?void 0:y.options)==null?void 0:_.firstWeekContainsDate)??1,l=Wo(t,0);l.setFullYear(n+1,0,o),l.setHours(0,0,0,0);const i=zh(l,s),d=Wo(t,0);d.setFullYear(n,0,o),d.setHours(0,0,0,0);const u=zh(d,s);return r.getTime()>=i.getTime()?n+1:r.getTime()>=u.getTime()?n:n-1}function hSt(t,s){var i,d,u,p;const r=gw(),n=(s==null?void 0:s.firstWeekContainsDate)??((d=(i=s==null?void 0:s.locale)==null?void 0:i.options)==null?void 0:d.firstWeekContainsDate)??r.firstWeekContainsDate??((p=(u=r.locale)==null?void 0:u.options)==null?void 0:p.firstWeekContainsDate)??1,a=Qje(t,s),o=Wo(t,0);return o.setFullYear(a,0,n),o.setHours(0,0,0,0),zh(o,s)}function Jje(t,s){const r=Yn(t),n=+zh(r,s)-+hSt(r,s);return Math.round(n/Kje)+1}function Go(t,s){const r=t<0?"-":"",n=Math.abs(t).toString().padStart(s,"0");return r+n}const g_={y(t,s){const r=t.getFullYear(),n=r>0?r:1-r;return Go(s==="yy"?n%100:n,s.length)},M(t,s){const r=t.getMonth();return s==="M"?String(r+1):Go(r+1,2)},d(t,s){return Go(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 Go(t.getHours()%12||12,s.length)},H(t,s){return Go(t.getHours(),s.length)},m(t,s){return Go(t.getMinutes(),s.length)},s(t,s){return Go(t.getSeconds(),s.length)},S(t,s){const r=s.length,n=t.getMilliseconds(),a=Math.trunc(n*Math.pow(10,r-3));return Go(a,s.length)}},f5={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},HPe={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 g_.y(t,s)},Y:function(t,s,r,n){const a=Qje(t,n),o=a>0?a:1-a;if(s==="YY"){const l=o%100;return Go(l,2)}return s==="Yo"?r.ordinalNumber(o,{unit:"year"}):Go(o,s.length)},R:function(t,s){const r=IWe(t);return Go(r,s.length)},u:function(t,s){const r=t.getFullYear();return Go(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 Go(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 Go(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 g_.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 Go(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=Jje(t,n);return s==="wo"?r.ordinalNumber(a,{unit:"week"}):Go(a,s.length)},I:function(t,s,r){const n=Xje(t);return s==="Io"?r.ordinalNumber(n,{unit:"week"}):Go(n,s.length)},d:function(t,s,r){return s==="do"?r.ordinalNumber(t.getDate(),{unit:"date"}):g_.d(t,s)},D:function(t,s,r){const n=uSt(t);return s==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):Go(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 Go(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 Go(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 Go(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=f5.noon:n===0?a=f5.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=f5.evening:n>=12?a=f5.afternoon:n>=4?a=f5.morning:a=f5.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 g_.h(t,s)},H:function(t,s,r){return s==="Ho"?r.ordinalNumber(t.getHours(),{unit:"hour"}):g_.H(t,s)},K:function(t,s,r){const n=t.getHours()%12;return s==="Ko"?r.ordinalNumber(n,{unit:"hour"}):Go(n,s.length)},k:function(t,s,r){let n=t.getHours();return n===0&&(n=24),s==="ko"?r.ordinalNumber(n,{unit:"hour"}):Go(n,s.length)},m:function(t,s,r){return s==="mo"?r.ordinalNumber(t.getMinutes(),{unit:"minute"}):g_.m(t,s)},s:function(t,s,r){return s==="so"?r.ordinalNumber(t.getSeconds(),{unit:"second"}):g_.s(t,s)},S:function(t,s){return g_.S(t,s)},X:function(t,s,r){const n=t.getTimezoneOffset();if(n===0)return"Z";switch(s){case"X":return WPe(n);case"XXXX":case"XX":return r4(n);case"XXXXX":case"XXX":default:return r4(n,":")}},x:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"x":return WPe(n);case"xxxx":case"xx":return r4(n);case"xxxxx":case"xxx":default:return r4(n,":")}},O:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"O":case"OO":case"OOO":return"GMT"+GPe(n,":");case"OOOO":default:return"GMT"+r4(n,":")}},z:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"z":case"zz":case"zzz":return"GMT"+GPe(n,":");case"zzzz":default:return"GMT"+r4(n,":")}},t:function(t,s,r){const n=Math.trunc(t.getTime()/1e3);return Go(n,s.length)},T:function(t,s,r){const n=t.getTime();return Go(n,s.length)}};function GPe(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+Go(o,2)}function WPe(t,s){return t%60===0?(t>0?"-":"+")+Go(Math.abs(t)/60,2):r4(t,s)}function r4(t,s=""){const r=t>0?"-":"+",n=Math.abs(t),a=Go(Math.trunc(n/60),2),o=Go(n%60,2);return r+a+s+o}const KPe=(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"})}},FWe=(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"})}},mSt=(t,s)=>{const r=t.match(/(P+)(p+)?/)||[],n=r[1],a=r[2];if(!a)return KPe(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}}",KPe(n,s)).replace("{{time}}",FWe(a,s))},j1e={p:FWe,P:mSt},pSt=/^D+$/,fSt=/^Y+$/,xSt=["D","DD","YY","YYYY"];function zWe(t){return pSt.test(t)}function BWe(t){return fSt.test(t)}function N1e(t,s,r){const n=gSt(t,s,r);if(console.warn(n),xSt.includes(t))throw new RangeError(n)}function gSt(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 ySt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,vSt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,_St=/^'([^]*?)'?$/,bSt=/''/g,wSt=/[a-zA-Z]/;function vs(t,s,r){var p,f,y,_,b,N,w,S;const n=gw(),a=(r==null?void 0:r.locale)??n.locale??Due,o=(r==null?void 0:r.firstWeekContainsDate)??((f=(p=r==null?void 0:r.locale)==null?void 0:p.options)==null?void 0:f.firstWeekContainsDate)??n.firstWeekContainsDate??((_=(y=n.locale)==null?void 0:y.options)==null?void 0:_.firstWeekContainsDate)??1,l=(r==null?void 0:r.weekStartsOn)??((N=(b=r==null?void 0:r.locale)==null?void 0:b.options)==null?void 0:N.weekStartsOn)??n.weekStartsOn??((S=(w=n.locale)==null?void 0:w.options)==null?void 0:S.weekStartsOn)??0,i=Yn(t);if(!w1e(i))throw new RangeError("Invalid time value");let d=s.match(vSt).map(C=>{const A=C[0];if(A==="p"||A==="P"){const I=j1e[A];return I(C,a.formatLong)}return C}).join("").match(ySt).map(C=>{if(C==="''")return{isToken:!1,value:"'"};const A=C[0];if(A==="'")return{isToken:!1,value:jSt(C)};if(HPe[A])return{isToken:!0,value:C};if(A.match(wSt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+A+"`");return{isToken:!1,value:C}});a.localize.preprocessor&&(d=a.localize.preprocessor(i,d));const u={firstWeekContainsDate:o,weekStartsOn:l,locale:a};return d.map(C=>{if(!C.isToken)return C.value;const A=C.value;(!(r!=null&&r.useAdditionalWeekYearTokens)&&BWe(A)||!(r!=null&&r.useAdditionalDayOfYearTokens)&&zWe(A))&&N1e(A,s,String(t));const I=HPe[A[0]];return I(i,A,a.localize,u)}).join("")}function jSt(t){const s=t.match(_St);return s?s[1].replace(bSt,"'"):t}function NSt(t,s,r){const n=gw(),a=(r==null?void 0:r.locale)??n.locale??Due,o=2520,l=$ie(t,s);if(isNaN(l))throw new RangeError("Invalid time value");const i=Object.assign({},r,{addSuffix:r==null?void 0:r.addSuffix,comparison:l});let d,u;l>0?(d=Yn(s),u=Yn(t)):(d=Yn(t),u=Yn(s));const p=E4t(u,d),f=(Xb(u)-Xb(d))/1e3,y=Math.round((p-f)/60);let _;if(y<2)return r!=null&&r.includeSeconds?p<5?a.formatDistance("lessThanXSeconds",5,i):p<10?a.formatDistance("lessThanXSeconds",10,i):p<20?a.formatDistance("lessThanXSeconds",20,i):p<40?a.formatDistance("halfAMinute",0,i):p<60?a.formatDistance("lessThanXMinutes",1,i):a.formatDistance("xMinutes",1,i):y===0?a.formatDistance("lessThanXMinutes",1,i):a.formatDistance("xMinutes",y,i);if(y<45)return a.formatDistance("xMinutes",y,i);if(y<90)return a.formatDistance("aboutXHours",1,i);if(yn.getTime()}function YS(t,s){const r=Yn(t),n=Yn(s);return+r<+n}function ESt(t){return+Yn(t)>Date.now()}function PSt(t,s){const r=s instanceof Date?Wo(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 ISt=10;class $We{constructor(){En(this,"subPriority",0)}validate(s,r){return!0}}class LSt extends $We{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 DSt extends $We{constructor(){super(...arguments);En(this,"priority",ISt);En(this,"subPriority",-1)}set(r,n){return n.timestampIsSet?r:Wo(r,PSt(r,Date))}}class Ro{run(s,r,n,a){const o=this.parse(s,r,n,a);return o?{setter:new LSt(o.value,this.validate,this.set,this.priority,this.subPriority),rest:o.rest}:null}validate(s,r,n){return!0}}class RSt extends Ro{constructor(){super(...arguments);En(this,"priority",140);En(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 yd={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}/},By={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 vd(t,s){return t&&{value:s(t.value),rest:t.rest}}function Rc(t,s){const r=s.match(t);return r?{value:parseInt(r[0],10),rest:s.slice(r[0].length)}:null}function $y(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*BR+o*Iue+l*_4t),rest:s.slice(r[0].length)}}function qWe(t){return Rc(yd.anyDigitsSigned,t)}function ld(t,s){switch(t){case 1:return Rc(yd.singleDigit,s);case 2:return Rc(yd.twoDigits,s);case 3:return Rc(yd.threeDigits,s);case 4:return Rc(yd.fourDigits,s);default:return Rc(new RegExp("^\\d{1,"+t+"}"),s)}}function Qoe(t,s){switch(t){case 1:return Rc(yd.singleDigitSigned,s);case 2:return Rc(yd.twoDigitsSigned,s);case 3:return Rc(yd.threeDigitsSigned,s);case 4:return Rc(yd.fourDigitsSigned,s);default:return Rc(new RegExp("^-?\\d{1,"+t+"}"),s)}}function eNe(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 UWe(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 VWe(t){return t%400===0||t%4===0&&t%100!==0}class OSt extends Ro{constructor(){super(...arguments);En(this,"priority",130);En(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 vd(ld(4,r),o);case"yo":return vd(a.ordinalNumber(r,{unit:"year"}),o);default:return vd(ld(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=UWe(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 FSt extends Ro{constructor(){super(...arguments);En(this,"priority",130);En(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 vd(ld(4,r),o);case"Yo":return vd(a.ordinalNumber(r,{unit:"year"}),o);default:return vd(ld(n.length,r),o)}}validate(r,n){return n.isTwoDigitYear||n.year>0}set(r,n,a,o){const l=Qje(r,o);if(a.isTwoDigitYear){const d=UWe(a.year,l);return r.setFullYear(d,0,o.firstWeekContainsDate),r.setHours(0,0,0,0),zh(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),zh(r,o)}}class zSt extends Ro{constructor(){super(...arguments);En(this,"priority",130);En(this,"incompatibleTokens",["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"])}parse(r,n){return Qoe(n==="R"?4:n.length,r)}set(r,n,a){const o=Wo(r,0);return o.setFullYear(a,0,4),o.setHours(0,0,0,0),x1(o)}}class BSt extends Ro{constructor(){super(...arguments);En(this,"priority",130);En(this,"incompatibleTokens",["G","y","Y","R","w","I","i","e","c","t","T"])}parse(r,n){return Qoe(n==="u"?4:n.length,r)}set(r,n,a){return r.setFullYear(a,0,1),r.setHours(0,0,0,0),r}}class $St extends Ro{constructor(){super(...arguments);En(this,"priority",120);En(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 ld(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 qSt extends Ro{constructor(){super(...arguments);En(this,"priority",120);En(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 ld(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 USt extends Ro{constructor(){super(...arguments);En(this,"incompatibleTokens",["Y","R","q","Q","L","w","I","D","i","e","c","t","T"]);En(this,"priority",110)}parse(r,n,a){const o=l=>l-1;switch(n){case"M":return vd(Rc(yd.month,r),o);case"MM":return vd(ld(2,r),o);case"Mo":return vd(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 VSt extends Ro{constructor(){super(...arguments);En(this,"priority",110);En(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 vd(Rc(yd.month,r),o);case"LL":return vd(ld(2,r),o);case"Lo":return vd(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 HSt(t,s,r){const n=Yn(t),a=Jje(n,r)-s;return n.setDate(n.getDate()-a*7),n}class GSt extends Ro{constructor(){super(...arguments);En(this,"priority",100);En(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","i","t","T"])}parse(r,n,a){switch(n){case"w":return Rc(yd.week,r);case"wo":return a.ordinalNumber(r,{unit:"week"});default:return ld(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a,o){return zh(HSt(r,a,o),o)}}function WSt(t,s){const r=Yn(t),n=Xje(r)-s;return r.setDate(r.getDate()-n*7),r}class KSt extends Ro{constructor(){super(...arguments);En(this,"priority",100);En(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 Rc(yd.week,r);case"Io":return a.ordinalNumber(r,{unit:"week"});default:return ld(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a){return x1(WSt(r,a))}}const ZSt=[31,28,31,30,31,30,31,31,30,31,30,31],YSt=[31,29,31,30,31,30,31,31,30,31,30,31];class XSt extends Ro{constructor(){super(...arguments);En(this,"priority",90);En(this,"subPriority",1);En(this,"incompatibleTokens",["Y","R","q","Q","w","I","D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"d":return Rc(yd.date,r);case"do":return a.ordinalNumber(r,{unit:"date"});default:return ld(n.length,r)}}validate(r,n){const a=r.getFullYear(),o=VWe(a),l=r.getMonth();return o?n>=1&&n<=YSt[l]:n>=1&&n<=ZSt[l]}set(r,n,a){return r.setDate(a),r.setHours(0,0,0,0),r}}class QSt extends Ro{constructor(){super(...arguments);En(this,"priority",90);En(this,"subpriority",1);En(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 Rc(yd.dayOfYear,r);case"Do":return a.ordinalNumber(r,{unit:"date"});default:return ld(n.length,r)}}validate(r,n){const a=r.getFullYear();return VWe(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 tNe(t,s,r){var f,y,_,b;const n=gw(),a=(r==null?void 0:r.weekStartsOn)??((y=(f=r==null?void 0:r.locale)==null?void 0:f.options)==null?void 0:y.weekStartsOn)??n.weekStartsOn??((b=(_=n.locale)==null?void 0:_.options)==null?void 0:b.weekStartsOn)??0,o=Yn(t),l=o.getDay(),d=(s%7+7)%7,u=7-a,p=s<0||s>6?s-(l+u)%7:(d+u)%7-(l+u)%7;return ml(o,p)}class JSt extends Ro{constructor(){super(...arguments);En(this,"priority",90);En(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=tNe(r,a,o),r.setHours(0,0,0,0),r}}class eCt extends Ro{constructor(){super(...arguments);En(this,"priority",90);En(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"])}parse(r,n,a,o){const l=i=>{const d=Math.floor((i-1)/7)*7;return(i+o.weekStartsOn+6)%7+d};switch(n){case"e":case"ee":return vd(ld(n.length,r),l);case"eo":return vd(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=tNe(r,a,o),r.setHours(0,0,0,0),r}}class tCt extends Ro{constructor(){super(...arguments);En(this,"priority",90);En(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"])}parse(r,n,a,o){const l=i=>{const d=Math.floor((i-1)/7)*7;return(i+o.weekStartsOn+6)%7+d};switch(n){case"c":case"cc":return vd(ld(n.length,r),l);case"co":return vd(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=tNe(r,a,o),r.setHours(0,0,0,0),r}}function sCt(t,s){const r=Yn(t),n=CSt(r),a=s-n;return ml(r,a)}class rCt extends Ro{constructor(){super(...arguments);En(this,"priority",90);En(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 ld(n.length,r);case"io":return a.ordinalNumber(r,{unit:"day"});case"iii":return vd(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 vd(a.day(r,{width:"narrow",context:"formatting"}),o);case"iiiiii":return vd(a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),o);case"iiii":default:return vd(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=sCt(r,a),r.setHours(0,0,0,0),r}}class nCt extends Ro{constructor(){super(...arguments);En(this,"priority",80);En(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(eNe(a),0,0,0),r}}class aCt extends Ro{constructor(){super(...arguments);En(this,"priority",80);En(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(eNe(a),0,0,0),r}}class iCt extends Ro{constructor(){super(...arguments);En(this,"priority",80);En(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(eNe(a),0,0,0),r}}class oCt extends Ro{constructor(){super(...arguments);En(this,"priority",70);En(this,"incompatibleTokens",["H","K","k","t","T"])}parse(r,n,a){switch(n){case"h":return Rc(yd.hour12h,r);case"ho":return a.ordinalNumber(r,{unit:"hour"});default:return ld(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 lCt extends Ro{constructor(){super(...arguments);En(this,"priority",70);En(this,"incompatibleTokens",["a","b","h","K","k","t","T"])}parse(r,n,a){switch(n){case"H":return Rc(yd.hour23h,r);case"Ho":return a.ordinalNumber(r,{unit:"hour"});default:return ld(n.length,r)}}validate(r,n){return n>=0&&n<=23}set(r,n,a){return r.setHours(a,0,0,0),r}}class cCt extends Ro{constructor(){super(...arguments);En(this,"priority",70);En(this,"incompatibleTokens",["h","H","k","t","T"])}parse(r,n,a){switch(n){case"K":return Rc(yd.hour11h,r);case"Ko":return a.ordinalNumber(r,{unit:"hour"});default:return ld(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 dCt extends Ro{constructor(){super(...arguments);En(this,"priority",70);En(this,"incompatibleTokens",["a","b","h","H","K","t","T"])}parse(r,n,a){switch(n){case"k":return Rc(yd.hour24h,r);case"ko":return a.ordinalNumber(r,{unit:"hour"});default:return ld(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 uCt extends Ro{constructor(){super(...arguments);En(this,"priority",60);En(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"m":return Rc(yd.minute,r);case"mo":return a.ordinalNumber(r,{unit:"minute"});default:return ld(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setMinutes(a,0,0),r}}class hCt extends Ro{constructor(){super(...arguments);En(this,"priority",50);En(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"s":return Rc(yd.second,r);case"so":return a.ordinalNumber(r,{unit:"second"});default:return ld(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setSeconds(a,0),r}}class mCt extends Ro{constructor(){super(...arguments);En(this,"priority",30);En(this,"incompatibleTokens",["t","T"])}parse(r,n){const a=o=>Math.trunc(o*Math.pow(10,-n.length+3));return vd(ld(n.length,r),a)}set(r,n,a){return r.setMilliseconds(a),r}}class pCt extends Ro{constructor(){super(...arguments);En(this,"priority",10);En(this,"incompatibleTokens",["t","T","x"])}parse(r,n){switch(n){case"X":return $y(By.basicOptionalMinutes,r);case"XX":return $y(By.basic,r);case"XXXX":return $y(By.basicOptionalSeconds,r);case"XXXXX":return $y(By.extendedOptionalSeconds,r);case"XXX":default:return $y(By.extended,r)}}set(r,n,a){return n.timestampIsSet?r:Wo(r,r.getTime()-Xb(r)-a)}}class fCt extends Ro{constructor(){super(...arguments);En(this,"priority",10);En(this,"incompatibleTokens",["t","T","X"])}parse(r,n){switch(n){case"x":return $y(By.basicOptionalMinutes,r);case"xx":return $y(By.basic,r);case"xxxx":return $y(By.basicOptionalSeconds,r);case"xxxxx":return $y(By.extendedOptionalSeconds,r);case"xxx":default:return $y(By.extended,r)}}set(r,n,a){return n.timestampIsSet?r:Wo(r,r.getTime()-Xb(r)-a)}}class xCt extends Ro{constructor(){super(...arguments);En(this,"priority",40);En(this,"incompatibleTokens","*")}parse(r){return qWe(r)}set(r,n,a){return[Wo(r,a*1e3),{timestampIsSet:!0}]}}class gCt extends Ro{constructor(){super(...arguments);En(this,"priority",20);En(this,"incompatibleTokens","*")}parse(r){return qWe(r)}set(r,n,a){return[Wo(r,a),{timestampIsSet:!0}]}}const yCt={G:new RSt,y:new OSt,Y:new FSt,R:new zSt,u:new BSt,Q:new $St,q:new qSt,M:new USt,L:new VSt,w:new GSt,I:new KSt,d:new XSt,D:new QSt,E:new JSt,e:new eCt,c:new tCt,i:new rCt,a:new nCt,b:new aCt,B:new iCt,h:new oCt,H:new lCt,K:new cCt,k:new dCt,m:new uCt,s:new hCt,S:new mCt,X:new pCt,x:new fCt,t:new xCt,T:new gCt},vCt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,_Ct=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,bCt=/^'([^]*?)'?$/,wCt=/''/g,jCt=/\S/,NCt=/[a-zA-Z]/;function sNe(t,s,r,n){var N,w,S,C;const a=SSt(),o=a.locale??Due,l=a.firstWeekContainsDate??((w=(N=a.locale)==null?void 0:N.options)==null?void 0:w.firstWeekContainsDate)??1,i=a.weekStartsOn??((C=(S=a.locale)==null?void 0:S.options)==null?void 0:C.weekStartsOn)??0;if(s==="")return t===""?Yn(r):Wo(r,NaN);const d={firstWeekContainsDate:l,weekStartsOn:i,locale:o},u=[new DSt],p=s.match(_Ct).map(A=>{const I=A[0];if(I in j1e){const L=j1e[I];return L(A,o.formatLong)}return A}).join("").match(vCt),f=[];for(let A of p){BWe(A)&&N1e(A,s,t),zWe(A)&&N1e(A,s,t);const I=A[0],L=yCt[I];if(L){const{incompatibleTokens:O}=L;if(Array.isArray(O)){const q=f.find(B=>O.includes(B.token)||B.token===I);if(q)throw new RangeError(`The format string mustn't contain \`${q.fullToken}\` and \`${A}\` at the same time`)}else if(L.incompatibleTokens==="*"&&f.length>0)throw new RangeError(`The format string mustn't contain \`${A}\` and any other token at the same time`);f.push({token:I,fullToken:A});const V=L.run(t,A,o.match,d);if(!V)return Wo(r,NaN);u.push(V.setter),t=V.rest}else{if(I.match(NCt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+I+"`");if(A==="''"?A="'":I==="'"&&(A=kCt(A)),t.indexOf(A)===0)t=t.slice(A.length);else return Wo(r,NaN)}}if(t.length>0&&jCt.test(t))return Wo(r,NaN);const y=u.map(A=>A.priority).sort((A,I)=>I-A).filter((A,I,L)=>L.indexOf(A)===I).map(A=>u.filter(I=>I.priority===A).sort((I,L)=>L.subPriority-I.subPriority)).map(A=>A[0]);let _=Yn(r);if(isNaN(_.getTime()))return Wo(r,NaN);const b={};for(const A of y){if(!A.validate(_,d))return Wo(r,NaN);const I=A.set(_,b,d);Array.isArray(I)?(_=I[0],Object.assign(b,I[1])):_=I}return Wo(r,_)}function kCt(t){return t.match(bCt)[1].replace(wCt,"'")}function a0(t){return+Yn(t)o-l);return r>=n&&r<=a}function qie(t,s){return ml(t,-s)}function xm(t,s){const n=PCt(t);let a;if(n.date){const d=ICt(n.date,2);a=LCt(d.restDateString,d.year)}if(!a||isNaN(a.getTime()))return new Date(NaN);const o=a.getTime();let l=0,i;if(n.time&&(l=DCt(n.time),isNaN(l)))return new Date(NaN);if(n.timezone){if(i=RCt(n.timezone),isNaN(i))return new Date(NaN)}else{const d=new Date(o+l),u=new Date(0);return u.setFullYear(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate()),u.setHours(d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds(),d.getUTCMilliseconds()),u}return new Date(o+l+i)}const Az={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},TCt=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,ACt=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,ECt=/^([+-])(\d{2})(?::?(\d{2}))?$/;function PCt(t){const s={},r=t.split(Az.dateTimeDelimiter);let n;if(r.length>2)return s;if(/:/.test(r[0])?n=r[0]:(s.date=r[0],n=r[1],Az.timeZoneDelimiter.test(s.date)&&(s.date=t.split(Az.timeZoneDelimiter)[0],n=t.substr(s.date.length,t.length))),n){const a=Az.timezone.exec(n);a?(s.time=n.replace(a[1],""),s.timezone=a[1]):s.time=n}return s}function ICt(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(TCt);if(!r)return new Date(NaN);const n=!!r[4],a=eI(r[1]),o=eI(r[2])-1,l=eI(r[3]),i=eI(r[4]),d=eI(r[5])-1;if(n)return $Ct(s,i,d)?OCt(s,i,d):new Date(NaN);{const u=new Date(0);return!zCt(s,o,l)||!BCt(s,a)?new Date(NaN):(u.setUTCFullYear(s,o,Math.max(a,l)),u)}}function eI(t){return t?parseInt(t):1}function DCt(t){const s=t.match(ACt);if(!s)return NaN;const r=_ge(s[1]),n=_ge(s[2]),a=_ge(s[3]);return qCt(r,n,a)?r*BR+n*Iue+a*1e3:NaN}function _ge(t){return t&&parseFloat(t.replace(",","."))||0}function RCt(t){if(t==="Z")return 0;const s=t.match(ECt);if(!s)return 0;const r=s[1]==="+"?-1:1,n=parseInt(s[2]),a=s[3]&&parseInt(s[3])||0;return UCt(n,a)?r*(n*BR+a*Iue):NaN}function OCt(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 FCt=[31,null,31,30,31,30,31,31,30,31,30,31];function HWe(t){return t%400===0||t%4===0&&t%100!==0}function zCt(t,s,r){return s>=0&&s<=11&&r>=1&&r<=(FCt[s]||(HWe(t)?29:28))}function BCt(t,s){return s>=1&&s<=(HWe(t)?366:365)}function $Ct(t,s,r){return s>=1&&s<=53&&r>=0&&r<=6}function qCt(t,s,r){return t===24?s===0&&r===0:r>=0&&r<60&&s>=0&&s<60&&t>=0&&t<25}function UCt(t,s){return s>=0&&s<=59}function bge(t,s){const r=Yn(t),n=r.getFullYear(),a=r.getDate(),o=Wo(t,0);o.setFullYear(n,s,15),o.setHours(0,0,0,0);const l=kSt(o);return r.setMonth(s,Math.min(a,l)),r}function QL(t,s){const r=Yn(t);return r.setHours(s),r}function JL(t,s){const r=Yn(t);return r.setMinutes(s),r}function YPe(t,s){const r=Yn(t);return isNaN(+r)?Wo(t,NaN):(r.setFullYear(s),r)}function g4(t,s){return Am(t,-s)}var jo;(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})(jo||(jo={}));var XPe;(function(t){t.mergeShapes=(s,r)=>({...s,...r})})(XPe||(XPe={}));const ca=jo.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),I_=t=>{switch(typeof t){case"undefined":return ca.undefined;case"string":return ca.string;case"number":return Number.isNaN(t)?ca.nan:ca.number;case"boolean":return ca.boolean;case"function":return ca.function;case"bigint":return ca.bigint;case"symbol":return ca.symbol;case"object":return Array.isArray(t)?ca.array:t===null?ca.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?ca.promise:typeof Map<"u"&&t instanceof Map?ca.map:typeof Set<"u"&&t instanceof Set?ca.set:typeof Date<"u"&&t instanceof Date?ca.date:ca.object;default:return ca.unknown}},en=jo.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class m0 extends Error{get errors(){return this.issues}constructor(s){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=s}format(s){const r=s||function(o){return o.message},n={_errors:[]},a=o=>{for(const l of o.issues)if(l.code==="invalid_union")l.unionErrors.map(a);else if(l.code==="invalid_return_type")a(l.returnTypeError);else if(l.code==="invalid_arguments")a(l.argumentsError);else if(l.path.length===0)n._errors.push(r(l));else{let i=n,d=0;for(;dr.message){const r={},n=[];for(const a of this.issues)if(a.path.length>0){const o=a.path[0];r[o]=r[o]||[],r[o].push(s(a))}else n.push(s(a));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}m0.create=t=>new m0(t);const k1e=(t,s)=>{let r;switch(t.code){case en.invalid_type:t.received===ca.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case en.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,jo.jsonStringifyReplacer)}`;break;case en.unrecognized_keys:r=`Unrecognized key(s) in object: ${jo.joinValues(t.keys,", ")}`;break;case en.invalid_union:r="Invalid input";break;case en.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${jo.joinValues(t.options)}`;break;case en.invalid_enum_value:r=`Invalid enum value. Expected ${jo.joinValues(t.options)}, received '${t.received}'`;break;case en.invalid_arguments:r="Invalid function arguments";break;case en.invalid_return_type:r="Invalid function return type";break;case en.invalid_date:r="Invalid date";break;case en.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}"`:jo.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case en.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 en.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 en.custom:r="Invalid input";break;case en.invalid_intersection_types:r="Intersection results could not be merged";break;case en.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case en.not_finite:r="Number must be finite";break;default:r=s.defaultError,jo.assertNever(t)}return{message:r}};let VCt=k1e;function HCt(){return VCt}const GCt=t=>{const{data:s,path:r,errorMaps:n,issueData:a}=t,o=[...r,...a.path||[]],l={...a,path:o};if(a.message!==void 0)return{...a,path:o,message:a.message};let i="";const d=n.filter(u=>!!u).slice().reverse();for(const u of d)i=u(l,{data:s,defaultError:i}).message;return{...a,path:o,message:i}};function Bn(t,s){const r=HCt(),n=GCt({issueData:s,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===k1e?void 0:k1e].filter(a=>!!a)});t.common.issues.push(n)}class gf{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 gi;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 gf.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 gi;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 gi=Object.freeze({status:"aborted"}),LI=t=>({status:"dirty",value:t}),Ix=t=>({status:"valid",value:t}),QPe=t=>t.status==="aborted",JPe=t=>t.status==="dirty",PT=t=>t.status==="valid",Joe=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 Qb{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 e6e=(t,s)=>{if(PT(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 m0(t.common.issues);return this._error=r,this._error}}};function zi(t){if(!t)return{};const{errorMap:s,invalid_type_error:r,required_error:n,description:a}=t;if(s&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return s?{errorMap:s,description:a}:{errorMap:(l,i)=>{const{message:d}=t;return l.code==="invalid_enum_value"?{message:d??i.defaultError}:typeof i.data>"u"?{message:d??n??i.defaultError}:l.code!=="invalid_type"?{message:i.defaultError}:{message:d??r??i.defaultError}},description:a}}class bo{get description(){return this._def.description}_getType(s){return I_(s.data)}_getOrReturnCtx(s,r){return r||{common:s.parent.common,data:s.data,parsedType:I_(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}_processInputParams(s){return{status:new gf,ctx:{common:s.parent.common,data:s.data,parsedType:I_(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}}_parseSync(s){const r=this._parse(s);if(Joe(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:I_(s)},a=this._parseSync({data:s,path:n.path,parent:n});return e6e(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:I_(s)};if(!this["~standard"].async)try{const o=this._parseSync({data:s,path:[],parent:r});return PT(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=>PT(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:I_(s)},a=this._parse({data:s,path:n.path,parent:n}),o=await(Joe(a)?a:Promise.resolve(a));return e6e(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:en.custom,...n(a)});return typeof Promise<"u"&&l instanceof Promise?l.then(d=>d?!0:(i(),!1)):l?!0:(i(),!1)})}refinement(s,r){return this._refinement((n,a)=>s(n)?!0:(a.addIssue(typeof r=="function"?r(n,a):r),!1))}_refinement(s){return new DT({schema:this,typeName:yi.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 Lb.create(this,this._def)}nullable(){return RT.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return i0.create(this)}promise(){return rle.create(this,this._def)}or(s){return tle.create([this,s],this._def)}and(s){return sle.create(this,s,this._def)}transform(s){return new DT({...zi(this._def),schema:this,typeName:yi.ZodEffects,effect:{type:"transform",transform:s}})}default(s){const r=typeof s=="function"?s:()=>s;return new T1e({...zi(this._def),innerType:this,defaultValue:r,typeName:yi.ZodDefault})}brand(){return new f3t({typeName:yi.ZodBranded,type:this,...zi(this._def)})}catch(s){const r=typeof s=="function"?s:()=>s;return new A1e({...zi(this._def),innerType:this,catchValue:r,typeName:yi.ZodCatch})}describe(s){const r=this.constructor;return new r({...this._def,description:s})}pipe(s){return rNe.create(this,s)}readonly(){return E1e.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const WCt=/^c[^\s-]{8,}$/i,KCt=/^[0-9a-z]+$/,ZCt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,YCt=/^[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,XCt=/^[a-z0-9_-]{21}$/i,QCt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,JCt=/^[-+]?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)?)??$/,e3t=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,t3t="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let wge;const s3t=/^(?:(?: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])$/,r3t=/^(?:(?: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])$/,n3t=/^(([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]))$/,a3t=/^(([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])$/,i3t=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,o3t=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,GWe="((\\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])))",l3t=new RegExp(`^${GWe}$`);function WWe(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 c3t(t){return new RegExp(`^${WWe(t)}$`)}function d3t(t){let s=`${GWe}T${WWe(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 u3t(t,s){return!!((s==="v4"||!s)&&s3t.test(t)||(s==="v6"||!s)&&n3t.test(t))}function h3t(t,s){if(!QCt.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 m3t(t,s){return!!((s==="v4"||!s)&&r3t.test(t)||(s==="v6"||!s)&&a3t.test(t))}class cb extends bo{_parse(s){if(this._def.coerce&&(s.data=String(s.data)),this._getType(s)!==ca.string){const o=this._getOrReturnCtx(s);return Bn(o,{code:en.invalid_type,expected:ca.string,received:o.parsedType}),gi}const n=new gf;let a;for(const o of this._def.checks)if(o.kind==="min")s.data.lengtho.value&&(a=this._getOrReturnCtx(s,a),Bn(a,{code:en.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:en.invalid_string,...ma.errToObj(n)})}_addCheck(s){return new cb({...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 cb({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new cb({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new cb({...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 cb({checks:[],typeName:yi.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...zi(t)});function p3t(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 IT extends bo{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)!==ca.number){const o=this._getOrReturnCtx(s);return Bn(o,{code:en.invalid_type,expected:ca.number,received:o.parsedType}),gi}let n;const a=new gf;for(const o of this._def.checks)o.kind==="int"?jo.isInteger(s.data)||(n=this._getOrReturnCtx(s,n),Bn(n,{code:en.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),Bn(n,{code:en.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="multipleOf"?p3t(s.data,o.value)!==0&&(n=this._getOrReturnCtx(s,n),Bn(n,{code:en.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):o.kind==="finite"?Number.isFinite(s.data)||(n=this._getOrReturnCtx(s,n),Bn(n,{code:en.not_finite,message:o.message}),a.dirty()):jo.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 IT({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:ma.toString(a)}]})}_addCheck(s){return new IT({...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"&&jo.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 IT({checks:[],typeName:yi.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...zi(t)});class aD extends bo{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)!==ca.bigint)return this._getInvalidInput(s);let n;const a=new gf;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?s.datao.value:s.data>=o.value)&&(n=this._getOrReturnCtx(s,n),Bn(n,{code:en.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),Bn(n,{code:en.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):jo.assertNever(o);return{status:a.value,value:s.data}}_getInvalidInput(s){const r=this._getOrReturnCtx(s);return Bn(r,{code:en.invalid_type,expected:ca.bigint,received:r.parsedType}),gi}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 aD({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:ma.toString(a)}]})}_addCheck(s){return new aD({...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 aD({checks:[],typeName:yi.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...zi(t)});class S1e extends bo{_parse(s){if(this._def.coerce&&(s.data=!!s.data),this._getType(s)!==ca.boolean){const n=this._getOrReturnCtx(s);return Bn(n,{code:en.invalid_type,expected:ca.boolean,received:n.parsedType}),gi}return Ix(s.data)}}S1e.create=t=>new S1e({typeName:yi.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...zi(t)});class ele extends bo{_parse(s){if(this._def.coerce&&(s.data=new Date(s.data)),this._getType(s)!==ca.date){const o=this._getOrReturnCtx(s);return Bn(o,{code:en.invalid_type,expected:ca.date,received:o.parsedType}),gi}if(Number.isNaN(s.data.getTime())){const o=this._getOrReturnCtx(s);return Bn(o,{code:en.invalid_date}),gi}const n=new gf;let a;for(const o of this._def.checks)o.kind==="min"?s.data.getTime()o.value&&(a=this._getOrReturnCtx(s,a),Bn(a,{code:en.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):jo.assertNever(o);return{status:n.value,value:new Date(s.data.getTime())}}_addCheck(s){return new ele({...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 ele({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:yi.ZodDate,...zi(t)});class t6e extends bo{_parse(s){if(this._getType(s)!==ca.symbol){const n=this._getOrReturnCtx(s);return Bn(n,{code:en.invalid_type,expected:ca.symbol,received:n.parsedType}),gi}return Ix(s.data)}}t6e.create=t=>new t6e({typeName:yi.ZodSymbol,...zi(t)});class s6e extends bo{_parse(s){if(this._getType(s)!==ca.undefined){const n=this._getOrReturnCtx(s);return Bn(n,{code:en.invalid_type,expected:ca.undefined,received:n.parsedType}),gi}return Ix(s.data)}}s6e.create=t=>new s6e({typeName:yi.ZodUndefined,...zi(t)});class r6e extends bo{_parse(s){if(this._getType(s)!==ca.null){const n=this._getOrReturnCtx(s);return Bn(n,{code:en.invalid_type,expected:ca.null,received:n.parsedType}),gi}return Ix(s.data)}}r6e.create=t=>new r6e({typeName:yi.ZodNull,...zi(t)});class n6e extends bo{constructor(){super(...arguments),this._any=!0}_parse(s){return Ix(s.data)}}n6e.create=t=>new n6e({typeName:yi.ZodAny,...zi(t)});class a6e extends bo{constructor(){super(...arguments),this._unknown=!0}_parse(s){return Ix(s.data)}}a6e.create=t=>new a6e({typeName:yi.ZodUnknown,...zi(t)});class Jb extends bo{_parse(s){const r=this._getOrReturnCtx(s);return Bn(r,{code:en.invalid_type,expected:ca.never,received:r.parsedType}),gi}}Jb.create=t=>new Jb({typeName:yi.ZodNever,...zi(t)});class i6e extends bo{_parse(s){if(this._getType(s)!==ca.undefined){const n=this._getOrReturnCtx(s);return Bn(n,{code:en.invalid_type,expected:ca.void,received:n.parsedType}),gi}return Ix(s.data)}}i6e.create=t=>new i6e({typeName:yi.ZodVoid,...zi(t)});class i0 extends bo{_parse(s){const{ctx:r,status:n}=this._processInputParams(s),a=this._def;if(r.parsedType!==ca.array)return Bn(r,{code:en.invalid_type,expected:ca.array,received:r.parsedType}),gi;if(a.exactLength!==null){const l=r.data.length>a.exactLength.value,i=r.data.lengtha.maxLength.value&&(Bn(r,{code:en.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 Qb(r,l,r.path,i)))).then(l=>gf.mergeArray(n,l));const o=[...r.data].map((l,i)=>a.type._parseSync(new Qb(r,l,r.path,i)));return gf.mergeArray(n,o)}get element(){return this._def.type}min(s,r){return new i0({...this._def,minLength:{value:s,message:ma.toString(r)}})}max(s,r){return new i0({...this._def,maxLength:{value:s,message:ma.toString(r)}})}length(s,r){return new i0({...this._def,exactLength:{value:s,message:ma.toString(r)}})}nonempty(s){return this.min(1,s)}}i0.create=(t,s)=>new i0({type:t,minLength:null,maxLength:null,exactLength:null,typeName:yi.ZodArray,...zi(s)});function P5(t){if(t instanceof Kc){const s={};for(const r in t.shape){const n=t.shape[r];s[r]=Lb.create(P5(n))}return new Kc({...t._def,shape:()=>s})}else return t instanceof i0?new i0({...t._def,type:P5(t.element)}):t instanceof Lb?Lb.create(P5(t.unwrap())):t instanceof RT?RT.create(P5(t.unwrap())):t instanceof XS?XS.create(t.items.map(s=>P5(s))):t}class Kc extends bo{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=jo.objectKeys(s);return this._cached={shape:s,keys:r},this._cached}_parse(s){if(this._getType(s)!==ca.object){const u=this._getOrReturnCtx(s);return Bn(u,{code:en.invalid_type,expected:ca.object,received:u.parsedType}),gi}const{status:n,ctx:a}=this._processInputParams(s),{shape:o,keys:l}=this._getCached(),i=[];if(!(this._def.catchall instanceof Jb&&this._def.unknownKeys==="strip"))for(const u in a.data)l.includes(u)||i.push(u);const d=[];for(const u of l){const p=o[u],f=a.data[u];d.push({key:{status:"valid",value:u},value:p._parse(new Qb(a,f,a.path,u)),alwaysSet:u in a.data})}if(this._def.catchall instanceof Jb){const u=this._def.unknownKeys;if(u==="passthrough")for(const p of i)d.push({key:{status:"valid",value:p},value:{status:"valid",value:a.data[p]}});else if(u==="strict")i.length>0&&(Bn(a,{code:en.unrecognized_keys,keys:i}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const p of i){const f=a.data[p];d.push({key:{status:"valid",value:p},value:u._parse(new Qb(a,f,a.path,p)),alwaysSet:p in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const u=[];for(const p of d){const f=await p.key,y=await p.value;u.push({key:f,value:y,alwaysSet:p.alwaysSet})}return u}).then(u=>gf.mergeObjectSync(n,u)):gf.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(s){return ma.errToObj,new Kc({...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 Kc({...this._def,unknownKeys:"strip"})}passthrough(){return new Kc({...this._def,unknownKeys:"passthrough"})}extend(s){return new Kc({...this._def,shape:()=>({...this._def.shape(),...s})})}merge(s){return new Kc({unknownKeys:s._def.unknownKeys,catchall:s._def.catchall,shape:()=>({...this._def.shape(),...s._def.shape()}),typeName:yi.ZodObject})}setKey(s,r){return this.augment({[s]:r})}catchall(s){return new Kc({...this._def,catchall:s})}pick(s){const r={};for(const n of jo.objectKeys(s))s[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new Kc({...this._def,shape:()=>r})}omit(s){const r={};for(const n of jo.objectKeys(this.shape))s[n]||(r[n]=this.shape[n]);return new Kc({...this._def,shape:()=>r})}deepPartial(){return P5(this)}partial(s){const r={};for(const n of jo.objectKeys(this.shape)){const a=this.shape[n];s&&!s[n]?r[n]=a:r[n]=a.optional()}return new Kc({...this._def,shape:()=>r})}required(s){const r={};for(const n of jo.objectKeys(this.shape))if(s&&!s[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof Lb;)o=o._def.innerType;r[n]=o}return new Kc({...this._def,shape:()=>r})}keyof(){return KWe(jo.objectKeys(this.shape))}}Kc.create=(t,s)=>new Kc({shape:()=>t,unknownKeys:"strip",catchall:Jb.create(),typeName:yi.ZodObject,...zi(s)});Kc.strictCreate=(t,s)=>new Kc({shape:()=>t,unknownKeys:"strict",catchall:Jb.create(),typeName:yi.ZodObject,...zi(s)});Kc.lazycreate=(t,s)=>new Kc({shape:t,unknownKeys:"strip",catchall:Jb.create(),typeName:yi.ZodObject,...zi(s)});class tle extends bo{_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 m0(i.ctx.common.issues));return Bn(r,{code:en.invalid_union,unionErrors:l}),gi}if(r.common.async)return Promise.all(n.map(async o=>{const l={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:l}),ctx:l}})).then(a);{let o;const l=[];for(const d of n){const u={...r,common:{...r.common,issues:[]},parent:null},p=d._parseSync({data:r.data,path:r.path,parent:u});if(p.status==="valid")return p;p.status==="dirty"&&!o&&(o={result:p,ctx:u}),u.common.issues.length&&l.push(u.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;const i=l.map(d=>new m0(d));return Bn(r,{code:en.invalid_union,unionErrors:i}),gi}}get options(){return this._def.options}}tle.create=(t,s)=>new tle({options:t,typeName:yi.ZodUnion,...zi(s)});function C1e(t,s){const r=I_(t),n=I_(s);if(t===s)return{valid:!0,data:t};if(r===ca.object&&n===ca.object){const a=jo.objectKeys(s),o=jo.objectKeys(t).filter(i=>a.indexOf(i)!==-1),l={...t,...s};for(const i of o){const d=C1e(t[i],s[i]);if(!d.valid)return{valid:!1};l[i]=d.data}return{valid:!0,data:l}}else if(r===ca.array&&n===ca.array){if(t.length!==s.length)return{valid:!1};const a=[];for(let o=0;o{if(QPe(o)||QPe(l))return gi;const i=C1e(o.value,l.value);return i.valid?((JPe(o)||JPe(l))&&r.dirty(),{status:r.value,value:i.data}):(Bn(n,{code:en.invalid_intersection_types}),gi)};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}))}}sle.create=(t,s,r)=>new sle({left:t,right:s,typeName:yi.ZodIntersection,...zi(r)});class XS extends bo{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==ca.array)return Bn(n,{code:en.invalid_type,expected:ca.array,received:n.parsedType}),gi;if(n.data.lengththis._def.items.length&&(Bn(n,{code:en.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const o=[...n.data].map((l,i)=>{const d=this._def.items[i]||this._def.rest;return d?d._parse(new Qb(n,l,n.path,i)):null}).filter(l=>!!l);return n.common.async?Promise.all(o).then(l=>gf.mergeArray(r,l)):gf.mergeArray(r,o)}get items(){return this._def.items}rest(s){return new XS({...this._def,rest:s})}}XS.create=(t,s)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new XS({items:t,typeName:yi.ZodTuple,rest:null,...zi(s)})};class o6e extends bo{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!==ca.map)return Bn(n,{code:en.invalid_type,expected:ca.map,received:n.parsedType}),gi;const a=this._def.keyType,o=this._def.valueType,l=[...n.data.entries()].map(([i,d],u)=>({key:a._parse(new Qb(n,i,n.path,[u,"key"])),value:o._parse(new Qb(n,d,n.path,[u,"value"]))}));if(n.common.async){const i=new Map;return Promise.resolve().then(async()=>{for(const d of l){const u=await d.key,p=await d.value;if(u.status==="aborted"||p.status==="aborted")return gi;(u.status==="dirty"||p.status==="dirty")&&r.dirty(),i.set(u.value,p.value)}return{status:r.value,value:i}})}else{const i=new Map;for(const d of l){const u=d.key,p=d.value;if(u.status==="aborted"||p.status==="aborted")return gi;(u.status==="dirty"||p.status==="dirty")&&r.dirty(),i.set(u.value,p.value)}return{status:r.value,value:i}}}}o6e.create=(t,s,r)=>new o6e({valueType:s,keyType:t,typeName:yi.ZodMap,...zi(r)});class iD extends bo{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==ca.set)return Bn(n,{code:en.invalid_type,expected:ca.set,received:n.parsedType}),gi;const a=this._def;a.minSize!==null&&n.data.sizea.maxSize.value&&(Bn(n,{code:en.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),r.dirty());const o=this._def.valueType;function l(d){const u=new Set;for(const p of d){if(p.status==="aborted")return gi;p.status==="dirty"&&r.dirty(),u.add(p.value)}return{status:r.value,value:u}}const i=[...n.data.values()].map((d,u)=>o._parse(new Qb(n,d,n.path,u)));return n.common.async?Promise.all(i).then(d=>l(d)):l(i)}min(s,r){return new iD({...this._def,minSize:{value:s,message:ma.toString(r)}})}max(s,r){return new iD({...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)}}iD.create=(t,s)=>new iD({valueType:t,minSize:null,maxSize:null,typeName:yi.ZodSet,...zi(s)});class l6e extends bo{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})}}l6e.create=(t,s)=>new l6e({getter:t,typeName:yi.ZodLazy,...zi(s)});class M1e extends bo{_parse(s){if(s.data!==this._def.value){const r=this._getOrReturnCtx(s);return Bn(r,{received:r.data,code:en.invalid_literal,expected:this._def.value}),gi}return{status:"valid",value:s.data}}get value(){return this._def.value}}M1e.create=(t,s)=>new M1e({value:t,typeName:yi.ZodLiteral,...zi(s)});function KWe(t,s){return new LT({values:t,typeName:yi.ZodEnum,...zi(s)})}class LT extends bo{_parse(s){if(typeof s.data!="string"){const r=this._getOrReturnCtx(s),n=this._def.values;return Bn(r,{expected:jo.joinValues(n),received:r.parsedType,code:en.invalid_type}),gi}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 Bn(r,{received:r.data,code:en.invalid_enum_value,options:n}),gi}return Ix(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 LT.create(s,{...this._def,...r})}exclude(s,r=this._def){return LT.create(this.options.filter(n=>!s.includes(n)),{...this._def,...r})}}LT.create=KWe;class c6e extends bo{_parse(s){const r=jo.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(s);if(n.parsedType!==ca.string&&n.parsedType!==ca.number){const a=jo.objectValues(r);return Bn(n,{expected:jo.joinValues(a),received:n.parsedType,code:en.invalid_type}),gi}if(this._cache||(this._cache=new Set(jo.getValidEnumValues(this._def.values))),!this._cache.has(s.data)){const a=jo.objectValues(r);return Bn(n,{received:n.data,code:en.invalid_enum_value,options:a}),gi}return Ix(s.data)}get enum(){return this._def.values}}c6e.create=(t,s)=>new c6e({values:t,typeName:yi.ZodNativeEnum,...zi(s)});class rle extends bo{unwrap(){return this._def.type}_parse(s){const{ctx:r}=this._processInputParams(s);if(r.parsedType!==ca.promise&&r.common.async===!1)return Bn(r,{code:en.invalid_type,expected:ca.promise,received:r.parsedType}),gi;const n=r.parsedType===ca.promise?r.data:Promise.resolve(r.data);return Ix(n.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}}rle.create=(t,s)=>new rle({type:t,typeName:yi.ZodPromise,...zi(s)});class DT extends bo{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===yi.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=>{Bn(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 gi;const d=await this._def.schema._parseAsync({data:i,path:n.path,parent:n});return d.status==="aborted"?gi:d.status==="dirty"||r.value==="dirty"?LI(d.value):d});{if(r.value==="aborted")return gi;const i=this._def.schema._parseSync({data:l,path:n.path,parent:n});return i.status==="aborted"?gi:i.status==="dirty"||r.value==="dirty"?LI(i.value):i}}if(a.type==="refinement"){const l=i=>{const d=a.refinement(i,o);if(n.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?gi:(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"?gi:(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(!PT(l))return gi;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=>PT(l)?Promise.resolve(a.transform(l.value,o)).then(i=>({status:r.value,value:i})):gi);jo.assertNever(a)}}DT.create=(t,s,r)=>new DT({schema:t,typeName:yi.ZodEffects,effect:s,...zi(r)});DT.createWithPreprocess=(t,s,r)=>new DT({schema:s,effect:{type:"preprocess",transform:t},typeName:yi.ZodEffects,...zi(r)});class Lb extends bo{_parse(s){return this._getType(s)===ca.undefined?Ix(void 0):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}Lb.create=(t,s)=>new Lb({innerType:t,typeName:yi.ZodOptional,...zi(s)});class RT extends bo{_parse(s){return this._getType(s)===ca.null?Ix(null):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}RT.create=(t,s)=>new RT({innerType:t,typeName:yi.ZodNullable,...zi(s)});class T1e extends bo{_parse(s){const{ctx:r}=this._processInputParams(s);let n=r.data;return r.parsedType===ca.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}T1e.create=(t,s)=>new T1e({innerType:t,typeName:yi.ZodDefault,defaultValue:typeof s.default=="function"?s.default:()=>s.default,...zi(s)});class A1e extends bo{_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 Joe(a)?a.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new m0(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new m0(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}A1e.create=(t,s)=>new A1e({innerType:t,typeName:yi.ZodCatch,catchValue:typeof s.catch=="function"?s.catch:()=>s.catch,...zi(s)});class d6e extends bo{_parse(s){if(this._getType(s)!==ca.nan){const n=this._getOrReturnCtx(s);return Bn(n,{code:en.invalid_type,expected:ca.nan,received:n.parsedType}),gi}return{status:"valid",value:s.data}}}d6e.create=t=>new d6e({typeName:yi.ZodNaN,...zi(t)});class f3t extends bo{_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 rNe extends bo{_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"?gi:o.status==="dirty"?(r.dirty(),LI(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"?gi: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 rNe({in:s,out:r,typeName:yi.ZodPipeline})}}class E1e extends bo{_parse(s){const r=this._def.innerType._parse(s),n=a=>(PT(a)&&(a.value=Object.freeze(a.value)),a);return Joe(r)?r.then(a=>n(a)):n(r)}unwrap(){return this._def.innerType}}E1e.create=(t,s)=>new E1e({innerType:t,typeName:yi.ZodReadonly,...zi(s)});Kc.lazycreate;var yi;(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"})(yi||(yi={}));const Xl=cb.create,e8=IT.create,x3t=S1e.create;Jb.create;i0.create;const kC=Kc.create;Kc.strictCreate;tle.create;sle.create;XS.create;const nle=M1e.create,ZWe=LT.create;rle.create;Lb.create;RT.create;const _r=k.forwardRef(({className:t,...s},r)=>e.jsx("textarea",{className:Ot("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}));_r.displayName="Textarea";const g3t=["Excellent","Good","Neutral","Bad","Very Bad"],y3t=[5,4,3,2,1];function v3t({questions:t,visitorId:s,onComplete:r,onSkip:n}){const a=a4t(),[o,l]=k.useState({}),i=t.filter(y=>y.question_type==="rating"),d=t.filter(y=>y.question_type!=="rating"),u=(y,_)=>{l(b=>({...b,[y]:{rating_value:_}}))},p=(y,_)=>{l(b=>({...b,[y]:{text_value:_}}))},f=async()=>{const y=Object.entries(o).filter(([,_])=>_.rating_value!=null||_.text_value&&_.text_value.trim()).map(([_,b])=>{var N;return{visitor_id:s,question_id:_,rating_value:b.rating_value??null,text_value:((N=b.text_value)==null?void 0:N.trim())||null}});if(y.length>0)try{await a.mutateAsync(y)}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"}),g3t.map(y=>e.jsx("div",{className:"w-12 text-center",children:e.jsx("span",{className:"text-[10px] text-slate-400 leading-tight block",children:y})},y))]}),i.map(y=>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:y.question_text}),y3t.map(_=>{var b;return e.jsx("div",{className:"w-12 flex justify-center",children:e.jsx("button",{type:"button",onClick:()=>u(y.id,_),className:`w-6 h-6 rounded-full border-2 transition-all ${((b=o[y.id])==null?void 0:b.rating_value)===_?"bg-slate-900 border-slate-900":"border-slate-300 hover:border-slate-500"}`})},_)})]},y.id))]}),d.map(y=>{var _;return e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-slate-700 block mb-1",children:y.question_text}),e.jsx(_r,{value:((_=o[y.id])==null?void 0:_.text_value)||"",onChange:b=>p(y.id,b.target.value),placeholder:"Your thoughts...",className:"h-16 text-sm resize-none rounded-xl border-slate-200"})]},y.id)}),e.jsx(W,{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(us,{className:"h-5 w-5 animate-spin"}):"Submit Feedback"})]})}const _3t=kC({first_name:Xl().trim().min(1,"First name is required").max(50),last_name:Xl().trim().max(50).optional(),email:Xl().trim().email("Please enter a valid email").max(255).optional().or(nle("")),phone:Xl().trim().max(20).optional().or(nle(""))}),b3t=[{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 YWe({slug:t}={}){var ve;const s=io(),r=t||s.slug,{data:n,isLoading:a,error:o}=s4t(r),l=u4t(),i=h4t(),d=m4t(),u=k.useRef(!1),[p,f]=k.useState("welcome"),[y,_]=k.useState(null),[b,N]=k.useState({first_name:"",last_name:"",email:"",phone:""}),[w,S]=k.useState(""),[C,A]=k.useState(!1),[I,L]=k.useState(!1),[O,V]=k.useState(""),[q,B]=k.useState(""),{data:U,isLoading:te}=n4t(n==null?void 0:n.id),Y=!!(n!=null&&n.enable_survey),J=(n==null?void 0:n.ask_visitor_intent)!==!1;k.useEffect(()=>{if(!r||!(n!=null&&n.id)||u.current)return;const he=`oh_scan_${n.id}`;if(sessionStorage.getItem(he)){u.current=!0;return}u.current=!0,sessionStorage.setItem(he,"1"),d.mutate(r)},[r,n==null?void 0:n.id]),k.useEffect(()=>{p==="pending_survey"&&(te||f(Y&&((U==null?void 0:U.length)??0)>0?"survey":"done"))},[p,te,Y,U]);const X=he=>{if(!he)return"";const[ge,je]=he.split(":"),qe=parseInt(ge),Me=qe>=12?"PM":"AM";return`${qe>12?qe-12:qe||12}:${je} ${Me}`},ce=async()=>{B("");const he=_3t.safeParse(b);if(!he.success){B(he.error.issues[0].message);return}if(!b.email&&!b.phone){B("Please provide either an email or phone number");return}if(!y&&(n!=null&&n.id))try{const ge=await l.mutateAsync({open_house_id:n.id,first_name:b.first_name.trim(),last_name:b.last_name.trim()||void 0,email:b.email.trim()||void 0,phone:b.phone.trim()||void 0,wants_market_updates:C,has_agent:I,working_with_agent_name:I&&O.trim()?O.trim():void 0,partial_signin:J});_(ge.id)}catch{}if(!J){Y?!te&&U&&U.length>0?f("survey"):f("pending_survey"):f("done");return}f("intent")},ie=async he=>{S(he);try{let ge=y;ge?await i.mutateAsync({visitor_id:ge,visitor_intent:he,wants_market_updates:C,has_agent:I,working_with_agent_name:I&&O.trim()?O.trim():null,partial_signin:!1}):(ge=(await l.mutateAsync({open_house_id:n.id,first_name:b.first_name.trim(),last_name:b.last_name.trim()||void 0,email:b.email.trim()||void 0,phone:b.phone.trim()||void 0,visitor_intent:he,wants_market_updates:C,has_agent:I,working_with_agent_name:I&&O.trim()?O.trim():void 0,partial_signin:!1})).id,_(ge)),Y?!te&&U&&U.length>0?f("survey"):f("pending_survey"):f("done")}catch{B("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(Mn,{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 ae=n.profiles,oe=((ve=ae==null?void 0:ae.name)==null?void 0:ve.split(" ").map(he=>he[0]).join("").slice(0,2))||"?",me=n.event_type==="community";return e.jsxs(e.Fragment,{children:[e.jsxs(kl,{children:[e.jsxs("title",{children:[me?"Community Event":"Open House"," | ",n.property_address]}),e.jsx("meta",{name:"description",content:`Sign in to the ${me?"community event":"open house"} at ${n.property_address}`}),e.jsx("meta",{name:"robots",content:"noindex, nofollow"})]}),e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsxs(Nn,{className:"h-16 w-16 mx-auto mb-3 ring-2 ring-white/20",children:[e.jsx(Ma,{src:(ae==null?void 0:ae.avatar_url)||"",alt:(ae==null?void 0:ae.name)||""}),e.jsx(kn,{className:"bg-white/10 text-white text-lg",children:oe})]}),e.jsx("p",{className:"text-white/60 text-sm",children:ae==null?void 0:ae.name}),(ae==null?void 0:ae.title)&&e.jsx("p",{className:"text-white/40 text-xs",children:ae.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(Ia,{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(cn,{className:"h-3 w-3"}),vs(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(nn,{className:"h-3 w-3"}),X(n.start_time),n.end_time?` – ${X(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:me?e.jsx(pa,{className:"h-5 w-5 text-white"}):e.jsx(Mn,{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(Ia,{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(cn,{className:"h-3 w-3"}),vs(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(nn,{className:"h-3 w-3"}),X(n.start_time),n.end_time?` – ${X(n.end_time)}`:""]})]})]})]})}),e.jsxs("div",{className:"p-6",children:[p==="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(W,{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(Wa,{className:"h-5 w-5 ml-2"})]}),e.jsx("p",{className:"text-xs text-slate-400",children:"Quick & easy — takes 30 seconds"})]}),p==="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(Oa,{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(xe,{className:"text-slate-600 text-xs",children:"First Name *"}),e.jsx(De,{value:b.first_name,onChange:he=>N(ge=>({...ge,first_name:he.target.value})),placeholder:"First",className:"mt-1 h-12 rounded-xl border-slate-200 text-base",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-slate-600 text-xs",children:"Last Name"}),e.jsx(De,{value:b.last_name,onChange:he=>N(ge=>({...ge,last_name:he.target.value})),placeholder:"Last",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-slate-600 text-xs",children:"Email"}),e.jsx(De,{type:"email",value:b.email,onChange:he=>N(ge=>({...ge,email:he.target.value})),placeholder:"your@email.com",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-slate-600 text-xs",children:"Phone"}),e.jsx(De,{type:"tel",value:b.phone,onChange:he=>N(ge=>({...ge,phone:he.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:C,onChange:he=>A(he.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(Ar,{checked:I,onCheckedChange:L})]})]}),I&&e.jsx(De,{value:O,onChange:he=>V(he.target.value),placeholder:"Agent's name",className:"mt-1 h-10 rounded-xl border-slate-200 text-sm"})]}),q&&e.jsx("p",{className:"text-destructive text-sm",children:q}),e.jsxs(W,{onClick:ce,className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Continue ",e.jsx(Wa,{className:"h-5 w-5 ml-2"})]})]}),p==="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(Oa,{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:b3t.map(he=>e.jsxs("button",{onClick:()=>ie(he.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:he.emoji}),e.jsx("span",{className:"text-sm font-medium text-slate-700 group-hover:text-slate-900",children:he.label})]},he.value))}),q&&e.jsx("p",{className:"text-destructive text-sm text-center",children:q})]}),p==="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..."})]}),p==="survey"&&y&&U&&e.jsx(v3t,{questions:U,visitorId:y,onComplete:()=>f("done"),onSkip:()=>f("done")}),p==="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($n,{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, ",b.first_name,". ",me?"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(vn,{className:"h-4 w-4"}),"View Seller's Disclosures"]}),(ae==null?void 0:ae.name)&&e.jsxs("p",{className:"text-sm text-slate-400",children:["Your host today: ",e.jsx("strong",{className:"text-slate-600",children:ae.name})]})]})]})]}),e.jsx("p",{className:"text-center text-white/30 text-xs mt-6",children:"Powered by LevelUp Guest Book"})]})})]})}function nAs(t){const{user:s}=Us();return gt({queryKey:["cohost-tokens",t],queryFn:async()=>{const{data:r,error:n}=await G.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 aAs(){const t=Qt(),{user:s}=Us();return Pt({mutationFn:async({openHouseId:r,label:n})=>{const{data:a,error:o}=await G.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 iAs(){const t=Qt();return Pt({mutationFn:async({id:s,openHouseId:r})=>{const{error:n}=await G.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 w3t(t){return gt({queryKey:["cohost-validate",t],queryFn:async()=>{const{data:s,error:r}=await G.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 nNe="ScrollArea",[XWe,oAs]=qc(nNe),[N3t,Lx]=XWe(nNe),QWe=k.forwardRef((t,s)=>{const{__scopeScrollArea:r,type:n="hover",dir:a,scrollHideDelay:o=600,...l}=t,[i,d]=k.useState(null),[u,p]=k.useState(null),[f,y]=k.useState(null),[_,b]=k.useState(null),[N,w]=k.useState(null),[S,C]=k.useState(0),[A,I]=k.useState(0),[L,O]=k.useState(!1),[V,q]=k.useState(!1),B=Ta(s,te=>d(te)),U=mw(a);return e.jsx(N3t,{scope:r,type:n,dir:U,scrollHideDelay:o,scrollArea:i,viewport:u,onViewportChange:p,content:f,onContentChange:y,scrollbarX:_,onScrollbarXChange:b,scrollbarXEnabled:L,onScrollbarXEnabledChange:O,scrollbarY:N,onScrollbarYChange:w,scrollbarYEnabled:V,onScrollbarYEnabledChange:q,onCornerWidthChange:C,onCornerHeightChange:I,children:e.jsx(Jr.div,{dir:U,...l,ref:B,style:{position:"relative","--radix-scroll-area-corner-width":S+"px","--radix-scroll-area-corner-height":A+"px",...t.style}})})});QWe.displayName=nNe;var JWe="ScrollAreaViewport",eKe=k.forwardRef((t,s)=>{const{__scopeScrollArea:r,children:n,nonce:a,...o}=t,l=Lx(JWe,r),i=k.useRef(null),d=Ta(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(Jr.div,{"data-radix-scroll-area-viewport":"",...o,ref:d,style:{overflowX:l.scrollbarXEnabled?"scroll":"hidden",overflowY:l.scrollbarYEnabled?"scroll":"hidden",...t.style},children:e.jsx("div",{ref:l.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});eKe.displayName=JWe;var N0="ScrollAreaScrollbar",aNe=k.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Lx(N0,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(k3t,{...n,ref:s,forceMount:r}):a.type==="scroll"?e.jsx(S3t,{...n,ref:s,forceMount:r}):a.type==="auto"?e.jsx(tKe,{...n,ref:s,forceMount:r}):a.type==="always"?e.jsx(iNe,{...n,ref:s}):null});aNe.displayName=N0;var k3t=k.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Lx(N0,t.__scopeScrollArea),[o,l]=k.useState(!1);return k.useEffect(()=>{const i=a.scrollArea;let d=0;if(i){const u=()=>{window.clearTimeout(d),l(!0)},p=()=>{d=window.setTimeout(()=>l(!1),a.scrollHideDelay)};return i.addEventListener("pointerenter",u),i.addEventListener("pointerleave",p),()=>{window.clearTimeout(d),i.removeEventListener("pointerenter",u),i.removeEventListener("pointerleave",p)}}},[a.scrollArea,a.scrollHideDelay]),e.jsx(jd,{present:r||o,children:e.jsx(tKe,{"data-state":o?"visible":"hidden",...n,ref:s})})}),S3t=k.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Lx(N0,t.__scopeScrollArea),o=t.orientation==="horizontal",l=Fue(()=>d("SCROLL_END"),100),[i,d]=j3t("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(()=>d("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(u)}},[i,a.scrollHideDelay,d]),k.useEffect(()=>{const u=a.viewport,p=o?"scrollLeft":"scrollTop";if(u){let f=u[p];const y=()=>{const _=u[p];f!==_&&(d("SCROLL"),l()),f=_};return u.addEventListener("scroll",y),()=>u.removeEventListener("scroll",y)}},[a.viewport,o,d,l]),e.jsx(jd,{present:r||i!=="hidden",children:e.jsx(iNe,{"data-state":i==="hidden"?"hidden":"visible",...n,ref:s,onPointerEnter:Mr(t.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:Mr(t.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),tKe=k.forwardRef((t,s)=>{const r=Lx(N0,t.__scopeScrollArea),{forceMount:n,...a}=t,[o,l]=k.useState(!1),i=t.orientation==="horizontal",d=Fue(()=>{if(r.viewport){const u=r.viewport.offsetWidth{const{orientation:r="vertical",...n}=t,a=Lx(N0,t.__scopeScrollArea),o=k.useRef(null),l=k.useRef(0),[i,d]=k.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=iKe(i.viewport,i.content),p={...n,sizes:i,onSizesChange:d,hasThumb:u>0&&u<1,onThumbChange:y=>o.current=y,onThumbPointerUp:()=>l.current=0,onThumbPointerDown:y=>l.current=y};function f(y,_){return P3t(y,l.current,i,_)}return r==="horizontal"?e.jsx(C3t,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const y=a.viewport.scrollLeft,_=u6e(y,i,a.dir);o.current.style.transform=`translate3d(${_}px, 0, 0)`}},onWheelScroll:y=>{a.viewport&&(a.viewport.scrollLeft=y)},onDragScroll:y=>{a.viewport&&(a.viewport.scrollLeft=f(y,a.dir))}}):r==="vertical"?e.jsx(M3t,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const y=a.viewport.scrollTop,_=u6e(y,i);o.current.style.transform=`translate3d(0, ${_}px, 0)`}},onWheelScroll:y=>{a.viewport&&(a.viewport.scrollTop=y)},onDragScroll:y=>{a.viewport&&(a.viewport.scrollTop=f(y))}}):null}),C3t=k.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=Lx(N0,t.__scopeScrollArea),[l,i]=k.useState(),d=k.useRef(null),u=Ta(s,d,o.onScrollbarXChange);return k.useEffect(()=>{d.current&&i(getComputedStyle(d.current))},[d]),e.jsx(rKe,{"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":Oue(r)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.x),onDragScroll:p=>t.onDragScroll(p.x),onWheelScroll:(p,f)=>{if(o.viewport){const y=o.viewport.scrollLeft+p.deltaX;t.onWheelScroll(y),lKe(y,f)&&p.preventDefault()}},onResize:()=>{d.current&&o.viewport&&l&&n({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:ile(l.paddingLeft),paddingEnd:ile(l.paddingRight)}})}})}),M3t=k.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=Lx(N0,t.__scopeScrollArea),[l,i]=k.useState(),d=k.useRef(null),u=Ta(s,d,o.onScrollbarYChange);return k.useEffect(()=>{d.current&&i(getComputedStyle(d.current))},[d]),e.jsx(rKe,{"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":Oue(r)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.y),onDragScroll:p=>t.onDragScroll(p.y),onWheelScroll:(p,f)=>{if(o.viewport){const y=o.viewport.scrollTop+p.deltaY;t.onWheelScroll(y),lKe(y,f)&&p.preventDefault()}},onResize:()=>{d.current&&o.viewport&&l&&n({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:ile(l.paddingTop),paddingEnd:ile(l.paddingBottom)}})}})}),[T3t,sKe]=XWe(N0),rKe=k.forwardRef((t,s)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:a,onThumbChange:o,onThumbPointerUp:l,onThumbPointerDown:i,onThumbPositionChange:d,onDragScroll:u,onWheelScroll:p,onResize:f,...y}=t,_=Lx(N0,r),[b,N]=k.useState(null),w=Ta(s,B=>N(B)),S=k.useRef(null),C=k.useRef(""),A=_.viewport,I=n.content-n.viewport,L=ed(p),O=ed(d),V=Fue(f,10);function q(B){if(S.current){const U=B.clientX-S.current.left,te=B.clientY-S.current.top;u({x:U,y:te})}}return k.useEffect(()=>{const B=U=>{const te=U.target;(b==null?void 0:b.contains(te))&&L(U,I)};return document.addEventListener("wheel",B,{passive:!1}),()=>document.removeEventListener("wheel",B,{passive:!1})},[A,b,I,L]),k.useEffect(O,[n,O]),OT(b,V),OT(_.content,V),e.jsx(T3t,{scope:r,scrollbar:b,hasThumb:a,onThumbChange:ed(o),onThumbPointerUp:ed(l),onThumbPositionChange:O,onThumbPointerDown:ed(i),children:e.jsx(Jr.div,{...y,ref:w,style:{position:"absolute",...y.style},onPointerDown:Mr(t.onPointerDown,B=>{B.button===0&&(B.target.setPointerCapture(B.pointerId),S.current=b.getBoundingClientRect(),C.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",_.viewport&&(_.viewport.style.scrollBehavior="auto"),q(B))}),onPointerMove:Mr(t.onPointerMove,q),onPointerUp:Mr(t.onPointerUp,B=>{const U=B.target;U.hasPointerCapture(B.pointerId)&&U.releasePointerCapture(B.pointerId),document.body.style.webkitUserSelect=C.current,_.viewport&&(_.viewport.style.scrollBehavior=""),S.current=null})})})}),ale="ScrollAreaThumb",nKe=k.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=sKe(ale,t.__scopeScrollArea);return e.jsx(jd,{present:r||a.hasThumb,children:e.jsx(A3t,{ref:s,...n})})}),A3t=k.forwardRef((t,s)=>{const{__scopeScrollArea:r,style:n,...a}=t,o=Lx(ale,r),l=sKe(ale,r),{onThumbPositionChange:i}=l,d=Ta(s,f=>l.onThumbChange(f)),u=k.useRef(void 0),p=Fue(()=>{u.current&&(u.current(),u.current=void 0)},100);return k.useEffect(()=>{const f=o.viewport;if(f){const y=()=>{if(p(),!u.current){const _=I3t(f,i);u.current=_,i()}};return i(),f.addEventListener("scroll",y),()=>f.removeEventListener("scroll",y)}},[o.viewport,p,i]),e.jsx(Jr.div,{"data-state":l.hasThumb?"visible":"hidden",...a,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:Mr(t.onPointerDownCapture,f=>{const _=f.target.getBoundingClientRect(),b=f.clientX-_.left,N=f.clientY-_.top;l.onThumbPointerDown({x:b,y:N})}),onPointerUp:Mr(t.onPointerUp,l.onThumbPointerUp)})});nKe.displayName=ale;var oNe="ScrollAreaCorner",aKe=k.forwardRef((t,s)=>{const r=Lx(oNe,t.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?e.jsx(E3t,{...t,ref:s}):null});aKe.displayName=oNe;var E3t=k.forwardRef((t,s)=>{const{__scopeScrollArea:r,...n}=t,a=Lx(oNe,r),[o,l]=k.useState(0),[i,d]=k.useState(0),u=!!(o&&i);return OT(a.scrollbarX,()=>{var f;const p=((f=a.scrollbarX)==null?void 0:f.offsetHeight)||0;a.onCornerHeightChange(p),d(p)}),OT(a.scrollbarY,()=>{var f;const p=((f=a.scrollbarY)==null?void 0:f.offsetWidth)||0;a.onCornerWidthChange(p),l(p)}),u?e.jsx(Jr.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 ile(t){return t?parseInt(t,10):0}function iKe(t,s){const r=t/s;return isNaN(r)?0:r}function Oue(t){const s=iKe(t.viewport,t.content),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=(t.scrollbar.size-r)*s;return Math.max(n,18)}function P3t(t,s,r,n="ltr"){const a=Oue(r),o=a/2,l=s||o,i=a-l,d=r.scrollbar.paddingStart+l,u=r.scrollbar.size-r.scrollbar.paddingEnd-i,p=r.content-r.viewport,f=n==="ltr"?[0,p]:[p*-1,0];return oKe([d,u],f)(t)}function u6e(t,s,r="ltr"){const n=Oue(s),a=s.scrollbar.paddingStart+s.scrollbar.paddingEnd,o=s.scrollbar.size-a,l=s.content-s.viewport,i=o-n,d=r==="ltr"?[0,l]:[l*-1,0],u=nD(t,d);return oKe([0,l],[0,i])(u)}function oKe(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 lKe(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 Fue(t,s){const r=ed(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 OT(t,s){const r=ed(s);od(()=>{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 cKe=QWe,L3t=eKe,D3t=aKe;const Ja=k.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(cKe,{ref:n,className:Ot("relative overflow-hidden",t),...r,children:[e.jsx(L3t,{className:"h-full w-full rounded-[inherit]",children:s}),e.jsx(zue,{}),e.jsx(D3t,{})]}));Ja.displayName=cKe.displayName;const zue=k.forwardRef(({className:t,orientation:s="vertical",...r},n)=>e.jsx(aNe,{ref:n,orientation:s,className:Ot("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(nKe,{className:"relative flex-1 rounded-full bg-border"})}));zue.displayName=aNe.displayName;const lNe=k.createContext({});function cNe(t){const s=k.useRef(null);return s.current===null&&(s.current=t()),s.current}const R3t=typeof window<"u",dKe=R3t?k.useLayoutEffect:k.useEffect,Bue=k.createContext(null);function dNe(t,s){t.indexOf(s)===-1&&t.push(s)}function ole(t,s){const r=t.indexOf(s);r>-1&&t.splice(r,1)}const p0=(t,s,r)=>r>s?s:r{},FT=()=>{};const ew={},uKe=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function hKe(t){return typeof t=="object"&&t!==null}const mKe=t=>/^0[^.\s]+$/u.test(t);function pKe(t){let s;return()=>(s===void 0&&(s=t()),s)}const _x=t=>t,O3t=(t,s)=>r=>s(t(r)),$R=(...t)=>t.reduce(O3t),oD=(t,s,r)=>{const n=s-t;return n===0?1:(r-t)/n};class uNe{constructor(){this.subscriptions=[]}add(s){return dNe(this.subscriptions,s),()=>ole(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,ux=t=>t/1e3;function fKe(t,s){return s?t*(1e3/s):0}const xKe=(t,s,r)=>(((1-3*r+3*s)*t+(3*r-6*s))*t+3*s)*t,F3t=1e-7,z3t=12;function B3t(t,s,r,n,a){let o,l,i=0;do l=s+(r-s)/2,o=xKe(l,n,a)-t,o>0?r=l:s=l;while(Math.abs(o)>F3t&&++iB3t(o,0,1,t,r);return o=>o===0||o===1?o:xKe(a(o),s,n)}const gKe=t=>s=>s<=.5?t(2*s)/2:(2-t(2*(1-s)))/2,yKe=t=>s=>1-t(1-s),vKe=qR(.33,1.53,.69,.99),hNe=yKe(vKe),_Ke=gKe(hNe),bKe=t=>t>=1?1:(t*=2)<1?.5*hNe(t):.5*(2-Math.pow(2,-10*(t-1))),mNe=t=>1-Math.sin(Math.acos(t)),wKe=yKe(mNe),jKe=gKe(mNe),$3t=qR(.42,0,1,1),q3t=qR(0,0,.58,1),NKe=qR(.42,0,.58,1),U3t=t=>Array.isArray(t)&&typeof t[0]!="number",kKe=t=>Array.isArray(t)&&typeof t[0]=="number",h6e={linear:_x,easeIn:$3t,easeInOut:NKe,easeOut:q3t,circIn:mNe,circInOut:jKe,circOut:wKe,backIn:hNe,backInOut:_Ke,backOut:vKe,anticipate:bKe},V3t=t=>typeof t=="string",m6e=t=>{if(kKe(t)){FT(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[s,r,n,a]=t;return qR(s,r,n,a)}else if(V3t(t))return FT(h6e[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),h6e[t];return t},Ez=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"],p6e={value:null,addProjectionMetrics:null};function H3t(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},d=0;function u(f){l.has(f)&&(p.schedule(f),t()),d++,f(i)}const p={schedule:(f,y=!1,_=!1)=>{const N=_&&a?r:n;return y&&l.add(f),N.add(f),f},cancel:f=>{n.delete(f),l.delete(f)},process:f=>{if(i=f,a){o=!0;return}a=!0;const y=r;r=n,n=y,r.forEach(u),s&&p6e.value&&p6e.value.frameloop[s].push(d),d=0,r.clear(),a=!1,o&&(o=!1,p.process(f))}};return p}const G3t=40;function SKe(t,s){let r=!1,n=!0;const a={delta:0,timestamp:0,isProcessing:!1},o=()=>r=!0,l=Ez.reduce((A,I)=>(A[I]=H3t(o,s?I:void 0),A),{}),{setup:i,read:d,resolveKeyframes:u,preUpdate:p,update:f,preRender:y,render:_,postRender:b}=l,N=()=>{const A=ew.useManualTiming,I=A?a.timestamp:performance.now();r=!1,A||(a.delta=n?1e3/60:Math.max(Math.min(I-a.timestamp,G3t),1)),a.timestamp=I,a.isProcessing=!0,i.process(a),d.process(a),u.process(a),p.process(a),f.process(a),y.process(a),_.process(a),b.process(a),a.isProcessing=!1,r&&s&&(n=!1,t(N))},w=()=>{r=!0,n=!0,a.isProcessing||t(N)};return{schedule:Ez.reduce((A,I)=>{const L=l[I];return A[I]=(O,V=!1,q=!1)=>(r||w(),L.schedule(O,V,q)),A},{}),cancel:A=>{for(let I=0;I(Uie===void 0&&gm.set(sh.isProcessing||ew.useManualTiming?sh.timestamp:performance.now()),Uie),set:t=>{Uie=t,queueMicrotask(W3t)}},CKe=t=>s=>typeof s=="string"&&s.startsWith(t),MKe=CKe("--"),K3t=CKe("var(--"),pNe=t=>K3t(t)?Z3t.test(t.split("/*")[0].trim()):!1,Z3t=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function f6e(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const GA={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},lD={...GA,transform:t=>p0(0,1,t)},Pz={...GA,default:1},t8=t=>Math.round(t*1e5)/1e5,fNe=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Y3t(t){return t==null}const X3t=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,xNe=(t,s)=>r=>!!(typeof r=="string"&&X3t.test(r)&&r.startsWith(t)||s&&!Y3t(r)&&Object.prototype.hasOwnProperty.call(r,s)),TKe=(t,s,r)=>n=>{if(typeof n!="string")return n;const[a,o,l,i]=n.match(fNe);return{[t]:parseFloat(a),[s]:parseFloat(o),[r]:parseFloat(l),alpha:i!==void 0?parseFloat(i):1}},Q3t=t=>p0(0,255,t),Nge={...GA,transform:t=>Math.round(Q3t(t))},y4={test:xNe("rgb","red"),parse:TKe("red","green","blue"),transform:({red:t,green:s,blue:r,alpha:n=1})=>"rgba("+Nge.transform(t)+", "+Nge.transform(s)+", "+Nge.transform(r)+", "+t8(lD.transform(n))+")"};function J3t(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 P1e={test:xNe("#"),parse:J3t,transform:y4.transform},UR=t=>({test:s=>typeof s=="string"&&s.endsWith(t)&&s.split(" ").length===1,parse:parseFloat,transform:s=>`${s}${t}`}),S_=UR("deg"),o0=UR("%"),na=UR("px"),e5t=UR("vh"),t5t=UR("vw"),x6e={...o0,parse:t=>o0.parse(t)/100,transform:t=>o0.transform(t*100)},eM={test:xNe("hsl","hue"),parse:TKe("hue","saturation","lightness"),transform:({hue:t,saturation:s,lightness:r,alpha:n=1})=>"hsla("+Math.round(t)+", "+o0.transform(t8(s))+", "+o0.transform(t8(r))+", "+t8(lD.transform(n))+")"},Dd={test:t=>y4.test(t)||P1e.test(t)||eM.test(t),parse:t=>y4.test(t)?y4.parse(t):eM.test(t)?eM.parse(t):P1e.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?y4.transform(t):eM.transform(t),getAnimatableNone:t=>{const s=Dd.parse(t);return s.alpha=0,Dd.transform(s)}},s5t=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function r5t(t){var s,r;return isNaN(t)&&typeof t=="string"&&(((s=t.match(fNe))==null?void 0:s.length)||0)+(((r=t.match(s5t))==null?void 0:r.length)||0)>0}const AKe="number",EKe="color",n5t="var",a5t="var(",g6e="${}",i5t=/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 zT(t){const s=t.toString(),r=[],n={color:[],number:[],var:[]},a=[];let o=0;const i=s.replace(i5t,d=>(Dd.test(d)?(n.color.push(o),a.push(EKe),r.push(Dd.parse(d))):d.startsWith(a5t)?(n.var.push(o),a.push(n5t),r.push(d)):(n.number.push(o),a.push(AKe),r.push(parseFloat(d))),++o,g6e)).split(g6e);return{values:r,split:i,indexes:n,types:a}}function o5t(t){return zT(t).values}function PKe({split:t,types:s}){const r=t.length;return n=>{let a="";for(let o=0;otypeof t=="number"?0:Dd.test(t)?Dd.getAnimatableNone(t):t,d5t=(t,s)=>typeof t=="number"?s!=null&&s.trim().endsWith("/")?t:0:c5t(t);function u5t(t){const s=zT(t);return PKe(s)(s.values.map((n,a)=>d5t(n,s.split[a])))}const Dg={test:r5t,parse:o5t,createTransformer:l5t,getAnimatableNone:u5t};function kge(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 h5t({hue:t,saturation:s,lightness:r,alpha:n}){t/=360,s/=100,r/=100;let a=0,o=0,l=0;if(!s)a=o=l=r;else{const i=r<.5?r*(1+s):r+s-r*s,d=2*r-i;a=kge(d,i,t+1/3),o=kge(d,i,t),l=kge(d,i,t-1/3)}return{red:Math.round(a*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:n}}function lle(t,s){return r=>r>0?s:t}const sc=(t,s,r)=>t+(s-t)*r,Sge=(t,s,r)=>{const n=t*t,a=r*(s*s-n)+n;return a<0?0:Math.sqrt(a)},m5t=[P1e,y4,eM],p5t=t=>m5t.find(s=>s.test(t));function y6e(t){const s=p5t(t);if($ue(!!s,`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!s)return!1;let r=s.parse(t);return s===eM&&(r=h5t(r)),r}const v6e=(t,s)=>{const r=y6e(t),n=y6e(s);if(!r||!n)return lle(t,s);const a={...r};return o=>(a.red=Sge(r.red,n.red,o),a.green=Sge(r.green,n.green,o),a.blue=Sge(r.blue,n.blue,o),a.alpha=sc(r.alpha,n.alpha,o),y4.transform(a))},I1e=new Set(["none","hidden"]);function f5t(t,s){return I1e.has(t)?r=>r<=0?t:s:r=>r>=1?s:t}function x5t(t,s){return r=>sc(t,s,r)}function gNe(t){return typeof t=="number"?x5t:typeof t=="string"?pNe(t)?lle:Dd.test(t)?v6e:v5t:Array.isArray(t)?IKe:typeof t=="object"?Dd.test(t)?v6e:g5t:lle}function IKe(t,s){const r=[...t],n=r.length,a=t.map((o,l)=>gNe(o)(o,s[l]));return o=>{for(let l=0;l{for(const o in n)r[o]=n[o](a);return r}}function y5t(t,s){const r=[],n={color:0,var:0,number:0};for(let a=0;a{const r=Dg.createTransformer(s),n=zT(t),a=zT(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?I1e.has(t)&&!a.values.length||I1e.has(s)&&!n.values.length?f5t(t,s):$R(IKe(y5t(n,a),a.values),r):($ue(!0,`Complex values '${t}' and '${s}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),lle(t,s))};function LKe(t,s,r){return typeof t=="number"&&typeof s=="number"&&typeof r=="number"?sc(t,s,r):gNe(t)(t,s)}const _5t=t=>{const s=({timestamp:r})=>t(r);return{start:(r=!0)=>xl.update(s,r),stop:()=>tw(s),now:()=>sh.isProcessing?sh.timestamp:gm.now()}},DKe=(t,s,r=10)=>{let n="";const a=Math.max(Math.round(s/r),2);for(let o=0;o=cle?1/0:s}function b5t(t,s=100,r){const n=r({...t,keyframes:[0,s]}),a=Math.min(yNe(n),cle);return{type:"keyframes",ease:o=>n.next(a*o).value/s,duration:ux(a)}}const Pc={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 L1e(t,s){return t*Math.sqrt(1-s*s)}const w5t=12;function j5t(t,s,r){let n=r;for(let a=1;a{const p=u*l,f=p*t,y=p-r,_=L1e(u,l),b=Math.exp(-f);return Cge-y/_*b},o=u=>{const f=u*l*t,y=f*r+r,_=Math.pow(l,2)*Math.pow(u,2)*t,b=Math.exp(-f),N=L1e(Math.pow(u,2),l);return(-a(u)+Cge>0?-1:1)*((y-_)*b)/N}):(a=u=>{const p=Math.exp(-u*t),f=(u-r)*t+1;return-Cge+p*f},o=u=>{const p=Math.exp(-u*t),f=(r-u)*(t*t);return p*f});const i=5/t,d=j5t(a,o,i);if(t=yp(t),isNaN(d))return{stiffness:Pc.stiffness,damping:Pc.damping,duration:t};{const u=Math.pow(d,2)*n;return{stiffness:u,damping:l*2*Math.sqrt(n*u),duration:t}}}const k5t=["duration","bounce"],S5t=["stiffness","damping","mass"];function _6e(t,s){return s.some(r=>t[r]!==void 0)}function C5t(t){let s={velocity:Pc.velocity,stiffness:Pc.stiffness,damping:Pc.damping,mass:Pc.mass,isResolvedFromDuration:!1,...t};if(!_6e(t,S5t)&&_6e(t,k5t))if(s.velocity=0,t.visualDuration){const r=t.visualDuration,n=2*Math.PI/(r*1.2),a=n*n,o=2*p0(.05,1,1-(t.bounce||0))*Math.sqrt(a);s={...s,mass:Pc.mass,stiffness:a,damping:o}}else{const r=N5t({...t,velocity:0});s={...s,...r,mass:Pc.mass},s.isResolvedFromDuration=!0}return s}function dle(t=Pc.visualDuration,s=Pc.bounce){const r=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:s}:t;let{restSpeed:n,restDelta:a}=r;const o=r.keyframes[0],l=r.keyframes[r.keyframes.length-1],i={done:!1,value:o},{stiffness:d,damping:u,mass:p,duration:f,velocity:y,isResolvedFromDuration:_}=C5t({...r,velocity:-ux(r.velocity||0)}),b=y||0,N=u/(2*Math.sqrt(d*p)),w=l-o,S=ux(Math.sqrt(d/p)),C=Math.abs(w)<5;n||(n=C?Pc.restSpeed.granular:Pc.restSpeed.default),a||(a=C?Pc.restDelta.granular:Pc.restDelta.default);let A,I,L,O,V,q;if(N<1)L=L1e(S,N),O=(b+N*S*w)/L,A=U=>{const te=Math.exp(-N*S*U);return l-te*(O*Math.sin(L*U)+w*Math.cos(L*U))},V=N*S*O+w*L,q=N*S*w-O*L,I=U=>Math.exp(-N*S*U)*(V*Math.sin(L*U)+q*Math.cos(L*U));else if(N===1){A=te=>l-Math.exp(-S*te)*(w+(b+S*w)*te);const U=b+S*w;I=te=>Math.exp(-S*te)*(S*U*te-b)}else{const U=S*Math.sqrt(N*N-1);A=X=>{const ce=Math.exp(-N*S*X),ie=Math.min(U*X,300);return l-ce*((b+N*S*w)*Math.sinh(ie)+U*w*Math.cosh(ie))/U};const te=(b+N*S*w)/U,Y=N*S*te-w*U,J=N*S*w-te*U;I=X=>{const ce=Math.exp(-N*S*X),ie=Math.min(U*X,300);return ce*(Y*Math.sinh(ie)+J*Math.cosh(ie))}}const B={calculatedDuration:_&&f||null,velocity:U=>yp(I(U)),next:U=>{if(!_&&N<1){const Y=Math.exp(-N*S*U),J=Math.sin(L*U),X=Math.cos(L*U),ce=l-Y*(O*J+w*X),ie=yp(Y*(V*J+q*X));return i.done=Math.abs(ie)<=n&&Math.abs(l-ce)<=a,i.value=i.done?l:ce,i}const te=A(U);if(_)i.done=U>=f;else{const Y=yp(I(U));i.done=Math.abs(Y)<=n&&Math.abs(l-te)<=a}return i.value=i.done?l:te,i},toString:()=>{const U=Math.min(yNe(B),cle),te=DKe(Y=>B.next(U*Y).value,U,30);return U+"ms "+te},toTransition:()=>{}};return B}dle.applyToOptions=t=>{const s=b5t(t,100,dle);return t.ease=s.ease,t.duration=yp(s.duration),t.type="keyframes",t};const M5t=5;function RKe(t,s,r){const n=Math.max(s-M5t,0);return fKe(r-t(n),s-n)}function D1e({keyframes:t,velocity:s=0,power:r=.8,timeConstant:n=325,bounceDamping:a=10,bounceStiffness:o=500,modifyTarget:l,min:i,max:d,restDelta:u=.5,restSpeed:p}){const f=t[0],y={done:!1,value:f},_=q=>i!==void 0&&qd,b=q=>i===void 0?d:d===void 0||Math.abs(i-q)-N*Math.exp(-q/n),A=q=>S+C(q),I=q=>{const B=C(q),U=A(q);y.done=Math.abs(B)<=u,y.value=y.done?S:U};let L,O;const V=q=>{_(y.value)&&(L=q,O=dle({keyframes:[y.value,b(y.value)],velocity:RKe(A,q,y.value),damping:a,stiffness:o,restDelta:u,restSpeed:p}))};return V(0),{calculatedDuration:null,next:q=>{let B=!1;return!O&&L===void 0&&(B=!0,I(q),V(q)),L!==void 0&&q>=L?O.next(q-L):(!B&&I(q),y)}}}function T5t(t,s,r){const n=[],a=r||ew.mix||LKe,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=T5t(s,n,a),d=i.length,u=p=>{if(l&&p1)for(;fu(p0(t[0],t[o-1],p)):u}function E5t(t,s){const r=t[t.length-1];for(let n=1;n<=s;n++){const a=oD(0,s,n);t.push(sc(r,1,a))}}function P5t(t){const s=[0];return E5t(s,t.length-1),s}function I5t(t,s){return t.map(r=>r*s)}function L5t(t,s){return t.map(()=>s||NKe).splice(0,t.length-1)}function s8({duration:t=300,keyframes:s,times:r,ease:n="easeInOut"}){const a=U3t(n)?n.map(m6e):m6e(n),o={done:!1,value:s[0]},l=I5t(r&&r.length===s.length?r:P5t(s),t),i=A5t(l,s,{ease:Array.isArray(a)?a:L5t(s,a)});return{calculatedDuration:t,next:d=>(o.value=i(d),o.done=d>=t,o)}}const D5t=t=>t!==null;function que(t,{repeat:s,repeatType:r="loop"},n,a=1){const o=t.filter(D5t),i=a<0||s&&r!=="loop"&&s%2===1?0:o.length-1;return!i||n===void 0?o[i]:n}const R5t={decay:D1e,inertia:D1e,tween:s8,keyframes:s8,spring:dle};function OKe(t){typeof t.type=="string"&&(t.type=R5t[t.type])}class vNe{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 O5t=t=>t/100;class ule extends vNe{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!==gm.now()&&this.tick(gm.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;OKe(s);const{type:r=s8,repeat:n=0,repeatDelay:a=0,repeatType:o,velocity:l=0}=s;let{keyframes:i}=s;const d=r||s8;d!==s8&&typeof i[0]!="number"&&(this.mixKeyframes=$R(O5t,LKe(i[0],i[1])),i=[0,100]);const u=d({...s,keyframes:i});o==="mirror"&&(this.mirroredGenerator=d({...s,keyframes:[...i].reverse(),velocity:-l})),u.calculatedDuration===null&&(u.calculatedDuration=yNe(u));const{calculatedDuration:p}=u;this.calculatedDuration=p,this.resolvedDuration=p+a,this.totalDuration=this.resolvedDuration*(n+1)-a,this.generator=u}updateTime(s){const r=Math.round(s-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=r}tick(s,r=!1){const{generator:n,totalDuration:a,mixKeyframes:o,mirroredGenerator:l,resolvedDuration:i,calculatedDuration:d}=this;if(this.startTime===null)return n.next(0);const{delay:u=0,keyframes:p,repeat:f,repeatType:y,repeatDelay:_,type:b,onUpdate:N,finalKeyframe:w}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,s):this.speed<0&&(this.startTime=Math.min(s-a/this.speed,this.startTime)),r?this.currentTime=s:this.updateTime(s);const S=this.currentTime-u*(this.playbackSpeed>=0?1:-1),C=this.playbackSpeed>=0?S<0:S>a;this.currentTime=Math.max(S,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let A=this.currentTime,I=n;if(f){const q=Math.min(this.currentTime,a)/i;let B=Math.floor(q),U=q%1;!U&&q>=1&&(U=1),U===1&&B--,B=Math.min(B,f+1),!!(B%2)&&(y==="reverse"?(U=1-U,_&&(U-=_/i)):y==="mirror"&&(I=l)),A=p0(0,1,U)*i}let L;C?(this.delayState.value=p[0],L=this.delayState):L=I.next(A),o&&!C&&(L.value=o(L.value));let{done:O}=L;!C&&d!==null&&(O=this.playbackSpeed>=0?this.currentTime>=a:this.currentTime<=0);const V=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&O);return V&&b!==D1e&&(L.value=que(p,this.options,w,this.speed)),N&&N(L.value),V&&this.finish(),L}then(s,r){return this.finished.then(s,r)}get duration(){return ux(this.calculatedDuration)}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+ux(s)}get time(){return ux(this.currentTime)}set time(s){s=yp(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 RKe(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(gm.now()),this.playbackSpeed=s,r&&this.driver&&(this.time=ux(this.currentTime))}play(){var a,o;if(this.isStopped)return;const{driver:s=_5t,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(gm.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 F5t(t){for(let s=1;st*180/Math.PI,R1e=t=>{const s=v4(Math.atan2(t[1],t[0]));return O1e(s)},z5t={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:R1e,rotateZ:R1e,skewX:t=>v4(Math.atan(t[1])),skewY:t=>v4(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},O1e=t=>(t=t%360,t<0&&(t+=360),t),b6e=R1e,w6e=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),j6e=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),B5t={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:w6e,scaleY:j6e,scale:t=>(w6e(t)+j6e(t))/2,rotateX:t=>O1e(v4(Math.atan2(t[6],t[5]))),rotateY:t=>O1e(v4(Math.atan2(-t[2],t[0]))),rotateZ:b6e,rotate:b6e,skewX:t=>v4(Math.atan(t[4])),skewY:t=>v4(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function F1e(t){return t.includes("scale")?1:0}function z1e(t,s){if(!t||t==="none")return F1e(s);const r=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let n,a;if(r)n=B5t,a=r;else{const i=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=z5t,a=i}if(!a)return F1e(s);const o=n[s],l=a[1].split(",").map(q5t);return typeof o=="function"?o(l):l[o]}const $5t=(t,s)=>{const{transform:r="none"}=getComputedStyle(t);return z1e(r,s)};function q5t(t){return parseFloat(t.trim())}const WA=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],KA=new Set(WA),N6e=t=>t===GA||t===na,U5t=new Set(["x","y","z"]),V5t=WA.filter(t=>!U5t.has(t));function H5t(t){const s=[];return V5t.forEach(r=>{const n=t.getValue(r);n!==void 0&&(s.push([r,n.get()]),n.set(r.startsWith("scale")?1:0))}),s}const db={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})=>z1e(s,"x"),y:(t,{transform:s})=>z1e(s,"y")};db.translateX=db.x;db.translateY=db.y;const NS=new Set;let B1e=!1,$1e=!1,q1e=!1;function FKe(){if($1e){const t=Array.from(NS).filter(n=>n.needsMeasurement),s=new Set(t.map(n=>n.element)),r=new Map;s.forEach(n=>{const a=H5t(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)})}$1e=!1,B1e=!1,NS.forEach(t=>t.complete(q1e)),NS.clear()}function zKe(){NS.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&($1e=!0)})}function G5t(){q1e=!0,zKe(),FKe(),q1e=!1}class _Ne{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?(NS.add(this),B1e||(B1e=!0,xl.read(zKe),xl.resolveKeyframes(FKe))):(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])}F5t(s)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(s=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,s),NS.delete(this)}cancel(){this.state==="scheduled"&&(NS.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const W5t=t=>t.startsWith("--");function BKe(t,s,r){W5t(s)?t.style.setProperty(s,r):t.style[s]=r}const K5t={};function $Ke(t,s){const r=pKe(t);return()=>K5t[s]??r()}const Z5t=$Ke(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),qKe=$Ke(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),DI=([t,s,r,n])=>`cubic-bezier(${t}, ${s}, ${r}, ${n})`,k6e={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:DI([0,.65,.55,1]),circOut:DI([.55,0,1,.45]),backIn:DI([.31,.01,.66,-.59]),backOut:DI([.33,1.53,.69,.99])};function UKe(t,s){if(t)return typeof t=="function"?qKe()?DKe(t,s):"ease-out":kKe(t)?DI(t):Array.isArray(t)?t.map(r=>UKe(r,s)||k6e.easeOut):k6e[t]}function Y5t(t,s,r,{delay:n=0,duration:a=300,repeat:o=0,repeatType:l="loop",ease:i="easeOut",times:d}={},u=void 0){const p={[s]:r};d&&(p.offset=d);const f=UKe(i,a);Array.isArray(f)&&(p.easing=f);const y={delay:n,duration:a,easing:Array.isArray(f)?"linear":f,fill:"both",iterations:o+1,direction:l==="reverse"?"alternate":"normal"};return u&&(y.pseudoElement=u),t.animate(p,y)}function VKe(t){return typeof t=="function"&&"applyToOptions"in t}function X5t({type:t,...s}){return VKe(t)&&qKe()?t.applyToOptions(s):(s.duration??(s.duration=300),s.ease??(s.ease="easeOut"),s)}class HKe extends vNe{constructor(s){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!s)return;const{element:r,name:n,keyframes:a,pseudoElement:o,allowFlatten:l=!1,finalKeyframe:i,onComplete:d}=s;this.isPseudoElement=!!o,this.allowFlatten=l,this.options=s,FT(typeof s.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=X5t(s);this.animation=Y5t(r,n,a,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const p=que(a,this.options,i,this.speed);this.updateMotionValue&&this.updateMotionValue(p),BKe(r,n,p),this.animation.cancel()}d==null||d(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var s,r;(r=(s=this.animation).finish)==null||r.call(s)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:s}=this;s==="idle"||s==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var r,n,a;const s=(r=this.options)==null?void 0:r.element;!this.isPseudoElement&&(s!=null&&s.isConnected)&&((a=(n=this.animation).commitStyles)==null||a.call(n))}get duration(){var r,n;const s=((n=(r=this.animation.effect)==null?void 0:r.getComputedTiming)==null?void 0:n.call(r).duration)||0;return ux(Number(s))}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+ux(s)}get time(){return ux(Number(this.animation.currentTime)||0)}set time(s){const r=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=yp(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&&Z5t()?(this.animation.timeline=s,r&&(this.animation.rangeStart=r),n&&(this.animation.rangeEnd=n),_x):a(this)}}const GKe={anticipate:bKe,backInOut:_Ke,circInOut:jKe};function Q5t(t){return t in GKe}function J5t(t){typeof t.ease=="string"&&Q5t(t.ease)&&(t.ease=GKe[t.ease])}const Mge=10;class eMt extends HKe{constructor(s){J5t(s),OKe(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 ule({...l,autoplay:!1}),d=Math.max(Mge,gm.now()-this.startTime),u=p0(0,Mge,d-Mge),p=i.sample(d).value,{name:f}=this.options;o&&f&&BKe(o,f,p),r.setWithVelocity(i.sample(Math.max(0,d-u)).value,p,u),i.stop()}}const S6e=(t,s)=>s==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Dg.test(t)||t==="0")&&!t.startsWith("url("));function tMt(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:p}=s.owner.getProps();return iMt()&&r&&(WKe.has(r)||aMt.has(r)&&nMt(i))&&(r!=="transform"||!p)&&!u&&!n&&a!=="mirror"&&o!==0&&l!=="inertia"}const lMt=40;class cMt extends vNe{constructor({autoplay:s=!0,delay:r=0,type:n="keyframes",repeat:a=0,repeatDelay:o=0,repeatType:l="loop",keyframes:i,name:d,motionValue:u,element:p,...f}){var b;super(),this.stop=()=>{var N,w;this._animation&&(this._animation.stop(),(N=this.stopTimeline)==null||N.call(this)),(w=this.keyframeResolver)==null||w.cancel()},this.createdAt=gm.now();const y={autoplay:s,delay:r,type:n,repeat:a,repeatDelay:o,repeatType:l,name:d,motionValue:u,element:p,...f},_=(p==null?void 0:p.KeyframeResolver)||_Ne;this.keyframeResolver=new _(i,(N,w,S)=>this.onKeyframesResolved(N,w,y,!S),d,u,p),(b=this.keyframeResolver)==null||b.scheduleResolve()}onKeyframesResolved(s,r,n,a){var S,C;this.keyframeResolver=void 0;const{name:o,type:l,velocity:i,delay:d,isHandoff:u,onUpdate:p}=n;this.resolvedAt=gm.now();let f=!0;sMt(s,o,l,i)||(f=!1,(ew.instantAnimations||!d)&&(p==null||p(que(s,n,r))),s[0]=s[s.length-1],U1e(n),n.repeat=0);const _={startTime:a?this.resolvedAt?this.resolvedAt-this.createdAt>lMt?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:r,...n,keyframes:s},b=f&&!u&&oMt(_),N=(C=(S=_.motionValue)==null?void 0:S.owner)==null?void 0:C.current;let w;if(b)try{w=new eMt({..._,element:N})}catch{w=new ule(_)}else w=new ule(_);w.finished.then(()=>{this.notifyFinished()}).catch(_x),this.pendingTimeline&&(this.stopTimeline=w.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=w}get finished(){return this._animation?this.animation.finished:this._finished}then(s,r){return this.finished.finally(s).then(()=>{})}get animation(){var s;return this._animation||((s=this.keyframeResolver)==null||s.resume(),G5t()),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 KKe(t,s,r,n=0,a=1){const o=Array.from(t).sort((u,p)=>u.sortNodePosition(p)).indexOf(s),l=t.size,i=(l-1)*n;return typeof r=="function"?r(o,l):a===1?o*n:i-o*n}const dMt=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function uMt(t){const s=dMt.exec(t);if(!s)return[,];const[,r,n,a]=s;return[`--${r??n}`,a]}const hMt=4;function ZKe(t,s,r=1){FT(r<=hMt,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[n,a]=uMt(t);if(!n)return;const o=window.getComputedStyle(s).getPropertyValue(n);if(o){const l=o.trim();return uKe(l)?parseFloat(l):l}return pNe(a)?ZKe(a,s,r+1):a}const mMt={type:"spring",stiffness:500,damping:25,restSpeed:10},pMt=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),fMt={type:"keyframes",duration:.8},xMt={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},gMt=(t,{keyframes:s})=>s.length>2?fMt:KA.has(t)?t.startsWith("scale")?pMt(s[1]):mMt:xMt;function YKe(t,s){if(t!=null&&t.inherit&&s){const{inherit:r,...n}=t;return{...s,...n}}return t}function bNe(t,s){const r=(t==null?void 0:t[s])??(t==null?void 0:t.default)??t;return r!==t?YKe(r,t):r}const yMt=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function vMt(t){for(const s in t)if(!yMt.has(s))return!0;return!1}const wNe=(t,s,r,n={},a,o)=>l=>{const i=bNe(n,t)||{},d=i.delay||n.delay||0;let{elapsed:u=0}=n;u=u-yp(d);const p={keyframes:Array.isArray(r)?r:[null,r],ease:"easeOut",velocity:s.getVelocity(),...i,delay:-u,onUpdate:y=>{s.set(y),i.onUpdate&&i.onUpdate(y)},onComplete:()=>{l(),i.onComplete&&i.onComplete()},name:t,motionValue:s,element:o?void 0:a};vMt(i)||Object.assign(p,gMt(t,p)),p.duration&&(p.duration=yp(p.duration)),p.repeatDelay&&(p.repeatDelay=yp(p.repeatDelay)),p.from!==void 0&&(p.keyframes[0]=p.from);let f=!1;if((p.type===!1||p.duration===0&&!p.repeatDelay)&&(U1e(p),p.delay===0&&(f=!0)),(ew.instantAnimations||ew.skipAnimations||a!=null&&a.shouldSkipAnimations)&&(f=!0,U1e(p),p.delay=0),p.allowFlatten=!i.type&&!i.ease,f&&!o&&s.get()!==void 0){const y=que(p.keyframes,i);if(y!==void 0){xl.update(()=>{p.onUpdate(y),p.onComplete()});return}}return i.isSync?new ule(p):new cMt(p)};function C6e(t){const s=[{},{}];return t==null||t.values.forEach((r,n)=>{s[0][n]=r.get(),s[1][n]=r.getVelocity()}),s}function jNe(t,s,r,n){if(typeof s=="function"){const[a,o]=C6e(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]=C6e(n);s=s(r!==void 0?r:t.custom,a,o)}return s}function kS(t,s,r){const n=t.getProps();return jNe(n,s,r!==void 0?r:n.custom,t)}const XKe=new Set(["width","height","top","left","right","bottom",...WA]),M6e=30,_Mt=t=>!isNaN(parseFloat(t));class bMt{constructor(s,r={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{var o;const a=gm.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=gm.now(),this.canTrackVelocity===null&&s!==void 0&&(this.canTrackVelocity=_Mt(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 uNe);const n=this.events[s].add(r);return s==="change"?()=>{n(),xl.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=gm.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||s-this.updatedAt>M6e)return 0;const r=Math.min(this.updatedAt-this.prevUpdatedAt,M6e);return fKe(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 BT(t,s){return new bMt(t,s)}const V1e=t=>Array.isArray(t);function wMt(t,s,r){t.hasValue(s)?t.getValue(s).set(r):t.addValue(s,BT(r))}function jMt(t){return V1e(t)?t[t.length-1]||0:t}function NMt(t,s){const r=kS(t,s);let{transitionEnd:n={},transition:a={},...o}=r||{};o={...o,...n};for(const l in o){const i=jMt(o[l]);wMt(t,l,i)}}const ah=t=>!!(t&&t.getVelocity);function kMt(t){return!!(ah(t)&&t.add)}function H1e(t,s){const r=t.getValue("willChange");if(kMt(r))return r.add(s);if(!r&&ew.WillChange){const n=new ew.WillChange("auto");t.addValue("willChange",n),n.add(s)}}function NNe(t){return t.replace(/([A-Z])/g,s=>`-${s.toLowerCase()}`)}const SMt="framerAppearId",QKe="data-"+NNe(SMt);function JKe(t){return t.props[QKe]}function CMt({protectedKeys:t,needsAnimating:s},r){const n=t.hasOwnProperty(r)&&s[r]!==!0;return s[r]=!1,n}function eZe(t,s,{delay:r=0,transitionOverride:n,type:a}={}){let{transition:o,transitionEnd:l,...i}=s;const d=t.getDefaultTransition();o=o?YKe(o,d):d;const u=o==null?void 0:o.reduceMotion;n&&(o=n);const p=[],f=a&&t.animationState&&t.animationState.getState()[a];for(const y in i){const _=t.getValue(y,t.latestValues[y]??null),b=i[y];if(b===void 0||f&&CMt(f,y))continue;const N={delay:r,...bNe(o||{},y)},w=_.get();if(w!==void 0&&!_.isAnimating()&&!Array.isArray(b)&&b===w&&!N.velocity){xl.update(()=>_.set(b));continue}let S=!1;if(window.MotionHandoffAnimation){const I=JKe(t);if(I){const L=window.MotionHandoffAnimation(I,y,xl);L!==null&&(N.startTime=L,S=!0)}}H1e(t,y);const C=u??t.shouldReduceMotion;_.start(wNe(y,_,b,C&&XKe.has(y)?{type:!1}:N,t,S));const A=_.animation;A&&p.push(A)}if(l){const y=()=>xl.update(()=>{l&&NMt(t,l)});p.length?Promise.all(p).then(y):y()}return p}function G1e(t,s,r={}){var d;const n=kS(t,s,r.type==="exit"?(d=t.presenceContext)==null?void 0:d.custom:void 0);let{transition:a=t.getDefaultTransition()||{}}=n||{};r.transitionOverride&&(a=r.transitionOverride);const o=n?()=>Promise.all(eZe(t,n,r)):()=>Promise.resolve(),l=t.variantChildren&&t.variantChildren.size?(u=0)=>{const{delayChildren:p=0,staggerChildren:f,staggerDirection:y}=a;return MMt(t,s,u,p,f,y,r)}:()=>Promise.resolve(),{when:i}=a;if(i){const[u,p]=i==="beforeChildren"?[o,l]:[l,o];return u().then(()=>p())}else return Promise.all([o(),l(r.delay)])}function MMt(t,s,r=0,n=0,a=0,o=1,l){const i=[];for(const d of t.variantChildren)d.notify("AnimationStart",s),i.push(G1e(d,s,{...l,delay:r+(typeof n=="function"?0:n)+KKe(t.variantChildren,d,n,a,o)}).then(()=>d.notify("AnimationComplete",s)));return Promise.all(i)}function TMt(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"?kS(t,s,r.custom):s;n=Promise.all(eZe(t,a,r))}return n.then(()=>{t.notify("AnimationComplete",s)})}const AMt={test:t=>t==="auto",parse:t=>t},tZe=t=>s=>s.test(t),sZe=[GA,na,o0,S_,t5t,e5t,AMt],T6e=t=>sZe.find(tZe(t));function EMt(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||mKe(t):!0}const PMt=new Set(["brightness","contrast","saturate","opacity"]);function IMt(t){const[s,r]=t.slice(0,-1).split("(");if(s==="drop-shadow")return t;const[n]=r.match(fNe)||[];if(!n)return t;const a=r.replace(n,"");let o=PMt.has(s)?1:0;return n!==r&&(o*=100),s+"("+o+a+")"}const LMt=/\b([a-z-]*)\(.*?\)/gu,W1e={...Dg,getAnimatableNone:t=>{const s=t.match(LMt);return s?s.map(IMt).join(" "):t}},K1e={...Dg,getAnimatableNone:t=>{const s=Dg.parse(t);return Dg.createTransformer(t)(s.map(n=>typeof n=="number"?0:typeof n=="object"?{...n,alpha:1}:n))}},A6e={...GA,transform:Math.round},DMt={rotate:S_,rotateX:S_,rotateY:S_,rotateZ:S_,scale:Pz,scaleX:Pz,scaleY:Pz,scaleZ:Pz,skew:S_,skewX:S_,skewY:S_,distance:na,translateX:na,translateY:na,translateZ:na,x:na,y:na,z:na,perspective:na,transformPerspective:na,opacity:lD,originX:x6e,originY:x6e,originZ:na},kNe={borderWidth:na,borderTopWidth:na,borderRightWidth:na,borderBottomWidth:na,borderLeftWidth:na,borderRadius:na,borderTopLeftRadius:na,borderTopRightRadius:na,borderBottomRightRadius:na,borderBottomLeftRadius:na,width:na,maxWidth:na,height:na,maxHeight:na,top:na,right:na,bottom:na,left:na,inset:na,insetBlock:na,insetBlockStart:na,insetBlockEnd:na,insetInline:na,insetInlineStart:na,insetInlineEnd:na,padding:na,paddingTop:na,paddingRight:na,paddingBottom:na,paddingLeft:na,paddingBlock:na,paddingBlockStart:na,paddingBlockEnd:na,paddingInline:na,paddingInlineStart:na,paddingInlineEnd:na,margin:na,marginTop:na,marginRight:na,marginBottom:na,marginLeft:na,marginBlock:na,marginBlockStart:na,marginBlockEnd:na,marginInline:na,marginInlineStart:na,marginInlineEnd:na,fontSize:na,backgroundPositionX:na,backgroundPositionY:na,...DMt,zIndex:A6e,fillOpacity:lD,strokeOpacity:lD,numOctaves:A6e},RMt={...kNe,color:Dd,backgroundColor:Dd,outlineColor:Dd,fill:Dd,stroke:Dd,borderColor:Dd,borderTopColor:Dd,borderRightColor:Dd,borderBottomColor:Dd,borderLeftColor:Dd,filter:W1e,WebkitFilter:W1e,mask:K1e,WebkitMask:K1e},rZe=t=>RMt[t],OMt=new Set([W1e,K1e]);function nZe(t,s){let r=rZe(t);return OMt.has(r)||(r=Dg),r.getAnimatableNone?r.getAnimatableNone(s):void 0}const FMt=new Set(["auto","none","0"]);function zMt(t,s,r){let n=0,a;for(;n{s.getValue(d).set(u)}),this.resolveNoneKeyframes()}}function SNe(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 aZe=(t,s)=>s&&typeof t=="number"?s.transform(t):t;function Vie(t){return hKe(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const{schedule:CNe,cancel:lAs}=SKe(queueMicrotask,!1),ug={x:!1,y:!1};function iZe(){return ug.x||ug.y}function $Mt(t){return t==="x"||t==="y"?ug[t]?null:(ug[t]=!0,()=>{ug[t]=!1}):ug.x||ug.y?null:(ug.x=ug.y=!0,()=>{ug.x=ug.y=!1})}function oZe(t,s){const r=SNe(t),n=new AbortController,a={passive:!0,...s,signal:n.signal};return[r,a,()=>n.abort()]}function qMt(t){return!(t.pointerType==="touch"||iZe())}function UMt(t,s,r={}){const[n,a,o]=oZe(t,r);return n.forEach(l=>{let i=!1,d=!1,u;const p=()=>{l.removeEventListener("pointerleave",b)},f=w=>{u&&(u(w),u=void 0),p()},y=w=>{i=!1,window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",y),d&&(d=!1,f(w))},_=()=>{i=!0,window.addEventListener("pointerup",y,a),window.addEventListener("pointercancel",y,a)},b=w=>{if(w.pointerType!=="touch"){if(i){d=!0;return}f(w)}},N=w=>{if(!qMt(w))return;d=!1;const S=s(l,w);typeof S=="function"&&(u=S,l.addEventListener("pointerleave",b,a))};l.addEventListener("pointerenter",N,a),l.addEventListener("pointerdown",_,a)}),o}const lZe=(t,s)=>s?t===s?!0:lZe(t,s.parentElement):!1,MNe=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,VMt=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function HMt(t){return VMt.has(t.tagName)||t.isContentEditable===!0}const GMt=new Set(["INPUT","SELECT","TEXTAREA"]);function WMt(t){return GMt.has(t.tagName)||t.isContentEditable===!0}const Hie=new WeakSet;function E6e(t){return s=>{s.key==="Enter"&&t(s)}}function Tge(t,s){t.dispatchEvent(new PointerEvent("pointer"+s,{isPrimary:!0,bubbles:!0}))}const KMt=(t,s)=>{const r=t.currentTarget;if(!r)return;const n=E6e(()=>{if(Hie.has(r))return;Tge(r,"down");const a=E6e(()=>{Tge(r,"up")}),o=()=>Tge(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 P6e(t){return MNe(t)&&!iZe()}const I6e=new WeakSet;function ZMt(t,s,r={}){const[n,a,o]=oZe(t,r),l=i=>{const d=i.currentTarget;if(!P6e(i)||I6e.has(i))return;Hie.add(d),r.stopPropagation&&I6e.add(i);const u=s(d,i),p=(_,b)=>{window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",y),Hie.has(d)&&Hie.delete(d),P6e(_)&&typeof u=="function"&&u(_,{success:b})},f=_=>{p(_,d===window||d===document||r.useGlobalTarget||lZe(d,_.target))},y=_=>{p(_,!1)};window.addEventListener("pointerup",f,a),window.addEventListener("pointercancel",y,a)};return n.forEach(i=>{(r.useGlobalTarget?window:i).addEventListener("pointerdown",l,a),Vie(i)&&(i.addEventListener("focus",u=>KMt(u,a)),!HMt(i)&&!i.hasAttribute("tabindex")&&(i.tabIndex=0))}),o}function TNe(t){return hKe(t)&&"ownerSVGElement"in t}const Gie=new WeakMap;let C_;const cZe=(t,s,r)=>(n,a)=>a&&a[0]?a[0][t+"Size"]:TNe(n)&&"getBBox"in n?n.getBBox()[s]:n[r],YMt=cZe("inline","width","offsetWidth"),XMt=cZe("block","height","offsetHeight");function QMt({target:t,borderBoxSize:s}){var r;(r=Gie.get(t))==null||r.forEach(n=>{n(t,{get width(){return YMt(t,s)},get height(){return XMt(t,s)}})})}function JMt(t){t.forEach(QMt)}function eTt(){typeof ResizeObserver>"u"||(C_=new ResizeObserver(JMt))}function tTt(t,s){C_||eTt();const r=SNe(t);return r.forEach(n=>{let a=Gie.get(n);a||(a=new Set,Gie.set(n,a)),a.add(s),C_==null||C_.observe(n)}),()=>{r.forEach(n=>{const a=Gie.get(n);a==null||a.delete(s),a!=null&&a.size||C_==null||C_.unobserve(n)})}}const Wie=new Set;let tM;function sTt(){tM=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};Wie.forEach(s=>s(t))},window.addEventListener("resize",tM)}function rTt(t){return Wie.add(t),tM||sTt(),()=>{Wie.delete(t),!Wie.size&&typeof tM=="function"&&(window.removeEventListener("resize",tM),tM=void 0)}}function L6e(t,s){return typeof t=="function"?rTt(t):tTt(t,s)}function nTt(t){return TNe(t)&&t.tagName==="svg"}const aTt=[...sZe,Dd,Dg],iTt=t=>aTt.find(tZe(t)),D6e=()=>({translate:0,scale:1,origin:0,originPoint:0}),sM=()=>({x:D6e(),y:D6e()}),R6e=()=>({min:0,max:0}),tu=()=>({x:R6e(),y:R6e()}),oTt=new WeakMap;function Uue(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function cD(t){return typeof t=="string"||Array.isArray(t)}const ANe=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],ENe=["initial",...ANe];function Vue(t){return Uue(t.animate)||ENe.some(s=>cD(t[s]))}function dZe(t){return!!(Vue(t)||t.variants)}function lTt(t,s,r){for(const n in s){const a=s[n],o=r[n];if(ah(a))t.addValue(n,a);else if(ah(o))t.addValue(n,BT(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,BT(l!==void 0?l:a,{owner:t}))}}for(const n in r)s[n]===void 0&&t.removeValue(n);return s}const Z1e={current:null},uZe={current:!1},cTt=typeof window<"u";function dTt(){if(uZe.current=!0,!!cTt)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),s=()=>Z1e.current=t.matches;t.addEventListener("change",s),s()}else Z1e.current=!1}const O6e=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let hle={};function hZe(t){hle=t}function uTt(){return hle}class hTt{scrapeMotionValuesFromProps(s,r,n){return{}}constructor({parent:s,props:r,presenceContext:n,reducedMotionConfig:a,skipAnimations:o,blockInitialAnimation:l,visualState:i},d={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=_Ne,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 _=gm.now();this.renderScheduledAt<_&&(this.renderScheduledAt=_,xl.render(this.render,!1,!0))};const{latestValues:u,renderState:p}=i;this.latestValues=u,this.baseTarget={...u},this.initialValues=r.initial?{...u}:{},this.renderState=p,this.parent=s,this.props=r,this.presenceContext=n,this.depth=s?s.depth+1:0,this.reducedMotionConfig=a,this.skipAnimationsConfig=o,this.options=d,this.blockInitialAnimation=!!l,this.isControllingVariants=Vue(r),this.isVariantNode=dZe(r),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(s&&s.current);const{willChange:f,...y}=this.scrapeMotionValuesFromProps(r,{},this);for(const _ in y){const b=y[_];u[_]!==void 0&&ah(b)&&b.set(u[_])}}mount(s){var r,n;if(this.hasBeenMounted)for(const a in this.initialValues)(r=this.values.get(a))==null||r.jump(this.initialValues[a]),this.latestValues[a]=this.initialValues[a];this.current=s,oTt.set(s,this),this.projection&&!this.projection.instance&&this.projection.mount(s),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((a,o)=>this.bindToMotionValue(o,a)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(uZe.current||dTt(),this.shouldReduceMotion=Z1e.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(),tw(this.notifyUpdate),tw(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&&WKe.has(s)&&this.current instanceof HTMLElement){const{factory:l,keyframes:i,times:d,ease:u,duration:p}=r.accelerate,f=new HKe({element:this.current,name:s,keyframes:i,times:d,ease:u,duration:yp(p)}),y=l(f);this.valueSubscriptions.set(s,()=>{y(),f.cancel()});return}const n=KA.has(s);n&&this.onBindTransform&&this.onBindTransform();const a=r.on("change",l=>{this.latestValues[s]=l,this.props.onUpdate&&xl.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 hle){const r=hle[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):tu()}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=BT(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"&&(uKe(n)||mKe(n))?n=parseFloat(n):!iTt(n)&&Dg.test(r)&&(n=nZe(s,r)),this.setBaseTarget(s,ah(n)?n.get():n)),ah(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=jNe(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&&!ah(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 uNe),this.events[s].add(r)}notify(s,...r){this.events[s]&&this.events[s].notify(...r)}scheduleRenderMicrotask(){CNe.render(this.render)}}class mZe extends hTt{constructor(){super(...arguments),this.KeyframeResolver=BMt}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;ah(s)&&(this.childSubscription=s.on("change",r=>{this.current&&(this.current.textContent=`${r}`)}))}}class yw{constructor(s){this.isMounted=!1,this.node=s}update(){}}function pZe({top:t,left:s,right:r,bottom:n}){return{x:{min:s,max:r},y:{min:t,max:n}}}function mTt({x:t,y:s}){return{top:s.min,right:t.max,bottom:s.max,left:t.min}}function pTt(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 Age(t){return t===void 0||t===1}function Y1e({scale:t,scaleX:s,scaleY:r}){return!Age(t)||!Age(s)||!Age(r)}function n4(t){return Y1e(t)||fZe(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function fZe(t){return F6e(t.x)||F6e(t.y)}function F6e(t){return t&&t!=="0%"}function mle(t,s,r){const n=t-r,a=s*n;return r+a}function z6e(t,s,r,n,a){return a!==void 0&&(t=mle(t,a,n)),mle(t,r,n)+s}function X1e(t,s=0,r=1,n,a){t.min=z6e(t.min,s,r,n,a),t.max=z6e(t.max,s,r,n,a)}function xZe(t,{x:s,y:r}){X1e(t.x,s.translate,s.scale,s.originPoint),X1e(t.y,r.translate,r.scale,r.originPoint)}const B6e=.999999999999,$6e=1.0000000000001;function fTt(t,s,r,n=!1){var i;const a=r.length;if(!a)return;s.x=s.y=1;let o,l;for(let d=0;dB6e&&(s.x=1),s.y<$6e&&s.y>B6e&&(s.y=1)}function Oy(t,s){t.min+=s,t.max+=s}function q6e(t,s,r,n,a=.5){const o=sc(t.min,t.max,a);X1e(t,s,r,o,n)}function U6e(t,s){return typeof t=="string"?parseFloat(t)/100*(s.max-s.min):t}function Kie(t,s,r){const n=r??t;q6e(t.x,U6e(s.x,n.x),s.scaleX,s.scale,s.originX),q6e(t.y,U6e(s.y,n.y),s.scaleY,s.scale,s.originY)}function gZe(t,s){return pZe(pTt(t.getBoundingClientRect(),s))}function xTt(t,s,r){const n=gZe(t,r),{scroll:a}=s;return a&&(Oy(n.x,a.offset.x),Oy(n.y,a.offset.y)),n}const gTt={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},yTt=WA.length;function vTt(t,s,r){let n="",a=!0;for(let o=0;o{if(!s.target)return t;if(typeof t=="string")if(na.test(t))t=parseFloat(t);else return t;const r=V6e(t,s.target.x),n=V6e(t,s.target.y);return`${r}% ${n}%`}},_Tt={correct:(t,{treeScale:s,projectionDelta:r})=>{const n=t,a=Dg.parse(t);if(a.length>5)return n;const o=Dg.createTransformer(t),l=typeof a[0]!="number"?1:0,i=r.x.scale*s.x,d=r.y.scale*s.y;a[0+l]/=i,a[1+l]/=d;const u=sc(i,d,.5);return typeof a[2+l]=="number"&&(a[2+l]/=u),typeof a[3+l]=="number"&&(a[3+l]/=u),o(a)}},Q1e={borderRadius:{...tI,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:tI,borderTopRightRadius:tI,borderBottomLeftRadius:tI,borderBottomRightRadius:tI,boxShadow:_Tt};function vZe(t,{layout:s,layoutId:r}){return KA.has(t)||t.startsWith("origin")||(s||r!==void 0)&&(!!Q1e[t]||t==="opacity")}function INe(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)(ah(n[i])||a&&ah(a[i])||vZe(i,t)||((l=r==null?void 0:r.getValue(i))==null?void 0:l.liveStyle)!==void 0)&&(o[i]=n[i]);return o}function bTt(t){return window.getComputedStyle(t)}class wTt extends mZe{constructor(){super(...arguments),this.type="html",this.renderInstance=yZe}readValueFromInstance(s,r){var n;if(KA.has(r))return(n=this.projection)!=null&&n.isProjecting?F1e(r):$5t(s,r);{const a=bTt(s),o=(MKe(r)?a.getPropertyValue(r):a[r])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(s,{transformPagePoint:r}){return gZe(s,r)}build(s,r,n){PNe(s,r,n.transformTemplate)}scrapeMotionValuesFromProps(s,r,n){return INe(s,r,n)}}const jTt={offset:"stroke-dashoffset",array:"stroke-dasharray"},NTt={offset:"strokeDashoffset",array:"strokeDasharray"};function kTt(t,s,r=1,n=0,a=!0){t.pathLength=1;const o=a?jTt:NTt;t[o.offset]=`${-n}`,t[o.array]=`${s} ${r}`}const STt=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function _Ze(t,{attrX:s,attrY:r,attrScale:n,pathLength:a,pathSpacing:o=1,pathOffset:l=0,...i},d,u,p){if(PNe(t,i,u),d){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:f,style:y}=t;f.transform&&(y.transform=f.transform,delete f.transform),(y.transform||f.transformOrigin)&&(y.transformOrigin=f.transformOrigin??"50% 50%",delete f.transformOrigin),y.transform&&(y.transformBox=(p==null?void 0:p.transformBox)??"fill-box",delete f.transformBox);for(const _ of STt)f[_]!==void 0&&(y[_]=f[_],delete f[_]);s!==void 0&&(f.x=s),r!==void 0&&(f.y=r),n!==void 0&&(f.scale=n),a!==void 0&&kTt(f,a,o,l,!1)}const bZe=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"]),wZe=t=>typeof t=="string"&&t.toLowerCase()==="svg";function CTt(t,s,r,n){yZe(t,s,void 0,n);for(const a in s.attrs)t.setAttribute(bZe.has(a)?a:NNe(a),s.attrs[a])}function jZe(t,s,r){const n=INe(t,s,r);for(const a in t)if(ah(t[a])||ah(s[a])){const o=WA.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;n[o]=t[a]}return n}class MTt extends mZe{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=tu}getBaseTargetFromProps(s,r){return s[r]}readValueFromInstance(s,r){if(KA.has(r)){const n=rZe(r);return n&&n.default||0}return r=bZe.has(r)?r:NNe(r),s.getAttribute(r)}scrapeMotionValuesFromProps(s,r,n){return jZe(s,r,n)}build(s,r,n){_Ze(s,r,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(s,r,n,a){CTt(s,r,n,a)}mount(s){this.isSVGTag=wZe(s.tagName),super.mount(s)}}const TTt=ENe.length;function NZe(t){if(!t)return;if(!t.isControllingVariants){const r=t.parent?NZe(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})=>TMt(t,r,n)))}function ITt(t){let s=PTt(t),r=H6e(),n=!0,a=!1;const o=u=>(p,f)=>{var _;const y=kS(t,f,u==="exit"?(_=t.presenceContext)==null?void 0:_.custom:void 0);if(y){const{transition:b,transitionEnd:N,...w}=y;p={...p,...w,...N}}return p};function l(u){s=u(t)}function i(u){const{props:p}=t,f=NZe(t.parent)||{},y=[],_=new Set;let b={},N=1/0;for(let S=0;SN&&L,U=!1;const te=Array.isArray(I)?I:[I];let Y=te.reduce(o(C),{});O===!1&&(Y={});const{prevResolvedValues:J={}}=A,X={...J,...Y},ce=oe=>{B=!0,_.has(oe)&&(U=!0,_.delete(oe)),A.needsAnimating[oe]=!0;const me=t.getValue(oe);me&&(me.liveStyle=!1)};for(const oe in X){const me=Y[oe],ve=J[oe];if(b.hasOwnProperty(oe))continue;let he=!1;V1e(me)&&V1e(ve)?he=!kZe(me,ve):he=me!==ve,he?me!=null?ce(oe):_.add(oe):me!==void 0&&_.has(oe)?ce(oe):A.protectedKeys[oe]=!0}A.prevProp=I,A.prevResolvedValues=Y,A.isActive&&(b={...b,...Y}),(n||a)&&t.blockInitialAnimation&&(B=!1);const ie=V&&q;B&&(!ie||U)&&y.push(...te.map(oe=>{const me={type:C};if(typeof oe=="string"&&(n||a)&&!ie&&t.manuallyAnimateOnMount&&t.parent){const{parent:ve}=t,he=kS(ve,oe);if(ve.enteringChildren&&he){const{delayChildren:ge}=he.transition||{};me.delay=KKe(ve.enteringChildren,t,ge)}}return{animation:oe,options:me}}))}if(_.size){const S={};if(typeof p.initial!="boolean"){const C=kS(t,Array.isArray(p.initial)?p.initial[0]:p.initial);C&&C.transition&&(S.transition=C.transition)}_.forEach(C=>{const A=t.getBaseTarget(C),I=t.getValue(C);I&&(I.liveStyle=!0),S[C]=A??null}),y.push({animation:S})}let w=!!y.length;return n&&(p.initial===!1||p.initial===p.animate)&&!t.manuallyAnimateOnMount&&(w=!1),n=!1,a=!1,w?s(y):Promise.resolve()}function d(u,p){var y;if(r[u].isActive===p)return Promise.resolve();(y=t.variantChildren)==null||y.forEach(_=>{var b;return(b=_.animationState)==null?void 0:b.setActive(u,p)}),r[u].isActive=p;const f=i(u);for(const _ in r)r[_].protectedKeys={};return f}return{animateChanges:i,setActive:d,setAnimateFunction:l,getState:()=>r,reset:()=>{r=H6e(),a=!0}}}function LTt(t,s){return typeof s=="string"?s!==t:Array.isArray(s)?!kZe(s,t):!1}function F2(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function H6e(){return{animate:F2(!0),whileInView:F2(),whileHover:F2(),whileTap:F2(),whileDrag:F2(),whileFocus:F2(),exit:F2()}}function J1e(t,s){t.min=s.min,t.max=s.max}function og(t,s){J1e(t.x,s.x),J1e(t.y,s.y)}function G6e(t,s){t.translate=s.translate,t.scale=s.scale,t.originPoint=s.originPoint,t.origin=s.origin}const SZe=1e-4,DTt=1-SZe,RTt=1+SZe,CZe=.01,OTt=0-CZe,FTt=0+CZe;function ym(t){return t.max-t.min}function zTt(t,s,r){return Math.abs(t-s)<=r}function W6e(t,s,r,n=.5){t.origin=n,t.originPoint=sc(s.min,s.max,t.origin),t.scale=ym(r)/ym(s),t.translate=sc(r.min,r.max,t.origin)-t.originPoint,(t.scale>=DTt&&t.scale<=RTt||isNaN(t.scale))&&(t.scale=1),(t.translate>=OTt&&t.translate<=FTt||isNaN(t.translate))&&(t.translate=0)}function r8(t,s,r,n){W6e(t.x,s.x,r.x,n?n.originX:void 0),W6e(t.y,s.y,r.y,n?n.originY:void 0)}function K6e(t,s,r,n=0){const a=n?sc(r.min,r.max,n):r.min;t.min=a+s.min,t.max=t.min+ym(s)}function BTt(t,s,r,n){K6e(t.x,s.x,r.x,n==null?void 0:n.x),K6e(t.y,s.y,r.y,n==null?void 0:n.y)}function Z6e(t,s,r,n=0){const a=n?sc(r.min,r.max,n):r.min;t.min=s.min-a,t.max=t.min+ym(s)}function ple(t,s,r,n){Z6e(t.x,s.x,r.x,n==null?void 0:n.x),Z6e(t.y,s.y,r.y,n==null?void 0:n.y)}function Y6e(t,s,r,n,a){return t-=s,t=mle(t,1/r,n),a!==void 0&&(t=mle(t,1/a,n)),t}function $Tt(t,s=0,r=1,n=.5,a,o=t,l=t){if(o0.test(s)&&(s=parseFloat(s),s=sc(l.min,l.max,s/100)-l.min),typeof s!="number")return;let i=sc(o.min,o.max,n);t===o&&(i-=s),t.min=Y6e(t.min,s,r,i,a),t.max=Y6e(t.max,s,r,i,a)}function X6e(t,s,[r,n,a],o,l){$Tt(t,s[r],s[n],s[a],s.scale,o,l)}const qTt=["x","scaleX","originX"],UTt=["y","scaleY","originY"];function Q6e(t,s,r,n){X6e(t.x,s,qTt,r?r.x:void 0,n?n.x:void 0),X6e(t.y,s,UTt,r?r.y:void 0,n?n.y:void 0)}function J6e(t){return t.translate===0&&t.scale===1}function MZe(t){return J6e(t.x)&&J6e(t.y)}function eIe(t,s){return t.min===s.min&&t.max===s.max}function VTt(t,s){return eIe(t.x,s.x)&&eIe(t.y,s.y)}function tIe(t,s){return Math.round(t.min)===Math.round(s.min)&&Math.round(t.max)===Math.round(s.max)}function TZe(t,s){return tIe(t.x,s.x)&&tIe(t.y,s.y)}function sIe(t){return ym(t.x)/ym(t.y)}function rIe(t,s){return t.translate===s.translate&&t.scale===s.scale&&t.originPoint===s.originPoint}function My(t){return[t("x"),t("y")]}function HTt(t,s,r){let n="";const a=t.x.translate/s.x,o=t.y.translate/s.y,l=(r==null?void 0:r.z)||0;if((a||o||l)&&(n=`translate3d(${a}px, ${o}px, ${l}px) `),(s.x!==1||s.y!==1)&&(n+=`scale(${1/s.x}, ${1/s.y}) `),r){const{transformPerspective:u,rotate:p,rotateX:f,rotateY:y,skewX:_,skewY:b}=r;u&&(n=`perspective(${u}px) ${n}`),p&&(n+=`rotate(${p}deg) `),f&&(n+=`rotateX(${f}deg) `),y&&(n+=`rotateY(${y}deg) `),_&&(n+=`skewX(${_}deg) `),b&&(n+=`skewY(${b}deg) `)}const i=t.x.scale*s.x,d=t.y.scale*s.y;return(i!==1||d!==1)&&(n+=`scale(${i}, ${d})`),n||"none"}const AZe=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],GTt=AZe.length,nIe=t=>typeof t=="string"?parseFloat(t):t,aIe=t=>typeof t=="number"||na.test(t);function WTt(t,s,r,n,a,o){a?(t.opacity=sc(0,r.opacity??1,KTt(n)),t.opacityExit=sc(s.opacity??1,0,ZTt(n))):o&&(t.opacity=sc(s.opacity??1,r.opacity??1,n));for(let l=0;lns?1:r(oD(t,s,n))}function YTt(t,s,r){const n=ah(t)?t:BT(t);return n.start(wNe("",n,s,r)),n.animation}function dD(t,s,r,n={passive:!0}){return t.addEventListener(s,r,n),()=>t.removeEventListener(s,r)}const XTt=(t,s)=>t.depth-s.depth;class QTt{constructor(){this.children=[],this.isDirty=!1}add(s){dNe(this.children,s),this.isDirty=!0}remove(s){ole(this.children,s),this.isDirty=!0}forEach(s){this.isDirty&&this.children.sort(XTt),this.isDirty=!1,this.children.forEach(s)}}function JTt(t,s){const r=gm.now(),n=({timestamp:a})=>{const o=a-r;o>=s&&(tw(n),t(o-s))};return xl.setup(n,!0),()=>tw(n)}function Zie(t){return ah(t)?t.get():t}class eAt{constructor(){this.members=[]}add(s){dNe(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&&(ole(this.members,n),n.unmount())}s.scheduleRender()}remove(s){if(ole(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 Yie={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Ege=["","X","Y","Z"],tAt=1e3;let sAt=0;function Pge(t,s,r,n){const{latestValues:a}=s;a[t]&&(r[t]=a[t],s.setStaticValue(t,0),n&&(n[t]=0))}function PZe(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:s}=t.options;if(!s)return;const r=JKe(s);if(window.MotionHasOptimisedAnimation(r,"transform")){const{layout:a,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(r,"transform",xl,!(a||o))}const{parent:n}=t;n&&!n.hasCheckedOptimisedAppear&&PZe(n)}function IZe({attachResizeListener:t,defaultParent:s,measureScroll:r,checkIsScrollRoot:n,resetTransform:a}){return class{constructor(l={},i=s==null?void 0:s()){this.id=sAt++,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(aAt),this.nodes.forEach(uAt),this.nodes.forEach(hAt),this.nodes.forEach(iAt)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=l,this.root=i?i.root||i:this,this.path=i?[...i.path,i]:[],this.parent=i,this.depth=i?i.depth+1:0;for(let d=0;dthis.root.updateBlockedByResize=!1;xl.read(()=>{f=window.innerWidth}),t(l,()=>{const _=window.innerWidth;_!==f&&(f=_,this.root.updateBlockedByResize=!0,p&&p(),p=JTt(y,250),Yie.hasAnimatedSinceResize&&(Yie.hasAnimatedSinceResize=!1,this.nodes.forEach(cIe)))})}i&&this.root.registerSharedNode(i,this),this.options.animate!==!1&&u&&(i||d)&&this.addEventListener("didUpdate",({delta:p,hasLayoutChanged:f,hasRelativeLayoutChanged:y,layout:_})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const b=this.options.transition||u.getDefaultTransition()||gAt,{onLayoutAnimationStart:N,onLayoutAnimationComplete:w}=u.getProps(),S=!this.targetLayout||!TZe(this.targetLayout,_),C=!f&&y;if(this.options.layoutRoot||this.resumeFrom||C||f&&(S||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const A={...bNe(b,"layout"),onPlay:N,onComplete:w};(u.shouldReduceMotion||this.options.layoutRoot)&&(A.delay=0,A.type=!1),this.startAnimation(A),this.setAnimationOrigin(p,C)}else f||cIe(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=_})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const l=this.getStack();l&&l.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),tw(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(mAt),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&&PZe(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let p=0;p{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!ym(this.snapshot.measuredBox.x)&&!ym(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let d=0;d{const L=I/1e3;dIe(f.x,l.x,L),dIe(f.y,l.y,L),this.setTargetDelta(f),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(ple(y,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),fAt(this.relativeTarget,this.relativeTargetOrigin,y,L),A&&VTt(this.relativeTarget,A)&&(this.isProjectionDirty=!1),A||(A=tu()),og(A,this.relativeTarget)),N&&(this.animationValues=p,WTt(p,u,this.latestValues,L,C,S)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=L},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(l){var i,d,u;this.notifyListeners("animationStart"),(i=this.currentAnimation)==null||i.stop(),(u=(d=this.resumingFrom)==null?void 0:d.currentAnimation)==null||u.stop(),this.pendingAnimation&&(tw(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=xl.update(()=>{Yie.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=BT(0)),this.motionValue.jump(0,!1),this.currentAnimation=YTt(this.motionValue,[0,1e3],{...l,velocity:0,isSync:!0,onUpdate:p=>{this.mixTargetDelta(p),l.onUpdate&&l.onUpdate(p)},onStop:()=>{},onComplete:()=>{l.onComplete&&l.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const l=this.getStack();l&&l.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(tAt),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const l=this.getLead();let{targetWithTransforms:i,target:d,layout:u,latestValues:p}=l;if(!(!i||!d||!u)){if(this!==l&&this.layout&&u&&LZe(this.options.animationType,this.layout.layoutBox,u.layoutBox)){d=this.target||tu();const f=ym(this.layout.layoutBox.x);d.x.min=l.target.x.min,d.x.max=d.x.min+f;const y=ym(this.layout.layoutBox.y);d.y.min=l.target.y.min,d.y.max=d.y.min+y}og(i,d),Kie(i,p),r8(this.projectionDeltaWithTransform,this.layoutCorrected,i,p)}}registerSharedNode(l,i){this.sharedNodes.has(l)||this.sharedNodes.set(l,new eAt),this.sharedNodes.get(l).add(i);const u=i.options.initialPromotionConfig;i.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(i):void 0})}isLead(){const l=this.getStack();return l?l.lead===this:!0}getLead(){var i;const{layoutId:l}=this.options;return l?((i=this.getStack())==null?void 0:i.lead)||this:this}getPrevLead(){var i;const{layoutId:l}=this.options;return l?(i=this.getStack())==null?void 0:i.prevLead:void 0}getStack(){const{layoutId:l}=this.options;if(l)return this.root.sharedNodes.get(l)}promote({needsReset:l,transition:i,preserveFollowOpacity:d}={}){const u=this.getStack();u&&u.promote(this,d),l&&(this.projectionDelta=void 0,this.needsReset=!0),i&&this.setOptions({transition:i})}relegate(){const l=this.getStack();return l?l.relegate(this):!1}resetSkewAndRotation(){const{visualElement:l}=this.options;if(!l)return;let i=!1;const{latestValues:d}=l;if((d.z||d.rotate||d.rotateX||d.rotateY||d.rotateZ||d.skewX||d.skewY)&&(i=!0),!i)return;const u={};d.z&&Pge("z",l,u,this.animationValues);for(let p=0;p{var i;return(i=l.currentAnimation)==null?void 0:i.stop()}),this.root.nodes.forEach(oIe),this.root.sharedNodes.clear()}}}function rAt(t){t.updateLayout()}function nAt(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")My(f=>{const y=l?s.measuredBox[f]:s.layoutBox[f],_=ym(y);y.min=n[f].min,y.max=y.min+_});else if(o==="x"||o==="y"){const f=o==="x"?"y":"x";J1e(l?s.measuredBox[f]:s.layoutBox[f],n[f])}else LZe(o,s.layoutBox,n)&&My(f=>{const y=l?s.measuredBox[f]:s.layoutBox[f],_=ym(n[f]);y.max=y.min+_,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[f].max=t.relativeTarget[f].min+_)});const i=sM();r8(i,n,s.layoutBox);const d=sM();l?r8(d,t.applyTransform(a,!0),s.measuredBox):r8(d,n,s.layoutBox);const u=!MZe(i);let p=!1;if(!t.resumeFrom){const f=t.getClosestProjectingParent();if(f&&!f.resumeFrom){const{snapshot:y,layout:_}=f;if(y&&_){const b=t.options.layoutAnchor||void 0,N=tu();ple(N,s.layoutBox,y.layoutBox,b);const w=tu();ple(w,n,_.layoutBox,b),TZe(N,w)||(p=!0),f.options.layoutRoot&&(t.relativeTarget=w,t.relativeTargetOrigin=N,t.relativeParent=f)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:s,delta:d,layoutDelta:i,hasLayoutChanged:u,hasRelativeLayoutChanged:p})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function aAt(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 iAt(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function oAt(t){t.clearSnapshot()}function oIe(t){t.clearMeasurements()}function lAt(t){t.isLayoutDirty=!0,t.updateLayout()}function lIe(t){t.isLayoutDirty=!1}function cAt(t){t.isAnimationBlocked&&t.layout&&!t.isLayoutDirty&&(t.snapshot=t.layout,t.isLayoutDirty=!0)}function dAt(t){const{visualElement:s}=t.options;s&&s.getProps().onBeforeLayoutMeasure&&s.notify("BeforeLayoutMeasure"),t.resetTransform()}function cIe(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function uAt(t){t.resolveTargetDelta()}function hAt(t){t.calcProjection()}function mAt(t){t.resetSkewAndRotation()}function pAt(t){t.removeLeadSnapshot()}function dIe(t,s,r){t.translate=sc(s.translate,0,r),t.scale=sc(s.scale,1,r),t.origin=s.origin,t.originPoint=s.originPoint}function uIe(t,s,r,n){t.min=sc(s.min,r.min,n),t.max=sc(s.max,r.max,n)}function fAt(t,s,r,n){uIe(t.x,s.x,r.x,n),uIe(t.y,s.y,r.y,n)}function xAt(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const gAt={duration:.45,ease:[.4,0,.1,1]},hIe=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),mIe=hIe("applewebkit/")&&!hIe("chrome/")?Math.round:_x;function pIe(t){t.min=mIe(t.min),t.max=mIe(t.max)}function yAt(t){pIe(t.x),pIe(t.y)}function LZe(t,s,r){return t==="position"||t==="preserve-aspect"&&!zTt(sIe(s),sIe(r),.2)}function vAt(t){var s;return t!==t.root&&((s=t.scroll)==null?void 0:s.wasRoot)}const _At=IZe({attachResizeListener:(t,s)=>dD(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}),Ige={current:void 0},DZe=IZe({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Ige.current){const t=new _At({});t.mount(window),t.setOptions({layoutScroll:!0}),Ige.current=t}return Ige.current},resetTransform:(t,s)=>{t.style.transform=s!==void 0?s:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),LNe=k.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function fIe(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function bAt(...t){return s=>{let r=!1;const n=t.map(a=>{const o=fIe(a,s);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a{const{width:_,height:b,top:N,left:w,right:S,bottom:C}=d.current;if(s||o===!1||!i.current||!_||!b)return;const A=r==="left"?`left: ${w}`:`right: ${S}`,I=n==="bottom"?`bottom: ${C}`:`top: ${N}`;i.current.dataset.motionPopId=l;const L=document.createElement("style");u&&(L.nonce=u);const O=a??document.head;return O.appendChild(L),L.sheet&&L.sheet.insertRule(` [data-motion-pop-id="${l}"] { position: absolute !important; width: ${_}px !important; height: ${b}px !important; ${A}px !important; ${I}px !important; } `),()=>{var V;(V=i.current)==null||V.removeAttribute("data-motion-pop-id"),O.contains(L)&&O.removeChild(L)}},[s]),e.jsx(jAt,{isPresent:s,childRef:i,sizeRef:d,pop:o,children:o===!1?t:k.cloneElement(t,{ref:f})})}const kAt=({children:t,initial:s,isPresent:r,onExitComplete:n,custom:a,presenceAffectsLayout:o,mode:l,anchorX:i,anchorY:d,root:u})=>{const p=cNe(SAt),f=k.useId();let y=!0,_=k.useMemo(()=>(y=!1,{id:f,initial:s,isPresent:r,custom:a,onExitComplete:b=>{p.set(b,!0);for(const N of p.values())if(!N)return;n&&n()},register:b=>(p.set(b,!1),()=>p.delete(b))}),[r,p,n]);return o&&y&&(_={..._}),k.useMemo(()=>{p.forEach((b,N)=>p.set(N,!1))},[r]),k.useEffect(()=>{!r&&!p.size&&n&&n()},[r]),t=e.jsx(NAt,{pop:l==="popLayout",isPresent:r,anchorX:i,anchorY:d,root:u,children:t}),e.jsx(Bue.Provider,{value:_,children:t})};function SAt(){return new Map}function RZe(t=!0){const s=k.useContext(Bue);if(s===null)return[!0,null];const{isPresent:r,onExitComplete:n,register:a}=s,o=k.useId();k.useEffect(()=>{if(t)return a(o)},[t]);const l=k.useCallback(()=>t&&n&&n(o),[o,n,t]);return!r&&n?[!1,l]:[!0]}const Iz=t=>t.key||"";function xIe(t){const s=[];return k.Children.forEach(t,r=>{k.isValidElement(r)&&s.push(r)}),s}const DNe=({children:t,custom:s,initial:r=!0,onExitComplete:n,presenceAffectsLayout:a=!0,mode:o="sync",propagate:l=!1,anchorX:i="left",anchorY:d="top",root:u})=>{const[p,f]=RZe(l),y=k.useMemo(()=>xIe(t),[t]),_=l&&!p?[]:y.map(Iz),b=k.useRef(!0),N=k.useRef(y),w=cNe(()=>new Map),S=k.useRef(new Set),[C,A]=k.useState(y),[I,L]=k.useState(y);dKe(()=>{b.current=!1,N.current=y;for(let q=0;q{const B=Iz(q),U=l&&!p?!1:y===I||_.includes(B),te=()=>{if(S.current.has(B))return;if(w.has(B))S.current.add(B),w.set(B,!0);else return;let Y=!0;w.forEach(J=>{J||(Y=!1)}),Y&&(V==null||V(),L(N.current),l&&(f==null||f()),n&&n())};return e.jsx(kAt,{isPresent:U,initial:!b.current||r?void 0:!1,custom:s,presenceAffectsLayout:a,mode:o,root:u,onExitComplete:U?void 0:te,anchorX:i,anchorY:d,children:q},B)})})},OZe=k.createContext({strict:!1}),gIe={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 yIe=!1;function CAt(){if(yIe)return;const t={};for(const s in gIe)t[s]={isEnabled:r=>gIe[s].some(n=>!!r[n])};hZe(t),yIe=!0}function FZe(){return CAt(),uTt()}function MAt(t){const s=FZe();for(const r in t)s[r]={...s[r],...t[r]};hZe(s)}const TAt=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 fle(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||TAt.has(t)}let zZe=t=>!fle(t);function AAt(t){typeof t=="function"&&(zZe=s=>s.startsWith("on")?!fle(s):t(s))}try{AAt(require("@emotion/is-prop-valid").default)}catch{}function EAt(t,s,r){const n={};for(const a in t)a==="values"&&typeof t.values=="object"||ah(t[a])||(zZe(a)||r===!0&&fle(a)||!s&&!fle(a)||t.draggable&&a.startsWith("onDrag"))&&(n[a]=t[a]);return n}const Hue=k.createContext({});function PAt(t,s){if(Vue(t)){const{initial:r,animate:n}=t;return{initial:r===!1||cD(r)?r:void 0,animate:cD(n)?n:void 0}}return t.inherit!==!1?s:{}}function IAt(t){const{initial:s,animate:r}=PAt(t,k.useContext(Hue));return k.useMemo(()=>({initial:s,animate:r}),[vIe(s),vIe(r)])}function vIe(t){return Array.isArray(t)?t.join(" "):t}const RNe=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function BZe(t,s,r){for(const n in s)!ah(s[n])&&!vZe(n,r)&&(t[n]=s[n])}function LAt({transformTemplate:t},s){return k.useMemo(()=>{const r=RNe();return PNe(r,s,t),Object.assign({},r.vars,r.style)},[s])}function DAt(t,s){const r=t.style||{},n={};return BZe(n,r,t),Object.assign(n,LAt(t,s)),n}function RAt(t,s){const r={},n=DAt(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 $Ze=()=>({...RNe(),attrs:{}});function OAt(t,s,r,n){const a=k.useMemo(()=>{const o=$Ze();return _Ze(o,s,wZe(n),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[s]);if(t.style){const o={};BZe(o,t.style,t),a.style={...o,...a.style}}return a}const FAt=["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 ONe(t){return typeof t!="string"||t.includes("-")?!1:!!(FAt.indexOf(t)>-1||/[A-Z]/u.test(t))}function zAt(t,s,r,{latestValues:n},a,o=!1,l){const d=(l??ONe(t)?OAt:RAt)(s,n,a,t),u=EAt(s,typeof t=="string",o),p=t!==k.Fragment?{...u,...d,ref:r}:{},{children:f}=s,y=k.useMemo(()=>ah(f)?f.get():f,[f]);return k.createElement(t,{...p,children:y})}function BAt({scrapeMotionValuesFromProps:t,createRenderState:s},r,n,a){return{latestValues:$At(r,n,a,t),renderState:s()}}function $At(t,s,r,n){const a={},o=n(t,{});for(const y in o)a[y]=Zie(o[y]);let{initial:l,animate:i}=t;const d=Vue(t),u=dZe(t);s&&u&&!d&&t.inherit!==!1&&(l===void 0&&(l=s.initial),i===void 0&&(i=s.animate));let p=r?r.initial===!1:!1;p=p||l===!1;const f=p?i:l;if(f&&typeof f!="boolean"&&!Uue(f)){const y=Array.isArray(f)?f:[f];for(let _=0;_(s,r)=>{const n=k.useContext(Hue),a=k.useContext(Bue),o=()=>BAt(t,s,n,a);return r?o():cNe(o)},qAt=qZe({scrapeMotionValuesFromProps:INe,createRenderState:RNe}),UAt=qZe({scrapeMotionValuesFromProps:jZe,createRenderState:$Ze}),VAt=Symbol.for("motionComponentSymbol");function HAt(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 d=l(o);typeof d=="function"&&(a.current=d)}else a.current?(a.current(),a.current=null):l(o);else l&&(l.current=o);s&&(o?s.mount(o):s.unmount())},[s])}const UZe=k.createContext({});function I5(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function GAt(t,s,r,n,a,o){var A,I;const{visualElement:l}=k.useContext(Hue),i=k.useContext(OZe),d=k.useContext(Bue),u=k.useContext(LNe),p=u.reducedMotion,f=u.skipAnimations,y=k.useRef(null),_=k.useRef(!1);n=n||i.renderer,!y.current&&n&&(y.current=n(t,{visualState:s,parent:l,props:r,presenceContext:d,blockInitialAnimation:d?d.initial===!1:!1,reducedMotionConfig:p,skipAnimations:f,isSVG:o}),_.current&&y.current&&(y.current.manuallyAnimateOnMount=!0));const b=y.current,N=k.useContext(UZe);b&&!b.projection&&a&&(b.type==="html"||b.type==="svg")&&WAt(y.current,r,a,N);const w=k.useRef(!1);k.useInsertionEffect(()=>{b&&w.current&&b.update(r,d)});const S=r[QKe],C=k.useRef(!!S&&typeof window<"u"&&!((A=window.MotionHandoffIsComplete)!=null&&A.call(window,S))&&((I=window.MotionHasOptimisedAnimation)==null?void 0:I.call(window,S)));return dKe(()=>{_.current=!0,b&&(w.current=!0,window.MotionIsMounted=!0,b.updateFeatures(),b.scheduleRenderMicrotask(),C.current&&b.animationState&&b.animationState.animateChanges())}),k.useEffect(()=>{b&&(!C.current&&b.animationState&&b.animationState.animateChanges(),C.current&&(queueMicrotask(()=>{var L;(L=window.MotionHandoffMarkAsComplete)==null||L.call(window,S)}),C.current=!1),b.enteringChildren=void 0)}),b}function WAt(t,s,r,n){const{layoutId:a,layout:o,drag:l,dragConstraints:i,layoutScroll:d,layoutRoot:u,layoutAnchor:p,layoutCrossfade:f}=s;t.projection=new r(t.latestValues,s["data-framer-portal-id"]?void 0:VZe(t.parent)),t.projection.setOptions({layoutId:a,layout:o,alwaysMeasureLayout:!!l||i&&I5(i),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:n,crossfade:f,layoutScroll:d,layoutRoot:u,layoutAnchor:p})}function VZe(t){if(t)return t.options.allowProjection!==!1?t.projection:VZe(t.parent)}function Lge(t,{forwardMotionProps:s=!1,type:r}={},n,a){n&&MAt(n);const o=r?r==="svg":ONe(t),l=o?UAt:qAt;function i(u,p){let f;const y={...k.useContext(LNe),...u,layoutId:KAt(u)},{isStatic:_}=y,b=IAt(u),N=l(u,_);if(!_&&typeof window<"u"){ZAt();const w=YAt(y);f=w.MeasureLayout,b.visualElement=GAt(t,N,y,a,w.ProjectionNode,o)}return e.jsxs(Hue.Provider,{value:b,children:[f&&b.visualElement?e.jsx(f,{visualElement:b.visualElement,...y}):null,zAt(t,u,HAt(N,b.visualElement,p),N,_,s,o)]})}i.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const d=k.forwardRef(i);return d[VAt]=t,d}function KAt({layoutId:t}){const s=k.useContext(lNe).id;return s&&t!==void 0?s+"-"+t:t}function ZAt(t,s){k.useContext(OZe).strict}function YAt(t){const s=FZe(),{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 XAt(t,s){if(typeof Proxy>"u")return Lge;const r=new Map,n=(o,l)=>Lge(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,Lge(l,void 0,t,s)),r.get(l))})}const QAt=(t,s)=>s.isSVG??ONe(t)?new MTt(s):new wTt(s,{allowProjection:t!==k.Fragment});class JAt extends yw{constructor(s){super(s),s.animationState||(s.animationState=ITt(s))}updateAnimationControlsSubscription(){const{animate:s}=this.node.getProps();Uue(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 eEt=0;class tEt extends yw{constructor(){super(...arguments),this.id=eEt++,this.isExitComplete=!1}update(){var o;if(!this.node.presenceContext)return;const{isPresent:s,onExitComplete:r}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||s===n)return;if(s&&n===!1){if(this.isExitComplete){const{initial:l,custom:i}=this.node.getProps();if(typeof l=="string"){const d=kS(this.node,l,i);if(d){const{transition:u,transitionEnd:p,...f}=d;for(const y in f)(o=this.node.getValue(y))==null||o.jump(f[y])}}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 sEt={animation:{Feature:JAt},exit:{Feature:tEt}};function VR(t){return{point:{x:t.pageX,y:t.pageY}}}const rEt=t=>s=>MNe(s)&&t(s,VR(s));function n8(t,s,r,n){return dD(t,s,rEt(r),n)}const HZe=({current:t})=>t?t.ownerDocument.defaultView:null,_Ie=(t,s)=>Math.abs(t-s);function nEt(t,s){const r=_Ie(t.x,s.x),n=_Ie(t.y,s.y);return Math.sqrt(r**2+n**2)}const bIe=new Set(["auto","scroll"]);class GZe{constructor(s,r,{transformPagePoint:n,contextWindow:a=window,dragSnapToOrigin:o=!1,distanceThreshold:l=3,element:i}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=_=>{this.handleScroll(_.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Lz(this.lastRawMoveEventInfo,this.transformPagePoint));const _=Dge(this.lastMoveEventInfo,this.history),b=this.startEvent!==null,N=nEt(_.offset,{x:0,y:0})>=this.distanceThreshold;if(!b&&!N)return;const{point:w}=_,{timestamp:S}=sh;this.history.push({...w,timestamp:S});const{onStart:C,onMove:A}=this.handlers;b||(C&&C(this.lastMoveEvent,_),this.startEvent=this.lastMoveEvent),A&&A(this.lastMoveEvent,_)},this.handlePointerMove=(_,b)=>{this.lastMoveEvent=_,this.lastRawMoveEventInfo=b,this.lastMoveEventInfo=Lz(b,this.transformPagePoint),xl.update(this.updatePoint,!0)},this.handlePointerUp=(_,b)=>{this.end();const{onEnd:N,onSessionEnd:w,resumeAnimation:S}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&S&&S(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const C=Dge(_.type==="pointercancel"?this.lastMoveEventInfo:Lz(b,this.transformPagePoint),this.history);this.startEvent&&N&&N(_,C),w&&w(_,C)},!MNe(s))return;this.dragSnapToOrigin=o,this.handlers=r,this.transformPagePoint=n,this.distanceThreshold=l,this.contextWindow=a||window;const d=VR(s),u=Lz(d,this.transformPagePoint),{point:p}=u,{timestamp:f}=sh;this.history=[{...p,timestamp:f}];const{onSessionStart:y}=r;y&&y(s,Dge(u,this.history)),this.removeListeners=$R(n8(this.contextWindow,"pointermove",this.handlePointerMove),n8(this.contextWindow,"pointerup",this.handlePointerUp),n8(this.contextWindow,"pointercancel",this.handlePointerUp)),i&&this.startScrollTracking(i)}startScrollTracking(s){let r=s.parentElement;for(;r;){const n=getComputedStyle(r);(bIe.has(n.overflowX)||bIe.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),xl.update(this.updatePoint,!0))}updateHandlers(s){this.handlers=s}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),tw(this.updatePoint)}}function Lz(t,s){return s?{point:s(t.point)}:t}function wIe(t,s){return{x:t.x-s.x,y:t.y-s.y}}function Dge({point:t},s){return{point:t,delta:wIe(t,WZe(s)),offset:wIe(t,aEt(s)),velocity:iEt(s,.1)}}function aEt(t){return t[0]}function WZe(t){return t[t.length-1]}function iEt(t,s){if(t.length<2)return{x:0,y:0};let r=t.length-1,n=null;const a=WZe(t);for(;r>=0&&(n=t[r],!(a.timestamp-n.timestamp>yp(s)));)r--;if(!n)return{x:0,y:0};n===t[0]&&t.length>2&&a.timestamp-n.timestamp>yp(s)*2&&(n=t[1]);const o=ux(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 oEt(t,{min:s,max:r},n){return s!==void 0&&tr&&(t=n?sc(r,t,n.max):Math.min(t,r)),t}function jIe(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 lEt(t,{top:s,left:r,bottom:n,right:a}){return{x:jIe(t.x,r,a),y:jIe(t.y,s,n)}}function NIe(t,s){let r=s.min-t.min,n=s.max-t.max;return s.max-s.minn?r=oD(s.min,s.max-n,t.min):n>a&&(r=oD(t.min,t.max-a,s.min)),p0(0,1,r)}function uEt(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 e_e=.35;function hEt(t=e_e){return t===!1?t=0:t===!0&&(t=e_e),{x:kIe(t,"left","right"),y:kIe(t,"top","bottom")}}function kIe(t,s,r){return{min:SIe(t,s),max:SIe(t,r)}}function SIe(t,s){return typeof t=="number"?t:t[s]||0}const mEt=new WeakMap;class pEt{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=tu(),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(VR(f).point),this.stopAnimation()},l=(f,y)=>{const{drag:_,dragPropagation:b,onDragStart:N}=this.getProps();if(_&&!b&&(this.openDragLock&&this.openDragLock(),this.openDragLock=$Mt(_),!this.openDragLock))return;this.latestPointerEvent=f,this.latestPanInfo=y,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),My(S=>{let C=this.getAxisMotionValue(S).get()||0;if(o0.test(C)){const{projection:A}=this.visualElement;if(A&&A.layout){const I=A.layout.layoutBox[S];I&&(C=ym(I)*(parseFloat(C)/100))}}this.originPoint[S]=C}),N&&xl.update(()=>N(f,y),!1,!0),H1e(this.visualElement,"transform");const{animationState:w}=this.visualElement;w&&w.setActive("whileDrag",!0)},i=(f,y)=>{this.latestPointerEvent=f,this.latestPanInfo=y;const{dragPropagation:_,dragDirectionLock:b,onDirectionLock:N,onDrag:w}=this.getProps();if(!_&&!this.openDragLock)return;const{offset:S}=y;if(b&&this.currentDirection===null){this.currentDirection=xEt(S),this.currentDirection!==null&&N&&N(this.currentDirection);return}this.updateAxis("x",y.point,S),this.updateAxis("y",y.point,S),this.visualElement.render(),w&&xl.update(()=>w(f,y),!1,!0)},d=(f,y)=>{this.latestPointerEvent=f,this.latestPanInfo=y,this.stop(f,y),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>{const{dragSnapToOrigin:f}=this.getProps();(f||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:p}=this.getProps();this.panSession=new GZe(s,{onSessionStart:o,onStart:l,onMove:i,onSessionEnd:d,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:p,distanceThreshold:n,contextWindow:HZe(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&&xl.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||!Dz(s,a,this.currentDirection))return;const o=this.getAxisMotionValue(s);let l=this.originPoint[s]+n[s];this.constraints&&this.constraints[s]&&(l=oEt(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&&I5(s)?this.constraints||(this.constraints=this.resolveRefConstraints()):s&&n?this.constraints=lEt(n.layoutBox,s):this.constraints=!1,this.elastic=hEt(r),a!==this.constraints&&!I5(s)&&n&&this.constraints&&!this.hasMutatedConstraints&&My(l=>{this.constraints!==!1&&this.getAxisMotionValue(l)&&(this.constraints[l]=uEt(n.layoutBox[l],this.constraints[l]))})}resolveRefConstraints(){const{dragConstraints:s,onMeasureDragConstraints:r}=this.getProps();if(!s||!I5(s))return!1;const n=s.current;FT(n!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const o=xTt(n,a.root,this.visualElement.getTransformPagePoint());let l=cEt(a.layout.layoutBox,o);if(r){const i=r(mTt(l));this.hasMutatedConstraints=!!i,i&&(l=pZe(i))}return l}startAnimation(s){const{drag:r,dragMomentum:n,dragElastic:a,dragTransition:o,dragSnapToOrigin:l,onDragTransitionEnd:i}=this.getProps(),d=this.constraints||{},u=My(p=>{if(!Dz(p,r,this.currentDirection))return;let f=d&&d[p]||{};(l===!0||l===p)&&(f={min:0,max:0});const y=a?200:1e6,_=a?40:1e7,b={type:"inertia",velocity:n?s[p]:0,bounceStiffness:y,bounceDamping:_,timeConstant:750,restDelta:1,restSpeed:10,...o,...f};return this.startAxisValueAnimation(p,b)});return Promise.all(u).then(i)}startAxisValueAnimation(s,r){const n=this.getAxisMotionValue(s);return H1e(this.visualElement,s),n.start(wNe(s,n,0,r,this.visualElement,!1))}stopAnimation(){My(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){My(r=>{const{drag:n}=this.getProps();if(!Dz(r,n,this.currentDirection))return;const{projection:a}=this.visualElement,o=this.getAxisMotionValue(r);if(a&&a.layout){const{min:l,max:i}=a.layout.layoutBox[r],d=o.get()||0;o.set(s[r]-sc(l,i,.5)+d)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:s,dragConstraints:r}=this.getProps(),{projection:n}=this.visualElement;if(!I5(r)||!n||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};My(l=>{const i=this.getAxisMotionValue(l);if(i&&this.constraints!==!1){const d=i.get();a[l]=dEt({min:d,max:d},this.constraints[l])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),My(l=>{if(!Dz(l,s,null))return;const i=this.getAxisMotionValue(l),{min:d,max:u}=this.constraints[l];i.set(sc(d,u,a[l]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;mEt.set(this.visualElement,this);const s=this.visualElement.current,r=n8(s,"pointerdown",u=>{const{drag:p,dragListener:f=!0}=this.getProps(),y=u.target,_=y!==s&&WMt(y);p&&f&&!_&&this.start(u)});let n;const a=()=>{const{dragConstraints:u}=this.getProps();I5(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),n||(n=fEt(s,u.current,()=>this.scalePositionWithinConstraints())))},{projection:o}=this.visualElement,l=o.addEventListener("measure",a);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),xl.read(a);const i=dD(window,"resize",()=>this.scalePositionWithinConstraints()),d=o.addEventListener("didUpdate",({delta:u,hasLayoutChanged:p})=>{this.isDragging&&p&&(My(f=>{const y=this.getAxisMotionValue(f);y&&(this.originPoint[f]+=u[f].translate,y.set(y.get()+u[f].translate))}),this.visualElement.render())});return()=>{i(),r(),l(),d&&d(),n&&n()}}getProps(){const s=this.visualElement.getProps(),{drag:r=!1,dragDirectionLock:n=!1,dragPropagation:a=!1,dragConstraints:o=!1,dragElastic:l=e_e,dragMomentum:i=!0}=s;return{...s,drag:r,dragDirectionLock:n,dragPropagation:a,dragConstraints:o,dragElastic:l,dragMomentum:i}}}function CIe(t){let s=!0;return()=>{if(s){s=!1;return}t()}}function fEt(t,s,r){const n=L6e(t,CIe(r)),a=L6e(s,CIe(r));return()=>{n(),a()}}function Dz(t,s,r){return(s===!0||s===t)&&(r===null||r===t)}function xEt(t,s=10){let r=null;return Math.abs(t.y)>s?r="y":Math.abs(t.x)>s&&(r="x"),r}class gEt extends yw{constructor(s){super(s),this.removeGroupControls=_x,this.removeListeners=_x,this.controls=new pEt(s)}mount(){const{dragControls:s}=this.node.getProps();s&&(this.removeGroupControls=s.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||_x}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 Rge=t=>(s,r)=>{t&&xl.update(()=>t(s,r),!1,!0)};class yEt extends yw{constructor(){super(...arguments),this.removePointerDownListener=_x}onPointerDown(s){this.session=new GZe(s,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:HZe(this.node)})}createPanHandlers(){const{onPanSessionStart:s,onPanStart:r,onPan:n,onPanEnd:a}=this.node.getProps();return{onSessionStart:Rge(s),onStart:Rge(r),onMove:Rge(n),onEnd:(o,l)=>{delete this.session,a&&xl.postRender(()=>a(o,l))}}}mount(){this.removePointerDownListener=n8(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 Oge=!1;class vEt 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),Oge&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Yie.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}),Oge=!0,a||s.layoutDependency!==r||r===void 0||s.isPresent!==o?l.willUpdate():this.safeToRemove(),s.isPresent!==o&&(o?l.promote():l.relegate()||xl.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(),CNe.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:s,layoutGroup:r,switchLayoutGroup:n}=this.props,{projection:a}=s;Oge=!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 KZe(t){const[s,r]=RZe(),n=k.useContext(lNe);return e.jsx(vEt,{...t,layoutGroup:n,switchLayoutGroup:k.useContext(UZe),isPresent:s,safeToRemove:r})}const _Et={pan:{Feature:yEt},drag:{Feature:gEt,ProjectionNode:DZe,MeasureLayout:KZe}};function MIe(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&&xl.postRender(()=>o(s,VR(s)))}class bEt extends yw{mount(){const{current:s}=this.node;s&&(this.unmount=UMt(s,(r,n)=>(MIe(this.node,n,"Start"),a=>MIe(this.node,a,"End"))))}unmount(){}}class wEt extends yw{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=$R(dD(this.node.current,"focus",()=>this.onFocus()),dD(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function TIe(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&&xl.postRender(()=>o(s,VR(s)))}class jEt extends yw{mount(){const{current:s}=this.node;if(!s)return;const{globalTapTarget:r,propagate:n}=this.node.props;this.unmount=ZMt(s,(a,o)=>(TIe(this.node,o,"Start"),(l,{success:i})=>TIe(this.node,l,i?"End":"Cancel")),{useGlobalTarget:r,stopPropagation:(n==null?void 0:n.tap)===!1})}unmount(){}}const t_e=new WeakMap,Fge=new WeakMap,NEt=t=>{const s=t_e.get(t.target);s&&s(t)},kEt=t=>{t.forEach(NEt)};function SEt({root:t,...s}){const r=t||document;Fge.has(r)||Fge.set(r,{});const n=Fge.get(r),a=JSON.stringify(s);return n[a]||(n[a]=new IntersectionObserver(kEt,{root:t,...s})),n[a]}function CEt(t,s,r){const n=SEt(s);return t_e.set(t,r),n.observe(t),()=>{t_e.delete(t),n.unobserve(t)}}const MEt={some:0,all:1};class TEt extends yw{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var d;(d=this.stopObserver)==null||d.call(this);const{viewport:s={}}=this.node.getProps(),{root:r,margin:n,amount:a="some",once:o}=s,l={root:r?r.current:void 0,rootMargin:n,threshold:typeof a=="number"?a:MEt[a]},i=u=>{const{isIntersecting:p}=u;if(this.isInView===p||(this.isInView=p,o&&!p&&this.hasEnteredView))return;p&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",p);const{onViewportEnter:f,onViewportLeave:y}=this.node.getProps(),_=p?f:y;_&&_(u)};this.stopObserver=CEt(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(AEt(s,r))&&this.startObserver()}unmount(){var s;(s=this.stopObserver)==null||s.call(this),this.hasEnteredView=!1,this.isInView=!1}}function AEt({viewport:t={}},{viewport:s={}}={}){return r=>t[r]!==s[r]}const EEt={inView:{Feature:TEt},tap:{Feature:jEt},focus:{Feature:wEt},hover:{Feature:bEt}},PEt={layout:{ProjectionNode:DZe,MeasureLayout:KZe}},IEt={...sEt,...EEt,..._Et,...PEt},hr=XAt(IEt,QAt),LEt={some:0,all:1};function DEt(t,s,{root:r,margin:n,amount:a="some"}={}){const o=SNe(t),l=new WeakMap,i=u=>{u.forEach(p=>{const f=l.get(p.target);if(p.isIntersecting!==!!f)if(p.isIntersecting){const y=s(p.target,p);typeof y=="function"?l.set(p.target,y):d.unobserve(p.target)}else typeof f=="function"&&(f(p),l.delete(p.target))})},d=new IntersectionObserver(i,{root:r,rootMargin:n,threshold:typeof a=="number"?a:LEt[a]});return o.forEach(u=>d.observe(u)),()=>d.disconnect()}function REt(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 d=()=>(i(!0),a?void 0:()=>i(!1)),u={root:s&&s.current||void 0,margin:r,amount:n};return DEt(t.current,d,u)},[s,t,r,a,n]),l}function OEt(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 AIe(t){return t.visitor_intent==="buying"&&!t.has_agent}function FEt({token:t}={}){var b;const s=io(),r=t||s.token,{data:n,isLoading:a,isError:o}=w3t(r),l=Qt(),i=(b=n==null?void 0:n.open_houses)==null?void 0:b.id,{data:d}=gt({queryKey:["cohost-visitors",i],queryFn:async()=>{const{data:N,error:w}=await G.from("open_house_visitors").select("*").eq("open_house_id",i).order("created_at",{ascending:!1});if(w)throw w;return N},enabled:!!i});if(k.useEffect(()=>{if(!i)return;const N=G.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()=>{G.removeChannel(N)}},[i,l]),a)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 flex items-center justify-center",children:e.jsx("div",{className:"animate-pulse text-white/40",children:"Validating access..."})});if(o||!n)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx("h1",{className:"text-xl font-bold mb-2",children:"Link Expired or Invalid"}),e.jsx("p",{className:"text-white/40 text-sm",children:"This co-host link is no longer active. Ask the host for a new one."})]})});const u=n.open_houses,p=(d==null?void 0:d.length)||0,f=(d==null?void 0:d.filter(N=>N.visitor_intent==="buying").length)||0,y=(d==null?void 0:d.filter(AIe).length)||0,_=N=>{if(!N)return"";const[w,S]=N.split(":"),C=parseInt(w);return`${C>12?C-12:C||12}:${S} ${C>=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(ir,{className:"h-4 w-4"}),e.jsx("span",{className:"font-bold text-white",children:p})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-orange-400",children:[e.jsx(rd,{className:"h-4 w-4"}),e.jsx("span",{className:"font-bold text-white",children:y})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Mn,{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:vs(new Date(u.event_date+"T00:00:00"),"EEEE, MMMM d, yyyy")}),u.start_time&&e.jsxs("span",{children:[_(u.start_time),u.end_time?` – ${_(u.end_time)}`:""]})]}),e.jsx(Ja,{className:"flex-1 p-4 sm:p-6",children:d!=null&&d.length?e.jsx("div",{className:"space-y-2 max-w-3xl mx-auto",children:e.jsx(DNe,{children:d.map((N,w)=>{var A;const S=OEt(N.visitor_intent),C=AIe(N);return e.jsxs(hr.div,{initial:{opacity:0,x:-40,scale:.95},animate:{opacity:1,x:0,scale:1},transition:{duration:.4,delay:w*.05},className:`flex items-center gap-4 p-4 rounded-xl border ${C?"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 ${C?"bg-gradient-to-br from-orange-500 to-amber-500 text-white":"bg-white/10 text-white/80"}`,children:(A=N.first_name[0])==null?void 0:A.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:[N.first_name," ",N.last_name||""]}),C&&e.jsx(Qe,{className:"bg-orange-500/20 text-orange-300 border-orange-500/40 text-[10px] px-1.5 py-0",children:"🔥 HOT"}),N.has_agent&&e.jsx(Qe,{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(Qe,{variant:"outline",className:`text-[10px] px-1.5 py-0 ${S.color}`,children:[S.emoji," ",S.label]}),e.jsx("span",{className:"text-white/30 text-xs",children:vs(new Date(N.created_at),"h:mm a")})]})]})]},N.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(e1,{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 zEt(){const s=$l().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(FEt,{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(YWe,{slug:s})}function BEt({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(Mn,{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(Ia,{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(In,{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(tr,{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(Fl,{className:"w-4 h-4 text-[#406E71]"}),e.jsx("span",{className:"text-sm font-medium text-[#406E71]",children:"Text"})]})]})})})]})}function $Et({journeyStages:t,currentIndex:s}){return t.length===0?null:e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-slate-100",children:[e.jsx("h2",{className:"text-base font-semibold text-slate-800 mb-1",children:"Your Home Journey"}),e.jsx("p",{className:"text-xs text-slate-400 mb-5",children:"Follow along as your transaction progresses"}),e.jsx("div",{className:"relative",children:t.map((r,n)=>{const a=ns;return e.jsxs("div",{className:"flex items-start gap-3.5 relative",children:[n{var l,i;if(o.includes("youtube.com/watch")){const d=new URL(o).searchParams.get("v");return d?`https://www.youtube.com/embed/${d}`:null}if(o.includes("youtu.be/")){const d=(l=o.split("youtu.be/")[1])==null?void 0:l.split("?")[0];return d?`https://www.youtube.com/embed/${d}`:null}if(o.includes("loom.com/share/")){const d=(i=o.split("loom.com/share/")[1])==null?void 0:i.split("?")[0];return d?`https://www.loom.com/embed/${d}`:null}return o};return e.jsxs("div",{className:"bg-gradient-to-br from-[#406E71]/5 via-white to-[#406E71]/5 rounded-2xl border border-[#406E71]/15 overflow-hidden",children:[e.jsx("div",{className:"bg-[#406E71] px-5 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Wa,{className:"w-4 h-4 text-white/80"}),e.jsx("h3",{className:"text-sm font-semibold text-white",children:"Current Stage"})]})}),e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-lg font-bold text-slate-800",children:t.label}),e.jsx("p",{className:"text-sm text-slate-500 mt-1 leading-relaxed",children:t.description})]}),s&&e.jsxs("div",{className:"bg-slate-50 rounded-xl p-4 border border-slate-100",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider mb-1.5",children:"Update from your agent"}),e.jsx("p",{className:"text-sm text-slate-700 leading-relaxed",children:s})]}),r&&e.jsxs("div",{className:"bg-blue-50/60 rounded-xl p-4 border border-blue-100",children:[e.jsx("p",{className:"text-xs font-semibold text-blue-600 uppercase tracking-wider mb-1.5",children:"What's Next"}),e.jsx("p",{className:"text-sm text-blue-800 leading-relaxed",children:r})]}),n&&e.jsx("div",{className:"rounded-xl overflow-hidden bg-slate-900 aspect-video shadow-md",children:e.jsx("iframe",{src:a(n)||n,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:"Next step video"})})]})]})}function ol(t){const s=t.split(/[-/T]/);if(s.length>=3){const r=Number(s[0]);return r>99?new Date(r,Number(s[1])-1,Number(s[2])):new Date(Number(s[2]),Number(s[0])-1,Number(s[1]))}return new Date(`${t}T12:00:00`)}function VEt(t,s){const r=vs(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 HEt(t,s){const r=vs(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 GEt({targetCloseDate:t,contractDate:s,inspectionDate:r,appraisalDate:n,actualCloseDate:a}){const o=[{label:"Contract Date",date:s,icon:wM,color:"text-blue-600 bg-blue-50"},{label:"Inspection",date:r,icon:ln,color:"text-amber-600 bg-amber-50"},{label:"Appraisal",date:n,icon:Mn,color:"text-purple-600 bg-purple-50"},{label:a?"Closed":"Target Close",date:a||t,icon:cn,color:"text-emerald-600 bg-emerald-50"}].filter(i=>i.date);if(o.length===0)return null;const l=(i,d,u)=>{const p=ol(d);if(u==="google")window.open(VEt(i,p),"_blank");else{const f=HEt(i,p),y=document.createElement("a");y.href=f,y.download=`${i.replace(/\s+/g,"-").toLowerCase()}.ics`,y.click()}};return e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-slate-100",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-800 mb-3",children:"Key Dates"}),e.jsx("div",{className:"space-y-3",children:o.map(({label:i,date:d,icon:u,color:p})=>{const f=ol(d),y=a0(f)&&!iu(f),_=iu(f),b=!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 ${p}`,children:e.jsx(u,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs text-slate-500",children:i}),e.jsxs("p",{className:`text-sm font-medium ${_?"text-emerald-600":y?"text-slate-400":"text-slate-800"}`,children:[vs(f,"MMM d, yyyy"),_&&e.jsx("span",{className:"ml-1.5 text-xs bg-emerald-100 text-emerald-700 px-1.5 py-0.5 rounded-full",children:"Today"})]})]}),y&&e.jsx("span",{className:"text-xs text-slate-400",children:"✓"}),b&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>l(i,d,"google"),className:"text-xs text-slate-400 hover:text-blue-500 transition-colors px-1.5 py-1 rounded hover:bg-blue-50",title:"Add to Google Calendar",children:e.jsx(jb,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>l(i,d,"apple"),className:"text-[10px] text-slate-400 hover:text-slate-600 transition-colors px-1.5 py-1 rounded hover:bg-slate-100",title:"Download .ics file",children:".ics"})]})]},i)})})]})}function WEt({documents:t}){const s=n=>n<1024?`${n} B`:n<1048576?`${(n/1024).toFixed(0)} KB`:`${(n/1048576).toFixed(1)} MB`,r=async n=>{const{data:a}=await G.storage.from("deal-files").createSignedUrl(n.storage_path,300);a!=null&&a.signedUrl&&window.open(a.signedUrl,"_blank")};return e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-slate-100",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-800 mb-3",children:"Documents"}),e.jsx("div",{className:"space-y-2",children:t.map(n=>e.jsxs("button",{onClick:()=>r(n),className:"w-full flex items-center gap-3 p-3 rounded-xl hover:bg-slate-50 transition-colors text-left group",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-slate-100 flex items-center justify-center flex-shrink-0 group-hover:bg-blue-50 transition-colors",children:e.jsx(vn,{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(Qa,{className:"w-4 h-4 text-slate-300 group-hover:text-blue-500 transition-colors"})]},n.id))})]})}function KEt({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(td,{className:"w-3.5 h-3.5 text-emerald-600"}):e.jsx(Sm,{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:vs(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 ZEt({portal:t,dealData:s,agentProfile:r,customQuestions:n,deviceFingerprint:a,onComplete:o}){var b,N;const[l,i]=k.useState({first_name:((b=t.client_name)==null?void 0:b.split(" ")[0])||"",last_name:((N=t.client_name)==null?void 0:N.split(" ").slice(1).join(" "))||"",email:t.client_email||"",phone:t.client_phone||"",preferred_contact_method:"email",client_role:"buyer",notes:"",spouse_first_name:"",spouse_last_name:"",spouse_email:"",spouse_phone:""}),[d,u]=k.useState({}),[p,f]=k.useState(!1),y=Pt({mutationFn:async()=>{const{error:w}=await G.from("portal_onboarding_submissions").insert({portal_id:t.id,first_name:l.first_name,last_name:l.last_name||null,email:l.email||null,phone:l.phone||null,preferred_contact_method:l.preferred_contact_method,client_role:l.client_role,notes:l.notes||null,device_fingerprint:a,custom_answers:Object.keys(d).length>0?d:null,spouse_first_name:p&&l.spouse_first_name||null,spouse_last_name:p&&l.spouse_last_name||null,spouse_email:p&&l.spouse_email||null,spouse_phone:p&&l.spouse_phone||null});if(w)throw w},onSuccess:o,onError:w=>{console.error("[PortalOnboarding] Submit failed:",w),pe.error("Something went wrong. Please try again.")}}),_=s!=null&&s.property_address?`${s.property_address}, ${s.city||""}, ${s.state||""}`:null;return e.jsxs("div",{className:"max-w-md mx-auto px-4 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[(r==null?void 0:r.avatar_url)&&e.jsx("img",{src:r.avatar_url,alt:r.name,className:"w-14 h-14 rounded-full border-2 border-slate-200 mx-auto mb-3 object-cover"}),e.jsx("h1",{className:"text-xl font-bold text-slate-800",children:"Welcome to Your Portal"}),_&&e.jsxs("div",{className:"flex items-center justify-center gap-1 text-slate-500 text-sm mt-1",children:[e.jsx(Ia,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:_.replace(/,\s*,/g,",").replace(/,\s*$/,"")})]}),e.jsx("p",{className:"text-sm text-slate-500 mt-2",children:"Please fill in your details to access your transaction portal."})]}),e.jsxs("form",{onSubmit:w=>{w.preventDefault(),y.mutate()},className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs text-slate-600",children:"First Name *"}),e.jsx(De,{required:!0,value:l.first_name,onChange:w=>i(S=>({...S,first_name:w.target.value})),className:"mt-1 rounded-xl",placeholder:"John"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs text-slate-600",children:"Last Name"}),e.jsx(De,{value:l.last_name,onChange:w=>i(S=>({...S,last_name:w.target.value})),className:"mt-1 rounded-xl",placeholder:"Doe"})]})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs text-slate-600",children:"Email"}),e.jsx(De,{type:"email",value:l.email,onChange:w=>i(S=>({...S,email:w.target.value})),className:"mt-1 rounded-xl",placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs text-slate-600",children:"Phone"}),e.jsx(De,{type:"tel",value:l.phone,onChange:w=>i(S=>({...S,phone:w.target.value})),className:"mt-1 rounded-xl",placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs text-slate-600",children:"Preferred Contact Method"}),e.jsx("div",{className:"flex gap-2 mt-1.5",children:[{value:"email",label:"Email"},{value:"call",label:"Phone"},{value:"text",label:"Text"}].map(w=>e.jsx("button",{type:"button",onClick:()=>i(S=>({...S,preferred_contact_method:w.value})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.preferred_contact_method===w.value?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:w.label},w.value))})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs text-slate-600",children:"Your Role"}),e.jsx("div",{className:"flex gap-2 mt-1.5",children:["buyer","seller","both"].map(w=>e.jsx("button",{type:"button",onClick:()=>i(S=>({...S,client_role:w})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.client_role===w?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:w.charAt(0).toUpperCase()+w.slice(1)},w))})]}),n.map(w=>e.jsxs("div",{children:[e.jsxs(xe,{className:"text-xs text-slate-600",children:[w.question_text," ",w.is_required&&"*"]}),w.field_type==="text"&&e.jsx(De,{required:w.is_required,value:d[w.id]||"",onChange:S=>u(C=>({...C,[w.id]:S.target.value})),className:"mt-1 rounded-xl"}),w.field_type==="textarea"&&e.jsx("textarea",{required:w.is_required,value:d[w.id]||"",onChange:S=>u(C=>({...C,[w.id]:S.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm min-h-[80px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}),w.field_type==="dropdown"&&e.jsxs("select",{required:w.is_required,value:d[w.id]||"",onChange:S=>u(C=>({...C,[w.id]:S.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm h-10",children:[e.jsx("option",{value:"",children:"Select..."}),(w.options||[]).map(S=>e.jsx("option",{value:S,children:S},S))]}),w.field_type==="toggle"&&e.jsx("div",{className:"mt-1.5 flex gap-2",children:["Yes","No"].map(S=>e.jsx("button",{type:"button",onClick:()=>u(C=>({...C,[w.id]:S})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${d[w.id]===S?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200"}`,children:S},S))})]},w.id)),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs text-slate-600",children:"Notes for your agent"}),e.jsx("textarea",{value:l.notes,onChange:w=>i(S=>({...S,notes:w.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm min-h-[60px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"Anything you'd like your agent to know..."})]}),t.allow_spouse&&e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>f(!p),className:"text-sm text-blue-600 hover:text-blue-700 font-medium",children:p?"− Remove spouse/partner":"+ Add spouse/partner"}),p&&e.jsxs("div",{className:"mt-3 p-4 bg-slate-50 rounded-xl space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs text-slate-600",children:"First Name"}),e.jsx(De,{value:l.spouse_first_name,onChange:w=>i(S=>({...S,spouse_first_name:w.target.value})),className:"mt-1 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs text-slate-600",children:"Last Name"}),e.jsx(De,{value:l.spouse_last_name,onChange:w=>i(S=>({...S,spouse_last_name:w.target.value})),className:"mt-1 rounded-xl"})]})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs text-slate-600",children:"Email"}),e.jsx(De,{type:"email",value:l.spouse_email,onChange:w=>i(S=>({...S,spouse_email:w.target.value})),className:"mt-1 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs text-slate-600",children:"Phone"}),e.jsx(De,{type:"tel",value:l.spouse_phone,onChange:w=>i(S=>({...S,spouse_phone:w.target.value})),className:"mt-1 rounded-xl"})]})]})]}),e.jsx(W,{type:"submit",disabled:y.isPending||!l.first_name,className:"w-full h-12 rounded-full text-sm font-semibold bg-slate-900 hover:bg-slate-800",children:y.isPending?"Submitting...":"Access My Portal"})]})]})}function YEt(t){const s=window.location.hostname;return s==="localhost"||s.includes("lovable.app")?`${window.location.origin}/portal/${t}/refer`:`https://clients.relevelup.com/${t}/refer`}function XEt(t){if(!t)return null;const s=t.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([\w-]+)/);if(s)return`https://www.youtube.com/embed/${s[1]}`;const r=t.match(/loom\.com\/share\/([\w-]+)/);return r?`https://www.loom.com/embed/${r[1]}`:(t.match(/\.(mp4|webm|mov)(\?|$)/i),t)}function QEt({portalId:t,portalSlug:s,ownerUserId:r,rewardText:n,ctaHeadline:a,agentName:o,clientName:l,reviewUrl:i,hubVideoUrl:d}){const[u,p]=k.useState(!1),f=k.useRef(!1),y=YEt(s);k.useEffect(()=>{f.current||(f.current=!0,G.from("portal_referral_clicks").insert({portal_id:t,owner_user_id:r,click_type:"card_view",user_agent:navigator.userAgent.slice(0,500)}).then(()=>{}))},[t,r]);const _=async O=>{await G.from("portal_referral_clicks").insert({portal_id:t,owner_user_id:r,click_type:O,user_agent:navigator.userAgent.slice(0,500)})},b=()=>`${l?`Hey, it's ${l}!`:"Hey!"} I just had an amazing experience working with ${o||"my real estate agent"} on my home. If you or someone you know is thinking about buying or selling, here's their referral link: ${y}`,N=async()=>{await navigator.clipboard.writeText(y),p(!0),_("copy_link"),setTimeout(()=>p(!1),2e3)},w=()=>{_("share_sms");const O=encodeURIComponent(b());window.location.href=`sms:?&body=${O}`},S=()=>{_("share_email");const O=encodeURIComponent("A referral you'll thank me for"),V=encodeURIComponent(b());window.location.href=`mailto:?subject=${O}&body=${V}`},C=()=>{_("open_form"),window.open(y,"_blank")},A=a||"Know someone buying or selling?",I=d?XEt(d):null,L=I==null?void 0:I.match(/\.(mp4|webm|mov)(\?|$)/i);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-gradient-to-br from-emerald-50 via-teal-50 to-cyan-50 rounded-2xl p-6 border border-emerald-100 text-center",children:[e.jsx("div",{className:"text-5xl mb-2",children:"🎉"}),e.jsxs("h3",{className:"text-xl font-bold text-emerald-900 mb-1 font-serif",children:["Welcome Home",l?`, ${l.split(" ")[0]}`:"","!"]}),e.jsx("p",{className:"text-sm text-emerald-700/80",children:"Your transaction is complete. We're so proud to have been part of your journey."})]}),I&&e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-100 shadow-sm overflow-hidden",children:[e.jsx("div",{className:"px-4 pt-4 pb-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Or,{className:"w-4 h-4 text-[#406E71]"}),e.jsxs("p",{className:"text-sm font-medium text-slate-700",children:["A message from ",o||"your agent"]})]})}),e.jsx("div",{className:"aspect-video bg-slate-900",children:L?e.jsx("video",{src:I,controls:!0,className:"w-full h-full",playsInline:!0}):e.jsx("iframe",{src:I,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})]}),e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-[#2a4c64] via-[#345e7a] to-[#406E71] text-white shadow-xl",children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.07]",style:{backgroundImage:"radial-gradient(circle at 25% 25%, white 1px, transparent 1px)",backgroundSize:"20px 20px"}}),e.jsxs("div",{className:"relative p-6",children:[e.jsxs("div",{className:"inline-flex items-center gap-1.5 bg-white/15 backdrop-blur-sm rounded-full px-3 py-1 text-xs font-medium mb-3",children:[e.jsx(hi,{className:"w-3 h-3"}),"Referral Program"]}),e.jsx("h3",{className:"text-xl font-bold leading-tight mb-2 font-serif",children:A}),n&&e.jsxs("p",{className:"text-sm text-white/85 mb-1",children:[e.jsx("span",{className:"font-semibold text-white",children:"Your reward:"})," ",n]}),e.jsxs("p",{className:"text-sm text-white/70 mb-5 leading-relaxed",children:["The biggest compliment you can give ",o||"us"," is sending a friend or family member."]}),e.jsxs("button",{onClick:C,className:"w-full bg-white text-[#2a4c64] font-semibold rounded-xl py-3.5 px-4 flex items-center justify-center gap-2 shadow-md hover:bg-white/95 active:scale-[0.99] transition-all",children:["Refer a Friend",e.jsx(Wa,{className:"w-4 h-4"})]}),e.jsxs("div",{className:"mt-4 grid grid-cols-3 gap-2",children:[e.jsxs("button",{onClick:w,className:"flex items-center justify-center gap-1.5 bg-white/10 hover:bg-white/20 backdrop-blur-sm rounded-lg py-2.5 text-xs font-medium transition-colors",children:[e.jsx(Fl,{className:"w-3.5 h-3.5"}),"Text"]}),e.jsxs("button",{onClick:S,className:"flex items-center justify-center gap-1.5 bg-white/10 hover:bg-white/20 backdrop-blur-sm rounded-lg py-2.5 text-xs font-medium transition-colors",children:[e.jsx(tr,{className:"w-3.5 h-3.5"}),"Email"]}),e.jsxs("button",{onClick:N,className:"flex items-center justify-center gap-1.5 bg-white/10 hover:bg-white/20 backdrop-blur-sm rounded-lg py-2.5 text-xs font-medium transition-colors",children:[u?e.jsx(Zn,{className:"w-3.5 h-3.5"}):e.jsx(Va,{className:"w-3.5 h-3.5"}),u?"Copied":"Copy"]})]})]})]}),i&&e.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",onClick:()=>_("review_click"),className:"block bg-white border border-slate-200 hover:border-amber-300 hover:bg-amber-50/30 rounded-2xl p-4 transition-colors",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"text-2xl",children:"⭐"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-800",children:"Loved working together?"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Leave a quick review — it means the world."})]}),e.jsx(Wa,{className:"w-4 h-4 text-slate-400"})]})})]})}function JEt(t){return t==="buy-side"?"Home Search in Progress":t==="listing"?"Your Home Is On The Market":"Active Phase"}function ePt(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 tPt={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. 🎉"}},ZZe=["Lead","Consultation","Agreement Signed","Active","Under Contract","Closing","Closed Won"];function FNe(t){return ZZe.map(s=>{if(s==="Active")return{key:"Active",label:JEt(t),description:ePt(t)};const r=tPt[s];return{key:s,label:r.label,description:r.description}})}function EIe(t){if(!t)return 0;const s=ZZe.indexOf(t);return s>=0?s:0}function sPt(t,s){return gt({queryKey:["client-portal-public",t],queryFn:async()=>{if(!t)return null;const{data:r,error:n}=await G.from("client_portals").select(` *, deal_pipeline ( id, deal_name, property_address, city, state, deal_type, target_close_date, contract_date, expected_price, actual_close_date, stage_id, owner_user_id, deal_pipeline_stages (id, name, color, icon, sort_order, is_won_stage, is_lost_stage) ) `).eq("slug",t).eq("is_enabled",!0).maybeSingle();if(n)throw n;return r},enabled:s})}function rPt(t){return gt({queryKey:["client-portal-by-id",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("client_portals").select(` *, deal_pipeline ( id, deal_name, property_address, city, state, deal_type, target_close_date, contract_date, expected_price, actual_close_date, stage_id, owner_user_id, deal_pipeline_stages (id, name, color, icon, sort_order, is_won_stage, is_lost_stage) ) `).eq("id",t).eq("is_enabled",!0).maybeSingle();if(r)throw r;return s},enabled:!!t})}function YZe({slug:t}){var Y,J,X,ce,ie,ae;const[s,r]=k.useState(!1),[n,a]=k.useState("primary"),[o]=k.useState(()=>{const oe=`portal_fp_${t}`;let me=localStorage.getItem(oe);return me||(me=localStorage.getItem("portal_fp"),me?localStorage.setItem(oe,me):(me=crypto.randomUUID(),localStorage.setItem(oe,me),localStorage.setItem("portal_fp",me))),me});k.useEffect(()=>(document.body.classList.add("client-portal-page"),()=>document.body.classList.remove("client-portal-page")),[]);const{data:l,isLoading:i,error:d}=sPt(t,!0),u=l==null?void 0:l.linked_portal_id,{data:p}=rPt(u),f=(Y=l==null?void 0:l.deal_pipeline)==null?void 0:Y.owner_user_id;gt({queryKey:["portal-stages",f],queryFn:async()=>{const{data:oe,error:me}=await G.from("deal_pipeline_stages").select("*").eq("owner_user_id",f).order("sort_order",{ascending:!0});if(me)throw me;return oe},enabled:!!f});const{data:y}=gt({queryKey:["portal-agent",f],queryFn:async()=>{const{data:oe,error:me}=await G.from("profiles").select("id, name, avatar_url, phone, email").eq("id",f).single();if(me)throw me;return oe},enabled:!!f}),_=n==="linked"&&p?p:l,b=_==null?void 0:_.id,{data:N}=gt({queryKey:["portal-updates-public",b],queryFn:async()=>{const{data:oe,error:me}=await G.from("portal_updates").select("*").eq("portal_id",b).order("created_at",{ascending:!1});if(me)throw me;return oe},enabled:!!b}),w=(J=_==null?void 0:_.deal_pipeline)==null?void 0:J.id,{data:S}=gt({queryKey:["portal-documents",w],queryFn:async()=>{const{data:oe,error:me}=await G.from("deal_files").select("*").eq("deal_id",w).eq("visible_on_portal",!0).order("created_at",{ascending:!1});if(me)throw me;return oe},enabled:!!w}),C=l==null?void 0:l.id,{data:A,isLoading:I}=gt({queryKey:["portal-onboarding-check",C,o],queryFn:async()=>{const{data:oe,error:me}=await G.from("portal_onboarding_submissions").select("id").eq("portal_id",C).eq("device_fingerprint",o).maybeSingle();if(me)throw me;return oe},enabled:!!C&&!!(l!=null&&l.require_onboarding)}),{data:L}=gt({queryKey:["portal-custom-questions-public",f],queryFn:async()=>{const{data:oe,error:me}=await G.from("portal_custom_questions").select("*").eq("owner_user_id",f).eq("is_active",!0).order("sort_order",{ascending:!0});if(me)throw me;return oe},enabled:!!f&&!!(l!=null&&l.require_onboarding)}),O=!!A||s||!(l!=null&&l.require_onboarding);if(i||l!=null&&l.require_onboarding&&I)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center",children:e.jsxs("div",{className:"w-full max-w-lg mx-auto p-6 space-y-6",children:[e.jsx(Ms,{className:"h-48 w-full rounded-2xl"}),e.jsx(Ms,{className:"h-10 w-48 mx-auto"}),e.jsx(Ms,{className:"h-32 w-full rounded-2xl"}),e.jsx(Ms,{className:"h-24 w-full rounded-2xl"})]})});if(d||!l)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-slate-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx("span",{className:"text-2xl",children:"🔒"})}),e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Portal Not Available"}),e.jsx("p",{className:"text-slate-500",children:"This portal is no longer active or doesn't exist."})]})});if(!O){const oe=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(ZEt,{portal:l,dealData:oe,agentProfile:y,customQuestions:L||[],deviceFingerprint:o,onComplete:()=>r(!0)})})}const V=(X=l==null?void 0:l.deal_pipeline)==null?void 0:X.deal_type,q=(ce=p==null?void 0:p.deal_pipeline)==null?void 0:ce.deal_type,B=!!p,U=oe=>oe==="listing"?"Your Sale":oe==="buy-side"?"Your Purchase":"Transaction",te=oe=>oe==="listing"?e.jsx(Mn,{className:"w-3.5 h-3.5"}):e.jsx(fp,{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(BEt,{dealData:_==null?void 0:_.deal_pipeline,agentProfile:y,welcomeMessage:_==null?void 0:_.welcome_message,isWon:(ae=(ie=_==null?void 0:_.deal_pipeline)==null?void 0:ie.deal_pipeline_stages)==null?void 0:ae.is_won_stage}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 space-y-5 mt-6",children:[B&&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:[te(V),U(V)]}),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:[te(q),U(q)]})]}),e.jsx(nPt,{portal:_,updates:N,documents:S,agentProfile:y}),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(zu,{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 nPt({portal:t,updates:s,documents:r,agentProfile:n}){const a=t,o=a==null?void 0:a.deal_pipeline,l=o==null?void 0:o.deal_pipeline_stages,i=l==null?void 0:l.is_won_stage,d=o==null?void 0:o.deal_type,u=t.stage_mapping;let p=FNe(d);u&&u.length>0&&(p=u.map((N,w)=>{var S,C;return{key:`custom-${w}`,label:N.label||((S=p[w])==null?void 0:S.label)||`Stage ${w+1}`,description:N.description||((C=p[w])==null?void 0:C.description)||"",video_url:N.video_url||void 0}}));const f=u&&u.length>0?Math.min(EIe(l==null?void 0:l.name),p.length-1):EIe(l==null?void 0:l.name),y=p[f],_=y==null?void 0:y.video_url,b=i&&t.show_post_close_tips!==!1&&t.referral_enabled!==!1;return e.jsxs(e.Fragment,{children:[b&&e.jsx(QEt,{portalId:t.id,portalSlug:t.slug,ownerUserId:t.owner_user_id,rewardText:t.referral_reward_text,ctaHeadline:t.referral_cta_headline,agentName:n==null?void 0:n.name,clientName:t.client_name,reviewUrl:t.review_url,hubVideoUrl:t.homeowner_hub_video_url}),e.jsx(qEt,{targetCloseDate:o==null?void 0:o.target_close_date,actualCloseDate:o==null?void 0:o.actual_close_date,clientName:t.client_name}),e.jsx($Et,{journeyStages:p,currentIndex:f}),y&&e.jsx(UEt,{currentStage:y,nextStepText:t.next_step_text,nextStepVideoUrl:_||t.next_step_video_url}),e.jsx(GEt,{targetCloseDate:o==null?void 0:o.target_close_date,contractDate:o==null?void 0:o.contract_date,inspectionDate:t.inspection_date,appraisalDate:t.appraisal_date,actualCloseDate:o==null?void 0:o.actual_close_date}),r&&r.length>0&&e.jsx(WEt,{documents:r}),s&&s.length>0&&e.jsx(KEt,{updates:s})]})}function XZe({slug:t}){const s=io(),r=t||s.slug,[n,a]=k.useState(!1),[o,l]=k.useState(!1),[i,d]=k.useState(""),[u,p]=k.useState(""),[f,y]=k.useState(""),[_,b]=k.useState(""),[N,w]=k.useState(""),[S,C]=k.useState("buying"),[A,I]=k.useState("");k.useEffect(()=>(document.body.classList.add("client-portal-page"),()=>document.body.classList.remove("client-portal-page")),[]);const{data:L,isLoading:O,error:V}=gt({queryKey:["portal-referral-target",r],queryFn:async()=>{if(!r)return null;const{data:U,error:te}=await G.from("client_portals").select(` id, slug, owner_user_id, client_name, referral_enabled, referral_reward_text, referral_cta_headline, is_enabled `).eq("slug",r).eq("is_enabled",!0).maybeSingle();if(te)throw te;return U},enabled:!!r}),{data:q}=gt({queryKey:["portal-referral-agent",L==null?void 0:L.owner_user_id],queryFn:async()=>{const{data:U}=await G.from("profiles").select("id, name, avatar_url").eq("id",L.owner_user_id).single();return U},enabled:!!(L!=null&&L.owner_user_id)}),B=async U=>{if(U.preventDefault(),!L||!f.trim()){pe.error("Please enter your friend's name");return}if(!_.trim()&&!N.trim()){pe.error("Please add at least an email or phone for your friend");return}a(!0);try{const{error:te}=await G.from("portal_referrals").insert({portal_id:L.id,owner_user_id:L.owner_user_id,referrer_name:i.trim()||L.client_name||null,referrer_email:u.trim()||null,friend_name:f.trim(),friend_email:_.trim()||null,friend_phone:N.trim()||null,friend_interest:S,friend_message:A.trim()||null});if(te)throw te;l(!0)}catch(te){pe.error(te.message||"Could not submit referral")}finally{a(!1)}};return O?e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center",children:e.jsx(Ms,{className:"h-96 w-full max-w-lg rounded-2xl mx-4"})}):V||!L||!L.referral_enabled?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:"Referral Page Unavailable"}),e.jsx("p",{className:"text-slate-500",children:"This referral link is no longer active."})]})}):o?e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-emerald-50 via-teal-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"max-w-md w-full bg-white rounded-2xl shadow-xl p-8 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-emerald-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(Zn,{className:"w-8 h-8 text-emerald-600"})}),e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2 font-serif",children:"Thank you! 🙏"}),e.jsxs("p",{className:"text-sm text-slate-600 leading-relaxed mb-6",children:["Your referral has been sent to ",(q==null?void 0:q.name)||"your agent",". They'll reach out to"," ",e.jsx("span",{className:"font-semibold text-slate-800",children:f})," personally and treat them like family."]}),e.jsxs("button",{onClick:()=>window.history.back(),className:"inline-flex items-center gap-2 text-sm text-[#406E71] hover:text-[#2a4c64] font-medium",children:[e.jsx(Oa,{className:"w-4 h-4"}),"Back to your portal"]})]})}):e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white pb-12",children:[e.jsxs("div",{className:"relative bg-gradient-to-br from-[#2a4c64] via-[#345e7a] to-[#406E71] text-white px-4 pt-10 pb-12 overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.05]",style:{backgroundImage:"radial-gradient(circle at 25% 25%, white 1px, transparent 1px)",backgroundSize:"24px 24px"}}),e.jsxs("div",{className:"relative max-w-lg mx-auto text-center",children:[q!=null&&q.avatar_url?e.jsx("img",{src:q.avatar_url,alt:q.name||"Agent",className:"w-16 h-16 rounded-full border-[3px] border-white/30 shadow-xl mx-auto mb-3 object-cover"}):e.jsx("div",{className:"w-16 h-16 rounded-full border-[3px] border-white/30 shadow-xl mx-auto mb-3 bg-white/10 flex items-center justify-center",children:e.jsx(hi,{className:"w-7 h-7 text-white/70"})}),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/90 mb-2",children:[e.jsx(hi,{className:"w-3 h-3"})," Referral"]}),e.jsx("h1",{className:"text-2xl font-bold tracking-tight mb-1 font-serif",children:L.referral_cta_headline||"Refer a Friend"}),e.jsxs("p",{className:"text-sm text-white/70",children:["Send ",(q==null?void 0:q.name)||"your agent"," someone you trust."]}),L.referral_reward_text&&e.jsxs("p",{className:"text-xs text-white/60 mt-2",children:["You'll get: ",e.jsx("span",{className:"text-white font-medium",children:L.referral_reward_text})," when they close."]})]})]}),e.jsx("div",{className:"max-w-lg mx-auto px-4 -mt-6 relative z-10",children:e.jsxs("form",{onSubmit:B,className:"bg-white rounded-2xl shadow-lg border border-slate-100 p-5 space-y-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-3",children:"Tell us about your friend"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs(xe,{htmlFor:"friend_name",className:"text-sm",children:["Their name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(De,{id:"friend_name",value:f,onChange:U=>y(U.target.value),placeholder:"Jane Smith",required:!0,className:"mt-1"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"friend_email",className:"text-sm",children:"Email"}),e.jsx(De,{id:"friend_email",type:"email",value:_,onChange:U=>b(U.target.value),placeholder:"jane@email.com",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"friend_phone",className:"text-sm",children:"Phone"}),e.jsx(De,{id:"friend_phone",type:"tel",value:N,onChange:U=>w(U.target.value),placeholder:"(555) 123-4567",className:"mt-1"})]})]}),e.jsx("p",{className:"text-[11px] text-slate-400",children:"Add at least an email or phone so we can reach them."}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm",children:"They're interested in..."}),e.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:[{v:"buying",l:"Buying"},{v:"selling",l:"Selling"},{v:"both",l:"Both"},{v:"unsure",l:"Not sure"}].map(U=>e.jsx("button",{type:"button",onClick:()=>C(U.v),className:`rounded-lg border px-3 py-2 text-sm font-medium transition-colors ${S===U.v?"bg-[#406E71] text-white border-[#406E71]":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:U.l},U.v))})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"friend_message",className:"text-sm",children:"A note (optional)"}),e.jsx("textarea",{id:"friend_message",value:A,onChange:U=>I(U.target.value),placeholder:"They're moving from Boston in the spring...",rows:3,className:"mt-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"})]})]})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-3",children:"Your info"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"referrer_name",className:"text-sm",children:"Your name"}),e.jsx(De,{id:"referrer_name",value:i,onChange:U=>d(U.target.value),placeholder:L.client_name||"Your name",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"referrer_email",className:"text-sm",children:"Your email"}),e.jsx(De,{id:"referrer_email",type:"email",value:u,onChange:U=>p(U.target.value),placeholder:"So we can thank you!",className:"mt-1"})]})]})]}),e.jsxs("button",{type:"submit",disabled:n,className:"w-full bg-[#406E71] hover:bg-[#345e7a] disabled:opacity-60 text-white font-semibold rounded-xl py-3.5 px-4 flex items-center justify-center gap-2 transition-colors",children:[n?e.jsx(us,{className:"w-4 h-4 animate-spin"}):e.jsx(hi,{className:"w-4 h-4"}),n?"Sending...":"Send Referral"]}),e.jsx("p",{className:"text-[11px] text-center text-slate-400",children:"By submitting, you confirm your friend has agreed to be contacted."})]})})]})}function aPt(){const s=$l().pathname.slice(1).replace(/\/$/,"");if(k.useEffect(()=>(document.body.classList.add("client-portal-page"),()=>{document.body.classList.remove("client-portal-page")}),[]),!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:"Client Portal"}),e.jsx("p",{className:"text-slate-500",children:"Visit your personalized portal link to view your transaction details."})]})});const r=s.match(/^([^/]+)\/refer$/);return r?e.jsx(XZe,{slug:r[1]}):s.includes("/")?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:"Page Not Found"}),e.jsx("p",{className:"text-slate-500",children:"This portal link doesn't look right."})]})}):e.jsx(YZe,{slug:s})}const s_e="levelup_affiliate_ref",iPt=30,oPt=()=>{const[t]=Nc();k.useEffect(()=>{const s=t.get("ref");if(s){const r={code:s.toUpperCase(),timestamp:Date.now()};localStorage.setItem(s_e,JSON.stringify(r)),console.log("[Affiliate] Stored referral code:",s)}},[t])},lPt=()=>{try{const t=localStorage.getItem(s_e);if(!t)return null;const s=JSON.parse(t),r=iPt*24*60*60*1e3;return Date.now()-s.timestamp>r?(localStorage.removeItem(s_e),console.log("[Affiliate] Referral code expired"),null):s.code}catch{return null}},xle="/assets/levelup-logo-header-_ZX7DvlA.png",cPt="/assets/scale-your-team-ku4MPatU.png";function dPt({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(ks,{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(pa,{className:"h-5 w-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(_s,{children:"Schedule a Brokerage Interest Meeting"}),e.jsx(Ir,{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 Tu={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",popular:!1},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"],popular:!0},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"],popular:!1}},uPt=[{icon:rp,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:zl,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:cn,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:Fl,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:vn,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:hi,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],hPt=[{icon:ir,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:Or,title:"Smart Touchpoint Plans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:In,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:Fu,title:"Birthday & Anniversary Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:Ia,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:so,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:Xa,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:Oh,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],mPt=[{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."}],pPt=()=>{const{user:t,loading:s}=Us(),r=wr(),[n]=Nc();k.useEffect(()=>{const V=window.location.host==="listings.relevelup.com",q=window.location.pathname==="/";if(V&&q){r("/public/listings",{replace:!0});return}},[r]);const[a,o]=k.useState(null),[l,i]=k.useState(null),[d,u]=k.useState(!1),[p,f]=k.useState(""),[y,_]=k.useState(""),[b,N]=k.useState(""),[w,S]=k.useState(!1),[C,A]=k.useState(!1),I=(V,q=!1)=>{i({tier:V,skipTrial:q}),u(!0)};oPt(),k.useEffect(()=>{const V=window.location.host==="listings.relevelup.com",q=location.pathname.startsWith("/public/");!s&&t&&!V&&!q&&r("/dashboard")},[t,s,r,location.pathname]),k.useEffect(()=>{n.get("canceled")==="true"&&pe.error("Checkout was canceled. Feel free to try again when you're ready!")},[n]);const L=async(V,q=!1)=>{if(!p){pe.error("Please enter your email address");return}if(!y.trim()){pe.error("Please enter your full name");return}S(!0),o(V+(q?"_direct":""));const B=lPt();try{const{data:U,error:te}=await G.functions.invoke("create-checkout",{body:{tier:V,email:p,name:y.trim(),couponCode:b.trim()||void 0,skipTrial:q,referralCode:B}});if(te)throw te;if(U!=null&&U.url)window.open(U.url,"_blank","noopener,noreferrer"),pe.success("Checkout opened in a new tab");else throw new Error("No checkout URL returned")}catch(U){console.error("Checkout error:",U),pe.error(U.message||"Failed to start checkout. Please try again.")}finally{S(!1),o(null),u(!1),i(null)}},O=()=>{l&&L(l.tier,l.skipTrial)};return s?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[#4a6b6d]",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-white border-t-transparent"})}):e.jsxs("div",{className:"min-h-screen bg-background overflow-hidden",children:[e.jsx("nav",{className:"fixed top-0 left-0 right-0 z-50 bg-[#4a6b6d] shadow-md",children:e.jsxs("div",{className:"container mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center",children:e.jsx("img",{src:xle,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[e.jsx(W,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var V;return(V=document.getElementById("features"))==null?void 0:V.scrollIntoView({behavior:"smooth"})},children:"Features"}),e.jsx(W,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var V;return(V=document.getElementById("pricing"))==null?void 0:V.scrollIntoView({behavior:"smooth"})},children:"Pricing"}),e.jsx(W,{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(W,{size:"lg",onClick:()=>{var V;return(V=document.getElementById("free-trial"))==null?void 0:V.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(Wa,{className:"ml-2 w-5 h-5 group-hover:translate-x-1 transition-transform"})]}),e.jsx(W,{size:"lg",variant:"outline",onClick:()=>{var V;return(V=document.getElementById("features"))==null?void 0:V.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(W,{size:"lg",variant:"outline",onClick:()=>{var V;return(V=document.getElementById("brokerage"))==null?void 0:V.scrollIntoView({behavior:"smooth"})},className:"border-[#4a6b6d] text-[#4a6b6d] hover:bg-[#4a6b6d]/5",children:[e.jsx(pa,{className:"mr-2 h-5 w-5"}),"Brokerage Partnership"]}),e.jsxs(W,{size:"lg",onClick:()=>{var V;return(V=document.getElementById("pricing"))==null?void 0:V.scrollIntoView({behavior:"smooth"})},className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:[e.jsx(Ai,{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:uPt.map((V,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(Dt,{children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-[#4a6b6d]/10 flex items-center justify-center mb-4",children:e.jsx(V.icon,{className:"w-7 h-7 text-[#4a6b6d]"})}),e.jsx(zt,{className:"text-xl font-sans",children:V.title})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:V.description})})]},q))})]})}),e.jsxs("section",{id:"agent-os",className:"py-20 bg-gradient-to-br from-[#4a6b6d] to-[#3d5a5c] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsxs("div",{className:"container mx-auto px-4 relative",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white/10 text-white text-sm font-medium mb-6",children:[e.jsx(Or,{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:hPt.map((V,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(Dt,{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(V.icon,{className:"w-6 h-6 text-white"})}),e.jsx(zt,{className:"text-lg font-semibold text-white",children:V.title})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-white/70 text-sm leading-relaxed",children:V.description})})]},q))}),e.jsx("div",{className:"text-center mt-12",children:e.jsxs(W,{size:"lg",onClick:()=>{var V;return(V=document.getElementById("pricing"))==null?void 0:V.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(Wa,{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(pa,{className:"w-4 h-4"}),"For Brokerages"]}),e.jsxs("h2",{className:"text-3xl font-sans font-bold md:text-6xl",children:["Empower Your"," ",e.jsx("span",{className:"italic text-[#4a6b6d]",children:"Entire Team"})]}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Give every agent on your team access to world-class training and resources. Track performance, streamline onboarding, and watch your brokerage thrive."}),e.jsx("ul",{className:"space-y-4",children:["Dedicated brokerage manager dashboard","Invite and manage agents with one click","Exclusive brokerage-only resources","Team analytics and performance tracking","Simplified agent onboarding","Share resources across your team"].map((V,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(Zn,{className:"w-4 h-4 text-[#4a6b6d]"})}),e.jsx("span",{className:"text-foreground",children:V})]},q))}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-4",children:[e.jsxs(W,{size:"lg",onClick:()=>{var V;return(V=document.getElementById("pricing"))==null?void 0:V.scrollIntoView({behavior:"smooth"})},className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:["See Brokerage Plans",e.jsx(xa,{className:"ml-2 w-5 h-5"})]}),e.jsxs(W,{size:"lg",variant:"outline",onClick:()=>A(!0),className:"border-[#4a6b6d] text-[#4a6b6d] hover:bg-[#4a6b6d]/10",children:[e.jsx(cn,{className:"mr-2 w-5 h-5"}),"Schedule Info Session"]})]})]}),e.jsx("div",{className:"relative hidden md:block",children:e.jsx("img",{src:cPt,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:mPt.map((V,q)=>e.jsx(Pe,{className:"bg-muted/30 border-0",children:e.jsxs(Oe,{className:"pt-8",children:[e.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map(B=>e.jsx(Gn,{className:"w-5 h-5 fill-yellow-400 text-yellow-400"},B))}),e.jsxs("p",{className:"text-lg mb-6 italic text-muted-foreground",children:['"',V.quote,'"']}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:V.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:V.role})]})]})},q))})]})}),e.jsxs("section",{id:"free-trial",className:"py-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-8",children:[e.jsxs("h2",{className:"text-3xl md:text-5xl font-bold text-white",children:["Start Your Free Trial ",e.jsx("span",{className:"italic",children:"Today"})]}),e.jsx("p",{className:"text-lg md:text-xl text-white/80 leading-relaxed",children:"Get instant access to 7 days of trainings, templates, and tools — designed to give you quick wins now and resources you'll keep forever."}),e.jsx("div",{className:"pt-4",children:e.jsxs(W,{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(Wa,{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(Dt,{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(Ai,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsx(zt,{className:"text-xl font-sans",children:Tu.individual_agent.name})]}),e.jsxs("div",{className:"flex items-baseline gap-1 mt-4",children:[e.jsx("span",{className:"text-5xl font-bold",children:Tu.individual_agent.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:Tu.individual_agent.period})]}),e.jsx(dr,{className:"text-base mt-2",children:Tu.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(nn,{className:"w-4 h-4"}),Tu.individual_agent.trial]})]}),e.jsx(Oe,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:Tu.individual_agent.features.map((V,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(Zn,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:V})]},q))})}),e.jsxs(XL,{className:"flex flex-col gap-3 pt-4",children:[e.jsx(W,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>I("individual_agent"),children:"Start Free Trial"}),e.jsx(W,{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(Dt,{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(pa,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-xl font-sans",children:Tu.brokerage_under_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Tu.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:Tu.brokerage_under_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:Tu.brokerage_under_25.period})]}),e.jsx(dr,{className:"text-base mt-2",children:Tu.brokerage_under_25.description})]}),e.jsx(Oe,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:Tu.brokerage_under_25.features.map((V,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(Zn,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:V})]},q))})}),e.jsx(XL,{className:"pt-4",children:e.jsx(W,{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(Dt,{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(pa,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-xl font-sans",children:Tu.brokerage_over_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Tu.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:Tu.brokerage_over_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:Tu.brokerage_over_25.period})]}),e.jsx(dr,{className:"text-base mt-2",children:Tu.brokerage_over_25.description})]}),e.jsx(Oe,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:Tu.brokerage_over_25.features.map((V,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(Zn,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:V})]},q))})}),e.jsx(XL,{className:"pt-4",children:e.jsx(W,{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(W,{size:"lg",onClick:()=>{var V;return(V=document.getElementById("pricing"))==null?void 0:V.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(Wa,{className:"ml-2 w-5 h-5"})]}),e.jsx(W,{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:xle,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(dPt,{open:C,onOpenChange:A}),e.jsx(fs,{open:d,onOpenChange:u,children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(ks,{children:[e.jsx(_s,{className:"text-xl font-sans font-semibold",children:"Enter your details to get started"}),e.jsx(Ir,{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(xe,{htmlFor:"dialog-name",children:["Full Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(De,{id:"dialog-name",type:"text",placeholder:"John Smith",value:y,onChange:V=>_(V.target.value),className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsxs(xe,{htmlFor:"dialog-email",children:["Email Address ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(De,{id:"dialog-email",type:"email",placeholder:"you@example.com",value:p,onChange:V=>f(V.target.value),className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsxs(xe,{htmlFor:"dialog-coupon",children:["Discount Code ",e.jsx("span",{className:"text-muted-foreground",children:"(Optional)"})]}),e.jsx(De,{id:"dialog-coupon",type:"text",placeholder:"Enter discount code",value:b,onChange:V=>N(V.target.value),className:"mt-1"})]})]}),e.jsx(W,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:O,disabled:w,children:w?"Loading...":"Continue to Checkout"})]})})]})},PIe=()=>e.jsxs(e.Fragment,{children:[e.jsxs(kl,{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"})]})]})]})]})})]}),IIe=()=>e.jsxs(e.Fragment,{children:[e.jsxs(kl,{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"})]})]})]})]})})]}),fPt=()=>e.jsxs(e.Fragment,{children:[e.jsxs(kl,{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"})]})]})]})]})})]}),xPt=kC({email:Xl().email("Invalid email address"),password:Xl().min(6,"Password must be at least 6 characters")}),gPt=()=>{const{signIn:t,user:s}=Us(),r=wr(),[n,a]=k.useState(!1),[o,l]=k.useState({}),[i,d]=k.useState(""),[u,p]=k.useState(!1),[f,y]=k.useState(!1);k.useEffect(()=>{if(s){const N=sessionStorage.getItem("redirectAfterLogin")||"/dashboard";sessionStorage.removeItem("redirectAfterLogin"),r(N)}},[s,r]);const _=async N=>{N.preventDefault(),l({}),a(!0);const w=new FormData(N.currentTarget),S=w.get("email"),C=w.get("password");try{xPt.parse({email:S,password:C}),await t(S,C)}catch(A){if(A instanceof m0){const I={};A.errors.forEach(L=>{L.path[0]&&(I[L.path[0]]=L.message)}),l(I)}}finally{a(!1)}},b=async()=>{if(!i){pe.error("Please enter your email address");return}p(!0);try{const{error:N}=await G.functions.invoke("send-password-reset",{body:{email:i,redirectTo:"https://dashboard.relevelup.com/profile?reset=true"}});if(N)throw N;pe.success("Password reset email sent! Check your inbox."),y(!1),d("")}catch(N){pe.error(N.message||"Failed to send reset email")}finally{p(!1)}};return e.jsxs("div",{className:"min-h-screen relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-[#4a6b6d] via-[#3d5a5c] to-[#2a4347]",children:e.jsxs("div",{className:"absolute inset-0 opacity-30",children:[e.jsx("div",{className:"absolute top-0 left-0 w-96 h-96 bg-white/10 rounded-full blur-3xl animate-pulse"}),e.jsx("div",{className:"absolute bottom-0 right-0 w-96 h-96 bg-white/5 rounded-full blur-3xl animate-pulse",style:{animationDelay:"1s"}}),e.jsx("div",{className:"absolute top-1/2 left-1/2 w-64 h-64 bg-white/5 rounded-full blur-3xl animate-pulse",style:{animationDelay:"2s"}})]})}),e.jsxs("div",{className:"relative z-10 flex flex-col min-h-screen",children:[e.jsx("header",{className:"p-6",children:e.jsxs(da,{to:"/",className:"inline-flex items-center gap-2 text-sm text-white/80 hover:text-white transition-colors",children:[e.jsx(Oa,{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:MGe,alt:"LevelUp",className:"h-12 w-auto"})})}),e.jsxs(Pe,{className:"border-0 shadow-2xl bg-white/95 backdrop-blur-sm",children:[e.jsxs(Dt,{className:"space-y-1 text-center pb-4",children:[e.jsx(zt,{className:"text-3xl font-bold text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Welcome Back"}),e.jsx(dr,{className:"text-gray-600",children:"Sign in to access your dashboard"})]}),e.jsx(Oe,{children:e.jsxs("form",{onSubmit:_,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"signin-email",className:"text-gray-700",children:"Email"}),e.jsx(De,{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(xe,{htmlFor:"signin-password",className:"text-gray-700",children:"Password"}),e.jsx(De,{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(W,{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:y,children:[e.jsx(mi,{asChild:!0,children:e.jsx(W,{variant:"link",className:"w-full text-sm text-[#4a6b6d] hover:text-[#3d5a5c]",children:"Forgot password?"})}),e.jsxs(ps,{className:"bg-white",children:[e.jsxs(ks,{children:[e.jsx(_s,{className:"text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Reset Password"}),e.jsx(Ir,{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(xe,{htmlFor:"reset-email",className:"text-gray-700",children:"Email"}),e.jsx(De,{id:"reset-email",type:"email",placeholder:"your@email.com",value:i,onChange:N=>d(N.target.value),className:"border-gray-300 focus:border-[#4a6b6d] focus:ring-[#4a6b6d]"})]}),e.jsx(W,{onClick:b,className:"w-full bg-[#4a6b6d] hover:bg-[#3d5a5c] text-white",disabled:u,children:u?"Sending...":"Send Reset Link"})]})]})]})]})})]}),e.jsxs("p",{className:"text-center text-white/70 text-sm mt-6",children:["Don't have an account?"," ",e.jsx(da,{to:"/",className:"text-white hover:underline font-medium",children:"View Plans"})]})]})})]})]})},yPt=()=>{const[t]=Nc(),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(Dt,{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(si,{className:"w-10 h-10 text-green-500"})}),e.jsx(zt,{className:"text-2xl",children:"Welcome to LevelUp!"}),e.jsx(dr,{className:"text-lg",children:"Your subscription has been activated successfully."})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"p-4 rounded-lg bg-primary/10 border border-primary/20 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[e.jsx(tr,{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."})})]})]})})},QZe=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 G.storage.from("avatars").list(`${t}`);if(i&&i.length>0){const{data:d}=G.storage.from("avatars").getPublicUrl(`${t}/${i[0].name}`);r(`${d.publicUrl}?t=${Date.now()}`)}else r(null)}catch(i){console.error("Error fetching avatar:",i),r(null)}finally{a(!1)}})()},[t]),{avatarUrl:s,loading:n,refreshAvatar:async()=>{if(t)try{const{data:l}=await G.storage.from("avatars").list(`${t}`);if(l&&l.length>0){const{data:i}=G.storage.from("avatars").getPublicUrl(`${t}/${l[0].name}`);r(`${i.publicUrl}?t=${Date.now()}`)}}catch(l){console.error("Error refreshing avatar:",l)}}}},JZe=async t=>{const s=new Map;return await Promise.all(t.map(async r=>{try{const{data:n}=await G.storage.from("avatars").list(`${r}`);if(n&&n.length>0){const{data:a}=G.storage.from("avatars").getPublicUrl(`${r}/${n[0].name}`);s.set(r,a.publicUrl)}}catch{}})),s},vPt=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 G.from("profiles").select("is_trial, trial_expires_at, subscription_status, subscription_end_date").eq("id",t).single();if(o){console.error("Error fetching trial status:",o),r(d=>({...d,loading:!1}));return}const l=(a==null?void 0:a.subscription_status)==="trialing"&&(a==null?void 0:a.subscription_end_date),i=(a==null?void 0:a.is_trial)&&(a==null?void 0:a.trial_expires_at);if(l){const d=new Date().getTime(),u=new Date(a.subscription_end_date).getTime(),p=Math.ceil((u-d)/(1e3*60*60*24)),f=p<=0;r({isTrial:!0,isExpired:f,expiresAt:a.subscription_end_date,daysLeft:f?0:p,loading:!1})}else if(i){const d=new Date().getTime(),u=new Date(a.trial_expires_at).getTime(),p=Math.ceil((u-d)/(1e3*60*60*24)),f=p<=0;r({isTrial:!0,isExpired:f,expiresAt:a.trial_expires_at,daysLeft:f?0:p,loading:!1})}else r({isTrial:!1,isExpired:!1,expiresAt:null,daysLeft:null,loading:!1})}catch(a){console.error("Error in useTrialStatus:",a),r(o=>({...o,loading:!1}))}})()},[t]),s},eYe=()=>{const{data:t,isLoading:s}=gt({queryKey:["feature-flags"],queryFn:async()=>{const{data:n,error:a}=await G.from("feature_flags").select("*");if(a)throw a;return n}}),r=n=>{if(!t)return!1;const a=t.find(o=>o.key===n);return(a==null?void 0:a.enabled)??!1};return{flags:t,isLoading:s,isFeatureEnabled:r,isAgentOSEnabled:r("agent_os_enabled"),isInnerCircleEnabled:r("innercircle_enabled"),isMarketplaceEnabled:r("marketplace")}},LIe="community_last_seen_post_at";function _Pt(){const{user:t}=Us(),s=$l(),[r,n]=k.useState(0),[a,o]=k.useState(null);k.useEffect(()=>{if(!t)return;const i=localStorage.getItem(`${LIe}_${t.id}`);o(i)},[t]),k.useEffect(()=>{if(!t)return;(async()=>{let d=G.from("community_posts").select("id",{count:"exact",head:!0});a&&(d=d.gt("created_at",a)),await G.from("profiles").select("brokerage_id").eq("id",t.id).single();const{count:u,error:p}=await d;!p&&u!==null&&n(u)})()},[t,a]),k.useEffect(()=>{if(!t)return;const i=G.channel("community-new-posts").on("postgres_changes",{event:"INSERT",schema:"public",table:"community_posts"},async d=>{const u=d.new;if(u.user_id===t.id)return;const p=s.pathname==="/community";p||n(N=>N+1);const{data:f}=await G.from("profiles").select("name").eq("id",u.user_id).single(),y=(f==null?void 0:f.name)||"Someone",_=u.content.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),b=_.length>50?_.substring(0,50)+"...":_;p||pe("New Community Post",{description:`${y}: ${b}`,action:{label:"View",onClick:()=>{window.location.href="/community"}}})}).subscribe();return()=>{G.removeChannel(i)}},[t,s.pathname]);const l=k.useCallback(()=>{if(!t)return;const i=new Date().toISOString();localStorage.setItem(`${LIe}_${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 bPt(){const{isAdmin:t}=Us(),{data:s=0}=gt({queryKey:["wishlist-open-count"],queryFn:async()=>{const{count:r,error:n}=await G.from("wishlist_items").select("*",{count:"exact",head:!0}).eq("status","open");if(n)throw n;return r||0},enabled:t,staleTime:6e4});return{openCount:t?s:0}}const ZA=jue,zNe=Vje,wPt=Nue,tYe=k.forwardRef(({className:t,...s},r)=>e.jsx(UA,{className:Ot("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}));tYe.displayName=UA.displayName;const jPt=bC("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"}}),SC=k.forwardRef(({side:t="right",className:s,children:r,...n},a)=>e.jsxs(wPt,{children:[e.jsx(tYe,{}),e.jsxs(VA,{ref:a,className:Ot(jPt({side:t}),s),...n,children:[r,e.jsxs(FR,{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(kr,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));SC.displayName=VA.displayName;const YA=({className:t,...s})=>e.jsx("div",{className:Ot("flex flex-col space-y-2 text-center sm:text-left",t),...s});YA.displayName="SheetHeader";const XA=k.forwardRef(({className:t,...s},r)=>e.jsx(RR,{ref:r,className:Ot("text-lg font-semibold text-foreground",t),...s}));XA.displayName=RR.displayName;const sYe=k.forwardRef(({className:t,...s},r)=>e.jsx(OR,{ref:r,className:Ot("text-sm text-muted-foreground",t),...s}));sYe.displayName=OR.displayName;var Gue="Collapsible",[NPt,dAs]=qc(Gue),[kPt,BNe]=NPt(Gue),rYe=k.forwardRef((t,s)=>{const{__scopeCollapsible:r,open:n,defaultOpen:a,disabled:o,onOpenChange:l,...i}=t,[d,u]=Uu({prop:n,defaultProp:a??!1,onChange:l,caller:Gue});return e.jsx(kPt,{scope:r,disabled:o,contentId:fu(),open:d,onOpenToggle:k.useCallback(()=>u(p=>!p),[u]),children:e.jsx(Jr.div,{"data-state":qNe(d),"data-disabled":o?"":void 0,...i,ref:s})})});rYe.displayName=Gue;var nYe="CollapsibleTrigger",aYe=k.forwardRef((t,s)=>{const{__scopeCollapsible:r,...n}=t,a=BNe(nYe,r);return e.jsx(Jr.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":qNe(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...n,ref:s,onClick:Mr(t.onClick,a.onOpenToggle)})});aYe.displayName=nYe;var $Ne="CollapsibleContent",iYe=k.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=BNe($Ne,t.__scopeCollapsible);return e.jsx(jd,{present:r||a.open,children:({present:o})=>e.jsx(SPt,{...n,ref:s,present:o})})});iYe.displayName=$Ne;var SPt=k.forwardRef((t,s)=>{const{__scopeCollapsible:r,present:n,children:a,...o}=t,l=BNe($Ne,r),[i,d]=k.useState(n),u=k.useRef(null),p=Ta(s,u),f=k.useRef(0),y=f.current,_=k.useRef(0),b=_.current,N=l.open||i,w=k.useRef(N),S=k.useRef(void 0);return k.useEffect(()=>{const C=requestAnimationFrame(()=>w.current=!1);return()=>cancelAnimationFrame(C)},[]),od(()=>{const C=u.current;if(C){S.current=S.current||{transitionDuration:C.style.transitionDuration,animationName:C.style.animationName},C.style.transitionDuration="0s",C.style.animationName="none";const A=C.getBoundingClientRect();f.current=A.height,_.current=A.width,w.current||(C.style.transitionDuration=S.current.transitionDuration,C.style.animationName=S.current.animationName),d(n)}},[l.open,n]),e.jsx(Jr.div,{"data-state":qNe(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!N,...o,ref:p,style:{"--radix-collapsible-content-height":y?`${y}px`:void 0,"--radix-collapsible-content-width":b?`${b}px`:void 0,...t.style},children:N&&a})});function qNe(t){return t?"open":"closed"}var CPt=rYe;const lf=CPt,cf=aYe,df=iYe,MPt="/assets/levelup-logo-Eif24dqY.png",TPt="/assets/levelup-logo-icon-C-7iromj.png",APt="/assets/levelup-logo-mobile-B9skSjUG.png";var HR=t=>t.type==="checkbox",_4=t=>t instanceof Date,fm=t=>t==null;const oYe=t=>typeof t=="object";var wd=t=>!fm(t)&&!Array.isArray(t)&&oYe(t)&&!_4(t),lYe=t=>wd(t)&&t.target?HR(t.target)?t.target.checked:t.target.value:t,EPt=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,cYe=(t,s)=>t.has(EPt(s)),PPt=t=>{const s=t.constructor&&t.constructor.prototype;return wd(s)&&s.hasOwnProperty("isPrototypeOf")},UNe=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function eu(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(!(UNe&&(t instanceof Blob||n))&&(r||wd(t)))if(s=r?[]:{},!r&&!PPt(t))s=t;else for(const a in t)t.hasOwnProperty(a)&&(s[a]=eu(t[a]));else return t;return s}var Wue=t=>/^\w*$/.test(t),pd=t=>t===void 0,VNe=t=>Array.isArray(t)?t.filter(Boolean):[],HNe=t=>VNe(t.replace(/["|']|\]/g,"").split(/\.|\[/)),Pn=(t,s,r)=>{if(!s||!wd(t))return r;const n=(Wue(s)?[s]:HNe(s)).reduce((a,o)=>fm(a)?a:a[o],t);return pd(n)||n===t?pd(t[s])?r:t[s]:n},Kp=t=>typeof t=="boolean",Ho=(t,s,r)=>{let n=-1;const a=Wue(s)?[s]:HNe(s),o=a.length,l=o-1;for(;++nxt.useContext(GNe),IPt=t=>{const{children:s,...r}=t;return xt.createElement(GNe.Provider,{value:r},s)};var dYe=(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]!==bg.all&&(s._proxyFormState[l]=!n||bg.all),r&&(r[l]=!0),t[l]}});return a};const WNe=typeof window<"u"?xt.useLayoutEffect:xt.useEffect;function LPt(t){const s=Kue(),{control:r=s.control,disabled:n,name:a,exact:o}=t||{},[l,i]=xt.useState(r._formState),d=xt.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return WNe(()=>r._subscribe({name:a,formState:d.current,exact:o,callback:u=>{!n&&i({...r._formState,...u})}}),[a,n,o]),xt.useEffect(()=>{d.current.isValid&&r._setValid(!0)},[r]),xt.useMemo(()=>dYe(l,r,d.current,!1),[l,r])}var Uy=t=>typeof t=="string",uYe=(t,s,r,n,a)=>Uy(t)?(n&&s.watch.add(t),Pn(r,t,a)):Array.isArray(t)?t.map(o=>(n&&s.watch.add(o),Pn(r,o))):(n&&(s.watchAll=!0),r),r_e=t=>fm(t)||!oYe(t);function Rv(t,s,r=new WeakSet){if(r_e(t)||r_e(s))return t===s;if(_4(t)&&_4(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(_4(l)&&_4(i)||wd(l)&&wd(i)||Array.isArray(l)&&Array.isArray(i)?!Rv(l,i,r):l!==i)return!1}}return!0}function DPt(t){const s=Kue(),{control:r=s.control,name:n,defaultValue:a,disabled:o,exact:l,compute:i}=t||{},d=xt.useRef(a),u=xt.useRef(i),p=xt.useRef(void 0);u.current=i;const f=xt.useMemo(()=>r._getWatch(n,d.current),[r,n]),[y,_]=xt.useState(u.current?u.current(f):f);return WNe(()=>r._subscribe({name:n,formState:{values:!0},exact:l,callback:b=>{if(!o){const N=uYe(n,r._names,b.values||r._formValues,!1,d.current);if(u.current){const w=u.current(N);Rv(w,p.current)||(_(w),p.current=w)}else _(N)}}}),[r,o,n,l]),xt.useEffect(()=>r._removeUnmounted()),y}function RPt(t){const s=Kue(),{name:r,disabled:n,control:a=s.control,shouldUnregister:o,defaultValue:l}=t,i=cYe(a._names.array,r),d=xt.useMemo(()=>Pn(a._formValues,r,Pn(a._defaultValues,r,l)),[a,r,l]),u=DPt({control:a,name:r,defaultValue:d,exact:!0}),p=LPt({control:a,name:r,exact:!0}),f=xt.useRef(t),y=xt.useRef(a.register(r,{...t.rules,value:u,...Kp(t.disabled)?{disabled:t.disabled}:{}}));f.current=t;const _=xt.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!Pn(p.errors,r)},isDirty:{enumerable:!0,get:()=>!!Pn(p.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!Pn(p.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!Pn(p.validatingFields,r)},error:{enumerable:!0,get:()=>Pn(p.errors,r)}}),[p,r]),b=xt.useCallback(C=>y.current.onChange({target:{value:lYe(C),name:r},type:gle.CHANGE}),[r]),N=xt.useCallback(()=>y.current.onBlur({target:{value:Pn(a._formValues,r),name:r},type:gle.BLUR}),[r,a._formValues]),w=xt.useCallback(C=>{const A=Pn(a._fields,r);A&&C&&(A._f.ref={focus:()=>C.focus&&C.focus(),select:()=>C.select&&C.select(),setCustomValidity:I=>C.setCustomValidity(I),reportValidity:()=>C.reportValidity()})},[a._fields,r]),S=xt.useMemo(()=>({name:r,value:u,...Kp(n)||p.disabled?{disabled:p.disabled||n}:{},onChange:b,onBlur:N,ref:w}),[r,n,p.disabled,b,N,w,u]);return xt.useEffect(()=>{const C=a._options.shouldUnregister||o;a.register(r,{...f.current.rules,...Kp(f.current.disabled)?{disabled:f.current.disabled}:{}});const A=(I,L)=>{const O=Pn(a._fields,I);O&&O._f&&(O._f.mount=L)};if(A(r,!0),C){const I=eu(Pn(a._options.defaultValues,r));Ho(a._defaultValues,r,I),pd(Pn(a._formValues,r))&&Ho(a._formValues,r,I)}return!i&&a.register(r),()=>{(i?C&&!a._state.action:C)?a.unregister(r):A(r,!1)}},[r,a,i,o]),xt.useEffect(()=>{a._setDisabledField({disabled:n,name:r})},[n,r,a]),xt.useMemo(()=>({field:S,formState:p,fieldState:_}),[S,p,_])}const OPt=t=>t.render(RPt(t));var hYe=(t,s,r,n,a)=>s?{...r[t],types:{...r[t]&&r[t].types?r[t].types:{},[n]:a||!0}}:{},a8=t=>Array.isArray(t)?t:[t],DIe=()=>{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=[]}}},Jm=t=>wd(t)&&!Object.keys(t).length,KNe=t=>t.type==="file",wg=t=>typeof t=="function",yle=t=>{if(!UNe)return!1;const s=t?t.ownerDocument:0;return t instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},mYe=t=>t.type==="select-multiple",ZNe=t=>t.type==="radio",FPt=t=>ZNe(t)||HR(t),zge=t=>yle(t)&&t.isConnected;function zPt(t,s){const r=s.slice(0,-1).length;let n=0;for(;n{for(const s in t)if(wg(t[s]))return!0;return!1};function vle(t,s={}){const r=Array.isArray(t);if(wd(t)||r)for(const n in t)Array.isArray(t[n])||wd(t[n])&&!pYe(t[n])?(s[n]=Array.isArray(t[n])?[]:{},vle(t[n],s[n])):fm(t[n])||(s[n]=!0);return s}function fYe(t,s,r){const n=Array.isArray(t);if(wd(t)||n)for(const a in t)Array.isArray(t[a])||wd(t[a])&&!pYe(t[a])?pd(s)||r_e(r[a])?r[a]=Array.isArray(t[a])?vle(t[a],[]):{...vle(t[a])}:fYe(t[a],fm(s)?{}:s[a],r[a]):r[a]=!Rv(t[a],s[a]);return r}var sI=(t,s)=>fYe(t,s,vle(s));const RIe={value:!1,isValid:!1},OIe={value:!0,isValid:!0};var xYe=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&&!pd(t[0].attributes.value)?pd(t[0].value)||t[0].value===""?OIe:{value:t[0].value,isValid:!0}:OIe:RIe}return RIe},gYe=(t,{valueAsNumber:s,valueAsDate:r,setValueAs:n})=>pd(t)?t:s?t===""?NaN:t&&+t:r&&Uy(t)?new Date(t):n?n(t):t;const FIe={isValid:!1,value:null};var yYe=t=>Array.isArray(t)?t.reduce((s,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:s,FIe):FIe;function zIe(t){const s=t.ref;return KNe(s)?s.files:ZNe(s)?yYe(t.refs).value:mYe(s)?[...s.selectedOptions].map(({value:r})=>r):HR(s)?xYe(t.refs).value:gYe(pd(s.value)?t.ref.value:s.value,t)}var $Pt=(t,s,r,n)=>{const a={};for(const o of t){const l=Pn(s,o);l&&Ho(a,o,l._f)}return{criteriaMode:r,names:[...t],fields:a,shouldUseNativeValidation:n}},_le=t=>t instanceof RegExp,rI=t=>pd(t)?t:_le(t)?t.source:wd(t)?_le(t.value)?t.value.source:t.value:t,BIe=t=>({isOnSubmit:!t||t===bg.onSubmit,isOnBlur:t===bg.onBlur,isOnChange:t===bg.onChange,isOnAll:t===bg.all,isOnTouch:t===bg.onTouched});const $Ie="AsyncFunction";var qPt=t=>!!t&&!!t.validate&&!!(wg(t.validate)&&t.validate.constructor.name===$Ie||wd(t.validate)&&Object.values(t.validate).find(s=>s.constructor.name===$Ie)),UPt=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),qIe=(t,s,r)=>!r&&(s.watchAll||s.watch.has(t)||[...s.watch].some(n=>t.startsWith(n)&&/^\.\w+/.test(t.slice(n.length))));const i8=(t,s,r,n)=>{for(const a of r||Object.keys(t)){const o=Pn(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(i8(i,s))break}else if(wd(i)&&i8(i,s))break}}};function UIe(t,s,r){const n=Pn(t,r);if(n||Wue(r))return{error:n,name:r};const a=r.split(".");for(;a.length;){const o=a.join("."),l=Pn(s,o),i=Pn(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 VPt=(t,s,r,n)=>{r(t);const{name:a,...o}=t;return Jm(o)||Object.keys(o).length>=Object.keys(s).length||Object.keys(o).find(l=>s[l]===(!n||bg.all))},HPt=(t,s,r)=>!t||!s||t===s||a8(t).some(n=>n&&(r?n===s:n.startsWith(s)||s.startsWith(n))),GPt=(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,WPt=(t,s)=>!VNe(Pn(t,s)).length&&Id(t,s),KPt=(t,s,r)=>{const n=a8(Pn(t,r));return Ho(n,"root",s[r]),Ho(t,r,n),t},Xie=t=>Uy(t);function VIe(t,s,r="validate"){if(Xie(t)||Array.isArray(t)&&t.every(Xie)||Kp(t)&&!t)return{type:r,message:Xie(t)?t:"",ref:s}}var x5=t=>wd(t)&&!_le(t)?t:{value:t,message:""},HIe=async(t,s,r,n,a,o)=>{const{ref:l,refs:i,required:d,maxLength:u,minLength:p,min:f,max:y,pattern:_,validate:b,name:N,valueAsNumber:w,mount:S}=t._f,C=Pn(r,N);if(!S||s.has(N))return{};const A=i?i[0]:l,I=Y=>{a&&A.reportValidity&&(A.setCustomValidity(Kp(Y)?"":Y||""),A.reportValidity())},L={},O=ZNe(l),V=HR(l),q=O||V,B=(w||KNe(l))&&pd(l.value)&&pd(C)||yle(l)&&l.value===""||C===""||Array.isArray(C)&&!C.length,U=hYe.bind(null,N,n,L),te=(Y,J,X,ce=mv.maxLength,ie=mv.minLength)=>{const ae=Y?J:X;L[N]={type:Y?ce:ie,message:ae,ref:l,...U(Y?ce:ie,ae)}};if(o?!Array.isArray(C)||!C.length:d&&(!q&&(B||fm(C))||Kp(C)&&!C||V&&!xYe(i).isValid||O&&!yYe(i).isValid)){const{value:Y,message:J}=Xie(d)?{value:!!d,message:d}:x5(d);if(Y&&(L[N]={type:mv.required,message:J,ref:A,...U(mv.required,J)},!n))return I(J),L}if(!B&&(!fm(f)||!fm(y))){let Y,J;const X=x5(y),ce=x5(f);if(!fm(C)&&!isNaN(C)){const ie=l.valueAsNumber||C&&+C;fm(X.value)||(Y=ie>X.value),fm(ce.value)||(J=ienew Date(new Date().toDateString()+" "+ve),oe=l.type=="time",me=l.type=="week";Uy(X.value)&&C&&(Y=oe?ae(C)>ae(X.value):me?C>X.value:ie>new Date(X.value)),Uy(ce.value)&&C&&(J=oe?ae(C)+Y.value,ce=!fm(J.value)&&C.length<+J.value;if((X||ce)&&(te(X,Y.message,J.message),!n))return I(L[N].message),L}if(_&&!B&&Uy(C)){const{value:Y,message:J}=x5(_);if(_le(Y)&&!C.match(Y)&&(L[N]={type:mv.pattern,message:J,ref:l,...U(mv.pattern,J)},!n))return I(J),L}if(b){if(wg(b)){const Y=await b(C,r),J=VIe(Y,A);if(J&&(L[N]={...J,...U(mv.validate,J.message)},!n))return I(J.message),L}else if(wd(b)){let Y={};for(const J in b){if(!Jm(Y)&&!n)break;const X=VIe(await b[J](C,r),A,J);X&&(Y={...X,...U(J,X.message)},I(X.message),n&&(L[N]=Y))}if(!Jm(Y)&&(L[N]={ref:A,...Y},!n))return L}}return I(!0),L};const ZPt={mode:bg.onSubmit,reValidateMode:bg.onChange,shouldFocusError:!0};function YPt(t={}){let s={...ZPt,...t},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:wg(s.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:s.errors||{},disabled:s.disabled||!1},n={},a=wd(s.defaultValues)||wd(s.values)?eu(s.defaultValues||s.values)||{}:{},o=s.shouldUnregister?{}:eu(a),l={action:!1,mount:!1,watch:!1},i={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},d,u=0;const p={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let f={...p};const y={array:DIe(),state:DIe()},_=s.criteriaMode===bg.all,b=Ke=>ot=>{clearTimeout(u),u=setTimeout(Ke,ot)},N=async Ke=>{if(!s.disabled&&(p.isValid||f.isValid||Ke)){const ot=s.resolver?Jm((await V()).errors):await B(n,!0);ot!==r.isValid&&y.state.next({isValid:ot})}},w=(Ke,ot)=>{!s.disabled&&(p.isValidating||p.validatingFields||f.isValidating||f.validatingFields)&&((Ke||Array.from(i.mount)).forEach(He=>{He&&(ot?Ho(r.validatingFields,He,ot):Id(r.validatingFields,He))}),y.state.next({validatingFields:r.validatingFields,isValidating:!Jm(r.validatingFields)}))},S=(Ke,ot=[],He,Je,ut=!0,mt=!0)=>{if(Je&&He&&!s.disabled){if(l.action=!0,mt&&Array.isArray(Pn(n,Ke))){const et=He(Pn(n,Ke),Je.argA,Je.argB);ut&&Ho(n,Ke,et)}if(mt&&Array.isArray(Pn(r.errors,Ke))){const et=He(Pn(r.errors,Ke),Je.argA,Je.argB);ut&&Ho(r.errors,Ke,et),WPt(r.errors,Ke)}if((p.touchedFields||f.touchedFields)&&mt&&Array.isArray(Pn(r.touchedFields,Ke))){const et=He(Pn(r.touchedFields,Ke),Je.argA,Je.argB);ut&&Ho(r.touchedFields,Ke,et)}(p.dirtyFields||f.dirtyFields)&&(r.dirtyFields=sI(a,o)),y.state.next({name:Ke,isDirty:te(Ke,ot),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else Ho(o,Ke,ot)},C=(Ke,ot)=>{Ho(r.errors,Ke,ot),y.state.next({errors:r.errors})},A=Ke=>{r.errors=Ke,y.state.next({errors:r.errors,isValid:!1})},I=(Ke,ot,He,Je)=>{const ut=Pn(n,Ke);if(ut){const mt=Pn(o,Ke,pd(He)?Pn(a,Ke):He);pd(mt)||Je&&Je.defaultChecked||ot?Ho(o,Ke,ot?mt:zIe(ut._f)):X(Ke,mt),l.mount&&N()}},L=(Ke,ot,He,Je,ut)=>{let mt=!1,et=!1;const Ze={name:Ke};if(!s.disabled){if(!He||Je){(p.isDirty||f.isDirty)&&(et=r.isDirty,r.isDirty=Ze.isDirty=te(),mt=et!==Ze.isDirty);const kt=Rv(Pn(a,Ke),ot);et=!!Pn(r.dirtyFields,Ke),kt?Id(r.dirtyFields,Ke):Ho(r.dirtyFields,Ke,!0),Ze.dirtyFields=r.dirtyFields,mt=mt||(p.dirtyFields||f.dirtyFields)&&et!==!kt}if(He){const kt=Pn(r.touchedFields,Ke);kt||(Ho(r.touchedFields,Ke,He),Ze.touchedFields=r.touchedFields,mt=mt||(p.touchedFields||f.touchedFields)&&kt!==He)}mt&&ut&&y.state.next(Ze)}return mt?Ze:{}},O=(Ke,ot,He,Je)=>{const ut=Pn(r.errors,Ke),mt=(p.isValid||f.isValid)&&Kp(ot)&&r.isValid!==ot;if(s.delayError&&He?(d=b(()=>C(Ke,He)),d(s.delayError)):(clearTimeout(u),d=null,He?Ho(r.errors,Ke,He):Id(r.errors,Ke)),(He?!Rv(ut,He):ut)||!Jm(Je)||mt){const et={...Je,...mt&&Kp(ot)?{isValid:ot}:{},errors:r.errors,name:Ke};r={...r,...et},y.state.next(et)}},V=async Ke=>{w(Ke,!0);const ot=await s.resolver(o,s.context,$Pt(Ke||i.mount,n,s.criteriaMode,s.shouldUseNativeValidation));return w(Ke),ot},q=async Ke=>{const{errors:ot}=await V(Ke);if(Ke)for(const He of Ke){const Je=Pn(ot,He);Je?Ho(r.errors,He,Je):Id(r.errors,He)}else r.errors=ot;return ot},B=async(Ke,ot,He={valid:!0})=>{for(const Je in Ke){const ut=Ke[Je];if(ut){const{_f:mt,...et}=ut;if(mt){const Ze=i.array.has(mt.name),kt=ut._f&&qPt(ut._f);kt&&p.validatingFields&&w([Je],!0);const Ut=await HIe(ut,i.disabled,o,_,s.shouldUseNativeValidation&&!ot,Ze);if(kt&&p.validatingFields&&w([Je]),Ut[mt.name]&&(He.valid=!1,ot))break;!ot&&(Pn(Ut,mt.name)?Ze?KPt(r.errors,Ut,mt.name):Ho(r.errors,mt.name,Ut[mt.name]):Id(r.errors,mt.name))}!Jm(et)&&await B(et,ot,He)}}return He.valid},U=()=>{for(const Ke of i.unMount){const ot=Pn(n,Ke);ot&&(ot._f.refs?ot._f.refs.every(He=>!zge(He)):!zge(ot._f.ref))&&Re(Ke)}i.unMount=new Set},te=(Ke,ot)=>!s.disabled&&(Ke&&ot&&Ho(o,Ke,ot),!Rv(ve(),a)),Y=(Ke,ot,He)=>uYe(Ke,i,{...l.mount?o:pd(ot)?a:Uy(Ke)?{[Ke]:ot}:ot},He,ot),J=Ke=>VNe(Pn(l.mount?o:a,Ke,s.shouldUnregister?Pn(a,Ke,[]):[])),X=(Ke,ot,He={})=>{const Je=Pn(n,Ke);let ut=ot;if(Je){const mt=Je._f;mt&&(!mt.disabled&&Ho(o,Ke,gYe(ot,mt)),ut=yle(mt.ref)&&fm(ot)?"":ot,mYe(mt.ref)?[...mt.ref.options].forEach(et=>et.selected=ut.includes(et.value)):mt.refs?HR(mt.ref)?mt.refs.forEach(et=>{(!et.defaultChecked||!et.disabled)&&(Array.isArray(ut)?et.checked=!!ut.find(Ze=>Ze===et.value):et.checked=ut===et.value||!!ut)}):mt.refs.forEach(et=>et.checked=et.value===ut):KNe(mt.ref)?mt.ref.value="":(mt.ref.value=ut,mt.ref.type||y.state.next({name:Ke,values:eu(o)})))}(He.shouldDirty||He.shouldTouch)&&L(Ke,ut,He.shouldTouch,He.shouldDirty,!0),He.shouldValidate&&me(Ke)},ce=(Ke,ot,He)=>{for(const Je in ot){if(!ot.hasOwnProperty(Je))return;const ut=ot[Je],mt=Ke+"."+Je,et=Pn(n,mt);(i.array.has(Ke)||wd(ut)||et&&!et._f)&&!_4(ut)?ce(mt,ut,He):X(mt,ut,He)}},ie=(Ke,ot,He={})=>{const Je=Pn(n,Ke),ut=i.array.has(Ke),mt=eu(ot);Ho(o,Ke,mt),ut?(y.array.next({name:Ke,values:eu(o)}),(p.isDirty||p.dirtyFields||f.isDirty||f.dirtyFields)&&He.shouldDirty&&y.state.next({name:Ke,dirtyFields:sI(a,o),isDirty:te(Ke,mt)})):Je&&!Je._f&&!fm(mt)?ce(Ke,mt,He):X(Ke,mt,He),qIe(Ke,i)&&y.state.next({...r,name:Ke}),y.state.next({name:l.mount?Ke:void 0,values:eu(o)})},ae=async Ke=>{l.mount=!0;const ot=Ke.target;let He=ot.name,Je=!0;const ut=Pn(n,He),mt=kt=>{Je=Number.isNaN(kt)||_4(kt)&&isNaN(kt.getTime())||Rv(kt,Pn(o,He,kt))},et=BIe(s.mode),Ze=BIe(s.reValidateMode);if(ut){let kt,Ut;const Nt=ot.type?zIe(ut._f):lYe(Ke),es=Ke.type===gle.BLUR||Ke.type===gle.FOCUS_OUT,ds=!UPt(ut._f)&&!s.resolver&&!Pn(r.errors,He)&&!ut._f.deps||GPt(es,Pn(r.touchedFields,He),r.isSubmitted,Ze,et),js=qIe(He,i,es);Ho(o,He,Nt),es?(ut._f.onBlur&&ut._f.onBlur(Ke),d&&d(0)):ut._f.onChange&&ut._f.onChange(Ke);const lr=L(He,Nt,es),Lt=!Jm(lr)||js;if(!es&&y.state.next({name:He,type:Ke.type,values:eu(o)}),ds)return(p.isValid||f.isValid)&&(s.mode==="onBlur"?es&&N():es||N()),Lt&&y.state.next({name:He,...js?{}:lr});if(!es&&js&&y.state.next({...r}),s.resolver){const{errors:Es}=await V([He]);if(mt(Nt),Je){const fr=UIe(r.errors,n,He),Hs=UIe(Es,n,fr.name||He);kt=Hs.error,He=Hs.name,Ut=Jm(Es)}}else w([He],!0),kt=(await HIe(ut,i.disabled,o,_,s.shouldUseNativeValidation))[He],w([He]),mt(Nt),Je&&(kt?Ut=!1:(p.isValid||f.isValid)&&(Ut=await B(n,!0)));Je&&(ut._f.deps&&me(ut._f.deps),O(He,Ut,kt,lr))}},oe=(Ke,ot)=>{if(Pn(r.errors,ot)&&Ke.focus)return Ke.focus(),1},me=async(Ke,ot={})=>{let He,Je;const ut=a8(Ke);if(s.resolver){const mt=await q(pd(Ke)?Ke:ut);He=Jm(mt),Je=Ke?!ut.some(et=>Pn(mt,et)):He}else Ke?(Je=(await Promise.all(ut.map(async mt=>{const et=Pn(n,mt);return await B(et&&et._f?{[mt]:et}:et)}))).every(Boolean),!(!Je&&!r.isValid)&&N()):Je=He=await B(n);return y.state.next({...!Uy(Ke)||(p.isValid||f.isValid)&&He!==r.isValid?{}:{name:Ke},...s.resolver||!Ke?{isValid:He}:{},errors:r.errors}),ot.shouldFocus&&!Je&&i8(n,oe,Ke?ut:i.mount),Je},ve=Ke=>{const ot={...l.mount?o:a};return pd(Ke)?ot:Uy(Ke)?Pn(ot,Ke):Ke.map(He=>Pn(ot,He))},he=(Ke,ot)=>({invalid:!!Pn((ot||r).errors,Ke),isDirty:!!Pn((ot||r).dirtyFields,Ke),error:Pn((ot||r).errors,Ke),isValidating:!!Pn(r.validatingFields,Ke),isTouched:!!Pn((ot||r).touchedFields,Ke)}),ge=Ke=>{Ke&&a8(Ke).forEach(ot=>Id(r.errors,ot)),y.state.next({errors:Ke?r.errors:{}})},je=(Ke,ot,He)=>{const Je=(Pn(n,Ke,{_f:{}})._f||{}).ref,ut=Pn(r.errors,Ke)||{},{ref:mt,message:et,type:Ze,...kt}=ut;Ho(r.errors,Ke,{...kt,...ot,ref:Je}),y.state.next({name:Ke,errors:r.errors,isValid:!1}),He&&He.shouldFocus&&Je&&Je.focus&&Je.focus()},qe=(Ke,ot)=>wg(Ke)?y.state.subscribe({next:He=>"values"in He&&Ke(Y(void 0,ot),He)}):Y(Ke,ot,!0),Me=Ke=>y.state.subscribe({next:ot=>{HPt(Ke.name,ot.name,Ke.exact)&&VPt(ot,Ke.formState||p,tt,Ke.reRenderRoot)&&Ke.callback({values:{...o},...r,...ot,defaultValues:a})}}).unsubscribe,ke=Ke=>(l.mount=!0,f={...f,...Ke.formState},Me({...Ke,formState:f})),Re=(Ke,ot={})=>{for(const He of Ke?a8(Ke):i.mount)i.mount.delete(He),i.array.delete(He),ot.keepValue||(Id(n,He),Id(o,He)),!ot.keepError&&Id(r.errors,He),!ot.keepDirty&&Id(r.dirtyFields,He),!ot.keepTouched&&Id(r.touchedFields,He),!ot.keepIsValidating&&Id(r.validatingFields,He),!s.shouldUnregister&&!ot.keepDefaultValue&&Id(a,He);y.state.next({values:eu(o)}),y.state.next({...r,...ot.keepDirty?{isDirty:te()}:{}}),!ot.keepIsValid&&N()},Ve=({disabled:Ke,name:ot})=>{(Kp(Ke)&&l.mount||Ke||i.disabled.has(ot))&&(Ke?i.disabled.add(ot):i.disabled.delete(ot))},Ne=(Ke,ot={})=>{let He=Pn(n,Ke);const Je=Kp(ot.disabled)||Kp(s.disabled);return Ho(n,Ke,{...He||{},_f:{...He&&He._f?He._f:{ref:{name:Ke}},name:Ke,mount:!0,...ot}}),i.mount.add(Ke),He?Ve({disabled:Kp(ot.disabled)?ot.disabled:s.disabled,name:Ke}):I(Ke,!0,ot.value),{...Je?{disabled:ot.disabled||s.disabled}:{},...s.progressive?{required:!!ot.required,min:rI(ot.min),max:rI(ot.max),minLength:rI(ot.minLength),maxLength:rI(ot.maxLength),pattern:rI(ot.pattern)}:{},name:Ke,onChange:ae,onBlur:ae,ref:ut=>{if(ut){Ne(Ke,ot),He=Pn(n,Ke);const mt=pd(ut.value)&&ut.querySelectorAll&&ut.querySelectorAll("input,select,textarea")[0]||ut,et=FPt(mt),Ze=He._f.refs||[];if(et?Ze.find(kt=>kt===mt):mt===He._f.ref)return;Ho(n,Ke,{_f:{...He._f,...et?{refs:[...Ze.filter(zge),mt,...Array.isArray(Pn(a,Ke))?[{}]:[]],ref:{type:mt.type,name:Ke}}:{ref:mt}}}),I(Ke,!1,void 0,mt)}else He=Pn(n,Ke,{}),He._f&&(He._f.mount=!1),(s.shouldUnregister||ot.shouldUnregister)&&!(cYe(i.array,Ke)&&l.action)&&i.unMount.add(Ke)}}},Ue=()=>s.shouldFocusError&&i8(n,oe,i.mount),Ie=Ke=>{Kp(Ke)&&(y.state.next({disabled:Ke}),i8(n,(ot,He)=>{const Je=Pn(n,He);Je&&(ot.disabled=Je._f.disabled||Ke,Array.isArray(Je._f.refs)&&Je._f.refs.forEach(ut=>{ut.disabled=Je._f.disabled||Ke}))},0,!1))},ye=(Ke,ot)=>async He=>{let Je;He&&(He.preventDefault&&He.preventDefault(),He.persist&&He.persist());let ut=eu(o);if(y.state.next({isSubmitting:!0}),s.resolver){const{errors:mt,values:et}=await V();r.errors=mt,ut=eu(et)}else await B(n);if(i.disabled.size)for(const mt of i.disabled)Id(ut,mt);if(Id(r.errors,"root"),Jm(r.errors)){y.state.next({errors:{}});try{await Ke(ut,He)}catch(mt){Je=mt}}else ot&&await ot({...r.errors},He),Ue(),setTimeout(Ue);if(y.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Jm(r.errors)&&!Je,submitCount:r.submitCount+1,errors:r.errors}),Je)throw Je},ct=(Ke,ot={})=>{Pn(n,Ke)&&(pd(ot.defaultValue)?ie(Ke,eu(Pn(a,Ke))):(ie(Ke,ot.defaultValue),Ho(a,Ke,eu(ot.defaultValue))),ot.keepTouched||Id(r.touchedFields,Ke),ot.keepDirty||(Id(r.dirtyFields,Ke),r.isDirty=ot.defaultValue?te(Ke,eu(Pn(a,Ke))):te()),ot.keepError||(Id(r.errors,Ke),p.isValid&&N()),y.state.next({...r}))},fe=(Ke,ot={})=>{const He=Ke?eu(Ke):a,Je=eu(He),ut=Jm(Ke),mt=ut?a:Je;if(ot.keepDefaultValues||(a=He),!ot.keepValues){if(ot.keepDirtyValues){const et=new Set([...i.mount,...Object.keys(sI(a,o))]);for(const Ze of Array.from(et))Pn(r.dirtyFields,Ze)?Ho(mt,Ze,Pn(o,Ze)):ie(Ze,Pn(mt,Ze))}else{if(UNe&&pd(Ke))for(const et of i.mount){const Ze=Pn(n,et);if(Ze&&Ze._f){const kt=Array.isArray(Ze._f.refs)?Ze._f.refs[0]:Ze._f.ref;if(yle(kt)){const Ut=kt.closest("form");if(Ut){Ut.reset();break}}}}if(ot.keepFieldsRef)for(const et of i.mount)ie(et,Pn(mt,et));else n={}}o=s.shouldUnregister?ot.keepDefaultValues?eu(a):{}:eu(mt),y.array.next({values:{...mt}}),y.state.next({values:{...mt}})}i={mount:ot.keepDirtyValues?i.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!p.isValid||!!ot.keepIsValid||!!ot.keepDirtyValues,l.watch=!!s.shouldUnregister,y.state.next({submitCount:ot.keepSubmitCount?r.submitCount:0,isDirty:ut?!1:ot.keepDirty?r.isDirty:!!(ot.keepDefaultValues&&!Rv(Ke,a)),isSubmitted:ot.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:ut?{}:ot.keepDirtyValues?ot.keepDefaultValues&&o?sI(a,o):r.dirtyFields:ot.keepDefaultValues&&Ke?sI(a,Ke):ot.keepDirty?r.dirtyFields:{},touchedFields:ot.keepTouched?r.touchedFields:{},errors:ot.keepErrors?r.errors:{},isSubmitSuccessful:ot.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},$e=(Ke,ot)=>fe(wg(Ke)?Ke(o):Ke,ot),Ye=(Ke,ot={})=>{const He=Pn(n,Ke),Je=He&&He._f;if(Je){const ut=Je.refs?Je.refs[0]:Je.ref;ut.focus&&(ut.focus(),ot.shouldSelect&&wg(ut.select)&&ut.select())}},tt=Ke=>{r={...r,...Ke}},We={control:{register:Ne,unregister:Re,getFieldState:he,handleSubmit:ye,setError:je,_subscribe:Me,_runSchema:V,_focusError:Ue,_getWatch:Y,_getDirty:te,_setValid:N,_setFieldArray:S,_setDisabledField:Ve,_setErrors:A,_getFieldArray:J,_reset:fe,_resetDefaultValues:()=>wg(s.defaultValues)&&s.defaultValues().then(Ke=>{$e(Ke,s.resetOptions),y.state.next({isLoading:!1})}),_removeUnmounted:U,_disableForm:Ie,_subjects:y,_proxyFormState:p,get _fields(){return n},get _formValues(){return o},get _state(){return l},set _state(Ke){l=Ke},get _defaultValues(){return a},get _names(){return i},set _names(Ke){i=Ke},get _formState(){return r},get _options(){return s},set _options(Ke){s={...s,...Ke}}},subscribe:ke,trigger:me,register:Ne,handleSubmit:ye,watch:qe,setValue:ie,getValues:ve,reset:$e,resetField:ct,clearErrors:ge,unregister:Re,setError:je,setFocus:Ye,getFieldState:he};return{...We,formControl:We}}function Zue(t={}){const s=xt.useRef(void 0),r=xt.useRef(void 0),[n,a]=xt.useState({isDirty:!1,isValidating:!1,isLoading:wg(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:wg(t.defaultValues)?void 0:t.defaultValues});if(!s.current)if(t.formControl)s.current={...t.formControl,formState:n},t.defaultValues&&!wg(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:l,...i}=YPt(t);s.current={...i,formState:n}}const o=s.current.control;return o._options=t,WNe(()=>{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]),xt.useEffect(()=>o._disableForm(t.disabled),[o,t.disabled]),xt.useEffect(()=>{t.mode&&(o._options.mode=t.mode),t.reValidateMode&&(o._options.reValidateMode=t.reValidateMode)},[o,t.mode,t.reValidateMode]),xt.useEffect(()=>{t.errors&&(o._setErrors(t.errors),o._focusError())},[o,t.errors]),xt.useEffect(()=>{t.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,t.shouldUnregister]),xt.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==n.isDirty&&o._subjects.state.next({isDirty:l})}},[o,n.isDirty]),xt.useEffect(()=>{t.values&&!Rv(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]),xt.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=dYe(n,o),s.current}const GIe=(t,s,r)=>{if(t&&"reportValidity"in t){const n=Pn(r,s);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},vYe=(t,s)=>{for(const r in s.fields){const n=s.fields[r];n&&n.ref&&"reportValidity"in n.ref?GIe(n.ref,r,t):n.refs&&n.refs.forEach(a=>GIe(a,r,t))}},XPt=(t,s)=>{s.shouldUseNativeValidation&&vYe(t,s);const r={};for(const n in t){const a=Pn(s.fields,n),o=Object.assign(t[n]||{},{ref:a&&a.ref});if(QPt(s.names||Object.keys(t),n)){const l=Object.assign({},Pn(r,n));Ho(l,"root",o),Ho(r,n,l)}else Ho(r,n,o)}return r},QPt=(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(p){return p.errors.forEach(function(f){return t.push(f)})}),s){var d=r[l].types,u=d&&d[n.code];r[l]=hYe(l,s,r,a,u?[].concat(u,n.message):n.message)}t.shift()}return r},Yue=function(t,s,r){return r===void 0&&(r={}),function(n,a,o){try{return Promise.resolve(function(l,i){try{var d=Promise.resolve(t[r.mode==="sync"?"parse":"parseAsync"](n,s)).then(function(u){return o.shouldUseNativeValidation&&vYe({},o),{errors:{},values:r.raw?n:u}})}catch(u){return i(u)}return d&&d.then?d.then(void 0,i):d}(0,function(l){if(function(i){return Array.isArray(i==null?void 0:i.errors)}(l))return{values:{},errors:XPt(JPt(l.errors,!o.shouldUseNativeValidation&&o.criteriaMode==="all"),o)};throw l}))}catch(l){return Promise.reject(l)}}};const Xue=IPt,_Ye=k.createContext({}),Ec=({...t})=>e.jsx(_Ye.Provider,{value:{name:t.name},children:e.jsx(OPt,{...t})}),Que=()=>{const t=k.useContext(_Ye),s=k.useContext(bYe),{getFieldState:r,formState:n}=Kue(),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}},bYe=k.createContext({}),mc=k.forwardRef(({className:t,...s},r)=>{const n=k.useId();return e.jsx(bYe.Provider,{value:{id:n},children:e.jsx("div",{ref:r,className:Ot("space-y-2",t),...s})})});mc.displayName="FormItem";const pc=k.forwardRef(({className:t,...s},r)=>{const{error:n,formItemId:a}=Que();return e.jsx(xe,{ref:r,className:Ot(n&&"text-destructive",t),htmlFor:a,...s})});pc.displayName="FormLabel";const fc=k.forwardRef(({...t},s)=>{const{error:r,formItemId:n,formDescriptionId:a,formMessageId:o}=Que();return e.jsx(tje,{ref:s,id:n,"aria-describedby":r?`${a} ${o}`:`${a}`,"aria-invalid":!!r,...t})});fc.displayName="FormControl";const Qie=k.forwardRef(({className:t,...s},r)=>{const{formDescriptionId:n}=Que();return e.jsx("p",{ref:r,id:n,className:Ot("text-sm text-muted-foreground",t),...s})});Qie.displayName="FormDescription";const vm=k.forwardRef(({className:t,children:s,...r},n)=>{const{error:a,formMessageId:o}=Que(),l=a?String(a==null?void 0:a.message):s;return l?e.jsx("p",{ref:n,id:o,className:Ot("text-sm font-medium text-destructive",t),...r,children:l}):null});vm.displayName="FormMessage";const e6t=kC({category:ZWe(["general","technology","crm","marketing"]),subject:Xl().min(5,"Subject must be at least 5 characters").max(200),description:Xl().min(20,"Please provide more details (at least 20 characters)").max(2e3)}),t6t={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function n_e({trigger:t}){const[s,r]=k.useState(!1),[n,a]=k.useState(!1),{user:o}=Us(),l=Zue({resolver:Yue(e6t),defaultValues:{category:"general",subject:"",description:""}}),i=async d=>{if(!o){pe.error("You must be logged in to submit a ticket");return}a(!0);try{const{error:u}=await G.from("support_tickets").insert({user_id:o.id,category:d.category,subject:d.subject,description:d.description});if(u)throw u;try{await G.functions.invoke("support-ticket-notify",{body:{category:t6t[d.category],subject:d.subject}})}catch(p){console.log("Notification send attempted:",p)}pe.success("Support ticket submitted successfully!"),l.reset(),r(!1)}catch(u){console.error("Error submitting ticket:",u),pe.error("Failed to submit ticket. Please try again.")}finally{a(!1)}};return e.jsxs(fs,{open:s,onOpenChange:r,children:[e.jsx(mi,{asChild:!0,children:t||e.jsxs(W,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(NL,{className:"h-5 w-5"}),e.jsx("span",{className:"sr-only",children:"Support"})]})}),e.jsxs(ps,{className:"sm:max-w-[500px]",children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Need Help?"}),e.jsx(Ir,{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(In,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["You can also text us at: ",e.jsx("span",{className:"font-medium text-foreground",children:"1-866-527-8668"})]})]}),e.jsx(Xue,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(i),className:"space-y-4",children:[e.jsx(Ec,{control:l.control,name:"category",render:({field:d})=>e.jsxs(mc,{children:[e.jsx(pc,{children:"Category"}),e.jsxs($s,{onValueChange:d.onChange,defaultValue:d.value,children:[e.jsx(fc,{children:e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select a category"})})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"general",children:"General Support"}),e.jsx(vt,{value:"technology",children:"Technology Support"}),e.jsx(vt,{value:"crm",children:"CRM Support"}),e.jsx(vt,{value:"marketing",children:"Marketing Support"})]})]}),e.jsx(vm,{})]})}),e.jsx(Ec,{control:l.control,name:"subject",render:({field:d})=>e.jsxs(mc,{children:[e.jsx(pc,{children:"Subject"}),e.jsx(fc,{children:e.jsx(De,{placeholder:"Brief description of your issue",...d})}),e.jsx(vm,{})]})}),e.jsx(Ec,{control:l.control,name:"description",render:({field:d})=>e.jsxs(mc,{children:[e.jsx(pc,{children:"Description"}),e.jsx(fc,{children:e.jsx(_r,{placeholder:"Please describe your issue in detail...",className:"min-h-[120px]",...d})}),e.jsx(vm,{})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(W,{type:"submit",disabled:n,children:n?"Submitting...":"Submit Ticket"})]})]})})]})]})}const s6t=()=>{const{user:t}=Us(),s=wr(),[r,n]=k.useState([]),[a,o]=k.useState(0),[l,i]=k.useState(!1),[d,u]=k.useState(null);k.useEffect(()=>{if(!t)return;const b=`notification_last_read_${t.id}`;let N=d;if(!N){const C=localStorage.getItem(b);C&&(N=C,u(C))}(async()=>{const{data:C,error:A}=await G.from("push_notifications").select("*").order("created_at",{ascending:!1}).limit(20);if(!A&&C){n(C);const I=N?new Date(N):null,L=C.filter(O=>I?new Date(O.created_at)>I:!0);o(L.length)}})();const S=G.channel("push-notifications").on("postgres_changes",{event:"INSERT",schema:"public",table:"push_notifications"},C=>{const A=C.new;n(L=>[A,...L].slice(0,20));const I=N?new Date(N):null;(!I||new Date(A.created_at)>I)&&o(L=>L+1),Notification.permission==="granted"&&new Notification(A.title,{body:A.body,icon:"/favicon.ico"})}).subscribe();return()=>{G.removeChannel(S)}},[t,d]);const p=b=>{const N=b.toLowerCase();return N.includes("community")||N.includes("post")?wi:N.includes("academy")||N.includes("video")?yn:N.includes("template")?zl:N.includes("event")?cn:N.includes("newsletter")?Jv:N.includes("brokerage")?dh:N.includes("swag")||N.includes("social")?hi:N.includes("toolbox")||N.includes("tool")?Lg:N.includes("brief")?Or:wi},f=b=>{i(!1),b.url&&b.url!=="/"&&s(b.url)},y=()=>{if(!t)return;const b=new Date().toISOString(),N=`notification_last_read_${t.id}`;localStorage.setItem(N,b),u(b),o(0)},_=b=>{i(b),b&&a>0&&y()};return e.jsxs(Hd,{open:l,onOpenChange:_,children:[e.jsx(Gd,{asChild:!0,children:e.jsxs(W,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(Sm,{className:"h-5 w-5"}),a>0&&e.jsx(Qe,{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(Nd,{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(W,{variant:"ghost",size:"sm",className:"text-xs h-6",onClick:y,children:"Mark all read"})]}),e.jsx(Ja,{className:"h-[300px]",children:r.length===0?e.jsx("div",{className:"p-4 text-center text-muted-foreground text-sm",children:"No notifications yet"}):r.map(b=>{const N=p(b.title);return e.jsxs(_a,{className:"group flex items-start gap-3 p-3 cursor-pointer data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground",onClick:()=>f(b),children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx(N,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[e.jsx("span",{className:"font-medium text-sm",children:b.title}),e.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2 group-data-[highlighted]:text-accent-foreground/80",children:b.body}),e.jsx("span",{className:"text-xs text-muted-foreground group-data-[highlighted]:text-accent-foreground/80",children:Nl(new Date(b.created_at),{addSuffix:!0})})]})]},b.id)})})]})]})};var WIe=1,r6t=.9,n6t=.8,a6t=.17,Bge=.1,$ge=.999,i6t=.9999,o6t=.99,l6t=/[\\\/_+.#"@\[\(\{&]/,c6t=/[\\\/_+.#"@\[\(\{&]/g,d6t=/[\s-]/,wYe=/[\s-]/g;function a_e(t,s,r,n,a,o,l){if(o===s.length)return a===t.length?WIe:o6t;var i=`${a},${o}`;if(l[i]!==void 0)return l[i];for(var d=n.charAt(o),u=r.indexOf(d,a),p=0,f,y,_,b;u>=0;)f=a_e(t,s,r,n,u+1,o+1,l),f>p&&(u===a?f*=WIe:l6t.test(t.charAt(u-1))?(f*=n6t,_=t.slice(a,u-1).match(c6t),_&&a>0&&(f*=Math.pow($ge,_.length))):d6t.test(t.charAt(u-1))?(f*=r6t,b=t.slice(a,u-1).match(wYe),b&&a>0&&(f*=Math.pow($ge,b.length))):(f*=a6t,a>0&&(f*=Math.pow($ge,u-a))),t.charAt(u)!==s.charAt(o)&&(f*=i6t)),(ff&&(f=y*Bge)),f>p&&(p=f),u=r.indexOf(d,u+1);return l[i]=p,p}function KIe(t){return t.toLowerCase().replace(wYe," ")}function u6t(t,s,r){return t=r&&r.length>0?`${t+" "+r.join(" ")}`:t,a_e(t,s,KIe(t),KIe(s),0,0,{})}var nI='[cmdk-group=""]',qge='[cmdk-group-items=""]',h6t='[cmdk-group-heading=""]',jYe='[cmdk-item=""]',ZIe=`${jYe}:not([aria-disabled="true"])`,i_e="cmdk-item-select",L5="data-value",m6t=(t,s,r)=>u6t(t,s,r),NYe=k.createContext(void 0),GR=()=>k.useContext(NYe),kYe=k.createContext(void 0),YNe=()=>k.useContext(kYe),SYe=k.createContext(void 0),CYe=k.forwardRef((t,s)=>{let r=D5(()=>{var ge,je;return{search:"",value:(je=(ge=t.value)!=null?ge:t.defaultValue)!=null?je:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=D5(()=>new Set),a=D5(()=>new Map),o=D5(()=>new Map),l=D5(()=>new Set),i=MYe(t),{label:d,children:u,value:p,onValueChange:f,filter:y,shouldFilter:_,loop:b,disablePointerSelection:N=!1,vimBindings:w=!0,...S}=t,C=fu(),A=fu(),I=fu(),L=k.useRef(null),O=N6t();QS(()=>{if(p!==void 0){let ge=p.trim();r.current.value=ge,V.emit()}},[p]),QS(()=>{O(6,J)},[]);let V=k.useMemo(()=>({subscribe:ge=>(l.current.add(ge),()=>l.current.delete(ge)),snapshot:()=>r.current,setState:(ge,je,qe)=>{var Me,ke,Re,Ve;if(!Object.is(r.current[ge],je)){if(r.current[ge]=je,ge==="search")Y(),U(),O(1,te);else if(ge==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Ne=document.getElementById(I);Ne?Ne.focus():(Me=document.getElementById(C))==null||Me.focus()}if(O(7,()=>{var Ne;r.current.selectedItemId=(Ne=X())==null?void 0:Ne.id,V.emit()}),qe||O(5,J),((ke=i.current)==null?void 0:ke.value)!==void 0){let Ne=je??"";(Ve=(Re=i.current).onValueChange)==null||Ve.call(Re,Ne);return}}V.emit()}},emit:()=>{l.current.forEach(ge=>ge())}}),[]),q=k.useMemo(()=>({value:(ge,je,qe)=>{var Me;je!==((Me=o.current.get(ge))==null?void 0:Me.value)&&(o.current.set(ge,{value:je,keywords:qe}),r.current.filtered.items.set(ge,B(je,qe)),O(2,()=>{U(),V.emit()}))},item:(ge,je)=>(n.current.add(ge),je&&(a.current.has(je)?a.current.get(je).add(ge):a.current.set(je,new Set([ge]))),O(3,()=>{Y(),U(),r.current.value||te(),V.emit()}),()=>{o.current.delete(ge),n.current.delete(ge),r.current.filtered.items.delete(ge);let qe=X();O(4,()=>{Y(),(qe==null?void 0:qe.getAttribute("id"))===ge&&te(),V.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:d||t["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:C,inputId:I,labelId:A,listInnerRef:L}),[]);function B(ge,je){var qe,Me;let ke=(Me=(qe=i.current)==null?void 0:qe.filter)!=null?Me:m6t;return ge?ke(ge,r.current.search,je):0}function U(){if(!r.current.search||i.current.shouldFilter===!1)return;let ge=r.current.filtered.items,je=[];r.current.filtered.groups.forEach(Me=>{let ke=a.current.get(Me),Re=0;ke.forEach(Ve=>{let Ne=ge.get(Ve);Re=Math.max(Ne,Re)}),je.push([Me,Re])});let qe=L.current;ce().sort((Me,ke)=>{var Re,Ve;let Ne=Me.getAttribute("id"),Ue=ke.getAttribute("id");return((Re=ge.get(Ue))!=null?Re:0)-((Ve=ge.get(Ne))!=null?Ve:0)}).forEach(Me=>{let ke=Me.closest(qge);ke?ke.appendChild(Me.parentElement===ke?Me:Me.closest(`${qge} > *`)):qe.appendChild(Me.parentElement===qe?Me:Me.closest(`${qge} > *`))}),je.sort((Me,ke)=>ke[1]-Me[1]).forEach(Me=>{var ke;let Re=(ke=L.current)==null?void 0:ke.querySelector(`${nI}[${L5}="${encodeURIComponent(Me[0])}"]`);Re==null||Re.parentElement.appendChild(Re)})}function te(){let ge=ce().find(qe=>qe.getAttribute("aria-disabled")!=="true"),je=ge==null?void 0:ge.getAttribute(L5);V.setState("value",je||void 0)}function Y(){var ge,je,qe,Me;if(!r.current.search||i.current.shouldFilter===!1){r.current.filtered.count=n.current.size;return}r.current.filtered.groups=new Set;let ke=0;for(let Re of n.current){let Ve=(je=(ge=o.current.get(Re))==null?void 0:ge.value)!=null?je:"",Ne=(Me=(qe=o.current.get(Re))==null?void 0:qe.keywords)!=null?Me:[],Ue=B(Ve,Ne);r.current.filtered.items.set(Re,Ue),Ue>0&&ke++}for(let[Re,Ve]of a.current)for(let Ne of Ve)if(r.current.filtered.items.get(Ne)>0){r.current.filtered.groups.add(Re);break}r.current.filtered.count=ke}function J(){var ge,je,qe;let Me=X();Me&&(((ge=Me.parentElement)==null?void 0:ge.firstChild)===Me&&((qe=(je=Me.closest(nI))==null?void 0:je.querySelector(h6t))==null||qe.scrollIntoView({block:"nearest"})),Me.scrollIntoView({block:"nearest"}))}function X(){var ge;return(ge=L.current)==null?void 0:ge.querySelector(`${jYe}[aria-selected="true"]`)}function ce(){var ge;return Array.from(((ge=L.current)==null?void 0:ge.querySelectorAll(ZIe))||[])}function ie(ge){let je=ce()[ge];je&&V.setState("value",je.getAttribute(L5))}function ae(ge){var je;let qe=X(),Me=ce(),ke=Me.findIndex(Ve=>Ve===qe),Re=Me[ke+ge];(je=i.current)!=null&&je.loop&&(Re=ke+ge<0?Me[Me.length-1]:ke+ge===Me.length?Me[0]:Me[ke+ge]),Re&&V.setState("value",Re.getAttribute(L5))}function oe(ge){let je=X(),qe=je==null?void 0:je.closest(nI),Me;for(;qe&&!Me;)qe=ge>0?w6t(qe,nI):j6t(qe,nI),Me=qe==null?void 0:qe.querySelector(ZIe);Me?V.setState("value",Me.getAttribute(L5)):ae(ge)}let me=()=>ie(ce().length-1),ve=ge=>{ge.preventDefault(),ge.metaKey?me():ge.altKey?oe(1):ae(1)},he=ge=>{ge.preventDefault(),ge.metaKey?ie(0):ge.altKey?oe(-1):ae(-1)};return k.createElement(Jr.div,{ref:s,tabIndex:-1,...S,"cmdk-root":"",onKeyDown:ge=>{var je;(je=S.onKeyDown)==null||je.call(S,ge);let qe=ge.nativeEvent.isComposing||ge.keyCode===229;if(!(ge.defaultPrevented||qe))switch(ge.key){case"n":case"j":{w&&ge.ctrlKey&&ve(ge);break}case"ArrowDown":{ve(ge);break}case"p":case"k":{w&&ge.ctrlKey&&he(ge);break}case"ArrowUp":{he(ge);break}case"Home":{ge.preventDefault(),ie(0);break}case"End":{ge.preventDefault(),me();break}case"Enter":{ge.preventDefault();let Me=X();if(Me){let ke=new Event(i_e);Me.dispatchEvent(ke)}}}}},k.createElement("label",{"cmdk-label":"",htmlFor:q.inputId,id:q.labelId,style:S6t},d),Jue(t,ge=>k.createElement(kYe.Provider,{value:V},k.createElement(NYe.Provider,{value:q},ge))))}),p6t=k.forwardRef((t,s)=>{var r,n;let a=fu(),o=k.useRef(null),l=k.useContext(SYe),i=GR(),d=MYe(t),u=(n=(r=d.current)==null?void 0:r.forceMount)!=null?n:l==null?void 0:l.forceMount;QS(()=>{if(!u)return i.item(a,l==null?void 0:l.id)},[u]);let p=TYe(a,o,[t.value,t.children,o],t.keywords),f=YNe(),y=sw(O=>O.value&&O.value===p.current),_=sw(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(i_e,b),()=>O.removeEventListener(i_e,b)},[_,t.onSelect,t.disabled]);function b(){var O,V;N(),(V=(O=d.current).onSelect)==null||V.call(O,p.current)}function N(){f.setState("value",p.current,!0)}if(!_)return null;let{disabled:w,value:S,onSelect:C,forceMount:A,keywords:I,...L}=t;return k.createElement(Jr.div,{ref:m1(o,s),...L,id:a,"cmdk-item":"",role:"option","aria-disabled":!!w,"aria-selected":!!y,"data-disabled":!!w,"data-selected":!!y,onPointerMove:w||i.getDisablePointerSelection()?void 0:N,onClick:w?void 0:b},t.children)}),f6t=k.forwardRef((t,s)=>{let{heading:r,children:n,forceMount:a,...o}=t,l=fu(),i=k.useRef(null),d=k.useRef(null),u=fu(),p=GR(),f=sw(_=>a||p.filter()===!1?!0:_.search?_.filtered.groups.has(l):!0);QS(()=>p.group(l),[]),TYe(l,i,[t.value,t.heading,d]);let y=k.useMemo(()=>({id:l,forceMount:a}),[a]);return k.createElement(Jr.div,{ref:m1(i,s),...o,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},r&&k.createElement("div",{ref:d,"cmdk-group-heading":"","aria-hidden":!0,id:u},r),Jue(t,_=>k.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?u:void 0},k.createElement(SYe.Provider,{value:y},_))))}),x6t=k.forwardRef((t,s)=>{let{alwaysRender:r,...n}=t,a=k.useRef(null),o=sw(l=>!l.search);return!r&&!o?null:k.createElement(Jr.div,{ref:m1(a,s),...n,"cmdk-separator":"",role:"separator"})}),g6t=k.forwardRef((t,s)=>{let{onValueChange:r,...n}=t,a=t.value!=null,o=YNe(),l=sw(u=>u.search),i=sw(u=>u.selectedItemId),d=GR();return k.useEffect(()=>{t.value!=null&&o.setState("search",t.value)},[t.value]),k.createElement(Jr.input,{ref:s,...n,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":d.listId,"aria-labelledby":d.labelId,"aria-activedescendant":i,id:d.inputId,type:"text",value:a?t.value:l,onChange:u=>{a||o.setState("search",u.target.value),r==null||r(u.target.value)}})}),y6t=k.forwardRef((t,s)=>{let{children:r,label:n="Suggestions",...a}=t,o=k.useRef(null),l=k.useRef(null),i=sw(u=>u.selectedItemId),d=GR();return k.useEffect(()=>{if(l.current&&o.current){let u=l.current,p=o.current,f,y=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let _=u.offsetHeight;p.style.setProperty("--cmdk-list-height",_.toFixed(1)+"px")})});return y.observe(u),()=>{cancelAnimationFrame(f),y.unobserve(u)}}},[]),k.createElement(Jr.div,{ref:m1(o,s),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":n,id:d.listId},Jue(t,u=>k.createElement("div",{ref:m1(l,d.listInnerRef),"cmdk-list-sizer":""},u)))}),v6t=k.forwardRef((t,s)=>{let{open:r,onOpenChange:n,overlayClassName:a,contentClassName:o,container:l,...i}=t;return k.createElement(jue,{open:r,onOpenChange:n},k.createElement(Nue,{container:l},k.createElement(UA,{"cmdk-overlay":"",className:a}),k.createElement(VA,{"aria-label":t.label,"cmdk-dialog":"",className:o},k.createElement(CYe,{ref:s,...i}))))}),_6t=k.forwardRef((t,s)=>sw(r=>r.filtered.count===0)?k.createElement(Jr.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),b6t=k.forwardRef((t,s)=>{let{progress:r,children:n,label:a="Loading...",...o}=t;return k.createElement(Jr.div,{ref:s,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},Jue(t,l=>k.createElement("div",{"aria-hidden":!0},l)))}),bp=Object.assign(CYe,{List:y6t,Item:p6t,Input:g6t,Group:f6t,Separator:x6t,Dialog:v6t,Empty:_6t,Loading:b6t});function w6t(t,s){let r=t.nextElementSibling;for(;r;){if(r.matches(s))return r;r=r.nextElementSibling}}function j6t(t,s){let r=t.previousElementSibling;for(;r;){if(r.matches(s))return r;r=r.previousElementSibling}}function MYe(t){let s=k.useRef(t);return QS(()=>{s.current=t}),s}var QS=typeof window>"u"?k.useEffect:k.useLayoutEffect;function D5(t){let s=k.useRef();return s.current===void 0&&(s.current=t()),s}function sw(t){let s=YNe(),r=()=>t(s.snapshot());return k.useSyncExternalStore(s.subscribe,r,r)}function TYe(t,s,r,n=[]){let a=k.useRef(),o=GR();return QS(()=>{var l;let i=(()=>{var u;for(let p of r){if(typeof p=="string")return p.trim();if(typeof p=="object"&&"current"in p)return p.current?(u=p.current.textContent)==null?void 0:u.trim():a.current}})(),d=n.map(u=>u.trim());o.value(t,i,d),(l=s.current)==null||l.setAttribute(L5,i),a.current=i}),a}var N6t=()=>{let[t,s]=k.useState(),r=D5(()=>new Map);return QS(()=>{r.current.forEach(n=>n()),r.current=new Map},[t]),(n,a)=>{r.current.set(n,a),s({})}};function k6t(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function Jue({asChild:t,children:s},r){return t&&k.isValidElement(s)?k.cloneElement(k6t(s),{ref:s.ref},r(s.props.children)):r(s)}var S6t={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Sx=k.forwardRef(({className:t,...s},r)=>e.jsx(bp,{ref:r,className:Ot("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...s}));Sx.displayName=bp.displayName;const C6t=({children:t,...s})=>e.jsx(fs,{...s,children:e.jsx(ps,{className:"overflow-hidden p-0 shadow-lg",children:e.jsx(Sx,{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})})}),Cx=k.forwardRef(({className:t,...s},r)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(ln,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(bp.Input,{ref:r,className:Ot("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})]}));Cx.displayName=bp.Input.displayName;const Mx=k.forwardRef(({className:t,...s},r)=>e.jsx(bp.List,{ref:r,className:Ot("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));Mx.displayName=bp.List.displayName;const Tx=k.forwardRef((t,s)=>e.jsx(bp.Empty,{ref:s,className:"py-6 text-center text-sm",...t}));Tx.displayName=bp.Empty.displayName;const Ax=k.forwardRef(({className:t,...s},r)=>e.jsx(bp.Group,{ref:r,className:Ot("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}));Ax.displayName=bp.Group.displayName;const M6t=k.forwardRef(({className:t,...s},r)=>e.jsx(bp.Separator,{ref:r,className:Ot("-mx-1 h-px bg-border",t),...s}));M6t.displayName=bp.Separator.displayName;const cp=k.forwardRef(({className:t,...s},r)=>e.jsx(bp.Item,{ref:r,className:Ot("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}));cp.displayName=bp.Item.displayName;const T6t={event:{label:"Events",icon:_d,color:"bg-blue-500/10 text-blue-600"},template:{label:"Templates",icon:zl,color:"bg-purple-500/10 text-purple-600"},academy:{label:"Academy",icon:Lh,color:"bg-amber-500/10 text-amber-600"},toolbox:{label:"Toolbox",icon:Lg,color:"bg-green-500/10 text-green-600"},"social-swag":{label:"Social Swag",icon:Or,color:"bg-fuchsia-500/10 text-fuchsia-600"}},YIe=()=>{const[t,s]=k.useState(!1),[r,n]=k.useState(""),[a,o]=k.useState([]),[l,i]=k.useState(!1),d=wr();k.useEffect(()=>{const y=_=>{_.key==="k"&&(_.metaKey||_.ctrlKey)&&(_.preventDefault(),s(b=>!b))};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[]);const u=k.useCallback(async y=>{if(!y.trim()){o([]);return}i(!0);const _=`%${y}%`;try{const[b,N,w,S,C]=await Promise.all([G.from("events").select("id, title, description, event_date").eq("is_published",!0).or(`title.ilike.${_},description.ilike.${_}`).limit(5),G.from("canva_templates").select("id, name, description, publish_date").or(`name.ilike.${_},description.ilike.${_}`).limit(5),G.from("academy_videos").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${_},description.ilike.${_}`).limit(5),G.from("resource_kits").select("id, name, description, publish_date").eq("is_published",!0).or(`name.ilike.${_},description.ilike.${_}`).limit(5),G.from("social_swag").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${_},description.ilike.${_}`).limit(5)]),A=[];b.data&&b.data.forEach(I=>{A.push({id:I.id,title:I.title,description:I.description,type:"event",date:I.event_date,path:`/event/${I.id}`})}),N.data&&N.data.forEach(I=>{A.push({id:I.id,title:I.name,description:I.description,type:"template",date:I.publish_date,path:`/templates/${I.id}`})}),w.data&&w.data.forEach(I=>{A.push({id:I.id,title:I.title,description:I.description,type:"academy",date:I.publish_date,path:`/academy/${I.id}`})}),S.data&&S.data.forEach(I=>{A.push({id:I.id,title:I.name,description:I.description,type:"toolbox",date:I.publish_date,path:`/toolbox/${I.id}`})}),C.data&&C.data.forEach(I=>{A.push({id:I.id,title:I.title,description:I.description,type:"social-swag",date:I.publish_date,path:`/social-swag/${I.id}`})}),o(A)}catch(b){console.error("Search error:",b)}finally{i(!1)}},[]);k.useEffect(()=>{const y=setTimeout(()=>{u(r)},300);return()=>clearTimeout(y)},[r,u]);const p=y=>{s(!1),n(""),d(y)},f=a.reduce((y,_)=>(y[_.type]||(y[_.type]=[]),y[_.type].push(_),y),{});return e.jsxs(e.Fragment,{children:[e.jsxs(W,{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(ln,{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(C6t,{open:t,onOpenChange:s,children:[e.jsx(Cx,{placeholder:"Search events, templates, academy, toolbox, social swag...",value:r,onValueChange:n}),e.jsxs(Mx,{children:[l&&e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"Searching..."}),!l&&r&&a.length===0&&e.jsxs(Tx,{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(([y,_])=>{const b=T6t[y],N=b.icon;return e.jsx(Ax,{heading:b.label,children:_.map(w=>e.jsxs(cp,{value:`${w.type}-${w.id}-${w.title}`,onSelect:()=>p(w.path),className:"flex items-start gap-3 py-3 cursor-pointer",children:[e.jsx("div",{className:`p-2 rounded-md ${b.color}`,children:e.jsx(N,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium truncate",children:w.title}),w.description&&e.jsx("div",{className:"text-sm text-muted-foreground truncate group-data-[selected=true]:text-primary-foreground/80",children:w.description})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[e.jsx(Qe,{variant:"secondary",className:"text-xs",children:b.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Nl(new Date(w.date),{addSuffix:!0})})]})]},`${w.type}-${w.id}`))},y)})]})]})]})},A6t=({expiresAt:t,className:s,showUpgradeButton:r=!0})=>{const[n,a]=k.useState(null),o=wr();if(k.useEffect(()=>{const u=()=>{const f=new Date().getTime(),_=new Date(t).getTime()-f;if(_<=0){a({days:0,hours:0,minutes:0});return}const b=Math.floor(_/(1e3*60*60*24)),N=Math.floor(_%(1e3*60*60*24)/(1e3*60*60)),w=Math.floor(_%(1e3*60*60)/(1e3*60));a({days:b,hours:N,minutes:w})};u();const p=setInterval(u,6e4);return()=>clearInterval(p)},[t]),!n)return null;const l=n.days===0&&n.hours===0&&n.minutes===0,i=n.days<=1,d=n.days<=3&&!i;return l?e.jsxs("div",{className:Ot("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(Dc,{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(W,{size:"sm",onClick:()=>o("/subscription"),className:"bg-primary hover:bg-primary/90 text-xs h-7 px-3",children:[e.jsx(Or,{className:"h-3 w-3 mr-1"}),"Upgrade Now"]})]}):e.jsxs("div",{className:Ot("flex items-center justify-between gap-3 px-4 py-2 rounded-lg border transition-colors",i?"bg-destructive/10 border-destructive/20":d?"bg-amber-500/10 border-amber-500/20":"bg-primary/10 border-primary/20",s),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(nn,{className:Ot("h-4 w-4",i?"text-destructive":d?"text-amber-500":"text-primary")}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:Ot("text-sm font-medium",i?"text-destructive":d?"text-amber-600":"text-primary"),children:"Free Trial:"}),e.jsxs("div",{className:"flex items-center gap-1",children:[n.days>0&&e.jsxs("span",{className:Ot("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.days,"d"]}),e.jsxs("span",{className:Ot("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.hours,"h"]}),e.jsxs("span",{className:Ot("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.minutes,"m"]}),e.jsx("span",{className:Ot("text-xs",i?"text-destructive/70":d?"text-amber-600/70":"text-primary/70"),children:"remaining"})]})]})]}),r&&e.jsxs(W,{size:"sm",onClick:()=>o("/subscription"),variant:i?"destructive":d?"default":"outline",className:Ot("text-xs h-7 px-3",d&&"bg-amber-500 hover:bg-amber-600 text-white"),children:[e.jsx(Or,{className:"h-3 w-3 mr-1"}),"Upgrade"]})]})},E6t=()=>{const t=wr();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(Dt,{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(Dc,{className:"h-8 w-8 text-destructive"})}),e.jsx(zt,{className:"text-2xl",children:"Your Free Trial Has Ended"}),e.jsx(dr,{className:"text-base",children:"Your 7-day free trial has expired. Upgrade now to continue accessing all the powerful tools and resources LevelUp has to offer!"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsx(Pe,{className:"border-2 border-primary/20 hover:border-primary/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:e.jsxs(Oe,{className:"p-5 text-center",children:[e.jsx("div",{className:"mx-auto mb-3 h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(ir,{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(W,{className:"w-full",onClick:s=>{s.stopPropagation(),t("/subscription")},children:[e.jsx(Or,{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(Oe,{className:"p-5 text-center",children:[e.jsx("div",{className:"mx-auto mb-3 h-12 w-12 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx(pa,{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(W,{variant:"outline",className:"w-full border-amber-500 text-amber-600 hover:bg-amber-50",onClick:s=>{s.stopPropagation(),t("/subscription")},children:[e.jsx(pa,{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(In,{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(tr,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})]})]})})},P6t=({hasUnseenBrief:t,onClick:s,className:r})=>e.jsxs(ec,{children:[e.jsx(tc,{asChild:!0,children:e.jsxs(W,{variant:"ghost",size:"icon",onClick:s,className:Ot("relative transition-colors",t&&"text-primary hover:text-primary",r),children:[e.jsx(uh,{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(Dl,{children:e.jsx("p",{children:"The LevelUp Brief"})})]});var ehe="Checkbox",[I6t,uAs]=qc(ehe),[L6t,XNe]=I6t(ehe);function D6t(t){const{__scopeCheckbox:s,checked:r,children:n,defaultChecked:a,disabled:o,form:l,name:i,onCheckedChange:d,required:u,value:p="on",internal_do_not_use_render:f}=t,[y,_]=Uu({prop:r,defaultProp:a??!1,onChange:d,caller:ehe}),[b,N]=k.useState(null),[w,S]=k.useState(null),C=k.useRef(!1),A=b?!!l||!!b.closest("form"):!0,I={checked:y,disabled:o,setChecked:_,control:b,setControl:N,name:i,form:l,value:p,hasConsumerStoppedPropagationRef:C,required:u,defaultChecked:Db(a)?!1:a,isFormControl:A,bubbleInput:w,setBubbleInput:S};return e.jsx(L6t,{scope:s,...I,children:R6t(f)?f(I):n})}var AYe="CheckboxTrigger",EYe=k.forwardRef(({__scopeCheckbox:t,onKeyDown:s,onClick:r,...n},a)=>{const{control:o,value:l,disabled:i,checked:d,required:u,setControl:p,setChecked:f,hasConsumerStoppedPropagationRef:y,isFormControl:_,bubbleInput:b}=XNe(AYe,t),N=Ta(a,p),w=k.useRef(d);return k.useEffect(()=>{const S=o==null?void 0:o.form;if(S){const C=()=>f(w.current);return S.addEventListener("reset",C),()=>S.removeEventListener("reset",C)}},[o,f]),e.jsx(Jr.button,{type:"button",role:"checkbox","aria-checked":Db(d)?"mixed":d,"aria-required":u,"data-state":RYe(d),"data-disabled":i?"":void 0,disabled:i,value:l,...n,ref:N,onKeyDown:Mr(s,S=>{S.key==="Enter"&&S.preventDefault()}),onClick:Mr(r,S=>{f(C=>Db(C)?!0:!C),b&&_&&(y.current=S.isPropagationStopped(),y.current||S.stopPropagation())})})});EYe.displayName=AYe;var QNe=k.forwardRef((t,s)=>{const{__scopeCheckbox:r,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:d,onCheckedChange:u,form:p,...f}=t;return e.jsx(D6t,{__scopeCheckbox:r,checked:a,defaultChecked:o,disabled:i,required:l,onCheckedChange:u,name:n,form:p,value:d,internal_do_not_use_render:({isFormControl:y})=>e.jsxs(e.Fragment,{children:[e.jsx(EYe,{...f,ref:s,__scopeCheckbox:r}),y&&e.jsx(DYe,{__scopeCheckbox:r})]})})});QNe.displayName=ehe;var PYe="CheckboxIndicator",IYe=k.forwardRef((t,s)=>{const{__scopeCheckbox:r,forceMount:n,...a}=t,o=XNe(PYe,r);return e.jsx(jd,{present:n||Db(o.checked)||o.checked===!0,children:e.jsx(Jr.span,{"data-state":RYe(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s,style:{pointerEvents:"none",...t.style}})})});IYe.displayName=PYe;var LYe="CheckboxBubbleInput",DYe=k.forwardRef(({__scopeCheckbox:t,...s},r)=>{const{control:n,hasConsumerStoppedPropagationRef:a,checked:o,defaultChecked:l,required:i,disabled:d,name:u,value:p,form:f,bubbleInput:y,setBubbleInput:_}=XNe(LYe,t),b=Ta(r,_),N=zR(o),w=kR(n);k.useEffect(()=>{const C=y;if(!C)return;const A=window.HTMLInputElement.prototype,L=Object.getOwnPropertyDescriptor(A,"checked").set,O=!a.current;if(N!==o&&L){const V=new Event("click",{bubbles:O});C.indeterminate=Db(o),L.call(C,Db(o)?!1:o),C.dispatchEvent(V)}},[y,N,o,a]);const S=k.useRef(Db(o)?!1:o);return e.jsx(Jr.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??S.current,required:i,disabled:d,name:u,value:p,form:f,...s,tabIndex:-1,ref:b,style:{...s.style,...w,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});DYe.displayName=LYe;function R6t(t){return typeof t=="function"}function Db(t){return t==="indeterminate"}function RYe(t){return Db(t)?"indeterminate":t?"checked":"unchecked"}const Ri=k.forwardRef(({className:t,...s},r)=>e.jsx(QNe,{ref:r,className:Ot("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(IYe,{className:Ot("flex items-center justify-center text-current"),children:e.jsx(Zn,{className:"h-4 w-4"})})}));Ri.displayName=QNe.displayName;var JNe="Radio",[O6t,OYe]=qc(JNe),[F6t,z6t]=O6t(JNe),FYe=k.forwardRef((t,s)=>{const{__scopeRadio:r,name:n,checked:a=!1,required:o,disabled:l,value:i="on",onCheck:d,form:u,...p}=t,[f,y]=k.useState(null),_=Ta(s,w=>y(w)),b=k.useRef(!1),N=f?u||!!f.closest("form"):!0;return e.jsxs(F6t,{scope:r,checked:a,disabled:l,children:[e.jsx(Jr.button,{type:"button",role:"radio","aria-checked":a,"data-state":qYe(a),"data-disabled":l?"":void 0,disabled:l,value:i,...p,ref:_,onClick:Mr(t.onClick,w=>{a||d==null||d(),N&&(b.current=w.isPropagationStopped(),b.current||w.stopPropagation())})}),N&&e.jsx($Ye,{control:f,bubbles:!b.current,name:n,value:i,checked:a,required:o,disabled:l,form:u,style:{transform:"translateX(-100%)"}})]})});FYe.displayName=JNe;var zYe="RadioIndicator",BYe=k.forwardRef((t,s)=>{const{__scopeRadio:r,forceMount:n,...a}=t,o=z6t(zYe,r);return e.jsx(jd,{present:n||o.checked,children:e.jsx(Jr.span,{"data-state":qYe(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s})})});BYe.displayName=zYe;var B6t="RadioBubbleInput",$Ye=k.forwardRef(({__scopeRadio:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=k.useRef(null),i=Ta(l,o),d=zR(r),u=kR(s);return k.useEffect(()=>{const p=l.current;if(!p)return;const f=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(f,"checked").set;if(d!==r&&_){const b=new Event("click",{bubbles:n});_.call(p,r),p.dispatchEvent(b)}},[d,r,n]),e.jsx(Jr.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}})});$Ye.displayName=B6t;function qYe(t){return t?"checked":"unchecked"}var $6t=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],the="RadioGroup",[q6t,hAs]=qc(the,[pw,OYe]),UYe=pw(),VYe=OYe(),[U6t,V6t]=q6t(the),HYe=k.forwardRef((t,s)=>{const{__scopeRadioGroup:r,name:n,defaultValue:a,value:o,required:l=!1,disabled:i=!1,orientation:d,dir:u,loop:p=!0,onValueChange:f,...y}=t,_=UYe(r),b=mw(u),[N,w]=Uu({prop:o,defaultProp:a??null,onChange:f,caller:the});return e.jsx(U6t,{scope:r,name:n,required:l,disabled:i,value:N,onValueChange:w,children:e.jsx(fue,{asChild:!0,..._,orientation:d,dir:b,loop:p,children:e.jsx(Jr.div,{role:"radiogroup","aria-required":l,"aria-orientation":d,"data-disabled":i?"":void 0,dir:b,...y,ref:s})})})});HYe.displayName=the;var GYe="RadioGroupItem",WYe=k.forwardRef((t,s)=>{const{__scopeRadioGroup:r,disabled:n,...a}=t,o=V6t(GYe,r),l=o.disabled||n,i=UYe(r),d=VYe(r),u=k.useRef(null),p=Ta(s,u),f=o.value===a.value,y=k.useRef(!1);return k.useEffect(()=>{const _=N=>{$6t.includes(N.key)&&(y.current=!0)},b=()=>y.current=!1;return document.addEventListener("keydown",_),document.addEventListener("keyup",b),()=>{document.removeEventListener("keydown",_),document.removeEventListener("keyup",b)}},[]),e.jsx(xue,{asChild:!0,...i,focusable:!l,active:f,children:e.jsx(FYe,{disabled:l,required:o.required,checked:f,...d,...a,name:o.name,ref:p,onCheck:()=>o.onValueChange(a.value),onKeyDown:Mr(_=>{_.key==="Enter"&&_.preventDefault()}),onFocus:Mr(a.onFocus,()=>{var _;y.current&&((_=u.current)==null||_.click())})})})});WYe.displayName=GYe;var H6t="RadioGroupIndicator",KYe=k.forwardRef((t,s)=>{const{__scopeRadioGroup:r,...n}=t,a=VYe(r);return e.jsx(BYe,{...a,...n,ref:s})});KYe.displayName=H6t;var ZYe=HYe,YYe=WYe,G6t=KYe;const eke=k.forwardRef(({className:t,...s},r)=>e.jsx(ZYe,{className:Ot("grid gap-2",t),...s,ref:r}));eke.displayName=ZYe.displayName;const ble=k.forwardRef(({className:t,...s},r)=>e.jsx(YYe,{ref:r,className:Ot("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(G6t,{className:"flex items-center justify-center",children:e.jsx(sd,{className:"h-2.5 w-2.5 fill-current text-current"})})}));ble.displayName=YYe.displayName;const W6t=({brief:t,open:s,onClose:r,onDismiss:n})=>{const{user:a}=Us(),[o,l]=k.useState({}),[i,d]=k.useState({}),[u,p]=k.useState([]);k.useEffect(()=>{s&&a&&t.polls.length>0&&f()},[s,a,t.polls]);const f=async()=>{if(!a)return;const w=t.polls.map(C=>C.id),{data:S}=await G.from("levelup_brief_poll_responses").select("poll_id, option_id").eq("user_id",a.id).in("poll_id",w);if(S){const C={};S.forEach(A=>{C[A.poll_id]||(C[A.poll_id]=[]),C[A.poll_id].push(A.option_id)}),d(C)}},y=(w,S)=>{l(C=>({...C,[w]:S}))},_=(w,S,C)=>{l(A=>{const I=A[w]||[];return C?{...A,[w]:[...I,S]}:{...A,[w]:I.filter(L=>L!==S)}})},b=async w=>{if(!a)return;const S=o[w];if(!S||Array.isArray(S)&&S.length===0){pe.error("Please select an option");return}p(C=>[...C,w]);try{await G.from("levelup_brief_poll_responses").delete().eq("poll_id",w).eq("user_id",a.id);const C=Array.isArray(S)?S:[S],A=C.map(L=>({poll_id:w,option_id:L,user_id:a.id})),{error:I}=await G.from("levelup_brief_poll_responses").insert(A);if(I)throw I;d(L=>({...L,[w]:C})),pe.success("Response submitted!")}catch(C){console.error("Error submitting poll response:",C),pe.error("Failed to submit response")}finally{p(C=>C.filter(A=>A!==w))}},N=w=>(w.includes("mediadelivery.net")||w.includes("bunny"),w);return e.jsx(fs,{open:s,onOpenChange:w=>!w&&r(),children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] p-0 overflow-hidden [&>button]:hidden",children:[e.jsxs("div",{className:"bg-gradient-to-r from-primary to-primary/80 p-4 pr-12 text-primary-foreground relative",children:[e.jsx("button",{onClick:r,className:"absolute top-3 right-3 p-1.5 rounded-full bg-white/30 hover:bg-white/50 transition-colors","aria-label":"Close",children:e.jsx(kr,{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(uh,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsx(Qe,{variant:"secondary",className:"mb-1 bg-white/20 text-white border-0",children:"The LevelUp Brief"}),e.jsx(_s,{className:"text-xl font-bold text-white",children:t.brief.title})]})]})]}),e.jsx(Ja,{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:N(t.brief.video_url),className:"absolute inset-0 w-full h-full",allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0})}),t.brief.graphic_url&&!t.brief.video_url&&e.jsx("div",{className:"rounded-lg overflow-hidden bg-muted",children:t.brief.graphic_link_url?e.jsx("a",{href:t.brief.graphic_link_url,target:"_blank",rel:"noopener noreferrer",className:"block",children:e.jsx("img",{src:t.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain cursor-pointer hover:opacity-90 transition-opacity"})}):e.jsx("img",{src:t.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain"})}),t.links.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-semibold text-foreground",children:"Quick Links"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.links.map(w=>e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>window.open(w.url,"_blank"),className:"gap-2",children:[e.jsx(Yr,{className:"h-4 w-4"}),w.title]},w.id))})]}),t.polls.map(w=>{var A,I;const S=((A=i[w.id])==null?void 0:A.length)>0,C=u.includes(w.id);return e.jsxs("div",{className:"space-y-3 p-4 bg-muted/50 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"font-semibold text-foreground",children:w.question}),S&&e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[e.jsx($n,{className:"h-3 w-3"}),"Responded"]})]}),w.poll_type==="single"?e.jsx(eke,{value:o[w.id]||((I=i[w.id])==null?void 0:I[0])||"",onValueChange:L=>y(w.id,L),className:"space-y-2",children:w.options.map(L=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ble,{value:L.id,id:L.id}),e.jsx(xe,{htmlFor:L.id,className:"cursor-pointer",children:L.option_text})]},L.id))}):e.jsx("div",{className:"space-y-2",children:w.options.map(L=>{const V=(o[w.id]||i[w.id]||[]).includes(L.id);return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ri,{id:L.id,checked:V,onCheckedChange:q=>_(w.id,L.id,q)}),e.jsx(xe,{htmlFor:L.id,className:"cursor-pointer",children:L.option_text})]},L.id)})}),e.jsx(W,{size:"sm",onClick:()=>b(w.id),disabled:C,children:C?"Submitting...":S?"Update Response":"Submit"})]},w.id)})]})}),e.jsxs("div",{className:"p-4 pb-[calc(1rem+env(safe-area-inset-bottom))] border-t bg-muted/30 flex flex-col items-center gap-2 sticky bottom-0 z-10",children:[e.jsx(W,{onClick:r,className:"w-full max-w-xs",children:"Got it!"}),e.jsx(W,{variant:"ghost",size:"sm",onClick:n,children:"Don't show again"})]})]})})},K6t=()=>{const{user:t}=Us(),[s,r]=k.useState(null),[n,a]=k.useState(!1),[o,l]=k.useState(!0),[i,d]=k.useState(!1),u=k.useCallback(async()=>{if(!t){l(!1);return}try{const{data:b,error:N}=await G.from("levelup_briefs").select("*").eq("is_published",!0).lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(1).single();if(N||!b){l(!1);return}const{data:w}=await G.from("levelup_brief_views").select("*").eq("brief_id",b.id).eq("user_id",t.id).maybeSingle(),[S,C]=await Promise.all([G.from("levelup_brief_links").select("*").eq("brief_id",b.id).order("sort_order"),G.from("levelup_brief_polls").select("*").eq("brief_id",b.id).order("sort_order")]),A=[];if(C.data)for(const q of C.data){const{data:B}=await G.from("levelup_brief_poll_options").select("*").eq("poll_id",q.id).order("sort_order");A.push({...q,options:B||[]})}const I={brief:b,links:S.data||[],polls:A};r(I);const L=!!w,O=(w==null?void 0:w.dismissed_at)!=null,V=localStorage.getItem(`brief-dismissed-${b.id}`)==="true";if(O||V)d(!1),a(!1);else if(!L)a(!0),d(!0);else if(b.show_frequency==="every_login")a(!0),d(!0);else if(b.show_frequency==="daily"){const q=new Date(w.viewed_at);(new Date().getTime()-q.getTime())/(1e3*60*60)>=24&&(a(!0),d(!0))}else d(!1)}catch(b){console.error("Error fetching brief:",b)}finally{l(!1)}},[t]);k.useEffect(()=>{u()},[u]);const p=async()=>{if(!(!t||!s))try{const{data:b}=await G.from("levelup_brief_views").select("id").eq("brief_id",s.brief.id).eq("user_id",t.id).maybeSingle();b?await G.from("levelup_brief_views").update({viewed_at:new Date().toISOString()}).eq("id",b.id):await G.from("levelup_brief_views").insert({brief_id:s.brief.id,user_id:t.id})}catch(b){console.error("Error marking brief as viewed:",b)}};return{currentBrief:s,shouldShowPopup:n,hasUnseenBrief:i,loading:o,openBrief:()=>{a(!0)},closeBrief:()=>{a(!1),p()},dismissBrief:async()=>{if(!(!t||!s)){a(!1),d(!1);try{const{data:b,error:N}=await G.from("levelup_brief_views").select("id").eq("brief_id",s.brief.id).eq("user_id",t.id).maybeSingle();if(N&&console.error("Error checking existing brief view:",N),b){const{error:w}=await G.from("levelup_brief_views").update({dismissed_at:new Date().toISOString()}).eq("id",b.id).eq("user_id",t.id);w&&console.error("Error updating brief dismiss:",w)}else{const{error:w}=await G.from("levelup_brief_views").insert({brief_id:s.brief.id,user_id:t.id,dismissed_at:new Date().toISOString()});w&&console.error("Error inserting brief dismiss:",w)}localStorage.setItem(`brief-dismissed-${s.brief.id}`,"true")}catch(b){console.error("Error dismissing brief:",b),s&&localStorage.setItem(`brief-dismissed-${s.brief.id}`,"true")}}},refetch:u}};function Z6t(){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 y=_=>{_.preventDefault(),o(_)};return window.addEventListener("beforeinstallprompt",y),()=>{window.removeEventListener("beforeinstallprompt",y)}},[]);const l=()=>{localStorage.setItem("install-banner-dismissed","true"),s(!1)},i=async()=>{if(a){await a.prompt();const{outcome:d}=await a.userChoice;d==="accepted"&&l(),o(null)}};return t?e.jsx("div",{className:"fixed bottom-0 left-0 right-0 z-50 p-4 bg-primary text-primary-foreground shadow-lg animate-in slide-in-from-bottom duration-300",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"flex-shrink-0 p-2 bg-primary-foreground/10 rounded-full",children:e.jsx(Qa,{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(zL,{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(W,{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(kr,{className:"h-4 w-4"})})]})]})}):null}const Y6t=({children:t,onRefresh:s})=>{const[r,n]=k.useState(!1),[a,o]=k.useState(0),[l,i]=k.useState(!1),d=k.useRef(null),u=k.useRef(0),p=Qt(),f=80,y=120,_=k.useCallback(C=>{const A=d.current;A&&A.scrollTop<=0&&(u.current=C.touches[0].clientY,n(!0))},[]),b=k.useCallback(C=>{if(!r||l)return;const A=d.current;if(!A||A.scrollTop>0){n(!1),o(0);return}const L=C.touches[0].clientY-u.current;if(L>0){const V=Math.min(L*.5,y);o(V),V>10&&C.preventDefault()}},[r,l]),N=k.useCallback(async()=>{if(r)if(n(!1),a>=f&&!l){i(!0),o(f);try{s?await s():await p.invalidateQueries()}catch(C){console.error("Refresh failed:",C)}finally{i(!1),o(0)}}else o(0)},[r,a,l,s,p]),w=Math.min(a/f,1),S=w*180;return e.jsxs("div",{ref:d,className:"h-full overflow-auto",onTouchStart:_,onTouchMove:b,onTouchEnd:N,children:[e.jsx("div",{className:"flex justify-center items-center overflow-hidden transition-all duration-200 ease-out",style:{height:a>0?a:0,opacity:w},children:e.jsx("div",{className:`p-2 rounded-full bg-primary/10 ${l?"animate-spin":""}`,style:{transform:l?void 0:`rotate(${S}deg)`,transition:l?void 0:"transform 0.1s ease-out"},children:e.jsx(Zi,{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})]})},XYe=()=>{const{user:t}=Us(),[s,r]=k.useState(!1),[n,a]=k.useState(!1),[o,l]=k.useState(0),[i,d]=k.useState(!0);k.useEffect(()=>{(async()=>{if(!t){d(!1);return}try{const{data:_}=await G.from("membership_reviews").select("id").eq("user_id",t.id).maybeSingle();if(_){a(!0),r(!1),d(!1);return}const{data:b}=await G.from("profiles").select("login_count").eq("id",t.id).single(),N=(b==null?void 0:b.login_count)||0;l(N);const w=sessionStorage.getItem("review-prompt-dismissed");r(N>=4&&!w)}catch(_){console.error("Error checking review eligibility:",_)}finally{d(!1)}})()},[t]);const u=k.useCallback(()=>{sessionStorage.setItem("review-prompt-dismissed","true"),r(!1)},[]),p=k.useCallback(async(y,_)=>{if(!t)return{success:!1,error:"Not authenticated"};try{const{error:b}=await G.from("membership_reviews").insert({user_id:t.id,rating:y,review_text:_});if(b)throw b;return a(!0),r(!1),{success:!0,pointsAwarded:25}}catch(b){return console.error("Error submitting review:",b),{success:!1,error:b.message}}},[t]),f=k.useCallback(async()=>{if(t)try{await G.from("membership_reviews").update({posted_to_google:!0}).eq("user_id",t.id)}catch(y){console.error("Error updating Google review status:",y)}},[t]);return{shouldShowPrompt:s,hasSubmittedReview:n,loginCount:o,isLoading:i,dismissPrompt:u,submitReview:p,markPostedToGoogle:f}},X6t="https://search.google.com/local/writereview?placeid=ChIJM73ERQD1QogRPxupMFObuck&source=g.page.m.ia._&laa=nmx-review-solicitation-ia2",Q6t=()=>{const{shouldShowPrompt:t,isLoading:s,dismissPrompt:r,submitReview:n,markPostedToGoogle:a}=XYe(),[o,l]=k.useState(!1),[i,d]=k.useState("review"),[u,p]=k.useState(0),[f,y]=k.useState(0),[_,b]=k.useState(""),[N,w]=k.useState(!1),[S,C]=k.useState(!1);if(s||!t&&!S)return null;const A=async()=>{if(u===0){fn({title:"Please select a rating",variant:"destructive"});return}w(!0);const O=await n(u,_);w(!1),O.success?(C(!0),fn({title:"Thank you for your feedback!",description:"Your review helps us improve."}),d("google")):fn({title:"Error submitting review",description:O.error,variant:"destructive"})},I=async O=>{O&&(await navigator.clipboard.writeText(_||`${u} star rating for LevelUp!`),fn({title:"Review copied!",description:"Paste it on Google Reviews."}),await a(),window.open(X6t,"_blank")),l(!1),r()},L=()=>{l(!1),r()};return e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>l(!0),className:"fixed bottom-20 left-1/2 -translate-x-1/2 z-40 flex items-center gap-2 rounded-full bg-primary/90 px-3 py-2 text-xs text-primary-foreground shadow-lg backdrop-blur-sm transition-all hover:bg-primary hover:scale-105 md:bottom-6",children:[e.jsx(Gn,{className:"h-3.5 w-3.5 fill-current"}),e.jsx("span",{className:"hidden sm:inline",children:"Leave a Review"})]}),e.jsx(fs,{open:o,onOpenChange:L,children:e.jsx(ps,{className:"sm:max-w-md",children:i==="review"?e.jsxs(e.Fragment,{children:[e.jsxs(ks,{children:[e.jsx(_s,{className:"text-center",children:"How are you enjoying LevelUp?"}),e.jsx(Ir,{className:"text-center",children:"Your feedback helps us improve the experience for all members."})]}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsx("div",{className:"flex justify-center gap-1",children:[1,2,3,4,5].map(O=>e.jsx("button",{type:"button",onClick:()=>p(O),onMouseEnter:()=>y(O),onMouseLeave:()=>y(0),className:"p-1 transition-transform hover:scale-110",children:e.jsx(Gn,{className:Ot("h-8 w-8 transition-colors",(f||u)>=O?"fill-yellow-400 text-yellow-400":"text-muted-foreground")})},O))}),e.jsx(_r,{placeholder:"Tell us about your experience (optional)",value:_,onChange:O=>b(O.target.value),rows:4,className:"resize-none"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{variant:"outline",onClick:L,className:"flex-1",children:"Maybe Later"}),e.jsx(W,{onClick:A,disabled:N||u===0,className:"flex-1",children:N?"Submitting...":"Submit Review"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(ks,{children:[e.jsx(_s,{className:"text-center",children:"🎉 Thank you!"}),e.jsx(Ir,{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(W,{variant:"outline",onClick:()=>I(!1),className:"flex-1",children:"No Thanks"}),e.jsx(W,{onClick:()=>I(!0),className:"flex-1",children:"Yes, Open Google"})]})]})]})})})]})};function J6t(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 N="vapid_public_key";let w=localStorage.getItem(N);if(!w){const{data:A,error:I}=await G.functions.invoke("get-vapid-public-key",{body:{}});if(I)throw I;if(w=(A==null?void 0:A.vapidPublicKey)??null,!w)throw new Error("Missing VAPID public key");localStorage.setItem(N,w)}p(w);const S=await navigator.serviceWorker.register("/push-sw.js",{scope:"/push-notifications/"});d(S),r(Notification.permission);const C=await S.pushManager.getSubscription();a(!!C)}catch(N){console.error("Error initializing push notifications:",N)}finally{l(!1)}})()},[f]);const y=k.useCallback(async()=>{if(!f||!i||!t)return console.error("Push notifications not supported or user not logged in"),!1;if(!u)return pe.error("Push notifications are not ready yet. Please try again in a moment."),!1;try{l(!0);const b=await i.pushManager.getSubscription();if(b){try{await b.unsubscribe()}catch(I){console.warn("Failed to unsubscribe existing push subscription:",I)}const{error:A}=await G.from("push_subscriptions").delete().eq("user_id",t.id);A&&console.warn("Failed to cleanup push_subscriptions rows:",A)}if(Notification.permission!=="granted"){const A=await Notification.requestPermission();if(r(A),A!=="granted")return A==="denied"?pe.error("Notifications blocked. Please enable them in your browser settings (click the lock icon in the address bar)."):pe.error("Notification permission was dismissed. Please try again."),!1}const N=J6t(u);let w;try{w=await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:N})}catch(A){console.error("PushManager.subscribe() failed:",A);const I=(A==null?void 0:A.message)||String(A);return I.includes("permission")?pe.error("Push permission denied. Check your browser notification settings."):I.includes("key")||I.includes("VAPID")?pe.error("Push configuration error. Please contact support."):I.includes("AbortError")?pe.error("Push subscription was cancelled. Please try again."):pe.error(`Failed to subscribe: ${I}`),!1}const S=w.toJSON(),{error:C}=await G.from("push_subscriptions").upsert({user_id:t.id,endpoint:S.endpoint,p256dh_key:S.keys.p256dh,auth_key:S.keys.auth},{onConflict:"user_id,endpoint"});if(C)throw console.error("Error saving subscription:",C),pe.error("Failed to save notification preferences. Please try again."),C;return a(!0),pe.success("Push notifications enabled!"),!0}catch(b){if(console.error("Error subscribing to push notifications:",b),!(b instanceof Error&&b.message.includes("toast"))){const N=b instanceof Error?b.message:"Unknown error";pe.error("Failed to enable push notifications: "+N)}return!1}finally{l(!1)}},[f,i,t,u]),_=k.useCallback(async()=>{if(!i||!t)return!1;try{l(!0);const b=await i.pushManager.getSubscription();return b&&await b.unsubscribe(),await G.from("push_subscriptions").delete().eq("user_id",t.id),a(!1),pe.success("Push notifications disabled"),!0}catch(b){console.error("Error unsubscribing:",b);const N=b instanceof Error?b.message:"Unknown error";return pe.error("Failed to disable push notifications: "+N),!1}finally{l(!1)}},[i,t]);return{isSupported:f,permission:s,isSubscribed:n,isLoading:o,vapidPublicKey:u,subscribe:y,unsubscribe:_}}const Uge="push_notification_prompt_dismissed",eIt=["/dashboard","/admin"],tIt=()=>{const{user:t}=Us(),{isSupported:s,isSubscribed:r,isLoading:n,subscribe:a}=QYe(),o=$l(),[l,i]=k.useState(!1),[d,u]=k.useState(!1),p=eIt.some(_=>o.pathname===_||o.pathname.startsWith(`${_}/`));k.useEffect(()=>{if(p){i(!1);return}if(!t||!s||r||n||localStorage.getItem(`${Uge}_${t.id}`))return;const b=setTimeout(()=>{i(!0)},2e3);return()=>clearTimeout(b)},[t,s,r,n,p]);const f=async()=>{u(!0);const _=await a();u(!1),_&&(t&&localStorage.setItem(`${Uge}_${t.id}`,"true"),i(!1))},y=()=>{t&&localStorage.setItem(`${Uge}_${t.id}`,"true"),i(!1)};return!s||r||p?null:e.jsx(fs,{open:l,onOpenChange:_=>!_&&y(),children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(ks,{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(Sm,{className:"h-6 w-6 text-primary"})}),e.jsx(_s,{className:"text-center",children:"Stay in the Loop!"}),e.jsx(Ir,{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(W,{onClick:f,disabled:d,className:"w-full",children:d?"Enabling...":"Enable Notifications"}),e.jsx(W,{variant:"ghost",onClick:y,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."})]})})},XIe=t=>{let s;const r=new Set,n=(u,p)=>{const f=typeof u=="function"?u(s):u;if(!Object.is(f,s)){const y=s;s=p??(typeof f!="object"||f===null)?f:Object.assign({},s,f),r.forEach(_=>_(s,y))}},a=()=>s,i={setState:n,getState:a,getInitialState:()=>d,subscribe:u=>(r.add(u),()=>r.delete(u))},d=s=t(n,a,i);return i},sIt=t=>t?XIe(t):XIe,rIt=t=>t;function nIt(t,s=rIt){const r=xt.useSyncExternalStore(t.subscribe,xt.useCallback(()=>s(t.getState()),[t,s]),xt.useCallback(()=>s(t.getInitialState()),[t,s]));return xt.useDebugValue(r),r}const QIe=t=>{const s=sIt(t),r=n=>nIt(s,n);return Object.assign(r,s),r},aIt=t=>t?QIe(t):QIe;function iIt(t,s){let r;try{r=t()}catch{return}return{getItem:a=>{var o;const l=d=>d===null?null:JSON.parse(d,void 0),i=(o=r.getItem(a))!=null?o:null;return i instanceof Promise?i.then(l):l(i)},setItem:(a,o)=>r.setItem(a,JSON.stringify(o,void 0)),removeItem:a=>r.removeItem(a)}}const o_e=t=>s=>{try{const r=t(s);return r instanceof Promise?r:{then(n){return o_e(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return o_e(n)(r)}}}},oIt=(t,s)=>(r,n,a)=>{let o={storage:iIt(()=>window.localStorage),partialize:w=>w,version:0,merge:(w,S)=>({...S,...w}),...s},l=!1,i=0;const d=new Set,u=new Set;let p=o.storage;if(!p)return t((...w)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),r(...w)},n,a);const f=()=>{const w=o.partialize({...n()});return p.setItem(o.name,{state:w,version:o.version})},y=a.setState;a.setState=(w,S)=>(y(w,S),f());const _=t((...w)=>(r(...w),f()),n,a);a.getInitialState=()=>_;let b;const N=()=>{var w,S;if(!p)return;const C=++i;l=!1,d.forEach(I=>{var L;return I((L=n())!=null?L:_)});const A=((S=o.onRehydrateStorage)==null?void 0:S.call(o,(w=n())!=null?w:_))||void 0;return o_e(p.getItem.bind(p))(o.name).then(I=>{if(I)if(typeof I.version=="number"&&I.version!==o.version){if(o.migrate){const L=o.migrate(I.state,I.version);return L instanceof Promise?L.then(O=>[!0,O]):[!0,L]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,I.state];return[!1,void 0]}).then(I=>{var L;if(C!==i)return;const[O,V]=I;if(b=o.merge(V,(L=n())!=null?L:_),r(b,!0),O)return f()}).then(()=>{C===i&&(A==null||A(n(),void 0),b=n(),l=!0,u.forEach(I=>I(b)))}).catch(I=>{C===i&&(A==null||A(void 0,I))})};return a.persist={setOptions:w=>{o={...o,...w},w.storage&&(p=w.storage)},clearStorage:()=>{p==null||p.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>N(),hasHydrated:()=>l,onHydrate:w=>(d.add(w),()=>{d.delete(w)}),onFinishHydration:w=>(u.add(w),()=>{u.delete(w)})},o.skipHydration||N(),b||_},lIt=oIt,she=aIt()(lIt((t,s)=>({cartItems:[],addToCart:(r,n,a=1,o)=>{t(l=>{const i=l.cartItems.findIndex(d=>{var u;return d.product.id===r.id&&((u=d.variant)==null?void 0:u.id)===(n==null?void 0:n.id)});if(i>=0){const d=[...l.cartItems];return d[i].quantity+=a,o&&(d[i].artworkUrl=o),{cartItems:d}}return{cartItems:[...l.cartItems,{product:r,variant:n,quantity:a,artworkUrl:o}]}})},removeFromCart:(r,n)=>{t(a=>({cartItems:a.cartItems.filter(o=>{var l;return!(o.product.id===r&&((l=o.variant)==null?void 0:l.id)===n)})}))},updateQuantity:(r,n,a)=>{t(o=>({cartItems:o.cartItems.map(l=>{var i;return l.product.id===r&&((i=l.variant)==null?void 0:i.id)===n?{...l,quantity:Math.max(1,a)}:l})}))},updateArtwork:(r,n,a)=>{t(o=>({cartItems:o.cartItems.map(l=>{var i;return l.product.id===r&&((i=l.variant)==null?void 0:i.id)===n?{...l,artworkUrl:a}:l})}))},clearCart:()=>t({cartItems:[]}),getItemPrice:r=>{const n=Number(r.product.base_price),a=r.variant?Number(r.variant.price_adjustment):0;return n+a},getSubtotal:()=>{const{cartItems:r,getItemPrice:n}=s();return r.reduce((a,o)=>a+n(o)*o.quantity,0)},getShippingTotal:()=>{const{cartItems:r}=s();return r.reduce((n,a)=>n+Number(a.product.shipping_fee)*a.quantity,0)},getTotal:()=>{const{getSubtotal:r,getShippingTotal:n}=s();return r()+n()}}),{name:"marketplace-cart",partialize:t=>({cartItems:t.cartItems})}));function CC(){const{user:t}=Us(),{data:s,isLoading:r}=gt({queryKey:["agent-lead-site",t==null?void 0:t.id],queryFn:async()=>{const{data:n,error:a}=await G.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 JYe=k.createContext({onlineUsers:[],totalOnline:0}),cIt=async t=>{try{const{data:s}=await G.storage.from("avatars").list(`${t}`);if(s&&s.length>0){const{data:r}=G.storage.from("avatars").getPublicUrl(`${t}/${s[0].name}`);return r.publicUrl}}catch{}},dIt=({children:t})=>{const{user:s,brokerageId:r,isAdmin:n}=Us(),[a,o]=k.useState([]),[l,i]=k.useState(null);k.useEffect(()=>{if(!s)return;const u=G.channel("app-presence",{config:{presence:{key:s.id}}});return u.on("presence",{event:"sync"},()=>{const p=u.presenceState(),f=[];Object.entries(p).forEach(([y,_])=>{if(_&&_.length>0){const b=_[0];f.push({id:y,name:b.name||"Unknown",avatarUrl:b.avatarUrl,brokerageId:b.brokerageId,onlineSince:b.onlineSince})}}),o(f)}).on("presence",{event:"join"},()=>{}).on("presence",{event:"leave"},()=>{}).subscribe(async p=>{var f;if(p==="SUBSCRIBED"){const{data:y}=await G.from("profiles").select("name, brokerage_id").eq("id",s.id).single(),_=await cIt(s.id);await u.track({name:(y==null?void 0:y.name)||((f=s.email)==null?void 0:f.split("@")[0])||"User",avatarUrl:_,brokerageId:y==null?void 0:y.brokerage_id,onlineSince:new Date().toISOString()})}}),i(u),()=>{u.unsubscribe()}},[s]);const d=a.filter(u=>u.id===(s==null?void 0:s.id)?!1:!!(n||r&&u.brokerageId===r||!r&&!u.brokerageId));return e.jsx(JYe.Provider,{value:{onlineUsers:d,totalOnline:a.length},children:t})},eXe=()=>k.useContext(JYe),JIe="dashboard-sidebar-collapsed",Ds=({children:t,title:s})=>{var fe;const{user:r,signOut:n,isAdmin:a,isBrokerageManager:o,brokerageId:l}=Us(),{isAssistant:i,actingAsAgent:d,hasPermission:u}=Eje(),{isImpersonating:p}=mue(),y=(i&&!!d?40:0)+(p?40:0),{avatarUrl:_}=QZe(r==null?void 0:r.id),{isTrial:b,isExpired:N,expiresAt:w}=vPt(r==null?void 0:r.id),{isInnerCircleEnabled:S,isMarketplaceEnabled:C}=eYe(),{currentBrief:A,shouldShowPopup:I,hasUnseenBrief:L,openBrief:O,closeBrief:V,dismissBrief:q}=K6t(),{unreadCount:B}=_Pt(),{openCount:U}=bPt(),{data:te}=Px(),Y=!!te,X=she($e=>$e.cartItems).reduce(($e,Ye)=>$e+Ye.quantity,0),{leadSite:ce,hasLeadSite:ie,siteUrl:ae}=CC(),oe=wr(),me=$l(),[ve,he]=k.useState(null);k.useEffect(()=>{r!=null&&r.id&&G.from("profiles").select("name").eq("id",r.id).single().then(({data:$e})=>{$e!=null&&$e.name&&he($e.name)})},[r==null?void 0:r.id]);const ge=ve||((fe=r==null?void 0:r.user_metadata)==null?void 0:fe.name)||(r==null?void 0:r.email)||"User",[je,qe]=k.useState(()=>typeof window<"u"?localStorage.getItem(JIe)==="true":!1);k.useEffect(()=>{localStorage.setItem(JIe,String(je))},[je]);const[Me,ke]=k.useState({agentos:!0,tools:!0,marketing:!0,learning:!0,community:!0,contacts:!0,website:!0,help:!1}),Re=$e=>{ke(Ye=>({...Ye,[$e]:!Ye[$e]}))},Ve=$e=>$e.split(" ").map(Ye=>Ye[0]).join("").toUpperCase().slice(0,2),Ne=$e=>me.pathname===$e,Ue=$e=>$e.some(Ye=>me.pathname===Ye),Ie=({path:$e,icon:Ye,label:tt,badgeCount:Te})=>{const We=e.jsxs(W,{variant:"ghost",size:"sm",className:Ot("text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",Ne($e)&&"bg-sidebar-accent text-sidebar-accent-foreground",je?"w-10 h-10 p-0 justify-center":"w-full justify-start gap-2"),onClick:()=>oe($e),children:[e.jsxs("div",{className:"relative",children:[e.jsx(Ye,{className:"h-4 w-4 shrink-0"}),je&&Te!=null&&Te>0&&e.jsx("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-muted-foreground/40 border border-background"})]}),!je&&tt,!je&&Te!=null&&Te>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:Te>9?"9+":Te})]});return je?e.jsxs(ec,{delayDuration:0,children:[e.jsx(tc,{asChild:!0,children:We}),e.jsxs(Dl,{side:"right",className:"flex items-center gap-2",children:[tt,Te!=null&&Te>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:Te>9?"9+":Te})]})]}):We},ye=({id:$e,label:Ye,icon:tt,children:Te,activePaths:We,showBetaBadge:Ke,defaultPath:ot,badgeCount:He})=>{if(je){const Je=ot||We[0];return e.jsxs(ec,{delayDuration:0,children:[e.jsx(tc,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"sm",className:Ot("w-10 h-10 p-0 justify-center text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",Ue(We)&&"text-primary"),onClick:()=>oe(Je),children:e.jsxs("div",{className:"relative",children:[e.jsx(tt,{className:"h-4 w-4"}),He!=null&&He>0&&e.jsx("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-muted-foreground/40 border border-background"})]})})}),e.jsxs(Dl,{side:"right",className:"flex items-center gap-2",children:[Ye,Ke&&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"}),He!=null&&He>0&&e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-muted text-muted-foreground text-xs font-medium border border-muted-foreground/20",children:He>9?"9+":He})]})]})}return e.jsxs(lf,{open:Me[$e],onOpenChange:()=>Re($e),children:[e.jsx(cf,{asChild:!0,children:e.jsxs(W,{variant:"ghost",size:"sm",className:Ot("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ue(We)&&"text-primary"),children:[e.jsxs("span",{className:"flex items-center gap-2 font-semibold text-[15px]",children:[e.jsx(tt,{className:"h-4 w-4"}),Ye,Ke&&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:[He!=null&&He>0&&e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-muted text-muted-foreground text-xs font-medium border border-muted-foreground/20",children:He>9?"9+":He}),e.jsx(Bi,{className:Ot("h-4 w-4 transition-transform duration-200",Me[$e]&&"rotate-180")})]})]})}),e.jsx(df,{className:"pl-4 space-y-1 mt-1",children:Te})]})},ct=({isMobile:$e=!1})=>{const Ye=$e?!1:je;return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:Ot("p-3 border-b border-sidebar-border",Ye?"flex flex-col items-center gap-2":"flex items-center justify-between"),children:[Ye?e.jsx("img",{src:TPt,alt:"LevelUp",className:"h-8 w-auto"}):e.jsx("img",{src:MPt,alt:"LevelUp",className:"h-8 w-auto"}),!$e&&e.jsxs(ec,{delayDuration:0,children:[e.jsx(tc,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>qe(!Ye),children:e.jsx(Xo,{className:Ot("h-4 w-4 transition-transform duration-300",Ye&&"rotate-180")})})}),e.jsx(Dl,{side:"right",children:Ye?"Expand sidebar":"Collapse sidebar"})]})]}),e.jsx(Ja,{className:"flex-1 [&_[data-radix-scroll-area-scrollbar]]:w-1.5",children:e.jsxs("nav",{className:Ot("p-3 space-y-1",Ye&&"flex flex-col items-center"),children:[e.jsx(Ie,{path:"/dashboard",icon:aS,label:"Dashboard"}),e.jsx(Ie,{path:"/apps",icon:Xf,label:"Apps & Tools"}),je?e.jsxs(ec,{delayDuration:0,children:[e.jsx(tc,{asChild:!0,children:e.jsxs(W,{variant:"ghost",size:"sm",className:Ot("w-10 h-10 p-0 justify-center relative text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ne("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/levelup-u"),children:[e.jsx(Lh,{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(Dl,{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(W,{variant:"ghost",size:"sm",className:Ot("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ne("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/levelup-u"),children:[e.jsx(Lh,{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(Ie,{path:"/events",icon:_d,label:"Events"}),e.jsxs(ye,{id:"agentos",label:"Agent OS",icon:vM,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(Ie,{path:"/mission-control",icon:Xa,label:"Mission Control"}),u("contacts")&&!Ye&&e.jsxs(lf,{open:Me.contacts,onOpenChange:()=>Re("contacts"),children:[e.jsx(cf,{asChild:!0,children:e.jsxs(W,{variant:"ghost",size:"sm",className:Ot("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ue(["/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(ir,{className:"h-4 w-4"}),"Contacts"]}),e.jsx(Bi,{className:Ot("h-3.5 w-3.5 transition-transform duration-200",Me.contacts&&"rotate-180")})]})}),e.jsxs(df,{className:"pl-4 pr-1 space-y-0.5 mt-0.5",children:[e.jsx(Ie,{path:"/mission-control/contacts",icon:ir,label:"All Contacts"}),e.jsx(Ie,{path:"/mission-control/relationship-scorecard",icon:lh,label:"Relationship Report"}),e.jsx(Ie,{path:"/mission-control/sphere-gaps",icon:OL,label:"Sphere Gaps"}),e.jsx(Ie,{path:"/mission-control/connect-page",icon:Do,label:"Connect Page"})]})]}),u("contacts")&&Ye&&e.jsx(Ie,{path:"/mission-control/contacts",icon:ir,label:"Contacts"}),u("contacts")&&e.jsx(Ie,{path:"/mission-control/plans",icon:_d,label:"TouchPlans"}),u("pipeline")&&e.jsx(Ie,{path:"/mission-control/pipeline",icon:Yy,label:"Deal Pipeline"}),u("pipeline")&&e.jsx(Ie,{path:"/mission-control/tasks",icon:Pv,label:"Tasks"}),u("popbys")&&e.jsx(Ie,{path:"/mission-control/popbys",icon:hi,label:"Popbys"}),u("videos")&&e.jsx(Ie,{path:"/mission-control/video-library",icon:yn,label:"Video Library"}),u("scorecard")&&e.jsx(Ie,{path:"/mission-control/scorecard",icon:so,label:"Scorecard"}),u("listings")&&e.jsx(Ie,{path:"/mission-control/listings",icon:pa,label:"Listing Exchange"}),!Ye&&e.jsxs(W,{variant:"ghost",size:"sm",className:Ot("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ne("/mission-control/smart-drips")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/mission-control/smart-drips"),children:[e.jsx(Oh,{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"})]}),Ye&&e.jsx(Ie,{path:"/mission-control/smart-drips",icon:Oh,label:"Smart Drips"})]}),ie&&ce&&e.jsxs(ye,{id:"website",label:"My Website",icon:nd,activePaths:[`/admin/lead-sites/${ce.id}/edit`],defaultPath:`/admin/lead-sites/${ce.id}/edit`,children:[Ye?e.jsxs(ec,{delayDuration:0,children:[e.jsx(tc,{asChild:!0,children:e.jsx(W,{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(ae||"#","_blank"),children:e.jsx(jn,{className:"h-4 w-4"})})}),e.jsx(Dl,{side:"right",children:"View Site"})]}):e.jsxs(W,{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(ae||"#","_blank"),children:[e.jsx(jn,{className:"h-4 w-4"}),"View Site",e.jsx(Yr,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsx(Ie,{path:`/my-website/${ce.id}/edit`,icon:ga,label:"Edit Website"}),e.jsx(Ie,{path:"/my-website/mls-listings",icon:Mn,label:"MLS Listings"}),e.jsx(Ie,{path:"/my-website/market-report",icon:so,label:"Market Reports"}),e.jsx(Ie,{path:"/mission-control/website-activity",icon:lh,label:"Website Activity"}),e.jsx(Ie,{path:"/m",icon:Ig,label:"Mobile Command"})]}),e.jsxs(ye,{id:"marketing",label:"Marketing",icon:uh,activePaths:["/templates","/social-swag-2","/newsletters"],defaultPath:"/templates",children:[e.jsx(Ie,{path:"/templates",icon:zl,label:"Templates"}),e.jsx(Ie,{path:"/social-swag-2",icon:Ig,label:"Social Swag"}),e.jsx(Ie,{path:"/newsletters",icon:Jv,label:"Newsletters"})]}),e.jsxs(ye,{id:"learning",label:"Learning",icon:ch,activePaths:["/academy","/toolbox"],defaultPath:"/academy",children:[e.jsx(Ie,{path:"/academy",icon:Lh,label:"Academy"}),e.jsx(Ie,{path:"/toolbox",icon:Lg,label:"Toolbox"})]}),e.jsxs(ye,{id:"community",label:"Community",icon:wi,activePaths:["/community","/wishlist"],defaultPath:"/community",badgeCount:B,children:[e.jsx(Ie,{path:"/community",icon:ir,label:"Community",badgeCount:B}),e.jsx(Ie,{path:"/wishlist",icon:Cb,label:"Wishlist",badgeCount:U}),!Ye&&e.jsxs(W,{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(Yr,{className:"h-4 w-4"}),"Facebook Group"]})]}),e.jsxs(ye,{id:"goods",label:"The Goods",icon:lp,activePaths:["/marketplace","/reward-store"],defaultPath:"/reward-store",children:[C&&!Ye&&e.jsxs(W,{variant:"ghost",size:"sm",className:Ot("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",me.pathname.startsWith("/marketplace")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/marketplace"),children:[e.jsx(lp,{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"})]}),C&&Ye&&e.jsx(Ie,{path:"/marketplace",icon:lp,label:"Marketplace"}),e.jsx(Ie,{path:"/reward-store",icon:Fi,label:"Reward Store"}),e.jsx(Ie,{path:"/refer-friends",icon:hi,label:"Refer & Earn"})]}),e.jsxs(ye,{id:"help",label:"Help & Services",icon:Mv,activePaths:["/support","/additional-services"],defaultPath:"/support",children:[e.jsx(Ie,{path:"/support",icon:TM,label:"Support"}),e.jsx(Ie,{path:"/additional-services",icon:Or,label:"Additional Services"})]}),a&&e.jsxs(e.Fragment,{children:[!Ye&&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"})}),Ye?e.jsx("div",{className:"pt-3 border-t border-sidebar-border mt-3 space-y-1",children:e.jsx(Ie,{path:"/admin",icon:ad,label:"Admin Dashboard"})}):e.jsxs(W,{variant:"ghost",size:"sm",className:Ot("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",me.pathname==="/admin"&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/admin"),children:[e.jsx(ad,{className:"h-4 w-4"}),"Admin Dashboard"]})]}),(l||o)&&!a&&e.jsxs(e.Fragment,{children:[!Ye&&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"})}),Ye?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(Ie,{path:"/my-brokerage",icon:pa,label:"My Brokerage"}),e.jsx(Ie,{path:"/brokerage-content",icon:ch,label:"Brokerage Content"})]}),Y&&!o&&e.jsx(Ie,{path:"/my-team",icon:ir,label:"My Team"}),o&&e.jsxs(e.Fragment,{children:[e.jsx(Ie,{path:"/brokerage/dashboard",icon:So,label:"Manage Brokerages"}),e.jsx(Ie,{path:"/brokerage/teams",icon:ir,label:"Teams"}),e.jsx(Ie,{path:"/brokerage/recruiting",icon:uh,label:"Recruiting"}),e.jsx(Ie,{path:"/brokerage-resources",icon:dh,label:"Brokerage Resources"})]})]}):e.jsxs(e.Fragment,{children:[l&&e.jsxs(e.Fragment,{children:[e.jsxs(W,{variant:"ghost",size:"sm",className:Ot("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ne("/my-brokerage")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/my-brokerage"),children:[e.jsx(pa,{className:"h-4 w-4"}),"My Brokerage"]}),e.jsxs(W,{variant:"ghost",size:"sm",className:Ot("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ne("/brokerage-content")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/brokerage-content"),children:[e.jsx(ch,{className:"h-4 w-4"}),"Brokerage Content"]})]}),Y&&!o&&e.jsxs(W,{variant:"ghost",size:"sm",className:Ot("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ne("/my-team")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/my-team"),children:[e.jsx(ir,{className:"h-4 w-4"}),"My Team"]}),o&&e.jsxs(e.Fragment,{children:[e.jsxs(W,{variant:"ghost",size:"sm",className:Ot("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ne("/brokerage/dashboard")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/brokerage/dashboard"),children:[e.jsx(So,{className:"h-4 w-4"}),"Manage Brokerages"]}),e.jsxs(W,{variant:"ghost",size:"sm",className:Ot("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ne("/brokerage/teams")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/brokerage/teams"),children:[e.jsx(ir,{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(W,{variant:"ghost",size:"sm",className:Ot("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ne("/brokerage/recruiting")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/brokerage/recruiting"),children:[e.jsx(uh,{className:"h-4 w-4"}),"Recruiting"]}),e.jsxs(W,{variant:"ghost",size:"sm",className:Ot("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ne("/brokerage-resources")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/brokerage-resources"),children:[e.jsx(dh,{className:"h-4 w-4"}),"Brokerage Resources"]})]})]})]})]})}),e.jsxs("div",{className:"p-3 border-t border-sidebar-border md:hidden",children:[e.jsxs(W,{variant:"ghost",size:"sm",className:Ot("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ne("/profile")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/profile"),children:[e.jsx(Ai,{className:"h-4 w-4"}),"Profile"]}),e.jsxs(W,{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(EM,{className:"h-4 w-4"}),"Sign Out"]})]})]})};return e.jsx(dIt,{children:e.jsx(S1,{children:e.jsxs("div",{className:"min-h-screen bg-background flex",children:[b&&N&&e.jsx(E6t,{}),typeof document<"u"&&op.createPortal(e.jsx("aside",{className:Ot("hidden md:flex flex-col bg-card border-r border-border fixed left-0 z-30 !pointer-events-auto transition-[width] duration-300",je?"w-16":"w-56"),style:{top:`${y}px`,height:`calc(100vh - ${y}px)`},children:e.jsx(ct,{})}),document.body),e.jsxs("div",{className:Ot("flex-1 flex flex-col overflow-hidden transition-all duration-300",je?"md:ml-16":"md:ml-56"),style:{height:`calc(100vh - ${y}px)`,marginTop:`${y}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(ZA,{children:[e.jsx(zNe,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",className:"md:hidden",children:e.jsx(dS,{className:"h-5 w-5"})})}),e.jsx(SC,{side:"left",className:"w-56 p-0 bg-card",children:e.jsx(ct,{isMobile:!0})})]}),e.jsx("div",{className:"flex-1 md:hidden",children:e.jsx("img",{src:APt,alt:"LevelUp",className:"h-8 w-auto"})}),e.jsx("div",{className:"hidden md:flex flex-1 justify-center",children:e.jsx(YIe,{})}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[b&&!N&&w&&e.jsx(A6t,{expiresAt:w,className:"hidden lg:flex"}),e.jsx("div",{className:"md:hidden",children:e.jsx(YIe,{})}),A&&e.jsx(P6t,{hasUnseenBrief:L,onClick:O}),C&&e.jsxs(W,{variant:"ghost",size:"icon",className:"relative",onClick:()=>oe("/marketplace/cart"),children:[e.jsx(lp,{className:"h-5 w-5"}),X>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:X>99?"99+":X})]}),e.jsx(s6t,{}),e.jsx(n_e,{}),e.jsxs("span",{className:"hidden sm:block text-sm font-medium text-foreground",children:["Hello, ",ge.split(" ")[0],"!"]}),e.jsxs(Hd,{children:[e.jsx(Gd,{asChild:!0,children:e.jsx("button",{className:"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 rounded-full",children:e.jsxs(Nn,{className:"h-9 w-9 cursor-pointer hover:opacity-80 transition-opacity",children:[e.jsx(Ma,{src:_||void 0}),e.jsx(kn,{className:"bg-primary text-primary-foreground font-medium text-sm",children:Ve(ge)})]})})}),e.jsxs(Nd,{align:"end",className:"w-48",children:[e.jsxs(_a,{onClick:()=>oe("/profile"),className:"cursor-pointer",children:[e.jsx(Ai,{className:"h-4 w-4 mr-2"}),"Profile"]}),e.jsxs(_a,{onClick:()=>oe("/mission-control/integrations"),className:"cursor-pointer",children:[e.jsx(AL,{className:"h-4 w-4 mr-2"}),"Integrations"]}),e.jsx(Yb,{}),e.jsxs(_a,{onClick:n,className:"cursor-pointer text-destructive focus:text-destructive",children:[e.jsx(EM,{className:"h-4 w-4 mr-2"}),"Sign Out"]})]})]})]})]})}),e.jsx(Y6t,{children:e.jsx("main",{className:"p-4 sm:p-6 lg:p-8 overflow-x-hidden",children:t})}),A&&e.jsx(W6t,{brief:A,open:I,onClose:V,onDismiss:q}),e.jsx(Z6t,{}),e.jsx(Q6t,{}),e.jsx(tIt,{})]})]})})})},uIt=()=>{const{user:t}=Us(),[s,r]=k.useState(!1),[n,a]=k.useState(null),[o,l]=k.useState(""),i=async f=>{var y;if(!(t!=null&&t.email)){pe.error("Please sign in to upgrade");return}r(!0),a(f);try{const{data:_,error:b}=await G.functions.invoke("create-checkout",{body:{tier:f,email:t.email,name:((y=t.user_metadata)==null?void 0:y.full_name)||t.email,couponCode:o.trim()||void 0,skipTrial:!0}});if(b)throw b;if(_!=null&&_.url)window.open(_.url,"_blank","noopener,noreferrer"),pe.success("Checkout opened in a new tab");else throw new Error("No checkout URL returned")}catch(_){console.error("Checkout error:",_),pe.error(_.message||"Failed to start checkout. Please try again.")}finally{r(!1),a(null)}},d=["Unlimited access to all marketing templates","Complete Academy training library","AI-powered tools and resources","Community forums and support","Exclusive member events and workshops","Deal pipeline & scorecard tracking","Listing exchange access","Social media content library"],u=["Everything in Individual plan","Up to 25 agent seats","Brokerage admin dashboard","Team performance analytics","Custom branding options","Priority support","Agent onboarding tools","Brokerage-wide announcements"],p=["Everything in Brokerage plan","Unlimited agent seats","Dedicated account manager","Advanced analytics & reporting","White-label options","API access","Custom integrations","Enterprise-level support"];return e.jsx(Ds,{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(xe,{htmlFor:"coupon",className:"text-sm font-medium",children:"Have a discount code?"}),e.jsx(De,{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(Dt,{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(ir,{className:"h-7 w-7 text-primary"})}),e.jsx(zt,{className:"text-xl",children:"Individual Agent"}),e.jsx(dr,{children:"Perfect for solo agents ready to level up"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-4xl font-bold text-primary",children:"$39"}),e.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),e.jsx("ul",{className:"space-y-2",children:d.map((f,y)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(Zn,{className:"h-4 w-4 text-primary mt-0.5 shrink-0"}),e.jsx("span",{children:f})]},y))}),e.jsxs(W,{className:"w-full",size:"lg",onClick:()=>i("individual_agent"),disabled:s,children:[s&&n==="individual_agent"?e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Or,{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(Dt,{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(pa,{className:"h-7 w-7 text-amber-600"})}),e.jsx(zt,{className:"text-xl",children:"Brokerage"}),e.jsx(dr,{children:"For teams and brokerages up to 25 agents"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-4xl font-bold text-amber-600",children:"$299"}),e.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),e.jsx("ul",{className:"space-y-2",children:u.map((f,y)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(Zn,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}),e.jsx("span",{children:f})]},y))}),e.jsxs(W,{variant:"outline",className:"w-full border-amber-500 text-amber-600 hover:bg-amber-50",size:"lg",onClick:()=>i("brokerage_under_25"),disabled:s,children:[s&&n==="brokerage_under_25"?e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(pa,{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(Dt,{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(pa,{className:"h-7 w-7 text-purple-600"})}),e.jsx(zt,{className:"text-xl",children:"Brokerage 25+"}),e.jsx(dr,{children:"For larger brokerages with 25+ agents"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-4xl font-bold text-purple-600",children:"$499"}),e.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),e.jsx("ul",{className:"space-y-2",children:p.map((f,y)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(Zn,{className:"h-4 w-4 text-purple-600 mt-0.5 shrink-0"}),e.jsx("span",{children:f})]},y))}),e.jsxs(W,{variant:"outline",className:"w-full border-purple-500 text-purple-600 hover:bg-purple-50",size:"lg",onClick:()=>i("brokerage_over_25"),disabled:s,children:[s&&n==="brokerage_over_25"?e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(pa,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]})]}),e.jsx(Pe,{className:"bg-muted/50",children:e.jsxs(Oe,{className:"py-6",children:[e.jsx("p",{className:"text-center font-medium mb-4",children:"Questions? We're here to help!"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[e.jsxs("a",{href:"tel:1-866-527-8668",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[e.jsx(In,{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(tr,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})})]})})},hIt=()=>{const{user:t,loading:s,isBrokerageManager:r,brokerageId:n}=Us(),a=wr(),[o,l]=k.useState(""),[i,d]=k.useState(!1),[u,p]=k.useState(!1);k.useEffect(()=>{!s&&!t&&a("/auth")},[t,s,a]),k.useEffect(()=>{!s&&t&&n&&a("/profile?setup=true")},[t,s,n,a]);const f=async()=>{if(!o.trim()){pe.error("Please enter a brokerage name");return}const{data:y}=await G.auth.getSession(),_=y.session;if(!t||!_){pe.error("Please sign in again to create your brokerage."),a("/auth");return}d(!0);try{console.log("[SetupBrokerage] Creating brokerage…",{hasUser:!!t,hasSession:!!_,userId:t==null?void 0:t.id});const{data:b,error:N}=await G.functions.invoke("create-brokerage",{body:{name:o.trim()}});if(console.log("[SetupBrokerage] create-brokerage response",{data:b,error:N}),N)throw N;if(!(b!=null&&b.ok))throw new Error((b==null?void 0:b.error)||"Failed to create brokerage");d(!1),p(!0),pe.success("Brokerage created! Setting up your account..."),setTimeout(()=>{a("/profile?setup=true")},2e3)}catch(b){console.error("Error creating brokerage:",b),pe.error(b.message||"Failed to create brokerage"),d(!1)}};return s?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):u?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-background via-primary/5 to-secondary/10 flex items-center justify-center p-4",children:e.jsxs(Pe,{className:"max-w-lg w-full",children:[e.jsxs(Dt,{className:"text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(us,{className:"w-10 h-10 text-primary animate-spin"})}),e.jsx(zt,{className:"text-2xl",children:"Setting Up Your Brokerage"}),e.jsx(dr,{className:"text-lg",children:"We're assigning you as the brokerage manager and preparing your dashboard..."})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground",children:[e.jsx(si,{className:"w-5 h-5 text-green-500"}),e.jsx("span",{children:"Brokerage created"})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground",children:[e.jsx(us,{className:"w-5 h-5 animate-spin text-primary"}),e.jsx("span",{children:"Assigning you as manager..."})]}),e.jsx("p",{className:"text-center text-sm text-muted-foreground mt-4",children:"You'll be redirected to complete your profile setup in a moment."})]})]})}):e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-background via-primary/5 to-secondary/10 flex items-center justify-center p-4",children:e.jsxs(Pe,{className:"max-w-lg w-full",children:[e.jsxs(Dt,{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(pa,{className:"w-10 h-10 text-primary"})}),e.jsx(zt,{className:"text-2xl",children:"Set Up Your Brokerage"}),e.jsx(dr,{className:"text-lg",children:"Create your brokerage to start managing your team"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"brokerage-name",children:"Brokerage Name"}),e.jsx(De,{id:"brokerage-name",placeholder:"Enter your brokerage name",value:o,onChange:y=>l(y.target.value),onKeyDown:y=>y.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(ir,{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(si,{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(si,{className:"w-4 h-4 text-green-500"}),"Access exclusive brokerage resources"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(si,{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(si,{className:"w-4 h-4 text-green-500"}),"Share resources with your agents"]})]})]}),e.jsxs(W,{onClick:f,className:"w-full",disabled:i||!o.trim(),children:[i?"Creating...":"Create Brokerage",e.jsx(Wa,{className:"w-4 h-4 ml-2"})]})]})]})})},eLe=()=>{const t=wr(),[s,r]=k.useState("verifying"),[n,a]=k.useState("");k.useEffect(()=>{(async()=>{try{const{data:{session:i},error:d}=await G.auth.getSession();if(d)throw d;if(i!=null&&i.user){const{data:u}=await G.from("profiles").select("login_count").eq("id",i.user.id).single();if(((u==null?void 0:u.login_count)||0)>1){console.log("Account already claimed, redirecting to dashboard"),r("already_claimed");return}console.log("User logged in successfully:",i.user.email),r("success");try{await G.functions.invoke("trial-claim-hook",{body:{userId:i.user.id}})}catch(p){console.log("Trial claim hook (non-critical):",p)}setTimeout(()=>{t("/profile?setup=true")},1500)}else setTimeout(()=>{r("already_claimed")},2e3)}catch(i){console.error("Claim error:",i),r("already_claimed")}})()},[t]);const o=()=>{window.location.href="https://dashboard.relevelup.com/auth"};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:e.jsxs(Pe,{className:"w-full max-w-md",children:[e.jsxs(Dt,{className:"space-y-1 text-center",children:[e.jsxs("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-primary/10",children:[s==="verifying"&&e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"}),s==="success"&&e.jsx("svg",{className:"h-8 w-8 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),s==="already_claimed"&&e.jsx("svg",{className:"h-8 w-8 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),s==="error"&&e.jsx("svg",{className:"h-8 w-8 text-destructive",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]}),e.jsxs(zt,{className:"text-2xl",children:[s==="verifying"&&"Claiming Your Account...",s==="success"&&"Account Claimed!",s==="already_claimed"&&"Account Already Claimed",s==="error"&&"Claim Failed"]}),e.jsxs(dr,{children:[s==="verifying"&&"Please wait while we verify your account...",s==="success"&&"Redirecting you to complete your profile...",s==="already_claimed"&&"This account has already been set up. Please log in to access your dashboard.",s==="error"&&n]})]}),(s==="already_claimed"||s==="error")&&e.jsx(Oe,{children:e.jsx(W,{onClick:o,className:"w-full",children:"Go to Login"})})]})})},mIt=()=>{const t=wr(),[s]=Nc(),[r,n]=k.useState(s.get("code")||""),[a,o]=k.useState(""),[l,i]=k.useState(""),[d,u]=k.useState(""),[p,f]=k.useState(!1),[y,_]=k.useState(!1),[b,N]=k.useState(!1),[w,S]=k.useState(!1),[C,A]=k.useState(null),[I,L]=k.useState(null),[O,V]=k.useState(null),[q,B]=k.useState(null);k.useEffect(()=>{const J=s.get("code");J&&(n(J),U(J))},[s]);const U=async J=>{N(!0);const{data:X,error:ce}=await G.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||!X){pe.error("Invalid invite code"),N(!1);return}if(!X.is_active){pe.error("This invite code is no longer active"),N(!1);return}if(X.max_uses&&X.uses_count>=X.max_uses){pe.error("This invite code has reached its maximum uses"),N(!1);return}if(X.expires_at&&new Date(X.expires_at){J.preventDefault(),U(r)},Y=async J=>{var X;if(J.preventDefault(),!d.trim()){pe.error("Please enter your name");return}if(l.length<6){pe.error("Password must be at least 6 characters");return}_(!0);try{const ce=`${window.location.origin}/`,{data:ie,error:ae}=await G.auth.signUp({email:a.trim(),password:l,options:{emailRedirectTo:ce,data:{name:d.trim()}}});if(ae){ae.message.includes("already registered")?pe.error("This email is already registered. Please sign in instead."):pe.error(ae.message);return}ie.user&&(await G.rpc("add_default_signup_tag",{user_id:ie.user.id}),I?await G.functions.invoke("assign-brokerage",{body:{userId:ie.user.id,brokerageId:I}}):q?await G.functions.invoke("assign-brokerage",{body:{userId:ie.user.id,trialDays:q}}):await G.functions.invoke("assign-brokerage",{body:{userId:ie.user.id,grandfathered:!0}}),C&&await G.from("invite_codes").update({uses_count:((X=(await G.from("invite_codes").select("uses_count").eq("id",C).single()).data)==null?void 0:X.uses_count)+1}).eq("id",C),pe.success("Account created! You can now access the dashboard."),t("/dashboard"))}catch(ce){console.error("Signup error:",ce),pe.error("An unexpected error occurred")}finally{_(!1)}};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Pe,{className:"w-full max-w-md",children:[e.jsxs(Dt,{className:"text-center",children:[e.jsx(zt,{className:"text-2xl font-bold text-primary",children:O?`Join ${O}`:"Join LevelUp"}),e.jsx(dr,{children:w?O?`Create your account to join ${O}`:"Create your account to get started":"Enter your invite code to continue"})]}),e.jsx(Oe,{children:w?e.jsxs("form",{onSubmit:Y,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"name",children:"Full Name"}),e.jsx(De,{id:"name",type:"text",placeholder:"John Doe",value:d,onChange:J=>u(J.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"email",children:"Email"}),e.jsx(De,{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(xe,{htmlFor:"password",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(De,{id:"password",type:p?"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(!p),children:p?e.jsx(pp,{className:"h-4 w-4"}):e.jsx(jn,{className:"h-4 w-4"})})]})]}),e.jsx(W,{type:"submit",className:"w-full",disabled:y,children:y?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating Account..."]}):"Create Account"})]}):e.jsxs("form",{onSubmit:te,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"inviteCode",children:"Invite Code"}),e.jsx(De,{id:"inviteCode",type:"text",placeholder:"Enter your invite code",value:r,onChange:J=>n(J.target.value),required:!0,autoFocus:!0})]}),e.jsx(W,{type:"submit",className:"w-full",disabled:b,children:b?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"mr-2 h-4 w-4 animate-spin"}),"Verifying..."]}):"Verify Code"})]})})]})})},pIt="/assets/testimonial-avatar-1-BsCQFauB.jpg",fIt="/assets/testimonial-avatar-2-B6VPVc2t.jpg",xIt="/assets/testimonial-avatar-3-GuEFwYUE.jpg",gIt="/assets/testimonial-avatar-4-98iKMtkB.jpg",yIt="/assets/testimonial-avatar-5-ZsZfyxMX.jpg",vIt=[pIt,fIt,xIt,gIt,yIt],_It=kC({name:Xl().trim().min(2,"Name must be at least 2 characters").max(100),email:Xl().trim().email("Please enter a valid email address").max(255),phone:Xl().trim().min(10,"Please enter a valid phone number").max(20).optional().or(nle("")),brokerage:Xl().trim().max(200).optional().or(nle(""))}),bIt=[{icon:rp,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:zl,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:cn,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:Fl,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:vn,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:hi,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],wIt=[{icon:ir,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:Or,title:"Smart TouchPlans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:In,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:Fu,title:"Birthday Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:Ia,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:so,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:Xa,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:Oh,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],jIt=[{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."}],NIt=()=>{const t=wr(),[s,r]=k.useState(!1),[n,a]=k.useState({name:"",email:"",phone:"",brokerage:""}),[o,l]=k.useState({}),i=async d=>{var p,f;d.preventDefault(),l({});const u=_It.safeParse(n);if(!u.success){const y={};u.error.errors.forEach(_=>{_.path[0]&&(y[_.path[0]]=_.message)}),l(y);return}r(!0);try{const y=typeof window<"u"&&localStorage.getItem("levelup_referral_code")||void 0,{data:_,error:b}=await G.functions.invoke("create-trial-signup",{body:{name:n.name.trim(),email:n.email.trim().toLowerCase(),phone:((p=n.phone)==null?void 0:p.trim())||void 0,brokerage:((f=n.brokerage)==null?void 0:f.trim())||void 0,referral_code:y}});if(b){console.error("Trial signup error:",b),pe.error(b.message||"Something went wrong. Please try again.");return}if(_!=null&&_.error){pe.error(_.error);return}pe.success("🎉 Welcome aboard! Check your email to claim your account."),t("/trial/success")}catch(y){console.error("Trial signup error:",y),pe.error("Something went wrong. Please try again.")}finally{r(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs(kl,{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:xle,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[e.jsx(W,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var d;return(d=document.getElementById("features"))==null?void 0:d.scrollIntoView({behavior:"smooth"})},children:"Features"}),e.jsx(W,{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(Or,{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($n,{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($n,{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:vIt.map((d,u)=>e.jsx("img",{src:d,alt:`Agent ${u+1}`,className:"w-10 h-10 rounded-full border-2 border-white/20 object-cover"},u))}),e.jsxs("div",{children:[e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(d=>e.jsx(Gn,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"},d))}),e.jsx("p",{className:"text-sm text-white/60",children:"Trusted by 3,000+ agents"})]})]})]}),e.jsx("div",{className:"lg:pl-8",children:e.jsx(Pe,{className:"bg-white shadow-2xl border-0",children:e.jsxs(Oe,{className:"p-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-[#4a6b6d] mb-4",children:e.jsx(e0,{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(xe,{htmlFor:"name",children:"Full Name *"}),e.jsx(De,{id:"name",type:"text",placeholder:"John Smith",value:n.name,onChange:d=>a({...n,name:d.target.value}),required:!0}),o.name&&e.jsx("p",{className:"text-sm text-destructive",children:o.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"email",children:"Email Address *"}),e.jsx(De,{id:"email",type:"email",placeholder:"john@example.com",value:n.email,onChange:d=>a({...n,email:d.target.value}),required:!0}),o.email&&e.jsx("p",{className:"text-sm text-destructive",children:o.email})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"phone",children:"Phone Number"}),e.jsx(De,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:n.phone,onChange:d=>a({...n,phone:d.target.value})}),o.phone&&e.jsx("p",{className:"text-sm text-destructive",children:o.phone})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"brokerage",children:"Brokerage Name"}),e.jsx(De,{id:"brokerage",type:"text",placeholder:"Your brokerage or team name",value:n.brokerage,onChange:d=>a({...n,brokerage:d.target.value})}),o.brokerage&&e.jsx("p",{className:"text-sm text-destructive",children:o.brokerage})]}),e.jsx(W,{type:"submit",className:"w-full h-12 text-lg font-semibold bg-[#4a6b6d] hover:bg-[#3d5a5c]",disabled:s,children:s?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"mr-2 h-5 w-5 animate-spin"}),"Creating Your Account..."]}):e.jsxs(e.Fragment,{children:["Start My Free Trial",e.jsx(Wa,{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:bIt.map((d,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(Dt,{children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-[#4a6b6d]/10 flex items-center justify-center mb-4",children:e.jsx(d.icon,{className:"w-7 h-7 text-[#4a6b6d]"})}),e.jsx(zt,{className:"text-xl font-sans",children:d.title})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:d.description})})]},u))})]})}),e.jsxs("section",{className:"py-20 bg-gradient-to-br from-[#4a6b6d] to-[#3d5a5c] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsxs("div",{className:"container mx-auto px-4 relative",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white/10 text-white text-sm font-medium mb-6",children:[e.jsx(Or,{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:wIt.map((d,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(Dt,{className:"pb-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-white/20 flex items-center justify-center mb-3",children:e.jsx(d.icon,{className:"w-6 h-6 text-white"})}),e.jsx(zt,{className:"text-lg font-semibold text-white",children:d.title})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-white/70 text-sm leading-relaxed",children:d.description})})]},u))})]})]}),e.jsx("section",{className:"py-20 bg-background",children:e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4 font-sans",children:"Loved by Top Producers"}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"See what agents are saying about LevelUp"})]}),e.jsx("div",{className:"grid md:grid-cols-3 gap-8 max-w-5xl mx-auto",children:jIt.map((d,u)=>e.jsx(Pe,{className:"border hover:shadow-lg transition-shadow",children:e.jsxs(Oe,{className:"p-6",children:[e.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map(p=>e.jsx(Gn,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"},p))}),e.jsxs("p",{className:"text-muted-foreground mb-4 italic",children:['"',d.quote,'"']}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:d.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d.role})]})]})},u))})]})}),e.jsx("section",{className:"py-16 bg-muted/30",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"flex flex-wrap justify-center gap-8 md:gap-16",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(zu,{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(Oh,{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(ir,{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(Oe,{className:"p-12 text-center relative",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-white mb-4 font-sans",children:"Ready to Level Up Your Business?"}),e.jsx("p",{className:"text-xl text-white/80 mb-8 max-w-2xl mx-auto",children:"Join thousands of successful agents. Start your free 7-day trial today."}),e.jsxs(W,{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(Wa,{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:Hje,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."})]})})})]})]})},kIt=()=>{const t=wr();return e.jsxs(e.Fragment,{children:[e.jsx(kl,{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:xle,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsx(W,{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(Oe,{className:"p-8 md:p-12 text-center",children:[e.jsxs("div",{className:"relative inline-block mb-8",children:[e.jsx("div",{className:"w-24 h-24 rounded-full bg-gradient-to-br from-[#4a6b6d] to-[#3d5a5c] flex items-center justify-center",children:e.jsx($n,{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(qd,{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(tr,{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(W,{onClick:()=>t("/auth"),className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:["Go to Sign In",e.jsx(Wa,{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:Hje,alt:"LevelUp",className:"h-8"}),e.jsxs("p",{className:"text-sm text-white/40",children:["© ",new Date().getFullYear()," LevelUp Consulting Group. All rights reserved."]})]})})})]})]})},SIt=kC({viewerName:Xl().min(1,"Name is required").max(100,"Name must be less than 100 characters"),viewerEmail:Xl().email("Please enter a valid email").max(255,"Email must be less than 255 characters"),viewerPhone:Xl().max(20,"Phone must be less than 20 characters").optional(),message:Xl().min(1,"Message is required").max(1e3,"Message must be less than 1000 characters")});function CIt({shareToken:t,agentName:s,hasContact:r}){const[n,a]=k.useState(!1),[o,l]=k.useState(!1),[i,d]=k.useState(null),u=Zue({resolver:Yue(SIt),defaultValues:{viewerName:"",viewerEmail:"",viewerPhone:"",message:""}}),p=async f=>{a(!0),d(null);try{const{data:y,error:_}=await G.functions.invoke("video-reply-notify",{body:{shareToken:t,viewerName:f.viewerName,viewerEmail:f.viewerEmail,viewerPhone:f.viewerPhone||void 0,message:f.message}});if(_)throw new Error(_.message);if(!(y!=null&&y.success))throw new Error((y==null?void 0:y.error)||"Failed to send reply");l(!0)}catch(y){console.error("Failed to submit reply:",y),d(y.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(Oe,{className:"py-8 text-center",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/20 mb-4",children:e.jsx($n,{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(Dt,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Fl,{className:"h-5 w-5 text-primary"}),e.jsx(zt,{className:"text-lg",children:"Reply to this video"})]}),e.jsx(dr,{children:r?`Have a question or want to connect? Send ${s||"them"} a message.`:`Interested? Share your info and ${s||"your agent"} will be in touch.`})]}),e.jsx(Oe,{children:e.jsx(Xue,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(p),className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(Ec,{control:u.control,name:"viewerName",render:({field:f})=>e.jsxs(mc,{children:[e.jsx(pc,{children:"Your Name *"}),e.jsx(fc,{children:e.jsx(De,{placeholder:"John Smith",...f})}),e.jsx(vm,{})]})}),e.jsx(Ec,{control:u.control,name:"viewerEmail",render:({field:f})=>e.jsxs(mc,{children:[e.jsx(pc,{children:"Email *"}),e.jsx(fc,{children:e.jsx(De,{type:"email",placeholder:"john@example.com",...f})}),e.jsx(vm,{})]})})]}),!r&&e.jsx(Ec,{control:u.control,name:"viewerPhone",render:({field:f})=>e.jsxs(mc,{children:[e.jsx(pc,{children:"Phone (optional)"}),e.jsx(fc,{children:e.jsx(De,{type:"tel",placeholder:"(555) 123-4567",...f})}),e.jsx(vm,{})]})}),e.jsx(Ec,{control:u.control,name:"message",render:({field:f})=>e.jsxs(mc,{children:[e.jsx(pc,{children:"Message *"}),e.jsx(fc,{children:e.jsx(_r,{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(vm,{})]})}),i&&e.jsx("p",{className:"text-sm text-destructive",children:i}),e.jsx(W,{type:"submit",className:"w-full gap-2",disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(_n,{className:"h-4 w-4"}),"Send Message"]})})]})})})]})}const MIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsxs("div",{className:"absolute inset-0 opacity-[0.08]",children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[16%] left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[32%] left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[48%] left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[64%] left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[80%] left-0 right-0 h-[8%] bg-red-600"})]}),e.jsx("div",{className:"absolute top-0 left-0 w-[35%] h-[45%] bg-blue-900/10 rounded-br-3xl"}),e.jsx(Gn,{className:"absolute top-[5%] left-[8%] w-6 h-6 text-blue-600/30 fill-blue-600/20"}),e.jsx(Gn,{className:"absolute top-[15%] left-[20%] w-4 h-4 text-blue-600/25 fill-blue-600/15"}),e.jsx(Gn,{className:"absolute top-[8%] left-[28%] w-5 h-5 text-blue-600/30 fill-blue-600/20"}),e.jsx(Gn,{className:"absolute top-[25%] left-[12%] w-4 h-4 text-blue-600/20 fill-blue-600/10"}),e.jsx(Gn,{className:"absolute top-[20%] right-[15%] w-5 h-5 text-red-500/25 fill-red-500/15 animate-pulse"}),e.jsx(Yv,{className:"absolute bottom-[20%] right-[10%] w-12 h-12 text-blue-600/15 rotate-12"})]}),TIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-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(Or,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-8 h-8 text-red-400/40"})]}),e.jsxs("div",{className:"absolute top-[5%] right-[20%] w-24 h-24",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-blue-400/20 animate-ping",style:{animationDuration:"4s",animationDelay:"1s"}}),e.jsx(Gn,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-6 h-6 text-blue-400/40 fill-blue-400/20"})]}),e.jsxs("div",{className:"absolute top-[20%] left-[50%] w-20 h-20",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border border-white/10 animate-ping",style:{animationDuration:"3.5s",animationDelay:"0.5s"}}),e.jsx(Or,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-5 h-5 text-amber-400/40"})]}),e.jsx(Gn,{className:"absolute bottom-[25%] left-[10%] w-6 h-6 text-blue-500/25 fill-blue-500/15 animate-pulse"}),e.jsx(Gn,{className:"absolute bottom-[15%] right-[15%] w-5 h-5 text-red-500/25 fill-red-500/15 animate-pulse",style:{animationDelay:"0.5s"}}),e.jsx(Yv,{className:"absolute top-[8%] left-[5%] w-10 h-10 text-red-500/20 rotate-12"})]}),AIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-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(kg,{className:"w-20 h-20 text-pink-400 rotate-12"})}),e.jsx("div",{className:"absolute top-[2%] right-[8%] opacity-15",children:e.jsx(kg,{className:"w-16 h-16 text-rose-400 -rotate-12"})}),e.jsx("div",{className:"absolute bottom-[15%] left-[8%] opacity-15",children:e.jsx(kg,{className:"w-14 h-14 text-purple-400 rotate-45"})}),e.jsx("div",{className:"absolute bottom-[20%] right-[5%] opacity-20",children:e.jsx(kg,{className:"w-16 h-16 text-pink-300 -rotate-6"})}),e.jsx(Xa,{className:"absolute top-[15%] left-[30%] w-5 h-5 text-rose-300/40 fill-rose-300/20 animate-pulse"}),e.jsx(Xa,{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(Xa,{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"})]}),EIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-900/5 via-slate-800/3 to-indigo-900/5"}),e.jsx("div",{className:"absolute top-[5%] right-[10%] opacity-15",children:e.jsxs("div",{className:"w-12 h-24 relative",children:[e.jsx("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-10 h-3 bg-blue-600 rounded-full"}),e.jsx("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 w-0 h-0 border-l-[20px] border-r-[20px] border-t-[60px] border-l-transparent border-r-transparent border-t-blue-500"})]})}),e.jsx(nc,{className:"absolute top-[8%] left-[12%] w-12 h-12 text-blue-600/15"}),e.jsx(Gn,{className:"absolute top-[15%] left-[22%] w-5 h-5 text-amber-500/25 fill-amber-500/15"}),e.jsx(nc,{className:"absolute bottom-[20%] right-[8%] w-14 h-14 text-indigo-500/12"}),e.jsx("div",{className:"absolute top-[3%] left-[40%] opacity-12",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"w-10 h-5 bg-slate-700 rounded-full rounded-tr-none rotate-6"}),e.jsx("div",{className:"w-10 h-5 bg-slate-700 rounded-full rounded-tl-none -rotate-6"})]})}),e.jsx(Gn,{className:"absolute bottom-[25%] left-[15%] w-6 h-6 text-blue-500/20 fill-blue-500/10 animate-pulse"}),e.jsx(Gn,{className:"absolute top-[20%] right-[22%] w-5 h-5 text-indigo-400/20 fill-indigo-400/10 animate-pulse",style:{animationDelay:"0.5s"}})]}),PIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-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(kg,{className:"absolute top-[20%] left-[32%] w-7 h-7 text-purple-400/30"}),e.jsx(kg,{className:"absolute top-[12%] right-[28%] w-6 h-6 text-pink-400/30"}),e.jsx(NM,{className:"absolute top-[18%] left-[52%] w-5 h-5 text-sky-400/35"})]}),IIt=()=>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(eS,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-orange-400/25"}),e.jsx(eS,{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(Or,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-purple-400/35 animate-pulse"}),e.jsx(Or,{className:"absolute bottom-[28%] right-[25%] w-5 h-5 text-orange-400/30 animate-pulse",style:{animationDelay:"0.5s"}})]}),LIt=()=>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(Ab,{className:"absolute bottom-[8%] left-[5%] w-20 h-20 text-green-600/18"}),e.jsx(Ab,{className:"absolute bottom-[12%] right-[8%] w-16 h-16 text-emerald-600/15"}),e.jsx(Ab,{className:"absolute bottom-[10%] left-[28%] w-12 h-12 text-green-500/12"}),e.jsx(qy,{className:"absolute top-[5%] left-[15%] w-10 h-10 text-sky-300/30 animate-pulse"}),e.jsx(qy,{className:"absolute top-[10%] right-[20%] w-8 h-8 text-blue-300/25 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(qy,{className:"absolute top-[18%] left-[45%] w-6 h-6 text-sky-200/25 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx(qy,{className:"absolute top-[8%] left-[70%] w-8 h-8 text-blue-200/20 animate-pulse",style:{animationDelay:"0.9s"}}),e.jsx("div",{className:"absolute top-[12%] left-[10%] w-5 h-5 rounded-full bg-red-500/25"}),e.jsx("div",{className:"absolute top-[15%] right-[15%] w-4 h-4 rounded-full bg-amber-400/25"}),e.jsx("div",{className:"absolute top-[20%] left-[55%] w-4 h-4 rounded-full bg-green-500/20"}),e.jsx(Gn,{className:"absolute top-[3%] left-[50%] -translate-x-1/2 w-10 h-10 text-amber-400/35 fill-amber-400/25"})]}),DIt=()=>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(Xa,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-red-400/22 fill-red-400/12"}),e.jsx(Xa,{className:"absolute top-[20%] right-[25%] w-5 h-5 text-orange-400/22 fill-orange-400/12"})]}),RIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-yellow-900/8 via-amber-900/4 to-purple-900/8"}),e.jsx(Gn,{className:"absolute top-[5%] left-[15%] w-12 h-12 text-yellow-400/35 fill-yellow-400/25 animate-pulse"}),e.jsx(Gn,{className:"absolute top-[8%] right-[12%] w-10 h-10 text-amber-400/30 fill-amber-400/20 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(Gn,{className:"absolute top-[15%] left-[40%] w-7 h-7 text-yellow-300/25 fill-yellow-300/15 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx(Gn,{className:"absolute top-[12%] right-[35%] w-8 h-8 text-amber-300/28 fill-amber-300/18 animate-pulse",style:{animationDelay:"0.9s"}}),e.jsx("div",{className:"absolute top-[20%] left-[25%] w-4 h-4 rounded-full bg-pink-400/30"}),e.jsx("div",{className:"absolute top-[18%] right-[30%] w-3 h-3 rounded-full bg-sky-400/30"}),e.jsx("div",{className:"absolute top-[25%] left-[60%] w-2.5 h-2.5 rounded-full bg-emerald-400/30"}),e.jsx("div",{className:"absolute top-[22%] right-[42%] w-3 h-3 rounded-full bg-purple-400/30"}),e.jsx(Or,{className:"absolute top-[3%] left-[50%] w-10 h-10 text-yellow-400/40"}),e.jsx(qd,{className:"absolute bottom-[18%] left-[10%] w-12 h-12 text-purple-400/18 rotate-12"}),e.jsx(qd,{className:"absolute bottom-[20%] right-[12%] w-10 h-10 text-amber-400/15 -rotate-12"})]}),OIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-900/10 via-indigo-900/6 to-sky-900/10"}),e.jsxs("div",{className:"absolute bottom-[12%] left-1/2 -translate-x-1/2 flex items-end gap-3",children:[e.jsx("div",{className:"w-2 h-14 bg-blue-400/18 rounded-full"}),e.jsx("div",{className:"w-2 h-12 bg-blue-300/15 rounded-full"}),e.jsx("div",{className:"w-2 h-16 bg-blue-400/20 rounded-full"}),e.jsx("div",{className:"w-2.5 h-20 bg-blue-500/22 rounded-full"})," ",e.jsx("div",{className:"w-2 h-16 bg-blue-400/20 rounded-full"}),e.jsx("div",{className:"w-2 h-12 bg-blue-300/15 rounded-full"}),e.jsx("div",{className:"w-2 h-14 bg-blue-400/18 rounded-full"})]}),e.jsx("div",{className:"absolute bottom-[38%] left-[calc(50%-42px)] w-3 h-4 bg-yellow-400/30 rounded-full blur-sm"}),e.jsx("div",{className:"absolute bottom-[35%] left-[calc(50%-28px)] w-2.5 h-3 bg-yellow-300/25 rounded-full blur-sm"}),e.jsx("div",{className:"absolute bottom-[40%] left-[calc(50%-14px)] w-3 h-4 bg-amber-400/30 rounded-full blur-sm"}),e.jsx("div",{className:"absolute bottom-[45%] left-1/2 -translate-x-1/2 w-4 h-5 bg-yellow-400/35 rounded-full blur-sm"}),e.jsx(Gn,{className:"absolute top-[8%] left-[50%] -translate-x-1/2 w-14 h-14 text-yellow-400/28 fill-yellow-400/18"}),e.jsx(Or,{className:"absolute top-[5%] left-[20%] w-7 h-7 text-blue-400/35"}),e.jsx(Or,{className:"absolute top-[10%] right-[18%] w-6 h-6 text-sky-400/30"})]}),FIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-green-900/12 via-emerald-900/6 to-teal-900/10"}),e.jsx(Bv,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-green-500/25"}),e.jsx(Bv,{className:"absolute top-[8%] right-[12%] w-12 h-12 text-emerald-500/20"}),e.jsx(Bv,{className:"absolute bottom-[18%] left-[12%] w-14 h-14 text-green-400/22"}),e.jsx(Bv,{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"})]})]})]}),zIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-900/10 via-indigo-900/6 to-sky-900/10"}),e.jsx("div",{className:"absolute top-[8%] left-[12%] w-16 h-16 rounded-full border-4 border-blue-500/18"}),e.jsx("div",{className:"absolute top-[10%] right-[10%] w-14 h-14 rounded-full border-4 border-indigo-500/15"}),e.jsx("div",{className:"absolute bottom-[18%] left-[18%] w-12 h-12 rounded-full border-3 border-sky-500/12"}),e.jsx(Gn,{className:"absolute top-[5%] left-[42%] w-10 h-10 text-amber-400/30 fill-amber-400/20"}),e.jsx(Gn,{className:"absolute top-[15%] right-[25%] w-7 h-7 text-yellow-400/25 fill-yellow-400/15"}),e.jsx(nc,{className:"absolute bottom-[20%] right-[12%] w-12 h-12 text-blue-500/18"}),e.jsx(nc,{className:"absolute top-[18%] left-[28%] w-8 h-8 text-indigo-400/15"}),e.jsx(Yv,{className:"absolute top-[8%] left-[60%] w-10 h-10 text-indigo-400/18"})]}),BIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-amber-900/6 via-rose-900/6 to-purple-900/6"}),e.jsx(Fu,{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(qd,{className:"absolute top-[8%] left-[45%] w-10 h-10 text-purple-400/22 rotate-12"}),e.jsx(hi,{className:"absolute bottom-[18%] right-[15%] w-12 h-12 text-rose-400/18"})]}),$It=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-rose-900/12 via-pink-900/8 to-red-900/12"}),e.jsx(Xa,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-rose-400/28 fill-rose-400/18"}),e.jsx(Xa,{className:"absolute top-[8%] right-[12%] w-14 h-14 text-pink-400/25 fill-pink-400/15"}),e.jsx(Xa,{className:"absolute bottom-[15%] left-[12%] w-12 h-12 text-red-400/22 fill-red-400/12"}),e.jsx(Xa,{className:"absolute bottom-[18%] right-[10%] w-13 h-13 text-rose-300/25 fill-rose-300/15"}),e.jsx(Xa,{className:"absolute top-[15%] left-[30%] w-6 h-6 text-pink-300/35 fill-pink-300/20 animate-pulse"}),e.jsx(Xa,{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(Xa,{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(Xa,{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"})]}),qIt=()=>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(s1,{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(s1,{className:"absolute top-[15%] left-[18%] w-10 h-10 text-yellow-400/30"}),e.jsx(Or,{className:"absolute top-[10%] left-[42%] w-7 h-7 text-amber-400/35"}),e.jsx(s1,{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"})]}),UIt=()=>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(Mn,{className:"absolute top-[8%] left-[10%] w-14 h-14 text-teal-500/22"}),e.jsx(Mn,{className:"absolute bottom-[15%] right-[8%] w-16 h-16 text-emerald-500/18"}),e.jsx(fp,{className:"absolute top-[12%] right-[18%] w-10 h-10 text-amber-400/25"}),e.jsx(fp,{className:"absolute bottom-[22%] left-[22%] w-8 h-8 text-yellow-400/22"}),e.jsx(Xa,{className:"absolute top-[18%] left-[40%] w-6 h-6 text-rose-400/22 fill-rose-400/12"}),e.jsx(Xa,{className:"absolute top-[22%] right-[35%] w-5 h-5 text-teal-400/20 fill-teal-400/10"}),e.jsx(Or,{className:"absolute top-[5%] left-[55%] w-8 h-8 text-teal-400/30"}),e.jsx(qd,{className:"absolute bottom-[20%] left-[48%] w-10 h-10 text-cyan-400/18 rotate-12"})]}),VIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-emerald-900/10 via-teal-900/6 to-cyan-900/10"}),e.jsx(qd,{className:"absolute top-[5%] left-[12%] w-14 h-14 text-emerald-400/25 rotate-12"}),e.jsx(qd,{className:"absolute top-[8%] right-[10%] w-12 h-12 text-teal-400/22 -rotate-12"}),e.jsx(fp,{className:"absolute bottom-[18%] left-[18%] w-12 h-12 text-amber-400/25"}),e.jsx(Mn,{className:"absolute bottom-[15%] right-[12%] w-14 h-14 text-teal-500/18"}),e.jsx(Or,{className:"absolute top-[15%] left-[42%] w-10 h-10 text-emerald-400/35"}),e.jsx(Or,{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"})]}),HIt=()=>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(fp,{className:"absolute bottom-[12%] left-[50%] -translate-x-1/2 w-24 h-24 text-amber-400/25 rotate-45"}),e.jsx(fp,{className:"absolute top-[10%] left-[12%] w-10 h-10 text-yellow-400/30"}),e.jsx(fp,{className:"absolute top-[12%] right-[15%] w-9 h-9 text-amber-300/25"}),e.jsx(Mn,{className:"absolute top-[8%] left-[42%] w-12 h-12 text-teal-500/18"}),e.jsx(qd,{className:"absolute bottom-[22%] right-[18%] w-12 h-12 text-orange-400/18 rotate-12"}),e.jsx(Or,{className:"absolute top-[5%] right-[35%] w-8 h-8 text-yellow-400/35"}),e.jsx(Gn,{className:"absolute top-[18%] left-[28%] w-6 h-6 text-amber-400/25 fill-amber-400/15"})]}),GIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-teal-900/10 via-emerald-900/6 to-green-900/10"}),e.jsx(Mn,{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(fp,{className:"absolute top-[10%] right-[12%] w-10 h-10 text-amber-400/28"}),e.jsx(Xa,{className:"absolute top-[8%] left-[18%] w-8 h-8 text-rose-400/25 fill-rose-400/15"}),e.jsx(Or,{className:"absolute top-[12%] left-[45%] w-8 h-8 text-teal-400/30"}),e.jsx(Kv,{className:"absolute top-[15%] right-[28%] w-10 h-10 text-emerald-400/20"})]}),tLe=()=>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"})]}),WIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Xa,{className:"absolute top-6 left-[12%] w-4 h-4 text-rose-300/50 fill-rose-300/30 animate-pulse"}),e.jsx(Xa,{className:"absolute top-10 right-[18%] w-3 h-3 text-pink-300/50 fill-pink-300/30 animate-pulse delay-150"}),e.jsx(Xa,{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(Xa,{className:"absolute top-14 right-[35%] w-3.5 h-3.5 text-pink-300/40 fill-pink-300/20 animate-pulse delay-200"})]}),KIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Kv,{className:"absolute top-5 left-[10%] w-4 h-4 text-blue-400/50 animate-pulse"}),e.jsx(Or,{className:"absolute top-10 right-[15%] w-3 h-3 text-amber-400/50 animate-pulse delay-100"}),e.jsx(Mn,{className:"absolute top-8 left-[38%] w-3 h-3 text-teal-300/40 animate-pulse delay-200"})]}),ZIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(X4,{className:"absolute top-5 left-[12%] w-4 h-4 text-amber-500/50 animate-pulse"}),e.jsx(PM,{className:"absolute top-10 right-[15%] w-3 h-3 text-rose-400/50 animate-pulse delay-100"}),e.jsx(X4,{className:"absolute top-8 left-[40%] w-3 h-3 text-amber-400/40 animate-pulse delay-200"})]}),aI=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Or,{className:"absolute top-5 left-[10%] w-4 h-4 text-emerald-400/50 animate-pulse"}),e.jsx(qd,{className:"absolute top-10 right-[12%] w-5 h-5 text-amber-400/50 animate-pulse delay-150"}),e.jsx(Or,{className:"absolute top-8 left-[45%] w-3 h-3 text-sky-400/40 animate-pulse delay-300"})]}),sLe=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Mn,{className:"absolute top-6 left-[12%] w-4 h-4 text-teal-400/40 animate-pulse"}),e.jsx(Or,{className:"absolute top-10 right-[15%] w-3 h-3 text-emerald-400/50 animate-pulse delay-100"}),e.jsx(Mn,{className:"absolute top-4 right-[40%] w-3 h-3 text-cyan-400/30 animate-pulse delay-200"})]}),l_e=[{id:"default",name:"Classic",description:"Clean, professional look for any occasion",icon:e.jsx(Or,{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(Xa,{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(WIt,{})},{id:"thinking_of_you",name:"Thinking of You",description:"Let them know they're on your mind",icon:e.jsx(lL,{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(aI,{})},{id:"check_in",name:"Check-in",description:"Touch base with your contacts",icon:e.jsx(X4,{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(ZIt,{})},{id:"market_update",name:"Market Update",description:"Share real estate market insights",icon:e.jsx(so,{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(ir,{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(aI,{})},{id:"congratulations",name:"Congratulations",description:"Celebrate their achievements",icon:e.jsx(nc,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Congratulations, ${t}!`:"Congratulations!",subText:"So proud of your accomplishment",gradientClasses:"from-amber-50/70 via-yellow-50/50 to-orange-50/40 dark:from-amber-950/30 dark:via-yellow-950/20 dark:to-orange-950/20",accentColor:"amber",decorativeElement:e.jsx(tLe,{})},{id:"welcome_neighborhood",name:"Welcome to the Neighborhood",description:"Greet new neighbors",icon:e.jsx(Ia,{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(sLe,{})},{id:"just_because",name:"Just Because",description:"No reason needed to connect",icon:e.jsx(PM,{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(aI,{})},{id:"birthday",name:"Birthday",description:"Celebrate their special day",icon:e.jsx(Fu,{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(BIt,{})},{id:"valentines_day",name:"Valentine's Day",description:"Show appreciation on this special day",icon:e.jsx(Xa,{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($It,{})},{id:"groundhog_day",name:"Groundhog Day",description:"A fun seasonal greeting",icon:e.jsx(s1,{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(qIt,{})},{id:"new_years",name:"New Year's Day",description:"Ring in the new year",icon:e.jsx(Gn,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy New Year, ${t}!`:"Happy New Year!",subText:"Wishing you a year full of success and happiness",gradientClasses:"from-yellow-50/70 via-amber-50/50 to-orange-50/40 dark:from-yellow-950/30 dark:via-amber-950/20 dark:to-orange-950/20",accentColor:"yellow",decorativeElement:e.jsx(RIt,{})},{id:"easter",name:"Easter",description:"Celebrate the spring season",icon:e.jsx(NM,{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(PIt,{})},{id:"mothers_day",name:"Mother's Day",description:"Celebrate the amazing moms",icon:e.jsx(kg,{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(AIt,{})},{id:"fathers_day",name:"Father's Day",description:"Celebrate the amazing dads",icon:e.jsx(nc,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Father's Day, ${t}!`:"Happy Father's Day!",subText:"Celebrating the wonderful fathers in our lives",gradientClasses:"from-blue-50/70 via-sky-50/50 to-indigo-50/40 dark:from-blue-950/30 dark:via-sky-950/20 dark:to-indigo-950/20",accentColor:"blue",decorativeElement:e.jsx(EIt,{})},{id:"memorial_day",name:"Memorial Day",description:"Honor those who served",icon:e.jsx(Yv,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Memorial Day, ${t}`:"Happy Memorial Day",subText:"Honoring those who served our country",gradientClasses:"from-red-50/60 via-white to-blue-50/60 dark:from-red-950/30 dark:via-slate-950/20 dark:to-blue-950/30",accentColor:"blue",decorativeElement:e.jsx(MIt,{})},{id:"independence_day",name:"4th of July",description:"Celebrate Independence Day",icon:e.jsx(rd,{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(TIt,{})},{id:"labor_day",name:"Labor Day",description:"Celebrate the workers",icon:e.jsx(nc,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Labor Day, ${t}!`:"Happy Labor Day!",subText:"Celebrating the hard work that builds our communities",gradientClasses:"from-blue-50/70 via-indigo-50/50 to-sky-50/40 dark:from-blue-950/30 dark:via-indigo-950/20 dark:to-sky-950/20",accentColor:"blue",decorativeElement:e.jsx(zIt,{})},{id:"halloween",name:"Halloween",description:"Spooky seasonal greetings",icon:e.jsx(eS,{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(IIt,{})},{id:"thanksgiving",name:"Thanksgiving",description:"Express gratitude this season",icon:e.jsx(Xa,{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(DIt,{})},{id:"christmas",name:"Christmas",description:"Spread holiday cheer",icon:e.jsx(Ab,{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(LIt,{})},{id:"hanukkah",name:"Hanukkah",description:"Celebrate the Festival of Lights",icon:e.jsx(Or,{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(OIt,{})},{id:"st_patricks_day",name:"St. Patrick's Day",description:"Celebrate the luck of the Irish",icon:e.jsx(Bv,{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(FIt,{})},{id:"home_anniversary",name:"Home Anniversary",description:"Celebrate their home ownership milestone",icon:e.jsx(Mn,{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(UIt,{})},{id:"under_contract",name:"Under Contract",description:"Celebrate this exciting milestone",icon:e.jsx(qd,{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(VIt,{})},{id:"just_listed",name:"Just Listed",description:"Announce a new listing",icon:e.jsx(cn,{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(sLe,{})},{id:"just_sold",name:"Just Sold",description:"Celebrate a successful sale",icon:e.jsx(_c,{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(aI,{})},{id:"price_reduction",name:"Price Reduction",description:"Notify about a price change",icon:e.jsx(bS,{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(Kv,{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(KIt,{})},{id:"closing_day",name:"Closing Day",description:"Celebrate their closing day",icon:e.jsx(fp,{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(HIt,{})},{id:"move_in_day",name:"Move-in Day",description:"Welcome them to their new home",icon:e.jsx(Mn,{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(GIt,{})},{id:"offer_accepted",name:"Offer Accepted",description:"Celebrate their accepted offer",icon:e.jsx(Bu,{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(aI,{})},{id:"pre_approval",name:"Pre-Approval Congrats",description:"Congratulate on pre-approval",icon:e.jsx(nc,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Congratulations, ${t}!`:"Congratulations!",subText:"You're pre-approved and ready to find your dream home",gradientClasses:"from-violet-50/70 via-purple-50/50 to-indigo-50/40 dark:from-violet-950/30 dark:via-purple-950/20 dark:to-indigo-950/20",accentColor:"violet",decorativeElement:e.jsx(tLe,{})}],YIt=[{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 XIt(t){return l_e.filter(s=>s.category===t)}function GM(t){return l_e.find(s=>s.id===t)||l_e[0]}function rLe(){const{shareToken:t,recipientToken:s}=io(),[r,n]=k.useState(null),[a,o]=k.useState(null),[l,i]=k.useState(null),[d,u]=k.useState(!0),[p,f]=k.useState(null),[y,_]=k.useState(!0),b=k.useRef(null),N=k.useRef(0),w=k.useRef(0),S=(()=>{const Y=new URLSearchParams(window.location.search);return s||Y.get("rt")||null})(),C=k.useCallback((Y,J=!1)=>{if(!S||Y<=0)return;const X=Math.max(1,Math.round(Y));if(X<=w.current)return;const ie=`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${encodeURIComponent(S)}&e=watch&ws=${X}`;J&&navigator.sendBeacon?navigator.sendBeacon(ie):fetch(ie,{method:"GET",keepalive:J}).catch(()=>{}),w.current=Math.max(w.current,X)},[S]);k.useEffect(()=>{var oe;if(!y||!(r!=null&&r.playback_url)||!S)return;let Y=!1;const J=()=>{N.current>0&&C(N.current,!0)},X=()=>{document.visibilityState==="hidden"&&J()},ce=()=>{J()},ie=()=>{var ve;if(Y||!b.current||!((ve=window.playerjs)!=null&&ve.Player))return;const me=new window.playerjs.Player(b.current);me.on("timeupdate",he=>{const ge=Math.floor(Number((he==null?void 0:he.seconds)??0));!Number.isFinite(ge)||ge<=0||(N.current=Math.max(N.current,ge))}),me.on("pause",()=>{N.current>0&&C(N.current)}),me.on("ended",()=>{N.current>0&&C(N.current,!0)})},ae=document.querySelector('script[data-bunny-playerjs="true"]');if((oe=window.playerjs)!=null&&oe.Player)ie();else if(ae)ae.addEventListener("load",ie,{once:!0});else{const me=document.createElement("script");me.src="https://assets.mediadelivery.net/playerjs/playerjs-latest.min.js",me.async=!0,me.defer=!0,me.dataset.bunnyPlayerjs="true",me.onload=ie,document.body.appendChild(me)}return document.addEventListener("visibilitychange",X),window.addEventListener("beforeunload",ce),()=>{Y=!0,document.removeEventListener("visibilitychange",X),window.removeEventListener("beforeunload",ce),J()}},[y,r==null?void 0:r.playback_url,S,C]),k.useEffect(()=>{N.current=0,w.current=0},[S,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(ie=>{document.querySelectorAll(ie).forEach(ae=>{ae.style.display="none"})})};Y();const J=[setTimeout(Y,500),setTimeout(Y,1500),setTimeout(Y,3e3)],X=new MutationObserver(Y);return X.observe(document.body,{childList:!0,subtree:!0}),()=>{J.forEach(clearTimeout),X.disconnect()}},[]),k.useEffect(()=>{(async()=>{if(!t){f("Invalid share link"),u(!1);return}const{data:J,error:X}=await G.from("agent_videos").select("id, title, playback_url, thumbnail_url, preview_url, duration_seconds, share_token, owner_user_id, contact_id, page_template, recipient_name").eq("share_token",t).eq("is_deleted",!1).single();if(X||!J){f("Video not found or has been removed"),u(!1);return}n(J);try{await G.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 G.from("profiles").select("id, name, email, phone").eq("id",J.owner_user_id).single();if(ce){o(ce);try{const{data:ie}=await G.storage.from("avatars").list(`${J.owner_user_id}`);if(ie&&ie.length>0){const{data:ae}=G.storage.from("avatars").getPublicUrl(`${J.owner_user_id}/${ie[0].name}`);i(ae.publicUrl)}}catch{}}}u(!1)})()},[t]);const A=Y=>{if(!Y)return"0:00";const J=Math.floor(Y/60),X=Y%60;return`${J}:${X.toString().padStart(2,"0")}`},I=Y=>Y.includes("iframe.mediadelivery.net/play/")?Y.replace("/play/","/embed/")+"?autoplay=true&responsive=true":Y,L=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=GM((r==null?void 0:r.page_template)||"default"),V=(r==null?void 0:r.recipient_name)||null,q=O.headerText(V),U=`https://dashboard.relevelup.com/share/video/${t}`;if(d)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx(us,{className:"h-8 w-8 animate-spin text-primary"})});if(p||!r)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsx(Pe,{className:"max-w-md w-full",children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(yn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Video Not Found"}),e.jsx("p",{className:"text-muted-foreground",children:p||"This video is no longer available."})]})})});const te=O.id!=="default";return e.jsxs(e.Fragment,{children:[e.jsxs(kl,{children:[e.jsx("title",{children:q}),e.jsx("meta",{name:"description",content:O.subText}),e.jsx("meta",{property:"og:title",content:q}),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:U}),r.preview_url&&e.jsx("meta",{property:"og:image",content:r.preview_url}),!r.preview_url&&r.thumbnail_url&&e.jsx("meta",{property:"og:image",content:r.thumbnail_url}),r.playback_url&&e.jsxs(e.Fragment,{children:[e.jsx("meta",{property:"og:video",content:r.playback_url}),e.jsx("meta",{property:"og:video:type",content:"text/html"}),e.jsx("meta",{property:"og:video:width",content:"1280"}),e.jsx("meta",{property:"og:video:height",content:"720"})]}),e.jsx("meta",{name:"twitter:card",content:"player"}),e.jsx("meta",{name:"twitter:title",content:q}),e.jsx("meta",{name:"twitter:description",content: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:Ot("min-h-screen flex items-center justify-center p-4 bg-gradient-to-b relative",O.gradientClasses),children:[te&&O.decorativeElement,e.jsxs("div",{className:"max-w-2xl w-full space-y-6 relative z-10",children:[te&&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:Ot("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:q}),e.jsx("p",{className:"text-muted-foreground",children:O.subText})]}),a&&e.jsxs("div",{className:"flex items-center gap-4 p-4 bg-card/90 backdrop-blur-sm rounded-lg border shadow-sm",children:[e.jsxs(Nn,{className:"h-14 w-14 border-2 border-primary/20",children:[e.jsx(Ma,{src:l||void 0,alt:a.name||"Agent"}),e.jsx(kn,{className:"bg-primary/10 text-primary font-semibold",children:L(a.name)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:te?"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(W,{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(In,{className:"h-4 w-4"})})}),a.email&&e.jsx(W,{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(tr,{className:"h-4 w-4"})})})]})]}),e.jsx(Pe,{className:"overflow-hidden shadow-lg",children:y&&r.playback_url?e.jsx("div",{className:"relative w-full",style:{paddingBottom:"56.25%"},children:e.jsx("iframe",{ref:b,src:I(r.playback_url),title:r.title||"Video message",className:"absolute top-0 left-0 w-full h-full",style:{border:0},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})}):e.jsxs("div",{className:"relative aspect-video bg-muted cursor-pointer group",onClick:()=>_(!0),children:[r.preview_url||r.thumbnail_url?e.jsx("img",{src:r.preview_url||r.thumbnail_url||"",alt:r.title?`${r.title} video preview`:"Video message preview",className:"w-full h-full object-cover",onError:Y=>{var X;Y.currentTarget.style.display="none";const J=(X=Y.currentTarget.parentElement)==null?void 0:X.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(yn,{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(Co,{className:"h-10 w-10 text-primary ml-1"})})}),r.duration_seconds&&e.jsx("div",{className:"absolute bottom-3 right-3 bg-black/70 text-white text-sm px-2 py-1 rounded",children:A(r.duration_seconds)})]})}),!te&&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:y?"Enjoy the video!":"Click to play the video"})]}),!y&&e.jsx("div",{className:"flex justify-center",children:e.jsxs(W,{size:"lg",onClick:()=>_(!0),className:"gap-2",children:[e.jsx(Co,{className:"h-5 w-5"}),"Watch Video"]})}),e.jsx(CIt,{shareToken:t,agentName:(a==null?void 0:a.name)||null,hasContact:!!r.contact_id})]})]})]})}function QIt(){return k.useEffect(()=>(document.body.classList.add("video-landing-page"),()=>{document.body.classList.remove("video-landing-page")}),[]),e.jsx(A1t,{})}function JIt(){const{token:t}=io();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(us,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Loading video preview…"})]})})}var rhe="Tabs",[eLt,mAs]=qc(rhe,[pw]),tXe=pw(),[tLt,tke]=eLt(rhe),sXe=k.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,onValueChange:a,defaultValue:o,orientation:l="horizontal",dir:i,activationMode:d="automatic",...u}=t,p=mw(i),[f,y]=Uu({prop:n,onChange:a,defaultProp:o??"",caller:rhe});return e.jsx(tLt,{scope:r,baseId:fu(),value:f,onValueChange:y,orientation:l,dir:p,activationMode:d,children:e.jsx(Jr.div,{dir:p,"data-orientation":l,...u,ref:s})})});sXe.displayName=rhe;var rXe="TabsList",nXe=k.forwardRef((t,s)=>{const{__scopeTabs:r,loop:n=!0,...a}=t,o=tke(rXe,r),l=tXe(r);return e.jsx(fue,{asChild:!0,...l,orientation:o.orientation,dir:o.dir,loop:n,children:e.jsx(Jr.div,{role:"tablist","aria-orientation":o.orientation,...a,ref:s})})});nXe.displayName=rXe;var aXe="TabsTrigger",iXe=k.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,disabled:a=!1,...o}=t,l=tke(aXe,r),i=tXe(r),d=cXe(l.baseId,n),u=dXe(l.baseId,n),p=n===l.value;return e.jsx(xue,{asChild:!0,...i,focusable:!a,active:p,children:e.jsx(Jr.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":u,"data-state":p?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:d,...o,ref:s,onMouseDown:Mr(t.onMouseDown,f=>{!a&&f.button===0&&f.ctrlKey===!1?l.onValueChange(n):f.preventDefault()}),onKeyDown:Mr(t.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&l.onValueChange(n)}),onFocus:Mr(t.onFocus,()=>{const f=l.activationMode!=="manual";!p&&!a&&f&&l.onValueChange(n)})})})});iXe.displayName=aXe;var oXe="TabsContent",lXe=k.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,forceMount:a,children:o,...l}=t,i=tke(oXe,r),d=cXe(i.baseId,n),u=dXe(i.baseId,n),p=n===i.value,f=k.useRef(p);return k.useEffect(()=>{const y=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(y)},[]),e.jsx(jd,{present:a||p,children:({present:y})=>e.jsx(Jr.div,{"data-state":p?"active":"inactive","data-orientation":i.orientation,role:"tabpanel","aria-labelledby":d,hidden:!y,id:u,tabIndex:0,...l,ref:s,style:{...t.style,animationDuration:f.current?"0s":void 0},children:y&&o})})});lXe.displayName=oXe;function cXe(t,s){return`${t}-trigger-${s}`}function dXe(t,s){return`${t}-content-${s}`}var sLt=sXe,uXe=nXe,hXe=iXe,mXe=lXe;const ta=sLt,Jn=k.forwardRef(({className:t,...s},r)=>e.jsx(uXe,{ref:r,className:Ot("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...s}));Jn.displayName=uXe.displayName;const cs=k.forwardRef(({className:t,...s},r)=>e.jsx(hXe,{ref:r,className:Ot("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}));cs.displayName=hXe.displayName;const Ss=k.forwardRef(({className:t,...s},r)=>e.jsx(mXe,{ref:r,className:Ot("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...s}));Ss.displayName=mXe.displayName;const rLt={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},nLt={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},g5={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function aLt(){var qe,Me,ke,Re;const{slugOrId:t}=io(),[s]=Nc(),{data:r,isLoading:n}=pWe(t||""),a=fWe(),o=ukt(),l=s.get("ref"),[i,d]=k.useState(""),[u,p]=k.useState(""),[f,y]=k.useState(""),[_,b]=k.useState(""),[N,w]=k.useState(""),[S,C]=k.useState(""),[A,I]=k.useState(""),[L,O]=k.useState("in_person"),[V,q]=k.useState("info"),[B,U]=k.useState(!1),[te,Y]=k.useState(!1),[J,X]=k.useState(null),[ce,ie]=k.useState(!1);k.useEffect(()=>{l&&o.mutate(l)},[l]);const ae=Ve=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(Ve),oe=async Ve=>{if(Ve.preventDefault(),!i.trim()||!f.trim()||!r)return;const Ne=V==="showing";if(Ne&&!S){pe.error("Please pick a preferred date for your showing");return}U(!0);try{await a.mutateAsync({listingId:r.id,agentId:r.agent_id,firstName:i.trim(),lastName:u.trim(),email:f.trim(),phone:_.trim(),shareToken:l,leadType:Ne?"showing_request":"info_request",preferredDate:Ne?S:null,preferredTime:Ne&&A||null,showingMode:Ne?L:null,message:N.trim()||null}),Y(!0),pe.success(Ne?"Showing request sent! The agent will confirm details shortly.":"Thanks! The agent will be in touch soon.")}catch(Ue){console.error("Lead submission error:",Ue),pe.error(`Failed to submit: ${Ue.message||"Please try again"}`)}finally{U(!1)}},me=(r==null?void 0:r.photos)||[],ve=me.find(Ve=>Ve.is_primary)||me[0],he=()=>{J!==null&&X(J===0?me.length-1:J-1)},ge=()=>{J!==null&&X(J===me.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(Ms,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(Ms,{className:"h-10 w-48 mb-6"}),e.jsx(Ms,{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(Ms,{className:"h-12 w-48"}),e.jsx(Ms,{className:"h-6 w-full"}),e.jsx(Ms,{className:"h-6 w-3/4"})]}),e.jsx(Ms,{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(da,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:Xoe,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(Mn,{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(W,{asChild:!0,children:e.jsx(da,{to:"/public/listings",children:"Browse All Listings"})})]})]});const je=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(kl,{children:[e.jsxs("title",{children:[je," | LevelUp Listings"]}),e.jsx("meta",{name:"description",content:`${ae(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA ${r.square_footage?r.square_footage.toLocaleString()+" sqft":""} ${g5[r.property_type]} in ${r.city}, ${r.state}. ${((qe=r.description)==null?void 0:qe.slice(0,150))||""}`}),e.jsx("link",{rel:"canonical",href:`https://listings.relevelup.com/${r.slug||r.id}`}),e.jsx("meta",{property:"og:title",content:je}),e.jsx("meta",{property:"og:description",content:`${ae(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA ${g5[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}`}),ve&&e.jsx("meta",{property:"og:image",content:ve.photo_url}),ve&&e.jsx("meta",{property:"og:image:alt",content:`${r.property_address||r.city} - ${g5[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:je}),e.jsx("meta",{name:"twitter:description",content:`${ae(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA in ${r.city}, ${r.state}`}),ve&&e.jsx("meta",{name:"twitter:image",content:ve.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||`${g5[r.property_type]} for sale in ${r.city}, ${r.state}`,url:`https://listings.relevelup.com/${r.slug||r.id}`,datePosted:r.created_at,image:me.map(Ve=>Ve.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:(Me=r.agent.brokerage)!=null&&Me.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(da,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:Xoe,alt:"LevelUp",className:"h-8"})})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-6",children:[e.jsxs(da,{to:"/public/listings",className:"inline-flex items-center text-muted-foreground hover:text-foreground mb-6",children:[e.jsx(Oa,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),me.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:()=>X(0),children:e.jsx("img",{src:ve==null?void 0:ve.photo_url,alt:`${r.property_address||r.city+", "+r.state} - ${g5[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:me.slice(1,5).map((Ve,Ne)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>X(Ne+1),children:[e.jsx("img",{src:Ve.photo_url,alt:`${r.property_address||r.city} - Photo ${Ne+2} of ${me.length}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),Ne===3&&me.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center text-white font-semibold",children:["+",me.length-5," more"]})]},Ve.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(Qe,{className:`${rLt[r.status]} text-white border-0`,children:nLt[r.status]})}),e.jsx("h1",{className:"text-4xl font-bold text-primary mb-2",children:ae(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(Ia,{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(Zy,{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(nf,{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(r0,{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(cn,{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(Qe,{variant:"secondary",children:[e.jsx(pa,{className:"h-3 w-3 mr-1"}),g5[r.property_type]]}),r.lot_size&&e.jsxs(Qe,{variant:"secondary",children:["Lot: ",r.lot_size]}),r.has_hoa&&e.jsx(Qe,{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(W,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:r.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Yr,{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(Oe,{className:"p-0",children:[e.jsxs("div",{className:"relative aspect-video bg-muted cursor-pointer group",onClick:()=>ie(!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(yn,{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(Co,{className:"h-8 w-8 text-primary fill-primary ml-1"})})})]}),e.jsxs("div",{className:"p-4",children:[e.jsxs(W,{onClick:()=>ie(!0),className:"w-full gap-2",size:"lg",children:[e.jsx(Co,{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(Dt,{children:e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Ai,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"font-semibold text-lg",children:r.agent.name}),((ke=r.agent.brokerage)==null?void 0:ke.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:r.agent.brokerage.name})]})]}),e.jsxs(Pe,{className:"border-primary",children:[e.jsx(Dt,{className:"pb-3",children:e.jsx(zt,{className:"text-lg",children:"Interested in this property?"})}),e.jsx(Oe,{children:te?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(tr,{className:"h-6 w-6 text-primary"})}),e.jsx("p",{className:"font-medium",children:V==="showing"?"Showing request sent!":"Thanks for your interest!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:V==="showing"?"The listing agent will reach out to confirm your showing time.":"The listing agent will contact you soon."})]}):e.jsxs(ta,{value:V,onValueChange:Ve=>q(Ve),children:[e.jsxs(Jn,{className:"grid w-full grid-cols-2 mb-4",children:[e.jsxs(cs,{value:"info",className:"gap-1.5",children:[e.jsx(tr,{className:"h-3.5 w-3.5"}),"Get Info"]}),e.jsxs(cs,{value:"showing",className:"gap-1.5",children:[e.jsx(bM,{className:"h-3.5 w-3.5"}),"Request Tour"]})]}),e.jsxs("form",{onSubmit:oe,className:"space-y-3",children:[e.jsxs(Ss,{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(xe,{htmlFor:"preferredDate",children:"Preferred Date *"}),e.jsx(De,{id:"preferredDate",type:"date",value:S,onChange:Ve=>C(Ve.target.value),min:new Date().toISOString().split("T")[0],required:V==="showing"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"preferredTime",children:"Preferred Time"}),e.jsxs($s,{value:A,onValueChange:I,children:[e.jsx(zs,{id:"preferredTime",children:e.jsx(Vs,{placeholder:"Any time"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"morning",children:"Morning (9am–12pm)"}),e.jsx(vt,{value:"afternoon",children:"Afternoon (12pm–5pm)"}),e.jsx(vt,{value:"evening",children:"Evening (5pm–8pm)"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"showingMode",children:"Tour Type"}),e.jsxs($s,{value:L,onValueChange:Ve=>O(Ve),children:[e.jsx(zs,{id:"showingMode",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"in_person",children:"🏡 In-person showing"}),e.jsx(vt,{value:"video",children:"📱 Video tour (FaceTime/Zoom)"}),e.jsx(vt,{value:"either",children:"Either works for me"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"firstName",children:"First Name *"}),e.jsx(De,{id:"firstName",type:"text",placeholder:"John",value:i,onChange:Ve=>d(Ve.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"lastName",children:"Last Name"}),e.jsx(De,{id:"lastName",type:"text",placeholder:"Doe",value:u,onChange:Ve=>p(Ve.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"email",children:"Email *"}),e.jsx(De,{id:"email",type:"email",placeholder:"you@example.com",value:f,onChange:Ve=>y(Ve.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsxs(xe,{htmlFor:"phone",children:["Phone ",V==="showing"&&"*"]}),e.jsx(De,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:_,onChange:Ve=>b(Ve.target.value),required:V==="showing"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"message",children:V==="showing"?"Anything else?":"Message (optional)"}),e.jsx(_r,{id:"message",placeholder:V==="showing"?"e.g. I have flexibility on weekends":"Any specific questions about the property?",value:N,onChange:Ve=>w(Ve.target.value),rows:2})]}),e.jsx(W,{type:"submit",className:"w-full",disabled:B,children:B?"Submitting...":V==="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:()=>X(null),children:e.jsxs(ps,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(ks,{className:"sr-only",children:e.jsx(_s,{children:"Photo Gallery"})}),e.jsx("button",{onClick:()=>X(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(kr,{className:"h-5 w-5"})}),J!==null&&me[J]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:me[J].photo_url,alt:`Photo ${J+1}`,className:"w-full max-h-[80vh] object-contain"}),me.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:he,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(Xo,{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(xa,{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," / ",me.length]})]})]})]})}),e.jsx(fs,{open:ce,onOpenChange:ie,children:e.jsxs(ps,{className:"max-w-4xl p-0 bg-black overflow-hidden",children:[e.jsx(ks,{className:"sr-only",children:e.jsx(_s,{children:"Video Tour"})}),e.jsx("button",{onClick:()=>ie(!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(kr,{className:"h-5 w-5"})}),((Re=r==null?void 0:r.video)==null?void 0:Re.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 iLt(){var o;const{slug:t}=io(),{data:s,isLoading:r,error:n}=vWe(t);if(k.useEffect(()=>(document.body.classList.add("agent-card-page"),()=>{document.body.classList.remove("agent-card-page")}),[]),k.useEffect(()=>{s!=null&&s.id&&Hi(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(Ms,{className:"h-28 w-28 rounded-full"}),e.jsx(Ms,{className:"h-6 w-48"}),e.jsx(Ms,{className:"h-4 w-36"})]}),e.jsx(Ms,{className:"h-12 w-full"}),e.jsx(Ms,{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(kl,{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(Wje,{card:s})]})}function pXe({slugOverride:t}={}){var Te;const{slug:s}=io(),r=t||s,[n]=Nc(),a=n.get("t"),[o,l]=k.useState(!0),[i,d]=k.useState(null),[u,p]=k.useState(null),f=k.useRef(null),y=k.useRef(null),[_,b]=k.useState(null),[N,w]=k.useState(null),[S,C]=k.useState(!1),[A,I]=k.useState(!1),[L,O]=k.useState(0),[V,q]=k.useState(!1),[B,U]=k.useState(""),[te,Y]=k.useState(""),[J,X]=k.useState(""),[ce,ie]=k.useState(""),[ae,oe]=k.useState(""),[me,ve]=k.useState(""),[he,ge]=k.useState(""),[je,qe]=k.useState(""),[Me,ke]=k.useState(""),[Re,Ve]=k.useState(""),[Ne,Ue]=k.useState(""),[Ie,ye]=k.useState("");k.useEffect(()=>{ct()},[r,a]);const ct=async()=>{if(!r)return;l(!0);const{data:We,error:Ke}=await G.from("contact_intake_pages").select("*").eq("slug",r).eq("is_active",!0).maybeSingle();if(Ke||!We){q(!0),l(!1);return}p(We),y.current=We;const{data:ot}=await G.from("profiles").select("name, avatar_url, title, phone, email, brokerage_id").eq("id",We.user_id).single();if(ot){let He;if(ot.brokerage_id){const{data:mt}=await G.from("brokerages").select("name").eq("id",ot.brokerage_id).single();He=(mt==null?void 0:mt.name)||void 0}let Je=ot.avatar_url||null;if(!Je){const{data:mt}=G.storage.from("avatars").getPublicUrl(`${We.user_id}/avatar.jpg`);mt!=null&&mt.publicUrl&&(Je=`${mt.publicUrl}?t=${Date.now()}`)}const ut={...ot,avatar_url:Je,brokerage_name:He};d(ut),f.current=ut}if(a)try{console.log("[ConnectPage] Resolving token:",a,"for page:",We.id);const{data:He,error:Je}=await G.functions.invoke("process-intake-submissions",{body:{action:"resolve_token",token:a,page_id:We.id}});if(console.log("[ConnectPage] Resolve result:",{resolved:He,resolveErr:Je}),!Je&&(He!=null&&He.contact_id)){w(He.contact_id);const ut=He.contact;ut&&(b(ut),U(ut.first_name||""),Y(ut.last_name||""),X(ut.email||""),ie(ut.phone||""),oe(ut.address||""),ve(ut.city||""),ge(ut.state||""),qe(ut.zip||""),ke(ut.birthday||""),Ve(ut.home_anniversary||""))}}catch(He){console.error("Failed to resolve token:",He)}l(!1)},fe=async()=>{var We,Ke;if(!B.trim()){pe.error("Please enter your first name");return}if(!r){pe.error("Invalid page. Please refresh.");return}I(!0);try{let ot=(We=y.current)==null?void 0:We.id,He=(Ke=y.current)==null?void 0:Ke.user_id;if(!ot||!He){const{data:ut}=await G.from("contact_intake_pages").select("id, user_id").eq("slug",r).eq("is_active",!0).maybeSingle();if(!ut){pe.error("This page is no longer active. Please contact the agent directly."),I(!1);return}ot=ut.id,He=ut.user_id}const{error:Je}=await G.from("contact_intake_submissions").insert({intake_page_id:ot,agent_user_id:He,existing_contact_id:N,first_name:B.trim(),last_name:te.trim()||null,email:J.trim()||null,phone:ce.trim()||null,address:ae.trim()||null,city:me.trim()||null,state:he.trim()||null,zip:je.trim()||null,birthday:Me||null,home_anniversary:Re||null,real_estate_interest:Ne||null,message:Ie.trim()||null});if(console.log("[ConnectPage] Insert result:",{error:Je}),Je)throw Je;a&&await G.from("contact_intake_tokens").update({used_at:new Date().toISOString()}).eq("token",a);try{const ut=[B.trim(),te.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:ut,contactEmail:J.trim()||null,contactPhone:ce.trim()||null,slug:r})})}catch(ut){console.warn("Connect page notification failed (non-blocking):",ut)}C(!0)}catch(ot){console.error(ot),pe.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(us,{className:"h-8 w-8 animate-spin text-slate-400"})});if(V)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(S)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(kl,{children:e.jsxs("title",{children:["Thank You | ",i==null?void 0:i.name]})}),e.jsxs(hr.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(hr.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($n,{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(Xa,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Powered by ReLevelUp"})]})]})]});const $e=!!a&&!!_,Ye=3,tt=[{title:$e?"Confirm Your Info":"Let's Get Connected",fields:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"First Name *"}),e.jsx("input",{type:"text",value:B,onChange:We=>U(We.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:te,onChange:We=>Y(We.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:We=>X(We.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:We=>ie(We.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:ae,onChange:We=>oe(We.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:me,onChange:We=>ve(We.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:he,onChange:We=>ge(We.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:je,onChange:We=>qe(We.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:Me,onChange:We=>ke(We.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:Re,onChange:We=>Ve(We.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(We=>e.jsxs("button",{type:"button",onClick:()=>Ue(Ne===We.value?"":We.value),className:`p-3.5 rounded-xl border-2 text-left transition-all ${Ne===We.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:We.label}),e.jsx("span",{className:"block text-xs text-slate-500 mt-0.5",children:We.desc})]},We.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:Ie,onChange:We=>ye(We.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(kl,{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(hr.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:((Te=i==null?void 0:i.name)==null?void 0:Te.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(In,{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(tr,{className:"h-4.5 w-4.5"})})]})]}),e.jsx(hr.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:Ye}).map((We,Ke)=>e.jsx("div",{className:`h-1.5 flex-1 rounded-full transition-all duration-500 ${Ke<=L?"bg-blue-500":"bg-slate-200"}`},Ke))}),e.jsxs(hr.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(DNe,{mode:"wait",children:e.jsxs(hr.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(Or,{className:"h-5 w-5 text-blue-500"}),e.jsx("h2",{className:"text-lg font-semibold text-slate-800",children:tt[L].title})]}),tt[L].fields]},L)}),e.jsxs("div",{className:"flex justify-between mt-8",children:[L>0?e.jsx("button",{type:"button",onClick:()=>O(We=>We-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",{}),L{if(L===0&&!B.trim()){pe.error("Please enter your first name");return}O(We=>We+1)},className:"px-6 py-2.5 bg-blue-600 text-white text-sm font-medium rounded-xl hover:bg-blue-700 transition-colors shadow-sm",children:"Continue"}):e.jsx("button",{type:"button",onClick:()=>fe(),disabled:A,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:A?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):"Submit"})]}),L>0&&LO(We=>We+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(Xa,{className:"h-3 w-3"}),e.jsx("span",{children:"Powered by ReLevelUp"})]})})]})]})}const QA=()=>({trackEngagement:k.useCallback(async(s,r,n,a="view")=>{try{const{data:{user:o}}=await G.auth.getUser();if(!o)return;await G.from("content_engagement_logs").insert({user_id:o.id,resource_type:s,resource_id:r,resource_title:n,action_type:a})}catch(o){console.error("Error tracking engagement:",o)}},[])});function iI({banners:t,autoPlayInterval:s=5e3,className:r}){const[n,a]=k.useState(0),[o,l]=k.useState(!1),{trackEngagement:i}=QA(),d=k.useCallback(_=>{i("newsletter",_.id,_.title,"click_link")},[i]),u=k.useCallback(()=>{a(_=>(_+1)%t.length)},[t.length]),p=k.useCallback(()=>{a(_=>(_-1+t.length)%t.length)},[t.length]),f=k.useCallback(_=>{a(_)},[]);if(k.useEffect(()=>{if(t.length<=1||o)return;const _=setInterval(u,s);return()=>clearInterval(_)},[t.length,o,s,u]),!t||t.length===0)return null;const y=t[n];return e.jsxs("div",{className:Ot("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:y.image_url,alt:y.title,className:"w-full h-full object-cover rounded-t-xl"}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(W,{variant:"ghost",size:"icon",className:Ot("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:p,children:e.jsx(Xo,{className:"h-6 w-6"})}),e.jsx(W,{variant:"ghost",size:"icon",className:Ot("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(xa,{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((_,b)=>e.jsx("button",{onClick:()=>f(b),className:Ot("w-2 h-2 rounded-full transition-all duration-300",b===n?"bg-white w-6":"bg-white/50 hover:bg-white/70"),"aria-label":`Go to slide ${b+1}`},b))})]}),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:y.title}),y.description&&e.jsx("p",{className:"text-xs text-background/70 truncate",children:y.description})]}),y.link_url&&e.jsx("a",{href:y.link_url,target:"_blank",rel:"noopener noreferrer",className:"shrink-0",onClick:()=>d(y),children:e.jsx(W,{size:"sm",className:"bg-primary text-primary-foreground font-semibold transition-colors hover:bg-background hover:text-foreground",children:y.link_text||"Learn More"})})]})]})}function oLt(t){return"EST"}function uD(t){const r=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit",hour12:!0,timeZone:"America/New_York"}).format(t),n=oLt();return`${r} ${n}`}function WM(t){const s=new Date,r=new Date(t),n=J5(r,-15),a=J5(r,30);return s>a?"ended":gg(s,{start:r,end:a})?"live":gg(s,{start:n,end:r})?"starting_soon":"upcoming"}function ske(t){const s=WM(t);return s==="starting_soon"||s==="live"}const nLe=ske,lLt=({events:t,registrations:s,onNavigateToEvents:r})=>{const[n,a]=k.useState(new Date);k.useEffect(()=>{const _=setInterval(()=>{a(new Date)},3e4);return()=>clearInterval(_)},[]);const o=t.filter(_=>ske(_.event_date));if(o.length===0)return null;const l=o[0],i=WM(l.event_date),d=s.find(_=>_.event_id===l.id),u=(d==null?void 0:d.zoom_join_url)||l.zoom_link,p=!!d,f=i==="live",y=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 ${y.container} border`,children:[e.jsx("div",{className:`absolute inset-0 bg-gradient-to-r ${y.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 ${y.indicator} opacity-75`}),e.jsx("span",{className:`relative flex h-3 w-3 rounded-full ${y.indicator}`})]}),e.jsx("div",{className:`flex items-center gap-2 ${y.text} font-bold text-sm uppercase tracking-wider`,children:f?e.jsxs(e.Fragment,{children:[e.jsx(e1,{className:"h-4 w-4"}),"Live Now"]}):e.jsxs(e.Fragment,{children:[e.jsx(nn,{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 ${uD(new Date(l.event_date))}`:`Starts at ${uD(new Date(l.event_date))}`})]}),e.jsx("div",{className:"flex items-center gap-2",children:p?e.jsxs(W,{onClick:()=>window.open(u,"_blank"),className:`${y.button} text-white gap-2`,children:[e.jsx(Yr,{className:"h-4 w-4"}),f?"Join Now":"Join When Live"]}):e.jsxs(W,{variant:"outline",onClick:r,className:`${y.outlineButton} gap-2`,children:[e.jsx(ir,{className:"h-4 w-4"}),"Register & Join"]})})]})})]})};var rke="Progress",nke=100,[cLt,pAs]=qc(rke),[dLt,uLt]=cLt(rke),fXe=k.forwardRef((t,s)=>{const{__scopeProgress:r,value:n=null,max:a,getValueLabel:o=hLt,...l}=t;(a||a===0)&&!aLe(a)&&console.error(mLt(`${a}`,"Progress"));const i=aLe(a)?a:nke;n!==null&&!iLe(n,i)&&console.error(pLt(`${n}`,"Progress"));const d=iLe(n,i)?n:null,u=wle(d)?o(d,i):void 0;return e.jsx(dLt,{scope:r,value:d,max:i,children:e.jsx(Jr.div,{"aria-valuemax":i,"aria-valuemin":0,"aria-valuenow":wle(d)?d:void 0,"aria-valuetext":u,role:"progressbar","data-state":yXe(d,i),"data-value":d??void 0,"data-max":i,...l,ref:s})})});fXe.displayName=rke;var xXe="ProgressIndicator",gXe=k.forwardRef((t,s)=>{const{__scopeProgress:r,...n}=t,a=uLt(xXe,r);return e.jsx(Jr.div,{"data-state":yXe(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...n,ref:s})});gXe.displayName=xXe;function hLt(t,s){return`${Math.round(t/s*100)}%`}function yXe(t,s){return t==null?"indeterminate":t===s?"complete":"loading"}function wle(t){return typeof t=="number"}function aLe(t){return wle(t)&&!isNaN(t)&&t>0}function iLe(t,s){return wle(t)&&!isNaN(t)&&t<=s&&t>=0}function mLt(t,s){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${s}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${nke}\`.`}function pLt(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 ${nke} if no \`max\` prop is set) - \`null\` or \`undefined\` if the progress is indeterminate. Defaulting to \`null\`.`}var vXe=fXe,fLt=gXe;const xi=k.forwardRef(({className:t,value:s,...r},n)=>e.jsx(vXe,{ref:n,className:Ot("relative h-4 w-full overflow-hidden rounded-full bg-secondary",t),...r,children:e.jsx(fLt,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(s||0)}%)`}})}));xi.displayName=vXe.displayName;function xLt(){const{user:t,isBrokerageManager:s}=Us(),[r,n]=k.useState([]),[a,o]=k.useState([]),[l,i]=k.useState(!1),[d,u]=k.useState(!0),p=s?"brokerage_manager":"agent";k.useEffect(()=>{if(!(t!=null&&t.id)){u(!1);return}f()},[t==null?void 0:t.id,p]);const f=async()=>{if(t!=null&&t.id)try{const{data:I,error:L}=await G.from("onboarding_checklist_items").select("*").eq("target_role",p).eq("is_active",!0).order("sort_order");if(L)throw L;const{data:O,error:V}=await G.from("onboarding_checklist_progress").select("item_id, completed_at").eq("user_id",t.id);if(V)throw V;const{data:q,error:B}=await G.from("onboarding_checklist_dismissed").select("id").eq("user_id",t.id).maybeSingle();if(B)throw B;n(I||[]),o(O||[]),i(!!q),I&&I.length>0&&await y(I,O||[])}catch(I){console.error("Error fetching checklist data:",I)}finally{u(!1)}},y=async(I,L)=>{var Ve,Ne;if(!(t!=null&&t.id))return;const O=L.map(Ue=>Ue.item_id),V=I.filter(Ue=>!O.includes(Ue.id));if(V.length===0)return;const[q,B,U,te,Y,J,X,ce,ie,ae,oe,me,ve,he,ge]=await Promise.all([G.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle(),G.from("resource_shares").select("id",{count:"exact",head:!0}).eq("sender_id",t.id),G.from("community_posts").select("id",{count:"exact",head:!0}).eq("user_id",t.id),G.from("event_registrations").select("id",{count:"exact",head:!0}).eq("user_id",t.id),G.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","template"),G.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","academy_video"),G.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","toolbox"),G.from("activity_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id),G.from("innercircle_contacts").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),G.from("agent_videos").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),G.from("contact_touch_logs").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),G.from("scorecard_transactions").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),G.from("listings").select("id",{count:"exact",head:!0}).eq("agent_id",t.id),G.from("innercircle_contacts").select("id").eq("owner_user_id",t.id),G.from("deal_pipeline").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id)]),je={},qe=(Ve=q.data)==null?void 0:Ve.brokerage_id;je.share_resource=(B.count||0)>0,je.post_community=(U.count||0)>0,je.register_event=(te.count||0)>0,je.view_template=(Y.count||0)>0,je.watch_academy=(J.count||0)>0,je.use_toolbox=(X.count||0)>0,je.launch_app=(ce.count||0)>0,je.add_contact=(ie.count||0)>0,je.create_video=(ae.count||0)>0,je.complete_touch=(oe.count||0)>0,je.add_transaction=(me.count||0)>0,je.add_listing=(ve.count||0)>0,je.add_deal=(ge.count||0)>0;const Me=((Ne=he.data)==null?void 0:Ne.map(Ue=>Ue.id))||[],ke=[];qe?ke.push(G.from("profiles").select("id").eq("brokerage_id",qe).neq("id",t.id).then(Ue=>{var Ie;je.add_agent=(((Ie=Ue.data)==null?void 0:Ie.length)||0)>0})):je.add_agent=!1,Me.length>0?(ke.push(G.from("contact_plan_cycles").select("id",{count:"exact",head:!0}).in("contact_id",Me).then(Ue=>{je.add_plan=(Ue.count||0)>0})),ke.push(G.from("contact_popby_settings").select("id",{count:"exact",head:!0}).in("contact_id",Me).then(Ue=>{je.schedule_popby=(Ue.count||0)>0}))):(je.add_plan=!1,je.schedule_popby=!1),await Promise.all(ke);const Re=V.filter(Ue=>je[Ue.action_type]);if(Re.length>0){const Ue=Re.map(ye=>({user_id:t.id,item_id:ye.id})),{error:Ie}=await G.from("onboarding_checklist_progress").upsert(Ue,{onConflict:"user_id,item_id",ignoreDuplicates:!0});if(!Ie){const ye=Re.map(ct=>({item_id:ct.id,completed_at:new Date().toISOString()}));o(ct=>[...ct,...ye])}}},_=async I=>{if(t!=null&&t.id)try{const{error:L}=await G.from("onboarding_checklist_progress").insert({user_id:t.id,item_id:I});if(L)throw L;o(O=>[...O,{item_id:I,completed_at:new Date().toISOString()}])}catch(L){console.error("Error marking item complete:",L)}},b=async()=>{if(t!=null&&t.id)try{const{error:I}=await G.from("onboarding_checklist_dismissed").insert({user_id:t.id});if(I)throw I;i(!0)}catch(I){console.error("Error dismissing checklist:",I)}},N=a.length,w=r.length,S=w>0&&N>=w,C=w>0?N/w*100:0;return{items:r,progress:a,isDismissed:l,loading:d,completedCount:N,totalCount:w,isComplete:S,progressPercentage:C,isItemComplete:I=>a.some(L=>L.item_id===I),markComplete:_,dismiss:b,refetch:f}}const gLt={add_agent:e.jsx(ir,{className:"h-4 w-4"}),share_resource:e.jsx(id,{className:"h-4 w-4"}),post_community:e.jsx(wi,{className:"h-4 w-4"}),register_event:e.jsx(cn,{className:"h-4 w-4"}),view_template:e.jsx(Av,{className:"h-4 w-4"}),watch_academy:e.jsx(Lh,{className:"h-4 w-4"}),use_toolbox:e.jsx(Lg,{className:"h-4 w-4"}),launch_app:e.jsx(sL,{className:"h-4 w-4"}),add_deal:e.jsx(Yy,{className:"h-4 w-4"}),add_listing:e.jsx(Mn,{className:"h-4 w-4"})},yLt={add_deal:"/mission-control/pipeline",add_listing:"/mission-control/listings/new",post_community:"/community",add_contact:"/mission-control/contacts"};function vLt(){const{items:t,isDismissed:s,loading:r,completedCount:n,totalCount:a,isComplete:o,progressPercentage:l,isItemComplete:i,markComplete:d,dismiss:u}=xLt(),p=wr(),[f,y]=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(Dt,{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(e0,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:"Get Started with LevelUp"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:"Complete these steps to make the most of your membership"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>y(!f),className:"h-8 w-8 p-0",children:f?e.jsx(af,{className:"h-4 w-4"}):e.jsx(Bi,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0 text-muted-foreground hover:text-foreground",children:e.jsx(kr,{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(xi,{value:l,className:"h-2"})]})]}),f&&e.jsx(Oe,{className:"pt-0",children:e.jsx("div",{className:"space-y-3",children:t.map(_=>{const b=i(_.id);return e.jsxs("div",{className:Ot("flex items-start gap-3 p-3 rounded-lg transition-colors",b?"bg-muted/50":"bg-background hover:bg-muted/30 cursor-pointer"),onClick:()=>{if(b)return;const N=yLt[_.action_type];N?p(N):d(_.id)},children:[e.jsx("div",{className:"mt-0.5",children:b?e.jsx($n,{className:"h-5 w-5 text-primary"}):e.jsx(sd,{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:gLt[_.action_type]||e.jsx(sd,{className:"h-4 w-4"})}),e.jsx("span",{className:Ot("font-medium",b&&"line-through text-muted-foreground"),children:_.title})]}),_.description&&e.jsx("p",{className:Ot("text-sm text-muted-foreground mt-1",b&&"line-through"),children:_.description})]})]},_.id)})})})]})}const Nf=()=>gt({queryKey:["relationship-types"],queryFn:async()=>{const{data:t,error:s}=await G.from("relationship_types").select("*").order("sort_order");if(s)throw s;return t}}),qh=t=>{const s=ya(),r=1e3,n=async a=>{const o=[];let l=0;for(;;){const{data:i,error:d}=await a.range(l,l+r-1);if(d)throw d;const u=i??[];if(o.push(...u),u.length{let a=G.from("innercircle_contacts").select(` *, lead_source_ref:lead_sources(id, name), tags:innercircle_contact_tags( id, contact_id, relationship_type_id, relationship_type:relationship_types(*) ) `).eq("owner_user_id",s).order("created_at",{ascending:!1}).order("first_name");return await n(a)},enabled:!!s})},_Lt=t=>gt({queryKey:["innercircle-contact",t],queryFn:async()=>{const{data:s,error:r}=await G.from("innercircle_contacts").select(` *, lead_source_ref:lead_sources(id, name), tags:innercircle_contact_tags( id, contact_id, relationship_type_id, relationship_type:relationship_types(*) ) `).eq("id",t).maybeSingle();if(r)throw r;return s},enabled:!!t}),_Xe=()=>{const t=ya();return gt({queryKey:["innercircle-contact-counts",t],queryFn:async()=>{const{data:s,error:r}=await G.from("innercircle_contacts").select(` id, tags:innercircle_contact_tags(relationship_type_id) `);if(r)throw r;const n={};return s==null||s.forEach(a=>{var o;(o=a.tags)==null||o.forEach(l=>{n[l.relationship_type_id]=(n[l.relationship_type_id]||0)+1})}),n},enabled:!!t})},nhe=()=>{const t=Qt(),s=ya();return Pt({mutationFn:async r=>{const{tagIds:n,...a}=r,o={...a,birthday:a.birthday||null,home_anniversary:a.home_anniversary||null,owner_user_id:s},{data:l,error:i}=await G.from("innercircle_contacts").insert(o).select().single();if(i)throw i;if(n&&n.length>0){const{error:d}=await G.from("innercircle_contact_tags").insert(n.map(u=>({contact_id:l.id,relationship_type_id:u})));if(d)throw d}return l},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),fn({title:"Contact created successfully"})},onError:r=>{fn({title:"Error creating contact",description:r.message,variant:"destructive"})}})},ake=()=>{const t=Qt();return Pt({mutationFn:async({id:s,...r})=>{const{tagIds:n,tags:a,...o}=r,l={...o,birthday:o.birthday||null,home_anniversary:o.home_anniversary||null},{data:i,error:d}=await G.from("innercircle_contacts").update(l).eq("id",s).select().single();if(d)throw d;if(n!==void 0&&(await G.from("innercircle_contact_tags").delete().eq("contact_id",s),n.length>0)){const{error:u}=await G.from("innercircle_contact_tags").insert(n.map(p=>({contact_id:s,relationship_type_id:p})));if(u)throw u}return i},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),fn({title:"Contact updated successfully"})},onError:s=>{fn({title:"Error updating contact",description:s.message,variant:"destructive"})}})},bXe=()=>{const t=Qt();return Pt({mutationFn:async({contactId:s,spouseContactId:r})=>{if(r){const{error:n}=await G.from("innercircle_contacts").update({spouse_contact_id:r}).eq("id",s);if(n)throw n;const{error:a}=await G.from("innercircle_contacts").update({spouse_contact_id:s}).eq("id",r);if(a)throw a}else{const{data:n}=await G.from("innercircle_contacts").select("spouse_contact_id").eq("id",s).single(),a=n==null?void 0:n.spouse_contact_id,{error:o}=await G.from("innercircle_contacts").update({spouse_contact_id:null}).eq("id",s);if(o)throw o;if(a){const{error:l}=await G.from("innercircle_contacts").update({spouse_contact_id:null}).eq("id",a);if(l)throw l}}},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact"]}),t.invalidateQueries({queryKey:["innercircle-contact-spouse"]}),fn({title:"Spouse link updated"})},onError:s=>{fn({title:"Error linking spouse",description:s.message,variant:"destructive"})}})},ike=()=>{const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("innercircle_contacts").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),fn({title:"Contact deleted successfully"})},onError:s=>{fn({title:"Error deleting contact",description:s.message,variant:"destructive"})}})},WR=()=>gt({queryKey:["action-types"],queryFn:async()=>{const{data:t,error:s}=await G.from("action_types").select("*").order("sort_order");if(s)throw s;return t}}),bLt=t=>gt({queryKey:["action-scripts",t],queryFn:async()=>{let s=G.from("action_scripts").select("*, action_type:action_types(*)");const{data:r,error:n}=await s;if(n)throw n;return r}}),wLt=()=>gt({queryKey:["touchpoint-plans"],queryFn:async()=>{const{data:t,error:s}=await G.from("touchpoint_plans").select(` *, items:touchpoint_plan_items( *, action_type:action_types(*), default_script:action_scripts(*) ) `).order("name");if(s)throw s;return t}}),jLt=()=>{const t=Qt(),s=ya();return Pt({mutationFn:async({name:r,description:n})=>{const{data:a,error:o}=await G.from("touchpoint_plans").insert({name:r,description:n,owner_user_id:s,active:!0,is_template:!1}).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),fn({title:"Plan created successfully"})},onError:r=>{fn({title:"Error creating plan",description:r.message,variant:"destructive"})}})},NLt=()=>{const t=Qt(),s=ya();return Pt({mutationFn:async({sourcePlanId:r,newName:n})=>{const{data:a,error:o}=await G.from("touchpoint_plans").select(` *, items:touchpoint_plan_items(*) `).eq("id",r).single();if(o)throw o;if(!a)throw new Error("Source plan not found");const{data:l,error:i}=await G.from("touchpoint_plans").insert({name:n,description:a.description,owner_user_id:s,active:!0,is_template:!1}).select().single();if(i)throw i;if(a.items&&a.items.length>0){const d=a.items.map(p=>({plan_id:l.id,month_number:p.month_number,action_type_id:p.action_type_id,default_script_id:p.default_script_id,notes:p.notes})),{error:u}=await G.from("touchpoint_plan_items").insert(d);if(u)throw u}return l},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),fn({title:"Plan duplicated successfully",description:"You can now edit your copy of this plan."})},onError:r=>{fn({title:"Error duplicating plan",description:r.message,variant:"destructive"})}})},kLt=()=>{const t=Qt();return Pt({mutationFn:async({id:s,name:r,description:n})=>{const{data:a,error:o}=await G.from("touchpoint_plans").update({name:r,description:n}).eq("id",s).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),fn({title:"Plan updated successfully"})}})},SLt=()=>{const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("touchpoint_plans").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),fn({title:"Plan deleted successfully"})}})},CLt=()=>{const t=Qt();return Pt({mutationFn:async({planId:s,items:r})=>{if(await G.from("touchpoint_plan_items").delete().eq("plan_id",s),r.length>0){const{error:n}=await G.from("touchpoint_plan_items").insert(r.map(a=>({plan_id:s,month_number:a.month_number,action_type_id:a.action_type_id,default_script_id:a.default_script_id||null,notes:a.notes})));if(n)throw n}},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),fn({title:"Plan schedule updated"})}})},MLt=()=>{const t=Qt();return Pt({mutationFn:async({actionTypeId:s,title:r,scriptBody:n,emailSubject:a,tone:o})=>{const{data:{user:l}}=await G.auth.getUser(),{data:i,error:d}=await G.from("action_scripts").insert({action_type_id:s,title:r,script_body:n,email_subject:a||null,tone:o||null,active:!0,user_id:l==null?void 0:l.id}).select().single();if(d)throw d;return i},onSuccess:()=>{t.invalidateQueries({queryKey:["action-scripts"]}),fn({title:"Script created successfully"})},onError:s=>{fn({title:"Error creating script",description:s.message,variant:"destructive"})}})},TLt=()=>{const t=ya();return gt({queryKey:["user-plan-enrollments",t],queryFn:async()=>{const{data:s,error:r}=await G.from("user_plan_enrollments").select(` *, plan:touchpoint_plans(*), relationship_type:relationship_types(*) `);if(r)throw r;return s},enabled:!!t})},ALt=()=>{const t=Qt(),s=ya();return Pt({mutationFn:async({planId:r,relationshipTypeId:n,active:a})=>{const{data:o}=await G.from("user_plan_enrollments").select("id").eq("plan_id",r).eq("relationship_type_id",n).maybeSingle();if(o){const{error:l}=await G.from("user_plan_enrollments").update({active:a}).eq("id",o.id);if(l)throw l}else if(a){const{error:l}=await G.from("user_plan_enrollments").insert({owner_user_id:s,plan_id:r,relationship_type_id:n,active:!0,start_date:new Date().toISOString().split("T")[0]});if(l)throw l}},onSuccess:()=>{t.invalidateQueries({queryKey:["user-plan-enrollments"]}),fn({title:"Plan enrollment updated"})}})},KR=(t=7)=>{const s=ya();return gt({queryKey:["contact-touch-logs",s,t],queryFn:async()=>{const r=new Date;r.setDate(r.getDate()-t);const{data:n,error:a}=await G.from("contact_touch_logs").select(` *, contact:innercircle_contacts(*), action_type:action_types(*) `).eq("owner_user_id",s).gte("completed_at",r.toISOString()).order("completed_at",{ascending:!1});if(a)throw a;return n},enabled:!!s})},wXe=()=>{const t=ya();return gt({queryKey:["contacts-last-touch",t],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_touch_logs").select("contact_id, completed_at").eq("owner_user_id",t).order("completed_at",{ascending:!1});if(r)throw r;const n={};return s==null||s.forEach(a=>{n[a.contact_id]||(n[a.contact_id]=a.completed_at)}),n},enabled:!!t})},ELt=(t=90)=>{const{data:s}=qh(),{data:r}=wXe();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=ya();return Pt({mutationFn:async({contactId:r,actionTypeId:n,scriptUsedId:a,notes:o,completedAt:l})=>{const{data:i,error:d}=await G.from("contact_touch_logs").insert({owner_user_id:s,contact_id:r,action_type_id:n,script_used_id:a,notes:o,completed_at:l||new Date().toISOString()}).select().single();if(d)throw d;return i},onSuccess:async(r,n)=>{var a,o;t.invalidateQueries({queryKey:["contact-touch-logs"]}),t.invalidateQueries({queryKey:["contacts-last-touch"]}),t.invalidateQueries({queryKey:["today-actions"]}),fn({title:"Action completed!"});try{const[l,i]=await Promise.all([G.from("innercircle_contacts").select("email").eq("id",n.contactId).single(),G.from("action_types").select("name").eq("id",n.actionTypeId).single()]),d=(a=l.data)==null?void 0:a.email,u=((o=i.data)==null?void 0:o.name)||"Touch";d&&G.functions.invoke("boldtrail-sync",{body:{action:"push_touch",contact_email:d,touch_type:u,touch_notes:n.notes||null,touch_date:n.completedAt||r.completed_at}}).catch(()=>{})}catch{}}})},jXe="agentos_weekly_touch_goal",oLe=20,jle=()=>{if(typeof window>"u")return oLe;const t=localStorage.getItem(jXe);if(t){const s=parseInt(t,10);if(!isNaN(s)&&s>0)return s}return oLe},NXe=t=>{localStorage.setItem(jXe,t.toString())},oke=()=>{const{data:t}=KR(7),s=new Date;s.setHours(0,0,0,0);const r=new Date(s);r.setDate(s.getDate()-s.getDay());const n=(t==null?void 0:t.filter(l=>new Date(l.completed_at)>=r).length)||0;let a=0;if(t&&t.length>0){const l=new Set(t.map(d=>new Date(d.completed_at).toDateString()));let i=new Date(s);for(;l.has(i.toDateString());)a++,i.setDate(i.getDate()-1)}const o=jle();return{actionsThisWeek:n,weeklyGoal:o,streak:a,progress:Math.min(n/o*100,100)}},PLt=()=>{const t=ya();return gt({queryKey:["contact-plan-cycles",t],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_plan_cycles").select(` *, contact:innercircle_contacts(*), plan:touchpoint_plans( *, items:touchpoint_plan_items( *, action_type:action_types(*), default_script:action_scripts(*) ) ) `);if(r)throw r;return s},enabled:!!t})},ILt=()=>{const t=Qt();return ya(),Pt({mutationFn:async()=>{const{data:s}=await G.from("user_plan_enrollments").select("*").eq("active",!0);if(!s||s.length===0)return;const{data:r}=await G.from("innercircle_contacts").select(` id, tags:innercircle_contact_tags(relationship_type_id) `);if(!r)return;const{data:n}=await G.from("contact_plan_cycles").select("contact_id, plan_id"),a=new Set((n==null?void 0:n.map(l=>`${l.contact_id}-${l.plan_id}`))||[]),o=[];for(const l of r)for(const i of l.tags||[]){const d=s.find(u=>u.relationship_type_id===i.relationship_type_id);d&&!a.has(`${l.id}-${d.plan_id}`)&&o.push({contact_id:l.id,plan_id:d.plan_id,relationship_type_id:i.relationship_type_id})}if(o.length>0){const{error:l}=await G.from("contact_plan_cycles").insert(o);if(l)throw l}return o.length},onSuccess:s=>{t.invalidateQueries({queryKey:["contact-plan-cycles"]}),s&&s>0&&fn({title:`${s} contact(s) enrolled in plans`})}})},kXe=()=>{const t=ya(),{data:s}=PLt(),{data:r}=KR(30);return gt({queryKey:["today-actions",t,s==null?void 0:s.length,r==null?void 0:r.length],queryFn:async()=>{var b;if(!s||s.length===0)return[];const{data:n}=await G.from("contact_snoozes").select("contact_id").gte("snoozed_until",new Date().toISOString()),a=new Set((n==null?void 0:n.map(N=>N.contact_id))||[]),o=new Date,l=[],i=new Date(o.getFullYear(),o.getMonth(),1),d=new Set((r==null?void 0:r.filter(N=>new Date(N.completed_at)>=i).map(N=>`${N.contact_id}-${N.action_type_id}`))||[]);for(const N of s){if(!((b=N.plan)!=null&&b.items)||N.plan.items.length===0||!N.contact||a.has(N.contact_id))continue;const w=new Date(N.cycle_start_date),C=Math.floor((o.getTime()-w.getTime())/(30.44*24*60*60*1e3))%12+1,A=N.plan.items.find(I=>I.month_number===C);if(A&&A.action_type){const I=`${N.contact_id}-${A.action_type_id}`;if(!d.has(I)){const{data:L}=await G.from("relationship_types").select("name").eq("id",N.relationship_type_id).single();l.push({contact:N.contact,actionType:A.action_type,script:A.default_script||void 0,planName:N.plan.name,relationshipTypeName:(L==null?void 0:L.name)||"",monthNumber:C})}}}const u=5,p=o.getDate(),f=l.sort((N,w)=>N.contact.first_name.localeCompare(w.contact.first_name)),y=(p-1)%Math.max(1,f.length);return[...f.slice(y),...f.slice(0,y)].slice(0,u)},enabled:!!t&&!!s})};function LLt(){const t=wr(),{data:s,isLoading:r}=kXe(),{data:n}=qh(),a=oke(),[o,l]=k.useState(jle()),[i,d]=k.useState(""),[u,p]=k.useState(!1);k.useEffect(()=>{l(jle())},[]);const f=()=>{const O=parseInt(i,10);if(isNaN(O)||O<1){fn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}l(O),NXe(O),p(!1),fn({title:"Goal updated",description:`Weekly touch goal set to ${O}`})},y=()=>{d(o.toString()),p(!0)},_=Em(new Date),b=ml(_,7),N=O=>{if(!O)return null;const V=O.split(/[-/T]/);if(V.length<3)return null;const q=parseInt(V[1],10)-1,B=parseInt(V[2],10);return isNaN(q)||isNaN(B)?null:new Date(_.getFullYear(),q,B)},w=(n==null?void 0:n.map(O=>{const V=N(O.birthday),q=N(O.home_anniversary),B=[];return V&&V>=_&&V<=b&&B.push({contact:O,type:"birthday",date:V,isToday:il(V,_)}),q&&q>=_&&q<=b&&B.push({contact:O,type:"anniversary",date:q,isToday:il(q,_)}),B}).flat().sort((O,V)=>O.date.getTime()-V.date.getTime()).slice(0,3))||[],S=(n==null?void 0:n.filter(O=>{const V=N(O.birthday),q=N(O.home_anniversary);return V&&il(V,_)||q&&il(q,_)}).length)||0,C=(s==null?void 0:s.length)||0,A=S+C,I=(a==null?void 0:a.actionsThisWeek)||0,L=(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(Oe,{className:"p-4",children:e.jsxs("div",{className:"animate-pulse flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 bg-primary/20 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-4 bg-primary/20 rounded w-1/3"}),e.jsx("div",{className:"h-3 bg-primary/10 rounded w-1/2"})]})]})})}):e.jsxs(Pe,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-primary/5 border-primary/20",children:[e.jsxs(Dt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(ir,{className:"h-5 w-5 text-primary"}),"Agent OS"]}),e.jsx("div",{className:"flex items-center gap-2",children:L>0&&e.jsxs(Qe,{variant:"secondary",className:"gap-1 bg-orange-500/10 text-orange-600 border-orange-200",children:[e.jsx(rd,{className:"h-3 w-3"}),L," day streak"]})})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[A>0?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-primary font-medium",children:[A," tasks"]})," for today"]}):"No tasks for today",I>0&&e.jsxs("span",{className:"ml-2",children:["• ",e.jsx("span",{className:"text-emerald-600 font-medium",children:I})," touches this week"]})]})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(W,{size:"sm",variant:"outline",className:"gap-1.5",onClick:O=>{O.stopPropagation(),t("/mission-control/contacts?new=true")},children:[e.jsx(Jo,{className:"h-3.5 w-3.5"}),"Add Contact"]}),e.jsxs(W,{size:"sm",variant:"outline",className:"gap-1.5",onClick:O=>{O.stopPropagation(),t("/mission-control")},children:[e.jsx(In,{className:"h-3.5 w-3.5"}),"Log Touch"]}),e.jsxs(W,{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(yn,{className:"h-3.5 w-3.5"}),"Quick Video"]}),e.jsxs(W,{size:"sm",variant:"outline",className:"gap-1.5",onClick:O=>{O.stopPropagation(),t("/mission-control/popbys")},children:[e.jsx(Ia,{className:"h-3.5 w-3.5"}),"Pop-by Map"]}),e.jsxs(W,{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(Yy,{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(Rh,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Weekly Goal"}),e.jsxs(fs,{open:u,onOpenChange:p,children:[e.jsx(mi,{asChild:!0,children:e.jsx("button",{onClick:y,className:"p-0.5 rounded hover:bg-muted transition-colors","aria-label":"Edit weekly goal",children:e.jsx(So,{className:"h-3.5 w-3.5 text-muted-foreground hover:text-primary"})})}),e.jsxs(ps,{className:"sm:max-w-[360px]",children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Set Weekly Goal"}),e.jsx(Ir,{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(xe,{htmlFor:"weekly-goal",children:"Weekly touch goal"}),e.jsx(De,{id:"weekly-goal",type:"number",min:"1",value:i,onChange:O=>d(O.target.value),placeholder:"20",onKeyDown:O=>{O.key==="Enter"&&f()}})]}),e.jsx(W,{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(xi,{value:Math.min(I/o*100,100),className:"h-2 bg-muted [&>div]:bg-primary"}),I>=o&&e.jsxs("p",{className:"text-xs text-emerald-600 mt-1.5 flex items-center gap-1",children:[e.jsx("span",{children:"🎉"})," Goal achieved! Keep the momentum going."]}),I0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1.5",children:[o-I," more to hit your weekly goal"]})]}),w.length>0&&e.jsxs("div",{className:"pt-3 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Fu,{className:"h-4 w-4 text-pink-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Upcoming Milestones"})]}),e.jsx("div",{className:"space-y-2",children:w.map((O,V)=>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:q=>{q.stopPropagation(),t(`/mission-control/contacts/${O.contact.id}`)},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[O.type==="birthday"?e.jsx(Fu,{className:"h-3.5 w-3.5 text-pink-500"}):e.jsx(Mn,{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(Qe,{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"?"🎂":"🏠":vs(O.date,"EEE, MMM d")}),e.jsx(xa,{className:"h-3 w-3"})]})]},`${O.contact.id}-${O.type}-${V}`))})]}),e.jsxs(W,{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(Wa,{className:"h-4 w-4"})]})]})]})}function DLt(t){return gt({queryKey:["brokerage-content-categories",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("brokerage_content_categories").select("*").eq("brokerage_id",t).order("sort_order");if(r)throw r;return s},enabled:!!t})}function RLt(t,s){return gt({queryKey:["brokerage-content",t,s],queryFn:async()=>{if(!t)return[];let r=G.from("brokerage_content").select("*, category:brokerage_content_categories(*)").eq("brokerage_id",t).order("created_at",{ascending:!1});s&&(r=r.eq("category_id",s));const{data:n,error:a}=await r;if(a)throw a;return n},enabled:!!t})}function OLt(t,s=4){return gt({queryKey:["brokerage-content-recent",t,s],queryFn:async()=>{if(!t)return[];const{data:r,error:n}=await G.from("brokerage_content").select("*, category:brokerage_content_categories(*)").eq("brokerage_id",t).order("created_at",{ascending:!1}).limit(s);if(n)throw n;return r},enabled:!!t})}function FLt(t){const s=Qt();return Pt({mutationFn:async r=>{const{data:n,error:a}=await G.from("brokerage_content").insert(r).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["brokerage-content"]}),s.invalidateQueries({queryKey:["brokerage-content-recent"]})}})}function zLt(){const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("brokerage_content").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-content"]}),t.invalidateQueries({queryKey:["brokerage-content-recent"]})}})}function BLt(t){const s=Qt();return Pt({mutationFn:async r=>{const{data:n,error:a}=await G.from("brokerage_content_categories").insert({...r,brokerage_id:t}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["brokerage-content-categories"]})}})}function $Lt(){const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("brokerage_content_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-content-categories"]})}})}function qLt(t){const s=Qt();return Pt({mutationFn:async()=>{const r=[{name:"Events",icon:"📅",sort_order:0,is_default:!0,brokerage_id:t},{name:"Videos",icon:"🎥",sort_order:1,is_default:!0,brokerage_id:t},{name:"Documents",icon:"📄",sort_order:2,is_default:!0,brokerage_id:t},{name:"Resources",icon:"🔗",sort_order:3,is_default:!0,brokerage_id:t},{name:"Graphics",icon:"🎨",sort_order:4,is_default:!0,brokerage_id:t}],{error:n}=await G.from("brokerage_content_categories").upsert(r,{onConflict:"brokerage_id,name"});if(n)throw n},onSuccess:()=>{s.invalidateQueries({queryKey:["brokerage-content-categories"]})}})}const ULt={video:Co,pdf:vn,link:Do,event:cn,graphic:zl},VLt={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 HLt(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 GLt(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 WLt({item:t}){const s=wr(),r=ULt[t.content_type]||Do,n=VLt[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"?HLt(t.url):null);k.useEffect(()=>{l||!t.url||t.content_type!=="video"||!GLt(t.url)||fetch(`https://www.youtube.com/oembed?url=${encodeURIComponent(t.url)}&format=json`).then(d=>d.ok?d.json():null).then(d=>{d!=null&&d.thumbnail_url&&o(d.thumbnail_url)}).catch(()=>{})},[t.url,t.content_type,l]);const i=l||a;return e.jsxs(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(Oe,{className:"p-3",children:[e.jsx("div",{className:"flex items-center gap-1.5 mb-1.5",children:e.jsxs(Qe,{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:vs(new Date(t.event_date),"MMM d · h:mm a")})]})]})}function KLt(){const{brokerageId:t}=Us(),s=wr(),{data:r=[],isLoading:n}=OLt(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(pa,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Brokerage Content"})]}),e.jsxs(W,{variant:"ghost",size:"sm",onClick:()=>s("/brokerage-content"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Wa,{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(WLt,{item:a},a.id))})]})}const SXe=()=>gt({queryKey:["listing-exchange-enabled"],queryFn:async()=>{const{data:t,error:s}=await G.from("feature_flags").select("enabled").eq("key","listing_exchange_enabled").maybeSingle();if(s)throw s;return(t==null?void 0:t.enabled)??!1}}),CXe=t=>{const{user:s,brokerageId:r}=Us();return gt({queryKey:["listings",t,r],queryFn:async()=>{let n=G.from("listings").select(` *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id, brokerage:brokerages(name)) `).eq("is_approved",!0).eq("is_public",!0);t!=null&&t.status&&(n=n.eq("status",t.status)),t!=null&&t.propertyType&&(n=n.eq("property_type",t.propertyType)),t!=null&&t.city&&(n=n.ilike("city",`%${t.city}%`)),t!=null&&t.minPrice&&(n=n.gte("price",t.minPrice)),t!=null&&t.maxPrice&&(n=n.lte("price",t.maxPrice)),t!=null&&t.openToReferrals&&(n=n.eq("open_to_referrals",!0));const{data:a,error:o}=await n;if(o)throw o;let l=a||[];if(r){const{data:i}=await G.from("profiles").select("id").eq("brokerage_id",r);if(i&&i.length>0){const d=i.map(f=>f.id);let u=G.from("listings").select(` *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id, brokerage:brokerages(name)) `).eq("is_approved",!0).eq("share_with_brokerage",!0).eq("is_public",!1).in("agent_id",d);t!=null&&t.status&&(u=u.eq("status",t.status)),t!=null&&t.propertyType&&(u=u.eq("property_type",t.propertyType)),t!=null&&t.city&&(u=u.ilike("city",`%${t.city}%`)),t!=null&&t.minPrice&&(u=u.gte("price",t.minPrice)),t!=null&&t.maxPrice&&(u=u.lte("price",t.maxPrice)),t!=null&&t.openToReferrals&&(u=u.eq("open_to_referrals",!0));const{data:p}=await u;if(p){const f=new Set(l.map(_=>_.id)),y=p.filter(_=>!f.has(_.id));l=[...l,...y]}}}switch(t==null?void 0:t.sortBy){case"updated":l.sort((i,d)=>new Date(d.updated_at).getTime()-new Date(i.updated_at).getTime());break;case"price_asc":l.sort((i,d)=>i.price-d.price);break;case"price_desc":l.sort((i,d)=>d.price-i.price);break;default:l.sort((i,d)=>new Date(d.created_at).getTime()-new Date(i.created_at).getTime())}return l}})},MXe=()=>{const{user:t}=Us();return gt({queryKey:["my-listings",t==null?void 0:t.id],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("listings").select(` *, photos:listing_photos(*) `).eq("agent_id",t.id).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})},TXe=t=>{const{user:s}=Us();return gt({queryKey:["listing",t],queryFn:async()=>{const{data:r,error:n}=await G.from("listings").select(` *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id, brokerage:brokerages(name)), video:agent_videos!listings_video_id_fkey(id, playback_url, thumbnail_url, title, duration_seconds) `).eq("id",t).single();if(n)throw n;return s&&await G.from("listing_views").insert({listing_id:t,viewer_id:s.id}),r},enabled:!!t})},ZLt=()=>{const t=Qt(),{user:s}=Us();return Pt({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n,error:a}=await G.from("listings").insert({...r,agent_id:s.id}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]})}})},YLt=()=>{const t=Qt();return Pt({mutationFn:async({agentId:s,...r})=>{const{data:n,error:a}=await G.from("listings").insert({...r,agent_id:s}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]}),t.invalidateQueries({queryKey:["brokerage-listings"]})}})},XLt=()=>{const t=Qt();return Pt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("listings").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]}),t.invalidateQueries({queryKey:["listing",s.id]})}})},AXe=()=>{const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("listings").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]})}})},QLt=()=>{const t=Qt();return Pt({mutationFn:async({listingId:s,photoUrl:r,isPrimary:n=!1})=>{const{data:a,error:o}=await G.from("listing_photos").insert({listing_id:s,photo_url:r,is_primary:n}).select().single();if(o)throw o;return a},onSuccess:s=>{t.invalidateQueries({queryKey:["listing",s.listing_id]}),t.invalidateQueries({queryKey:["my-listings"]})}})},JLt=()=>{const t=Qt();return Pt({mutationFn:async({photoId:s,listingId:r})=>{const{error:n}=await G.from("listing_photos").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["listing",s]}),t.invalidateQueries({queryKey:["my-listings"]})}})},e8t=()=>{const t=Qt();return Pt({mutationFn:async({photos:s})=>{var o;const r=s.map(l=>G.from("listing_photos").update({sort_order:l.sort_order,is_primary:l.is_primary}).eq("id",l.id)),a=(o=(await Promise.all(r)).find(l=>l.error))==null?void 0:o.error;if(a)throw a;return s},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["listing"]}),t.invalidateQueries({queryKey:["my-listings"]})}})},t8t=()=>{const t=Qt();return Pt({mutationFn:async({photoId:s,listingId:r})=>{const{error:n}=await G.from("listing_photos").update({is_primary:!1}).eq("listing_id",r);if(n)throw n;const{error:a}=await G.from("listing_photos").update({is_primary:!0}).eq("id",s);if(a)throw a;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["listing",s]}),t.invalidateQueries({queryKey:["my-listings"]})}})},s8t=()=>{const{user:t}=Us();return gt({queryKey:["saved-listings",t==null?void 0:t.id],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("listing_saves").select(` *, listing:listings( *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id) ) `).eq("agent_id",t.id);if(r)throw r;return s},enabled:!!t})},EXe=()=>{const t=Qt(),{user:s}=Us();return Pt({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n}=await G.from("listing_saves").select("id").eq("listing_id",r).eq("agent_id",s.id).maybeSingle();return n?(await G.from("listing_saves").delete().eq("id",n.id),{saved:!1}):(await G.from("listing_saves").insert({listing_id:r,agent_id:s.id}),{saved:!0})},onSuccess:()=>{t.invalidateQueries({queryKey:["saved-listings"]}),t.invalidateQueries({queryKey:["listings"]})}})},PXe=t=>{const{user:s}=Us();return gt({queryKey:["listing-saved",t,s==null?void 0:s.id],queryFn:async()=>{if(!s)return!1;const{data:r}=await G.from("listing_saves").select("id").eq("listing_id",t).eq("agent_id",s.id).maybeSingle();return!!r},enabled:!!s&&!!t})},r8t=()=>{const t=Qt(),{user:s}=Us();return Pt({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n}=await G.from("listing_follows").select("id").eq("listing_id",r).eq("agent_id",s.id).maybeSingle();return n?(await G.from("listing_follows").delete().eq("id",n.id),{following:!1}):(await G.from("listing_follows").insert({listing_id:r,agent_id:s.id}),{following:!0})},onSuccess:()=>{t.invalidateQueries({queryKey:["listing-following"]})}})},n8t=t=>{const{user:s}=Us();return gt({queryKey:["listing-following",t,s==null?void 0:s.id],queryFn:async()=>{if(!s)return!1;const{data:r}=await G.from("listing_follows").select("id").eq("listing_id",t).eq("agent_id",s.id).maybeSingle();return!!r},enabled:!!s&&!!t})},a8t=()=>{const{user:t}=Us();return Pt({mutationFn:async({listingId:s,shareType:r})=>{if(!t)throw new Error("Not authenticated");const{error:n}=await G.from("listing_shares").insert({listing_id:s,sharing_agent_id:t.id,share_type:r});if(n)throw n}})},i8t=()=>{const{user:t}=Us();return gt({queryKey:["my-referrals",t==null?void 0:t.id],queryFn:async()=>{if(!t)return{sent:[],received:[]};const[s,r]=await Promise.all([G.from("listing_referrals").select(` *, listing:listings(*,photos:listing_photos(*)) `).eq("sender_agent_id",t.id).order("created_at",{ascending:!1}),G.from("listing_referrals").select(` *, sender:profiles!listing_referrals_sender_agent_id_fkey(id, name, email), listing:listings(*,photos:listing_photos(*)) `).eq("listing_agent_id",t.id).order("created_at",{ascending:!1})]);return{sent:s.data||[],received:r.data||[]}},enabled:!!t})},o8t=()=>{const t=Qt(),{user:s}=Us();return Pt({mutationFn:async({listingId:r,listingAgentId:n,buyerName:a,buyerType:o,notes:l})=>{if(!s)throw new Error("Not authenticated");const{data:i,error:d}=await G.from("listing_referrals").insert({listing_id:r,sender_agent_id:s.id,listing_agent_id:n,buyer_name:a,buyer_type:o,notes:l}).select().single();if(d)throw d;return i},onSuccess:()=>{t.invalidateQueries({queryKey:["my-referrals"]})}})},l8t=()=>gt({queryKey:["listing-leaderboard"],queryFn:async()=>{const{data:t}=await G.from("listing_shares").select("sharing_agent_id, profiles!listing_shares_agent_id_fkey(name)").order("created_at",{ascending:!1}),s=new Map;t==null||t.forEach(l=>{var u;const i=l.sharing_agent_id;if(!i)return;const d=s.get(i);d?d.count++:s.set(i,{name:((u=l.profiles)==null?void 0:u.name)||"Unknown",count:1})});const r=Array.from(s.entries()).map(([l,i])=>({agentId:l,...i})).sort((l,i)=>i.count-l.count).slice(0,10),{data:n}=await G.from("listings").select("agent_id, agent:profiles!listings_agent_id_fkey(name)").eq("is_approved",!0),a=new Map;n==null||n.forEach(l=>{var d;const i=a.get(l.agent_id);i?i.count++:a.set(l.agent_id,{name:((d=l.agent)==null?void 0:d.name)||"Unknown",count:1})});const o=Array.from(a.entries()).map(([l,i])=>({agentId:l,...i})).sort((l,i)=>i.count-l.count).slice(0,10);return{topSharers:r,topListers:o}}}),c8t=()=>{const{user:t,brokerageId:s}=Us();return gt({queryKey:["brokerage-listings",s],queryFn:async()=>{if(!t||!s)return[];const{data:r}=await G.from("profiles").select("id").eq("brokerage_id",s);if(!r||r.length===0)return[];const n=r.map(l=>l.id),{data:a,error:o}=await G.from("listings").select(` *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id, brokerage:brokerages(name)) `).in("agent_id",n).eq("is_approved",!0).order("created_at",{ascending:!1});if(o)throw o;return a},enabled:!!t&&!!s})},IXe=({className:t,variant:s="default"})=>e.jsx(Qe,{variant:"outline",className:Ot("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"}),d8t={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"},u8t={coming_soon:"Coming Soon",active:"Active",under_contract:"Under Contract",sold:"Sold",withdrawn:"Withdrawn"};function h8t(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function m8t(){const t=wr(),{data:s,isLoading:r}=SXe(),{data:n,isLoading:a}=CXe({status:void 0,propertyType:void 0,sortBy:"newest"}),o=(n==null?void 0:n.filter(p=>p.is_approved&&p.is_public))||[],l=o.filter(p=>p.is_featured),i=o.filter(p=>!p.is_featured),d=[...l,...i].slice(0,6),u=r||a;return!u&&!s?null:u?e.jsx(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(Oe,{className:"p-4",children:e.jsxs("div",{className:"animate-pulse flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 bg-emerald-500/20 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-4 bg-emerald-500/20 rounded w-1/3"}),e.jsx("div",{className:"h-3 bg-emerald-500/10 rounded w-1/2"})]})]})})}):e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Listing Exchange"}),e.jsx(IXe,{})]}),e.jsxs(W,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control/listings"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Wa,{className:"h-4 w-4"})]})]}),d.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Mn,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No listings available yet"}),e.jsx(W,{variant:"link",size:"sm",onClick:()=>t("/mission-control/listings/new"),className:"mt-2",children:"Add the first listing"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:d.map(p=>{var y,_;const f=((y=p.photos)==null?void 0:y.find(b=>b.is_primary))||((_=p.photos)==null?void 0:_[0]);return e.jsxs("div",{onClick:()=>t(`/mission-control/listings/${p.id}`),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsxs("div",{className:"aspect-[4/3] bg-muted/50 overflow-hidden relative",children:[f!=null&&f.photo_url?e.jsx("img",{src:f.photo_url,alt:`${p.city}, ${p.state}`,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Mn,{className:"h-8 w-8 text-muted-foreground/50"})}),p.is_featured&&e.jsx("div",{className:"absolute top-1.5 left-1.5",children:e.jsxs(Qe,{className:"gap-1 bg-amber-500 text-white border-0 text-[10px] px-1.5 py-0.5",children:[e.jsx(Gn,{className:"h-2.5 w-2.5 fill-current"}),"Featured"]})}),e.jsx("div",{className:"absolute top-1.5 right-1.5",children:e.jsx(Qe,{className:`text-[10px] px-1.5 py-0.5 ${d8t[p.status]}`,children:u8t[p.status]})})]}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"font-bold text-sm text-foreground",children:h8t(p.price)}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[p.city,", ",p.state]}),(p.bedrooms||p.bathrooms)&&e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:[p.bedrooms&&`${p.bedrooms} bed`,p.bedrooms&&p.bathrooms&&" · ",p.bathrooms&&`${p.bathrooms} bath`]})]})]},p.id)})})]})}function LXe(t=10,s){return gt({queryKey:["event-leaderboard",t,s],queryFn:async()=>{const{data:r}=await G.from("user_roles").select("user_id").eq("role","admin"),n=new Set((r==null?void 0:r.map(y=>y.user_id))||[]);let a=null;if(s){const{data:y}=await G.from("profiles").select("id").eq("brokerage_id",s);a=new Set((y==null?void 0:y.map(_=>_.id))||[])}const{data:o,error:l}=await G.from("agent_attendance_stats").select("user_id, total_points, total_events_attended, current_streak").order("total_points",{ascending:!1}).limit(t+n.size+50);if(l)throw l;if(!o||o.length===0)return[];let i=o.filter(y=>!n.has(y.user_id));a&&(i=i.filter(y=>a.has(y.user_id)));const d=i.slice(0,t),u=d.map(y=>y.user_id),{data:p}=await G.from("profiles").select("id, name").in("id",u),f=new Map((p==null?void 0:p.map(y=>[y.id,{name:y.name}]))||[]);return d.map(y=>({user_id:y.user_id,total_points:y.total_points,total_events_attended:y.total_events_attended,current_streak:y.current_streak,profile:f.get(y.user_id)||null}))}})}function DXe(t){return gt({queryKey:["user-attendance-stats",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("agent_attendance_stats").select("*").eq("user_id",t).single();if(r&&r.code!=="PGRST116")throw r;return s},enabled:!!t})}function RXe(t){return gt({queryKey:["user-badges",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("agent_badges").select("*").eq("user_id",t).order("earned_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function OXe(t,s){return gt({queryKey:["user-rank",t,s],queryFn:async()=>{if(!t)return null;const{data:r}=await G.from("agent_attendance_stats").select("total_points").eq("user_id",t).single();if(!r)return null;const{data:n}=await G.from("user_roles").select("user_id").eq("role","admin"),a=new Set((n==null?void 0:n.map(d=>d.user_id))||[]),{data:o,error:l}=await G.from("agent_attendance_stats").select("user_id, total_points").gt("total_points",r.total_points);if(l)throw l;let i=(o==null?void 0:o.filter(d=>!a.has(d.user_id)))||[];if(s){const{data:d}=await G.from("profiles").select("id").eq("brokerage_id",s),u=new Set((d==null?void 0:d.map(p=>p.id))||[]);i=i.filter(p=>u.has(p.user_id))}return i.length+1},enabled:!!t})}function p8t(){const{user:t,brokerageId:s,isAdmin:r}=Us();wr();const n=!!s,[a,o]=k.useState("brokerage"),l=()=>{if(r)return null;if(n)return a==="global"?null:s},{data:i,isLoading:d}=LXe(5,l()),{data:u}=DXe(t==null?void 0:t.id),{data:p}=OXe(t==null?void 0:t.id,l()),{data:f}=RXe(t==null?void 0:t.id),y=r||n,_=()=>r?"Agent Leaderboard":n?a==="global"?"All LevelUp":"My Brokerage":"My Points";if(d)return e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Fi,{className:"h-4 w-4 text-yellow-500"}),_()]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-2",children:[...Array(y?5:3)].map((N,w)=>e.jsx(Ms,{className:"h-10 w-full"},w))})})]});const b=N=>N===0?e.jsx(Fi,{className:"h-4 w-4 text-yellow-500 mx-auto"}):N===1?e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"2"}):N===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:N+1});if(y){const N=(i==null?void 0:i.slice(0,5))||[];return e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"pb-2",children:[e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Fi,{className:"h-4 w-4 text-yellow-500"}),_()]}),!r&&n&&e.jsxs("div",{className:"flex gap-1 mt-2",children:[e.jsx(W,{variant:a==="brokerage"?"default":"outline",size:"sm",className:"text-xs h-7 flex-1",onClick:()=>o("brokerage"),children:"My Brokerage"}),e.jsx(W,{variant:a==="global"?"default":"outline",size:"sm",className:"text-xs h-7 flex-1",onClick:()=>o("global"),children:"All LevelUp"})]})]}),e.jsxs(Oe,{children:[!r&&u&&e.jsx("div",{className:"mb-3 p-2 rounded-lg bg-primary/5 border border-primary/10",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Your Rank:"}),e.jsxs("span",{className:"font-bold text-primary",children:["#",p||"-"]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[e.jsxs("span",{children:[e.jsx("strong",{className:"text-primary",children:u.total_points})," pts"]}),e.jsxs("span",{children:[e.jsx("strong",{children:u.total_events_attended})," events"]})]})]})}),e.jsxs("div",{className:"space-y-2",children:[N.map((w,S)=>{var C,A,I;return e.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg ${w.user_id===(t==null?void 0:t.id)?"bg-primary/10 border border-primary/20":S===0?"bg-yellow-500/10":""}`,children:[e.jsx("div",{className:"w-5 text-center",children:b(S)}),e.jsx(Nn,{className:"h-6 w-6",children:e.jsx(kn,{className:"text-xs",children:((A=(C=w.profile)==null?void 0:C.name)==null?void 0:A.charAt(0))||"?"})}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:((I=w.profile)==null?void 0:I.name)||"Unknown"}),e.jsx("span",{className:"text-sm font-bold text-primary",children:w.total_points})]},w.user_id)}),N.length===0&&e.jsx("div",{className:"text-center text-muted-foreground py-2 text-sm",children:"No data yet"})]}),e.jsxs(da,{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(hi,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(xa,{className:"h-4 w-4"})]})]})]})}return e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Fi,{className:"h-4 w-4 text-yellow-500"}),"My Points"]})}),e.jsx(Oe,{children:u?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"p-3 rounded-lg bg-primary/5 border border-primary/10 text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-primary",children:u.total_points}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Points"})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-muted/50 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:u.total_events_attended}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Events Attended"})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-orange-500/10 border border-orange-500/20",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(rd,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Current Streak"})]}),e.jsxs("span",{className:"font-bold text-orange-500",children:[u.current_streak," 🔥"]})]}),f&&f.length>0&&e.jsxs("div",{className:"pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[e.jsx(nc,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Badges"})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[f.slice(0,4).map(N=>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:N.badge_name},N.id)),f.length>4&&e.jsxs("span",{className:"text-xs text-muted-foreground px-2 py-1",children:["+",f.length-4," more"]})]})]}),e.jsxs(da,{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(hi,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(xa,{className:"h-4 w-4"})]})]}):e.jsxs("div",{className:"text-center text-muted-foreground py-4 text-sm",children:[e.jsx(Gn,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/50"}),e.jsx("p",{children:"Attend events to earn points!"}),e.jsxs(da,{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(hi,{className:"h-4 w-4"}),"Visit Reward Store",e.jsx(xa,{className:"h-4 w-4"})]})]})})]})}const JA=()=>gt({queryKey:["lead-sources"],queryFn:async()=>{const{data:t,error:s}=await G.from("lead_sources").select("*").eq("is_active",!0).order("sort_order");if(s)throw s;return t}}),lke=()=>{const t=Qt(),{user:s}=Us();return Pt({mutationFn:async r=>{const{data:n}=await G.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 G.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"]}),pe.success("Lead source added")},onError:r=>{pe.error("Failed to add lead source"),console.error(r)}})},f8t=()=>{const t=Qt();return Pt({mutationFn:async({id:s,name:r})=>{const{error:n}=await G.from("lead_sources").update({name:r}).eq("id",s);if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["lead-sources"]}),pe.success("Lead source updated")},onError:s=>{pe.error(s.message||"Failed to update lead source")}})},x8t=()=>{const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("lead_sources").update({is_active:!1}).eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["lead-sources"]}),pe.success("Lead source removed")},onError:s=>{pe.error(s.message||"Failed to remove lead source")}})},cke=(t,s)=>{const{user:r,isAdmin:n}=Us(),a=n&&s?s:r==null?void 0:r.id;return gt({queryKey:["scorecard-transactions",t,a],queryFn:async()=>{let o=G.from("scorecard_transactions").select(` *, lead_source:lead_sources(id, name), client_type:relationship_types(id, name), contact:innercircle_contacts(id, first_name, last_name) `).eq("owner_user_id",a).order("close_date",{ascending:!1});t&&(o=o.gte("close_date",`${t}-01-01`).lte("close_date",`${t}-12-31`));const{data:l,error:i}=await o;if(i)throw i;return l},enabled:!!a})},dke=t=>{const{user:s,isAdmin:r}=Us(),n=r&&t?t:s==null?void 0:s.id;return gt({queryKey:["scorecard-transactions-all",n],queryFn:async()=>{const{data:a,error:o}=await G.from("scorecard_transactions").select(` *, lead_source:lead_sources(id, name), client_type:relationship_types(id, name), contact:innercircle_contacts(id, first_name, last_name) `).eq("owner_user_id",n).order("close_date",{ascending:!1});if(o)throw o;return a},enabled:!!n})},ihe=()=>{const t=Qt(),{user:s}=Us();return Pt({mutationFn:async r=>{const{data:n,error:a}=await G.from("scorecard_transactions").insert({...r,owner_user_id:s.id}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-transactions"]}),t.invalidateQueries({queryKey:["scorecard-transactions-all"]}),pe.success("Transaction added")},onError:r=>{pe.error("Failed to add transaction"),console.error(r)}})},g8t=()=>{const t=Qt();return Pt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("scorecard_transactions").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-transactions"]}),t.invalidateQueries({queryKey:["scorecard-transactions-all"]}),pe.success("Transaction updated")},onError:s=>{pe.error("Failed to update transaction"),console.error(s)}})},y8t=()=>{const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("scorecard_transactions").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-transactions"]}),t.invalidateQueries({queryKey:["scorecard-transactions-all"]}),pe.success("Transaction deleted")},onError:s=>{pe.error("Failed to delete transaction"),console.error(s)}})},FXe=(t,s)=>{const{user:r,isAdmin:n}=Us(),a=n&&s?s:r==null?void 0:r.id;return gt({queryKey:["scorecard-goals",t,a],queryFn:async()=>{const{data:o,error:l}=await G.from("scorecard_goals").select("*").eq("owner_user_id",a).eq("year",t).maybeSingle();if(l)throw l;return o},enabled:!!a})},v8t=()=>{const t=Qt(),{user:s}=Us();return Pt({mutationFn:async r=>{const{data:n,error:a}=await G.from("scorecard_goals").upsert({...r,owner_user_id:s.id},{onConflict:"owner_user_id,year"}).select().single();if(a)throw a;return n},onSuccess:(r,n)=>{t.invalidateQueries({queryKey:["scorecard-goals",n.year]}),pe.success("Goals saved")},onError:r=>{pe.error("Failed to save goals"),console.error(r)}})},ohe=()=>{const{user:t}=Us();return gt({queryKey:["scorecard-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("scorecard_settings").select("*").eq("user_id",t.id).maybeSingle();if(r)throw r;return s},enabled:!!(t!=null&&t.id)})},_8t=()=>{const t=Qt(),{user:s}=Us();return Pt({mutationFn:async r=>{const{data:n,error:a}=await G.from("scorecard_settings").upsert({...r,user_id:s.id},{onConflict:"user_id"}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-settings"]}),pe.success("Settings saved")},onError:r=>{pe.error("Failed to save settings"),console.error(r)}})},zXe=(t,s)=>{const{data:r,isLoading:n}=cke(t,s),{data:a,isLoading:o}=dke(s),{data:l}=ohe(),i=(l==null?void 0:l.show_commission)??!0,d=u=>{if(!u||u.length===0)return{totalTransactions:0,buyerCount:0,sellerCount:0,totalVolume:0,averagePrice:0,totalCommission:0,totalNetToAgent:0,topLeadSource:null,transactionsByMonth:[],leadSourceBreakdown:[]};const p=u.filter(L=>L.transaction_type==="buyer").length,f=u.filter(L=>L.transaction_type==="seller").length,y=u.reduce((L,O)=>L+Number(O.sale_price),0),_=u.reduce((L,O)=>L+(Number(O.commission_amount)||0),0),b=u.reduce((L,O)=>{const V=Number(O.commission_amount)||0;if(!V)return L;let q=V;return O.brokerage_split_pct&&(q-=V*(O.brokerage_split_pct/100)),O.team_split_pct&&(q-=V*(O.team_split_pct/100)),O.franchise_fee_pct&&(q-=V*(O.franchise_fee_pct/100)),O.referral_fee_pct&&(q-=V*(O.referral_fee_pct/100)),O.transaction_fee&&(q-=O.transaction_fee),L+Math.max(0,q)},0),N={};u.forEach(L=>{var V;const O=((V=L.lead_source)==null?void 0:V.name)||"Unknown";N[O]=(N[O]||0)+1});const w=Object.entries(N).map(([L,O])=>({name:L,count:O})).sort((L,O)=>O.count-L.count),S=w[0]||null,C={};u.forEach(L=>{const O=ol(L.close_date).toLocaleString("default",{month:"short"});C[O]=(C[O]||0)+1});const I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(L=>({month:L,count:C[L]||0}));return{totalTransactions:u.length,buyerCount:p,sellerCount:f,totalVolume:y,averagePrice:u.length>0?y/u.length:0,totalCommission:i?_:0,totalNetToAgent:i?b:0,topLeadSource:S,transactionsByMonth:I,leadSourceBreakdown:w}};return{yearStats:d(r),lifetimeStats:d(a),isLoading:n||o,showCommission:i}},b8t=()=>{const{isAdmin:t}=Us();return gt({queryKey:["agents-with-transactions"],queryFn:async()=>{const{data:s,error:r}=await G.from("scorecard_transactions").select("owner_user_id").order("owner_user_id");if(r)throw r;const n=[...new Set(s.map(l=>l.owner_user_id))],{data:a,error:o}=await G.from("profiles").select("id, name, email").in("id",n);if(o)throw o;return a},enabled:t})},L_={recency:40,touchpoints:30,transactions:20,referrals:10},lLe={warm:70,cooling:40};function w8t(t){return t===null?0:t<=14?L_.recency:t<=30?L_.recency*.85:t<=60?L_.recency*.65:t<=90?L_.recency*.4:t<=180?L_.recency*.2:L_.recency*.05}function j8t(t){const s=Math.min(t/12,1);return Math.round(L_.touchpoints*s)}function N8t(t){return t?L_.transactions:0}function k8t(){return 0}function S8t(t){return t>=lLe.warm?"warm":t>=lLe.cooling?"cooling":"at-risk"}function lhe(){const{data:t,isLoading:s}=qh(),{data:r}=wXe(),{data:n}=KR(365),{data:a}=dke(),o=k.useMemo(()=>{if(!t)return[];const i=new Date,d=g4(i,12),u={};n==null||n.forEach(f=>{new Date(f.completed_at)>=d&&(u[f.contact_id]=(u[f.contact_id]||0)+1)});const p=new Set((a==null?void 0:a.filter(f=>f.contact_id).map(f=>f.contact_id))||[]);return t.map(f=>{const y=(r==null?void 0:r[f.id])||null,_=y?$g(i,new Date(y)):null,b=u[f.id]||0,N=p.has(f.id),w=w8t(_),S=j8t(b),C=N8t(N),A=k8t(),I=Math.round(w+S+C+A),L={score:I,status:S8t(I),breakdown:{recency:Math.round(w),touchpoints:Math.round(S),transactions:Math.round(C),referrals:Math.round(A)},lastTouchDate:y,daysSinceTouch:_,touchCountLast12Months:b,hasTransaction:N};return{...f,relationshipScore:L}})},[t,r,n,a]),l=k.useMemo(()=>{const i=o.filter(y=>y.relationshipScore.status==="warm").length,d=o.filter(y=>y.relationshipScore.status==="cooling").length,u=o.filter(y=>y.relationshipScore.status==="at-risk").length,p=o.length,f=p>0?Math.round(o.reduce((y,_)=>y+_.relationshipScore.score,0)/p):0;return{warm:i,cooling:d,atRisk:u,total:p,averageScore:f}},[o]);return{contactsWithScores:o,stats:l,isLoading:s}}function BXe(){const t=wr(),{stats:s,contactsWithScores:r,isLoading:n}=lhe();if(n)return e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(Ms,{className:"h-5 w-40"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(Ms,{className:"h-20 w-full"}),e.jsx(Ms,{className:"h-16 w-full"})]})]});if(s.total===0)return e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(ir,{className:"h-5 w-5"}),"Relationship Health"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add contacts to see your relationship health scores."}),e.jsx(W,{variant:"outline",size:"sm",className:"mt-3",onClick:()=>t("/mission-control/contacts?new=true"),children:"Add Your First Contact"})]})]});const a=Math.round(s.warm/s.total*100),o=Math.round(s.cooling/s.total*100),l=Math.round(s.atRisk/s.total*100),i=r.filter(d=>d.relationshipScore.status==="at-risk").sort((d,u)=>d.relationshipScore.score-u.relationshipScore.score).slice(0,3);return e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Qo,{className:"h-5 w-5 text-emerald-500"}),"Relationship Health"]}),e.jsx("span",{className:"text-2xl font-bold",children:s.averageScore})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Average score across ",s.total," contacts"]})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-emerald-500"}),e.jsx("span",{children:"Warm"})]}),e.jsxs("span",{className:"font-medium",children:[s.warm," (",a,"%)"]})]}),e.jsx(xi,{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(xi,{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(xi,{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(bS,{className:"h-4 w-4 text-red-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Needs Attention"})]}),e.jsx("div",{className:"space-y-2",children:i.map(d=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-red-500/5 hover:bg-red-500/10 cursor-pointer transition-colors",onClick:()=>t(`/mission-control/contacts/${d.id}`),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-red-500"}),e.jsxs("span",{className:"text-sm",children:[d.first_name," ",d.last_name]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:d.relationshipScore.daysSinceTouch===null?"Never":`${d.relationshipScore.daysSinceTouch}d`}),e.jsx(xa,{className:"h-3 w-3"})]})]},d.id))})]}),e.jsxs(W,{variant:"outline",size:"sm",className:"w-full",onClick:()=>t("/mission-control/contacts?filter=at-risk"),children:["View All At-Risk Contacts",e.jsx(xa,{className:"h-4 w-4 ml-1"})]})]})]})}const C8t=()=>{var ie;const{user:t,isAdmin:s}=Us(),r=wr(),[n,a]=k.useState([]),[o,l]=k.useState([]),[i,d]=k.useState([]),[u,p]=k.useState([]),[f,y]=k.useState([]),[_,b]=k.useState([]),[N,w]=k.useState(new Set),[S,C]=k.useState([]),[A,I]=k.useState([]),[L,O]=k.useState([]),[V,q]=k.useState(null),[B,U]=k.useState(!0);k.useEffect(()=>{te()},[t]);const te=async()=>{var ae,oe,me,ve,he;try{const[ge,je,qe,Me,ke,Re,Ve,Ne,Ue,Ie,ye]=await Promise.all([G.from("user_tags").select("tag").eq("user_id",t==null?void 0:t.id),G.from("app_tiles").select("*").order("name"),G.from("user_favorites").select("app_id").eq("user_id",t==null?void 0:t.id),G.from("events").select("*").order("event_date",{ascending:!0}),G.from("event_registrations").select("event_id, zoom_join_url").eq("user_id",t==null?void 0:t.id),G.from("canva_templates").select("id, name, preview_image_url, publish_date").order("publish_date",{ascending:!1}).limit(4),G.from("resource_kits").select("id, name, description, featured_image_url, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),G.from("academy_videos").select("id, title, description, thumbnail_url, duration, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),G.from("additional_services").select("id, name, description, preview_image_url, signup_link_url, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),G.from("dashboard_banners").select("id, title, description, image_url, link_url, link_text, placement, section_after").eq("is_active",!0).order("sort_order"),G.from("profiles").select("name").eq("id",t==null?void 0:t.id).single()]);(ae=ye.data)!=null&&ae.name&&q(ye.data.name);const ct=((oe=ge.data)==null?void 0:oe.map(We=>We.tag))||[],fe=new Set(((me=qe.data)==null?void 0:me.map(We=>We.app_id))||[]);w(fe);const Ye=(((ve=je.data)==null?void 0:ve.filter(We=>!We.required_tags||We.required_tags.length===0?!0:We.required_tags.some(Ke=>ct.includes(Ke))))||[]).sort((We,Ke)=>We.name==="LevelUp Members Portal"?-1:Ke.name==="LevelUp Members Portal"?1:0);a(Ye.slice(0,6));const tt=((he=Me.data)==null?void 0:he.filter(We=>WM(We.event_date)!=="ended"))||[];l(tt.slice(0,4)),C(ke.data||[]),d(Re.data||[]),p(Ve.data||[]),y(Ne.data||[]),b(Ue.data||[]);const Te=Ie.data||[];I(Te.filter(We=>We.placement==="top")),O(Te.filter(We=>We.placement==="between"))}catch(ge){console.error("Error loading dashboard:",ge),pe.error("Failed to load dashboard data")}finally{U(!1)}},Y=async ae=>{var me;const oe=window.open("about:blank","_blank");try{await G.from("activity_logs").insert({user_id:t==null?void 0:t.id,app_id:ae.app_id,app_name:ae.name,user_agent:navigator.userAgent});const{data:ve,error:he}=await G.functions.invoke("sso-launch",{body:{app_id:ae.app_id}});if(he)throw he;ve!=null&&ve.redirect_url?oe&&!oe.closed?(oe.location.href=ve.redirect_url,(me=oe.focus)==null||me.call(oe)):window.location.assign(ve.redirect_url):(oe==null||oe.close(),pe.error("Launch link unavailable"))}catch(ve){oe==null||oe.close(),console.error("Error launching app:",ve),pe.error("Failed to launch app")}},J=ae=>S==null?void 0:S.some(oe=>oe.event_id===ae),X=ae=>{const oe=S==null?void 0:S.find(me=>me.event_id===ae);return oe==null?void 0:oe.zoom_join_url};if(B)return e.jsx(Ds,{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=ae=>L.filter(oe=>oe.section_after===ae);return e.jsxs(Ds,{title:"Dashboard",children:[e.jsx(lLt,{events:o,registrations:S,onNavigateToEvents:()=>r("/events")}),A.length>0&&e.jsx("div",{className:"mb-8",children:e.jsx(iI,{banners:A})}),e.jsx(vLt,{}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("h2",{className:"text-2xl font-bold text-foreground",children:["Welcome back, ",(V||((ie=t==null?void 0:t.user_metadata)==null?void 0:ie.name)||"there").split(" ")[0],"!"]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Are you ready to LevelUp today?"})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4 mb-8",children:[e.jsx(LLt,{}),e.jsx(BXe,{}),e.jsx(p8t,{})]}),e.jsx(KLt,{}),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(W,{variant:"ghost",size:"sm",onClick:()=>r("/events"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Wa,{className:"h-4 w-4"})]})]}),o.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(cn,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No upcoming events"})]})})}):e.jsx("div",{className:"bg-card rounded-xl border border-border overflow-hidden divide-y divide-border max-w-full",children:o.map(ae=>{const oe=J(ae.id),me=X(ae.id)||ae.zoom_link;return e.jsxs("div",{className:`flex items-start gap-3 sm:gap-4 p-3 sm:p-4 hover:bg-muted/50 transition-colors cursor-pointer group ${nLe(ae.event_date)?"bg-red-500/5 border-l-2 border-l-red-500":""}`,onClick:()=>r("/events"),children:[nLe(ae.event_date)?e.jsxs("div",{className:"flex-shrink-0 w-12 h-12 sm:w-14 sm:h-14 rounded-lg bg-red-500/10 flex flex-col items-center justify-center relative",children:[e.jsx("span",{className:"absolute inline-flex h-3 w-3 top-1 right-1 animate-ping rounded-full bg-red-500 opacity-75"}),e.jsx(e1,{className:"h-5 w-5 text-red-500"}),e.jsx("span",{className:"text-[10px] font-bold text-red-500 uppercase mt-0.5",children:"Live"})]}):e.jsxs("div",{className:"flex-shrink-0 w-12 h-12 sm:w-14 sm:h-14 rounded-lg bg-primary/10 flex flex-col items-center justify-center",children:[e.jsx("span",{className:"text-[10px] sm:text-xs font-medium text-primary uppercase",children:new Intl.DateTimeFormat("en-US",{month:"short",timeZone:"America/New_York"}).format(new Date(ae.event_date))}),e.jsx("span",{className:"text-lg sm:text-xl font-bold text-primary",children:new Intl.DateTimeFormat("en-US",{day:"numeric",timeZone:"America/New_York"}).format(new Date(ae.event_date))})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-medium text-sm sm:text-base text-foreground group-hover:text-primary transition-colors line-clamp-2 sm:truncate",children:ae.title}),e.jsxs("p",{className:"text-xs sm:text-sm text-muted-foreground mt-0.5",children:[new Intl.DateTimeFormat("en-US",{weekday:"long",timeZone:"America/New_York"}).format(new Date(ae.event_date))," at ",uD(new Date(ae.event_date))]})]}),e.jsx("div",{className:"hidden sm:flex flex-shrink-0",children:oe?e.jsxs(W,{size:"sm",variant:"default",className:"gap-1",onClick:ve=>{ve.stopPropagation(),window.open(me,"_blank")},children:[e.jsx(Yr,{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(xa,{className:"h-4 w-4"})]})})]},ae.id)})})]}),ce("events").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(iI,{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(W,{variant:"ghost",size:"sm",onClick:()=>r("/academy"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Wa,{className:"h-4 w-4"})]})]}),f.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(rp,{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(ae=>e.jsxs("div",{onClick:()=>r(`/academy/${ae.id}`),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsxs("div",{className:"aspect-[3/2] bg-muted/50 overflow-hidden relative",children:[ae.thumbnail_url?e.jsx("img",{src:ae.thumbnail_url,alt:ae.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(rp,{className:"h-8 w-8 text-muted-foreground/50"})}),ae.duration&&e.jsx("span",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-1.5 py-0.5 rounded",children:ae.duration})]}),e.jsx("div",{className:"p-3",children:e.jsx("h4",{className:"font-medium text-sm text-foreground line-clamp-2 group-hover:text-primary transition-colors",children:ae.title})})]},ae.id))})]}),ce("academy").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(iI,{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(W,{variant:"ghost",size:"sm",onClick:()=>r("/toolbox"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Wa,{className:"h-4 w-4"})]})]}),u.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Mm,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No resource kits available"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:u.map(ae=>e.jsxs("div",{onClick:()=>r(`/toolbox/${ae.id}`),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsx("div",{className:"aspect-[3/2] bg-muted/50 overflow-hidden",children:ae.featured_image_url?e.jsx("img",{src:ae.featured_image_url,alt:ae.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Mm,{className:"h-8 w-8 text-muted-foreground/50"})})}),e.jsx("div",{className:"p-3",children:e.jsx("h4",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:ae.name})})]},ae.id))})]}),ce("toolbox").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(iI,{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(W,{variant:"ghost",size:"sm",onClick:()=>r("/templates"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Wa,{className:"h-4 w-4"})]})]}),i.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(kb,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No templates available"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:i.map(ae=>e.jsxs("div",{onClick:()=>r("/templates"),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsx("div",{className:"aspect-[3/2] bg-muted/50 overflow-hidden",children:ae.preview_image_url?e.jsx("img",{src:ae.preview_image_url,alt:ae.name,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(kb,{className:"h-8 w-8 text-muted-foreground/50"})})}),e.jsx("div",{className:"p-3",children:e.jsx("h4",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:ae.name})})]},ae.id))})]}),ce("templates").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(iI,{banners:ce("templates")})}),e.jsx("div",{className:"mb-10",children:e.jsx(m8t,{})}),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(W,{variant:"ghost",size:"sm",onClick:()=>r("/apps"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Wa,{className:"h-4 w-4"})]})]}),n.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx(fx,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No apps available"})]})})}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:n.map(ae=>{const oe=N.has(ae.id);return e.jsxs("div",{onClick:()=>Y(ae),className:"group flex items-start gap-4 p-5 bg-card rounded-xl border border-border cursor-pointer transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsx("div",{className:"flex-shrink-0 w-14 h-14 rounded-xl bg-primary/10 flex items-center justify-center text-3xl",children:ae.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold text-foreground group-hover:text-primary transition-colors truncate",children:ae.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:ae.description})]}),oe&&e.jsx(fx,{className:"h-5 w-5 text-primary fill-current flex-shrink-0"})]},ae.id)})})]}),e.jsxs("section",{className:"mt-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Additional Services"}),e.jsxs(W,{variant:"ghost",size:"sm",onClick:()=>r("/additional-services"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Wa,{className:"h-4 w-4"})]})]}),_.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Or,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No additional services available"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:_.map(ae=>e.jsxs("div",{onClick:()=>window.open(ae.signup_link_url,"_blank"),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsx("div",{className:"aspect-[4/3] bg-muted/50 overflow-hidden",children:ae.preview_image_url?e.jsx("img",{src:ae.preview_image_url,alt:ae.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Or,{className:"h-8 w-8 text-muted-foreground/50"})})}),e.jsxs("div",{className:"p-3",children:[e.jsx("h4",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:ae.name}),ae.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:ae.description})]})]},ae.id))})]})]})};var $Xe="AlertDialog",[M8t,fAs]=qc($Xe,[uGe]),C1=uGe(),qXe=t=>{const{__scopeAlertDialog:s,...r}=t,n=C1(s);return e.jsx(jue,{...n,...r,modal:!0})};qXe.displayName=$Xe;var T8t="AlertDialogTrigger",UXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=C1(r);return e.jsx(Vje,{...a,...n,ref:s})});UXe.displayName=T8t;var A8t="AlertDialogPortal",VXe=t=>{const{__scopeAlertDialog:s,...r}=t,n=C1(s);return e.jsx(Nue,{...n,...r})};VXe.displayName=A8t;var E8t="AlertDialogOverlay",HXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=C1(r);return e.jsx(UA,{...a,...n,ref:s})});HXe.displayName=E8t;var KM="AlertDialogContent",[P8t,I8t]=M8t(KM),L8t=Pqe("AlertDialogContent"),GXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,children:n,...a}=t,o=C1(r),l=k.useRef(null),i=Ta(s,l),d=k.useRef(null);return e.jsx(jNt,{contentName:KM,titleName:WXe,docsSlug:"alert-dialog",children:e.jsx(P8t,{scope:r,cancelRef:d,children:e.jsxs(VA,{role:"alertdialog",...o,...a,ref:i,onOpenAutoFocus:Mr(a.onOpenAutoFocus,u=>{var p;u.preventDefault(),(p=d.current)==null||p.focus({preventScroll:!0})}),onPointerDownOutside:u=>u.preventDefault(),onInteractOutside:u=>u.preventDefault(),children:[e.jsx(L8t,{children:n}),e.jsx(R8t,{contentRef:l})]})})})});GXe.displayName=KM;var WXe="AlertDialogTitle",KXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=C1(r);return e.jsx(RR,{...a,...n,ref:s})});KXe.displayName=WXe;var ZXe="AlertDialogDescription",YXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=C1(r);return e.jsx(OR,{...a,...n,ref:s})});YXe.displayName=ZXe;var D8t="AlertDialogAction",XXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=C1(r);return e.jsx(FR,{...a,...n,ref:s})});XXe.displayName=D8t;var QXe="AlertDialogCancel",JXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,{cancelRef:a}=I8t(QXe,r),o=C1(r),l=Ta(s,a);return e.jsx(FR,{...o,...n,ref:l})});JXe.displayName=QXe;var R8t=({contentRef:t})=>{const s=`\`${KM}\` requires a description for the component to be accessible for screen reader users. You can add a description to the \`${KM}\` by passing a \`${ZXe}\` 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 \`${KM}\`. 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},O8t=qXe,F8t=UXe,z8t=VXe,eQe=HXe,tQe=GXe,sQe=XXe,rQe=JXe,nQe=KXe,aQe=YXe;const Rl=O8t,_m=F8t,B8t=z8t,iQe=k.forwardRef(({className:t,...s},r)=>e.jsx(eQe,{className:Ot("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}));iQe.displayName=eQe.displayName;const gl=k.forwardRef(({className:t,...s},r)=>e.jsxs(B8t,{children:[e.jsx(iQe,{}),e.jsx(tQe,{ref:r,className:Ot("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})]}));gl.displayName=tQe.displayName;const yl=({className:t,...s})=>e.jsx("div",{className:Ot("flex flex-col space-y-2 text-center sm:text-left",t),...s});yl.displayName="AlertDialogHeader";const vl=({className:t,...s})=>e.jsx("div",{className:Ot("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});vl.displayName="AlertDialogFooter";const _l=k.forwardRef(({className:t,...s},r)=>e.jsx(nQe,{ref:r,className:Ot("text-lg font-semibold",t),...s}));_l.displayName=nQe.displayName;const bl=k.forwardRef(({className:t,...s},r)=>e.jsx(aQe,{ref:r,className:Ot("text-sm text-muted-foreground",t),...s}));bl.displayName=aQe.displayName;const ll=k.forwardRef(({className:t,...s},r)=>e.jsx(sQe,{ref:r,className:Ot(TT(),t),...s}));ll.displayName=sQe.displayName;const wl=k.forwardRef(({className:t,...s},r)=>e.jsx(rQe,{ref:r,className:Ot(TT({variant:"outline"}),"mt-2 sm:mt-0",t),...s}));wl.displayName=rQe.displayName;const $8t=[{key:"contacts",label:"Contacts",icon:In,description:"View, add, and edit contacts"},{key:"pipeline",label:"Deal Pipeline",icon:aS,description:"View, add, and move deals"},{key:"client_portal",label:"Client Portals",icon:Mm,description:"Manage client portals on deals"},{key:"videos",label:"Videos",icon:yn,description:"View and upload videos"},{key:"listings",label:"Listings",icon:Mn,description:"View, create, and edit listings"},{key:"scorecard",label:"Scorecard",icon:Nb,description:"View and add transactions"},{key:"popbys",label:"Pop-bys",icon:Ia,description:"View and log pop-bys"},{key:"digital_card",label:"Digital Card",icon:yx,description:"Create and edit digital business card"},{key:"guest_book",label:"Guest Book",icon:ch,description:"Manage open house guest books"},{key:"presentations",label:"Presentations",icon:Pg,description:"Create and manage smart presentations"}];function q8t(){var V;const{user:t}=Us(),[s,r]=k.useState([]),[n,a]=k.useState(!0),[o,l]=k.useState(!1),[i,d]=k.useState(!1),[u,p]=k.useState(null),[f,y]=k.useState({email:"",name:"",password:""}),[_,b]=k.useState("create"),[N,w]=k.useState(!1),[S,C]=k.useState(null);k.useEffect(()=>{t&&A()},[t]);const A=async()=>{if(t){a(!0);try{const{data:q,error:B}=await G.from("agent_assistant_assignments").select("id, assistant_id, permissions, created_at").eq("agent_id",t.id);if(B)throw B;if(q&&q.length>0){const U=q.map(J=>J.assistant_id),{data:te}=await G.from("profiles").select("id, name, email").in("id",U),Y=q.map(J=>{const X=te==null?void 0:te.find(ce=>ce.id===J.assistant_id);return{...J,permissions:J.permissions,assistant_profile:X?{name:X.name||"",email:X.email||""}:void 0}});r(Y)}else r([])}catch(q){console.error("Error loading assistants:",q)}finally{a(!1)}}},I=async()=>{if(t){if(_==="link"){if(!f.email.trim()){pe.error("Please enter the assistant's email");return}w(!0);try{const{data:{session:q}}=await G.auth.getSession();if(!q)throw new Error("Not authenticated");const{data:B,error:U}=await G.from("profiles").select("id, name, email").eq("email",f.email.trim().toLowerCase()).single();if(U||!B){pe.error("No account found with that email. Try creating a new assistant instead.");return}const{data:te}=await G.from("agent_assistant_assignments").select("id").eq("agent_id",t.id).eq("assistant_id",B.id);if(te&&te.length>0){pe.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 ${q.access_token}`},body:JSON.stringify({userId:B.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:X}=await G.from("agent_assistant_assignments").insert({agent_id:t.id,assistant_id:B.id,permissions:{contacts:!0,pipeline:!0,videos:!1,listings:!1,scorecard:!1,popbys:!1,digital_card:!1,client_portal:!1,guest_book:!1,presentations:!1}});if(X)throw X;pe.success(`${B.name||B.email} linked as your assistant`),l(!1),y({email:"",name:"",password:""}),A()}catch(q){console.error("Error linking assistant:",q),pe.error(q.message||"Failed to link assistant")}finally{w(!1)}return}if(!f.email.trim()||!f.name.trim()||!f.password.trim()){pe.error("Please fill in all fields");return}if(f.password.length<6){pe.error("Password must be at least 6 characters");return}w(!0);try{const{data:{session:q}}=await G.auth.getSession();if(!q)throw new Error("Not authenticated");const B=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${q.access_token}`},body:JSON.stringify({email:f.email.trim(),password:f.password,name:f.name.trim(),purpose:"assistant"})}),U=await B.json();if(!B.ok)throw new Error(U.error||"Failed to create assistant account");const te=U.userId||U.id;if(!te)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 ${q.access_token}`},body:JSON.stringify({userId:te,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:X}=await G.from("agent_assistant_assignments").insert({agent_id:t.id,assistant_id:te,permissions:{contacts:!0,pipeline:!0,videos:!1,listings:!1,scorecard:!1,popbys:!1,digital_card:!1,client_portal:!1,guest_book:!1,presentations:!1}});if(X)throw X;pe.success(`Assistant account created for ${f.name.trim()}`),l(!1),y({email:"",name:"",password:""}),A()}catch(q){console.error("Error adding assistant:",q),pe.error(q.message||"Failed to add assistant")}finally{w(!1)}}},L=async()=>{if(!(!u||!t))try{const{data:{session:q}}=await G.auth.getSession();if(!q)throw new Error("Not authenticated");const{error:B}=await G.from("agent_assistant_assignments").delete().eq("id",u.id);if(B)throw B;const{data:U}=await G.from("agent_assistant_assignments").select("id").eq("assistant_id",u.assistant_id);(!U||U.length===0)&&await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${q.access_token}`},body:JSON.stringify({userId:u.assistant_id,role:"assistant",action:"remove"})}),pe.success("Assistant removed"),d(!1),p(null),A()}catch(q){console.error("Error removing assistant:",q),pe.error(q.message||"Failed to remove assistant")}},O=async(q,B,U)=>{C(q);try{const te=s.find(X=>X.id===q);if(!te)return;const Y={...te.permissions,[B]:U},{error:J}=await G.from("agent_assistant_assignments").update({permissions:Y}).eq("id",q);if(J)throw J;r(X=>X.map(ce=>ce.id===q?{...ce,permissions:Y}:ce))}catch(te){console.error("Error updating permissions:",te),pe.error("Failed to update permissions")}finally{C(null)}};return n?e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(ir,{className:"h-5 w-5"}),"My Assistants"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(us,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(ir,{className:"h-5 w-5"}),"My Assistants"]}),e.jsx(dr,{children:"Add assistants to help manage your Agent OS"})]}),e.jsxs(W,{size:"sm",onClick:()=>{b("create"),l(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Assistant"]})]})}),e.jsx(Oe,{children:s.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No assistant assigned. Add one to help manage your contacts, deals, and more."}):e.jsx("div",{className:"space-y-4",children:s.map(q=>{var B,U,te,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(Nn,{className:"h-10 w-10",children:e.jsx(kn,{children:((U=(B=q.assistant_profile)==null?void 0:B.name)==null?void 0:U.split(" ").map(J=>J[0]).join("").toUpperCase())||"A"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((te=q.assistant_profile)==null?void 0:te.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((Y=q.assistant_profile)==null?void 0:Y.email)||""})]}),e.jsxs(Qe,{variant:"secondary",className:"ml-2",children:[e.jsx(zu,{className:"h-3 w-3 mr-1"}),"Assistant"]})]}),e.jsx(W,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>{p(q),d(!0)},children:e.jsx(vr,{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:$8t.map(J=>{const X=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(X,{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(Ar,{checked:q.permissions[J.key]||!1,onCheckedChange:ce=>O(q.id,J.key,ce),disabled:S===q.id})]},J.key)})})]})]},q.id)})})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Add Assistant"}),e.jsx(Ir,{children:_==="create"?"Create a new account for your assistant.":"Link an existing assistant account by their email."})]}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsxs(W,{variant:_==="create"?"default":"outline",size:"sm",onClick:()=>b("create"),children:[e.jsx(qs,{className:"h-3 w-3 mr-1"}),"Create New"]}),e.jsxs(W,{variant:_==="link"?"default":"outline",size:"sm",onClick:()=>b("link"),children:[e.jsx(vo,{className:"h-3 w-3 mr-1"}),"Link Existing"]})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[_==="create"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"assistant-name",children:"Name"}),e.jsx(De,{id:"assistant-name",value:f.name,onChange:q=>y({...f,name:q.target.value}),placeholder:"Assistant's full name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"assistant-email",children:"Email"}),e.jsx(De,{id:"assistant-email",type:"email",value:f.email,onChange:q=>y({...f,email:q.target.value}),placeholder:"assistant@email.com"})]}),_==="create"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"assistant-password",children:"Temporary Password"}),e.jsx(De,{id:"assistant-password",type:"password",value:f.password,onChange:q=>y({...f,password:q.target.value}),placeholder:"Min 6 characters"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your assistant can change this after their first login."})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(W,{onClick:I,disabled:N,children:[N&&e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),_==="create"?"Create Assistant":"Link Assistant"]})]})]})}),e.jsx(Rl,{open:i,onOpenChange:d,children:e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Remove Assistant?"}),e.jsxs(bl,{children:["This will remove ",(V=u==null?void 0:u.assistant_profile)==null?void 0:V.name,"'s access to your Agent OS. Their account will remain active but they won't be able to manage your data."]})]}),e.jsxs(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:L,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})})]})}function th(t){this.content=t}th.prototype={constructor:th,find:function(t){for(var s=0;s>1}};th.from=function(t){if(t instanceof th)return t;var s=[];if(t)for(var r in t)s.push(r,t[r]);return new th(s)};function oQe(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=oQe(a.content,o.content,r+1);if(l!=null)return l}r+=a.nodeSize}}function lQe(t,s,r,n){for(let a=t.childCount,o=s.childCount;;){if(a==0||o==0)return a==o?null:{a:r,b:n};let l=t.child(--a),i=s.child(--o),d=l.nodeSize;if(l==i){r-=d,n-=d;continue}if(!l.sameMarkup(i))return{a:r,b:n};if(l.isText&&l.text!=i.text){let u=0,p=Math.min(l.text.length,i.text.length);for(;us&&n(d,a+i,o||null,l)!==!1&&d.content.size){let p=i+1;d.nodesBetween(Math.max(0,s-p),Math.min(d.content.size,r-p),n,a+p)}i=u}}descendants(s){this.nodesBetween(0,this.size,s)}textBetween(s,r,n,a){let o="",l=!0;return this.nodesBetween(s,r,(i,d)=>{let u=i.isText?i.text.slice(Math.max(s,d)-d,r-d):i.isLeaf?a?typeof a=="function"?a(i):a:i.type.spec.leafText?i.type.spec.leafText(i):"":"";i.isBlock&&(i.isLeaf&&u||i.isTextblock)&&n&&(l?l=!1:o+=n),o+=u},0),o}append(s){if(!s.size)return this;if(!this.size)return s;let r=this.lastChild,n=s.firstChild,a=this.content.slice(),o=0;for(r.isText&&r.sameMarkup(n)&&(a[a.length-1]=r.withText(r.text+n.text),o=1);os)for(let o=0,l=0;ls&&((lr)&&(i.isText?i=i.cut(Math.max(0,s-l),Math.min(i.text.length,r-l)):i=i.cut(Math.max(0,s-l-1),Math.min(i.content.size,r-l-1))),n.push(i),a+=i.nodeSize),l=d}return new Tr(n,a)}cutByIndex(s,r){return s==r?Tr.empty:s==0&&r==this.content.length?this:new Tr(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 Tr(a,o)}addToStart(s){return new Tr([s].concat(this.content),this.size+s.nodeSize)}addToEnd(s){return new Tr(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?Rz(r+1,o):Rz(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 Tr.empty;if(!Array.isArray(r))throw new RangeError("Invalid input for Fragment.fromJSON");return new Tr(r.map(s.nodeFromJSON))}static fromArray(s){if(!s.length)return Tr.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}};fl.none=[];class kle extends Error{}class wn{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=dQe(this.content,s+this.openStart,r);return n&&new wn(n,this.openStart,this.openEnd)}removeBetween(s,r){return new wn(cQe(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 wn.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 wn(Tr.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 wn(s,n,a)}}wn.empty=new wn(Tr.empty,0,0);function cQe(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(cQe(o.content,s-a-1,r-a-1)))}function dQe(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=dQe(l.content,s-o-1,r,l);return i&&t.replaceChild(a,l.copy(i))}function U8t(t,s,r){if(r.openStart>t.depth)throw new kle("Inserted content deeper than insertion position");if(t.depth-r.openStart!=s.depth-r.openEnd)throw new kle("Inconsistent open depths");return uQe(t,s,r,0)}function uQe(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 o8(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&&(SS(t.nodeAfter,n),o++));for(let i=o;ia&&d_e(t,s,a+1),l=n.depth>a&&d_e(r,n,a+1),i=[];return o8(null,t,a,i),o&&l&&s.index(a)==r.index(a)?(hQe(o,l),SS(CS(o,mQe(t,s,r,n,a+1)),i)):(o&&SS(CS(o,Sle(t,s,a+1)),i),o8(s,r,a,i),l&&SS(CS(l,Sle(r,n,a+1)),i)),o8(n,null,a,i),new Tr(i)}function Sle(t,s,r){let n=[];if(o8(null,t,r,n),t.depth>r){let a=d_e(t,s,r+1);SS(CS(a,Sle(t,s,r+1)),n)}return o8(s,null,r,n),new Tr(n)}function V8t(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(Tr.from(a));return{start:a.resolveNoCache(t.openStart+r),end:a.resolveNoCache(a.content.size-t.openEnd-r)}}class hD{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 Cle(this,s,n);return null}sameParent(s){return this.pos-this.parentOffset==s.pos-s.parentOffset}max(s){return s.pos>this.pos?s:this}min(s){return s.pos=0&&r<=s.content.size))throw new RangeError("Position "+r+" out of range");let n=[],a=0,o=r;for(let l=s;;){let{index:i,offset:d}=l.content.findIndex(o),u=o-d;if(n.push(l,i,a+d),!u||(l=l.child(i),l.isText))break;o=u-1,a+=d+1}return new hD(r,n,o)}static resolveCached(s,r){let n=cLe.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()+")"),pQe(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=Tr.empty,a=0,o=n.childCount){let l=this.contentMatchAt(s).matchFragment(n,a,o),i=l&&l.matchFragment(this.content,r);if(!i||!i.validEnd)return!1;for(let d=a;dr.type.name)}`);this.content.forEach(r=>r.check())}toJSON(){let s={type:this.type.name};for(let r in this.attrs){s.attrs=this.attrs;break}return this.content.size&&(s.content=this.content.toJSON()),this.marks.length&&(s.marks=this.marks.map(r=>r.toJSON())),s}static fromJSON(s,r){if(!r)throw new RangeError("Invalid input for Node.fromJSON");let n;if(r.marks){if(!Array.isArray(r.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=r.marks.map(s.markFromJSON)}if(r.type=="text"){if(typeof r.text!="string")throw new RangeError("Invalid text node in JSON");return s.text(r.text,n)}let a=Tr.fromJSON(s,r.content),o=s.nodeType(r.type).create(r.attrs,a,n);return o.type.checkAttrs(o.attrs),o}};Rb.prototype.text=void 0;class Mle extends Rb{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):pQe(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 pQe(t,s){for(let r=t.length-1;r>=0;r--)s=t[r].type.name+"("+s+")";return s}class JS{constructor(s){this.validEnd=s,this.next=[],this.wrapCache=[]}static parse(s,r){let n=new K8t(s,r);if(n.next==null)return JS.empty;let a=fQe(n);n.next&&n.err("Unexpected trailing text");let o=tDt(eDt(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(` `)}}JS.empty=new JS(!0);class K8t{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 fQe(t){let s=[];do s.push(Z8t(t));while(t.eat("|"));return s.length==1?s[0]:{type:"choice",exprs:s}}function Z8t(t){let s=[];do s.push(Y8t(t));while(t.next&&t.next!=")"&&t.next!="|");return s.length==1?s[0]:{type:"seq",exprs:s}}function Y8t(t){let s=J8t(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=X8t(t,s);else break;return s}function dLe(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let s=Number(t.next);return t.pos++,s}function X8t(t,s){let r=dLe(t),n=r;return t.eat(",")&&(t.next!="}"?n=dLe(t):n=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:n,expr:s}}function Q8t(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 J8t(t){if(t.eat("(")){let s=fQe(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=Q8t(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 eDt(t){let s=[[]];return a(o(t,0),r()),s;function r(){return s.push([])-1}function n(l,i,d){let u={term:d,to:i};return s[l].push(u),u}function a(l,i){l.forEach(d=>d.to=i)}function o(l,i){if(l.type=="choice")return l.exprs.reduce((d,u)=>d.concat(o(u,i)),[]);if(l.type=="seq")for(let d=0;;d++){let u=o(l.exprs[d],i);if(d==l.exprs.length-1)return u;a(u,i=r())}else if(l.type=="star"){let d=r();return n(i,d),a(o(l.expr,d),d),[n(d)]}else if(l.type=="plus"){let d=r();return a(o(l.expr,i),d),a(o(l.expr,d),d),[n(d)]}else{if(l.type=="opt")return[n(i)].concat(o(l.expr,i));if(l.type=="range"){let d=i;for(let u=0;u{t[l].forEach(({term:i,to:d})=>{if(!i)return;let u;for(let p=0;p{u||a.push([i,u=[]]),u.indexOf(p)==-1&&u.push(p)})})});let o=s[n.join(",")]=new JS(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:yQe(this.attrs,s)}create(s=null,r,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Rb(this,this.computeAttrs(s),Tr.from(r),fl.setFrom(n))}createChecked(s=null,r,n){return r=Tr.from(r),this.checkContent(r),new Rb(this,this.computeAttrs(s),r,fl.setFrom(n))}createAndFill(s=null,r,n){if(s=this.computeAttrs(s),r=Tr.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(Tr.empty,!0);return o?new Rb(this,s,r.append(o),fl.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 bQe(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 rDt(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 nDt{constructor(s,r,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?rDt(s,r,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class che{constructor(s,r,n,a){this.name=s,this.rank=r,this.schema=n,this.spec=a,this.attrs=_Qe(s,a.attrs),this.excluded=null;let o=gQe(this.attrs);this.instance=o?new fl(this,o):null}create(s=null){return!s&&this.instance?this.instance:new fl(this,yQe(this.attrs,s))}static compile(s,r){let n=Object.create(null),a=0;return s.forEach((o,l)=>n[o]=new che(o,a++,r,l)),n}removeFromSet(s){for(var r=0;r-1}}class wQe{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=th.from(s.nodes),r.marks=th.from(s.marks||{}),this.nodes=hLe.compile(this.spec.nodes,this),this.marks=che.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]=JS.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?mLe(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==""?[]:mLe(this,l.split(" "))}this.nodeFromJSON=a=>Rb.fromJSON(this,a),this.markFromJSON=a=>fl.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 hLe){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,fl.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 mLe(t,s){let r=[];for(let n=0;n-1)&&r.push(l=d)}if(!l)throw new SyntaxError("Unknown mark type: '"+s[n]+"'")}return r}function aDt(t){return t.tag!=null}function iDt(t){return t.style!=null}let l8=class h_e{constructor(s,r){this.schema=s,this.rules=r,this.tags=[],this.styles=[];let n=this.matchedStyles=[];r.forEach(a=>{if(aDt(a))this.tags.push(a);else if(iDt(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 fLe(this,r,!1);return n.addAll(s,fl.none,r.from,r.to),n.finish()}parseSlice(s,r={}){let n=new fLe(this,r,!0);return n.addAll(s,fl.none,r.from,r.to),wn.maxOpen(n.finish())}matchTag(s,r,n){for(let a=n?this.tags.indexOf(n)+1:0;as.length&&(i.charCodeAt(s.length)!=61||i.slice(s.length+1)!=r))){if(l.getAttrs){let d=l.getAttrs(r);if(d===!1)continue;l.attrs=d||void 0}return l}}}static schemaRules(s){let r=[];function n(a){let o=a.priority==null?50:a.priority,l=0;for(;l{n(l=xLe(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=xLe(l)),l.node||l.ignore||l.mark||(l.node=a)})}return r}static fromSchema(s){return s.cached.domParser||(s.cached.domParser=new h_e(s,h_e.schemaRules(s)))}};const jQe={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},oDt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},NQe={ol:!0,ul:!0},mD=1,m_e=2,c8=4;function pLe(t,s,r){return s!=null?(s?mD:0)|(s==="full"?m_e:0):t&&t.whitespace=="pre"?mD|m_e:r&~c8}class Oz{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=fl.none,this.match=o||(l&c8?null:s.contentMatch)}findWrapping(s){if(!this.match){if(!this.type)return[];let r=this.type.contentMatch.fillBefore(Tr.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&mD)){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=Tr.from(this.content);return!s&&this.match&&(r=r.append(this.match.fillBefore(Tr.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&&!jQe.hasOwnProperty(s.parentNode.nodeName.toLowerCase())}}class fLe{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=pLe(null,r.preserveWhitespace,0)|(n?c8:0);a?o=new Oz(a.type,a.attrs,fl.none,!0,r.topMatch||a.type.contentMatch,l):n?o=new Oz(null,null,fl.none,!0,null,l):o=new Oz(s.schema.topNodeType,null,fl.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&m_e?"full":this.localPreserveWS||(a.options&mD)>0,{schema:l}=this.parser;if(o==="full"||a.inlineContext(s)||/[^ \t\r\n\u000c]/.test(n)){if(o)if(o==="full")n=n.replace(/\r\n?/g,` `);else if(l.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(l.linebreakReplacement.create())){let i=n.split(/\r?\n|\r/);for(let d=0;d!d.clearMark(u)):r=r.concat(this.parser.schema.marks[d.mark].create(d.attrs)),d.consuming===!1)i=d;else break}}return r}addElementByRule(s,r,n,a){let o,l;if(r.node)if(l=this.parser.schema.nodes[r.node],l.isLeaf)this.insertNode(l.create(r.attrs),n,s.nodeName=="BR")||this.leafFallback(s,n);else{let d=this.enter(l,r.attrs||null,n,r.preserveWhitespace);d&&(o=!0,n=d)}else{let d=this.parser.schema.marks[r.mark];n=n.concat(d.create(r.attrs))}let i=this.top;if(l&&l.isLeaf)this.findInside(s);else if(a)this.addElement(s,n,a);else if(r.getContent)this.findInside(s),r.getContent(s,this.parser.schema).forEach(d=>this.insertNode(d,n,!1));else{let d=s;typeof r.contentElement=="string"?d=s.querySelector(r.contentElement):typeof r.contentElement=="function"?d=r.contentElement(s):r.contentElement&&(d=r.contentElement),this.findAround(s,d,!0),this.addAll(d,n),this.findAround(s,d,!1)}o&&this.sync(i)&&this.open--}addAll(s,r,n,a){let o=n||0;for(let l=n?s.childNodes[n]:s.firstChild,i=a==null?null:s.childNodes[a];l!=i;l=l.nextSibling,++o)this.findAtPoint(s,o),this.addDOM(l,r);this.findAtPoint(s,o)}findPlace(s,r,n){let a,o;for(let l=this.open,i=0;l>=0;l--){let d=this.nodes[l],u=d.findWrapping(s);if(u&&(!a||a.length>u.length+i)&&(a=u,o=d,!u.length))break;if(d.solid){if(n)break;i+=2}}if(!a)return null;this.sync(o);for(let l=0;l(l.type?l.type.allowsMarkType(u.type):gLe(u.type,s))?(d=u.addToSet(d),!1):!0),this.nodes.push(new Oz(s,r,d,a,null,i)),this.open++,n}closeExtra(s=!1){let r=this.nodes.length-1;if(r>this.open){for(;r>this.open;r--)this.nodes[r-1].content.push(this.nodes[r].finish(s));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(s){for(let r=this.open;r>=0;r--){if(this.nodes[r]==s)return this.open=r,!0;this.localPreserveWS&&(this.nodes[r].options|=mD)}return!1}get currentPos(){this.closeExtra();let s=0;for(let r=this.open;r>=0;r--){let n=this.nodes[r].content;for(let a=n.length-1;a>=0;a--)s+=n[a].nodeSize;r&&s++}return s}findAtPoint(s,r){if(this.find)for(let n=0;n-1)return s.split(/\s*\|\s*/).some(this.matchesContext,this);let r=s.split("/"),n=this.options.context,a=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),o=-(n?n.depth+1:0)+(a?0:1),l=(i,d)=>{for(;i>=0;i--){let u=r[i];if(u==""){if(i==r.length-1||i==0)continue;for(;d>=o;d--)if(l(i-1,d))return!0;return!1}else{let p=d>0||d==0&&a?this.nodes[d].type:n&&d>=o?n.node(d-o).type:null;if(!p||p.name!=u&&!p.isInGroup(u))return!1;d--}}return!0};return l(r.length-1,this.open)}textblockFromContext(){let s=this.options.context;if(s)for(let r=s.depth;r>=0;r--){let n=s.node(r).contentMatchAt(s.indexAfter(r)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let r in this.parser.schema.nodes){let n=this.parser.schema.nodes[r];if(n.isTextblock&&n.defaultAttrs)return n}}}function lDt(t){for(let s=t.firstChild,r=null;s;s=s.nextSibling){let n=s.nodeType==1?s.nodeName.toLowerCase():null;n&&NQe.hasOwnProperty(n)&&r?(r.appendChild(s),s=r):n=="li"?r=s:n&&(r=null)}}function cDt(t,s){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,s)}function xLe(t){let s={};for(let r in t)s[r]=t[r];return s}function gLe(t,s){let r=s.schema.nodes;for(let n in r){let a=r[n];if(!a.allowsMarkType(t))continue;let o=[],l=i=>{o.push(i);for(let d=0;d{if(o.length||l.marks.length){let i=0,d=0;for(;i=0;a--){let o=this.serializeMark(s.marks[a],s.isInline,r);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(s,r,n={}){let a=this.marks[s.type.name];return a&&Jie(Hge(n),a(s,r),null,s.attrs)}static renderSpec(s,r,n=null,a){return Jie(s,r,n,a)}static fromSchema(s){return s.cached.domSerializer||(s.cached.domSerializer=new MC(this.nodesFromSchema(s),this.marksFromSchema(s)))}static nodesFromSchema(s){let r=yLe(s.nodes);return r.text||(r.text=n=>n.text),r}static marksFromSchema(s){return yLe(s.marks)}}function yLe(t){let s={};for(let r in t){let n=t[r].spec.toDOM;n&&(s[r]=n)}return s}function Hge(t){return t.document||window.document}const vLe=new WeakMap;function dDt(t){let s=vLe.get(t);return s===void 0&&vLe.set(t,s=uDt(t)),s}function uDt(t){let s=null;function r(n){if(n&&typeof n=="object")if(Array.isArray(n))if(typeof n[0]=="string")s||(s=[]),s.push(n);else for(let a=0;a-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let l=a.indexOf(" ");l>0&&(r=a.slice(0,l),a=a.slice(l+1));let i,d=r?t.createElementNS(r,a):t.createElement(a),u=s[1],p=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){p=2;for(let f in u)if(u[f]!=null){let y=f.indexOf(" ");y>0?d.setAttributeNS(f.slice(0,y),f.slice(y+1),u[f]):f=="style"&&d.style?d.style.cssText=u[f]:d.setAttribute(f,u[f])}}for(let f=p;fp)throw new RangeError("Content hole must be the only child of its parent node");return{dom:d,contentDOM:d}}else{let{dom:_,contentDOM:b}=Jie(t,y,r,n);if(d.appendChild(_),b){if(i)throw new RangeError("Multiple content holes");i=b}}}return{dom:d,contentDOM:i}}const kQe=65535,SQe=Math.pow(2,16);function hDt(t,s){return t+s*SQe}function _Le(t){return t&kQe}function mDt(t){return(t-(t&kQe))/SQe}const CQe=1,MQe=2,eoe=4,TQe=8;class p_e{constructor(s,r,n){this.pos=s,this.delInfo=r,this.recover=n}get deleted(){return(this.delInfo&TQe)>0}get deletedBefore(){return(this.delInfo&(CQe|eoe))>0}get deletedAfter(){return(this.delInfo&(MQe|eoe))>0}get deletedAcross(){return(this.delInfo&eoe)>0}}class Qp{constructor(s,r=!1){if(this.ranges=s,this.inverted=r,!s.length&&Qp.empty)return Qp.empty}recover(s){let r=0,n=_Le(s);if(!this.inverted)for(let a=0;as)break;let u=this.ranges[i+o],p=this.ranges[i+l],f=d+u;if(s<=f){let y=u?s==d?-1:s==f?1:r:r,_=d+a+(y<0?0:p);if(n)return _;let b=s==(r<0?d:f)?null:hDt(i/3,s-d),N=s==d?MQe:s==f?CQe:eoe;return(r<0?s!=d:s!=f)&&(N|=TQe),new p_e(_,N,b)}a+=p-u}return n?s+a:new p_e(s+a,0,null)}touches(s,r){let n=0,a=_Le(r),o=this.inverted?2:1,l=this.inverted?1:2;for(let i=0;is)break;let u=this.ranges[i+o],p=d+u;if(s<=p&&i==a*3)return!0;n+=this.ranges[i+l]-u}return!1}forEach(s){let r=this.inverted?2:1,n=this.inverted?1:2;for(let a=0,o=0;a=0;r--){let a=s.getMirror(r);this.appendMap(s._maps[r].invert(),a!=null&&a>r?n-a-1:void 0)}}invert(){let s=new pD;return s.appendMappingInverted(this),s}map(s,r=1){if(this.mirror)return this._map(s,r,!0);for(let n=this.from;no&&d!l.isAtom||!i.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),a),r.openStart,r.openEnd);return Bd.fromReplace(s,this.from,this.to,o)}invert(){return new Vy(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 ub(r.pos,n.pos,this.mark)}merge(s){return s instanceof ub&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new ub(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 ub(r.from,r.to,s.markFromJSON(r.mark))}}Uh.jsonID("addMark",ub);class Vy extends Uh{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 wn(uke(r.content,a=>a.mark(this.mark.removeFromSet(a.marks)),s),r.openStart,r.openEnd);return Bd.fromReplace(s,this.from,this.to,n)}invert(){return new ub(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 Vy(r.pos,n.pos,this.mark)}merge(s){return s instanceof Vy&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new Vy(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 Vy(r.from,r.to,s.markFromJSON(r.mark))}}Uh.jsonID("removeMark",Vy);class hb extends Uh{constructor(s,r){super(),this.pos=s,this.mark=r}apply(s){let r=s.nodeAt(this.pos);if(!r)return Bd.fail("No node at mark step's position");let n=r.type.create(r.attrs,null,this.mark.addToSet(r.marks));return Bd.fromReplace(s,this.pos,this.pos+1,new wn(Tr.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 $u(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 $u(r.from,r.to,r.gapFrom,r.gapTo,wn.fromJSON(s,r.slice),r.insert,!!r.structure)}}Uh.jsonID("replaceAround",$u);function f_e(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 pDt(t,s,r,n){let a=[],o=[],l,i;t.doc.nodesBetween(s,r,(d,u,p)=>{if(!d.isInline)return;let f=d.marks;if(!n.isInSet(f)&&p.type.allowsMarkType(n.type)){let y=Math.max(u,s),_=Math.min(u+d.nodeSize,r),b=n.addToSet(f);for(let N=0;Nt.step(d)),o.forEach(d=>t.step(d))}function fDt(t,s,r,n){let a=[],o=0;t.doc.nodesBetween(s,r,(l,i)=>{if(!l.isInline)return;o++;let d=null;if(n instanceof che){let u=l.marks,p;for(;p=n.isInSet(u);)(d||(d=[])).push(p),u=p.removeFromSet(u)}else n?n.isInSet(l.marks)&&(d=[n]):d=l.marks;if(d&&d.length){let u=Math.min(i+l.nodeSize,r);for(let p=0;pt.step(new Vy(l.from,l.to,l.style)))}function hke(t,s,r,n=r.contentMatch,a=!0){let o=t.doc.nodeAt(s),l=[],i=s+1;for(let d=0;d=0;d--)t.step(l[d])}function xDt(t,s,r){return(s==0||t.canReplace(s,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function eE(t){let r=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let n=t.depth,a=0,o=0;;--n){let l=t.$from.node(n),i=t.$from.index(n)+a,d=t.$to.indexAfter(n)-o;if(nr;b--)N||n.index(b)>0?(N=!0,p=Tr.from(n.node(b).copy(p)),f++):d--;let y=Tr.empty,_=0;for(let b=o,N=!1;b>r;b--)N||a.after(b+1)=0;l--){if(n.size){let i=r[l].type.contentMatch.matchFragment(n);if(!i||!i.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=Tr.from(r[l].type.create(r[l].attrs,n))}let a=s.start,o=s.end;t.step(new $u(a,o,a,o,new wn(n,0,0),r.length,!0))}function bDt(t,s,r,n,a){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=t.steps.length;t.doc.nodesBetween(s,r,(l,i)=>{let d=typeof a=="function"?a(l):a;if(l.isTextblock&&!l.hasMarkup(n,d)&&wDt(t.doc,t.mapping.slice(o).map(i),n)){let u=null;if(n.schema.linebreakReplacement){let _=n.whitespace=="pre",b=!!n.contentMatch.matchType(n.schema.linebreakReplacement);_&&!b?u=!1:!_&&b&&(u=!0)}u===!1&&EQe(t,l,i,o),hke(t,t.mapping.slice(o).map(i,1),n,void 0,u===null);let p=t.mapping.slice(o),f=p.map(i,1),y=p.map(i+l.nodeSize,1);return t.step(new $u(f,y,f+1,y-1,new wn(Tr.from(n.create(d,null,l.marks)),0,0),1,!0)),u===!0&&AQe(t,l,i,o),!1}})}function AQe(t,s,r,n){s.forEach((a,o)=>{if(a.isText){let l,i=/\r?\n|\r/g;for(;l=i.exec(a.text);){let d=t.mapping.slice(n).map(r+1+o+l.index);t.replaceWith(d,d+1,s.type.schema.linebreakReplacement.create())}}})}function EQe(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 wDt(t,s,r){let n=t.resolve(s),a=n.index();return n.parent.canReplaceWith(a,a+1,r)}function jDt(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 $u(s,s+o.nodeSize,s+1,s+o.nodeSize-1,new wn(Tr.from(l),0,0),1,!0))}function ZM(t,s,r=1,n){let a=t.resolve(s),o=a.depth-r,l=n&&n[n.length-1]||a.parent;if(o<0||a.parent.type.spec.isolating||!a.parent.canReplace(a.index(),a.parent.childCount)||!l.type.validContent(a.parent.content.cutByIndex(a.index(),a.parent.childCount)))return!1;for(let u=a.depth-1,p=r-2;u>o;u--,p--){let f=a.node(u),y=a.index(u);if(f.type.spec.isolating)return!1;let _=f.content.cutByIndex(y,f.childCount),b=n&&n[p+1];b&&(_=_.replaceChild(0,b.type.create(b.attrs)));let N=n&&n[p]||f;if(!f.canReplace(y+1,f.childCount)||!N.type.validContent(_))return!1}let i=a.indexAfter(o),d=n&&n[0];return a.node(o).canReplaceWith(i,i,d?d.type:a.node(o+1).type)}function NDt(t,s,r=1,n){let a=t.doc.resolve(s),o=Tr.empty,l=Tr.empty;for(let i=a.depth,d=a.depth-r,u=r-1;i>d;i--,u--){o=Tr.from(a.node(i).copy(o));let p=n&&n[u];l=Tr.from(p?p.type.create(p.attrs,l):a.node(i).copy(l))}t.step(new Od(s,s,new wn(o.append(l),r,r),!0))}function vw(t,s){let r=t.resolve(s),n=r.index();return PQe(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(n,n+1)}function kDt(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&&PQe(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 SDt(t,s,r){let n=null,{linebreakReplacement:a}=t.doc.type.schema,o=t.doc.resolve(s-r),l=o.node().type;if(a&&l.inlineContent){let p=l.whitespace=="pre",f=!!l.contentMatch.matchType(a);p&&!f?n=!1:!p&&f&&(n=!0)}let i=t.steps.length;if(n===!1){let p=t.doc.resolve(s+r);EQe(t,p.node(),p.before(),i)}l.inlineContent&&hke(t,s+r-1,l,o.node().contentMatchAt(o.index()),n==null);let d=t.mapping.slice(i),u=d.map(s-r);if(t.step(new Od(u,d.map(s+r,-1),wn.empty,!0)),n===!0){let p=t.doc.resolve(u);AQe(t,p.node(),p.before(),t.steps.length)}return t}function CDt(t,s,r){let n=t.resolve(s);if(n.parent.canReplaceWith(n.index(),n.index(),r))return s;if(n.parentOffset==0)for(let a=n.depth-1;a>=0;a--){let o=n.index(a);if(n.node(a).canReplaceWith(o,o,r))return n.before(a+1);if(o>0)return null}if(n.parentOffset==n.parent.content.size)for(let a=n.depth-1;a>=0;a--){let o=n.indexAfter(a);if(n.node(a).canReplaceWith(o,o,r))return n.after(a+1);if(o=0;l--){let i=l==n.depth?0:n.pos<=(n.start(l+1)+n.end(l+1))/2?-1:1,d=n.index(l)+(i>0?1:0),u=n.node(l),p=!1;if(o==1)p=u.canReplace(d,d,a);else{let f=u.contentMatchAt(d).findWrapping(a.firstChild.type);p=f&&u.canReplaceWith(d,d,f[0])}if(p)return i==0?n.pos:i<0?n.before(l+1):n.after(l+1)}return null}function uhe(t,s,r=s,n=wn.empty){if(s==r&&!n.size)return null;let a=t.resolve(s),o=t.resolve(r);return LQe(a,o,n)?new Od(s,r,n):new MDt(a,o,n).fit()}function LQe(t,s,r){return!r.openStart&&!r.openEnd&&t.start()==s.start()&&t.parent.canReplace(t.index(),s.index(),r.content)}class MDt{constructor(s,r,n){this.$from=s,this.$to=r,this.unplaced=n,this.frontier=[],this.placed=Tr.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=Tr.from(s.node(a).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let s=this.mustMoveInline(),r=this.placed.size-this.depth-this.$from.depth,n=this.$from,a=this.close(s<0?this.$to:n.doc.resolve(s));if(!a)return null;let o=this.placed,l=n.depth,i=a.depth;for(;l&&i&&o.childCount==1;)o=o.firstChild.content,l--,i--;let d=new wn(o,l,i);return s>-1?new $u(n.pos,s,this.$to.pos,this.$to.end(),d,r):d.size||n.pos!=this.$to.pos?new Od(n.pos,a.pos,d):null}findFittable(){let s=this.unplaced.openStart;for(let r=this.unplaced.content,n=0,a=this.unplaced.openEnd;n1&&(a=0),o.type.spec.isolating&&a<=n){s=n;break}r=o.content}for(let r=1;r<=2;r++)for(let n=r==1?s:this.unplaced.openStart;n>=0;n--){let a,o=null;n?(o=Wge(this.unplaced.content,n-1).firstChild,a=o.content):a=this.unplaced.content;let l=a.firstChild;for(let i=this.depth;i>=0;i--){let{type:d,match:u}=this.frontier[i],p,f=null;if(r==1&&(l?u.matchType(l.type)||(f=u.fillBefore(Tr.from(l),!1)):o&&d.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:i,parent:o,inject:f};if(r==2&&l&&(p=u.findWrapping(l.type)))return{sliceDepth:n,frontierDepth:i,parent:o,wrap:p};if(o&&u.matchType(o.type))break}}}openMore(){let{content:s,openStart:r,openEnd:n}=this.unplaced,a=Wge(s,r);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new wn(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=Wge(s,r);if(a.childCount<=1&&r>0){let o=s.size-r<=r+a.size;this.unplaced=new wn(RI(s,r-1,1),r-1,o?r-1:n)}else this.unplaced=new wn(RI(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 N=0;N1||d==0||N.content.size)&&(f=w,p.push(DQe(N.mark(y.allowedMarks(N.marks)),u==1?d:0,u==i.childCount?_:-1)))}let b=u==i.childCount;b||(_=-1),this.placed=OI(this.placed,r,Tr.from(p)),this.frontier[r].match=f,b&&_<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let N=0,w=i;N<_;N++){let S=w.lastChild;this.frontier.push({type:S.type,match:S.contentMatchAt(S.childCount)}),w=S.content}this.unplaced=b?s==0?wn.empty:new wn(RI(l.content,s-1,1),s-1,_<0?l.openEnd:s-1):new wn(RI(l.content,s,u),l.openStart,l.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let s=this.frontier[this.depth],r;if(!s.type.isTextblock||!Kge(this.$to,this.$to.depth,s.type,s.match,!1)||this.$to.depth==this.depth&&(r=this.findCloseLevel(this.$to))&&r.depth==this.depth)return-1;let{depth:n}=this.$to,a=this.$to.after(n);for(;n>1&&a==this.$to.end(--n);)++a;return a}findCloseLevel(s){e:for(let r=Math.min(this.depth,s.depth);r>=0;r--){let{match:n,type:a}=this.frontier[r],o=r=0;i--){let{match:d,type:u}=this.frontier[i],p=Kge(s,i,u,d,!0);if(!p||p.childCount)continue e}return{depth:r,fit:l,move:o?s.doc.resolve(s.after(r+1)):s}}}}close(s){let r=this.findCloseLevel(s);if(!r)return null;for(;this.depth>r.depth;)this.closeFrontierNode();r.fit.childCount&&(this.placed=OI(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=OI(this.placed,this.depth,Tr.from(s.create(r,n))),this.frontier.push({type:s,match:s.contentMatch})}closeFrontierNode(){let r=this.frontier.pop().match.fillBefore(Tr.empty,!0);r.childCount&&(this.placed=OI(this.placed,this.frontier.length,r))}}function RI(t,s,r){return s==0?t.cutByIndex(r,t.childCount):t.replaceChild(0,t.firstChild.copy(RI(t.firstChild.content,s-1,r)))}function OI(t,s,r){return s==0?t.append(r):t.replaceChild(t.childCount-1,t.lastChild.copy(OI(t.lastChild.content,s-1,r)))}function Wge(t,s){for(let r=0;r1&&(n=n.replaceChild(0,DQe(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(Tr.empty,!0)))),t.copy(n)}function Kge(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&&!TDt(r,o.content,l)?i:null}function TDt(t,s,r){for(let n=r;n0;y--,_--){let b=a.node(y).type.spec;if(b.defining||b.definingAsContext||b.isolating)break;l.indexOf(y)>-1?i=y:a.before(y)==_&&l.splice(1,0,-y)}let d=l.indexOf(i),u=[],p=n.openStart;for(let y=n.content,_=0;;_++){let b=y.firstChild;if(u.push(b),_==n.openStart)break;y=b.content}for(let y=p-1;y>=0;y--){let _=u[y],b=ADt(_.type);if(b&&!_.sameMarkup(a.node(Math.abs(i)-1)))p=y;else if(b||!_.type.isTextblock)break}for(let y=n.openStart;y>=0;y--){let _=(y+p+1)%(n.openStart+1),b=u[_];if(b)for(let N=0;N=0&&(t.replace(s,r,n),!(t.steps.length>f));y--){let _=l[y];_<0||(s=a.before(_),r=o.after(_))}}function RQe(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(Tr.empty,!0))}return t}function PDt(t,s,r,n){if(!n.isInline&&s==r&&t.doc.resolve(s).parent.content.size){let a=CDt(t.doc,s,n.type);a!=null&&(s=r=a)}t.replaceRange(s,r,new wn(Tr.from(n),0,0))}function IDt(t,s,r){let n=t.doc.resolve(s),a=t.doc.resolve(r);if(n.parent.isTextblock&&a.parent.isTextblock&&n.start()!=a.start()&&n.parentOffset==0&&a.parentOffset==0){let l=n.sharedDepth(r),i=!1;for(let d=n.depth;d>l;d--)n.node(d).type.spec.isolating&&(i=!0);for(let d=a.depth;d>l;d--)a.node(d).type.spec.isolating&&(i=!0);if(!i){for(let d=n.depth;d>0&&s==n.start(d);d--)s=n.before(d);for(let d=a.depth;d>0&&r==a.start(d);d--)r=a.before(d);n=t.doc.resolve(s),a=t.doc.resolve(r)}}let o=OQe(n,a);for(let l=0;l0&&(d||n.node(i-1).canReplace(n.index(i-1),a.indexAfter(i-1))))return t.delete(n.before(i),a.after(i))}for(let l=1;l<=n.depth&&l<=a.depth;l++)if(s-n.start(l)==n.depth-l&&r>n.end(l)&&a.end(l)-r!=a.depth-l&&n.start(l-1)==a.start(l-1)&&n.node(l-1).canReplace(n.index(l-1),a.index(l-1)))return t.delete(n.before(l),r);t.delete(s,r)}function OQe(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 YM extends Uh{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 Bd.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 Bd.fromReplace(s,this.pos,this.pos+1,new wn(Tr.from(a),0,r.isLeaf?0:1))}getMap(){return Qp.empty}invert(s){return new YM(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 YM(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 YM(r.pos,r.attr,r.value)}}Uh.jsonID("attr",YM);class fD extends Uh{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 Bd.ok(n)}getMap(){return Qp.empty}invert(s){return new fD(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 fD(r.attr,r.value)}}Uh.jsonID("docAttr",fD);let $T=class extends Error{};$T=function t(s){let r=Error.call(this,s);return r.__proto__=t.prototype,r};$T.prototype=Object.create(Error.prototype);$T.prototype.constructor=$T;$T.prototype.name="TransformError";class pke{constructor(s){this.doc=s,this.steps=[],this.docs=[],this.mapping=new pD}get before(){return this.docs.length?this.docs[0]:this.doc}step(s){let r=this.maybeStep(s);if(r.failed)throw new $T(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}changedRange(){let s=1e9,r=-1e9;for(let n=0;n{s=Math.min(s,i),r=Math.max(r,d)})}return s==1e9?null:{from:s,to:r}}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=wn.empty){let a=uhe(this.doc,s,r,n);return a&&this.step(a),this}replaceWith(s,r,n){return this.replace(s,r,new wn(Tr.from(n),0,0))}delete(s,r){return this.replace(s,r,wn.empty)}insert(s,r){return this.replaceWith(s,s,r)}replaceRange(s,r,n){return EDt(this,s,r,n),this}replaceRangeWith(s,r,n){return PDt(this,s,r,n),this}deleteRange(s,r){return IDt(this,s,r),this}lift(s,r){return gDt(this,s,r),this}join(s,r=1){return SDt(this,s,r),this}wrap(s,r){return _Dt(this,s,r),this}setBlockType(s,r=s,n,a=null){return bDt(this,s,r,n,a),this}setNodeMarkup(s,r,n=null,a){return jDt(this,s,r,n,a),this}setNodeAttribute(s,r,n){return this.step(new YM(s,r,n)),this}setDocAttribute(s,r){return this.step(new fD(s,r)),this}addNodeMark(s,r){return this.step(new hb(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 fl)r.isInSet(n.marks)&&this.step(new eC(s,r));else{let a=n.marks,o,l=[];for(;o=r.isInSet(a);)l.push(new eC(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 NDt(this,s,r,n),this}addMark(s,r,n){return pDt(this,s,r,n),this}removeMark(s,r,n){return fDt(this,s,r,n),this}clearIncompatible(s,r,n){return hke(this,s,r,n),this}}const Zge=Object.create(null);class ti{constructor(s,r,n){this.$anchor=s,this.$head=r,this.ranges=n||[new FQe(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?R5(s.node(0),s.node(o),s.before(o+1),s.index(o),r,n):R5(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 bx(s.node(0))}static atStart(s){return R5(s,s,0,0,1)||new bx(s)}static atEnd(s){return R5(s,s,s.content.size,s.childCount,-1)||new bx(s)}static fromJSON(s,r){if(!r||!r.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Zge[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 Zge)throw new RangeError("Duplicate use of selection JSON ID "+s);return Zge[s]=r,r.prototype.jsonID=s,r}getBookmark(){return Ha.between(this.$anchor,this.$head).getBookmark()}}ti.prototype.visible=!0;class FQe{constructor(s,r){this.$from=s,this.$to=r}}let wLe=!1;function jLe(t){!wLe&&!t.parent.inlineContent&&(wLe=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Ha extends ti{constructor(s,r=s){jLe(s),jLe(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 ti.near(n);let a=s.resolve(r.map(this.anchor));return new Ha(a.parent.inlineContent?a:n,n)}replace(s,r=wn.empty){if(super.replace(s,r),r==wn.empty){let n=this.$from.marksAcross(this.$to);n&&s.ensureMarks(n)}}eq(s){return s instanceof Ha&&s.anchor==this.anchor&&s.head==this.head}getBookmark(){return new hhe(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 Ha(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=ti.findFrom(r,n,!0)||ti.findFrom(r,-n,!0);if(o)r=o.$head;else return ti.near(r,n)}return s.parent.inlineContent||(a==0?s=r:(s=(ti.findFrom(s,-n,!0)||ti.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&&Fa.isSelectable(i))return Fa.create(t,r-(a<0?i.nodeSize:0))}else{let d=R5(t,i,r+a,a<0?i.childCount:0,a,o);if(d)return d}r+=i.nodeSize*a}return null}function NLe(t,s,r){let n=t.steps.length-1;if(n{l==null&&(l=p)}),t.setSelection(ti.near(t.doc.resolve(l),r))}const kLe=1,Fz=2,SLe=4;class DDt extends pke{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|=Fz,this}ensureMarks(s){return fl.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&Fz)>0}addStep(s,r){super.addStep(s,r),this.updated=this.updated&~Fz,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)||fl.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(ti.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|=SLe,this}get scrolledIntoView(){return(this.updated&SLe)>0}}function CLe(t,s){return!s||!t?t:t.bind(s)}class FI{constructor(s,r,n){this.name=s,this.init=CLe(r.init,n),this.apply=CLe(r.apply,n)}}const RDt=[new FI("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new FI("selection",{init(t,s){return t.selection||ti.atStart(s.doc)},apply(t){return t.selection}}),new FI("storedMarks",{init(t){return t.storedMarks||null},apply(t,s,r,n){return n.selection.$cursor?t.storedMarks:null}}),new FI("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=RDt.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 FI(n.key,n.spec.state,n))})}}class rM{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 rM(a);return a.fields.forEach(l=>{if(l.name=="doc")o.doc=Rb.fromJSON(s.schema,r.doc);else if(l.name=="selection")o.selection=ti.fromJSON(o.doc,r.selection);else if(l.name=="storedMarks")r.storedMarks&&(o.storedMarks=r.storedMarks.map(s.schema.markFromJSON));else{if(n)for(let i in n){let d=n[i],u=d.spec.state;if(d.key==l.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(r,i)){o[l.name]=u.fromJSON.call(d,s,r[i],o);return}}o[l.name]=l.init(s,o)}}),o}}function zQe(t,s,r){for(let n in t){let a=t[n];a instanceof Function?a=a.bind(s):n=="handleDOMEvents"&&(a=zQe(a,s,{})),r[n]=a}return r}class vu{constructor(s){this.spec=s,this.props={},s.props&&zQe(s.props,this,this.props),this.key=s.key?s.key.key:BQe("plugin")}getState(s){return s[this.key]}}const Xge=Object.create(null);function BQe(t){return t in Xge?t+"$"+ ++Xge[t]:(Xge[t]=0,t+"$")}class Vh{constructor(s="key"){this.key=BQe(s)}get(s){return s.config.pluginsByKey[this.key]}getState(s){return s[this.key]}}const rh=function(t){for(var s=0;;s++)if(t=t.previousSibling,!t)return s},qT=function(t){let s=t.assignedSlot||t.parentNode;return s&&s.nodeType==11?s.host:s};let x_e=null;const kv=function(t,s,r){let n=x_e||(x_e=document.createRange());return n.setEnd(t,r??t.nodeValue.length),n.setStart(t,s||0),n},ODt=function(){x_e=null},tC=function(t,s,r,n){return r&&(MLe(t,s,r,n,-1)||MLe(t,s,r,n,1))},FDt=/^(img|br|input|textarea|hr)$/i;function MLe(t,s,r,n,a){for(var o;;){if(t==r&&s==n)return!0;if(s==(a<0?0:ox(t))){let l=t.parentNode;if(!l||l.nodeType!=1||ZR(t)||FDt.test(t.nodeName)||t.contentEditable=="false")return!1;s=rh(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?ox(t):0}else return!1}}function ox(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function zDt(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=ox(t)}else if(t.parentNode&&!ZR(t))s=rh(t),t=t.parentNode;else return null}}function BDt(t,s){for(;;){if(t.nodeType==3&&s2),sx=UT||(f0?/Mac/.test(f0.platform):!1),UQe=f0?/Win/.test(f0.platform):!1,$v=/Android \d/.test(_w),YR=!!TLe&&"webkitFontSmoothing"in TLe.documentElement.style,VDt=YR?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function HDt(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 pv(t,s){return typeof t=="number"?t:t[s]}function GDt(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 ALe(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=qT(l);continue}let i=l,d=i==o.body,u=d?HDt(o):GDt(i),p=0,f=0;if(s.topu.bottom-pv(n,"bottom")&&(f=s.bottom-s.top>u.bottom-u.top?s.top+pv(a,"top")-u.top:s.bottom-u.bottom+pv(a,"bottom")),s.leftu.right-pv(n,"right")&&(p=s.right-u.right+pv(a,"right")),p||f)if(d)o.defaultView.scrollBy(p,f);else{let _=i.scrollLeft,b=i.scrollTop;f&&(i.scrollTop+=f),p&&(i.scrollLeft+=p);let N=i.scrollLeft-_,w=i.scrollTop-b;s={left:s.left-N,top:s.top-w,right:s.right-N,bottom:s.bottom-w}}let y=d?"fixed":getComputedStyle(l).position;if(/^(fixed|sticky)$/.test(y))break;l=y=="absolute"?l.offsetParent:qT(l)}}function WDt(t){let s=t.dom.getBoundingClientRect(),r=Math.max(0,s.top),n,a;for(let o=(s.left+s.right)/2,l=r+1;l=r-20){n=i,a=d.top;break}}return{refDOM:n,refTop:a,stack:VQe(t.dom)}}function VQe(t){let s=[],r=t.ownerDocument;for(let n=t;n&&(s.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),t!=r);n=qT(n));return s}function KDt({refDOM:t,refTop:s,stack:r}){let n=t?t.getBoundingClientRect().top:0;HQe(r,n==0?0:n-s)}function HQe(t,s){for(let r=0;r=i){l=Math.max(b.bottom,l),i=Math.min(b.top,i);let N=b.left>s.left?b.left-s.left:b.right=(b.left+b.right)/2?1:0));continue}}else b.top>s.top&&!d&&b.left<=s.left&&b.right>=s.left&&(d=p,u={left:Math.max(b.left,Math.min(b.right,s.left)),top:b.top});!r&&(s.left>=b.right&&s.top>=b.top||s.left>=b.left&&s.top>=b.bottom)&&(o=f+1)}}return!r&&d&&(r=d,a=u,n=0),r&&r.nodeType==3?YDt(r,a):!r||n&&r.nodeType==1?{node:t,offset:o}:GQe(r,a)}function YDt(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 xke(t,s){return t.left>=s.left-1&&t.left<=s.right+1&&t.top>=s.top-1&&t.top<=s.bottom+1}function XDt(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 JDt(t,s,r,n){let a=-1;for(let o=s,l=!1;o!=t.dom;){let i=t.docView.nearestDesc(o,!0),d;if(!i)return null;if(i.dom.nodeType==1&&(i.node.isBlock&&i.parent||!i.contentDOM)&&((d=i.dom.getBoundingClientRect()).width||d.height)&&(i.node.isBlock&&i.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(i.dom.nodeName)&&(!l&&d.left>n.left||d.top>n.top?a=i.posBefore:(!l&&d.right-1?a:t.docView.posFromDOM(s,r,-1)}function WQe(t,s,r){let n=t.childNodes.length;if(n&&r.tops.top&&a++}let u;YR&&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=JDt(t,n,a,s))}i==null&&(i=QDt(t,l,s));let d=t.docView.nearestDesc(l,!0);return{pos:i,inside:d?d.posAtStart-d.border:-1}}function ELe(t){return t.top=0&&a==n.nodeValue.length?(d--,p=1):r<0?d--:u++,oI(M_(kv(n,d,u),p),p<0)}if(!t.state.doc.resolve(s-(o||0)).parent.inlineContent){if(o==null&&a&&(r<0||a==ox(n))){let d=n.childNodes[a-1];if(d.nodeType==1)return Qge(d.getBoundingClientRect(),!1)}if(o==null&&a=0)}if(o==null&&a&&(r<0||a==ox(n))){let d=n.childNodes[a-1],u=d.nodeType==3?kv(d,ox(d)-(l?0:1)):d.nodeType==1&&(d.nodeName!="BR"||!d.nextSibling)?d:null;if(u)return oI(M_(u,1),!1)}if(o==null&&a=0)}function oI(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 Qge(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 ZQe(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 sRt(t,s,r){let n=s.selection,a=r=="up"?n.$from:n.$to;return ZQe(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=KQe(t,a.pos,1);for(let i=o.firstChild;i;i=i.nextSibling){let d;if(i.nodeType==1)d=i.getClientRects();else if(i.nodeType==3)d=kv(i,0,i.nodeValue.length).getClientRects();else continue;for(let u=0;up.top+1&&(r=="up"?l.top-p.top>(p.bottom-l.top)*2:p.bottom-l.bottom>(l.bottom-p.top)*2))return!1}}return!0})}const rRt=/[\u0590-\u08ac]/;function nRt(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?!rRt.test(n.parent.textContent)||!i.modify?r=="left"||r=="backward"?o:l:ZQe(t,s,()=>{let{focusNode:d,focusOffset:u,anchorNode:p,anchorOffset:f}=t.domSelectionRange(),y=i.caretBidiLevel;i.modify("move",r,"character");let _=n.depth?t.docView.domAfterPos(n.before()):t.dom,{focusNode:b,focusOffset:N}=t.domSelectionRange(),w=b&&!_.contains(b.nodeType==1?b:b.parentNode)||d==b&&u==N;try{i.collapse(p,f),d&&(d!=p||u!=f)&&i.extend&&i.extend(d,u)}catch{}return y!=null&&(i.caretBidiLevel=y),w}):n.pos==n.start()||n.pos==n.end()}let PLe=null,ILe=null,LLe=!1;function aRt(t,s,r){return PLe==s&&ILe==r?LLe:(PLe=s,ILe=r,LLe=r=="up"||r=="down"?sRt(t,s,r):nRt(t,s,r))}const jx=0,DLe=1,b4=2,x0=3;class XR{constructor(s,r,n,a){this.parent=s,this.children=r,this.dom=n,this.contentDOM=a,this.dirty=jx,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;rrh(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 XQe){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 YQe&&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?rh(o.dom)+1:0}}else{let o,l=!0;for(;o=n=p&&r<=u-d.border&&d.node&&d.contentDOM&&this.contentDOM.contains(d.contentDOM))return d.parseRange(s,r,p);s=l;for(let f=i;f>0;f--){let y=this.children[f-1];if(y.size&&y.dom.parentNode==this.contentDOM&&!y.emptyChildAt(1)){a=rh(y.dom)+1;break}s-=y.size}a==-1&&(a=0)}if(a>-1&&(u>r||i==this.children.length-1)){r=u;for(let p=i+1;pb&&lr){let b=i;i=d,d=b}let _=document.createRange();_.setEnd(d.node,d.offset),_.setStart(i.node,i.offset),u.removeAllRanges(),u.addRange(_)}}ignoreMutation(s){return!this.contentDOM&&s.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(s,r){for(let n=0,a=0;a=n:sn){let i=n+o.border,d=l-o.border;if(s>=i&&r<=d){this.dirty=s==n||r==l?b4:DLe,s==i&&r==d&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=x0:o.markDirty(s-i,r-i);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?b4:x0}n=l}this.dirty=b4}markParentsDirty(){let s=1;for(let r=this.parent;r;r=r.parent,s++){let n=s==1?b4:DLe;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==jx&&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 iRt extends XR{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 sC extends XR{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=MC.renderSpec(document,r.type.spec.toDOM(r,n),null,r.attrs)),new sC(s,r,l.dom,l.contentDOM||l.dom,l)}parseRule(){return this.dirty&x0||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(s){return this.dirty!=x0&&this.mark.eq(s)}markDirty(s,r){if(super.markDirty(s,r),this.dirty!=jx){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty0&&(o=b_e(o,0,s,n));for(let i=0;i{if(!d)return l;if(d.parent)return d.parent.posBeforeChild(d)},n,a),p=u&&u.dom,f=u&&u.contentDOM;if(r.isText){if(!p)p=document.createTextNode(r.text);else if(p.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else p||({dom:p,contentDOM:f}=MC.renderSpec(document,r.type.spec.toDOM(r),null,r.attrs));!f&&!r.isText&&p.nodeName!="BR"&&(p.hasAttribute("contenteditable")||(p.contentEditable="false"),r.type.spec.draggable&&(p.draggable=!0));let y=p;return p=eJe(p,n,r),u?d=new oRt(s,r,n,a,p,f||null,y,u,o,l+1):r.isText?new phe(s,r,n,a,p,y,o):new Fb(s,r,n,a,p,f||null,y,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=()=>Tr.empty)}return s}matchesNode(s,r,n){return this.dirty==jx&&s.eq(this.node)&&Tle(r,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(s,r){let n=this.node.inlineContent,a=r,o=s.composing?this.localCompositionInfo(s,r):null,l=o&&o.pos>-1?o:null,i=o&&o.pos<0,d=new cRt(this,l&&l.node,s);hRt(this.node,this.innerDeco,(u,p,f)=>{u.spec.marks?d.syncToMarks(u.spec.marks,n,s,p):u.type.side>=0&&!f&&d.syncToMarks(p==this.node.childCount?fl.none:this.node.child(p).marks,n,s,p),d.placeWidget(u,s,a)},(u,p,f,y)=>{d.syncToMarks(u.marks,n,s,y);let _;d.findNodeMatch(u,p,f,y)||i&&s.state.selection.from>a&&s.state.selection.to-1&&d.updateNodeAt(u,p,f,_,s)||d.updateNextNode(u,p,f,s,y,a)||d.addNode(u,p,f,s,a),a+=u.nodeSize}),d.syncToMarks([],n,s,0),this.node.isTextblock&&d.addTextblockHacks(),d.destroyRest(),(d.changed||this.dirty==b4)&&(l&&this.protectLocalComposition(s,l),QQe(this.contentDOM,this.children,s),UT&&mRt(this.dom))}localCompositionInfo(s,r){let{from:n,to:a}=s.state.selection;if(!(s.state.selection instanceof Ha)||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=pRt(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 iRt(this,o,r,a);s.input.compositionNodes.push(l),this.children=b_e(this.children,n,n+a.length,s,l)}update(s,r,n,a){return this.dirty==x0||!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=jx}updateOuterDeco(s){if(Tle(s,this.outerDeco))return;let r=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=JQe(this.dom,this.nodeDOM,__e(this.outerDeco,this.node,r),__e(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 RLe(t,s,r,n,a){eJe(n,s,t);let o=new Fb(void 0,t,s,r,n,n,n,a,0);return o.contentDOM&&o.updateChildren(a,0),o}class phe extends Fb{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==x0||this.dirty!=jx&&!this.inParent()||!s.sameMarkup(this.node)?!1:(this.updateOuterDeco(r),(this.dirty!=jx||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=jx,!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 phe(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=x0)}get domAtom(){return!1}isText(s){return this.node.text==s}}class XQe extends XR{parseRule(){return{ignore:!0}}matchesHack(s){return this.dirty==jx&&this.dom.nodeName==s}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class oRt extends Fb{constructor(s,r,n,a,o,l,i,d,u,p){super(s,r,n,a,o,l,i,u,p),this.spec=d}update(s,r,n,a){if(this.dirty==x0)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 QQe(t,s,r){let n=t.firstChild,a=!1;for(let o=0;o>1,i=Math.min(l,s.length);for(;o-1)d>this.index&&(this.changed=!0,this.destroyBetween(this.index,d)),this.top=this.top.children[this.index];else{let p=sC.create(this.top,s[l],r,n);this.top.children.splice(this.index,0,p),this.top=p,this.changed=!0}this.index=0,l++}}findNodeMatch(s,r,n,a){let o=-1,l;if(a>=this.preMatch.index&&(l=this.preMatch.matches[a-this.preMatch.index]).parent==this.top&&l.matchesNode(s,r,n))o=this.top.children.indexOf(l,this.index);else for(let i=this.index,d=Math.min(this.top.children.length,i+5);i0;){let i;for(;;)if(n){let u=r.children[n-1];if(u instanceof sC)r=u,n=u.children.length;else{i=u,n--;break}}else{if(r==s)break e;n=r.parent.children.indexOf(r),r=r.parent}let d=i.node;if(d){if(d!=t.child(a-1))break;--a,o.set(i,a),l.push(i)}}return{index:a,matched:o,matches:l.reverse()}}function uRt(t,s){return t.type.side-s.type.side}function hRt(t,s,r,n){let a=s.locals(t),o=0;if(a.length==0){for(let u=0;uo;)i.push(a[l++]);let b=o+y.nodeSize;if(y.isText){let w=b;l!w.inline):i.slice();n(y,N,s.forChild(o,y),_),o=b}}function mRt(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 pRt(t,s,r,n){for(let a=0,o=0;a=r){if(o>=n&&d.slice(n-s.length-i,n-i)==s)return n-s.length;let u=i=0&&u+s.length+i>=r)return i+u;if(r==n&&d.length>=n+s.length-i&&d.slice(n-i,n-i+s.length)==s)return n}}return-1}function b_e(t,s,r,n,a){let o=[];for(let l=0,i=0;l=r||p<=s?o.push(d):(ur&&o.push(d.slice(r-u,d.size,n)))}return o}function gke(t,s=null){let r=t.domSelectionRange(),n=t.state.doc;if(!r.focusNode)return null;let a=t.docView.nearestDesc(r.focusNode),o=a&&a.size==0,l=t.docView.posFromDOM(r.focusNode,r.focusOffset,1);if(l<0)return null;let i=n.resolve(l),d,u;if(mhe(r)){for(d=l;a&&!a.node;)a=a.parent;let f=a.node;if(a&&f.isAtom&&Fa.isSelectable(f)&&a.parent&&!(f.isInline&&$Dt(r.focusNode,r.focusOffset,a.dom))){let y=a.posBefore;u=new Fa(l==y?i:n.resolve(y))}}else{if(r instanceof t.dom.ownerDocument.defaultView.Selection&&r.rangeCount>1){let f=l,y=l;for(let _=0;_{(r.anchorNode!=n||r.anchorOffset!=a)&&(s.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!tJe(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function xRt(t){let s=t.domSelection();if(!s)return;let r=t.cursorWrapper.dom,n=r.nodeName=="IMG";n?s.collapse(r.parentNode,rh(r)+1):s.collapse(r,0),!n&&!t.state.selection.visible&&vp&&Ob<=11&&(r.disabled=!0,r.disabled=!1)}function sJe(t,s){if(s instanceof Fa){let r=t.docView.descAt(s.from);r!=t.lastSelectedViewDesc&&($Le(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else $Le(t)}function $Le(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function yke(t,s,r,n){return t.someProp("createSelectionBetween",a=>a(t,s,r))||Ha.between(s,r,n)}function qLe(t){return t.editable&&!t.hasFocus()?!1:rJe(t)}function rJe(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 gRt(t){let s=t.docView.domFromPos(t.state.selection.anchor,0),r=t.domSelectionRange();return tC(s.node,s.offset,r.anchorNode,r.anchorOffset)}function w_e(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&&ti.findFrom(o,s)}function D_(t,s){return t.dispatch(t.state.tr.setSelection(s).scrollIntoView()),!0}function ULe(t,s,r){let n=t.state.selection;if(n instanceof Ha)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 D_(t,new Ha(n.$anchor,l))}else if(n.empty){if(t.endOfTextblock(s>0?"forward":"backward")){let a=w_e(t.state,s);return a&&a instanceof Fa?D_(t,a):!1}else if(!(sx&&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?Fa.isSelectable(o)?D_(t,new Fa(s<0?t.state.doc.resolve(a.pos-o.nodeSize):a)):YR?D_(t,new Ha(t.state.doc.resolve(s<0?i:i+o.nodeSize))):!1:!1}}else return!1;else{if(n instanceof Fa&&n.node.isInline)return D_(t,new Ha(s>0?n.$to:n.$from));{let a=w_e(t.state,s);return a?D_(t,a):!1}}}function Ale(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function u8(t,s){let r=t.pmViewDesc;return r&&r.size==0&&(s<0||t.nextSibling||t.nodeName!="BR")}function v5(t,s){return s<0?yRt(t):vRt(t)}function yRt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a,o,l=!1;for(wx&&r.nodeType==1&&n0){if(r.nodeType!=1)break;{let i=r.childNodes[n-1];if(u8(i,-1))a=r,o=--n;else if(i.nodeType==3)r=i,n=r.nodeValue.length;else break}}else{if(nJe(r))break;{let i=r.previousSibling;for(;i&&u8(i,-1);)a=r.parentNode,o=rh(i),i=i.previousSibling;if(i)r=i,n=Ale(r);else{if(r=r.parentNode,r==t.dom)break;n=0}}}l?j_e(t,r,n):a&&j_e(t,a,o)}function vRt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a=Ale(r),o,l;for(;;)if(n{t.state==a&&r1(t)},50)}function VLe(t,s){let r=t.state.doc.resolve(s);if(!(ih||UQe)&&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 HLe(t,s,r){let n=t.state.selection;if(n instanceof Ha&&!n.empty||r.indexOf("s")>-1||sx&&r.indexOf("m")>-1)return!1;let{$from:a,$to:o}=n;if(!a.parent.inlineContent||t.endOfTextblock(s<0?"up":"down")){let l=w_e(t.state,s);if(l&&l instanceof Fa)return D_(t,l)}if(!a.parent.inlineContent){let l=s<0?a:o,i=n instanceof bx?ti.near(l,s):ti.findFrom(l,s);return i?D_(t,i):!1}return!1}function GLe(t,s){if(!(t.state.selection instanceof Ha))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 WLe(t,s,r){t.domObserver.stop(),s.contentEditable=r,t.domObserver.start()}function wRt(t){if(!Bh||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;WLe(t,n,"true"),setTimeout(()=>WLe(t,n,"false"),20)}return!1}function jRt(t){let s="";return t.ctrlKey&&(s+="c"),t.metaKey&&(s+="m"),t.altKey&&(s+="a"),t.shiftKey&&(s+="s"),s}function NRt(t,s){let r=s.keyCode,n=jRt(s);if(r==8||sx&&r==72&&n=="c")return GLe(t,-1)||v5(t,-1);if(r==46&&!s.shiftKey||sx&&r==68&&n=="c")return GLe(t,1)||v5(t,1);if(r==13||r==27)return!0;if(r==37||sx&&r==66&&n=="c"){let a=r==37?VLe(t,t.state.selection.from)=="ltr"?-1:1:-1;return ULe(t,a,n)||v5(t,a)}else if(r==39||sx&&r==70&&n=="c"){let a=r==39?VLe(t,t.state.selection.from)=="ltr"?1:-1:1;return ULe(t,a,n)||v5(t,a)}else{if(r==38||sx&&r==80&&n=="c")return HLe(t,-1,n)||v5(t,-1);if(r==40||sx&&r==78&&n=="c")return wRt(t)||HLe(t,1,n)||v5(t,1);if(n==(sx?"m":"c")&&(r==66||r==73||r==89||r==90))return!0}return!1}function vke(t,s){t.someProp("transformCopied",_=>{s=_(s,t)});let r=[],{content:n,openStart:a,openEnd:o}=s;for(;a>1&&o>1&&n.childCount==1&&n.firstChild.childCount==1;){a--,o--;let _=n.firstChild;r.push(_.type.name,_.attrs!=_.type.defaultAttrs?_.attrs:null),n=_.content}let l=t.someProp("clipboardSerializer")||MC.fromSchema(t.state.schema),i=dJe(),d=i.createElement("div");d.appendChild(l.serializeFragment(n,{document:i}));let u=d.firstChild,p,f=0;for(;u&&u.nodeType==1&&(p=cJe[u.nodeName.toLowerCase()]);){for(let _=p.length-1;_>=0;_--){let b=i.createElement(p[_]);for(;d.firstChild;)b.appendChild(d.firstChild);d.appendChild(b),f++}u=d.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${a} ${o}${f?` -${f}`:""} ${JSON.stringify(r)}`);let y=t.someProp("clipboardTextSerializer",_=>_(s,t))||s.content.textBetween(0,s.content.size,` `);return{dom:d,text:y,slice:s}}function aJe(t,s,r,n,a){let o=a.parent.type.spec.code,l,i;if(!r&&!s)return null;let d=!!s&&(n||o||!r);if(d){if(t.someProp("transformPastedText",y=>{s=y(s,o||n,t)}),o)return i=new wn(Tr.from(t.state.schema.text(s.replace(/\r\n?/g,` `))),0,0),t.someProp("transformPasted",y=>{i=y(i,t,!0)}),i;let f=t.someProp("clipboardTextParser",y=>y(s,a,n,t));if(f)i=f;else{let y=a.marks(),{schema:_}=t.state,b=MC.fromSchema(_);l=document.createElement("div"),s.split(/(?:\r\n?|\n)+/).forEach(N=>{let w=l.appendChild(document.createElement("p"));N&&w.appendChild(b.serializeNode(_.text(N,y)))})}}else t.someProp("transformPastedHTML",f=>{r=f(r,t)}),l=MRt(r),YR&&TRt(l);let u=l&&l.querySelector("[data-pm-slice]"),p=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(p&&p[3])for(let f=+p[3];f>0;f--){let y=l.firstChild;for(;y&&y.nodeType!=1;)y=y.nextSibling;if(!y)break;l=y}if(i||(i=(t.someProp("clipboardParser")||t.someProp("domParser")||l8.fromSchema(t.state.schema)).parseSlice(l,{preserveWhitespace:!!(d||p),context:a,ruleFromNode(y){return y.nodeName=="BR"&&!y.nextSibling&&y.parentNode&&!kRt.test(y.parentNode.nodeName)?{ignore:!0}:null}})),p)i=ARt(KLe(i,+p[1],+p[2]),p[4]);else if(i=wn.maxOpen(SRt(i.content,a),!0),i.openStart||i.openEnd){let f=0,y=0;for(let _=i.content.firstChild;f{i=f(i,t,d)}),i}const kRt=/^(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 SRt(t,s){if(t.childCount<2)return t;for(let r=s.depth;r>=0;r--){let a=s.node(r).contentMatchAt(s.index(r)),o,l=[];if(t.forEach(i=>{if(!l)return;let d=a.findWrapping(i.type),u;if(!d)return l=null;if(u=l.length&&o.length&&oJe(d,o,i,l[l.length-1],0))l[l.length-1]=u;else{l.length&&(l[l.length-1]=lJe(l[l.length-1],o.length));let p=iJe(i,d);l.push(p),a=a.matchType(p.type),o=d}}),l)return Tr.from(l)}return t}function iJe(t,s,r=0){for(let n=s.length-1;n>=r;n--)t=s[n].create(null,Tr.from(t));return t}function oJe(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(Tr.empty,!0))),t.replaceChild(s<0?0:t.childCount-1,l.copy(i))}function KLe(t,s,r){return sr})),eye.createHTML(t)):t}function MRt(t){let s=/^(\s*]*>)*/.exec(t);s&&(t=t.slice(s[0].length));let r=dJe().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(t),a;if((a=n&&cJe[n[1].toLowerCase()])&&(t=a.map(o=>"<"+o+">").join("")+t+a.map(o=>"").reverse().join("")),r.innerHTML=CRt(t),a)for(let o=0;o=0;i-=2){let d=r.nodes[n[i]];if(!d||d.hasRequiredAttrs())break;a=Tr.from(d.create(n[i+1],a)),o++,l++}return new wn(a,o,l)}const Pm={},Im={},ERt={touchstart:!0,touchmove:!0};class PRt{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.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function IRt(t){for(let s in Pm){let r=Pm[s];t.dom.addEventListener(s,t.input.eventHandlers[s]=n=>{DRt(t,n)&&!_ke(t,n)&&(t.editable||!(n.type in Im))&&r(t,n)},ERt[s]?{passive:!0}:void 0)}Bh&&t.dom.addEventListener("input",()=>null),k_e(t)}function mb(t,s){t.input.lastSelectionOrigin=s,t.input.lastSelectionTime=Date.now()}function LRt(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 k_e(t){t.someProp("handleDOMEvents",s=>{for(let r in s)t.input.eventHandlers[r]||t.dom.addEventListener(r,t.input.eventHandlers[r]=n=>_ke(t,n))})}function _ke(t,s){return t.someProp("handleDOMEvents",r=>{let n=r[s.type];return n?n(t,s)||s.defaultPrevented:!1})}function DRt(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 RRt(t,s){!_ke(t,s)&&Pm[s.type]&&(t.editable||!(s.type in Im))&&Pm[s.type](t,s)}Im.keydown=(t,s)=>{let r=s;if(t.input.shiftKey=r.keyCode==16||r.shiftKey,!hJe(t,r)&&(t.input.lastKeyCode=r.keyCode,t.input.lastKeyCodeTime=Date.now(),!($v&&ih&&r.keyCode==13)))if(r.keyCode!=229&&t.domObserver.forceFlush(),UT&&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,d4(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",n=>n(t,r))||NRt(t,r)?r.preventDefault():mb(t,"key")};Im.keyup=(t,s)=>{s.keyCode==16&&(t.input.shiftKey=!1)};Im.keypress=(t,s)=>{let r=s;if(hJe(t,r)||!r.charCode||r.ctrlKey&&!r.altKey||sx&&r.metaKey)return;if(t.someProp("handleKeyPress",a=>a(t,r))){r.preventDefault();return}let n=t.state.selection;if(!(n instanceof Ha)||!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 fhe(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 bke(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 XM(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 FRt(t,s){if(s==-1)return!1;let r=t.state.doc.resolve(s),n=r.nodeAfter;return n&&n.isAtom&&Fa.isSelectable(n)?(XM(t,new Fa(r)),!0):!1}function zRt(t,s){if(s==-1)return!1;let r=t.state.selection,n,a;r instanceof Fa&&(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(Fa.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?(XM(t,Fa.create(t.state.doc,a)),!0):!1}function BRt(t,s,r,n,a){return bke(t,"handleClickOn",s,r,n)||t.someProp("handleClick",o=>o(t,s,n))||(a?zRt(t,r):FRt(t,r))}function $Rt(t,s,r,n){return bke(t,"handleDoubleClickOn",s,r,n)||t.someProp("handleDoubleClick",a=>a(t,s,n))}function qRt(t,s,r,n){return bke(t,"handleTripleClickOn",s,r,n)||t.someProp("handleTripleClick",a=>a(t,s,n))||URt(t,r,n)}function URt(t,s,r){if(r.button!=0)return!1;let n=t.state.doc;if(s==-1)return n.inlineContent?(XM(t,Ha.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)XM(t,Ha.create(n,i+1,i+1+l.content.size));else if(Fa.isSelectable(l))XM(t,Fa.create(n,i));else continue;return!0}}function wke(t){return Ele(t)}const uJe=sx?"metaKey":"ctrlKey";Pm.mousedown=(t,s)=>{let r=s;t.input.shiftKey=r.shiftKey;let n=wke(t),a=Date.now(),o="singleClick";a-t.input.lastClick.time<500&&ORt(r,t.input.lastClick)&&!r[uJe]&&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(fhe(r));l&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new VRt(t,l,r,!!n)):(o=="doubleClick"?$Rt:qRt)(t,l.pos,l.inside,r)?r.preventDefault():mb(t,"pointer"))};class VRt{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[uJe],this.allowDefault=n.shiftKey;let o,l;if(r.inside>-1)o=s.state.doc.nodeAt(r.inside),l=r.inside;else{let p=s.state.doc.resolve(r.pos);o=p.parent,l=p.depth?p.before():0}const i=a?null:n.target,d=i?s.docView.nearestDesc(i,!0):null;this.target=d&&d.nodeDOM.nodeType==1?d.nodeDOM:null;let{selection:u}=s.state;n.button==0&&(o.type.spec.draggable&&o.type.spec.selectable!==!1||u instanceof Fa&&u.from<=l&&u.to>l)&&(this.mightDrag={node:o,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&wx&&!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)),mb(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(()=>r1(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(fhe(s))),this.updateAllowDefault(s),this.allowDefault||!r?mb(this.view,"pointer"):BRt(this.view,r.pos,r.inside,s,this.selectNode)?s.preventDefault():s.button==0&&(this.flushed||Bh&&this.mightDrag&&!this.mightDrag.node.isAtom||ih&&!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)?(XM(this.view,ti.near(this.view.state.doc.resolve(r.pos))),s.preventDefault()):mb(this.view,"pointer")}move(s){this.updateAllowDefault(s),mb(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)}}Pm.touchstart=t=>{t.input.lastTouch=Date.now(),wke(t),mb(t,"pointer")};Pm.touchmove=t=>{t.input.lastTouch=Date.now(),mb(t,"pointer")};Pm.contextmenu=t=>wke(t);function hJe(t,s){return t.composing?!0:Bh&&Math.abs(s.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const HRt=$v?5e3:-1;Im.compositionstart=Im.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:s}=t,r=s.selection.$to;if(s.selection instanceof Ha&&(s.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||ih&&UQe&&GRt(t)))t.markCursor=t.state.storedMarks||r.marks(),Ele(t,!0),t.markCursor=null;else if(Ele(t,!s.selection.empty),wx&&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}mJe(t,HRt)};function GRt(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"}Im.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.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,mJe(t,20))};function mJe(t,s){clearTimeout(t.input.composingTimeout),s>-1&&(t.input.composingTimeout=setTimeout(()=>Ele(t),s))}function pJe(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=KRt());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function WRt(t){let s=t.domSelectionRange();if(!s.focusNode)return null;let r=zDt(s.focusNode,s.focusOffset),n=BDt(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 KRt(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Ele(t,s=!1){if(!($v&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),pJe(t),s||t.docView&&t.docView.dirty){let r=gke(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 ZRt(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 xD=vp&&Ob<15||UT&&VDt<604;Pm.copy=Im.cut=(t,s)=>{let r=s,n=t.state.selection,a=r.type=="cut";if(n.empty)return;let o=xD?null:r.clipboardData,l=n.content(),{dom:i,text:d}=vke(t,l);o?(r.preventDefault(),o.clearData(),o.setData("text/html",i.innerHTML),o.setData("text/plain",d)):ZRt(t,i),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function YRt(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function XRt(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?gD(t,n.value,null,a,s):gD(t,n.textContent,n.innerHTML,a,s)},50)}function gD(t,s,r,n,a){let o=aJe(t,s,r,n,t.state.selection.$from);if(t.someProp("handlePaste",d=>d(t,a,o||wn.empty)))return!0;if(!o)return!1;let l=YRt(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 fJe(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," "):""}Im.paste=(t,s)=>{let r=s;if(t.composing&&!$v)return;let n=xD?null:r.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;n&&gD(t,fJe(n),n.getData("text/html"),a,r)?r.preventDefault():XRt(t,r)};class xJe{constructor(s,r,n){this.slice=s,this.move=r,this.node=n}}const QRt=sx?"altKey":"ctrlKey";function gJe(t,s){let r;return t.someProp("dragCopies",n=>{r=r||n(s)}),r!=null?!r:!s[QRt]}Pm.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(fhe(r)),l;if(!(o&&o.pos>=a.from&&o.pos<=(a instanceof Fa?a.to-1:a.to))){if(n&&n.mightDrag)l=Fa.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=Fa.create(t.state.doc,f.posBefore))}}let i=(l||t.state.selection).content(),{dom:d,text:u,slice:p}=vke(t,i);(!r.dataTransfer.files.length||!ih||qQe>120)&&r.dataTransfer.clearData(),r.dataTransfer.setData(xD?"Text":"text/html",d.innerHTML),r.dataTransfer.effectAllowed="copyMove",xD||r.dataTransfer.setData("text/plain",u),t.dragging=new xJe(p,gJe(t,r),l)};Pm.dragend=t=>{let s=t.dragging;window.setTimeout(()=>{t.dragging==s&&(t.dragging=null)},50)};Im.dragover=Im.dragenter=(t,s)=>s.preventDefault();Im.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(fhe(s));if(!n)return;let a=t.state.doc.resolve(n.pos),o=r&&r.slice;o?t.someProp("transformPasted",_=>{o=_(o,t,!1)}):o=aJe(t,fJe(s.dataTransfer),xD?null:s.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&gJe(t,s));if(t.someProp("handleDrop",_=>_(t,s,o||wn.empty,l))){s.preventDefault();return}if(!o)return;s.preventDefault();let i=o?IQe(t.state.doc,a.pos,o):a.pos;i==null&&(i=a.pos);let d=t.state.tr;if(l){let{node:_}=r;_?_.replace(d):d.deleteSelection()}let u=d.mapping.map(i),p=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=d.doc;if(p?d.replaceRangeWith(u,u,o.content.firstChild):d.replaceRange(u,u,o),d.doc.eq(f))return;let y=d.doc.resolve(u);if(p&&Fa.isSelectable(o.content.firstChild)&&y.nodeAfter&&y.nodeAfter.sameMarkup(o.content.firstChild))d.setSelection(new Fa(y));else{let _=d.mapping.map(i);d.mapping.maps[d.mapping.maps.length-1].forEach((b,N,w,S)=>_=S),d.setSelection(yke(t,y,d.doc.resolve(_)))}t.focus(),t.dispatch(d.setMeta("uiEvent","drop"))}Pm.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())&&r1(t)},20))};Pm.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)};Pm.beforeinput=(t,s)=>{if(ih&&$v&&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,d4(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 Im)Pm[t]=Im[t];function yD(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 Ple{constructor(s,r){this.toDOM=s,this.spec=r||MS,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 bm(o-n,o-n,this)}valid(){return!0}eq(s){return this==s||s instanceof Ple&&(this.spec.key&&this.spec.key==s.spec.key||this.toDOM==s.toDOM&&yD(this.spec,s.spec))}destroy(s){this.spec.destroy&&this.spec.destroy(s)}}class zb{constructor(s,r){this.attrs=s,this.spec=r||MS}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 bm(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==Ch||s.maps.length==0?this:this.mapInner(s,r,0,0,n||MS)}mapInner(s,r,n,a,o){let l;for(let i=0;i{let u=d+n,p;if(p=vJe(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&&d.type instanceof zb){let u=Math.max(o,d.from)-o,p=Math.min(l,d.to)-o;ua.map(s,r,MS));return H_.from(n)}forChild(s,r){if(r.isLeaf)return Xc.empty;let n=[];for(let a=0;ar instanceof Xc)?s:s.reduce((r,n)=>r.concat(n instanceof Xc?n:n.members),[]))}}forEachSet(s){for(let r=0;r{let w=N-b-(_-y);for(let S=0;SC+p-f)continue;let A=i[S]+p-f;_>=A?i[S+1]=y<=A?-2:-1:y>=p&&w&&(i[S]+=w,i[S+1]+=w)}f+=w}),p=r.maps[u].map(p,-1)}let d=!1;for(let u=0;u=n.content.size){d=!0;continue}let y=r.map(t[u+1]+o,-1),_=y-a,{index:b,offset:N}=n.content.findIndex(f),w=n.maybeChild(b);if(w&&N==f&&N+w.nodeSize==_){let S=i[u+2].mapInner(r,w,p+1,t[u]+o+1,l);S!=Ch?(i[u]=f,i[u+1]=_,i[u+2]=S):(i[u+1]=-2,d=!0)}else d=!0}if(d){let u=tOt(i,t,s,r,a,o,l),p=Ile(u,n,0,l);s=p.local;for(let f=0;fr&&l.to{let u=vJe(t,i,d+r);if(u){o=!0;let p=Ile(u,i,r+d+1,n);p!=Ch&&a.push(d,d+i.nodeSize,p)}});let l=yJe(o?_Je(t):t,-r).sort(TS);for(let i=0;i0;)s++;t.splice(s,0,r)}function tye(t){let s=[];return t.someProp("decorations",r=>{let n=r(t.state);n&&n!=Ch&&s.push(n)}),t.cursorWrapper&&s.push(Xc.create(t.state.doc,[t.cursorWrapper.deco])),H_.from(s)}const sOt={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},rOt=vp&&Ob<=11;class nOt{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 aOt{constructor(s,r){this.view=s,this.handleDOMChange=r,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new nOt,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():Bh&&s.composing&&n.some(a=>a.type=="childList"&&a.target.nodeName=="TR")?(s.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),rOt&&(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,sOt)),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(qLe(this.view)){if(this.suppressingSelectionUpdates)return r1(this.view);if(vp&&Ob<=11&&!this.view.state.selection.empty){let s=this.view.domSelectionRange();if(s.focusNode&&tC(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=qT(o))r.add(o);for(let o=s.anchorNode;o;o=qT(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)&&qLe(s)&&!this.ignoreSelectionChange(n),o=-1,l=-1,i=!1,d=[];if(s.editable)for(let p=0;pp.nodeName=="BR")&&(s.input.lastKeyCode==8||s.input.lastKeyCode==46)){for(let p of d)if(p.nodeName=="BR"&&p.parentNode){let f=p.nextSibling;for(;f&&f.nodeType==1;){if(f.contentEditable=="false"){p.parentNode.removeChild(p);break}f=f.firstChild}}}else if(wx&&d.length){let p=d.filter(f=>f.nodeName=="BR");if(p.length==2){let[f,y]=p;f.parentNode&&f.parentNode.parentNode==y.parentNode?y.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let y of p){let _=y.parentNode;_&&_.nodeName=="LI"&&(!f||lOt(s,f)!=_)&&y.remove()}}}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),iOt(s)),s.input.badSafariComposition&&(s.input.badSafariComposition=!1,cOt(s,d)),this.handleDOMChange(o,l,i,d),s.docView&&s.docView.dirty?s.updateState(s.state):this.currentSelection.eq(n)||r1(s),this.currentSelection.set(n))}registerMutation(s,r){if(r.indexOf(s.target)>-1)return null;let n=this.view.docView.nearestDesc(s.target);if(s.type=="attributes"&&(n==this.view.docView||s.attributeName=="contenteditable"||s.attributeName=="style"&&!s.oldValue&&!s.target.getAttribute("style"))||!n||n.ignoreMutation(s))return null;if(s.type=="childList"){for(let p=0;pa;w--){let S=n.childNodes[w-1],C=S.pmViewDesc;if(S.nodeName=="BR"&&!C){o=w;break}if(!C||C.size)break}let f=t.state.doc,y=t.someProp("domParser")||l8.fromSchema(t.state.schema),_=f.resolve(l),b=null,N=y.parse(n,{topNode:_.parent,topMatch:_.parent.contentMatchAt(_.index()),topOpen:!0,from:a,to:o,preserveWhitespace:_.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:uOt,context:_});if(u&&u[0].pos!=null){let w=u[0].pos,S=u[1]&&u[1].pos;S==null&&(S=w),b={anchor:w+l,head:S+l}}return{doc:N,sel:b,from:l,to:i}}function uOt(t){let s=t.pmViewDesc;if(s)return s.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Bh&&/^(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||Bh&&/^(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 hOt=/^(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 mOt(t,s,r,n,a){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,s<0){let V=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,q=gke(t,V);if(q&&!t.state.selection.eq(q)){if(ih&&$v&&t.input.lastKeyCode===13&&Date.now()-100U(t,d4(13,"Enter"))))return;let B=t.state.tr.setSelection(q);V=="pointer"?B.setMeta("pointer",!0):V=="key"&&B.scrollIntoView(),o&&B.setMeta("composition",o),t.dispatch(B)}return}let l=t.state.doc.resolve(s),i=l.sharedDepth(r);s=l.before(i+1),r=t.state.doc.resolve(r).after(i+1);let d=t.state.selection,u=dOt(t,s,r),p=t.state.doc,f=p.slice(u.from,u.to),y,_;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||$v)&&a.some(V=>V.nodeType==1&&!hOt.test(V.nodeName))&&(!b||b.endA>=b.endB)&&t.someProp("handleKeyDown",V=>V(t,d4(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!b)if(n&&d instanceof Ha&&!d.empty&&d.$head.sameParent(d.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))b={start:d.from,endA:d.to,endB:d.to};else{if(u.sel){let V=e8e(t,t.state.doc,u.sel);if(V&&!V.eq(t.state.selection)){let q=t.state.tr.setSelection(V);o&&q.setMeta("composition",o),t.dispatch(q)}}return}t.state.selection.fromt.state.selection.from&&b.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?b.start=t.state.selection.from:b.endA=t.state.selection.to-2&&t.state.selection.to<=u.to&&(b.endB+=t.state.selection.to-b.endA,b.endA=t.state.selection.to)),vp&&Ob<=11&&b.endB==b.start+1&&b.endA==b.start&&b.start>u.from&&u.doc.textBetween(b.start-u.from-1,b.start-u.from+1)=="  "&&(b.start--,b.endA--,b.endB--);let N=u.doc.resolveNoCache(b.start-u.from),w=u.doc.resolveNoCache(b.endB-u.from),S=p.resolve(b.start),C=N.sameParent(w)&&N.parent.inlineContent&&S.end()>=b.endA;if((UT&&t.input.lastIOSEnter>Date.now()-225&&(!C||a.some(V=>V.nodeName=="DIV"||V.nodeName=="P"))||!C&&N.posV(t,d4(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>b.start&&fOt(p,b.start,b.endA,N,w)&&t.someProp("handleKeyDown",V=>V(t,d4(8,"Backspace")))){$v&&ih&&t.domObserver.suppressSelectionUpdates();return}ih&&b.endB==b.start&&(t.input.lastChromeDelete=Date.now()),$v&&!C&&N.start()!=w.start()&&w.parentOffset==0&&N.depth==w.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==b.endA&&(b.endB-=2,w=u.doc.resolveNoCache(b.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(V){return V(t,d4(13,"Enter"))})},20));let A=b.start,I=b.endA,L=V=>{let q=V||t.state.tr.replace(A,I,u.doc.slice(b.start-u.from,b.endB-u.from));if(u.sel){let B=e8e(t,q.doc,u.sel);B&&!(ih&&t.composing&&B.empty&&(b.start!=b.endB||t.input.lastChromeDeleter1(t),20));let V=L(t.state.tr.delete(A,I)),q=p.resolve(b.start).marksAcross(p.resolve(b.endA));q&&V.ensureMarks(q),t.dispatch(V)}else if(b.endA==b.endB&&(O=pOt(N.parent.content.cut(N.parentOffset,w.parentOffset),S.parent.content.cut(S.parentOffset,b.endA-S.start())))){let V=L(t.state.tr);O.type=="add"?V.addMark(A,I,O.mark):V.removeMark(A,I,O.mark),t.dispatch(V)}else if(N.parent.child(N.index()).isText&&N.index()==w.index()-(w.textOffset?0:1)){let V=N.parent.textBetween(N.parentOffset,w.parentOffset),q=()=>L(t.state.tr.insertText(V,A,I));t.someProp("handleTextInput",B=>B(t,A,I,V,q))||t.dispatch(q())}else t.dispatch(L());else t.dispatch(L())}function e8e(t,s,r){return Math.max(r.anchor,r.head)>s.content.size?null:yke(t,s.resolve(r.anchor),s.resolve(r.head))}function pOt(t,s){let r=t.firstChild.marks,n=s.firstChild.marks,a=r,o=n,l,i,d;for(let p=0;pp.mark(i.addToSet(p.marks));else if(a.length==0&&o.length==1)i=o[0],l="remove",d=p=>p.mark(i.removeFromSet(p.marks));else return null;let u=[];for(let p=0;pr||sye(l,!0,!1)0&&(s||t.indexAfter(n)==t.node(n).childCount);)n--,a++,s=!1;if(r){let o=t.node(n).maybeChild(t.indexAfter(n));for(;o&&!o.isLeaf;)o=o.firstChild,a++}return a}function xOt(t,s,r,n,a){let o=t.findDiffStart(s,r);if(o==null)return null;let{a:l,b:i}=t.findDiffEnd(s,r+t.size,r+s.size);if(a=="end"){let d=Math.max(0,o-Math.min(l,i));n-=l+d-o}if(l=l?o-n:0;o-=d,o&&o=i?o-n:0;o-=d,o&&o=56320&&s<=57343&&r>=55296&&r<=56319}class bJe{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 PRt,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=r,this.state=r.state,this.directPlugins=r.plugins||[],this.directPlugins.forEach(i8e),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=n8e(this),r8e(this),this.nodeViews=a8e(this),this.docView=RLe(this.state.doc,s8e(this),tye(this),this.dom,this),this.domObserver=new aOt(this,(n,a,o,l)=>mOt(this,n,a,o,l)),this.domObserver.start(),IRt(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&&k_e(this);let r=this._props;this._props=s,s.plugins&&(s.plugins.forEach(i8e),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&&(pJe(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 _=a8e(this);yOt(_,this.nodeViews)&&(this.nodeViews=_,o=!0)}(i||r.handleDOMEvents!=this._props.handleDOMEvents)&&k_e(this),this.editable=n8e(this),r8e(this);let d=tye(this),u=s8e(this),p=a.plugins!=s.plugins&&!a.doc.eq(s.doc)?"reset":s.scrollToSelection>a.scrollToSelection?"to selection":"preserve",f=o||!this.docView.matchesNode(s.doc,u,d);(f||!s.selection.eq(a.selection))&&(l=!0);let y=p=="preserve"&&l&&this.dom.style.overflowAnchor==null&&WDt(this);if(l){this.domObserver.stop();let _=f&&(vp||ih)&&!this.composing&&!a.selection.empty&&!s.selection.empty&&gOt(a.selection,s.selection);if(f){let b=ih?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=WRt(this)),(o||!this.docView.update(s.doc,u,d,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=RLe(s.doc,u,d,this.dom,this)),b&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(_=!0)}_||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&gRt(this))?r1(this,_):(sJe(this,s.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(a),!((n=this.dragging)===null||n===void 0)&&n.node&&!a.doc.eq(s.doc)&&this.updateDraggedNode(this.dragging,a),p=="reset"?this.dom.scrollTop=0:p=="to selection"?this.scrollToSelection():y&&KDt(y)}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 Fa){let r=this.docView.domAfterPos(this.state.selection.from);r.nodeType==1&&ALe(this,r.getBoundingClientRect(),s)}else ALe(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&&or.ownerDocument.getSelection()),this._root=r}return s||document}updateRoot(){this._root=null}posAtCoords(s){return eRt(this,s)}coordsAtPos(s,r=1){return KQe(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 aRt(this,r||this.state,s)}pasteHTML(s,r){return gD(this,"",s,!1,r||new ClipboardEvent("paste"))}pasteText(s,r){return gD(this,s,null,!0,r||new ClipboardEvent("paste"))}serializeForClipboard(s){return vke(this,s)}destroy(){this.docView&&(LRt(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],tye(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,ODt())}get isDestroyed(){return this.docView==null}dispatchEvent(s){return RRt(this,s)}domSelectionRange(){let s=this.domSelection();return s?Bh&&this.root.nodeType===11&&qDt(this.dom.ownerDocument)==this.dom&&oOt(this,s)||s:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}bJe.prototype.dispatch=function(t){let s=this._props.dispatchTransaction;s?s.call(this,t):this.updateState(this.state.apply(t))};function s8e(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"),[bm.node(0,t.state.doc.content.size,s)]}function r8e(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:bm.widget(t.state.selection.from,s,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function n8e(t){return!t.someProp("editable",s=>s(t.state)===!1)}function gOt(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 a8e(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 yOt(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 i8e(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 rw={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:"'"},Lle={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},vOt=typeof navigator<"u"&&/Mac/.test(navigator.platform),_Ot=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var nh=0;nh<10;nh++)rw[48+nh]=rw[96+nh]=String(nh);for(var nh=1;nh<=24;nh++)rw[nh+111]="F"+nh;for(var nh=65;nh<=90;nh++)rw[nh]=String.fromCharCode(nh+32),Lle[nh]=String.fromCharCode(nh);for(var rye in rw)Lle.hasOwnProperty(rye)||(Lle[rye]=rw[rye]);function bOt(t){var s=vOt&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||_Ot&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",r=!s&&t.key||(t.shiftKey?Lle:rw)[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 wOt=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),jOt=typeof navigator<"u"&&/Win/.test(navigator.platform);function NOt(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 wJe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("backward",t):r.parentOffset>0)?null:r}const MOt=(t,s,r)=>{let n=wJe(t,r);if(!n)return!1;let a=Ske(n);if(!a){let l=n.blockRange(),i=l&&eE(l);return i==null?!1:(s&&s(t.tr.lift(l,i).scrollIntoView()),!0)}let o=a.nodeBefore;if(SJe(t,a,s,-1))return!0;if(n.parent.content.size==0&&(VT(o,"end")||Fa.isSelectable(o)))for(let l=n.depth;;l--){let i=uhe(t.doc,n.before(l),n.after(l),wn.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},TOt=(t,s,r)=>{let n=wJe(t,r);if(!n)return!1;let a=Ske(n);return a?jJe(t,a,s):!1},AOt=(t,s,r)=>{let n=NJe(t,r);if(!n)return!1;let a=Cke(n);return a?jJe(t,a,s):!1};function jJe(t,s,r){let n=s.nodeBefore,a=n,o=s.pos-1;for(;!a.isTextblock;o--){if(a.type.spec.isolating)return!1;let p=a.lastChild;if(!p)return!1;a=p}let l=s.nodeAfter,i=l,d=s.pos+1;for(;!i.isTextblock;d++){if(i.type.spec.isolating)return!1;let p=i.firstChild;if(!p)return!1;i=p}let u=uhe(t.doc,o,d,wn.empty);if(!u||u.from!=o||u instanceof Od&&u.slice.size>=d-o)return!1;if(r){let p=t.tr.step(u);p.setSelection(Ha.create(p.doc,o)),r(p.scrollIntoView())}return!0}function VT(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 EOt=(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=Ske(n)}let l=o&&o.nodeBefore;return!l||!Fa.isSelectable(l)?!1:(s&&s(t.tr.setSelection(Fa.create(t.doc,o.pos-l.nodeSize)).scrollIntoView()),!0)};function Ske(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 NJe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("forward",t):r.parentOffset{let n=NJe(t,r);if(!n)return!1;let a=Cke(n);if(!a)return!1;let o=a.nodeAfter;if(SJe(t,a,s,1))return!0;if(n.parent.content.size==0&&(VT(o,"start")||Fa.isSelectable(o))){let l=uhe(t.doc,n.before(),n.after(),wn.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 Fa,a;if(n){if(r.node.isTextblock||!vw(t.doc,r.from))return!1;a=r.from}else if(a=dhe(t.doc,r.from,-1),a==null)return!1;if(s){let o=t.tr.join(a);n&&o.setSelection(Fa.create(o.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),s(o.scrollIntoView())}return!0},DOt=(t,s)=>{let r=t.selection,n;if(r instanceof Fa){if(r.node.isTextblock||!vw(t.doc,r.to))return!1;n=r.to}else if(n=dhe(t.doc,r.to,1),n==null)return!1;return s&&s(t.tr.join(n).scrollIntoView()),!0},ROt=(t,s)=>{let{$from:r,$to:n}=t.selection,a=r.blockRange(n),o=a&&eE(a);return o==null?!1:(s&&s(t.tr.lift(a,o).scrollIntoView()),!0)},OOt=(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 kJe(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=kJe(a.contentMatchAt(o));if(!l||!a.canReplaceWith(o,o,l))return!1;if(s){let i=r.after(),d=t.tr.replaceWith(i,i,l.createAndFill());d.setSelection(ti.near(d.doc.resolve(i),1)),s(d.scrollIntoView())}return!0},zOt=(t,s)=>{let r=t.selection,{$from:n,$to:a}=r;if(r instanceof bx||n.parent.inlineContent||a.parent.inlineContent)return!1;let o=kJe(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(ZM(t.doc,o))return s&&s(t.tr.split(o).scrollIntoView()),!0}let n=r.blockRange(),a=n&&eE(n);return a==null?!1:(s&&s(t.tr.lift(n,a).scrollIntoView()),!0)},$Ot=(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(Fa.create(t.doc,a))),!0)};function qOt(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||vw(t.doc,s.pos))?!1:(r&&r(t.tr.join(s.pos).scrollIntoView()),!0)}function SJe(t,s,r,n){let a=s.nodeBefore,o=s.nodeAfter,l,i,d=a.type.spec.isolating||o.type.spec.isolating;if(!d&&qOt(t,s,r))return!0;let u=!d&&s.parent.canReplace(s.index(),s.index()+1);if(u&&(l=(i=a.contentMatchAt(a.childCount)).findWrapping(o.type))&&i.matchType(l[0]||o.type).validEnd){if(r){let _=s.pos+o.nodeSize,b=Tr.empty;for(let S=l.length-1;S>=0;S--)b=Tr.from(l[S].create(null,b));b=Tr.from(a.copy(b));let N=t.tr.step(new $u(s.pos-1,_,s.pos,_,new wn(b,1,0),l.length,!0)),w=N.doc.resolve(_+2*l.length);w.nodeAfter&&w.nodeAfter.type==a.type&&vw(N.doc,w.pos)&&N.join(w.pos),r(N.scrollIntoView())}return!0}let p=o.type.spec.isolating||n>0&&d?null:ti.findFrom(s,1),f=p&&p.$from.blockRange(p.$to),y=f&&eE(f);if(y!=null&&y>=s.depth)return r&&r(t.tr.lift(f,y).scrollIntoView()),!0;if(u&&VT(o,"start",!0)&&VT(a,"end")){let _=a,b=[];for(;b.push(_),!_.isTextblock;)_=_.lastChild;let N=o,w=1;for(;!N.isTextblock;N=N.firstChild)w++;if(_.canReplace(_.childCount,_.childCount,N.content)){if(r){let S=Tr.empty;for(let A=b.length-1;A>=0;A--)S=Tr.from(b[A].copy(S));let C=t.tr.step(new $u(s.pos-b.length,s.pos+o.nodeSize,s.pos+w,s.pos+o.nodeSize-w,new wn(S,b.length,0),0,!0));r(C.scrollIntoView())}return!0}}return!1}function CJe(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(Ha.create(s.doc,t<0?a.start(o):a.end(o)))),!0):!1}}const UOt=CJe(-1),VOt=CJe(1);function HOt(t,s=null){return function(r,n){let{$from:a,$to:o}=r.selection,l=a.blockRange(o),i=l&&mke(l,t,s);return i?(n&&n(r.tr.wrap(l,i).scrollIntoView()),!0):!1}}function o8e(t,s=null){return function(r,n){let a=!1;for(let o=0;o{if(a)return!1;if(!(!d.isTextblock||d.hasMarkup(t,s)))if(d.type==t)a=!0;else{let p=r.doc.resolve(u),f=p.index();a=p.parent.canReplaceWith(f,f+1,t)}})}if(!a)return!1;if(n){let o=r.tr;for(let l=0;l=2&&s.$from.node(s.depth-1).type.compatibleContent(r)&&s.startIndex==0){if(s.$from.index(s.depth-1)==0)return!1;let d=l.resolve(s.start-2);o=new Cle(d,d,s.depth),s.endIndex=0;p--)o=Tr.from(r[p].type.create(r[p].attrs,o));t.step(new $u(s.start-(n?2:0),s.end,s.start,s.end,new wn(o,0,0),r.length,!0));let l=0;for(let p=0;pl.childCount>0&&l.firstChild.type==t);return o?r?n.node(o.depth-1).type==t?YOt(s,r,t,o):XOt(s,r,o):!0:!1}}function YOt(t,s,r,n){let a=t.tr,o=n.end,l=n.$to.end(n.depth);oN;b--)_-=a.child(b).nodeSize,n.delete(_-1,_+1);let o=n.doc.resolve(r.start),l=o.nodeAfter;if(n.mapping.map(r.end)!=r.start+o.nodeAfter.nodeSize)return!1;let i=r.startIndex==0,d=r.endIndex==a.childCount,u=o.node(-1),p=o.index(-1);if(!u.canReplace(p+(i?0:1),p+1,l.content.append(d?Tr.empty:Tr.from(a))))return!1;let f=o.pos,y=f+l.nodeSize;return n.step(new $u(f-(i?1:0),y+(d?1:0),f+1,y-1,new wn((i?Tr.empty:Tr.from(a.copy(Tr.empty))).append(d?Tr.empty:Tr.from(a.copy(Tr.empty))),i?0:1,d?0:1),i?0:1)),s(n.scrollIntoView()),!0}function QOt(t){return function(s,r){let{$from:n,$to:a}=s.selection,o=n.blockRange(a,u=>u.childCount>0&&u.firstChild.type==t);if(!o)return!1;let l=o.startIndex;if(l==0)return!1;let i=o.parent,d=i.child(l-1);if(d.type!=t)return!1;if(r){let u=d.lastChild&&d.lastChild.type==i.type,p=Tr.from(u?t.create():null),f=new wn(Tr.from(t.create(null,Tr.from(i.type.create(null,p)))),u?3:1,0),y=o.start,_=o.end;r(s.tr.step(new $u(y-(u?3:1),_,y,_,f,1,!0)).scrollIntoView())}return!0}}function xhe(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 ghe{constructor(s){this.editor=s.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=s.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:s,editor:r,state:n}=this,{view:a}=r,{tr:o}=n,l=this.buildProps(o);return Object.fromEntries(Object.entries(s).map(([i,d])=>[i,(...p)=>{const f=d(...p)(l);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(o),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(s,r=!0){const{rawCommands:n,editor:a,state:o}=this,{view:l}=a,i=[],d=!!s,u=s||o.tr,p=()=>(!d&&r&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&l.dispatch(u),i.every(y=>y===!0)),f={...Object.fromEntries(Object.entries(n).map(([y,_])=>[y,(...N)=>{const w=this.buildProps(u,r),S=_(...N)(w);return i.push(S),f}])),run:p};return f}createCan(s){const{rawCommands:r,state:n}=this,a=!1,o=s||n.tr,l=this.buildProps(o,a);return{...Object.fromEntries(Object.entries(r).map(([d,u])=>[d,(...p)=>u(...p)({...l,dispatch:void 0})])),chain:()=>this.createChain(o,a)}}buildProps(s,r=!0){const{rawCommands:n,editor:a,state:o}=this,{view:l}=a,i={tr:s,editor:a,view:l,state:xhe({state:o,transaction:s}),dispatch:r?()=>{}:void 0,chain:()=>this.createChain(s,r),can:()=>this.createCan(s),get commands(){return Object.fromEntries(Object.entries(n).map(([d,u])=>[d,(...p)=>u(...p)(i)]))}};return i}}let JOt=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 aa(t,s,r){return t.config[s]===void 0&&t.parent?aa(t.parent,s,r):typeof t.config[s]=="function"?t.config[s].bind({...r,parent:t.parent?aa(t.parent,s,r):null}):t.config[s]}function yhe(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 MJe(t){const s=[],{nodeExtensions:r,markExtensions:n}=yhe(t),a=[...r,...n],o={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(l=>{const i={name:l.name,options:l.options,storage:l.storage,extensions:a},d=aa(l,"addGlobalAttributes",i);if(!d)return;d().forEach(p=>{p.types.forEach(f=>{Object.entries(p.attributes).forEach(([y,_])=>{s.push({type:f,name:y,attribute:{...o,..._}})})})})}),a.forEach(l=>{const i={name:l.name,options:l.options,storage:l.storage},d=aa(l,"addAttributes",i);if(!d)return;const u=d();Object.entries(u).forEach(([p,f])=>{const y={...o,...f};typeof(y==null?void 0:y.default)=="function"&&(y.default=y.default()),y!=null&&y.isRequired&&(y==null?void 0:y.default)===void 0&&delete y.default,s.push({type:l.name,name:p,attribute:y})})}),s}function Vu(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 jc(...t){return t.filter(s=>!!s).reduce((s,r)=>{const n={...s};return Object.entries(r).forEach(([a,o])=>{if(!n[a]){n[a]=o;return}if(a==="class"){const i=o?String(o).split(" "):[],d=n[a]?n[a].split(" "):[],u=i.filter(p=>!d.includes(p));n[a]=[...d,...u].join(" ")}else if(a==="style"){const i=o?o.split(";").map(p=>p.trim()).filter(Boolean):[],d=n[a]?n[a].split(";").map(p=>p.trim()).filter(Boolean):[],u=new Map;d.forEach(p=>{const[f,y]=p.split(":").map(_=>_.trim());u.set(f,y)}),i.forEach(p=>{const[f,y]=p.split(":").map(_=>_.trim());u.set(f,y)}),n[a]=Array.from(u.entries()).map(([p,f])=>`${p}: ${f}`).join("; ")}else n[a]=o}),n},{})}function S_e(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)=>jc(r,n),{})}function TJe(t){return typeof t=="function"}function Di(t,s=void 0,...r){return TJe(t)?s?t.bind(s)(...r):t(...r):t}function eFt(t={}){return Object.keys(t).length===0&&t.constructor===Object}function tFt(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function l8e(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):tFt(r.getAttribute(l.name));return i==null?o:{...o,[l.name]:i}},{});return{...n,...a}}}}function c8e(t){return Object.fromEntries(Object.entries(t).filter(([s,r])=>s==="attrs"&&eFt(r)?!1:r!=null))}function sFt(t,s){var r;const n=MJe(t),{nodeExtensions:a,markExtensions:o}=yhe(t),l=(r=a.find(u=>aa(u,"topNode")))===null||r===void 0?void 0:r.name,i=Object.fromEntries(a.map(u=>{const p=n.filter(S=>S.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:s},y=t.reduce((S,C)=>{const A=aa(C,"extendNodeSchema",f);return{...S,...A?A(u):{}}},{}),_=c8e({...y,content:Di(aa(u,"content",f)),marks:Di(aa(u,"marks",f)),group:Di(aa(u,"group",f)),inline:Di(aa(u,"inline",f)),atom:Di(aa(u,"atom",f)),selectable:Di(aa(u,"selectable",f)),draggable:Di(aa(u,"draggable",f)),code:Di(aa(u,"code",f)),whitespace:Di(aa(u,"whitespace",f)),linebreakReplacement:Di(aa(u,"linebreakReplacement",f)),defining:Di(aa(u,"defining",f)),isolating:Di(aa(u,"isolating",f)),attrs:Object.fromEntries(p.map(S=>{var C;return[S.name,{default:(C=S==null?void 0:S.attribute)===null||C===void 0?void 0:C.default}]}))}),b=Di(aa(u,"parseHTML",f));b&&(_.parseDOM=b.map(S=>l8e(S,p)));const N=aa(u,"renderHTML",f);N&&(_.toDOM=S=>N({node:S,HTMLAttributes:S_e(S,p)}));const w=aa(u,"renderText",f);return w&&(_.toText=w),[u.name,_]})),d=Object.fromEntries(o.map(u=>{const p=n.filter(w=>w.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:s},y=t.reduce((w,S)=>{const C=aa(S,"extendMarkSchema",f);return{...w,...C?C(u):{}}},{}),_=c8e({...y,inclusive:Di(aa(u,"inclusive",f)),excludes:Di(aa(u,"excludes",f)),group:Di(aa(u,"group",f)),spanning:Di(aa(u,"spanning",f)),code:Di(aa(u,"code",f)),attrs:Object.fromEntries(p.map(w=>{var S;return[w.name,{default:(S=w==null?void 0:w.attribute)===null||S===void 0?void 0:S.default}]}))}),b=Di(aa(u,"parseHTML",f));b&&(_.parseDOM=b.map(w=>l8e(w,p)));const N=aa(u,"renderHTML",f);return N&&(_.toDOM=w=>N({mark:w,HTMLAttributes:S_e(w,p)})),[u.name,_]}));return new wQe({topNode:l,nodes:i,marks:d})}function aye(t,s){return s.nodes[t]||s.marks[t]||null}function d8e(t,s){return Array.isArray(s)?s.some(r=>(typeof r=="string"?r:r.name)===t.name):s}function Mke(t,s){const r=MC.fromSchema(s).serializeFragment(t),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(r),a.innerHTML}const rFt=(t,s=500)=>{let r="";const n=t.parentOffset;return t.parent.nodesBetween(Math.max(0,n-s),n,(a,o,l,i)=>{var d,u;const p=((u=(d=a.type.spec).toText)===null||u===void 0?void 0:u.call(d,{node:a,pos:o,parent:l,index:i}))||a.textContent||"%leaf%";r+=a.isAtom&&!a.isText?p:p.slice(0,Math.max(0,n-o))}),r};function Tke(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class vhe{constructor(s){this.find=s.find,this.handler=s.handler}}const nFt=(t,s)=>{if(Tke(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 zz(t){var s;const{editor:r,from:n,to:a,text:o,rules:l,plugin:i}=t,{view:d}=r;if(d.composing)return!1;const u=d.state.doc.resolve(n);if(u.parent.type.spec.code||!((s=u.nodeBefore||u.nodeAfter)===null||s===void 0)&&s.marks.find(y=>y.type.spec.code))return!1;let p=!1;const f=rFt(u)+o;return l.forEach(y=>{if(p)return;const _=nFt(f,y.find);if(!_)return;const b=d.state.tr,N=xhe({state:d.state,transaction:b}),w={from:n-(_[0].length-o.length),to:a},{commands:S,chain:C,can:A}=new ghe({editor:r,state:N});y.handler({state:N,range:w,match:_,commands:S,chain:C,can:A})===null||!b.steps.length||(b.setMeta(i,{transform:b,from:n,to:a,text:o}),d.dispatch(b),p=!0)}),p}function aFt(t){const{editor:s,rules:r}=t,n=new vu({state:{init(){return null},apply(a,o,l){const i=a.getMeta(n);if(i)return i;const d=a.getMeta("applyInputRules");return!!d&&setTimeout(()=>{let{text:p}=d;typeof p=="string"?p=p:p=Mke(Tr.from(p),l.schema);const{from:f}=d,y=f+p.length;zz({editor:s,from:f,to:y,text:p,rules:r,plugin:n})}),a.selectionSet||a.docChanged?null:o}},props:{handleTextInput(a,o,l,i){return zz({editor:s,from:o,to:l,text:i,rules:r,plugin:n})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:o}=a.state.selection;o&&zz({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?zz({editor:s,from:l.pos,to:l.pos,text:` `,rules:r,plugin:n}):!1}},isInputRules:!0});return n}function iFt(t){return Object.prototype.toString.call(t).slice(8,-1)}function Bz(t){return iFt(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function _he(t,s){const r={...t};return Bz(t)&&Bz(s)&&Object.keys(s).forEach(n=>{Bz(s[n])&&Bz(t[n])?r[n]=_he(t[n],s[n]):r[n]=s[n]}),r}class qg{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=Di(aa(this,"addOptions",{name:this.name}))),this.storage=Di(aa(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new qg(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>_he(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new qg(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=Di(aa(r,"addOptions",{name:r.name})),r.storage=Di(aa(r,"addStorage",{name:r.name,options:r.options})),r}static handleExit({editor:s,mark:r}){const{tr:n}=s.state,a=s.state.selection.$from;if(a.pos===a.end()){const l=a.marks();if(!!!l.find(u=>(u==null?void 0:u.type.name)===r.name))return!1;const d=l.find(u=>(u==null?void 0:u.type.name)===r.name);return d&&n.removeStoredMark(d),n.insertText(" ",a.pos),s.view.dispatch(n),!0}return!1}}function oFt(t){return typeof t=="number"}class lFt{constructor(s){this.find=s.find,this.handler=s.handler}}const cFt=(t,s,r)=>{if(Tke(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 dFt(t){const{editor:s,state:r,from:n,to:a,rule:o,pasteEvent:l,dropEvent:i}=t,{commands:d,chain:u,can:p}=new ghe({editor:s,state:r}),f=[];return r.doc.nodesBetween(n,a,(_,b)=>{if(!_.isTextblock||_.type.spec.code)return;const N=Math.max(n,b),w=Math.min(a,b+_.content.size),S=_.textBetween(N-b,w-b,void 0,"");cFt(S,o.find,l).forEach(A=>{if(A.index===void 0)return;const I=N+A.index+1,L=I+A[0].length,O={from:r.tr.mapping.map(I),to:r.tr.mapping.map(L)},V=o.handler({state:r,range:O,match:A,commands:d,chain:u,can:p,pasteEvent:l,dropEvent:i});f.push(V)})}),f.every(_=>_!==null)}let $z=null;const uFt=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 hFt(t){const{editor:s,rules:r}=t;let n=null,a=!1,o=!1,l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,i;try{i=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{i=null}const d=({state:p,from:f,to:y,rule:_,pasteEvt:b})=>{const N=p.tr,w=xhe({state:p,transaction:N});if(!(!dFt({editor:s,state:w,from:Math.max(f-1,0),to:y.b-1,rule:_,pasteEvent:b,dropEvent:i})||!N.steps.length)){try{i=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{i=null}return l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,N}};return r.map(p=>new vu({view(f){const y=b=>{var N;n=!((N=f.dom.parentElement)===null||N===void 0)&&N.contains(b.target)?f.dom.parentElement:null,n&&($z=s)},_=()=>{$z&&($z=null)};return window.addEventListener("dragstart",y),window.addEventListener("dragend",_),{destroy(){window.removeEventListener("dragstart",y),window.removeEventListener("dragend",_)}}},props:{handleDOMEvents:{drop:(f,y)=>{if(o=n===f.dom.parentElement,i=y,!o){const _=$z;_!=null&&_.isEditable&&setTimeout(()=>{const b=_.state.selection;b&&_.commands.deleteRange({from:b.from,to:b.to})},10)}return!1},paste:(f,y)=>{var _;const b=(_=y.clipboardData)===null||_===void 0?void 0:_.getData("text/html");return l=y,a=!!(b!=null&&b.includes("data-pm-slice")),!1}}},appendTransaction:(f,y,_)=>{const b=f[0],N=b.getMeta("uiEvent")==="paste"&&!a,w=b.getMeta("uiEvent")==="drop"&&!o,S=b.getMeta("applyPasteRules"),C=!!S;if(!N&&!w&&!C)return;if(C){let{text:L}=S;typeof L=="string"?L=L:L=Mke(Tr.from(L),_.schema);const{from:O}=S,V=O+L.length,q=uFt(L);return d({rule:p,state:_,from:O,to:{b:V},pasteEvt:q})}const A=y.doc.content.findDiffStart(_.doc.content),I=y.doc.content.findDiffEnd(_.doc.content);if(!(!oFt(A)||!I||A===I.b))return d({rule:p,state:_,from:A,to:I,pasteEvt:l})}}))}function mFt(t){const s=t.filter((r,n)=>t.indexOf(r)!==n);return Array.from(new Set(s))}class nM{constructor(s,r){this.splittableMarks=[],this.editor=r,this.extensions=nM.resolve(s),this.schema=sFt(this.extensions,r),this.setupExtensions()}static resolve(s){const r=nM.sort(nM.flatten(s)),n=mFt(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=aa(r,"addExtensions",n);return a?[r,...this.flatten(a())]:r}).flat(10)}static sort(s){return s.sort((n,a)=>{const o=aa(n,"priority")||100,l=aa(a,"priority")||100;return o>l?-1:o{const n={name:r.name,options:r.options,storage:r.storage,editor:this.editor,type:aye(r.name,this.schema)},a=aa(r,"addCommands",n);return a?{...s,...a()}:s},{})}get plugins(){const{editor:s}=this,r=nM.sort([...this.extensions].reverse()),n=[],a=[],o=r.map(l=>{const i={name:l.name,options:l.options,storage:l.storage,editor:s,type:aye(l.name,this.schema)},d=[],u=aa(l,"addKeyboardShortcuts",i);let p={};if(l.type==="mark"&&aa(l,"exitable",i)&&(p.ArrowRight=()=>qg.handleExit({editor:s,mark:l})),u){const N=Object.fromEntries(Object.entries(u()).map(([w,S])=>[w,()=>S({editor:s})]));p={...p,...N}}const f=SOt(p);d.push(f);const y=aa(l,"addInputRules",i);d8e(l,s.options.enableInputRules)&&y&&n.push(...y());const _=aa(l,"addPasteRules",i);d8e(l,s.options.enablePasteRules)&&_&&a.push(..._());const b=aa(l,"addProseMirrorPlugins",i);if(b){const N=b();d.push(...N)}return d}).flat();return[aFt({editor:s,rules:n}),...hFt({editor:s,rules:a}),...o]}get attributes(){return MJe(this.extensions)}get nodeViews(){const{editor:s}=this,{nodeExtensions:r}=yhe(this.extensions);return Object.fromEntries(r.filter(n=>!!aa(n,"addNodeView")).map(n=>{const a=this.attributes.filter(d=>d.type===n.name),o={name:n.name,options:n.options,storage:n.storage,editor:s,type:Vu(n.name,this.schema)},l=aa(n,"addNodeView",o);if(!l)return[];const i=(d,u,p,f,y)=>{const _=S_e(d,a);return l()({node:d,view:u,getPos:p,decorations:f,innerDecorations:y,editor:s,extension:n,HTMLAttributes:_})};return[n.name,i]}))}setupExtensions(){this.extensions.forEach(s=>{var r;this.editor.extensionStorage[s.name]=s.storage;const n={name:s.name,options:s.options,storage:s.storage,editor:this.editor,type:aye(s.name,this.schema)};s.type==="mark"&&(!((r=Di(aa(s,"keepOnSplit",n)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(s.name);const a=aa(s,"onBeforeCreate",n),o=aa(s,"onCreate",n),l=aa(s,"onUpdate",n),i=aa(s,"onSelectionUpdate",n),d=aa(s,"onTransaction",n),u=aa(s,"onFocus",n),p=aa(s,"onBlur",n),f=aa(s,"onDestroy",n);a&&this.editor.on("beforeCreate",a),o&&this.editor.on("create",o),l&&this.editor.on("update",l),i&&this.editor.on("selectionUpdate",i),d&&this.editor.on("transaction",d),u&&this.editor.on("focus",u),p&&this.editor.on("blur",p),f&&this.editor.on("destroy",f)})}}class xh{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=Di(aa(this,"addOptions",{name:this.name}))),this.storage=Di(aa(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new xh(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>_he(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new xh({...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=Di(aa(r,"addOptions",{name:r.name})),r.storage=Di(aa(r,"addStorage",{name:r.name,options:r.options})),r}}function AJe(t,s,r){const{from:n,to:a}=s,{blockSeparator:o=` `,textSerializers:l={}}=r||{};let i="";return t.nodesBetween(n,a,(d,u,p,f)=>{var y;d.isBlock&&u>n&&(i+=o);const _=l==null?void 0:l[d.type.name];if(_)return p&&(i+=_({node:d,pos:u,parent:p,index:f,range:s})),!1;d.isText&&(i+=(y=d==null?void 0:d.text)===null||y===void 0?void 0:y.slice(Math.max(n,u)-u,a-u))}),i}function EJe(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,s])=>s.spec.toText).map(([s,r])=>[s,r.spec.toText]))}const pFt=xh.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new vu({key:new Vh("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:s,schema:r}=t,{doc:n,selection:a}=s,{ranges:o}=a,l=Math.min(...o.map(p=>p.$from.pos)),i=Math.max(...o.map(p=>p.$to.pos)),d=EJe(r);return AJe(n,{from:l,to:i},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:d})}}})]}}),fFt=()=>({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),xFt=(t=!1)=>({commands:s})=>s.setContent("",t),gFt=()=>({state:t,tr:s,dispatch:r})=>{const{selection:n}=s,{ranges:a}=n;return r&&a.forEach(({$from:o,$to:l})=>{t.doc.nodesBetween(o.pos,l.pos,(i,d)=>{if(i.type.isText)return;const{doc:u,mapping:p}=s,f=u.resolve(p.map(d)),y=u.resolve(p.map(d+i.nodeSize)),_=f.blockRange(y);if(!_)return;const b=eE(_);if(i.type.isTextblock){const{defaultType:N}=f.parent.contentMatchAt(f.index());s.setNodeMarkup(_.start,N)}(b||b===0)&&s.lift(_,b)})}),!0},yFt=t=>s=>t(s),vFt=()=>({state:t,dispatch:s})=>zOt(t,s),_Ft=(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 Ha(n.doc.resolve(Math.max(l-1,0)))),!0},bFt=()=>({tr:t,dispatch:s})=>{const{selection:r}=t,n=r.$anchor.node();if(n.content.size>0)return!1;const a=t.selection.$anchor;for(let o=a.depth;o>0;o-=1)if(a.node(o).type===n.type){if(s){const i=a.before(o),d=a.after(o);t.delete(i,d).scrollIntoView()}return!0}return!1},wFt=t=>({tr:s,state:r,dispatch:n})=>{const a=Vu(t,r.schema),o=s.selection.$anchor;for(let l=o.depth;l>0;l-=1)if(o.node(l).type===a){if(n){const d=o.before(l),u=o.after(l);s.delete(d,u).scrollIntoView()}return!0}return!1},jFt=t=>({tr:s,dispatch:r})=>{const{from:n,to:a}=t;return r&&s.delete(n,a),!0},NFt=()=>({state:t,dispatch:s})=>COt(t,s),kFt=()=>({commands:t})=>t.keyboardShortcut("Enter"),SFt=()=>({state:t,dispatch:s})=>FOt(t,s);function Dle(t,s,r={strict:!0}){const n=Object.keys(s);return n.length?n.every(a=>r.strict?s[a]===t[a]:Tke(s[a])?s[a].test(t[a]):s[a]===t[a]):!0}function PJe(t,s,r={}){return t.find(n=>n.type===s&&Dle(Object.fromEntries(Object.keys(r).map(a=>[a,n.attrs[a]])),r))}function u8e(t,s,r={}){return!!PJe(t,s,r)}function Ake(t,s,r){var n;if(!t||!s)return;let a=t.parent.childAfter(t.parentOffset);if((!a.node||!a.node.marks.some(p=>p.type===s))&&(a=t.parent.childBefore(t.parentOffset)),!a.node||!a.node.marks.some(p=>p.type===s)||(r=r||((n=a.node.marks[0])===null||n===void 0?void 0:n.attrs),!PJe([...a.node.marks],s,r)))return;let l=a.index,i=t.start()+a.offset,d=l+1,u=i+a.node.nodeSize;for(;l>0&&u8e([...t.parent.child(l-1).marks],s,r);)l-=1,i-=t.parent.child(l).nodeSize;for(;d({tr:r,state:n,dispatch:a})=>{const o=bw(t,n.schema),{doc:l,selection:i}=r,{$from:d,from:u,to:p}=i;if(a){const f=Ake(d,o,s);if(f&&f.from<=u&&f.to>=p){const y=Ha.create(l,f.from,f.to);r.setSelection(y)}}return!0},MFt=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=()=>{(Rle()||h8e())&&n.dom.focus(),requestAnimationFrame(()=>{r.isDestroyed||(n.focus(),TFt()&&!Rle()&&!h8e()&&n.dom.focus({preventScroll:!0}))})};if(n.hasFocus()&&t===null||t===!1)return!0;if(o&&t===null&&!IJe(r.state.selection))return l(),!0;const i=LJe(a.doc,t)||r.state.selection,d=r.state.selection.eq(i);return o&&(d||a.setSelection(i),d&&a.storedMarks&&a.setStoredMarks(a.storedMarks),l()),!0},EFt=(t,s)=>r=>t.every((n,a)=>s(n,{...r,index:a})),PFt=(t,s)=>({tr:r,commands:n})=>n.insertContentAt({from:r.selection.from,to:r.selection.to},t,s),DJe=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&&DJe(n)}return t};function qz(t){const s=`${t}`,r=new window.DOMParser().parseFromString(s,"text/html").body;return DJe(r)}function vD(t,s,r){if(t instanceof Rb||t instanceof Tr)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 Tr.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),vD("",s,r)}if(a){if(r.errorOnInvalidContent){let l=!1,i="";const d=new wQe({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?l8.fromSchema(d).parseSlice(qz(t),r.parseOptions):l8.fromSchema(d).parse(qz(t),r.parseOptions),r.errorOnInvalidContent&&l)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}const o=l8.fromSchema(s);return r.slice?o.parseSlice(qz(t),r.parseOptions).content:o.parse(qz(t),r.parseOptions)}return vD("",s,r)}function IFt(t,s,r){const n=t.steps.length-1;if(n{l===0&&(l=p)}),t.setSelection(ti.near(t.doc.resolve(l),r))}const LFt=t=>!("type"in t),DFt=(t,s,r)=>({tr:n,dispatch:a,editor:o})=>{var l;if(a){r={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...r};let i;const d=w=>{o.emit("contentError",{editor:o,error:w,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...r.parseOptions};if(!r.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{vD(s,o.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(w){d(w)}try{i=vD(s,o.schema,{parseOptions:u,errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:o.options.enableContentCheck})}catch(w){return d(w),!1}let{from:p,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},y=!0,_=!0;if((LFt(i)?i:[i]).forEach(w=>{w.check(),y=y?w.isText&&w.marks.length===0:!1,_=_?w.isBlock:!1}),p===f&&_){const{parent:w}=n.doc.resolve(p);w.isTextblock&&!w.type.spec.code&&!w.childCount&&(p-=1,f+=1)}let N;if(y){if(Array.isArray(s))N=s.map(w=>w.text||"").join("");else if(s instanceof Tr){let w="";s.forEach(S=>{S.text&&(w+=S.text)}),N=w}else typeof s=="object"&&s&&s.text?N=s.text:N=s;n.insertText(N,p,f)}else N=i,n.replaceWith(p,f,N);r.updateSelection&&IFt(n,n.steps.length-1,-1),r.applyInputRules&&n.setMeta("applyInputRules",{from:p,text:N}),r.applyPasteRules&&n.setMeta("applyPasteRules",{from:p,text:N})}return!0},RFt=()=>({state:t,dispatch:s})=>LOt(t,s),OFt=()=>({state:t,dispatch:s})=>DOt(t,s),FFt=()=>({state:t,dispatch:s})=>MOt(t,s),zFt=()=>({state:t,dispatch:s})=>POt(t,s),BFt=()=>({state:t,dispatch:s,tr:r})=>{try{const n=dhe(t.doc,t.selection.$from.pos,-1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},$Ft=()=>({state:t,dispatch:s,tr:r})=>{try{const n=dhe(t.doc,t.selection.$from.pos,1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},qFt=()=>({state:t,dispatch:s})=>TOt(t,s),UFt=()=>({state:t,dispatch:s})=>AOt(t,s);function RJe(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function VFt(t){const s=t.split(/-(?!$)/);let r=s[s.length-1];r==="Space"&&(r=" ");let n,a,o,l;for(let i=0;i({editor:s,view:r,tr:n,dispatch:a})=>{const o=VFt(t).split(/-(?!$)/),l=o.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),i=new KeyboardEvent("keydown",{key:l==="Space"?" ":l,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),d=s.captureTransaction(()=>{r.someProp("handleKeyDown",u=>u(r,i))});return d==null||d.steps.forEach(u=>{const p=u.map(n.mapping);p&&a&&n.maybeStep(p)}),!0};function _D(t,s,r={}){const{from:n,to:a,empty:o}=t.selection,l=s?Vu(s,t.schema):null,i=[];t.doc.nodesBetween(n,a,(f,y)=>{if(f.isText)return;const _=Math.max(n,y),b=Math.min(a,y+f.nodeSize);i.push({node:f,from:_,to:b})});const d=a-n,u=i.filter(f=>l?l.name===f.node.type.name:!0).filter(f=>Dle(f.node.attrs,r,{strict:!1}));return o?!!u.length:u.reduce((f,y)=>f+y.to-y.from,0)>=d}const GFt=(t,s={})=>({state:r,dispatch:n})=>{const a=Vu(t,r.schema);return _D(r,a,s)?ROt(r,n):!1},WFt=()=>({state:t,dispatch:s})=>BOt(t,s),KFt=t=>({state:s,dispatch:r})=>{const n=Vu(t,s.schema);return ZOt(n)(s,r)},ZFt=()=>({state:t,dispatch:s})=>OOt(t,s);function bhe(t,s){return s.nodes[t]?"node":s.marks[t]?"mark":null}function m8e(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 YFt=(t,s)=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=bhe(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=Vu(t,n.schema)),i==="mark"&&(l=bw(t,n.schema)),a&&r.selection.ranges.forEach(d=>{n.doc.nodesBetween(d.$from.pos,d.$to.pos,(u,p)=>{o&&o===u.type&&r.setNodeMarkup(p,void 0,m8e(u.attrs,s)),l&&u.marks.length&&u.marks.forEach(f=>{l===f.type&&r.addMark(p,p+u.nodeSize,l.create(m8e(f.attrs,s)))})})}),!0):!1},XFt=()=>({tr:t,dispatch:s})=>(s&&t.scrollIntoView(),!0),QFt=()=>({tr:t,dispatch:s})=>{if(s){const r=new bx(t.doc);t.setSelection(r)}return!0},JFt=()=>({state:t,dispatch:s})=>EOt(t,s),e7t=()=>({state:t,dispatch:s})=>IOt(t,s),t7t=()=>({state:t,dispatch:s})=>$Ot(t,s),s7t=()=>({state:t,dispatch:s})=>VOt(t,s),r7t=()=>({state:t,dispatch:s})=>UOt(t,s);function C_e(t,s,r={},n={}){return vD(t,s,{slice:!1,parseOptions:r,errorOnInvalidContent:n.errorOnInvalidContent})}const n7t=(t,s=!1,r={},n={})=>({editor:a,tr:o,dispatch:l,commands:i})=>{var d,u;const{doc:p}=o;if(r.preserveWhitespace!=="full"){const f=C_e(t,a.schema,r,{errorOnInvalidContent:(d=n.errorOnInvalidContent)!==null&&d!==void 0?d:a.options.enableContentCheck});return l&&o.replaceWith(0,p.content.size,f).setMeta("preventUpdate",!s),!0}return l&&o.setMeta("preventUpdate",!s),i.insertContentAt({from:0,to:p.content.size},t,{parseOptions:r,errorOnInvalidContent:(u=n.errorOnInvalidContent)!==null&&u!==void 0?u:a.options.enableContentCheck})};function OJe(t,s){const r=bw(s,t.schema),{from:n,to:a,empty:o}=t.selection,l=[];o?(t.storedMarks&&l.push(...t.storedMarks),l.push(...t.selection.$head.marks())):t.doc.nodesBetween(n,a,d=>{l.push(...d.marks)});const i=l.find(d=>d.type.name===r.name);return i?{...i.attrs}:{}}function a7t(t,s){const r=new pke(t);return s.forEach(n=>{n.steps.forEach(a=>{r.step(a)})}),r}function i7t(t){for(let s=0;s{r(a)&&n.push({node:a,pos:o})}),n}function FJe(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 Eke(t){return s=>FJe(s.$from,t)}function l7t(t,s){const r={from:0,to:t.content.size};return AJe(t,r,s)}function c7t(t,s){const r=Vu(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 zJe(t,s){const r=bhe(typeof s=="string"?s:s.name,t.schema);return r==="node"?c7t(t,s):r==="mark"?OJe(t,s):{}}function d7t(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 u7t(t){const s=d7t(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 h7t(t){const{mapping:s,steps:r}=t,n=[];return s.maps.forEach((a,o)=>{const l=[];if(a.ranges.length)a.forEach((i,d)=>{l.push({from:i,to:d})});else{const{from:i,to:d}=r[o];if(i===void 0||d===void 0)return;l.push({from:i,to:d})}l.forEach(({from:i,to:d})=>{const u=s.slice(o).map(i,-1),p=s.slice(o).map(d),f=s.invert().map(u,-1),y=s.invert().map(p);n.push({oldRange:{from:f,to:y},newRange:{from:u,to:p}})})}),u7t(n)}function Pke(t,s,r){const n=[];return t===s?r.resolve(t).marks().forEach(a=>{const o=r.resolve(t),l=Ake(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 toe(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 M_e(t,s,r={}){const{empty:n,ranges:a}=t.selection,o=s?bw(s,t.schema):null;if(n)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>o?o.name===f.type.name:!0).find(f=>Dle(f.attrs,r,{strict:!1}));let l=0;const i=[];if(a.forEach(({$from:f,$to:y})=>{const _=f.pos,b=y.pos;t.doc.nodesBetween(_,b,(N,w)=>{if(!N.isText&&!N.marks.length)return;const S=Math.max(_,w),C=Math.min(b,w+N.nodeSize),A=C-S;l+=A,i.push(...N.marks.map(I=>({mark:I,from:S,to:C})))})}),l===0)return!1;const d=i.filter(f=>o?o.name===f.mark.type.name:!0).filter(f=>Dle(f.mark.attrs,r,{strict:!1})).reduce((f,y)=>f+y.to-y.from,0),u=i.filter(f=>o?f.mark.type!==o&&f.mark.type.excludes(o):!0).reduce((f,y)=>f+y.to-y.from,0);return(d>0?d+u:d)>=l}function m7t(t,s,r={}){if(!s)return _D(t,null,r)||M_e(t,null,r);const n=bhe(s,t.schema);return n==="node"?_D(t,s,r):n==="mark"?M_e(t,s,r):!1}function p8e(t,s){const{nodeExtensions:r}=yhe(s),n=r.find(l=>l.name===t);if(!n)return!1;const a={name:n.name,options:n.options,storage:n.storage},o=Di(aa(n,"group",a));return typeof o!="string"?!1:o.split(" ").includes("list")}function Ike(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&&(Ike(o,{ignoreWhitespace:r,checkChildren:s})||(a=!1))}),a}return!1}function p7t(t){return t instanceof Fa}function f7t(t,s,r){var n;const{selection:a}=s;let o=null;if(IJe(a)&&(o=a.$cursor),o){const i=(n=t.storedMarks)!==null&&n!==void 0?n:o.marks();return!!r.isInSet(i)||!i.some(d=>d.type.excludes(r))}const{ranges:l}=a;return l.some(({$from:i,$to:d})=>{let u=i.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(r):!1;return t.doc.nodesBetween(i.pos,d.pos,(p,f,y)=>{if(u)return!1;if(p.isInline){const _=!y||y.type.allowsMarkType(r),b=!!r.isInSet(p.marks)||!p.marks.some(N=>N.type.excludes(r));u=_&&b}return!u}),u})}const x7t=(t,s={})=>({tr:r,state:n,dispatch:a})=>{const{selection:o}=r,{empty:l,ranges:i}=o,d=bw(t,n.schema);if(a)if(l){const u=OJe(n,d);r.addStoredMark(d.create({...u,...s}))}else i.forEach(u=>{const p=u.$from.pos,f=u.$to.pos;n.doc.nodesBetween(p,f,(y,_)=>{const b=Math.max(_,p),N=Math.min(_+y.nodeSize,f);y.marks.find(S=>S.type===d)?y.marks.forEach(S=>{d===S.type&&r.addMark(b,N,d.create({...S.attrs,...s}))}):r.addMark(b,N,d.create(s))})});return f7t(n,r,d)},g7t=(t,s)=>({tr:r})=>(r.setMeta(t,s),!0),y7t=(t,s={})=>({state:r,dispatch:n,chain:a})=>{const o=Vu(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})=>o8e(o,{...l,...s})(r)?!0:i.clearNodes()).command(({state:i})=>o8e(o,{...l,...s})(i,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},v7t=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,a=j4(t,0,n.content.size),o=Fa.create(n,a);s.setSelection(o)}return!0},_7t=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,{from:a,to:o}=typeof t=="number"?{from:t,to:t}:t,l=Ha.atStart(n).from,i=Ha.atEnd(n).to,d=j4(a,l,i),u=j4(o,l,i),p=Ha.create(n,d,u);s.setSelection(p)}return!0},b7t=t=>({state:s,dispatch:r})=>{const n=Vu(t,s.schema);return QOt(n)(s,r)};function f8e(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 w7t=({keepMarks:t=!0}={})=>({tr:s,state:r,dispatch:n,editor:a})=>{const{selection:o,doc:l}=s,{$from:i,$to:d}=o,u=a.extensionManager.attributes,p=toe(u,i.node().type.name,i.node().attrs);if(o instanceof Fa&&o.node.isBlock)return!i.parentOffset||!ZM(l,i.pos)?!1:(n&&(t&&f8e(r,a.extensionManager.splittableMarks),s.split(i.pos).scrollIntoView()),!0);if(!i.parent.isBlock)return!1;const f=d.parentOffset===d.parent.content.size,y=i.depth===0?void 0:i7t(i.node(-1).contentMatchAt(i.indexAfter(-1)));let _=f&&y?[{type:y,attrs:p}]:void 0,b=ZM(s.doc,s.mapping.map(i.pos),1,_);if(!_&&!b&&ZM(s.doc,s.mapping.map(i.pos),1,y?[{type:y}]:void 0)&&(b=!0,_=y?[{type:y,attrs:p}]:void 0),n){if(b&&(o instanceof Ha&&s.deleteSelection(),s.split(s.mapping.map(i.pos),1,_),y&&!f&&!i.parentOffset&&i.parent.type!==y)){const N=s.mapping.map(i.before()),w=s.doc.resolve(N);i.node(-1).canReplaceWith(w.index(),w.index()+1,y)&&s.setNodeMarkup(s.mapping.map(i.before()),y)}t&&f8e(r,a.extensionManager.splittableMarks),s.scrollIntoView()}return b},j7t=(t,s={})=>({tr:r,state:n,dispatch:a,editor:o})=>{var l;const i=Vu(t,n.schema),{$from:d,$to:u}=n.selection,p=n.selection.node;if(p&&p.isBlock||d.depth<2||!d.sameParent(u))return!1;const f=d.node(-1);if(f.type!==i)return!1;const y=o.extensionManager.attributes;if(d.parent.content.size===0&&d.node(-1).childCount===d.indexAfter(-1)){if(d.depth===2||d.node(-3).type!==i||d.index(-2)!==d.node(-2).childCount-1)return!1;if(a){let S=Tr.empty;const C=d.index(-1)?1:d.index(-2)?2:3;for(let q=d.depth-C;q>=d.depth-3;q-=1)S=Tr.from(d.node(q).copy(S));const A=d.indexAfter(-1){if(V>-1)return!1;q.isTextblock&&q.content.size===0&&(V=B+1)}),V>-1&&r.setSelection(Ha.near(r.doc.resolve(V))),r.scrollIntoView()}return!0}const _=u.pos===d.end()?f.contentMatchAt(0).defaultType:null,b={...toe(y,f.type.name,f.attrs),...s},N={...toe(y,d.node().type.name,d.node().attrs),...s};r.delete(d.pos,u.pos);const w=_?[{type:i,attrs:b},{type:_,attrs:N}]:[{type:i,attrs:b}];if(!ZM(r.doc,d.pos,2))return!1;if(a){const{selection:S,storedMarks:C}=n,{splittableMarks:A}=o.extensionManager,I=C||S.$to.parentOffset&&S.$from.marks();if(r.split(d.pos,2,w).scrollIntoView(),!I||!a)return!0;const L=I.filter(O=>A.includes(O.type.name));r.ensureMarks(L)}return!0},iye=(t,s)=>{const r=Eke(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)&&vw(t.doc,r.pos)&&t.join(r.pos),!0},oye=(t,s)=>{const r=Eke(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)&&vw(t.doc,n)&&t.join(n),!0},N7t=(t,s,r,n={})=>({editor:a,tr:o,state:l,dispatch:i,chain:d,commands:u,can:p})=>{const{extensions:f,splittableMarks:y}=a.extensionManager,_=Vu(t,l.schema),b=Vu(s,l.schema),{selection:N,storedMarks:w}=l,{$from:S,$to:C}=N,A=S.blockRange(C),I=w||N.$to.parentOffset&&N.$from.marks();if(!A)return!1;const L=Eke(O=>p8e(O.type.name,f))(N);if(A.depth>=1&&L&&A.depth-L.depth<=1){if(L.node.type===_)return u.liftListItem(b);if(p8e(L.node.type.name,f)&&_.validContent(L.node.content)&&i)return d().command(()=>(o.setNodeMarkup(L.pos,_),!0)).command(()=>iye(o,_)).command(()=>oye(o,_)).run()}return!r||!I||!i?d().command(()=>p().wrapInList(_,n)?!0:u.clearNodes()).wrapInList(_,n).command(()=>iye(o,_)).command(()=>oye(o,_)).run():d().command(()=>{const O=p().wrapInList(_,n),V=I.filter(q=>y.includes(q.type.name));return o.ensureMarks(V),O?!0:u.clearNodes()}).wrapInList(_,n).command(()=>iye(o,_)).command(()=>oye(o,_)).run()},k7t=(t,s={},r={})=>({state:n,commands:a})=>{const{extendEmptyMarkRange:o=!1}=r,l=bw(t,n.schema);return M_e(n,l,s)?a.unsetMark(l,{extendEmptyMarkRange:o}):a.setMark(l,s)},S7t=(t,s,r={})=>({state:n,commands:a})=>{const o=Vu(t,n.schema),l=Vu(s,n.schema),i=_D(n,o,r);let d;return n.selection.$anchor.sameParent(n.selection.$head)&&(d=n.selection.$anchor.parent.attrs),i?a.setNode(l,d):a.setNode(o,{...d,...r})},C7t=(t,s={})=>({state:r,commands:n})=>{const a=Vu(t,r.schema);return _D(r,a,s)?n.lift(a):n.wrapIn(a,s)},M7t=()=>({state:t,dispatch:s})=>{const r=t.plugins;for(let n=0;n=0;d-=1)l.step(i.steps[d].invert(i.docs[d]));if(o.text){const d=l.doc.resolve(o.from).marks();l.replaceWith(o.from,o.to,t.schema.text(o.text,d))}else l.delete(o.from,o.to)}return!0}}return!1},T7t=()=>({tr:t,dispatch:s})=>{const{selection:r}=t,{empty:n,ranges:a}=r;return n||s&&a.forEach(o=>{t.removeMark(o.$from.pos,o.$to.pos)}),!0},A7t=(t,s={})=>({tr:r,state:n,dispatch:a})=>{var o;const{extendEmptyMarkRange:l=!1}=s,{selection:i}=r,d=bw(t,n.schema),{$from:u,empty:p,ranges:f}=i;if(!a)return!0;if(p&&l){let{from:y,to:_}=i;const b=(o=u.marks().find(w=>w.type===d))===null||o===void 0?void 0:o.attrs,N=Ake(u,d,b);N&&(y=N.from,_=N.to),r.removeMark(y,_,d)}else f.forEach(y=>{r.removeMark(y.$from.pos,y.$to.pos,d)});return r.removeStoredMark(d),!0},E7t=(t,s={})=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=bhe(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=Vu(t,n.schema)),i==="mark"&&(l=bw(t,n.schema)),a&&r.selection.ranges.forEach(d=>{const u=d.$from.pos,p=d.$to.pos;let f,y,_,b;r.selection.empty?n.doc.nodesBetween(u,p,(N,w)=>{o&&o===N.type&&(_=Math.max(w,u),b=Math.min(w+N.nodeSize,p),f=w,y=N)}):n.doc.nodesBetween(u,p,(N,w)=>{w=u&&w<=p&&(o&&o===N.type&&r.setNodeMarkup(w,void 0,{...N.attrs,...s}),l&&N.marks.length&&N.marks.forEach(S=>{if(l===S.type){const C=Math.max(w,u),A=Math.min(w+N.nodeSize,p);r.addMark(C,A,l.create({...S.attrs,...s}))}}))}),y&&(f!==void 0&&r.setNodeMarkup(f,void 0,{...y.attrs,...s}),l&&y.marks.length&&y.marks.forEach(N=>{l===N.type&&r.addMark(_,b,l.create({...N.attrs,...s}))}))}),!0):!1},P7t=(t,s={})=>({state:r,dispatch:n})=>{const a=Vu(t,r.schema);return HOt(a,s)(r,n)},I7t=(t,s={})=>({state:r,dispatch:n})=>{const a=Vu(t,r.schema);return GOt(a,s)(r,n)};var L7t=Object.freeze({__proto__:null,blur:fFt,clearContent:xFt,clearNodes:gFt,command:yFt,createParagraphNear:vFt,cut:_Ft,deleteCurrentNode:bFt,deleteNode:wFt,deleteRange:jFt,deleteSelection:NFt,enter:kFt,exitCode:SFt,extendMarkRange:CFt,first:MFt,focus:AFt,forEach:EFt,insertContent:PFt,insertContentAt:DFt,joinBackward:FFt,joinDown:OFt,joinForward:zFt,joinItemBackward:BFt,joinItemForward:$Ft,joinTextblockBackward:qFt,joinTextblockForward:UFt,joinUp:RFt,keyboardShortcut:HFt,lift:GFt,liftEmptyBlock:WFt,liftListItem:KFt,newlineInCode:ZFt,resetAttributes:YFt,scrollIntoView:XFt,selectAll:QFt,selectNodeBackward:JFt,selectNodeForward:e7t,selectParentNode:t7t,selectTextblockEnd:s7t,selectTextblockStart:r7t,setContent:n7t,setMark:x7t,setMeta:g7t,setNode:y7t,setNodeSelection:v7t,setTextSelection:_7t,sinkListItem:b7t,splitBlock:w7t,splitListItem:j7t,toggleList:N7t,toggleMark:k7t,toggleNode:S7t,toggleWrap:C7t,undoInputRule:M7t,unsetAllMarks:T7t,unsetMark:A7t,updateAttributes:E7t,wrapIn:P7t,wrapInList:I7t});const D7t=xh.create({name:"commands",addCommands(){return{...L7t}}}),R7t=xh.create({name:"drop",addProseMirrorPlugins(){return[new vu({key:new Vh("tiptapDrop"),props:{handleDrop:(t,s,r,n)=>{this.editor.emit("drop",{editor:this.editor,event:s,slice:r,moved:n})}}})]}}),O7t=xh.create({name:"editable",addProseMirrorPlugins(){return[new vu({key:new Vh("editable"),props:{editable:()=>this.editor.options.editable}})]}}),F7t=new Vh("focusEvents"),z7t=xh.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new vu({key:F7t,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}}}})]}}),B7t=xh.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:l})=>[()=>l.undoInputRule(),()=>l.command(({tr:i})=>{const{selection:d,doc:u}=i,{empty:p,$anchor:f}=d,{pos:y,parent:_}=f,b=f.parent.isTextblock&&y>0?i.doc.resolve(y-1):f,N=b.parent.type.spec.isolating,w=f.pos-f.parentOffset,S=N&&b.parent.childCount===1?w===f.pos:ti.atStart(u).from===y;return!p||!_.type.isTextblock||_.textContent.length||!S||S&&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 Rle()||RJe()?o:a},addProseMirrorPlugins(){return[new vu({key:new Vh("clearDocument"),appendTransaction:(t,s,r)=>{if(t.some(N=>N.getMeta("composition")))return;const n=t.some(N=>N.docChanged)&&!s.doc.eq(r.doc),a=t.some(N=>N.getMeta("preventClearDocument"));if(!n||a)return;const{empty:o,from:l,to:i}=s.selection,d=ti.atStart(s.doc).from,u=ti.atEnd(s.doc).to;if(o||!(l===d&&i===u)||!Ike(r.doc))return;const y=r.tr,_=xhe({state:r,transaction:y}),{commands:b}=new ghe({editor:this.editor,state:_});if(b.clearNodes(),!!y.steps.length)return y}})]}}),$7t=xh.create({name:"paste",addProseMirrorPlugins(){return[new vu({key:new Vh("tiptapPaste"),props:{handlePaste:(t,s,r)=>{this.editor.emit("paste",{editor:this.editor,event:s,slice:r})}}})]}}),q7t=xh.create({name:"tabindex",addProseMirrorPlugins(){return[new vu({key:new Vh("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class u4{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 u4(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 u4(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 u4(s,this.editor)}get children(){const s=[];return this.node.content.forEach((r,n)=>{const a=r.isBlock&&!r.isTextblock,o=r.isAtom&&!r.isText,l=this.pos+n+(o?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const i=this.resolvedPos.doc.resolve(l);if(!a&&i.depth<=this.depth)return;const d=new u4(i,this.editor,a,a?r:null);a&&(d.actualDepth=this.depth+1),s.push(new u4(i,this.editor,a,a?r:null))}),s}get firstChild(){return this.children[0]||null}get lastChild(){const s=this.children;return s[s.length-1]||null}closest(s,r={}){let n=null,a=this.parent;for(;a&&!n;){if(a.node.type.name===s)if(Object.keys(r).length>0){const o=a.node.attrs,l=Object.keys(r);for(let i=0;i{n&&a.length>0||(l.node.type.name===s&&o.every(d=>r[d]===l.node.attrs[d])&&a.push(l),!(n&&a.length>0)&&(a=a.concat(l.querySelectorAll(s,r,n))))}),a}setAttribute(s){const{tr:r}=this.editor.state;r.setNodeMarkup(this.from,void 0,{...this.node.attrs,...s}),this.editor.view.dispatch(r)}}const U7t=`.ProseMirror { position: relative; } .ProseMirror { word-wrap: break-word; white-space: pre-wrap; white-space: break-spaces; -webkit-font-variant-ligatures: none; font-variant-ligatures: none; font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */ } .ProseMirror [contenteditable="false"] { white-space: normal; } .ProseMirror [contenteditable="false"] [contenteditable="true"] { white-space: pre-wrap; } .ProseMirror pre { white-space: pre-wrap; } img.ProseMirror-separator { display: inline !important; border: none !important; margin: 0 !important; width: 0 !important; height: 0 !important; } .ProseMirror-gapcursor { display: none; pointer-events: none; position: absolute; margin: 0; } .ProseMirror-gapcursor:after { content: ""; display: block; position: absolute; top: -2px; width: 20px; border-top: 1px solid black; animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite; } @keyframes ProseMirror-cursor-blink { to { visibility: hidden; } } .ProseMirror-hideselection *::selection { background: transparent; } .ProseMirror-hideselection *::-moz-selection { background: transparent; } .ProseMirror-hideselection * { caret-color: transparent; } .ProseMirror-focused .ProseMirror-gapcursor { display: block; } .tippy-box[data-animation=fade][data-state=hidden] { opacity: 0 }`;function V7t(t,s,r){const n=document.querySelector("style[data-tiptap-style]");if(n!==null)return n;const a=document.createElement("style");return s&&a.setAttribute("nonce",s),a.setAttribute("data-tiptap-style",""),a.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(a),a}class H7t extends JOt{constructor(s={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(s),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:n,moved:a})=>this.options.onDrop(r,n,a)),this.on("paste",({event:r,slice:n})=>this.options.onPaste(r,n)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=V7t(U7t,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=TJe(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?[O7t,pFt.configure({blockSeparator:(r=(s=this.options.coreExtensionOptions)===null||s===void 0?void 0:s.clipboardTextSerializer)===null||r===void 0?void 0:r.blockSeparator}),D7t,z7t,B7t,q7t,R7t,$7t].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 nM(a,this)}createCommandManager(){this.commandManager=new ghe({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var s;let r;try{r=C_e(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=C_e(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const n=LJe(r,this.options.autofocus);this.view=new bJe(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:rM.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 zJe(this.state,s)}isActive(s,r){const n=typeof s=="string"?s:null,a=typeof s=="string"?r:s;return m7t(this.state,n,a)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Mke(this.state.doc.content,this.schema)}getText(s){const{blockSeparator:r=` `,textSerializers:n={}}=s||{};return l7t(this.state.doc,{blockSeparator:r,textSerializers:{...EJe(this.schema),...n}})}get isEmpty(){return Ike(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 u4(r,this)}get $doc(){return this.$pos(0)}}function HT(t){return new vhe({find:t.find,handler:({state:s,range:r,match:n})=>{const a=Di(t.getAttributes,void 0,n);if(a===!1||a===null)return null;const{tr:o}=s,l=n[n.length-1],i=n[0];if(l){const d=i.search(/\S/),u=r.from+i.indexOf(l),p=u+l.length;if(Pke(r.from,r.to,s.doc).filter(_=>_.mark.type.excluded.find(N=>N===t.type&&N!==_.mark.type)).filter(_=>_.to>u).length)return null;pr.from&&o.delete(r.from+d,u);const y=r.from+d+l.length;o.addMark(r.from+d,y,t.type.create(a||{})),o.removeStoredMark(t.type)}}})}function BJe(t){return new vhe({find:t.find,handler:({state:s,range:r,match:n})=>{const a=Di(t.getAttributes,void 0,n)||{},{tr:o}=s,l=r.from;let i=r.to;const d=t.type.create(a);if(n[1]){const u=n[0].lastIndexOf(n[1]);let p=l+u;p>i?p=i:i=p+n[1].length;const f=n[0][n[0].length-1];o.insertText(f,l+n[0].length-1),o.replaceWith(p,i,d)}else if(n[0]){const u=t.type.isInline?l:l-1;o.insert(u,t.type.create(a)).delete(o.mapping.map(l),o.mapping.map(i))}o.scrollIntoView()}})}function T_e(t){return new vhe({find:t.find,handler:({state:s,range:r,match:n})=>{const a=s.doc.resolve(r.from),o=Di(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 bD(t){return new vhe({find:t.find,handler:({state:s,range:r,match:n,chain:a})=>{const o=Di(t.getAttributes,void 0,n)||{},l=s.tr.delete(r.from,r.to),d=l.doc.resolve(r.from).blockRange(),u=d&&mke(d,t.type,o);if(!u)return null;if(l.wrap(d,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:y}=s,{splittableMarks:_}=t.editor.extensionManager,b=y||f.$to.parentOffset&&f.$from.marks();if(b){const N=b.filter(w=>_.includes(w.type.name));l.ensureMarks(N)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";a().updateAttributes(f,o).run()}const p=l.doc.resolve(r.from-1).nodeBefore;p&&p.type===t.type&&vw(l.doc,r.from-1)&&(!t.joinPredicate||t.joinPredicate(n,p))&&l.join(r.from-1)}})}let Hh=class A_e{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=Di(aa(this,"addOptions",{name:this.name}))),this.storage=Di(aa(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new A_e(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>_he(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new A_e(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=Di(aa(r,"addOptions",{name:r.name})),r.storage=Di(aa(r,"addStorage",{name:r.name,options:r.options})),r}};function rC(t){return new lFt({find:t.find,handler:({state:s,range:r,match:n,pasteEvent:a})=>{const o=Di(t.getAttributes,void 0,n,a);if(o===!1||o===null)return null;const{tr:l}=s,i=n[n.length-1],d=n[0];let u=r.to;if(i){const p=d.search(/\S/),f=r.from+d.indexOf(i),y=f+i.length;if(Pke(r.from,r.to,s.doc).filter(b=>b.mark.type.excluded.find(w=>w===t.type&&w!==b.mark.type)).filter(b=>b.to>f).length)return null;yr.from&&l.delete(r.from+p,f),u=r.from+p+i.length,l.addMark(r.from+p,u,t.type.create(o||{})),l.removeStoredMark(t.type)}}})}function G7t(t,s){const{selection:r}=t,{$from:n}=r;if(r instanceof Fa){const o=n.index();return n.parent.canReplaceWith(o,o+1,s)}let a=n.depth;for(;a>=0;){const o=n.index(a);if(n.node(a).contentMatchAt(o).matchType(s))return!0;a-=1}return!1}function W7t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var $Je={exports:{}},lye={};/** * @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 x8e;function K7t(){if(x8e)return lye;x8e=1;var t=xt;function s(f,y){return f===y&&(f!==0||1/f===1/y)||f!==f&&y!==y}var r=typeof Object.is=="function"?Object.is:s,n=t.useState,a=t.useEffect,o=t.useLayoutEffect,l=t.useDebugValue;function i(f,y){var _=y(),b=n({inst:{value:_,getSnapshot:y}}),N=b[0].inst,w=b[1];return o(function(){N.value=_,N.getSnapshot=y,d(N)&&w({inst:N})},[f,_,y]),a(function(){return d(N)&&w({inst:N}),f(function(){d(N)&&w({inst:N})})},[f]),l(_),_}function d(f){var y=f.getSnapshot;f=f.value;try{var _=y();return!r(f,_)}catch{return!0}}function u(f,y){return y()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:i;return lye.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:p,lye}$Je.exports=K7t();var Lke=$Je.exports;const Z7t=(...t)=>s=>{t.forEach(r=>{typeof r=="function"?r(s):r&&(r.current=s)})},Y7t=({contentComponent:t})=>{const s=Lke.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return xt.createElement(xt.Fragment,null,Object.values(s))};function X7t(){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]:eje.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 Q7t extends xt.Component{constructor(s){var r;super(s),this.editorContentRef=xt.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=X7t(),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 xt.createElement(xt.Fragment,null,xt.createElement("div",{ref:Z7t(r,this.editorContentRef),...n}),(s==null?void 0:s.contentComponent)&&xt.createElement(Y7t,{contentComponent:s.contentComponent}))}}const J7t=k.forwardRef((t,s)=>{const r=xt.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return xt.createElement(Q7t,{key:r,innerRef:s,...t})}),Dke=xt.memo(J7t);var ezt=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},tzt=W7t(ezt),qJe={exports:{}},cye={};/** * @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 g8e;function szt(){if(g8e)return cye;g8e=1;var t=xt,s=Lke;function r(u,p){return u===p&&(u!==0||1/u===1/p)||u!==u&&p!==p}var n=typeof Object.is=="function"?Object.is:r,a=s.useSyncExternalStore,o=t.useRef,l=t.useEffect,i=t.useMemo,d=t.useDebugValue;return cye.useSyncExternalStoreWithSelector=function(u,p,f,y,_){var b=o(null);if(b.current===null){var N={hasValue:!1,value:null};b.current=N}else N=b.current;b=i(function(){function S(O){if(!C){if(C=!0,A=O,O=y(O),_!==void 0&&N.hasValue){var V=N.value;if(_(V,O))return I=V}return I=O}if(V=I,n(A,O))return V;var q=y(O);return _!==void 0&&_(V,q)?V:(A=O,I=q)}var C=!1,A,I,L=f===void 0?null:f;return[function(){return S(p())},L===null?void 0:function(){return S(L())}]},[p,f,y,_]);var w=a(u,b[0],b[1]);return l(function(){N.hasValue=!0,N.value=w},[w]),d(w),w},cye}qJe.exports=szt();var rzt=qJe.exports;const nzt=typeof window<"u"?k.useLayoutEffect:k.useEffect;class azt{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 izt(t){var s;const[r]=k.useState(()=>new azt(t.editor)),n=rzt.useSyncExternalStoreWithSelector(r.subscribe,r.getSnapshot,r.getServerSnapshot,t.selector,(s=t.equalityFn)!==null&&s!==void 0?s:tzt);return nzt(()=>r.watch(t.editor),[t.editor,r]),k.useDebugValue(n),n}const ozt=!1,E_e=typeof window>"u",lzt=E_e||!!(typeof window<"u"&&window.next);class Rke{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(){if(this.options.current.immediatelyRender===void 0)return E_e||lzt?null:this.createEditor();if(this.options.current.immediatelyRender&&E_e&&ozt)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return 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 H7t(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?Rke.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 Oke(t={},s=[]){const r=k.useRef(t);r.current=t;const[n]=k.useState(()=>new Rke(r)),a=Lke.useSyncExternalStore(n.subscribe,n.getEditor,n.getServerSnapshot);return k.useDebugValue(a),k.useEffect(n.onRender(s)),izt({editor:a,selector:({transactionNumber:o})=>t.shouldRerenderOnTransaction===!1?null:t.immediatelyRender&&o===0?0:o+1}),a}const czt=k.createContext({editor:null});czt.Consumer;const dzt=k.createContext({onDragStart:void 0}),uzt=()=>k.useContext(dzt);xt.forwardRef((t,s)=>{const{onDragStart:r}=uzt(),n=t.as||"div";return xt.createElement(n,{...t,ref:s,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...t.style}})});const hzt=/^\s*>\s$/,mzt=Hh.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",jc(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[bD({find:hzt,type:this.type})]}}),pzt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,fzt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,xzt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,gzt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,yzt=qg.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",jc(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[HT({find:pzt,type:this.type}),HT({find:xzt,type:this.type})]},addPasteRules(){return[rC({find:fzt,type:this.type}),rC({find:gzt,type:this.type})]}}),vzt="listItem",y8e="textStyle",v8e=/^\s*([-+*])\s$/,_zt=Hh.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",jc(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(vzt,this.editor.getAttributes(y8e)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=bD({find:v8e,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=bD({find:v8e,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(y8e),editor:this.editor})),[t]}}),bzt=/(^|[^`])`([^`]+)`(?!`)/,wzt=/(^|[^`])`([^`]+)`(?!`)/g,jzt=qg.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",jc(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[HT({find:bzt,type:this.type})]},addPasteRules(){return[rC({find:wzt,type:this.type})]}}),Nzt=/^```([a-z]+)?[\s\n]$/,kzt=/^~~~([a-z]+)?[\s\n]$/,Szt=Hh.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",jc(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(ti.near(n.resolve(i))),!0)):t.commands.exitCode()}}},addInputRules(){return[T_e({find:Nzt,type:this.type,getAttributes:t=>({language:t[1]})}),T_e({find:kzt,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new vu({key:new Vh("codeBlockVSCodeHandler"),props:{handlePaste:(t,s)=>{if(!s.clipboardData||this.editor.isActive(this.type.name))return!1;const r=s.clipboardData.getData("text/plain"),n=s.clipboardData.getData("vscode-editor-data"),a=n?JSON.parse(n):void 0,o=a==null?void 0:a.mode;if(!r||!o)return!1;const{tr:l,schema:i}=t.state,d=i.text(r.replace(/\r\n?/g,` `));return l.replaceSelectionWith(this.type.create({language:o},d)),l.selection.$from.parent.type!==this.type&&l.setSelection(Ha.near(l.doc.resolve(Math.max(0,l.selection.from-2)))),l.setMeta("paste",!0),t.dispatch(l),!0}}})]}}),Czt=Hh.create({name:"doc",topNode:!0,content:"block+"});function Mzt(t={}){return new vu({view(s){return new Tzt(s,t)}})}class Tzt{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,y=s.nodeAfter;if(f||y){let _=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(_){let b=_.getBoundingClientRect(),N=f?b.bottom:b.top;f&&y&&(N=(N+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let w=this.width/2*i;n={left:b.left,right:b.right,top:N-w,bottom:N+w}}}}if(!n){let f=this.editorView.coordsAtPos(this.cursorPos),y=this.width/2*l;n={left:f.left-y,right:f.left+y,top:f.top,bottom:f.bottom}}let d=this.editorView.dom.offsetParent;this.element||(this.element=d.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",r),this.element.classList.toggle("prosemirror-dropcursor-inline",!r);let u,p;if(!d||d==document.body&&getComputedStyle(d).position=="static")u=-pageXOffset,p=-pageYOffset;else{let f=d.getBoundingClientRect(),y=f.width/d.offsetWidth,_=f.height/d.offsetHeight;u=f.left-d.scrollLeft*y,p=f.top-d.scrollTop*_}this.element.style.left=(n.left-u)/l+"px",this.element.style.top=(n.top-p)/i+"px",this.element.style.width=(n.right-n.left)/l+"px",this.element.style.height=(n.bottom-n.top)/i+"px"}scheduleRemoval(s){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),s)}dragover(s){if(!this.editorView.editable)return;let r=this.editorView.posAtCoords({left:s.clientX,top:s.clientY}),n=r&&r.inside>=0&&this.editorView.state.doc.nodeAt(r.inside),a=n&&n.type.spec.disableDropCursor,o=typeof a=="function"?a(this.editorView,r,s):a;if(r&&!o){let l=r.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let i=IQe(this.editorView.state.doc,l,this.editorView.dragging.slice);i!=null&&(l=i)}this.setCursor(l),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(s){this.editorView.dom.contains(s.relatedTarget)||this.setCursor(null)}}const Azt=xh.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Mzt(this.options)]}});class Qc extends ti{constructor(s){super(s,s)}map(s,r){let n=s.resolve(r.map(this.head));return Qc.valid(n)?new Qc(n):ti.near(n)}content(){return wn.empty}eq(s){return s instanceof Qc&&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 Qc(s.resolve(r.pos))}getBookmark(){return new Fke(this.anchor)}static valid(s){let r=s.parent;if(r.inlineContent||!Ezt(s)||!Pzt(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&&Qc.valid(s))return s;let a=s.pos,o=null;for(let l=s.depth;;l--){let i=s.node(l);if(r>0?s.indexAfter(l)0){o=i.child(r>0?s.indexAfter(l):s.index(l)-1);break}else if(l==0)return null;a+=r;let d=s.doc.resolve(a);if(Qc.valid(d))return d}for(;;){let l=r>0?o.firstChild:o.lastChild;if(!l){if(o.isAtom&&!o.isText&&!Fa.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(Qc.valid(i))return i}return null}}}Qc.prototype.visible=!1;Qc.findFrom=Qc.findGapCursorFrom;ti.jsonID("gapcursor",Qc);class Fke{constructor(s){this.pos=s}map(s){return new Fke(s.map(this.pos))}resolve(s){let r=s.resolve(this.pos);return Qc.valid(r)?new Qc(r):ti.near(r)}}function UJe(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function Ezt(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||UJe(a.type))return!0;if(a.inlineContent)return!1}}return!0}function Pzt(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||UJe(a.type))return!0;if(a.inlineContent)return!1}}return!0}function Izt(){return new vu({props:{decorations:Ozt,createSelectionBetween(t,s,r){return s.pos==r.pos&&Qc.valid(r)?new Qc(r):null},handleClick:Dzt,handleKeyDown:Lzt,handleDOMEvents:{beforeinput:Rzt}}})}const Lzt=kke({ArrowLeft:Uz("horiz",-1),ArrowRight:Uz("horiz",1),ArrowUp:Uz("vert",-1),ArrowDown:Uz("vert",1)});function Uz(t,s){const r=t=="vert"?s>0?"down":"up":s>0?"right":"left";return function(n,a,o){let l=n.selection,i=s>0?l.$to:l.$from,d=l.empty;if(l instanceof Ha){if(!o.endOfTextblock(r)||i.depth==0)return!1;d=!1,i=n.doc.resolve(s>0?i.after():i.before())}let u=Qc.findGapCursorFrom(i,s,d);return u?(a&&a(n.tr.setSelection(new Qc(u))),!0):!1}}function Dzt(t,s,r){if(!t||!t.editable)return!1;let n=t.state.doc.resolve(s);if(!Qc.valid(n))return!1;let a=t.posAtCoords({left:r.clientX,top:r.clientY});return a&&a.inside>-1&&Fa.isSelectable(t.state.doc.nodeAt(a.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Qc(n))),!0)}function Rzt(t,s){if(s.inputType!="insertCompositionText"||!(t.state.selection instanceof Qc))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=Tr.empty;for(let l=n.length-1;l>=0;l--)a=Tr.from(n[l].createAndFill(null,a));let o=t.state.tr.replace(r.pos,r.pos,new wn(a,0,0));return o.setSelection(Ha.near(o.doc.resolve(r.pos+1))),t.dispatch(o),!1}function Ozt(t){if(!(t.selection instanceof Qc))return null;let s=document.createElement("div");return s.className="ProseMirror-gapcursor",Xc.create(t.doc,[bm.widget(t.selection.head,s,{key:"gapcursor"})])}const Fzt=xh.create({name:"gapCursor",addProseMirrorPlugins(){return[Izt()]},extendNodeSchema(t){var s;const r={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(s=Di(aa(t,"allowGapCursor",r)))!==null&&s!==void 0?s:null}}}),zzt=Hh.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",jc(this.options.HTMLAttributes,t)]},renderText(){return` `},addCommands(){return{setHardBreak:()=>({commands:t,chain:s,state:r,editor:n})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:a,storedMarks:o}=r;if(a.$from.parent.type.spec.isolating)return!1;const{keepMarks:l}=this.options,{splittableMarks:i}=n.extensionManager,d=o||a.$to.parentOffset&&a.$from.marks();return s().insertContent({type:this.name}).command(({tr:u,dispatch:p})=>{if(p&&d&&l){const f=d.filter(y=>i.includes(y.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Bzt=Hh.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]}`,jc(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=>T_e({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var Ole=200,qu=function(){};qu.prototype.append=function(s){return s.length?(s=qu.from(s),!this.length&&s||s.length=r?qu.empty:this.sliceInner(Math.max(0,s),Math.min(this.length,r))};qu.prototype.get=function(s){if(!(s<0||s>=this.length))return this.getInner(s)};qu.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)};qu.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};qu.from=function(s){return s instanceof qu?s:s&&s.length?new VJe(s):qu.empty};var VJe=function(t){function s(n){t.call(this),this.values=n}t&&(s.__proto__=t),s.prototype=Object.create(t&&t.prototype),s.prototype.constructor=s;var r={length:{configurable:!0},depth:{configurable:!0}};return s.prototype.flatten=function(){return this.values},s.prototype.sliceInner=function(a,o){return a==0&&o==this.length?this:new s(this.values.slice(a,o))},s.prototype.getInner=function(a){return this.values[a]},s.prototype.forEachInner=function(a,o,l,i){for(var d=o;d=l;d--)if(a(this.values[d],i+d)===!1)return!1},s.prototype.leafAppend=function(a){if(this.length+a.length<=Ole)return new s(this.values.concat(a.flatten()))},s.prototype.leafPrepend=function(a){if(this.length+a.length<=Ole)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}(qu);qu.empty=new VJe([]);var $zt=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}(qu);const qzt=500;class jg{constructor(s,r){this.items=s,this.eventCount=r}popEvent(s,r){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let a,o;r&&(a=this.remapping(n,this.items.length),o=a.maps.length);let l=s.tr,i,d,u=[],p=[];return this.items.forEach((f,y)=>{if(!f.step){a||(a=this.remapping(n,y+1),o=a.maps.length),o--,p.push(f);return}if(a){p.push(new Ty(f.map));let _=f.step.map(a.slice(o)),b;_&&l.maybeStep(_).doc&&(b=l.mapping.maps[l.mapping.maps.length-1],u.push(new Ty(b,void 0,void 0,u.length+p.length))),o--,b&&a.appendMap(b,o)}else l.maybeStep(f.step);if(f.selection)return i=a?f.selection.map(a.slice(o)):f.selection,d=new jg(this.items.slice(0,n).append(p.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:d,transform:l,selection:i}}addTransform(s,r,n,a){let o=[],l=this.eventCount,i=this.items,d=!a&&i.length?i.get(i.length-1):null;for(let p=0;pVzt&&(i=Uzt(i,u),l-=u),new jg(i.append(o),l)}remapping(s,r){let n=new pD;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 jg(this.items.append(s.map(r=>new Ty(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(y=>{y.selection&&i--},a);let d=r;this.items.forEach(y=>{let _=o.getMirror(--d);if(_==null)return;l=Math.min(l,_);let b=o.maps[_];if(y.step){let N=s.steps[_].invert(s.docs[_]),w=y.selection&&y.selection.map(o.slice(d+1,_));w&&i++,n.push(new Ty(b,N,w))}else n.push(new Ty(b))},a);let u=[];for(let y=r;yqzt&&(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 d=l.step.map(r.slice(n)),u=d&&d.getMap();if(n--,u&&r.appendMap(u,n),d){let p=l.selection&&l.selection.map(r.slice(n));p&&o++;let f=new Ty(u.invert(),d,p),y,_=a.length-1;(y=a.length&&a[_].merge(f))?a[_]=y:a.push(f)}}else l.map&&n--},this.items.length,0),new jg(qu.from(a.reverse()),o)}}jg.empty=new jg(qu.empty,0);function Uzt(t,s){let r;return t.forEach((n,a)=>{if(n.selection&&s--==0)return r=a,!1}),t.slice(r)}class Ty{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 Ty(r.getMap().invert(),r,this.selection)}}}class R_{constructor(s,r,n,a,o){this.done=s,this.undone=r,this.prevRanges=n,this.prevTime=a,this.prevComposition=o}}const Vzt=20;function Hzt(t,s,r,n){let a=r.getMeta(AS),o;if(a)return a.historyState;r.getMeta(Kzt)&&(t=new R_(t.done,t.undone,null,0,-1));let l=r.getMeta("appendedTransaction");if(r.steps.length==0)return t;if(l&&l.getMeta(AS))return l.getMeta(AS).redo?new R_(t.done.addTransform(r,void 0,n,soe(s)),t.undone,_8e(r.mapping.maps),t.prevTime,t.prevComposition):new R_(t.done,t.undone.addTransform(r,void 0,n,soe(s)),null,t.prevTime,t.prevComposition);if(r.getMeta("addToHistory")!==!1&&!(l&&l.getMeta("addToHistory")===!1)){let i=r.getMeta("composition"),d=t.prevTime==0||!l&&t.prevComposition!=i&&(t.prevTime<(r.time||0)-n.newGroupDelay||!Gzt(r,t.prevRanges)),u=l?dye(t.prevRanges,r.mapping):_8e(r.mapping.maps);return new R_(t.done.addTransform(r,d?s.selection.getBookmark():void 0,n,soe(s)),jg.empty,u,r.time,i??t.prevComposition)}else return(o=r.getMeta("rebased"))?new R_(t.done.rebased(r,o),t.undone.rebased(r,o),dye(t.prevRanges,r.mapping),t.prevTime,t.prevComposition):new R_(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),dye(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}function Gzt(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 _8e(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 dye(t,s){if(!t)return null;let r=[];for(let n=0;n{let a=AS.getState(r);if(!a||(t?a.undone:a.done).eventCount==0)return!1;if(n){let o=Wzt(a,r,t);o&&n(s?o.scrollIntoView():o)}return!0}}const GJe=HJe(!1,!0),WJe=HJe(!0,!0),Yzt=xh.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:s})=>GJe(t,s),redo:()=>({state:t,dispatch:s})=>WJe(t,s)}},addProseMirrorPlugins(){return[Zzt(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()}}}),Xzt=Hh.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",jc(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:s})=>{if(!G7t(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}):p7t(r)?o.insertContentAt(a.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({tr:l,dispatch:i})=>{var d;if(i){const{$to:u}=l.selection,p=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?l.setSelection(Ha.create(l.doc,u.pos+1)):u.nodeAfter.isBlock?l.setSelection(Fa.create(l.doc,u.pos)):l.setSelection(Ha.create(l.doc,u.pos));else{const f=(d=u.parent.type.contentMatch.defaultType)===null||d===void 0?void 0:d.create();f&&(l.insert(p,f),l.setSelection(Ha.create(l.doc,p+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[BJe({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Qzt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Jzt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,e9t=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,t9t=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,s9t=qg.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",jc(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[HT({find:Qzt,type:this.type}),HT({find:e9t,type:this.type})]},addPasteRules(){return[rC({find:Jzt,type:this.type}),rC({find:t9t,type:this.type})]}}),r9t=Hh.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",jc(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)}}}),n9t="listItem",w8e="textStyle",j8e=/^(\d+)\.\s$/,a9t=Hh.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",jc(this.options.HTMLAttributes,r),0]:["ol",jc(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(n9t,this.editor.getAttributes(w8e)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=bD({find:j8e,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=bD({find:j8e,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:s=>({start:+s[1],...this.editor.getAttributes(w8e)}),joinPredicate:(s,r)=>r.childCount+r.attrs.start===+s[1],editor:this.editor})),[t]}}),i9t=Hh.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",jc(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),o9t=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,l9t=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,c9t=qg.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",jc(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[HT({find:o9t,type:this.type})]},addPasteRules(){return[rC({find:l9t,type:this.type})]}}),d9t=Hh.create({name:"text",group:"inline"}),zke=xh.create({name:"starterKit",addExtensions(){const t=[];return this.options.bold!==!1&&t.push(yzt.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(mzt.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(_zt.configure(this.options.bulletList)),this.options.code!==!1&&t.push(jzt.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(Szt.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(Czt.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(Azt.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(Fzt.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(zzt.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(Bzt.configure(this.options.heading)),this.options.history!==!1&&t.push(Yzt.configure(this.options.history)),this.options.horizontalRule!==!1&&t.push(Xzt.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(s9t.configure(this.options.italic)),this.options.listItem!==!1&&t.push(r9t.configure(this.options.listItem)),this.options.orderedList!==!1&&t.push(a9t.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(i9t.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(c9t.configure(this.options.strike)),this.options.text!==!1&&t.push(d9t.configure(this.options.text)),t}}),u9t="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",h9t="ελ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",P_e="numeric",I_e="ascii",L_e="alpha",h8="asciinumeric",zI="alphanumeric",D_e="domain",KJe="emoji",m9t="scheme",p9t="slashscheme",hye="whitespace";function f9t(t,s){return t in s||(s[t]=[]),s[t]}function N4(t,s,r){s[P_e]&&(s[h8]=!0,s[zI]=!0),s[I_e]&&(s[h8]=!0,s[L_e]=!0),s[h8]&&(s[zI]=!0),s[L_e]&&(s[zI]=!0),s[zI]&&(s[D_e]=!0),s[KJe]&&(s[D_e]=!0);for(const n in s){const a=f9t(n,r);a.indexOf(t)<0&&a.push(t)}}function x9t(t,s){const r={};for(const n in s)s[n].indexOf(t)>=0&&(r[n]=!0);return r}function ap(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}ap.groups={};ap.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),Uc=(t,s,r,n,a)=>t.tr(s,r,n,a),N8e=(t,s,r,n,a)=>t.ts(s,r,n,a),Hr=(t,s,r,n,a)=>t.tt(s,r,n,a),bv="WORD",R_e="UWORD",ZJe="ASCIINUMERICAL",YJe="ALPHANUMERICAL",wD="LOCALHOST",O_e="TLD",F_e="UTLD",roe="SCHEME",F5="SLASH_SCHEME",Bke="NUM",z_e="WS",$ke="NL",m8="OPENBRACE",p8="CLOSEBRACE",Fle="OPENBRACKET",zle="CLOSEBRACKET",Ble="OPENPAREN",$le="CLOSEPAREN",qle="OPENANGLEBRACKET",Ule="CLOSEANGLEBRACKET",Vle="FULLWIDTHLEFTPAREN",Hle="FULLWIDTHRIGHTPAREN",Gle="LEFTCORNERBRACKET",Wle="RIGHTCORNERBRACKET",Kle="LEFTWHITECORNERBRACKET",Zle="RIGHTWHITECORNERBRACKET",Yle="FULLWIDTHLESSTHAN",Xle="FULLWIDTHGREATERTHAN",Qle="AMPERSAND",Jle="APOSTROPHE",ece="ASTERISK",O_="AT",tce="BACKSLASH",sce="BACKTICK",rce="CARET",G_="COLON",qke="COMMA",nce="DOLLAR",Ay="DOT",ace="EQUALS",Uke="EXCLAMATION",Yf="HYPHEN",f8="PERCENT",ice="PIPE",oce="PLUS",lce="POUND",x8="QUERY",Vke="QUOTE",XJe="FULLWIDTHMIDDLEDOT",Hke="SEMI",Ey="SLASH",g8="TILDE",cce="UNDERSCORE",QJe="EMOJI",dce="SYM";var JJe=Object.freeze({__proto__:null,ALPHANUMERICAL:YJe,AMPERSAND:Qle,APOSTROPHE:Jle,ASCIINUMERICAL:ZJe,ASTERISK:ece,AT:O_,BACKSLASH:tce,BACKTICK:sce,CARET:rce,CLOSEANGLEBRACKET:Ule,CLOSEBRACE:p8,CLOSEBRACKET:zle,CLOSEPAREN:$le,COLON:G_,COMMA:qke,DOLLAR:nce,DOT:Ay,EMOJI:QJe,EQUALS:ace,EXCLAMATION:Uke,FULLWIDTHGREATERTHAN:Xle,FULLWIDTHLEFTPAREN:Vle,FULLWIDTHLESSTHAN:Yle,FULLWIDTHMIDDLEDOT:XJe,FULLWIDTHRIGHTPAREN:Hle,HYPHEN:Yf,LEFTCORNERBRACKET:Gle,LEFTWHITECORNERBRACKET:Kle,LOCALHOST:wD,NL:$ke,NUM:Bke,OPENANGLEBRACKET:qle,OPENBRACE:m8,OPENBRACKET:Fle,OPENPAREN:Ble,PERCENT:f8,PIPE:ice,PLUS:oce,POUND:lce,QUERY:x8,QUOTE:Vke,RIGHTCORNERBRACKET:Wle,RIGHTWHITECORNERBRACKET:Zle,SCHEME:roe,SEMI:Hke,SLASH:Ey,SLASH_SCHEME:F5,SYM:dce,TILDE:g8,TLD:O_e,UNDERSCORE:cce,UTLD:F_e,UWORD:R_e,WORD:bv,WS:z_e});const fv=/[a-z]/,lI=new RegExp("\\p{L}","u"),mye=new RegExp("\\p{Emoji}","u"),xv=/\d/,pye=/\s/,k8e="\r",fye=` `,g9t="️",y9t="‍",xye="";let Vz=null,Hz=null;function v9t(t=[]){const s={};ap.groups=s;const r=new ap;Vz==null&&(Vz=S8e(u9t)),Hz==null&&(Hz=S8e(h9t)),Hr(r,"'",Jle),Hr(r,"{",m8),Hr(r,"}",p8),Hr(r,"[",Fle),Hr(r,"]",zle),Hr(r,"(",Ble),Hr(r,")",$le),Hr(r,"<",qle),Hr(r,">",Ule),Hr(r,"(",Vle),Hr(r,")",Hle),Hr(r,"「",Gle),Hr(r,"」",Wle),Hr(r,"『",Kle),Hr(r,"』",Zle),Hr(r,"<",Yle),Hr(r,">",Xle),Hr(r,"&",Qle),Hr(r,"*",ece),Hr(r,"@",O_),Hr(r,"`",sce),Hr(r,"^",rce),Hr(r,":",G_),Hr(r,",",qke),Hr(r,"$",nce),Hr(r,".",Ay),Hr(r,"=",ace),Hr(r,"!",Uke),Hr(r,"-",Yf),Hr(r,"%",f8),Hr(r,"|",ice),Hr(r,"+",oce),Hr(r,"#",lce),Hr(r,"?",x8),Hr(r,'"',Vke),Hr(r,"/",Ey),Hr(r,";",Hke),Hr(r,"~",g8),Hr(r,"_",cce),Hr(r,"\\",tce),Hr(r,"・",XJe);const n=Uc(r,xv,Bke,{[P_e]:!0});Uc(n,xv,n);const a=Uc(n,fv,ZJe,{[h8]:!0}),o=Uc(n,lI,YJe,{[zI]:!0}),l=Uc(r,fv,bv,{[I_e]:!0});Uc(l,xv,a),Uc(l,fv,l),Uc(a,xv,a),Uc(a,fv,a);const i=Uc(r,lI,R_e,{[L_e]:!0});Uc(i,fv),Uc(i,xv,o),Uc(i,lI,i),Uc(o,xv,o),Uc(o,fv),Uc(o,lI,o);const d=Hr(r,fye,$ke,{[hye]:!0}),u=Hr(r,k8e,z_e,{[hye]:!0}),p=Uc(r,pye,z_e,{[hye]:!0});Hr(r,xye,p),Hr(u,fye,d),Hr(u,xye,p),Uc(u,pye,p),Hr(p,k8e),Hr(p,fye),Uc(p,pye,p),Hr(p,xye,p);const f=Uc(r,mye,QJe,{[KJe]:!0});Hr(f,"#"),Uc(f,mye,f),Hr(f,g9t,f);const y=Hr(f,y9t);Hr(y,"#"),Uc(y,mye,f);const _=[[fv,l],[xv,a]],b=[[fv,null],[lI,i],[xv,o]];for(let N=0;NN[0]>w[0]?1:-1);for(let N=0;N=0?C[D_e]=!0:fv.test(w)?xv.test(w)?C[h8]=!0:C[I_e]=!0:C[P_e]=!0,N8e(r,w,w,C)}return N8e(r,"localhost",wD,{ascii:!0}),r.jd=new ap(dce),{start:r,tokens:Object.assign({groups:s},JJe)}}function eet(t,s){const r=_9t(s.replace(/[A-Z]/g,i=>i.toLowerCase())),n=r.length,a=[];let o=0,l=0;for(;l=0&&(f+=r[l].length,y++),u+=r[l].length,o+=r[l].length,l++;o-=f,l-=y,u-=f,a.push({t:p.t,v:s.slice(o-u,o),s:o-u,e:o})}return a}function _9t(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 y_(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 jD={defaultProtocol:"http",events:null,format:C8e,formatHref:C8e,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Gke(t,s=null){let r=Object.assign({},jD);t&&(r=Object.assign(r,t instanceof Gke?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=jD.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const s=this,r=this.toHref(t.get("defaultProtocol")),n=t.get("formatHref",r,this),a=t.get("tagName",r,s),o=this.toFormattedString(t),l={},i=t.get("className",r,s),d=t.get("target",r,s),u=t.get("rel",r,s),p=t.getObj("attributes",r,s),f=t.getObj("events",r,s);return l.href=n,i&&(l.class=i),d&&(l.target=d),u&&(l.rel=u),p&&Object.assign(l,p),{tagName:a,attributes:l,content:o,eventListeners:f}}};function whe(t,s){class r extends tet{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 M8e=whe("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),T8e=whe("text"),b9t=whe("nl"),Gz=whe("url",{isLink:!0,toHref(t=jD.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==wD&&t[1].t===G_}}),Uf=t=>new ap(t);function w9t({groups:t}){const s=t.domain.concat([Qle,ece,O_,tce,sce,rce,nce,ace,Yf,Bke,f8,ice,oce,lce,Ey,dce,g8,cce]),r=[Jle,G_,qke,Ay,Uke,f8,x8,Vke,Hke,qle,Ule,m8,p8,zle,Fle,Ble,$le,Vle,Hle,Gle,Wle,Kle,Zle,Yle,Xle],n=[Qle,Jle,ece,tce,sce,rce,nce,ace,Yf,m8,p8,f8,ice,oce,lce,x8,Ey,dce,g8,cce],a=Uf(),o=Hr(a,g8);Li(o,n,o),Li(o,t.domain,o);const l=Uf(),i=Uf(),d=Uf();Li(a,t.domain,l),Li(a,t.scheme,i),Li(a,t.slashscheme,d),Li(l,n,o),Li(l,t.domain,l);const u=Hr(l,O_);Hr(o,O_,u),Hr(i,O_,u),Hr(d,O_,u);const p=Hr(o,Ay);Li(p,n,o),Li(p,t.domain,o);const f=Uf();Li(u,t.domain,f),Li(f,t.domain,f);const y=Hr(f,Ay);Li(y,t.domain,f);const _=Uf(M8e);Li(y,t.tld,_),Li(y,t.utld,_),Hr(u,wD,_);const b=Hr(f,Yf);Hr(b,Yf,b),Li(b,t.domain,f),Li(_,t.domain,f),Hr(_,Ay,y),Hr(_,Yf,b);const N=Hr(_,G_);Li(N,t.numeric,M8e);const w=Hr(l,Yf),S=Hr(l,Ay);Hr(w,Yf,w),Li(w,t.domain,l),Li(S,n,o),Li(S,t.domain,l);const C=Uf(Gz);Li(S,t.tld,C),Li(S,t.utld,C),Li(C,t.domain,l),Li(C,n,o),Hr(C,Ay,S),Hr(C,Yf,w),Hr(C,O_,u);const A=Hr(C,G_),I=Uf(Gz);Li(A,t.numeric,I);const L=Uf(Gz),O=Uf();Li(L,s,L),Li(L,r,O),Li(O,s,L),Li(O,r,O),Hr(C,Ey,L),Hr(I,Ey,L);const V=Hr(i,G_),q=Hr(d,G_),B=Hr(q,Ey),U=Hr(B,Ey);Li(i,t.domain,l),Hr(i,Ay,S),Hr(i,Yf,w),Li(d,t.domain,l),Hr(d,Ay,S),Hr(d,Yf,w),Li(V,t.domain,L),Hr(V,Ey,L),Hr(V,x8,L),Li(U,t.domain,L),Li(U,s,L),Hr(U,Ey,L);const te=[[m8,p8],[Fle,zle],[Ble,$le],[qle,Ule],[Vle,Hle],[Gle,Wle],[Kle,Zle],[Yle,Xle]];for(let Y=0;Y=0&&y++,a++,p++;if(y<0)a-=p,a0&&(o.push(gye(T8e,s,l)),l=[]),a-=y,p-=y;const _=f.t,b=r.slice(a-p,a);o.push(gye(_,s,b))}}return l.length>0&&o.push(gye(T8e,s,l)),o}function gye(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 N9t=typeof console<"u"&&console&&console.warn||(()=>{}),k9t="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Yl={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function S9t(){return ap.groups={},Yl.scanner=null,Yl.parser=null,Yl.tokenQueue=[],Yl.pluginQueue=[],Yl.customSchemes=[],Yl.initialized=!1,Yl}function A8e(t,s=!1){if(Yl.initialized&&N9t(`linkifyjs: already initialized - will not register custom scheme "${t}" ${k9t}`),!/^[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`);Yl.customSchemes.push([t,s])}function C9t(){Yl.scanner=v9t(Yl.customSchemes);for(let t=0;t{const a=s.some(u=>u.docChanged)&&!r.doc.eq(n.doc),o=s.some(u=>u.getMeta("preventAutolink"));if(!a||o)return;const{tr:l}=n,i=a7t(r.doc,[...s]);if(h7t(i).forEach(({newRange:u})=>{const p=o7t(n.doc,u,_=>_.isTextblock);let f,y;if(p.length>1)f=p[0],y=n.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(p.length){const _=n.doc.textBetween(u.from,u.to," "," ");if(!T9t.test(_))return;f=p[0],y=n.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&y){const _=y.split(M9t).filter(Boolean);if(_.length<=0)return!1;const b=_[_.length-1],N=f.pos+y.lastIndexOf(b);if(!b)return!1;const w=Wke(b).map(S=>S.toObject(t.defaultProtocol));if(!E9t(w))return!1;w.filter(S=>S.isLink).map(S=>({...S,from:N+S.start+1,to:N+S.end+1})).filter(S=>n.schema.marks.code?!n.doc.rangeHasMark(S.from,S.to,n.schema.marks.code):!0).filter(S=>t.validate(S.value)).filter(S=>t.shouldAutoLink(S.value)).forEach(S=>{Pke(S.from,S.to,n.doc).some(C=>C.mark.type===t.type)||l.addMark(S.from,S.to,t.type.create({href:S.href}))})}}),!!l.steps.length)return l}})}function I9t(t){return new vu({key:new Vh("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(y=>y.nodeName==="A"))return!1;const d=zJe(s.state,t.type.name),u=n.target,p=(a=u==null?void 0:u.href)!==null&&a!==void 0?a:d.href,f=(o=u==null?void 0:u.target)!==null&&o!==void 0?o:d.target;return u&&p?(window.open(p,f),!0):!1}}})}function L9t(t){return new vu({key:new Vh("handlePasteLink"),props:{handlePaste:(s,r,n)=>{const{state:a}=s,{selection:o}=a,{empty:l}=o;if(l)return!1;let i="";n.content.forEach(u=>{i+=u.textContent});const d=set(i,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===i);return!i||!d?!1:t.editor.commands.setMark(t.type,{href:d.href})}}})}function z2(t,s){const r=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return s&&s.forEach(n=>{const a=typeof n=="string"?n:n.scheme;a&&r.push(a)}),!t||t.replace(A9t,"").match(new RegExp(`^(?:(?:${r.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const Zke=qg.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"){A8e(t);return}A8e(t.scheme,t.optionalSlashes)})},onDestroy(){S9t()},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)=>!!z2(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=>!!z2(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=>!!z2(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",jc(this.options.HTMLAttributes,t),0]:["a",jc(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:s})=>{const{href:r}=t;return this.options.isAllowedUri(r,{defaultValidate:n=>!!z2(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=>!!z2(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[rC({find:t=>{const s=[];if(t){const{protocols:r,defaultProtocol:n}=this.options,a=set(t).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:l=>!!z2(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(P9t({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:n=>this.options.isAllowedUri(n,{defaultValidate:a=>!!z2(a,s),protocols:s,defaultProtocol:r}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(I9t({type:this.type})),this.options.linkOnPaste&&t.push(L9t({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}}),Yke=xh.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const s=t.style.textAlign;return this.options.alignments.includes(s)?s:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:s})=>this.options.alignments.includes(t)?this.options.types.map(r=>s.updateAttributes(r,{textAlign:t})).every(r=>r):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(s=>t.resetAttributes(s,"textAlign")).every(s=>s),toggleTextAlign:t=>({editor:s,commands:r})=>this.options.alignments.includes(t)?s.isActive({textAlign:t})?r.unsetTextAlign():r.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),D9t=t=>{if(!t.children.length)return;const s=t.querySelectorAll("span");s&&s.forEach(r=>{var n,a;const o=r.getAttribute("style"),l=(a=(n=r.parentElement)===null||n===void 0?void 0:n.closest("span"))===null||a===void 0?void 0:a.getAttribute("style");r.setAttribute("style",`${l};${o}`)})},Xke=qg.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&D9t(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",jc(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}}}}),R9t=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,O9t=Hh.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",jc(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:s})=>s.insertContent({type:this.name,attrs:t})}},addInputRules(){return[BJe({find:R9t,type:this.type,getAttributes:t=>{const[,,s,r,n]=t;return{src:r,alt:s,title:n}}})]}});let B_e,$_e;if(typeof WeakMap<"u"){let t=new WeakMap;B_e=s=>t.get(s),$_e=(s,r)=>(t.set(s,r),r)}else{const t=[];let r=0;B_e=n=>{for(let a=0;a(r==10&&(r=0),t[r++]=n,t[r++]=a)}var Jc=class{constructor(t,s,r,n){this.width=t,this.height=s,this.map=r,this.problems=n}findCell(t){for(let s=0;s=r){(o||(o=[])).push({type:"overlong_rowspan",pos:p,n:S-A});break}const I=a+A*s;for(let L=0;Ln&&(o+=u.attrs.colspan)}}for(let l=0;l1&&(r=!0)}s==-1?s=o:s!=o&&(s=Math.max(s,o))}return s}function B9t(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 q9t(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 Gg(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 jhe(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=nC(s.$head)||U9t(s.$head);if(r)return r;throw new RangeError(`No cell found around position ${s.head}`)}function U9t(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 q_e(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function V9t(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Qke(t,s){return t.depth==s.depth&&t.pos>=s.start(-1)&&t.pos<=s.end(-1)}function ret(t,s,r){const n=t.node(-1),a=Jc.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 aC(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 net(t,s,r=1){const n={...t,colspan:t.colspan+r};if(n.colwidth){n.colwidth=n.colwidth.slice();for(let a=0;ap!=r.pos-o);d.unshift(r.pos-o);const u=d.map(p=>{const f=n.nodeAt(p);if(!f)throw new RangeError(`No cell with offset ${p} found`);const y=o+p+1;return new FQe(i.resolve(y),i.resolve(y+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(q_e(n)&&q_e(a)&&Qke(n,a)){const o=this.$anchorCell.node(-1)!=n.node(-1);return o&&this.isRowSelection()?wv.rowSelection(n,a):o&&this.isColSelection()?wv.colSelection(n,a):new wv(n,a)}return Ha.between(n,a)}content(){const s=this.$anchorCell.node(-1),r=Jc.get(s),n=this.$anchorCell.start(-1),a=r.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),o={},l=[];for(let d=a.top;d0||w>0){let S=b.attrs;if(N>0&&(S=aC(S,0,N)),w>0&&(S=aC(S,S.colspan-w,w)),_.lefta.bottom){const S={...b.attrs,rowspan:Math.min(_.bottom,a.bottom)-Math.max(_.top,a.top)};_.top0)return!1;const n=s+this.$anchorCell.nodeAfter.attrs.rowspan,a=r+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,a)==this.$headCell.node(-1).childCount}static colSelection(s,r=s){const n=s.node(-1),a=Jc.get(n),o=s.start(-1),l=a.findCell(s.pos-o),i=a.findCell(r.pos-o),d=s.node(0);return l.top<=i.top?(l.top>0&&(s=d.resolve(o+a.map[l.left])),i.bottom0&&(r=d.resolve(o+a.map[i.left])),l.bottom0)return!1;const l=a+this.$anchorCell.nodeAfter.attrs.colspan,i=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(l,i)==r.width}eq(s){return s instanceof wv&&s.$anchorCell.pos==this.$anchorCell.pos&&s.$headCell.pos==this.$headCell.pos}static rowSelection(s,r=s){const n=s.node(-1),a=Jc.get(n),o=s.start(-1),l=a.findCell(s.pos-o),i=a.findCell(r.pos-o),d=s.node(0);return l.left<=i.left?(l.left>0&&(s=d.resolve(o+a.map[l.top*a.width])),i.right0&&(r=d.resolve(o+a.map[i.top*a.width])),l.right{s.push(bm.node(n,n+r.nodeSize,{class:"selectedCell"}))}),Xc.create(t.doc,s)}function K9t({$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 Z9t({$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 Y9t(t,s,r){const n=(s||t).selection,a=(s||t).doc;let o,l;if(n instanceof Fa&&(l=n.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")o=Bl.create(a,n.from);else if(l=="row"){const i=a.resolve(n.from+1);o=Bl.rowSelection(i,i)}else if(!r){const i=Jc.get(n.node),d=n.from+1,u=d+i.map[i.width*i.height-1];o=Bl.create(a,d+1,u)}}else n instanceof Ha&&K9t(n)?o=Ha.create(a,n.from):n instanceof Ha&&Z9t(n)&&(o=Ha.create(a,n.$from.start(),n.$from.end()));return o&&(s||(s=t.tr)).setSelection(o),s}const X9t=new Vh("fix-tables");function iet(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=Q9t(t,a,o,r))};return s?s.doc!=t.doc&&iet(s.doc,t.doc,0,n):t.doc.descendants(n),r}function Q9t(t,s,r,n){const a=Jc.get(s);if(!a.problems)return n;n||(n=t.tr);const o=[];for(let d=0;d0){let _="cell";p.firstChild&&(_=p.firstChild.type.spec.tableRole);const b=[];for(let w=0;w0?-1:0;H9t(s,n,a+o)&&(o=a==0||a==s.width?null:0);for(let l=0;l0&&a0&&s.map[i-1]==d||a0?-1:0;rBt(s,n,a+i)&&(i=a==0||a==s.height?null:0);for(let u=0,p=s.width*a;u0&&a0&&f==s.map[p-s.width]){const y=r.nodeAt(f).attrs;t.setNodeMarkup(t.mapping.slice(i).map(f+n),null,{...y,rowspan:y.rowspan-1}),u+=y.colspan-1}else if(a0&&r[o]==r[o-1]||n.right0&&r[a]==r[a-t]||n.bottom0){const p=d+1+u.content.size,f=E8e(u)?d+1:p;o.replaceWith(f+n.tableStart,p+n.tableStart,i)}o.setSelection(new Bl(o.doc.resolve(d+n.tableStart))),s(o)}return!0}function I8e(t,s){const r=$h(t.schema);return cBt(({node:n})=>r[n.type.spec.tableRole])(t,s)}function cBt(t){return(s,r)=>{const n=s.selection;let a,o;if(n instanceof Bl){if(n.$anchorCell.pos!=n.$headCell.pos)return!1;a=n.$anchorCell.nodeAfter,o=n.$anchorCell.pos}else{var l;if(a=q9t(n.$from),!a)return!1;o=(l=nC(n.$from))===null||l===void 0?void 0:l.pos}if(a==null||o==null||a.attrs.colspan==1&&a.attrs.rowspan==1)return!1;if(r){let i=a.attrs;const d=[],u=i.colwidth;i.rowspan>1&&(i={...i,rowspan:1}),i.colspan>1&&(i={...i,colspan:1});const p=k0(s),f=s.tr;for(let _=0;_{l.attrs[t]!==s&&o.setNodeMarkup(i,null,{...l.attrs,[t]:s})}):o.setNodeMarkup(a.pos,null,{...a.nodeAfter.attrs,[t]:s}),n(o)}return!0}}function uBt(t){return function(s,r){if(!Gg(s))return!1;if(r){const n=$h(s.schema),a=k0(s),o=s.tr,l=a.map.cellsInRect(t=="column"?{left:a.left,top:0,right:a.right,bottom:a.map.height}:t=="row"?{left:0,top:a.top,right:a.map.width,bottom:a.bottom}:a),i=l.map(d=>a.table.nodeAt(d));for(let d=0;d{const _=y+o.tableStart,b=l.doc.nodeAt(_);b&&l.setNodeMarkup(_,f,b.attrs)}),n(l)}return!0}}ND("row",{useDeprecatedLogic:!0});ND("column",{useDeprecatedLogic:!0});const hBt=ND("cell",{useDeprecatedLogic:!0});function mBt(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 Wz(t,s){const r=t.selection;if(!(r instanceof Bl))return!1;if(s){const n=t.tr,a=$h(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 wn(a,0,0))}),n.docChanged&&s(n)}return!0}function fBt(t){if(t.size===0)return null;let{content:s,openStart:r,openEnd:n}=t;for(;s.childCount==1&&(r>0&&n>0||s.child(0).type.spec.tableRole=="table");)r--,n--,s=s.child(0).content;const a=s.child(0),o=a.type.spec.tableRole,l=a.type.schema,i=[];if(o=="row")for(let d=0;d=0;l--){const{rowspan:i,colspan:d}=o.child(l).attrs;for(let u=a;u=s.length&&s.push(Tr.empty),r[a]n&&(y=y.type.createChecked(aC(y.attrs,y.attrs.colspan,p+y.attrs.colspan-n),y.content)),u.push(y),p+=y.attrs.colspan;for(let _=1;_a&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,a-f.attrs.rowspan)},f.content)),d.push(f)}o.push(Tr.from(d))}r=o,s=a}return{width:t,height:s,rows:r}}function yBt(t,s,r,n,a,o,l){const i=t.doc.type.schema,d=$h(i);let u,p;if(a>s.width)for(let f=0,y=0;fs.height){const f=[];for(let b=0,N=(s.height-1)*s.width;b=s.width?!1:r.nodeAt(s.map[N+b]).type==d.header_cell;f.push(w?p||(p=d.header_cell.createAndFill()):u||(u=d.cell.createAndFill()))}const y=d.row.create(null,Tr.from(f)),_=[];for(let b=s.height;b{if(!a)return!1;const o=r.selection;if(o instanceof Bl)return noe(r,n,ti.near(o.$headCell,s));if(t!="horiz"&&!o.empty)return!1;const l=uet(a,t,s);if(l==null)return!1;if(t=="horiz")return noe(r,n,ti.near(r.doc.resolve(o.head+s),s));{const i=r.doc.resolve(l),d=ret(i,t,s);let u;return d?u=ti.near(d,1):s<0?u=ti.near(r.doc.resolve(i.before(-1)),-1):u=ti.near(r.doc.resolve(i.after(-1)),1),noe(r,n,u)}}}function Zz(t,s){return(r,n,a)=>{if(!a)return!1;const o=r.selection;let l;if(o instanceof Bl)l=o;else{const d=uet(a,t,s);if(d==null)return!1;l=new Bl(r.doc.resolve(d))}const i=ret(l.$headCell,t,s);return i?noe(r,n,new Bl(l.$anchorCell,i)):!1}}function _Bt(t,s){const r=t.state.doc,n=nC(r.resolve(s));return n?(t.dispatch(t.state.tr.setSelection(new Bl(n))),!0):!1}function bBt(t,s,r){if(!Gg(t.state))return!1;let n=fBt(r);const a=t.state.selection;if(a instanceof Bl){n||(n={width:1,height:1,rows:[Tr.from(U_e($h(t.state.schema).cell,r))]});const o=a.$anchorCell.node(-1),l=a.$anchorCell.start(-1),i=Jc.get(o).rectBetween(a.$anchorCell.pos-l,a.$headCell.pos-l);return n=gBt(n,i.right-i.left,i.bottom-i.top),F8e(t.state,t.dispatch,l,i,n),!0}else if(n){const o=jhe(t.state),l=o.start(-1);return F8e(t.state,t.dispatch,l,Jc.get(o.node(-1)).findCell(o.pos-l),n),!0}else return!1}function wBt(t,s){var r;if(s.button!=0||s.ctrlKey||s.metaKey)return;const n=z8e(t,s.target);let a;if(s.shiftKey&&t.state.selection instanceof Bl)o(t.state.selection.$anchorCell,s),s.preventDefault();else if(s.shiftKey&&n&&(a=nC(t.state.selection.$anchor))!=null&&((r=yye(t,s))===null||r===void 0?void 0:r.pos)!=a.pos)o(a,s),s.preventDefault();else if(!n)return;function o(d,u){let p=yye(t,u);const f=W_.getState(t.state)==null;if(!p||!Qke(d,p))if(f)p=d;else return;const y=new Bl(d,p);if(f||!t.state.selection.eq(y)){const _=t.state.tr.setSelection(y);f&&_.setMeta(W_,d.pos),t.dispatch(_)}}function l(){t.root.removeEventListener("mouseup",l),t.root.removeEventListener("dragstart",l),t.root.removeEventListener("mousemove",i),W_.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(W_,-1))}function i(d){const u=d,p=W_.getState(t.state);let f;if(p!=null)f=t.state.doc.resolve(p);else if(z8e(t,u.target)!=n&&(f=yye(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 uet(t,s,r){if(!(t.state.selection instanceof Ha))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 z8e(t,s){for(;s&&s!=t.dom;s=s.parentNode)if(s.nodeName=="TD"||s.nodeName=="TH")return s;return null}function yye(t,s){const r=t.posAtCoords({left:s.clientX,top:s.clientY});if(!r)return null;let{inside:n,pos:a}=r;return n>=0&&nC(t.state.doc.resolve(n))||nC(t.state.doc.resolve(a))}var jBt=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")),V_e(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,V_e(s,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(s){return s.type=="attributes"&&(s.target==this.table||this.colgroup.contains(s.target))}};function V_e(t,s,r,n,a,o){let l=0,i=!0,d=s.firstChild;const u=t.firstChild;if(u){for(let f=0,y=0;fnew n(f,r,y)),new kBt(-1,!1)},apply(l,i){return i.apply(l)}},props:{attributes:l=>{const i=Jp.getState(l);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,i)=>{SBt(l,i,t,a)},mouseleave:l=>{CBt(l)},mousedown:(l,i)=>{MBt(l,i,s,r)}},decorations:l=>{const i=Jp.getState(l);if(i&&i.activeHandle>-1)return IBt(l,i.activeHandle)},nodeViews:{}}});return o}var kBt=class aoe{constructor(s,r){this.activeHandle=s,this.dragging=r}apply(s){const r=this,n=s.getMeta(Jp);if(n&&n.setHandle!=null)return new aoe(n.setHandle,!1);if(n&&n.setDragging!==void 0)return new aoe(r.activeHandle,n.setDragging);if(r.activeHandle>-1&&s.docChanged){let a=s.mapping.map(r.activeHandle,-1);return q_e(s.doc.resolve(a))||(a=-1),new aoe(a,r.dragging)}return r}};function SBt(t,s,r,n){if(!t.editable)return;const a=Jp.getState(t.state);if(a&&!a.dragging){const o=ABt(s.target);let l=-1;if(o){const{left:i,right:d}=o.getBoundingClientRect();s.clientX-i<=r?l=B8e(t,s,"left",r):d-s.clientX<=r&&(l=B8e(t,s,"right",r))}if(l!=a.activeHandle){if(!n&&l!==-1){const i=t.state.doc.resolve(l),d=i.node(-1),u=Jc.get(d),p=i.start(-1);if(u.colCount(i.pos-p)+i.nodeAfter.attrs.colspan-1==u.width-1)return}het(t,l)}}}function CBt(t){if(!t.editable)return;const s=Jp.getState(t.state);s&&s.activeHandle>-1&&!s.dragging&&het(t,-1)}function MBt(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=Jp.getState(t.state);if(!l||l.activeHandle==-1||l.dragging)return!1;const i=t.state.doc.nodeAt(l.activeHandle),d=TBt(t,l.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta(Jp,{setDragging:{startX:s.clientX,startWidth:d}}));function u(f){o.removeEventListener("mouseup",u),o.removeEventListener("mousemove",p);const y=Jp.getState(t.state);y!=null&&y.dragging&&(EBt(t,y.activeHandle,$8e(y.dragging,f,r)),t.dispatch(t.state.tr.setMeta(Jp,{setDragging:null})))}function p(f){if(!f.which)return u(f);const y=Jp.getState(t.state);if(y&&y.dragging){const _=$8e(y.dragging,f,r);q8e(t,y.activeHandle,_,n)}}return q8e(t,l.activeHandle,d,n),o.addEventListener("mouseup",u),o.addEventListener("mousemove",p),s.preventDefault(),!0}function TBt(t,s,{colspan:r,colwidth:n}){const a=n&&n[n.length-1];if(a)return a;const o=t.domAtPos(s);let l=o.node.childNodes[o.offset].offsetWidth,i=r;if(n)for(let d=0;d{const n=t.nodes[r];n.spec.tableRole&&(s[n.spec.tableRole]=n)}),t.cached.tableNodeTypes=s,s}function FBt(t,s,r,n,a){const o=OBt(t),l=[],i=[];for(let u=0;u{const{selection:s}=t.state;if(!zBt(s))return!1;let r=0;const n=FJe(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},BBt=Hh.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:DBt,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:s}){const{colgroup:r,tableWidth:n,tableMinWidth:a}=RBt(t,this.options.cellMinWidth),o=["table",jc(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=FBt(o.schema,t,s,r);if(a){const i=n.selection.from+1;n.replaceSelectionWith(l).scrollIntoView().setSelection(Ha.near(n.doc.resolve(i)))}return!0},addColumnBefore:()=>({state:t,dispatch:s})=>J9t(t,s),addColumnAfter:()=>({state:t,dispatch:s})=>eBt(t,s),deleteColumn:()=>({state:t,dispatch:s})=>sBt(t,s),addRowBefore:()=>({state:t,dispatch:s})=>nBt(t,s),addRowAfter:()=>({state:t,dispatch:s})=>aBt(t,s),deleteRow:()=>({state:t,dispatch:s})=>oBt(t,s),deleteTable:()=>({state:t,dispatch:s})=>pBt(t,s),mergeCells:()=>({state:t,dispatch:s})=>P8e(t,s),splitCell:()=>({state:t,dispatch:s})=>I8e(t,s),toggleHeaderColumn:()=>({state:t,dispatch:s})=>ND("column")(t,s),toggleHeaderRow:()=>({state:t,dispatch:s})=>ND("row")(t,s),toggleHeaderCell:()=>({state:t,dispatch:s})=>hBt(t,s),mergeOrSplit:()=>({state:t,dispatch:s})=>P8e(t,s)?!0:I8e(t,s),setCellAttribute:(t,s)=>({state:r,dispatch:n})=>dBt(t,s)(r,n),goToNextCell:()=>({state:t,dispatch:s})=>D8e(1)(t,s),goToPreviousCell:()=>({state:t,dispatch:s})=>D8e(-1)(t,s),fixTables:()=>({state:t,dispatch:s})=>(s&&oet(t),!0),setCellSelection:t=>({tr:s,dispatch:r})=>{if(r){const n=Bl.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:Yz,"Mod-Backspace":Yz,Delete:Yz,"Mod-Delete":Yz}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[NBt({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],LBt({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const s={name:t.name,options:t.options,storage:t.storage};return{tableRole:Di(aa(t,"tableRole",s))}}}),$Bt=Hh.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",jc(this.options.HTMLAttributes,t),0]}}),qBt=Hh.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",jc(this.options.HTMLAttributes,t),0]}}),UBt=Hh.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",jc(this.options.HTMLAttributes,t),0]}});function Wg({content:t,onChange:s,placeholder:r="Enter content...",minHeight:n="150px",compact:a=!1}){const[o,l]=k.useState(!1),[i,d]=k.useState(""),[u,p]=k.useState(!0),f=Oke({extensions:[zke,Zke.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),Yke.configure({types:["heading","paragraph"]}),Xke,O9t.extend({addAttributes(){var N;return{...(N=this.parent)==null?void 0:N.call(this),width:{default:null},height:{default:null},style:{default:null}}}}).configure({inline:!0,allowBase64:!0}),BBt.extend({addAttributes(){var N;return{...(N=this.parent)==null?void 0:N.call(this),style:{default:null},width:{default:null},cellpadding:{default:null},cellspacing:{default:null},border:{default:null}}}}).configure({resizable:!1}),$Bt.extend({addAttributes(){var N;return{...(N=this.parent)==null?void 0:N.call(this),style:{default:null}}}}),qBt.extend({addAttributes(){var N;return{...(N=this.parent)==null?void 0:N.call(this),style:{default:null},width:{default:null},colspan:{default:1},rowspan:{default:1},valign:{default:null}}}}),UBt.extend({addAttributes(){var N;return{...(N=this.parent)==null?void 0:N.call(this),style:{default:null},width:{default:null},colspan:{default:1},rowspan:{default:1}}}})],content:t,onUpdate:({editor:N})=>{s(N.getHTML())},editorProps:{attributes:{class:"outline-none","data-placeholder":r},handlePaste:(N,w)=>{var C;const S=(C=w.clipboardData)==null?void 0:C.items;if(!S)return!1;for(const A of Array.from(S))if(A.type.startsWith("image/")){w.preventDefault();const I=A.getAsFile();if(!I)continue;const L=new FileReader;return L.onload=O=>{var q;const V=(q=O.target)==null?void 0:q.result;N.dispatch(N.state.tr.replaceSelectionWith(N.state.schema.nodes.image.create({src:V})))},L.readAsDataURL(I),!0}return!1}}});k.useEffect(()=>{f&&t!==f.getHTML()&&f.commands.setContent(t)},[t,f]);const y=()=>{if(!f)return;const N=f.getAttributes("link").href||"",w=f.getAttributes("link").target;d(N),p(w==="_blank"),l(!0)},_=()=>{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),d(""))},b=()=>{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(W,{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(SM,{className:"h-4 w-4"})}),e.jsx(W,{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(CM,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleBold().run(),className:f.isActive("bold")?"bg-muted":"",title:"Bold",children:e.jsx(K4,{className:"h-4 w-4"})}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleItalic().run(),className:f.isActive("italic")?"bg-muted":"",title:"Italic",children:e.jsx(rS,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleBulletList().run(),className:f.isActive("bulletList")?"bg-muted":"",title:"Bullet List",children:e.jsx(Dh,{className:"h-4 w-4"})}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleOrderedList().run(),className:f.isActive("orderedList")?"bg-muted":"",title:"Numbered List",children:e.jsx(Xy,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(W,{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(H4,{className:"h-4 w-4"})}),e.jsx(W,{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(V4,{className:"h-4 w-4"})}),e.jsx(W,{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(G4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",onClick:y,className:f.isActive("link")?"bg-muted":"",title:"Add Link",children:e.jsx(vo,{className:"h-4 w-4"})}),f.isActive("link")&&e.jsx(W,{type:"button",variant:"ghost",size:"sm",onClick:b,title:"Remove Link",children:e.jsx(vo,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().undo().run(),disabled:!f.can().undo(),title:"Undo",children:e.jsx(wS,{className:"h-4 w-4"})}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().redo().run(),disabled:!f.can().redo(),title:"Redo",children:e.jsx(fS,{className:"h-4 w-4"})})]}),e.jsx(Dke,{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(ks,{children:e.jsx(_s,{children:"Insert Link"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"link-url",children:"URL"}),e.jsx(De,{id:"link-url",value:i,onChange:N=>d(N.target.value),placeholder:"https://example.com"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ar,{id:"link-new-tab",checked:u,onCheckedChange:p}),e.jsx(xe,{htmlFor:"link-new-tab",children:"Open in new tab"})]})]}),e.jsxs(gn,{children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(W,{type:"button",onClick:_,children:i?"Apply Link":"Remove Link"})]})]})})]}):null}var VBt=Object.defineProperty,HBt=(t,s,r)=>s in t?VBt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,hc=(t,s,r)=>HBt(t,typeof s!="symbol"?s+"":s,r);const uce={x:0,y:0,width:0,height:0,unit:"px"},_5=(t,s,r)=>Math.min(Math.max(t,s),r),GBt=(...t)=>t.filter(s=>s&&typeof s=="string").join(" "),H8e=(t,s)=>t===s||t.width===s.width&&t.height===s.height&&t.x===s.x&&t.y===s.y&&t.unit===s.unit;function WBt(t,s,r,n){const a=Py(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==="%"?F_(a,r,n):a}function KBt(t,s,r){const n=Py(t,s,r);return n.x=(s-n.width)/2,n.y=(r-n.height)/2,t.unit==="%"?F_(n,s,r):n}function F_(t,s,r){return t.unit==="%"?{...uce,...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 Py(t,s,r){return t.unit?t.unit==="px"?{...uce,...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}:{...uce,...t,unit:"px"}}function G8e(t,s,r,n,a,o=0,l=0,i=n,d=a){const u={...t};let p=Math.min(o,n),f=Math.min(l,a),y=Math.min(i,n),_=Math.min(d,a);s&&(s>1?(p=l?l*s:p,f=p/s,y=i*s):(f=o?o/s:f,p=f*s,_=d/s)),u.y<0&&(u.height=Math.max(u.height+u.y,f),u.y=0),u.x<0&&(u.width=Math.max(u.width+u.x,p),u.x=0);const b=n-(u.x+u.width);b<0&&(u.x=Math.min(u.x,n-p),u.width+=b);const N=a-(u.y+u.height);if(N<0&&(u.y=Math.min(u.y,a-f),u.height+=N),u.widthy&&((r==="sw"||r=="nw")&&(u.x-=y-u.width),u.width=y),u.height>_&&((r==="nw"||r=="ne")&&(u.y-=_-u.height),u.height=_),s){const w=u.width/u.height;if(ws){const S=Math.max(u.height*s,p);(r==="sw"||r=="nw")&&(u.x-=S-u.width),u.width=S}}return u}function ZBt(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 b5={capture:!0,passive:!1};let YBt=0;const T_=class cg extends k.PureComponent{constructor(){super(...arguments),hc(this,"docMoveBound",!1),hc(this,"mouseDownOnCrop",!1),hc(this,"dragStarted",!1),hc(this,"evData",{startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0}),hc(this,"componentRef",k.createRef()),hc(this,"mediaRef",k.createRef()),hc(this,"resizeObserver"),hc(this,"initChangeCalled",!1),hc(this,"instanceId",`rc-${YBt++}`),hc(this,"state",{cropIsActive:!1,newCropIsBeingDrawn:!1}),hc(this,"onCropPointerDown",s=>{const{crop:r,disabled:n}=this.props,a=this.getBox();if(!r)return;const o=Py(r,a.width,a.height);if(n)return;s.cancelable&&s.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const l=s.target.dataset.ord,i=!!l;let d=s.clientX,u=s.clientY,p=o.x,f=o.y;if(l){const y=s.clientX-a.x,_=s.clientY-a.y;let b=0,N=0;l==="ne"||l=="e"?(b=y-(o.x+o.width),N=_-o.y,p=o.x,f=o.y+o.height):l==="se"||l==="s"?(b=y-(o.x+o.width),N=_-(o.y+o.height),p=o.x,f=o.y):l==="sw"||l=="w"?(b=y-o.x,N=_-(o.y+o.height),p=o.x+o.width,f=o.y):(l==="nw"||l=="n")&&(b=y-o.x,N=_-o.y,p=o.x+o.width,f=o.y+o.height),d=p+a.x+b,u=f+a.y+N}this.evData={startClientX:d,startClientY:u,startCropX:p,startCropY:f,clientX:s.clientX,clientY:s.clientY,isResize:i,ord:l},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})}),hc(this,"onComponentPointerDown",s=>{const{crop:r,disabled:n,locked:a,keepSelection:o,onChange:l}=this.props,i=this.getBox();if(n||a||o&&r)return;s.cancelable&&s.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const d=s.clientX-i.x,u=s.clientY-i.y,p={unit:"px",x:d,y:u,width:0,height:0};this.evData={startClientX:s.clientX,startClientY:s.clientY,startCropX:d,startCropY:u,clientX:s.clientX,clientY:s.clientY,isResize:!0},this.mouseDownOnCrop=!0,l(Py(p,i.width,i.height),F_(p,i.width,i.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})}),hc(this,"onDocPointerMove",s=>{const{crop:r,disabled:n,onChange:a,onDragStart:o}=this.props,l=this.getBox();if(n||!r||!this.mouseDownOnCrop)return;s.cancelable&&s.preventDefault(),this.dragStarted||(this.dragStarted=!0,o&&o(s));const{evData:i}=this;i.clientX=s.clientX,i.clientY=s.clientY;let d;i.isResize?d=this.resizeCrop():d=this.dragCrop(),H8e(r,d)||a(Py(d,l.width,l.height),F_(d,l.width,l.height))}),hc(this,"onComponentKeyDown",s=>{const{crop:r,disabled:n,onChange:a,onComplete:o}=this.props;if(n)return;const l=s.key;let i=!1;if(!r)return;const d=this.getBox(),u=this.makePixelCrop(d),p=(navigator.platform.match("Mac")?s.metaKey:s.ctrlKey)?cg.nudgeStepLarge:s.shiftKey?cg.nudgeStepMedium:cg.nudgeStep;if(l==="ArrowLeft"?(u.x-=p,i=!0):l==="ArrowRight"?(u.x+=p,i=!0):l==="ArrowUp"?(u.y-=p,i=!0):l==="ArrowDown"&&(u.y+=p,i=!0),i){s.cancelable&&s.preventDefault(),u.x=_5(u.x,0,d.width-u.width),u.y=_5(u.y,0,d.height-u.height);const f=Py(u,d.width,d.height),y=F_(u,d.width,d.height);a(f,y),o&&o(f,y)}}),hc(this,"onHandlerKeyDown",(s,r)=>{const{aspect:n=0,crop:a,disabled:o,minWidth:l=0,minHeight:i=0,maxWidth:d,maxHeight:u,onChange:p,onComplete:f}=this.props,y=this.getBox();if(o||!a)return;if(s.key==="ArrowUp"||s.key==="ArrowDown"||s.key==="ArrowLeft"||s.key==="ArrowRight")s.stopPropagation(),s.preventDefault();else return;const _=(navigator.platform.match("Mac")?s.metaKey:s.ctrlKey)?cg.nudgeStepLarge:s.shiftKey?cg.nudgeStepMedium:cg.nudgeStep,b=Py(a,y.width,y.height),N=ZBt(b,s.key,_,r),w=G8e(N,n,r,y.width,y.height,l,i,d,u);if(!H8e(a,w)){const S=F_(w,y.width,y.height);p(w,S),f&&f(w,S)}}),hc(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(Py(r,l.width,l.height),F_(r,l.width,l.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))}),hc(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(Py(r,a,o),F_(r,a,o))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,b5),this.document.addEventListener("pointerup",this.onDocPointerDone,b5),this.document.addEventListener("pointercancel",this.onDocPointerDone,b5),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,b5),this.document.removeEventListener("pointerup",this.onDocPointerDone,b5),this.document.removeEventListener("pointercancel",this.onDocPointerDone,b5),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=_5(s.startCropX+a,0,r.width-n.width),n.y=_5(s.startCropY+o,0,r.height-n.height),n}getPointRegion(s,r,n,a){const{evData:o}=this,l=o.clientX-s.x,i=o.clientY-s.y;let d;a&&r?d=r==="nw"||r==="n"||r==="ne":d=i1?o?[o,o/r]:[l*r,l]:l?[l*r,l]:[o,o/r]}resizeCrop(){const{evData:s}=this,{aspect:r=0,maxWidth:n,maxHeight:a}=this.props,o=this.getBox(),[l,i]=this.resolveMinDimensions(o,r,this.props.minWidth,this.props.minHeight);let d=this.makePixelCrop(o);const u=this.getPointRegion(o,s.ord,l,i),p=s.ord||u;let f=s.clientX-s.startClientX,y=s.clientY-s.startClientY;(l&&p==="nw"||p==="w"||p==="sw")&&(f=Math.min(f,-l)),(i&&p==="nw"||p==="n"||p==="ne")&&(y=Math.min(y,-i));const _={unit:"px",x:0,y:0,width:0,height:0};u==="ne"?(_.x=s.startCropX,_.width=f,r?(_.height=_.width/r,_.y=s.startCropY-_.height):(_.height=Math.abs(y),_.y=s.startCropY-_.height)):u==="se"?(_.x=s.startCropX,_.y=s.startCropY,_.width=f,r?_.height=_.width/r:_.height=y):u==="sw"?(_.x=s.startCropX+f,_.y=s.startCropY,_.width=Math.abs(f),r?_.height=_.width/r:_.height=y):u==="nw"&&(_.x=s.startCropX+f,_.width=Math.abs(f),r?(_.height=_.width/r,_.y=s.startCropY-_.height):(_.height=Math.abs(y),_.y=s.startCropY+y));const b=G8e(_,r,u,o.width,o.height,l,i,n,a);return r||cg.xyOrds.indexOf(p)>-1?d=b:cg.xOrds.indexOf(p)>-1?(d.x=b.x,d.width=b.width):cg.yOrds.indexOf(p)>-1&&(d.y=b.y,d.height=b.height),d.x=_5(d.x,0,o.width-d.width),d.y=_5(d.y,0,o.height-d.height),d}renderCropSelection(){const{ariaLabels:s=cg.defaultProps.ariaLabels,disabled:r,locked:n,renderSelectionAddon:a,ruleOfThirds:o,crop:l}=this.props,i=this.getCropStyle();if(l)return xt.createElement("div",{style:i,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":s.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!r&&!n&&xt.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},xt.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),xt.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),xt.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),xt.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),xt.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":s.nwDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"nw"),role:"button"}),xt.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":s.nDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"n"),role:"button"}),xt.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":s.neDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"ne"),role:"button"}),xt.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":s.eDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"e"),role:"button"}),xt.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":s.seDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"se"),role:"button"}),xt.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":s.sDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"s"),role:"button"}),xt.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":s.swDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"sw"),role:"button"}),xt.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":s.wDragHandle,onKeyDown:d=>this.onHandlerKeyDown(d,"w"),role:"button"})),a&&xt.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:d=>d.stopPropagation()},a(this.state)),o&&xt.createElement(xt.Fragment,null,xt.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),xt.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(s){const r={...uce,...this.props.crop||{}};return Py(r,s.width,s.height)}render(){const{aspect:s,children:r,circularCrop:n,className:a,crop:o,disabled:l,locked:i,style:d,ruleOfThirds:u}=this.props,{cropIsActive:p,newCropIsBeingDrawn:f}=this.state,y=o?this.renderCropSelection():null,_=GBt("ReactCrop",a,p&&"ReactCrop--active",l&&"ReactCrop--disabled",i&&"ReactCrop--locked",f&&"ReactCrop--new-crop",o&&s&&"ReactCrop--fixed-aspect",o&&n&&"ReactCrop--circular-crop",o&&u&&"ReactCrop--rule-of-thirds",!this.dragStarted&&o&&!o.width&&!o.height&&"ReactCrop--invisible-crop",n&&"ReactCrop--no-animate");return xt.createElement("div",{ref:this.componentRef,className:_,style:d},xt.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},r),o?xt.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},xt.createElement("defs",null,xt.createElement("mask",{id:`hole-${this.instanceId}`},xt.createElement("rect",{width:"100%",height:"100%",fill:"white"}),n?xt.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"}):xt.createElement("rect",{x:`${o.x}${o.unit}`,y:`${o.y}${o.unit}`,width:`${o.width}${o.unit}`,height:`${o.height}${o.unit}`,fill:"black"}))),xt.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,y)}};hc(T_,"xOrds",["e","w"]),hc(T_,"yOrds",["n","s"]),hc(T_,"xyOrds",["nw","ne","se","sw"]),hc(T_,"nudgeStep",1),hc(T_,"nudgeStepMedium",10),hc(T_,"nudgeStepLarge",100),hc(T_,"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 XBt=T_;var met=["PageUp","PageDown"],pet=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],fet={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},tE="Slider",[G_e,QBt,JBt]=wR(tE),[xet,vAs]=qc(tE,[JBt]),[e$t,Nhe]=xet(tE),get=k.forwardRef((t,s)=>{const{name:r,min:n=0,max:a=100,step:o=1,orientation:l="horizontal",disabled:i=!1,minStepsBetweenThumbs:d=0,defaultValue:u=[n],value:p,onValueChange:f=()=>{},onValueCommit:y=()=>{},inverted:_=!1,form:b,...N}=t,w=k.useRef(new Set),S=k.useRef(0),A=l==="horizontal"?t$t:s$t,[I=[],L]=Uu({prop:p,defaultProp:u,onChange:te=>{var J;(J=[...w.current][S.current])==null||J.focus(),f(te)}}),O=k.useRef(I);function V(te){const Y=o$t(I,te);U(te,Y)}function q(te){U(te,S.current)}function B(){const te=O.current[S.current];I[S.current]!==te&&y(I)}function U(te,Y,{commit:J}={commit:!1}){const X=u$t(o),ce=h$t(Math.round((te-n)/o)*o+n,X),ie=nD(ce,[n,a]);L((ae=[])=>{const oe=a$t(ae,ie,Y);if(d$t(oe,d*o)){S.current=oe.indexOf(ie);const me=String(oe)!==String(ae);return me&&J&&y(oe),me?oe:ae}else return ae})}return e.jsx(e$t,{scope:t.__scopeSlider,name:r,disabled:i,min:n,max:a,valueIndexToChangeRef:S,thumbs:w.current,values:I,orientation:l,form:b,children:e.jsx(G_e.Provider,{scope:t.__scopeSlider,children:e.jsx(G_e.Slot,{scope:t.__scopeSlider,children:e.jsx(A,{"aria-disabled":i,"data-disabled":i?"":void 0,...N,ref:s,onPointerDown:Mr(N.onPointerDown,()=>{i||(O.current=I)}),min:n,max:a,inverted:_,onSlideStart:i?void 0:V,onSlideMove:i?void 0:q,onSlideEnd:i?void 0:B,onHomeKeyDown:()=>!i&&U(n,0,{commit:!0}),onEndKeyDown:()=>!i&&U(a,I.length-1,{commit:!0}),onStepKeyDown:({event:te,direction:Y})=>{if(!i){const ce=met.includes(te.key)||te.shiftKey&&pet.includes(te.key)?10:1,ie=S.current,ae=I[ie],oe=o*ce*Y;U(ae+oe,ie,{commit:!0})}}})})})})});get.displayName=tE;var[yet,vet]=xet(tE,{startEdge:"left",endEdge:"right",size:"width",direction:1}),t$t=k.forwardRef((t,s)=>{const{min:r,max:n,dir:a,inverted:o,onSlideStart:l,onSlideMove:i,onSlideEnd:d,onStepKeyDown:u,...p}=t,[f,y]=k.useState(null),_=Ta(s,A=>y(A)),b=k.useRef(void 0),N=mw(a),w=N==="ltr",S=w&&!o||!w&&o;function C(A){const I=b.current||f.getBoundingClientRect(),L=[0,I.width],V=Jke(L,S?[r,n]:[n,r]);return b.current=I,V(A-I.left)}return e.jsx(yet,{scope:t.__scopeSlider,startEdge:S?"left":"right",endEdge:S?"right":"left",direction:S?1:-1,size:"width",children:e.jsx(_et,{dir:N,"data-orientation":"horizontal",...p,ref:_,style:{...p.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:A=>{const I=C(A.clientX);l==null||l(I)},onSlideMove:A=>{const I=C(A.clientX);i==null||i(I)},onSlideEnd:()=>{b.current=void 0,d==null||d()},onStepKeyDown:A=>{const L=fet[S?"from-left":"from-right"].includes(A.key);u==null||u({event:A,direction:L?-1:1})}})})}),s$t=k.forwardRef((t,s)=>{const{min:r,max:n,inverted:a,onSlideStart:o,onSlideMove:l,onSlideEnd:i,onStepKeyDown:d,...u}=t,p=k.useRef(null),f=Ta(s,p),y=k.useRef(void 0),_=!a;function b(N){const w=y.current||p.current.getBoundingClientRect(),S=[0,w.height],A=Jke(S,_?[n,r]:[r,n]);return y.current=w,A(N-w.top)}return e.jsx(yet,{scope:t.__scopeSlider,startEdge:_?"bottom":"top",endEdge:_?"top":"bottom",size:"height",direction:_?1:-1,children:e.jsx(_et,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:N=>{const w=b(N.clientY);o==null||o(w)},onSlideMove:N=>{const w=b(N.clientY);l==null||l(w)},onSlideEnd:()=>{y.current=void 0,i==null||i()},onStepKeyDown:N=>{const S=fet[_?"from-bottom":"from-top"].includes(N.key);d==null||d({event:N,direction:S?-1:1})}})})}),_et=k.forwardRef((t,s)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:a,onSlideEnd:o,onHomeKeyDown:l,onEndKeyDown:i,onStepKeyDown:d,...u}=t,p=Nhe(tE,r);return e.jsx(Jr.span,{...u,ref:s,onKeyDown:Mr(t.onKeyDown,f=>{f.key==="Home"?(l(f),f.preventDefault()):f.key==="End"?(i(f),f.preventDefault()):met.concat(pet).includes(f.key)&&(d(f),f.preventDefault())}),onPointerDown:Mr(t.onPointerDown,f=>{const y=f.target;y.setPointerCapture(f.pointerId),f.preventDefault(),p.thumbs.has(y)?y.focus():n(f)}),onPointerMove:Mr(t.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&a(f)}),onPointerUp:Mr(t.onPointerUp,f=>{const y=f.target;y.hasPointerCapture(f.pointerId)&&(y.releasePointerCapture(f.pointerId),o(f))})})}),bet="SliderTrack",wet=k.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=Nhe(bet,r);return e.jsx(Jr.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...n,ref:s})});wet.displayName=bet;var W_e="SliderRange",jet=k.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=Nhe(W_e,r),o=vet(W_e,r),l=k.useRef(null),i=Ta(s,l),d=a.values.length,u=a.values.map(y=>Cet(y,a.min,a.max)),p=d>1?Math.min(...u):0,f=100-Math.max(...u);return e.jsx(Jr.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...n,ref:i,style:{...t.style,[o.startEdge]:p+"%",[o.endEdge]:f+"%"}})});jet.displayName=W_e;var K_e="SliderThumb",Net=k.forwardRef((t,s)=>{const r=QBt(t.__scopeSlider),[n,a]=k.useState(null),o=Ta(s,i=>a(i)),l=k.useMemo(()=>n?r().findIndex(i=>i.ref.current===n):-1,[r,n]);return e.jsx(r$t,{...t,ref:o,index:l})}),r$t=k.forwardRef((t,s)=>{const{__scopeSlider:r,index:n,name:a,...o}=t,l=Nhe(K_e,r),i=vet(K_e,r),[d,u]=k.useState(null),p=Ta(s,C=>u(C)),f=d?l.form||!!d.closest("form"):!0,y=kR(d),_=l.values[n],b=_===void 0?0:Cet(_,l.min,l.max),N=i$t(n,l.values.length),w=y==null?void 0:y[i.size],S=w?l$t(w,b,i.direction):0;return k.useEffect(()=>{if(d)return l.thumbs.add(d),()=>{l.thumbs.delete(d)}},[d,l.thumbs]),e.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[i.startEdge]:`calc(${b}% + ${S}px)`},children:[e.jsx(G_e.ItemSlot,{scope:t.__scopeSlider,children:e.jsx(Jr.span,{role:"slider","aria-label":t["aria-label"]||N,"aria-valuemin":l.min,"aria-valuenow":_,"aria-valuemax":l.max,"aria-orientation":l.orientation,"data-orientation":l.orientation,"data-disabled":l.disabled?"":void 0,tabIndex:l.disabled?void 0:0,...o,ref:p,style:_===void 0?{display:"none"}:t.style,onFocus:Mr(t.onFocus,()=>{l.valueIndexToChangeRef.current=n})})}),f&&e.jsx(ket,{name:a??(l.name?l.name+(l.values.length>1?"[]":""):void 0),form:l.form,value:_},n)]})});Net.displayName=K_e;var n$t="RadioBubbleInput",ket=k.forwardRef(({__scopeSlider:t,value:s,...r},n)=>{const a=k.useRef(null),o=Ta(a,n),l=zR(s);return k.useEffect(()=>{const i=a.current;if(!i)return;const d=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==s&&p){const f=new Event("input",{bubbles:!0});p.call(i,s),i.dispatchEvent(f)}},[l,s]),e.jsx(Jr.input,{style:{display:"none"},...r,ref:o,defaultValue:s})});ket.displayName=n$t;function a$t(t=[],s,r){const n=[...t];return n[r]=s,n.sort((a,o)=>a-o)}function Cet(t,s,r){const o=100/(r-s)*(t-s);return nD(o,[0,100])}function i$t(t,s){return s>2?`Value ${t+1} of ${s}`:s===2?["Minimum","Maximum"][t]:void 0}function o$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 l$t(t,s,r){const n=t/2,o=Jke([0,50],[0,n]);return(n-o(s)*r)*r}function c$t(t){return t.slice(0,-1).map((s,r)=>t[r+1]-s)}function d$t(t,s){if(s>0){const r=c$t(t);return Math.min(...r)>=s}return!0}function Jke(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 u$t(t){return(String(t).split(".")[1]||"").length}function h$t(t,s){const r=Math.pow(10,s);return Math.round(t*r)/r}var Met=get,m$t=wet,p$t=jet,f$t=Net;const Cg=k.forwardRef(({className:t,...s},r)=>e.jsxs(Met,{ref:r,className:Ot("relative flex w-full touch-none select-none items-center",t),...s,children:[e.jsx(m$t,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(p$t,{className:"absolute h-full bg-primary"})}),e.jsx(f$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"})]}));Cg.displayName=Met.displayName;function x$t(t,s,r){return KBt(WBt({unit:"%",width:90},r,t,s),t,s)}const e4e=({open:t,onClose:s,imageSrc:r,onCropComplete:n,aspectRatio:a=1})=>{const o=k.useRef(null),[l,i]=k.useState(),[d,u]=k.useState(),[p,f]=k.useState(1),[y,_]=k.useState(0),b=k.useCallback(S=>{const{width:C,height:A}=S.currentTarget;i(x$t(C,A,a))},[a]),N=k.useCallback(async()=>{const S=o.current;if(!S||!d)return;const C=document.createElement("canvas"),A=C.getContext("2d");if(!A)return;const I=S.naturalWidth/S.width,L=S.naturalHeight/S.height,O=400;C.width=O,C.height=O,A.imageSmoothingQuality="high";const V=d.x*I,q=d.y*L,B=d.width*I,U=d.height*L,te=y*Math.PI/180,Y=C.width/2,J=C.height/2;return A.save(),A.translate(Y,J),A.rotate(te),A.scale(p,p),A.translate(-Y,-J),A.drawImage(S,V,q,B,U,0,0,O,O),A.restore(),new Promise((X,ce)=>{C.toBlob(ie=>{ie?X(ie):ce(new Error("Canvas is empty"))},"image/jpeg",.95)})},[d,p,y]),w=async()=>{try{const S=await N();S&&(n(S),s())}catch(S){console.error("Error cropping image:",S)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsx(ks,{children:e.jsx(_s,{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(XBt,{crop:l,onChange:(S,C)=>i(C),onComplete:S=>u(S),aspect:a,circularCrop:!0,className:"max-h-[400px]",children:e.jsx("img",{ref:o,src:r,alt:"Crop preview",style:{transform:`scale(${p}) rotate(${y}deg)`,maxHeight:"400px",width:"auto"},onLoad:b})})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(zM,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Cg,{value:[p],min:.5,max:3,step:.1,onValueChange:([S])=>f(S),className:"flex-1"}),e.jsx(Eb,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(DL,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Cg,{value:[y],min:-180,max:180,step:1,onValueChange:([S])=>_(S),className:"flex-1"}),e.jsxs("span",{className:"text-sm text-muted-foreground w-12",children:[y,"°"]})]})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:s,children:"Cancel"}),e.jsx(W,{onClick:w,children:"Save Photo"})]})]})})},g$t=()=>{const{user:t}=Us(),{toast:s}=ja(),[r,n]=k.useState(!1),[a,o]=k.useState(!1),[l,i]=k.useState(null);k.useEffect(()=>{t&&d()},[t]);const d=async()=>{n(!0);try{const{data:f}=await G.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 G.auth.getSession();if(!f)throw new Error("Not authenticated");const{data:y,error:_}=await G.functions.invoke("customer-portal",{headers:{Authorization:`Bearer ${f.access_token}`}});if(_)throw _;y!=null&&y.url&&window.open(y.url,"_blank")}catch(f){console.error("Error opening customer portal:",f),s({title:"Error",description:f.message||"Failed to open billing portal",variant:"destructive"})}finally{o(!1)}},p=()=>{if(l!=null&&l.isGrandfathered)return e.jsx(Qe,{className:"bg-amber-500",children:"Grandfathered"});switch(l==null?void 0:l.status){case"active":return e.jsx(Qe,{className:"bg-green-500",children:"Active"});case"trialing":return e.jsx(Qe,{className:"bg-blue-500",children:"Trial"});case"past_due":return e.jsx(Qe,{variant:"destructive",children:"Past Due"});case"canceled":return e.jsx(Qe,{variant:"secondary",children:"Canceled"});default:return e.jsx(Qe,{variant:"outline",children:"No Subscription"})}};return r?e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(yx,{className:"h-5 w-5"}),"Subscription"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(us,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(yx,{className:"h-5 w-5"}),"Subscription"]}),e.jsx(dr,{children:"Manage your subscription and billing"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Status"}),e.jsx("div",{className:"mt-1",children:p()})]}),(l==null?void 0:l.endDate)&&l.status==="active"&&e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Next billing date"}),e.jsx("p",{className:"font-medium",children:new Date(l.endDate).toLocaleDateString()})]})]}),l!=null&&l.isGrandfathered?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your account was upgraded from LevelUp 1.0. To update/manage your subscription please reach out to support."}):(l==null?void 0:l.status)==="active"||(l==null?void 0:l.status)==="trialing"?e.jsxs(e.Fragment,{children:[(l==null?void 0:l.status)==="trialing"&&(l==null?void 0:l.endDate)&&e.jsxs("p",{className:"text-sm text-muted-foreground mb-3",children:["Your trial ends on ",new Date(l.endDate).toLocaleDateString(),". After the trial, you'll be charged automatically."]}),e.jsxs(W,{onClick:u,variant:"outline",disabled:a,children:[a?e.jsx(us,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Yr,{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."})]})]})},y$t=()=>{const{user:t}=Us(),s=wr(),{toast:r}=ja(),[n]=Nc(),a=n.get("setup")==="true",o=n.get("reset")==="true",{isSupported:l,isSubscribed:i,isLoading:d,subscribe:u,unsubscribe:p}=QYe(),[f,y]=k.useState(!1),[_,b]=k.useState(""),[N,w]=k.useState(!1),[S,C]=k.useState(!1),[A,I]=k.useState(""),[L,O]=k.useState({name:"",email:"",phone:"",title:"",bio:"",areas_served:"",years_experience:"",instagram_url:"",facebook_url:"",linkedin_url:"",email_signature:"",use_email_signature:!1}),[V,q]=k.useState(!1),[B,U]=k.useState(!1),[te,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,me,ve;if(!(t!=null&&t.id)){console.log("No user ID available yet");return}try{console.log("Loading profile for user:",t.id);const{data:he,error:ge}=await G.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;he?(console.log("Profile loaded successfully:",he),O({name:he.name||"",email:he.email||"",phone:he.phone||"",title:he.title||"",bio:he.bio||"",areas_served:he.areas_served||"",years_experience:((oe=he.years_experience)==null?void 0:oe.toString())||"",instagram_url:he.instagram_url||"",facebook_url:he.facebook_url||"",linkedin_url:he.linkedin_url||"",email_signature:he.email_signature||"",use_email_signature:he.use_email_signature||!1}),q(he.digest_opt_out||!1)):(console.warn("No profile found for user"),O({name:((me=t.user_metadata)==null?void 0:me.name)||((ve=t.email)==null?void 0:ve.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:je}=await G.storage.from("avatars").list(`${t.id}`);if(je&&je.length>0){const{data:qe}=G.storage.from("avatars").getPublicUrl(`${t.id}/${je[0].name}`);b(qe.publicUrl)}}catch(he){console.error("Error loading profile:",he),r({title:"Error",description:he.message||"Failed to load profile",variant:"destructive"})}},X=oe=>{var he;const me=(he=oe.target.files)==null?void 0:he[0];if(!me)return;const ve=new FileReader;ve.onloadend=()=>{I(ve.result),C(!0)},ve.readAsDataURL(me),oe.target.value=""},ce=async oe=>{if(t){w(!0);try{const{data:me}=await G.storage.from("avatars").list(`${t.id}`);me&&me.length>0&&await G.storage.from("avatars").remove(me.map(Me=>`${t.id}/${Me.name}`));const he=`${t.id}/avatar.jpg`,{error:ge}=await G.storage.from("avatars").upload(he,oe,{upsert:!0,contentType:"image/jpeg"});if(ge)throw ge;const{data:je}=G.storage.from("avatars").getPublicUrl(he),qe=je.publicUrl;b(`${qe}?t=${Date.now()}`),await G.from("profiles").update({avatar_url:qe}).eq("id",t.id),r({title:"Success",description:"Profile photo updated successfully"})}catch(me){console.error("Error uploading avatar:",me),r({title:"Error",description:me.message||"Failed to upload photo",variant:"destructive"})}finally{w(!1)}}},ie=async()=>{if(!L.name.trim()||!L.email.trim()){r({title:"Error",description:"Name and email are required",variant:"destructive"});return}y(!0);try{const{error:oe}=await G.from("profiles").update({name:L.name.trim(),email:L.email.trim(),phone:L.phone.trim()||null,title:L.title.trim()||null,bio:L.bio.trim()||null,areas_served:L.areas_served.trim()||null,years_experience:L.years_experience?parseInt(L.years_experience):null,instagram_url:L.instagram_url.trim()||null,facebook_url:L.facebook_url.trim()||null,linkedin_url:L.linkedin_url.trim()||null,email_signature:L.email_signature||"",use_email_signature:L.use_email_signature}).eq("id",t==null?void 0:t.id);if(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{y(!1)}},ae=async()=>{if(!te.newPassword){r({title:"Error",description:"Please enter a new password",variant:"destructive"});return}if(te.newPassword.length<6){r({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}if(te.newPassword!==te.confirmPassword){r({title:"Error",description:"Passwords do not match",variant:"destructive"});return}y(!0);try{const{error:oe}=await G.auth.updateUser({password:te.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{y(!1)}};return e.jsx(Ds,{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(W,{variant:"outline",onClick:()=>{var oe;(oe=document.getElementById("change-password-section"))==null||oe.scrollIntoView({behavior:"smooth",block:"center"})},className:"gap-2",children:[e.jsx(nS,{className:"h-4 w-4"}),"Change Password"]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"Profile Photo"}),e.jsx(dr,{children:"Upload a professional photo for your profile"})]}),e.jsxs(Oe,{className:"flex items-center gap-6",children:[e.jsxs(Nn,{className:"h-24 w-24",children:[e.jsx(Ma,{src:_}),e.jsx(kn,{className:"text-2xl",children:L.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:X,disabled:N}),e.jsxs(W,{variant:"outline",onClick:()=>{var oe;return(oe=document.getElementById("avatar-upload"))==null?void 0:oe.click()},disabled:N,children:[e.jsx(Ra,{className:"mr-2 h-4 w-4"}),N?"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(Dt,{children:[e.jsx(zt,{children:"Personal Information"}),e.jsx(dr,{children:"Update your profile details"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"name",children:"Name"}),e.jsx(De,{id:"name",value:L.name,onChange:oe=>O({...L,name:oe.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"email",children:"Email"}),e.jsx(De,{id:"email",type:"email",value:L.email,onChange:oe=>O({...L,email:oe.target.value}),maxLength:255})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"phone",children:"Phone Number"}),e.jsx(De,{id:"phone",type:"tel",value:L.phone,onChange:oe=>O({...L,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(xe,{htmlFor:"title",children:"Job Title"}),e.jsx(De,{id:"title",value:L.title,onChange:oe=>O({...L,title:oe.target.value}),placeholder:"e.g., Broker Associate, Team Lead",maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"bio",children:"Bio"}),e.jsx(_r,{id:"bio",value:L.bio,onChange:oe=>O({...L,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(xe,{htmlFor:"areas_served",children:"Areas Served"}),e.jsx(De,{id:"areas_served",value:L.areas_served,onChange:oe=>O({...L,areas_served:oe.target.value}),placeholder:"e.g., Downtown, Suburbs"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"years_experience",children:"Years Experience"}),e.jsx(De,{id:"years_experience",type:"number",min:"0",value:L.years_experience,onChange:oe=>O({...L,years_experience:oe.target.value}),placeholder:"e.g., 5"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Social Links"}),e.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[e.jsx(De,{value:L.linkedin_url,onChange:oe=>O({...L,linkedin_url:oe.target.value}),placeholder:"LinkedIn URL"}),e.jsx(De,{value:L.instagram_url,onChange:oe=>O({...L,instagram_url:oe.target.value}),placeholder:"Instagram URL"}),e.jsx(De,{value:L.facebook_url,onChange:oe=>O({...L,facebook_url:oe.target.value}),placeholder:"Facebook URL"})]})]}),e.jsxs(W,{onClick:ie,disabled:f,children:[e.jsx(bc,{className:"mr-2 h-4 w-4"}),"Save Changes"]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Ev,{className:"h-5 w-5"}),"Email Signature"]}),e.jsx(dr,{children:"Add a signature that will be appended to emails sent via Gmail"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Use email signature in all emails"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:L.use_email_signature?"Your signature will be added to every email sent via Gmail":"Signature is currently disabled"})]}),e.jsx(Ar,{checked:L.use_email_signature,onCheckedChange:oe=>O({...L,use_email_signature:oe})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Signature"}),e.jsx(Wg,{content:L.email_signature,onChange:oe=>O({...L,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(W,{onClick:ie,disabled:f,children:[e.jsx(bc,{className:"mr-2 h-4 w-4"}),"Save Signature"]})]})]}),e.jsxs(Pe,{id:"change-password-section",children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:a?"Set Your Password":"Change Password"}),e.jsx(dr,{children:a?"Create a secure password for your account":"Update your password to keep your account secure"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"newPassword",children:"New Password"}),e.jsx(De,{id:"newPassword",type:"password",value:te.newPassword,onChange:oe=>Y({...te,newPassword:oe.target.value}),placeholder:"Min 6 characters"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"confirmPassword",children:"Confirm Password"}),e.jsx(De,{id:"confirmPassword",type:"password",value:te.confirmPassword,onChange:oe=>Y({...te,confirmPassword:oe.target.value}),placeholder:"Re-enter your new password"})]}),e.jsxs(W,{onClick:ae,disabled:f,children:[e.jsx(bc,{className:"mr-2 h-4 w-4"}),a?"Complete Setup":"Update Password"]}),a&&e.jsx(W,{variant:"outline",onClick:()=>s("/dashboard"),className:"ml-2",children:"Skip for Now"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[i?e.jsx(Sm,{className:"h-5 w-5"}):e.jsx(Wv,{className:"h-5 w-5"}),"Push Notifications"]}),e.jsx(dr,{children:"Receive browser notifications when new content is added"})]}),e.jsx(Oe,{children:l?e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:i?"Notifications enabled":"Notifications disabled"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:i?"You'll receive notifications about new templates, videos, and events":"Enable to get notified about new content"})]}),e.jsx(Ar,{checked:i,onCheckedChange:oe=>{oe?u():p()},disabled:d})]}):e.jsxs("div",{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{children:"Push notifications are not 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(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[V?e.jsx(wL,{className:"h-5 w-5"}):e.jsx(tr,{className:"h-5 w-5"}),"Email Preferences"]}),e.jsx(dr,{children:"Manage your email subscription settings"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Weekly Digest"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:V?"You won't receive weekly digest emails":"Receive a weekly summary of new content, events, and your progress"})]}),e.jsx(Ar,{checked:!V,onCheckedChange:async oe=>{U(!0);try{const{error:me}=await G.from("profiles").update({digest_opt_out:!oe}).eq("id",t==null?void 0:t.id);if(me)throw me;q(!oe),r({title:oe?"Subscribed":"Unsubscribed",description:oe?"You will now receive weekly digest emails":"You will no longer receive weekly digest emails"})}catch(me){r({title:"Error",description:me.message||"Failed to update preference",variant:"destructive"})}finally{U(!1)}},disabled:B})]})})]}),e.jsx(q8t,{}),e.jsx(g$t,{})]}),e.jsx(e4e,{open:S,onClose:()=>C(!1),imageSrc:A,onCropComplete:ce,aspectRatio:1})]})})};var v$t="AspectRatio",Tet=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(Jr.div,{...a,ref:s,style:{...n,position:"absolute",top:0,right:0,bottom:0,left:0}})})});Tet.displayName=v$t;var _$t=Tet;const b$t=_$t;function w$t(){const{user:t}=Us(),s=Qt(),[r,n]=k.useState(!1),[a,o]=k.useState(!1),{data:l,isLoading:i}=gt({queryKey:["calendar-token",t==null?void 0:t.id],queryFn:async()=>{const{data:b,error:N}=await G.from("profiles").select("calendar_token").eq("id",t==null?void 0:t.id).single();if(N)throw N;return b},enabled:!!t&&a}),d=Pt({mutationFn:async()=>{const b=new Uint8Array(12);crypto.getRandomValues(b);const N=btoa(String.fromCharCode(...b)).replace(/\+/g,"x").replace(/\//g,"y").replace(/=/g,"").substring(0,16),{error:w}=await G.from("profiles").update({calendar_token:N}).eq("id",t==null?void 0:t.id);if(w)throw w;return N},onSuccess:()=>{s.invalidateQueries({queryKey:["calendar-token",t==null?void 0:t.id]}),pe.success("Calendar subscription URL generated!")},onError:b=>{pe.error("Failed to generate calendar URL: "+b.message)}}),u=l!=null&&l.calendar_token?`https://dashboard.relevelup.com/api/calendar/${l.calendar_token}.ics`:null,p=async()=>{u&&(await navigator.clipboard.writeText(u),n(!0),pe.success("Calendar URL copied to clipboard!"),setTimeout(()=>n(!1),2e3))},f=()=>{u&&(window.location.href=u.replace("https://","webcal://"))},y=()=>{if(u){const b=u.replace("https://","webcal://"),N=`https://calendar.google.com/calendar/r?cid=${encodeURIComponent(b)}`;window.open(N,"_blank")}},_=()=>{if(u){const b=`https://outlook.live.com/calendar/0/addfromweb?url=${encodeURIComponent(u)}&name=Level%20Up%20Events`;window.open(b,"_blank")}};return e.jsxs(fs,{open:a,onOpenChange:o,children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{variant:"outline",className:"gap-2",children:[e.jsx(cn,{className:"h-4 w-4"}),"Subscribe to Calendar"]})}),e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(cn,{className:"h-5 w-5 text-primary"}),"Subscribe to Events Calendar"]}),e.jsx(Ir,{children:"Add all Level Up events to your personal calendar. Events will sync automatically and update when we add or change events."})]}),e.jsx("div",{className:"space-y-4 py-4",children:i?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(us,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):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(De,{value:u,readOnly:!0,className:"text-xs font-mono"}),e.jsx(W,{variant:"outline",size:"icon",onClick:p,children:r?e.jsx(Zn,{className:"h-4 w-4 text-green-500"}):e.jsx(Va,{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(W,{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(Yr,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsxs(W,{variant:"outline",className:"w-full justify-start gap-2",onClick:y,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(Yr,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsxs(W,{variant:"outline",className:"w-full justify-start gap-2",onClick:_,children:[e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M7.88 12.04q0 .45-.11.87-.1.41-.33.74-.22.33-.58.52-.37.2-.87.2t-.85-.2q-.35-.21-.57-.55-.22-.33-.33-.75-.1-.42-.1-.86t.1-.87q.1-.43.34-.76.22-.34.59-.54.36-.2.87-.2t.86.2q.35.21.57.55.22.34.31.77.1.43.1.88zM24 12v9.38q0 .46-.33.8-.33.32-.8.32H7.13q-.46 0-.8-.33-.32-.33-.32-.8V18H1q-.41 0-.7-.3-.3-.29-.3-.7V7q0-.41.3-.7Q.58 6 1 6h6.5V2.55q0-.44.3-.75.3-.3.75-.3h12.9q.44 0 .75.3.3.3.3.75V12zm-6-8.25v3h3v-3zm0 4.5v3h3v-3zm0 4.5v1.83l3.05-1.83zm-5.25-9v3h3.75v-3zm0 4.5v3h3.75v-3zm0 4.5v2.03l2.41 1.5 1.34-.81v-2.72zM9 3.75V6h2l.13.01.12.04v-2.3zM5.98 15.98q.9 0 1.6-.3.7-.32 1.19-.86.48-.55.73-1.28.25-.74.25-1.61 0-.83-.25-1.55-.24-.71-.71-1.24t-1.15-.83q-.68-.3-1.55-.3-.92 0-1.64.3-.71.3-1.2.85-.5.54-.75 1.3-.25.74-.25 1.63 0 .85.26 1.56.26.72.74 1.23.48.52 1.17.81.69.3 1.56.3zM7.5 21h12.39L12 16.08V17q0 .41-.3.7-.29.3-.7.3H7.5zm15-.13v-7.24l-5.9 3.54Z"})}),"Add to Outlook",e.jsx(Yr,{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(W,{onClick:()=>d.mutate(),disabled:d.isPending,className:"w-full",children:d.isPending?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(cn,{className:"h-4 w-4 mr-2"}),"Generate Calendar URL"]})})]})})]})]})}const j$t={first_timer:Gn,regular:Qv,dedicated:nc,veteran:Fi,streak_master:rd,century:Fi},N$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 W8e(t){return t===1?e.jsx(Fi,{className:"h-5 w-5 text-yellow-500"}):t===2?e.jsx(Qv,{className:"h-5 w-5 text-gray-400"}):t===3?e.jsx(nc,{className:"h-5 w-5 text-amber-600"}):e.jsx("span",{className:"w-5 text-center text-sm font-medium text-muted-foreground",children:t})}function Aet({showUserStats:t=!0,compact:s=!1,brokerageId:r,title:n="Event Leaderboard"}){const{user:a}=Us(),{data:o,isLoading:l}=LXe(s?5:10,r),{data:i}=DXe(a==null?void 0:a.id),{data:d}=OXe(a==null?void 0:a.id),{data:u}=RXe(a==null?void 0:a.id);return l?e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Fi,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((p,f)=>e.jsx(Ms,{className:"h-12 w-full"},f))})})]}):e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Fi,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsxs(Oe,{children:[t&&i&&e.jsxs("div",{className:"mb-4 p-3 rounded-lg bg-primary/5 border border-primary/10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Your Stats"}),d&&e.jsxs(Qe,{variant:"secondary",className:"text-xs",children:["Rank #",d]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold text-primary",children:i.total_points}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Points"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold",children:i.total_events_attended}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Events"})]}),e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(rd,{className:"h-4 w-4 text-orange-500"}),e.jsx("div",{className:"text-lg font-bold",children:i.current_streak}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Streak"})]})]}),u&&u.length>0&&e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1",children:[u.slice(0,4).map(p=>{const f=j$t[p.badge_type]||Gn;return e.jsxs(Qe,{variant:"outline",className:`text-xs ${N$t[p.badge_type]||""}`,title:p.badge_description||"",children:[e.jsx(f,{className:"h-3 w-3 mr-1"}),p.badge_name]},p.id)}),u.length>4&&e.jsxs(Qe,{variant:"outline",className:"text-xs",children:["+",u.length-4," more"]})]})]}),e.jsxs(ta,{defaultValue:"points",className:"w-full",children:[e.jsxs(Jn,{className:"w-full mb-3",children:[e.jsx(cs,{value:"points",className:"flex-1",children:"By Points"}),e.jsx(cs,{value:"events",className:"flex-1",children:"By Events"})]}),e.jsx(Ss,{value:"points",className:"mt-0",children:e.jsxs("div",{className:"space-y-2",children:[o==null?void 0:o.map((p,f)=>{var y,_,b;return e.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg ${p.user_id===(a==null?void 0:a.id)?"bg-primary/5 border border-primary/10":""} ${f===0?"bg-yellow-500/5":""}`,children:[e.jsx("div",{className:"w-6 flex justify-center",children:W8e(f+1)}),e.jsx(Nn,{className:"h-8 w-8",children:e.jsx(kn,{className:"text-xs",children:((_=(y=p.profile)==null?void 0:y.name)==null?void 0:_.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium text-sm truncate",children:[((b=p.profile)==null?void 0:b.name)||"Unknown",p.user_id===(a==null?void 0:a.id)&&e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(You)"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[p.total_events_attended," events"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"font-bold text-primary",children:p.total_points}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"pts"})]})]},p.user_id)}),(!o||o.length===0)&&e.jsx("div",{className:"text-center text-muted-foreground py-4 text-sm",children:"No attendance data yet. Attend an event to get on the leaderboard!"})]})}),e.jsx(Ss,{value:"events",className:"mt-0",children:e.jsx("div",{className:"space-y-2",children:[...o||[]].sort((p,f)=>f.total_events_attended-p.total_events_attended).map((p,f)=>{var y,_,b;return e.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg ${p.user_id===(a==null?void 0:a.id)?"bg-primary/5 border border-primary/10":""} ${f===0?"bg-yellow-500/5":""}`,children:[e.jsx("div",{className:"w-6 flex justify-center",children:W8e(f+1)}),e.jsx(Nn,{className:"h-8 w-8",children:e.jsx(kn,{className:"text-xs",children:((_=(y=p.profile)==null?void 0:y.name)==null?void 0:_.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium text-sm truncate",children:[((b=p.profile)==null?void 0:b.name)||"Unknown",p.user_id===(a==null?void 0:a.id)&&e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(You)"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[p.total_points," points"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"font-bold",children:p.total_events_attended}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"events"})]})]},p.user_id)})})})]})]})]})}function k$t(){const t=wr(),{user:s,isAdmin:r}=Us(),n=Qt(),{data:a,isLoading:o}=gt({queryKey:["public-events"],queryFn:async()=>{const{data:N,error:w}=await G.from("events").select("*").order("event_date",{ascending:!0});if(w)throw w;return N}}),{data:l}=gt({queryKey:["my-registrations"],queryFn:async()=>{if(!s)return[];const{data:N,error:w}=await G.from("event_registrations").select("event_id, zoom_join_url").eq("user_id",s.id);if(w)throw w;return N},enabled:!!s}),{data:i}=gt({queryKey:["event-registration-counts"],queryFn:async()=>{let N=[],w=0;const S=1e3;for(;;){const{data:A,error:I}=await G.from("event_registrations").select("event_id").range(w,w+S-1);if(I)throw I;if(!A||A.length===0||(N=N.concat(A),A.length{C[A.event_id]=(C[A.event_id]||0)+1}),C}}),d=Pt({mutationFn:async N=>{await G.auth.refreshSession();const{data:w,error:S}=await G.functions.invoke("zoom-register",{body:{event_id:N}});if(S)throw S;if(w!=null&&w.error)throw new Error(w.error);return w},onSuccess:N=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),N!=null&&N.join_url?pe.success("Successfully registered! You'll receive a Zoom confirmation email."):pe.success("Successfully registered for the event!")},onError:N=>{pe.error("Failed to register: "+N.message)}}),u=Pt({mutationFn:async N=>{const{data:w,error:S}=await G.functions.invoke("zoom-unregister",{body:{event_id:N}});if(S)throw S;if(w!=null&&w.error)throw new Error(w.error);return w},onSuccess:()=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),pe.success("Registration cancelled and removed from Zoom")},onError:N=>{pe.error("Failed to cancel: "+N.message)}}),p=N=>l==null?void 0:l.some(w=>w.event_id===N),f=N=>{const w=l==null?void 0:l.find(S=>S.event_id===N);return w==null?void 0:w.zoom_join_url},y=N=>N.capacity?((i==null?void 0:i[N.id])||0)>=N.capacity:!1,_=(a==null?void 0:a.filter(N=>WM(N.event_date)!=="ended"))||[],b=(a==null?void 0:a.filter(N=>WM(N.event_date)==="ended"))||[];return e.jsx(Ds,{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(w$t,{}),r&&e.jsx(W,{variant:"outline",onClick:()=>t("/admin/events"),children:"Manage Events"})]})]}),e.jsxs("div",{className:`grid grid-cols-1 ${r?"lg:grid-cols-3":""} gap-6`,children:[e.jsxs("div",{className:r?"lg:col-span-2":"",children:[o?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading events..."}):_.length===0?e.jsx(Pe,{className:"text-center py-12",children:e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground",children:"No upcoming events at the moment. Check back soon!"})})}):e.jsx("div",{className:"grid gap-6 md:grid-cols-2",children:_.map(N=>{const w=WM(N.event_date),S=ske(N.event_date),C=w==="live",A=w==="starting_soon";return e.jsxs(Pe,{className:`flex flex-col overflow-hidden cursor-pointer hover:shadow-lg transition-all ${C?"border-red-500 ring-2 ring-red-500/20":A?"border-amber-500 ring-2 ring-amber-500/20":"hover:border-primary/50"}`,onClick:()=>t(`/events/${N.id}`),children:[S&&e.jsxs("div",{className:`${C?"bg-red-500":"bg-amber-500"} text-white px-3 py-1.5 flex items-center gap-2 text-sm font-medium`,children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-white opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-white"})]}),C?e.jsxs(e.Fragment,{children:[e.jsx(e1,{className:"h-3.5 w-3.5"}),"LIVE NOW"]}):e.jsxs(e.Fragment,{children:[e.jsx(nn,{className:"h-3.5 w-3.5"}),"STARTING SOON"]})]}),N.image_url&&e.jsx(b$t,{ratio:3/2,className:"overflow-hidden",children:e.jsx("img",{src:N.image_url,alt:N.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform"})}),e.jsxs(Dt,{children:[e.jsx(zt,{className:"line-clamp-2",children:N.title}),N.description&&e.jsx(dr,{className:"line-clamp-2",children:N.description.replace(/<[^>]*>/g,"")})]}),e.jsxs(Oe,{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(cn,{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(N.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(nn,{className:"h-4 w-4"}),uD(new Date(N.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ir,{className:"h-4 w-4"}),(i==null?void 0:i[N.id])||0," registered",N.capacity&&` / ${N.capacity} spots`]})]}),e.jsx(XL,{className:"flex gap-2",onClick:I=>I.stopPropagation(),children:p(N.id)?e.jsxs(e.Fragment,{children:[e.jsxs(W,{variant:"outline",className:"flex-1",onClick:()=>u.mutate(N.id),disabled:u.isPending,children:[e.jsx(kr,{className:"h-4 w-4 mr-2"}),"Cancel"]}),e.jsxs(W,{className:"flex-1",onClick:()=>window.open(f(N.id)||N.zoom_link,"_blank"),children:[e.jsx(Yr,{className:"h-4 w-4 mr-2"}),"Join Zoom"]})]}):e.jsx(W,{className:"w-full",onClick:()=>d.mutate(N.id),disabled:d.isPending||y(N),children:y(N)?"Event Full":e.jsxs(e.Fragment,{children:[e.jsx(Zn,{className:"h-4 w-4 mr-2"}),"Register"]})})})]},N.id)})}),b.length>0&&e.jsxs("div",{className:"mt-12",children:[e.jsx("h3",{className:"text-xl font-semibold mb-4 text-muted-foreground",children:"Past Events"}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:b.map(N=>e.jsx(Pe,{className:"opacity-60 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>t(`/events/${N.id}`),children:e.jsxs(Dt,{children:[e.jsx(zt,{className:"text-base line-clamp-1",children:N.title}),e.jsx(dr,{children:new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(N.event_date))})]})},N.id))})]})]}),r&&e.jsx("div",{className:"lg:col-span-1",children:e.jsx(Aet,{showUserStats:!0})})]})]})})}const vye=[{value:"all",label:"All Roles",icon:ir},{value:"newest",label:"Newest Members",icon:nn},{value:"brokerage_manager",label:"Brokerage Managers",icon:HL},{value:"admin",label:"Admins",icon:zu}];function S$t({open:t,onOpenChange:s,resourceType:r,resourceId:n,resourceTitle:a}){var Ue,Ie;const{user:o,isAdmin:l,isBrokerageManager:i}=Us(),[d,u]=k.useState([]),[p,f]=k.useState([]),[y,_]=k.useState([]),[b,N]=k.useState([]),[w,S]=k.useState(""),[C,A]=k.useState(""),[I,L]=k.useState(""),[O,V]=k.useState(!1),[q,B]=k.useState(!1),[U,te]=k.useState("agents"),[Y,J]=k.useState("all"),[X,ce]=k.useState({}),ie=l||i;k.useEffect(()=>{t&&o&&(l?ae():oe())},[t,o,l]),k.useEffect(()=>{t||(_([]),N([]),S(""),A(""),L(""),te("agents"),J("all"))},[t]);const ae=async()=>{if(o){V(!0);try{const{data:ye,error:ct}=await G.from("brokerages").select("id, name").order("name");if(ct)throw ct;const fe=1e3,$e={};let Ye=0,tt=!0;for(;tt;){const{data:Ke,error:ot}=await G.from("profiles").select("brokerage_id").range(Ye*fe,(Ye+1)*fe-1);if(ot)throw ot;Ke==null||Ke.forEach(He=>{He.brokerage_id&&($e[He.brokerage_id]=($e[He.brokerage_id]||0)+1)}),tt=(Ke==null?void 0:Ke.length)===fe,Ye++}f((ye==null?void 0:ye.map(Ke=>({...Ke,agent_count:$e[Ke.id]||0})))||[]);const Te=[];for(Ye=0,tt=!0;tt;){const{data:Ke,error:ot}=await G.from("profiles").select("id, name, email, brokerage_id, created_at, brokerages(name)").neq("id",o.id).order("name").range(Ye*fe,(Ye+1)*fe-1);if(ot)throw ot;Ke&&Te.push(...Ke),tt=(Ke==null?void 0:Ke.length)===fe,Ye++}const We={};for(Ye=0,tt=!0;tt;){const{data:Ke,error:ot}=await G.from("user_roles").select("user_id, role").range(Ye*fe,(Ye+1)*fe-1);if(ot)throw ot;Ke==null||Ke.forEach(He=>{We[He.user_id]||(We[He.user_id]=[]),We[He.user_id].push(He.role)}),tt=(Ke==null?void 0:Ke.length)===fe,Ye++}ce(We),u(Te.map(Ke=>{var ot;return{id:Ke.id,name:Ke.name,email:Ke.email,brokerage_name:((ot=Ke.brokerages)==null?void 0:ot.name)||"No Brokerage",roles:We[Ke.id]||[],created_at:Ke.created_at}}))}catch(ye){console.error("Error loading data:",ye),pe.error("Failed to load agents and brokerages")}finally{V(!1)}}},oe=async()=>{if(o){V(!0);try{const{data:ye}=await G.from("profiles").select("brokerage_id").eq("id",o.id).single();if(!(ye!=null&&ye.brokerage_id)){pe.error("You must be part of a brokerage to share resources"),s(!1);return}const{data:ct,error:fe}=await G.from("profiles").select("id, name, email").eq("brokerage_id",ye.brokerage_id).neq("id",o.id).order("name");if(fe)throw fe;u(ct||[])}catch(ye){console.error("Error loading agents:",ye),pe.error("Failed to load agents")}finally{V(!1)}}},me=d.filter(ye=>{var fe;const ct=ye.name.toLowerCase().includes(w.toLowerCase())||ye.email.toLowerCase().includes(w.toLowerCase())||((fe=ye.brokerage_name)==null?void 0:fe.toLowerCase().includes(w.toLowerCase()));if(l&&Y!=="all"&&Y!=="newest"){const $e=X[ye.id]||[];return ct&&$e.includes(Y)}return ct}).sort((ye,ct)=>Y==="newest"?(ct.created_at||"").localeCompare(ye.created_at||""):0),ve=p.filter(ye=>ye.name.toLowerCase().includes(C.toLowerCase())),he=()=>{y.length===me.length?_([]):_(me.map(ye=>ye.id))},ge=()=>{b.length===ve.length?N([]):N(ve.map(ye=>ye.id))},je=ye=>{if(!ie){_([ye]);return}_(ct=>ct.includes(ye)?ct.filter(fe=>fe!==ye):[...ct,ye])},qe=ye=>{N(ct=>ct.includes(ye)?ct.filter(fe=>fe!==ye):[...ct,ye])},Me=async()=>{if(!(y.length>0||b.length>0)){pe.error("Please select at least one agent or brokerage to share with");return}B(!0);try{const{data:ct,error:fe}=await G.functions.invoke("send-share-notification",{body:{recipientIds:y,brokerageIds:b,resourceType:r,resourceId:n,resourceTitle:a,message:I.trim()||void 0}});if(fe)throw fe;const $e=(ct==null?void 0:ct.sharesCreated)||y.length;pe.success(`Shared with ${$e} agent${$e!==1?"s":""}`),s(!1)}catch(ct){console.error("Error sharing resource:",ct),pe.error("Failed to share resource")}finally{B(!1)}},ke=ye=>ye.split(" ").map(ct=>ct[0]).join("").toUpperCase().slice(0,2),Re=ye=>{const ct=X[ye]||[];return ct.includes("admin")?e.jsx(Qe,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"Admin"}):ct.includes("brokerage_manager")?e.jsx(Qe,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"Manager"}):null},Ve=y.length+b.length,Ne=Y!=="all"&&Y!=="newest"?me.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(ks,{className:"flex-shrink-0",children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(_n,{className:"h-5 w-5 text-primary"}),"Share Resource"]}),e.jsxs(Ir,{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(ta,{value:U,onValueChange:te,className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs(Jn,{className:"grid w-full grid-cols-2 flex-shrink-0",children:[e.jsxs(cs,{value:"agents",className:"flex items-center gap-2",children:[e.jsx(ir,{className:"h-4 w-4"}),e.jsx("span",{children:"Agents"}),y.length>0&&e.jsx(Qe,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:y.length})]}),e.jsxs(cs,{value:"brokerages",className:"flex items-center gap-2",children:[e.jsx(pa,{className:"h-4 w-4"}),e.jsx("span",{children:"Brokerages"}),b.length>0&&e.jsx(Qe,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:b.length})]})]}),e.jsxs(Ss,{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(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name, email, or brokerage...",value:w,onChange:ye=>S(ye.target.value),className:"pl-9"})]}),e.jsxs($s,{value:Y,onValueChange:J,children:[e.jsxs(zs,{className:"w-[180px]",children:[e.jsx(Eg,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(Vs,{placeholder:"Filter by role"})]}),e.jsx(Bs,{children:vye.map(ye=>e.jsx(vt,{value:ye.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ye.icon,{className:"h-4 w-4"}),e.jsx("span",{children:ye.label})]})},ye.value))})]})]}),e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(W,{variant:"ghost",size:"sm",onClick:he,className:"text-xs h-8",disabled:me.length===0,children:[e.jsx(ir,{className:"h-3.5 w-3.5 mr-1.5"}),y.length===me.length&&me.length>0?"Deselect All":"Select All"]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[Ne!==null&&e.jsxs("span",{className:"text-primary font-medium",children:[Ne," ",(Ue=vye.find(ye=>ye.value===Y))==null?void 0:Ue.label]}),e.jsxs("span",{className:"font-medium",children:[y.length," selected"]})]})]}),e.jsx(Ja,{className:"h-[300px] border rounded-lg",children:O?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(us,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):me.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[e.jsx(ir,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:Y!=="all"?`No ${(Ie=vye.find(ye=>ye.value===Y))==null?void 0:Ie.label.toLowerCase()} found`:"No agents found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:me.map(ye=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${y.includes(ye.id)?"bg-accent":""}`,onClick:()=>je(ye.id),children:[e.jsx(Ri,{checked:y.includes(ye.id),onCheckedChange:()=>je(ye.id),className:"flex-shrink-0"}),e.jsx(Nn,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(kn,{className:"text-xs bg-primary/10 text-primary",children:ke(ye.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:ye.name}),Re(ye.id)]}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[ye.email,ye.brokerage_name&&e.jsxs("span",{className:"ml-1 opacity-75",children:["• ",ye.brokerage_name]})]})]})]},ye.id))})})]}),e.jsxs(Ss,{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(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search brokerages...",value:C,onChange:ye=>A(ye.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(W,{variant:"ghost",size:"sm",onClick:ge,className:"text-xs h-8",disabled:ve.length===0,children:[e.jsx(pa,{className:"h-3.5 w-3.5 mr-1.5"}),b.length===ve.length&&ve.length>0?"Deselect All":"Select All"]}),e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:[b.length," selected"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground px-1 flex-shrink-0",children:"Selecting a brokerage will send to all agents in that brokerage."}),e.jsx(Ja,{className:"h-[250px] border rounded-lg",children:O?e.jsx("div",{className:"flex items-center justify-center h-[180px]",children:e.jsx(us,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):ve.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[180px] text-muted-foreground",children:[e.jsx(pa,{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:ve.map(ye=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${b.includes(ye.id)?"bg-accent":""}`,onClick:()=>qe(ye.id),children:[e.jsx(Ri,{checked:b.includes(ye.id),onCheckedChange:()=>qe(ye.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(pa,{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:ye.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ye.agent_count," agent",ye.agent_count!==1?"s":""]})]})]},ye.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(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search agents...",value:w,onChange:ye=>S(ye.target.value),className:"pl-9"})]}),ie&&e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(W,{variant:"ghost",size:"sm",onClick:he,className:"text-xs h-8",disabled:me.length===0,children:[e.jsx(ir,{className:"h-3.5 w-3.5 mr-1.5"}),y.length===me.length&&me.length>0?"Deselect All":"Select All"]}),e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:[y.length," selected"]})]}),e.jsx(Ja,{className:"h-[300px] border rounded-lg",children:O?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(us,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):me.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[e.jsx(ir,{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:me.map(ye=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${y.includes(ye.id)?"bg-accent":""}`,onClick:()=>je(ye.id),children:[e.jsx(Ri,{checked:y.includes(ye.id),onCheckedChange:()=>je(ye.id),className:"flex-shrink-0"}),e.jsx(Nn,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(kn,{className:"text-xs bg-primary/10 text-primary",children:ke(ye.name)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:ye.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:ye.email})]})]},ye.id))})})]}),e.jsxs("div",{className:"space-y-2 flex-shrink-0",children:[e.jsx(xe,{htmlFor:"message",className:"text-sm font-medium",children:"Add a message (optional)"}),e.jsx(_r,{id:"message",placeholder:"I thought you might find this useful...",value:I,onChange:ye=>L(ye.target.value),rows:2,className:"resize-none"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2 flex-shrink-0",children:[e.jsx(W,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(W,{onClick:Me,disabled:Ve===0||q,children:q?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Sharing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(_n,{className:"h-4 w-4 mr-2"}),"Share"]})})]})]})]})})}function sE({resourceType:t,resourceId:s,resourceTitle:r,variant:n="outline",size:a="sm",className:o=""}){const[l,i]=k.useState(!1),{user:d}=Us();return d?e.jsxs(e.Fragment,{children:[e.jsxs(W,{variant:n,size:a,onClick:()=>i(!0),className:o,children:[e.jsx(id,{className:"h-4 w-4 mr-2"}),"Share"]}),e.jsx(S$t,{open:l,onOpenChange:i,resourceType:t,resourceId:s,resourceTitle:r})]}):null}function C$t(){const{eventId:t}=io(),s=wr(),{user:r}=Us(),[n,a]=k.useState(null),[o,l]=k.useState(null),[i,d]=k.useState(0),[u,p]=k.useState(!0),[f,y]=k.useState(!1);k.useEffect(()=>{t&&_()},[t,r]);const _=async()=>{try{const{data:A,error:I}=await G.from("events").select("*").eq("id",t).single();if(I)throw I;a(A);const{count:L}=await G.from("event_registrations").select("*",{count:"exact",head:!0}).eq("event_id",t);if(d(L||0),r){const{data:O}=await G.from("event_registrations").select("id, zoom_join_url").eq("event_id",t).eq("user_id",r.id).maybeSingle();l(O)}}catch(A){console.error("Error loading event:",A),pe.error("Failed to load event"),s("/events")}finally{p(!1)}},b=async()=>{if(!(!r||!n)){y(!0);try{const{error:A}=await G.auth.refreshSession();if(A){console.error("Session refresh failed:",A),pe.error("Your session has expired. Please log in again.");return}if(o){const{error:I}=await G.functions.invoke("zoom-unregister",{body:{event_id:n.id}});if(I)throw I;pe.success("Successfully cancelled registration"),l(null),d(L=>L-1)}else{const{data:I,error:L}=await G.functions.invoke("zoom-register",{body:{event_id:n.id}});if(L)throw L;pe.success("Successfully registered for event!"),l({id:I.registration_id,zoom_join_url:I.zoom_join_url}),d(O=>O+1)}}catch(A){console.error("Registration error:",A),pe.error(o?"Failed to cancel registration":"Failed to register for event")}finally{y(!1)}}},N=A=>{var I,L,O;if(A.includes("iframe.mediadelivery.net")||A.includes("video.bunnycdn.com")){const V=A.match(/embed\/(\d+)\/([a-f0-9-]+)/);if(V)return`https://iframe.mediadelivery.net/embed/${V[1]}/${V[2]}?autoplay=false&preload=true`}if(A.includes("youtube.com")||A.includes("youtu.be")){const V=A.includes("youtu.be")?(I=A.split("youtu.be/")[1])==null?void 0:I.split("?")[0]:(L=A.split("v=")[1])==null?void 0:L.split("&")[0];if(V)return`https://www.youtube.com/embed/${V}`}if(A.includes("vimeo.com")){const V=(O=A.split("vimeo.com/")[1])==null?void 0:O.split("?")[0];if(V)return`https://player.vimeo.com/video/${V}`}return A};if(u)return e.jsx(Ds,{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(Ds,{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(W,{onClick:()=>s("/events"),className:"mt-4",children:"Back to Events"})]})});const w=a0(new Date(n.event_date)),S=n.capacity&&i>=n.capacity,C=(o==null?void 0:o.zoom_join_url)||n.zoom_link;return e.jsx(Ds,{title:n.title,children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs(W,{variant:"ghost",className:"mb-6 gap-2",onClick:()=>s("/events"),children:[e.jsx(Oa,{className:"h-4 w-4"}),"Back to Events"]}),n.image_url&&e.jsxs("div",{className:"relative aspect-video rounded-xl overflow-hidden mb-6",children:[e.jsx("img",{src:n.image_url,alt:n.title,className:"w-full h-full object-cover"}),w&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(Qe,{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(sE,{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(rp,{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:N(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(Oe,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(cn,{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:uD(new Date(n.event_date))})]})]}),n.capacity&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ir,{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(si,{className:"h-5 w-5 text-green-600"}),e.jsx("span",{className:"text-sm font-medium text-green-700",children:"You're registered!"})]}),e.jsxs("div",{className:"space-y-2 pt-2",children:[!w&&e.jsx(e.Fragment,{children:o?e.jsxs(e.Fragment,{children:[e.jsxs(W,{className:"w-full gap-2",onClick:()=>window.open(C,"_blank"),children:[e.jsx(Yr,{className:"h-4 w-4"}),"Join Event"]}),e.jsxs(W,{variant:"outline",className:"w-full",onClick:b,disabled:f,children:[f?e.jsx(us,{className:"h-4 w-4 animate-spin mr-2"}):null,"Cancel Registration"]})]}):e.jsx(W,{className:"w-full gap-2",onClick:b,disabled:f||(S??!1),children:f?e.jsx(us,{className:"h-4 w-4 animate-spin"}):S?"Event Full":"Register Now"})}),w&&o&&e.jsxs(W,{variant:"outline",className:"w-full gap-2",onClick:()=>window.open(n.zoom_link,"_blank"),children:[e.jsx(Yr,{className:"h-4 w-4"}),"View Recording"]})]})]})})})]})]})})}const M$t=[{id:"quickvid",name:"QuickVid",description:"Record, manage, and share personalized video messages",icon:e.jsx(yn,{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(yx,{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(Pg,{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(vn,{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(ch,{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(Or,{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(tr,{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(Rd,{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(_n,{className:"h-6 w-6"}),path:"/admin/email-campaigns",category:"Marketing",beta:!0,color:"bg-teal-500/15 text-teal-600"}],T$t=()=>{const{user:t,isAdmin:s}=Us(),r=wr(),[n,a]=k.useState([]),[o,l]=k.useState(!0),[i,d]=k.useState(""),[u,p]=k.useState("all"),[f,y]=k.useState(new Set),[_,b]=k.useState(new Set);k.useEffect(()=>{N()},[t]);const N=async()=>{try{const{data:B}=await G.from("user_tags").select("tag").eq("user_id",t==null?void 0:t.id),U=(B==null?void 0:B.map(me=>me.tag))||[],{data:te,error:Y}=await G.from("app_tiles").select("*").order("name");if(Y)throw Y;const[{data:J},{data:X}]=await Promise.all([G.from("user_favorites").select("app_id").eq("user_id",t==null?void 0:t.id),G.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(me=>me.app_id))||[]);y(ce);const ie=new Set((X||[]).map(me=>me.tool_id));b(ie);const oe=((te==null?void 0:te.filter(me=>!me.required_tags||me.required_tags.length===0?!0:me.required_tags.some(ve=>U.includes(ve))))||[]).sort((me,ve)=>me.name==="LevelUp Members Portal"?-1:ve.name==="LevelUp Members Portal"?1:0);a(oe)}catch(B){console.error("Error loading apps:",B),pe.error("Failed to load apps")}finally{l(!1)}},w=async B=>{var te;const U=window.open("about:blank","_blank");try{const{data:Y,error:J}=await G.auth.getSession();if(J||!Y.session){U==null||U.close(),pe.error("Session expired. Please refresh the page and try again.");return}const X=Y.session.access_token;await G.from("activity_logs").insert({user_id:t==null?void 0:t.id,app_id:B.app_id,app_name:B.name,user_agent:navigator.userAgent});const{data:ce,error:ie}=await G.functions.invoke("sso-launch",{body:{app_id:B.app_id},headers:{Authorization:`Bearer ${X}`}});if(ie)throw ie;ce!=null&&ce.redirect_url?U&&!U.closed?(U.location.href=ce.redirect_url,(te=U.focus)==null||te.call(U)):window.location.assign(ce.redirect_url):(U==null||U.close(),pe.error("Launch link unavailable"))}catch(Y){U==null||U.close(),console.error("Error launching app:",Y),pe.error("Failed to launch app. Please try again.")}},S=async(B,U)=>{B.stopPropagation();const te=f.has(U);try{if(te){const{error:Y}=await G.from("user_favorites").delete().eq("user_id",t==null?void 0:t.id).eq("app_id",U);if(Y)throw Y;y(J=>{const X=new Set(J);return X.delete(U),X}),pe.success("Removed from favorites")}else{const{error:Y}=await G.from("user_favorites").insert({user_id:t==null?void 0:t.id,app_id:U});if(Y)throw Y;y(J=>new Set(J).add(U)),pe.success("Added to favorites")}}catch(Y){console.error("Error toggling favorite:",Y),pe.error("Failed to update favorites")}},C=async(B,U)=>{B.stopPropagation();const te=_.has(U);try{if(te){const{error:Y}=await G.from("user_tool_favorites").delete().eq("user_id",t==null?void 0:t.id).eq("tool_id",U);if(Y)throw Y;b(J=>{const X=new Set(J);return X.delete(U),X}),pe.success("Removed from favorites")}else{const{error:Y}=await G.from("user_tool_favorites").insert({user_id:t==null?void 0:t.id,tool_id:U});if(Y)throw Y;b(J=>new Set(J).add(U)),pe.success("Added to favorites")}}catch(Y){console.error("Error toggling tool favorite:",Y),pe.error("Failed to update favorites")}},A=n.filter(B=>{var te;const U=B.name.toLowerCase().includes(i.toLowerCase())||((te=B.description)==null?void 0:te.toLowerCase().includes(i.toLowerCase()));return u==="favorites"?U&&f.has(B.id):U}),I=M$t.filter(B=>{if(B.adminOnly&&!s)return!1;const U=B.name.toLowerCase().includes(i.toLowerCase())||B.description.toLowerCase().includes(i.toLowerCase());return u==="favorites"?U&&_.has(B.id):U}),L=I.reduce((B,U)=>(B[U.category]||(B[U.category]=[]),B[U.category].push(U),B),{}),O=[{id:"all",label:"All"},{id:"tools",label:"Built-in Tools"},{id:"apps",label:"Connected Apps"},{id:"favorites",label:"Favorites"}];if(o)return e.jsx(Ds,{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 V=u==="all"||u==="tools"||u==="favorites",q=u==="all"||u==="apps"||u==="favorites";return e.jsxs(Ds,{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(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search apps & tools...",className:"pl-10 bg-muted/50 border-0 focus-visible:ring-1",value:i,onChange:B=>d(B.target.value)})]})]}),e.jsx("div",{className:"flex gap-6 border-b border-border mb-8",children:O.map(B=>e.jsxs("button",{onClick:()=>p(B.id),className:Ot("pb-3 text-sm font-medium transition-colors relative",u===B.id?"text-primary":"text-muted-foreground hover:text-foreground"),children:[B.label,u===B.id&&e.jsx("span",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]},B.id))}),V&&Object.keys(L).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(Lg,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Built-in Tools"})]}),Object.entries(L).map(([B,U])=>e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground bg-muted px-2.5 py-1 rounded-full",children:B})}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:U.map(te=>{const Y=_.has(te.id);return e.jsxs("div",{onClick:()=>r(te.path),className:Ot("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",te.isNew?"border-primary/40 ring-1 ring-primary/20 hover:border-primary/60":"border-border hover:border-primary/30"),children:[te.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:Ot("flex-shrink-0 w-14 h-14 rounded-xl flex items-center justify-center transition-transform group-hover:scale-105",te.color||"bg-primary/10 text-primary"),children:te.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:[te.name,te.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:te.description})]}),e.jsx("button",{className:Ot("flex-shrink-0 p-1 transition-colors",Y?"text-primary":"text-muted-foreground/50 hover:text-primary"),onClick:J=>C(J,te.id),children:e.jsx(fx,{className:Ot("h-5 w-5",Y&&"fill-current")})})]},te.id)})})]},B))]}),q&&e.jsxs("div",{children:[u==="all"&&A.length>0&&e.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[e.jsx(Yr,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Connected Apps"})]}),A.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(fx,{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(ad,{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(W,{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:A.map(B=>{const U=f.has(B.id),te=B.name.toLowerCase().includes("agent review")||B.app_id==="agent_review";return e.jsxs("div",{className:"group flex flex-col p-5 bg-card rounded-xl border border-border transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsxs("div",{className:"flex items-start gap-4 cursor-pointer",onClick:()=>w(B),children:[e.jsx("div",{className:"flex-shrink-0 w-14 h-14 rounded-xl bg-primary/10 flex items-center justify-center text-3xl",children:B.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold text-foreground group-hover:text-primary transition-colors truncate",children:B.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:B.description})]}),e.jsx("button",{className:Ot("flex-shrink-0 p-1 transition-colors",U?"text-primary":"text-muted-foreground/50 hover:text-primary"),onClick:Y=>S(Y,B.id),children:e.jsx(fx,{className:Ot("h-5 w-5",U&&"fill-current")})})]}),te&&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 →"})]},B.id)})})]}),V&&q&&A.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(ln,{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"})]})]})},A$t=()=>{const t=wr(),[s,r]=k.useState(""),[n,a]=k.useState("all"),[o,l]=k.useState("all"),[i,d]=k.useState("grid"),{data:u=[]}=gt({queryKey:["template-categories"],queryFn:async()=>{const{data:S,error:C}=await G.from("template_categories").select("*").order("name");if(C)throw C;return S}}),{data:p=[]}=gt({queryKey:["template-types"],queryFn:async()=>{const{data:S,error:C}=await G.from("template_types").select("*").order("name");if(C)throw C;return S}}),{data:f=[],isLoading:y}=gt({queryKey:["canva-templates"],queryFn:async()=>{const{data:S,error:C}=await G.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(C)throw C;const{data:A,error:I}=await G.from("template_links").select("*").order("sort_order");if(I)throw I;const{data:L}=await G.from("template_likes").select("template_id"),{data:O}=await G.from("template_comments").select("template_id"),V=new Map;L==null||L.forEach(U=>{V.set(U.template_id,(V.get(U.template_id)||0)+1)});const q=new Map;return O==null||O.forEach(U=>{q.set(U.template_id,(q.get(U.template_id)||0)+1)}),(S||[]).map(U=>({...U,links:(A||[]).filter(te=>te.template_id===U.id)||[],likesCount:V.get(U.id)||0,commentsCount:q.get(U.id)||0}))}}),_=f.filter(S=>{var L;const C=S.name.toLowerCase().includes(s.toLowerCase())||((L=S.description)==null?void 0:L.toLowerCase().includes(s.toLowerCase())),A=n==="all"||S.category_id===n,I=o==="all"||S.type_id===o;return C&&A&&I}),b=()=>{r(""),a("all"),l("all")},N=s||n!=="all"||o!=="all",w=S=>{t(`/templates/${S}`)};return e.jsx(Ds,{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(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search templates...",value:s,onChange:S=>r(S.target.value),className:"pl-9"})]}),e.jsxs($s,{value:n,onValueChange:a,children:[e.jsx(zs,{className:"w-full sm:w-48",children:e.jsx(Vs,{placeholder:"All Categories"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Categories"}),u.map(S=>e.jsx(vt,{value:S.id,children:S.name},S.id))]})]}),e.jsxs($s,{value:o,onValueChange:l,children:[e.jsx(zs,{className:"w-full sm:w-48",children:e.jsx(Vs,{placeholder:"All Types"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Types"}),p.map(S=>e.jsx(vt,{value:S.id,children:S.name},S.id))]})]}),e.jsxs("div",{className:"flex gap-2",children:[N&&e.jsx(W,{variant:"outline",size:"sm",onClick:b,children:"Clear Filters"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(W,{variant:i==="grid"?"secondary":"outline",size:"icon",onClick:()=>d("grid"),className:"rounded-full",children:e.jsx(xp,{className:"h-4 w-4"})}),e.jsx(W,{variant:i==="list"?"secondary":"outline",size:"icon",onClick:()=>d("list"),className:"rounded-full",children:e.jsx(Dh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[_.length," template",_.length!==1?"s":""," found"]}),y&&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((S,C)=>e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(Ms,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(Ms,{className:"h-5 w-3/4 mb-2"}),e.jsx(Ms,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ms,{className:"h-5 w-16"}),e.jsx(Ms,{className:"h-5 w-20"})]})]})},C))}),!y&&_.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:N?"No templates match your filters":"No templates available yet"}),N&&e.jsx(W,{variant:"outline",onClick:b,children:"Clear Filters"})]}),!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:_.map(S=>e.jsxs(Pe,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${i==="list"?"flex flex-row":""}`,onClick:()=>w(S.id),children:[e.jsxs("div",{className:`relative overflow-hidden bg-muted ${i==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:[S.preview_image_url?e.jsx("img",{src:S.preview_image_url,alt:S.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"}),S.links.length>1&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(Qe,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm !text-secondary",children:[e.jsx(vo,{className:"h-3 w-3"}),S.links.length]})})]}),e.jsxs(Oe,{className:`p-4 flex flex-col ${i==="list"?"flex-1":""}`,children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:S.name}),S.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:Qde(S.description)}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[S.category&&e.jsx(Qe,{variant:"secondary",className:"text-xs",children:S.category.name}),S.type&&e.jsx(Qe,{variant:"outline",className:"text-xs",children:S.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(Bu,{className:"h-3.5 w-3.5"}),S.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Fl,{className:"h-3.5 w-3.5"}),S.commentsCount]})]}),e.jsxs(W,{size:"sm",className:"w-full gap-2",onClick:C=>{C.stopPropagation(),w(S.id)},children:[e.jsx(Yr,{className:"h-4 w-4"}),"View Template"]})]})]},S.id))})]})})};var E$t="Separator",K8e="horizontal",P$t=["horizontal","vertical"],Eet=k.forwardRef((t,s)=>{const{decorative:r,orientation:n=K8e,...a}=t,o=I$t(n)?n:K8e,i=r?{role:"none"}:{"aria-orientation":o==="vertical"?o:void 0,role:"separator"};return e.jsx(Jr.div,{"data-orientation":o,...i,...a,ref:s})});Eet.displayName=E$t;function I$t(t){return P$t.includes(t)}var Pet=Eet;const ho=k.forwardRef(({className:t,orientation:s="horizontal",decorative:r=!0,...n},a)=>e.jsx(Pet,{ref:a,decorative:r,orientation:s,className:Ot("shrink-0 bg-border",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...n}));ho.displayName=Pet.displayName;const L$t=()=>{const{templateId:t}=io(),s=wr(),{user:r,isAdmin:n}=Us(),{toast:a}=ja(),o=Qt(),{trackEngagement:l}=QA(),[i,d]=k.useState(""),{data:u,isLoading:p}=gt({queryKey:["template-detail",t],queryFn:async()=>{const{data:I,error:L}=await G.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("id",t).single();if(L)throw L;const{data:O}=await G.from("template_links").select("*").eq("template_id",t).order("sort_order"),{data:V}=await G.from("template_guides").select("*").eq("template_id",t).order("sort_order");return{...I,links:O||[],guides:V||[]}},enabled:!!t}),{data:f=[]}=gt({queryKey:["template-linked-toolkits",t],queryFn:async()=>{const{data:I,error:L}=await G.from("resource_kit_templates").select("kit_id, resource_kits:kit_id(id, name, featured_image_url)").eq("template_id",t);if(L)throw L;return(I||[]).map(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:y=[]}=gt({queryKey:["template-likes",t],queryFn:async()=>{const{data:I,error:L}=await G.from("template_likes").select("*").eq("template_id",t);if(L)throw L;return I},enabled:!!t}),{data:_=[]}=gt({queryKey:["template-comments",t],queryFn:async()=>{const{data:I,error:L}=await G.from("template_comments").select("*").eq("template_id",t).order("created_at",{ascending:!1});if(L)throw L;const O=[...new Set(I.map(B=>B.user_id))],{data:V}=await G.from("profiles").select("id, name").in("id",O),q=new Map((V==null?void 0:V.map(B=>[B.id,B.name]))||[]);return I.map(B=>({...B,user_name:q.get(B.user_id)||"Unknown User"}))},enabled:!!t}),b=Pt({mutationFn:async I=>{const{error:L}=await G.from("template_comments").insert({template_id:t,user_id:r.id,content:I});if(L)throw L},onSuccess:()=>{o.invalidateQueries({queryKey:["template-comments",t]}),d(""),a({title:"Comment added!"})},onError:I=>{a({title:"Error adding comment",description:I.message,variant:"destructive"})}}),N=Pt({mutationFn:async I=>{const{error:L}=await G.from("template_comments").delete().eq("id",I);if(L)throw L},onSuccess:()=>{o.invalidateQueries({queryKey:["template-comments",t]}),a({title:"Comment deleted"})}}),w=Pt({mutationFn:async()=>{const I=y.find(L=>L.user_id===(r==null?void 0:r.id));if(I){const{error:L}=await G.from("template_likes").delete().eq("id",I.id);if(L)throw L}else{const{error:L}=await G.from("template_likes").insert({template_id:t,user_id:r.id});if(L)throw L}},onSuccess:()=>{o.invalidateQueries({queryKey:["template-likes",t]})}}),S=y.some(I=>I.user_id===(r==null?void 0:r.id)),C=I=>I.split(" ").map(L=>L[0]).join("").toUpperCase().slice(0,2),A=I=>{I.preventDefault(),!(!i.trim()||!r)&&b.mutate(i.trim())};return p?e.jsx(Ds,{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(Ds,{title:u.name,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(W,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(da,{to:"/templates",children:[e.jsx(Oa,{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(Qe,{variant:"secondary",children:u.category.name}),u.type&&e.jsx(Qe,{variant:"outline",children:u.type.name})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&e.jsx(W,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(da,{to:`/admin/templates?edit=${u.id}`,children:[e.jsx(ga,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(sE,{resourceType:"template",resourceId:u.id,resourceTitle:u.name,size:"default",className:"rounded-full"}),e.jsxs(W,{variant:S?"default":"outline",className:"gap-2 rounded-full",onClick:()=>w.mutate(),disabled:!r||w.isPending,children:[e.jsx(Bu,{className:`h-4 w-4 ${S?"fill-current":""}`}),y.length," ",y.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(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(vo,{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(W,{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(Yr,{className:"h-4 w-4 text-muted-foreground"})]},I.id))})]})}),u.video_url&&e.jsx(Pe,{children:e.jsx(Oe,{className:"pt-6",children:e.jsx("div",{className:"aspect-video w-full rounded-lg overflow-hidden",children:e.jsx("iframe",{src:u.video_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})}),u.guides&&u.guides.length>0&&e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(vn,{className:"h-4 w-4"}),"Guide Files"]}),e.jsx("div",{className:"grid gap-2",children:u.guides.map(I=>e.jsxs(W,{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(vn,{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(Qa,{className:"h-4 w-4 text-muted-foreground"})]},I.id))})]})}),f.length>0&&e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(cl,{className:"h-4 w-4"}),"Related Toolkits"]}),e.jsx("div",{className:"grid gap-2",children:f.map(I=>e.jsxs(W,{variant:"outline",className:"w-full justify-start gap-3 h-auto py-3",onClick:()=>s(`/toolbox/${I.id}`),children:[I.featured_image_url?e.jsx("img",{src:I.featured_image_url,alt:"",className:"w-10 h-10 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(cl,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"font-medium",children:I.name})]},I.id))})]})}),e.jsx(ho,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(Fl,{className:"h-5 w-5"}),"Comments (",_.length,")"]}),r?e.jsxs("form",{onSubmit:A,className:"flex gap-2",children:[e.jsx(_r,{placeholder:"Add a comment...",value:i,onChange:I=>d(I.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(W,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!i.trim()||b.isPending,children:e.jsx(_n,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),e.jsx("div",{className:"space-y-4",children:_.length===0?e.jsx(Pe,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):_.map(I=>e.jsx(Pe,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Nn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(kn,{className:"text-sm",children:C(I.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:I.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Nl(new Date(I.created_at),{addSuffix:!0})}),I.user_id===(r==null?void 0:r.id)&&e.jsx(W,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>N.mutate(I.id),children:e.jsx(vr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:I.content})]})]})})},I.id))})]})]})}):e.jsx(Ds,{title:"Templates",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(vo,{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(W,{asChild:!0,className:"mt-4",children:e.jsx(da,{to:"/templates",children:"Back to Templates"})})]})})},D$t=()=>{const{user:t}=Us(),[s,r]=k.useState(""),[n,a]=k.useState("all"),{data:o=[]}=gt({queryKey:["academy-categories"],queryFn:async()=>{const{data:y,error:_}=await G.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(_)throw _;return y}}),{data:l=[],isLoading:i}=gt({queryKey:["academy-videos"],queryFn:async()=>{const{data:y,error:_}=await G.from("academy_videos").select(` *, category:academy_categories(id, name) `).eq("is_published",!0).order("publish_date",{ascending:!1});if(_)throw _;const{data:b,error:N}=await G.from("academy_resources").select("*").order("sort_order");if(N)throw N;return y.map(S=>({...S,resources:(b==null?void 0:b.filter(C=>C.video_id===S.id))||[]}))}}),{data:d=[]}=gt({queryKey:["academy-video-likes"],queryFn:async()=>{const{data:y,error:_}=await G.from("academy_video_likes").select("video_id, user_id");if(_)throw _;return y}}),u=l.filter(y=>{var N;const _=s===""||y.title.toLowerCase().includes(s.toLowerCase())||((N=y.description)==null?void 0:N.toLowerCase().includes(s.toLowerCase())),b=n==="all"||y.category_id===n;return _&&b}),p=y=>d.filter(_=>_.video_id===y).length,f=y=>d.some(_=>_.video_id===y&&_.user_id===(t==null?void 0:t.id));return e.jsx(Ds,{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(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search videos...",value:s,onChange:y=>r(y.target.value),className:"pl-10"})]})}),e.jsx(ta,{value:n,onValueChange:a,children:e.jsxs(Jn,{className:"w-full justify-start flex-wrap h-auto gap-2 bg-transparent p-0",children:[e.jsx(cs,{value:"all",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:"All Videos"}),o.map(y=>e.jsx(cs,{value:y.id,className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:y.name},y.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(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(yn,{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(y=>e.jsx(da,{to:`/academy/${y.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:[y.thumbnail_url?e.jsx("img",{src:y.thumbnail_url,alt:y.title,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(yn,{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(Co,{className:"h-8 w-8 text-primary-foreground ml-1"})})}),y.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(nn,{className:"h-3 w-3"}),y.duration]})]}),e.jsxs(Dt,{className:"pb-2",children:[e.jsx("div",{className:"flex items-start justify-between gap-2",children:e.jsx(zt,{className:"text-lg line-clamp-2",children:y.title})}),y.category&&e.jsx(Qe,{variant:"secondary",className:"w-fit",children:y.category.name})]}),e.jsxs(Oe,{className:"pt-0",children:[y.description&&e.jsx(dr,{className:"line-clamp-2",children:y.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(Bu,{className:`h-4 w-4 ${f(y.id)?"fill-primary text-primary":""}`}),p(y.id)]}),y.resources&&y.resources.length>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(vn,{className:"h-4 w-4"}),y.resources.length]})]})]})]})},y.id))})]})})};function Iet({resourceType:t,resourceId:s}){const{data:r=[]}=gt({queryKey:["linked-templates",t,s],queryFn:async()=>{if(t==="academy_video"){const{data:n,error:a}=await G.from("academy_video_templates").select("template_id, canva_templates:template_id(id, name, preview_image_url)").eq("video_id",s);if(a)throw a;return(n||[]).map(o=>o.canva_templates).filter(Boolean)}else{const{data:n,error:a}=await G.from("resource_kit_templates").select("template_id, canva_templates:template_id(id, name, preview_image_url)").eq("kit_id",s);if(a)throw a;return(n||[]).map(o=>o.canva_templates).filter(Boolean)}},enabled:!!s});return r.length===0?null:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-sm",children:[e.jsx(zl,{className:"h-4 w-4"}),"Related Templates"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(n=>e.jsx(da,{to:`/templates/${n.id}`,children:e.jsxs(Qe,{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(zl,{className:"h-3 w-3"}),n.name]})},n.id))})]})}const R$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},O$t=()=>{const{videoId:t}=io();wr();const{user:s,isAdmin:r}=Us(),{toast:n}=ja(),a=Qt(),{trackEngagement:o}=QA(),[l,i]=k.useState(""),{data:d,isLoading:u}=gt({queryKey:["academy-video",t],queryFn:async()=>{const{data:A,error:I}=await G.from("academy_videos").select(` *, category:academy_categories(id, name) `).eq("id",t).eq("is_published",!0).single();if(I)throw I;const{data:L}=await G.from("academy_resources").select("*").eq("video_id",t).order("sort_order");return{...A,resources:L||[]}},enabled:!!t});k.useEffect(()=>{d&&o("academy_video",d.id,d.title,"view")},[d==null?void 0:d.id]);const{data:p=[]}=gt({queryKey:["academy-video-likes",t],queryFn:async()=>{const{data:A,error:I}=await G.from("academy_video_likes").select("*").eq("video_id",t);if(I)throw I;return A},enabled:!!t}),{data:f=[]}=gt({queryKey:["academy-video-comments",t],queryFn:async()=>{const{data:A,error:I}=await G.from("academy_video_comments").select("*").eq("video_id",t).order("created_at",{ascending:!1});if(I)throw I;const L=[...new Set(A.map(q=>q.user_id))],{data:O}=await G.from("profiles").select("id, name").in("id",L),V=new Map((O==null?void 0:O.map(q=>[q.id,q.name]))||[]);return A.map(q=>({...q,user_name:V.get(q.user_id)||"Unknown User"}))},enabled:!!t}),y=Pt({mutationFn:async A=>{const{error:I}=await G.from("academy_video_comments").insert({video_id:t,user_id:s.id,content:A});if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",t]}),i(""),n({title:"Comment added!"})},onError:A=>{n({title:"Error adding comment",description:A.message,variant:"destructive"})}}),_=Pt({mutationFn:async A=>{const{error:I}=await G.from("academy_video_comments").delete().eq("id",A);if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",t]}),n({title:"Comment deleted"})}}),b=Pt({mutationFn:async()=>{const A=p.find(I=>I.user_id===(s==null?void 0:s.id));if(A){const{error:I}=await G.from("academy_video_likes").delete().eq("id",A.id);if(I)throw I}else{const{error:I}=await G.from("academy_video_likes").insert({video_id:t,user_id:s.id});if(I)throw I}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-likes",t]})}}),N=p.some(A=>A.user_id===(s==null?void 0:s.id)),w=A=>{switch(A==null?void 0:A.toLowerCase()){case"pdf":return"📄";case"pptx":case"ppt":return"📊";case"xlsx":case"xls":return"📈";case"docx":case"doc":return"📝";case"zip":return"📦";default:return"📁"}},S=A=>A.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),C=A=>{A.preventDefault(),!(!l.trim()||!s)&&y.mutate(l.trim())};return u?e.jsx(Ds,{title:"Academy",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):d?e.jsx(Ds,{title:d.title,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(W,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(da,{to:"/academy",children:[e.jsx(Oa,{className:"h-4 w-4"}),"Back to Academy"]})}),e.jsx("div",{className:"relative w-full rounded-lg overflow-hidden bg-black",style:{paddingTop:"56.25%"},children:["youtube","vimeo","loom","bunny_stream"].includes(d.video_type)?e.jsx("iframe",{src:R$t(d.video_url,d.video_type),loading:"lazy",style:{border:0,position:"absolute",top:0,left:0,height:"100%",width:"100%"},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0}):e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-white gap-4",children:[e.jsx(yn,{className:"h-16 w-16 opacity-50"}),e.jsx(W,{variant:"secondary",asChild:!0,children:e.jsxs("a",{href:d.video_url,target:"_blank",rel:"noopener noreferrer",className:"gap-2",children:[e.jsx(Yr,{className:"h-4 w-4"}),"Open Video"]})})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:d.title}),d.category&&e.jsx(Qe,{variant:"secondary",children:d.category.name})]}),e.jsxs("div",{className:"flex gap-2",children:[r&&e.jsx(W,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(da,{to:`/admin/academy?edit=${d.id}`,children:[e.jsx(ga,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(sE,{resourceType:"academy_video",resourceId:d.id,resourceTitle:d.title}),e.jsxs(W,{variant:N?"default":"outline",className:"gap-2 w-fit",onClick:()=>b.mutate(),disabled:!s||b.isPending,children:[e.jsx(Bu,{className:`h-4 w-4 ${N?"fill-current":""}`}),p.length," ",p.length===1?"Like":"Likes"]})]})]}),d.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:d.description}})]}),d.resources&&d.resources.length>0&&e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(vn,{className:"h-4 w-4"}),"Resources"]}),e.jsx("div",{className:"grid gap-2",children:d.resources.map(A=>e.jsxs("a",{href:A.file_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 p-3 rounded-lg border hover:bg-muted transition-colors",children:[e.jsx("span",{className:"text-2xl",children:w(A.file_type)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:A.title}),e.jsx("p",{className:"text-xs text-muted-foreground uppercase",children:A.file_type})]}),e.jsx(Qa,{className:"h-4 w-4 text-muted-foreground"})]},A.id))})]})}),e.jsx(Iet,{resourceType:"academy_video",resourceId:d.id}),e.jsx(ho,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(Fl,{className:"h-5 w-5"}),"Comments (",f.length,")"]}),s?e.jsxs("form",{onSubmit:C,className:"flex gap-2",children:[e.jsx(_r,{placeholder:"Add a comment...",value:l,onChange:A=>i(A.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(W,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||y.isPending,children:e.jsx(_n,{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(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):f.map(A=>e.jsx(Pe,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Nn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(kn,{className:"text-sm",children:S(A.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:A.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Nl(new Date(A.created_at),{addSuffix:!0})}),A.user_id===(s==null?void 0:s.id)&&e.jsx(W,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>_.mutate(A.id),children:e.jsx(vr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:A.content})]})]})})},A.id))})]})]})}):e.jsx(Ds,{title:"Academy",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(yn,{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(W,{asChild:!0,className:"mt-4",children:e.jsx(da,{to:"/academy",children:"Back to Academy"})})]})})};function F$t(){const t=wr(),[s,r]=k.useState(""),{data:n,isLoading:a}=gt({queryKey:["resource-kits-published"],queryFn:async()=>{const{data:_,error:b}=await G.from("resource_kits").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(b)throw b;return _}}),{data:o}=gt({queryKey:["resource-kit-files-all"],queryFn:async()=>{const{data:_,error:b}=await G.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(b)throw b;return _}}),{data:l}=gt({queryKey:["resource-kit-likes-all"],queryFn:async()=>{const{data:_,error:b}=await G.from("resource_kit_likes").select("kit_id");if(b)throw b;return _}}),{data:i}=gt({queryKey:["resource-kit-comments-all"],queryFn:async()=>{const{data:_,error:b}=await G.from("resource_kit_comments").select("kit_id");if(b)throw b;return _}}),d=n==null?void 0:n.filter(_=>{var b;return _.name.toLowerCase().includes(s.toLowerCase())||((b=_.description)==null?void 0:b.toLowerCase().includes(s.toLowerCase()))}),u=_=>(o==null?void 0:o.filter(b=>b.kit_id===_))||[],p=_=>(l==null?void 0:l.filter(b=>b.kit_id===_).length)||0,f=_=>(i==null?void 0:i.filter(b=>b.kit_id===_).length)||0,y=_=>{t(`/toolbox/${_}`)};return e.jsx(Ds,{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(ln,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search resource kits...",value:s,onChange:_=>r(_.target.value),className:"pl-10"})]}),!a&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(d==null?void 0:d.length)||0," resource kit",(d==null?void 0:d.length)!==1?"s":""," available"]}),a?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:[...Array(8)].map((_,b)=>e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(Ms,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(Ms,{className:"h-5 w-3/4 mb-2"}),e.jsx(Ms,{className:"h-4 w-full mb-4"}),e.jsx(Ms,{className:"h-4 w-2/3"})]})},b))}):(d==null?void 0:d.length)===0?e.jsxs(Pe,{className:"p-12 text-center",children:[e.jsx(cl,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No resource kits found"}),e.jsx("p",{className:"text-muted-foreground",children:s?"Try adjusting your search terms":"Check back later for new resources"})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:d==null?void 0:d.map(_=>{const b=u(_.id).length,N=p(_.id),w=f(_.id);return e.jsxs(Pe,{className:"group overflow-hidden cursor-pointer hover:shadow-lg transition-all duration-200",onClick:()=>y(_.id),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:_.featured_image_url?e.jsx("img",{src:_.featured_image_url,alt:_.name,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(cl,{className:"h-16 w-16 text-muted-foreground"})})}),e.jsxs(Oe,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:_.name}),_.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:Qde(_.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(vn,{className:"h-4 w-4"}),b," file",b!==1?"s":""]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Bu,{className:"h-3.5 w-3.5"}),N]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Fl,{className:"h-3.5 w-3.5"}),w]})]})]})]})]},_.id)})})]})})}const z$t=()=>{const{kitId:t}=io(),{user:s,isAdmin:r}=Us(),{toast:n}=ja(),a=Qt(),{trackEngagement:o}=QA(),[l,i]=k.useState(""),{data:d,isLoading:u}=gt({queryKey:["resource-kit-detail",t],queryFn:async()=>{const{data:A,error:I}=await G.from("resource_kits").select("*").eq("id",t).eq("is_published",!0).single();if(I)throw I;const{data:L}=await G.from("resource_kit_files").select("*").eq("kit_id",t).order("sort_order"),{data:O}=await G.from("resource_kit_links").select("*").eq("kit_id",t).order("sort_order");return{...A,files:L||[],links:O||[]}},enabled:!!t});k.useEffect(()=>{d&&o("toolbox",d.id,d.name,"view")},[d==null?void 0:d.id]);const{data:p=[]}=gt({queryKey:["resource-kit-likes",t],queryFn:async()=>{const{data:A,error:I}=await G.from("resource_kit_likes").select("*").eq("kit_id",t);if(I)throw I;return A},enabled:!!t}),{data:f=[]}=gt({queryKey:["resource-kit-comments",t],queryFn:async()=>{const{data:A,error:I}=await G.from("resource_kit_comments").select("*").eq("kit_id",t).order("created_at",{ascending:!1});if(I)throw I;const L=[...new Set(A.map(q=>q.user_id))],{data:O}=await G.from("profiles").select("id, name").in("id",L),V=new Map((O==null?void 0:O.map(q=>[q.id,q.name]))||[]);return A.map(q=>({...q,user_name:V.get(q.user_id)||"Unknown User"}))},enabled:!!t}),y=Pt({mutationFn:async A=>{const{error:I}=await G.from("resource_kit_comments").insert({kit_id:t,user_id:s.id,content:A});if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",t]}),i(""),n({title:"Comment added!"})},onError:A=>{n({title:"Error adding comment",description:A.message,variant:"destructive"})}}),_=Pt({mutationFn:async A=>{const{error:I}=await G.from("resource_kit_comments").delete().eq("id",A);if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",t]}),n({title:"Comment deleted"})}}),b=Pt({mutationFn:async()=>{const A=p.find(I=>I.user_id===(s==null?void 0:s.id));if(A){const{error:I}=await G.from("resource_kit_likes").delete().eq("id",A.id);if(I)throw I}else{const{error:I}=await G.from("resource_kit_likes").insert({kit_id:t,user_id:s.id});if(I)throw I}},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-likes",t]})}}),N=p.some(A=>A.user_id===(s==null?void 0:s.id)),w=A=>A.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),S=A=>A?A<1024?A+" B":A<1024*1024?(A/1024).toFixed(1)+" KB":(A/(1024*1024)).toFixed(1)+" MB":"",C=A=>{A.preventDefault(),!(!l.trim()||!s)&&y.mutate(l.trim())};return u?e.jsx(Ds,{title:"Toolbox",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):d?e.jsx(Ds,{title:d.name,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(W,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(da,{to:"/toolbox",children:[e.jsx(Oa,{className:"h-4 w-4"}),"Back to Toolbox"]})}),d.featured_image_url&&e.jsx("div",{className:"relative w-full rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:d.featured_image_url,alt:d.name,className:"w-full max-h-[400px] object-cover"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsx("div",{className:"space-y-2",children:e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:d.name})}),e.jsxs("div",{className:"flex items-center gap-2",children:[r&&e.jsx(W,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(da,{to:`/admin/toolbox?edit=${d.id}`,children:[e.jsx(ga,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(sE,{resourceType:"resource_kit",resourceId:d.id,resourceTitle:d.name,size:"default",className:"rounded-full"}),e.jsxs(W,{variant:N?"default":"outline",className:"gap-2 rounded-full",onClick:()=>b.mutate(),disabled:!s||b.isPending,children:[e.jsx(Bu,{className:`h-4 w-4 ${N?"fill-current":""}`}),p.length," ",p.length===1?"Like":"Likes"]})]})]}),d.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:d.description}})]}),d.files&&d.files.length>0&&e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(vn,{className:"h-4 w-4"}),"Included Resources (",d.files.length,")"]}),e.jsx("div",{className:"grid gap-2",children:d.files.map(A=>e.jsxs("a",{href:A.file_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("toolbox",d.id,d.name,"click_pdf"),className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(vn,{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:S(A.file_size)})]})]}),e.jsx(Qa,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},A.id))})]})}),d.links&&d.links.length>0&&e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Yr,{className:"h-4 w-4"}),"Canva Templates (",d.links.length,")"]}),e.jsx("div",{className:"grid gap-2",children:d.links.map(A=>e.jsxs("a",{href:A.canva_share_link,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("toolbox",d.id,d.name,"click_canva"),className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-purple-500/10",children:e.jsx(Yr,{className:"h-4 w-4 text-purple-600"})}),e.jsx("div",{className:"font-medium text-sm",children:A.title})]}),e.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-primary transition-colors",children:"Open in Canva"})]},A.id))})]})}),e.jsx(Iet,{resourceType:"resource_kit",resourceId:d.id}),e.jsx(ho,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(Fl,{className:"h-5 w-5"}),"Comments (",f.length,")"]}),s?e.jsxs("form",{onSubmit:C,className:"flex gap-2",children:[e.jsx(_r,{placeholder:"Add a comment...",value:l,onChange:A=>i(A.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(W,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||y.isPending,children:e.jsx(_n,{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(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):f.map(A=>e.jsx(Pe,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Nn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(kn,{className:"text-sm",children:w(A.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:A.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Nl(new Date(A.created_at),{addSuffix:!0})}),A.user_id===(s==null?void 0:s.id)&&e.jsx(W,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>_.mutate(A.id),children:e.jsx(vr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:A.content})]})]})})},A.id))})]})]})}):e.jsx(Ds,{title:"Toolbox",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(cl,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Resource kit not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This resource kit may have been removed or is not available."}),e.jsx(W,{asChild:!0,className:"mt-4",children:e.jsx(da,{to:"/toolbox",children:"Back to Toolbox"})})]})})},B$t=()=>{const t=wr(),[s,r]=k.useState(""),[n,a]=k.useState("grid"),{data:o=[],isLoading:l}=gt({queryKey:["social-swag"],queryFn:async()=>{const{data:u,error:p}=await G.from("social_swag").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(p)throw p;const{data:f,error:y}=await G.from("social_swag_links").select("*").order("sort_order");if(y)throw y;const{data:_}=await G.from("social_swag_likes").select("swag_id"),{data:b}=await G.from("social_swag_comments").select("swag_id"),N=new Map;_==null||_.forEach(C=>{N.set(C.swag_id,(N.get(C.swag_id)||0)+1)});const w=new Map;return b==null||b.forEach(C=>{w.set(C.swag_id,(w.get(C.swag_id)||0)+1)}),(u||[]).map(C=>({...C,links:(f||[]).filter(A=>A.swag_id===C.id)||[],likesCount:N.get(C.id)||0,commentsCount:w.get(C.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()))}),d=u=>{t(`/social-swag/${u}`)};return e.jsx(Ds,{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(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{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(W,{variant:"outline",size:"sm",onClick:()=>r(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(W,{variant:n==="grid"?"secondary":"outline",size:"icon",onClick:()=>a("grid"),className:"rounded-full",children:e.jsx(xp,{className:"h-4 w-4"})}),e.jsx(W,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(Dh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[i.length," item",i.length!==1?"s":""," found"]}),l&&e.jsx("div",{className:n==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:[...Array(8)].map((u,p)=>e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(Ms,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(Ms,{className:"h-5 w-3/4 mb-2"}),e.jsx(Ms,{className:"h-4 w-full mb-4"})]})},p))}),!l&&i.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:s?"No items match your search":"No social swag available yet"}),s&&e.jsx(W,{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:()=>d(u.id),children:[e.jsxs("div",{className:`relative overflow-hidden bg-muted ${n==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:[u.preview_image_url?e.jsx("img",{src:u.preview_image_url,alt:u.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No Preview"}),u.links.length>1&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(Qe,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm",children:[e.jsx(vo,{className:"h-3 w-3"}),u.links.length]})})]}),e.jsxs(Oe,{className:`p-4 flex flex-col ${n==="list"?"flex-1":""}`,children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:u.title}),u.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:u.description.replace(/<[^>]*>/g,"")}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mb-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Bu,{className:"h-3.5 w-3.5"}),u.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Fl,{className:"h-3.5 w-3.5"}),u.commentsCount]})]}),e.jsxs(W,{size:"sm",className:"w-full gap-2",onClick:p=>{p.stopPropagation(),d(u.id)},children:[e.jsx(Yr,{className:"h-4 w-4"}),"View Details"]})]})]},u.id))})]})})};var ni=function(){return ni=Object.assign||function(s){for(var r,n=1,a=arguments.length;n1&&(d||!u),f=s>1&&(u||!d),y=function(){n&&o(n)},_=function(){a&&o(a)};return e.jsx(vqt,{displayMonth:t.displayMonth,hideNext:p,hidePrevious:f,nextMonth:a,previousMonth:n,onPreviousClick:y,onNextClick:_})}function _qt(t){var s,r=ql(),n=r.classNames,a=r.disableNavigation,o=r.styles,l=r.captionLayout,i=r.components,d=(s=i==null?void 0:i.CaptionLabel)!==null&&s!==void 0?s:Ret,u;return a?u=e.jsx(d,{id:t.id,displayMonth:t.displayMonth}):l==="dropdown"?u=e.jsx(Z8e,{displayMonth:t.displayMonth,id:t.id}):l==="dropdown-buttons"?u=e.jsxs(e.Fragment,{children:[e.jsx(Z8e,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id}),e.jsx(Y8e,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id})]}):u=e.jsxs(e.Fragment,{children:[e.jsx(d,{id:t.id,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(Y8e,{displayMonth:t.displayMonth,id:t.id})]}),e.jsx("div",{className:n.caption,style:o.caption,children:u})}function bqt(t){var s=ql(),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 wqt(t,s,r){for(var n=r?x1(new Date):zh(new Date,{locale:t,weekStartsOn:s}),a=[],o=0;o<7;o++){var l=ml(n,o);a.push(l)}return a}function jqt(){var t=ql(),s=t.classNames,r=t.styles,n=t.showWeekNumber,a=t.locale,o=t.weekStartsOn,l=t.ISOWeek,i=t.formatters.formatWeekdayName,d=t.labels.labelWeekday,u=wqt(a,o,l);return e.jsxs("tr",{style:r.head_row,className:s.head_row,children:[n&&e.jsx("td",{style:r.head_cell,className:s.head_cell}),u.map(function(p,f){return e.jsx("th",{scope:"col",className:s.head_cell,style:r.head_cell,"aria-label":d(p,{locale:a}),children:i(p,{locale:a})},f)})]})}function Nqt(){var t,s=ql(),r=s.classNames,n=s.styles,a=s.components,o=(t=a==null?void 0:a.HeadRow)!==null&&t!==void 0?t:jqt;return e.jsx("thead",{style:n.head,className:r.head,children:e.jsx(o,{})})}function kqt(t){var s=ql(),r=s.locale,n=s.formatters.formatDay;return e.jsx(e.Fragment,{children:n(t.date,{locale:r})})}var t4e=k.createContext(void 0);function Sqt(t){if(!QR(t.initialProps)){var s={selected:void 0,modifiers:{disabled:[]}};return e.jsx(t4e.Provider,{value:s,children:t.children})}return e.jsx(Cqt,{initialProps:t.initialProps,children:t.children})}function Cqt(t){var s=t.initialProps,r=t.children,n=s.selected,a=s.min,o=s.max,l=function(u,p,f){var y,_;(y=s.onDayClick)===null||y===void 0||y.call(s,u,p,f);var b=!!(p.selected&&a&&(n==null?void 0:n.length)===a);if(!b){var N=!!(!p.selected&&o&&(n==null?void 0:n.length)===o);if(!N){var w=n?Let([],n):[];if(p.selected){var S=w.findIndex(function(C){return il(u,C)});w.splice(S,1)}else w.push(u);(_=s.onSelect)===null||_===void 0||_.call(s,w,u,p,f)}}},i={disabled:[]};n&&i.disabled.push(function(u){var p=o&&n.length>o-1,f=n.some(function(y){return il(y,u)});return!!(p&&!f)});var d={selected:n,onDayClick:l,modifiers:i};return e.jsx(t4e.Provider,{value:d,children:r})}function s4e(){var t=k.useContext(t4e);if(!t)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return t}function Mqt(t,s){var r=s||{},n=r.from,a=r.to;return n&&a?il(a,t)&&il(n,t)?void 0:il(a,t)?{from:a,to:void 0}:il(n,t)?void 0:ZS(n,t)?{from:t,to:a}:{from:n,to:t}:a?ZS(t,a)?{from:a,to:t}:{from:t,to:a}:n?YS(t,n)?{from:t,to:n}:{from:n,to:t}:{from:t,to:void 0}}var r4e=k.createContext(void 0);function Tqt(t){if(!JR(t.initialProps)){var s={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return e.jsx(r4e.Provider,{value:s,children:t.children})}return e.jsx(Aqt,{initialProps:t.initialProps,children:t.children})}function Aqt(t){var s=t.initialProps,r=t.children,n=s.selected,a=n||{},o=a.from,l=a.to,i=s.min,d=s.max,u=function(_,b,N){var w,S;(w=s.onDayClick)===null||w===void 0||w.call(s,_,b,N);var C=Mqt(_,n);(S=s.onSelect)===null||S===void 0||S.call(s,C,_,b,N)},p={range_start:[],range_end:[],range_middle:[],disabled:[]};if(o?(p.range_start=[o],l?(p.range_end=[l],il(o,l)||(p.range_middle=[{after:o,before:l}])):p.range_end=[o]):l&&(p.range_start=[l],p.range_end=[l]),i&&(o&&!l&&p.disabled.push({after:qie(o,i-1),before:ml(o,i-1)}),o&&l&&p.disabled.push({after:o,before:ml(o,i-1)}),!o&&l&&p.disabled.push({after:qie(l,i-1),before:ml(l,i-1)})),d){if(o&&!l&&(p.disabled.push({before:ml(o,-d+1)}),p.disabled.push({after:ml(o,d-1)})),o&&l){var f=sf(l,o)+1,y=d-f;p.disabled.push({before:qie(o,y)}),p.disabled.push({after:ml(l,y)})}!o&&l&&(p.disabled.push({before:ml(l,-d+1)}),p.disabled.push({after:ml(l,d-1)}))}return e.jsx(r4e.Provider,{value:{selected:n,onDayClick:u,modifiers:p},children:r})}function n4e(){var t=k.useContext(r4e);if(!t)throw new Error("useSelectRange must be used within a SelectRangeProvider");return t}function ioe(t){return Array.isArray(t)?Let([],t):t!==void 0?[t]:[]}function Eqt(t){var s={};return Object.entries(t).forEach(function(r){var n=r[0],a=r[1];s[n]=ioe(a)}),s}var Ug;(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"})(Ug||(Ug={}));var Pqt=Ug.Selected,gv=Ug.Disabled,Iqt=Ug.Hidden,Lqt=Ug.Today,_ye=Ug.RangeEnd,bye=Ug.RangeMiddle,wye=Ug.RangeStart,Dqt=Ug.Outside;function Rqt(t,s,r){var n,a=(n={},n[Pqt]=ioe(t.selected),n[gv]=ioe(t.disabled),n[Iqt]=ioe(t.hidden),n[Lqt]=[t.today],n[_ye]=[],n[bye]=[],n[wye]=[],n[Dqt]=[],n);return t.fromDate&&a[gv].push({before:t.fromDate}),t.toDate&&a[gv].push({after:t.toDate}),QR(t)?a[gv]=a[gv].concat(s.modifiers[gv]):JR(t)&&(a[gv]=a[gv].concat(r.modifiers[gv]),a[wye]=r.modifiers[wye],a[bye]=r.modifiers[bye],a[_ye]=r.modifiers[_ye]),a}var zet=k.createContext(void 0);function Oqt(t){var s=ql(),r=s4e(),n=n4e(),a=Rqt(s,r,n),o=Eqt(s.modifiers),l=ni(ni({},a),o);return e.jsx(zet.Provider,{value:l,children:t.children})}function Bet(){var t=k.useContext(zet);if(!t)throw new Error("useModifiers must be used within a ModifiersProvider");return t}function Fqt(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function zqt(t){return!!(t&&typeof t=="object"&&"from"in t)}function Bqt(t){return!!(t&&typeof t=="object"&&"after"in t)}function $qt(t){return!!(t&&typeof t=="object"&&"before"in t)}function qqt(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function Uqt(t,s){var r,n=s.from,a=s.to;if(n&&a){var o=sf(a,n)<0;o&&(r=[a,n],n=r[0],a=r[1]);var l=sf(t,n)>=0&&sf(a,t)>=0;return l}return a?il(a,t):n?il(n,t):!1}function Vqt(t){return Yje(t)}function Hqt(t){return Array.isArray(t)&&t.every(Yje)}function Gqt(t,s){return s.some(function(r){if(typeof r=="boolean")return r;if(Vqt(r))return il(t,r);if(Hqt(r))return r.includes(t);if(zqt(r))return Uqt(t,r);if(qqt(r))return r.dayOfWeek.includes(t.getDay());if(Fqt(r)){var n=sf(r.before,t),a=sf(r.after,t),o=n>0,l=a<0,i=ZS(r.before,r.after);return i?l&&o:o||l}return Bqt(r)?sf(t,r.after)>0:$qt(r)?sf(r.before,t)>0:typeof r=="function"?r(t):!1})}function a4e(t,s,r){var n=Object.keys(s).reduce(function(o,l){var i=s[l];return Gqt(t,i)&&o.push(l),o},[]),a={};return n.forEach(function(o){return a[o]=!0}),r&&!Rue(t,r)&&(a.outside=!0),a}function Wqt(t,s){for(var r=gc(t[0]),n=tx(t[t.length-1]),a,o,l=r;l<=n;){var i=a4e(l,s),d=!i.disabled&&!i.hidden;if(!d){l=ml(l,1);continue}if(i.selected)return l;i.today&&!o&&(o=l),a||(a=l),l=ml(l,1)}return o||a}var Kqt=365;function $et(t,s){var r=s.moveBy,n=s.direction,a=s.context,o=s.modifiers,l=s.retry,i=l===void 0?{count:0,lastFocused:t}:l,d=a.weekStartsOn,u=a.fromDate,p=a.toDate,f=a.locale,y={day:ml,week:x4,month:Am,year:j4t,startOfWeek:function(w){return a.ISOWeek?x1(w):zh(w,{locale:f,weekStartsOn:d})},endOfWeek:function(w){return a.ISOWeek?OWe(w):Lue(w,{locale:f,weekStartsOn:d})}},_=y[r](t,n==="after"?1:-1);n==="before"&&u?_=N4t([u,_]):n==="after"&&p&&(_=k4t([p,_]));var b=!0;if(o){var N=a4e(_,o);b=!N.disabled&&!N.hidden}return b?_:i.count>Kqt?i.lastFocused:$et(_,{moveBy:r,direction:n,context:a,modifiers:o,retry:ni(ni({},i),{count:i.count+1})})}var qet=k.createContext(void 0);function Zqt(t){var s=eO(),r=Bet(),n=k.useState(),a=n[0],o=n[1],l=k.useState(),i=l[0],d=l[1],u=Wqt(s.displayMonths,r),p=a??(i&&s.isDateDisplayed(i))?i:u,f=function(){d(a),o(void 0)},y=function(w){o(w)},_=ql(),b=function(w,S){if(a){var C=$et(a,{moveBy:w,direction:S,context:_,modifiers:r});il(a,C)||(s.goToDate(C,a),y(C))}},N={focusedDay:a,focusTarget:p,blur:f,focus:y,focusDayAfter:function(){return b("day","after")},focusDayBefore:function(){return b("day","before")},focusWeekAfter:function(){return b("week","after")},focusWeekBefore:function(){return b("week","before")},focusMonthBefore:function(){return b("month","before")},focusMonthAfter:function(){return b("month","after")},focusYearBefore:function(){return b("year","before")},focusYearAfter:function(){return b("year","after")},focusStartOfWeek:function(){return b("startOfWeek","before")},focusEndOfWeek:function(){return b("endOfWeek","after")}};return e.jsx(qet.Provider,{value:N,children:t.children})}function i4e(){var t=k.useContext(qet);if(!t)throw new Error("useFocusContext must be used within a FocusProvider");return t}function Yqt(t,s){var r=Bet(),n=a4e(t,r,s);return n}var o4e=k.createContext(void 0);function Xqt(t){if(!khe(t.initialProps)){var s={selected:void 0};return e.jsx(o4e.Provider,{value:s,children:t.children})}return e.jsx(Qqt,{initialProps:t.initialProps,children:t.children})}function Qqt(t){var s=t.initialProps,r=t.children,n=function(o,l,i){var d,u,p;if((d=s.onDayClick)===null||d===void 0||d.call(s,o,l,i),l.selected&&!s.required){(u=s.onSelect)===null||u===void 0||u.call(s,void 0,o,l,i);return}(p=s.onSelect)===null||p===void 0||p.call(s,o,o,l,i)},a={selected:s.selected,onDayClick:n};return e.jsx(o4e.Provider,{value:a,children:r})}function Uet(){var t=k.useContext(o4e);if(!t)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return t}function Jqt(t,s){var r=ql(),n=Uet(),a=s4e(),o=n4e(),l=i4e(),i=l.focusDayAfter,d=l.focusDayBefore,u=l.focusWeekAfter,p=l.focusWeekBefore,f=l.blur,y=l.focus,_=l.focusMonthBefore,b=l.focusMonthAfter,N=l.focusYearBefore,w=l.focusYearAfter,S=l.focusStartOfWeek,C=l.focusEndOfWeek,A=function(ae){var oe,me,ve,he;khe(r)?(oe=n.onDayClick)===null||oe===void 0||oe.call(n,t,s,ae):QR(r)?(me=a.onDayClick)===null||me===void 0||me.call(a,t,s,ae):JR(r)?(ve=o.onDayClick)===null||ve===void 0||ve.call(o,t,s,ae):(he=r.onDayClick)===null||he===void 0||he.call(r,t,s,ae)},I=function(ae){var oe;y(t),(oe=r.onDayFocus)===null||oe===void 0||oe.call(r,t,s,ae)},L=function(ae){var oe;f(),(oe=r.onDayBlur)===null||oe===void 0||oe.call(r,t,s,ae)},O=function(ae){var oe;(oe=r.onDayMouseEnter)===null||oe===void 0||oe.call(r,t,s,ae)},V=function(ae){var oe;(oe=r.onDayMouseLeave)===null||oe===void 0||oe.call(r,t,s,ae)},q=function(ae){var oe;(oe=r.onDayPointerEnter)===null||oe===void 0||oe.call(r,t,s,ae)},B=function(ae){var oe;(oe=r.onDayPointerLeave)===null||oe===void 0||oe.call(r,t,s,ae)},U=function(ae){var oe;(oe=r.onDayTouchCancel)===null||oe===void 0||oe.call(r,t,s,ae)},te=function(ae){var oe;(oe=r.onDayTouchEnd)===null||oe===void 0||oe.call(r,t,s,ae)},Y=function(ae){var oe;(oe=r.onDayTouchMove)===null||oe===void 0||oe.call(r,t,s,ae)},J=function(ae){var oe;(oe=r.onDayTouchStart)===null||oe===void 0||oe.call(r,t,s,ae)},X=function(ae){var oe;(oe=r.onDayKeyUp)===null||oe===void 0||oe.call(r,t,s,ae)},ce=function(ae){var oe;switch(ae.key){case"ArrowLeft":ae.preventDefault(),ae.stopPropagation(),r.dir==="rtl"?i():d();break;case"ArrowRight":ae.preventDefault(),ae.stopPropagation(),r.dir==="rtl"?d():i();break;case"ArrowDown":ae.preventDefault(),ae.stopPropagation(),u();break;case"ArrowUp":ae.preventDefault(),ae.stopPropagation(),p();break;case"PageUp":ae.preventDefault(),ae.stopPropagation(),ae.shiftKey?N():_();break;case"PageDown":ae.preventDefault(),ae.stopPropagation(),ae.shiftKey?w():b();break;case"Home":ae.preventDefault(),ae.stopPropagation(),S();break;case"End":ae.preventDefault(),ae.stopPropagation(),C();break}(oe=r.onDayKeyDown)===null||oe===void 0||oe.call(r,t,s,ae)},ie={onClick:A,onFocus:I,onBlur:L,onKeyDown:ce,onKeyUp:X,onMouseEnter:O,onMouseLeave:V,onPointerEnter:q,onPointerLeave:B,onTouchCancel:U,onTouchEnd:te,onTouchMove:Y,onTouchStart:J};return ie}function eUt(){var t=ql(),s=Uet(),r=s4e(),n=n4e(),a=khe(t)?s.selected:QR(t)?r.selected:JR(t)?n.selected:void 0;return a}function tUt(t){return Object.values(Ug).includes(t)}function sUt(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(tUt(n)){var o=t.classNames["day_".concat(n)];o&&r.push(o)}}),r}function rUt(t,s){var r=ni({},t.styles.day);return Object.keys(s).forEach(function(n){var a;r=ni(ni({},r),(a=t.modifiersStyles)===null||a===void 0?void 0:a[n])}),r}function nUt(t,s,r){var n,a,o,l=ql(),i=i4e(),d=Yqt(t,s),u=Jqt(t,d),p=eUt(),f=!!(l.onDayClick||l.mode!=="default");k.useEffect(function(){var O;d.outside||i.focusedDay&&f&&il(i.focusedDay,t)&&((O=r.current)===null||O===void 0||O.focus())},[i.focusedDay,t,r,f,d.outside]);var y=sUt(l,d).join(" "),_=rUt(l,d),b=!!(d.outside&&!l.showOutsideDays||d.hidden),N=(o=(a=l.components)===null||a===void 0?void 0:a.DayContent)!==null&&o!==void 0?o:kqt,w=e.jsx(N,{date:t,displayMonth:s,activeModifiers:d}),S={style:_,className:y,children:w,role:"gridcell"},C=i.focusTarget&&il(i.focusTarget,t)&&!d.outside,A=i.focusedDay&&il(i.focusedDay,t),I=ni(ni(ni({},S),(n={disabled:d.disabled,role:"gridcell"},n["aria-selected"]=d.selected,n.tabIndex=A||C?0:-1,n)),u),L={isButton:f,isHidden:b,activeModifiers:d,selectedDays:p,buttonProps:I,divProps:S};return L}function aUt(t){var s=k.useRef(null),r=nUt(t.date,t.displayMonth,s);return r.isHidden?e.jsx("div",{role:"gridcell"}):r.isButton?e.jsx(hce,ni({name:"day",ref:s},r.buttonProps)):e.jsx("div",ni({},r.divProps))}function iUt(t){var s=t.number,r=t.dates,n=ql(),a=n.onWeekNumberClick,o=n.styles,l=n.classNames,i=n.locale,d=n.labels.labelWeekNumber,u=n.formatters.formatWeekNumber,p=u(Number(s),{locale:i});if(!a)return e.jsx("span",{className:l.weeknumber,style:o.weeknumber,children:p});var f=d(Number(s),{locale:i}),y=function(_){a(s,r,_)};return e.jsx(hce,{name:"week-number","aria-label":f,className:l.weeknumber,style:o.weeknumber,onClick:y,children:p})}function oUt(t){var s,r,n=ql(),a=n.styles,o=n.classNames,l=n.showWeekNumber,i=n.components,d=(s=i==null?void 0:i.Day)!==null&&s!==void 0?s:aUt,u=(r=i==null?void 0:i.WeekNumber)!==null&&r!==void 0?r:iUt,p;return l&&(p=e.jsx("td",{className:o.cell,style:a.cell,children:e.jsx(u,{number:t.weekNumber,dates:t.dates})})),e.jsxs("tr",{className:o.row,style:a.row,children:[p,t.dates.map(function(f){return e.jsx("td",{className:o.cell,style:a.cell,role:"presentation",children:e.jsx(d,{displayMonth:t.displayMonth,date:f})},MSt(f))})]})}function X8e(t,s,r){for(var n=r!=null&&r.ISOWeek?OWe(s):Lue(s,r),a=r!=null&&r.ISOWeek?x1(t):zh(t,r),o=sf(n,a),l=[],i=0;i<=o;i++)l.push(ml(a,i));var d=l.reduce(function(u,p){var f=r!=null&&r.ISOWeek?Xje(p):Jje(p,r),y=u.find(function(_){return _.weekNumber===f});return y?(y.dates.push(p),u):(u.push({weekNumber:f,dates:[p]}),u)},[]);return d}function lUt(t,s){var r=X8e(gc(t),tx(t),s);if(s!=null&&s.useFixedWeeks){var n=ASt(t,s);if(n<6){var a=r[r.length-1],o=a.dates[a.dates.length-1],l=x4(o,6-n),i=X8e(x4(o,1),l,s);r.push.apply(r,i)}}return r}function cUt(t){var s,r,n,a=ql(),o=a.locale,l=a.classNames,i=a.styles,d=a.hideHead,u=a.fixedWeeks,p=a.components,f=a.weekStartsOn,y=a.firstWeekContainsDate,_=a.ISOWeek,b=lUt(t.displayMonth,{useFixedWeeks:!!u,ISOWeek:_,locale:o,weekStartsOn:f,firstWeekContainsDate:y}),N=(s=p==null?void 0:p.Head)!==null&&s!==void 0?s:Nqt,w=(r=p==null?void 0:p.Row)!==null&&r!==void 0?r:oUt,S=(n=p==null?void 0:p.Footer)!==null&&n!==void 0?n:bqt;return e.jsxs("table",{id:t.id,className:l.table,style:i.table,role:"grid","aria-labelledby":t["aria-labelledby"],children:[!d&&e.jsx(N,{}),e.jsx("tbody",{className:l.tbody,style:i.tbody,children:b.map(function(C){return e.jsx(w,{displayMonth:t.displayMonth,dates:C.dates,weekNumber:C.weekNumber},C.weekNumber)})}),e.jsx(S,{displayMonth:t.displayMonth})]})}function dUt(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var uUt=dUt()?k.useLayoutEffect:k.useEffect,jye=!1,hUt=0;function Q8e(){return"react-day-picker-".concat(++hUt)}function mUt(t){var s,r=t??(jye?Q8e():null),n=k.useState(r),a=n[0],o=n[1];return uUt(function(){a===null&&o(Q8e())},[]),k.useEffect(function(){jye===!1&&(jye=!0)},[]),(s=t??a)!==null&&s!==void 0?s:void 0}function pUt(t){var s,r,n=ql(),a=n.dir,o=n.classNames,l=n.styles,i=n.components,d=eO().displayMonths,u=mUt(n.id?"".concat(n.id,"-").concat(t.displayIndex):void 0),p=n.id?"".concat(n.id,"-grid-").concat(t.displayIndex):void 0,f=[o.month],y=l.month,_=t.displayIndex===0,b=t.displayIndex===d.length-1,N=!_&&!b;a==="rtl"&&(s=[_,b],b=s[0],_=s[1]),_&&(f.push(o.caption_start),y=ni(ni({},y),l.caption_start)),b&&(f.push(o.caption_end),y=ni(ni({},y),l.caption_end)),N&&(f.push(o.caption_between),y=ni(ni({},y),l.caption_between));var w=(r=i==null?void 0:i.Caption)!==null&&r!==void 0?r:_qt;return e.jsxs("div",{className:f.join(" "),style:y,children:[e.jsx(w,{id:u,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(cUt,{id:p,"aria-labelledby":u,displayMonth:t.displayMonth})]},t.displayIndex)}function fUt(t){var s=ql(),r=s.classNames,n=s.styles;return e.jsx("div",{className:r.months,style:n.months,children:t.children})}function xUt(t){var s,r,n=t.initialProps,a=ql(),o=i4e(),l=eO(),i=k.useState(!1),d=i[0],u=i[1];k.useEffect(function(){a.initialFocus&&o.focusTarget&&(d||(o.focus(o.focusTarget),u(!0)))},[a.initialFocus,d,o.focus,o.focusTarget,o]);var p=[a.classNames.root,a.className];a.numberOfMonths>1&&p.push(a.classNames.multiple_months),a.showWeekNumber&&p.push(a.classNames.with_weeknumber);var f=ni(ni({},a.styles.root),a.style),y=Object.keys(n).filter(function(b){return b.startsWith("data-")}).reduce(function(b,N){var w;return ni(ni({},b),(w={},w[N]=n[N],w))},{}),_=(r=(s=n.components)===null||s===void 0?void 0:s.Months)!==null&&r!==void 0?r:fUt;return e.jsx("div",ni({className:p.join(" "),style:f,dir:a.dir,id:a.id,nonce:n.nonce,title:n.title,lang:n.lang},y,{children:e.jsx(_,{children:l.displayMonths.map(function(b,N){return e.jsx(pUt,{displayIndex:N,displayMonth:b},N)})})}))}function gUt(t){var s=t.children,r=$$t(t,["children"]);return e.jsx(iqt,{initialProps:r,children:e.jsx(xqt,{children:e.jsx(Xqt,{initialProps:r,children:e.jsx(Sqt,{initialProps:r,children:e.jsx(Tqt,{initialProps:r,children:e.jsx(Oqt,{children:e.jsx(Zqt,{children:s})})})})})})})}function yUt(t){return e.jsx(gUt,ni({},t,{children:e.jsx(xUt,{initialProps:t})}))}function uf({className:t,classNames:s,showOutsideDays:r=!0,...n}){return e.jsx(yUt,{showOutsideDays:r,className:Ot("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:Ot(TT({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:Ot(TT({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(Xo,{className:"h-4 w-4"}),IconRight:({...a})=>e.jsx(xa,{className:"h-4 w-4"})},...n})}uf.displayName="Calendar";var She="Popover",[Vet,_As]=qc(She,[w0]),tO=w0(),[vUt,ww]=Vet(She),Het=t=>{const{__scopePopover:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!1}=t,i=tO(s),d=k.useRef(null),[u,p]=k.useState(!1),[f,y]=Uu({prop:n,defaultProp:a??!1,onChange:o,caller:She});return e.jsx(SR,{...i,children:e.jsx(vUt,{scope:s,contentId:fu(),triggerRef:d,open:f,onOpenChange:y,onOpenToggle:k.useCallback(()=>y(_=>!_),[y]),hasCustomAnchor:u,onCustomAnchorAdd:k.useCallback(()=>p(!0),[]),onCustomAnchorRemove:k.useCallback(()=>p(!1),[]),modal:l,children:r})})};Het.displayName=She;var Get="PopoverAnchor",_Ut=k.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=ww(Get,r),o=tO(r),{onCustomAnchorAdd:l,onCustomAnchorRemove:i}=a;return k.useEffect(()=>(l(),()=>i()),[l,i]),e.jsx(OA,{...o,...n,ref:s})});_Ut.displayName=Get;var Wet="PopoverTrigger",Ket=k.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=ww(Wet,r),o=tO(r),l=Ta(s,a.triggerRef),i=e.jsx(Jr.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":Jet(a.open),...n,ref:l,onClick:Mr(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?i:e.jsx(OA,{asChild:!0,...o,children:i})});Ket.displayName=Wet;var l4e="PopoverPortal",[bUt,wUt]=Vet(l4e,{forceMount:void 0}),Zet=t=>{const{__scopePopover:s,forceMount:r,children:n,container:a}=t,o=ww(l4e,s);return e.jsx(bUt,{scope:s,forceMount:r,children:e.jsx(jd,{present:r||o.open,children:e.jsx(IA,{asChild:!0,container:a,children:n})})})};Zet.displayName=l4e;var GT="PopoverContent",Yet=k.forwardRef((t,s)=>{const r=wUt(GT,t.__scopePopover),{forceMount:n=r.forceMount,...a}=t,o=ww(GT,t.__scopePopover);return e.jsx(jd,{present:n||o.open,children:o.modal?e.jsx(NUt,{...a,ref:s}):e.jsx(kUt,{...a,ref:s})})});Yet.displayName=GT;var jUt=Hb("PopoverContent.RemoveScroll"),NUt=k.forwardRef((t,s)=>{const r=ww(GT,t.__scopePopover),n=k.useRef(null),a=Ta(s,n),o=k.useRef(!1);return k.useEffect(()=>{const l=n.current;if(l)return gue(l)},[]),e.jsx(IR,{as:jUt,allowPinchZoom:!0,children:e.jsx(Xet,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Mr(t.onCloseAutoFocus,l=>{var i;l.preventDefault(),o.current||(i=r.triggerRef.current)==null||i.focus()}),onPointerDownOutside:Mr(t.onPointerDownOutside,l=>{const i=l.detail.originalEvent,d=i.button===0&&i.ctrlKey===!0,u=i.button===2||d;o.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Mr(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})}),kUt=k.forwardRef((t,s)=>{const r=ww(GT,t.__scopePopover),n=k.useRef(!1),a=k.useRef(!1);return e.jsx(Xet,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var l,i;(l=t.onCloseAutoFocus)==null||l.call(t,o),o.defaultPrevented||(n.current||(i=r.triggerRef.current)==null||i.focus(),o.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:o=>{var d,u;(d=t.onInteractOutside)==null||d.call(t,o),o.defaultPrevented||(n.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=o.target;((u=r.triggerRef.current)==null?void 0:u.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),Xet=k.forwardRef((t,s)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEscapeKeyDown:i,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:p,...f}=t,y=ww(GT,r),_=tO(r);return pue(),e.jsx(ER,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(dw,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:p,onEscapeKeyDown:i,onPointerDownOutside:d,onFocusOutside:u,onDismiss:()=>y.onOpenChange(!1),children:e.jsx(CR,{"data-state":Jet(y.open),role:"dialog",id:y.contentId,..._,...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)"}})})})}),Qet="PopoverClose",SUt=k.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=ww(Qet,r);return e.jsx(Jr.button,{type:"button",...n,ref:s,onClick:Mr(t.onClick,()=>a.onOpenChange(!1))})});SUt.displayName=Qet;var CUt="PopoverArrow",MUt=k.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=tO(r);return e.jsx(MR,{...a,...n,ref:s})});MUt.displayName=CUt;function Jet(t){return t?"open":"closed"}var TUt=Het,AUt=Ket,EUt=Zet,ett=Yet;const mo=TUt,po=AUt,no=k.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(EUt,{children:e.jsx(ett,{ref:a,align:s,sideOffset:r,className:Ot("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})}));no.displayName=ett.displayName;const PUt=bC("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"}}),c4e=k.forwardRef(({className:t,variant:s,...r},n)=>e.jsx("div",{ref:n,role:"alert",className:Ot(PUt({variant:s}),t),...r}));c4e.displayName="Alert";const IUt=k.forwardRef(({className:t,...s},r)=>e.jsx("h5",{ref:r,className:Ot("mb-1 font-medium leading-none tracking-tight",t),...s}));IUt.displayName="AlertTitle";const d4e=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Ot("text-sm [&_p]:leading-relaxed",t),...s}));d4e.displayName="AlertDescription";function LUt({open:t,onOpenChange:s,imageUrl:r,imageId:n,defaultCaption:a="",swagItemId:o,reelId:l}){const i=Qt(),[d,u]=k.useState(a),[p,f]=k.useState([]),[y,_]=k.useState(null),[b,N]=k.useState("now"),[w,S]=k.useState(UPe(ZPe(new Date),1)),[C,A]=k.useState("12"),[I,L]=k.useState("00"),[O,V]=k.useState("PM");k.useEffect(()=>{if(t){u(a),N("now"),f([]);const je=UPe(ZPe(new Date),1);S(je);const qe=je.getHours();A(String(qe>12?qe-12:qe===0?12:qe)),L("00"),V(qe>=12?"PM":"AM")}},[t,a]);const q=()=>{if(!w)return null;let je=parseInt(C);const qe=parseInt(I);return O==="PM"&&je!==12&&(je+=12),O==="AM"&&je===12&&(je=0),JL(QL(w,je),qe)},{data:B,isLoading:U}=gt({queryKey:["social-accounts-for-post"],queryFn:async()=>{const{data:{user:je}}=await G.auth.getUser();if(!je)return[];const{data:qe,error:Me}=await G.from("social_accounts").select("*").eq("user_id",je.id).eq("is_active",!0).order("platform",{ascending:!0});if(Me)throw Me;return console.log("Fetched social accounts for posting:",qe),qe},enabled:t,staleTime:0}),te=Pt({mutationFn:async({accountId:je,platform:qe})=>{_(je);const{data:Me,error:ke}=await G.functions.invoke("social-post",{body:{platform:qe,accountId:je,imageUrl:r,caption:d}});if(ke)throw ke;if(Me!=null&&Me.error)throw new Error(Me.error);return Me},onSuccess:je=>{const qe=je.platform==="facebook"?"Facebook":je.platform==="instagram"?"Instagram":je.platform==="linkedin"?"LinkedIn":"Google Business";pe.success(`Posted to ${qe}!`)},onError:je=>{pe.error(`Failed to post: ${je.message}`)},onSettled:()=>{_(null)}}),Y=Pt({mutationFn:async({accountId:je,platform:qe,scheduledFor:Me})=>{const{data:{user:ke}}=await G.auth.getUser();if(!ke)throw new Error("Not authenticated");const{error:Re}=await G.from("scheduled_posts").insert({user_id:ke.id,social_account_id:je,platform:qe,image_url:r,caption:d,swag_item_id:o||null,reel_id:l||null,scheduled_for:Me.toISOString(),status:"scheduled"});if(Re)throw Re;return{platform:qe}},onSuccess:je=>{const qe=je.platform==="facebook"?"Facebook":je.platform==="instagram"?"Instagram":"LinkedIn";pe.success(`Post scheduled for ${qe}!`)},onError:je=>{pe.error(`Failed to schedule: ${je.message}`)}}),J=async()=>{if(p.length===0){pe.error("Please select at least one account");return}if(b==="schedule"){const je=q();if(!je||je<=new Date){pe.error("Please select a future date and time");return}for(const qe of p){const Me=B==null?void 0:B.find(ke=>ke.id===qe);Me&&await Y.mutateAsync({accountId:qe,platform:Me.platform,scheduledFor:je})}i.invalidateQueries({queryKey:["scheduled-posts"]}),pe.success(`${p.length} post(s) scheduled for ${vs(je,"PPp")}`)}else for(const je of p){const qe=B==null?void 0:B.find(Me=>Me.id===je);qe&&await te.mutateAsync({accountId:je,platform:qe.platform})}i.invalidateQueries({queryKey:["scheduled-posts"]}),u(""),f([]),s(!1)},X=je=>{f(qe=>qe.includes(je)?qe.filter(Me=>Me!==je):[...qe,je])},ce=(B==null?void 0:B.filter(je=>je.platform==="facebook"))||[],ie=(B==null?void 0:B.filter(je=>je.platform==="instagram"))||[],ae=(B==null?void 0:B.filter(je=>je.platform==="linkedin"))||[],oe=(B==null?void 0:B.filter(je=>je.platform==="google_business"))||[],me=((B==null?void 0:B.length)||0)>0,ve=te.isPending||Y.isPending,he=Array.from({length:12},(je,qe)=>String(qe+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(ks,{children:[e.jsx(_s,{children:"Create Social Post"}),e.jsx(Ir,{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(xe,{htmlFor:"caption",children:"Caption"}),e.jsx(_r,{id:"caption",placeholder:"Write a caption for your post...",value:d,onChange:je=>u(je.target.value),rows:3}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[d.length,"/2200 characters"]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(xe,{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:()=>N("now"),className:Ot("flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all",b==="now"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"Post Now"}),e.jsx("button",{type:"button",onClick:()=>N("schedule"),className:Ot("flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all",b==="schedule"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"Schedule"})]})]}),b==="schedule"&&e.jsxs("div",{className:"space-y-3 p-4 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(nn,{className:"h-4 w-4"}),"Schedule for"]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(mo,{children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{variant:"outline",className:Ot("justify-start text-left font-normal flex-1",!w&&"text-muted-foreground"),children:[e.jsx(cn,{className:"mr-2 h-4 w-4"}),w?vs(w,"PPP"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(no,{className:"w-auto p-0",align:"start",children:e.jsx(uf,{mode:"single",selected:w,onSelect:S,disabled:je=>jee.jsx(vt,{value:je,children:je},je))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs($s,{value:I,onValueChange:L,children:[e.jsx(zs,{className:"w-[70px]",children:e.jsx(Vs,{})}),e.jsx(Bs,{children:ge.map(je=>e.jsx(vt,{value:je,children:je},je))})]}),e.jsxs($s,{value:O,onValueChange:je=>V(je),children:[e.jsx(zs,{className:"w-[70px]",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"AM",children:"AM"}),e.jsx(vt,{value:"PM",children:"PM"})]})]})]})]}),w&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Post will be published on ",vs(q()||new Date,"PPP 'at' p")]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(xe,{children:"Post to"}),U&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(us,{className:"h-6 w-6 animate-spin"})}),!U&&!me&&e.jsxs(c4e,{children:[e.jsx(ro,{className:"h-4 w-4"}),e.jsxs(d4e,{className:"flex flex-col gap-2",children:[e.jsx("span",{children:"No social accounts connected yet."}),e.jsxs(da,{to:"/social-connections",className:"inline-flex items-center gap-1.5 text-primary hover:underline font-medium",children:[e.jsx(So,{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(hu,{className:"h-4 w-4 text-blue-600"})," Facebook"]}),ce.map(je=>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(Ri,{checked:p.includes(je.id),onCheckedChange:()=>X(je.id),disabled:y===je.id}),e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:je.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(hu,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:je.page_name||je.platform_username}),y===je.id&&e.jsx(us,{className:"h-4 w-4 animate-spin"})]},je.id))]}),ie.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(pu,{className:"h-4 w-4 text-pink-600"})," Instagram"]}),ie.map(je=>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(Ri,{checked:p.includes(je.id),onCheckedChange:()=>X(je.id),disabled:y===je.id}),e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:je.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(pu,{className:"h-4 w-4"})})]}),e.jsxs("span",{className:"flex-1 text-sm font-medium",children:["@",je.platform_username]}),y===je.id&&e.jsx(us,{className:"h-4 w-4 animate-spin"})]},je.id))]}),ae.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(gp,{className:"h-4 w-4 text-blue-700"})," LinkedIn"]}),ae.map(je=>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(Ri,{checked:p.includes(je.id),onCheckedChange:()=>X(je.id),disabled:y===je.id}),e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:je.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(gp,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:je.platform_username}),y===je.id&&e.jsx(us,{className:"h-4 w-4 animate-spin"})]},je.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(Ia,{className:"h-4 w-4 text-red-600"})," Google Business"]}),oe.map(je=>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(Ri,{checked:p.includes(je.id),onCheckedChange:()=>X(je.id),disabled:y===je.id}),e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:je.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(Ia,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:je.page_name||je.platform_username}),y===je.id&&e.jsx(us,{className:"h-4 w-4 animate-spin"})]},je.id))]})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(W,{onClick:J,disabled:p.length===0||ve,className:"gap-2",children:[ve?e.jsx(us,{className:"h-4 w-4 animate-spin"}):b==="schedule"?e.jsx(cn,{className:"h-4 w-4"}):e.jsx(_n,{className:"h-4 w-4"}),b==="schedule"?`Schedule ${p.length} post${p.length!==1?"s":""}`:`Post to ${p.length} account${p.length!==1?"s":""}`]})]})]})})}function DUt(){const t=Qt(),[s,r]=k.useState(void 0),[n,a]=k.useState("all"),[o,l]=k.useState(null),[i,d]=k.useState(""),[u,p]=k.useState(void 0),[f,y]=k.useState("12"),[_,b]=k.useState("00"),[N,w]=k.useState("PM"),{data:S=[],isLoading:C}=gt({queryKey:["scheduled-posts"],queryFn:async()=>{const{data:oe,error:me}=await G.from("scheduled_posts").select(` *, social_accounts ( page_name, platform_username, profile_picture_url ) `).order("scheduled_for",{ascending:!1});if(me)throw me;return oe}}),A=S.filter(oe=>{if(n!=="all"&&oe.status!==n)return!1;if(s&&oe.scheduled_for){const me=new Date(oe.scheduled_for);if(!il(me,s))return!1}return!0}),I=S.filter(oe=>oe.scheduled_for).map(oe=>Em(new Date(oe.scheduled_for))),L=Pt({mutationFn:async oe=>{const{error:me}=await G.from("scheduled_posts").update({caption:oe.caption,scheduled_for:oe.scheduled_for}).eq("id",oe.id);if(me)throw me},onSuccess:()=>{pe.success("Post updated!"),t.invalidateQueries({queryKey:["scheduled-posts"]}),l(null)},onError:oe=>{pe.error(`Failed to update: ${oe.message}`)}}),O=Pt({mutationFn:async oe=>{const{error:me}=await G.from("scheduled_posts").update({status:"cancelled"}).eq("id",oe);if(me)throw me},onSuccess:()=>{pe.success("Post cancelled"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:oe=>{pe.error(`Failed to cancel: ${oe.message}`)}}),V=Pt({mutationFn:async oe=>{const{error:me}=await G.from("scheduled_posts").delete().eq("id",oe);if(me)throw me},onSuccess:()=>{pe.success("Post deleted"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:oe=>{pe.error(`Failed to delete: ${oe.message}`)}}),q=Pt({mutationFn:async oe=>{const{data:me,error:ve}=await G.functions.invoke("social-post",{body:{platform:oe.platform,accountId:oe.social_account_id,imageUrl:oe.image_url,caption:oe.caption}});if(ve)throw ve;if(me!=null&&me.error)throw new Error(me.error);return await G.from("scheduled_posts").update({status:"posted",posted_at:new Date().toISOString(),post_id:me.postId}).eq("id",oe.id),me},onSuccess:oe=>{const me=oe.platform==="facebook"?"Facebook":oe.platform==="instagram"?"Instagram":"LinkedIn";pe.success(`Posted to ${me}!`),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:oe=>{pe.error(`Failed to post: ${oe.message}`)}}),B=oe=>{if(l(oe),d(oe.caption||""),oe.scheduled_for){const me=new Date(oe.scheduled_for);p(me);const ve=me.getHours();y(String(ve>12?ve-12:ve===0?12:ve)),b(String(me.getMinutes()).padStart(2,"0")),w(ve>=12?"PM":"AM")}},U=()=>{if(!o||!u)return;let oe=parseInt(f);const me=parseInt(_);N==="PM"&&oe!==12&&(oe+=12),N==="AM"&&oe===12&&(oe=0);const ve=JL(QL(u,oe),me);L.mutate({id:o.id,caption:i,scheduled_for:ve.toISOString()})},te=oe=>{switch(oe){case"facebook":return e.jsx(hu,{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(gp,{className:"h-4 w-4 text-blue-700"});default:return null}},Y=oe=>{switch(oe){case"scheduled":return e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[e.jsx(nn,{className:"h-3 w-3"}),"Scheduled"]});case"posted":return e.jsxs(Qe,{variant:"default",className:"gap-1 bg-green-600",children:[e.jsx(si,{className:"h-3 w-3"}),"Posted"]});case"failed":return e.jsxs(Qe,{variant:"destructive",className:"gap-1",children:[e.jsx(Jl,{className:"h-3 w-3"}),"Failed"]});case"cancelled":return e.jsxs(Qe,{variant:"outline",className:"gap-1 text-muted-foreground",children:[e.jsx(ro,{className:"h-3 w-3"}),"Cancelled"]});default:return e.jsx(Qe,{variant:"outline",children:oe})}},J=Array.from({length:12},(oe,me)=>String(me+1)),X=["00","15","30","45"],ce=S.filter(oe=>oe.status==="scheduled").length,ie=S.filter(oe=>oe.status==="posted").length,ae=S.filter(oe=>oe.status==="scheduled"&&oe.scheduled_for&&ESt(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:ae}),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:ie}),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:S.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(_d,{className:"h-5 w-5"}),e.jsx("h3",{className:"font-semibold",children:"Calendar"})]}),e.jsx(uf,{mode:"single",selected:s,onSelect:r,className:Ot("pointer-events-auto"),modifiers:{hasPost:I},modifiersStyles:{hasPost:{fontWeight:"bold",backgroundColor:"hsl(var(--primary) / 0.1)",borderRadius:"50%"}}}),s&&e.jsx(W,{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(Eg,{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(W,{variant:n===oe?"default":"outline",size:"sm",onClick:()=>a(oe),className:"capitalize",children:oe},oe))})]}),C&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(us,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),!C&&A.length===0&&e.jsxs(Pe,{className:"p-8 text-center",children:[e.jsx(cn,{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 ${vs(s,"PPP")}`:"Schedule a post from Social Swag to get started!"})]}),e.jsx("div",{className:"space-y-4",children:A.map(oe=>{var me,ve;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(Oe,{className:"flex-1 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[te(oe.platform),e.jsx("span",{className:"font-medium",children:((me=oe.social_accounts)==null?void 0:me.page_name)||((ve=oe.social_accounts)==null?void 0:ve.platform_username)||"Unknown"}),Y(oe.status)]}),e.jsxs("div",{className:"flex items-center gap-1",children:[oe.status==="scheduled"&&e.jsxs(S1,{children:[e.jsxs(ec,{children:[e.jsx(tc,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>B(oe),children:e.jsx(ga,{className:"h-4 w-4"})})}),e.jsx(Dl,{children:"Edit post"})]}),e.jsxs(ec,{children:[e.jsx(tc,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>q.mutate(oe),disabled:q.isPending,children:q.isPending?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(_n,{className:"h-4 w-4"})})}),e.jsx(Dl,{children:"Post now"})]}),e.jsxs(Rl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(vr,{className:"h-4 w-4"})})}),e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Cancel this scheduled post?"}),e.jsx(bl,{children:"This will cancel the post. You can delete it entirely or keep it in your history."})]}),e.jsxs(vl,{children:[e.jsx(wl,{children:"Keep"}),e.jsx(ll,{onClick:()=>O.mutate(oe.id),className:"bg-amber-600 hover:bg-amber-700",children:"Cancel Post"}),e.jsx(ll,{onClick:()=>V.mutate(oe.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]}),(oe.status==="posted"||oe.status==="cancelled"||oe.status==="failed")&&e.jsxs(Rl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(vr,{className:"h-4 w-4"})})}),e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Delete this post?"}),e.jsx(bl,{children:"This will permanently remove this post from your history."})]}),e.jsxs(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:()=>V.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(nn,{className:"h-3 w-3"}),oe.status==="posted"&&oe.posted_at?`Posted ${vs(new Date(oe.posted_at),"PPp")}`:oe.scheduled_for?`Scheduled for ${vs(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(ks,{children:[e.jsx(_s,{children:"Edit Scheduled Post"}),e.jsx(Ir,{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(xe,{children:"Caption"}),e.jsx(_r,{value:i,onChange:oe=>d(oe.target.value),rows:3})]}),e.jsxs("div",{className:"space-y-3 p-4 border rounded-lg",children:[e.jsx(xe,{children:"Schedule for"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(mo,{children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{variant:"outline",className:Ot("justify-start text-left font-normal flex-1",!u&&"text-muted-foreground"),children:[e.jsx(cn,{className:"mr-2 h-4 w-4"}),u?vs(u,"PPP"):"Pick a date"]})}),e.jsx(no,{className:"w-auto p-0",align:"start",children:e.jsx(uf,{mode:"single",selected:u,onSelect:p,disabled:oe=>oee.jsx(vt,{value:oe,children:oe},oe))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs($s,{value:_,onValueChange:b,children:[e.jsx(zs,{className:"w-[70px]",children:e.jsx(Vs,{})}),e.jsx(Bs,{children:X.map(oe=>e.jsx(vt,{value:oe,children:oe},oe))})]}),e.jsxs($s,{value:N,onValueChange:oe=>w(oe),children:[e.jsx(zs,{className:"w-[70px]",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"AM",children:"AM"}),e.jsx(vt,{value:"PM",children:"PM"})]})]})]})]})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>l(null),children:"Cancel"}),e.jsxs(W,{onClick:U,disabled:L.isPending,children:[L.isPending?e.jsx(us,{className:"h-4 w-4 animate-spin mr-2"}):null,"Save Changes"]})]})]})})]})}function Xz(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 ttt={exports:{}};/*! JSZip v3.10.1 - A JavaScript class for generating and reading zip files (c) 2009-2016 Stuart Knightley Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. JSZip uses the library pako released under the MIT license : https://github.com/nodeca/pako/blob/main/LICENSE */(function(t,s){(function(r){t.exports=r()})(function(){return function r(n,a,o){function l(u,p){if(!a[u]){if(!n[u]){var f=typeof Xz=="function"&&Xz;if(!p&&f)return f(u,!0);if(i)return i(u,!0);var y=new Error("Cannot find module '"+u+"'");throw y.code="MODULE_NOT_FOUND",y}var _=a[u]={exports:{}};n[u][0].call(_.exports,function(b){var N=n[u][1][b];return l(N||b)},_,_.exports,r,n,a,o)}return a[u].exports}for(var i=typeof Xz=="function"&&Xz,d=0;d>2,_=(3&u)<<4|p>>4,b=1>6:64,N=2>4,p=(15&y)<<4|(_=i.indexOf(d.charAt(N++)))>>2,f=(3&_)<<6|(b=i.indexOf(d.charAt(N++))),C[w++]=u,_!==64&&(C[w++]=p),b!==64&&(C[w++]=f);return C}},{"./support":30,"./utils":32}],2:[function(r,n,a){var o=r("./external"),l=r("./stream/DataWorker"),i=r("./stream/Crc32Probe"),d=r("./stream/DataLengthProbe");function u(p,f,y,_,b){this.compressedSize=p,this.uncompressedSize=f,this.crc32=y,this.compression=_,this.compressedContent=b}u.prototype={getContentWorker:function(){var p=new l(o.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new d("data_length")),f=this;return p.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),p},getCompressedWorker:function(){return new l(o.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(p,f,y){return p.pipe(new i).pipe(new d("uncompressedSize")).pipe(f.compressWorker(y)).pipe(new d("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,d=[],u=0;u<256;u++){i=u;for(var p=0;p<8;p++)i=1&i?3988292384^i>>>1:i>>>1;d[u]=i}return d}();n.exports=function(i,d){return i!==void 0&&i.length?o.getTypeOf(i)!=="string"?function(u,p,f,y){var _=l,b=y+f;u^=-1;for(var N=y;N>>8^_[255&(u^p[N])];return-1^u}(0|d,i,i.length,0):function(u,p,f,y){var _=l,b=y+f;u^=-1;for(var N=y;N>>8^_[255&(u^p.charCodeAt(N))];return-1^u}(0|d,i,i.length,0):0}},{"./utils":32}],5:[function(r,n,a){a.base64=!1,a.binary=!1,a.dir=!1,a.createFolders=!0,a.date=null,a.compression=null,a.compressionOptions=null,a.comment=null,a.unixPermissions=null,a.dosPermissions=null},{}],6:[function(r,n,a){var o=null;o=typeof Promise<"u"?Promise:r("lie"),n.exports={Promise:o}},{lie:37}],7:[function(r,n,a){var o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",l=r("pako"),i=r("./utils"),d=r("./stream/GenericWorker"),u=o?"uint8array":"array";function p(f,y){d.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=y,this.meta={}}a.magic="\b\0",i.inherits(p,d),p.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(i.transformTo(u,f.data),!1)},p.prototype.flush=function(){d.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},p.prototype.cleanUp=function(){d.prototype.cleanUp.call(this),this._pako=null},p.prototype._createPako=function(){this._pako=new l[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(y){f.push({data:y,meta:f.meta})}},a.compressWorker=function(f){return new p("Deflate",f)},a.uncompressWorker=function(){return new p("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(r,n,a){function o(_,b){var N,w="";for(N=0;N>>=8;return w}function l(_,b,N,w,S,C){var A,I,L=_.file,O=_.compression,V=C!==u.utf8encode,q=i.transformTo("string",C(L.name)),B=i.transformTo("string",u.utf8encode(L.name)),U=L.comment,te=i.transformTo("string",C(U)),Y=i.transformTo("string",u.utf8encode(U)),J=B.length!==L.name.length,X=Y.length!==U.length,ce="",ie="",ae="",oe=L.dir,me=L.date,ve={crc32:0,compressedSize:0,uncompressedSize:0};b&&!N||(ve.crc32=_.crc32,ve.compressedSize=_.compressedSize,ve.uncompressedSize=_.uncompressedSize);var he=0;b&&(he|=8),V||!J&&!X||(he|=2048);var ge=0,je=0;oe&&(ge|=16),S==="UNIX"?(je=798,ge|=function(Me,ke){var Re=Me;return Me||(Re=ke?16893:33204),(65535&Re)<<16}(L.unixPermissions,oe)):(je=20,ge|=function(Me){return 63&(Me||0)}(L.dosPermissions)),A=me.getUTCHours(),A<<=6,A|=me.getUTCMinutes(),A<<=5,A|=me.getUTCSeconds()/2,I=me.getUTCFullYear()-1980,I<<=4,I|=me.getUTCMonth()+1,I<<=5,I|=me.getUTCDate(),J&&(ie=o(1,1)+o(p(q),4)+B,ce+="up"+o(ie.length,2)+ie),X&&(ae=o(1,1)+o(p(te),4)+Y,ce+="uc"+o(ae.length,2)+ae);var qe="";return qe+=` \0`,qe+=o(he,2),qe+=O.magic,qe+=o(A,2),qe+=o(I,2),qe+=o(ve.crc32,4),qe+=o(ve.compressedSize,4),qe+=o(ve.uncompressedSize,4),qe+=o(q.length,2),qe+=o(ce.length,2),{fileRecord:f.LOCAL_FILE_HEADER+qe+q+ce,dirRecord:f.CENTRAL_FILE_HEADER+o(je,2)+qe+o(te.length,2)+"\0\0\0\0"+o(ge,4)+o(w,4)+q+ce+te}}var i=r("../utils"),d=r("../stream/GenericWorker"),u=r("../utf8"),p=r("../crc32"),f=r("../signature");function y(_,b,N,w){d.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,this.zipPlatform=N,this.encodeFileName=w,this.streamFiles=_,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}i.inherits(y,d),y.prototype.push=function(_){var b=_.meta.percent||0,N=this.entriesCount,w=this._sources.length;this.accumulate?this.contentBuffer.push(_):(this.bytesWritten+=_.data.length,d.prototype.push.call(this,{data:_.data,meta:{currentFile:this.currentFile,percent:N?(b+100*(N-w-1))/N:100}}))},y.prototype.openedSource=function(_){this.currentSourceOffset=this.bytesWritten,this.currentFile=_.file.name;var b=this.streamFiles&&!_.file.dir;if(b){var N=l(_,b,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:N.fileRecord,meta:{percent:0}})}else this.accumulate=!0},y.prototype.closedSource=function(_){this.accumulate=!1;var b=this.streamFiles&&!_.file.dir,N=l(_,b,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(N.dirRecord),b)this.push({data:function(w){return f.DATA_DESCRIPTOR+o(w.crc32,4)+o(w.compressedSize,4)+o(w.uncompressedSize,4)}(_),meta:{percent:100}});else for(this.push({data:N.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},y.prototype.flush=function(){for(var _=this.bytesWritten,b=0;b=this.index;d--)u=(u<<8)+this.byteAt(d);return this.index+=i,u},readString:function(i){return o.transformTo("string",this.readData(i))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var i=this.readInt(4);return new Date(Date.UTC(1980+(i>>25&127),(i>>21&15)-1,i>>16&31,i>>11&31,i>>5&63,(31&i)<<1))}},n.exports=l},{"../utils":32}],19:[function(r,n,a){var o=r("./Uint8ArrayReader");function l(i){o.call(this,i)}r("../utils").inherits(l,o),l.prototype.readData=function(i){this.checkOffset(i);var d=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,d},n.exports=l},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(r,n,a){var o=r("./DataReader");function l(i){o.call(this,i)}r("../utils").inherits(l,o),l.prototype.byteAt=function(i){return this.data.charCodeAt(this.zero+i)},l.prototype.lastIndexOfSignature=function(i){return this.data.lastIndexOf(i)-this.zero},l.prototype.readAndCheckSignature=function(i){return i===this.readData(4)},l.prototype.readData=function(i){this.checkOffset(i);var d=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,d},n.exports=l},{"../utils":32,"./DataReader":18}],21:[function(r,n,a){var o=r("./ArrayReader");function l(i){o.call(this,i)}r("../utils").inherits(l,o),l.prototype.readData=function(i){if(this.checkOffset(i),i===0)return new Uint8Array(0);var d=this.data.subarray(this.zero+this.index,this.zero+this.index+i);return this.index+=i,d},n.exports=l},{"../utils":32,"./ArrayReader":17}],22:[function(r,n,a){var o=r("../utils"),l=r("../support"),i=r("./ArrayReader"),d=r("./StringReader"),u=r("./NodeBufferReader"),p=r("./Uint8ArrayReader");n.exports=function(f){var y=o.getTypeOf(f);return o.checkSupport(y),y!=="string"||l.uint8array?y==="nodebuffer"?new u(f):l.uint8array?new p(o.transformTo("uint8array",f)):new i(o.transformTo("array",f)):new d(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(d){o.call(this,"ConvertWorker to "+d),this.destType=d}l.inherits(i,o),i.prototype.processChunk=function(d){this.push({data:l.transformTo(this.destType,d.data),meta:d.meta})},n.exports=i},{"../utils":32,"./GenericWorker":28}],25:[function(r,n,a){var o=r("./GenericWorker"),l=r("../crc32");function i(){o.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}r("../utils").inherits(i,o),i.prototype.processChunk=function(d){this.streamInfo.crc32=l(d.data,this.streamInfo.crc32||0),this.push(d)},n.exports=i},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(r,n,a){var o=r("../utils"),l=r("./GenericWorker");function i(d){l.call(this,"DataLengthProbe for "+d),this.propName=d,this.withStreamInfo(d,0)}o.inherits(i,l),i.prototype.processChunk=function(d){if(d){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+d.data.length}l.prototype.processChunk.call(this,d)},n.exports=i},{"../utils":32,"./GenericWorker":28}],27:[function(r,n,a){var o=r("../utils"),l=r("./GenericWorker");function i(d){l.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,d.then(function(p){u.dataIsReady=!0,u.data=p,u.max=p&&p.length||0,u.type=o.getTypeOf(p),u.isPaused||u._tickAndRepeat()},function(p){u.error(p)})}o.inherits(i,l),i.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this.data=null},i.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,o.delay(this._tickAndRepeat,[],this)),!0)},i.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(o.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},i.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var d=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":d=this.data.substring(this.index,u);break;case"uint8array":d=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":d=this.data.slice(this.index,u)}return this.index=u,this.push({data:d,meta:{percent:this.max?this.index/this.max*100:0}})},n.exports=i},{"../utils":32,"./GenericWorker":28}],28:[function(r,n,a){function o(l){this.name=l||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}o.prototype={push:function(l){this.emit("data",l)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(l){this.emit("error",l)}return!0},error:function(l){return!this.isFinished&&(this.isPaused?this.generatedError=l:(this.isFinished=!0,this.emit("error",l),this.previous&&this.previous.error(l),this.cleanUp()),!0)},on:function(l,i){return this._listeners[l].push(i),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(l,i){if(this._listeners[l])for(var d=0;d "+l:l}},n.exports=o},{}],29:[function(r,n,a){var o=r("../utils"),l=r("./ConvertWorker"),i=r("./GenericWorker"),d=r("../base64"),u=r("../support"),p=r("../external"),f=null;if(u.nodestream)try{f=r("../nodejs/NodejsStreamOutputAdapter")}catch{}function y(b,N){return new p.Promise(function(w,S){var C=[],A=b._internalType,I=b._outputType,L=b._mimeType;b.on("data",function(O,V){C.push(O),N&&N(V)}).on("error",function(O){C=[],S(O)}).on("end",function(){try{var O=function(V,q,B){switch(V){case"blob":return o.newBlob(o.transformTo("arraybuffer",q),B);case"base64":return d.encode(q);default:return o.transformTo(V,q)}}(I,function(V,q){var B,U=0,te=null,Y=0;for(B=0;B"u")a.blob=!1;else{var o=new ArrayBuffer(0);try{a.blob=new Blob([o],{type:"application/zip"}).size===0}catch{try{var l=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);l.append(o),a.blob=l.getBlob("application/zip").size===0}catch{a.blob=!1}}}try{a.nodestream=!!r("readable-stream").Readable}catch{a.nodestream=!1}},{"readable-stream":16}],31:[function(r,n,a){for(var o=r("./utils"),l=r("./support"),i=r("./nodejsUtils"),d=r("./stream/GenericWorker"),u=new Array(256),p=0;p<256;p++)u[p]=252<=p?6:248<=p?5:240<=p?4:224<=p?3:192<=p?2:1;u[254]=u[254]=1;function f(){d.call(this,"utf-8 decode"),this.leftOver=null}function y(){d.call(this,"utf-8 encode")}a.utf8encode=function(_){return l.nodebuffer?i.newBufferFrom(_,"utf-8"):function(b){var N,w,S,C,A,I=b.length,L=0;for(C=0;C>>6:(w<65536?N[A++]=224|w>>>12:(N[A++]=240|w>>>18,N[A++]=128|w>>>12&63),N[A++]=128|w>>>6&63),N[A++]=128|63&w);return N}(_)},a.utf8decode=function(_){return l.nodebuffer?o.transformTo("nodebuffer",_).toString("utf-8"):function(b){var N,w,S,C,A=b.length,I=new Array(2*A);for(N=w=0;N>10&1023,I[w++]=56320|1023&S)}return I.length!==w&&(I.subarray?I=I.subarray(0,w):I.length=w),o.applyFromCharCode(I)}(_=o.transformTo(l.uint8array?"uint8array":"array",_))},o.inherits(f,d),f.prototype.processChunk=function(_){var b=o.transformTo(l.uint8array?"uint8array":"array",_.data);if(this.leftOver&&this.leftOver.length){if(l.uint8array){var N=b;(b=new Uint8Array(N.length+this.leftOver.length)).set(this.leftOver,0),b.set(N,this.leftOver.length)}else b=this.leftOver.concat(b);this.leftOver=null}var w=function(C,A){var I;for((A=A||C.length)>C.length&&(A=C.length),I=A-1;0<=I&&(192&C[I])==128;)I--;return I<0||I===0?A:I+u[C[I]]>A?I:A}(b),S=b;w!==b.length&&(l.uint8array?(S=b.subarray(0,w),this.leftOver=b.subarray(w,b.length)):(S=b.slice(0,w),this.leftOver=b.slice(w,b.length))),this.push({data:a.utf8decode(S),meta:_.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(y,d),y.prototype.processChunk=function(_){this.push({data:a.utf8encode(_.data),meta:_.meta})},a.Utf8EncodeWorker=y},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(r,n,a){var o=r("./support"),l=r("./base64"),i=r("./nodejsUtils"),d=r("./external");function u(N){return N}function p(N,w){for(var S=0;S>8;this.dir=!!(16&this.externalFileAttributes),_==0&&(this.dosPermissions=63&this.externalFileAttributes),_==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var _=o(this.extraFields[1].value);this.uncompressedSize===l.MAX_VALUE_32BITS&&(this.uncompressedSize=_.readInt(8)),this.compressedSize===l.MAX_VALUE_32BITS&&(this.compressedSize=_.readInt(8)),this.localHeaderOffset===l.MAX_VALUE_32BITS&&(this.localHeaderOffset=_.readInt(8)),this.diskNumberStart===l.MAX_VALUE_32BITS&&(this.diskNumberStart=_.readInt(4))}},readExtraFields:function(_){var b,N,w,S=_.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});_.index+4>>6:(_<65536?y[w++]=224|_>>>12:(y[w++]=240|_>>>18,y[w++]=128|_>>>12&63),y[w++]=128|_>>>6&63),y[w++]=128|63&_);return y},a.buf2binstring=function(f){return p(f,f.length)},a.binstring2buf=function(f){for(var y=new o.Buf8(f.length),_=0,b=y.length;_>10&1023,C[b++]=56320|1023&N)}return p(C,b)},a.utf8border=function(f,y){var _;for((y=y||f.length)>f.length&&(y=f.length),_=y-1;0<=_&&(192&f[_])==128;)_--;return _<0||_===0?y:_+d[f[_]]>y?_:y}},{"./common":41}],43:[function(r,n,a){n.exports=function(o,l,i,d){for(var u=65535&o|0,p=o>>>16&65535|0,f=0;i!==0;){for(i-=f=2e3>>1:l>>>1;i[d]=l}return i}();n.exports=function(l,i,d,u){var p=o,f=u+d;l^=-1;for(var y=u;y>>8^p[255&(l^i[y])];return-1^l}},{}],46:[function(r,n,a){var o,l=r("../utils/common"),i=r("./trees"),d=r("./adler32"),u=r("./crc32"),p=r("./messages"),f=0,y=4,_=0,b=-2,N=-1,w=4,S=2,C=8,A=9,I=286,L=30,O=19,V=2*I+1,q=15,B=3,U=258,te=U+B+1,Y=42,J=113,X=1,ce=2,ie=3,ae=4;function oe(fe,$e){return fe.msg=p[$e],$e}function me(fe){return(fe<<1)-(4fe.avail_out&&(Ye=fe.avail_out),Ye!==0&&(l.arraySet(fe.output,$e.pending_buf,$e.pending_out,Ye,fe.next_out),fe.next_out+=Ye,$e.pending_out+=Ye,fe.total_out+=Ye,fe.avail_out-=Ye,$e.pending-=Ye,$e.pending===0&&($e.pending_out=0))}function ge(fe,$e){i._tr_flush_block(fe,0<=fe.block_start?fe.block_start:-1,fe.strstart-fe.block_start,$e),fe.block_start=fe.strstart,he(fe.strm)}function je(fe,$e){fe.pending_buf[fe.pending++]=$e}function qe(fe,$e){fe.pending_buf[fe.pending++]=$e>>>8&255,fe.pending_buf[fe.pending++]=255&$e}function Me(fe,$e){var Ye,tt,Te=fe.max_chain_length,We=fe.strstart,Ke=fe.prev_length,ot=fe.nice_match,He=fe.strstart>fe.w_size-te?fe.strstart-(fe.w_size-te):0,Je=fe.window,ut=fe.w_mask,mt=fe.prev,et=fe.strstart+U,Ze=Je[We+Ke-1],kt=Je[We+Ke];fe.prev_length>=fe.good_match&&(Te>>=2),ot>fe.lookahead&&(ot=fe.lookahead);do if(Je[(Ye=$e)+Ke]===kt&&Je[Ye+Ke-1]===Ze&&Je[Ye]===Je[We]&&Je[++Ye]===Je[We+1]){We+=2,Ye++;do;while(Je[++We]===Je[++Ye]&&Je[++We]===Je[++Ye]&&Je[++We]===Je[++Ye]&&Je[++We]===Je[++Ye]&&Je[++We]===Je[++Ye]&&Je[++We]===Je[++Ye]&&Je[++We]===Je[++Ye]&&Je[++We]===Je[++Ye]&&WeHe&&--Te!=0);return Ke<=fe.lookahead?Ke:fe.lookahead}function ke(fe){var $e,Ye,tt,Te,We,Ke,ot,He,Je,ut,mt=fe.w_size;do{if(Te=fe.window_size-fe.lookahead-fe.strstart,fe.strstart>=mt+(mt-te)){for(l.arraySet(fe.window,fe.window,mt,mt,0),fe.match_start-=mt,fe.strstart-=mt,fe.block_start-=mt,$e=Ye=fe.hash_size;tt=fe.head[--$e],fe.head[$e]=mt<=tt?tt-mt:0,--Ye;);for($e=Ye=mt;tt=fe.prev[--$e],fe.prev[$e]=mt<=tt?tt-mt:0,--Ye;);Te+=mt}if(fe.strm.avail_in===0)break;if(Ke=fe.strm,ot=fe.window,He=fe.strstart+fe.lookahead,Je=Te,ut=void 0,ut=Ke.avail_in,Je=B)for(We=fe.strstart-fe.insert,fe.ins_h=fe.window[We],fe.ins_h=(fe.ins_h<=B&&(fe.ins_h=(fe.ins_h<=B)if(tt=i._tr_tally(fe,fe.strstart-fe.match_start,fe.match_length-B),fe.lookahead-=fe.match_length,fe.match_length<=fe.max_lazy_match&&fe.lookahead>=B){for(fe.match_length--;fe.strstart++,fe.ins_h=(fe.ins_h<=B&&(fe.ins_h=(fe.ins_h<=B&&fe.match_length<=fe.prev_length){for(Te=fe.strstart+fe.lookahead-B,tt=i._tr_tally(fe,fe.strstart-1-fe.prev_match,fe.prev_length-B),fe.lookahead-=fe.prev_length-1,fe.prev_length-=2;++fe.strstart<=Te&&(fe.ins_h=(fe.ins_h<fe.pending_buf_size-5&&(Ye=fe.pending_buf_size-5);;){if(fe.lookahead<=1){if(ke(fe),fe.lookahead===0&&$e===f)return X;if(fe.lookahead===0)break}fe.strstart+=fe.lookahead,fe.lookahead=0;var tt=fe.block_start+Ye;if((fe.strstart===0||fe.strstart>=tt)&&(fe.lookahead=fe.strstart-tt,fe.strstart=tt,ge(fe,!1),fe.strm.avail_out===0)||fe.strstart-fe.block_start>=fe.w_size-te&&(ge(fe,!1),fe.strm.avail_out===0))return X}return fe.insert=0,$e===y?(ge(fe,!0),fe.strm.avail_out===0?ie:ae):(fe.strstart>fe.block_start&&(ge(fe,!1),fe.strm.avail_out),X)}),new Ne(4,4,8,4,Re),new Ne(4,5,16,8,Re),new Ne(4,6,32,32,Re),new Ne(4,4,16,16,Ve),new Ne(8,16,32,32,Ve),new Ne(8,16,128,128,Ve),new Ne(8,32,128,256,Ve),new Ne(32,128,258,1024,Ve),new Ne(32,258,258,4096,Ve)],a.deflateInit=function(fe,$e){return ct(fe,$e,C,15,8,0)},a.deflateInit2=ct,a.deflateReset=ye,a.deflateResetKeep=Ie,a.deflateSetHeader=function(fe,$e){return fe&&fe.state?fe.state.wrap!==2?b:(fe.state.gzhead=$e,_):b},a.deflate=function(fe,$e){var Ye,tt,Te,We;if(!fe||!fe.state||5<$e||$e<0)return fe?oe(fe,b):b;if(tt=fe.state,!fe.output||!fe.input&&fe.avail_in!==0||tt.status===666&&$e!==y)return oe(fe,fe.avail_out===0?-5:b);if(tt.strm=fe,Ye=tt.last_flush,tt.last_flush=$e,tt.status===Y)if(tt.wrap===2)fe.adler=0,je(tt,31),je(tt,139),je(tt,8),tt.gzhead?(je(tt,(tt.gzhead.text?1:0)+(tt.gzhead.hcrc?2:0)+(tt.gzhead.extra?4:0)+(tt.gzhead.name?8:0)+(tt.gzhead.comment?16:0)),je(tt,255&tt.gzhead.time),je(tt,tt.gzhead.time>>8&255),je(tt,tt.gzhead.time>>16&255),je(tt,tt.gzhead.time>>24&255),je(tt,tt.level===9?2:2<=tt.strategy||tt.level<2?4:0),je(tt,255&tt.gzhead.os),tt.gzhead.extra&&tt.gzhead.extra.length&&(je(tt,255&tt.gzhead.extra.length),je(tt,tt.gzhead.extra.length>>8&255)),tt.gzhead.hcrc&&(fe.adler=u(fe.adler,tt.pending_buf,tt.pending,0)),tt.gzindex=0,tt.status=69):(je(tt,0),je(tt,0),je(tt,0),je(tt,0),je(tt,0),je(tt,tt.level===9?2:2<=tt.strategy||tt.level<2?4:0),je(tt,3),tt.status=J);else{var Ke=C+(tt.w_bits-8<<4)<<8;Ke|=(2<=tt.strategy||tt.level<2?0:tt.level<6?1:tt.level===6?2:3)<<6,tt.strstart!==0&&(Ke|=32),Ke+=31-Ke%31,tt.status=J,qe(tt,Ke),tt.strstart!==0&&(qe(tt,fe.adler>>>16),qe(tt,65535&fe.adler)),fe.adler=1}if(tt.status===69)if(tt.gzhead.extra){for(Te=tt.pending;tt.gzindex<(65535&tt.gzhead.extra.length)&&(tt.pending!==tt.pending_buf_size||(tt.gzhead.hcrc&&tt.pending>Te&&(fe.adler=u(fe.adler,tt.pending_buf,tt.pending-Te,Te)),he(fe),Te=tt.pending,tt.pending!==tt.pending_buf_size));)je(tt,255&tt.gzhead.extra[tt.gzindex]),tt.gzindex++;tt.gzhead.hcrc&&tt.pending>Te&&(fe.adler=u(fe.adler,tt.pending_buf,tt.pending-Te,Te)),tt.gzindex===tt.gzhead.extra.length&&(tt.gzindex=0,tt.status=73)}else tt.status=73;if(tt.status===73)if(tt.gzhead.name){Te=tt.pending;do{if(tt.pending===tt.pending_buf_size&&(tt.gzhead.hcrc&&tt.pending>Te&&(fe.adler=u(fe.adler,tt.pending_buf,tt.pending-Te,Te)),he(fe),Te=tt.pending,tt.pending===tt.pending_buf_size)){We=1;break}We=tt.gzindexTe&&(fe.adler=u(fe.adler,tt.pending_buf,tt.pending-Te,Te)),We===0&&(tt.gzindex=0,tt.status=91)}else tt.status=91;if(tt.status===91)if(tt.gzhead.comment){Te=tt.pending;do{if(tt.pending===tt.pending_buf_size&&(tt.gzhead.hcrc&&tt.pending>Te&&(fe.adler=u(fe.adler,tt.pending_buf,tt.pending-Te,Te)),he(fe),Te=tt.pending,tt.pending===tt.pending_buf_size)){We=1;break}We=tt.gzindexTe&&(fe.adler=u(fe.adler,tt.pending_buf,tt.pending-Te,Te)),We===0&&(tt.status=103)}else tt.status=103;if(tt.status===103&&(tt.gzhead.hcrc?(tt.pending+2>tt.pending_buf_size&&he(fe),tt.pending+2<=tt.pending_buf_size&&(je(tt,255&fe.adler),je(tt,fe.adler>>8&255),fe.adler=0,tt.status=J)):tt.status=J),tt.pending!==0){if(he(fe),fe.avail_out===0)return tt.last_flush=-1,_}else if(fe.avail_in===0&&me($e)<=me(Ye)&&$e!==y)return oe(fe,-5);if(tt.status===666&&fe.avail_in!==0)return oe(fe,-5);if(fe.avail_in!==0||tt.lookahead!==0||$e!==f&&tt.status!==666){var ot=tt.strategy===2?function(He,Je){for(var ut;;){if(He.lookahead===0&&(ke(He),He.lookahead===0)){if(Je===f)return X;break}if(He.match_length=0,ut=i._tr_tally(He,0,He.window[He.strstart]),He.lookahead--,He.strstart++,ut&&(ge(He,!1),He.strm.avail_out===0))return X}return He.insert=0,Je===y?(ge(He,!0),He.strm.avail_out===0?ie:ae):He.last_lit&&(ge(He,!1),He.strm.avail_out===0)?X:ce}(tt,$e):tt.strategy===3?function(He,Je){for(var ut,mt,et,Ze,kt=He.window;;){if(He.lookahead<=U){if(ke(He),He.lookahead<=U&&Je===f)return X;if(He.lookahead===0)break}if(He.match_length=0,He.lookahead>=B&&0He.lookahead&&(He.match_length=He.lookahead)}if(He.match_length>=B?(ut=i._tr_tally(He,1,He.match_length-B),He.lookahead-=He.match_length,He.strstart+=He.match_length,He.match_length=0):(ut=i._tr_tally(He,0,He.window[He.strstart]),He.lookahead--,He.strstart++),ut&&(ge(He,!1),He.strm.avail_out===0))return X}return He.insert=0,Je===y?(ge(He,!0),He.strm.avail_out===0?ie:ae):He.last_lit&&(ge(He,!1),He.strm.avail_out===0)?X:ce}(tt,$e):o[tt.level].func(tt,$e);if(ot!==ie&&ot!==ae||(tt.status=666),ot===X||ot===ie)return fe.avail_out===0&&(tt.last_flush=-1),_;if(ot===ce&&($e===1?i._tr_align(tt):$e!==5&&(i._tr_stored_block(tt,0,0,!1),$e===3&&(ve(tt.head),tt.lookahead===0&&(tt.strstart=0,tt.block_start=0,tt.insert=0))),he(fe),fe.avail_out===0))return tt.last_flush=-1,_}return $e!==y?_:tt.wrap<=0?1:(tt.wrap===2?(je(tt,255&fe.adler),je(tt,fe.adler>>8&255),je(tt,fe.adler>>16&255),je(tt,fe.adler>>24&255),je(tt,255&fe.total_in),je(tt,fe.total_in>>8&255),je(tt,fe.total_in>>16&255),je(tt,fe.total_in>>24&255)):(qe(tt,fe.adler>>>16),qe(tt,65535&fe.adler)),he(fe),0=Ye.w_size&&(We===0&&(ve(Ye.head),Ye.strstart=0,Ye.block_start=0,Ye.insert=0),Je=new l.Buf8(Ye.w_size),l.arraySet(Je,$e,ut-Ye.w_size,Ye.w_size,0),$e=Je,ut=Ye.w_size),Ke=fe.avail_in,ot=fe.next_in,He=fe.input,fe.avail_in=ut,fe.next_in=0,fe.input=$e,ke(Ye);Ye.lookahead>=B;){for(tt=Ye.strstart,Te=Ye.lookahead-(B-1);Ye.ins_h=(Ye.ins_h<>>=B=q>>>24,A-=B,(B=q>>>16&255)===0)ce[p++]=65535&q;else{if(!(16&B)){if(!(64&B)){q=I[(65535&q)+(C&(1<>>=B,A-=B),A<15&&(C+=X[d++]<>>=B=q>>>24,A-=B,!(16&(B=q>>>16&255))){if(!(64&B)){q=L[(65535&q)+(C&(1<>>=B,A-=B,(B=p-f)>3,C&=(1<<(A-=U<<3))-1,o.next_in=d,o.next_out=p,o.avail_in=d>>24&255)+(Y>>>8&65280)+((65280&Y)<<8)+((255&Y)<<24)}function C(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new o.Buf16(320),this.work=new o.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function A(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=b,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(N),J.distcode=J.distdyn=new o.Buf32(w),J.sane=1,J.back=-1,y):_}function I(Y){var J;return Y&&Y.state?((J=Y.state).wsize=0,J.whave=0,J.wnext=0,A(Y)):_}function L(Y,J){var X,ce;return Y&&Y.state?(ce=Y.state,J<0?(X=0,J=-J):(X=1+(J>>4),J<48&&(J&=15)),J&&(J<8||15=ae.wsize?(o.arraySet(ae.window,J,X-ae.wsize,ae.wsize,0),ae.wnext=0,ae.whave=ae.wsize):(ce<(ie=ae.wsize-ae.wnext)&&(ie=ce),o.arraySet(ae.window,J,X-ce,ie,ae.wnext),(ce-=ie)?(o.arraySet(ae.window,J,X-ce,ce,0),ae.wnext=ce,ae.whave=ae.wsize):(ae.wnext+=ie,ae.wnext===ae.wsize&&(ae.wnext=0),ae.whave>>8&255,X.check=i(X.check,We,2,0),ge=he=0,X.mode=2;break}if(X.flags=0,X.head&&(X.head.done=!1),!(1&X.wrap)||(((255&he)<<8)+(he>>8))%31){Y.msg="incorrect header check",X.mode=30;break}if((15&he)!=8){Y.msg="unknown compression method",X.mode=30;break}if(ge-=4,fe=8+(15&(he>>>=4)),X.wbits===0)X.wbits=fe;else if(fe>X.wbits){Y.msg="invalid window size",X.mode=30;break}X.dmax=1<>8&1),512&X.flags&&(We[0]=255&he,We[1]=he>>>8&255,X.check=i(X.check,We,2,0)),ge=he=0,X.mode=3;case 3:for(;ge<32;){if(me===0)break e;me--,he+=ce[ae++]<>>8&255,We[2]=he>>>16&255,We[3]=he>>>24&255,X.check=i(X.check,We,4,0)),ge=he=0,X.mode=4;case 4:for(;ge<16;){if(me===0)break e;me--,he+=ce[ae++]<>8),512&X.flags&&(We[0]=255&he,We[1]=he>>>8&255,X.check=i(X.check,We,2,0)),ge=he=0,X.mode=5;case 5:if(1024&X.flags){for(;ge<16;){if(me===0)break e;me--,he+=ce[ae++]<>>8&255,X.check=i(X.check,We,2,0)),ge=he=0}else X.head&&(X.head.extra=null);X.mode=6;case 6:if(1024&X.flags&&(me<(Me=X.length)&&(Me=me),Me&&(X.head&&(fe=X.head.extra_len-X.length,X.head.extra||(X.head.extra=new Array(X.head.extra_len)),o.arraySet(X.head.extra,ce,ae,Me,fe)),512&X.flags&&(X.check=i(X.check,ce,Me,ae)),me-=Me,ae+=Me,X.length-=Me),X.length))break e;X.length=0,X.mode=7;case 7:if(2048&X.flags){if(me===0)break e;for(Me=0;fe=ce[ae+Me++],X.head&&fe&&X.length<65536&&(X.head.name+=String.fromCharCode(fe)),fe&&Me>9&1,X.head.done=!0),Y.adler=X.check=0,X.mode=12;break;case 10:for(;ge<32;){if(me===0)break e;me--,he+=ce[ae++]<>>=7&ge,ge-=7&ge,X.mode=27;break}for(;ge<3;){if(me===0)break e;me--,he+=ce[ae++]<>>=1)){case 0:X.mode=14;break;case 1:if(U(X),X.mode=20,J!==6)break;he>>>=2,ge-=2;break e;case 2:X.mode=17;break;case 3:Y.msg="invalid block type",X.mode=30}he>>>=2,ge-=2;break;case 14:for(he>>>=7&ge,ge-=7≥ge<32;){if(me===0)break e;me--,he+=ce[ae++]<>>16^65535)){Y.msg="invalid stored block lengths",X.mode=30;break}if(X.length=65535&he,ge=he=0,X.mode=15,J===6)break e;case 15:X.mode=16;case 16:if(Me=X.length){if(me>>=5,ge-=5,X.ndist=1+(31&he),he>>>=5,ge-=5,X.ncode=4+(15&he),he>>>=4,ge-=4,286>>=3,ge-=3}for(;X.have<19;)X.lens[Ke[X.have++]]=0;if(X.lencode=X.lendyn,X.lenbits=7,Ye={bits:X.lenbits},$e=u(0,X.lens,0,19,X.lencode,0,X.work,Ye),X.lenbits=Ye.bits,$e){Y.msg="invalid code lengths set",X.mode=30;break}X.have=0,X.mode=19;case 19:for(;X.have>>16&255,Ue=65535&Te,!((Ve=Te>>>24)<=ge);){if(me===0)break e;me--,he+=ce[ae++]<>>=Ve,ge-=Ve,X.lens[X.have++]=Ue;else{if(Ue===16){for(tt=Ve+2;ge>>=Ve,ge-=Ve,X.have===0){Y.msg="invalid bit length repeat",X.mode=30;break}fe=X.lens[X.have-1],Me=3+(3&he),he>>>=2,ge-=2}else if(Ue===17){for(tt=Ve+3;ge>>=Ve)),he>>>=3,ge-=3}else{for(tt=Ve+7;ge>>=Ve)),he>>>=7,ge-=7}if(X.have+Me>X.nlen+X.ndist){Y.msg="invalid bit length repeat",X.mode=30;break}for(;Me--;)X.lens[X.have++]=fe}}if(X.mode===30)break;if(X.lens[256]===0){Y.msg="invalid code -- missing end-of-block",X.mode=30;break}if(X.lenbits=9,Ye={bits:X.lenbits},$e=u(p,X.lens,0,X.nlen,X.lencode,0,X.work,Ye),X.lenbits=Ye.bits,$e){Y.msg="invalid literal/lengths set",X.mode=30;break}if(X.distbits=6,X.distcode=X.distdyn,Ye={bits:X.distbits},$e=u(f,X.lens,X.nlen,X.ndist,X.distcode,0,X.work,Ye),X.distbits=Ye.bits,$e){Y.msg="invalid distances set",X.mode=30;break}if(X.mode=20,J===6)break e;case 20:X.mode=21;case 21:if(6<=me&&258<=ve){Y.next_out=oe,Y.avail_out=ve,Y.next_in=ae,Y.avail_in=me,X.hold=he,X.bits=ge,d(Y,qe),oe=Y.next_out,ie=Y.output,ve=Y.avail_out,ae=Y.next_in,ce=Y.input,me=Y.avail_in,he=X.hold,ge=X.bits,X.mode===12&&(X.back=-1);break}for(X.back=0;Ne=(Te=X.lencode[he&(1<>>16&255,Ue=65535&Te,!((Ve=Te>>>24)<=ge);){if(me===0)break e;me--,he+=ce[ae++]<>Ie)])>>>16&255,Ue=65535&Te,!(Ie+(Ve=Te>>>24)<=ge);){if(me===0)break e;me--,he+=ce[ae++]<>>=Ie,ge-=Ie,X.back+=Ie}if(he>>>=Ve,ge-=Ve,X.back+=Ve,X.length=Ue,Ne===0){X.mode=26;break}if(32&Ne){X.back=-1,X.mode=12;break}if(64&Ne){Y.msg="invalid literal/length code",X.mode=30;break}X.extra=15&Ne,X.mode=22;case 22:if(X.extra){for(tt=X.extra;ge>>=X.extra,ge-=X.extra,X.back+=X.extra}X.was=X.length,X.mode=23;case 23:for(;Ne=(Te=X.distcode[he&(1<>>16&255,Ue=65535&Te,!((Ve=Te>>>24)<=ge);){if(me===0)break e;me--,he+=ce[ae++]<>Ie)])>>>16&255,Ue=65535&Te,!(Ie+(Ve=Te>>>24)<=ge);){if(me===0)break e;me--,he+=ce[ae++]<>>=Ie,ge-=Ie,X.back+=Ie}if(he>>>=Ve,ge-=Ve,X.back+=Ve,64&Ne){Y.msg="invalid distance code",X.mode=30;break}X.offset=Ue,X.extra=15&Ne,X.mode=24;case 24:if(X.extra){for(tt=X.extra;ge>>=X.extra,ge-=X.extra,X.back+=X.extra}if(X.offset>X.dmax){Y.msg="invalid distance too far back",X.mode=30;break}X.mode=25;case 25:if(ve===0)break e;if(Me=qe-ve,X.offset>Me){if((Me=X.offset-Me)>X.whave&&X.sane){Y.msg="invalid distance too far back",X.mode=30;break}ke=Me>X.wnext?(Me-=X.wnext,X.wsize-Me):X.wnext-Me,Me>X.length&&(Me=X.length),Re=X.window}else Re=ie,ke=oe-X.offset,Me=X.length;for(veV?(B=ke[Re+w[J]],ge[je+w[J]]):(B=96,0),C=1<>oe)+(A-=C)]=q<<24|B<<16|U|0,A!==0;);for(C=1<>=1;if(C!==0?(he&=C-1,he+=C):he=0,J++,--qe[Y]==0){if(Y===ce)break;Y=f[y+w[J]]}if(ie>>7)]}function je(Te,We){Te.pending_buf[Te.pending++]=255&We,Te.pending_buf[Te.pending++]=We>>>8&255}function qe(Te,We,Ke){Te.bi_valid>S-Ke?(Te.bi_buf|=We<>S-Te.bi_valid,Te.bi_valid+=Ke-S):(Te.bi_buf|=We<>>=1,Ke<<=1,0<--We;);return Ke>>>1}function Re(Te,We,Ke){var ot,He,Je=new Array(w+1),ut=0;for(ot=1;ot<=w;ot++)Je[ot]=ut=ut+Ke[ot-1]<<1;for(He=0;He<=We;He++){var mt=Te[2*He+1];mt!==0&&(Te[2*He]=ke(Je[mt]++,mt))}}function Ve(Te){var We;for(We=0;We>1;1<=Ke;Ke--)Ie(Te,Je,Ke);for(He=et;Ke=Te.heap[1],Te.heap[1]=Te.heap[Te.heap_len--],Ie(Te,Je,1),ot=Te.heap[1],Te.heap[--Te.heap_max]=Ke,Te.heap[--Te.heap_max]=ot,Je[2*He]=Je[2*Ke]+Je[2*ot],Te.depth[He]=(Te.depth[Ke]>=Te.depth[ot]?Te.depth[Ke]:Te.depth[ot])+1,Je[2*Ke+1]=Je[2*ot+1]=He,Te.heap[1]=He++,Ie(Te,Je,1),2<=Te.heap_len;);Te.heap[--Te.heap_max]=Te.heap[1],function(kt,Ut){var Nt,es,ds,js,lr,Lt,Es=Ut.dyn_tree,fr=Ut.max_code,Hs=Ut.stat_desc.static_tree,mr=Ut.stat_desc.has_stree,an=Ut.stat_desc.extra_bits,Cr=Ut.stat_desc.extra_base,Fr=Ut.stat_desc.max_length,$r=0;for(js=0;js<=w;js++)kt.bl_count[js]=0;for(Es[2*kt.heap[kt.heap_max]+1]=0,Nt=kt.heap_max+1;Nt>=7;He<_;He++)for(me[He]=Je<<7,We=0;We<1<>>=1)if(1&Ze&&mt.dyn_ltree[2*et]!==0)return l;if(mt.dyn_ltree[18]!==0||mt.dyn_ltree[20]!==0||mt.dyn_ltree[26]!==0)return i;for(et=32;et>>3,(Je=Te.static_len+3+7>>>3)<=He&&(He=Je)):He=Je=Ke+5,Ke+4<=He&&We!==-1?tt(Te,We,Ke,ot):Te.strategy===4||Je===He?(qe(Te,2+(ot?1:0),3),ye(Te,te,Y)):(qe(Te,4+(ot?1:0),3),function(mt,et,Ze,kt){var Ut;for(qe(mt,et-257,5),qe(mt,Ze-1,5),qe(mt,kt-4,4),Ut=0;Ut>>8&255,Te.pending_buf[Te.d_buf+2*Te.last_lit+1]=255&We,Te.pending_buf[Te.l_buf+Te.last_lit]=255&Ke,Te.last_lit++,We===0?Te.dyn_ltree[2*Ke]++:(Te.matches++,We--,Te.dyn_ltree[2*(X[Ke]+f+1)]++,Te.dyn_dtree[2*ge(We)]++),Te.last_lit===Te.lit_bufsize-1},a._tr_align=function(Te){qe(Te,2,3),Me(Te,A,te),function(We){We.bi_valid===16?(je(We,We.bi_buf),We.bi_buf=0,We.bi_valid=0):8<=We.bi_valid&&(We.pending_buf[We.pending++]=255&We.bi_buf,We.bi_buf>>=8,We.bi_valid-=8)}(Te)}},{"../utils/common":41}],53:[function(r,n,a){n.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(r,n,a){(function(o){(function(l,i){if(!l.setImmediate){var d,u,p,f,y=1,_={},b=!1,N=l.document,w=Object.getPrototypeOf&&Object.getPrototypeOf(l);w=w&&w.setTimeout?w:l,d={}.toString.call(l.process)==="[object process]"?function(I){process.nextTick(function(){C(I)})}:function(){if(l.postMessage&&!l.importScripts){var I=!0,L=l.onmessage;return l.onmessage=function(){I=!1},l.postMessage("","*"),l.onmessage=L,I}}()?(f="setImmediate$"+Math.random()+"$",l.addEventListener?l.addEventListener("message",A,!1):l.attachEvent("onmessage",A),function(I){l.postMessage(f+I,"*")}):l.MessageChannel?((p=new MessageChannel).port1.onmessage=function(I){C(I.data)},function(I){p.port2.postMessage(I)}):N&&"onreadystatechange"in N.createElement("script")?(u=N.documentElement,function(I){var L=N.createElement("script");L.onreadystatechange=function(){C(I),L.onreadystatechange=null,u.removeChild(L),L=null},u.appendChild(L)}):function(I){setTimeout(C,0,I)},w.setImmediate=function(I){typeof I!="function"&&(I=new Function(""+I));for(var L=new Array(arguments.length-1),O=0;O"u"?o===void 0?this:o:self)}).call(this,typeof gd<"u"?gd:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(ttt);var RUt=ttt.exports;const OUt=ao(RUt);function Nye(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 FUt=()=>{const{isAdmin:t}=Us(),[s,r]=k.useState(null),[n,a]=k.useState(null),[o,l]=k.useState("all"),[i,d]=k.useState(new Set),[u,p]=k.useState(!1),[f,y]=k.useState(!1),[_,b]=k.useState("images"),[N,w]=k.useState(null),{data:S=[],isLoading:C}=gt({queryKey:["social-swag-2"],queryFn:async()=>{const{data:me,error:ve}=await G.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(ve)throw ve;return me}}),{data:A=[]}=gt({queryKey:["social-swag-2-months"],queryFn:async()=>{const{data:me,error:ve}=await G.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(ve)throw ve;return me}}),{data:I=[]}=gt({queryKey:["social-swag-2-reels"],queryFn:async()=>{const{data:me,error:ve}=await G.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(ve)throw ve;return me}}),{data:L=[]}=gt({queryKey:["my-social-accounts-count"],queryFn:async()=>{const{data:me,error:ve}=await G.from("social_accounts").select("id, platform").eq("is_active",!0);if(ve)throw ve;return me||[]}}),O=L.length>0,V=k.useMemo(()=>o==="all"?null:I.find(me=>me.month===o)||null,[o,I]),q=k.useMemo(()=>[...new Set(S.map(ve=>ve.month))].sort((ve,he)=>he.localeCompare(ve)),[S]);k.useEffect(()=>{q.length>0&&o==="all"&&l(q[0])},[q,o]);const B=me=>{try{const ve=sNe(me,"yyyy-MM",new Date);return vs(ve,"MMMM yyyy")}catch{return me}},U=k.useMemo(()=>o==="all"?S:S.filter(me=>me.month===o),[o,S]),te=k.useMemo(()=>{var me;return o==="all"?null:((me=A.find(ve=>ve.month===o))==null?void 0:me.canva_link)||null},[o,A]),Y=async me=>{try{await navigator.clipboard.writeText(me),pe.success("Caption copied to clipboard!")}catch{pe.error("Failed to copy caption")}},J=async(me,ve)=>{try{const ge=await(await fetch(me)).blob(),je=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),qe=navigator.canShare&&navigator.canShare({files:[new File([ge],"test.jpg",{type:"image/jpeg"})]});if(je&&qe){const Me=new File([ge],`social-swag-${ve}.jpg`,{type:"image/jpeg"});await navigator.share({files:[Me],title:"Social Swag Image"}),pe.success("Image ready to save!")}else{const Me=window.URL.createObjectURL(ge),ke=document.createElement("a");ke.href=Me,ke.download=`social-swag-${ve}.jpg`,document.body.appendChild(ke),ke.click(),document.body.removeChild(ke),window.URL.revokeObjectURL(Me),pe.success("Image downloaded!")}}catch(he){he.name!=="AbortError"&&pe.error("Failed to download image")}},X=me=>{d(ve=>{const he=new Set(ve);return he.has(me)?he.delete(me):he.add(me),he})},ce=()=>{d(new Set(U.map(me=>me.id)))},ie=()=>{d(new Set),p(!1)},ae=async()=>{const me=U.filter(ve=>i.has(ve.id));if(me.length===0){pe.error("No images selected");return}y(!0),pe.info(`Preparing ${me.length} images for download...`);try{const ve=new OUt,he=[...me].sort((ke,Re)=>ke.sort_order-Re.sort_order);for(let ke=0;ke{u?X(me.id):r(me)};return e.jsx(Ds,{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(Qe,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(Or,{className:"h-3 w-3 mr-1"}),"New content monthly"]}),e.jsxs(Qe,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(qo,{className:"h-3 w-3 mr-1"}),S.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(ta,{defaultValue:"gallery",className:"space-y-6",children:[e.jsxs(Jn,{className:"grid w-full max-w-md grid-cols-2",children:[e.jsxs(cs,{value:"gallery",className:"gap-2",children:[e.jsx(qo,{className:"h-4 w-4"}),"Gallery"]}),e.jsxs(cs,{value:"scheduled",className:"gap-2",children:[e.jsx(_d,{className:"h-4 w-4"}),"Scheduled"]})]}),e.jsxs(Ss,{value:"gallery",className:"space-y-6",children:[t?O?e.jsx(Pe,{className:"border rounded-xl",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-muted text-2xl",children:"📸"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-foreground mb-1",children:"Ready to post!"}),e.jsx("p",{className:"text-muted-foreground",children:'Click any image and use "Create Post" to share directly to your connected accounts.'})]}),e.jsx(W,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsx(da,{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(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(hu,{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(W,{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(da,{to:"/social-connections",children:[e.jsx(Do,{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(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-full bg-muted",children:e.jsx(nn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(hu,{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(Qe,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Soon you'll be able to connect your Facebook & Instagram accounts to post images with one click!"})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:q.map(me=>e.jsx("button",{onClick:()=>l(me),className:Ot("px-4 py-2 rounded-full text-sm font-medium transition-all",o===me?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:B(me)},me))}),o!=="all"&&(te?e.jsxs("a",{href:te,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",B(o)," Images in Canva"]}):e.jsxs("span",{className:"inline-flex items-center gap-2 text-sm text-muted-foreground/50",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",B(o)," Images in Canva"]}))]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1 p-1 bg-muted rounded-full",children:[e.jsxs("button",{onClick:()=>{b("images"),ie()},className:Ot("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",_==="images"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(qo,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{b("reels"),ie()},className:Ot("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",_==="reels"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(Rd,{className:"h-4 w-4"}),"Reels"]})]}),_==="images"&&e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:u?e.jsxs(e.Fragment,{children:[e.jsxs(W,{variant:"outline",size:"sm",onClick:ce,className:"gap-2",children:["Select All (",U.length,")"]}),e.jsxs(W,{variant:"outline",size:"sm",onClick:ie,className:"gap-2",children:[e.jsx(kr,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(W,{size:"sm",onClick:ae,disabled:f,className:"gap-2",children:[e.jsx(Qa,{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(W,{variant:"outline",size:"sm",onClick:()=>p(!0),className:"gap-2",children:[e.jsx(Zn,{className:"h-4 w-4"}),"Select Images"]})})]}),C&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!C&&_==="images"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:U.map(me=>{const ve=i.has(me.id);return e.jsx(Pe,{className:Ot("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",u&&ve&&"ring-2 ring-primary ring-offset-2"),onClick:()=>oe(me),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:Nye(me.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"}),me.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:vs(new Date(me.post_date+"T00:00:00"),"MMM d")})}),u&&e.jsx("div",{className:Ot("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",ve?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:ve&&e.jsx(Zn,{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"})})]})},me.id)})}),U.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(qo,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No images available for this month yet."})]})]}),!C&&_==="reels"&&e.jsx(e.Fragment,{children:V?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(V),children:e.jsxs("div",{className:"relative aspect-[9/16] overflow-hidden",children:[e.jsx("img",{src:Nye(V.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(Qe,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(Rd,{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(Rd,{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:Nye(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(cn,{className:"h-4 w-4"}),vs(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(cn,{className:"h-3.5 w-3.5"}),"Post on ",vs(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(W,{onClick:()=>{w({imageUrl:s.image_url,imageId:s.id,caption:s.caption})},className:"w-full gap-2 bg-gradient-to-r from-pink-500 via-purple-500 to-blue-500 hover:from-pink-600 hover:via-purple-600 hover:to-blue-600 text-white",children:[e.jsx(_n,{className:"h-4 w-4"}),"Create Post"]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(W,{variant:"outline",onClick:()=>Y(s.caption),className:"flex-1 gap-2",children:[e.jsx(Va,{className:"h-4 w-4"}),"Copy Caption"]}),e.jsxs(W,{variant:"outline",onClick:()=>J(s.image_url,s.id),className:"flex-1 gap-2",children:[e.jsx(Qa,{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(Rd,{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(W,{onClick:()=>Y(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(Va,{className:"h-4 w-4"}),"Copy Caption"]}),n.canva_link&&e.jsxs(W,{variant:"outline",onClick:()=>window.open(n.canva_link,"_blank"),className:"flex-1 gap-2",children:[e.jsx(Yr,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})}),e.jsx(LUt,{open:!!N,onOpenChange:me=>!me&&w(null),imageUrl:(N==null?void 0:N.imageUrl)||"",imageId:(N==null?void 0:N.imageId)||"",defaultCaption:(N==null?void 0:N.caption)||"",swagItemId:N==null?void 0:N.imageId})]}),e.jsx(Ss,{value:"scheduled",children:e.jsx(DUt,{})})]}):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(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-full bg-muted",children:e.jsx(nn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(hu,{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(Qe,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Soon you'll be able to connect your Facebook & Instagram accounts to post images with one click!"})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:q.map(me=>e.jsx("button",{onClick:()=>l(me),className:Ot("px-4 py-2 rounded-full text-sm font-medium transition-all",o===me?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:B(me)},me))}),o!=="all"&&(te?e.jsxs("a",{href:te,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",B(o)," Images in Canva"]}):e.jsxs("span",{className:"inline-flex items-center gap-2 text-sm text-muted-foreground/50",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",B(o)," Images in Canva"]}))]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1 p-1 bg-muted rounded-full",children:[e.jsxs("button",{onClick:()=>{b("images"),ie()},className:Ot("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",_==="images"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(qo,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{b("reels"),ie()},className:Ot("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",_==="reels"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(Rd,{className:"h-4 w-4"}),"Reels"]})]}),_==="images"&&e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:u?e.jsxs(e.Fragment,{children:[e.jsxs(W,{variant:"outline",size:"sm",onClick:ce,className:"gap-2",children:["Select All (",U.length,")"]}),e.jsxs(W,{variant:"outline",size:"sm",onClick:ie,className:"gap-2",children:[e.jsx(kr,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&e.jsxs(W,{size:"sm",onClick:ae,disabled:f,className:"gap-2",children:[e.jsx(Qa,{className:"h-4 w-4"}),f?"Downloading...":`Download ${i.size} Selected`]})]}):e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>p(!0),className:"gap-2",children:[e.jsx(Zn,{className:"h-4 w-4"}),"Select Images"]})})]}),C&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!C&&_==="images"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:U.map(me=>{const ve=i.has(me.id);return e.jsx(Pe,{className:Ot("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",u&&ve&&"ring-2 ring-primary ring-offset-2"),onClick:()=>oe(me),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:me.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:Ot("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",ve?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:ve&&e.jsx(Zn,{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"})})]})},me.id)})}),U.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(qo,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No images available for this month yet."})]})]}),!C&&_==="reels"&&e.jsx(e.Fragment,{children:V?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(V),children:e.jsxs("div",{className:"relative aspect-[9/16] overflow-hidden",children:[e.jsx("img",{src:V.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(Qe,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(Rd,{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(Rd,{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(cn,{className:"h-4 w-4"}),vs(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(W,{variant:"outline",onClick:()=>Y(s.caption),className:"flex-1 gap-2",children:[e.jsx(Va,{className:"h-4 w-4"}),"Copy Caption"]}),e.jsxs(W,{variant:"outline",onClick:()=>J(s.image_url,s.id),className:"flex-1 gap-2",children:[e.jsx(Qa,{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(Rd,{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(W,{onClick:()=>Y(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(Va,{className:"h-4 w-4"}),"Copy Caption"]}),n.canva_link&&e.jsxs(W,{variant:"outline",onClick:()=>window.open(n.canva_link,"_blank"),className:"flex-1 gap-2",children:[e.jsx(Yr,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})})]})]})})},zUt=()=>{const{swagId:t}=io(),{user:s}=Us(),{toast:r}=ja(),n=Qt(),{trackEngagement:a}=QA(),[o,l]=k.useState(""),{data:i,isLoading:d}=gt({queryKey:["social-swag-detail",t],queryFn:async()=>{const{data:S,error:C}=await G.from("social_swag").select("*").eq("id",t).single();if(C)throw C;const{data:A}=await G.from("social_swag_links").select("*").eq("swag_id",t).order("sort_order");return{...S,links:A||[]}},enabled:!!t});k.useEffect(()=>{i&&a("social_swag",i.id,i.title,"view")},[i==null?void 0:i.id]);const{data:u=[]}=gt({queryKey:["social-swag-likes",t],queryFn:async()=>{const{data:S,error:C}=await G.from("social_swag_likes").select("*").eq("swag_id",t);if(C)throw C;return S},enabled:!!t}),{data:p=[]}=gt({queryKey:["social-swag-comments",t],queryFn:async()=>{const{data:S,error:C}=await G.from("social_swag_comments").select("*").eq("swag_id",t).order("created_at",{ascending:!1});if(C)throw C;const A=[...new Set(S.map(O=>O.user_id))],{data:I}=await G.from("profiles").select("id, name").in("id",A),L=new Map((I==null?void 0:I.map(O=>[O.id,O.name]))||[]);return S.map(O=>({...O,user_name:L.get(O.user_id)||"Unknown User"}))},enabled:!!t}),f=Pt({mutationFn:async S=>{const{error:C}=await G.from("social_swag_comments").insert({swag_id:t,user_id:s.id,content:S});if(C)throw C},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),l(""),r({title:"Comment added!"})},onError:S=>{r({title:"Error adding comment",description:S.message,variant:"destructive"})}}),y=Pt({mutationFn:async S=>{const{error:C}=await G.from("social_swag_comments").delete().eq("id",S);if(C)throw C},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),r({title:"Comment deleted"})}}),_=Pt({mutationFn:async()=>{const S=u.find(C=>C.user_id===(s==null?void 0:s.id));if(S){const{error:C}=await G.from("social_swag_likes").delete().eq("id",S.id);if(C)throw C}else{const{error:C}=await G.from("social_swag_likes").insert({swag_id:t,user_id:s.id});if(C)throw C}},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-likes",t]})}}),b=u.some(S=>S.user_id===(s==null?void 0:s.id)),N=S=>S.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),w=S=>{S.preventDefault(),!(!o.trim()||!s)&&f.mutate(o.trim())};return d?e.jsx(Ds,{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(Ds,{title:i.title,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(W,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(da,{to:"/social-swag",children:[e.jsx(Oa,{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(sE,{resourceType:"social_swag",resourceId:i.id,resourceTitle:i.title}),e.jsxs(W,{variant:b?"default":"outline",className:"gap-2 w-fit",onClick:()=>_.mutate(),disabled:!s||_.isPending,children:[e.jsx(Bu,{className:`h-4 w-4 ${b?"fill-current":""}`}),u.length," ",u.length===1?"Like":"Likes"]})]})]}),i.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:i.description}})]}),i.links.length>0&&e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(vo,{className:"h-4 w-4"}),i.links.length===1?"Canva Link":"Canva Links"]}),e.jsx("div",{className:"grid gap-2",children:i.links.map(S=>e.jsxs(W,{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(S.canva_share_link,"_blank")},children:[e.jsx("span",{className:"font-medium",children:S.title}),e.jsx(Yr,{className:"h-4 w-4 text-muted-foreground"})]},S.id))})]})}),e.jsx(ho,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(Fl,{className:"h-5 w-5"}),"Comments (",p.length,")"]}),s?e.jsxs("form",{onSubmit:w,className:"flex gap-2",children:[e.jsx(_r,{placeholder:"Add a comment...",value:o,onChange:S=>l(S.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(W,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!o.trim()||f.isPending,children:e.jsx(_n,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),e.jsx("div",{className:"space-y-4",children:p.length===0?e.jsx(Pe,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):p.map(S=>e.jsx(Pe,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Nn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(kn,{className:"text-sm",children:N(S.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:S.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Nl(new Date(S.created_at),{addSuffix:!0})}),S.user_id===(s==null?void 0:s.id)&&e.jsx(W,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>y.mutate(S.id),children:e.jsx(vr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:S.content})]})]})})},S.id))})]})]})}):e.jsx(Ds,{title:"Social Swag",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(vo,{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(W,{asChild:!0,className:"mt-4",children:e.jsx(da,{to:"/social-swag",children:"Back to Social Swag"})})]})})},BUt=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=k.useState(!0),[i,d]=k.useState(!0),[u,p]=k.useState(!0),f=y=>y.split(" ").map(_=>_[0]).join("").toUpperCase().slice(0,2);return e.jsx("aside",{className:"w-64 shrink-0 hidden lg:block relative z-0",children:e.jsx("div",{className:"sticky top-4 space-y-4 max-h-[calc(100vh-8rem)] overflow-y-auto overscroll-contain",children:e.jsxs("div",{className:"space-y-2 pr-4",children:[e.jsxs(W,{variant:r==="all"?"secondary":"ghost",className:"w-full justify-start",onClick:()=>n("all"),children:[e.jsx(tS,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsxs(lf,{open:o,onOpenChange:l,children:[e.jsx(cf,{asChild:!0,children:e.jsxs(W,{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(Bi,{className:"h-4 w-4"}):e.jsx(xa,{className:"h-4 w-4"})]})}),e.jsx(df,{className:"space-y-1 pl-2",children:t.map(y=>e.jsxs(W,{variant:r===y.id?"secondary":"ghost",size:"sm",className:"w-full justify-start h-9",onClick:()=>n(y.id),children:[e.jsx("span",{className:"mr-2",children:y.icon||"📂"}),e.jsx("span",{className:"truncate",children:y.name})]},y.id))})]}),s.length>0&&e.jsxs(lf,{open:i,onOpenChange:d,children:[e.jsx(cf,{asChild:!0,children:e.jsxs(W,{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(ad,{className:"h-3 w-3"}),"Your Groups"]}),i?e.jsx(Bi,{className:"h-4 w-4"}):e.jsx(xa,{className:"h-4 w-4"})]})}),e.jsx(df,{className:"space-y-1 pl-2",children:s.map(y=>e.jsxs(W,{variant:r===`group:${y.id}`?"secondary":"ghost",size:"sm",className:"w-full justify-start h-9",onClick:()=>n(`group:${y.id}`),children:[e.jsx("span",{className:"mr-2",children:y.icon||"🔒"}),e.jsx("span",{className:"truncate",children:y.name})]},y.id))})]}),e.jsxs(lf,{open:u,onOpenChange:p,children:[e.jsx(cf,{asChild:!0,children:e.jsxs(W,{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(ir,{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(Bi,{className:"h-4 w-4"}):e.jsx(xa,{className:"h-4 w-4"})]})}),e.jsx(df,{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(y=>e.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-2 rounded-md hover:bg-muted transition-colors",children:[e.jsxs("div",{className:"relative",children:[e.jsxs(Nn,{className:"h-7 w-7",children:[e.jsx(Ma,{src:y.avatarUrl}),e.jsx(kn,{className:"text-xs",children:f(y.name)})]}),e.jsx(sd,{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:y.name})]},y.id))})]})]})})})},$Ut=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=k.useState(!1),i=u=>u.split(" ").map(p=>p[0]).join("").toUpperCase().slice(0,2),d=()=>{if(r==="all")return"All Posts";if(r.startsWith("group:")){const p=r.replace("group:",""),f=s.find(y=>y.id===p);return f?`🔒 ${f.name}`:"Private Group"}const u=t.find(p=>p.id===r);return u?`${u.icon||"📂"} ${u.name}`:"Category"};return e.jsxs("div",{className:"lg:hidden flex items-center gap-2 mb-4",children:[e.jsxs(Hd,{children:[e.jsx(Gd,{asChild:!0,children:e.jsxs(W,{variant:"outline",className:"flex-1 justify-between",children:[e.jsx("span",{className:"truncate",children:d()}),e.jsx(Bi,{className:"h-4 w-4 ml-2 shrink-0"})]})}),e.jsxs(Nd,{className:"w-56 bg-background border",children:[e.jsxs(_a,{onClick:()=>n("all"),children:[e.jsx(tS,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsx(Yb,{}),e.jsx(f1e,{className:"text-xs text-muted-foreground",children:"Categories"}),t.map(u=>e.jsxs(_a,{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(Yb,{}),e.jsxs(f1e,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(ad,{className:"h-3 w-3"}),"Your Groups"]}),s.map(u=>e.jsxs(_a,{onClick:()=>n(`group:${u.id}`),children:[e.jsx("span",{className:"mr-2",children:u.icon||"🔒"}),u.name]},u.id))]})]})]}),e.jsxs(ZA,{open:o,onOpenChange:l,children:[e.jsx(zNe,{asChild:!0,children:e.jsxs(W,{variant:"outline",size:"icon",className:"relative",children:[e.jsx(ir,{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(SC,{children:[e.jsx(YA,{children:e.jsxs(XA,{className:"flex items-center gap-2",children:[e.jsx(ir,{className:"h-5 w-5"}),"Online Now (",a.length,")"]})}),e.jsx(Ja,{className:"h-[calc(100vh-8rem)] mt-4",children:a.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No one else online right now"}):e.jsx("div",{className:"space-y-2",children:a.map(u=>e.jsxs("div",{className:"flex items-center gap-3 py-2 px-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsxs("div",{className:"relative",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:u.avatarUrl}),e.jsx(kn,{children:i(u.name)})]}),e.jsx(sd,{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 kye,Che="HoverCard",[stt,bAs]=qc(Che,[w0]),Mhe=w0(),[qUt,u4e]=stt(Che),rtt=t=>{const{__scopeHoverCard:s,children:r,open:n,defaultOpen:a,onOpenChange:o,openDelay:l=700,closeDelay:i=300}=t,d=Mhe(s),u=k.useRef(0),p=k.useRef(0),f=k.useRef(!1),y=k.useRef(!1),[_,b]=Uu({prop:n,defaultProp:a??!1,onChange:o,caller:Che}),N=k.useCallback(()=>{clearTimeout(p.current),u.current=window.setTimeout(()=>b(!0),l)},[l,b]),w=k.useCallback(()=>{clearTimeout(u.current),!f.current&&!y.current&&(p.current=window.setTimeout(()=>b(!1),i))},[i,b]),S=k.useCallback(()=>b(!1),[b]);return k.useEffect(()=>()=>{clearTimeout(u.current),clearTimeout(p.current)},[]),e.jsx(qUt,{scope:s,open:_,onOpenChange:b,onOpen:N,onClose:w,onDismiss:S,hasSelectionRef:f,isPointerDownOnContentRef:y,children:e.jsx(SR,{...d,children:r})})};rtt.displayName=Che;var ntt="HoverCardTrigger",att=k.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=u4e(ntt,r),o=Mhe(r);return e.jsx(OA,{asChild:!0,...o,children:e.jsx(Jr.a,{"data-state":a.open?"open":"closed",...n,ref:s,onPointerEnter:Mr(t.onPointerEnter,pce(a.onOpen)),onPointerLeave:Mr(t.onPointerLeave,pce(a.onClose)),onFocus:Mr(t.onFocus,a.onOpen),onBlur:Mr(t.onBlur,a.onClose),onTouchStart:Mr(t.onTouchStart,l=>l.preventDefault())})})});att.displayName=ntt;var UUt="HoverCardPortal",[wAs,VUt]=stt(UUt,{forceMount:void 0}),mce="HoverCardContent",itt=k.forwardRef((t,s)=>{const r=VUt(mce,t.__scopeHoverCard),{forceMount:n=r.forceMount,...a}=t,o=u4e(mce,t.__scopeHoverCard);return e.jsx(jd,{present:n||o.open,children:e.jsx(HUt,{"data-state":o.open?"open":"closed",...a,onPointerEnter:Mr(t.onPointerEnter,pce(o.onOpen)),onPointerLeave:Mr(t.onPointerLeave,pce(o.onClose)),ref:s})})});itt.displayName=mce;var HUt=k.forwardRef((t,s)=>{const{__scopeHoverCard:r,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,...i}=t,d=u4e(mce,r),u=Mhe(r),p=k.useRef(null),f=Ta(s,p),[y,_]=k.useState(!1);return k.useEffect(()=>{if(y){const b=document.body;return kye=b.style.userSelect||b.style.webkitUserSelect,b.style.userSelect="none",b.style.webkitUserSelect="none",()=>{b.style.userSelect=kye,b.style.webkitUserSelect=kye}}},[y]),k.useEffect(()=>{if(p.current){const b=()=>{_(!1),d.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var w;((w=document.getSelection())==null?void 0:w.toString())!==""&&(d.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",b),()=>{document.removeEventListener("pointerup",b),d.hasSelectionRef.current=!1,d.isPointerDownOnContentRef.current=!1}}},[d.isPointerDownOnContentRef,d.hasSelectionRef]),k.useEffect(()=>{p.current&&KUt(p.current).forEach(N=>N.setAttribute("tabindex","-1"))}),e.jsx(dw,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:l,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:Mr(o,b=>{b.preventDefault()}),onDismiss:d.onDismiss,children:e.jsx(CR,{...u,...i,onPointerDown:Mr(i.onPointerDown,b=>{b.currentTarget.contains(b.target)&&_(!0),d.hasSelectionRef.current=!1,d.isPointerDownOnContentRef.current=!0}),ref:f,style:{...i.style,userSelect:y?"text":void 0,WebkitUserSelect:y?"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)"}})})}),GUt="HoverCardArrow",WUt=k.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=Mhe(r);return e.jsx(MR,{...a,...n,ref:s})});WUt.displayName=GUt;function pce(t){return s=>s.pointerType==="touch"?void 0:t()}function KUt(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 ZUt=rtt,YUt=att,ott=itt;const XUt=ZUt,QUt=YUt,ltt=k.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(ott,{ref:a,align:s,sideOffset:r,className:Ot("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}));ltt.displayName=ott.displayName;const JUt=[{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"}],eVt=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2),ctt=({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(XUt,{openDelay:200,closeDelay:100,children:[e.jsx(QUt,{asChild:!0,children:e.jsx("div",{className:"cursor-pointer",children:s})}),e.jsx(ltt,{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=JUt.find(l=>l.type===n);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-lg",children:o==null?void 0:o.emoji}),e.jsxs("span",{className:"text-sm font-medium text-foreground",children:[o==null?void 0:o.label," (",a.length,")"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[a.slice(0,10).map(l=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Nn,{className:"h-6 w-6",children:[e.jsx(Ma,{src:l.user_avatar||void 0}),e.jsx(kn,{className:"text-[10px]",children:eVt(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 tVt({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 d=()=>{o(y=>y>0?y-1:t.length-1),i(!1)},u=()=>{o(y=>y{r&&(y.key==="ArrowLeft"&&d(),y.key==="ArrowRight"&&u(),y.key==="Escape"&&n(!1))},[r,t.length]);k.useEffect(()=>(window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)),[p]);const f=t[a];return e.jsx(fs,{open:r,onOpenChange:n,children:e.jsxs(ps,{className:"max-w-[95vw] max-h-[95vh] w-auto h-auto p-0 border-none bg-black/95 overflow-hidden",children:[e.jsx(W,{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(kr,{className:"h-6 w-6"})}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(W,{variant:"ghost",size:"icon",className:"absolute left-2 top-1/2 -translate-y-1/2 z-50 text-white hover:bg-white/20 h-12 w-12",onClick:d,children:e.jsx(Xo,{className:"h-8 w-8"})}),e.jsx(W,{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(xa,{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(W,{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(zM,{className:"h-5 w-5"}):e.jsx(Eb,{className:"h-5 w-5"})}),e.jsx("div",{className:Ot("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:y=>y.stopPropagation()}):e.jsx("img",{src:f==null?void 0:f.url,alt:"",className:Ot("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((y,_)=>e.jsx("button",{onClick:()=>{o(_),i(!1)},className:Ot("w-12 h-12 rounded overflow-hidden flex-shrink-0 border-2 transition-all",a===_?"border-white":"border-transparent opacity-60 hover:opacity-100"),children:y.type==="video"?e.jsx("video",{src:y.url,className:"w-full h-full object-cover"}):e.jsx("img",{src:y.url,alt:"",className:"w-full h-full object-cover"})},_))})]})})}const Qz=[{type:"like",emoji:"👍",label:"Like"},{type:"love",emoji:"❤️",label:"Love"}],sVt=({commentId:t,reactions:s,currentUserId:r})=>{var u,p;const n=Qt(),[a,o]=k.useState(!1),l=s.find(f=>f.user_id===r),i=Pt({mutationFn:async f=>{l?l.reaction_type===f?await G.from("community_comment_reactions").delete().eq("id",l.id):await G.from("community_comment_reactions").update({reaction_type:f}).eq("id",l.id):await G.from("community_comment_reactions").insert({comment_id:t,user_id:r,reaction_type:f})},onSuccess:()=>{n.invalidateQueries({queryKey:["community-posts"]}),o(!1)}}),d={};return s.forEach(f=>{d[f.reaction_type]=(d[f.reaction_type]||0)+1}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.length>0&&e.jsx(ctt,{reactions:s,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx("div",{className:"flex -space-x-0.5",children:Object.keys(d).slice(0,2).map(f=>{var y;return e.jsx("span",{className:"text-sm",children:(y=Qz.find(_=>_.type===f))==null?void 0:y.emoji},f)})}),e.jsx("span",{children:s.length})]})}),r&&e.jsxs(mo,{open:a,onOpenChange:o,children:[e.jsx(po,{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," ",(p=Qz.find(f=>f.type===l.reaction_type))==null?void 0:p.label]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Xa,{className:"h-3 w-3"}),"Like"]})})}),e.jsx(no,{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 h4e({content:t,className:s}){const r=/([@#])\[([^\]]+)\]\(([^)]+)\)|(https?:\/\/[^\s<>]+)/g,n=[];let a=0,o,l=0;for(;(o=r.exec(t))!==null;){if(o.index>a&&n.push(t.substring(a,o.index)),o[1]){const i=o[1],d=o[2],u=o[3],p=i==="#";n.push(e.jsx(da,{to:p?`/templates/${u}`:`/profile?user=${u}`,className:Ot("font-medium hover:underline",p?"text-white bg-[#2a4c64] px-1.5 py-0.5 rounded":"text-primary"),onClick:f=>f.stopPropagation(),children:p?d:`@${d}`},`mention-${l++}`))}else if(o[4]){const i=o[4],d=i.replace(/[.,;:!?)]+$/,""),u=i.slice(d.length);let p;try{const f=new URL(d);p=f.hostname+(f.pathname!=="/"?f.pathname.slice(0,20)+(f.pathname.length>20?"...":""):"")}catch{p=d.length>40?d.slice(0,40)+"...":d}n.push(e.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline break-all",onClick:f=>f.stopPropagation(),children:p},`url-${l++}`)),u&&n.push(u)}a=o.index+o[0].length}return ae.jsx(k.Fragment,{children:i},d))})}function fce({value:t,onChange:s,placeholder:r="What's on your mind? Use @ to mention someone",className:n,minHeight:a="80px",onMentionsChange:o,onTemplatesChange:l,onKeyDown:i,mentionFormat:d="encoded",enableTemplateMentions:u=!1}){const p=k.useRef(null),f=k.useRef(null),[y,_]=k.useState(!1),[b,N]=k.useState("user"),[w,S]=k.useState(""),[C,A]=k.useState(null),[I,L]=k.useState(0),[O,V]=k.useState({top:0,left:0,width:0}),q=k.useRef(new Map),B=k.useRef(new Map),U=ge=>{if(d==="plain"){const ke=[];return q.current.forEach((Ve,Ne)=>{ge.includes(`@${Ne}`)&&ke.push(Ve)}),[...new Set(ke)]}const je=/@\[([^\]]+)\]\(([^)]+)\)/g,qe=[];let Me;for(;(Me=je.exec(ge))!==null;)qe.push(Me[2]);return[...new Set(qe)]},te=ge=>{if(d==="plain"){const ke=[];return B.current.forEach((Ve,Ne)=>{ge.includes(`#${Ne}`)&&ke.push(Ve)}),[...new Set(ke)]}const je=/#\[([^\]]+)\]\(([^)]+)\)/g,qe=[];let Me;for(;(Me=je.exec(ge))!==null;)qe.push(Me[2]);return[...new Set(qe)]};k.useEffect(()=>{if(o){const ge=U(t);o(ge)}if(l){const ge=te(t);l(ge)}},[t,o,l,d]);const{data:Y=[],isLoading:J}=gt({queryKey:["mention-users",w],queryFn:async()=>{const ge=G.from("profiles").select("id, name").limit(8),je=w.length>=1?ge.ilike("name",`%${w}%`):ge.order("name"),{data:qe,error:Me}=await je;if(Me)throw Me;const ke=qe.map(Ve=>Ve.id),Re=await JZe(ke);return qe.map(Ve=>({id:Ve.id,name:Ve.name||"Unknown",avatar_url:Re.get(Ve.id)}))},enabled:y&&b==="user",staleTime:3e4}),{data:X=[],isLoading:ce}=gt({queryKey:["mention-templates",w],queryFn:async()=>{let ge=G.from("canva_templates").select("id, name, preview_image_url").lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(8);w.length>=1&&(ge=ge.ilike("name",`%${w}%`));const{data:je,error:qe}=await ge;if(qe)throw qe;return je||[]},enabled:y&&b==="template"&&u,staleTime:3e4}),ie=b==="user"?J:ce,ae=b==="user"?Y:X,oe=ge=>ge.split(" ").map(je=>je[0]).join("").toUpperCase().slice(0,2),me=ge=>{const je=ge.target.value,qe=ge.target.selectionStart;s(je);const Me=je.substring(0,qe),ke=Me.lastIndexOf("@"),Re=u?Me.lastIndexOf("#"):-1;let Ve=-1,Ne="user";if(ke>Re?(Ve=ke,Ne="user"):Re>ke&&u&&(Ve=Re,Ne="template"),Ve!==-1){const Ue=Me.substring(Ve+1),Ie=Ue.includes(" "),ye=Ue.includes(` `);if(!Ie&&!ye&&Ue.length<=30){A(Ve),S(Ue),N(Ne),_(!0),L(0);return}}_(!1),A(null)},ve=ge=>{if(C===null)return;const je=t.substring(0,C),qe=t.substring(C+w.length+1),Me=b==="user"?"@":"#",ke=d==="plain"?`${Me}${ge.name} `:`${Me}[${ge.name}](${ge.id}) `;d==="plain"&&(b==="user"?q.current.set(ge.name,ge.id):B.current.set(ge.name,ge.id));const Re=je+ke+qe;s(Re),_(!1),A(null),S(""),setTimeout(()=>{if(p.current){const Ve=je.length+ke.length;p.current.focus(),p.current.setSelectionRange(Ve,Ve)}},0)},he=ge=>{if(!(!y||ae.length===0))switch(ge.key){case"ArrowDown":ge.preventDefault(),L(je=>(je+1)%ae.length);break;case"ArrowUp":ge.preventDefault(),L(je=>(je-1+ae.length)%ae.length);break;case"Enter":ae[I]&&(ge.preventDefault(),ve(ae[I]));break;case"Escape":ge.preventDefault(),_(!1);break;case"Tab":ae[I]&&(ge.preventDefault(),ve(ae[I]));break}};return k.useEffect(()=>{const ge=je=>{f.current&&!f.current.contains(je.target)&&p.current&&!p.current.contains(je.target)&&_(!1)};return document.addEventListener("mousedown",ge),()=>document.removeEventListener("mousedown",ge)},[]),k.useEffect(()=>{if(!y)return;const ge=()=>{const je=p.current;if(!je)return;const qe=je.getBoundingClientRect();V({top:qe.bottom+4,left:qe.left,width:qe.width})};return ge(),window.addEventListener("resize",ge),window.addEventListener("scroll",ge,!0),()=>{window.removeEventListener("resize",ge),window.removeEventListener("scroll",ge,!0)}},[y,t]),e.jsxs("div",{className:"relative flex-1",children:[e.jsx(_r,{ref:p,value:t,onChange:me,onKeyDown:ge=>{he(ge),ge.defaultPrevented||i==null||i(ge)},placeholder:r,className:Ot("resize-none",n),style:{minHeight:a}}),y&&op.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:b==="user"?"👤 Mention a person":"📋 Link a template"}),ie?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Searching..."}):ae.length===0?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:w.length<1?`Type to search ${b==="user"?"people":"templates"}...`:`No ${b==="user"?"users":"templates"} found`}):e.jsx("ul",{className:"py-1 max-h-[180px] overflow-y-auto",children:ae.map((ge,je)=>e.jsx("li",{className:Ot("flex items-center gap-2 px-3 py-2 cursor-pointer transition-colors",je===I?"bg-accent":"hover:bg-accent/50"),onClick:()=>ve(ge),onMouseEnter:()=>L(je),children:b==="user"?e.jsxs(e.Fragment,{children:[e.jsxs(Nn,{className:"h-6 w-6",children:[e.jsx(Ma,{src:ge.avatar_url}),e.jsx(kn,{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(zl,{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 rVt(t){const s=/#\[([^\]]+)\]\(([^)]+)\)/g,r=[];let n;for(;(n=s.exec(t))!==null;)r.push(n[2]);return[...new Set(r)]}const J8e=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2);function dtt({comment:t,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l=0}){const i=Qt(),[d,u]=k.useState(!1),[p,f]=k.useState(""),[y,_]=k.useState([]),b=Pt({mutationFn:async({content:C,parentCommentId:A})=>{const{data:I,error:L}=await G.from("community_comments").insert({post_id:s,user_id:r,content:C,parent_comment_id:A}).select("id").single();if(L)throw L;const O=y;if(O.length>0&&I){const V=O.filter(q=>q!==r).map(q=>({comment_id:I.id,mentioned_user_id:q,mentioned_by_user_id:r}));V.length>0&&await G.from("community_comment_mentions").insert(V)}},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),f(""),_([]),u(!1)}}),N=Pt({mutationFn:async C=>{const{error:A}=await G.from("community_comments").delete().eq("id",C);if(A)throw A},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),w=()=>{p.trim()&&b.mutate({content:p,parentCommentId:t.id})};return e.jsxs("div",{className:l>0?"ml-8 border-l-2 border-muted pl-3":"",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Nn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Ma,{src:t.user_avatar||void 0}),e.jsx(kn,{className:"text-xs",children:J8e(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(h4e,{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:Nl(new Date(t.created_at),{addSuffix:!0})}),e.jsx(sVt,{commentId:t.id,reactions:t.reactions,currentUserId:r}),r&&l<2&&e.jsxs("button",{onClick:()=>u(!d),className:"hover:text-primary flex items-center gap-1",children:[e.jsx(LL,{className:"h-3 w-3"}),"Reply"]}),(t.user_id===r||o)&&e.jsx("button",{onClick:()=>N.mutate(t.id),className:"hover:text-destructive",children:t.user_id!==r?"Remove":"Delete"})]}),d&&r&&e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsxs(Nn,{className:"h-6 w-6 shrink-0 mt-1",children:[e.jsx(Ma,{src:n||void 0}),e.jsx(kn,{className:"text-xs",children:J8e((a==null?void 0:a.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2 items-start",children:[e.jsx(fce,{placeholder:`Reply to ${t.user_name}...`,value:p,onChange:f,onMentionsChange:_,mentionFormat:"plain",className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(W,{size:"sm",variant:"ghost",onClick:w,disabled:!p.trim()||b.isPending,className:"h-8 px-2 mt-0.5",children:e.jsx(_n,{className:"h-3 w-3"})})]})]})]})]}),t.replies&&t.replies.length>0&&e.jsx("div",{className:"mt-2 space-y-2",children:t.replies.map(C=>e.jsx(dtt,{comment:C,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l+1},C.id))})]})}const Jz=[{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"}],nVt=()=>{const{user:t,isBrokerageManager:s,managedBrokerages:r,isAdmin:n}=Us(),{avatarUrl:a}=QZe(t==null?void 0:t.id),{onlineUsers:o}=eXe(),{toast:l}=ja(),i=Qt(),d=k.useRef(null),[u,p]=k.useState("all"),[f,y]=k.useState(""),[_,b]=k.useState(""),[N,w]=k.useState(""),[S,C]=k.useState([]),[A,I]=k.useState([]),[L,O]=k.useState(""),[V,q]=k.useState(!1),[B,U]=k.useState(null),[te,Y]=k.useState(""),[J,X]=k.useState(new Set),[ce,ie]=k.useState({}),[ae,oe]=k.useState({}),[me,ve]=k.useState([]),[he,ge]=k.useState([]),[je,qe]=k.useState({open:!1,images:[],index:0});k.useEffect(()=>{if(u.startsWith("group:")){const Ze=u.replace("group:","");w(Ze),b("")}else u!=="all"?(b(u),w("")):(b(""),w(""))},[u]);const{data:Me=[]}=gt({queryKey:["community-categories"],queryFn:async()=>{const{data:Ze,error:kt}=await G.from("community_categories").select("*").order("sort_order");if(kt)throw kt;return Ze}}),{data:ke=[]}=gt({queryKey:["community-private-groups"],queryFn:async()=>{const{data:Ze,error:kt}=await G.from("community_private_groups").select("id, name, description, icon, brokerage_id, sort_order").order("sort_order");if(kt)throw kt;return Ze}}),Re=20,{data:Ve,isLoading:Ne,hasNextPage:Ue,fetchNextPage:Ie,isFetchingNextPage:ye}=Bvt({queryKey:["community-posts",u],initialPageParam:0,queryFn:async({pageParam:Ze})=>{var Fe;const kt=Ze*Re,Ut=kt+Re;let Nt=G.from("community_posts").select("*").order("is_pinned",{ascending:!1}).order("pinned_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1}).range(kt,Ut);if(u.startsWith("group:")){const Xe=u.replace("group:","");Nt=Nt.eq("private_group_id",Xe)}else u==="all"||(Nt=Nt.eq("category_id",u).is("private_group_id",null));const{data:es,error:ds}=await Nt;if(ds)throw ds;const js=((es==null?void 0:es.length)||0)>Re,lr=(es||[]).slice(0,Re);if(lr.length===0)return{posts:[],hasMore:!1,nextPage:Ze+1};const Lt=lr.map(Xe=>Xe.id),Es=[...new Set(lr.filter(Xe=>Xe.category_id).map(Xe=>Xe.category_id))].filter(Boolean),[fr,Hs,mr,an,Cr]=await Promise.all([Es.length?G.from("community_categories").select("*").in("id",Es):Promise.resolve({data:[]}),G.from("community_post_media").select("*").in("post_id",Lt).order("sort_order"),G.from("community_reactions").select("*").in("post_id",Lt),G.from("community_comments").select("*").in("post_id",Lt).order("created_at",{ascending:!0}),G.from("community_post_resources").select("*").in("post_id",Lt)]),Fr=fr==null?void 0:fr.data,$r=Hs==null?void 0:Hs.data,nr=mr==null?void 0:mr.data,cr=an==null?void 0:an.data,Br=Cr==null?void 0:Cr.data,Kr=(cr||[]).map(Xe=>Xe.id),[Sn,ai]=await Promise.all([Kr.length?G.from("community_comment_reactions").select("*").in("comment_id",Kr):Promise.resolve({data:[]}),(()=>{const Xe=(Br||[]).filter(yt=>yt.resource_type==="template").map(yt=>yt.resource_id);return Xe.length===0?Promise.resolve({data:[]}):G.from("canva_templates").select("id, name, preview_image_url").in("id",Xe)})()]),as=(Sn==null?void 0:Sn.data)||[],qn=(ai==null?void 0:ai.data)||[],un=new Map(qn.map(Xe=>[Xe.id,{name:Xe.name,preview_image_url:Xe.preview_image_url}])),qr=Array.from(new Set([...lr.map(Xe=>Xe.user_id),...(nr||[]).map(Xe=>Xe.user_id),...(cr||[]).map(Xe=>Xe.user_id),...as.map(Xe=>Xe.user_id)])),[Zr,La]=await Promise.all([qr.length?G.from("profiles").select("id, name").in("id",qr):Promise.resolve({data:[]}),JZe(qr)]),Yt=new Map(((Fe=Zr==null?void 0:Zr.data)==null?void 0:Fe.map(Xe=>[Xe.id,Xe.name]))||[]),Lr=new Map((Fr||[]).map(Xe=>[Xe.id,Xe])),$t=Xe=>{const yt=new Map,bt=[];return Xe.forEach(At=>{yt.set(At.id,{...At,user_name:Yt.get(At.user_id)||"Unknown User",user_avatar:La.get(At.user_id),reactions:as.filter(Gt=>Gt.comment_id===At.id).map(Gt=>({...Gt,user_name:Yt.get(Gt.user_id)||"Unknown User",user_avatar:La.get(Gt.user_id)})),replies:[]})}),Xe.forEach(At=>{const Gt=yt.get(At.id);if(At.parent_comment_id&&yt.has(At.parent_comment_id)){const Vt=yt.get(At.parent_comment_id);Vt.replies=Vt.replies||[],Vt.replies.push(Gt)}else bt.push(Gt)}),bt};return{posts:lr.map(Xe=>{const yt=(Br||[]).filter(bt=>bt.post_id===Xe.id).map(bt=>{let At="",Gt=null;if(bt.resource_type==="template"){const Vt=un.get(bt.resource_id);At=(Vt==null?void 0:Vt.name)||"Unknown Template",Gt=(Vt==null?void 0:Vt.preview_image_url)||null}return{id:bt.id,resource_type:bt.resource_type,resource_id:bt.resource_id,resource_name:At,resource_preview_url:Gt}});return{...Xe,user_name:Yt.get(Xe.user_id)||"Unknown User",user_avatar:La.get(Xe.user_id),category:Xe.category_id?Lr.get(Xe.category_id):null,media:($r||[]).filter(bt=>bt.post_id===Xe.id),reactions:((nr||[]).filter(bt=>bt.post_id===Xe.id)||[]).map(bt=>({...bt,user_name:Yt.get(bt.user_id)||"Unknown User",user_avatar:La.get(bt.user_id)})),comments:$t((cr||[]).filter(bt=>bt.post_id===Xe.id)),resources:yt}}),hasMore:js,nextPage:Ze+1}},getNextPageParam:Ze=>Ze.hasMore?Ze.nextPage:void 0}),ct=k.useMemo(()=>(Ve==null?void 0:Ve.pages.flatMap(Ze=>Ze.posts))??[],[Ve]),fe=Pt({mutationFn:async()=>{q(!0);const{data:Ze,error:kt}=await G.from("community_posts").insert({user_id:t.id,category_id:N?null:_||null,private_group_id:N||null,content:f,link_url:L||null}).select().single();if(kt)throw kt;for(let Nt=0;Nt0){const Nt=me.filter(es=>es!==t.id).map(es=>({post_id:Ze.id,mentioned_user_id:es,mentioned_by_user_id:t.id}));Nt.length>0&&await G.from("community_post_mentions").insert(Nt)}const Ut=rVt(f);if(Ut.length>0){const Nt=Ut.map(es=>({post_id:Ze.id,resource_type:"template",resource_id:es}));await G.from("community_post_resources").insert(Nt)}return Ze},onSuccess:async Ze=>{var kt;i.invalidateQueries({queryKey:["community-posts"]}),y(""),ve([]),ge([]),b(""),w(""),C([]),I([]),O(""),l({title:"Post created!"});try{const Ut=((kt=t==null?void 0:t.user_metadata)==null?void 0:kt.name)||"Someone",Nt=f.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),es=Nt.length>50?Nt.substring(0,50)+"...":Nt;await G.functions.invoke("send-push-notification",{body:{title:"New Community Post",body:`${Ut}: ${es}`,url:"/community"}})}catch(Ut){console.error("Failed to send push notification:",Ut)}},onError:Ze=>{l({title:"Error creating post",description:Ze.message,variant:"destructive"})},onSettled:()=>q(!1)}),$e=Pt({mutationFn:async({postId:Ze,content:kt})=>{const{error:Ut}=await G.from("community_posts").update({content:kt}).eq("id",Ze);if(Ut)throw Ut},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),U(null),Y(""),l({title:"Post updated!"})}}),Ye=Pt({mutationFn:async Ze=>{const{error:kt}=await G.from("community_posts").delete().eq("id",Ze);if(kt)throw kt},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:"Post deleted"})}}),tt=Pt({mutationFn:async({postId:Ze,isPinned:kt})=>{const{error:Ut}=await G.from("community_posts").update({is_pinned:!kt,pinned_at:kt?null:new Date().toISOString(),pinned_by:kt?null:t==null?void 0:t.id}).eq("id",Ze);if(Ut)throw Ut},onSuccess:(Ze,{isPinned:kt})=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:kt?"Post unpinned":"Post pinned to top"})}}),Te=Pt({mutationFn:async({postId:Ze,reactionType:kt})=>{var Nt;const Ut=(Nt=ct.find(es=>es.id===Ze))==null?void 0:Nt.reactions.find(es=>es.user_id===(t==null?void 0:t.id));Ut?Ut.reaction_type===kt?await G.from("community_reactions").delete().eq("id",Ut.id):await G.from("community_reactions").update({reaction_type:kt}).eq("id",Ut.id):await G.from("community_reactions").insert({post_id:Ze,user_id:t.id,reaction_type:kt})},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),We=Pt({mutationFn:async({postId:Ze,content:kt})=>{const{data:Ut,error:Nt}=await G.from("community_comments").insert({post_id:Ze,user_id:t.id,content:kt}).select("id").single();if(Nt)throw Nt;const es=ae[Ze]||[];if(es.length>0&&Ut){const ds=es.filter(js=>js!==t.id).map(js=>({comment_id:Ut.id,mentioned_user_id:js,mentioned_by_user_id:t.id}));ds.length>0&&await G.from("community_comment_mentions").insert(ds)}},onSuccess:(Ze,{postId:kt})=>{i.invalidateQueries({queryKey:["community-posts"]}),ie(Ut=>({...Ut,[kt]:""})),oe(Ut=>({...Ut,[kt]:[]}))}});Pt({mutationFn:async Ze=>{const{error:kt}=await G.from("community_comments").delete().eq("id",Ze);if(kt)throw kt},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})});const Ke=Ze=>{const kt=Array.from(Ze.target.files||[]);if(kt.length+S.length>10){l({title:"Maximum 10 files allowed",variant:"destructive"});return}C(Ut=>[...Ut,...kt]),kt.forEach(Ut=>{const Nt=new FileReader;Nt.onloadend=()=>{I(es=>[...es,Nt.result])},Nt.readAsDataURL(Ut)})},ot=Ze=>{C(kt=>kt.filter((Ut,Nt)=>Nt!==Ze)),I(kt=>kt.filter((Ut,Nt)=>Nt!==Ze))},He=Ze=>Ze.split(" ").map(kt=>kt[0]).join("").toUpperCase().slice(0,2),Je=Ze=>{const kt={};return Ze.forEach(Ut=>{kt[Ut.reaction_type]=(kt[Ut.reaction_type]||0)+1}),kt},ut=Ze=>{var kt;return(kt=Ze.find(Ut=>Ut.user_id===(t==null?void 0:t.id)))==null?void 0:kt.reaction_type},mt=Ze=>Ze.reduce((kt,Ut)=>kt+1+(Ut.replies?mt(Ut.replies):0),0),et=Ze=>{if(n)return!0;if(!s||!Ze.private_group_id)return!1;const kt=ke.find(Ut=>Ut.id===Ze.private_group_id);return kt!=null&&kt.brokerage_id?r.some(Ut=>Ut.id===kt.brokerage_id):!1};return e.jsx(Ds,{title:"Community",children:e.jsxs("div",{className:"flex gap-6 w-full isolate z-0",children:[e.jsx(BUt,{categories:Me,privateGroups:ke,selectedFilter:u,onFilterChange:p,onlineUsers:o}),e.jsxs("div",{className:"flex-1 min-w-0 max-w-2xl mx-auto lg:mx-0 space-y-6",children:[e.jsxs("div",{className:"px-1",children:[e.jsx("h1",{className:"text-4xl lg:text-5xl font-bold text-foreground",children:"Community"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Connect and share with fellow agents"})]}),e.jsx($Ut,{categories:Me,privateGroups:ke,selectedFilter:u,onFilterChange:p,onlineUsers:o}),e.jsx(Pe,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:a||void 0}),e.jsx(kn,{children:t!=null&&t.email?He(t.email.split("@")[0]):"U"})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(fce,{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:y,onMentionsChange:ve,onTemplatesChange:ge,mentionFormat:"encoded",minHeight:"80px",enableTemplateMentions:n}),A.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:A.map((Ze,kt)=>{var Ut;return e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden bg-muted",children:[(Ut=S[kt])!=null&&Ut.type.startsWith("video/")?e.jsx("video",{src:Ze,className:"w-full h-full object-cover"}):e.jsx("img",{src:Ze,alt:"",className:"w-full h-full object-cover"}),e.jsx(W,{variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>ot(kt),children:e.jsx(kr,{className:"h-3 w-3"})})]},kt)})}),L&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(vo,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(De,{value:L,onChange:Ze=>O(Ze.target.value),placeholder:"https://...",className:"flex-1"}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>O(""),children:e.jsx(kr,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx("input",{type:"file",ref:d,onChange:Ke,accept:"image/*,video/*",multiple:!0,className:"hidden"}),e.jsxs(W,{variant:"ghost",size:"sm",onClick:()=>{var Ze;return(Ze=d.current)==null?void 0:Ze.click()},children:[e.jsx(qo,{className:"h-4 w-4 mr-1"}),"Photo"]}),e.jsxs(W,{variant:"ghost",size:"sm",onClick:()=>{var Ze;return(Ze=d.current)==null?void 0:Ze.click()},children:[e.jsx(yn,{className:"h-4 w-4 mr-1"}),"Video"]}),e.jsxs(W,{variant:"ghost",size:"sm",onClick:()=>O("https://"),children:[e.jsx(vo,{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:[ke.length>0?e.jsxs($s,{value:N||_||"none",onValueChange:Ze=>{Ze==="none"?(b(""),w("")):Ze.startsWith("group:")?(w(Ze.replace("group:","")),b("")):(b(Ze),w(""))},children:[e.jsx(zs,{className:"w-[130px] sm:w-[160px] h-8 text-xs sm:text-sm",children:e.jsx(Vs,{placeholder:"Select..."})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"none",children:"No category"}),Me.map(Ze=>e.jsxs(vt,{value:Ze.id,children:[Ze.icon," ",Ze.name]},Ze.id)),ke.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"}),ke.map(Ze=>e.jsxs(vt,{value:`group:${Ze.id}`,children:[Ze.icon||"🔒"," ",Ze.name]},Ze.id))]})]})]}):e.jsxs($s,{value:_,onValueChange:b,children:[e.jsx(zs,{className:"w-[110px] sm:w-[140px] h-8 text-xs sm:text-sm",children:e.jsx(Vs,{placeholder:"Category"})}),e.jsx(Bs,{children:Me.map(Ze=>e.jsxs(vt,{value:Ze.id,children:[Ze.icon," ",Ze.name]},Ze.id))})]}),e.jsxs(W,{size:"sm",onClick:()=>fe.mutate(),disabled:!f.trim()||V,children:[e.jsx(_n,{className:"h-4 w-4 mr-1"}),"Post"]})]})]})]})]})})}),Ne?e.jsx("div",{className:"space-y-4",children:[...Array(3)].map((Ze,kt)=>e.jsx(Pe,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Ms,{className:"h-10 w-10 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(Ms,{className:"h-4 w-32"}),e.jsx(Ms,{className:"h-4 w-full"}),e.jsx(Ms,{className:"h-4 w-3/4"})]})]})})},kt))}):ct.length===0?e.jsx(Pe,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Fl,{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:[ct.map(Ze=>{var kt,Ut,Nt,es;return e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex gap-3 min-w-0",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:Ze.user_avatar||void 0}),e.jsx(kn,{children:He(Ze.user_name||"U")})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-semibold break-words",children:Ze.user_name}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("span",{children:Nl(new Date(Ze.created_at),{addSuffix:!0})}),Ze.category&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs(Qe,{variant:"secondary",className:"text-xs",children:[Ze.category.icon," ",Ze.category.name]})]})]})]})]}),(Ze.user_id===(t==null?void 0:t.id)||et(Ze))&&e.jsxs(Hd,{children:[e.jsx(Gd,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(Zp,{className:"h-4 w-4"})})}),e.jsxs(Nd,{align:"end",children:[et(Ze)&&Ze.private_group_id&&e.jsx(_a,{onClick:()=>tt.mutate({postId:Ze.id,isPinned:Ze.is_pinned}),children:Ze.is_pinned?e.jsxs(e.Fragment,{children:[e.jsx(TL,{className:"h-4 w-4 mr-2"}),"Unpin Post"]}):e.jsxs(e.Fragment,{children:[e.jsx(Tb,{className:"h-4 w-4 mr-2"}),"Pin to Top"]})}),Ze.user_id===(t==null?void 0:t.id)&&e.jsxs(_a,{onClick:()=>{U(Ze),Y(Ze.content)},children:[e.jsx(ga,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(_a,{className:"text-destructive",onClick:()=>Ye.mutate(Ze.id),children:[e.jsx(vr,{className:"h-4 w-4 mr-2"}),Ze.user_id!==(t==null?void 0:t.id)?"Remove (Moderate)":"Delete"]})]})]})]}),Ze.is_pinned&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-primary",children:[e.jsx(Tb,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Pinned"})]}),e.jsx("div",{className:"mb-3",children:e.jsx(h4e,{content:Ze.content})}),Ze.media.length>0&&e.jsx("div",{className:`grid gap-2 mb-3 ${Ze.media.length===1?"grid-cols-1":Ze.media.length===2?"grid-cols-2":Ze.media.length===3?"grid-cols-3":"grid-cols-2"}`,children:Ze.media.slice(0,4).map((ds,js)=>{const lr=js===3&&Ze.media.length>4,Lt=Ze.media.length-4;return e.jsxs("div",{className:`relative rounded-lg overflow-hidden bg-muted cursor-pointer group ${Ze.media.length===1?"max-h-[500px]":Ze.media.length===2?"aspect-[4/3]":"aspect-square"}`,onClick:()=>qe({open:!0,images:Ze.media.map(Es=>({url:Es.media_url,type:Es.media_type==="video"?"video":"image"})),index:js}),children:[ds.media_type==="video"?e.jsx("video",{src:ds.media_url,className:"w-full h-full object-cover transition-transform group-hover:scale-105"}):e.jsx("img",{src:ds.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"})})})}),lr&&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:["+",Lt]})})]},ds.id)})}),Ze.link_url&&e.jsxs("a",{href:Ze.link_url,target:"_blank",rel:"noopener noreferrer",className:"block rounded-lg border hover:bg-muted transition-colors mb-3 overflow-hidden",children:[Ze.link_image&&e.jsx("div",{className:"aspect-video bg-muted",children:e.jsx("img",{src:Ze.link_image,alt:Ze.link_title||"Link preview",className:"w-full h-full object-cover",onError:ds=>{ds.currentTarget.style.display="none"}})}),e.jsx("div",{className:"p-3",children:Ze.link_title?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"font-medium text-foreground line-clamp-2",children:Ze.link_title}),Ze.link_description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mt-1",children:Ze.link_description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 truncate",children:new URL(Ze.link_url).hostname})]}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-primary",children:[e.jsx(vo,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:Ze.link_url})]})})]}),Ze.reactions.length>0&&e.jsx(ctt,{reactions:Ze.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(Je(Ze.reactions)).slice(0,3).map(([ds])=>{var js;return e.jsx("span",{className:"text-base",children:(js=Jz.find(lr=>lr.type===ds))==null?void 0:js.emoji},ds)})}),e.jsx("span",{children:Ze.reactions.length})]})}),e.jsxs("div",{className:"flex items-center gap-1 border-t border-b py-1 my-2",children:[e.jsxs(mo,{children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{variant:"ghost",size:"sm",className:"flex-1",children:[ut(Ze.reactions)?e.jsx("span",{className:"mr-1",children:(kt=Jz.find(ds=>ds.type===ut(Ze.reactions)))==null?void 0:kt.emoji}):e.jsx(Bu,{className:"h-4 w-4 mr-1"}),ut(Ze.reactions)?(Ut=Jz.find(ds=>ds.type===ut(Ze.reactions)))==null?void 0:Ut.label:"Like"]})}),e.jsx(no,{className:"w-auto p-2",side:"top",children:e.jsx("div",{className:"flex gap-1",children:Jz.map(ds=>e.jsx("button",{onClick:()=>Te.mutate({postId:Ze.id,reactionType:ds.type}),className:"text-2xl hover:scale-125 transition-transform p-1",title:ds.label,children:ds.emoji},ds.type))})})]}),e.jsxs(W,{variant:"ghost",size:"sm",className:"flex-1",onClick:()=>X(ds=>{const js=new Set(ds);return js.has(Ze.id)?js.delete(Ze.id):js.add(Ze.id),js}),children:[e.jsx(Fl,{className:"h-4 w-4 mr-1"}),(()=>{const ds=mt(Ze.comments);return ds>0?`Comment (${ds})`:"Comment"})()]})]}),J.has(Ze.id)&&e.jsxs("div",{className:"space-y-3 mt-3",children:[Ze.comments.map(ds=>e.jsx(dtt,{comment:ds,postId:Ze.id,currentUserId:t==null?void 0:t.id,currentUserAvatar:a,currentUserEmail:t==null?void 0:t.email,canModerate:et(Ze)},ds.id)),t&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:a||void 0}),e.jsx(kn,{className:"text-xs",children:He(((Nt=t.email)==null?void 0:Nt.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2",children:[e.jsx(fce,{placeholder:"Write a comment... (use @ to mention)",value:ce[Ze.id]||"",onChange:ds=>ie(js=>({...js,[Ze.id]:ds})),onMentionsChange:ds=>oe(js=>({...js,[Ze.id]:ds})),mentionFormat:"plain",onKeyDown:ds=>{var js;ds.defaultPrevented||ds.key==="Enter"&&!ds.shiftKey&&((js=ce[Ze.id])!=null&&js.trim())&&(ds.preventDefault(),We.mutate({postId:Ze.id,content:ce[Ze.id]}))},className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(W,{size:"sm",variant:"ghost",onClick:()=>{var ds;(ds=ce[Ze.id])!=null&&ds.trim()&&We.mutate({postId:Ze.id,content:ce[Ze.id]})},disabled:!((es=ce[Ze.id])!=null&&es.trim()),className:"h-8 px-2 mt-0.5",children:e.jsx(_n,{className:"h-4 w-4"})})]})]})]})]})},Ze.id)}),Ue&&e.jsx("div",{className:"flex justify-center pt-2",children:e.jsx(W,{variant:"outline",onClick:()=>Ie(),disabled:ye,children:ye?"Loading…":"Load more posts"})})]}),e.jsx(fs,{open:!!B,onOpenChange:()=>U(null),children:e.jsxs(ps,{children:[e.jsx(ks,{children:e.jsx(_s,{children:"Edit Post"})}),e.jsx(_r,{value:te,onChange:Ze=>Y(Ze.target.value),className:"min-h-[120px]"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(W,{variant:"outline",onClick:()=>U(null),children:"Cancel"}),e.jsx(W,{onClick:()=>{B&&$e.mutate({postId:B.id,content:te})},disabled:!te.trim(),children:"Save Changes"})]})]})}),e.jsx(tVt,{images:je.images,initialIndex:je.index,open:je.open,onOpenChange:Ze=>qe(kt=>({...kt,open:Ze}))})]})]})})},w5={open:{label:"Open",icon:nn,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:Fl,color:"bg-blue-500"},resolved:{label:"Resolved",icon:si,color:"bg-green-500"},closed:{label:"Closed",icon:Jl,color:"bg-muted-foreground"}},eDe={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function aVt(){const{user:t}=Us(),s=Qt(),[r,n]=k.useState(null),[a,o]=k.useState(""),{data:l=[],isLoading:i}=gt({queryKey:["support-tickets"],queryFn:async()=>{const{data:f,error:y}=await G.from("support_tickets").select("*").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});if(y)throw y;return f},enabled:!!t}),{data:d=[]}=gt({queryKey:["ticket-replies",r==null?void 0:r.id],queryFn:async()=>{if(!r)return[];const{data:f,error:y}=await G.from("support_ticket_replies").select("*, profiles(name)").eq("ticket_id",r.id).order("created_at",{ascending:!0});if(y)throw y;return f},enabled:!!r}),u=Pt({mutationFn:async f=>{if(!r||!t)throw new Error("Missing data");const{error:y}=await G.from("support_ticket_replies").insert({ticket_id:r.id,user_id:t.id,content:f,is_admin_reply:!1});if(y)throw y},onSuccess:()=>{s.invalidateQueries({queryKey:["ticket-replies",r==null?void 0:r.id]}),o(""),pe.success("Reply sent!")},onError:()=>{pe.error("Failed to send reply")}}),p=()=>{a.trim()&&u.mutate(a)};if(r){const f=w5[r.status].icon;return e.jsx(Ds,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>n(null),children:e.jsx(Oa,{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(Qe,{variant:"secondary",children:eDe[r.category]}),e.jsxs(Qe,{className:w5[r.status].color,children:[e.jsx(f,{className:"h-3 w-3 mr-1"}),w5[r.status].label]})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(dr,{children:["Created on ",vs(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"Conversation"})}),e.jsxs(Oe,{children:[e.jsx(Ja,{className:"h-[300px] pr-4",children:d.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No replies yet"}):e.jsx("div",{className:"space-y-4",children:d.map(y=>{var _;return e.jsxs("div",{className:`p-4 rounded-lg ${y.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:y.is_admin_reply?"Support Team":((_=y.profiles)==null?void 0:_.name)||"You"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:vs(new Date(y.created_at),"MMM d, h:mm a")})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:y.content})]},y.id)})})}),r.status!=="closed"&&e.jsxs(e.Fragment,{children:[e.jsx(ho,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(_r,{placeholder:"Type your reply...",value:a,onChange:y=>o(y.target.value),className:"min-h-[80px]"}),e.jsx(W,{onClick:p,disabled:!a.trim()||u.isPending,className:"self-end",children:e.jsx(_n,{className:"h-4 w-4"})})]})]})]})]})]})})}return e.jsx(Ds,{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(Oe,{className:"p-6 sm:p-8",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-6",children:[e.jsx("div",{className:"p-4 bg-primary/20 rounded-full",children:e.jsx(Mv,{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(n_e,{trigger:e.jsxs(W,{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(In,{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(n_e,{trigger:e.jsxs(W,{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(Oe,{className:"text-center py-12",children:[e.jsx(Fl,{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 y=w5[f.status].icon;return e.jsx(Pe,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(f),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium truncate",children:f.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(Qe,{variant:"outline",className:"text-xs",children:eDe[f.category]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:vs(new Date(f.created_at),"MMM d, yyyy")})]})]}),e.jsxs(Qe,{className:w5[f.status].color,children:[e.jsx(y,{className:"h-3 w-3 mr-1"}),w5[f.status].label]})]})})},f.id)})})]})})}function iVt({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(ks,{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(cn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(_s,{children:"Schedule Agent Onboarding"}),e.jsx(Ir,{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 oVt({open:t,onOpenChange:s}){const{brokerageId:r}=Us(),[n,a]=k.useState(""),[o,l]=k.useState([]),[i,d]=k.useState(!1),{data:u,isLoading:p}=gt({queryKey:["brokerage-agents-for-onboarding",r],queryFn:async()=>{if(!r)return[];const{data:N,error:w}=await G.from("profiles").select("id, name, email").eq("brokerage_id",r).order("name",{ascending:!0});if(w)throw w;return N},enabled:t&&!!r}),f=u==null?void 0:u.filter(N=>N.name.toLowerCase().includes(n.toLowerCase())||N.email.toLowerCase().includes(n.toLowerCase())),y=N=>{l(w=>w.includes(N)?w.filter(S=>S!==N):[...w,N])},_=async()=>{if(o.length===0){pe.error("Please select at least one agent");return}d(!0);try{const{data:N,error:w}=await G.functions.invoke("send-onboarding-link",{body:{agentIds:o}});if(w)throw w;pe.success(`Onboarding link sent to ${o.length} agent${o.length>1?"s":""}`),l([]),s(!1)}catch(N){console.error("Error sending onboarding link:",N),pe.error(N.message||"Failed to send onboarding link")}finally{d(!1)}},b=N=>{N||(l([]),a("")),s(N)};return e.jsx(fs,{open:t,onOpenChange:b,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(ks,{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(_n,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(_s,{children:"Send Onboarding Link"}),e.jsx(Ir,{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(ln,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search agents...",value:n,onChange:N=>a(N.target.value),className:"pl-10"})]}),p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(us,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):(f==null?void 0:f.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ir,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No agents found"})]}):e.jsx(Ja,{className:"h-[300px] border rounded-lg",children:e.jsx("div",{className:"p-2 space-y-1",children:f==null?void 0:f.map(N=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-muted cursor-pointer",onClick:()=>y(N.id),children:[e.jsx(Ri,{checked:o.includes(N.id),onCheckedChange:()=>y(N.id)}),e.jsx(Nn,{className:"h-8 w-8",children:e.jsx(kn,{className:"text-xs",children:N.name.split(" ").map(w=>w[0]).join("").toUpperCase()})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:N.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:N.email})]})]},N.id))})}),o.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[o.length," agent",o.length>1?"s":""," selected"]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>b(!1),children:"Cancel"}),e.jsx(W,{onClick:_,disabled:o.length===0||i,children:i?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(_n,{className:"h-4 w-4 mr-2"}),"Send Link"]})})]})]})})}function lVt(){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(Dt,{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(ir,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{children:"Agent Onboarding"}),e.jsx(dr,{children:"Schedule onboarding sessions for yourself or your agents"})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsxs(W,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx(cn,{className:"h-4 w-4"}),"Schedule Agent Onboarding"]}),e.jsxs(W,{variant:"outline",onClick:()=>n(!0),className:"flex items-center gap-2",children:[e.jsx(_n,{className:"h-4 w-4"}),"Send New Agent Onboarding Link"]})]})})]}),e.jsx(iVt,{open:t,onOpenChange:s}),e.jsx(oVt,{open:r,onOpenChange:n})]})}function cVt({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(ks,{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(e0,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(_s,{children:"Schedule Launch Meeting"}),e.jsx(Ir,{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 dVt(){const[t,s]=k.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{className:"mb-8",children:[e.jsx(Dt,{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(e0,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{children:"Launch or ReLaunch Meeting"}),e.jsx(dr,{children:"Schedule a private LevelUp information session for your brokerage. Have one of our staff host a meeting to help your team get the most out of all our trainings, tools, and resources."})]})]})}),e.jsx(Oe,{children:e.jsxs(W,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx(e0,{className:"h-4 w-4"}),"Schedule Launch Meeting"]})})]}),e.jsx(cVt,{open:t,onOpenChange:s})]})}function uVt(){const t=wr(),[s,r]=k.useState(""),[n,a]=k.useState(null),{data:o,isLoading:l}=gt({queryKey:["brokerage-resources-published"],queryFn:async()=>{const{data:N,error:w}=await G.from("brokerage_resources").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(w)throw w;return N}}),{data:i}=gt({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:N,error:w}=await G.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(w)throw w;return N}}),{data:d}=gt({queryKey:["brokerage-resource-pdfs-all"],queryFn:async()=>{const{data:N,error:w}=await G.from("brokerage_resource_pdfs").select("resource_id");if(w)throw w;return N}}),{data:u}=gt({queryKey:["brokerage-resource-videos-all"],queryFn:async()=>{const{data:N,error:w}=await G.from("brokerage_resource_videos").select("resource_id");if(w)throw w;return N}}),{data:p}=gt({queryKey:["brokerage-resource-links-all"],queryFn:async()=>{const{data:N,error:w}=await G.from("brokerage_resource_links").select("resource_id");if(w)throw w;return N}}),f=o==null?void 0:o.filter(N=>{var C;const w=N.title.toLowerCase().includes(s.toLowerCase())||((C=N.description)==null?void 0:C.toLowerCase().includes(s.toLowerCase())),S=!n||N.category_id===n;return w&&S}),y=i==null?void 0:i.filter(N=>o==null?void 0:o.some(w=>w.category_id===N.id)),_=N=>{const w=(d==null?void 0:d.filter(A=>A.resource_id===N).length)||0,S=(u==null?void 0:u.filter(A=>A.resource_id===N).length)||0,C=(p==null?void 0:p.filter(A=>A.resource_id===N).length)||0;return{pdfCount:w,videoCount:S,linkCount:C}},b=N=>{t(`/brokerage-resources/${N}`)};return e.jsx(Ds,{title:"Brokerage Resources",description:"Access exclusive resources for brokerage managers",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(lVt,{}),e.jsx(dVt,{}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search resources...",value:s,onChange:N=>r(N.target.value),className:"pl-10"})]}),y&&y.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Qe,{variant:n===null?"default":"outline",className:"cursor-pointer",onClick:()=>a(null),children:"All"}),y.map(N=>e.jsx(Qe,{variant:n===N.id?"default":"outline",className:"cursor-pointer",onClick:()=>a(N.id),children:N.name},N.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((N,w)=>e.jsxs(Pe,{children:[e.jsx(Ms,{className:"h-40 w-full"}),e.jsx(Dt,{children:e.jsx(Ms,{className:"h-5 w-3/4"})}),e.jsxs(Oe,{children:[e.jsx(Ms,{className:"h-4 w-full mb-2"}),e.jsx(Ms,{className:"h-4 w-2/3"})]})]},w))}):(f==null?void 0:f.length)===0?e.jsxs(Pe,{className:"p-12 text-center",children:[e.jsx(dh,{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(N=>{const{pdfCount:w,videoCount:S,linkCount:C}=_(N.id),A=i==null?void 0:i.find(I=>I.id===N.category_id);return e.jsxs(Pe,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>b(N.id),children:[N.preview_image_url?e.jsx("img",{src:N.preview_image_url,alt:N.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(dh,{className:"h-16 w-16 text-muted-foreground"})}),e.jsx(Dt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(zt,{className:"text-lg line-clamp-1",children:N.title}),A&&e.jsx(Qe,{variant:"secondary",className:"shrink-0 text-xs",children:A.name})]})}),e.jsxs(Oe,{children:[N.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:N.description}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[w>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(vn,{className:"h-4 w-4"}),w]}),S>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(yn,{className:"h-4 w-4"}),S]}),C>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(vo,{className:"h-4 w-4"}),C]})]})]})]},N.id)})})]})})}const hVt=()=>{const{resourceId:t}=io(),{data:s,isLoading:r}=gt({queryKey:["brokerage-resource-detail",t],queryFn:async()=>{const{data:a,error:o}=await G.from("brokerage_resources").select("*").eq("id",t).eq("is_published",!0).single();if(o)throw o;const{data:l}=await G.from("brokerage_resource_pdfs").select("*").eq("resource_id",t).order("sort_order"),{data:i}=await G.from("brokerage_resource_videos").select("*").eq("resource_id",t).order("sort_order"),{data:d}=await G.from("brokerage_resource_links").select("*").eq("resource_id",t).order("sort_order");return{...a,pdfs:l||[],videos:i||[],links:d||[]}},enabled:!!t}),n=a=>a?a<1024?a+" B":a<1024*1024?(a/1024).toFixed(1)+" KB":(a/(1024*1024)).toFixed(1)+" MB":"";return r?e.jsx(Ds,{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(Ds,{title:s.title,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(W,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(da,{to:"/brokerage-resources",children:[e.jsx(Oa,{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(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(yn,{className:"h-4 w-4"}),"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(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(vn,{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(vn,{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(Qa,{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(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Yr,{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(Yr,{className:"h-4 w-4 text-primary"})}),e.jsx("div",{className:"font-medium text-sm",children:a.title})]}),e.jsx(Yr,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},a.id))})]})})]})}):e.jsx(Ds,{title:"Brokerage Resources",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(dh,{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(W,{asChild:!0,className:"mt-4",children:e.jsx(da,{to:"/brokerage-resources",children:"Back to Resources"})})]})})};function mVt(){const{onlineUsers:t,totalOnline:s}=eXe();return e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(ir,{className:"h-4 w-4"}),"Online Now"]}),e.jsxs(Qe,{variant:"secondary",className:"bg-green-100 text-green-700",children:[e.jsx(sd,{className:"h-2 w-2 fill-green-500 text-green-500 mr-1"}),s," online"]})]})}),e.jsx(Oe,{children:t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No other users online right now"}):e.jsx(Ja,{className:"h-[300px] pr-4",children:e.jsx("div",{className:"space-y-3",children:t.map(r=>{var n;return e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"relative",children:[e.jsxs(Nn,{className:"h-9 w-9",children:[e.jsx(Ma,{src:r.avatarUrl,alt:r.name}),e.jsx(kn,{className:"text-xs",children:(n=r.name)==null?void 0:n.split(" ").map(a=>a[0]).join("").slice(0,2).toUpperCase()})]}),e.jsx("span",{className:"absolute bottom-0 right-0 h-2.5 w-2.5 rounded-full bg-green-500 ring-2 ring-background"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:r.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Online ",Nl(new Date(r.onlineSince),{addSuffix:!1})]})]})]},r.id)})})})})]})}const tDe={users:{label:"Users & Access",sections:[{title:"Members",description:"Manage users, roles, and brokerage assignments",icon:ir,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:yx,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:hL,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:mh,path:"/admin/discounts",color:"bg-red-500/10 text-red-600"},{title:"Referral Program",description:"Track brokerage referrals and discounts",icon:id,path:"/admin/referrals",color:"bg-teal-500/10 text-teal-600"},{title:"Teams",description:"Manage agent teams across all brokerages",icon:ir,path:"/admin/members?tab=teams",color:"bg-violet-500/10 text-violet-600"},{title:"Prospector",description:"Send free trial invites and track conversions",icon:Rh,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:Jo,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:zl,path:"/admin/templates",color:"bg-pink-500/10 text-pink-600"},{title:"Manage Academy",description:"Upload videos and training content",icon:Lh,path:"/admin/academy",color:"bg-indigo-500/10 text-indigo-600"},{title:"Manage Toolbox",description:"Create and manage resource kits",icon:Lg,path:"/admin/toolbox",color:"bg-orange-500/10 text-orange-600"},{title:"Social Swag",description:"Manage social media content and links",icon:Or,path:"/admin/social-swag",color:"bg-fuchsia-500/10 text-fuchsia-600"},{title:"Social Swag 2.0",description:"New monthly social media images",icon:Or,path:"/admin/social-swag-2",color:"bg-cyan-500/10 text-cyan-600"},{title:"Newsletters",description:"Manage monthly newsletter templates",icon:Jv,path:"/admin/newsletters",color:"bg-violet-500/10 text-violet-600"},{title:"Manage Events",description:"Create and publish events with Zoom integration",icon:_d,path:"/admin/events",color:"bg-green-500/10 text-green-600"},{title:"Additional Services",description:"Manage additional service offerings",icon:dh,path:"/admin/additional-services",color:"bg-lime-500/10 text-lime-600"},{title:"Brokerage Resources",description:"Manage resources for brokerage managers",icon:dh,path:"/admin/brokerage-resources",color:"bg-slate-500/10 text-slate-600"},{title:"Agent Email Templates",description:"Manage curated email templates for agents",icon:tr,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:uh,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:aS,path:"/admin/dashboard-management",color:"bg-teal-500/10 text-teal-600"},{title:"Manage Apps",description:"Configure app tiles and access requirements",icon:Xf,path:"/admin/apps",color:"bg-purple-500/10 text-purple-600"},{title:"Email Templates",description:"Customize system email templates",icon:tr,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:uh,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:wM,path:"/admin/onboarding-checklist",color:"bg-emerald-500/10 text-emerald-600"},{title:"Marketplace",description:"Manage store categories, products, and orders",icon:s0,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:hi,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:Fi,path:"/admin/agent-points",color:"bg-amber-500/10 text-amber-600"},{title:"Integrations",description:"Connect Canva, Facebook & Instagram for platform-level features",icon:Do,path:"/admin/integrations",color:"bg-blue-500/10 text-blue-600"},{title:"Agent Cards",description:"Manage digital business cards for agents",icon:ir,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:uh,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:wi,path:"/admin/community",color:"bg-cyan-500/10 text-cyan-600"},{title:"Support Tickets",description:"View and respond to agent support requests",icon:TM,path:"/admin/support-tickets",color:"bg-rose-500/10 text-rose-600"},{title:"Wishlist",description:"Review and manage community feature requests",icon:Cb,path:"/admin/wishlist",color:"bg-yellow-500/10 text-yellow-600"},{title:"Membership Reviews",description:"View member feedback and ratings",icon:Gn,path:"/admin/membership-reviews",color:"bg-amber-500/10 text-amber-600"},{title:"Weekly Digest",description:"Configure automated weekly email digests",icon:tr,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:so,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:ch,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:Lh,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:Xa,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:Mn,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:Pg,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:ch,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:qo,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:tr,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:Sb,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:mL,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:Qo,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:vn,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:vn,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:_c,path:"/admin/mls-fee-tracker",color:"bg-gradient-to-br from-teal-500/20 to-cyan-500/10 text-teal-600"}]}};function sDe(){const t=wr();return console.log("[AdminDashboard] render"),e.jsx(Ds,{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(mVt,{})})]}),e.jsxs(ta,{defaultValue:"users",className:"w-full",children:[e.jsx(Jn,{className:"w-full justify-start flex-wrap h-auto gap-1 bg-muted/50 p-1 overflow-x-auto",children:Object.entries(tDe).map(([s,r])=>e.jsx(cs,{value:s,className:"data-[state=active]:bg-background",children:r.label},s))}),Object.entries(tDe).map(([s,r])=>e.jsx(Ss,{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(Dt,{className:"pb-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${n.color} mb-2 group-hover:scale-110 transition-transform`,children:e.jsx(n.icon,{className:"h-5 w-5"})}),e.jsx(zt,{className:"text-base",children:n.title})]}),e.jsx(Oe,{className:"pt-0",children:e.jsx(dr,{className:"text-sm",children:n.description})})]},n.path))})},s))]})]})})}const Ln=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:r,className:Ot("w-full caption-bottom text-sm",t),...s})}));Ln.displayName="Table";const Dn=k.forwardRef(({className:t,...s},r)=>e.jsx("thead",{ref:r,className:Ot("[&_tr]:border-b",t),...s}));Dn.displayName="TableHeader";const Rn=k.forwardRef(({className:t,...s},r)=>e.jsx("tbody",{ref:r,className:Ot("[&_tr:last-child]:border-0",t),...s}));Rn.displayName="TableBody";const pVt=k.forwardRef(({className:t,...s},r)=>e.jsx("tfoot",{ref:r,className:Ot("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...s}));pVt.displayName="TableFooter";const Ps=k.forwardRef(({className:t,...s},r)=>e.jsx("tr",{ref:r,className:Ot("border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50",t),...s}));Ps.displayName="TableRow";const St=k.forwardRef(({className:t,...s},r)=>e.jsx("th",{ref:r,className:Ot("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...s}));St.displayName="TableHead";const ht=k.forwardRef(({className:t,...s},r)=>e.jsx("td",{ref:r,className:Ot("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...s}));ht.displayName="TableCell";const fVt=k.forwardRef(({className:t,...s},r)=>e.jsx("caption",{ref:r,className:Ot("mt-4 text-sm text-muted-foreground",t),...s}));fVt.displayName="TableCaption";const xVt=()=>{const{isAdmin:t}=Us(),s=wr(),[r,n]=k.useState([]),[a,o]=k.useState(!0),[l,i]=k.useState(!1),[d,u]=k.useState(null);k.useEffect(()=>{if(!t){s("/dashboard");return}p()},[t]);const p=async()=>{try{const{data:N,error:w}=await G.from("app_tiles").select("*").order("name");if(w)throw w;n(N||[])}catch(N){console.error("Error loading apps:",N),pe.error("Failed to load apps")}finally{o(!1)}},f=async N=>{N.preventDefault();const w=new FormData(N.currentTarget),S={name:w.get("name"),description:w.get("description"),icon:w.get("icon"),app_id:w.get("app_id"),target_url:w.get("target_url"),required_tags:w.get("required_tags").split(",").map(C=>C.trim()).filter(Boolean)};try{if(d){const{error:C}=await G.from("app_tiles").update(S).eq("id",d.id);if(C)throw C;pe.success("App updated successfully")}else{const{error:C}=await G.from("app_tiles").insert([S]);if(C)throw C;pe.success("App created successfully")}i(!1),u(null),p()}catch(C){console.error("Error saving app:",C),pe.error("Failed to save app")}},y=async N=>{if(confirm("Are you sure you want to delete this app?"))try{const{error:w}=await G.from("app_tiles").delete().eq("id",N);if(w)throw w;pe.success("App deleted successfully"),p()}catch(w){console.error("Error deleting app:",w),pe.error("Failed to delete app")}},_=N=>{u(N),i(!0)},b=()=>{u(null),i(!0)};return a?e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}):e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(W,{variant:"ghost",size:"sm",onClick:()=>s("/dashboard"),children:[e.jsx(Oa,{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(mi,{asChild:!0,children:e.jsxs(W,{onClick:b,children:[e.jsx(qs,{className:"mr-2 h-4 w-4"}),"Add App"]})}),e.jsxs(ps,{className:"max-w-2xl",children:[e.jsxs(ks,{children:[e.jsx(_s,{children:d?"Edit App":"Create New App"}),e.jsx(Ir,{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(xe,{htmlFor:"name",children:"App Name"}),e.jsx(De,{id:"name",name:"name",defaultValue:d==null?void 0:d.name,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"app_id",children:"App ID"}),e.jsx(De,{id:"app_id",name:"app_id",defaultValue:d==null?void 0:d.app_id,placeholder:"agent_connect",required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"description",children:"Description"}),e.jsx(_r,{id:"description",name:"description",defaultValue:d==null?void 0:d.description})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"icon",children:"Icon (emoji)"}),e.jsx(De,{id:"icon",name:"icon",defaultValue:d==null?void 0:d.icon,placeholder:"🚀",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"target_url",children:"Target URL"}),e.jsx(De,{id:"target_url",name:"target_url",type:"url",defaultValue:d==null?void 0:d.target_url,required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"required_tags",children:"Required Tags (comma-separated)"}),e.jsx(De,{id:"required_tags",name:"required_tags",defaultValue:d==null?void 0:d.required_tags.join(", "),placeholder:"levelup-member, agent-connect"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(W,{type:"submit",children:d?"Update":"Create"})]})]})]})]})]})})}),e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"Application Tiles"}),e.jsx(dr,{children:"Manage the apps that appear on the member dashboard"})]}),e.jsx(Oe,{children:r.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No apps configured yet"}),e.jsxs(W,{onClick:b,children:[e.jsx(qs,{className:"mr-2 h-4 w-4"}),"Create First App"]})]}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Icon"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"App ID"}),e.jsx(St,{children:"Target URL"}),e.jsx(St,{children:"Tags"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:r.map(N=>e.jsxs(Ps,{children:[e.jsx(ht,{className:"text-2xl",children:N.icon}),e.jsx(ht,{className:"font-medium",children:N.name}),e.jsx(ht,{className:"font-mono text-sm",children:N.app_id}),e.jsx(ht,{className:"text-sm text-muted-foreground max-w-xs truncate",children:N.target_url}),e.jsx(ht,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:N.required_tags.map(w=>e.jsx("span",{className:"text-xs bg-secondary text-secondary-foreground px-2 py-1 rounded",children:w},w))})}),e.jsx(ht,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(W,{size:"sm",variant:"ghost",onClick:()=>_(N),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(W,{size:"sm",variant:"ghost",onClick:()=>y(N.id),children:e.jsx(vr,{className:"h-4 w-4"})})]})})]},N.id))})]})})]})})]})};function Hu({title:t,description:s,children:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx(da,{to:"/admin",children:e.jsxs(W,{variant:"ghost",size:"sm",className:"gap-2 text-muted-foreground hover:text-foreground",children:[e.jsx(Oa,{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 rDe=({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(Qe,{variant:"destructive",className:Ot("gap-1",s),children:[e.jsx(Dc,{className:"h-3 w-3"}),"Trial Expired"]}):a<=1?e.jsxs(Qe,{variant:"destructive",className:Ot("gap-1",s),children:[e.jsx(nn,{className:"h-3 w-3"}),"Trial: <1 day left"]}):a<=3?e.jsxs(Qe,{className:Ot("gap-1 bg-amber-500 hover:bg-amber-600",s),children:[e.jsx(nn,{className:"h-3 w-3"}),"Trial: ",a," days left"]}):e.jsxs(Qe,{variant:"secondary",className:Ot("gap-1",s),children:[e.jsx(nn,{className:"h-3 w-3"}),"Trial: ",a," days left"]})},utt=({open:t,onOpenChange:s,brokerages:r,fixedBrokerageId:n,onSuccess:a})=>{const{toast:o}=ja(),l=k.useRef(null),[i,d]=k.useState([]),[u,p]=k.useState(""),[f,y]=k.useState(!1),[_,b]=k.useState("upload"),[N,w]=k.useState(null),S=()=>{d([]),p(""),b("upload"),w(null),l.current&&(l.current.value="")},C=()=>{S(),s(!1)},A=q=>{const B=q.split(` `).map(X=>X.trim()).filter(X=>X);if(B.length===0)return[];const U=B[0].toLowerCase(),Y=U.includes("first")||U.includes("last")||U.includes("email")||U.includes("name")||U.includes("phone")||U.includes("sms")||U.includes("consent")?B.slice(1):B,J=[];for(const X of Y){const ie=(X.includes(" ")?X.split(" "):X.split(",")).map(ae=>ae.trim().replace(/^["']|["']$/g,""));if(ie.length>=2){let ae="",oe="",me="",ve="",he;if(ie.length===2){const qe=ie[0].split(" ");ae=qe[0]||"",oe=qe.slice(1).join(" ")||"",me=ie[1]}else if(ie.length===3)ae=ie[0],oe=ie[1],me=ie[2];else if(ie.length===4)ae=ie[0],oe=ie[1],me=ie[2],ve=ie[3];else if(ie.length>=5){ae=ie[0],oe=ie[1],me=ie[2],ve=ie[3];const qe=ie[4].toLowerCase();he=qe==="true"||qe==="yes"||qe==="1"||qe==="y"}const je=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(me);J.push({firstName:ae.trim(),lastName:oe.trim(),email:me.trim().toLowerCase(),phone:ve.trim()||void 0,smsConsent:he,isValid:je&&ae.trim().length>0,error:je?ae.trim()?void 0:"Missing name":"Invalid email"})}}return J},I=q=>{var te;const B=(te=q.target.files)==null?void 0:te[0];if(!B)return;const U=new FileReader;U.onload=Y=>{var ce;const J=(ce=Y.target)==null?void 0:ce.result,X=A(J);if(X.length===0){o({title:"No data found",description:"The CSV file appears to be empty or in an unsupported format.",variant:"destructive"});return}d(X),b("preview")},U.readAsText(B)},L=async()=>{const q=i.filter(U=>U.isValid);if(q.length===0){o({title:"No valid users",description:"There are no valid users to import.",variant:"destructive"});return}const B=n||u||null;y(!0);try{const{data:{session:U}}=await G.auth.getSession(),te=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/bulk-create-users",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${U==null?void 0:U.access_token}`},body:JSON.stringify({users:q.map(J=>({firstName:J.firstName,lastName:J.lastName,email:J.email,phone:J.phone,smsConsent:J.smsConsent})),brokerageId:B})}),Y=await te.json();if(!te.ok)throw new Error(Y.error||"Failed to import users");w(Y),b("result"),Y.created>0&&a(),o({title:"Import Complete",description:`${Y.created} user(s) created successfully.${Y.failed>0?` ${Y.failed} failed.`:""}`})}catch(U){console.error("Import error:",U),o({title:"Import Failed",description:U.message||"Failed to import users",variant:"destructive"})}finally{y(!1)}},O=i.filter(q=>q.isValid).length,V=i.filter(q=>!q.isValid).length;return e.jsx(fs,{open:t,onOpenChange:C,children:e.jsxs(ps,{className:"max-w-2xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(Zv,{className:"h-5 w-5"}),"Import Agents from CSV"]}),e.jsx(Ir,{children:"Upload a CSV file with agent information. Each row should contain First Name, Last Name, and Email."})]}),_==="upload"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-8 text-center",children:[e.jsx("input",{type:"file",accept:".csv,.txt",ref:l,onChange:I,className:"hidden"}),e.jsx(Ra,{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(W,{onClick:()=>{var q;return(q=l.current)==null?void 0:q.click()},children:"Select CSV File"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 text-sm",children:[e.jsx("p",{className:"font-medium mb-2",children:"Expected CSV Format:"}),e.jsxs("code",{className:"text-xs block bg-background p-2 rounded",children:["First Name, Last Name, Email, Phone, SMS Consent",e.jsx("br",{}),"John, Doe, john@example.com, 555-123-4567, yes",e.jsx("br",{}),"Jane, Smith, jane@example.com, 555-987-6543, true"]}),e.jsx("p",{className:"text-muted-foreground mt-2 text-xs",children:"Phone and SMS Consent columns are optional. SMS Consent accepts: yes/no, true/false, 1/0, y/n."})]})]}),_==="preview"&&e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4",children:[!n&&r&&r.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Assign to Brokerage (optional)"}),e.jsxs($s,{value:u||"none",onValueChange:q=>p(q==="none"?"":q),children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select a brokerage..."})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"none",children:"No brokerage"}),r.map(q=>e.jsx(vt,{value:q.id,children:q.name},q.id))]})]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($n,{className:"h-4 w-4 text-green-500"}),e.jsxs("span",{children:[O," valid"]})]}),V>0&&e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(ro,{className:"h-4 w-4"}),e.jsxs("span",{children:[V," invalid"]})]})]}),e.jsxs("div",{className:"flex-1 overflow-auto border rounded-lg",children:[e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{className:"bg-muted/30",children:[e.jsx(St,{children:"First Name"}),e.jsx(St,{children:"Last Name"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Phone"}),e.jsx(St,{children:"SMS"}),e.jsx(St,{children:"Status"})]})}),e.jsx(Rn,{children:i.slice(0,100).map((q,B)=>e.jsxs(Ps,{children:[e.jsx(ht,{children:q.firstName}),e.jsx(ht,{children:q.lastName}),e.jsx(ht,{children:q.email}),e.jsx(ht,{className:"text-muted-foreground",children:q.phone||"-"}),e.jsx(ht,{className:"text-muted-foreground",children:q.smsConsent===!0?"✓":q.smsConsent===!1?"✗":"-"}),e.jsx(ht,{children:q.isValid?e.jsx(Qe,{variant:"default",className:"bg-green-500/10 text-green-600",children:"Valid"}):e.jsx(Qe,{variant:"destructive",children:q.error||"Invalid"})})]},B))})]}),i.length>100&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-2",children:["Showing first 100 of ",i.length," users"]})]})]}),_==="result"&&N&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx($n,{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:[N.created," agent(s) created and invited"]}),N.failed>0&&e.jsxs("p",{className:"text-destructive mt-1",children:[N.failed," failed to create"]})]}),N.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:[N.errors.slice(0,10).map((q,B)=>e.jsxs("li",{children:["• ",q]},B)),N.errors.length>10&&e.jsxs("li",{children:["...and ",N.errors.length-10," more"]})]})]})]}),e.jsxs(gn,{children:[_==="upload"&&e.jsx(W,{variant:"outline",onClick:C,children:"Cancel"}),_==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(W,{variant:"outline",onClick:S,children:"Back"}),e.jsx(W,{onClick:L,disabled:f||O===0,children:f?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${O} Agent${O!==1?"s":""}`})]}),_==="result"&&e.jsx(W,{onClick:C,children:"Done"})]})]})})};function Zo({sortKey:t,currentSortKey:s,currentDirection:r,onSort:n,children:a,className:o,...l}){const i=s===t;return e.jsx(St,{className:Ot("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(uu,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(Ih,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(td,{className:"h-3.5 w-3.5 shrink-0 opacity-40"})]})})}function sO(t=null,s=null){const[r,n]=k.useState(t),[a,o]=k.useState(s),l=k.useCallback(d=>{r===d?a==="asc"?o("desc"):a==="desc"?(n(null),o(null)):o("asc"):(n(d),o("asc"))},[r,a]),i=k.useCallback((d,u)=>{if(!r||!a||!u[r])return d;const p=u[r];return[...d].sort((f,y)=>{const _=p(f),b=p(y);if(_==null&&b==null)return 0;if(_==null)return 1;if(b==null)return-1;let N;return typeof _=="string"&&typeof b=="string"?N=_.localeCompare(b,void 0,{sensitivity:"base"}):N=_-b,a==="asc"?N:-N})},[r,a]);return{sortKey:r,sortDirection:a,handleSort:l,sortData:i}}const gVt=[{type:"custom",title:"Great job!",message:"Keep up the amazing work!",icon:Gn},{type:"custom",title:"You're on fire!",message:"Your dedication is inspiring!",icon:Fi},{type:"custom",title:"Congratulations!",message:"You earned this celebration!",icon:qd}];function htt({open:t,onOpenChange:s,userId:r,userName:n}){const[a,o]=k.useState("custom"),[l,i]=k.useState(""),[d,u]=k.useState(""),p=xNt(),f=_=>{o(_.type),i(_.title),u(_.message)},y=async _=>{if(_.preventDefault(),!l.trim()){fn({title:"Title required",description:"Please enter a celebration title",variant:"destructive"});return}try{await p.mutateAsync({user_id:r,celebration_type:a,title:l.trim(),message:d.trim()||void 0}),fn({title:"Celebration sent! 🎉",description:`${n} will see confetti on their next visit!`}),s(!1),i(""),u(""),o("custom")}catch{fn({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(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(qd,{className:"h-5 w-5 text-primary"}),"Send Celebration to ",n]}),e.jsx(Ir,{children:"They'll see confetti and this message next time they log in!"})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx(xe,{className:"text-sm text-muted-foreground mb-2 block",children:"Quick presets:"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:gVt.map((_,b)=>e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>f(_),className:"text-xs",children:[e.jsx(_.icon,{className:"h-3 w-3 mr-1"}),_.title]},b))})]}),e.jsxs("form",{onSubmit:y,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"type",children:"Celebration Type"}),e.jsxs($s,{value:a,onValueChange:_=>o(_),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"custom",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Gn,{className:"h-4 w-4"})," Custom"]})}),e.jsx(vt,{value:"points_earned",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fi,{className:"h-4 w-4"})," Points Earned"]})}),e.jsx(vt,{value:"listing_created",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mn,{className:"h-4 w-4"})," Listing Created"]})}),e.jsx(vt,{value:"deal_closed",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_c,{className:"h-4 w-4"})," Deal Closed"]})})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"title",children:"Title *"}),e.jsx(De,{id:"title",value:l,onChange:_=>i(_.target.value),placeholder:"e.g., Congratulations!",maxLength:100})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"message",children:"Message (optional)"}),e.jsx(_r,{id:"message",value:d,onChange:_=>u(_.target.value),placeholder:"Add a personal message...",rows:3,maxLength:500})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(W,{type:"submit",disabled:p.isPending,children:[e.jsx(qd,{className:"h-4 w-4 mr-2"}),p.isPending?"Sending...":"Send Celebration"]})]})]})]})})}const Sye={points_earned:{label:"Points Earned",icon:Fi,color:"bg-yellow-500"},listing_created:{label:"Listing Created",icon:Mn,color:"bg-blue-500"},deal_closed:{label:"Deal Closed",icon:_c,color:"bg-green-500"},custom:{label:"Custom",icon:Or,color:"bg-purple-500"}};function yVt(){const[t,s]=k.useState(""),[r,n]=k.useState("all"),[a,o]=k.useState("all"),{data:l=[],isLoading:i}=gt({queryKey:["admin-celebrations"],queryFn:async()=>{const{data:p,error:f}=await G.from("celebration_queue").select("*").order("created_at",{ascending:!1}).limit(500);if(f)throw f;const y=[...new Set([...p.map(N=>N.user_id),...p.map(N=>N.created_by).filter(Boolean)])],{data:_}=await G.from("profiles").select("id, name, email").in("id",y),b=new Map((_==null?void 0:_.map(N=>[N.id,N]))||[]);return p.map(N=>{var w,S,C;return{...N,user_name:((w=b.get(N.user_id))==null?void 0:w.name)||"Unknown",user_email:((S=b.get(N.user_id))==null?void 0:S.email)||"",creator_name:N.created_by?((C=b.get(N.created_by))==null?void 0:C.name)||"System":"Auto-triggered"}})}}),d=l.filter(p=>{var b,N;const f=((b=p.user_name)==null?void 0:b.toLowerCase().includes(t.toLowerCase()))||((N=p.user_email)==null?void 0:N.toLowerCase().includes(t.toLowerCase()))||p.title.toLowerCase().includes(t.toLowerCase()),y=r==="all"||p.celebration_type===r,_=a==="all"||a==="seen"&&p.seen_at||a==="unseen"&&!p.seen_at;return f&&y&&_}),u={total:l.length,seen:l.filter(p=>p.seen_at).length,unseen:l.filter(p=>!p.seen_at).length,byType:Object.keys(Sye).reduce((p,f)=>(p[f]=l.filter(y=>y.celebration_type===f).length,p),{})};return i?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(us,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium",children:"Total Celebrations"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:u.total})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-green-600",children:"Seen"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold text-green-600",children:u.seen})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-orange-600",children:"Pending"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold text-orange-600",children:u.unseen})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-purple-600",children:"Custom Sent"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold text-purple-600",children:u.byType.custom||0})})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(qd,{className:"h-5 w-5"}),"Celebration History"]}),e.jsx(dr,{children:"View all celebrations awarded to agents"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by agent name, email, or title...",value:t,onChange:p=>s(p.target.value),className:"pl-9"})]}),e.jsxs($s,{value:r,onValueChange:n,children:[e.jsx(zs,{className:"w-[180px]",children:e.jsx(Vs,{placeholder:"Filter by type"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Types"}),Object.entries(Sye).map(([p,f])=>e.jsx(vt,{value:p,children:f.label},p))]})]}),e.jsxs($s,{value:a,onValueChange:o,children:[e.jsx(zs,{className:"w-[140px]",children:e.jsx(Vs,{placeholder:"Status"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Status"}),e.jsx(vt,{value:"seen",children:"Seen"}),e.jsx(vt,{value:"unseen",children:"Pending"})]})]})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Type"}),e.jsx(St,{children:"Agent"}),e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Points"}),e.jsx(St,{children:"Created By"}),e.jsx(St,{children:"Created"}),e.jsx(St,{children:"Status"})]})}),e.jsx(Rn,{children:d.length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No celebrations found"})}):d.map(p=>{const f=Sye[p.celebration_type],y=f.icon;return e.jsxs(Ps,{children:[e.jsx(ht,{children:e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(y,{className:"h-3 w-3"}),f.label]})}),e.jsx(ht,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:p.user_name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:p.user_email})]})}),e.jsx(ht,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:p.title}),p.message&&e.jsx("div",{className:"text-xs text-muted-foreground truncate max-w-[200px]",children:p.message})]})}),e.jsx(ht,{children:p.points_amount?e.jsxs(Qe,{variant:"secondary",children:["+",p.points_amount]}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(ht,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:p.creator_name})}),e.jsx(ht,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:vs(new Date(p.created_at),"MMM d, yyyy h:mm a")})}),e.jsx(ht,{children:p.seen_at?e.jsx(Qe,{variant:"outline",className:"bg-green-50 text-green-700 border-green-200",children:"Seen"}):e.jsx(Qe,{variant:"outline",className:"bg-orange-50 text-orange-700 border-orange-200",children:"Pending"})})]},p.id)})})]})}),d.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground text-right",children:["Showing ",d.length," of ",l.length," celebrations"]})]})]})]})}const vVt=()=>{const{user:t}=Us(),{toast:s}=ja(),[r,n]=k.useState([]),[a,o]=k.useState(!0),[l,i]=k.useState(!1),[d,u]=k.useState("all"),[p,f]=k.useState("all"),[y,_]=k.useState("new"),[b,N]=k.useState(new Set),w=k.useCallback(async()=>{try{o(!0);const{data:J,error:X}=await G.from("profiles").select("id, name, email, phone, is_trial, trial_started_at, trial_expires_at, subscription_status, subscription_end_date, converted_from_trial_at, created_at").or("is_trial.eq.true,subscription_status.eq.trialing,converted_from_trial_at.not.is.null");if(X)throw X;const{data:ce,error:ie}=await G.from("trial_email_exports").select("user_id");if(ie)throw ie;const ae=new Set((ce||[]).map(me=>me.user_id)),oe=(J||[]).map(me=>({...me,converted_from_trial_at:me.converted_from_trial_at??null,already_exported:ae.has(me.id)}));oe.sort((me,ve)=>new Date(ve.created_at).getTime()-new Date(me.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(()=>{w()},[w]);const S=J=>J.trial_started_at?"ghl":"stripe",C=J=>J.trial_expires_at?J.trial_expires_at:J.subscription_end_date?J.subscription_end_date:null,A=J=>J.converted_from_trial_at!==null,I=J=>{if(A(J))return!1;const X=C(J);return X?new Date(X).getTime()<=Date.now():!1},L=r.filter(J=>!(d!=="all"&&S(J)!==d||p==="active"&&(I(J)||A(J))||p==="expired"&&!I(J)||p==="converted"&&!A(J)||y==="new"&&J.already_exported||y==="exported"&&!J.already_exported)),O=()=>{b.size===L.length?N(new Set):N(new Set(L.map(J=>J.id)))},V=J=>{const X=new Set(b);X.has(J)?X.delete(J):X.add(J),N(X)},q=async()=>{if(b.size===0){s({title:"No users selected",description:"Select users to export",variant:"destructive"});return}i(!0);try{const J=r.filter(he=>b.has(he.id)),X="First Name,Last Name,Email,Phone,Trial Type,Status,Signup Date,Expiry Date",ce=J.map(he=>{const ge=(he.name||"").split(" "),je=ge[0]||"",qe=ge.slice(1).join(" ")||"",Me=S(he)==="stripe"?"Credit Card Trial":"Free Trial (No CC)",ke=A(he)?"Converted":I(he)?"Expired":"Active",Re=he.created_at?new Date(he.created_at).toLocaleDateString():"",Ve=C(he)?new Date(C(he)).toLocaleDateString():"";return`"${je}","${qe}","${he.email}","${he.phone||""}","${Me}","${ke}","${Re}","${Ve}"`}),ie=[X,...ce].join(` `),ae=new Blob([ie],{type:"text/csv"}),oe=URL.createObjectURL(ae),me=document.createElement("a");me.href=oe,me.download=`trial-users-${new Date().toISOString().split("T")[0]}.csv`,me.click(),URL.revokeObjectURL(oe);const ve=J.filter(he=>!he.already_exported).map(he=>({user_id:he.id,exported_by:t.id}));if(ve.length>0){const{error:he}=await G.from("trial_email_exports").upsert(ve,{onConflict:"user_id"});he&&console.error("Error marking exports:",he)}s({title:"Export complete",description:`Downloaded ${J.length} trial user(s). ${ve.length} newly marked as exported.`}),N(new Set),w()}catch(J){console.error("Export error:",J),s({title:"Error",description:"Failed to export",variant:"destructive"})}finally{i(!1)}},B=r.filter(J=>!J.already_exported).length,U=r.filter(J=>J.already_exported).length,te=r.filter(J=>A(J)).length,Y=r.filter(J=>!I(J)&&!A(J)).length;return a?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(us,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-4",children:[e.jsx(Pe,{children:e.jsxs(Dt,{className:"pb-2",children:[e.jsx(dr,{children:"Total"}),e.jsx(zt,{className:"text-2xl",children:r.length})]})}),e.jsx(Pe,{children:e.jsxs(Dt,{className:"pb-2",children:[e.jsx(dr,{children:"New (Not Exported)"}),e.jsx(zt,{className:"text-2xl text-green-600",children:B})]})}),e.jsx(Pe,{children:e.jsxs(Dt,{className:"pb-2",children:[e.jsx(dr,{children:"Active Trials"}),e.jsx(zt,{className:"text-2xl",children:Y})]})}),e.jsx(Pe,{children:e.jsxs(Dt,{className:"pb-2",children:[e.jsx(dr,{children:"Converted 🎉"}),e.jsx(zt,{className:"text-2xl text-primary",children:te})]})}),e.jsx(Pe,{children:e.jsxs(Dt,{className:"pb-2",children:[e.jsx(dr,{children:"Already Exported"}),e.jsx(zt,{className:"text-2xl text-muted-foreground",children:U})]})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs($s,{value:y,onValueChange:J=>_(J),children:[e.jsx(zs,{className:"w-[160px]",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Users"}),e.jsx(vt,{value:"new",children:"New Only"}),e.jsx(vt,{value:"exported",children:"Already Exported"})]})]}),e.jsxs($s,{value:d,onValueChange:J=>u(J),children:[e.jsx(zs,{className:"w-[180px]",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Trial Types"}),e.jsx(vt,{value:"stripe",children:"Credit Card Trial"}),e.jsx(vt,{value:"ghl",children:"Free Trial (No CC)"})]})]}),e.jsxs($s,{value:p,onValueChange:J=>f(J),children:[e.jsx(zs,{className:"w-[160px]",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Statuses"}),e.jsx(vt,{value:"active",children:"Active Trial"}),e.jsx(vt,{value:"expired",children:"Expired"}),e.jsx(vt,{value:"converted",children:"Converted ✓"})]})]}),e.jsx("div",{className:"ml-auto",children:e.jsxs(W,{onClick:q,disabled:l||b.size===0,children:[l?e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Qa,{className:"h-4 w-4 mr-2"}),"Export Selected (",b.size,")"]})})]}),e.jsx("div",{className:"border rounded-lg",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(St,{className:"w-[40px]",children:e.jsx(Ri,{checked:L.length>0&&b.size===L.length,onCheckedChange:O})}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Trial Type"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Signup Date"}),e.jsx(St,{children:"Expires / Renews"}),e.jsx(St,{children:"Exported"})]})}),e.jsx(Rn,{children:L.length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"No trial users match the current filters"})}):L.map(J=>{const X=S(J),ce=A(J),ie=I(J),ae=C(J);return e.jsxs(Ps,{className:`hover:bg-muted/30 ${ce?"bg-primary/5":""}`,children:[e.jsx(ht,{children:e.jsx(Ri,{checked:b.has(J.id),onCheckedChange:()=>V(J.id)})}),e.jsx(ht,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[J.name,ce&&e.jsx(Qo,{className:"h-3.5 w-3.5 text-primary"})]})}),e.jsx(ht,{className:"text-muted-foreground",children:J.email}),e.jsx(ht,{children:X==="stripe"?e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(yx,{className:"h-3 w-3"}),"Credit Card"]}):e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[e.jsx(tr,{className:"h-3 w-3"}),"Free (No CC)"]})}),e.jsx(ht,{children:ce?e.jsxs(Qe,{className:"bg-primary/10 text-primary hover:bg-primary/20 gap-1",children:[e.jsx(Qo,{className:"h-3 w-3"}),"Converted"]}):ie?e.jsx(Qe,{variant:"destructive",children:"Expired"}):e.jsx(Qe,{className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active Trial"})}),e.jsx(ht,{className:"text-sm",children:J.created_at?new Date(J.created_at).toLocaleDateString():"—"}),e.jsx(ht,{className:"text-sm",children:ce&&ae?e.jsxs("span",{className:"text-muted-foreground",children:["Renews ",new Date(ae).toLocaleDateString()]}):ae?new Date(ae).toLocaleDateString():"—"}),e.jsx(ht,{children:J.already_exported?e.jsx($n,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Qe,{variant:"outline",className:"text-green-600 border-green-300",children:"New"})})]},J.id)})})]})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",L.length," of ",r.length," trial users · ",te," converted to paid"]})]})},_Vt=()=>{const[t,s]=k.useState([]),[r,n]=k.useState(!0);return k.useEffect(()=>{(async()=>{const{data:o,error:l}=await G.from("user_deletion_log").select("*").order("created_at",{ascending:!1});!l&&o&&s(o),n(!1)})()},[]),r?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(us,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):t.length===0?e.jsx(Pe,{children:e.jsxs(Oe,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(vr,{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(Dt,{children:e.jsx(zt,{className:"text-lg",children:"User Deletion History"})}),e.jsx(Oe,{children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Date"}),e.jsx(St,{children:"User"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Brokerage"}),e.jsx(St,{children:"Type"}),e.jsx(St,{children:"Deleted By"})]})}),e.jsx(Rn,{children:t.map(a=>e.jsxs(Ps,{children:[e.jsx(ht,{className:"whitespace-nowrap text-sm",children:vs(new Date(a.created_at),"MMM d, yyyy h:mm a")}),e.jsx(ht,{className:"font-medium",children:a.deleted_user_name||"—"}),e.jsx(ht,{className:"text-sm text-muted-foreground",children:a.deleted_user_email||"—"}),e.jsx(ht,{children:a.brokerage_name||"—"}),e.jsx(ht,{children:e.jsx(Qe,{variant:a.deletion_type==="deleted"?"destructive":"secondary",children:a.deletion_type==="deleted"?"Account Deleted":"Removed"})}),e.jsx(ht,{className:"text-sm",children:a.deleted_by_name||a.deleted_by_email||"—"})]},a.id))})]})})]})},TC=t=>{const{user:s}=Us(),r=Qt(),n=gt({queryKey:["teams",t],queryFn:async()=>{let f=G.from("teams").select("*").order("created_at",{ascending:!1});t&&(f=f.eq("brokerage_id",t));const{data:y,error:_}=await f;if(_)throw _;return y||[]},enabled:!!s}),a=f=>gt({queryKey:["team-members",f],queryFn:async()=>{const{data:y,error:_}=await G.from("team_members").select("*").eq("team_id",f).order("role",{ascending:!0});if(_)throw _;const b=(y||[]).map(S=>S.user_id),{data:N}=await G.from("profiles").select("id, name, email, avatar_url").in("id",b),w=new Map((N||[]).map(S=>[S.id,S]));return(y||[]).map(S=>({...S,profile:w.get(S.user_id)||null}))},enabled:!!f}),o=Pt({mutationFn:async f=>{const y={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&&(y.brokerage_id=f.brokerage_id);const{data:_,error:b}=await G.from("teams").insert(y).select().single();if(b)throw b;return _},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),pe.success("Team created!")},onError:f=>{pe.error("Failed to create team: "+f.message)}}),l=Pt({mutationFn:async({id:f,...y})=>{const{data:_,error:b}=await G.from("teams").update(y).eq("id",f).select().single();if(b)throw b;return _},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),pe.success("Team updated")},onError:f=>{pe.error("Failed to update team: "+f.message)}}),i=Pt({mutationFn:async f=>{const{error:y}=await G.from("teams").delete().eq("id",f);if(y)throw y},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),pe.success("Team deleted")},onError:f=>{pe.error("Failed to delete team: "+f.message)}}),d=Pt({mutationFn:async f=>{const{data:y,error:_}=await G.from("team_members").insert({team_id:f.team_id,user_id:f.user_id,role:f.role||"team_member"}).select().single();if(_)throw _.message.includes("duplicate")||_.message.includes("unique")?new Error("This agent is already on a team. They must be removed from their current team first."):_;return y},onSuccess:(f,y)=>{r.invalidateQueries({queryKey:["team-members",y.team_id]}),pe.success("Member added to team")},onError:f=>{pe.error(f.message)}}),u=Pt({mutationFn:async f=>{const{error:y}=await G.from("team_members").delete().eq("id",f.member_id);if(y)throw y},onSuccess:(f,y)=>{r.invalidateQueries({queryKey:["team-members",y.team_id]}),pe.success("Member removed from team")},onError:f=>{pe.error("Failed to remove member: "+f.message)}}),p=Pt({mutationFn:async f=>{const{error:y}=await G.from("team_members").update({role:f.role}).eq("id",f.member_id);if(y)throw y},onSuccess:(f,y)=>{r.invalidateQueries({queryKey:["team-members",y.team_id]}),pe.success("Member role updated")},onError:f=>{pe.error("Failed to update role: "+f.message)}});return{teams:n.data||[],isLoading:n.isLoading,createTeam:o,updateTeam:l,deleteTeam:i,addMember:d,removeMember:u,updateMemberRole:p,useTeamMembers:a}},bVt=()=>{const{user:t}=Us();return gt({queryKey:["team-contacts",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.rpc("get_team_contacts",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})},mtt=t=>{const{user:s}=Us(),r=Qt(),n=gt({queryKey:["lead-pond",t],queryFn:async()=>{const{data:i,error:d}=await G.from("team_lead_pond").select("*").eq("team_id",t).order("created_at",{ascending:!1});if(d)throw d;if(!i||i.length===0)return[];const u=i.map(S=>S.contact_id),p=[...new Set(i.map(S=>S.added_by))],f=i.filter(S=>S.claimed_by).map(S=>S.claimed_by),y=[...new Set([...p,...f])],[_,b]=await Promise.all([G.from("innercircle_contacts").select("id, first_name, last_name, email, phone").in("id",u),G.from("profiles").select("id, name, avatar_url").in("id",y)]),N=new Map((_.data||[]).map(S=>[S.id,S])),w=new Map((b.data||[]).map(S=>[S.id,S]));return i.map(S=>({...S,status:S.claimed_by?"claimed":"available",contact:N.get(S.contact_id)||null,contributor:w.get(S.added_by)||null,claimer:S.claimed_by&&w.get(S.claimed_by)||null}))},enabled:!!t&&!!s}),a=Pt({mutationFn:async i=>{const{data:d,error:u}=await G.rpc("add_to_lead_pond",{_contact_id:i.contact_id,_team_id:i.team_id,_notes:i.notes||null});if(u)throw u;return d},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),pe.success("Contact added to Lead Pond")},onError:i=>{pe.error(i.message)}}),o=Pt({mutationFn:async i=>{const{error:d}=await G.rpc("claim_lead_pond_contact",{_lead_pond_id:i});if(d)throw d},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),pe.success("Lead claimed!")},onError:i=>{pe.error(i.message)}}),l=Pt({mutationFn:async i=>{const{error:d}=await G.rpc("return_lead_pond_contact",{_lead_pond_id:i});if(d)throw d},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),pe.success("Lead returned to pond")},onError:i=>{pe.error(i.message)}});return{leadPondItems:n.data||[],isLoading:n.isLoading,addToLeadPond:a,claimLead:o,returnLead:l}},wVt=()=>{const t=Qt();return Pt({mutationFn:async s=>{const{data:r,error:n}=await G.rpc("transfer_contact",{_contact_id:s.contactId,_to_user_id:s.toUserId,_notes:s.notes||null});if(n)throw n;const a=r;if(!a.success)throw new Error(a.error);return a},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["team-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),pe.success("Contact transferred successfully")},onError:s=>{pe.error(s.message||"Failed to transfer contact")}})};function ptt({open:t,onOpenChange:s,contactIds:r,contactNames:n=[],onComplete:a}){var L;const{user:o}=Us(),{data:l}=Px(),{useTeamMembers:i}=TC(),{data:d=[]}=i((l==null?void 0:l.teamId)||""),u=wVt(),[p,f]=k.useState(null),[y,_]=k.useState(""),[b,N]=k.useState(!1),w=d.filter(O=>O.user_id!==(o==null?void 0:o.id)),S=async()=>{if(p){N(!0);try{for(const O of r)await u.mutateAsync({contactId:O,toUserId:p,notes:y||void 0});s(!1),f(null),_(""),a==null||a()}catch{}finally{N(!1)}}},C=w.find(O=>O.user_id===p),A=r.length>1,I=n.length>0?A?`${n.length} contacts`:n[0]:A?`${r.length} contacts`:"this contact";return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(Gv,{className:"h-5 w-5"}),"Transfer ",I]}),e.jsxs(Ir,{children:["Select a team member to transfer ",A?"these contacts":"this contact"," to. The contact will be removed from the current owner's CRM and added to the selected member's."]})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm font-medium mb-2 block",children:"Transfer to:"}),e.jsx("div",{className:"space-y-1 max-h-[240px] overflow-y-auto",children:w.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No other team members available"}):w.map(O=>{var V,q,B;return e.jsxs("button",{onClick:()=>f(O.user_id),className:`w-full flex items-center gap-3 p-3 rounded-lg text-left transition-colors ${p===O.user_id?"bg-primary/10 border border-primary/30":"hover:bg-accent border border-transparent"}`,children:[e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:((V=O.profile)==null?void 0:V.avatar_url)||""}),e.jsx(kn,{className:"text-xs",children:(((q=O.profile)==null?void 0:q.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:((B=O.profile)==null?void 0:B.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:O.role.replace("_"," ")})]})]},O.user_id)})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"transfer-notes",className:"text-sm font-medium",children:"Notes (optional)"}),e.jsx(_r,{id:"transfer-notes",value:y,onChange:O=>_(O.target.value),placeholder:"Reason for transfer...",className:"mt-1",rows:2})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(W,{onClick:S,disabled:!p||b,children:[b?e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Gv,{className:"h-4 w-4 mr-2"}),"Transfer",C?` to ${(L=C.profile)==null?void 0:L.name}`:""]})]})]})})}const m4e=()=>{const t=wr(),{data:s,isLoading:r}=bVt(),{data:n}=Px(),[a,o]=k.useState(""),[l,i]=k.useState("all"),[d,u]=k.useState(null),[p,f]=k.useState(""),y=(n==null?void 0:n.role)==="team_leader",_=k.useMemo(()=>{if(!s)return[];const N=new Map;return s.forEach(w=>{N.has(w.owner_user_id)||N.set(w.owner_user_id,{id:w.owner_user_id,name:w.owner_name||"Unknown",avatar:w.owner_avatar_url})}),Array.from(N.values())},[s]),b=k.useMemo(()=>{if(!s)return[];let N=s;if(l!=="all"&&(N=N.filter(w=>w.owner_user_id===l)),a.trim()){const w=a.toLowerCase();N=N.filter(S=>{var C,A,I;return(S.first_name+" "+(S.last_name||"")).toLowerCase().includes(w)||((C=S.email)==null?void 0:C.toLowerCase().includes(w))||((A=S.phone)==null?void 0:A.includes(w))||((I=S.owner_name)==null?void 0:I.toLowerCase().includes(w))})}return N},[s,a,l]);return r?e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ms,{className:"h-10 w-full"}),e.jsx(Ms,{className:"h-64 w-full"})]}):!s||s.length===0?e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(ir,{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(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name, email, phone, or agent...",value:a,onChange:N=>o(N.target.value),className:"pl-9"})]}),e.jsxs($s,{value:l,onValueChange:i,children:[e.jsx(zs,{className:"w-[200px]",children:e.jsx(Vs,{placeholder:"Filter by agent"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Team Members"}),_.map(N=>e.jsx(vt,{value:N.id,children:N.name},N.id))]})]})]})})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[b.length," contact",b.length!==1?"s":""," from ",_.length," teammate",_.length!==1?"s":""]}),e.jsx(Pe,{children:e.jsx(Oe,{className:"p-0 overflow-x-auto",children:e.jsxs(Ln,{className:"min-w-[800px]",children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Agent"}),e.jsx(St,{children:"Contact Info"}),e.jsx(St,{children:"Address"}),e.jsx(St,{children:"Lead Source"}),e.jsx(St,{children:"Date Added"}),y&&e.jsx(St,{className:"w-[80px]",children:"Actions"})]})}),e.jsx(Rn,{children:b.length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:y?7:6,className:"text-center py-8 text-muted-foreground",children:a||l!=="all"?"No contacts match your filters":"No team contacts available"})}):b.map(N=>e.jsxs(Ps,{className:`hover:bg-accent/50 ${y?"cursor-pointer":""}`,onClick:y?()=>t(`/mission-control/contacts/${N.id}`):void 0,children:[e.jsx(ht,{className:"font-medium",children:e.jsxs("span",{className:y?"hover:text-primary hover:underline transition-colors":"",children:[N.first_name," ",N.last_name||""]})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Nn,{className:"h-6 w-6",children:[e.jsx(Ma,{src:N.owner_avatar_url||""}),e.jsx(kn,{className:"text-[10px]",children:(N.owner_name||"?").charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-sm text-muted-foreground truncate max-w-[120px]",children:N.owner_name||"Unknown"})]})}),e.jsx(ht,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[N.email&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(tr,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:N.email})]}),N.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(In,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:N.phone})]}),!N.email&&!N.phone&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"No contact info"})]})}),e.jsx(ht,{children:N.address?e.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(Ia,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate max-w-[180px]",children:N.address})]}):e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),e.jsx(ht,{children:N.lead_source?e.jsx(Qe,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:N.lead_source}):e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),e.jsx(ht,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:vs(new Date(N.created_at),"MMM d, yyyy")})}),y&&e.jsx(ht,{children:e.jsx(W,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:w=>{w.stopPropagation(),u(N.id),f(`${N.first_name} ${N.last_name||""}`.trim())},title:"Transfer to team member",children:e.jsx(Gv,{className:"h-4 w-4"})})})]},N.id))})]})})}),e.jsx(ptt,{open:!!d,onOpenChange:N=>{N||u(null)},contactIds:d?[d]:[],contactNames:p?[p]:[],onComplete:()=>u(null)})]})},p4e=({teamId:t})=>{const{user:s}=Us(),{leadPondItems:r,isLoading:n,claimLead:a,returnLead:o}=mtt(t);if(console.log("[LeadPondView] render — teamId:",t,"itemCount:",r.length,"loading:",n),n)return e.jsx("div",{className:"space-y-3",children:[1,2,3].map(d=>e.jsx(Ms,{className:"h-20 w-full"},d))});if(r.length===0)return e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Ag,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Lead Pond is Empty"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Team members can contribute contacts here for others to claim and follow up with."})]})});const l=r.filter(d=>d.status==="available"),i=r.filter(d=>d.status==="claimed");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground mb-3",children:["Available (",l.length,")"]}),l.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No leads available right now."}):e.jsx("div",{className:"space-y-2",children:l.map(d=>{var u,p,f,y,_,b,N;return e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(u=d.contact)==null?void 0:u.first_name," ",((p=d.contact)==null?void 0:p.last_name)||""]}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 mt-1",children:[((f=d.contact)==null?void 0:f.email)&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(tr,{className:"h-3 w-3"})," ",d.contact.email]}),((y=d.contact)==null?void 0:y.phone)&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(In,{className:"h-3 w-3"})," ",d.contact.phone]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsxs(Nn,{className:"h-4 w-4",children:[e.jsx(Ma,{src:((_=d.contributor)==null?void 0:_.avatar_url)||""}),e.jsx(kn,{className:"text-[8px]",children:(((b=d.contributor)==null?void 0:b.name)||"?").charAt(0)})]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["from ",((N=d.contributor)==null?void 0:N.name)||"Unknown"]})]})]}),e.jsxs(W,{size:"sm",onClick:()=>a.mutate(d.id),disabled:a.isPending,children:[e.jsx(xL,{className:"mr-1 h-3 w-3"}),"Claim"]})]})},d.id)})})]}),i.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground mb-3",children:["Claimed (",i.length,")"]}),e.jsx("div",{className:"space-y-2",children:i.map(d=>{var u,p,f;return e.jsx(Pe,{className:"opacity-75",children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(u=d.contact)==null?void 0:u.first_name," ",((p=d.contact)==null?void 0:p.last_name)||""]}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs(Qe,{variant:"secondary",className:"text-xs",children:["Claimed by ",((f=d.claimer)==null?void 0:f.name)||"Unknown"]})})]}),d.claimed_by===(s==null?void 0:s.id)&&e.jsxs(W,{size:"sm",variant:"outline",onClick:()=>o.mutate(d.id),disabled:o.isPending,children:[e.jsx(t0,{className:"mr-1 h-3 w-3"}),"Return"]})]})},d.id)})})]})]})},ftt=({teamId:t})=>{const{useTeamMembers:s}=TC(),{data:r=[]}=s(t),n=r.map(_=>_.user_id),a=new Map(r.map(_=>[_.user_id,_.profile])),{data:o=[],isLoading:l}=gt({queryKey:["team-shared-presentations",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:_,error:b}=await G.from("smart_presentations").select("id, owner_user_id, title, client_name, status, view_count, cta_clicked_count, share_token, created_at, published_at").in("owner_user_id",n).neq("status","archived").order("created_at",{ascending:!1});if(b)throw b;return _||[]},enabled:n.length>0}),{data:i=[],isLoading:d}=gt({queryKey:["team-shared-open-houses",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:_,error:b}=await G.from("open_houses").select("id, agent_id, property_address, city, state, event_date, is_active, visitor_count, slug, created_at").in("agent_id",n).order("event_date",{ascending:!1});if(b)throw b;return _||[]},enabled:n.length>0}),{data:u=[],isLoading:p}=gt({queryKey:["team-shared-videos",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:_,error:b}=await G.from("agent_videos").select("id, owner_user_id, title, recipient_name, status, view_count, touch_type, share_token, created_at").in("owner_user_id",n).eq("is_deleted",!1).order("created_at",{ascending:!1}).limit(50);if(b)throw b;return _||[]},enabled:n.length>0});if(l||d||p)return e.jsx("div",{className:"space-y-3",children:[1,2,3].map(_=>e.jsx(Ms,{className:"h-20 w-full"},_))});const y=_=>{const b=a.get(_);return{name:(b==null?void 0:b.name)||"Unknown",avatar:(b==null?void 0:b.avatar_url)||"",initials:((b==null?void 0:b.name)||"?").charAt(0).toUpperCase()}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 grid-cols-3",children:[e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsx(Pg,{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(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsx(Mn,{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(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsx(yn,{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(ta,{defaultValue:"presentations",className:"space-y-4",children:[e.jsxs(Jn,{children:[e.jsxs(cs,{value:"presentations",children:["Presentations (",o.length,")"]}),e.jsxs(cs,{value:"guest-books",children:["Guest Books (",i.length,")"]}),e.jsxs(cs,{value:"videos",children:["Videos (",u.length,")"]})]}),e.jsx(Ss,{value:"presentations",className:"space-y-2",children:o.length===0?e.jsx(Cye,{icon:e.jsx(Pg,{className:"h-10 w-10"}),label:"No presentations yet"}):o.map(_=>{const b=y(_.owner_user_id);return e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(Nn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Ma,{src:b.avatar}),e.jsx(kn,{className:"text-xs",children:b.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:_.title||"Untitled"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[b.name," · ",vs(new Date(_.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(Qe,{variant:_.status==="published"?"default":"secondary",className:"text-xs capitalize",children:_.status}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(jn,{className:"h-3 w-3"}),_.view_count||0]})]})]})},_.id)})}),e.jsx(Ss,{value:"guest-books",className:"space-y-2",children:i.length===0?e.jsx(Cye,{icon:e.jsx(Mn,{className:"h-10 w-10"}),label:"No guest books yet"}):i.map(_=>{const b=y(_.agent_id);return e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(Nn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Ma,{src:b.avatar}),e.jsx(kn,{className:"text-xs",children:b.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:_.property_address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[b.name," · ",vs(new Date(_.event_date),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[_.is_active?e.jsx(Qe,{className:"text-xs",children:"Active"}):e.jsx(Qe,{variant:"secondary",className:"text-xs",children:"Inactive"}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(ir,{className:"h-3 w-3"}),_.visitor_count||0]})]})]})},_.id)})}),e.jsx(Ss,{value:"videos",className:"space-y-2",children:u.length===0?e.jsx(Cye,{icon:e.jsx(yn,{className:"h-10 w-10"}),label:"No videos yet"}):u.map(_=>{const b=y(_.owner_user_id);return e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(Nn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Ma,{src:b.avatar}),e.jsx(kn,{className:"text-xs",children:b.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:_.title||_.recipient_name||"Untitled Video"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[b.name," · ",vs(new Date(_.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(Qe,{variant:"secondary",className:"text-xs capitalize",children:_.touch_type}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(jn,{className:"h-3 w-3"}),_.view_count||0]})]})]})},_.id)})})]})]})},Cye=({icon:t,label:s})=>e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-8 text-center text-muted-foreground",children:[t,e.jsx("p",{className:"mt-2 text-sm",children:s})]})}),xtt=({team:t,brokerageAgents:s,onBack:r,onUpdate:n,onAddMember:a,onRemoveMember:o,onUpdateRole:l,onDeleteTeam:i,isUpdating:d,isAddingMember:u})=>{var V,q;const{useTeamMembers:p}=TC(),{data:f=[],isLoading:y}=p(t.id),[_,b]=k.useState(!1),[N,w]=k.useState(""),[S,C]=k.useState("team_member"),{data:A}=gt({queryKey:["agents-on-other-teams",t.id],queryFn:async()=>{const{data:B}=await G.from("team_members").select("user_id, team_id, teams:team_id(name)").neq("team_id",t.id),U=new Map;return(B||[]).forEach(te=>{var Y;U.set(te.user_id,((Y=te.teams)==null?void 0:Y.name)||"another team")}),U}}),I=new Set(f.map(B=>B.user_id)),L=s.filter(B=>!I.has(B.id)),O=async()=>{N&&(await a(N,S),w(""),C("team_member"),b(!1))};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(W,{variant:"ghost",onClick:r,className:"mb-2",children:"← Back to Teams"}),e.jsxs(ta,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(Jn,{children:[e.jsx(cs,{value:"members",children:"Members"}),e.jsxs(cs,{value:"contacts",children:[e.jsx(Q4,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),t.lead_pond_enabled&&e.jsxs(cs,{value:"lead-pond",children:[e.jsx(Ag,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),t.shared_assets_enabled&&e.jsxs(cs,{value:"shared-assets",children:[e.jsx(Mm,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]}),e.jsx(cs,{value:"settings",children:"Settings"})]}),e.jsxs(Ss,{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:_,onOpenChange:b,children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{size:"sm",children:[e.jsx(Jo,{className:"mr-2 h-4 w-4"}),"Add Member"]})}),e.jsxs(ps,{children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Add Team Member"}),e.jsxs(Ir,{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(xe,{children:"Agent"}),e.jsxs(mo,{children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[N&&(((V=L.find(B=>B.id===N))==null?void 0:V.name)||((q=L.find(B=>B.id===N))==null?void 0:q.email))||"Select an agent",e.jsx(gx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(no,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Sx,{children:[e.jsx(Cx,{placeholder:"Search agents..."}),e.jsxs(Mx,{children:[e.jsx(Tx,{children:"No agents found."}),e.jsx(Ax,{children:L.map(B=>{const U=A==null?void 0:A.get(B.id);return e.jsxs(cp,{value:B.name||B.email||B.id,disabled:!!U,onSelect:()=>w(B.id),children:[e.jsx(Zn,{className:Ot("mr-2 h-4 w-4",N===B.id?"opacity-100":"opacity-0")}),B.name||B.email,U&&e.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["(on ",U,")"]})]},B.id)})})]})]})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Role"}),e.jsxs($s,{value:S,onValueChange:C,children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"team_leader",children:"Team Leader"}),e.jsx(vt,{value:"team_member",children:"Team Member"})]})]})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>b(!1),children:"Cancel"}),e.jsx(W,{onClick:O,disabled:!N||u,children:u?"Adding...":"Add to Team"})]})]})]})]}),y?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(B=>e.jsx(Ms,{className:"h-16 w-full"},B))}):f.length===0?e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(ir,{className:"h-10 w-10 text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No members yet. Add agents to this team."})]})}):e.jsx("div",{className:"space-y-2",children:f.map(B=>{var U,te,Y,J,X;return e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:((U=B.profile)==null?void 0:U.avatar_url)||""}),e.jsx(kn,{children:(((te=B.profile)==null?void 0:te.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Y=B.profile)==null?void 0:Y.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(J=B.profile)==null?void 0:J.email})]}),B.role==="team_leader"?e.jsxs(Qe,{className:"bg-[hsl(var(--chart-4)/0.1)] text-[hsl(var(--chart-4))] border-[hsl(var(--chart-4))]",children:[e.jsx(Cm,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(Qe,{variant:"secondary",children:"Member"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs($s,{value:B.role,onValueChange:ce=>l(B.id,ce),children:[e.jsx(zs,{className:"w-[140px]",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"team_leader",children:"Team Leader"}),e.jsx(vt,{value:"team_member",children:"Team Member"})]})]}),e.jsxs(Rl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive",children:e.jsx(GL,{className:"h-4 w-4"})})}),e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Remove Member?"}),e.jsxs(bl,{children:["Remove ",((X=B.profile)==null?void 0:X.name)||"this member"," from ",t.name,"?"]})]}),e.jsxs(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:()=>o(B.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})]})]})]})},B.id)})})]}),e.jsx(Ss,{value:"contacts",className:"space-y-4",children:e.jsx(m4e,{})}),t.lead_pond_enabled&&e.jsx(Ss,{value:"lead-pond",className:"space-y-4",children:e.jsx(p4e,{teamId:t.id})}),t.shared_assets_enabled&&e.jsx(Ss,{value:"shared-assets",className:"space-y-4",children:e.jsx(ftt,{teamId:t.id})}),e.jsxs(Ss,{value:"settings",className:"space-y-4",children:[e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{className:"text-lg",children:"Team Settings"}),e.jsx(dr,{children:"Configure how this team operates."})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Team Name"}),e.jsx(De,{defaultValue:t.name,onBlur:B=>{B.target.value!==t.name&&n({name:B.target.value})}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Description"}),e.jsx(_r,{defaultValue:t.description||"",onBlur:B=>{B.target.value!==(t.description||"")&&n({description:B.target.value||null})},rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Contact Visibility"}),e.jsxs($s,{defaultValue:t.contact_visibility,onValueChange:B=>n({contact_visibility:B}),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"private",children:"Private — Members keep their contacts private"}),e.jsx(vt,{value:"leader_only",children:"Leader Only — Only team leaders can see member contacts"}),e.jsx(vt,{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(xe,{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(Ar,{checked:t.lead_pond_enabled,onCheckedChange:B=>n({lead_pond_enabled:B})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(xe,{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(Ar,{checked:t.shared_assets_enabled,onCheckedChange:B=>n({shared_assets_enabled:B})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(xe,{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(Ar,{checked:t.shared_videos_enabled??!1,onCheckedChange:B=>n({shared_videos_enabled:B})})]})]})]}),e.jsxs(Rl,{children:[e.jsx(_m,{asChild:!0,children:e.jsxs(W,{variant:"destructive",size:"sm",children:[e.jsx(vr,{className:"mr-2 h-4 w-4"}),"Delete Team"]})}),e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Delete Team?"}),e.jsxs(bl,{children:['This will permanently delete "',t.name,'" and remove all team members. This cannot be undone.']})]}),e.jsxs(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:()=>{i(),r()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Team"})]})]})]})]})]})]})},gtt=({open:t,onOpenChange:s,onCreateTeam:r,isCreating:n,brokerageAgents:a,isAdmin:o,allBrokerages:l,activeBrokerageId:i})=>{const[d,u]=k.useState(1),[p,f]=k.useState(""),[y,_]=k.useState(""),[b,N]=k.useState(""),[w,S]=k.useState(""),[C,A]=k.useState([]),I=()=>{u(1),f(""),_(""),N(""),S(""),A([])},L=B=>{B||I(),s(B)},O=async()=>{const B=b&&b!=="none"?b:i||null;await r({name:p.trim(),description:y.trim()||void 0,brokerage_id:B,leaderId:w||void 0,memberIds:C.length>0?C:void 0}),I()},V=B=>{B!==w&&A(U=>U.includes(B)?U.filter(te=>te!==B):[...U,B])},q=a.filter(B=>B.id!==w);return e.jsx(fs,{open:t,onOpenChange:L,children:e.jsxs(ps,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[e.jsxs(ks,{children:[e.jsx(_s,{children:d===1?"Create New Team":"Assign Team Members"}),e.jsx(Ir,{children:d===1?"Name your team and add a description.":"Pick a leader and optionally add initial members."}),e.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsx("div",{className:Ot("h-1.5 flex-1 rounded-full transition-colors","bg-primary")}),e.jsx("div",{className:Ot("h-1.5 flex-1 rounded-full transition-colors",d===2?"bg-primary":"bg-muted")})]})]}),e.jsx("div",{className:"overflow-y-auto flex-1 pr-1",children:d===1?e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"team-name",children:"Team Name *"}),e.jsx(De,{id:"team-name",value:p,onChange:B=>f(B.target.value),placeholder:"e.g., Downtown Squad",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"team-desc",children:"Description"}),e.jsx(_r,{id:"team-desc",value:y,onChange:B=>_(B.target.value),placeholder:"What is this team focused on?",rows:3})]}),o&&l&&l.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Brokerage"}),e.jsxs($s,{value:b,onValueChange:N,children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"No brokerage (independent team)"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"none",children:"No brokerage (independent)"}),l.map(B=>e.jsx(vt,{value:B.id,children:B.name},B.id))]})]})]})]}):e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{className:"flex items-center gap-1.5",children:[e.jsx(Cm,{className:"h-3.5 w-3.5 text-[hsl(var(--chart-4))]"}),"Team Leader"]}),e.jsxs($s,{value:w,onValueChange:B=>{S(B),A(U=>U.filter(te=>te!==B))},children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select a team leader (optional)"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"none",children:"No leader for now"}),a.map(B=>e.jsx(vt,{value:B.id,children:B.name||B.email||"Unknown"},B.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{className:"flex items-center gap-1.5",children:[e.jsx(Jo,{className:"h-3.5 w-3.5"}),"Initial Members",C.length>0&&e.jsxs(Qe,{variant:"secondary",className:"ml-1 text-xs",children:[C.length," selected"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Click agents to add them. You can always add more later."}),e.jsx("div",{className:"border rounded-lg max-h-[240px] overflow-y-auto divide-y",children:q.length===0?e.jsxs("div",{className:"p-4 text-center text-sm text-muted-foreground",children:[e.jsx(ir,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),"No agents available"]}):q.map(B=>{const U=C.includes(B.id);return e.jsxs("button",{type:"button",className:Ot("w-full flex items-center gap-3 p-3 text-left transition-colors hover:bg-accent/50",U&&"bg-primary/5"),onClick:()=>V(B.id),children:[e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:B.avatar_url||""}),e.jsx(kn,{className:"text-xs",children:(B.name||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:B.name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:B.email})]}),e.jsx("div",{className:Ot("h-5 w-5 rounded-full border-2 flex items-center justify-center transition-colors shrink-0",U?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30"),children:U&&e.jsx(Zn,{className:"h-3 w-3"})})]},B.id)})})]})]})}),e.jsx(gn,{className:"gap-2 sm:gap-0",children:d===1?e.jsxs(e.Fragment,{children:[e.jsx(W,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),e.jsxs(W,{onClick:()=>u(2),disabled:!p.trim(),children:["Next",e.jsx(Wa,{className:"ml-2 h-4 w-4"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(W,{variant:"outline",onClick:()=>u(1),children:[e.jsx(Oa,{className:"mr-2 h-4 w-4"}),"Back"]}),e.jsx(W,{onClick:O,disabled:n,children:n?"Creating…":"Create Team"})]})})]})})},jVt=()=>{const{teams:t,isLoading:s,createTeam:r,updateTeam:n,deleteTeam:a,addMember:o,removeMember:l,updateMemberRole:i}=TC(),[d,u]=k.useState(!1),[p,f]=k.useState(null),[y,_]=k.useState(""),{data:b}=gt({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:L,error:O}=await G.from("brokerages").select("id, name").order("name");if(O)throw O;return L||[]}}),{data:N}=gt({queryKey:["admin-team-member-info",t.map(L=>L.id).join(",")],queryFn:async()=>{var B;if(t.length===0)return{};const{data:L}=await G.from("team_members").select("team_id, user_id, role").in("team_id",t.map(U=>U.id));if(!L)return{};const O=L.filter(U=>U.role==="team_leader").map(U=>U.user_id);let V={};if(O.length>0){const{data:U}=await G.from("profiles").select("id, name").in("id",O);U&&(V=Object.fromEntries(U.map(te=>[te.id,{name:te.name}])))}const q={};for(const U of t){const te=L.filter(J=>J.team_id===U.id),Y=te.find(J=>J.role==="team_leader");q[U.id]={count:te.length,leaderName:Y&&((B=V[Y.user_id])==null?void 0:B.name)||null}}return q},enabled:t.length>0}),w=(p==null?void 0:p.brokerage_id)||null,{data:S}=gt({queryKey:["brokerage-agents-for-teams",w],queryFn:async()=>{let L=G.from("profiles").select("id, name, email, avatar_url").order("name");w&&(L=L.eq("brokerage_id",w));const{data:O,error:V}=await L;if(V)throw V;return O||[]},enabled:!!p}),C=Object.fromEntries((b||[]).map(L=>[L.id,L.name])),A=async L=>{const O=await r.mutateAsync({name:L.name,brokerage_id:L.brokerage_id||null,description:L.description});if(L.leaderId&&L.leaderId!=="none"&&await o.mutateAsync({team_id:O.id,user_id:L.leaderId,role:"team_leader"}),L.memberIds)for(const V of L.memberIds)await o.mutateAsync({team_id:O.id,user_id:V,role:"team_member"});u(!1)};if(p)return e.jsx(xtt,{team:p,brokerageAgents:S||[],onBack:()=>f(null),onUpdate:L=>n.mutateAsync({id:p.id,...L}).then(O=>f(O)),onAddMember:(L,O)=>o.mutateAsync({team_id:p.id,user_id:L,role:O}),onRemoveMember:L=>l.mutateAsync({team_id:p.id,member_id:L}),onUpdateRole:(L,O)=>i.mutateAsync({team_id:p.id,member_id:L,role:O}),onDeleteTeam:()=>{a.mutate(p.id),f(null)},isUpdating:n.isPending,isAddingMember:o.isPending});const I=t.filter(L=>L.name.toLowerCase().includes(y.toLowerCase())||(L.description||"").toLowerCase().includes(y.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(ln,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search teams...",value:y,onChange:L=>_(L.target.value),className:"pl-10"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[I.length," of ",t.length," teams"]})]}),e.jsxs(W,{size:"sm",onClick:()=>u(!0),children:[e.jsx(qs,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(gtt,{open:d,onOpenChange:u,onCreateTeam:A,isCreating:r.isPending,brokerageAgents:[],isAdmin:!0,allBrokerages:b,activeBrokerageId:null}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(St,{className:"font-semibold",children:"Team Name"}),e.jsx(St,{className:"font-semibold",children:"Brokerage"}),e.jsx(St,{className:"font-semibold",children:"Leader"}),e.jsx(St,{className:"font-semibold",children:"Members"}),e.jsx(St,{className:"font-semibold",children:"Visibility"}),e.jsx(St,{className:"w-[100px]"})]})}),e.jsx(Rn,{children:s?e.jsx(e.Fragment,{children:[1,2,3].map(L=>e.jsxs(Ps,{children:[e.jsx(ht,{children:e.jsx(Ms,{className:"h-4 w-32"})}),e.jsx(ht,{children:e.jsx(Ms,{className:"h-4 w-24"})}),e.jsx(ht,{children:e.jsx(Ms,{className:"h-4 w-28"})}),e.jsx(ht,{children:e.jsx(Ms,{className:"h-4 w-12"})}),e.jsx(ht,{children:e.jsx(Ms,{className:"h-4 w-20"})}),e.jsx(ht,{children:e.jsx(Ms,{className:"h-4 w-16"})})]},L))}):I.length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:6,className:"text-center py-12 text-muted-foreground",children:y?"No teams match your search":"No teams found. Create one to get started."})}):I.map(L=>{const O=N==null?void 0:N[L.id];return e.jsxs(Ps,{className:"hover:bg-muted/30",children:[e.jsxs(ht,{children:[e.jsx("button",{onClick:()=>f(L),className:"text-primary hover:underline font-medium",children:L.name}),L.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:L.description})]}),e.jsx(ht,{children:L.brokerage_id?e.jsx("span",{className:"text-sm",children:C[L.brokerage_id]||"—"}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"Independent"})}),e.jsx(ht,{children:O!=null&&O.leaderName?e.jsxs("span",{className:"text-sm flex items-center gap-1",children:[e.jsx(Cm,{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(ht,{children:e.jsxs(Qe,{variant:"secondary",className:"text-xs",children:[e.jsx(ir,{className:"h-3 w-3 mr-1"}),(O==null?void 0:O.count)??0]})}),e.jsx(ht,{children:e.jsxs("span",{className:"text-xs text-muted-foreground capitalize flex items-center gap-1",children:[e.jsx(zu,{className:"h-3 w-3"}),L.contact_visibility.replace("_"," ")]})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>f(L),title:"Edit team",children:e.jsx(ga,{className:"h-3.5 w-3.5"})}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>{confirm(`Delete team "${L.name}"? This cannot be undone.`)&&a.mutate(L.id)},title:"Delete team",children:e.jsx(vr,{className:"h-3.5 w-3.5"})})]})})]},L.id)})})]})})]})},NVt=()=>{const t=wr(),{user:s,isAdmin:r}=Us(),{startImpersonation:n,isLoading:a}=mue(),{toast:o}=ja(),[l,i]=k.useState([]),[d,u]=k.useState([]),[p,f]=k.useState([]),[y,_]=k.useState({}),[b,N]=k.useState(!0);k.useState({});const[w,S]=k.useState(!1),[C,A]=k.useState({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),[I,L]=k.useState(!1),[O,V]=k.useState(""),[q,B]=k.useState(1),[U,te]=k.useState(50),[Y,J]=k.useState("all"),[X,ce]=k.useState("all"),[ie,ae]=k.useState("all"),[oe,me]=k.useState("all"),[ve,he]=k.useState(!1),[ge,je]=k.useState(!1),[qe,Me]=k.useState(null),[ke,Re]=k.useState(null),[Ve,Ne]=k.useState(!1),[Ue,Ie]=k.useState({name:"",email:"",brokerage_id:"",phone:""}),[ye,ct]=k.useState(null),[fe,$e]=k.useState(!1),[Ye,tt]=k.useState(""),[Te,We]=k.useState(!1),[Ke,ot]=k.useState(!1),[He,Je]=k.useState(null),[ut,mt]=k.useState(""),[et,Ze]=k.useState(!1),[kt,Ut]=k.useState(!1),[Nt,es]=k.useState(null),[ds,js]=k.useState(!1),[lr,Lt]=k.useState(!1),[Es,fr]=k.useState(null),[Hs,mr]=k.useState(""),[an,Cr]=k.useState(!1),[Fr,$r]=k.useState({email:"",name:"",password:"",phone:""}),[nr,cr]=k.useState(!1),[Br,Kr]=k.useState(!1),[Sn,ai]=k.useState(""),[as,qn]=k.useState(!1),[un,qr]=k.useState(!1),[Zr,La]=k.useState(""),[Yt,Lr]=k.useState(new Set),[$t,Se]=k.useState(!1),[Fe,Xe]=k.useState(!1),[yt,bt]=k.useState(null),[At,Gt]=k.useState(!1),[Vt,Xt]=k.useState(null),[Is,bs]=k.useState([]),[or,Rr]=k.useState([]),[Wr,zr]=k.useState(!1),[hn,Wn]=k.useState({});k.useEffect(()=>{!s||!r||(ua(),To())},[s,r]);const sa=async()=>{try{const{data:Ct,error:Fs}=await G.from("brokerage_manager_assignments").select("user_id, brokerage_id");if(Fs)throw Fs;const ar={};for(const tn of Ct??[])ar[tn.brokerage_id]||(ar[tn.brokerage_id]=[]),ar[tn.brokerage_id].push(tn.user_id);_(ar)}catch(Ct){console.error("Error loading brokerage manager assignments:",Ct)}},ua=async()=>{try{N(!0);const{data:Ct,error:Fs}=await G.functions.invoke("get-user-details");if(Fs)throw Fs;const ar=Ct.users||[];i(ar),f(Ct.brokerages||[]),await sa();const tn=ar.filter(xn=>xn.roles.includes("assistant"));if(tn.length>0){const xn=tn.map(fa=>fa.id),{data:oa}=await G.from("agent_assistant_assignments").select("agent_id, assistant_id").in("assistant_id",xn);if(oa&&oa.length>0){const fa=[...new Set(oa.map($m=>$m.agent_id))],{data:Ei}=await G.from("profiles").select("id, name, email").in("id",fa),kc={};for(const $m of oa){const Zh=Ei==null?void 0:Ei.find(O0=>O0.id===$m.agent_id);Zh&&(kc[$m.assistant_id]={agent_name:Zh.name||"",agent_email:Zh.email||""})}Wn(kc)}}}catch(Ct){console.error("Error loading members:",Ct),o({title:"Error",description:"Failed to load members",variant:"destructive"})}finally{N(!1)}},To=async()=>{try{const{data:Ct,error:Fs}=await G.from("app_tiles").select("id, name, icon, app_id, required_tags").order("name");if(Fs)throw Fs;u(Ct||[])}catch(Ct){console.error("Error loading apps:",Ct),o({title:"Error",description:"Failed to load apps",variant:"destructive"})}},wo=async Ct=>{if(!Ue.name.trim()||!Ue.email.trim()){o({title:"Error",description:"Name and email are required",variant:"destructive"});return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(Ue.email)){o({title:"Error",description:"Please enter a valid email address",variant:"destructive"});return}try{const{error:ar}=await G.from("profiles").update({name:Ue.name.trim(),email:Ue.email.trim(),brokerage_id:Ue.brokerage_id||null,phone:Ue.phone.trim()||null}).eq("id",Ct);if(ar)throw ar;o({title:"Success",description:"Member details updated successfully"}),Me(null),ua()}catch(ar){console.error("Error updating member:",ar),o({title:"Error",description:ar.message||"Failed to update member",variant:"destructive"})}},Yi=async Ct=>{try{const{data:{session:Fs}}=await G.auth.getSession(),ar=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Fs==null?void 0:Fs.access_token}`},body:JSON.stringify({userId:Ct})}),tn=await ar.json();if(!ar.ok)throw new Error(tn.error||"Failed to resend welcome email");o({title:"Success",description:"Welcome email sent successfully"})}catch(Fs){console.error("Error resending welcome email:",Fs),o({title:"Error",description:Fs.message||"Failed to resend welcome email",variant:"destructive"})}},ii=async(Ct,Fs)=>{try{const{error:ar}=await G.functions.invoke("send-password-reset",{body:{email:Ct,redirectTo:window.location.origin}});if(ar)throw ar;o({title:"Password Reset Sent",description:`Password reset email sent to ${Fs}`})}catch(ar){console.error("Error sending password reset:",ar),o({title:"Error",description:ar.message||"Failed to send password reset email",variant:"destructive"})}},$i=async(Ct,Fs)=>{if(confirm(`Are you sure you want to delete ${Fs}? This action cannot be undone.`))try{const{data:{session:ar}}=await G.auth.getSession(),tn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ar==null?void 0:ar.access_token}`},body:JSON.stringify({userId:Ct})}),xn=await tn.json();if(!tn.ok)throw new Error(xn.error||"Failed to delete user");o({title:"Success",description:"User deleted successfully"}),ua()}catch(ar){console.error("Error deleting user:",ar),o({title:"Error",description:ar.message||"Failed to delete user",variant:"destructive"})}},tl=async()=>{if(!C.email||!C.name||!C.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}if(C.role==="brokerage_manager"&&!C.brokerage_id){o({title:"Error",description:"Please select a brokerage for this manager",variant:"destructive"});return}S(!0);try{const{data:{session:Ct}}=await G.auth.getSession(),Fs=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ct==null?void 0:Ct.access_token}`},body:JSON.stringify(C)}),ar=await Fs.json();if(!Fs.ok)throw new Error(ar.error||"Failed to create user");if(C.role&&C.role!=="user"&&ar.userId){const tn=C.role==="brokerage_manager"?C.brokerage_id:void 0;await ui(ar.userId,C.role,"add",tn)}o({title:"Success",description:`User ${C.email} created successfully`}),A({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),L(!1),ua()}catch(Ct){console.error("Error creating user:",Ct),o({title:"Error",description:Ct.message||"Failed to create user",variant:"destructive"})}finally{S(!1)}},ui=async(Ct,Fs,ar,tn)=>{try{const{data:{session:xn}}=await G.auth.getSession(),oa={userId:Ct,role:Fs,action:ar};if(Fs==="brokerage_manager"){if(!tn){o({title:"Error",description:"Please choose a brokerage for this manager assignment",variant:"destructive"});return}oa.brokerageId=tn}const fa=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${xn==null?void 0:xn.access_token}`},body:JSON.stringify(oa)}),Ei=await fa.json();if(!fa.ok)throw new Error(Ei.error||"Failed to manage user role");o({title:"Success",description:`Role ${ar==="add"?"added":"removed"} successfully`}),ua()}catch(xn){console.error("Error managing user role:",xn),o({title:"Error",description:xn.message||"Failed to manage user role",variant:"destructive"})}},qi=(Ct,Fs)=>Fs.length===0?!0:Fs.some(ar=>Ct.includes(ar)),Xi=async(Ct,Fs,ar)=>{const tn=`${Ct}-${Fs.id}`;ct(tn);try{if(ar){const xn=l.find(fa=>fa.id===Ct),oa=Fs.required_tags.filter(fa=>xn==null?void 0:xn.tags.includes(fa));for(const fa of oa){const{error:Ei}=await G.from("user_tags").delete().eq("user_id",Ct).eq("tag",fa);if(Ei)throw Ei}o({title:"Access Removed",description:`Removed access to ${Fs.name}`})}else if(Fs.required_tags.length>0){const{error:xn}=await G.from("user_tags").insert({user_id:Ct,tag:Fs.required_tags[0]});if(xn)throw xn;o({title:"Access Granted",description:`Granted access to ${Fs.name}`})}await ua()}catch(xn){console.error("Error toggling access:",xn),o({title:"Error",description:xn.message||"Failed to update access",variant:"destructive"})}finally{ct(null)}},ha=async()=>{const Ct=Ye.trim();if(!Ct){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(Ct.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}if(p.find(ar=>ar.name.toLowerCase()===Ct.toLowerCase())){o({title:"Error",description:"A brokerage with this name already exists",variant:"destructive"});return}We(!0);try{const{error:ar}=await G.from("brokerages").insert({name:Ct});if(ar)throw ar;o({title:"Success",description:`Brokerage "${Ct}" created successfully`}),tt(""),$e(!1),ua()}catch(ar){console.error("Error creating brokerage:",ar),o({title:"Error",description:ar.message||"Failed to create brokerage",variant:"destructive"})}finally{We(!1)}},sl=Ct=>{Je(Ct),mt(Ct.name),ot(!0)},ac=()=>{Je(null),mt(""),ot(!1)},ic=async()=>{if(!He)return;const Ct=ut.trim();if(!Ct){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(Ct.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}Ze(!0);try{const{error:Fs}=await G.from("brokerages").update({name:Ct}).eq("id",He.id);if(Fs)throw Fs;o({title:"Success",description:"Brokerage updated successfully"}),ac(),ua()}catch(Fs){console.error("Error updating brokerage:",Fs),o({title:"Error",description:Fs.message||"Failed to update brokerage",variant:"destructive"})}finally{Ze(!1)}},bu=async(Ct,Fs)=>{var ar;if(!Fs||typeof Fs!="string"){o({title:"Error",description:"Please select a brokerage first",variant:"destructive"});return}try{const tn={userId:Ct,role:"brokerage_manager",action:"add",brokerageId:Fs};console.debug("[assignManagerToBrokerage] payload",tn);const{data:{session:xn}}=await G.auth.getSession(),oa=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${xn==null?void 0:xn.access_token}`},body:JSON.stringify(tn)}),fa=await oa.json();if(!oa.ok&&!((ar=fa.error)!=null&&ar.includes("duplicate")))throw new Error(fa.error||"Failed to add role");o({title:"Success",description:"Manager assigned to brokerage"}),await ua()}catch(tn){console.error("Error assigning manager:",tn),o({title:"Error",description:tn.message||"Failed to assign manager",variant:"destructive"})}},wu=Ct=>{es(Ct),Ut(!0)},Fm=async()=>{if(Nt){js(!0);try{const Ct=l.filter(tn=>tn.brokerage_id===Nt.id),{data:{session:Fs}}=await G.auth.getSession();for(const tn of Ct){const xn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Fs==null?void 0:Fs.access_token}`},body:JSON.stringify({userId:tn.id})});if(!xn.ok){const oa=await xn.json();console.error(`Failed to delete user ${tn.email}:`,oa.error)}}const{error:ar}=await G.from("brokerages").delete().eq("id",Nt.id);if(ar)throw ar;o({title:"Success",description:`Brokerage "${Nt.name}" and ${Ct.length} member(s) deleted`}),Ut(!1),es(null),ua()}catch(Ct){console.error("Error deleting brokerage:",Ct),o({title:"Error",description:Ct.message||"Failed to delete brokerage",variant:"destructive"})}finally{js(!1)}}},kd=Ct=>{fr(Ct),mr(""),Lt(!0)},ju=()=>{fr(null),mr(""),Lt(!1)},zm=async Ct=>{try{const{error:Fs}=await G.from("profiles").update({brokerage_id:null}).eq("id",Ct);if(Fs)throw Fs;o({title:"Success",description:"User removed from brokerage"}),ua()}catch(Fs){console.error("Error removing user from brokerage:",Fs),o({title:"Error",description:Fs.message||"Failed to remove user",variant:"destructive"})}},Wu=async(Ct,Fs)=>{try{const{error:ar}=await G.from("profiles").update({brokerage_id:Fs}).eq("id",Ct);if(ar)throw ar;o({title:"Success",description:"User added to brokerage"}),ua()}catch(ar){console.error("Error adding user to brokerage:",ar),o({title:"Error",description:ar.message||"Failed to add user",variant:"destructive"})}},Bm=async()=>{if(!Es||!Fr.email||!Fr.name||!Fr.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}cr(!0);try{const{data:{session:Ct}}=await G.auth.getSession(),Fs=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ct==null?void 0:Ct.access_token}`},body:JSON.stringify({...Fr,brokerage_id:Es.id,role:"user"})}),ar=await Fs.json();if(!Fs.ok)throw new Error(ar.error||"Failed to create agent");o({title:"Success",description:`Agent ${Fr.email} created successfully`}),$r({email:"",name:"",password:"",phone:""}),Cr(!1),ua()}catch(Ct){console.error("Error creating agent:",Ct),o({title:"Error",description:Ct.message||"Failed to create agent",variant:"destructive"})}finally{cr(!1)}},Sd=Ct=>l.filter(Fs=>Fs.brokerage_id===Ct),Cd=Ct=>{const Fs=Sd(Ct);if(!Hs)return Fs;const ar=Hs.toLowerCase();return Fs.filter(tn=>tn.name.toLowerCase().includes(ar)||tn.email.toLowerCase().includes(ar))},L0=Ct=>l.filter(Fs=>Fs.brokerage_id!==Ct),Aw=l.filter(Ct=>{var ar;if(O){const tn=O.toLowerCase();if(!(Ct.name.toLowerCase().includes(tn)||Ct.email.toLowerCase().includes(tn)||((ar=Ct.brokerage_name)==null?void 0:ar.toLowerCase().includes(tn))))return!1}if(Y==="claimed"&&!Ct.claimed||Y==="unclaimed"&&Ct.claimed||X!=="all"&&!Ct.roles.includes(X))return!1;const Fs=Ct.is_trial||Ct.subscription_status==="trialing";return!(ie==="trial"&&!Fs||ie==="non-trial"&&Fs||oe==="none"&&Ct.brokerage_id||oe!=="all"&&oe!=="none"&&Ct.brokerage_id!==oe)}),{sortKey:gh,sortDirection:kp,handleSort:Sp,sortData:Ew}=sO("created_at","desc"),Kh=Ew(Aw,{name:Ct=>{var Fs;return((Fs=Ct.name)==null?void 0:Fs.toLowerCase())||""},brokerage:Ct=>{var Fs;return((Fs=Ct.brokerage_name)==null?void 0:Fs.toLowerCase())||""},status:Ct=>Ct.claimed?"active":"pending",role:Ct=>Ct.roles[0]||"",last_login:Ct=>Ct.last_sign_in_at?new Date(Ct.last_sign_in_at).getTime():null,created_at:Ct=>Ct.created_at?new Date(Ct.created_at).getTime():null}),Cf=Kh.length,zx=U===0,Md=zx?1:Math.ceil(Cf/U),Bx=zx?0:(q-1)*U,Cp=zx?Cf:Bx+U,Wd=Kh.slice(Bx,Cp),Pw=Ct=>{V(Ct),B(1)},yh=Ct=>{te(Ct),B(1)},Qg=(Ct,Fs)=>{Ct(Fs),B(1)},Mf=async(Ct,Fs)=>{he(!0);try{const ar=l.find(fa=>fa.id===Ct);if(!ar)return;const tn=ar.trial_expires_at?new Date(ar.trial_expires_at):new Date,xn=new Date(tn.getTime()+Fs*24*60*60*1e3),{error:oa}=await G.from("profiles").update({trial_expires_at:xn.toISOString()}).eq("id",Ct);if(oa)throw oa;o({title:"Trial Extended",description:`Trial extended by ${Fs} days`}),ua()}catch(ar){console.error("Error extending trial:",ar),o({title:"Error",description:ar.message||"Failed to extend trial",variant:"destructive"})}finally{he(!1)}},D0=async Ct=>{je(!0);try{const{error:Fs}=await G.from("profiles").update({is_trial:!1,trial_expires_at:null,trial_started_at:null,trial_claimed_at:null}).eq("id",Ct);if(Fs)throw Fs;o({title:"Account Converted",description:"User has been converted to a full account"}),ua(),Sa()}catch(Fs){console.error("Error converting trial:",Fs),o({title:"Error",description:Fs.message||"Failed to convert account",variant:"destructive"})}finally{je(!1)}},Iw=async Ct=>{zr(!0);try{const{data:Fs}=await G.from("agent_assistant_assignments").select("id, assistant_id, permissions").eq("agent_id",Ct);if(Fs&&Fs.length>0){const tn=Fs.map(oa=>oa.assistant_id),{data:xn}=await G.from("profiles").select("id, name, email").in("id",tn);bs(Fs.map(oa=>{const fa=xn==null?void 0:xn.find(Ei=>Ei.id===oa.assistant_id);return{id:oa.id,assistant_id:oa.assistant_id,assistant_name:(fa==null?void 0:fa.name)||"Unknown",assistant_email:(fa==null?void 0:fa.email)||"",permissions:oa.permissions||{}}}))}else bs([]);const{data:ar}=await G.from("agent_assistant_assignments").select("id, agent_id, permissions").eq("assistant_id",Ct);if(ar&&ar.length>0){const tn=ar.map(oa=>oa.agent_id),{data:xn}=await G.from("profiles").select("id, name, email").in("id",tn);Rr(ar.map(oa=>{const fa=xn==null?void 0:xn.find(Ei=>Ei.id===oa.agent_id);return{id:oa.id,agent_id:oa.agent_id,agent_name:(fa==null?void 0:fa.name)||"Unknown",agent_email:(fa==null?void 0:fa.email)||"",permissions:oa.permissions||{}}}))}else Rr([])}catch(Fs){console.error("Error loading assistant data:",Fs)}finally{zr(!1)}},P1=Ct=>{Re(Ct),Ie({name:Ct.name,email:Ct.email,brokerage_id:Ct.brokerage_id||"",phone:Ct.phone||""}),Ne(!0),Iw(Ct.id)},Sa=()=>{Re(null),Ne(!1),Ie({name:"",email:"",brokerage_id:"",phone:""})},Jg=async()=>{ke&&(await wo(ke.id),Sa())},ey=Ct=>{Lr(Fs=>{const ar=new Set(Fs);return ar.has(Ct)?ar.delete(Ct):ar.add(Ct),ar})},OE=()=>{if(Yt.size===Wd.length&&Wd.every(Ct=>Yt.has(Ct.id))){const Ct=new Set(Yt);Wd.forEach(Fs=>Ct.delete(Fs.id)),Lr(Ct)}else{const Ct=new Set(Yt);Wd.forEach(Fs=>Ct.add(Fs.id)),Lr(Ct)}},$x=()=>{Lr(new Set)},Tf=async()=>{if(Yt.size===0)return;Se(!0);let Ct=0,Fs=0;try{const{data:{session:ar}}=await G.auth.getSession();for(const tn of Yt)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ar==null?void 0:ar.access_token}`},body:JSON.stringify({userId:tn})})).ok?Ct++:Fs++}catch{Fs++}o({title:"Bulk Email Complete",description:`Sent ${Ct} emails${Fs>0?`, ${Fs} failed`:""}`}),$x()}catch(ar){o({title:"Error",description:ar.message||"Failed to send emails",variant:"destructive"})}finally{Se(!1)}},ty=async()=>{if(Yt.size===0)return;Se(!0);let Ct=0,Fs=0;try{const{data:{session:ar}}=await G.auth.getSession();for(const tn of Yt)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-password-reset",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ar==null?void 0:ar.access_token}`},body:JSON.stringify({userId:tn})})).ok?Ct++:Fs++}catch{Fs++}o({title:"Bulk Password Reset Complete",description:`Sent ${Ct} reset emails${Fs>0?`, ${Fs} failed`:""}`}),$x()}catch(ar){o({title:"Error",description:ar.message||"Failed to send password reset emails",variant:"destructive"})}finally{Se(!1)}},R0=async()=>{if(Yt.size===0)return;const Ct=l.filter(xn=>Yt.has(xn.id)).map(xn=>xn.name).slice(0,5).join(", "),Fs=Yt.size>5?` and ${Yt.size-5} more`:"";if(!confirm(`Are you sure you want to delete ${Yt.size} users (${Ct}${Fs})? This action cannot be undone.`))return;Se(!0);let ar=0,tn=0;try{const{data:{session:xn}}=await G.auth.getSession();for(const oa of Yt)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${xn==null?void 0:xn.access_token}`},body:JSON.stringify({userId:oa})})).ok?ar++:tn++}catch{tn++}o({title:"Bulk Delete Complete",description:`Deleted ${ar} users${tn>0?`, ${tn} failed`:""}`}),$x(),ua()}catch(xn){o({title:"Error",description:xn.message||"Failed to delete users",variant:"destructive"})}finally{Se(!1)}},I1=async()=>{Xe(!0);try{const{data:{session:Ct}}=await G.auth.getSession(),Fs=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-phone-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ct==null?void 0:Ct.access_token}`}});if(!Fs.ok){const tn=await Fs.json();throw new Error(tn.error||"Failed to sync phones")}const ar=await Fs.json();o({title:"Phone Sync Complete",description:`Pulled ${ar.summary.pulledFromGHL} from GHL, pushed ${ar.summary.pushedToGHL} to GHL, ${ar.summary.alreadySynced} already synced`}),ua()}catch(Ct){o({title:"Error",description:Ct.message||"Failed to sync phones with GHL",variant:"destructive"})}finally{Xe(!1)}},RC=async(Ct,Fs)=>{bt(Ct);try{const{data:{session:ar}}=await G.auth.getSession(),{data:tn}=await G.from("profiles").select("phone").eq("id",Ct).single(),xn=(tn==null?void 0:tn.phone)||"",oa=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-tag-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ar==null?void 0:ar.access_token}`},body:JSON.stringify({email:Fs,action:"update",phone:xn||void 0})});if(!oa.ok){const Ei=await oa.json();throw new Error(Ei.error||"Failed to sync with GHL")}const fa=await fetch(`https://services.leadconnectorhq.com/contacts/lookup?locationId=&email=${encodeURIComponent(Fs)}`,{method:"GET",headers:{"Content-Type":"application/json"}});o({title:"Phone Synced",description:xn?`Phone ${xn} synced to GHL`:"Sync attempted - run bulk sync to pull phone from GHL"}),ua()}catch(ar){o({title:"Error",description:ar.message||"Failed to sync phone",variant:"destructive"})}finally{bt(null)}},Af=async Ct=>{await n(Ct)},OC=()=>{if(Yt.size===0){o({title:"No members selected",description:"Please select members to export",variant:"destructive"});return}const Ct=l.filter(Ei=>Yt.has(Ei.id)),Fs=["Name","Email","Phone","Brokerage","Roles","Status","Created At"],ar=Ct.map(Ei=>[Ei.name,Ei.email,Ei.phone||"",Ei.brokerage_name||"",Ei.roles.join("; "),Ei.claimed?"Claimed":"Unclaimed",new Date(Ei.created_at).toLocaleDateString()]),tn=[Fs.join(","),...ar.map(Ei=>Ei.map(kc=>`"${(kc||"").replace(/"/g,'""')}"`).join(","))].join(` `),xn=new Blob([tn],{type:"text/csv"}),oa=URL.createObjectURL(xn),fa=document.createElement("a");fa.href=oa,fa.download=`members-export-${new Date().toISOString().split("T")[0]}.csv`,fa.click(),URL.revokeObjectURL(oa),o({title:"Export complete",description:`Exported ${Ct.length} member(s)`})};return b?e.jsx(Ds,{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(Ds,{title:"Members",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(Hu,{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(W,{size:"sm",variant:"outline",onClick:I1,disabled:Fe,children:[Fe?e.jsx(us,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(In,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:Fe?"Syncing...":"Sync Phones with GHL"}),e.jsx("span",{className:"sm:hidden",children:Fe?"Syncing...":"Sync GHL"})]}),e.jsxs(W,{size:"sm",variant:"outline",onClick:()=>Kr(!0),children:[e.jsx(Zv,{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:I,onOpenChange:L,children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{size:"sm",children:[e.jsx(Jo,{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(ks,{children:[e.jsx(_s,{children:"Create New User"}),e.jsx(Ir,{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(xe,{htmlFor:"name",children:"Name"}),e.jsx(De,{id:"name",placeholder:"John Doe",value:C.name,onChange:Ct=>A({...C,name:Ct.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"email",children:"Email"}),e.jsx(De,{id:"email",type:"email",placeholder:"john@example.com",value:C.email,onChange:Ct=>A({...C,email:Ct.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"password",children:"Password"}),e.jsx(De,{id:"password",type:"password",placeholder:"Min 6 characters",value:C.password,onChange:Ct=>A({...C,password:Ct.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(De,{id:"phone",type:"tel",placeholder:"555-123-4567",value:C.phone,onChange:Ct=>A({...C,phone:Ct.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{htmlFor:"brokerage",children:["Brokerage",C.role==="brokerage_manager"?" (required)":""]}),e.jsxs($s,{value:C.brokerage_id||"none",onValueChange:Ct=>A({...C,brokerage_id:Ct==="none"?"":Ct}),children:[e.jsx(zs,{id:"brokerage",children:e.jsx(Vs,{placeholder:C.role==="brokerage_manager"?"Select brokerage":"Select brokerage (optional)"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"none",children:"None"}),p.map(Ct=>e.jsx(vt,{value:Ct.id,children:Ct.name},Ct.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"role",children:"Role"}),e.jsxs($s,{value:C.role,onValueChange:Ct=>A({...C,role:Ct}),children:[e.jsx(zs,{id:"role",children:e.jsx(Vs,{placeholder:"Select role"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"user",children:"User"}),e.jsx(vt,{value:"moderator",children:"Moderator"}),e.jsx(vt,{value:"brokerage_manager",children:"Brokerage Manager"}),e.jsx(vt,{value:"admin",children:"Admin"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"trial_days",children:"Trial Period (optional)"}),e.jsxs($s,{value:C.trial_days||"none",onValueChange:Ct=>A({...C,trial_days:Ct==="none"?"":Ct}),children:[e.jsx(zs,{id:"trial_days",children:e.jsx(Vs,{placeholder:"No trial (full access)"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"none",children:"No trial (full access)"}),e.jsx(vt,{value:"7",children:"7-day trial"}),e.jsx(vt,{value:"30",children:"30-day trial"}),e.jsx(vt,{value:"60",children:"60-day trial"}),e.jsx(vt,{value:"90",children:"90-day trial"}),e.jsx(vt,{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(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),e.jsx(W,{onClick:tl,disabled:w,children:w?"Creating...":"Create User"})]})]})]})]})]}),e.jsxs(ta,{defaultValue:new URLSearchParams(window.location.search).get("tab")||"members",className:"space-y-6",children:[e.jsxs(Jn,{children:[e.jsx(cs,{value:"members",children:"Members"}),e.jsx(cs,{value:"brokerages",children:"Brokerages"}),e.jsx(cs,{value:"teams",children:"Teams"}),e.jsx(cs,{value:"trials",children:"Trial Users"}),e.jsx(cs,{value:"access",children:"Access Matrix"}),e.jsx(cs,{value:"celebrations",children:"Celebrations"}),e.jsx(cs,{value:"deletions",children:"Deletion Log"})]}),e.jsxs(Ss,{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(ln,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search members...",value:O,onChange:Ct=>Pw(Ct.target.value),className:"pl-10 h-9"})]}),e.jsxs($s,{value:Y,onValueChange:Ct=>Qg(J,Ct),children:[e.jsx(zs,{className:"w-[130px] h-9",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Status"}),e.jsx(vt,{value:"claimed",children:"Active"}),e.jsx(vt,{value:"unclaimed",children:"Pending"})]})]}),e.jsxs($s,{value:X,onValueChange:Ct=>Qg(ce,Ct),children:[e.jsx(zs,{className:"w-[130px] h-9",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Roles"}),e.jsx(vt,{value:"admin",children:"Admin"}),e.jsx(vt,{value:"brokerage_manager",children:"Manager"}),e.jsx(vt,{value:"assistant",children:"Assistant"}),e.jsx(vt,{value:"user",children:"User"})]})]}),e.jsxs($s,{value:ie,onValueChange:Ct=>Qg(ae,Ct),children:[e.jsx(zs,{className:"w-[130px] h-9",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Users"}),e.jsx(vt,{value:"trial",children:"Trial Only"}),e.jsx(vt,{value:"non-trial",children:"Full Only"})]})]}),e.jsxs($s,{value:oe,onValueChange:Ct=>Qg(me,Ct),children:[e.jsx(zs,{className:"w-[150px] h-9",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Brokerages"}),e.jsx(vt,{value:"none",children:"No Brokerage"}),p.map(Ct=>e.jsx(vt,{value:Ct.id,children:Ct.name},Ct.id))]})]}),(O||Y!=="all"||X!=="all"||ie!=="all"||oe!=="all")&&e.jsxs(W,{variant:"ghost",size:"sm",className:"h-9",onClick:()=>{V(""),J("all"),ce("all"),ae("all"),me("all"),B(1)},children:[e.jsx(kr,{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:zx?`Showing all ${Cf} members`:`Showing ${Bx+1}-${Math.min(Cp,Cf)} of ${Cf} members`}),e.jsxs($s,{value:U.toString(),onValueChange:Ct=>yh(Number(Ct)),children:[e.jsx(zs,{className:"h-9 w-[110px]",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"50",children:"50 / page"}),e.jsx(vt,{value:"100",children:"100 / page"}),e.jsx(vt,{value:"250",children:"250 / page"}),e.jsx(vt,{value:"0",children:"All"})]})]})]})]}),Yt.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(Pv,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm font-medium",children:[Yt.size," selected"]})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(W,{size:"sm",variant:"outline",onClick:Tf,disabled:$t,children:[$t?e.jsx(us,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(tr,{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(W,{size:"sm",variant:"outline",onClick:ty,disabled:$t,children:[$t?e.jsx(us,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(fp,{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(W,{size:"sm",variant:"outline",onClick:OC,children:[e.jsx(Qa,{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(W,{size:"sm",variant:"destructive",onClick:R0,disabled:$t,children:[$t?e.jsx(us,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(vr,{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(W,{size:"sm",variant:"ghost",onClick:$x,disabled:$t,children:e.jsx(kr,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(St,{className:"w-[50px]",children:e.jsx(Ri,{checked:Wd.length>0&&Wd.every(Ct=>Yt.has(Ct.id)),onCheckedChange:OE,"aria-label":"Select all on page"})}),e.jsx(Zo,{sortKey:"name",currentSortKey:gh,currentDirection:kp,onSort:Sp,children:"Name"}),e.jsx(Zo,{sortKey:"brokerage",currentSortKey:gh,currentDirection:kp,onSort:Sp,children:"Brokerage"}),e.jsx(Zo,{sortKey:"status",currentSortKey:gh,currentDirection:kp,onSort:Sp,children:"Status"}),e.jsx(Zo,{sortKey:"role",currentSortKey:gh,currentDirection:kp,onSort:Sp,children:"Role"}),e.jsx(Zo,{sortKey:"last_login",currentSortKey:gh,currentDirection:kp,onSort:Sp,children:"Last Login"}),e.jsx(Zo,{sortKey:"created_at",currentSortKey:gh,currentDirection:kp,onSort:Sp,children:"Member Since"}),e.jsx(St,{className:"w-[100px]"})]})}),e.jsx(Rn,{children:Wd.length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:8,className:"text-center py-12 text-muted-foreground",children:"No members found"})}):Wd.map(Ct=>e.jsxs(Ps,{className:`hover:bg-muted/30 ${Yt.has(Ct.id)?"bg-primary/5":""}`,children:[e.jsx(ht,{children:e.jsx(Ri,{checked:Yt.has(Ct.id),onCheckedChange:()=>ey(Ct.id),"aria-label":`Select ${Ct.name}`})}),e.jsx(ht,{children:e.jsxs("div",{children:[e.jsx("button",{onClick:()=>P1(Ct),className:"text-primary hover:underline font-medium text-left",children:Ct.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:Ct.email})]})}),e.jsx(ht,{className:"text-muted-foreground",children:Ct.brokerage_name||"—"}),e.jsx(ht,{children:e.jsx("div",{className:"flex flex-col",children:(()=>{const Fs=Ct.is_trial&&Ct.trial_expires_at||!Ct.is_trial&&Ct.subscription_status==="trialing"&&Ct.subscription_end_date,ar=Ct.trial_expires_at||Ct.subscription_end_date;if(Fs&&ar){const tn=Math.ceil((new Date(ar).getTime()-Date.now())/864e5),xn=tn<=0,oa=tn<=3;return e.jsx(Qe,{variant:"outline",className:Ot("w-fit",xn?"border-destructive text-destructive":oa?"border-amber-500 text-amber-600":"border-violet-300 text-violet-700 bg-violet-50"),children:xn?"Trial Expired":`Trial · ${tn}d left`})}return e.jsx(Qe,{variant:Ct.claimed?"default":"secondary",className:Ct.claimed?"bg-primary text-primary-foreground w-fit":"w-fit",children:Ct.claimed?"Active":"Pending"})})()})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex flex-col",children:[Ct.roles.length>0?e.jsx("span",{className:"text-sm capitalize",children:Ct.roles[0]}):e.jsx("span",{className:"text-muted-foreground",children:"—"}),Ct.roles.includes("assistant")&&hn[Ct.id]&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["→ ",hn[Ct.id].agent_name||hn[Ct.id].agent_email]})]})}),e.jsx(ht,{className:"text-muted-foreground",children:Ct.last_sign_in_at?new Date(Ct.last_sign_in_at).toLocaleDateString():"—"}),e.jsx(ht,{className:"text-muted-foreground",children:Ct.created_at?new Date(Ct.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"—"}),e.jsx(ht,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsx(W,{size:"icon",variant:"ghost",className:"h-8 w-8 text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",onClick:()=>{Xt(Ct),Gt(!0)},title:"Send celebration",children:e.jsx(qd,{className:"h-4 w-4"})}),e.jsx(W,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>P1(Ct),title:"Edit member",children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(W,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>RC(Ct.id,Ct.email),disabled:yt===Ct.id,title:"Sync phone with GHL",children:yt===Ct.id?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(In,{className:"h-4 w-4"})}),e.jsx(W,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Yi(Ct.id),title:"Resend welcome email",children:e.jsx(tr,{className:"h-4 w-4"})}),e.jsx(W,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>ii(Ct.email,Ct.name),title:"Send password reset",children:e.jsx(nS,{className:"h-4 w-4"})}),e.jsx(W,{size:"icon",variant:"ghost",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:()=>Af(Ct.id),disabled:a||Ct.id===(s==null?void 0:s.id),title:Ct.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${Ct.name}`,children:a?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(lS,{className:"h-4 w-4"})}),e.jsx(W,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>$i(Ct.id,Ct.name),title:"Delete user",children:e.jsx(vr,{className:"h-4 w-4"})})]})})]},Ct.id))})]})}),Md>1&&e.jsxs("div",{className:"flex items-center justify-between px-2 py-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Page ",q," of ",Md]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(W,{variant:"outline",size:"sm",onClick:()=>B(1),disabled:q===1,children:"First"}),e.jsx(W,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>B(Ct=>Math.max(1,Ct-1)),disabled:q===1,children:e.jsx(Xo,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(5,Md)},(Ct,Fs)=>{let ar;return Md<=5||q<=3?ar=Fs+1:q>=Md-2?ar=Md-4+Fs:ar=q-2+Fs,e.jsx(W,{variant:q===ar?"default":"outline",size:"sm",className:"h-8 w-8 p-0",onClick:()=>B(ar),children:ar},ar)})}),e.jsx(W,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>B(Ct=>Math.min(Md,Ct+1)),disabled:q===Md,children:e.jsx(xa,{className:"h-4 w-4"})}),e.jsx(W,{variant:"outline",size:"sm",onClick:()=>B(Md),disabled:q===Md,children:"Last"})]})]})]}),e.jsx(fs,{open:Ve,onOpenChange:Ne,children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Edit Member"}),e.jsx(Ir,{children:"Update member details, roles, and app access"})]}),ke&&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(xe,{htmlFor:"edit-name",children:"Name"}),e.jsx(De,{id:"edit-name",value:Ue.name,onChange:Ct=>Ie({...Ue,name:Ct.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"edit-email",children:"Email"}),e.jsx(De,{id:"edit-email",type:"email",value:Ue.email,onChange:Ct=>Ie({...Ue,email:Ct.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(xe,{htmlFor:"edit-phone",children:"Phone"}),e.jsx(De,{id:"edit-phone",type:"tel",value:Ue.phone,onChange:Ct=>Ie({...Ue,phone:Ct.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"edit-brokerage",children:"Brokerage"}),e.jsxs($s,{value:Ue.brokerage_id||"none",onValueChange:Ct=>Ie({...Ue,brokerage_id:Ct==="none"?"":Ct}),children:[e.jsx(zs,{id:"edit-brokerage",children:e.jsx(Vs,{placeholder:"Select brokerage"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"none",children:"None"}),p.map(Ct=>e.jsx(vt,{value:Ct.id,children:Ct.name},Ct.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:[ke.roles.map(Ct=>e.jsxs(Qe,{variant:"default",className:"gap-1",children:[e.jsx(zu,{className:"h-3 w-3"}),Ct,Ct==="brokerage_manager"?e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(manage in Brokerages tab)"}):e.jsx("button",{onClick:()=>ui(ke.id,Ct,"remove"),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove role",children:e.jsx(kr,{className:"h-3 w-3"})})]},Ct)),ke.roles.length===0&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"No roles assigned"})]}),e.jsxs($s,{onValueChange:Ct=>ui(ke.id,Ct,"add"),children:[e.jsx(zs,{className:"w-[200px]",children:e.jsx(Vs,{placeholder:"Add role..."})}),e.jsxs(Bs,{children:[!ke.roles.includes("admin")&&e.jsx(vt,{value:"admin",children:"Admin"}),!ke.roles.includes("user")&&e.jsx(vt,{value:"user",children:"User"})]})]}),!ke.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"})]}),(Is.length>0||or.length>0||ke.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(ir,{className:"h-4 w-4"}),"Assistant Relationships"]}),Wr?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(us,{className:"h-4 w-4 animate-spin"}),"Loading..."]}):e.jsxs("div",{className:"space-y-3",children:[Is.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:"}),Is.map(Ct=>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:Ct.assistant_name}),e.jsx(Qe,{variant:"outline",className:"text-xs",children:"Assistant"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Ct.assistant_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(Ct.permissions).filter(([,Fs])=>Fs).map(([Fs])=>e.jsx(Qe,{variant:"secondary",className:"text-[10px] capitalize",children:Fs},Fs))})]},Ct.id))]}),or.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:"}),or.map(Ct=>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:Ct.agent_name}),e.jsx(Qe,{variant:"outline",className:"text-xs",children:"Agent"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Ct.agent_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(Ct.permissions).filter(([,Fs])=>Fs).map(([Fs])=>e.jsx(Qe,{variant:"secondary",className:"text-[10px] capitalize",children:Fs},Fs))})]},Ct.id))]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"App Access"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Toggle which apps this member can access"}),e.jsx("div",{className:"grid gap-3",children:d.map(Ct=>{const Fs=qi(ke.tags,Ct.required_tags),ar=`${ke.id}-${Ct.id}`,tn=ye===ar,xn=Ct.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:Ct.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:Ct.name}),xn&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Available to all members"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:tn?e.jsx(us,{className:"h-4 w-4 animate-spin text-muted-foreground"}):xn?e.jsx(Qe,{variant:"secondary",className:"text-xs",children:"Always On"}):e.jsx(Ar,{checked:Fs,onCheckedChange:()=>Xi(ke.id,Ct,Fs)})})]},Ct.id)})})]}),(ke.is_trial||ke.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(nn,{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:[ke.trial_expires_at&&e.jsx(rDe,{expiresAt:ke.trial_expires_at}),!ke.trial_expires_at&&ke.subscription_status==="trialing"&&ke.subscription_end_date&&e.jsx(rDe,{expiresAt:ke.subscription_end_date})]}),(ke.trial_expires_at||ke.subscription_end_date)&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Expires: ",new Date(ke.trial_expires_at||ke.subscription_end_date).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(W,{size:"sm",variant:"outline",onClick:()=>Mf(ke.id,7),disabled:ve,children:[e.jsx(jb,{className:"h-4 w-4 mr-1"}),"+7 Days"]}),e.jsxs(W,{size:"sm",variant:"outline",onClick:()=>Mf(ke.id,14),disabled:ve,children:[e.jsx(jb,{className:"h-4 w-4 mr-1"}),"+14 Days"]}),e.jsxs(W,{size:"sm",variant:"outline",onClick:()=>Mf(ke.id,30),disabled:ve,children:[e.jsx(jb,{className:"h-4 w-4 mr-1"}),"+30 Days"]}),e.jsxs(W,{size:"sm",variant:"default",onClick:()=>D0(ke.id),disabled:ge,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(n0,{className:"h-4 w-4 mr-1"}),"Convert to Full Account"]})]}),ke.trial_started_at&&e.jsxs("div",{className:"mt-3 text-xs text-muted-foreground",children:["Trial started: ",new Date(ke.trial_started_at).toLocaleDateString(),ke.trial_claimed_at&&e.jsxs("span",{children:[" • Claimed: ",new Date(ke.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:[ke.email_confirmed_at&&e.jsxs("div",{children:["Claimed: ",new Date(ke.email_confirmed_at).toLocaleString()]}),ke.last_sign_in_at&&e.jsxs("div",{children:["Last login: ",new Date(ke.last_sign_in_at).toLocaleString()]}),e.jsxs("div",{children:["Created: ",new Date(ke.created_at).toLocaleString()]})]})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:Sa,children:"Cancel"}),e.jsx(W,{onClick:Jg,children:"Save Changes"})]})]})}),e.jsxs(Ss,{value:"access",children:[d.length===0?e.jsx(Pe,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No apps configured yet"}),e.jsx(W,{onClick:()=>t("/admin/apps"),children:"Configure Apps"})]})}):e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 space-y-0",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Member Access Matrix"}),e.jsx(dr,{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(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search agents by name or email...",value:O,onChange:Ct=>{V(Ct.target.value),B(1)},className:"pl-9"})]})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"text-left p-4 font-semibold sticky left-0 bg-card z-10",children:"Member"}),d.map(Ct=>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:Ct.icon}),e.jsx("span",{className:"text-sm",children:Ct.name})]})},Ct.id))]})}),e.jsxs("tbody",{children:[Wd.map(Ct=>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:Ct.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:Ct.email})]})}),d.map(Fs=>{const ar=qi(Ct.tags,Fs.required_tags),tn=`${Ct.id}-${Fs.id}`,xn=ye===tn;return e.jsx("td",{className:"p-4 text-center",children:e.jsx("div",{className:"flex items-center justify-center",children:xn?e.jsx(us,{className:"h-5 w-5 animate-spin text-muted-foreground"}):e.jsx(Ar,{checked:ar,onCheckedChange:()=>Xi(Ct.id,Fs,ar),disabled:Fs.required_tags.length===0})})},Fs.id)})]},Ct.id)),Wd.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:d.length+1,className:"p-8 text-center text-muted-foreground",children:"No members found"})})]})]})}),Md>1&&e.jsxs("div",{className:"flex items-center justify-between px-2 py-4 border-t",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Showing ",Bx+1,"-",Math.min(Cp,Cf)," of ",Cf," • Page ",q," of ",Md]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(W,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>B(Ct=>Math.max(1,Ct-1)),disabled:q===1,children:e.jsx(Xo,{className:"h-4 w-4"})}),e.jsx(W,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>B(Ct=>Math.min(Md,Ct+1)),disabled:q===Md,children:e.jsx(xa,{className:"h-4 w-4"})})]})]})]})]}),e.jsx("div",{className:"mt-6",children:e.jsx(W,{variant:"outline",onClick:()=>t("/admin/apps"),children:"Manage Apps"})})]}),e.jsxs(Ss,{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(ln,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search brokerages...",value:Sn,onChange:Ct=>ai(Ct.target.value),className:"pl-10"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[p.filter(Ct=>Ct.name.toLowerCase().includes(Sn.toLowerCase())).length," of ",p.length," brokerages"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(W,{size:"sm",variant:"outline",onClick:()=>{const Ct=[];for(const fa of p){const Ei=y[fa.id]??[];for(const kc of Ei){const $m=l.find(Zh=>Zh.id===kc);if($m){const Zh=($m.name||"").trim().split(/\s+/),O0=Zh[0]||"",Aa=Zh.slice(1).join(" ")||"";Ct.push({firstName:O0,lastName:Aa,email:$m.email,brokerageName:fa.name})}}}if(Ct.length===0){o({title:"No managers found to export"});return}const ar=[["First Name","Last Name","Email","Brokerage Name"].join(","),...Ct.map(fa=>[fa.firstName,fa.lastName,fa.email,fa.brokerageName].map(Ei=>`"${(Ei||"").replace(/"/g,'""')}"`).join(","))].join(` `),tn=new Blob([ar],{type:"text/csv"}),xn=URL.createObjectURL(tn),oa=document.createElement("a");oa.href=xn,oa.download=`brokerage-managers-${new Date().toISOString().slice(0,10)}.csv`,oa.click(),URL.revokeObjectURL(xn),o({title:`Exported ${Ct.length} managers`})},children:[e.jsx(Qa,{className:"mr-2 h-4 w-4"}),"Export Managers"]}),e.jsxs(fs,{open:fe,onOpenChange:$e,children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{size:"sm",children:[e.jsx(pa,{className:"mr-2 h-4 w-4"}),"Add Brokerage"]})}),e.jsxs(ps,{children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Create New Brokerage"}),e.jsx(Ir,{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(xe,{htmlFor:"brokerage-name",children:"Brokerage Name"}),e.jsx(De,{id:"brokerage-name",placeholder:"Enter brokerage name",value:Ye,onChange:Ct=>tt(Ct.target.value),maxLength:100})]})}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>$e(!1),children:"Cancel"}),e.jsx(W,{onClick:ha,disabled:Te,children:Te?"Creating...":"Create Brokerage"})]})]})]})]})]}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(St,{className:"font-semibold",children:"Brokerage Name"}),e.jsx(St,{className:"font-semibold",children:"Manager(s)"}),e.jsx(St,{className:"font-semibold",children:"Agents"}),e.jsx(St,{className:"w-[150px]"})]})}),e.jsx(Rn,{children:(()=>{const Ct=p.filter(Fs=>Fs.name.toLowerCase().includes(Sn.toLowerCase()));return Ct.length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:4,className:"text-center py-12 text-muted-foreground",children:Sn?"No brokerages match your search":"No brokerages found"})}):Ct.map(Fs=>{const ar=l.filter(fa=>fa.brokerage_id===Fs.id),xn=(y[Fs.id]??[]).map(fa=>l.find(Ei=>Ei.id===fa)).filter(Boolean),oa=ar.length;return e.jsxs(Ps,{className:"hover:bg-muted/30",children:[e.jsx(ht,{children:e.jsx("button",{onClick:()=>sl(Fs),className:"text-primary hover:underline font-medium",children:Fs.name})}),e.jsx(ht,{children:xn.length>0?e.jsx("div",{className:"flex flex-wrap gap-1",children:xn.map(fa=>e.jsx(Qe,{variant:"secondary",className:"text-xs",children:fa.name},fa.id))}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"No manager"})}),e.jsxs(ht,{children:[oa," member",oa!==1?"s":""]}),e.jsx(ht,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsxs(W,{size:"sm",variant:"outline",className:"h-8",onClick:()=>kd(Fs),children:[e.jsx(ir,{className:"h-4 w-4 mr-1"}),"Manage"]}),e.jsx(W,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>sl(Fs),title:"Edit brokerage",children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(W,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>wu(Fs),title:"Delete brokerage",children:e.jsx(vr,{className:"h-4 w-4"})})]})})]},Fs.id)})})()})]})}),e.jsx(fs,{open:Ke,onOpenChange:ot,children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Edit Brokerage"}),e.jsx(Ir,{children:"Update brokerage details and manage managers"})]}),He&&e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"edit-brokerage-name",children:"Brokerage Name"}),e.jsx(De,{id:"edit-brokerage-name",value:ut,onChange:Ct=>mt(Ct.target.value),maxLength:100})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(xe,{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 Fs=(y[He.id]??[]).map(ar=>l.find(tn=>tn.id===ar)).filter(Boolean);return Fs.length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No managers assigned"}):Fs.map(ar=>e.jsxs(Qe,{variant:"default",className:"gap-1",children:[e.jsx(zu,{className:"h-3 w-3"}),ar.name,e.jsx("button",{onClick:()=>ui(ar.id,"brokerage_manager","remove",He.id),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove manager from this brokerage",children:e.jsx(kr,{className:"h-3 w-3"})})]},ar.id))})()}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{className:"text-sm text-muted-foreground",children:"Assign manager from existing members:"}),e.jsxs(mo,{open:as,onOpenChange:qn,children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{variant:"outline",role:"combobox","aria-expanded":as,className:"w-full justify-between",children:["Search for a member...",e.jsx(ln,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(no,{className:"w-full p-0",align:"start",children:e.jsxs(Sx,{children:[e.jsx(Cx,{placeholder:"Search by name or email..."}),e.jsxs(Mx,{className:"max-h-[200px]",children:[e.jsx(Tx,{children:"No members found."}),e.jsx(Ax,{children:(()=>{const Ct=new Set(y[He.id]??[]);return l.filter(Fs=>!Ct.has(Fs.id)&&(r||Fs.brokerage_id===He.id)).map(Fs=>e.jsxs(cp,{value:`${Fs.name} ${Fs.email}`,onSelect:()=>{bu(Fs.id,He.id),qn(!1)},children:[Fs.name," (",Fs.email,")"]},Fs.id))})()})]})]})})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Members in this Brokerage"}),e.jsx("div",{className:"max-h-32 overflow-y-auto border rounded p-2",children:l.filter(Ct=>Ct.brokerage_id===He.id).length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No members"}):l.filter(Ct=>Ct.brokerage_id===He.id).map(Ct=>e.jsxs("div",{className:"text-sm py-1 flex items-center justify-between",children:[e.jsx("span",{children:Ct.name}),Ct.roles.includes("brokerage_manager")&&e.jsx(Qe,{variant:"outline",className:"text-xs",children:"Manager"})]},Ct.id))})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:ac,children:"Cancel"}),e.jsx(W,{onClick:ic,disabled:et,children:et?"Saving...":"Save Changes"})]})]})}),e.jsx(fs,{open:kt,onOpenChange:Ut,children:e.jsxs(ps,{children:[e.jsxs(ks,{children:[e.jsx(_s,{className:"text-destructive",children:"Delete Brokerage"}),e.jsxs(Ir,{children:['Are you sure you want to delete "',Nt==null?void 0:Nt.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 "',Nt==null?void 0:Nt.name,'"']}),e.jsxs("li",{children:["All ",l.filter(Ct=>Ct.brokerage_id===(Nt==null?void 0:Nt.id)).length," member(s) assigned to this brokerage"]}),e.jsx("li",{children:"All their data, roles, and access"})]})]})}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>Ut(!1),children:"Cancel"}),e.jsx(W,{variant:"destructive",onClick:Fm,disabled:ds,children:ds?"Deleting...":"Yes, Delete Brokerage"})]})]})}),e.jsx(fs,{open:lr,onOpenChange:Lt,children:e.jsxs(ps,{className:"max-w-4xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(pa,{className:"h-5 w-5"}),"Manage ",Es==null?void 0:Es.name]}),e.jsx(Ir,{children:"Add, remove, or manage users in this brokerage"})]}),Es&&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(ln,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search members...",value:Hs,onChange:Ct=>mr(Ct.target.value),className:"pl-10 h-9"})]}),e.jsxs(fs,{open:an,onOpenChange:Cr,children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{size:"sm",children:[e.jsx(Jo,{className:"h-4 w-4 mr-1"}),"Add New Agent"]})}),e.jsxs(ps,{children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Add New Agent"}),e.jsxs(Ir,{children:["Create a new agent for ",Es.name]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"agent-name",children:"Name"}),e.jsx(De,{id:"agent-name",placeholder:"John Doe",value:Fr.name,onChange:Ct=>$r({...Fr,name:Ct.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"agent-email",children:"Email"}),e.jsx(De,{id:"agent-email",type:"email",placeholder:"john@example.com",value:Fr.email,onChange:Ct=>$r({...Fr,email:Ct.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"agent-password",children:"Password"}),e.jsx(De,{id:"agent-password",type:"password",placeholder:"Min 6 characters",value:Fr.password,onChange:Ct=>$r({...Fr,password:Ct.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"agent-phone",children:"Phone (optional)"}),e.jsx(De,{id:"agent-phone",type:"tel",placeholder:"555-123-4567",value:Fr.phone,onChange:Ct=>$r({...Fr,phone:Ct.target.value})})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>Cr(!1),children:"Cancel"}),e.jsx(W,{onClick:Bm,disabled:nr,children:nr?"Creating...":"Create Agent"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Add existing user:"}),e.jsxs(mo,{open:un,onOpenChange:qr,children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{variant:"outline",role:"combobox","aria-expanded":un,className:"w-[300px] justify-between",children:["Select a user to add...",e.jsx(ln,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(no,{className:"w-[300px] p-0",align:"start",children:e.jsxs(Sx,{children:[e.jsx(Cx,{placeholder:"Search users...",value:Zr,onValueChange:La}),e.jsxs(Mx,{children:[e.jsx(Tx,{children:"No users found."}),e.jsx(Ax,{children:L0(Es.id).filter(Ct=>Zr===""||Ct.name.toLowerCase().includes(Zr.toLowerCase())||Ct.email.toLowerCase().includes(Zr.toLowerCase())).map(Ct=>e.jsxs(cp,{value:`${Ct.name} ${Ct.email}`,onSelect:()=>{Wu(Ct.id,Es.id),qr(!1),La("")},children:[Ct.name," (",Ct.email,")"]},Ct.id))})]})]})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto border rounded-lg",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(St,{className:"font-semibold",children:"Name"}),e.jsx(St,{className:"font-semibold",children:"Email"}),e.jsx(St,{className:"font-semibold",children:"Status"}),e.jsx(St,{className:"font-semibold",children:"Role"}),e.jsx(St,{className:"w-[120px]"})]})}),e.jsx(Rn,{children:Cd(Es.id).length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:Hs?"No matching members found":"No members in this brokerage"})}):Cd(Es.id).map(Ct=>e.jsxs(Ps,{className:"hover:bg-muted/30",children:[e.jsx(ht,{className:"font-medium",children:Ct.name}),e.jsx(ht,{className:"text-muted-foreground",children:Ct.email}),e.jsx(ht,{children:Ct.claimed?e.jsx(Qe,{variant:"default",className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active"}):e.jsx(Qe,{variant:"secondary",children:"Pending"})}),e.jsx(ht,{children:Ct.roles.includes("brokerage_manager")?e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(zu,{className:"h-3 w-3"}),"Manager"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"Agent"})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[!Ct.claimed&&e.jsx(W,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Yi(Ct.id),title:"Resend welcome email",children:e.jsx(tr,{className:"h-4 w-4"})}),e.jsx(W,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>zm(Ct.id),title:"Remove from brokerage",children:e.jsx(kr,{className:"h-4 w-4"})}),e.jsx(W,{size:"icon",variant:"ghost",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:()=>Af(Ct.id),disabled:a||Ct.id===(s==null?void 0:s.id),title:Ct.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${Ct.name}`,children:a?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(lS,{className:"h-4 w-4"})}),e.jsx(W,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>$i(Ct.id,Ct.name),title:"Delete user",children:e.jsx(vr,{className:"h-4 w-4"})})]})})]},Ct.id))})]})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Sd(Es.id).length," total member",Sd(Es.id).length!==1?"s":""," •",Sd(Es.id).filter(Ct=>Ct.roles.includes("brokerage_manager")).length," manager",Sd(Es.id).filter(Ct=>Ct.roles.includes("brokerage_manager")).length!==1?"s":""]})]}),e.jsx(gn,{children:e.jsx(W,{variant:"outline",onClick:ju,children:"Close"})})]})})]}),e.jsx(Ss,{value:"teams",children:e.jsx(jVt,{})}),e.jsx(Ss,{value:"trials",children:e.jsx(vVt,{})}),e.jsx(Ss,{value:"celebrations",children:e.jsx(yVt,{})}),e.jsx(Ss,{value:"deletions",children:e.jsx(_Vt,{})})]})]}),e.jsx(utt,{open:Br,onOpenChange:Kr,brokerages:p,onSuccess:ua}),Vt&&e.jsx(htt,{open:At,onOpenChange:Ct=>{Gt(Ct),Ct||Xt(null)},userId:Vt.id,userName:Vt.name})]})},kVt=()=>{const[t,s]=k.useState([]),[r,n]=k.useState(!0),[a,o]=k.useState(!1),[l,i]=k.useState(""),[d,u]=k.useState(""),[p,f]=k.useState(""),[y,_]=k.useState("");k.useEffect(()=>{b()},[]);const b=async()=>{const{data:L,error:O}=await G.from("invite_codes").select("*").order("created_at",{ascending:!1});O?(pe.error("Failed to load invite codes"),console.error(O)):s(L||[]),n(!1)},N=async L=>{if(L.preventDefault(),!l.trim()){pe.error("Please enter a code");return}o(!0);const{error:O}=await G.from("invite_codes").insert({code:l.trim().toUpperCase(),description:d.trim()||null,max_uses:p?parseInt(p):null,trial_days:y?parseInt(y):null});O?O.code==="23505"?pe.error("This code already exists"):(pe.error("Failed to create invite code"),console.error(O)):(pe.success("Invite code created"),i(""),u(""),f(""),_(""),b()),o(!1)},w=async(L,O)=>{const{error:V}=await G.from("invite_codes").update({is_active:!O}).eq("id",L);V?pe.error("Failed to update code"):s(t.map(q=>q.id===L?{...q,is_active:!O}:q))},S=async L=>{const{error:O}=await G.from("invite_codes").delete().eq("id",L);O?pe.error("Failed to delete code"):(pe.success("Code deleted"),s(t.filter(V=>V.id!==L)))},C="https://dashboard.relevelup.com",A=L=>{const O=`${C}/join?code=${L}`;navigator.clipboard.writeText(O),pe.success("Link copied to clipboard")},I=`${C}/join`;return e.jsx(Ds,{title:"Invite Codes",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Hu,{title:"Invite Codes",description:"Manage signup invite codes"}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"Create New Code"}),e.jsxs(dr,{children:["Share link: ",e.jsx("code",{className:"bg-muted px-2 py-1 rounded text-sm",children:I})]})]}),e.jsx(Oe,{children:e.jsxs("form",{onSubmit:N,className:"flex flex-wrap gap-4 items-end",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"code",children:"Code"}),e.jsx(De,{id:"code",placeholder:"WELCOME2024",value:l,onChange:L=>i(L.target.value),className:"w-40"})]}),e.jsxs("div",{className:"space-y-2 flex-1 min-w-[200px]",children:[e.jsx(xe,{htmlFor:"description",children:"Description (optional)"}),e.jsx(De,{id:"description",placeholder:"For marketing campaign",value:d,onChange:L=>u(L.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"maxUses",children:"Max Uses"}),e.jsx(De,{id:"maxUses",type:"number",placeholder:"Unlimited",value:p,onChange:L=>f(L.target.value),className:"w-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"trialDays",children:"Trial Days"}),e.jsx(De,{id:"trialDays",type:"number",placeholder:"None",value:y,onChange:L=>_(L.target.value),className:"w-28"})]}),e.jsxs(W,{type:"submit",disabled:a,children:[a?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create"]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Active Codes"})}),e.jsx(Oe,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(us,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):t.length===0?e.jsx("p",{className:"text-center py-8 text-muted-foreground",children:"No invite codes yet"}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Code"}),e.jsx(St,{children:"Description"}),e.jsx(St,{children:"Uses"}),e.jsx(St,{children:"Trial"}),e.jsx(St,{children:"Created"}),e.jsx(St,{children:"Active"}),e.jsx(St,{className:"w-24",children:"Actions"})]})}),e.jsx(Rn,{children:t.map(L=>e.jsxs(Ps,{children:[e.jsx(ht,{className:"font-mono font-medium",children:L.code}),e.jsx(ht,{className:"text-muted-foreground",children:L.description||"—"}),e.jsxs(ht,{children:[L.uses_count,L.max_uses&&` / ${L.max_uses}`]}),e.jsx(ht,{children:L.trial_days?e.jsxs("span",{className:"text-amber-600 dark:text-amber-400 font-medium",children:[L.trial_days," days"]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(ht,{className:"text-muted-foreground",children:vs(new Date(L.created_at),"MMM d, yyyy")}),e.jsx(ht,{children:e.jsx(Ar,{checked:L.is_active,onCheckedChange:()=>w(L.id,L.is_active)})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>A(L.code),title:"Copy invite link",children:e.jsx(Va,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>S(L.id),className:"text-destructive hover:text-destructive",title:"Delete code",children:e.jsx(vr,{className:"h-4 w-4"})})]})})]},L.id))})]})})]})]})})},rO=async t=>{try{const{data:s,error:r}=await G.from("push_notification_settings").select("is_enabled").eq("setting_key",t).maybeSingle();return r?(console.error("Error checking notification setting:",r),!0):(s==null?void 0:s.is_enabled)??!0}catch(s){return console.error("Error checking notification setting:",s),!0}},rE=async t=>{try{const{data:s,error:r}=await G.functions.invoke("send-push-notification",{body:t});return r?(console.error("Error sending notification:",r),{success:!1,error:r}):(console.log("Notification sent:",s),{success:!0,data:s})}catch(s){return console.error("Error sending notification:",s),{success:!1,error:s}}},SVt=async(t,s)=>await rO("new_templates")?rE({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}),CVt=async(t,s)=>rE({title:"New Academy Video",body:`New video added: ${t}`,url:`/academy/${s}`}),MVt=async(t,s)=>await rO("new_events")?rE({title:"New Event",body:`New event: ${t}`,url:`/events/${s}`}):(console.log("New event notifications are disabled"),{success:!1,skipped:!0}),TVt=async(t,s)=>await rO("new_toolbox")?rE({title:"New Resource Kit",body:`New resource kit available: ${t}`,url:`/toolbox/${s}`}):(console.log("New toolbox notifications are disabled"),{success:!1,skipped:!0}),Z_e=async(t,s)=>await rO("new_social_swag")?rE({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}),AVt=async(t,s)=>await rO("new_newsletters")?rE({title:"New Newsletter",body:`New newsletter available: ${t}`,url:`/newsletters/${s}`}):(console.log("New newsletter notifications are disabled"),{success:!1,skipped:!0}),e9={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 EVt(){const t=wr(),s=Qt(),[r,n]=k.useState(!1),[a,o]=k.useState(null),[l,i]=k.useState(e9),[d,u]=k.useState(null),[p,f]=k.useState(null),[y,_]=k.useState(!1),b=k.useRef(null),[N,w]=k.useState(!1),[S,C]=k.useState(null),[A,I]=k.useState(!1),[L,O]=k.useState(null),[V,q]=k.useState(null),[B,U]=k.useState(!0),[te,Y]=k.useState(""),{data:J,isLoading:X}=gt({queryKey:["admin-events"],queryFn:async()=>{const{data:Te,error:We}=await G.from("events").select("*").order("event_date",{ascending:!0});if(We)throw We;return Te}}),{data:ce}=gt({queryKey:["event-registrations-count"],queryFn:async()=>{let Te=[],We=0;const Ke=1e3;for(;;){const{data:He,error:Je}=await G.from("event_registrations").select("event_id").range(We,We+Ke-1);if(Je)throw Je;if(!He||He.length===0||(Te=Te.concat(He),He.length{ot[He.event_id]=(ot[He.event_id]||0)+1}),ot}}),{data:ie,isLoading:ae}=gt({queryKey:["event-registrations-details",S==null?void 0:S.id],queryFn:async()=>{if(!S)return[];const{data:Te,error:We}=await G.from("event_registrations").select("id, user_id, registered_at, zoom_join_url, zoom_name, zoom_email").eq("event_id",S.id).order("registered_at",{ascending:!1});if(We)throw We;if(!Te||Te.length===0)return[];const Ke=Te.map(Je=>Je.user_id).filter(Boolean);let ot=[];if(Ke.length>0){const{data:Je,error:ut}=await G.from("profiles").select("id, name, email").in("id",Ke);if(ut)throw ut;ot=Je||[]}const He=new Map((ot==null?void 0:ot.map(Je=>[Je.id,Je]))||[]);return Te.map(Je=>({...Je,profiles:Je.user_id&&He.get(Je.user_id)||null}))},enabled:!!S}),{data:oe,isLoading:me}=gt({queryKey:["event-attendees-details",S==null?void 0:S.id],queryFn:async()=>{if(!S)return[];const{data:Te,error:We}=await G.from("event_attendees").select("id, user_id, zoom_email, zoom_name, join_time, leave_time, duration_minutes, manually_added, created_at").eq("event_id",S.id).order("created_at",{ascending:!1});if(We)throw We;if(!Te||Te.length===0)return[];const Ke=Te.map(mt=>mt.user_id).filter(Boolean);let ot=[];if(Ke.length>0){const{data:mt,error:et}=await G.from("profiles").select("id, name, email").in("id",Ke);if(et)throw et;ot=mt||[]}const{data:He}=await G.from("agent_points").select("user_id").eq("event_id",S.id),Je=new Set((He==null?void 0:He.map(mt=>mt.user_id))||[]),ut=new Map((ot==null?void 0:ot.map(mt=>[mt.id,mt]))||[]);return Te.map(mt=>({...mt,profiles:mt.user_id&&ut.get(mt.user_id)||null,points_awarded:mt.user_id?Je.has(mt.user_id):!1}))},enabled:!!S}),ve=Te=>{C(Te),w(!0)},he=Pt({mutationFn:async Te=>{const{data:{session:We}}=await G.auth.getSession();if(!We)throw new Error("Not authenticated");const Ke=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-registrations",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${We.access_token}`},body:JSON.stringify({event_id:Te})}),ot=await Ke.json();if(!Ke.ok)throw new Error(ot.error||"Failed to sync");return ot},onSuccess:Te=>{s.invalidateQueries({queryKey:["event-registrations-details",S==null?void 0:S.id]}),s.invalidateQueries({queryKey:["event-registrations-count"]}),pe.success(Te.message)},onError:Te=>{pe.error("Failed to sync: "+Te.message)}}),ge=Pt({mutationFn:async Te=>{const{data:{session:We}}=await G.auth.getSession();if(!We)throw new Error("Not authenticated");const Ke=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-attendees",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${We.access_token}`},body:JSON.stringify({event_id:Te})}),ot=await Ke.json();if(!Ke.ok)throw new Error(ot.error||"Failed to sync attendees");return ot},onSuccess:Te=>{s.invalidateQueries({queryKey:["event-attendees-details",S==null?void 0:S.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]}),Te!=null&&Te.message?pe.success(Te.message):pe.success(`Synced ${Te.synced||0} attendees. ${Te.points_awarded||0} points awarded!`)},onError:Te=>{pe.error("Failed to sync attendees: "+Te.message)}}),je=Pt({mutationFn:async({eventId:Te,testMode:We})=>{const{data:{session:Ke}}=await G.auth.getSession();if(!Ke)throw new Error("Not authenticated");const ot=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-event-reminder",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ke.access_token}`},body:JSON.stringify({event_id:Te,test_mode:We})}),He=await ot.json();if(!ot.ok)throw new Error(He.error||"Failed to send reminders");return He},onSuccess:Te=>{Te.test?pe.success(Te.message||"Test email sent!"):pe.success(Te.message||`Reminder emails sent to ${Te.sent} registrants!`)},onError:Te=>{pe.error("Failed to send reminders: "+Te.message)}}),{data:qe}=gt({queryKey:["all-profiles-for-linking"],queryFn:async()=>{let Te=[],We=0;const Ke=1e3;for(;;){const{data:ot,error:He}=await G.from("profiles").select("id, name, email").order("name",{ascending:!0}).range(We,We+Ke-1);if(He)throw He;if(!ot||ot.length===0||(Te=[...Te,...ot],ot.length{const{error:He}=await G.from("event_attendees").update({user_id:We}).eq("id",Te);if(He)throw He;if(ot&&Ke){const{error:ut}=await G.from("zoom_email_aliases").upsert({user_id:We,zoom_email:Ke.toLowerCase()},{onConflict:"zoom_email"});ut&&console.error("Failed to save alias:",ut)}const Je=S==null?void 0:S.id;if(Je){const{data:ut}=await G.from("user_roles").select("id").eq("user_id",We).eq("role","admin").single();if(!ut){const{data:mt}=await G.from("agent_points").select("id").eq("user_id",We).eq("event_id",Je).single();mt||(await G.rpc("award_attendance_points",{p_user_id:We,p_event_id:Je,p_points:10,p_reason:"Event Attendance (Manual Link)"}),await G.rpc("check_and_award_badges",{p_user_id:We}))}}return{userId:We,zoomEmail:Ke,shouldSaveAlias:ot}},onSuccess:Te=>{s.invalidateQueries({queryKey:["event-attendees-details",S==null?void 0:S.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]});let We="Attendee linked and points awarded!";Te.shouldSaveAlias&&Te.zoomEmail&&(We+=` Email "${Te.zoomEmail}" will be auto-matched in the future.`),pe.success(We),I(!1),O(null),q(null),Y("")},onError:Te=>{pe.error("Failed to link attendee: "+Te.message)}}),ke=Te=>{O(Te),q(null),U(!0),Y(""),I(!0)},Re=()=>{!L||!V||Me.mutate({attendeeId:L.id,userId:V,zoomEmail:L.zoom_email,shouldSaveAlias:B})},Ve=(qe==null?void 0:qe.filter(Te=>{var Ke,ot;if(!te)return!0;const We=te.toLowerCase();return((Ke=Te.name)==null?void 0:Ke.toLowerCase().includes(We))||((ot=Te.email)==null?void 0:ot.toLowerCase().includes(We))}))||[],Ne=async Te=>{const We=Te.name.split(".").pop(),ot=`${`${crypto.randomUUID()}.${We}`}`,{error:He}=await G.storage.from("event-images").upload(ot,Te);if(He)throw He;const{data:{publicUrl:Je}}=G.storage.from("event-images").getPublicUrl(ot);return Je},Ue=Te=>{var Ke;const We=(Ke=Te.target.files)==null?void 0:Ke[0];if(We){if(We.size>5*1024*1024){pe.error("Image must be less than 5MB");return}u(We),f(URL.createObjectURL(We))}},Ie=()=>{u(null),f(null),i({...l,image_url:""}),b.current&&(b.current.value="")},ye=Pt({mutationFn:async Te=>{_(!0);let We=Te.image_url;d&&(We=await Ne(d)||"");const Ke=new Date(Te.event_date),[ot,He]=Te.event_time.split(":");Ke.setHours(parseInt(ot),parseInt(He));const Je=[new Date(Ke)];if(Te.is_recurring&&Te.recurrence_end_date){let Ze=new Date(Ke);for(;Te.recurrence_pattern==="weekly"?Ze=x4(Ze,1):Te.recurrence_pattern==="biweekly"?Ze=x4(Ze,2):Ze=Am(Ze,1),!(Ze>Te.recurrence_end_date);)Je.push(new Date(Ze))}const ut=Je.map(Ze=>({title:Te.title,description:Te.description||null,image_url:We||null,video_url:Te.video_url||null,event_date:Ze.toISOString(),zoom_link:Te.zoom_link,zoom_meeting_id:Te.zoom_meeting_id||null,capacity:Te.capacity?parseInt(Te.capacity):null,is_published:Te.is_published})),{data:mt,error:et}=await G.from("events").insert(ut).select();if(et)throw et;return mt&&mt.length>0&&MVt(Te.title,mt[0].id),Je.length},onSuccess:Te=>{s.invalidateQueries({queryKey:["admin-events"]}),pe.success(Te>1?`${Te} recurring events created successfully`:"Event created successfully"),n(!1),i(e9),u(null),f(null),_(!1)},onError:Te=>{pe.error("Failed to create event: "+Te.message),_(!1)}}),ct=Pt({mutationFn:async({id:Te,data:We})=>{_(!0);let Ke=We.image_url;d&&(Ke=await Ne(d)||"");const ot=new Date(We.event_date),[He,Je]=We.event_time.split(":");ot.setHours(parseInt(He),parseInt(Je));const{error:ut}=await G.from("events").update({title:We.title,description:We.description||null,image_url:Ke||null,video_url:We.video_url||null,event_date:ot.toISOString(),zoom_link:We.zoom_link,zoom_meeting_id:We.zoom_meeting_id||null,capacity:We.capacity?parseInt(We.capacity):null,is_published:We.is_published}).eq("id",Te);if(ut)throw ut},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),pe.success("Event updated successfully"),n(!1),o(null),i(e9),u(null),f(null),_(!1)},onError:Te=>{pe.error("Failed to update event: "+Te.message),_(!1)}}),fe=Pt({mutationFn:async Te=>{const{error:We}=await G.from("events").delete().eq("id",Te);if(We)throw We},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),pe.success("Event deleted successfully")},onError:Te=>{pe.error("Failed to delete event: "+Te.message)}}),$e=Te=>{var Ke;const We=new Date(Te.event_date);o(Te),i({title:Te.title,description:Te.description||"",image_url:Te.image_url||"",video_url:Te.video_url||"",event_date:We,event_time:vs(We,"HH:mm"),zoom_link:Te.zoom_link,zoom_meeting_id:Te.zoom_meeting_id||"",capacity:((Ke=Te.capacity)==null?void 0:Ke.toString())||"",is_published:Te.is_published,is_recurring:!1,recurrence_pattern:"weekly",recurrence_end_date:void 0}),f(Te.image_url||null),u(null),n(!0)},Ye=Te=>{if(Te.preventDefault(),!l.event_date){pe.error("Please select a date");return}if(l.is_recurring&&!l.recurrence_end_date){pe.error("Please select an end date for recurring events");return}a?ct.mutate({id:a.id,data:l}):ye.mutate(l)},tt=()=>{n(!1),o(null),i(e9),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(W,{variant:"ghost",size:"icon",onClick:()=>t("/dashboard"),children:e.jsx(Oa,{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(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{children:"All Events"}),e.jsxs(fs,{open:r,onOpenChange:Te=>!Te&&tt(),children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{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(ks,{children:e.jsx(_s,{children:a?"Edit Event":"Create New Event"})}),e.jsxs("form",{onSubmit:Ye,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"title",children:"Title *"}),e.jsx(De,{id:"title",value:l.title,onChange:Te=>i({...l,title:Te.target.value}),placeholder:"Event title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Description"}),e.jsx(Wg,{content:l.description,onChange:Te=>i({...l,description:Te}),placeholder:"Event description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Event Image"}),e.jsx("input",{type:"file",ref:b,accept:"image/*",onChange:Ue,className:"hidden"}),p?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:p,alt:"Event preview",className:"w-full h-32 object-cover rounded-lg border"}),e.jsx(W,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:Ie,children:e.jsx(kr,{className:"h-4 w-4"})})]}):e.jsxs(W,{type:"button",variant:"outline",className:"w-full h-32 border-dashed flex flex-col gap-2",onClick:()=>{var Te;return(Te=b.current)==null?void 0:Te.click()},children:[e.jsx(Ra,{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(xe,{children:"Date *"}),e.jsxs(mo,{children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{variant:"outline",className:Ot("w-full justify-start text-left font-normal",!l.event_date&&"text-muted-foreground"),children:[e.jsx(cn,{className:"mr-2 h-4 w-4"}),l.event_date?vs(l.event_date,"PPP"):"Pick a date"]})}),e.jsx(no,{className:"w-auto p-0",align:"start",children:e.jsx(uf,{mode:"single",selected:l.event_date,onSelect:Te=>i({...l,event_date:Te}),initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"time",children:"Time *"}),e.jsx(De,{id:"time",type:"time",value:l.event_time,onChange:Te=>i({...l,event_time:Te.target.value}),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"zoom_link",children:"Zoom Link *"}),e.jsx(De,{id:"zoom_link",value:l.zoom_link,onChange:Te=>i({...l,zoom_link:Te.target.value}),placeholder:"https://zoom.us/j/...",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"zoom_meeting_id",children:"Zoom Meeting ID (for API registration)"}),e.jsx(De,{id:"zoom_meeting_id",value:l.zoom_meeting_id,onChange:Te=>i({...l,zoom_meeting_id:Te.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(xe,{htmlFor:"video_url",children:"Promo Video URL (optional)"}),e.jsx(De,{id:"video_url",value:l.video_url,onChange:Te=>i({...l,video_url:Te.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(xe,{htmlFor:"capacity",children:"Capacity (optional)"}),e.jsx(De,{id:"capacity",type:"number",value:l.capacity,onChange:Te=>i({...l,capacity:Te.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(IL,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(xe,{htmlFor:"is_recurring",children:"Recurring Event"})]}),e.jsx(Ar,{id:"is_recurring",checked:l.is_recurring,onCheckedChange:Te=>i({...l,is_recurring:Te})})]}),l.is_recurring&&e.jsxs("div",{className:"space-y-3 pt-1",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Frequency"}),e.jsxs($s,{value:l.recurrence_pattern,onValueChange:Te=>i({...l,recurrence_pattern:Te}),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"weekly",children:"Weekly"}),e.jsx(vt,{value:"biweekly",children:"Every 2 Weeks"}),e.jsx(vt,{value:"monthly",children:"Monthly"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Repeat Until"}),e.jsxs(mo,{children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{variant:"outline",className:Ot("w-full justify-start text-left font-normal",!l.recurrence_end_date&&"text-muted-foreground"),children:[e.jsx(cn,{className:"mr-2 h-4 w-4"}),l.recurrence_end_date?vs(l.recurrence_end_date,"PPP"):"Pick end date"]})}),e.jsx(no,{className:"w-auto p-0",align:"start",children:e.jsx(uf,{mode:"single",selected:l.recurrence_end_date,onSelect:Te=>i({...l,recurrence_end_date:Te}),disabled:Te=>Te<(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 Te=1,We=new Date(l.event_date);for(;We=l.recurrence_pattern==="weekly"?x4(We,1):l.recurrence_pattern==="biweekly"?x4(We,2):Am(We,1),!(We>l.recurrence_end_date);)Te++;return Te})()," events with the same Zoom link"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{htmlFor:"is_published",children:"Published"}),e.jsx(Ar,{id:"is_published",checked:l.is_published,onCheckedChange:Te=>i({...l,is_published:Te})})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx(W,{type:"button",variant:"outline",onClick:tt,className:"flex-1",children:"Cancel"}),e.jsx(W,{type:"submit",className:"flex-1",disabled:ye.isPending||ct.isPending||y,children:y?"Uploading...":a?"Update Event":l.is_recurring&&l.event_date&&l.recurrence_end_date?"Create Recurring Events":"Create Event"})]})]})]})]})]}),e.jsx(Oe,{children:X?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading events..."}):(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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Date & Time"}),e.jsx(St,{children:"Registrations"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:J==null?void 0:J.map(Te=>e.jsxs(Ps,{children:[e.jsx(ht,{className:"font-medium",children:Te.title}),e.jsx(ht,{children:vs(new Date(Te.event_date),"PPP p")}),e.jsx(ht,{children:e.jsxs(W,{variant:"ghost",size:"sm",className:"gap-1",onClick:()=>ve(Te),children:[e.jsx(ir,{className:"h-4 w-4"}),(ce==null?void 0:ce[Te.id])||0,Te.capacity&&` / ${Te.capacity}`]})}),e.jsx(ht,{children:e.jsx("span",{className:Ot("px-2 py-1 rounded-full text-xs font-medium",Te.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:Te.is_published?"Published":"Draft"})}),e.jsx(ht,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>window.open(Te.zoom_link,"_blank"),title:"Open Zoom Link",children:e.jsx(Yr,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>$e(Te),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this event?")&&fe.mutate(Te.id)},children:e.jsx(vr,{className:"h-4 w-4 text-destructive"})})]})})]},Te.id))})]})})]}),e.jsx(fs,{open:N,onOpenChange:w,children:e.jsxs(ps,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(ir,{className:"h-5 w-5"}),S==null?void 0:S.title]}),e.jsx(Ir,{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(W,{variant:"ghost",size:"sm",onClick:()=>je.mutate({eventId:S.id,testMode:!0}),disabled:je.isPending,children:[e.jsx(tr,{className:Ot("h-4 w-4 mr-2",je.isPending&&"animate-spin")}),"Send Test to Me"]}),e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>je.mutate({eventId:S.id}),disabled:je.isPending||!(ie!=null&&ie.length),children:[e.jsx(tr,{className:Ot("h-4 w-4 mr-2",je.isPending&&"animate-spin")}),je.isPending?"Sending...":"Send Reminder to All"]}),(S==null?void 0:S.zoom_meeting_id)&&e.jsxs(e.Fragment,{children:[e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>he.mutate(S.id),disabled:he.isPending,children:[e.jsx(Zi,{className:Ot("h-4 w-4 mr-2",he.isPending&&"animate-spin")}),he.isPending?"Syncing...":"Sync Registrations"]}),e.jsxs(W,{variant:"default",size:"sm",onClick:()=>ge.mutate(S.id),disabled:ge.isPending,children:[e.jsx(Fi,{className:Ot("h-4 w-4 mr-2",ge.isPending&&"animate-spin")}),ge.isPending?"Syncing...":"Sync Attendees & Award Points"]})]})]}),e.jsxs(ta,{defaultValue:"registrations",className:"w-full",children:[e.jsxs(Jn,{className:"grid w-full grid-cols-2",children:[e.jsxs(cs,{value:"registrations",className:"gap-2",children:[e.jsx(ir,{className:"h-4 w-4"}),"Registrations (",(ie==null?void 0:ie.length)||0,")"]}),e.jsxs(cs,{value:"attendees",className:"gap-2",children:[e.jsx($n,{className:"h-4 w-4"}),"Attendees (",(oe==null?void 0:oe.length)||0,")"]})]}),e.jsx(Ss,{value:"registrations",className:"mt-4",children:ae?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading registrations..."}):(ie==null?void 0:ie.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No registrations yet for this event."}),(S==null?void 0:S.zoom_meeting_id)&&e.jsx("p",{className:"text-xs mt-2",children:'Click "Sync Registrations" to import from Zoom.'})]}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Registered"}),e.jsx(St,{children:"Status"})]})}),e.jsx(Rn,{children:ie==null?void 0:ie.map(Te=>{var He,Je;const We=((He=Te.profiles)==null?void 0:He.name)||Te.zoom_name||"Unknown",Ke=((Je=Te.profiles)==null?void 0:Je.email)||Te.zoom_email||null,ot=!Te.user_id;return e.jsxs(Ps,{children:[e.jsx(ht,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[We,ot&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"External"})]})}),e.jsx(ht,{children:Ke?e.jsxs("a",{href:`mailto:${Ke}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(tr,{className:"h-3 w-3"}),Ke]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(ht,{className:"text-muted-foreground text-sm",children:vs(new Date(Te.registered_at),"MMM d, yyyy h:mm a")}),e.jsx(ht,{children:Te.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"})})]},Te.id)})})]})}),e.jsx(Ss,{value:"attendees",className:"mt-4",children:me?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."}),(S==null?void 0:S.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(Te=>!Te.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(ro,{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(Te=>!Te.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(Te=>!Te.user_id).map(Te=>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:Te.zoom_name||"Unknown"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Te.zoom_email||"No email"})]}),e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>ke(Te),className:"gap-1",children:[e.jsx(Do,{className:"h-3 w-3"}),"Link to Profile"]})]},Te.id))})]}),e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Duration"}),e.jsx(St,{children:"Points"})]})}),e.jsx(Rn,{children:oe==null?void 0:oe.filter(Te=>Te.user_id).map(Te=>{var ot,He;const We=((ot=Te.profiles)==null?void 0:ot.name)||Te.zoom_name||"Unknown",Ke=((He=Te.profiles)==null?void 0:He.email)||Te.zoom_email||null;return e.jsxs(Ps,{children:[e.jsx(ht,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[We,Te.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(ht,{children:Ke?e.jsxs("a",{href:`mailto:${Ke}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(tr,{className:"h-3 w-3"}),Ke]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(ht,{children:Te.duration_minutes?e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-sm",children:[e.jsx(nn,{className:"h-3 w-3"}),Te.duration_minutes," min"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(ht,{children:Te.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(Fi,{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"})})]},Te.id)})})]})]})})]})]})}),e.jsx(fs,{open:A,onOpenChange:I,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsxs(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(Do,{className:"h-5 w-5"}),"Link Attendee to Profile"]}),e.jsx(Ir,{children:"Link this Zoom attendee to an existing member profile to award them points."})]}),L&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-3 bg-muted rounded-lg",children:[e.jsx("p",{className:"text-sm font-medium",children:L.zoom_name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:L.zoom_email||"No email"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Search for a profile"}),e.jsxs("div",{className:"relative",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name or email...",value:te,onChange:Te=>Y(Te.target.value),className:"pl-9"})]})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-md",children:Ve.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:Ve.slice(0,20).map(Te=>e.jsxs("button",{type:"button",onClick:()=>q(Te.id),className:Ot("w-full p-3 text-left hover:bg-muted/50 transition-colors",V===Te.id&&"bg-primary/10 border-l-2 border-primary"),children:[e.jsx("p",{className:"text-sm font-medium",children:Te.name||"Unnamed"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Te.email})]},Te.id))})}),L.zoom_email&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ri,{id:"save-alias",checked:B,onCheckedChange:Te=>U(Te)}),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(W,{variant:"outline",onClick:()=>I(!1),children:"Cancel"}),e.jsx(W,{onClick:Re,disabled:!V||Me.isPending,children:Me.isPending?"Linking...":"Link & Award Points"})]})]})]})})]})})}function PVt({selectedKitIds:t,onChange:s}){const[r,n]=k.useState(""),[a,o]=k.useState(!1),{data:l=[]}=gt({queryKey:["all-resource-kits-picker"],queryFn:async()=>{const{data:f,error:y}=await G.from("resource_kits").select("id, name, featured_image_url").eq("is_published",!0).order("name");if(y)throw y;return f}}),i=l.filter(f=>t.includes(f.id)),d=l.filter(f=>!t.includes(f.id)&&f.name.toLowerCase().includes(r.toLowerCase())),u=f=>{s([...t,f])},p=f=>{s(t.filter(y=>y!==f))};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{className:"flex items-center gap-2",children:[e.jsx(cl,{className:"h-4 w-4"}),"Linked Toolkits"]}),i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(f=>e.jsxs(Qe,{variant:"secondary",className:"gap-1 pr-1",children:[f.name,e.jsx("button",{type:"button",onClick:()=>p(f.id),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(kr,{className:"h-3 w-3"})})]},f.id))}),e.jsxs(mo,{open:a,onOpenChange:o,children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(cl,{className:"h-3.5 w-3.5"}),"Add Toolkit"]})}),e.jsxs(no,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(ln,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(De,{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:d.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:r?"No toolkits found":"All toolkits selected"}):d.map(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(cl,{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 IVt=()=>{const{user:t}=Us(),{toast:s}=ja(),r=Qt(),[n,a]=Nc(),[o,l]=k.useState(!1),[i,d]=k.useState(null),[u,p]=k.useState({name:"",description:"",category_id:"",type_id:"",publish_date:new Date().toISOString().split("T")[0],links:[{title:"",canva_share_link:"",sort_order:0}],guides:[],video_url:""}),[f,y]=k.useState(null),[_,b]=k.useState(0),[N,w]=k.useState(!1),[S,C]=k.useState(null),[A,I]=k.useState(""),[L,O]=k.useState([]),[V,q]=k.useState(""),[B,U]=k.useState(""),[te,Y]=k.useState(!1),[J,X]=k.useState(!1),{data:ce=[]}=gt({queryKey:["template-categories"],queryFn:async()=>{const{data:$e,error:Ye}=await G.from("template_categories").select("*").order("name");if(Ye)throw Ye;return $e}}),{data:ie=[]}=gt({queryKey:["template-types"],queryFn:async()=>{const{data:$e,error:Ye}=await G.from("template_types").select("*").order("name");if(Ye)throw Ye;return $e}}),{data:ae=[],isLoading:oe}=gt({queryKey:["canva-templates-admin"],queryFn:async()=>{const{data:$e,error:Ye}=await G.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(Ye)throw Ye;const{data:tt,error:Te}=await G.from("template_links").select("*").order("sort_order");if(Te)throw Te;const{data:We,error:Ke}=await G.from("template_guides").select("*").order("sort_order");if(Ke)throw Ke;return $e.map(He=>({...He,links:(tt==null?void 0:tt.filter(Je=>Je.template_id===He.id))||[],guides:(We==null?void 0:We.filter(Je=>Je.template_id===He.id))||[]}))}});k.useEffect(()=>{const $e=n.get("edit");if($e&&ae.length>0){const Ye=ae.find(tt=>tt.id===$e);Ye&&(qe(Ye),a({},{replace:!0}))}},[ae,n]);const me=Pt({mutationFn:async $e=>{const{data:Ye,error:tt}=await G.from("template_categories").insert({name:$e}).select().single();if(tt)throw tt;return Ye},onSuccess:$e=>{r.invalidateQueries({queryKey:["template-categories"]}),p({...u,category_id:$e.id}),q(""),Y(!1),s({title:"Category added"})},onError:$e=>{s({title:"Error adding category",description:$e.message,variant:"destructive"})}}),ve=Pt({mutationFn:async $e=>{const{data:Ye,error:tt}=await G.from("template_types").insert({name:$e}).select().single();if(tt)throw tt;return Ye},onSuccess:$e=>{r.invalidateQueries({queryKey:["template-types"]}),p({...u,type_id:$e.id}),U(""),X(!1),s({title:"Type added"})},onError:$e=>{s({title:"Error adding type",description:$e.message,variant:"destructive"})}}),he=Pt({mutationFn:async $e=>{var Ke;let Ye=$e.existingImageUrl;if($e.image){const ot=$e.image.name.split(".").pop(),He=`${Date.now()}-${Math.random().toString(36).substring(7)}.${ot}`,{error:Je}=await G.storage.from("template-previews").upload(He,$e.image);if(Je)throw Je;const{data:ut}=G.storage.from("template-previews").getPublicUrl(He);Ye=ut.publicUrl}const tt={name:$e.template.name,description:$e.template.description||null,category_id:$e.template.category_id||null,type_id:$e.template.type_id||null,preview_image_url:Ye,video_url:$e.videoUrl||null,publish_date:$e.template.publish_date?new Date($e.template.publish_date).toISOString():new Date().toISOString(),created_by:t==null?void 0:t.id};let Te=$e.templateId;if(Te){const{error:ot}=await G.from("canva_templates").update(tt).eq("id",Te);if(ot)throw ot;const{error:He}=await G.from("template_links").delete().eq("template_id",Te);if(He)throw He;const Je=((Ke=$e.existingGuides)==null?void 0:Ke.map(et=>et.id).filter(Boolean))||[],ut=$e.template.guides.map(et=>et.id).filter(Boolean),mt=Je.filter(et=>!ut.includes(et));mt.length>0&&await G.from("template_guides").delete().in("id",mt)}else{const{data:ot,error:He}=await G.from("canva_templates").insert(tt).select().single();if(He)throw He;Te=ot.id,SVt($e.template.name,ot.id)}const We=$e.template.links.filter(ot=>ot.title.trim()&&ot.canva_share_link.trim());if(We.length>0){const ot=We.map((Je,ut)=>({template_id:Te,title:Je.title.trim(),canva_share_link:Je.canva_share_link.trim(),sort_order:ut})),{error:He}=await G.from("template_links").insert(ot);if(He)throw He}for(let ot=0;ot<$e.template.guides.length;ot++){const He=$e.template.guides[ot];if(He.file){const Je=He.file.name.split(".").pop(),ut=`${Date.now()}-${Math.random().toString(36).substring(7)}.${Je}`,{error:mt}=await G.storage.from("template-guides").upload(ut,He.file);if(mt)throw mt;const{data:et}=G.storage.from("template-guides").getPublicUrl(ut),{error:Ze}=await G.from("template_guides").insert({template_id:Te,name:He.name||He.file.name,file_url:et.publicUrl,file_type:He.file.type,file_size:He.file.size,sort_order:ot});if(Ze)throw Ze}else He.id&&await G.from("template_guides").update({sort_order:ot}).eq("id",He.id)}if(Te&&(await G.from("resource_kit_templates").delete().eq("template_id",Te),$e.linkedKitIds.length>0)){const{error:ot}=await G.from("resource_kit_templates").insert($e.linkedKitIds.map(He=>({template_id:Te,kit_id:He})));if(ot)throw ot}},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),je(),l(!1),s({title:i?"Template updated":"Template created"})},onError:$e=>{s({title:"Error saving template",description:$e.message,variant:"destructive"})}}),ge=Pt({mutationFn:async $e=>{const{error:Ye}=await G.from("canva_templates").delete().eq("id",$e);if(Ye)throw Ye},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),s({title:"Template deleted"})},onError:$e=>{s({title:"Error deleting template",description:$e.message,variant:"destructive"})}}),je=()=>{p({name:"",description:"",category_id:"",type_id:"",publish_date:new Date().toISOString().split("T")[0],links:[{title:"",canva_share_link:"",sort_order:0}],guides:[],video_url:""}),C(null),I(""),d(null),Y(!1),X(!1),q(""),U(""),y(null),b(0),w(!1),O([])},qe=async $e=>{var tt;d($e),p({name:$e.name,description:$e.description||"",category_id:$e.category_id||"",type_id:$e.type_id||"",publish_date:$e.publish_date?new Date($e.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],links:$e.links&&$e.links.length>0?$e.links.map(Te=>({id:Te.id,title:Te.title,canva_share_link:Te.canva_share_link,sort_order:Te.sort_order})):[{title:"",canva_share_link:"",sort_order:0}],guides:((tt=$e.guides)==null?void 0:tt.map(Te=>({id:Te.id,name:Te.name,file_url:Te.file_url,file_type:Te.file_type,file_size:Te.file_size,sort_order:Te.sort_order})))||[],video_url:$e.video_url||""}),I($e.preview_image_url||""),y(null);const{data:Ye}=await G.from("resource_kit_templates").select("kit_id").eq("template_id",$e.id);O((Ye||[]).map(Te=>Te.kit_id)),l(!0)},Me=$e=>{var tt;const Ye=(tt=$e.target.files)==null?void 0:tt[0];Ye&&(C(Ye),I(URL.createObjectURL(Ye)))},ke=()=>{p({...u,links:[...u.links,{title:"",canva_share_link:"",sort_order:u.links.length}]})},Re=$e=>{if(u.links.length<=1)return;const Ye=u.links.filter((tt,Te)=>Te!==$e);p({...u,links:Ye})},Ve=($e,Ye,tt)=>{const Te=[...u.links];Te[$e]={...Te[$e],[Ye]:tt},p({...u,links:Te})},Ne=$e=>{const Ye=$e.target.files;if(!Ye)return;const tt=Array.from(Ye).map((Te,We)=>({name:Te.name.replace(/\.[^/.]+$/,""),file_url:"",file_type:Te.type,file_size:Te.size,sort_order:u.guides.length+We,file:Te}));p({...u,guides:[...u.guides,...tt]}),$e.target.value=""},Ue=$e=>{const Ye=u.guides.filter((tt,Te)=>Te!==$e);p({...u,guides:Ye})},Ie=($e,Ye)=>{const tt=[...u.guides];tt[$e]={...tt[$e],name:Ye},p({...u,guides:tt})},ye=async()=>{if(!f)return null;w(!0),b(0);try{const{data:$e,error:Ye}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:u.name||f.name}});if(Ye)throw new Error(Ye.message);const{videoId:tt,libraryId:Te}=$e,{data:We,error:Ke}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:tt}});if(Ke)throw new Error(Ke.message);const ot=new XMLHttpRequest;return await new Promise((Je,ut)=>{ot.upload.addEventListener("progress",mt=>{if(mt.lengthComputable){const et=Math.round(mt.loaded/mt.total*100);b(et)}}),ot.addEventListener("load",()=>{ot.status>=200&&ot.status<300?Je():ut(new Error(`Upload failed with status ${ot.status}`))}),ot.addEventListener("error",()=>ut(new Error("Upload failed"))),ot.open("PUT",We.uploadUrl),ot.setRequestHeader("AccessKey",We.apiKey),ot.send(f)}),`https://player.mediadelivery.net/embed/${Te}/${tt}`}catch($e){return console.error("Bunny upload error:",$e),s({title:"Video upload failed",description:$e instanceof Error?$e.message:"Unknown error",variant:"destructive"}),null}finally{w(!1)}},ct=$e=>{var tt;const Ye=(tt=$e.target.files)==null?void 0:tt[0];Ye&&y(Ye),$e.target.value=""},fe=async $e=>{if($e.preventDefault(),!u.name.trim()){s({title:"Please enter a template name",variant:"destructive"});return}if(u.links.filter(Te=>Te.title.trim()&&Te.canva_share_link.trim()).length===0){s({title:"Please add at least one Canva link",variant:"destructive"});return}let tt=u.video_url;if(f){const Te=await ye();if(!Te)return;tt=Te}he.mutate({template:u,image:S,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:tt,linkedKitIds:L})};return e.jsx(Ds,{title:"Manage Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Hu,{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(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Templates"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:ae.length})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Categories"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:ce.length})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Template Types"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:ie.length})})]})]}),e.jsxs(fs,{open:o,onOpenChange:$e=>{l($e),$e||je()},children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{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(ks,{children:e.jsx(_s,{children:i?"Edit Template":"Add New Template"})}),e.jsxs("form",{onSubmit:fe,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"name",children:"Name *"}),e.jsx(De,{id:"name",value:u.name,onChange:$e=>p({...u,name:$e.target.value}),placeholder:"Template name",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Description"}),e.jsx(Wg,{content:u.description,onChange:$e=>p({...u,description:$e}),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(xe,{children:"Canva Links *"}),e.jsxs(W,{type:"button",variant:"outline",size:"sm",onClick:ke,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(($e,Ye)=>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(De,{value:$e.title,onChange:tt=>Ve(Ye,"title",tt.target.value),placeholder:"Link title (e.g., Instagram Post, Story)"}),e.jsx(De,{value:$e.canva_share_link,onChange:tt=>Ve(Ye,"canva_share_link",tt.target.value),placeholder:"https://www.canva.com/design/..."})]}),u.links.length>1&&e.jsx(W,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>Re(Ye),children:e.jsx(kr,{className:"h-4 w-4"})})]},Ye))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Category"}),te?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{value:V,onChange:$e=>q($e.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(W,{type:"button",size:"sm",onClick:()=>V.trim()&&me.mutate(V.trim()),disabled:me.isPending,children:"Add"}),e.jsx(W,{type:"button",size:"sm",variant:"ghost",onClick:()=>{Y(!1),q("")},children:e.jsx(kr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs($s,{value:u.category_id,onValueChange:$e=>p({...u,category_id:$e}),children:[e.jsx(zs,{className:"flex-1",children:e.jsx(Vs,{placeholder:"Select category"})}),e.jsx(Bs,{children:ce.map($e=>e.jsx(vt,{value:$e.id,children:$e.name},$e.id))})]}),e.jsx(W,{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(xe,{children:"Template Type"}),J?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{value:B,onChange:$e=>U($e.target.value),placeholder:"New type name",className:"flex-1"}),e.jsx(W,{type:"button",size:"sm",onClick:()=>B.trim()&&ve.mutate(B.trim()),disabled:ve.isPending,children:"Add"}),e.jsx(W,{type:"button",size:"sm",variant:"ghost",onClick:()=>{X(!1),U("")},children:e.jsx(kr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs($s,{value:u.type_id,onValueChange:$e=>p({...u,type_id:$e}),children:[e.jsx(zs,{className:"flex-1",children:e.jsx(Vs,{placeholder:"Select type"})}),e.jsx(Bs,{children:ie.map($e=>e.jsx(vt,{value:$e.id,children:$e.name},$e.id))})]}),e.jsx(W,{type:"button",variant:"outline",size:"icon",onClick:()=>X(!0),children:e.jsx(qs,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(De,{id:"publish_date",type:"date",value:u.publish_date,onChange:$e=>p({...u,publish_date:$e.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(xe,{children:"Preview Image"}),e.jsxs("div",{className:"flex items-start gap-4",children:[A?e.jsxs("div",{className:"relative w-32 h-24 rounded-lg overflow-hidden border bg-muted",children:[e.jsx("img",{src:A,alt:"Preview",className:"w-full h-full object-cover"}),e.jsx(W,{type:"button",size:"icon",variant:"destructive",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>{C(null),I("")},children:e.jsx(kr,{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(qo,{className:"h-8 w-8 text-muted-foreground/50"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx(De,{type:"file",accept:"image/*",onChange:Me,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(xe,{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(yn,{className:"h-5 w-5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:"Video uploaded"}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",onClick:()=>p({...u,video_url:""}),className:"text-destructive hover:text-destructive",children:"Remove"})]}),e.jsx("div",{className:"aspect-video max-w-md rounded-lg overflow-hidden border",children:e.jsx("iframe",{src:u.video_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})]}):N?e.jsxs("div",{className:"space-y-2 p-4 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(us,{className:"h-4 w-4 animate-spin"}),e.jsxs("span",{className:"text-sm",children:["Uploading video... ",_,"%"]})]}),e.jsx(xi,{value:_,className:"h-2"})]}):f?e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/30",children:[e.jsx(yn,{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(W,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive h-8 w-8",onClick:()=>y(null),children:e.jsx(kr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(De,{type:"file",accept:"video/*",onChange:ct,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(yn,{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(xe,{children:"Guide Files (PDFs)"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(De,{type:"file",accept:".pdf,.doc,.docx",multiple:!0,onChange:Ne,className:"hidden"}),e.jsx(W,{type:"button",variant:"outline",size:"sm",className:"gap-1",asChild:!0,children:e.jsxs("span",{children:[e.jsx(Ra,{className:"h-3 w-3"}),"Add Files"]})})]})]}),u.guides.length>0?e.jsx("div",{className:"space-y-2",children:u.guides.map(($e,Ye)=>e.jsxs("div",{className:"flex gap-2 items-center p-3 border rounded-lg bg-muted/30",children:[e.jsx(vn,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsx(De,{value:$e.name,onChange:tt=>Ie(Ye,tt.target.value),placeholder:"Guide name",className:"flex-1"}),$e.file_size&&e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[($e.file_size/1024).toFixed(0)," KB"]}),e.jsx(W,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive h-8 w-8",onClick:()=>Ue(Ye),children:e.jsx(kr,{className:"h-4 w-4"})})]},$e.id||Ye))}):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(PVt,{selectedKitIds:L,onChange:O}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>{l(!1),je()},children:"Cancel"}),e.jsx(W,{type:"submit",disabled:he.isPending,children:he.isPending?"Saving...":i?"Update":"Create"})]})]})]})]})]}),e.jsx(Pe,{children:e.jsx(Oe,{className:"p-0",children:oe?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading..."}):ae.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No templates yet. Add your first template!"}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Preview"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Links"}),e.jsx(St,{children:"Category"}),e.jsx(St,{children:"Type"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:ae.map($e=>{var Ye,tt,Te,We,Ke;return e.jsxs(Ps,{children:[e.jsx(ht,{children:e.jsx("div",{className:"w-16 h-12 rounded overflow-hidden bg-muted",children:$e.preview_image_url?e.jsx("img",{src:$e.preview_image_url,alt:$e.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(qo,{className:"h-4 w-4 text-muted-foreground"})})})}),e.jsx(ht,{className:"font-medium",children:$e.name}),e.jsx(ht,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs(Qe,{variant:"secondary",children:[((Ye=$e.links)==null?void 0:Ye.length)||0," link",(((tt=$e.links)==null?void 0:tt.length)||0)!==1?"s":""]}),(((Te=$e.guides)==null?void 0:Te.length)||0)>0&&e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(vn,{className:"h-3 w-3"}),(We=$e.guides)==null?void 0:We.length," guide",(((Ke=$e.guides)==null?void 0:Ke.length)||0)!==1?"s":""]})]})}),e.jsx(ht,{children:$e.category?e.jsx(Qe,{variant:"secondary",children:$e.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(ht,{children:$e.type?e.jsx(Qe,{variant:"outline",children:$e.type.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(ht,{className:"text-muted-foreground",children:new Date($e.publish_date).toLocaleDateString()}),e.jsx(ht,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(W,{size:"icon",variant:"ghost",onClick:()=>qe($e),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(W,{size:"icon",variant:"ghost",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&ge.mutate($e.id)},children:e.jsx(vr,{className:"h-4 w-4"})})]})})]},$e.id)})})]})})})]})})};function ytt({selectedTemplateIds:t,onChange:s}){const[r,n]=k.useState(""),[a,o]=k.useState(!1),{data:l=[]}=gt({queryKey:["all-canva-templates-picker"],queryFn:async()=>{const{data:f,error:y}=await G.from("canva_templates").select("id, name, preview_image_url").order("name");if(y)throw y;return f}}),i=l.filter(f=>t.includes(f.id)),d=l.filter(f=>!t.includes(f.id)&&f.name.toLowerCase().includes(r.toLowerCase())),u=f=>{s([...t,f])},p=f=>{s(t.filter(y=>y!==f))};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{className:"flex items-center gap-2",children:[e.jsx(iS,{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(Qe,{variant:"secondary",className:"gap-1 pr-1",children:[f.name,e.jsx("button",{type:"button",onClick:()=>p(f.id),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(kr,{className:"h-3 w-3"})})]},f.id))}),e.jsxs(mo,{open:a,onOpenChange:o,children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(iS,{className:"h-3.5 w-3.5"}),"Add Template"]})}),e.jsxs(no,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(ln,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(De,{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:d.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:r?"No templates found":"All templates selected"}):d.map(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(iS,{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 LVt=[{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"}],DVt=()=>{const{user:t}=Us(),[s,r]=Nc(),{toast:n}=ja(),a=Qt(),[o,l]=k.useState(!1),[i,d]=k.useState(null),[u,p]=k.useState({title:"",description:"",video_url:"",video_type:"youtube",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[f,y]=k.useState(null),[_,b]=k.useState(""),[N,w]=k.useState([]),[S,C]=k.useState([]),[A,I]=k.useState([]),[L,O]=k.useState([]),[V,q]=k.useState(""),[B,U]=k.useState(!1),[te,Y]=k.useState(null),[J,X]=k.useState(0),[ce,ie]=k.useState(!1),[ae,oe]=k.useState(null),{data:me=[]}=gt({queryKey:["academy-categories"],queryFn:async()=>{const{data:fe,error:$e}=await G.from("academy_categories").select("*").order("sort_order",{ascending:!0});if($e)throw $e;return fe}}),{data:ve=[],isLoading:he}=gt({queryKey:["academy-videos-admin"],queryFn:async()=>{const{data:fe,error:$e}=await G.from("academy_videos").select(` *, category:academy_categories(id, name) `).order("publish_date",{ascending:!1});if($e)throw $e;const{data:Ye,error:tt}=await G.from("academy_resources").select("*").order("sort_order");if(tt)throw tt;return fe.map(We=>({...We,resources:(Ye==null?void 0:Ye.filter(Ke=>Ke.video_id===We.id))||[]}))}});k.useEffect(()=>{const fe=s.get("edit");if(fe&&ve.length>0){const $e=ve.find(Ye=>Ye.id===fe);$e&&(Re($e),r({},{replace:!0}))}},[ve,s]);const ge=Pt({mutationFn:async fe=>{const{data:$e,error:Ye}=await G.from("academy_categories").insert({name:fe,sort_order:me.length}).select().single();if(Ye)throw Ye;return $e},onSuccess:fe=>{a.invalidateQueries({queryKey:["academy-categories"]}),p({...u,category_id:fe.id}),q(""),U(!1),n({title:"Category added"})},onError:fe=>{n({title:"Error adding category",description:fe.message,variant:"destructive"})}}),je=Pt({mutationFn:async fe=>{let $e=fe.existingThumbnailUrl;if(fe.thumbnail){const Te=fe.thumbnail.name.split(".").pop(),We=`thumbnails/${Date.now()}-${Math.random().toString(36).substring(7)}.${Te}`,{error:Ke}=await G.storage.from("academy-resources").upload(We,fe.thumbnail);if(Ke)throw Ke;const{data:ot}=G.storage.from("academy-resources").getPublicUrl(We);$e=ot.publicUrl}const Ye={title:fe.video.title,description:fe.video.description||null,video_url:fe.video.video_url,video_type:fe.video.video_type,duration:fe.video.duration||null,thumbnail_url:$e,category_id:fe.video.category_id||null,publish_date:fe.video.publish_date?new Date(fe.video.publish_date).toISOString():new Date().toISOString(),is_published:fe.video.is_published,created_by:t==null?void 0:t.id};let tt=fe.videoId;if(tt){const{error:Te}=await G.from("academy_videos").update(Ye).eq("id",tt);if(Te)throw Te}else{const{data:Te,error:We}=await G.from("academy_videos").insert(Ye).select().single();if(We)throw We;tt=Te.id,CVt(fe.video.title,Te.id)}if(fe.resourcesToDelete.length>0){const{error:Te}=await G.from("academy_resources").delete().in("id",fe.resourcesToDelete);if(Te)throw Te}for(let Te=0;Te0){const{error:Te}=await G.from("academy_video_templates").insert(L.map(We=>({video_id:tt,template_id:We})));if(Te)throw Te}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),ke(),l(!1),n({title:i?"Video updated":"Video created"})},onError:fe=>{n({title:"Error saving video",description:fe.message,variant:"destructive"})}}),qe=Pt({mutationFn:async fe=>{const{error:$e}=await G.from("academy_videos").delete().eq("id",fe);if($e)throw $e},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),n({title:"Video deleted"})},onError:fe=>{n({title:"Error deleting video",description:fe.message,variant:"destructive"})}}),Me=Pt({mutationFn:async({id:fe,is_published:$e})=>{const{error:Ye}=await G.from("academy_videos").update({is_published:$e}).eq("id",fe);if(Ye)throw Ye},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]})},onError:fe=>{n({title:"Error updating video",description:fe.message,variant:"destructive"})}}),ke=()=>{p({title:"",description:"",video_url:"",video_type:"bunny_stream",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),y(null),b(""),w([]),C([]),I([]),d(null),O([]),q(""),Y(null),X(0),ie(!1),oe(null)},Re=async fe=>{d(fe),p({title:fe.title,description:fe.description||"",video_url:fe.video_url,video_type:fe.video_type,duration:fe.duration||"",category_id:fe.category_id||"",publish_date:fe.publish_date?new Date(fe.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:fe.is_published}),b(fe.thumbnail_url||""),C(fe.resources||[]),w([]),I([]);const{data:$e}=await G.from("academy_video_templates").select("template_id").eq("video_id",fe.id);O(($e||[]).map(Ye=>Ye.template_id)),l(!0)},Ve=fe=>{var Ye;const $e=(Ye=fe.target.files)==null?void 0:Ye[0];$e&&(y($e),b(URL.createObjectURL($e)))},Ne=fe=>{const $e=fe.target.files;if($e){const Ye=Array.from($e).map(tt=>({file:tt,title:tt.name.replace(/\.[^/.]+$/,"")}));w([...N,...Ye])}fe.target.value=""},Ue=fe=>{w(N.filter(($e,Ye)=>Ye!==fe))},Ie=fe=>{I([...A,fe]),C(S.filter($e=>$e.id!==fe))},ye=async()=>{if(!te)return null;ie(!0),X(0);try{const{data:fe,error:$e}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:u.title||te.name}});if($e)throw new Error($e.message);const{videoId:Ye,libraryId:tt}=fe;oe(Ye);const{data:Te,error:We}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Ye}});if(We)throw new Error(We.message);const Ke=new XMLHttpRequest;return await new Promise((He,Je)=>{Ke.upload.addEventListener("progress",ut=>{if(ut.lengthComputable){const mt=Math.round(ut.loaded/ut.total*100);X(mt)}}),Ke.addEventListener("load",()=>{Ke.status>=200&&Ke.status<300?He():Je(new Error(`Upload failed with status ${Ke.status}`))}),Ke.addEventListener("error",()=>Je(new Error("Upload failed"))),Ke.open("PUT",Te.uploadUrl),Ke.setRequestHeader("AccessKey",Te.apiKey),Ke.send(te)}),`https://player.mediadelivery.net/embed/${tt}/${Ye}`}catch(fe){return console.error("Bunny upload error:",fe),n({title:"Video upload failed",description:fe instanceof Error?fe.message:"Unknown error",variant:"destructive"}),null}finally{ie(!1)}},ct=async fe=>{if(fe.preventDefault(),!u.title.trim()){n({title:"Please enter a video title",variant:"destructive"});return}let $e=u.video_url;if(u.video_type==="bunny_stream"&&te&&!i){const Ye=await ye();if(!Ye)return;$e=Ye}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"&&!te&&!u.video_url&&!i){n({title:"Please select a video file to upload",variant:"destructive"});return}je.mutate({video:{...u,video_url:$e},thumbnail:f,existingThumbnailUrl:(i==null?void 0:i.thumbnail_url)||null,videoId:i==null?void 0:i.id,newResources:N,resourcesToDelete:A})};return e.jsx(Ds,{title:"Manage Academy",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Hu,{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(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Videos"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:ve.length})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:ve.filter(fe=>fe.is_published).length})})]})]}),e.jsxs(fs,{open:o,onOpenChange:fe=>{l(fe),fe||ke()},children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{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(ks,{children:e.jsx(_s,{children:i?"Edit Video":"Add New Video"})}),e.jsxs("form",{onSubmit:ct,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"title",children:"Title *"}),e.jsx(De,{id:"title",value:u.title,onChange:fe=>p({...u,title:fe.target.value}),placeholder:"Video title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Description"}),e.jsx(Wg,{content:u.description,onChange:fe=>p({...u,description:fe}),placeholder:"Brief description of the video",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Video Type"}),e.jsxs($s,{value:u.video_type,onValueChange:fe=>{p({...u,video_type:fe,video_url:""}),Y(null)},disabled:ce,children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsx(Bs,{children:LVt.map(fe=>e.jsx(vt,{value:fe.value,children:fe.label},fe.value))})]})]}),u.video_type==="bunny_stream"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs(xe,{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(De,{type:"file",accept:"video/*",onChange:fe=>{var Ye;const $e=(Ye=fe.target.files)==null?void 0:Ye[0];$e&&Y($e)},disabled:ce}),te&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(yn,{className:"h-4 w-4"}),te.name," (",(te.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(us,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Uploading to Bunny.net..."})]}),e.jsx(xi,{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(xe,{htmlFor:"video_url",children:"Video URL *"}),e.jsx(De,{id:"video_url",value:u.video_url,onChange:fe=>p({...u,video_url:fe.target.value}),placeholder:"https://...",required:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"duration",children:"Duration"}),e.jsx(De,{id:"duration",value:u.duration,onChange:fe=>p({...u,duration:fe.target.value}),placeholder:"e.g., 45:30"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(De,{id:"publish_date",type:"date",value:u.publish_date,onChange:fe=>p({...u,publish_date:fe.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Category"}),B?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{value:V,onChange:fe=>q(fe.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(W,{type:"button",size:"sm",onClick:()=>V.trim()&&ge.mutate(V.trim()),disabled:ge.isPending,children:"Add"}),e.jsx(W,{type:"button",size:"sm",variant:"ghost",onClick:()=>{U(!1),q("")},children:e.jsx(kr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs($s,{value:u.category_id,onValueChange:fe=>p({...u,category_id:fe}),children:[e.jsx(zs,{className:"flex-1",children:e.jsx(Vs,{placeholder:"Select category"})}),e.jsx(Bs,{children:me.map(fe=>e.jsx(vt,{value:fe.id,children:fe.name},fe.id))})]}),e.jsx(W,{type:"button",variant:"outline",size:"sm",onClick:()=>U(!0),children:e.jsx(qs,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Thumbnail Image"}),e.jsxs("div",{className:"flex items-start gap-4",children:[_&&e.jsx("img",{src:_,alt:"Thumbnail preview",className:"w-32 h-20 object-cover rounded-md border"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(De,{type:"file",accept:"image/*",onChange:Ve,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(xe,{children:"Resource Files"}),e.jsx(W,{type:"button",variant:"outline",size:"sm",asChild:!0,children:e.jsxs("label",{className:"cursor-pointer gap-1",children:[e.jsx(Ra,{className:"h-3 w-3"}),"Add Files",e.jsx("input",{type:"file",multiple:!0,accept:".pdf,.pptx,.ppt,.xlsx,.xls,.docx,.doc,.zip",onChange:Ne,className:"hidden"})]})})]}),(S.length>0||N.length>0)&&e.jsxs("div",{className:"space-y-2 mt-2",children:[S.map(fe=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(vn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm truncate",children:fe.title}),e.jsx(Qe,{variant:"outline",className:"text-xs",children:fe.file_type}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",onClick:()=>Ie(fe.id),className:"text-destructive hover:text-destructive",children:e.jsx(kr,{className:"h-4 w-4"})})]},fe.id)),N.map((fe,$e)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(vn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(De,{value:fe.title,onChange:Ye=>{const tt=[...N];tt[$e].title=Ye.target.value,w(tt)},className:"flex-1 h-8",placeholder:"Resource title"}),e.jsx(Qe,{variant:"secondary",className:"text-xs",children:"New"}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",onClick:()=>Ue($e),className:"text-destructive hover:text-destructive",children:e.jsx(kr,{className:"h-4 w-4"})})]},$e))]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Supported: PDF, PowerPoint, Excel, Word, ZIP"})]}),e.jsx(ytt,{selectedTemplateIds:L,onChange:O}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ar,{id:"is_published",checked:u.is_published,onCheckedChange:fe=>p({...u,is_published:fe})}),e.jsx(xe,{htmlFor:"is_published",children:"Published"})]}),e.jsxs(gn,{children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>l(!1),disabled:ce,children:"Cancel"}),e.jsx(W,{type:"submit",disabled:je.isPending||ce,children:ce?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):je.isPending?"Saving...":i?"Update Video":"Add Video"})]})]})]})]})]}),e.jsx(Pe,{children:e.jsx(Oe,{className:"p-0",children:he?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"})}):ve.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(yn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No videos yet"}),e.jsx("p",{className:"text-sm",children:"Add your first academy video"})]}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Category"}),e.jsx(St,{children:"Duration"}),e.jsx(St,{children:"Resources"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-[120px]",children:"Actions"})]})}),e.jsx(Rn,{children:ve.map(fe=>e.jsxs(Ps,{children:[e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[fe.thumbnail_url?e.jsx("img",{src:fe.thumbnail_url,alt:"",className:"w-16 h-10 object-cover rounded"}):e.jsx("div",{className:"w-16 h-10 bg-muted rounded flex items-center justify-center",children:e.jsx(yn,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:fe.title}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:fe.video_type.replace("_"," ")})]})]})}),e.jsx(ht,{children:fe.category?e.jsx(Qe,{variant:"outline",children:fe.category.name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(ht,{children:fe.duration||"-"}),e.jsx(ht,{children:fe.resources&&fe.resources.length>0?e.jsxs(Qe,{variant:"secondary",children:[fe.resources.length," file(s)"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(ht,{children:new Date(fe.publish_date).toLocaleDateString()}),e.jsx(ht,{children:e.jsx(Ar,{checked:fe.is_published,onCheckedChange:$e=>Me.mutate({id:fe.id,is_published:$e})})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>Re(fe),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>qe.mutate(fe.id),className:"text-destructive hover:text-destructive",children:e.jsx(vr,{className:"h-4 w-4"})})]})})]},fe.id))})]})})})]})})};function RVt(){var je,qe,Me;const t=Qt(),[s,r]=Nc(),[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,d]=k.useState({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,p]=k.useState(null),[f,y]=k.useState(""),[_,b]=k.useState([]),[N,w]=k.useState([]),[S,C]=k.useState([]),[A,I]=k.useState(null),{data:L,isLoading:O}=gt({queryKey:["resource-kits"],queryFn:async()=>{const{data:ke,error:Re}=await G.from("resource_kits").select("*").order("publish_date",{ascending:!1});if(Re)throw Re;return ke}}),{data:V}=gt({queryKey:["resource-kit-files"],queryFn:async()=>{const{data:ke,error:Re}=await G.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(Re)throw Re;return ke}}),{data:q}=gt({queryKey:["resource-kit-links"],queryFn:async()=>{const{data:ke,error:Re}=await G.from("resource_kit_links").select("*").order("sort_order",{ascending:!0});if(Re)throw Re;return ke}});k.useEffect(()=>{const ke=s.get("edit");if(ke&&L&&L.length>0&&V&&q){const Re=L.find(Ve=>Ve.id===ke);Re&&(U(Re),r({},{replace:!0}))}},[L,V,q,s]);const B=()=>{d({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),p(null),y(""),b([]),w([]),C([]),l(null)},U=async ke=>{l(ke),d({name:ke.name,description:ke.description||"",publish_date:ke.publish_date.split("T")[0],is_published:ke.is_published}),y(ke.featured_image_url||"");const Re=(V==null?void 0:V.filter(Ue=>Ue.kit_id===ke.id))||[];b(Re.map(Ue=>({id:Ue.id,name:Ue.name,file_url:Ue.file_url,file_type:Ue.file_type,file_size:Ue.file_size,sort_order:Ue.sort_order})));const Ve=(q==null?void 0:q.filter(Ue=>Ue.kit_id===ke.id))||[];w(Ve.map(Ue=>({id:Ue.id,title:Ue.title,canva_share_link:Ue.canva_share_link,sort_order:Ue.sort_order})));const{data:Ne}=await G.from("resource_kit_templates").select("template_id").eq("kit_id",ke.id);C((Ne||[]).map(Ue=>Ue.template_id)),a(!0)},te=ke=>{var Ve;const Re=(Ve=ke.target.files)==null?void 0:Ve[0];Re&&(p(Re),y(URL.createObjectURL(Re)))},Y=()=>{b([..._,{name:"",file_url:"",sort_order:_.length}])},J=ke=>{b(_.filter((Re,Ve)=>Ve!==ke))},X=(ke,Re,Ve)=>{const Ne=[..._];Ne[ke]={...Ne[ke],[Re]:Ve},b(Ne)},ce=()=>{w([...N,{title:"",canva_share_link:"",sort_order:N.length}])},ie=ke=>{w(N.filter((Re,Ve)=>Ve!==ke))},ae=(ke,Re,Ve)=>{const Ne=[...N];Ne[ke]={...Ne[ke],[Re]:Ve},w(Ne)},oe=(ke,Re)=>{var Ne;const Ve=(Ne=Re.target.files)==null?void 0:Ne[0];if(Ve){const Ue=[..._],Ie=Ve.name.replace(/\.[^/.]+$/,"");Ue[ke]={...Ue[ke],file:Ve,file_type:Ve.type,file_size:Ve.size,name:Ue[ke].name||Ie},b(Ue)}},me=Pt({mutationFn:async()=>{let ke=(o==null?void 0:o.featured_image_url)||null;if(u){const Ie=u.name.split(".").pop(),ye=`${Date.now()}.${Ie}`,{error:ct}=await G.storage.from("resource-kits").upload(`featured/${ye}`,u);if(ct)throw ct;const{data:fe}=G.storage.from("resource-kits").getPublicUrl(`featured/${ye}`);ke=fe.publicUrl}const Re={name:i.name,description:i.description||null,featured_image_url:ke,publish_date:i.publish_date,is_published:i.is_published};let Ve;const Ne=!o,Ue=(o==null?void 0:o.is_published)||!1;if(o){const{error:Ie}=await G.from("resource_kits").update(Re).eq("id",o.id);if(Ie)throw Ie;Ve=o.id;const ye=(V==null?void 0:V.filter(Te=>Te.kit_id===o.id).map(Te=>Te.id))||[],ct=_.filter(Te=>Te.id).map(Te=>Te.id),fe=ye.filter(Te=>!ct.includes(Te));fe.length>0&&await G.from("resource_kit_files").delete().in("id",fe);const $e=(q==null?void 0:q.filter(Te=>Te.kit_id===o.id).map(Te=>Te.id))||[],Ye=N.filter(Te=>Te.id).map(Te=>Te.id),tt=$e.filter(Te=>!Ye.includes(Te));tt.length>0&&await G.from("resource_kit_links").delete().in("id",tt)}else{const{data:Ie,error:ye}=await G.from("resource_kits").insert(Re).select().single();if(ye)throw ye;Ve=Ie.id}for(let Ie=0;Ie<_.length;Ie++){const ye=_[Ie];let ct=ye.file_url;if(ye.file){const fe=ye.file.name.split(".").pop(),$e=`${Date.now()}-${Ie}.${fe}`,{error:Ye}=await G.storage.from("resource-kits").upload(`files/${$e}`,ye.file);if(Ye)throw Ye;const{data:tt}=G.storage.from("resource-kits").getPublicUrl(`files/${$e}`);ct=tt.publicUrl}ye.id?await G.from("resource_kit_files").update({name:ye.name,file_url:ct,file_type:ye.file_type,file_size:ye.file_size,sort_order:Ie}).eq("id",ye.id):ct&&ye.name&&await G.from("resource_kit_files").insert({kit_id:Ve,name:ye.name,file_url:ct,file_type:ye.file_type,file_size:ye.file_size,sort_order:Ie})}for(let Ie=0;Ie0){const{error:Ie}=await G.from("resource_kit_templates").insert(S.map(ye=>({kit_id:Ve,template_id:ye})));if(Ie)throw Ie}return{kitId:Ve,kitName:i.name,isNewKit:Ne,wasPublished:Ue,isPublished:i.is_published}},onSuccess:ke=>{t.invalidateQueries({queryKey:["resource-kits"]}),t.invalidateQueries({queryKey:["resource-kit-files"]}),t.invalidateQueries({queryKey:["resource-kit-links"]}),pe.success(o?"Resource kit updated":"Resource kit created"),ke.isPublished&&(ke.isNewKit||!ke.wasPublished)&&TVt(ke.kitName,ke.kitId),a(!1),B()},onError:ke=>{pe.error("Failed to save resource kit: "+ke.message)}}),ve=Pt({mutationFn:async ke=>{const{error:Re}=await G.from("resource_kits").delete().eq("id",ke);if(Re)throw Re},onSuccess:()=>{t.invalidateQueries({queryKey:["resource-kits"]}),t.invalidateQueries({queryKey:["resource-kit-files"]}),pe.success("Resource kit deleted")},onError:ke=>{pe.error("Failed to delete: "+ke.message)}}),he=ke=>{if(ke.preventDefault(),!i.name){pe.error("Please enter a name");return}me.mutate()},ge=ke=>(V==null?void 0:V.filter(Re=>Re.kit_id===ke).length)||0;return e.jsx(Ds,{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(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Kits"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(L==null?void 0:L.length)||0})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(L==null?void 0:L.filter(ke=>ke.is_published).length)||0})})]})]}),e.jsxs(W,{onClick:()=>{B(),a(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Resource Kit"]})]}),e.jsx(Pe,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Files"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:O?e.jsx(Ps,{children:e.jsx(ht,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):(L==null?void 0:L.length)===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No resource kits yet. Create your first one!"})}):L==null?void 0:L.map(ke=>e.jsxs(Ps,{children:[e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[ke.featured_image_url?e.jsx("img",{src:ke.featured_image_url,alt:ke.name,className:"w-10 h-10 rounded object-cover"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center",children:e.jsx(cl,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:ke.name}),ke.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:ke.description})]})]})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(vn,{className:"h-4 w-4 text-muted-foreground"}),ge(ke.id)]})}),e.jsx(ht,{children:vs(new Date(ke.publish_date),"MMM d, yyyy")}),e.jsx(ht,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${ke.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:ke.is_published?"Published":"Draft"})}),e.jsx(ht,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>{const Re=(V==null?void 0:V.filter(Ne=>Ne.kit_id===ke.id))||[],Ve=(q==null?void 0:q.filter(Ne=>Ne.kit_id===ke.id))||[];I({...ke,files:Re,links:Ve})},children:e.jsx(jn,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>U(ke),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource kit?")&&ve.mutate(ke.id)},children:e.jsx(vr,{className:"h-4 w-4 text-destructive"})})]})})]},ke.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(ks,{children:e.jsx(_s,{children:o?"Edit Resource Kit":"Add Resource Kit"})}),e.jsxs("form",{onSubmit:he,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{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(cl,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(De,{type:"file",accept:"image/*",onChange:te})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"name",children:"Name *"}),e.jsx(De,{id:"name",value:i.name,onChange:ke=>d({...i,name:ke.target.value}),placeholder:"Resource Kit Name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Description"}),e.jsx(Wg,{content:i.description,onChange:ke=>d({...i,description:ke}),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(xe,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(De,{id:"publish_date",type:"date",value:i.publish_date,onChange:ke=>d({...i,publish_date:ke.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Published"}),e.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[e.jsx(Ar,{checked:i.is_published,onCheckedChange:ke=>d({...i,is_published:ke})}),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(xe,{children:"Resource Files"}),e.jsxs(W,{type:"button",variant:"outline",size:"sm",onClick:Y,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add File"]})]}),_.length===0?e.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center border rounded-md border-dashed",children:'No files added yet. Click "Add File" to include resources.'}):e.jsx("div",{className:"space-y-3",children:_.map((ke,Re)=>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 ",Re+1]}),e.jsx(W,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>J(Re),children:e.jsx(kr,{className:"h-4 w-4"})})]}),e.jsx(De,{placeholder:"File name (e.g., Getting Started Guide)",value:ke.name,onChange:Ve=>X(Re,"name",Ve.target.value)}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{type:"file",onChange:Ve=>oe(Re,Ve),className:"flex-1"}),ke.file_url&&!ke.file&&e.jsx("a",{href:ke.file_url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline whitespace-nowrap",children:"Current file"}),ke.file&&e.jsx("span",{className:"text-sm text-green-600 whitespace-nowrap",children:"New file selected"})]})]},Re))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(xe,{children:"Canva Links"}),e.jsxs(W,{type:"button",variant:"outline",size:"sm",onClick:ce,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Canva Link"]})]}),N.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:N.map((ke,Re)=>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 ",Re+1]}),e.jsx(W,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>ie(Re),children:e.jsx(kr,{className:"h-4 w-4"})})]}),e.jsx(De,{placeholder:"Link title (e.g., Social Media Post Template)",value:ke.title,onChange:Ve=>ae(Re,"title",Ve.target.value)}),e.jsx(De,{placeholder:"Canva share link (e.g., https://www.canva.com/design/...)",value:ke.canva_share_link,onChange:Ve=>ae(Re,"canva_share_link",Ve.target.value)})]},Re))})]}),e.jsx(ytt,{selectedTemplateIds:S,onChange:C}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(W,{type:"submit",disabled:me.isPending,children:me.isPending?"Saving...":o?"Update":"Create"})]})]})]})}),e.jsx(fs,{open:!!A,onOpenChange:()=>I(null),children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsx(ks,{children:e.jsx(_s,{children:A==null?void 0:A.name})}),e.jsxs("div",{className:"space-y-4",children:[(A==null?void 0:A.featured_image_url)&&e.jsx("img",{src:A.featured_image_url,alt:A.name,className:"w-full h-48 object-cover rounded-lg"}),(A==null?void 0:A.description)&&e.jsx("p",{className:"text-muted-foreground",children:A.description}),e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2",children:["Resource Files (",((je=A==null?void 0:A.files)==null?void 0:je.length)||0,")"]}),((qe=A==null?void 0:A.files)==null?void 0:qe.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:(Me=A==null?void 0:A.files)==null?void 0:Me.map(ke=>e.jsxs("a",{href:ke.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(vn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:ke.name})]},ke.id))})]}),(A==null?void 0:A.links)&&A.links.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2",children:["Canva Links (",A.links.length,")"]}),e.jsx("div",{className:"space-y-2",children:A.links.map(ke=>e.jsxs("a",{href:ke.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(vo,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:ke.title})]},ke.id))})]})]})]})})]})})}const OVt=()=>{const{user:t}=Us(),{toast:s}=ja(),r=Qt(),[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,d]=k.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,links:[{title:"",canva_share_link:"",sort_order:0}]}),[u,p]=k.useState(null),[f,y]=k.useState(""),{data:_=[],isLoading:b}=gt({queryKey:["social-swag-admin"],queryFn:async()=>{const{data:q,error:B}=await G.from("social_swag").select("*").order("publish_date",{ascending:!1});if(B)throw B;const{data:U,error:te}=await G.from("social_swag_links").select("*").order("sort_order");if(te)throw te;return q.map(J=>({...J,links:(U==null?void 0:U.filter(X=>X.swag_id===J.id))||[]}))}}),N=Pt({mutationFn:async q=>{let B=q.existingImageUrl;if(q.image){const ce=q.image.name.split(".").pop(),ie=`${Date.now()}-${Math.random().toString(36).substring(7)}.${ce}`,{error:ae}=await G.storage.from("template-previews").upload(ie,q.image);if(ae)throw ae;const{data:oe}=G.storage.from("template-previews").getPublicUrl(ie);B=oe.publicUrl}const U={title:q.item.title,description:q.item.description||null,preview_image_url:B,publish_date:q.item.publish_date?new Date(q.item.publish_date).toISOString():new Date().toISOString(),is_published:q.item.is_published,created_by:t==null?void 0:t.id};let te=q.itemId;const Y=!te,J=(o==null?void 0:o.is_published)||!1;if(te){const{error:ce}=await G.from("social_swag").update(U).eq("id",te);if(ce)throw ce;await G.from("social_swag_links").delete().eq("swag_id",te)}else{const{data:ce,error:ie}=await G.from("social_swag").insert(U).select().single();if(ie)throw ie;te=ce.id}const X=q.item.links.filter(ce=>ce.title.trim()&&ce.canva_share_link.trim());if(X.length>0){const ce=X.map((ae,oe)=>({swag_id:te,title:ae.title.trim(),canva_share_link:ae.canva_share_link.trim(),sort_order:oe})),{error:ie}=await G.from("social_swag_links").insert(ce);if(ie)throw ie}return{itemId:te,itemTitle:q.item.title,isNewItem:Y,wasPublished:J,isPublished:q.item.is_published}},onSuccess:q=>{r.invalidateQueries({queryKey:["social-swag-admin"]}),r.invalidateQueries({queryKey:["social-swag"]}),s({title:o?"Item updated":"Item created"}),q.isPublished&&(q.isNewItem||!q.wasPublished)&&Z_e(q.itemTitle,q.itemId),a(!1),S()},onError:q=>{s({title:"Error saving item",description:q.message,variant:"destructive"})}}),w=Pt({mutationFn:async q=>{const{error:B}=await G.from("social_swag").delete().eq("id",q);if(B)throw B},onSuccess:()=>{r.invalidateQueries({queryKey:["social-swag-admin"]}),r.invalidateQueries({queryKey:["social-swag"]}),s({title:"Item deleted"})},onError:q=>{s({title:"Error deleting item",description:q.message,variant:"destructive"})}}),S=()=>{d({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,links:[{title:"",canva_share_link:"",sort_order:0}]}),p(null),y(""),l(null)},C=q=>{l(q),d({title:q.title,description:q.description||"",publish_date:q.publish_date?new Date(q.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:q.is_published,links:q.links&&q.links.length>0?q.links.map(B=>({id:B.id,title:B.title,canva_share_link:B.canva_share_link,sort_order:B.sort_order})):[{title:"",canva_share_link:"",sort_order:0}]}),y(q.preview_image_url||""),a(!0)},A=q=>{var U;const B=(U=q.target.files)==null?void 0:U[0];B&&(p(B),y(URL.createObjectURL(B)))},I=()=>{d({...i,links:[...i.links,{title:"",canva_share_link:"",sort_order:i.links.length}]})},L=q=>{if(i.links.length<=1)return;const B=i.links.filter((U,te)=>te!==q);d({...i,links:B})},O=(q,B,U)=>{const te=[...i.links];te[q]={...te[q],[B]:U},d({...i,links:te})},V=q=>{if(q.preventDefault(),!i.title.trim()){s({title:"Title is required",variant:"destructive"});return}N.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(Ds,{title:"Manage Social Swag",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Hu,{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(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Items"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.length})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.filter(q=>q.is_published).length})})]})]}),e.jsxs(fs,{open:n,onOpenChange:q=>{a(q),q||S()},children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{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(ks,{children:e.jsx(_s,{children:o?"Edit Item":"Add New Item"})}),e.jsxs("form",{onSubmit:V,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"title",children:"Title *"}),e.jsx(De,{id:"title",value:i.title,onChange:q=>d({...i,title:q.target.value}),placeholder:"Enter title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Description"}),e.jsx(Wg,{content:i.description,onChange:q=>d({...i,description:q}),placeholder:"Enter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(De,{id:"publish_date",type:"date",value:i.publish_date,onChange:q=>d({...i,publish_date:q.target.value})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ar,{id:"is_published",checked:i.is_published,onCheckedChange:q=>d({...i,is_published:q})}),e.jsx(xe,{htmlFor:"is_published",children:"Published"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{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(W,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{p(null),y("")},children:e.jsx(kr,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[e.jsx(qo,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx(De,{type:"file",accept:"image/*",onChange:A,className:"cursor-pointer"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{children:"Canva Links"}),e.jsxs(W,{type:"button",variant:"outline",size:"sm",onClick:I,children:[e.jsx(qs,{className:"h-3 w-3 mr-1"}),"Add Link"]})]}),i.links.map((q,B)=>e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-4 pb-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground",children:["Link ",B+1]}),i.links.length>1&&e.jsx(W,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>L(B),children:e.jsx(kr,{className:"h-3 w-3"})})]}),e.jsx(De,{placeholder:"Link title (e.g., Instagram Post)",value:q.title,onChange:U=>O(B,"title",U.target.value)}),e.jsx(De,{placeholder:"Canva share link",value:q.canva_share_link,onChange:U=>O(B,"canva_share_link",U.target.value)})]})},B))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(W,{type:"submit",disabled:N.isPending,children:N.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(Pe,{children:e.jsx(Oe,{className:"p-0",children:b?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):_.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'No items yet. Click "Add Item" to create your first one.'}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{className:"w-16",children:"Preview"}),e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Links"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:_.map(q=>{var B;return e.jsxs(Ps,{children:[e.jsx(ht,{children:q.preview_image_url?e.jsx("img",{src:q.preview_image_url,alt:"",className:"w-12 h-12 object-cover rounded"}):e.jsx("div",{className:"w-12 h-12 bg-muted rounded flex items-center justify-center",children:e.jsx(qo,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsx(ht,{className:"font-medium",children:q.title}),e.jsxs(ht,{children:[((B=q.links)==null?void 0:B.length)||0," links"]}),e.jsx(ht,{children:new Date(q.publish_date).toLocaleDateString()}),e.jsx(ht,{children:e.jsx(Qe,{variant:q.is_published?"default":"secondary",children:q.is_published?"Published":"Draft"})}),e.jsx(ht,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>window.open(`/social-swag/${q.id}`,"_blank"),children:e.jsx(jn,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>C(q),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this item?")&&w.mutate(q.id)},children:e.jsx(vr,{className:"h-4 w-4"})})]})})]},q.id)})})]})})})]})})};function FVt(){for(var t=arguments.length,s=new Array(t),r=0;rn=>{s.forEach(a=>a(n))},s)}const The=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function nE(t){const s=Object.prototype.toString.call(t);return s==="[object Window]"||s==="[object global]"}function f4e(t){return"nodeType"in t}function wp(t){var s,r;return t?nE(t)?t:f4e(t)&&(s=(r=t.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function x4e(t){const{Document:s}=wp(t);return t instanceof s}function nO(t){return nE(t)?!1:t instanceof wp(t).HTMLElement}function vtt(t){return t instanceof wp(t).SVGElement}function aE(t){return t?nE(t)?t.document:f4e(t)?x4e(t)?t:nO(t)||vtt(t)?t.ownerDocument:document:document:document}const g0=The?k.useLayoutEffect:k.useEffect;function g4e(t){const s=k.useRef(t);return g0(()=>{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 kD(t,s){s===void 0&&(s=[t]);const r=k.useRef(t);return g0(()=>{r.current!==t&&(r.current=t)},s),r}function aO(t,s){const r=k.useRef();return k.useMemo(()=>{const n=t(r.current);return r.current=n,n},[...s])}function xce(t){const s=g4e(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 Y_e(t){const s=k.useRef();return k.useEffect(()=>{s.current=t},[t]),s.current}let Mye={};function iO(t,s){return k.useMemo(()=>{if(s)return s;const r=Mye[t]==null?0:Mye[t]+1;return Mye[t]=r,t+"-"+r},[t,s])}function _tt(t){return function(s){for(var r=arguments.length,n=new Array(r>1?r-1:0),a=1;a{const i=Object.entries(l);for(const[d,u]of i){const p=o[d];p!=null&&(o[d]=p+t*u)}return o},{...s})}}const QM=_tt(1),SD=_tt(-1);function BVt(t){return"clientX"in t&&"clientY"in t}function y4e(t){if(!t)return!1;const{KeyboardEvent:s}=wp(t.target);return s&&t instanceof s}function $Vt(t){if(!t)return!1;const{TouchEvent:s}=wp(t.target);return s&&t instanceof s}function X_e(t){if($Vt(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 BVt(t)?{x:t.clientX,y:t.clientY}:null}const iC=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[iC.Translate.toString(t),iC.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:s,duration:r,easing:n}=t;return s+" "+r+"ms "+n}}}),nDe="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function qVt(t){return t.matches(nDe)?t:t.querySelector(nDe)}const UVt={display:"none"};function VVt(t){let{id:s,value:r}=t;return xt.createElement("div",{id:s,style:UVt},r)}function HVt(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 xt.createElement("div",{id:s,style:a,role:"status","aria-live":n,"aria-atomic":!0},r)}function GVt(){const[t,s]=k.useState("");return{announce:k.useCallback(n=>{n!=null&&s(n)},[]),announcement:t}}const btt=k.createContext(null);function WVt(t){const s=k.useContext(btt);k.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of ");return s(t)},[t,s])}function KVt(){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 ZVt={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. `},YVt={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 XVt(t){let{announcements:s=YVt,container:r,hiddenTextDescribedById:n,screenReaderInstructions:a=ZVt}=t;const{announce:o,announcement:l}=GVt(),i=iO("DndLiveRegion"),[d,u]=k.useState(!1);if(k.useEffect(()=>{u(!0)},[]),WVt(k.useMemo(()=>({onDragStart(f){let{active:y}=f;o(s.onDragStart({active:y}))},onDragMove(f){let{active:y,over:_}=f;s.onDragMove&&o(s.onDragMove({active:y,over:_}))},onDragOver(f){let{active:y,over:_}=f;o(s.onDragOver({active:y,over:_}))},onDragEnd(f){let{active:y,over:_}=f;o(s.onDragEnd({active:y,over:_}))},onDragCancel(f){let{active:y,over:_}=f;o(s.onDragCancel({active:y,over:_}))}}),[o,s])),!d)return null;const p=xt.createElement(xt.Fragment,null,xt.createElement(VVt,{id:n,value:a.draggable}),xt.createElement(HVt,{id:i,announcement:l}));return r?op.createPortal(p,r):p}var ru;(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"})(ru||(ru={}));function gce(){}function yce(t,s){return k.useMemo(()=>({sensor:t,options:s??{}}),[t,s])}function v4e(){for(var t=arguments.length,s=new Array(t),r=0;r[...s].filter(n=>n!=null),[...s])}const Vg=Object.freeze({x:0,y:0});function wtt(t,s){return Math.sqrt(Math.pow(t.x-s.x,2)+Math.pow(t.y-s.y,2))}function jtt(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return r-n}function QVt(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return n-r}function aDe(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 Ntt(t,s){if(!t||t.length===0)return null;const[r]=t;return r[s]}function iDe(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 _4e=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=iDe(s,s.left,s.top),o=[];for(const l of n){const{id:i}=l,d=r.get(i);if(d){const u=wtt(iDe(d),a);o.push({id:i,data:{droppableContainer:l,value:u}})}}return o.sort(jtt)},JVt=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=aDe(s),o=[];for(const l of n){const{id:i}=l,d=r.get(i);if(d){const u=aDe(d),p=a.reduce((y,_,b)=>y+wtt(u[b],_),0),f=Number((p/4).toFixed(4));o.push({id:i,data:{droppableContainer:l,value:f}})}}return o.sort(jtt)};function eHt(t,s){const r=Math.max(s.top,t.top),n=Math.max(s.left,t.left),a=Math.min(s.left+s.width,t.left+t.width),o=Math.min(s.top+s.height,t.top+t.height),l=a-n,i=o-r;if(n{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=[];for(const o of n){const{id:l}=o,i=r.get(l);if(i){const d=eHt(i,s);d>0&&a.push({id:l,data:{droppableContainer:o,value:d}})}}return a.sort(QVt)};function sHt(t,s,r){return{...t,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function ktt(t,s){return t&&s?{x:t.left-s.left,y:t.top-s.top}:Vg}function rHt(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 nHt=rHt(1);function aHt(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 iHt(t,s,r){const n=aHt(s);if(!n)return t;const{scaleX:a,scaleY:o,x:l,y:i}=n,d=t.left-l-(1-a)*parseFloat(r),u=t.top-i-(1-o)*parseFloat(r.slice(r.indexOf(" ")+1)),p=a?t.width/a:t.width,f=o?t.height/o:t.height;return{width:p,height:f,top:u,right:d+p,bottom:u+f,left:d}}const oHt={ignoreTransform:!1};function iE(t,s){s===void 0&&(s=oHt);let r=t.getBoundingClientRect();if(s.ignoreTransform){const{transform:u,transformOrigin:p}=wp(t).getComputedStyle(t);u&&(r=iHt(r,u,p))}const{top:n,left:a,width:o,height:l,bottom:i,right:d}=r;return{top:n,left:a,width:o,height:l,bottom:i,right:d}}function oDe(t){return iE(t,{ignoreTransform:!0})}function lHt(t){const s=t.innerWidth,r=t.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function cHt(t,s){return s===void 0&&(s=wp(t).getComputedStyle(t)),s.position==="fixed"}function dHt(t,s){s===void 0&&(s=wp(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 Ahe(t,s){const r=[];function n(a){if(s!=null&&r.length>=s||!a)return r;if(x4e(a)&&a.scrollingElement!=null&&!r.includes(a.scrollingElement))return r.push(a.scrollingElement),r;if(!nO(a)||vtt(a)||r.includes(a))return r;const o=wp(t).getComputedStyle(a);return a!==t&&dHt(a,o)&&r.push(a),cHt(a,o)?r:n(a.parentNode)}return t?n(t):r}function Stt(t){const[s]=Ahe(t,1);return s??null}function Tye(t){return!The||!t?null:nE(t)?t:f4e(t)?x4e(t)||t===aE(t).scrollingElement?window:nO(t)?t:null:null}function Ctt(t){return nE(t)?t.scrollX:t.scrollLeft}function Mtt(t){return nE(t)?t.scrollY:t.scrollTop}function Q_e(t){return{x:Ctt(t),y:Mtt(t)}}var Lu;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Lu||(Lu={}));function Ttt(t){return!The||!t?!1:t===document.scrollingElement}function Att(t){const s={x:0,y:0},r=Ttt(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 uHt={x:.2,y:.2};function hHt(t,s,r,n,a){let{top:o,left:l,right:i,bottom:d}=r;n===void 0&&(n=10),a===void 0&&(a=uHt);const{isTop:u,isBottom:p,isLeft:f,isRight:y}=Att(t),_={x:0,y:0},b={x:0,y:0},N={height:s.height*a.y,width:s.width*a.x};return!u&&o<=s.top+N.height?(_.y=Lu.Backward,b.y=n*Math.abs((s.top+N.height-o)/N.height)):!p&&d>=s.bottom-N.height&&(_.y=Lu.Forward,b.y=n*Math.abs((s.bottom-N.height-d)/N.height)),!y&&i>=s.right-N.width?(_.x=Lu.Forward,b.x=n*Math.abs((s.right-N.width-i)/N.width)):!f&&l<=s.left+N.width&&(_.x=Lu.Backward,b.x=n*Math.abs((s.left+N.width-l)/N.width)),{direction:_,speed:b}}function mHt(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 Ett(t){return t.reduce((s,r)=>QM(s,Q_e(r)),Vg)}function pHt(t){return t.reduce((s,r)=>s+Ctt(r),0)}function fHt(t){return t.reduce((s,r)=>s+Mtt(r),0)}function xHt(t,s){if(s===void 0&&(s=iE),!t)return;const{top:r,left:n,bottom:a,right:o}=s(t);Stt(t)&&(a<=0||o<=0||r>=window.innerHeight||n>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const gHt=[["x",["left","right"],pHt],["y",["top","bottom"],fHt]];class b4e{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=Ahe(r),a=Ett(n);this.rect={...s},this.width=s.width,this.height=s.height;for(const[o,l,i]of gHt)for(const d of l)Object.defineProperty(this,d,{get:()=>{const u=i(n),p=a[o]-u;return this.rect[d]+p},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class y8{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 yHt(t){const{EventTarget:s}=wp(t);return t instanceof s?t:aE(t)}function Aye(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 rx;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(rx||(rx={}));function lDe(t){t.preventDefault()}function vHt(t){t.stopPropagation()}var to;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(to||(to={}));const Ptt={start:[to.Space,to.Enter],cancel:[to.Esc],end:[to.Space,to.Enter,to.Tab]},_Ht=(t,s)=>{let{currentCoordinates:r}=s;switch(t.code){case to.Right:return{...r,x:r.x+25};case to.Left:return{...r,x:r.x-25};case to.Down:return{...r,y:r.y+25};case to.Up:return{...r,y:r.y-25}}};class w4e{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 y8(aE(r)),this.windowListeners=new y8(wp(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(rx.Resize,this.handleCancel),this.windowListeners.add(rx.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(rx.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,n=s.node.current;n&&xHt(n),r(Vg)}handleKeyDown(s){if(y4e(s)){const{active:r,context:n,options:a}=this.props,{keyboardCodes:o=Ptt,coordinateGetter:l=_Ht,scrollBehavior:i="smooth"}=a,{code:d}=s;if(o.end.includes(d)){this.handleEnd(s);return}if(o.cancel.includes(d)){this.handleCancel(s);return}const{collisionRect:u}=n.current,p=u?{x:u.left,y:u.top}:Vg;this.referenceCoordinates||(this.referenceCoordinates=p);const f=l(s,{active:r,context:n.current,currentCoordinates:p});if(f){const y=SD(f,p),_={x:0,y:0},{scrollableAncestors:b}=n.current;for(const N of b){const w=s.code,{isTop:S,isRight:C,isLeft:A,isBottom:I,maxScroll:L,minScroll:O}=Att(N),V=mHt(N),q={x:Math.min(w===to.Right?V.right-V.width/2:V.right,Math.max(w===to.Right?V.left:V.left+V.width/2,f.x)),y:Math.min(w===to.Down?V.bottom-V.height/2:V.bottom,Math.max(w===to.Down?V.top:V.top+V.height/2,f.y))},B=w===to.Right&&!C||w===to.Left&&!A,U=w===to.Down&&!I||w===to.Up&&!S;if(B&&q.x!==f.x){const te=N.scrollLeft+y.x,Y=w===to.Right&&te<=L.x||w===to.Left&&te>=O.x;if(Y&&!y.y){N.scrollTo({left:te,behavior:i});return}Y?_.x=N.scrollLeft-te:_.x=w===to.Right?N.scrollLeft-L.x:N.scrollLeft-O.x,_.x&&N.scrollBy({left:-_.x,behavior:i});break}else if(U&&q.y!==f.y){const te=N.scrollTop+y.y,Y=w===to.Down&&te<=L.y||w===to.Up&&te>=O.y;if(Y&&!y.x){N.scrollTo({top:te,behavior:i});return}Y?_.y=N.scrollTop-te:_.y=w===to.Down?N.scrollTop-L.y:N.scrollTop-O.y,_.y&&N.scrollBy({top:-_.y,behavior:i});break}}this.handleMove(s,QM(SD(f,this.referenceCoordinates),_))}}}handleMove(s,r){const{onMove:n}=this.props;s.preventDefault(),n(r)}handleEnd(s){const{onEnd:r}=this.props;s.preventDefault(),this.detach(),r()}handleCancel(s){const{onCancel:r}=this.props;s.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}w4e.activators=[{eventName:"onKeyDown",handler:(t,s,r)=>{let{keyboardCodes:n=Ptt,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 cDe(t){return!!(t&&"distance"in t)}function dDe(t){return!!(t&&"delay"in t)}class j4e{constructor(s,r,n){var a;n===void 0&&(n=yHt(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=aE(l),this.documentListeners=new y8(this.document),this.listeners=new y8(n),this.windowListeners=new y8(wp(l)),this.initialCoordinates=(a=X_e(o))!=null?a:Vg,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(rx.Resize,this.handleCancel),this.windowListeners.add(rx.DragStart,lDe),this.windowListeners.add(rx.VisibilityChange,this.handleCancel),this.windowListeners.add(rx.ContextMenu,lDe),this.documentListeners.add(rx.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(dDe(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(cDe(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(rx.Click,vHt,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(rx.SelectionChange,this.removeTextSelection),r(s))}handleMove(s){var r;const{activated:n,initialCoordinates:a,props:o}=this,{onMove:l,options:{activationConstraint:i}}=o;if(!a)return;const d=(r=X_e(s))!=null?r:Vg,u=SD(a,d);if(!n&&i){if(cDe(i)){if(i.tolerance!=null&&Aye(u,i.tolerance))return this.handleCancel();if(Aye(u,i.distance))return this.handleStart()}if(dDe(i)&&Aye(u,i.tolerance))return this.handleCancel();this.handlePending(i,u);return}s.cancelable&&s.preventDefault(),l(d)}handleEnd(){const{onAbort:s,onEnd:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleCancel(){const{onAbort:s,onCancel:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleKeydown(s){s.code===to.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const bHt={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class oO extends j4e{constructor(s){const{event:r}=s,n=aE(r.target);super(s,bHt,n)}}oO.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 wHt={move:{name:"mousemove"},end:{name:"mouseup"}};var J_e;(function(t){t[t.RightClick=2]="RightClick"})(J_e||(J_e={}));class jHt extends j4e{constructor(s){super(s,wHt,aE(s.event.target))}}jHt.activators=[{eventName:"onMouseDown",handler:(t,s)=>{let{nativeEvent:r}=t,{onActivation:n}=s;return r.button===J_e.RightClick?!1:(n==null||n({event:r}),!0)}}];const Eye={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class NHt extends j4e{constructor(s){super(s,Eye)}static setup(){return window.addEventListener(Eye.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(Eye.move.name,s)};function s(){}}}NHt.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 v8;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(v8||(v8={}));var vce;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(vce||(vce={}));function kHt(t){let{acceleration:s,activator:r=v8.Pointer,canScroll:n,draggingRect:a,enabled:o,interval:l=5,order:i=vce.TreeOrder,pointerCoordinates:d,scrollableAncestors:u,scrollableAncestorRects:p,delta:f,threshold:y}=t;const _=CHt({delta:f,disabled:!o}),[b,N]=zVt(),w=k.useRef({x:0,y:0}),S=k.useRef({x:0,y:0}),C=k.useMemo(()=>{switch(r){case v8.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case v8.DraggableRect:return a}},[r,a,d]),A=k.useRef(null),I=k.useCallback(()=>{const O=A.current;if(!O)return;const V=w.current.x*S.current.x,q=w.current.y*S.current.y;O.scrollBy(V,q)},[]),L=k.useMemo(()=>i===vce.TreeOrder?[...u].reverse():u,[i,u]);k.useEffect(()=>{if(!o||!u.length||!C){N();return}for(const O of L){if((n==null?void 0:n(O))===!1)continue;const V=u.indexOf(O),q=p[V];if(!q)continue;const{direction:B,speed:U}=hHt(O,q,C,s,y);for(const te of["x","y"])_[te][B[te]]||(U[te]=0,B[te]=0);if(U.x>0||U.y>0){N(),A.current=O,b(I,l),w.current=U,S.current=B;return}}w.current={x:0,y:0},S.current={x:0,y:0},N()},[s,I,n,N,o,l,JSON.stringify(C),JSON.stringify(_),b,u,L,p,JSON.stringify(y)])}const SHt={x:{[Lu.Backward]:!1,[Lu.Forward]:!1},y:{[Lu.Backward]:!1,[Lu.Forward]:!1}};function CHt(t){let{delta:s,disabled:r}=t;const n=Y_e(s);return aO(a=>{if(r||!n||!a)return SHt;const o={x:Math.sign(s.x-n.x),y:Math.sign(s.y-n.y)};return{x:{[Lu.Backward]:a.x[Lu.Backward]||o.x===-1,[Lu.Forward]:a.x[Lu.Forward]||o.x===1},y:{[Lu.Backward]:a.y[Lu.Backward]||o.y===-1,[Lu.Forward]:a.y[Lu.Forward]||o.y===1}}},[r,s,n])}function MHt(t,s){const r=s!=null?t.get(s):void 0,n=r?r.node.current:null;return aO(a=>{var o;return s==null?null:(o=n??a)!=null?o:null},[n,s])}function THt(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 CD;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(CD||(CD={}));var ebe;(function(t){t.Optimized="optimized"})(ebe||(ebe={}));const uDe=new Map;function AHt(t,s){let{dragging:r,dependencies:n,config:a}=s;const[o,l]=k.useState(null),{frequency:i,measure:d,strategy:u}=a,p=k.useRef(t),f=w(),y=kD(f),_=k.useCallback(function(S){S===void 0&&(S=[]),!y.current&&l(C=>C===null?S:C.concat(S.filter(A=>!C.includes(A))))},[y]),b=k.useRef(null),N=aO(S=>{if(f&&!r)return uDe;if(!S||S===uDe||p.current!==t||o!=null){const C=new Map;for(let A of t){if(!A)continue;if(o&&o.length>0&&!o.includes(A.id)&&A.rect.current){C.set(A.id,A.rect.current);continue}const I=A.node.current,L=I?new b4e(d(I),I):null;A.rect.current=L,L&&C.set(A.id,L)}return C}return S},[t,o,r,f,d]);return k.useEffect(()=>{p.current=t},[t]),k.useEffect(()=>{f||_()},[r,f]),k.useEffect(()=>{o&&o.length>0&&l(null)},[JSON.stringify(o)]),k.useEffect(()=>{f||typeof i!="number"||b.current!==null||(b.current=setTimeout(()=>{_(),b.current=null},i))},[i,f,_,...n]),{droppableRects:N,measureDroppableContainers:_,measuringScheduled:o!=null};function w(){switch(u){case CD.Always:return!1;case CD.BeforeDragging:return r;default:return!r}}}function Itt(t,s){return aO(r=>t?r||(typeof s=="function"?s(t):t):null,[s,t])}function EHt(t,s){return Itt(t,s)}function PHt(t){let{callback:s,disabled:r}=t;const n=g4e(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 Ehe(t){let{callback:s,disabled:r}=t;const n=g4e(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 IHt(t){return new b4e(iE(t),t)}function hDe(t,s,r){s===void 0&&(s=IHt);const[n,a]=k.useState(null);function o(){a(d=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=d??r)!=null?u:null}const p=s(t);return JSON.stringify(d)===JSON.stringify(p)?d:p})}const l=PHt({callback(d){if(t)for(const u of d){const{type:p,target:f}=u;if(p==="childList"&&f instanceof HTMLElement&&f.contains(t)){o();break}}}}),i=Ehe({callback:o});return g0(()=>{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 LHt(t){const s=Itt(t);return ktt(t,s)}const mDe=[];function DHt(t){const s=k.useRef(t),r=aO(n=>t?n&&n!==mDe&&t&&s.current&&t.parentNode===s.current.parentNode?n:Ahe(t):mDe,[t]);return k.useEffect(()=>{s.current=t},[t]),r}function RHt(t){const[s,r]=k.useState(null),n=k.useRef(t),a=k.useCallback(o=>{const l=Tye(o.target);l&&r(i=>i?(i.set(l,Q_e(l)),new Map(i)):null)},[]);return k.useEffect(()=>{const o=n.current;if(t!==o){l(o);const i=t.map(d=>{const u=Tye(d);return u?(u.addEventListener("scroll",a,{passive:!0}),[u,Q_e(u)]):null}).filter(d=>d!=null);r(i.length?new Map(i):null),n.current=t}return()=>{l(t),l(o)};function l(i){i.forEach(d=>{const u=Tye(d);u==null||u.removeEventListener("scroll",a)})}},[a,t]),k.useMemo(()=>t.length?s?Array.from(s.values()).reduce((o,l)=>QM(o,l),Vg):Ett(t):Vg,[t,s])}function pDe(t,s){s===void 0&&(s=[]);const r=k.useRef(null);return k.useEffect(()=>{r.current=null},s),k.useEffect(()=>{const n=t!==Vg;n&&!r.current&&(r.current=t),!n&&r.current&&(r.current=null)},[t]),r.current?SD(t,r.current):Vg}function OHt(t){k.useEffect(()=>{if(!The)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 FHt(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 Ltt(t){return k.useMemo(()=>t?lHt(t):null,[t])}const fDe=[];function zHt(t,s){s===void 0&&(s=iE);const[r]=t,n=Ltt(r?wp(r):null),[a,o]=k.useState(fDe);function l(){o(()=>t.length?t.map(d=>Ttt(d)?n:new b4e(s(d),d)):fDe)}const i=Ehe({callback:l});return g0(()=>{i==null||i.disconnect(),l(),t.forEach(d=>i==null?void 0:i.observe(d))},[t]),a}function BHt(t){if(!t)return null;if(t.children.length>1)return t;const s=t.children[0];return nO(s)?s:t}function $Ht(t){let{measure:s}=t;const[r,n]=k.useState(null),a=k.useCallback(u=>{for(const{target:p}of u)if(nO(p)){n(f=>{const y=s(p);return f?{...f,width:y.width,height:y.height}:y});break}},[s]),o=Ehe({callback:a}),l=k.useCallback(u=>{const p=BHt(u);o==null||o.disconnect(),p&&(o==null||o.observe(p)),n(p?s(p):null)},[s,o]),[i,d]=xce(l);return k.useMemo(()=>({nodeRef:i,rect:r,setRef:d}),[r,i,d])}const qHt=[{sensor:oO,options:{}},{sensor:w4e,options:{}}],UHt={current:{}},ooe={draggable:{measure:oDe},droppable:{measure:oDe,strategy:CD.WhileDragging,frequency:ebe.Optimized},dragOverlay:{measure:iE}};class _8 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 VHt={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new _8,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:gce},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:ooe,measureDroppableContainers:gce,windowRect:null,measuringScheduled:!1},HHt={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:gce,draggableNodes:new Map,over:null,measureDroppableContainers:gce},Phe=k.createContext(HHt),Dtt=k.createContext(VHt);function GHt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new _8}}}function WHt(t,s){switch(s.type){case ru.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case ru.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 ru.DragEnd:case ru.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ru.RegisterDroppable:{const{element:r}=s,{id:n}=r,a=new _8(t.droppable.containers);return a.set(n,r),{...t,droppable:{...t.droppable,containers:a}}}case ru.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 _8(t.droppable.containers);return l.set(r,{...o,disabled:a}),{...t,droppable:{...t.droppable,containers:l}}}case ru.UnregisterDroppable:{const{id:r,key:n}=s,a=t.droppable.containers.get(r);if(!a||n!==a.key)return t;const o=new _8(t.droppable.containers);return o.delete(r),{...t,droppable:{...t.droppable,containers:o}}}default:return t}}function KHt(t){let{disabled:s}=t;const{active:r,activatorEvent:n,draggableNodes:a}=k.useContext(Phe),o=Y_e(n),l=Y_e(r==null?void 0:r.id);return k.useEffect(()=>{if(!s&&!n&&o&&l!=null){if(!y4e(o)||document.activeElement===o.target)return;const i=a.get(l);if(!i)return;const{activatorNode:d,node:u}=i;if(!d.current&&!u.current)return;requestAnimationFrame(()=>{for(const p of[d.current,u.current]){if(!p)continue;const f=qVt(p);if(f){f.focus();break}}})}},[n,s,a,l,o]),null}function ZHt(t,s){let{transform:r,...n}=s;return t!=null&&t.length?t.reduce((a,o)=>o({transform:a,...n}),r):r}function YHt(t){return k.useMemo(()=>({draggable:{...ooe.draggable,...t==null?void 0:t.draggable},droppable:{...ooe.droppable,...t==null?void 0:t.droppable},dragOverlay:{...ooe.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 XHt(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;g0(()=>{if(!l&&!i||!s){o.current=!1;return}if(o.current||!n)return;const u=s==null?void 0:s.node.current;if(!u||u.isConnected===!1)return;const p=r(u),f=ktt(p,n);if(l||(f.x=0),i||(f.y=0),o.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const y=Stt(u);y&&y.scrollBy({top:f.y,left:f.x})}},[s,l,i,n,r])}const Rtt=k.createContext({...Vg,scaleX:1,scaleY:1});var z_;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(z_||(z_={}));const N4e=k.memo(function(s){var r,n,a,o;let{id:l,accessibility:i,autoScroll:d=!0,children:u,sensors:p=qHt,collisionDetection:f=tHt,measuring:y,modifiers:_,...b}=s;const N=k.useReducer(WHt,void 0,GHt),[w,S]=N,[C,A]=KVt(),[I,L]=k.useState(z_.Uninitialized),O=I===z_.Initialized,{draggable:{active:V,nodes:q,translate:B},droppable:{containers:U}}=w,te=V!=null?q.get(V):null,Y=k.useRef({initial:null,translated:null}),J=k.useMemo(()=>{var Fr;return V!=null?{id:V,data:(Fr=te==null?void 0:te.data)!=null?Fr:UHt,rect:Y}:null},[V,te]),X=k.useRef(null),[ce,ie]=k.useState(null),[ae,oe]=k.useState(null),me=kD(b,Object.values(b)),ve=iO("DndDescribedBy",l),he=k.useMemo(()=>U.getEnabled(),[U]),ge=YHt(y),{droppableRects:je,measureDroppableContainers:qe,measuringScheduled:Me}=AHt(he,{dragging:O,dependencies:[B.x,B.y],config:ge.droppable}),ke=MHt(q,V),Re=k.useMemo(()=>ae?X_e(ae):null,[ae]),Ve=Cr(),Ne=EHt(ke,ge.draggable.measure);XHt({activeNode:V!=null?q.get(V):null,config:Ve.layoutShiftCompensation,initialRect:Ne,measure:ge.draggable.measure});const Ue=hDe(ke,ge.draggable.measure,Ne),Ie=hDe(ke?ke.parentElement:null),ye=k.useRef({activatorEvent:null,active:null,activeNode:ke,collisionRect:null,collisions:null,droppableRects:je,draggableNodes:q,draggingNode:null,draggingNodeRect:null,droppableContainers:U,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ct=U.getNodeFor((r=ye.current.over)==null?void 0:r.id),fe=$Ht({measure:ge.dragOverlay.measure}),$e=(n=fe.nodeRef.current)!=null?n:ke,Ye=O?(a=fe.rect)!=null?a:Ue:null,tt=!!(fe.nodeRef.current&&fe.rect),Te=LHt(tt?null:Ue),We=Ltt($e?wp($e):null),Ke=DHt(O?ct??ke:null),ot=zHt(Ke),He=ZHt(_,{transform:{x:B.x-Te.x,y:B.y-Te.y,scaleX:1,scaleY:1},activatorEvent:ae,active:J,activeNodeRect:Ue,containerNodeRect:Ie,draggingNodeRect:Ye,over:ye.current.over,overlayNodeRect:fe.rect,scrollableAncestors:Ke,scrollableAncestorRects:ot,windowRect:We}),Je=Re?QM(Re,B):null,ut=RHt(Ke),mt=pDe(ut),et=pDe(ut,[Ue]),Ze=QM(He,mt),kt=Ye?nHt(Ye,He):null,Ut=J&&kt?f({active:J,collisionRect:kt,droppableRects:je,droppableContainers:he,pointerCoordinates:Je}):null,Nt=Ntt(Ut,"id"),[es,ds]=k.useState(null),js=tt?He:QM(He,et),lr=sHt(js,(o=es==null?void 0:es.rect)!=null?o:null,Ue),Lt=k.useRef(null),Es=k.useCallback((Fr,$r)=>{let{sensor:nr,options:cr}=$r;if(X.current==null)return;const Br=q.get(X.current);if(!Br)return;const Kr=Fr.nativeEvent,Sn=new nr({active:X.current,activeNode:Br,event:Kr,options:cr,context:ye,onAbort(as){if(!q.get(as))return;const{onDragAbort:un}=me.current,qr={id:as};un==null||un(qr),C({type:"onDragAbort",event:qr})},onPending(as,qn,un,qr){if(!q.get(as))return;const{onDragPending:La}=me.current,Yt={id:as,constraint:qn,initialCoordinates:un,offset:qr};La==null||La(Yt),C({type:"onDragPending",event:Yt})},onStart(as){const qn=X.current;if(qn==null)return;const un=q.get(qn);if(!un)return;const{onDragStart:qr}=me.current,Zr={activatorEvent:Kr,active:{id:qn,data:un.data,rect:Y}};op.unstable_batchedUpdates(()=>{qr==null||qr(Zr),L(z_.Initializing),S({type:ru.DragStart,initialCoordinates:as,active:qn}),C({type:"onDragStart",event:Zr}),ie(Lt.current),oe(Kr)})},onMove(as){S({type:ru.DragMove,coordinates:as})},onEnd:ai(ru.DragEnd),onCancel:ai(ru.DragCancel)});Lt.current=Sn;function ai(as){return async function(){const{active:un,collisions:qr,over:Zr,scrollAdjustedTranslate:La}=ye.current;let Yt=null;if(un&&La){const{cancelDrop:Lr}=me.current;Yt={activatorEvent:Kr,active:un,collisions:qr,delta:La,over:Zr},as===ru.DragEnd&&typeof Lr=="function"&&await Promise.resolve(Lr(Yt))&&(as=ru.DragCancel)}X.current=null,op.unstable_batchedUpdates(()=>{S({type:as}),L(z_.Uninitialized),ds(null),ie(null),oe(null),Lt.current=null;const Lr=as===ru.DragEnd?"onDragEnd":"onDragCancel";if(Yt){const $t=me.current[Lr];$t==null||$t(Yt),C({type:Lr,event:Yt})}})}}},[q]),fr=k.useCallback((Fr,$r)=>(nr,cr)=>{const Br=nr.nativeEvent,Kr=q.get(cr);if(X.current!==null||!Kr||Br.dndKit||Br.defaultPrevented)return;const Sn={active:Kr};Fr(nr,$r.options,Sn)===!0&&(Br.dndKit={capturedBy:$r.sensor},X.current=cr,Es(nr,$r))},[q,Es]),Hs=THt(p,fr);OHt(p),g0(()=>{Ue&&I===z_.Initializing&&L(z_.Initialized)},[Ue,I]),k.useEffect(()=>{const{onDragMove:Fr}=me.current,{active:$r,activatorEvent:nr,collisions:cr,over:Br}=ye.current;if(!$r||!nr)return;const Kr={active:$r,activatorEvent:nr,collisions:cr,delta:{x:Ze.x,y:Ze.y},over:Br};op.unstable_batchedUpdates(()=>{Fr==null||Fr(Kr),C({type:"onDragMove",event:Kr})})},[Ze.x,Ze.y]),k.useEffect(()=>{const{active:Fr,activatorEvent:$r,collisions:nr,droppableContainers:cr,scrollAdjustedTranslate:Br}=ye.current;if(!Fr||X.current==null||!$r||!Br)return;const{onDragOver:Kr}=me.current,Sn=cr.get(Nt),ai=Sn&&Sn.rect.current?{id:Sn.id,rect:Sn.rect.current,data:Sn.data,disabled:Sn.disabled}:null,as={active:Fr,activatorEvent:$r,collisions:nr,delta:{x:Br.x,y:Br.y},over:ai};op.unstable_batchedUpdates(()=>{ds(ai),Kr==null||Kr(as),C({type:"onDragOver",event:as})})},[Nt]),g0(()=>{ye.current={activatorEvent:ae,active:J,activeNode:ke,collisionRect:kt,collisions:Ut,droppableRects:je,draggableNodes:q,draggingNode:$e,draggingNodeRect:Ye,droppableContainers:U,over:es,scrollableAncestors:Ke,scrollAdjustedTranslate:Ze},Y.current={initial:Ye,translated:kt}},[J,ke,Ut,kt,q,$e,Ye,je,U,es,Ke,Ze]),kHt({...Ve,delta:B,draggingRect:kt,pointerCoordinates:Je,scrollableAncestors:Ke,scrollableAncestorRects:ot});const mr=k.useMemo(()=>({active:J,activeNode:ke,activeNodeRect:Ue,activatorEvent:ae,collisions:Ut,containerNodeRect:Ie,dragOverlay:fe,draggableNodes:q,droppableContainers:U,droppableRects:je,over:es,measureDroppableContainers:qe,scrollableAncestors:Ke,scrollableAncestorRects:ot,measuringConfiguration:ge,measuringScheduled:Me,windowRect:We}),[J,ke,Ue,ae,Ut,Ie,fe,q,U,je,es,qe,Ke,ot,ge,Me,We]),an=k.useMemo(()=>({activatorEvent:ae,activators:Hs,active:J,activeNodeRect:Ue,ariaDescribedById:{draggable:ve},dispatch:S,draggableNodes:q,over:es,measureDroppableContainers:qe}),[ae,Hs,J,Ue,S,ve,q,es,qe]);return xt.createElement(btt.Provider,{value:A},xt.createElement(Phe.Provider,{value:an},xt.createElement(Dtt.Provider,{value:mr},xt.createElement(Rtt.Provider,{value:lr},u)),xt.createElement(KHt,{disabled:(i==null?void 0:i.restoreFocus)===!1})),xt.createElement(XVt,{...i,hiddenTextDescribedById:ve}));function Cr(){const Fr=(ce==null?void 0:ce.autoScrollEnabled)===!1,$r=typeof d=="object"?d.enabled===!1:d===!1,nr=O&&!Fr&&!$r;return typeof d=="object"?{...d,enabled:nr}:{enabled:nr}}}),QHt=k.createContext(null),xDe="button",JHt="Draggable";function eGt(t){let{id:s,data:r,disabled:n=!1,attributes:a}=t;const o=iO(JHt),{activators:l,activatorEvent:i,active:d,activeNodeRect:u,ariaDescribedById:p,draggableNodes:f,over:y}=k.useContext(Phe),{role:_=xDe,roleDescription:b="draggable",tabIndex:N=0}=a??{},w=(d==null?void 0:d.id)===s,S=k.useContext(w?Rtt:QHt),[C,A]=xce(),[I,L]=xce(),O=FHt(l,s),V=kD(r);g0(()=>(f.set(s,{id:s,key:o,node:C,activatorNode:I,data:V}),()=>{const B=f.get(s);B&&B.key===o&&f.delete(s)}),[f,s]);const q=k.useMemo(()=>({role:_,tabIndex:N,"aria-disabled":n,"aria-pressed":w&&_===xDe?!0:void 0,"aria-roledescription":b,"aria-describedby":p.draggable}),[n,_,N,w,b,p.draggable]);return{active:d,activatorEvent:i,activeNodeRect:u,attributes:q,isDragging:w,listeners:n?void 0:O,node:C,over:y,setNodeRef:A,setActivatorNodeRef:L,transform:S}}function tGt(){return k.useContext(Dtt)}const sGt="Droppable",rGt={timeout:25};function nGt(t){let{data:s,disabled:r=!1,id:n,resizeObserverConfig:a}=t;const o=iO(sGt),{active:l,dispatch:i,over:d,measureDroppableContainers:u}=k.useContext(Phe),p=k.useRef({disabled:r}),f=k.useRef(!1),y=k.useRef(null),_=k.useRef(null),{disabled:b,updateMeasurementsFor:N,timeout:w}={...rGt,...a},S=kD(N??n),C=k.useCallback(()=>{if(!f.current){f.current=!0;return}_.current!=null&&clearTimeout(_.current),_.current=setTimeout(()=>{u(Array.isArray(S.current)?S.current:[S.current]),_.current=null},w)},[w]),A=Ehe({callback:C,disabled:b||!l}),I=k.useCallback((q,B)=>{A&&(B&&(A.unobserve(B),f.current=!1),q&&A.observe(q))},[A]),[L,O]=xce(I),V=kD(s);return k.useEffect(()=>{!A||!L.current||(A.disconnect(),f.current=!1,A.observe(L.current))},[L,A]),k.useEffect(()=>(i({type:ru.RegisterDroppable,element:{id:n,key:o,disabled:r,node:L,rect:y,data:V}}),()=>i({type:ru.UnregisterDroppable,key:o,id:n})),[n]),k.useEffect(()=>{r!==p.current.disabled&&(i({type:ru.SetDroppableDisabled,id:n,key:o,disabled:r}),p.current.disabled=r)},[n,o,r,i]),{active:l,rect:y,isOver:(d==null?void 0:d.id)===n,node:L,over:d,setNodeRef:O}}function k4e(t,s,r){const n=t.slice();return n.splice(r<0?n.length+r:r,0,n.splice(s,1)[0]),n}function aGt(t,s){return t.reduce((r,n,a)=>{const o=s.get(n);return o&&(r[a]=o),r},Array(t.length))}function t9(t){return t!==null&&t>=0}function iGt(t,s){if(t===s)return!0;if(t.length!==s.length)return!1;for(let r=0;r{var s;let{rects:r,activeNodeRect:n,activeIndex:a,overIndex:o,index:l}=t;const i=(s=r[a])!=null?s:n;if(!i)return null;const d=lGt(r,l,a);if(l===a){const u=r[o];return u?{x:aa&&l<=o?{x:-i.width-d,y:0,...s9}:l=o?{x:i.width+d,y:0,...s9}:{x:0,y:0,...s9}};function lGt(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=k4e(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}},r9={scaleX:1,scaleY:1},NAs=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-d,...r9}:a=l?{x:0,y:i.height+d,...r9}:{x:0,y:0,...r9}};function cGt(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]),b=l!=null,N=l?_.indexOf(l.id):-1,w=u?_.indexOf(u.id):-1,S=k.useRef(_),C=!iGt(_,S.current),A=w!==-1&&N===-1||C,I=oGt(o);g0(()=>{C&&b&&p(_)},[C,_,b,p]),k.useEffect(()=>{S.current=_},[_]);const L=k.useMemo(()=>({activeIndex:N,containerId:f,disabled:I,disableTransforms:A,items:_,overIndex:w,useDragOverlay:y,sortedRects:aGt(_,d),strategy:a}),[N,f,I.draggable,I.droppable,A,_,w,d,y,a]);return xt.createElement(Ftt.Provider,{value:L},s)}const dGt=t=>{let{id:s,items:r,activeIndex:n,overIndex:a}=t;return k4e(r,n,a).indexOf(s)},uGt=t=>{let{containerId:s,isSorting:r,wasDragging:n,index:a,items:o,newIndex:l,previousItems:i,previousContainerId:d,transition:u}=t;return!u||!n||i!==o&&a===l?!1:r?!0:l!==a&&s===d},hGt={duration:200,easing:"ease"},ztt="transform",mGt=iC.Transition.toString({property:ztt,duration:0,easing:"linear"}),pGt={roleDescription:"sortable"};function fGt(t){let{disabled:s,index:r,node:n,rect:a}=t;const[o,l]=k.useState(null),i=k.useRef(r);return g0(()=>{if(!s&&r!==i.current&&n.current){const d=a.current;if(d){const u=iE(n.current,{ignoreTransform:!0}),p={x:d.left-u.left,y:d.top-u.top,scaleX:d.width/u.width,scaleY:d.height/u.height};(p.x||p.y)&&l(p)}}r!==i.current&&(i.current=r)},[s,r,n,a]),k.useEffect(()=>{o&&l(null)},[o]),o}function C4e(t){let{animateLayoutChanges:s=uGt,attributes:r,disabled:n,data:a,getNewIndex:o=dGt,id:l,strategy:i,resizeObserverConfig:d,transition:u=hGt}=t;const{items:p,containerId:f,activeIndex:y,disabled:_,disableTransforms:b,sortedRects:N,overIndex:w,useDragOverlay:S,strategy:C}=k.useContext(Ftt),A=xGt(n,_),I=p.indexOf(l),L=k.useMemo(()=>({sortable:{containerId:f,index:I,items:p},...a}),[f,a,I,p]),O=k.useMemo(()=>p.slice(p.indexOf(l)),[p,l]),{rect:V,node:q,isOver:B,setNodeRef:U}=nGt({id:l,data:L,disabled:A.droppable,resizeObserverConfig:{updateMeasurementsFor:O,...d}}),{active:te,activatorEvent:Y,activeNodeRect:J,attributes:X,setNodeRef:ce,listeners:ie,isDragging:ae,over:oe,setActivatorNodeRef:me,transform:ve}=eGt({id:l,data:L,attributes:{...pGt,...r},disabled:A.draggable}),he=FVt(U,ce),ge=!!te,je=ge&&!b&&t9(y)&&t9(w),qe=!S&&ae,Me=qe&&je?ve:null,Re=je?Me??(i??C)({rects:N,activeNodeRect:J,activeIndex:y,overIndex:w,index:I}):null,Ve=t9(y)&&t9(w)?o({id:l,items:p,activeIndex:y,overIndex:w}):I,Ne=te==null?void 0:te.id,Ue=k.useRef({activeId:Ne,items:p,newIndex:Ve,containerId:f}),Ie=p!==Ue.current.items,ye=s({active:te,containerId:f,isDragging:ae,isSorting:ge,id:l,index:I,items:p,newIndex:Ue.current.newIndex,previousItems:Ue.current.items,previousContainerId:Ue.current.containerId,transition:u,wasDragging:Ue.current.activeId!=null}),ct=fGt({disabled:!ye,index:I,node:q,rect:V});return k.useEffect(()=>{ge&&Ue.current.newIndex!==Ve&&(Ue.current.newIndex=Ve),f!==Ue.current.containerId&&(Ue.current.containerId=f),p!==Ue.current.items&&(Ue.current.items=p)},[ge,Ve,f,p]),k.useEffect(()=>{if(Ne===Ue.current.activeId)return;if(Ne!=null&&Ue.current.activeId==null){Ue.current.activeId=Ne;return}const $e=setTimeout(()=>{Ue.current.activeId=Ne},50);return()=>clearTimeout($e)},[Ne]),{active:te,activeIndex:y,attributes:X,data:L,rect:V,index:I,newIndex:Ve,items:p,isOver:B,isSorting:ge,isDragging:ae,listeners:ie,node:q,overIndex:w,over:oe,setNodeRef:he,setActivatorNodeRef:me,setDroppableNodeRef:U,setDraggableNodeRef:ce,transform:ct??Re,transition:fe()};function fe(){if(ct||Ie&&Ue.current.newIndex===I)return mGt;if(!(qe&&!y4e(Y)||!u)&&(ge||ye))return iC.Transition.toString({...u,property:ztt})}}function xGt(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 _ce(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 gGt=[to.Down,to.Right,to.Up,to.Left],yGt=(t,s)=>{let{context:{active:r,collisionRect:n,droppableRects:a,droppableContainers:o,over:l,scrollableAncestors:i}}=s;if(gGt.includes(t.code)){if(t.preventDefault(),!r||!n)return;const d=[];o.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const y=a.get(f.id);if(y)switch(t.code){case to.Down:n.topy.top&&d.push(f);break;case to.Left:n.left>y.left&&d.push(f);break;case to.Right:n.left1&&(p=u[1].id),p!=null){const f=o.get(r.id),y=o.get(p),_=y?a.get(y.id):null,b=y==null?void 0:y.node.current;if(b&&_&&f&&y){const w=Ahe(b).some((O,V)=>i[V]!==O),S=Btt(f,y),C=vGt(f,y),A=w||!S?{x:0,y:0}:{x:C?n.width-_.width:0,y:C?n.height-_.height:0},I={x:_.left,y:_.top};return A.x&&A.y?I:SD(I,A)}}}};function Btt(t,s){return!_ce(t)||!_ce(s)?!1:t.data.current.sortable.containerId===s.data.current.sortable.containerId}function vGt(t,s){return!_ce(t)||!_ce(s)||!Btt(t,s)?!1:t.data.current.sortable.indexs(t),children:e.jsx(ga,{className:"h-3.5 w-3.5"})}),e.jsx(W,{variant:"destructive",size:"icon",className:"h-7 w-7",onClick:()=>r(t),children:e.jsx(vr,{className:"h-3.5 w-3.5"})})]}),t.post_date&&e.jsx("div",{className:"absolute bottom-2 left-2",children:e.jsxs(Qe,{className:"bg-primary/90 text-primary-foreground text-[10px] gap-1 backdrop-blur-sm px-1.5 py-0.5",children:[e.jsx(cn,{className:"h-2.5 w-2.5"}),vs(new Date(t.post_date+"T00:00:00"),"MMM d")]})})]}),e.jsxs(Oe,{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-3",children:t.caption}),e.jsxs(mo,{children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{variant:"outline",size:"sm",className:Ot("w-full h-7 text-[11px] gap-1 justify-start font-normal",!t.post_date&&"text-muted-foreground"),children:[e.jsx(cn,{className:"h-3 w-3"}),t.post_date?vs(new Date(t.post_date+"T00:00:00"),"MMM d, yyyy"):"Set post date"]})}),e.jsxs(no,{className:"w-auto p-0",align:"start",children:[e.jsx(uf,{mode:"single",selected:t.post_date?new Date(t.post_date+"T00:00:00"):void 0,onSelect:f=>n(t.id,f?vs(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(W,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>n(t.id,null),children:"Clear date"})})]})]})]})]})})}const bGt=()=>{const t=Qt(),[s,r]=k.useState("all"),[n,a]=k.useState(!1),[o,l]=k.useState(vs(new Date,"yyyy-MM")),[i,d]=k.useState([]),[u,p]=k.useState(!1),[f,y]=k.useState(null),[_,b]=k.useState(null),[N,w]=k.useState(""),[S,C]=k.useState(null),[A,I]=k.useState(!1),[L,O]=k.useState(!1),[V,q]=k.useState(vs(new Date,"yyyy-MM")),[B,U]=k.useState(null),[te,Y]=k.useState(""),[J,X]=k.useState(""),[ce,ie]=k.useState(""),[ae,oe]=k.useState(!1),me=v4e(yce(oO,{activationConstraint:{distance:5}}),yce(w4e,{coordinateGetter:yGt})),{data:ve=[],isLoading:he}=gt({queryKey:["admin-social-swag-2"],queryFn:async()=>{const{data:Je,error:ut}=await G.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(ut)throw ut;return Je}}),{data:ge=[]}=gt({queryKey:["admin-social-swag-2-months"],queryFn:async()=>{const{data:Je,error:ut}=await G.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(ut)throw ut;return Je}}),{data:je=[]}=gt({queryKey:["admin-social-swag-2-reels"],queryFn:async()=>{const{data:Je,error:ut}=await G.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(ut)throw ut;return Je}}),qe=[...new Set(ve.map(Je=>Je.month))].sort((Je,ut)=>ut.localeCompare(Je)),Me=s==="all"?ve:ve.filter(Je=>Je.month===s),ke=Je=>{const ut=sNe(Je,"yyyy-MM",new Date);return vs(ut,"MMMM yyyy")},Re=Je=>{b(Je),w(Je.caption),C(Je.post_date)},Ve=async()=>{if(_){I(!0);try{const{error:Je}=await G.from("social_swag_2").update({caption:N,post_date:S}).eq("id",_.id);if(Je)throw Je;pe.success("Image updated"),b(null),t.invalidateQueries({queryKey:["admin-social-swag-2"]}),t.invalidateQueries({queryKey:["social-swag-2"]})}catch{pe.error("Failed to update image")}finally{I(!1)}}},Ne=async Je=>{const{active:ut,over:mt}=Je;if(!mt||ut.id===mt.id)return;const et=Me,Ze=et.findIndex(Nt=>Nt.id===ut.id),kt=et.findIndex(Nt=>Nt.id===mt.id);if(Ze===-1||kt===-1)return;const Ut=k4e(et,Ze,kt);t.setQueryData(["admin-social-swag-2"],Nt=>{if(!Nt)return Nt;const es={};return Ut.forEach((ds,js)=>{es[ds.id]=js}),Nt.map(ds=>es[ds.id]!==void 0?{...ds,sort_order:es[ds.id]}:ds).sort((ds,js)=>ds.month!==js.month?js.month.localeCompare(ds.month):ds.sort_order-js.sort_order)});try{await Promise.all(Ut.map((Nt,es)=>G.from("social_swag_2").update({sort_order:es}).eq("id",Nt.id)))}catch{pe.error("Failed to save order"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})}},Ue=Je=>{const mt=Array.from(Je.target.files||[]).sort((et,Ze)=>et.name.localeCompare(Ze.name,void 0,{numeric:!0,sensitivity:"base"})).slice(0,16-i.length).map(et=>({file:et,preview:URL.createObjectURL(et),caption:""}));d(et=>[...et,...mt].slice(0,16))},Ie=Je=>{d(ut=>{const mt=[...ut];return URL.revokeObjectURL(mt[Je].preview),mt.splice(Je,1),mt})},ye=(Je,ut)=>{d(mt=>{const et=[...mt];return et[Je]={...et[Je],caption:ut},et})},ct=async()=>{var ut;if(i.length===0){pe.error("Please add at least one image");return}if(i.filter(mt=>!mt.caption.trim()).length>0){pe.error("Please add captions to all images");return}p(!0);try{const{data:mt}=await G.from("social_swag_2").select("sort_order").eq("month",o).order("sort_order",{ascending:!1}).limit(1),et=(((ut=mt==null?void 0:mt[0])==null?void 0:ut.sort_order)??-1)+1;for(let Ze=0;Ze{const ut=Je.image_url.split("/social-swag-2/");ut[1]&&await G.storage.from("social-swag-2").remove([ut[1]]);const{error:mt}=await G.from("social_swag_2").delete().eq("id",Je.id);if(mt)throw mt},onSuccess:()=>{pe.success("Image deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})},onError:()=>pe.error("Failed to delete image")}),$e=Pt({mutationFn:async({id:Je,postDate:ut})=>{const{error:mt}=await G.from("social_swag_2").update({post_date:ut}).eq("id",Je);if(mt)throw mt},onSuccess:()=>{pe.success("Post date updated"),t.invalidateQueries({queryKey:["admin-social-swag-2"]}),t.invalidateQueries({queryKey:["social-swag-2"]})},onError:()=>pe.error("Failed to update post date")}),Ye=Pt({mutationFn:async({month:Je,link:ut})=>{const{error:mt}=await G.from("social_swag_2_months").upsert({month:Je,canva_link:ut||null},{onConflict:"month"});if(mt)throw mt},onSuccess:()=>{pe.success("Canva link updated"),y(null),t.invalidateQueries({queryKey:["admin-social-swag-2-months"]})},onError:()=>pe.error("Failed to update Canva link")}),tt=Je=>{var ut;return((ut=ge.find(mt=>mt.month===Je))==null?void 0:ut.canva_link)||""},Te=Je=>je.find(ut=>ut.month===Je)||null,We=Je=>{var mt;const ut=(mt=Je.target.files)==null?void 0:mt[0];ut&&(U(ut),Y(URL.createObjectURL(ut)))},Ke=()=>{te&&URL.revokeObjectURL(te),U(null),Y(""),X(""),ie("")},ot=async()=>{if(!B){pe.error("Please select an image");return}oe(!0);try{const Je=B.name.split(".").pop(),ut=`reels/${V}-${Date.now()}.${Je}`,{error:mt}=await G.storage.from("social-swag-2").upload(ut,B);if(mt)throw mt;const{data:{publicUrl:et}}=G.storage.from("social-swag-2").getPublicUrl(ut),{error:Ze}=await G.from("social_swag_2_reels").upsert({month:V,image_url:et,canva_link:ce||null,caption:J||null},{onConflict:"month"});if(Ze)throw Ze;pe.success("Reel uploaded successfully!"),Z_e(`${ke(V)} Reel`,"social-swag-2"),Ke(),O(!1),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})}catch(Je){console.error("Reel upload error:",Je),pe.error("Failed to upload reel")}finally{oe(!1)}},He=Pt({mutationFn:async Je=>{const ut=Je.image_url.split("/social-swag-2/");ut[1]&&await G.storage.from("social-swag-2").remove([ut[1]]);const{error:mt}=await G.from("social_swag_2_reels").delete().eq("id",Je.id);if(mt)throw mt},onSuccess:()=>{pe.success("Reel deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})},onError:()=>pe.error("Failed to delete reel")});return e.jsxs(Ds,{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(mi,{asChild:!0,children:e.jsxs(W,{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(ks,{children:e.jsx(_s,{children:"Upload Social Swag Images"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Month"}),e.jsx(De,{type:"month",value:o,onChange:Je=>l(Je.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{children:["Images (",i.length,"/16)"]}),e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6 text-center",children:[e.jsx("input",{type:"file",accept:"image/*",multiple:!0,onChange:Ue,className:"hidden",id:"swag-upload",disabled:i.length>=16}),e.jsxs("label",{htmlFor:"swag-upload",className:"cursor-pointer",children:[e.jsx(Ra,{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((Je,ut)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative aspect-[4/5] rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:Je.preview,alt:`Upload ${ut+1}`,className:"w-full h-full object-cover"}),e.jsx(W,{variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>Ie(ut),children:e.jsx(kr,{className:"h-3 w-3"})})]}),e.jsx(_r,{placeholder:"Caption...",value:Je.caption,onChange:mt=>ye(ut,mt.target.value),className:"text-xs h-20"})]},ut))}),e.jsx(W,{onClick:ct,disabled:u||i.length===0,className:"w-full gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ra,{className:"h-4 w-4"}),"Upload ",i.length," Images"]})})]})]})]}),e.jsxs(fs,{open:L,onOpenChange:Je=>{O(Je),Je||Ke()},children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{variant:"outline",className:"gap-2",children:[e.jsx(Rd,{className:"h-4 w-4"}),"Upload Reel"]})}),e.jsxs(ps,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(_s,{children:"Upload Monthly Reel"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Month"}),e.jsx(De,{type:"month",value:V,onChange:Je=>q(Je.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Reel Preview Image"}),te?e.jsxs("div",{className:"relative aspect-[9/16] max-w-[120px] mx-auto rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:te,alt:"Reel preview",className:"w-full h-full object-cover"}),e.jsx(W,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{URL.revokeObjectURL(te),U(null),Y("")},children:e.jsx(kr,{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:We,className:"hidden",id:"reel-upload"}),e.jsxs("label",{htmlFor:"reel-upload",className:"cursor-pointer",children:[e.jsx(Rd,{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(xe,{children:"Canva Download Link"}),e.jsx(De,{value:ce,onChange:Je=>ie(Je.target.value),placeholder:"https://www.canva.com/..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Caption"}),e.jsx(_r,{value:J,onChange:Je=>X(Je.target.value),placeholder:"Enter caption for this reel...",className:"h-24"})]}),e.jsx(W,{onClick:ot,disabled:ae||!B,className:"w-full gap-2",children:ae?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ra,{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(Oe,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:ve.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total Images"})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:qe.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Months"})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(ta,{value:s,onValueChange:r,children:e.jsxs(Jn,{children:[e.jsx(cs,{value:"all",children:"All"}),qe.map(Je=>e.jsx(cs,{value:Je,children:ke(Je)},Je))]})}),s!=="all"&&e.jsx(Pe,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(vo,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(xe,{className:"text-sm text-muted-foreground",children:["Canva Edit Link for ",ke(s)]}),(f==null?void 0:f.month)===s?e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsx(De,{value:f.link,onChange:Je=>y({...f,link:Je.target.value}),placeholder:"https://www.canva.com/..."}),e.jsx(W,{size:"sm",onClick:()=>Ye.mutate(f),children:"Save"}),e.jsx(W,{size:"sm",variant:"outline",onClick:()=>y(null),children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("span",{className:"text-sm",children:tt(s)||"No link set"}),e.jsx(W,{size:"sm",variant:"outline",onClick:()=>y({month:s,link:tt(s)}),children:"Edit"})]})]})]})})}),s!=="all"&&e.jsx(Pe,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(Rd,{className:"h-4 w-4 text-muted-foreground mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(xe,{className:"text-sm text-muted-foreground",children:["Reel for ",ke(s)]}),(()=>{const Je=Te(s);return Je?e.jsxs("div",{className:"flex items-center gap-4 mt-2",children:[e.jsx("img",{src:Je.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:Je.caption||"No caption"}),Je.canva_link&&e.jsx("a",{href:Je.canva_link,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-xs",children:"View Canva Link"})]}),e.jsx(W,{variant:"destructive",size:"sm",onClick:()=>He.mutate(Je),children:e.jsx(vr,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"No reel uploaded for this month"})})()]})]})})})]}),he?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}):Me.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(qo,{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(N4e,{sensors:me,collisionDetection:_4e,onDragEnd:Ne,children:e.jsx(S4e,{items:Me.map(Je=>Je.id),strategy:lO,children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:Me.map(Je=>e.jsx(_Gt,{item:Je,onEdit:Re,onDelete:ut=>fe.mutate(ut),onDateChange:(ut,mt)=>$e.mutate({id:ut,postDate:mt})},Je.id))})})})]}),e.jsx(fs,{open:!!_,onOpenChange:Je=>{Je||b(null)},children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(ks,{children:e.jsx(_s,{children:"Edit Image"})}),_&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"aspect-[4/5] max-h-48 w-full rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:_.image_url,alt:"Preview",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Caption"}),e.jsx(_r,{value:N,onChange:Je=>w(Je.target.value),placeholder:"Enter caption...",className:"h-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Post Date"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs(mo,{children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{variant:"outline",className:Ot("flex-1 justify-start gap-2 font-normal",!S&&"text-muted-foreground"),children:[e.jsx(cn,{className:"h-4 w-4"}),S?vs(new Date(S+"T00:00:00"),"MMM d, yyyy"):"Pick a date"]})}),e.jsx(no,{className:"w-auto p-0",align:"start",children:e.jsx(uf,{mode:"single",selected:S?new Date(S+"T00:00:00"):void 0,onSelect:Je=>C(Je?vs(Je,"yyyy-MM-dd"):null),className:"p-3 pointer-events-auto"})})]}),S&&e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>C(null),children:e.jsx(kr,{className:"h-4 w-4"})})]})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>b(null),children:"Cancel"}),e.jsx(W,{onClick:Ve,disabled:A,className:"gap-2",children:A?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})})]})},wGt=()=>{const{toast:t}=ja(),s=Qt(),[r,n]=k.useState("categories"),[a,o]=k.useState(!1),[l,i]=k.useState(null),[d,u]=k.useState({name:"",description:"",icon:""}),[p,f]=k.useState(!1),[y,_]=k.useState(null),[b,N]=k.useState({name:"",description:"",icon:""}),[w,S]=k.useState(!1),[C,A]=k.useState(null),[I,L]=k.useState(""),{data:O=[],isLoading:V}=gt({queryKey:["admin-community-categories"],queryFn:async()=>{const{data:Ne,error:Ue}=await G.from("community_categories").select("*").order("sort_order");if(Ue)throw Ue;return Ne}}),{data:q=[],isLoading:B}=gt({queryKey:["admin-private-groups"],queryFn:async()=>{const{data:Ne,error:Ue}=await G.from("community_private_groups").select("*").order("sort_order");if(Ue)throw Ue;return Ne}}),{data:U=[]}=gt({queryKey:["admin-group-members",C==null?void 0:C.id],queryFn:async()=>{if(!C)return[];const{data:Ne,error:Ue}=await G.from("community_private_group_members").select("*").eq("group_id",C.id);if(Ue)throw Ue;return Ne},enabled:!!C}),{data:te=[]}=gt({queryKey:["admin-all-profiles"],queryFn:async()=>{let Ue=[],Ie=0,ye=!0;for(;ye;){const{data:ct,error:fe}=await G.from("profiles").select("id, name, email, brokerage_id").order("name").range(Ie,Ie+1e3-1);if(fe)throw fe;ct&&ct.length>0?(Ue=[...Ue,...ct],Ie+=1e3,ye=ct.length===1e3):ye=!1}return Ue}}),{data:Y=[]}=gt({queryKey:["admin-all-brokerages"],queryFn:async()=>{const{data:Ne,error:Ue}=await G.from("brokerages").select("*").order("name");if(Ue)throw Ue;return Ne}}),J=Pt({mutationFn:async Ne=>{if(Ne.id){const{error:Ue}=await G.from("community_categories").update({name:Ne.name,description:Ne.description||null,icon:Ne.icon||null}).eq("id",Ne.id);if(Ue)throw Ue}else{const Ue=Math.max(...O.map(ye=>ye.sort_order),0),{error:Ie}=await G.from("community_categories").insert({name:Ne.name,description:Ne.description||null,icon:Ne.icon||null,sort_order:Ue+1});if(Ie)throw Ie}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),o(!1),i(null),u({name:"",description:"",icon:""}),t({title:l?"Category updated!":"Category created!"})},onError:Ne=>{t({title:"Error",description:Ne.message,variant:"destructive"})}}),X=Pt({mutationFn:async Ne=>{const{error:Ue}=await G.from("community_categories").delete().eq("id",Ne);if(Ue)throw Ue},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),t({title:"Category deleted"})}}),ce=Pt({mutationFn:async({id:Ne,direction:Ue})=>{const Ie=O.findIndex(ye=>ye.id===Ne);if(Ue==="up"&&Ie>0){const ye=O[Ie-1],ct=O[Ie];await G.from("community_categories").update({sort_order:ct.sort_order}).eq("id",ye.id),await G.from("community_categories").update({sort_order:ye.sort_order}).eq("id",ct.id)}else if(Ue==="down"&&Ies.invalidateQueries({queryKey:["admin-community-categories"]})}),ie=Pt({mutationFn:async Ne=>{if(Ne.id){const{error:Ue}=await G.from("community_private_groups").update({name:Ne.name,description:Ne.description||null,icon:Ne.icon||null}).eq("id",Ne.id);if(Ue)throw Ue}else{const Ue=Math.max(...q.map(ye=>ye.sort_order),0),{error:Ie}=await G.from("community_private_groups").insert({name:Ne.name,description:Ne.description||null,icon:Ne.icon||null,sort_order:Ue+1});if(Ie)throw Ie}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),f(!1),_(null),N({name:"",description:"",icon:""}),t({title:y?"Private group updated!":"Private group created!"})},onError:Ne=>{t({title:"Error",description:Ne.message,variant:"destructive"})}}),ae=Pt({mutationFn:async Ne=>{const{error:Ue}=await G.from("community_private_groups").delete().eq("id",Ne);if(Ue)throw Ue},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),t({title:"Private group deleted"})}}),oe=Pt({mutationFn:async({id:Ne,direction:Ue})=>{const Ie=q.findIndex(ye=>ye.id===Ne);if(Ue==="up"&&Ie>0){const ye=q[Ie-1],ct=q[Ie];await G.from("community_private_groups").update({sort_order:ct.sort_order}).eq("id",ye.id),await G.from("community_private_groups").update({sort_order:ye.sort_order}).eq("id",ct.id)}else if(Ue==="down"&&Ies.invalidateQueries({queryKey:["admin-private-groups"]})}),me=Pt({mutationFn:async({groupId:Ne,userId:Ue,isMember:Ie})=>{if(Ie){const{error:ye}=await G.from("community_private_group_members").delete().eq("group_id",Ne).eq("user_id",Ue);if(ye)throw ye}else{const{error:ye}=await G.from("community_private_group_members").insert({group_id:Ne,user_id:Ue});if(ye)throw ye}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",C==null?void 0:C.id]})}}),ve=Pt({mutationFn:async({groupId:Ne,brokerageId:Ue,isMember:Ie})=>{if(Ie){const{error:ye}=await G.from("community_private_group_members").delete().eq("group_id",Ne).eq("brokerage_id",Ue);if(ye)throw ye}else{const{error:ye}=await G.from("community_private_group_members").insert({group_id:Ne,brokerage_id:Ue});if(ye)throw ye}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",C==null?void 0:C.id]})}}),he=Ne=>{i(Ne),u({name:Ne.name,description:Ne.description||"",icon:Ne.icon||""}),o(!0)},ge=()=>{i(null),u({name:"",description:"",icon:""}),o(!0)},je=Ne=>{_(Ne),N({name:Ne.name,description:Ne.description||"",icon:Ne.icon||""}),f(!0)},qe=()=>{_(null),N({name:"",description:"",icon:""}),f(!0)},Me=Ne=>{A(Ne),L(""),S(!0)},ke=Ne=>U.some(Ue=>Ue.user_id===Ne),Re=Ne=>U.some(Ue=>Ue.brokerage_id===Ne),Ve=te.filter(Ne=>Ne.name.toLowerCase().includes(I.toLowerCase())||Ne.email.toLowerCase().includes(I.toLowerCase()));return e.jsx(Ds,{title:"Community Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Hu,{title:"Community Management",description:"Manage categories and private groups for community discussions"}),e.jsxs(ta,{value:r,onValueChange:n,children:[e.jsxs(Jn,{children:[e.jsx(cs,{value:"categories",children:"Public Categories"}),e.jsxs(cs,{value:"private-groups",children:[e.jsx(ad,{className:"h-4 w-4 mr-1"}),"Private Groups"]})]}),e.jsxs(Ss,{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(W,{onClick:ge,children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(Pe,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{className:"w-[50px]",children:"Order"}),e.jsx(St,{className:"w-[80px]",children:"Icon"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Rn,{children:V?e.jsx(Ps,{children:e.jsx(ht,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):O.length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first one!"})}):O.map((Ne,Ue)=>e.jsxs(Ps,{children:[e.jsx(ht,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(W,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Ue===0,onClick:()=>ce.mutate({id:Ne.id,direction:"up"}),children:"↑"}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Ue===O.length-1,onClick:()=>ce.mutate({id:Ne.id,direction:"down"}),children:"↓"})]})}),e.jsx(ht,{className:"text-2xl",children:Ne.icon||"📁"}),e.jsx(ht,{className:"font-medium",children:Ne.name}),e.jsx(ht,{className:"text-muted-foreground",children:Ne.description||"—"}),e.jsx(ht,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>he(Ne),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{confirm("Delete this category? Posts will be uncategorized.")&&X.mutate(Ne.id)},children:e.jsx(vr,{className:"h-4 w-4"})})]})})]},Ne.id))})]})})})]}),e.jsxs(Ss,{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(pa,{className:"h-3 w-3"}),"Brokerage groups are created automatically and sync with brokerage names"]})]}),e.jsxs(W,{onClick:qe,children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Private Group"]})]}),e.jsx(Pe,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{className:"w-[50px]",children:"Order"}),e.jsx(St,{className:"w-[80px]",children:"Icon"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{className:"w-[120px]",children:"Members"}),e.jsx(St,{className:"w-[140px]",children:"Actions"})]})}),e.jsx(Rn,{children:B?e.jsx(Ps,{children:e.jsx(ht,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):q.length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No private groups yet. Create your first one!"})}):q.map((Ne,Ue)=>e.jsxs(Ps,{children:[e.jsx(ht,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(W,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Ue===0,onClick:()=>oe.mutate({id:Ne.id,direction:"up"}),children:"↑"}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Ue===q.length-1,onClick:()=>oe.mutate({id:Ne.id,direction:"down"}),children:"↓"})]})}),e.jsx(ht,{className:"text-2xl",children:Ne.icon||"🔒"}),e.jsx(ht,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[Ne.name,Ne.brokerage_id?e.jsxs(Qe,{variant:"outline",className:"text-xs bg-blue-50 text-blue-700 border-blue-200",children:[e.jsx(pa,{className:"h-3 w-3 mr-1"}),"Auto-managed"]}):e.jsxs(Qe,{variant:"secondary",className:"text-xs",children:[e.jsx(ad,{className:"h-3 w-3 mr-1"}),"Private"]})]})}),e.jsx(ht,{className:"text-muted-foreground",children:Ne.description||"—"}),e.jsx(ht,{children:e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>Me(Ne),children:[e.jsx(ir,{className:"h-4 w-4 mr-1"}),"Manage"]})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex gap-1",children:[!Ne.brokerage_id&&e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>je(Ne),children:e.jsx(ga,{className:"h-4 w-4"})}),!Ne.brokerage_id&&e.jsx(W,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{confirm("Delete this private group? All posts in this group will be deleted.")&&ae.mutate(Ne.id)},children:e.jsx(vr,{className:"h-4 w-4"})}),Ne.brokerage_id&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Managed via brokerage"})]})})]},Ne.id))})]})})})]})]}),e.jsx(fs,{open:a,onOpenChange:o,children:e.jsxs(ps,{children:[e.jsx(ks,{children:e.jsx(_s,{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(De,{value:d.icon,onChange:Ne=>u(Ue=>({...Ue,icon:Ne.target.value})),placeholder:"💬",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Name *"}),e.jsx(De,{value:d.name,onChange:Ne=>u(Ue=>({...Ue,name:Ne.target.value})),placeholder:"Category name",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Description"}),e.jsx(_r,{value:d.description,onChange:Ne=>u(Ue=>({...Ue,description:Ne.target.value})),placeholder:"Brief description of this category",className:"mt-1"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(W,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(W,{onClick:()=>J.mutate({...d,id:l==null?void 0:l.id}),disabled:!d.name.trim(),children:l?"Save Changes":"Create Category"})]})]})]})}),e.jsx(fs,{open:p,onOpenChange:f,children:e.jsxs(ps,{children:[e.jsx(ks,{children:e.jsx(_s,{children:y?"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(De,{value:b.icon,onChange:Ne=>N(Ue=>({...Ue,icon:Ne.target.value})),placeholder:"🔒",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Name *"}),e.jsx(De,{value:b.name,onChange:Ne=>N(Ue=>({...Ue,name:Ne.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(_r,{value:b.description,onChange:Ne=>N(Ue=>({...Ue,description:Ne.target.value})),placeholder:"Brief description of this private group",className:"mt-1"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(W,{variant:"outline",onClick:()=>f(!1),children:"Cancel"}),e.jsx(W,{onClick:()=>ie.mutate({...b,id:y==null?void 0:y.id}),disabled:!b.name.trim(),children:y?"Save Changes":"Create Private Group"})]})]})]})}),e.jsx(fs,{open:w,onOpenChange:S,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(ks,{children:e.jsxs(_s,{children:["Manage Members: ",C==null?void 0:C.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(ta,{defaultValue:"brokerages",children:[e.jsxs(Jn,{className:"w-full",children:[e.jsx(cs,{value:"brokerages",className:"flex-1",children:"By Brokerage"}),e.jsx(cs,{value:"users",className:"flex-1",children:"Individual Users"})]}),e.jsxs(Ss,{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(Ja,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[Y.map(Ne=>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(Ri,{checked:Re(Ne.id),onCheckedChange:()=>{C&&ve.mutate({groupId:C.id,brokerageId:Ne.id,isMember:Re(Ne.id)})}}),e.jsx("span",{className:"font-medium",children:Ne.name})]}),e.jsxs(Qe,{variant:"secondary",children:[te.filter(Ue=>Ue.brokerage_id===Ne.id).length," agents"]})]},Ne.id)),Y.length===0&&e.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No brokerages found"})]})})]}),e.jsxs(Ss,{value:"users",className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search users...",value:I,onChange:Ne=>L(Ne.target.value),className:"pl-9"})]}),e.jsx(Ja,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[Ve.map(Ne=>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(Ri,{checked:ke(Ne.id),onCheckedChange:()=>{C&&me.mutate({groupId:C.id,userId:Ne.id,isMember:ke(Ne.id)})}}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Ne.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:Ne.email})]})]})},Ne.id)),Ve.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(W,{onClick:()=>S(!1),children:"Done"})})]})]})})]})})},gDe=t=>{switch(t){case"academy_video":return e.jsx(Co,{className:"h-3 w-3"});case"template":return e.jsx(vn,{className:"h-3 w-3"});case"toolbox":return e.jsx(cl,{className:"h-3 w-3"});case"newsletter":return e.jsx(Jv,{className:"h-3 w-3"});case"social_swag":return e.jsx(Or,{className:"h-3 w-3"});default:return e.jsx(Yr,{className:"h-3 w-3"})}},jGt=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}},NGt=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}},kGt=()=>{const{toast:t}=ja(),[s,r]=k.useState([]),[n,a]=k.useState([]),[o,l]=k.useState([]),[i,d]=k.useState(!0),[u,p]=k.useState(""),[f,y]=k.useState(null),[_,b]=k.useState([]),[N,w]=k.useState([]);k.useEffect(()=>{S()},[]);const S=async()=>{try{d(!0);const{data:U,error:te}=await G.from("activity_logs").select(` id, user_id, app_name, launched_at, profiles ( name, email, brokerages ( name ) ) `).order("launched_at",{ascending:!1}).limit(5e3);if(te)throw te;const{data:Y,error:J}=await G.from("content_engagement_logs").select(` id, user_id, resource_type, resource_id, resource_title, action_type, created_at `).order("created_at",{ascending:!1}).limit(5e3);if(J)throw J;const X=[...new Set((Y==null?void 0:Y.map(he=>he.user_id))||[])],{data:ce}=await G.from("profiles").select(` id, name, email, brokerages ( name ) `).in("id",X),ie=new Map((ce==null?void 0:ce.map(he=>[he.id,he]))||[]),ae=(U==null?void 0:U.map(he=>{var ge,je,qe,Me;return{id:he.id,user_id:he.user_id,app_name:he.app_name,launched_at:he.launched_at,user_name:((ge=he.profiles)==null?void 0:ge.name)||"Unknown",user_email:((je=he.profiles)==null?void 0:je.email)||"Unknown",brokerage_name:((Me=(qe=he.profiles)==null?void 0:qe.brokerages)==null?void 0:Me.name)||null}}))||[],oe=(Y==null?void 0:Y.map(he=>{var je;const ge=ie.get(he.user_id);return{id:he.id,user_id:he.user_id,resource_type:he.resource_type,resource_id:he.resource_id,resource_title:he.resource_title,action_type:he.action_type,created_at:he.created_at,user_name:(ge==null?void 0:ge.name)||"Unknown",user_email:(ge==null?void 0:ge.email)||"Unknown",brokerage_name:((je=ge==null?void 0:ge.brokerages)==null?void 0:je.name)||null}}))||[];r(ae),a(oe);const me=new Map;ae.forEach(he=>{if(!me.has(he.user_id))me.set(he.user_id,{user_id:he.user_id,user_name:he.user_name,user_email:he.user_email,brokerage_name:he.brokerage_name,last_activity_type:"app",last_activity_name:he.app_name,last_activity_at:he.launched_at,total_app_launches:1,total_content_views:0});else{const ge=me.get(he.user_id);ge.total_app_launches++,new Date(he.launched_at)>new Date(ge.last_activity_at)&&(ge.last_activity_type="app",ge.last_activity_name=he.app_name,ge.last_activity_at=he.launched_at)}}),oe.forEach(he=>{if(!me.has(he.user_id))me.set(he.user_id,{user_id:he.user_id,user_name:he.user_name,user_email:he.user_email,brokerage_name:he.brokerage_name,last_activity_type:he.resource_type,last_activity_name:he.resource_title,last_activity_at:he.created_at,total_app_launches:0,total_content_views:1});else{const ge=me.get(he.user_id);ge.total_content_views++,new Date(he.created_at)>new Date(ge.last_activity_at)&&(ge.last_activity_type=he.resource_type,ge.last_activity_name=he.resource_title,ge.last_activity_at=he.created_at)}});const ve=Array.from(me.values()).sort((he,ge)=>new Date(ge.last_activity_at).getTime()-new Date(he.last_activity_at).getTime());l(ve)}catch(U){console.error("Error loading activity:",U),t({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{d(!1)}},C=U=>{y({id:U.user_id,name:U.user_name,email:U.user_email});const te=s.filter(J=>J.user_id===U.user_id),Y=n.filter(J=>J.user_id===U.user_id);b(te),w(Y)},A=()=>{y(null),b([]),w([])},{sortKey:I,sortDirection:L,handleSort:O,sortData:V}=sO("last_activity_at","desc"),q=o.filter(U=>{var Y;if(!u)return!0;const te=u.toLowerCase();return U.user_name.toLowerCase().includes(te)||U.user_email.toLowerCase().includes(te)||((Y=U.brokerage_name)==null?void 0:Y.toLowerCase().includes(te))}),B=V(q,{user:U=>{var te;return((te=U.user_name)==null?void 0:te.toLowerCase())||""},brokerage:U=>{var te;return((te=U.brokerage_name)==null?void 0:te.toLowerCase())||""},last_activity_at:U=>new Date(U.last_activity_at).getTime(),apps:U=>U.total_app_launches,content:U=>U.total_content_views});return i?e.jsx(Pe,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"User Activity"}),e.jsx(dr,{children:"App launches and content engagement - click to see full history"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"relative",children:[e.jsx(ln,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name, email, or brokerage...",value:u,onChange:U=>p(U.target.value),className:"pl-9"})]})}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(Zo,{sortKey:"user",currentSortKey:I,currentDirection:L,onSort:O,children:"User"}),e.jsx(Zo,{sortKey:"brokerage",currentSortKey:I,currentDirection:L,onSort:O,children:"Brokerage"}),e.jsx(St,{children:"Last Activity"}),e.jsx(Zo,{sortKey:"last_activity_at",currentSortKey:I,currentDirection:L,onSort:O,children:"Last Active"}),e.jsx(Zo,{sortKey:"apps",currentSortKey:I,currentDirection:L,onSort:O,className:"text-right",children:"Apps"}),e.jsx(Zo,{sortKey:"content",currentSortKey:I,currentDirection:L,onSort:O,className:"text-right",children:"Content"})]})}),e.jsx(Rn,{children:B.length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:6,className:"text-center text-muted-foreground",children:"No activity found"})}):B.map(U=>e.jsxs(Ps,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>C(U),children:[e.jsx(ht,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:U.user_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:U.user_email})]})}),e.jsx(ht,{children:U.brokerage_name?e.jsx(Qe,{variant:"outline",children:U.brokerage_name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(ht,{children:e.jsx("div",{className:"flex items-center gap-2",children:U.last_activity_type==="app"?e.jsxs(Qe,{variant:"secondary",children:[e.jsx(Yr,{className:"h-3 w-3 mr-1"}),U.last_activity_name]}):e.jsxs(Qe,{variant:"outline",className:"flex items-center gap-1",children:[gDe(U.last_activity_type),e.jsx("span",{className:"max-w-32 truncate",children:U.last_activity_name})]})})}),e.jsx(ht,{className:"text-sm text-muted-foreground",children:Nl(new Date(U.last_activity_at),{addSuffix:!0})}),e.jsx(ht,{className:"text-right",children:e.jsx(Qe,{variant:"outline",children:U.total_app_launches})}),e.jsx(ht,{className:"text-right",children:e.jsx(Qe,{variant:"outline",children:U.total_content_views})})]},U.user_id))})]})})]})]}),e.jsx(fs,{open:!!f,onOpenChange:U=>!U&&A(),children:e.jsxs(ps,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(ks,{children:[e.jsxs(_s,{children:[f==null?void 0:f.name,"'s Activity"]}),e.jsx(Ir,{children:f==null?void 0:f.email})]}),e.jsxs(ta,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(Jn,{className:"grid w-full grid-cols-2",children:[e.jsxs(cs,{value:"content",children:["Content (",N.length,")"]}),e.jsxs(cs,{value:"apps",children:["App Launches (",_.length,")"]})]}),e.jsx(Ss,{value:"content",className:"flex-1 overflow-auto mt-4",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Type"}),e.jsx(St,{children:"Resource"}),e.jsx(St,{children:"Action"}),e.jsx(St,{children:"Time"})]})}),e.jsx(Rn,{children:N.length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement"})}):N.map(U=>e.jsxs(Ps,{children:[e.jsx(ht,{children:e.jsxs(Qe,{variant:"outline",className:"flex items-center gap-1 w-fit",children:[gDe(U.resource_type),jGt(U.resource_type)]})}),e.jsx(ht,{className:"max-w-48",children:e.jsx("span",{className:"truncate block",children:U.resource_title})}),e.jsx(ht,{children:e.jsx(Qe,{variant:"secondary",children:NGt(U.action_type)})}),e.jsx(ht,{className:"text-sm text-muted-foreground",children:Nl(new Date(U.created_at),{addSuffix:!0})})]},U.id))})]})})}),e.jsx(Ss,{value:"apps",className:"flex-1 overflow-auto mt-4",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"App"}),e.jsx(St,{children:"Time"})]})}),e.jsx(Rn,{children:_.length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches"})}):_.map(U=>e.jsxs(Ps,{children:[e.jsx(ht,{children:e.jsx(Qe,{variant:"secondary",children:U.app_name})}),e.jsx(ht,{className:"text-sm text-muted-foreground",children:Nl(new Date(U.launched_at),{addSuffix:!0})})]},U.id))})]})})})]})]})})]})},SGt=()=>{const{toast:t}=ja(),[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 G.from("profiles").select("*",{count:"exact",head:!0}),{count:i}=await G.from("profiles").select("*",{count:"exact",head:!0}).not("last_login","is",null),d=(l||0)-(i||0),{count:u}=await G.from("brokerages").select("*",{count:"exact",head:!0}),{count:p}=await G.from("activity_logs").select("*",{count:"exact",head:!0}),f=new Date;f.setDate(f.getDate()-7);const{count:y}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).gte("launched_at",f.toISOString()),_=new Date;_.setMonth(_.getMonth()-1);const{count:b}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).gte("launched_at",_.toISOString()),{data:N}=await G.from("activity_logs").select("user_id").gte("launched_at",f.toISOString()),w=new Set(N==null?void 0:N.map(S=>S.user_id)).size;r({totalUsers:l||0,activeUsers:i||0,pendingUsers:d,totalBrokerages:u||0,totalLaunches:p||0,launchesThisWeek:y||0,launchesThisMonth:b||0,uniqueActiveThisWeek:w})}catch(l){console.error("Error loading analytics:",l),t({title:"Error",description:"Failed to load analytics",variant:"destructive"})}finally{a(!1)}};return n?e.jsx(Pe,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total Users"}),e.jsx(ir,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.totalUsers}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.activeUsers," active, ",s.pendingUsers," pending"]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Active Users"}),e.jsx(si,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.activeUsers}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.totalUsers>0?`${Math.round(s.activeUsers/s.totalUsers*100)}% of total`:"0% of total"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(nn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.pendingUsers}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Awaiting setup"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Brokerages"}),e.jsx(pa,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.totalBrokerages}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total brokerages"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(lh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.totalLaunches}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"All time"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Launches This Week"}),e.jsx(lh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.launchesThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 7 days"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Launches This Month"}),e.jsx(lh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.launchesThisMonth}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 30 days"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Active This Week"}),e.jsx(Qo,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.uniqueActiveThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Unique users"})]})]})]})},yDe={event:"Event",template:"Template",academy_video:"Academy Video",resource_kit:"Resource Kit",newsletter:"Newsletter",social_swag:"Social Swag"},vDe={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 $tt({brokerageOnly:t=!1,brokerageId:s}){const[r,n]=k.useState([]),[a,o]=k.useState(!0),[l,i]=k.useState(""),[d,u]=k.useState("all");k.useEffect(()=>{p()},[s]);const p=async()=>{o(!0);try{let O=[];if(t&&s){const{data:X}=await G.from("profiles").select("id").eq("brokerage_id",s);if(O=(X==null?void 0:X.map(ce=>ce.id))||[],O.length===0){n([]),o(!1);return}}let V=G.from("resource_shares").select("*").order("created_at",{ascending:!1});t&&O.length>0&&(V=V.or(`sender_id.in.(${O.join(",")}),recipient_id.in.(${O.join(",")})`));const{data:q,error:B}=await V;if(B)throw B;const U=new Set;q==null||q.forEach(X=>{U.add(X.sender_id),U.add(X.recipient_id)});const{data:te}=await G.from("profiles").select("id, name, email").in("id",Array.from(U)),Y=new Map((te==null?void 0:te.map(X=>[X.id,X]))||[]),J=(q==null?void 0:q.map(X=>({...X,sender:Y.get(X.sender_id),recipient:Y.get(X.recipient_id)})))||[];n(J)}catch(O){console.error("Error loading shares:",O)}finally{o(!1)}},{sortKey:f,sortDirection:y,handleSort:_,sortData:b}=sO("created_at","desc"),N=r.filter(O=>{var B,U;const V=l===""||O.resource_title.toLowerCase().includes(l.toLowerCase())||((B=O.sender)==null?void 0:B.name.toLowerCase().includes(l.toLowerCase()))||((U=O.recipient)==null?void 0:U.name.toLowerCase().includes(l.toLowerCase())),q=d==="all"||O.resource_type===d;return V&&q}),w=b(N,{resource:O=>{var V;return((V=O.resource_title)==null?void 0:V.toLowerCase())||""},type:O=>O.resource_type,sender:O=>{var V,q;return((q=(V=O.sender)==null?void 0:V.name)==null?void 0:q.toLowerCase())||""},recipient:O=>{var V,q;return((q=(V=O.recipient)==null?void 0:V.name)==null?void 0:q.toLowerCase())||""},status:O=>O.is_read?1:0,created_at:O=>new Date(O.created_at).getTime()}),S=r.length,C=new Set(r.map(O=>O.sender_id)).size,A=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,L=r.reduce((O,V)=>(O[V.resource_type]=(O[V.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,V)=>e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(Ms,{className:"h-4 w-20"})}),e.jsx(Oe,{children:e.jsx(Ms,{className:"h-8 w-16"})})]},V))}),e.jsx(Pe,{children:e.jsx(Oe,{className:"p-6",children:e.jsx(Ms,{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(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total Shares"}),e.jsx(id,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:S})})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Active Sharers"}),e.jsx(ir,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:C})})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Recipients Reached"}),e.jsx(Qo,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:A})})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Read Rate"}),e.jsx(vn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"text-2xl font-bold",children:[I,"%"]})})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-sm font-medium",children:"Shares by Resource Type"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Object.entries(L).map(([O,V])=>e.jsxs(Qe,{variant:"secondary",className:vDe[O],children:[yDe[O],": ",V]},O)),Object.keys(L).length===0&&e.jsx("span",{className:"text-muted-foreground text-sm",children:"No shares yet"})]})})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"Share History"}),e.jsxs(dr,{children:["All resource shares ",t?"in your brokerage":"across the platform"]})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 mb-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by resource, sender, or recipient...",value:l,onChange:O=>i(O.target.value),className:"pl-9"})]}),e.jsxs($s,{value:d,onValueChange:u,children:[e.jsx(zs,{className:"w-[180px]",children:e.jsx(Vs,{placeholder:"Resource type"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Types"}),e.jsx(vt,{value:"event",children:"Events"}),e.jsx(vt,{value:"template",children:"Templates"}),e.jsx(vt,{value:"academy_video",children:"Academy Videos"}),e.jsx(vt,{value:"resource_kit",children:"Resource Kits"}),e.jsx(vt,{value:"newsletter",children:"Newsletters"}),e.jsx(vt,{value:"social_swag",children:"Social Swag"})]})]})]}),e.jsx(Ja,{className:"h-[400px]",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(Zo,{sortKey:"resource",currentSortKey:f,currentDirection:y,onSort:_,children:"Resource"}),e.jsx(Zo,{sortKey:"type",currentSortKey:f,currentDirection:y,onSort:_,children:"Type"}),e.jsx(Zo,{sortKey:"sender",currentSortKey:f,currentDirection:y,onSort:_,children:"Sender"}),e.jsx(Zo,{sortKey:"recipient",currentSortKey:f,currentDirection:y,onSort:_,children:"Recipient"}),e.jsx(Zo,{sortKey:"status",currentSortKey:f,currentDirection:y,onSort:_,children:"Status"}),e.jsx(Zo,{sortKey:"created_at",currentSortKey:f,currentDirection:y,onSort:_,children:"Date"})]})}),e.jsx(Rn,{children:w.length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No shares found"})}):w.map(O=>{var V,q;return e.jsxs(Ps,{children:[e.jsx(ht,{className:"font-medium max-w-[200px] truncate",children:O.resource_title}),e.jsx(ht,{children:e.jsx(Qe,{variant:"secondary",className:vDe[O.resource_type],children:yDe[O.resource_type]})}),e.jsx(ht,{children:((V=O.sender)==null?void 0:V.name)||"Unknown"}),e.jsx(ht,{children:((q=O.recipient)==null?void 0:q.name)||"Unknown"}),e.jsx(ht,{children:e.jsx(Qe,{variant:O.is_read?"default":"outline",children:O.is_read?"Read":"Unread"})}),e.jsx(ht,{className:"text-muted-foreground",children:vs(new Date(O.created_at),"MMM d, yyyy")})]},O.id)})})]})})]})]})]})}const Pye={academy_video:{label:"Academy Videos",icon:yn,color:"bg-purple-100 text-purple-800",actionLabel:"Watched",actionIcon:jn},template:{label:"Templates",icon:Av,color:"bg-blue-100 text-blue-800",actionLabel:"Accessed",actionIcon:au},toolbox:{label:"Toolkit",icon:Lg,color:"bg-amber-100 text-amber-800",actionLabel:"Downloaded",actionIcon:Qa},newsletter:{label:"Newsletters",icon:tr,color:"bg-emerald-100 text-emerald-800",actionLabel:"Clicked",actionIcon:au},social_swag:{label:"Social Swag",icon:zl,color:"bg-pink-100 text-pink-800",actionLabel:"Accessed",actionIcon:au},event:{label:"Events",icon:cn,color:"bg-cyan-100 text-cyan-800",actionLabel:"Registered",actionIcon:au}};function _De(t){return t.resource_type==="toolbox"?t.total_downloads:t.total_clicks}function CGt(t,s){return t==="toolbox"?s.downloads:s.clicks}function MGt(){var O;const[t,s]=k.useState([]),[r,n]=k.useState(!0),[a,o]=k.useState(null),l=k.useRef(null),{sortKey:i,sortDirection:d,handleSort:u,sortData:p}=sO("total_views","desc");k.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:V,error:q}=await G.rpc("get_admin_content_engagement");if(q)throw q;s(V||[])}catch(V){console.error("Error loading content engagement:",V)}finally{n(!1)}},y=V=>{o(q=>{const B=q===V?null:V;return requestAnimationFrame(()=>{var U;(U=l.current)==null||U.scrollIntoView({behavior:"smooth",block:"start"})}),B})};if(r)return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-4",children:[...Array(4)].map((V,q)=>e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(Ms,{className:"h-4 w-20"})}),e.jsx(Oe,{children:e.jsx(Ms,{className:"h-8 w-16"})})]},q))}),e.jsx(Pe,{children:e.jsx(Oe,{className:"py-8",children:e.jsx(Ms,{className:"h-64 w-full"})})})]});const _=t.reduce((V,q)=>V+q.total_views,0),b=t.reduce((V,q)=>V+q.total_clicks,0),N=t.reduce((V,q)=>V+q.total_downloads,0),w=t.length,S=t.reduce((V,q)=>(V[q.resource_type]||(V[q.resource_type]={views:0,clicks:0,downloads:0,assets:0,uniqueUsers:0}),V[q.resource_type].views+=q.total_views,V[q.resource_type].clicks+=q.total_clicks,V[q.resource_type].downloads+=q.total_downloads,V[q.resource_type].assets+=1,V[q.resource_type].uniqueUsers+=q.unique_users,V),{}),C=a?t.filter(V=>V.resource_type===a):t,A=p(C,{asset:V=>{var q;return((q=V.resource_title)==null?void 0:q.toLowerCase())||""},type:V=>V.resource_type,views:V=>V.total_views,actions:V=>_De(V),unique_users:V=>V.unique_users,last_activity:V=>V.last_engaged_at?new Date(V.last_engaged_at).getTime():0}),I=a?Pye[a]||{label:a,icon:jn,color:"bg-muted text-muted-foreground",actionLabel:"Actions",actionIcon:au}:null,L=I==null?void 0:I.icon;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-5",children:[e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total Views"}),e.jsx(jn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:_.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Across all content"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total Clicks"}),e.jsx(au,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:b.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Link & Canva clicks"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Downloads"}),e.jsx(Qa,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:N.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"PDF downloads"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Assets Tracked"}),e.jsx(Qo,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:w}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Unique content items"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(au,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[_>0?Math.round((b+N)/_*100):0,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Of views → actions"})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{className:"text-sm font-medium",children:"Engagement by Content Type"}),e.jsx(dr,{children:"Click a category to see individual asset performance"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-3",children:Object.entries(S).map(([V,q])=>{const B=Pye[V]||{label:V,icon:jn,color:"bg-muted text-muted-foreground",actionLabel:"Actions",actionIcon:au},U=B.icon,te=a===V;return e.jsxs("button",{type:"button",onClick:()=>y(V),className:`flex items-center gap-3 p-3 rounded-lg border text-left transition-colors cursor-pointer ${te?"ring-2 ring-primary border-primary bg-primary/5":"hover:bg-muted/50"}`,children:[e.jsx("div",{className:`p-2 rounded-md ${B.color}`,children:e.jsx(U,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:B.label}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(jn,{className:"h-3 w-3"})," ",q.views]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(B.actionIcon,{className:"h-3 w-3"})," ",CGt(V,q)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ir,{className:"h-3 w-3"})," ",q.uniqueUsers]})]})]}),e.jsxs(Qe,{variant:"secondary",className:"text-[10px]",children:[q.assets," items"]})]},V)})})})]}),e.jsx("div",{ref:l,children:e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{className:"text-sm font-medium flex items-center gap-2",children:I&&L?e.jsxs(e.Fragment,{children:[e.jsx(L,{className:"h-4 w-4"}),I.label," — Top Performers"]}):"Top Content by Engagement"}),e.jsx(dr,{children:a?`${C.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(W,{variant:"ghost",size:"sm",onClick:()=>o(null),className:"gap-1",children:[e.jsx(Oa,{className:"h-3.5 w-3.5"}),"Show All"]})]})}),e.jsx(Oe,{children:C.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No engagement data yet. As users view and click content, stats will appear here."}):e.jsx(Ja,{className:"h-[400px]",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{className:"w-[40px]",children:"#"}),e.jsx(Zo,{sortKey:"asset",currentSortKey:i,currentDirection:d,onSort:u,children:"Asset"}),!a&&e.jsx(Zo,{sortKey:"type",currentSortKey:i,currentDirection:d,onSort:u,children:"Type"}),e.jsx(Zo,{sortKey:"views",currentSortKey:i,currentDirection:d,onSort:u,className:"text-right",children:"Views"}),e.jsx(Zo,{sortKey:"actions",currentSortKey:i,currentDirection:d,onSort:u,className:"text-right",children:I?I.actionLabel:"Actions"}),e.jsx(Zo,{sortKey:"unique_users",currentSortKey:i,currentDirection:d,onSort:u,className:"text-right",children:"Unique Users"}),e.jsx(Zo,{sortKey:"last_activity",currentSortKey:i,currentDirection:d,onSort:u,children:"Last Activity"})]})}),e.jsx(Rn,{children:A.map((V,q)=>{const B=Pye[V.resource_type]||{label:V.resource_type,color:"bg-muted text-muted-foreground",actionLabel:"Actions",actionIcon:au};return e.jsxs(Ps,{children:[e.jsx(ht,{className:"text-muted-foreground text-xs",children:q+1}),e.jsx(ht,{children:e.jsx("p",{className:"font-medium text-sm truncate max-w-[250px]",children:V.resource_title})}),!a&&e.jsx(ht,{children:e.jsx(Qe,{className:`text-[10px] ${B.color}`,children:B.label})}),e.jsx(ht,{className:"text-right font-medium",children:V.total_views}),e.jsx(ht,{className:"text-right font-medium",children:_De(V)}),e.jsx(ht,{className:"text-right",children:V.unique_users}),e.jsx(ht,{className:"text-xs text-muted-foreground",children:V.last_engaged_at?Nl(new Date(V.last_engaged_at),{addSuffix:!0}):"—"})]},`${V.resource_type}-${V.resource_id}`)})})]})})})]})})]})}var TGt=Array.isArray,jp=TGt,AGt=typeof gd=="object"&&gd&&gd.Object===Object&&gd,qtt=AGt,EGt=qtt,PGt=typeof self=="object"&&self&&self.Object===Object&&self,IGt=EGt||PGt||Function("return this")(),S0=IGt,LGt=S0,DGt=LGt.Symbol,cO=DGt,bDe=cO,Utt=Object.prototype,RGt=Utt.hasOwnProperty,OGt=Utt.toString,cI=bDe?bDe.toStringTag:void 0;function FGt(t){var s=RGt.call(t,cI),r=t[cI];try{t[cI]=void 0;var n=!0}catch{}var a=OGt.call(t);return n&&(s?t[cI]=r:delete t[cI]),a}var zGt=FGt,BGt=Object.prototype,$Gt=BGt.toString;function qGt(t){return $Gt.call(t)}var UGt=qGt,wDe=cO,VGt=zGt,HGt=UGt,GGt="[object Null]",WGt="[object Undefined]",jDe=wDe?wDe.toStringTag:void 0;function KGt(t){return t==null?t===void 0?WGt:GGt:jDe&&jDe in Object(t)?VGt(t):HGt(t)}var M1=KGt;function ZGt(t){return t!=null&&typeof t=="object"}var T1=ZGt,YGt=M1,XGt=T1,QGt="[object Symbol]";function JGt(t){return typeof t=="symbol"||XGt(t)&&YGt(t)==QGt}var oE=JGt,eWt=jp,tWt=oE,sWt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,rWt=/^\w*$/;function nWt(t,s){if(eWt(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||tWt(t)?!0:rWt.test(t)||!sWt.test(t)||s!=null&&t in Object(s)}var M4e=nWt;function aWt(t){var s=typeof t;return t!=null&&(s=="object"||s=="function")}var jw=aWt;const lE=ao(jw);var iWt=M1,oWt=jw,lWt="[object AsyncFunction]",cWt="[object Function]",dWt="[object GeneratorFunction]",uWt="[object Proxy]";function hWt(t){if(!oWt(t))return!1;var s=iWt(t);return s==cWt||s==dWt||s==lWt||s==uWt}var T4e=hWt;const di=ao(T4e);var mWt=S0,pWt=mWt["__core-js_shared__"],fWt=pWt,Iye=fWt,NDe=function(){var t=/[^.]+$/.exec(Iye&&Iye.keys&&Iye.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function xWt(t){return!!NDe&&NDe in t}var gWt=xWt,yWt=Function.prototype,vWt=yWt.toString;function _Wt(t){if(t!=null){try{return vWt.call(t)}catch{}try{return t+""}catch{}}return""}var Vtt=_Wt,bWt=T4e,wWt=gWt,jWt=jw,NWt=Vtt,kWt=/[\\^$.*+?()[\]{}|]/g,SWt=/^\[object .+?Constructor\]$/,CWt=Function.prototype,MWt=Object.prototype,TWt=CWt.toString,AWt=MWt.hasOwnProperty,EWt=RegExp("^"+TWt.call(AWt).replace(kWt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function PWt(t){if(!jWt(t)||wWt(t))return!1;var s=bWt(t)?EWt:SWt;return s.test(NWt(t))}var IWt=PWt;function LWt(t,s){return t==null?void 0:t[s]}var DWt=LWt,RWt=IWt,OWt=DWt;function FWt(t,s){var r=OWt(t,s);return RWt(r)?r:void 0}var AC=FWt,zWt=AC,BWt=zWt(Object,"create"),Ihe=BWt,kDe=Ihe;function $Wt(){this.__data__=kDe?kDe(null):{},this.size=0}var qWt=$Wt;function UWt(t){var s=this.has(t)&&delete this.__data__[t];return this.size-=s?1:0,s}var VWt=UWt,HWt=Ihe,GWt="__lodash_hash_undefined__",WWt=Object.prototype,KWt=WWt.hasOwnProperty;function ZWt(t){var s=this.__data__;if(HWt){var r=s[t];return r===GWt?void 0:r}return KWt.call(s,t)?s[t]:void 0}var YWt=ZWt,XWt=Ihe,QWt=Object.prototype,JWt=QWt.hasOwnProperty;function eKt(t){var s=this.__data__;return XWt?s[t]!==void 0:JWt.call(s,t)}var tKt=eKt,sKt=Ihe,rKt="__lodash_hash_undefined__";function nKt(t,s){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=sKt&&s===void 0?rKt:s,this}var aKt=nKt,iKt=qWt,oKt=VWt,lKt=YWt,cKt=tKt,dKt=aKt;function cE(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s-1}var CKt=SKt,MKt=Lhe;function TKt(t,s){var r=this.__data__,n=MKt(r,t);return n<0?(++this.size,r.push([t,s])):r[n][1]=s,this}var AKt=TKt,EKt=mKt,PKt=bKt,IKt=NKt,LKt=CKt,DKt=AKt;function dE(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s0?1:-1},k4=function(s){return oC(s)&&s.indexOf("%")===s.length-1},sn=function(s){return rYt(s)&&!dO(s)},oYt=function(s){return vi(s)},cu=function(s){return sn(s)||oC(s)},lYt=0,hE=function(s){var r=++lYt;return"".concat(s||"").concat(r)},jm=function(s,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!sn(s)&&!oC(s))return n;var o;if(k4(s)){var l=s.indexOf("%");o=r*parseFloat(s.slice(0,l))/100}else o=+s;return dO(o)&&(o=n),a&&o>r&&(o=r),o},K_=function(s){if(!s)return null;var r=Object.keys(s);return r&&r.length?s[r[0]]:null},cYt=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 xYt(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 sbe(t){"@babel/helpers - typeof";return sbe=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},sbe(t)}var PDe={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"},n1=function(s){return typeof s=="string"?s:s?s.displayName||s.name||"Component":""},IDe=null,Dye=null,z4e=function t(s){if(s===IDe&&Array.isArray(Dye))return Dye;var r=[];return k.Children.forEach(s,function(n){vi(n)||(QZt.isFragment(n)?r=r.concat(t(n.props.children)):r.push(n))}),Dye=r,IDe=s,r};function mf(t,s){var r=[],n=[];return Array.isArray(s)?n=s.map(function(a){return n1(a)}):n=[n1(s)],z4e(t).forEach(function(a){var o=hf(a,"type.displayName")||hf(a,"type.name");n.indexOf(o)!==-1&&r.push(a)}),r}function Wp(t,s){var r=mf(t,s);return r&&r[0]}var LDe=function(s){if(!s||!s.props)return!1;var r=s.props,n=r.width,a=r.height;return!(!sn(n)||n<=0||!sn(a)||a<=0)},gYt=["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"],yYt=function(s){return s&&s.type&&oC(s.type)&&gYt.indexOf(s.type)>=0},vYt=function(s){return s&&sbe(s)==="object"&&"clipDot"in s},_Yt=function(s,r,n,a){var o,l=(o=Lye==null?void 0:Lye[a])!==null&&o!==void 0?o:[];return r.startsWith("data-")||!di(s)&&(a&&l.includes(r)||hYt.includes(r))||n&&F4e.includes(r)},Ua=function(s,r,n){if(!s||typeof s=="function"||typeof s=="boolean")return null;var a=s;if(k.isValidElement(s)&&(a=s.props),!lE(a))return null;var o={};return Object.keys(a).forEach(function(l){var i;_Yt((i=a)===null||i===void 0?void 0:i[l],l,r,n)&&(o[l]=a[l])}),o},rbe=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 DDe(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 kYt(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,d=t.desc,u=NYt(t,jYt),p=a||{width:r,height:n,x:0,y:0},f=bi("recharts-surface",o);return xt.createElement("svg",nbe({},Ua(u,!0,"svg"),{className:f,width:r,height:n,style:l,viewBox:"".concat(p.x," ").concat(p.y," ").concat(p.width," ").concat(p.height)}),xt.createElement("title",null,i),xt.createElement("desc",null,d),s)}var SYt=["children","className"];function ibe(){return ibe=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 MYt(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 No=xt.forwardRef(function(t,s){var r=t.children,n=t.className,a=CYt(t,SYt),o=bi("recharts-layer",n);return xt.createElement("g",ibe({className:o},Ua(a,!0),{ref:s}),r)}),Rg=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:EYt(t,s,r)}var IYt=PYt,LYt="\\ud800-\\udfff",DYt="\\u0300-\\u036f",RYt="\\ufe20-\\ufe2f",OYt="\\u20d0-\\u20ff",FYt=DYt+RYt+OYt,zYt="\\ufe0e\\ufe0f",BYt="\\u200d",$Yt=RegExp("["+BYt+LYt+FYt+zYt+"]");function qYt(t){return $Yt.test(t)}var est=qYt;function UYt(t){return t.split("")}var VYt=UYt,tst="\\ud800-\\udfff",HYt="\\u0300-\\u036f",GYt="\\ufe20-\\ufe2f",WYt="\\u20d0-\\u20ff",KYt=HYt+GYt+WYt,ZYt="\\ufe0e\\ufe0f",YYt="["+tst+"]",obe="["+KYt+"]",lbe="\\ud83c[\\udffb-\\udfff]",XYt="(?:"+obe+"|"+lbe+")",sst="[^"+tst+"]",rst="(?:\\ud83c[\\udde6-\\uddff]){2}",nst="[\\ud800-\\udbff][\\udc00-\\udfff]",QYt="\\u200d",ast=XYt+"?",ist="["+ZYt+"]?",JYt="(?:"+QYt+"(?:"+[sst,rst,nst].join("|")+")"+ist+ast+")*",eXt=ist+ast+JYt,tXt="(?:"+[sst+obe+"?",obe,rst,nst,YYt].join("|")+")",sXt=RegExp(lbe+"(?="+lbe+")|"+tXt+eXt,"g");function rXt(t){return t.match(sXt)||[]}var nXt=rXt,aXt=VYt,iXt=est,oXt=nXt;function lXt(t){return iXt(t)?oXt(t):aXt(t)}var cXt=lXt,dXt=IYt,uXt=est,hXt=cXt,mXt=Ktt;function pXt(t){return function(s){s=mXt(s);var r=uXt(s)?hXt(s):void 0,n=r?r[0]:s.charAt(0),a=r?dXt(r,1).join(""):s.slice(1);return n[t]()+a}}var fXt=pXt,xXt=fXt,gXt=xXt("toUpperCase"),yXt=gXt;const Khe=ao(yXt);function Pl(t){return function(){return t}}const ost=Math.cos,jce=Math.sin,Kg=Math.sqrt,Nce=Math.PI,Zhe=2*Nce,cbe=Math.PI,dbe=2*cbe,a4=1e-6,vXt=dbe-a4;function lst(t){this._+=t[0];for(let s=1,r=t.length;s=0))throw new Error(`invalid digits: ${t}`);if(s>15)return lst;const r=10**s;return function(n){this._+=n[0];for(let a=1,o=n.length;aa4)if(!(Math.abs(f*d-u*p)>a4)||!o)this._append`L${this._x1=s},${this._y1=r}`;else{let _=n-l,b=a-i,N=d*d+u*u,w=_*_+b*b,S=Math.sqrt(N),C=Math.sqrt(y),A=o*Math.tan((cbe-Math.acos((N+y-w)/(2*S*C)))/2),I=A/C,L=A/S;Math.abs(I-1)>a4&&this._append`L${s+I*p},${r+I*f}`,this._append`A${o},${o},0,0,${+(f*_>p*b)},${this._x1=s+L*d},${this._y1=r+L*u}`}}arc(s,r,n,a,o,l){if(s=+s,r=+r,n=+n,l=!!l,n<0)throw new Error(`negative radius: ${n}`);let i=n*Math.cos(a),d=n*Math.sin(a),u=s+i,p=r+d,f=1^l,y=l?a-o:o-a;this._x1===null?this._append`M${u},${p}`:(Math.abs(this._x1-u)>a4||Math.abs(this._y1-p)>a4)&&this._append`L${u},${p}`,n&&(y<0&&(y=y%dbe+dbe),y>vXt?this._append`A${n},${n},0,1,${f},${s-i},${r-d}A${n},${n},0,1,${f},${this._x1=u},${this._y1=p}`:y>a4&&this._append`A${n},${n},0,${+(y>=cbe)},${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 B4e(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 bXt(s)}function $4e(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function cst(t){this._context=t}cst.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 Yhe(t){return new cst(t)}function dst(t){return t[0]}function ust(t){return t[1]}function hst(t,s){var r=Pl(!0),n=null,a=Yhe,o=null,l=B4e(i);t=typeof t=="function"?t:t===void 0?dst:Pl(t),s=typeof s=="function"?s:s===void 0?ust:Pl(s);function i(d){var u,p=(d=$4e(d)).length,f,y=!1,_;for(n==null&&(o=a(_=l())),u=0;u<=p;++u)!(u=_;--b)i.point(A[b],I[b]);i.lineEnd(),i.areaEnd()}S&&(A[y]=+t(w,y,f),I[y]=+s(w,y,f),i.point(n?+n(w,y,f):A[y],r?+r(w,y,f):I[y]))}if(C)return i=null,C+""||null}function p(){return hst().defined(a).curve(l).context(o)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:Pl(+f),n=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:Pl(+f),u):t},u.x1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Pl(+f),u):n},u.y=function(f){return arguments.length?(s=typeof f=="function"?f:Pl(+f),r=null,u):s},u.y0=function(f){return arguments.length?(s=typeof f=="function"?f:Pl(+f),u):s},u.y1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:Pl(+f),u):r},u.lineX0=u.lineY0=function(){return p().x(t).y(s)},u.lineY1=function(){return p().x(t).y(r)},u.lineX1=function(){return p().x(n).y(s)},u.defined=function(f){return arguments.length?(a=typeof f=="function"?f:Pl(!!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 mst{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 wXt(t){return new mst(t,!0)}function jXt(t){return new mst(t,!1)}const q4e={draw(t,s){const r=Kg(s/Nce);t.moveTo(r,0),t.arc(0,0,r,0,Zhe)}},NXt={draw(t,s){const r=Kg(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()}},pst=Kg(1/3),kXt=pst*2,SXt={draw(t,s){const r=Kg(s/kXt),n=r*pst;t.moveTo(0,-r),t.lineTo(n,0),t.lineTo(0,r),t.lineTo(-n,0),t.closePath()}},CXt={draw(t,s){const r=Kg(s),n=-r/2;t.rect(n,n,r,r)}},MXt=.8908130915292852,fst=jce(Nce/10)/jce(7*Nce/10),TXt=jce(Zhe/10)*fst,AXt=-ost(Zhe/10)*fst,EXt={draw(t,s){const r=Kg(s*MXt),n=TXt*r,a=AXt*r;t.moveTo(0,-r),t.lineTo(n,a);for(let o=1;o<5;++o){const l=Zhe*o/5,i=ost(l),d=jce(l);t.lineTo(d*r,-i*r),t.lineTo(i*n-d*a,d*n+i*a)}t.closePath()}},Rye=Kg(3),PXt={draw(t,s){const r=-Kg(s/(Rye*3));t.moveTo(0,r*2),t.lineTo(-Rye*r,-r),t.lineTo(Rye*r,-r),t.closePath()}},Vf=-.5,Hf=Kg(3)/2,ube=1/Kg(12),IXt=(ube/2+1)*3,LXt={draw(t,s){const r=Kg(s/IXt),n=r/2,a=r*ube,o=n,l=r*ube+r,i=-o,d=l;t.moveTo(n,a),t.lineTo(o,l),t.lineTo(i,d),t.lineTo(Vf*n-Hf*a,Hf*n+Vf*a),t.lineTo(Vf*o-Hf*l,Hf*o+Vf*l),t.lineTo(Vf*i-Hf*d,Hf*i+Vf*d),t.lineTo(Vf*n+Hf*a,Vf*a-Hf*n),t.lineTo(Vf*o+Hf*l,Vf*l-Hf*o),t.lineTo(Vf*i+Hf*d,Vf*d-Hf*i),t.closePath()}};function DXt(t,s){let r=null,n=B4e(a);t=typeof t=="function"?t:Pl(t||q4e),s=typeof s=="function"?s:Pl(s===void 0?64:+s);function a(){let o;if(r||(r=o=n()),t.apply(this,arguments).draw(r,+s.apply(this,arguments)),o)return r=null,o+""||null}return a.type=function(o){return arguments.length?(t=typeof o=="function"?o:Pl(o),a):t},a.size=function(o){return arguments.length?(s=typeof o=="function"?o:Pl(+o),a):s},a.context=function(o){return arguments.length?(r=o??null,a):r},a}function kce(){}function Sce(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 xst(t){this._context=t}xst.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:Sce(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:Sce(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function RXt(t){return new xst(t)}function gst(t){this._context=t}gst.prototype={areaStart:kce,areaEnd:kce,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:Sce(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function OXt(t){return new gst(t)}function yst(t){this._context=t}yst.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:Sce(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function FXt(t){return new yst(t)}function vst(t){this._context=t}vst.prototype={areaStart:kce,areaEnd:kce,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 zXt(t){return new vst(t)}function ODe(t){return t<0?-1:1}function FDe(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(ODe(o)+ODe(l))*Math.min(Math.abs(o),Math.abs(l),.5*Math.abs(i))||0}function zDe(t,s){var r=t._x1-t._x0;return r?(3*(t._y1-t._y0)/r-s)/2:s}function Oye(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 Cce(t){this._context=t}Cce.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:Oye(this,this._t0,zDe(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,Oye(this,zDe(this,r=FDe(this,t,s)),r);break;default:Oye(this,this._t0,r=FDe(this,t,s));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s,this._t0=r}}};function _st(t){this._context=new bst(t)}(_st.prototype=Object.create(Cce.prototype)).point=function(t,s){Cce.prototype.point.call(this,s,t)};function bst(t){this._context=t}bst.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 BXt(t){return new Cce(t)}function $Xt(t){return new _st(t)}function wst(t){this._context=t}wst.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 UXt(t){return new Xhe(t,.5)}function VXt(t){return new Xhe(t,0)}function HXt(t){return new Xhe(t,1)}function WT(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 GXt(t,s){return t[s]}function WXt(t){const s=[];return s.key=t,s}function KXt(){var t=Pl([]),s=hbe,r=WT,n=GXt;function a(o){var l=Array.from(t.apply(this,arguments),WXt),i,d=l.length,u=-1,p;for(const f of o)for(i=0,++u;i0){for(var r,n,a=0,o=t[0].length,l;a0){for(var r=0,n=t[s[0]],a,o=n.length;r0)||!((o=(a=t[s[0]]).length)>0))){for(var r=0,n=1,a,o,l;n=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function rQt(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 jst={symbolCircle:q4e,symbolCross:NXt,symbolDiamond:SXt,symbolSquare:CXt,symbolStar:EXt,symbolTriangle:PXt,symbolWye:LXt},nQt=Math.PI/180,aQt=function(s){var r="symbol".concat(Khe(s));return jst[r]||q4e},iQt=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*nQt;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}},oQt=function(s,r){jst["symbol".concat(Khe(s))]=r},U4e=function(s){var r=s.type,n=r===void 0?"circle":r,a=s.size,o=a===void 0?64:a,l=s.sizeType,i=l===void 0?"area":l,d=sQt(s,QXt),u=qDe(qDe({},d),{},{type:n,size:o,sizeType:i}),p=function(){var w=aQt(n),S=DXt().type(w).size(iQt(o,i,n));return S()},f=u.className,y=u.cx,_=u.cy,b=Ua(u,!0);return y===+y&&_===+_&&o===+o?xt.createElement("path",mbe({},b,{className:bi("recharts-symbols",f),transform:"translate(".concat(y,", ").concat(_,")"),d:p()})):null};U4e.registerSymbol=oQt;function KT(t){"@babel/helpers - typeof";return KT=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},KT(t)}function pbe(){return pbe=Object.assign?Object.assign.bind():function(t){for(var s=1;s`);var C=_.inactive?u:_.color;return xt.createElement("li",pbe({className:w,style:f,key:"legend-item-".concat(b)},lC(n.props,_,b)),xt.createElement(abe,{width:l,height:l,viewBox:p,style:y},n.renderIcon(_)),xt.createElement("span",{className:"recharts-legend-item-text",style:{color:C}},N?N(S,_,b):S))})}},{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 xt.createElement("ul",{className:"recharts-default-legend",style:i},this.renderItems())}}])}(k.PureComponent);TD(V4e,"displayName","Legend");TD(V4e,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var gQt=Dhe;function yQt(){this.__data__=new gQt,this.size=0}var vQt=yQt;function _Qt(t){var s=this.__data__,r=s.delete(t);return this.size=s.size,r}var bQt=_Qt;function wQt(t){return this.__data__.get(t)}var jQt=wQt;function NQt(t){return this.__data__.has(t)}var kQt=NQt,SQt=Dhe,CQt=E4e,MQt=P4e,TQt=200;function AQt(t,s){var r=this.__data__;if(r instanceof SQt){var n=r.__data__;if(!CQt||n.lengthi))return!1;var u=o.get(t),p=o.get(s);if(u&&p)return u==s&&p==t;var f=-1,y=!0,_=r&QQt?new KQt:void 0;for(o.set(t,s),o.set(s,t);++f-1&&t%1==0&&t-1&&t%1==0&&t<=ses}var K4e=res,nes=M1,aes=K4e,ies=T1,oes="[object Arguments]",les="[object Array]",ces="[object Boolean]",des="[object Date]",ues="[object Error]",hes="[object Function]",mes="[object Map]",pes="[object Number]",fes="[object Object]",xes="[object RegExp]",ges="[object Set]",yes="[object String]",ves="[object WeakMap]",_es="[object ArrayBuffer]",bes="[object DataView]",wes="[object Float32Array]",jes="[object Float64Array]",Nes="[object Int8Array]",kes="[object Int16Array]",Ses="[object Int32Array]",Ces="[object Uint8Array]",Mes="[object Uint8ClampedArray]",Tes="[object Uint16Array]",Aes="[object Uint32Array]",Zl={};Zl[wes]=Zl[jes]=Zl[Nes]=Zl[kes]=Zl[Ses]=Zl[Ces]=Zl[Mes]=Zl[Tes]=Zl[Aes]=!0;Zl[oes]=Zl[les]=Zl[_es]=Zl[ces]=Zl[bes]=Zl[des]=Zl[ues]=Zl[hes]=Zl[mes]=Zl[pes]=Zl[fes]=Zl[xes]=Zl[ges]=Zl[yes]=Zl[ves]=!1;function Ees(t){return ies(t)&&aes(t.length)&&!!Zl[nes(t)]}var Pes=Ees;function Ies(t){return function(s){return t(s)}}var Lst=Ies,Ece={exports:{}};Ece.exports;(function(t,s){var r=qtt,n=s&&!s.nodeType&&s,a=n&&!0&&t&&!t.nodeType&&t,o=a&&a.exports===n,l=o&&r.process,i=function(){try{var d=a&&a.require&&a.require("util").types;return d||l&&l.binding&&l.binding("util")}catch{}}();t.exports=i})(Ece,Ece.exports);var Les=Ece.exports,Des=Pes,Res=Lst,ZDe=Les,YDe=ZDe&&ZDe.isTypedArray,Oes=YDe?Res(YDe):Des,Dst=Oes,Fes=$Jt,zes=G4e,Bes=jp,$es=Ist,qes=W4e,Ues=Dst,Ves=Object.prototype,Hes=Ves.hasOwnProperty;function Ges(t,s){var r=Bes(t),n=!r&&zes(t),a=!r&&!n&&$es(t),o=!r&&!n&&!a&&Ues(t),l=r||n||a||o,i=l?Fes(t.length,String):[],d=i.length;for(var u in t)(s||Hes.call(t,u))&&!(l&&(u=="length"||a&&(u=="offset"||u=="parent")||o&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||qes(u,d)))&&i.push(u);return i}var Wes=Ges,Kes=Object.prototype;function Zes(t){var s=t&&t.constructor,r=typeof s=="function"&&s.prototype||Kes;return t===r}var Yes=Zes;function Xes(t,s){return function(r){return t(s(r))}}var Rst=Xes,Qes=Rst,Jes=Qes(Object.keys,Object),ets=Jes,tts=Yes,sts=ets,rts=Object.prototype,nts=rts.hasOwnProperty;function ats(t){if(!tts(t))return sts(t);var s=[];for(var r in Object(t))nts.call(t,r)&&r!="constructor"&&s.push(r);return s}var its=ats,ots=T4e,lts=K4e;function cts(t){return t!=null&<s(t.length)&&!ots(t)}var uO=cts,dts=Wes,uts=its,hts=uO;function mts(t){return hts(t)?dts(t):uts(t)}var Qhe=mts,pts=TJt,fts=zJt,xts=Qhe;function gts(t){return pts(t,xts,fts)}var yts=gts,XDe=yts,vts=1,_ts=Object.prototype,bts=_ts.hasOwnProperty;function wts(t,s,r,n,a,o){var l=r&vts,i=XDe(t),d=i.length,u=XDe(s),p=u.length;if(d!=p&&!l)return!1;for(var f=d;f--;){var y=i[f];if(!(l?y in s:bts.call(s,y)))return!1}var _=o.get(t),b=o.get(s);if(_&&b)return _==s&&b==t;var N=!0;o.set(t,s),o.set(s,t);for(var w=l;++f-1}var _rs=vrs;function brs(t,s,r){for(var n=-1,a=t==null?0:t.length;++n=Rrs){var u=s?null:Lrs(t);if(u)return Drs(u);l=!1,a=Irs,d=new Ars}else d=s?[]:i;e:for(;++n=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Qrs(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function Jrs(t){return t.value}function ens(t,s){if(xt.isValidElement(t))return xt.cloneElement(t,s);if(typeof t=="function")return xt.createElement(t,s);s.ref;var r=Xrs(s,Urs);return xt.createElement(V4e,r)}var mRe=1,eT=function(t){function s(){var r;Vrs(this,s);for(var n=arguments.length,a=new Array(n),o=0;omRe||Math.abs(a.height-this.lastBoundingBox.height)>mRe)&&(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?yv({},this.lastBoundingBox):{width:0,height:0}}},{key:"getDefaultPosition",value:function(n){var a=this.props,o=a.layout,l=a.align,i=a.verticalAlign,d=a.margin,u=a.chartWidth,p=a.chartHeight,f,y;if(!n||(n.left===void 0||n.left===null)&&(n.right===void 0||n.right===null))if(l==="center"&&o==="vertical"){var _=this.getBBoxSnapshot();f={left:((u||0)-_.width)/2}}else f=l==="right"?{right:d&&d.right||0}:{left:d&&d.left||0};if(!n||(n.top===void 0||n.top===null)&&(n.bottom===void 0||n.bottom===null))if(i==="middle"){var b=this.getBBoxSnapshot();y={top:((p||0)-b.height)/2}}else y=i==="bottom"?{bottom:d&&d.bottom||0}:{top:d&&d.top||0};return yv(yv({},f),y)}},{key:"render",value:function(){var n=this,a=this.props,o=a.content,l=a.width,i=a.height,d=a.wrapperStyle,u=a.payloadUniqBy,p=a.payload,f=yv(yv({position:"absolute",width:l||"auto",height:i||"auto"},this.getDefaultPosition(d)),d);return xt.createElement("div",{className:"recharts-legend-wrapper",style:f,ref:function(_){n.wrapperNode=_}},ens(o,yv(yv({},this.props),{},{payload:Ust(p,u,Jrs)})))}}],[{key:"getWithHeight",value:function(n,a){var o=yv(yv({},this.defaultProps),n.props),l=o.layout;return l==="vertical"&&sn(n.props.height)?{height:n.props.height}:l==="horizontal"?{width:n.props.width||a}:null}}])}(k.PureComponent);Jhe(eT,"displayName","Legend");Jhe(eT,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var pRe=cO,tns=G4e,sns=jp,fRe=pRe?pRe.isConcatSpreadable:void 0;function rns(t){return sns(t)||tns(t)||!!(fRe&&t&&t[fRe])}var nns=rns,ans=Est,ins=nns;function Gst(t,s,r,n,a){var o=-1,l=t.length;for(r||(r=ins),a||(a=[]);++o0&&r(i)?s>1?Gst(i,s-1,r,n,a):ans(a,i):n||(a[a.length]=i)}return a}var Wst=Gst;function ons(t){return function(s,r,n){for(var a=-1,o=Object(s),l=n(s),i=l.length;i--;){var d=l[t?i:++a];if(r(o[d],d,o)===!1)break}return s}}var lns=ons,cns=lns,dns=cns(),uns=dns,hns=uns,mns=Qhe;function pns(t,s){return t&&hns(t,s,mns)}var Kst=pns,fns=uO;function xns(t,s){return function(r,n){if(r==null)return r;if(!fns(r))return t(r,n);for(var a=r.length,o=s?a:-1,l=Object(r);(s?o--:++os||o&&l&&d&&!i&&!u||n&&l&&d||!r&&d||!a)return 1;if(!n&&!o&&!u&&t=i)return d;var u=r[n];return d*(u=="desc"?-1:1)}}return t.index-s.index}var Ans=Tns,$ye=L4e,Ens=D4e,Pns=C0,Ins=Zst,Lns=kns,Dns=Lst,Rns=Ans,Ons=fE,Fns=jp;function zns(t,s,r){s.length?s=$ye(s,function(o){return Fns(o)?function(l){return Ens(l,o.length===1?o[0]:o)}:o}):s=[Ons];var n=-1;s=$ye(s,Dns(Pns));var a=Ins(t,function(o,l,i){var d=$ye(s,function(u){return u(o)});return{criteria:d,index:++n,value:o}});return Lns(a,function(o,l){return Rns(o,l,r)})}var Bns=zns;function $ns(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 qns=$ns,Uns=qns,gRe=Math.max;function Vns(t,s,r){return s=gRe(s===void 0?t.length-1:s,0),function(){for(var n=arguments,a=-1,o=gRe(n.length-s,0),l=Array(o);++a0){if(++s>=eas)return arguments[0]}else s=0;return t.apply(void 0,arguments)}}var nas=ras,aas=Jns,ias=nas,oas=ias(aas),las=oas,cas=fE,das=Hns,uas=las;function has(t,s){return uas(das(t,s,cas),t+"")}var mas=has,pas=A4e,fas=uO,xas=W4e,gas=jw;function yas(t,s,r){if(!gas(r))return!1;var n=typeof s;return(n=="number"?fas(r)&&xas(s,r.length):n=="string"&&s in r)?pas(r[s],t):!1}var eme=yas,vas=Wst,_as=Bns,bas=mas,vRe=eme,was=bas(function(t,s){if(t==null)return[];var r=s.length;return r>1&&vRe(t,s[0],s[1])?s=[]:r>2&&vRe(s[0],s[1],s[2])&&(s=[s[0]]),_as(t,vas(s,1),[])}),jas=was;const X4e=ao(jas);function AD(t){"@babel/helpers - typeof";return AD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},AD(t)}function 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(dI,"-left"),sn(r)&&s&&sn(s.x)&&r=s.y),"".concat(dI,"-top"),sn(n)&&s&&sn(s.y)&&nN?Math.max(p,d[n]):Math.max(f,d[n])}function Fas(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 zas(t){var s=t.allowEscapeViewBox,r=t.coordinate,n=t.offsetTopLeft,a=t.position,o=t.reverseDirection,l=t.tooltipBox,i=t.useTranslate3d,d=t.viewBox,u,p,f;return l.height>0&&l.width>0&&r?(p=wRe({allowEscapeViewBox:s,coordinate:r,key:"x",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.width,viewBox:d,viewBoxDimension:d.width}),f=wRe({allowEscapeViewBox:s,coordinate:r,key:"y",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.height,viewBox:d,viewBoxDimension:d.height}),u=Fas({translateX:p,translateY:f,useTranslate3d:i})):u=Ras,{cssProperties:u,cssClasses:Oas({translateX:p,translateY:f,coordinate:r})}}function YT(t){"@babel/helpers - typeof";return YT=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},YT(t)}function jRe(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 NRe(t){for(var s=1;skRe||Math.abs(n.height-this.state.lastBoundingBox.height)>kRe)&&this.setState({lastBoundingBox:{width:n.width,height:n.height}})}else(this.state.lastBoundingBox.width!==-1||this.state.lastBoundingBox.height!==-1)&&this.setState({lastBoundingBox:{width:-1,height:-1}})}},{key:"componentDidMount",value:function(){document.addEventListener("keydown",this.handleKeyDown),this.updateBBox()}},{key:"componentWillUnmount",value:function(){document.removeEventListener("keydown",this.handleKeyDown)}},{key:"componentDidUpdate",value:function(){var n,a;this.props.active&&this.updateBBox(),this.state.dismissed&&(((n=this.props.coordinate)===null||n===void 0?void 0:n.x)!==this.state.dismissedAtCoordinate.x||((a=this.props.coordinate)===null||a===void 0?void 0:a.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}},{key:"render",value:function(){var n=this,a=this.props,o=a.active,l=a.allowEscapeViewBox,i=a.animationDuration,d=a.animationEasing,u=a.children,p=a.coordinate,f=a.hasPayload,y=a.isAnimationActive,_=a.offset,b=a.position,N=a.reverseDirection,w=a.useTranslate3d,S=a.viewBox,C=a.wrapperStyle,A=zas({allowEscapeViewBox:l,coordinate:p,offsetTopLeft:_,position:b,reverseDirection:N,tooltipBox:this.state.lastBoundingBox,useTranslate3d:w,viewBox:S}),I=A.cssClasses,L=A.cssProperties,O=NRe(NRe({transition:y&&o?"transform ".concat(i,"ms ").concat(d):void 0},L),{},{pointerEvents:"none",visibility:!this.state.dismissed&&o&&f?"visible":"hidden",position:"absolute",top:0,left:0},C);return xt.createElement("div",{tabIndex:-1,className:I,style:O,ref:function(q){n.wrapperNode=q}},u)}}])}(k.PureComponent),Zas=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},l0={isSsr:Zas(),get:function(s){return l0[s]},set:function(s,r){if(typeof s=="string")l0[s]=r;else{var n=Object.keys(s);n&&n.length&&n.forEach(function(a){l0[a]=s[a]})}}};function XT(t){"@babel/helpers - typeof";return XT=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},XT(t)}function SRe(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 CRe(t){for(var s=1;s0;return xt.createElement(Kas,{allowEscapeViewBox:l,animationDuration:i,animationEasing:d,isAnimationActive:y,active:o,coordinate:p,hasPayload:O,offset:_,position:w,reverseDirection:S,useTranslate3d:C,viewBox:A,wrapperStyle:I},ais(u,CRe(CRe({},this.props),{},{payload:L})))}}])}(k.PureComponent);Q4e(tp,"displayName","Tooltip");Q4e(tp,"defaultProps",{accessibilityLayer:!1,allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",contentStyle:{},coordinate:{x:0,y:0},cursor:!0,cursorStyle:{},filterNull:!0,isAnimationActive:!l0.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 iis=S0,ois=function(){return iis.Date.now()},lis=ois,cis=/\s/;function dis(t){for(var s=t.length;s--&&cis.test(t.charAt(s)););return s}var uis=dis,his=uis,mis=/^\s+/;function pis(t){return t&&t.slice(0,his(t)+1).replace(mis,"")}var fis=pis,xis=fis,MRe=jw,gis=oE,TRe=NaN,yis=/^[-+]0x[0-9a-f]+$/i,vis=/^0b[01]+$/i,_is=/^0o[0-7]+$/i,bis=parseInt;function wis(t){if(typeof t=="number")return t;if(gis(t))return TRe;if(MRe(t)){var s=typeof t.valueOf=="function"?t.valueOf():t;t=MRe(s)?s+"":s}if(typeof t!="string")return t===0?t:+t;t=xis(t);var r=vis.test(t);return r||_is.test(t)?bis(t.slice(2),r?2:8):yis.test(t)?TRe:+t}var trt=wis,jis=jw,Uye=lis,ARe=trt,Nis="Expected a function",kis=Math.max,Sis=Math.min;function Cis(t,s,r){var n,a,o,l,i,d,u=0,p=!1,f=!1,y=!0;if(typeof t!="function")throw new TypeError(Nis);s=ARe(s)||0,jis(r)&&(p=!!r.leading,f="maxWait"in r,o=f?kis(ARe(r.maxWait)||0,s):o,y="trailing"in r?!!r.trailing:y);function _(O){var V=n,q=a;return n=a=void 0,u=O,l=t.apply(q,V),l}function b(O){return u=O,i=setTimeout(S,s),p?_(O):l}function N(O){var V=O-d,q=O-u,B=s-V;return f?Sis(B,o-q):B}function w(O){var V=O-d,q=O-u;return d===void 0||V>=s||V<0||f&&q>=o}function S(){var O=Uye();if(w(O))return C(O);i=setTimeout(S,N(O))}function C(O){return i=void 0,y&&n?_(O):(n=a=void 0,l)}function A(){i!==void 0&&clearTimeout(i),u=0,n=d=a=i=void 0}function I(){return i===void 0?l:C(Uye())}function L(){var O=Uye(),V=w(O);if(n=arguments,a=this,d=O,V){if(i===void 0)return b(d);if(f)return clearTimeout(i),i=setTimeout(S,s),_(d)}return i===void 0&&(i=setTimeout(S,s)),l}return L.cancel=A,L.flush=I,L}var Mis=Cis,Tis=Mis,Ais=jw,Eis="Expected a function";function Pis(t,s,r){var n=!0,a=!0;if(typeof t!="function")throw new TypeError(Eis);return Ais(r)&&(n="leading"in r?!!r.leading:n,a="trailing"in r?!!r.trailing:a),Tis(t,s,{leading:n,maxWait:s,trailing:a})}var Iis=Pis;const srt=ao(Iis);function PD(t){"@babel/helpers - typeof";return PD=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},PD(t)}function ERe(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 o9(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r0&&(J=srt(J,N,{trailing:!0,leading:!1}));var X=new ResizeObserver(J),ce=L.current.getBoundingClientRect(),ie=ce.width,ae=ce.height;return te(ie,ae),X.observe(L.current),function(){X.disconnect()}},[te,N]);var Y=k.useMemo(function(){var J=B.containerWidth,X=B.containerHeight;if(J<0||X<0)return null;Rg(k4(l)||k4(d),`The width(%s) and height(%s) are both fixed numbers, maybe you don't need to use a ResponsiveContainer.`,l,d),Rg(!r||r>0,"The aspect(%s) must be greater than zero.",r);var ce=k4(l)?J:l,ie=k4(d)?X:d;r&&r>0&&(ce?ie=ce/r:ie&&(ce=ie*r),y&&ie>y&&(ie=y)),Rg(ce>0||ie>0,`The width(%s) and height(%s) of chart should be greater than 0, please check the style of container, or the props width(%s) and height(%s), or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the height and width.`,ce,ie,l,d,p,f,r);var ae=!Array.isArray(_)&&n1(_.type).endsWith("Chart");return xt.Children.map(_,function(oe){return xt.isValidElement(oe)?k.cloneElement(oe,o9({width:ce,height:ie},ae?{style:o9({height:"100%",width:"100%",maxHeight:ie,maxWidth:ce},oe.props.style)}:{})):oe})},[r,_,d,y,f,p,B,l]);return xt.createElement("div",{id:w?"".concat(w):void 0,className:bi("recharts-responsive-container",S),style:o9(o9({},I),{},{width:l,height:d,minWidth:p,minHeight:f,maxHeight:y}),ref:L},Y)}),hO=function(s){return null};hO.displayName="Cell";function ID(t){"@babel/helpers - typeof";return ID=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},ID(t)}function IRe(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 Sbe(t){for(var s=1;s1&&arguments[1]!==void 0?arguments[1]:{};if(s==null||l0.isSsr)return{width:0,height:0};var n=Wis(r),a=JSON.stringify({text:s,copyStyle:n});if(j5.widthCache[a])return j5.widthCache[a];try{var o=document.getElementById(LRe);o||(o=document.createElement("span"),o.setAttribute("id",LRe),o.setAttribute("aria-hidden","true"),document.body.appendChild(o));var l=Sbe(Sbe({},Gis),n);Object.assign(o.style,l),o.textContent="".concat(s);var i=o.getBoundingClientRect(),d={width:i.width,height:i.height};return j5.widthCache[a]=d,++j5.cacheCount>His&&(j5.cacheCount=0,j5.widthCache={}),d}catch{return{width:0,height:0}}},Kis=function(s){return{top:s.top+window.scrollY-document.documentElement.clientTop,left:s.left+window.scrollX-document.documentElement.clientLeft}};function LD(t){"@babel/helpers - typeof";return LD=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},LD(t)}function Dce(t,s){return Qis(t)||Xis(t,s)||Yis(t,s)||Zis()}function Zis(){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 Yis(t,s){if(t){if(typeof t=="string")return DRe(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 DRe(t,s)}}function DRe(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 hos(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 $Re(t,s){return xos(t)||fos(t,s)||pos(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 pos(t,s){if(t){if(typeof t=="string")return qRe(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 qRe(t,s)}}function qRe(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(ie,ae){var oe=ae.word,me=ae.width,ve=ie[ie.length-1];if(ve&&(a==null||o||ve.width+me+nae.width?ie:ae})};if(!p)return _;for(var N="…",w=function(ce){var ie=f.slice(0,ce),ae=irt({breakAll:u,style:d,children:ie+N}).wordsWithComputedWidth,oe=y(ae),me=oe.length>l||b(oe).width>Number(a);return[me,oe]},S=0,C=f.length-1,A=0,I;S<=C&&A<=f.length-1;){var L=Math.floor((S+C)/2),O=L-1,V=w(O),q=$Re(V,2),B=q[0],U=q[1],te=w(L),Y=$Re(te,1),J=Y[0];if(!B&&!J&&(S=L+1),B&&J&&(C=L-1),!B&&J){I=U;break}A++}return I||_},URe=function(s){var r=vi(s)?[]:s.toString().split(art);return[{words:r}]},yos=function(s){var r=s.width,n=s.scaleToFit,a=s.children,o=s.style,l=s.breakAll,i=s.maxLines;if((r||n)&&!l0.isSsr){var d,u,p=irt({breakAll:l,children:a,style:o});if(p){var f=p.wordsWithComputedWidth,y=p.spaceWidth;d=f,u=y}else return URe(a);return gos({breakAll:l,children:a,maxLines:i,style:o},d,u,r,n)}return URe(a)},VRe="#808080",cC=function(s){var r=s.x,n=r===void 0?0:r,a=s.y,o=a===void 0?0:a,l=s.lineHeight,i=l===void 0?"1em":l,d=s.capHeight,u=d===void 0?"0.71em":d,p=s.scaleToFit,f=p===void 0?!1:p,y=s.textAnchor,_=y===void 0?"start":y,b=s.verticalAnchor,N=b===void 0?"end":b,w=s.fill,S=w===void 0?VRe:w,C=BRe(s,dos),A=k.useMemo(function(){return yos({breakAll:C.breakAll,children:C.children,maxLines:C.maxLines,scaleToFit:f,style:C.style,width:C.width})},[C.breakAll,C.children,C.maxLines,f,C.style,C.width]),I=C.dx,L=C.dy,O=C.angle,V=C.className,q=C.breakAll,B=BRe(C,uos);if(!cu(n)||!cu(o))return null;var U=n+(sn(I)?I:0),te=o+(sn(L)?L:0),Y;switch(N){case"start":Y=Vye("calc(".concat(u,")"));break;case"middle":Y=Vye("calc(".concat((A.length-1)/2," * -").concat(i," + (").concat(u," / 2))"));break;default:Y=Vye("calc(".concat(A.length-1," * -").concat(i,")"));break}var J=[];if(f){var X=A[0].width,ce=C.width;J.push("scale(".concat((sn(ce)?ce/X:1)/X,")"))}return O&&J.push("rotate(".concat(O,", ").concat(U,", ").concat(te,")")),J.length&&(B.transform=J.join(" ")),xt.createElement("text",Cbe({},Ua(B,!0),{x:U,y:te,className:bi("recharts-text",V),textAnchor:_,fill:S.includes("url")?VRe:S}),A.map(function(ie,ae){var oe=ie.words.join(q?"":" ");return xt.createElement("tspan",{x:U,dy:ae===0?Y:i,key:"".concat(oe,"-").concat(ae)},oe)}))};function Bb(t,s){return t==null||s==null?NaN:ts?1:t>=s?0:NaN}function vos(t,s){return t==null||s==null?NaN:st?1:s>=t?0:NaN}function J4e(t){let s,r,n;t.length!==2?(s=Bb,r=(i,d)=>Bb(t(i),d),n=(i,d)=>t(i)-d):(s=t===Bb||t===vos?t:_os,r=t,n=t);function a(i,d,u=0,p=i.length){if(u>>1;r(i[f],d)<0?u=f+1:p=f}while(u>>1;r(i[f],d)<=0?u=f+1:p=f}while(uu&&n(i[f-1],d)>-n(i[f],d)?f-1:f}return{left:a,center:l,right:o}}function _os(){return 0}function ort(t){return t===null?NaN:+t}function*bos(t,s){for(let r of t)r!=null&&(r=+r)>=r&&(yield r)}const wos=J4e(Bb),mO=wos.right;J4e(ort).center;class HRe extends Map{constructor(s,r=kos){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(GRe(this,s))}has(s){return super.has(GRe(this,s))}set(s,r){return super.set(jos(this,s),r)}delete(s){return super.delete(Nos(this,s))}}function GRe({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):r}function jos({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):(t.set(n,r),r)}function Nos({_intern:t,_key:s},r){const n=s(r);return t.has(n)&&(r=t.get(n),t.delete(n)),r}function kos(t){return t!==null&&typeof t=="object"?t.valueOf():t}function Sos(t=Bb){if(t===Bb)return lrt;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 lrt(t,s){return(t==null||!(t>=t))-(s==null||!(s>=s))||(ts?1:0)}const Cos=Math.sqrt(50),Mos=Math.sqrt(10),Tos=Math.sqrt(2);function Rce(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>=Cos?10:o>=Mos?5:o>=Tos?2:1;let i,d,u;return a<0?(u=Math.pow(10,-a)/l,i=Math.round(t*u),d=Math.round(s*u),i/us&&--d,u=-u):(u=Math.pow(10,a)*l,i=Math.round(t/u),d=Math.round(s/u),i*us&&--d),d0))return[];if(t===s)return[t];const n=s=a))return[];const i=o-a+1,d=new Array(i);if(n)if(l<0)for(let u=0;u=n)&&(r=n);return r}function KRe(t,s){let r;for(const n of t)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);return r}function crt(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?lrt:Sos(a);n>r;){if(n-r>600){const d=n-r+1,u=s-r+1,p=Math.log(d),f=.5*Math.exp(2*p/3),y=.5*Math.sqrt(p*f*(d-f)/d)*(u-d/2<0?-1:1),_=Math.max(r,Math.floor(s-u*f/d+y)),b=Math.min(n,Math.floor(s+(d-u)*f/d+y));crt(t,s,_,b,a)}const o=t[s];let l=r,i=n;for(uI(t,r,s),a(t[n],o)>0&&uI(t,r,n);l0;)--i}a(t[r],o)===0?uI(t,r,i):(++i,uI(t,i,n)),i<=s&&(r=i+1),s<=i&&(n=i-1)}return t}function uI(t,s,r){const n=t[s];t[s]=t[r],t[r]=n}function Aos(t,s,r){if(t=Float64Array.from(bos(t)),!(!(n=t.length)||isNaN(s=+s))){if(s<=0||n<2)return KRe(t);if(s>=1)return WRe(t);var n,a=(n-1)*s,o=Math.floor(a),l=WRe(crt(t,o).subarray(0,o+1)),i=KRe(t.subarray(o+1));return l+(i-l)*(a-o)}}function Eos(t,s,r=ort){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 Pos(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?c9(s>>24&255,s>>16&255,s>>8&255,(s&255)/255):r===4?c9(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=Los.exec(t))?new dp(s[1],s[2],s[3],1):(s=Dos.exec(t))?new dp(s[1]*255/100,s[2]*255/100,s[3]*255/100,1):(s=Ros.exec(t))?c9(s[1],s[2],s[3],s[4]):(s=Oos.exec(t))?c9(s[1]*255/100,s[2]*255/100,s[3]*255/100,s[4]):(s=Fos.exec(t))?tOe(s[1],s[2]/100,s[3]/100,1):(s=zos.exec(t))?tOe(s[1],s[2]/100,s[3]/100,s[4]):ZRe.hasOwnProperty(t)?QRe(ZRe[t]):t==="transparent"?new dp(NaN,NaN,NaN,0):null}function QRe(t){return new dp(t>>16&255,t>>8&255,t&255,1)}function c9(t,s,r,n){return n<=0&&(t=s=r=NaN),new dp(t,s,r,n)}function qos(t){return t instanceof pO||(t=FD(t)),t?(t=t.rgb(),new dp(t.r,t.g,t.b,t.opacity)):new dp}function Pbe(t,s,r,n){return arguments.length===1?qos(t):new dp(t,s,r,n??1)}function dp(t,s,r,n){this.r=+t,this.g=+s,this.b=+r,this.opacity=+n}tSe(dp,Pbe,urt(pO,{brighter(t){return t=t==null?Oce:Math.pow(Oce,t),new dp(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?RD:Math.pow(RD,t),new dp(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new dp(ES(this.r),ES(this.g),ES(this.b),Fce(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:JRe,formatHex:JRe,formatHex8:Uos,formatRgb:eOe,toString:eOe}));function JRe(){return`#${S4(this.r)}${S4(this.g)}${S4(this.b)}`}function Uos(){return`#${S4(this.r)}${S4(this.g)}${S4(this.b)}${S4((isNaN(this.opacity)?1:this.opacity)*255)}`}function eOe(){const t=Fce(this.opacity);return`${t===1?"rgb(":"rgba("}${ES(this.r)}, ${ES(this.g)}, ${ES(this.b)}${t===1?")":`, ${t})`}`}function Fce(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ES(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function S4(t){return t=ES(t),(t<16?"0":"")+t.toString(16)}function tOe(t,s,r,n){return n<=0?t=s=r=NaN:r<=0||r>=1?t=s=NaN:s<=0&&(t=NaN),new Ng(t,s,r,n)}function hrt(t){if(t instanceof Ng)return new Ng(t.h,t.s,t.l,t.opacity);if(t instanceof pO||(t=FD(t)),!t)return new Ng;if(t instanceof Ng)return t;t=t.rgb();var s=t.r/255,r=t.g/255,n=t.b/255,a=Math.min(s,r,n),o=Math.max(s,r,n),l=NaN,i=o-a,d=(o+a)/2;return i?(s===o?l=(r-n)/i+(r0&&d<1?0:l,new Ng(l,i,d,t.opacity)}function Vos(t,s,r,n){return arguments.length===1?hrt(t):new Ng(t,s,r,n??1)}function Ng(t,s,r,n){this.h=+t,this.s=+s,this.l=+r,this.opacity=+n}tSe(Ng,Vos,urt(pO,{brighter(t){return t=t==null?Oce:Math.pow(Oce,t),new Ng(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?RD:Math.pow(RD,t),new Ng(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 dp(Hye(t>=240?t-240:t+120,a,n),Hye(t,a,n),Hye(t<120?t+240:t-120,a,n),this.opacity)},clamp(){return new Ng(sOe(this.h),d9(this.s),d9(this.l),Fce(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=Fce(this.opacity);return`${t===1?"hsl(":"hsla("}${sOe(this.h)}, ${d9(this.s)*100}%, ${d9(this.l)*100}%${t===1?")":`, ${t})`}`}}));function sOe(t){return t=(t||0)%360,t<0?t+360:t}function d9(t){return Math.max(0,Math.min(1,t||0))}function Hye(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 sSe=t=>()=>t;function Hos(t,s){return function(r){return t+r*s}}function Gos(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 Wos(t){return(t=+t)==1?mrt:function(s,r){return r-s?Gos(s,r,t):sSe(isNaN(s)?r:s)}}function mrt(t,s){var r=s-t;return r?Hos(t,r):sSe(isNaN(t)?s:t)}const rOe=function t(s){var r=Wos(s);function n(a,o){var l=r((a=Pbe(a)).r,(o=Pbe(o)).r),i=r(a.g,o.g),d=r(a.b,o.b),u=mrt(a.opacity,o.opacity);return function(p){return a.r=l(p),a.g=i(p),a.b=d(p),a.opacity=u(p),a+""}}return n.gamma=t,n}(1);function Kos(t,s){s||(s=[]);var r=t?Math.min(s.length,t.length):0,n=s.slice(),a;return function(o){for(a=0;ar&&(o=s.slice(r,o),i[l]?i[l]+=o:i[++l]=o),(n=n[0])===(a=a[0])?i[l]?i[l]+=a:i[++l]=a:(i[++l]=null,d.push({i:l,x:zce(n,a)})),r=Gye.lastIndex;return rs&&(r=t,t=s,s=r),function(n){return Math.max(t,Math.min(s,n))}}function als(t,s,r){var n=t[0],a=t[1],o=s[0],l=s[1];return a2?ils:als,d=u=null,f}function f(y){return y==null||isNaN(y=+y)?o:(d||(d=i(t.map(n),s,r)))(n(l(y)))}return f.invert=function(y){return l(a((u||(u=i(s,t.map(n),zce)))(y)))},f.domain=function(y){return arguments.length?(t=Array.from(y,Bce),p()):t.slice()},f.range=function(y){return arguments.length?(s=Array.from(y),p()):s.slice()},f.rangeRound=function(y){return s=Array.from(y),r=rSe,p()},f.clamp=function(y){return arguments.length?(l=y?!0:Nm,p()):l!==Nm},f.interpolate=function(y){return arguments.length?(r=y,p()):r},f.unknown=function(y){return arguments.length?(o=y,f):o},function(y,_){return n=y,a=_,p()}}function nSe(){return tme()(Nm,Nm)}function ols(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function $ce(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 QT(t){return t=$ce(Math.abs(t)),t?t[1]:NaN}function lls(t,s){return function(r,n){for(var a=r.length,o=[],l=0,i=t[0],d=0;a>0&&i>0&&(d+i+1>n&&(i=Math.max(1,n-d)),o.push(r.substring(a-=i,a+i)),!((d+=i+1)>n));)i=t[l=(l+1)%t.length];return o.reverse().join(s)}}function cls(t){return function(s){return s.replace(/[0-9]/g,function(r){return t[+r]})}}var dls=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function zD(t){if(!(s=dls.exec(t)))throw new Error("invalid format: "+t);var s;return new aSe({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]})}zD.prototype=aSe.prototype;function aSe(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+""}aSe.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 uls(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 prt;function hls(t,s){var r=$ce(t,s);if(!r)return t+"";var n=r[0],a=r[1],o=a-(prt=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")+$ce(t,Math.max(0,s+o-1))[0]}function aOe(t,s){var r=$ce(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 iOe={"%":(t,s)=>(t*100).toFixed(s),b:t=>Math.round(t).toString(2),c:t=>t+"",d:ols,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)=>aOe(t*100,s),r:aOe,s:hls,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function oOe(t){return t}var lOe=Array.prototype.map,cOe=["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?oOe:lls(lOe.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?oOe:cls(lOe.call(t.numerals,String)),l=t.percent===void 0?"%":t.percent+"",i=t.minus===void 0?"−":t.minus+"",d=t.nan===void 0?"NaN":t.nan+"";function u(f){f=zD(f);var y=f.fill,_=f.align,b=f.sign,N=f.symbol,w=f.zero,S=f.width,C=f.comma,A=f.precision,I=f.trim,L=f.type;L==="n"?(C=!0,L="g"):iOe[L]||(A===void 0&&(A=12),I=!0,L="g"),(w||y==="0"&&_==="=")&&(w=!0,y="0",_="=");var O=N==="$"?r:N==="#"&&/[boxX]/.test(L)?"0"+L.toLowerCase():"",V=N==="$"?n:/[%p]/.test(L)?l:"",q=iOe[L],B=/[defgprs%]/.test(L);A=A===void 0?6:/[gprs]/.test(L)?Math.max(1,Math.min(21,A)):Math.max(0,Math.min(20,A));function U(te){var Y=O,J=V,X,ce,ie;if(L==="c")J=q(te)+J,te="";else{te=+te;var ae=te<0||1/te<0;if(te=isNaN(te)?d:q(Math.abs(te),A),I&&(te=uls(te)),ae&&+te==0&&b!=="+"&&(ae=!1),Y=(ae?b==="("?b:i:b==="-"||b==="("?"":b)+Y,J=(L==="s"?cOe[8+prt/3]:"")+J+(ae&&b==="("?")":""),B){for(X=-1,ce=te.length;++Xie||ie>57){J=(ie===46?a+te.slice(X+1):te.slice(X))+J,te=te.slice(0,X);break}}}C&&!w&&(te=s(te,1/0));var oe=Y.length+te.length+J.length,me=oe>1)+Y+te+J+me.slice(oe);break;default:te=me+Y+te+J;break}return o(te)}return U.toString=function(){return f+""},U}function p(f,y){var _=u((f=zD(f),f.type="f",f)),b=Math.max(-8,Math.min(8,Math.floor(QT(y)/3)))*3,N=Math.pow(10,-b),w=cOe[8+b/3];return function(S){return _(N*S)+w}}return{format:u,formatPrefix:p}}var u9,iSe,frt;pls({thousands:",",grouping:[3],currency:["$",""]});function pls(t){return u9=mls(t),iSe=u9.format,frt=u9.formatPrefix,u9}function fls(t){return Math.max(0,-QT(Math.abs(t)))}function xls(t,s){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(QT(s)/3)))*3-QT(Math.abs(t)))}function gls(t,s){return t=Math.abs(t),s=Math.abs(s)-t,Math.max(0,QT(s)-QT(t))+1}function xrt(t,s,r,n){var a=Abe(t,s,r),o;switch(n=zD(n??",f"),n.type){case"s":{var l=Math.max(Math.abs(t),Math.abs(s));return n.precision==null&&!isNaN(o=xls(a,l))&&(n.precision=o),frt(n,l)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(o=gls(a,Math.max(Math.abs(t),Math.abs(s))))&&(n.precision=o-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(o=fls(a))&&(n.precision=o-(n.type==="%")*2);break}}return iSe(n)}function Nw(t){var s=t.domain;return t.ticks=function(r){var n=s();return Mbe(n[0],n[n.length-1],r??10)},t.tickFormat=function(r,n){var a=s();return xrt(a[0],a[a.length-1],r??10,n)},t.nice=function(r){r==null&&(r=10);var n=s(),a=0,o=n.length-1,l=n[a],i=n[o],d,u,p=10;for(i0;){if(u=Tbe(l,i,r),u===d)return n[a]=l,n[o]=i,s(n);if(u>0)l=Math.floor(l/u)*u,i=Math.ceil(i/u)*u;else if(u<0)l=Math.ceil(l*u)/u,i=Math.floor(i*u)/u;else break;d=u}return t},t}function qce(){var t=nSe();return t.copy=function(){return fO(t,qce())},Rx.apply(t,arguments),Nw(t)}function grt(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,Bce),r):t.slice()},r.unknown=function(n){return arguments.length?(s=n,r):s},r.copy=function(){return grt(t).unknown(s)},t=arguments.length?Array.from(t,Bce):[0,1],Nw(r)}function yrt(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 wls(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 hOe(t){return(s,r)=>-t(-s,r)}function oSe(t){const s=t(dOe,uOe),r=s.domain;let n=10,a,o;function l(){return a=wls(n),o=bls(n),r()[0]<0?(a=hOe(a),o=hOe(o),t(yls,vls)):t(dOe,uOe),s}return s.base=function(i){return arguments.length?(n=+i,l()):n},s.domain=function(i){return arguments.length?(r(i),l()):r()},s.ticks=i=>{const d=r();let u=d[0],p=d[d.length-1];const f=p0){for(;y<=_;++y)for(b=1;bp)break;S.push(N)}}else for(;y<=_;++y)for(b=n-1;b>=1;--b)if(N=y>0?b/o(-y):b*o(y),!(Np)break;S.push(N)}S.length*2{if(i==null&&(i=10),d==null&&(d=n===10?"s":","),typeof d!="function"&&(!(n%1)&&(d=zD(d)).precision==null&&(d.trim=!0),d=iSe(d)),i===1/0)return d;const u=Math.max(1,n*i/s.ticks().length);return p=>{let f=p/o(Math.round(a(p)));return f*nr(yrt(r(),{floor:i=>o(Math.floor(a(i))),ceil:i=>o(Math.ceil(a(i)))})),s}function vrt(){const t=oSe(tme()).domain([1,10]);return t.copy=()=>fO(t,vrt()).base(t.base()),Rx.apply(t,arguments),t}function mOe(t){return function(s){return Math.sign(s)*Math.log1p(Math.abs(s/t))}}function pOe(t){return function(s){return Math.sign(s)*Math.expm1(Math.abs(s))*t}}function lSe(t){var s=1,r=t(mOe(s),pOe(s));return r.constant=function(n){return arguments.length?t(mOe(s=+n),pOe(s)):s},Nw(r)}function _rt(){var t=lSe(tme());return t.copy=function(){return fO(t,_rt()).constant(t.constant())},Rx.apply(t,arguments)}function fOe(t){return function(s){return s<0?-Math.pow(-s,t):Math.pow(s,t)}}function jls(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function Nls(t){return t<0?-t*t:t*t}function cSe(t){var s=t(Nm,Nm),r=1;function n(){return r===1?t(Nm,Nm):r===.5?t(jls,Nls):t(fOe(r),fOe(1/r))}return s.exponent=function(a){return arguments.length?(r=+a,n()):r},Nw(s)}function dSe(){var t=cSe(tme());return t.copy=function(){return fO(t,dSe()).exponent(t.exponent())},Rx.apply(t,arguments),t}function kls(){return dSe.apply(null,arguments).exponent(.5)}function xOe(t){return Math.sign(t)*t*t}function Sls(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function brt(){var t=nSe(),s=[0,1],r=!1,n;function a(o){var l=Sls(t(o));return isNaN(l)?n:r?Math.round(l):l}return a.invert=function(o){return t.invert(xOe(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,Bce)).map(xOe)),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 brt(t.domain(),s).round(r).clamp(t.clamp()).unknown(n)},Rx.apply(a,arguments),Nw(a)}function wrt(){var t=[],s=[],r=[],n;function a(){var l=0,i=Math.max(1,s.length);for(r=new Array(i-1);++l0?r[i-1]:t[0],i=r?[n[r-1],s]:[n[u-1],n[u]]},l.unknown=function(d){return arguments.length&&(o=d),l},l.thresholds=function(){return n.slice()},l.copy=function(){return jrt().domain([t,s]).range(a).unknown(o)},Rx.apply(Nw(l),arguments)}function Nrt(){var t=[.5],s=[0,1],r,n=1;function a(o){return o!=null&&o<=o?s[mO(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 Nrt().domain(t).range(s).unknown(r)},Rx.apply(a,arguments)}const Wye=new Date,Kye=new Date;function _u(t,s,r,n){function a(o){return t(o=arguments.length===0?new Date:new Date(+o)),o}return a.floor=o=>(t(o=new Date(+o)),o),a.ceil=o=>(t(o=new Date(o-1)),s(o,1),t(o),o),a.round=o=>{const l=a(o),i=a.ceil(o);return o-l(s(o=new Date(+o),l==null?1:Math.floor(l)),o),a.range=(o,l,i)=>{const d=[];if(o=a.ceil(o),i=i==null?1:Math.floor(i),!(o0))return d;let u;do d.push(u=new Date(+o)),s(o,i),t(o);while(u_u(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)=>(Wye.setTime(+o),Kye.setTime(+l),t(Wye),t(Kye),Math.floor(r(Wye,Kye))),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 Uce=_u(()=>{},(t,s)=>{t.setTime(+t+s)},(t,s)=>s-t);Uce.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?_u(s=>{s.setTime(Math.floor(s/t)*t)},(s,r)=>{s.setTime(+s+r*t)},(s,r)=>(r-s)/t):Uce);Uce.range;const qv=1e3,hx=qv*60,Uv=hx*60,g1=Uv*24,uSe=g1*7,gOe=g1*30,Zye=g1*365,C4=_u(t=>{t.setTime(t-t.getMilliseconds())},(t,s)=>{t.setTime(+t+s*qv)},(t,s)=>(s-t)/qv,t=>t.getUTCSeconds());C4.range;const hSe=_u(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*qv)},(t,s)=>{t.setTime(+t+s*hx)},(t,s)=>(s-t)/hx,t=>t.getMinutes());hSe.range;const mSe=_u(t=>{t.setUTCSeconds(0,0)},(t,s)=>{t.setTime(+t+s*hx)},(t,s)=>(s-t)/hx,t=>t.getUTCMinutes());mSe.range;const pSe=_u(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*qv-t.getMinutes()*hx)},(t,s)=>{t.setTime(+t+s*Uv)},(t,s)=>(s-t)/Uv,t=>t.getHours());pSe.range;const fSe=_u(t=>{t.setUTCMinutes(0,0,0)},(t,s)=>{t.setTime(+t+s*Uv)},(t,s)=>(s-t)/Uv,t=>t.getUTCHours());fSe.range;const xO=_u(t=>t.setHours(0,0,0,0),(t,s)=>t.setDate(t.getDate()+s),(t,s)=>(s-t-(s.getTimezoneOffset()-t.getTimezoneOffset())*hx)/g1,t=>t.getDate()-1);xO.range;const sme=_u(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/g1,t=>t.getUTCDate()-1);sme.range;const krt=_u(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/g1,t=>Math.floor(t/g1));krt.range;function EC(t){return _u(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())*hx)/uSe)}const rme=EC(0),Vce=EC(1),Cls=EC(2),Mls=EC(3),JT=EC(4),Tls=EC(5),Als=EC(6);rme.range;Vce.range;Cls.range;Mls.range;JT.range;Tls.range;Als.range;function PC(t){return _u(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)/uSe)}const nme=PC(0),Hce=PC(1),Els=PC(2),Pls=PC(3),eA=PC(4),Ils=PC(5),Lls=PC(6);nme.range;Hce.range;Els.range;Pls.range;eA.range;Ils.range;Lls.range;const xSe=_u(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());xSe.range;const gSe=_u(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());gSe.range;const y1=_u(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());y1.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:_u(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)});y1.range;const v1=_u(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());v1.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:_u(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)});v1.range;function Srt(t,s,r,n,a,o){const l=[[C4,1,qv],[C4,5,5*qv],[C4,15,15*qv],[C4,30,30*qv],[o,1,hx],[o,5,5*hx],[o,15,15*hx],[o,30,30*hx],[a,1,Uv],[a,3,3*Uv],[a,6,6*Uv],[a,12,12*Uv],[n,1,g1],[n,2,2*g1],[r,1,uSe],[s,1,gOe],[s,3,3*gOe],[t,1,Zye]];function i(u,p,f){const y=pw).right(l,y);if(_===l.length)return t.every(Abe(u/Zye,p/Zye,f));if(_===0)return Uce.every(Math.max(Abe(u,p,f),1));const[b,N]=l[y/l[_-1][2]53)return null;"w"in ye||(ye.w=1),"Z"in ye?(fe=Xye(hI(ye.y,0,1)),$e=fe.getUTCDay(),fe=$e>4||$e===0?Hce.ceil(fe):Hce(fe),fe=sme.offset(fe,(ye.V-1)*7),ye.y=fe.getUTCFullYear(),ye.m=fe.getUTCMonth(),ye.d=fe.getUTCDate()+(ye.w+6)%7):(fe=Yye(hI(ye.y,0,1)),$e=fe.getDay(),fe=$e>4||$e===0?Vce.ceil(fe):Vce(fe),fe=xO.offset(fe,(ye.V-1)*7),ye.y=fe.getFullYear(),ye.m=fe.getMonth(),ye.d=fe.getDate()+(ye.w+6)%7)}else("W"in ye||"U"in ye)&&("w"in ye||(ye.w="u"in ye?ye.u%7:"W"in ye?1:0),$e="Z"in ye?Xye(hI(ye.y,0,1)).getUTCDay():Yye(hI(ye.y,0,1)).getDay(),ye.m=0,ye.d="W"in ye?(ye.w+6)%7+ye.W*7-($e+5)%7:ye.w+ye.U*7-($e+6)%7);return"Z"in ye?(ye.H+=ye.Z/100|0,ye.M+=ye.Z%100,Xye(ye)):Yye(ye)}}function q(Ne,Ue,Ie,ye){for(var ct=0,fe=Ue.length,$e=Ie.length,Ye,tt;ct=$e)return-1;if(Ye=Ue.charCodeAt(ct++),Ye===37){if(Ye=Ue.charAt(ct++),tt=L[Ye in yOe?Ue.charAt(ct++):Ye],!tt||(ye=tt(Ne,Ie,ye))<0)return-1}else if(Ye!=Ie.charCodeAt(ye++))return-1}return ye}function B(Ne,Ue,Ie){var ye=u.exec(Ue.slice(Ie));return ye?(Ne.p=p.get(ye[0].toLowerCase()),Ie+ye[0].length):-1}function U(Ne,Ue,Ie){var ye=_.exec(Ue.slice(Ie));return ye?(Ne.w=b.get(ye[0].toLowerCase()),Ie+ye[0].length):-1}function te(Ne,Ue,Ie){var ye=f.exec(Ue.slice(Ie));return ye?(Ne.w=y.get(ye[0].toLowerCase()),Ie+ye[0].length):-1}function Y(Ne,Ue,Ie){var ye=S.exec(Ue.slice(Ie));return ye?(Ne.m=C.get(ye[0].toLowerCase()),Ie+ye[0].length):-1}function J(Ne,Ue,Ie){var ye=N.exec(Ue.slice(Ie));return ye?(Ne.m=w.get(ye[0].toLowerCase()),Ie+ye[0].length):-1}function X(Ne,Ue,Ie){return q(Ne,s,Ue,Ie)}function ce(Ne,Ue,Ie){return q(Ne,r,Ue,Ie)}function ie(Ne,Ue,Ie){return q(Ne,n,Ue,Ie)}function ae(Ne){return l[Ne.getDay()]}function oe(Ne){return o[Ne.getDay()]}function me(Ne){return d[Ne.getMonth()]}function ve(Ne){return i[Ne.getMonth()]}function he(Ne){return a[+(Ne.getHours()>=12)]}function ge(Ne){return 1+~~(Ne.getMonth()/3)}function je(Ne){return l[Ne.getUTCDay()]}function qe(Ne){return o[Ne.getUTCDay()]}function Me(Ne){return d[Ne.getUTCMonth()]}function ke(Ne){return i[Ne.getUTCMonth()]}function Re(Ne){return a[+(Ne.getUTCHours()>=12)]}function Ve(Ne){return 1+~~(Ne.getUTCMonth()/3)}return{format:function(Ne){var Ue=O(Ne+="",A);return Ue.toString=function(){return Ne},Ue},parse:function(Ne){var Ue=V(Ne+="",!1);return Ue.toString=function(){return Ne},Ue},utcFormat:function(Ne){var Ue=O(Ne+="",I);return Ue.toString=function(){return Ne},Ue},utcParse:function(Ne){var Ue=V(Ne+="",!0);return Ue.toString=function(){return Ne},Ue}}}var yOe={"-":"",_:" ",0:"0"},Gu=/^\s*\d+/,Bls=/^%/,$ls=/[\\^$*+?|[\]().{}]/g;function Mo(t,s,r){var n=t<0?"-":"",a=(n?-t:t)+"",o=a.length;return n+(o[s.toLowerCase(),r]))}function Uls(t,s,r){var n=Gu.exec(s.slice(r,r+1));return n?(t.w=+n[0],r+n[0].length):-1}function Vls(t,s,r){var n=Gu.exec(s.slice(r,r+1));return n?(t.u=+n[0],r+n[0].length):-1}function Hls(t,s,r){var n=Gu.exec(s.slice(r,r+2));return n?(t.U=+n[0],r+n[0].length):-1}function Gls(t,s,r){var n=Gu.exec(s.slice(r,r+2));return n?(t.V=+n[0],r+n[0].length):-1}function Wls(t,s,r){var n=Gu.exec(s.slice(r,r+2));return n?(t.W=+n[0],r+n[0].length):-1}function vOe(t,s,r){var n=Gu.exec(s.slice(r,r+4));return n?(t.y=+n[0],r+n[0].length):-1}function _Oe(t,s,r){var n=Gu.exec(s.slice(r,r+2));return n?(t.y=+n[0]+(+n[0]>68?1900:2e3),r+n[0].length):-1}function Kls(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 Zls(t,s,r){var n=Gu.exec(s.slice(r,r+1));return n?(t.q=n[0]*3-3,r+n[0].length):-1}function Yls(t,s,r){var n=Gu.exec(s.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function bOe(t,s,r){var n=Gu.exec(s.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function Xls(t,s,r){var n=Gu.exec(s.slice(r,r+3));return n?(t.m=0,t.d=+n[0],r+n[0].length):-1}function wOe(t,s,r){var n=Gu.exec(s.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function Qls(t,s,r){var n=Gu.exec(s.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function Jls(t,s,r){var n=Gu.exec(s.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function ecs(t,s,r){var n=Gu.exec(s.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function tcs(t,s,r){var n=Gu.exec(s.slice(r,r+6));return n?(t.L=Math.floor(n[0]/1e3),r+n[0].length):-1}function scs(t,s,r){var n=Bls.exec(s.slice(r,r+1));return n?r+n[0].length:-1}function rcs(t,s,r){var n=Gu.exec(s.slice(r));return n?(t.Q=+n[0],r+n[0].length):-1}function ncs(t,s,r){var n=Gu.exec(s.slice(r));return n?(t.s=+n[0],r+n[0].length):-1}function jOe(t,s){return Mo(t.getDate(),s,2)}function acs(t,s){return Mo(t.getHours(),s,2)}function ics(t,s){return Mo(t.getHours()%12||12,s,2)}function ocs(t,s){return Mo(1+xO.count(y1(t),t),s,3)}function Crt(t,s){return Mo(t.getMilliseconds(),s,3)}function lcs(t,s){return Crt(t,s)+"000"}function ccs(t,s){return Mo(t.getMonth()+1,s,2)}function dcs(t,s){return Mo(t.getMinutes(),s,2)}function ucs(t,s){return Mo(t.getSeconds(),s,2)}function hcs(t){var s=t.getDay();return s===0?7:s}function mcs(t,s){return Mo(rme.count(y1(t)-1,t),s,2)}function Mrt(t){var s=t.getDay();return s>=4||s===0?JT(t):JT.ceil(t)}function pcs(t,s){return t=Mrt(t),Mo(JT.count(y1(t),t)+(y1(t).getDay()===4),s,2)}function fcs(t){return t.getDay()}function xcs(t,s){return Mo(Vce.count(y1(t)-1,t),s,2)}function gcs(t,s){return Mo(t.getFullYear()%100,s,2)}function ycs(t,s){return t=Mrt(t),Mo(t.getFullYear()%100,s,2)}function vcs(t,s){return Mo(t.getFullYear()%1e4,s,4)}function _cs(t,s){var r=t.getDay();return t=r>=4||r===0?JT(t):JT.ceil(t),Mo(t.getFullYear()%1e4,s,4)}function bcs(t){var s=t.getTimezoneOffset();return(s>0?"-":(s*=-1,"+"))+Mo(s/60|0,"0",2)+Mo(s%60,"0",2)}function NOe(t,s){return Mo(t.getUTCDate(),s,2)}function wcs(t,s){return Mo(t.getUTCHours(),s,2)}function jcs(t,s){return Mo(t.getUTCHours()%12||12,s,2)}function Ncs(t,s){return Mo(1+sme.count(v1(t),t),s,3)}function Trt(t,s){return Mo(t.getUTCMilliseconds(),s,3)}function kcs(t,s){return Trt(t,s)+"000"}function Scs(t,s){return Mo(t.getUTCMonth()+1,s,2)}function Ccs(t,s){return Mo(t.getUTCMinutes(),s,2)}function Mcs(t,s){return Mo(t.getUTCSeconds(),s,2)}function Tcs(t){var s=t.getUTCDay();return s===0?7:s}function Acs(t,s){return Mo(nme.count(v1(t)-1,t),s,2)}function Art(t){var s=t.getUTCDay();return s>=4||s===0?eA(t):eA.ceil(t)}function Ecs(t,s){return t=Art(t),Mo(eA.count(v1(t),t)+(v1(t).getUTCDay()===4),s,2)}function Pcs(t){return t.getUTCDay()}function Ics(t,s){return Mo(Hce.count(v1(t)-1,t),s,2)}function Lcs(t,s){return Mo(t.getUTCFullYear()%100,s,2)}function Dcs(t,s){return t=Art(t),Mo(t.getUTCFullYear()%100,s,2)}function Rcs(t,s){return Mo(t.getUTCFullYear()%1e4,s,4)}function Ocs(t,s){var r=t.getUTCDay();return t=r>=4||r===0?eA(t):eA.ceil(t),Mo(t.getUTCFullYear()%1e4,s,4)}function Fcs(){return"+0000"}function kOe(){return"%"}function SOe(t){return+t}function COe(t){return Math.floor(+t/1e3)}var N5,Ert,Prt;zcs({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 zcs(t){return N5=zls(t),Ert=N5.format,N5.parse,Prt=N5.utcFormat,N5.utcParse,N5}function Bcs(t){return new Date(t)}function $cs(t){return t instanceof Date?+t:+new Date(+t)}function ySe(t,s,r,n,a,o,l,i,d,u){var p=nSe(),f=p.invert,y=p.domain,_=u(".%L"),b=u(":%S"),N=u("%I:%M"),w=u("%I %p"),S=u("%a %d"),C=u("%b %d"),A=u("%B"),I=u("%Y");function L(O){return(d(O)s(a/(t.length-1)))},r.quantiles=function(n){return Array.from({length:n+1},(a,o)=>Aos(t,o/n))},r.copy=function(){return Rrt(s).domain(t)},A1.apply(r,arguments)}function ime(){var t=0,s=.5,r=1,n=1,a,o,l,i,d,u=Nm,p,f=!1,y;function _(N){return isNaN(N=+N)?y:(N=.5+((N=+p(N))-o)*(n*Ns}var Brt=Kcs,Zcs=ome,Ycs=Brt,Xcs=fE;function Qcs(t){return t&&t.length?Zcs(t,Xcs,Ycs):void 0}var Jcs=Qcs;const lme=ao(Jcs);function eds(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};Qn.decimalPlaces=Qn.dp=function(){var t=this,s=t.d.length-1,r=(s-t.e)*Ql;if(s=t.d[s],s)for(;s%10==0;s/=10)r--;return r<0?0:r};Qn.dividedBy=Qn.div=function(t){return a1(this,new this.constructor(t))};Qn.dividedToIntegerBy=Qn.idiv=function(t){var s=this,r=s.constructor;return jl(a1(s,new r(t),0,1),r.precision)};Qn.equals=Qn.eq=function(t){return!this.cmp(t)};Qn.exponent=function(){return Ud(this)};Qn.greaterThan=Qn.gt=function(t){return this.cmp(t)>0};Qn.greaterThanOrEqualTo=Qn.gte=function(t){return this.cmp(t)>=0};Qn.isInteger=Qn.isint=function(){return this.e>this.d.length-2};Qn.isNegative=Qn.isneg=function(){return this.s<0};Qn.isPositive=Qn.ispos=function(){return this.s>0};Qn.isZero=function(){return this.s===0};Qn.lessThan=Qn.lt=function(t){return this.cmp(t)<0};Qn.lessThanOrEqualTo=Qn.lte=function(t){return this.cmp(t)<1};Qn.logarithm=Qn.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(ef))throw Error(Ex+"NaN");if(r.s<1)throw Error(Ex+(r.s?"NaN":"-Infinity"));return r.eq(ef)?new n(0):(vc=!1,s=a1(BD(r,o),BD(t,o),o),vc=!0,jl(s,a))};Qn.minus=Qn.sub=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?Hrt(s,t):Urt(s,(t.s=-t.s,t))};Qn.modulo=Qn.mod=function(t){var s,r=this,n=r.constructor,a=n.precision;if(t=new n(t),!t.s)throw Error(Ex+"NaN");return r.s?(vc=!1,s=a1(r,t,0,1).times(t),vc=!0,r.minus(s)):jl(new n(r),a)};Qn.naturalExponential=Qn.exp=function(){return Vrt(this)};Qn.naturalLogarithm=Qn.ln=function(){return BD(this)};Qn.negated=Qn.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Qn.plus=Qn.add=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?Urt(s,t):Hrt(s,(t.s=-t.s,t))};Qn.precision=Qn.sd=function(t){var s,r,n,a=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(PS+t);if(s=Ud(a)+1,n=a.d.length-1,r=n*Ql+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};Qn.squareRoot=Qn.sqrt=function(){var t,s,r,n,a,o,l,i=this,d=i.constructor;if(i.s<1){if(!i.s)return new d(0);throw Error(Ex+"NaN")}for(t=Ud(i),vc=!1,a=Math.sqrt(+i),a==0||a==1/0?(s=Hy(i.d),(s.length+t)%2==0&&(s+="0"),a=Math.sqrt(s),t=yE((t+1)/2)-(t<0||t%2),a==1/0?s="5e"+t:(s=a.toExponential(),s=s.slice(0,s.indexOf("e")+1)+t),n=new d(s)):n=new d(a.toString()),r=d.precision,a=l=r+3;;)if(o=n,n=o.plus(a1(i,o,l+2)).times(.5),Hy(o.d).slice(0,l)===(s=Hy(n.d)).slice(0,l)){if(s=s.slice(l-3,l+1),a==l&&s=="4999"){if(jl(o,r+1,0),o.times(o).eq(i)){n=o;break}}else if(s!="9999")break;l+=4}return vc=!0,jl(n,r)};Qn.times=Qn.mul=function(t){var s,r,n,a,o,l,i,d,u,p=this,f=p.constructor,y=p.d,_=(t=new f(t)).d;if(!p.s||!t.s)return new f(0);for(t.s*=p.s,r=p.e+t.e,d=y.length,u=_.length,d=0;){for(s=0,a=d+n;a>n;)i=o[a]+_[n]*y[a-n-1]+s,o[a--]=i%Pu|0,s=i/Pu|0;o[a]=(o[a]+s)%Pu|0}for(;!o[--l];)o.pop();return s?++r:o.shift(),t.d=o,t.e=r,vc?jl(t,f.precision):t};Qn.toDecimalPlaces=Qn.todp=function(t,s){var r=this,n=r.constructor;return r=new n(r),t===void 0?r:(y0(t,0,gE),s===void 0?s=n.rounding:y0(s,0,8),jl(r,t+Ud(r)+1,s))};Qn.toExponential=function(t,s){var r,n=this,a=n.constructor;return t===void 0?r=dC(n,!0):(y0(t,0,gE),s===void 0?s=a.rounding:y0(s,0,8),n=jl(new a(n),t+1,s),r=dC(n,!0,t+1)),r};Qn.toFixed=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?dC(a):(y0(t,0,gE),s===void 0?s=o.rounding:y0(s,0,8),n=jl(new o(a),t+Ud(a)+1,s),r=dC(n.abs(),!1,t+Ud(n)+1),a.isneg()&&!a.isZero()?"-"+r:r)};Qn.toInteger=Qn.toint=function(){var t=this,s=t.constructor;return jl(new s(t),Ud(t)+1,s.rounding)};Qn.toNumber=function(){return+this};Qn.toPower=Qn.pow=function(t){var s,r,n,a,o,l,i=this,d=i.constructor,u=12,p=+(t=new d(t));if(!t.s)return new d(ef);if(i=new d(i),!i.s){if(t.s<1)throw Error(Ex+"Infinity");return i}if(i.eq(ef))return i;if(n=d.precision,t.eq(ef))return jl(i,n);if(s=t.e,r=t.d.length-1,l=s>=r,o=i.s,l){if((r=p<0?-p:p)<=qrt){for(a=new d(ef),s=Math.ceil(n/Ql+4),vc=!1;r%2&&(a=a.times(i),AOe(a.d,s)),r=yE(r/2),r!==0;)i=i.times(i),AOe(i.d,s);return vc=!0,t.s<0?new d(ef).div(a):jl(a,n)}}else if(o<0)throw Error(Ex+"NaN");return o=o<0&&t.d[Math.max(s,r)]&1?-1:1,i.s=1,vc=!1,a=t.times(BD(i,n+u)),vc=!0,a=Vrt(a),a.s=o,a};Qn.toPrecision=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?(r=Ud(a),n=dC(a,r<=o.toExpNeg||r>=o.toExpPos)):(y0(t,1,gE),s===void 0?s=o.rounding:y0(s,0,8),a=jl(new o(a),t,s),r=Ud(a),n=dC(a,t<=r||r<=o.toExpNeg,t)),n};Qn.toSignificantDigits=Qn.tosd=function(t,s){var r=this,n=r.constructor;return t===void 0?(t=n.precision,s=n.rounding):(y0(t,1,gE),s===void 0?s=n.rounding:y0(s,0,8)),jl(new n(r),t,s)};Qn.toString=Qn.valueOf=Qn.val=Qn.toJSON=Qn[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,s=Ud(t),r=t.constructor;return dC(t,s<=r.toExpNeg||s>=r.toExpPos)};function Urt(t,s){var r,n,a,o,l,i,d,u,p=t.constructor,f=p.precision;if(!t.s||!s.s)return s.s||(s=new p(t)),vc?jl(s,f):s;if(d=t.d,u=s.d,l=t.e,a=s.e,d=d.slice(),o=l-a,o){for(o<0?(n=d,o=-o,i=u.length):(n=u,a=l,i=d.length),l=Math.ceil(f/Ql),i=l>i?l+1:i+1,o>i&&(o=i,n.length=1),n.reverse();o--;)n.push(0);n.reverse()}for(i=d.length,o=u.length,i-o<0&&(o=i,n=u,u=d,d=n),r=0;o;)r=(d[--o]=d[o]+u[o]+r)/Pu|0,d[o]%=Pu;for(r&&(d.unshift(r),++a),i=d.length;d[--i]==0;)d.pop();return s.d=d,s.e=a,vc?jl(s,f):s}function y0(t,s,r){if(t!==~~t||tr)throw Error(PS+t)}function Hy(t){var s,r,n,a=t.length-1,o="",l=t[0];if(a>0){for(o+=l,s=1;sl?1:-1;else for(i=d=0;ia[i]?1:-1;break}return d}function r(n,a,o){for(var l=0;o--;)n[o]-=l,l=n[o]1;)n.shift()}return function(n,a,o,l){var i,d,u,p,f,y,_,b,N,w,S,C,A,I,L,O,V,q,B=n.constructor,U=n.s==a.s?1:-1,te=n.d,Y=a.d;if(!n.s)return new B(n);if(!a.s)throw Error(Ex+"Division by zero");for(d=n.e-a.e,V=Y.length,L=te.length,_=new B(U),b=_.d=[],u=0;Y[u]==(te[u]||0);)++u;if(Y[u]>(te[u]||0)&&--d,o==null?C=o=B.precision:l?C=o+(Ud(n)-Ud(a))+1:C=o,C<0)return new B(0);if(C=C/Ql+2|0,u=0,V==1)for(p=0,Y=Y[0],C++;(u1&&(Y=t(Y,p),te=t(te,p),V=Y.length,L=te.length),I=V,N=te.slice(0,V),w=N.length;w=Pu/2&&++O;do p=0,i=s(Y,N,V,w),i<0?(S=N[0],V!=w&&(S=S*Pu+(N[1]||0)),p=S/O|0,p>1?(p>=Pu&&(p=Pu-1),f=t(Y,p),y=f.length,w=N.length,i=s(f,N,y,w),i==1&&(p--,r(f,V16)throw Error(bSe+Ud(t));if(!t.s)return new p(ef);for(s==null?(vc=!1,i=f):i=s,l=new p(.03125);t.abs().gte(.1);)t=t.times(l),u+=5;for(n=Math.log(o4(2,u))/Math.LN10*2+5|0,i+=n,r=a=o=new p(ef),p.precision=i;;){if(a=jl(a.times(t),i),r=r.times(++d),l=o.plus(a1(a,r,i)),Hy(l.d).slice(0,i)===Hy(o.d).slice(0,i)){for(;u--;)o=jl(o.times(o),i);return p.precision=f,s==null?(vc=!0,jl(o,f)):o}o=l}}function Ud(t){for(var s=t.e*Ql,r=t.d[0];r>=10;r/=10)s++;return s}function Qye(t,s,r){if(s>t.LN10.sd())throw vc=!0,r&&(t.precision=r),Error(Ex+"LN10 precision limit exceeded");return jl(new t(t.LN10),s)}function B_(t){for(var s="";t--;)s+="0";return s}function BD(t,s){var r,n,a,o,l,i,d,u,p,f=1,y=10,_=t,b=_.d,N=_.constructor,w=N.precision;if(_.s<1)throw Error(Ex+(_.s?"NaN":"-Infinity"));if(_.eq(ef))return new N(0);if(s==null?(vc=!1,u=w):u=s,_.eq(10))return s==null&&(vc=!0),Qye(N,u);if(u+=y,N.precision=u,r=Hy(b),n=r.charAt(0),o=Ud(_),Math.abs(o)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)_=_.times(t),r=Hy(_.d),n=r.charAt(0),f++;o=Ud(_),n>1?(_=new N("0."+r),o++):_=new N(n+"."+r.slice(1))}else return d=Qye(N,u+2,w).times(o+""),_=BD(new N(n+"."+r.slice(1)),u-y).plus(d),N.precision=w,s==null?(vc=!0,jl(_,w)):_;for(i=l=_=a1(_.minus(ef),_.plus(ef),u),p=jl(_.times(_),u),a=3;;){if(l=jl(l.times(p),u),d=i.plus(a1(l,new N(a),u)),Hy(d.d).slice(0,u)===Hy(i.d).slice(0,u))return i=i.times(2),o!==0&&(i=i.plus(Qye(N,u+2,w).times(o+""))),i=a1(i,new N(f),u),N.precision=w,s==null?(vc=!0,jl(i,w)):i;i=d,a+=2}}function TOe(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=yE(r/Ql),t.d=[],n=(r+1)%Ql,r<0&&(n+=Ql),nGce||t.e<-Gce))throw Error(bSe+r)}else t.s=0,t.e=0,t.d=[0];return t}function jl(t,s,r){var n,a,o,l,i,d,u,p,f=t.d;for(l=1,o=f[0];o>=10;o/=10)l++;if(n=s-l,n<0)n+=Ql,a=s,u=f[p=0];else{if(p=Math.ceil((n+1)/Ql),o=f.length,p>=o)return t;for(u=o=f[p],l=1;o>=10;o/=10)l++;n%=Ql,a=n-Ql+l}if(r!==void 0&&(o=o4(10,l-a-1),i=u/o%10|0,d=s<0||f[p+1]!==void 0||u%o,d=r<4?(i||d)&&(r==0||r==(t.s<0?3:2)):i>5||i==5&&(r==4||d||r==6&&(n>0?a>0?u/o4(10,l-a):0:f[p-1])%10&1||r==(t.s<0?8:7))),s<1||!f[0])return d?(o=Ud(t),f.length=1,s=s-o-1,f[0]=o4(10,(Ql-s%Ql)%Ql),t.e=yE(-s/Ql)||0):(f.length=1,f[0]=t.e=t.s=0),t;if(n==0?(f.length=p,o=1,p--):(f.length=p+1,o=o4(10,Ql-n),f[p]=a>0?(u/o4(10,l-a)%o4(10,a)|0)*o:0),d)for(;;)if(p==0){(f[0]+=o)==Pu&&(f[0]=1,++t.e);break}else{if(f[p]+=o,f[p]!=Pu)break;f[p--]=0,o=1}for(n=f.length;f[--n]===0;)f.pop();if(vc&&(t.e>Gce||t.e<-Gce))throw Error(bSe+Ud(t));return t}function Hrt(t,s){var r,n,a,o,l,i,d,u,p,f,y=t.constructor,_=y.precision;if(!t.s||!s.s)return s.s?s.s=-s.s:s=new y(t),vc?jl(s,_):s;if(d=t.d,f=s.d,n=s.e,u=t.e,d=d.slice(),l=u-n,l){for(p=l<0,p?(r=d,l=-l,i=f.length):(r=f,n=u,i=d.length),a=Math.max(Math.ceil(_/Ql),i)+2,l>a&&(l=a,r.length=1),r.reverse(),a=l;a--;)r.push(0);r.reverse()}else{for(a=d.length,i=f.length,p=a0;--a)d[i++]=0;for(a=f.length;a>l;){if(d[--a]0?o=o.charAt(0)+"."+o.slice(1)+B_(n):l>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(a<0?"e":"e+")+a):a<0?(o="0."+B_(-a-1)+o,r&&(n=r-l)>0&&(o+=B_(n))):a>=l?(o+=B_(a+1-l),r&&(n=r-a-1)>0&&(o=o+"."+B_(n))):((n=a+1)0&&(a+1===l&&(o+="."),o+=B_(n))),t.s<0?"-"+o:o}function AOe(t,s){if(t.length>s)return t.length=s,!0}function Grt(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(PS+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 TOe(l,o.toString())}else if(typeof o!="string")throw Error(PS+o);if(o.charCodeAt(0)===45?(o=o.slice(1),l.s=-1):l.s=1,bds.test(o))TOe(l,o);else throw Error(PS+o)}if(a.prototype=Qn,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=Grt,a.config=a.set=wds,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(PS+r+": "+n);if((n=t[r="LN10"])!==void 0)if(n==Math.LN10)this[r]=new this(n);else throw Error(PS+r+": "+n);return this}var wSe=Grt(_ds);ef=new wSe(1);const nl=wSe;function jds(t){return Cds(t)||Sds(t)||kds(t)||Nds()}function Nds(){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 kds(t,s){if(t){if(typeof t=="string")return Dbe(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 Dbe(t,s)}}function Sds(t){if(typeof Symbol<"u"&&Symbol.iterator in Object(t))return Array.from(t)}function Cds(t){if(Array.isArray(t))return Dbe(t)}function Dbe(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,EOe(function(){for(var i=arguments.length,d=new Array(i),u=0;ut.length)&&(s=t.length);for(var r=0,n=new Array(s);r"u"||!(Symbol.iterator in Object(t)))){var r=[],n=!0,a=!1,o=void 0;try{for(var l=t[Symbol.iterator](),i;!(n=(i=l.next()).done)&&(r.push(i.value),!(s&&r.length===s));n=!0);}catch(d){a=!0,o=d}finally{try{!n&&l.return!=null&&l.return()}finally{if(a)throw o}}return r}}function qds(t){if(Array.isArray(t))return t}function Xrt(t){var s=$D(t,2),r=s[0],n=s[1],a=r,o=n;return r>n&&(a=n,o=r),[a,o]}function Qrt(t,s,r){if(t.lte(0))return new nl(0);var n=ume.getDigitCount(t.toNumber()),a=new nl(10).pow(n),o=t.div(a),l=n!==1?.05:.1,i=new nl(Math.ceil(o.div(l).toNumber())).add(r).mul(l),d=i.mul(a);return s?d:new nl(Math.ceil(d))}function Uds(t,s,r){var n=1,a=new nl(t);if(!a.isint()&&r){var o=Math.abs(t);o<1?(n=new nl(10).pow(ume.getDigitCount(t)-1),a=new nl(Math.floor(a.div(n).toNumber())).mul(n)):o>1&&(a=new nl(Math.floor(t)))}else t===0?a=new nl(Math.floor((s-1)/2)):r||(a=new nl(Math.floor(t)));var l=Math.floor((s-1)/2),i=Eds(Ads(function(d){return a.add(new nl(d-l).mul(n)).toNumber()}),Rbe);return i(0,s)}function Jrt(t,s,r,n){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((s-t)/(r-1)))return{step:new nl(0),tickMin:new nl(0),tickMax:new nl(0)};var o=Qrt(new nl(s).sub(t).div(r-1),n,a),l;t<=0&&s>=0?l=new nl(0):(l=new nl(t).add(s).div(2),l=l.sub(new nl(l).mod(o)));var i=Math.ceil(l.sub(t).div(o).toNumber()),d=Math.ceil(new nl(s).sub(l).div(o).toNumber()),u=i+d+1;return u>r?Jrt(t,s,r,n,a+1):(u0?d+(r-u):d,i=s>0?i:i+(r-u)),{step:o,tickMin:l.sub(new nl(i).mul(o)),tickMax:l.add(new nl(d).mul(o))})}function Vds(t){var s=$D(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=Xrt([r,n]),d=$D(i,2),u=d[0],p=d[1];if(u===-1/0||p===1/0){var f=p===1/0?[u].concat(Fbe(Rbe(0,a-1).map(function(){return 1/0}))):[].concat(Fbe(Rbe(0,a-1).map(function(){return-1/0})),[p]);return r>n?Obe(f):f}if(u===p)return Uds(u,a,o);var y=Jrt(u,p,l,o),_=y.step,b=y.tickMin,N=y.tickMax,w=ume.rangeStep(b,N.add(new nl(.1).mul(_)),_);return r>n?Obe(w):w}function Hds(t,s){var r=$D(t,2),n=r[0],a=r[1],o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,l=Xrt([n,a]),i=$D(l,2),d=i[0],u=i[1];if(d===-1/0||u===1/0)return[n,a];if(d===u)return[d];var p=Math.max(s,2),f=Qrt(new nl(u).sub(d).div(p-1),o,0),y=[].concat(Fbe(ume.rangeStep(new nl(d),new nl(u).sub(new nl(.99).mul(f)),f)),[u]);return n>a?Obe(y):y}var Gds=Zrt(Vds),Wds=Zrt(Hds),Kds="Invariant failed";function uC(t,s){throw new Error(Kds)}var Zds=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];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 Wce(){return Wce=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 sus(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 rus(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function nus(t,s){for(var r=0;rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r1&&arguments[1]!==void 0?arguments[1]:[],a=arguments.length>2?arguments[2]:void 0,o=arguments.length>3?arguments[3]:void 0,l=-1,i=(r=n==null?void 0:n.length)!==null&&r!==void 0?r:0;if(i<=1)return 0;if(o&&o.axisType==="angleAxis"&&Math.abs(Math.abs(o.range[1]-o.range[0])-360)<=1e-6)for(var d=o.range,u=0;u0?a[u-1].coordinate:a[i-1].coordinate,f=a[u].coordinate,y=u>=i-1?a[0].coordinate:a[u+1].coordinate,_=void 0;if(wm(f-p)!==wm(y-f)){var b=[];if(wm(y-f)===wm(d[1]-d[0])){_=y;var N=f+d[1]-d[0];b[0]=Math.min(N,(N+p)/2),b[1]=Math.max(N,(N+p)/2)}else{_=p;var w=y+d[1]-d[0];b[0]=Math.min(f,(w+f)/2),b[1]=Math.max(f,(w+f)/2)}var S=[Math.min(f,(_+f)/2),Math.max(f,(_+f)/2)];if(s>S[0]&&s<=S[1]||s>=b[0]&&s<=b[1]){l=a[u].index;break}}else{var C=Math.min(p,y),A=Math.max(p,y);if(s>(C+f)/2&&s<=(A+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},jSe=function(s){var r,n=s,a=n.type.displayName,o=(r=s.type)!==null&&r!==void 0&&r.defaultProps?Yc(Yc({},s.type.defaultProps),s.props):s.props,l=o.stroke,i=o.fill,d;switch(a){case"Line":d=l;break;case"Area":case"Radar":d=l&&l!=="none"?l:i;break;default:d=i;break}return d},bus=function(s){var r=s.barSize,n=s.totalSize,a=s.stackGroups,o=a===void 0?{}:a;if(!o)return{};for(var l={},i=Object.keys(o),d=0,u=i.length;d=0});if(S&&S.length){var C=S[0].type.defaultProps,A=C!==void 0?Yc(Yc({},C),S[0].props):S[0].props,I=A.barSize,L=A[w];l[L]||(l[L]=[]);var O=vi(I)?r:I;l[L].push({item:S[0],stackList:S.slice(1),barSize:vi(O)?void 0:jm(O,n,0)})}}return l},wus=function(s){var r=s.barGap,n=s.barCategoryGap,a=s.bandSize,o=s.sizeList,l=o===void 0?[]:o,i=s.maxBarSize,d=l.length;if(d<1)return null;var u=jm(r,a,0,!0),p,f=[];if(l[0].barSize===+l[0].barSize){var y=!1,_=a/d,b=l.reduce(function(I,L){return I+L.barSize||0},0);b+=(d-1)*u,b>=a&&(b-=(d-1)*u,u=0),b>=a&&_>0&&(y=!0,_*=.9,b=d*_);var N=(a-b)/2>>0,w={offset:N-u,size:0};p=l.reduce(function(I,L){var O={item:L.item,position:{offset:w.offset+w.size+u,size:y?_:L.barSize}},V=[].concat(LOe(I),[O]);return w=V[V.length-1].position,L.stackList&&L.stackList.length&&L.stackList.forEach(function(q){V.push({item:q,position:w})}),V},f)}else{var S=jm(n,a,0,!0);a-2*S-(d-1)*u<=0&&(u=0);var C=(a-2*S-(d-1)*u)/d;C>1&&(C>>=0);var A=i===+i?Math.min(C,i):C;p=l.reduce(function(I,L,O){var V=[].concat(LOe(I),[{item:L.item,position:{offset:S+(C+u)*O+(C-A)/2,size:A}}]);return L.stackList&&L.stackList.length&&L.stackList.forEach(function(q){V.push({item:q,position:V[V.length-1].position})}),V},f)}return p},jus=function(s,r,n,a){var o=n.children,l=n.width,i=n.margin,d=l-(i.left||0)-(i.right||0),u=rnt({children:o,legendWidth:d});if(u){var p=a||{},f=p.width,y=p.height,_=u.align,b=u.verticalAlign,N=u.layout;if((N==="vertical"||N==="horizontal"&&b==="middle")&&_!=="center"&&sn(s[_]))return Yc(Yc({},s),{},rT({},_,s[_]+(f||0)));if((N==="horizontal"||N==="vertical"&&_==="center")&&b!=="middle"&&sn(s[b]))return Yc(Yc({},s),{},rT({},b,s[b]+(y||0)))}return s},Nus=function(s,r,n){return vi(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=mf(l,yO).filter(function(u){return Nus(a,o,u.props.direction)});if(i&&i.length){var d=i.map(function(u){return u.props.dataKey});return s.reduce(function(u,p){var f=ou(p,n);if(vi(f))return u;var y=Array.isArray(f)?[cme(f),lme(f)]:[f,f],_=d.reduce(function(b,N){var w=ou(p,N,0),S=y[0]-Math.abs(Array.isArray(w)?w[0]:w),C=y[1]+Math.abs(Array.isArray(w)?w[1]:w);return[Math.min(S,b[0]),Math.max(C,b[1])]},[1/0,-1/0]);return[Math.min(_[0],u[0]),Math.max(_[1],u[1])]},[1/0,-1/0])}return null},kus=function(s,r,n,a,o){var l=r.map(function(i){return nnt(s,i,n,o,a)}).filter(function(i){return!vi(i)});return l&&l.length?l.reduce(function(i,d){return[Math.min(i[0],d[0]),Math.max(i[1],d[1])]},[1/0,-1/0]):null},ant=function(s,r,n,a,o){var l=r.map(function(d){var u=d.props.dataKey;return n==="number"&&u&&nnt(s,d,u,a)||j8(s,u,n,o)});if(n==="number")return l.reduce(function(d,u){return[Math.min(d[0],u[0]),Math.max(d[1],u[1])]},[1/0,-1/0]);var i={};return l.reduce(function(d,u){for(var p=0,f=u.length;p=2?wm(i[0]-i[1])*2*u:u,r&&(s.ticks||s.niceTicks)){var p=(s.ticks||s.niceTicks).map(function(f){var y=o?o.indexOf(f):f;return{coordinate:a(y)+u,value:f,offset:u}});return p.filter(function(f){return!dO(f.coordinate)})}return s.isCategorical&&s.categoricalDomain?s.categoricalDomain.map(function(f,y){return{coordinate:a(f)+u,value:f,index:y,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,y){return{coordinate:a(f)+u,value:o?o[f]:f,index:y,offset:u}})},Jye=new WeakMap,h9=function(s,r){if(typeof r!="function")return s;Jye.has(s)||Jye.set(s,new WeakMap);var n=Jye.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},lnt=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:DD(),realScaleType:"band"}:l==="radial"&&i==="angleAxis"?{scale:qce(),realScaleType:"linear"}:o==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?{scale:w8(),realScaleType:"point"}:o==="category"?{scale:DD(),realScaleType:"band"}:{scale:qce(),realScaleType:"linear"};if(oC(a)){var d="scale".concat(Khe(a));return{scale:(MOe[d]||w8)(),realScaleType:MOe[d]?d:"point"}}return di(a)?{scale:a}:{scale:w8(),realScaleType:"point"}},ROe=1e-4,cnt=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])-ROe,l=Math.max(a[0],a[1])+ROe,i=s(r[0]),d=s(r[n-1]);(il||dl)&&s.domain([r[0],r[n-1]])}},Sus=function(s,r){if(!s)return null;for(var n=0,a=s.length;na)&&(o[1]=a),o[0]>a&&(o[0]=a),o[1]=0?(s[i][n][0]=o,s[i][n][1]=o+d,o=s[i][n][1]):(s[i][n][0]=l,s[i][n][1]=l+d,l=s[i][n][1])}},Tus=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)}},Aus={sign:Mus,expand:ZXt,none:WT,silhouette:YXt,wiggle:XXt,positive:Tus},Eus=function(s,r,n){var a=r.map(function(i){return i.props.dataKey}),o=Aus[n],l=KXt().keys(a).value(function(i,d){return+ou(i,d,0)}).order(hbe).offset(o);return l(s)},Pus=function(s,r,n,a,o,l){if(!s)return null;var i=l?r.reverse():r,d={},u=i.reduce(function(f,y){var _,b=(_=y.type)!==null&&_!==void 0&&_.defaultProps?Yc(Yc({},y.type.defaultProps),y.props):y.props,N=b.stackId,w=b.hide;if(w)return f;var S=b[n],C=f[S]||{hasStack:!1,stackGroups:{}};if(cu(N)){var A=C.stackGroups[N]||{numericAxisId:n,cateAxisId:a,items:[]};A.items.push(y),C.hasStack=!0,C.stackGroups[N]=A}else C.stackGroups[hE("_stackId_")]={numericAxisId:n,cateAxisId:a,items:[y]};return Yc(Yc({},f),{},rT({},S,C))},d),p={};return Object.keys(u).reduce(function(f,y){var _=u[y];if(_.hasStack){var b={};_.stackGroups=Object.keys(_.stackGroups).reduce(function(N,w){var S=_.stackGroups[w];return Yc(Yc({},N),{},rT({},w,{numericAxisId:n,cateAxisId:a,items:S.items,stackedData:Eus(s,S.items,o)}))},b)}return Yc(Yc({},f),{},rT({},y,_))},p)},dnt=function(s,r){var n=r.realScaleType,a=r.type,o=r.tickCount,l=r.originalDomain,i=r.allowDecimals,d=n||r.scale;if(d!=="auto"&&d!=="linear")return null;if(o&&a==="number"&&l&&(l[0]==="auto"||l[1]==="auto")){var u=s.domain();if(!u.length)return null;var p=Gds(u,o,i);return s.domain([cme(p),lme(p)]),{niceTicks:p}}if(o&&a==="number"){var f=s.domain(),y=Wds(f,o,i);return{niceTicks:y}}return null};function OOe(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&&!vi(a[s.dataKey])){var i=bce(r,"value",a[s.dataKey]);if(i)return i.coordinate+n/2}return r[o]?r[o].coordinate+n/2:null}var d=ou(a,vi(l)?s.dataKey:l);return vi(d)?null:s.scale(d)}var FOe=function(s){var r=s.axis,n=s.ticks,a=s.offset,o=s.bandSize,l=s.entry,i=s.index;if(r.type==="category")return n[i]?n[i].coordinate+a:null;var d=ou(l,r.dataKey,r.domain[i]);return vi(d)?null:r.scale(d)-o/2+a},Ius=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]},Lus=function(s,r){var n,a=(n=s.type)!==null&&n!==void 0&&n.defaultProps?Yc(Yc({},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},Dus=function(s){return s.reduce(function(r,n){return[cme(n.concat([r[0]]).filter(sn)),lme(n.concat([r[1]]).filter(sn))]},[1/0,-1/0])},unt=function(s,r,n){return Object.keys(s).reduce(function(a,o){var l=s[o],i=l.stackedData,d=i.reduce(function(u,p){var f=Dus(p.slice(r,n+1));return[Math.min(u[0],f[0]),Math.max(u[1],f[1])]},[1/0,-1/0]);return[Math.min(d[0],a[0]),Math.max(d[1],a[1])]},[1/0,-1/0]).map(function(a){return a===1/0||a===-1/0?0:a})},zOe=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,BOe=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,qbe=function(s,r,n){if(di(s))return s(r,n);if(!Array.isArray(s))return r;var a=[];if(sn(s[0]))a[0]=n?s[0]:Math.min(s[0],r[0]);else if(zOe.test(s[0])){var o=+zOe.exec(s[0])[1];a[0]=r[0]-o}else di(s[0])?a[0]=s[0](r[0]):a[0]=r[0];if(sn(s[1]))a[1]=n?s[1]:Math.max(s[1],r[1]);else if(BOe.test(s[1])){var l=+BOe.exec(s[1])[1];a[1]=r[1]+l}else di(s[1])?a[1]=s[1](r[1]):a[1]=r[1];return a},Zce=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=X4e(r,function(f){return f.coordinate}),l=1/0,i=1,d=o.length;it.length)&&(s=t.length);for(var r=0,n=new Array(s);r2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(s-(n.left||0)-(n.right||0)),Math.abs(r-(n.top||0)-(n.bottom||0)))/2},Vus=function(s,r,n,a,o){var l=s.width,i=s.height,d=s.startAngle,u=s.endAngle,p=jm(s.cx,l,l/2),f=jm(s.cy,i,i/2),y=pnt(l,i,n),_=jm(s.innerRadius,y,0),b=jm(s.outerRadius,y,y*.8),N=Object.keys(r);return N.reduce(function(w,S){var C=r[S],A=C.domain,I=C.reversed,L;if(vi(C.range))a==="angleAxis"?L=[d,u]:a==="radiusAxis"&&(L=[_,b]),I&&(L=[L[1],L[0]]);else{L=C.range;var O=L,V=Fus(O,2);d=V[0],u=V[1]}var q=lnt(C,o),B=q.realScaleType,U=q.scale;U.domain(A).range(L),cnt(U);var te=dnt(U,Sv(Sv({},C),{},{realScaleType:B})),Y=Sv(Sv(Sv({},C),te),{},{range:L,radius:b,realScaleType:B,scale:U,cx:p,cy:f,innerRadius:_,outerRadius:b,startAngle:d,endAngle:u});return Sv(Sv({},w),{},mnt({},S,Y))},{})},Hus=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))},Gus=function(s,r){var n=s.x,a=s.y,o=r.cx,l=r.cy,i=Hus({x:n,y:a},{x:o,y:l});if(i<=0)return{radius:i};var d=(n-o)/i,u=Math.acos(d);return a>l&&(u=2*Math.PI-u),{radius:i,angle:Uus(u),angleInRadian:u}},Wus=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}},Kus=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},VOe=function(s,r){var n=s.x,a=s.y,o=Gus({x:n,y:a},r),l=o.radius,i=o.angle,d=r.innerRadius,u=r.outerRadius;if(lu)return!1;if(l===0)return!0;var p=Wus(r),f=p.startAngle,y=p.endAngle,_=i,b;if(f<=y){for(;_>y;)_-=360;for(;_=f&&_<=y}else{for(;_>f;)_-=360;for(;_=y&&_<=f}return b?Sv(Sv({},r),{},{radius:l,angle:Kus(_,r)}):null},fnt=function(s){return!k.isValidElement(s)&&!di(s)&&typeof s!="boolean"?s.className:""};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)}var Zus=["offset"];function Yus(t){return ehs(t)||Jus(t)||Qus(t)||Xus()}function Xus(){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 Qus(t,s){if(t){if(typeof t=="string")return Ube(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 Ube(t,s)}}function Jus(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function ehs(t){if(Array.isArray(t))return Ube(t)}function Ube(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 shs(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 HOe(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 Jd(t){for(var s=1;s=0?1:-1,A,I;a==="insideStart"?(A=_+C*l,I=N):a==="insideEnd"?(A=b-C*l,I=!N):a==="end"&&(A=b+C*l,I=N),I=S<=0?I:!I;var L=Ol(u,p,w,A),O=Ol(u,p,w,A+(I?1:-1)*359),V="M".concat(L.x,",").concat(L.y,` A`).concat(w,",").concat(w,",0,1,").concat(I?0:1,`, `).concat(O.x,",").concat(O.y),q=vi(s.id)?hE("recharts-radial-line-"):s.id;return xt.createElement("text",GD({},n,{dominantBaseline:"central",className:bi("recharts-radial-bar-label",i)}),xt.createElement("defs",null,xt.createElement("path",{id:q,d:V})),xt.createElement("textPath",{xlinkHref:"#".concat(q)},r))},chs=function(s){var r=s.viewBox,n=s.offset,a=s.position,o=r,l=o.cx,i=o.cy,d=o.innerRadius,u=o.outerRadius,p=o.startAngle,f=o.endAngle,y=(p+f)/2;if(a==="outside"){var _=Ol(l,i,u+n,y),b=_.x,N=_.y;return{x:b,y:N,textAnchor:b>=l?"start":"end",verticalAnchor:"middle"}}if(a==="center")return{x:l,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(a==="centerTop")return{x:l,y:i,textAnchor:"middle",verticalAnchor:"start"};if(a==="centerBottom")return{x:l,y:i,textAnchor:"middle",verticalAnchor:"end"};var w=(d+u)/2,S=Ol(l,i,w,y),C=S.x,A=S.y;return{x:C,y:A,textAnchor:"middle",verticalAnchor:"middle"}},dhs=function(s){var r=s.viewBox,n=s.parentViewBox,a=s.offset,o=s.position,l=r,i=l.x,d=l.y,u=l.width,p=l.height,f=p>=0?1:-1,y=f*a,_=f>0?"end":"start",b=f>0?"start":"end",N=u>=0?1:-1,w=N*a,S=N>0?"end":"start",C=N>0?"start":"end";if(o==="top"){var A={x:i+u/2,y:d-f*a,textAnchor:"middle",verticalAnchor:_};return Jd(Jd({},A),n?{height:Math.max(d-n.y,0),width:u}:{})}if(o==="bottom"){var I={x:i+u/2,y:d+p+y,textAnchor:"middle",verticalAnchor:b};return Jd(Jd({},I),n?{height:Math.max(n.y+n.height-(d+p),0),width:u}:{})}if(o==="left"){var L={x:i-w,y:d+p/2,textAnchor:S,verticalAnchor:"middle"};return Jd(Jd({},L),n?{width:Math.max(L.x-n.x,0),height:p}:{})}if(o==="right"){var O={x:i+u+w,y:d+p/2,textAnchor:C,verticalAnchor:"middle"};return Jd(Jd({},O),n?{width:Math.max(n.x+n.width-O.x,0),height:p}:{})}var V=n?{width:u,height:p}:{};return o==="insideLeft"?Jd({x:i+w,y:d+p/2,textAnchor:C,verticalAnchor:"middle"},V):o==="insideRight"?Jd({x:i+u-w,y:d+p/2,textAnchor:S,verticalAnchor:"middle"},V):o==="insideTop"?Jd({x:i+u/2,y:d+y,textAnchor:"middle",verticalAnchor:b},V):o==="insideBottom"?Jd({x:i+u/2,y:d+p-y,textAnchor:"middle",verticalAnchor:_},V):o==="insideTopLeft"?Jd({x:i+w,y:d+y,textAnchor:C,verticalAnchor:b},V):o==="insideTopRight"?Jd({x:i+u-w,y:d+y,textAnchor:S,verticalAnchor:b},V):o==="insideBottomLeft"?Jd({x:i+w,y:d+p-y,textAnchor:C,verticalAnchor:_},V):o==="insideBottomRight"?Jd({x:i+u-w,y:d+p-y,textAnchor:S,verticalAnchor:_},V):lE(o)&&(sn(o.x)||k4(o.x))&&(sn(o.y)||k4(o.y))?Jd({x:i+jm(o.x,u),y:d+jm(o.y,p),textAnchor:"end",verticalAnchor:"end"},V):Jd({x:i+u/2,y:d+p/2,textAnchor:"middle",verticalAnchor:"middle"},V)},uhs=function(s){return"cx"in s&&sn(s.cx)};function Ru(t){var s=t.offset,r=s===void 0?5:s,n=ths(t,Zus),a=Jd({offset:r},n),o=a.viewBox,l=a.position,i=a.value,d=a.children,u=a.content,p=a.className,f=p===void 0?"":p,y=a.textBreakAll;if(!o||vi(i)&&vi(d)&&!k.isValidElement(u)&&!di(u))return null;if(k.isValidElement(u))return k.cloneElement(u,a);var _;if(di(u)){if(_=k.createElement(u,a),k.isValidElement(_))return _}else _=ihs(a);var b=uhs(o),N=Ua(a,!0);if(b&&(l==="insideStart"||l==="insideEnd"||l==="end"))return lhs(a,_,N);var w=b?chs(a):dhs(a);return xt.createElement(cC,GD({className:bi("recharts-label",f)},N,w,{breakAll:y}),_)}Ru.displayName="Label";var xnt=function(s){var r=s.cx,n=s.cy,a=s.angle,o=s.startAngle,l=s.endAngle,i=s.r,d=s.radius,u=s.innerRadius,p=s.outerRadius,f=s.x,y=s.y,_=s.top,b=s.left,N=s.width,w=s.height,S=s.clockWise,C=s.labelViewBox;if(C)return C;if(sn(N)&&sn(w)){if(sn(f)&&sn(y))return{x:f,y,width:N,height:w};if(sn(_)&&sn(b))return{x:_,y:b,width:N,height:w}}return sn(f)&&sn(y)?{x:f,y,width:0,height:0}:sn(r)&&sn(n)?{cx:r,cy:n,startAngle:o||a||0,endAngle:l||a||0,innerRadius:u||0,outerRadius:p||d||i||0,clockWise:S}:s.viewBox?s.viewBox:{}},hhs=function(s,r){return s?s===!0?xt.createElement(Ru,{key:"label-implicit",viewBox:r}):cu(s)?xt.createElement(Ru,{key:"label-implicit",viewBox:r,value:s}):k.isValidElement(s)?s.type===Ru?k.cloneElement(s,{key:"label-implicit",viewBox:r}):xt.createElement(Ru,{key:"label-implicit",content:s,viewBox:r}):di(s)?xt.createElement(Ru,{key:"label-implicit",content:s,viewBox:r}):lE(s)?xt.createElement(Ru,GD({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=xnt(s),l=mf(a,Ru).map(function(d,u){return k.cloneElement(d,{viewBox:r||o,key:"label-".concat(u)})});if(!n)return l;var i=hhs(s.label,r||o);return[i].concat(Yus(l))};Ru.parseViewBox=xnt;Ru.renderCallByParent=mhs;function phs(t){var s=t==null?0:t.length;return s?t[s-1]:void 0}var fhs=phs;const xhs=ao(fhs);function WD(t){"@babel/helpers - typeof";return WD=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},WD(t)}var ghs=["valueAccessor"],yhs=["data","dataKey","clockWise","id","textBreakAll"];function vhs(t){return jhs(t)||whs(t)||bhs(t)||_hs()}function _hs(){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 bhs(t,s){if(t){if(typeof t=="string")return Vbe(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 Vbe(t,s)}}function whs(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function jhs(t){if(Array.isArray(t))return Vbe(t)}function Vbe(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 Chs(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 Mhs=function(s){return Array.isArray(s.value)?xhs(s.value):s.value};function i1(t){var s=t.valueAccessor,r=s===void 0?Mhs:s,n=KOe(t,ghs),a=n.data,o=n.dataKey,l=n.clockWise,i=n.id,d=n.textBreakAll,u=KOe(n,yhs);return!a||!a.length?null:xt.createElement(No,{className:"recharts-label-list"},a.map(function(p,f){var y=vi(o)?r(p,f):ou(p&&p.payload,o),_=vi(i)?{}:{id:"".concat(i,"-").concat(f)};return xt.createElement(Ru,Xce({},Ua(p,!0),u,_,{parentViewBox:p.parentViewBox,value:y,textBreakAll:d,viewBox:Ru.parseViewBox(vi(l)?p:WOe(WOe({},p),{},{clockWise:l})),key:"label-".concat(f),index:f}))}))}i1.displayName="LabelList";function Ths(t,s){return t?t===!0?xt.createElement(i1,{key:"labelList-implicit",data:s}):xt.isValidElement(t)||di(t)?xt.createElement(i1,{key:"labelList-implicit",data:s,content:t}):lE(t)?xt.createElement(i1,Xce({data:s},t,{key:"labelList-implicit"})):null:null}function Ahs(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=mf(n,i1).map(function(l,i){return k.cloneElement(l,{data:s,key:"labelList-".concat(i)})});if(!r)return a;var o=Ths(t.label,s);return[o].concat(vhs(a))}i1.renderCallByParent=Ahs;function KD(t){"@babel/helpers - typeof";return KD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},KD(t)}function Hbe(){return Hbe=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 _=Ol(r,n,a,l),b=Ol(r,n,a,u);y+="L ".concat(b.x,",").concat(b.y,` A `).concat(a,",").concat(a,`,0, `).concat(+(Math.abs(d)>180),",").concat(+(l<=u),`, `).concat(_.x,",").concat(_.y," Z")}else y+="L ".concat(r,",").concat(n," Z");return y},Dhs=function(s){var r=s.cx,n=s.cy,a=s.innerRadius,o=s.outerRadius,l=s.cornerRadius,i=s.forceCornerRadius,d=s.cornerIsExternal,u=s.startAngle,p=s.endAngle,f=wm(p-u),y=m9({cx:r,cy:n,radius:o,angle:u,sign:f,cornerRadius:l,cornerIsExternal:d}),_=y.circleTangency,b=y.lineTangency,N=y.theta,w=m9({cx:r,cy:n,radius:o,angle:p,sign:-f,cornerRadius:l,cornerIsExternal:d}),S=w.circleTangency,C=w.lineTangency,A=w.theta,I=d?Math.abs(u-p):Math.abs(u-p)-N-A;if(I<0)return i?"M ".concat(b.x,",").concat(b.y,` a`).concat(l,",").concat(l,",0,0,1,").concat(l*2,`,0 a`).concat(l,",").concat(l,",0,0,1,").concat(-l*2,`,0 `):gnt({cx:r,cy:n,innerRadius:a,outerRadius:o,startAngle:u,endAngle:p});var L="M ".concat(b.x,",").concat(b.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(_.x,",").concat(_.y,` A`).concat(o,",").concat(o,",0,").concat(+(I>180),",").concat(+(f<0),",").concat(S.x,",").concat(S.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(C.x,",").concat(C.y,` `);if(a>0){var O=m9({cx:r,cy:n,radius:a,angle:u,sign:f,isExternal:!0,cornerRadius:l,cornerIsExternal:d}),V=O.circleTangency,q=O.lineTangency,B=O.theta,U=m9({cx:r,cy:n,radius:a,angle:p,sign:-f,isExternal:!0,cornerRadius:l,cornerIsExternal:d}),te=U.circleTangency,Y=U.lineTangency,J=U.theta,X=d?Math.abs(u-p):Math.abs(u-p)-B-J;if(X<0&&l===0)return"".concat(L,"L").concat(r,",").concat(n,"Z");L+="L".concat(Y.x,",").concat(Y.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(te.x,",").concat(te.y,` A`).concat(a,",").concat(a,",0,").concat(+(X>180),",").concat(+(f>0),",").concat(V.x,",").concat(V.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(q.x,",").concat(q.y,"Z")}else L+="L".concat(r,",").concat(n,"Z");return L},Rhs={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},ynt=function(s){var r=YOe(YOe({},Rhs),s),n=r.cx,a=r.cy,o=r.innerRadius,l=r.outerRadius,i=r.cornerRadius,d=r.forceCornerRadius,u=r.cornerIsExternal,p=r.startAngle,f=r.endAngle,y=r.className;if(l0&&Math.abs(p-f)<360?w=Dhs({cx:n,cy:a,innerRadius:o,outerRadius:l,cornerRadius:Math.min(N,b/2),forceCornerRadius:d,cornerIsExternal:u,startAngle:p,endAngle:f}):w=gnt({cx:n,cy:a,innerRadius:o,outerRadius:l,startAngle:p,endAngle:f}),xt.createElement("path",Hbe({},Ua(r,!0),{className:_,d:w,role:"img"}))};function ZD(t){"@babel/helpers - typeof";return ZD=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},ZD(t)}function Gbe(){return Gbe=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 Xhs(t,s){return vE(t.getTime(),s.getTime())}function nFe(t,s,r){if(t.size!==s.size)return!1;for(var n={},a=t.entries(),o=0,l,i;(l=a.next())&&!l.done;){for(var d=s.entries(),u=!1,p=0;(i=d.next())&&!i.done;){var f=l.value,y=f[0],_=f[1],b=i.value,N=b[0],w=b[1];!u&&!n[p]&&(u=r.equals(y,N,o,p,t,s,r)&&r.equals(_,w,y,N,t,s,r))&&(n[p]=!0),p++}if(!u)return!1;o++}return!0}function Qhs(t,s,r){var n=rFe(t),a=n.length;if(rFe(s).length!==a)return!1;for(var o;a-- >0;)if(o=n[a],o===jnt&&(t.$$typeof||s.$$typeof)&&t.$$typeof!==s.$$typeof||!wnt(s,o)||!r.equals(t[o],s[o],o,o,t,s,r))return!1;return!0}function gI(t,s,r){var n=tFe(t),a=n.length;if(tFe(s).length!==a)return!1;for(var o,l,i;a-- >0;)if(o=n[a],o===jnt&&(t.$$typeof||s.$$typeof)&&t.$$typeof!==s.$$typeof||!wnt(s,o)||!r.equals(t[o],s[o],o,o,t,s,r)||(l=sFe(t,o),i=sFe(s,o),(l||i)&&(!l||!i||l.configurable!==i.configurable||l.enumerable!==i.enumerable||l.writable!==i.writable)))return!1;return!0}function Jhs(t,s){return vE(t.valueOf(),s.valueOf())}function ems(t,s){return t.source===s.source&&t.flags===s.flags}function aFe(t,s,r){if(t.size!==s.size)return!1;for(var n={},a=t.values(),o,l;(o=a.next())&&!o.done;){for(var i=s.values(),d=!1,u=0;(l=i.next())&&!l.done;)!d&&!n[u]&&(d=r.equals(o.value,l.value,o.value,l.value,t,s,r))&&(n[u]=!0),u++;if(!d)return!1}return!0}function tms(t,s){var r=t.length;if(s.length!==r)return!1;for(;r-- >0;)if(t[r]!==s[r])return!1;return!0}var sms="[object Arguments]",rms="[object Boolean]",nms="[object Date]",ams="[object Map]",ims="[object Number]",oms="[object Object]",lms="[object RegExp]",cms="[object Set]",dms="[object String]",ums=Array.isArray,iFe=typeof ArrayBuffer=="function"&&ArrayBuffer.isView?ArrayBuffer.isView:null,oFe=Object.assign,hms=Object.prototype.toString.call.bind(Object.prototype.toString);function mms(t){var s=t.areArraysEqual,r=t.areDatesEqual,n=t.areMapsEqual,a=t.areObjectsEqual,o=t.arePrimitiveWrappersEqual,l=t.areRegExpsEqual,i=t.areSetsEqual,d=t.areTypedArraysEqual;return function(p,f,y){if(p===f)return!0;if(p==null||f==null||typeof p!="object"||typeof f!="object")return p!==p&&f!==f;var _=p.constructor;if(_!==f.constructor)return!1;if(_===Object)return a(p,f,y);if(ums(p))return s(p,f,y);if(iFe!=null&&iFe(p))return d(p,f,y);if(_===Date)return r(p,f,y);if(_===RegExp)return l(p,f,y);if(_===Map)return n(p,f,y);if(_===Set)return i(p,f,y);var b=hms(p);return b===nms?r(p,f,y):b===lms?l(p,f,y):b===ams?n(p,f,y):b===cms?i(p,f,y):b===oms?typeof p.then!="function"&&typeof f.then!="function"&&a(p,f,y):b===sms?a(p,f,y):b===rms||b===ims||b===dms?o(p,f,y):!1}}function pms(t){var s=t.circular,r=t.createCustomConfig,n=t.strict,a={areArraysEqual:n?gI:Yhs,areDatesEqual:Xhs,areMapsEqual:n?eFe(nFe,gI):nFe,areObjectsEqual:n?gI:Qhs,arePrimitiveWrappersEqual:Jhs,areRegExpsEqual:ems,areSetsEqual:n?eFe(aFe,gI):aFe,areTypedArraysEqual:n?gI:tms};if(r&&(a=oFe({},a,r(a))),s){var o=f9(a.areArraysEqual),l=f9(a.areMapsEqual),i=f9(a.areObjectsEqual),d=f9(a.areSetsEqual);a=oFe({},a,{areArraysEqual:o,areMapsEqual:l,areObjectsEqual:i,areSetsEqual:d})}return a}function fms(t){return function(s,r,n,a,o,l,i){return t(s,r,i)}}function xms(t){var s=t.circular,r=t.comparator,n=t.createState,a=t.equals,o=t.strict;if(n)return function(d,u){var p=n(),f=p.cache,y=f===void 0?s?new WeakMap:void 0:f,_=p.meta;return r(d,u,{cache:y,equals:a,meta:_,strict:o})};if(s)return function(d,u){return r(d,u,{cache:new WeakMap,equals:a,meta:void 0,strict:o})};var l={cache:void 0,equals:a,meta:void 0,strict:o};return function(d,u){return r(d,u,l)}}var gms=Sw();Sw({strict:!0});Sw({circular:!0});Sw({circular:!0,strict:!0});Sw({createInternalComparator:function(){return vE}});Sw({strict:!0,createInternalComparator:function(){return vE}});Sw({circular:!0,createInternalComparator:function(){return vE}});Sw({circular:!0,createInternalComparator:function(){return vE},strict:!0});function Sw(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=pms(t),d=mms(i),u=n?n(d):fms(d);return xms({circular:r,comparator:d,createState:a,equals:u,strict:l})}function yms(t){typeof requestAnimationFrame<"u"&&requestAnimationFrame(t)}function lFe(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):yms(a)};requestAnimationFrame(n)}function Wbe(t){"@babel/helpers - typeof";return Wbe=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},Wbe(t)}function vms(t){return jms(t)||wms(t)||bms(t)||_ms()}function _ms(){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 bms(t,s){if(t){if(typeof t=="string")return cFe(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 cFe(t,s)}}function cFe(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:S<0?0:S},N=function(S){for(var C=S>1?1:S,A=C,I=0;I<8;++I){var L=f(A)-C,O=_(A);if(Math.abs(L-C)0&&arguments[0]!==void 0?arguments[0]:{},r=s.stiff,n=r===void 0?100:r,a=s.damping,o=a===void 0?8:a,l=s.dt,i=l===void 0?17:l,d=function(p,f,y){var _=-(p-f)*n,b=y*o,N=y+(_-b)*i/1e3,w=y*i/1e3+p;return Math.abs(w-f)t.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function eps(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 e0e(t){return nps(t)||rps(t)||sps(t)||tps()}function tps(){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 sps(t,s){if(t){if(typeof t=="string")return Qbe(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 Qbe(t,s)}}function rps(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function nps(t){if(Array.isArray(t))return Qbe(t)}function Qbe(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 tde(t){return tde=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},tde(t)}var v0=function(t){cps(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,d=l.attributeName,u=l.from,p=l.to,f=l.steps,y=l.children,_=l.duration;if(o.handleStyleChange=o.handleStyleChange.bind(twe(o)),o.changeStyle=o.changeStyle.bind(twe(o)),!i||_<=0)return o.state={style:{}},typeof y=="function"&&(o.state={style:p}),ewe(o);if(f&&f.length)o.state={style:f[0].style};else if(u){if(typeof y=="function")return o.state={style:u},ewe(o);o.state={style:d?BI({},d,u):u}}else o.state={style:{}};return o}return ops(r,[{key:"componentDidMount",value:function(){var a=this.props,o=a.isActive,l=a.canBegin;this.mounted=!0,!(!o||!l)&&this.runAnimation(this.props)}},{key:"componentDidUpdate",value:function(a){var o=this.props,l=o.isActive,i=o.canBegin,d=o.attributeName,u=o.shouldReAnimate,p=o.to,f=o.from,y=this.state.style;if(i){if(!l){var _={style:d?BI({},d,p):p};this.state&&y&&(d&&y[d]!==p||!d&&y!==p)&&this.setState(_);return}if(!(gms(a.to,p)&&a.canBegin&&a.isActive)){var b=!a.canBegin||!a.isActive;this.manager&&this.manager.stop(),this.stopJSAnimation&&this.stopJSAnimation();var N=b||u?f:a.to;if(this.state&&y){var w={style:d?BI({},d,N):N};(d&&y[d]!==N||!d&&y!==N)&&this.setState(w)}this.runAnimation(lg(lg({},this.props),{},{from:N,begin:0}))}}}},{key:"componentWillUnmount",value:function(){this.mounted=!1;var a=this.props.onAnimationEnd;this.unSubscribe&&this.unSubscribe(),this.manager&&(this.manager.stop(),this.manager=null),this.stopJSAnimation&&this.stopJSAnimation(),a&&a()}},{key:"handleStyleChange",value:function(a){this.changeStyle(a)}},{key:"changeStyle",value:function(a){this.mounted&&this.setState({style:a})}},{key:"runJSAnimation",value:function(a){var o=this,l=a.from,i=a.to,d=a.duration,u=a.easing,p=a.begin,f=a.onAnimationEnd,y=a.onAnimationStart,_=Xms(l,i,Bms(u),d,this.changeStyle),b=function(){o.stopJSAnimation=_()};this.manager.start([y,p,b,d,f])}},{key:"runStepAnimation",value:function(a){var o=this,l=a.steps,i=a.begin,d=a.onAnimationStart,u=l[0],p=u.style,f=u.duration,y=f===void 0?0:f,_=function(N,w,S){if(S===0)return N;var C=w.duration,A=w.easing,I=A===void 0?"ease":A,L=w.style,O=w.properties,V=w.onAnimationEnd,q=S>0?l[S-1]:w,B=O||Object.keys(L);if(typeof I=="function"||I==="spring")return[].concat(e0e(N),[o.runJSAnimation.bind(o,{from:q.style,to:L,duration:C,easing:I}),C]);var U=hFe(B,C,I),te=lg(lg(lg({},q.style),L),{},{transition:U});return[].concat(e0e(N),[te,C,V]).filter(Mms)};return this.manager.start([d].concat(e0e(l.reduce(_,[p,Math.max(y,i)])),[a.onAnimationEnd]))}},{key:"runAnimation",value:function(a){this.manager||(this.manager=Nms());var o=a.begin,l=a.duration,i=a.attributeName,d=a.to,u=a.easing,p=a.onAnimationStart,f=a.onAnimationEnd,y=a.steps,_=a.children,b=this.manager;if(this.unSubscribe=b.subscribe(this.handleStyleChange),typeof u=="function"||typeof _=="function"||u==="spring"){this.runJSAnimation(a);return}if(y.length>1){this.runStepAnimation(a);return}var N=i?BI({},i,d):d,w=hFe(Object.keys(N),l,u);b.start([p,o,lg(lg({},N),{},{transition:w}),l,f])}},{key:"render",value:function(){var a=this.props,o=a.children;a.begin;var l=a.duration;a.attributeName,a.easing;var i=a.isActive;a.steps,a.from,a.to,a.canBegin,a.onAnimationEnd,a.shouldReAnimate,a.onAnimationReStart;var d=Jms(a,Qms),u=k.Children.count(o),p=this.state.style;if(typeof o=="function")return o(p);if(!i||u===0||l<=0)return o;var f=function(_){var b=_.props,N=b.style,w=N===void 0?{}:N,S=b.className,C=k.cloneElement(_,lg(lg({},d),{},{style:lg(lg({},w),p),className:S}));return C};return u===1?f(k.Children.only(o)):xt.createElement("div",null,k.Children.map(o,function(y){return f(y)}))}}]),r}(k.PureComponent);v0.displayName="Animate";v0.defaultProps={begin:0,duration:1e3,from:"",to:"",attributeName:"",easing:"ease",isActive:!0,canBegin:!0,steps:[],onAnimationEnd:function(){},onAnimationStart:function(){}};v0.propTypes={from:$o.oneOfType([$o.object,$o.string]),to:$o.oneOfType([$o.object,$o.string]),attributeName:$o.string,duration:$o.number,begin:$o.number,easing:$o.oneOfType([$o.string,$o.func]),steps:$o.arrayOf($o.shape({duration:$o.number.isRequired,style:$o.object.isRequired,easing:$o.oneOfType([$o.oneOf(["ease","ease-in","ease-out","ease-in-out","linear"]),$o.func]),properties:$o.arrayOf("string"),onAnimationEnd:$o.func})),children:$o.oneOfType([$o.node,$o.func]),isActive:$o.bool,canBegin:$o.bool,onAnimationEnd:$o.func,shouldReAnimate:$o.bool,onAnimationStart:$o.func,onAnimationReStart:$o.func};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 sde(){return sde=Object.assign?Object.assign.bind():function(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0?1:-1,d=n>=0?1:-1,u=a>=0&&n>=0||a<0&&n<0?1:0,p;if(l>0&&o instanceof Array){for(var f=[0,0,0,0],y=0,_=4;y<_;y++)f[y]=o[y]>l?l:o[y];p="M".concat(s,",").concat(r+i*f[0]),f[0]>0&&(p+="A ".concat(f[0],",").concat(f[0],",0,0,").concat(u,",").concat(s+d*f[0],",").concat(r)),p+="L ".concat(s+n-d*f[1],",").concat(r),f[1]>0&&(p+="A ".concat(f[1],",").concat(f[1],",0,0,").concat(u,`, `).concat(s+n,",").concat(r+i*f[1])),p+="L ".concat(s+n,",").concat(r+a-i*f[2]),f[2]>0&&(p+="A ".concat(f[2],",").concat(f[2],",0,0,").concat(u,`, `).concat(s+n-d*f[2],",").concat(r+a)),p+="L ".concat(s+d*f[3],",").concat(r+a),f[3]>0&&(p+="A ".concat(f[3],",").concat(f[3],",0,0,").concat(u,`, `).concat(s,",").concat(r+a-i*f[3])),p+="Z"}else if(l>0&&o===+o&&o>0){var b=Math.min(l,o);p="M ".concat(s,",").concat(r+i*b,` A `).concat(b,",").concat(b,",0,0,").concat(u,",").concat(s+d*b,",").concat(r,` L `).concat(s+n-d*b,",").concat(r,` A `).concat(b,",").concat(b,",0,0,").concat(u,",").concat(s+n,",").concat(r+i*b,` L `).concat(s+n,",").concat(r+a-i*b,` A `).concat(b,",").concat(b,",0,0,").concat(u,",").concat(s+n-d*b,",").concat(r+a,` L `).concat(s+d*b,",").concat(r+a,` A `).concat(b,",").concat(b,",0,0,").concat(u,",").concat(s,",").concat(r+a-i*b," Z")}else p="M ".concat(s,",").concat(r," h ").concat(n," v ").concat(a," h ").concat(-n," Z");return p},_ps=function(s,r){if(!s||!r)return!1;var n=s.x,a=s.y,o=r.x,l=r.y,i=r.width,d=r.height;if(Math.abs(i)>0&&Math.abs(d)>0){var u=Math.min(o,o+i),p=Math.max(o,o+i),f=Math.min(l,l+d),y=Math.max(l,l+d);return n>=u&&n<=p&&a>=f&&a<=y}return!1},bps={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},NSe=function(s){var r=_Fe(_Fe({},bps),s),n=k.useRef(),a=k.useState(-1),o=hps(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 d=r.x,u=r.y,p=r.width,f=r.height,y=r.radius,_=r.className,b=r.animationEasing,N=r.animationDuration,w=r.animationBegin,S=r.isAnimationActive,C=r.isUpdateAnimationActive;if(d!==+d||u!==+u||p!==+p||f!==+f||p===0||f===0)return null;var A=bi("recharts-rectangle",_);return C?xt.createElement(v0,{canBegin:l>0,from:{width:p,height:f,x:d,y:u},to:{width:p,height:f,x:d,y:u},duration:N,animationEasing:b,isActive:C},function(I){var L=I.width,O=I.height,V=I.x,q=I.y;return xt.createElement(v0,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:w,duration:N,isActive:S,easing:b},xt.createElement("path",sde({},Ua(r,!0),{className:A,d:bFe(V,q,L,O,y),ref:n})))}):xt.createElement("path",sde({},Ua(r,!0),{className:A,d:bFe(d,u,p,f,y)}))},wps=["points","className","baseLinePoints","connectNulls"];function iM(){return iM=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Nps(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function wFe(t){return Mps(t)||Cps(t)||Sps(t)||kps()}function kps(){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 Sps(t,s){if(t){if(typeof t=="string")return swe(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 swe(t,s)}}function Cps(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Mps(t){if(Array.isArray(t))return swe(t)}function swe(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){jFe(n)?r[r.length-1].push(n):r[r.length-1].length>0&&r.push([])}),jFe(s[0])&&r[r.length-1].push(s[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},k8=function(s,r){var n=Tps(s);r&&(n=[n.reduce(function(o,l){return[].concat(wFe(o),wFe(l))},[])]);var a=n.map(function(o){return o.reduce(function(l,i,d){return"".concat(l).concat(d===0?"M":"L").concat(i.x,",").concat(i.y)},"")}).join("");return n.length===1?"".concat(a,"Z"):a},Aps=function(s,r,n){var a=k8(s,n);return"".concat(a.slice(-1)==="Z"?a.slice(0,-1):a,"L").concat(k8(r.reverse(),n).slice(1))},Eps=function(s){var r=s.points,n=s.className,a=s.baseLinePoints,o=s.connectNulls,l=jps(s,wps);if(!r||!r.length)return null;var i=bi("recharts-polygon",n);if(a&&a.length){var d=l.stroke&&l.stroke!=="none",u=Aps(r,a,o);return xt.createElement("g",{className:i},xt.createElement("path",iM({},Ua(l,!0),{fill:u.slice(-1)==="Z"?l.fill:"none",stroke:"none",d:u})),d?xt.createElement("path",iM({},Ua(l,!0),{fill:"none",d:k8(r,o)})):null,d?xt.createElement("path",iM({},Ua(l,!0),{fill:"none",d:k8(a,o)})):null)}var p=k8(r,o);return xt.createElement("path",iM({},Ua(l,!0),{fill:p.slice(-1)==="Z"?l.fill:"none",className:i,d:p}))};function rwe(){return rwe=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 Fps(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 zps=function(s,r,n,a,o,l){return"M".concat(s,",").concat(o,"v").concat(a,"M").concat(l,",").concat(r,"h").concat(n)},Bps=function(s){var r=s.x,n=r===void 0?0:r,a=s.y,o=a===void 0?0:a,l=s.top,i=l===void 0?0:l,d=s.left,u=d===void 0?0:d,p=s.width,f=p===void 0?0:p,y=s.height,_=y===void 0?0:y,b=s.className,N=Ops(s,Pps),w=Ips({x:n,y:o,top:i,left:u,width:f,height:_},N);return!sn(n)||!sn(o)||!sn(f)||!sn(_)||!sn(i)||!sn(u)?null:xt.createElement("path",nwe({},Ua(w,!0),{className:bi("recharts-cross",b),d:zps(n,o,f,_,i,u)}))},$ps=ome,qps=Brt,Ups=C0;function Vps(t,s){return t&&t.length?$ps(t,Ups(s),qps):void 0}var Hps=Vps;const Gps=ao(Hps);var Wps=ome,Kps=C0,Zps=$rt;function Yps(t,s){return t&&t.length?Wps(t,Kps(s),Zps):void 0}var Xps=Yps;const Qps=ao(Xps);var Jps=["cx","cy","angle","ticks","axisLine"],efs=["ticks","tick","angle","tickFormatter","stroke"];function rA(t){"@babel/helpers - typeof";return rA=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},rA(t)}function S8(){return S8=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 tfs(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 sfs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function CFe(t,s){for(var r=0;rAFe?l=a==="outer"?"start":"end":o<-AFe?l=a==="outer"?"end":"start":l="middle",l}},{key:"renderAxisLine",value:function(){var n=this.props,a=n.cx,o=n.cy,l=n.radius,i=n.axisLine,d=n.axisLineType,u=q2(q2({},Ua(this.props,!1)),{},{fill:"none"},Ua(i,!1));if(d==="circle")return xt.createElement(hme,h4({className:"recharts-polar-angle-axis-line"},u,{cx:a,cy:o,r:l}));var p=this.props.ticks,f=p.map(function(y){return Ol(a,o,l,y.coordinate)});return xt.createElement(Eps,h4({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,d=a.tickFormatter,u=a.stroke,p=Ua(this.props,!1),f=Ua(l,!1),y=q2(q2({},p),{},{fill:"none"},Ua(i,!1)),_=o.map(function(b,N){var w=n.getTickLineCoord(b),S=n.getTickTextAnchor(b),C=q2(q2(q2({textAnchor:S},p),{},{stroke:"none",fill:u},f),{},{index:N,payload:b,x:w.x2,y:w.y2});return xt.createElement(No,h4({className:bi("recharts-polar-angle-axis-tick",fnt(l)),key:"tick-".concat(b.coordinate)},lC(n.props,b,N)),i&&xt.createElement("line",h4({className:"recharts-polar-angle-axis-tick-line"},y,w)),l&&s.renderTickItem(l,C,d?d(b.value,N):b.value))});return xt.createElement(No,{className:"recharts-polar-angle-axis-ticks"},_)}},{key:"render",value:function(){var n=this.props,a=n.ticks,o=n.radius,l=n.axisLine;return o<=0||!a||!a.length?null:xt.createElement(No,{className:bi("recharts-polar-angle-axis",this.props.className)},l&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(n,a,o){var l;return xt.isValidElement(n)?l=xt.cloneElement(n,a):di(n)?l=n(a):l=xt.createElement(cC,h4({},a,{className:"recharts-polar-angle-axis-tick-value"}),o),l}}])}(k.PureComponent);fme(xme,"displayName","PolarAngleAxis");fme(xme,"axisType","angleAxis");fme(xme,"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 gfs=Rst,yfs=gfs(Object.getPrototypeOf,Object),vfs=yfs,_fs=M1,bfs=vfs,wfs=T1,jfs="[object Object]",Nfs=Function.prototype,kfs=Object.prototype,Lnt=Nfs.toString,Sfs=kfs.hasOwnProperty,Cfs=Lnt.call(Object);function Mfs(t){if(!wfs(t)||_fs(t)!=jfs)return!1;var s=bfs(t);if(s===null)return!0;var r=Sfs.call(s,"constructor")&&s.constructor;return typeof r=="function"&&r instanceof r&&Lnt.call(r)==Cfs}var Tfs=Mfs;const Afs=ao(Tfs);var Efs=M1,Pfs=T1,Ifs="[object Boolean]";function Lfs(t){return t===!0||t===!1||Pfs(t)&&Efs(t)==Ifs}var Dfs=Lfs;const Rfs=ao(Dfs);function eR(t){"@babel/helpers - typeof";return eR=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},eR(t)}function ade(){return ade=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:y,x:d,y:u},to:{upperWidth:p,lowerWidth:f,height:y,x:d,y:u},duration:N,animationEasing:b,isActive:S},function(A){var I=A.upperWidth,L=A.lowerWidth,O=A.height,V=A.x,q=A.y;return xt.createElement(v0,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:w,duration:N,easing:b},xt.createElement("path",ade({},Ua(r,!0),{className:C,d:LFe(V,q,I,L,O),ref:n})))}):xt.createElement("g",null,xt.createElement("path",ade({},Ua(r,!0),{className:C,d:LFe(d,u,p,f,y)})))},Wfs=["option","shapeType","propTransformer","activeClassName","isActive"];function tR(t){"@babel/helpers - typeof";return tR=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},tR(t)}function Kfs(t,s){if(t==null)return{};var r=Zfs(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 Zfs(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 DFe(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 ide(t){for(var s=1;s0?hf(A,"paddingAngle",0):0;if(L){var V=Xp(L.endAngle-L.startAngle,A.endAngle-A.startAngle),q=El(El({},A),{},{startAngle:C+O,endAngle:C+V(N)+O});w.push(q),C=q.endAngle}else{var B=A.endAngle,U=A.startAngle,te=Xp(0,B-U),Y=te(N),J=El(El({},A),{},{startAngle:C+O,endAngle:C+Y+O});w.push(J),C=J.endAngle}}),xt.createElement(No,null,n.renderSectorsStatically(w))})}},{key:"attachKeyboardHandlers",value:function(n){var a=this;n.onkeydown=function(o){if(!o.altKey)switch(o.key){case"ArrowLeft":{var l=++a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[l].focus(),a.setState({sectorToFocus:l});break}case"ArrowRight":{var i=--a.state.sectorToFocus<0?a.sectorRefs.length-1:a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[i].focus(),a.setState({sectorToFocus:i});break}case"Escape":{a.sectorRefs[a.state.sectorToFocus].blur(),a.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var n=this.props,a=n.sectors,o=n.isAnimationActive,l=this.state.prevSectors;return o&&a&&a.length&&(!l||!gO(l,a))?this.renderSectorsWithAnimation():this.renderSectorsStatically(a)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var n=this,a=this.props,o=a.hide,l=a.sectors,i=a.className,d=a.label,u=a.cx,p=a.cy,f=a.innerRadius,y=a.outerRadius,_=a.isAnimationActive,b=this.state.isAnimationFinished;if(o||!l||!l.length||!sn(u)||!sn(p)||!sn(f)||!sn(y))return null;var N=bi("recharts-pie",i);return xt.createElement(No,{tabIndex:this.props.rootTabIndex,className:N,ref:function(S){n.pieRef=S}},this.renderSectors(),d&&this.renderLabels(l),Ru.renderCallByParent(this.props,null,!1),(!_||b)&&i1.renderCallByParent(this.props,l,!1))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return a.prevIsAnimationActive!==n.isAnimationActive?{prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:[],isAnimationFinished:!0}:n.isAnimationActive&&n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:a.curSectors,isAnimationFinished:!0}:n.sectors!==a.curSectors?{curSectors:n.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(n,a){return n>a?"start":n=360?C:C-1)*d,I=w-C*_-A,L=a.reduce(function(q,B){var U=ou(B,S,0);return q+(sn(U)?U:0)},0),O;if(L>0){var V;O=a.map(function(q,B){var U=ou(q,S,0),te=ou(q,p,B),Y=(sn(U)?U:0)/L,J;B?J=V.endAngle+wm(N)*d*(U!==0?1:0):J=l;var X=J+wm(N)*((U!==0?_:0)+Y*I),ce=(J+X)/2,ie=(b.innerRadius+b.outerRadius)/2,ae=[{name:te,value:U,payload:q,dataKey:S,type:y}],oe=Ol(b.cx,b.cy,ie,ce);return V=El(El(El({percent:Y,cornerRadius:o,name:te,tooltipPayload:ae,midAngle:ce,middleRadius:ie,tooltipPosition:oe},q),b),{},{value:ou(q,S),startAngle:J,endAngle:X,payload:q,paddingAngle:wm(N)*d}),V})}return El(El({},b),{},{sectors:O,data:a})});var xxs=Math.ceil,gxs=Math.max;function yxs(t,s,r,n){for(var a=-1,o=gxs(xxs((s-t)/(r||1)),0),l=Array(o);o--;)l[n?o:++a]=t,t+=r;return l}var vxs=yxs,_xs=trt,zFe=1/0,bxs=17976931348623157e292;function wxs(t){if(!t)return t===0?t:0;if(t=_xs(t),t===zFe||t===-zFe){var s=t<0?-1:1;return s*bxs}return t===t?t:0}var Fnt=wxs,jxs=vxs,Nxs=eme,t0e=Fnt;function kxs(t){return function(s,r,n){return n&&typeof n!="number"&&Nxs(s,r,n)&&(r=n=void 0),s=t0e(s),r===void 0?(r=s,s=0):r=t0e(r),n=n===void 0?s0&&n.handleDrag(a.changedTouches[0])}),Hp(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()}),Hp(n,"handleLeaveWrapper",function(){(n.state.isTravellerMoving||n.state.isSlideMoving)&&(n.leaveTimer=window.setTimeout(n.handleDragEnd,n.props.leaveTimeOut))}),Hp(n,"handleEnterSlideOrTraveller",function(){n.setState({isTextActive:!0})}),Hp(n,"handleLeaveSlideOrTraveller",function(){n.setState({isTextActive:!1})}),Hp(n,"handleSlideDragStart",function(a){var o=VFe(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 zxs(s,t),Dxs(s,[{key:"componentWillUnmount",value:function(){this.leaveTimer&&(clearTimeout(this.leaveTimer),this.leaveTimer=null),this.detachDragEndListener()}},{key:"getIndex",value:function(n){var a=n.startX,o=n.endX,l=this.state.scaleValues,i=this.props,d=i.gap,u=i.data,p=u.length-1,f=Math.min(a,o),y=Math.max(a,o),_=s.getIndexInRange(l,f),b=s.getIndexInRange(l,y);return{startIndex:_-_%d,endIndex:b===p?p:b-b%d}}},{key:"getTextOfTick",value:function(n){var a=this.props,o=a.data,l=a.tickFormatter,i=a.dataKey,d=ou(o[n],i,n);return di(l)?l(d,n):d}},{key:"attachDragEndListener",value:function(){window.addEventListener("mouseup",this.handleDragEnd,!0),window.addEventListener("touchend",this.handleDragEnd,!0),window.addEventListener("mousemove",this.handleDrag,!0)}},{key:"detachDragEndListener",value:function(){window.removeEventListener("mouseup",this.handleDragEnd,!0),window.removeEventListener("touchend",this.handleDragEnd,!0),window.removeEventListener("mousemove",this.handleDrag,!0)}},{key:"handleSlideDrag",value:function(n){var a=this.state,o=a.slideMoveStartX,l=a.startX,i=a.endX,d=this.props,u=d.x,p=d.width,f=d.travellerWidth,y=d.startIndex,_=d.endIndex,b=d.onChange,N=n.pageX-o;N>0?N=Math.min(N,u+p-f-i,u+p-f-l):N<0&&(N=Math.max(N,u-l,u-i));var w=this.getIndex({startX:l+N,endX:i+N});(w.startIndex!==y||w.endIndex!==_)&&b&&b(w),this.setState({startX:l+N,endX:i+N,slideMoveStartX:n.pageX})}},{key:"handleTravellerDragStart",value:function(n,a){var o=VFe(a)?a.changedTouches[0]:a;this.setState({isSlideMoving:!1,isTravellerMoving:!0,movingTravellerId:n,brushMoveStartX:o.pageX}),this.attachDragEndListener()}},{key:"handleTravellerMove",value:function(n){var a=this.state,o=a.brushMoveStartX,l=a.movingTravellerId,i=a.endX,d=a.startX,u=this.state[l],p=this.props,f=p.x,y=p.width,_=p.travellerWidth,b=p.onChange,N=p.gap,w=p.data,S={startX:this.state.startX,endX:this.state.endX},C=n.pageX-o;C>0?C=Math.min(C,f+y-_-u):C<0&&(C=Math.max(C,f-u)),S[l]=u+C;var A=this.getIndex(S),I=A.startIndex,L=A.endIndex,O=function(){var q=w.length-1;return l==="startX"&&(i>d?I%N===0:L%N===0)||id?L%N===0:I%N===0)||i>d&&L===q};this.setState(Hp(Hp({},l,u+C),"brushMoveStartX",n.pageX),function(){b&&O()&&b(A)})}},{key:"handleTravellerMoveKeyboard",value:function(n,a){var o=this,l=this.state,i=l.scaleValues,d=l.startX,u=l.endX,p=this.state[a],f=i.indexOf(p);if(f!==-1){var y=f+n;if(!(y===-1||y>=i.length)){var _=i[y];a==="startX"&&_>=u||a==="endX"&&_<=d||this.setState(Hp({},a,_),function(){o.props.onChange(o.getIndex({startX:o.state.startX,endX:o.state.endX}))})}}}},{key:"renderBackground",value:function(){var n=this.props,a=n.x,o=n.y,l=n.width,i=n.height,d=n.fill,u=n.stroke;return xt.createElement("rect",{stroke:u,fill:d,x:a,y:o,width:l,height:i})}},{key:"renderPanorama",value:function(){var n=this.props,a=n.x,o=n.y,l=n.width,i=n.height,d=n.data,u=n.children,p=n.padding,f=k.Children.only(u);return f?xt.cloneElement(f,{x:a,y:o,width:l,height:i,margin:p,compact:!0,data:d}):null}},{key:"renderTravellerLayer",value:function(n,a){var o,l,i=this,d=this.props,u=d.y,p=d.travellerWidth,f=d.height,y=d.traveller,_=d.ariaLabel,b=d.data,N=d.startIndex,w=d.endIndex,S=Math.max(n,this.props.x),C=s0e(s0e({},Ua(this.props,!1)),{},{x:S,y:u,width:p,height:f}),A=_||"Min value: ".concat((o=b[N])===null||o===void 0?void 0:o.name,", Max value: ").concat((l=b[w])===null||l===void 0?void 0:l.name);return xt.createElement(No,{tabIndex:0,role:"slider","aria-label":A,"aria-valuenow":n,className:"recharts-brush-traveller",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.travellerDragStartHandlers[a],onTouchStart:this.travellerDragStartHandlers[a],onKeyDown:function(L){["ArrowLeft","ArrowRight"].includes(L.key)&&(L.preventDefault(),L.stopPropagation(),i.handleTravellerMoveKeyboard(L.key==="ArrowRight"?1:-1,a))},onFocus:function(){i.setState({isTravellerFocused:!0})},onBlur:function(){i.setState({isTravellerFocused:!1})},style:{cursor:"col-resize"}},s.renderTraveller(y,C))}},{key:"renderSlide",value:function(n,a){var o=this.props,l=o.y,i=o.height,d=o.stroke,u=o.travellerWidth,p=Math.min(n,a)+u,f=Math.max(Math.abs(a-n)-u,0);return xt.createElement("rect",{className:"recharts-brush-slide",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.handleSlideDragStart,onTouchStart:this.handleSlideDragStart,style:{cursor:"move"},stroke:"none",fill:d,fillOpacity:.2,x:p,y:l,width:f,height:i})}},{key:"renderText",value:function(){var n=this.props,a=n.startIndex,o=n.endIndex,l=n.y,i=n.height,d=n.travellerWidth,u=n.stroke,p=this.state,f=p.startX,y=p.endX,_=5,b={pointerEvents:"none",fill:u};return xt.createElement(No,{className:"recharts-brush-texts"},xt.createElement(cC,cde({textAnchor:"end",verticalAnchor:"middle",x:Math.min(f,y)-_,y:l+i/2},b),this.getTextOfTick(a)),xt.createElement(cC,cde({textAnchor:"start",verticalAnchor:"middle",x:Math.max(f,y)+d+_,y:l+i/2},b),this.getTextOfTick(o)))}},{key:"render",value:function(){var n=this.props,a=n.data,o=n.className,l=n.children,i=n.x,d=n.y,u=n.width,p=n.height,f=n.alwaysShowText,y=this.state,_=y.startX,b=y.endX,N=y.isTextActive,w=y.isSlideMoving,S=y.isTravellerMoving,C=y.isTravellerFocused;if(!a||!a.length||!sn(i)||!sn(d)||!sn(u)||!sn(p)||u<=0||p<=0)return null;var A=bi("recharts-brush",o),I=xt.Children.count(l)===1,L=Ixs("userSelect","none");return xt.createElement(No,{className:A,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:L},this.renderBackground(),I&&this.renderPanorama(),this.renderSlide(_,b),this.renderTravellerLayer(_,"startX"),this.renderTravellerLayer(b,"endX"),(N||w||S||C||f)&&this.renderText())}}],[{key:"renderDefaultTraveller",value:function(n){var a=n.x,o=n.y,l=n.width,i=n.height,d=n.stroke,u=Math.floor(o+i/2)-1;return xt.createElement(xt.Fragment,null,xt.createElement("rect",{x:a,y:o,width:l,height:i,fill:d,stroke:"none"}),xt.createElement("line",{x1:a+1,y1:u,x2:a+l-1,y2:u,fill:"none",stroke:"#fff"}),xt.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 xt.isValidElement(n)?o=xt.cloneElement(n,a):di(n)?o=n(a):o=s.renderDefaultTraveller(a),o}},{key:"getDerivedStateFromProps",value:function(n,a){var o=n.data,l=n.width,i=n.x,d=n.travellerWidth,u=n.updateId,p=n.startIndex,f=n.endIndex;if(o!==a.prevData||u!==a.prevUpdateId)return s0e({prevData:o,prevTravellerWidth:d,prevUpdateId:u,prevX:i,prevWidth:l},o&&o.length?$xs({data:o,width:l,x:i,travellerWidth:d,startIndex:p,endIndex:f}):{scale:null,scaleValues:null});if(a.scale&&(l!==a.prevWidth||i!==a.prevX||d!==a.prevTravellerWidth)){a.scale.range([i,i+l-d]);var y=a.scale.domain().map(function(_){return a.scale(_)});return{prevData:o,prevTravellerWidth:d,prevUpdateId:u,prevX:i,prevWidth:l,startX:a.scale(n.startIndex),endX:a.scale(n.endIndex),scaleValues:y}}return null}},{key:"getIndexInRange",value:function(n,a){for(var o=n.length,l=0,i=o-1;i-l>1;){var d=Math.floor((l+i)/2);n[d]>a?i=d:l=d}return a>=n[i]?i:l}}])}(k.PureComponent);Hp(oA,"displayName","Brush");Hp(oA,"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 qxs=Y4e;function Uxs(t,s){var r;return qxs(t,function(n,a,o){return r=s(n,a,o),!r}),!!r}var Vxs=Uxs,Hxs=Mst,Gxs=C0,Wxs=Vxs,Kxs=jp,Zxs=eme;function Yxs(t,s,r){var n=Kxs(t)?Hxs:Wxs;return r&&Zxs(t,s,r)&&(s=void 0),n(t,Gxs(s))}var Xxs=Yxs;const Qxs=ao(Xxs);var d0=function(s,r){var n=s.alwaysShow,a=s.ifOverflow;return n&&(a="extendDomain"),a===r},HFe=Yst;function Jxs(t,s,r){s=="__proto__"&&HFe?HFe(t,s,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[s]=r}var egs=Jxs,tgs=egs,sgs=Kst,rgs=C0;function ngs(t,s){var r={};return s=rgs(s),sgs(t,function(n,a,o){tgs(r,a,s(n,a,o))}),r}var ags=ngs;const igs=ao(ags);function ogs(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 Ngs(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 kgs(t,s){var r=t.x,n=t.y,a=jgs(t,vgs),o="".concat(r),l=parseInt(o,10),i="".concat(n),d=parseInt(i,10),u="".concat(s.height||a.height),p=parseInt(u,10),f="".concat(s.width||a.width),y=parseInt(f,10);return yI(yI(yI(yI(yI({},s),a),l?{x:l}:{}),d?{y:d}:{}),{},{height:p,width:y,name:s.name,radius:s.radius})}function WFe(t){return xt.createElement(Dnt,cwe({shapeType:"rectangle",propTransformer:kgs,activeClassName:"recharts-active-bar"},t))}var Sgs=function(s){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return function(n,a){if(typeof s=="number")return s;var o=sn(n)||oYt(n);return o?s(n,a):(o||uC(),r)}},Cgs=["value","background"],Unt;function lA(t){"@babel/helpers - typeof";return lA=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},lA(t)}function Mgs(t,s){if(t==null)return{};var r=Tgs(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 Tgs(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 ude(){return ude=Object.assign?Object.assign.bind():function(t){for(var s=1;s0&&Math.abs(ce)0&&Math.abs(X)0&&(J=Math.min((qe||0)-(X[Me-1]||0),J))}),Number.isFinite(J)){var ce=J/Y,ie=N.layout==="vertical"?n.height:n.width;if(N.padding==="gap"&&(V=ce*ie/2),N.padding==="no-gap"){var ae=jm(s.barCategoryGap,ce*ie),oe=ce*ie/2;V=oe-ae-(oe-ae)/ie*ae}}}a==="xAxis"?q=[n.left+(A.left||0)+(V||0),n.left+n.width-(A.right||0)-(V||0)]:a==="yAxis"?q=d==="horizontal"?[n.top+n.height-(A.bottom||0),n.top+(A.top||0)]:[n.top+(A.top||0)+(V||0),n.top+n.height-(A.bottom||0)-(V||0)]:q=N.range,L&&(q=[q[1],q[0]]);var me=lnt(N,o,y),ve=me.scale,he=me.realScaleType;ve.domain(S).range(q),cnt(ve);var ge=dnt(ve,yg(yg({},N),{},{realScaleType:he}));a==="xAxis"?(te=w==="top"&&!I||w==="bottom"&&I,B=n.left,U=f[O]-te*N.height):a==="yAxis"&&(te=w==="left"&&!I||w==="right"&&I,B=f[O]-te*N.width,U=n.top);var je=yg(yg(yg({},N),ge),{},{realScaleType:he,x:B,y:U,scale:ve,width:a==="xAxis"?n.width:N.width,height:a==="yAxis"?n.height:N.height});return je.bandSize=Zce(je,ge),!N.hide&&a==="xAxis"?f[O]+=(te?-1:1)*je.height:N.hide||(f[O]+=(te?-1:1)*je.width),yg(yg({},_),{},vme({},b,je))},{})},Knt=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)}},Bgs=function(s){var r=s.x1,n=s.y1,a=s.x2,o=s.y2;return Knt({x:r,y:n},{x:a,y:o})},Znt=function(){function t(s){Ogs(this,t),this.scale=s}return Fgs(t,[{key:"domain",get:function(){return this.scale.domain}},{key:"range",get:function(){return this.scale.range}},{key:"rangeMin",get:function(){return this.range()[0]}},{key:"rangeMax",get:function(){return this.range()[1]}},{key:"bandwidth",get:function(){return this.scale.bandwidth}},{key:"apply",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=n.bandAware,o=n.position;if(r!==void 0){if(o)switch(o){case"start":return this.scale(r);case"middle":{var l=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+l}case"end":{var i=this.bandwidth?this.bandwidth():0;return this.scale(r)+i}default:return this.scale(r)}if(a){var d=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+d}return this.scale(r)}}},{key:"isInRange",value:function(r){var n=this.range(),a=n[0],o=n[n.length-1];return a<=o?r>=a&&r<=o:r>=o&&r<=a}}],[{key:"create",value:function(r){return new t(r)}}])}();vme(Znt,"EPS",1e-4);var kSe=function(s){var r=Object.keys(s).reduce(function(n,a){return yg(yg({},n),{},vme({},a,Znt.create(s[a])))},{});return yg(yg({},r),{},{apply:function(a){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=o.bandAware,i=o.position;return igs(a,function(d,u){return r[u].apply(d,{bandAware:l,position:i})})},isInRange:function(a){return qnt(a,function(o,l){return r[l].isInRange(o)})}})};function $gs(t){return(t%180+180)%180}var qgs=function(s){var r=s.width,n=s.height,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,o=$gs(a),l=o*Math.PI/180,i=Math.atan(n/r),d=l>i&&l-1?a[o?s[l]:l]:void 0}}var Wgs=Ggs,Kgs=Fnt;function Zgs(t){var s=Kgs(t),r=s%1;return s===s?r?s-r:s:0}var Ygs=Zgs,Xgs=qst,Qgs=C0,Jgs=Ygs,eys=Math.max;function tys(t,s,r){var n=t==null?0:t.length;if(!n)return-1;var a=r==null?0:Jgs(r);return a<0&&(a=eys(n+a,0)),Xgs(t,Qgs(s),a)}var sys=tys,rys=Wgs,nys=sys,ays=rys(nys),iys=ays;const oys=ao(iys);var lys=uZt(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("")}),SSe=k.createContext(void 0),CSe=k.createContext(void 0),Ynt=k.createContext(void 0),Xnt=k.createContext({}),Qnt=k.createContext(void 0),Jnt=k.createContext(0),eat=k.createContext(0),QFe=function(s){var r=s.state,n=r.xAxisMap,a=r.yAxisMap,o=r.offset,l=s.clipPathId,i=s.children,d=s.width,u=s.height,p=lys(o);return xt.createElement(SSe.Provider,{value:n},xt.createElement(CSe.Provider,{value:a},xt.createElement(Xnt.Provider,{value:o},xt.createElement(Ynt.Provider,{value:p},xt.createElement(Qnt.Provider,{value:l},xt.createElement(Jnt.Provider,{value:u},xt.createElement(eat.Provider,{value:d},i)))))))},cys=function(){return k.useContext(Qnt)},tat=function(s){var r=k.useContext(SSe);r==null&&uC();var n=r[s];return n==null&&uC(),n},dys=function(){var s=k.useContext(SSe);return K_(s)},uys=function(){var s=k.useContext(CSe),r=oys(s,function(n){return qnt(n.domain,Number.isFinite)});return r||K_(s)},sat=function(s){var r=k.useContext(CSe);r==null&&uC();var n=r[s];return n==null&&uC(),n},hys=function(){var s=k.useContext(Ynt);return s},mys=function(){return k.useContext(Xnt)},MSe=function(){return k.useContext(eat)},TSe=function(){return k.useContext(Jnt)};function cA(t){"@babel/helpers - typeof";return cA=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},cA(t)}function pys(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function fys(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 Yys(t,s){return cat(t,s+1)}function Xys(t,s,r,n,a){for(var o=(n||[]).slice(),l=s.start,i=s.end,d=0,u=1,p=l,f=function(){var b=n==null?void 0:n[d];if(b===void 0)return{v:cat(n,u)};var N=d,w,S=function(){return w===void 0&&(w=r(b,N)),w},C=b.coordinate,A=d===0||xde(t,C,S,p,i);A||(d=0,p=l,u+=1),A&&(p=C+t*(S()/2+a),d+=u)},y;u<=o.length;)if(y=f(),y)return y.v;return[]}function iR(t){"@babel/helpers - typeof";return iR=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},iR(t)}function i7e(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 Mh(t){for(var s=1;s0?_.coordinate-w*t:_.coordinate})}else o[y]=_=Mh(Mh({},_),{},{tickCoord:_.coordinate});var S=xde(t,_.tickCoord,N,i,d);S&&(d=_.tickCoord-t*(N()/2+a),o[y]=Mh(Mh({},_),{},{isShow:!0}))},p=l-1;p>=0;p--)u(p);return o}function s0s(t,s,r,n,a,o){var l=(n||[]).slice(),i=l.length,d=s.start,u=s.end;if(o){var p=n[i-1],f=r(p,i-1),y=t*(p.coordinate+t*f/2-u);l[i-1]=p=Mh(Mh({},p),{},{tickCoord:y>0?p.coordinate-y*t:p.coordinate});var _=xde(t,p.tickCoord,function(){return f},d,u);_&&(u=p.tickCoord-t*(f/2+a),l[i-1]=Mh(Mh({},p),{},{isShow:!0}))}for(var b=o?i-1:i,N=function(C){var A=l[C],I,L=function(){return I===void 0&&(I=r(A,C)),I};if(C===0){var O=t*(A.coordinate-t*L()/2-d);l[C]=A=Mh(Mh({},A),{},{tickCoord:O<0?A.coordinate-O*t:A.coordinate})}else l[C]=A=Mh(Mh({},A),{},{tickCoord:A.coordinate});var V=xde(t,A.tickCoord,L,d,u);V&&(d=A.tickCoord+t*(L()/2+a),l[C]=Mh(Mh({},A),{},{isShow:!0}))},w=0;w=2?wm(a[1].coordinate-a[0].coordinate):1,S=Zys(o,w,_);return d==="equidistantPreserveStart"?Xys(w,S,N,a,l):(d==="preserveStart"||d==="preserveStartEnd"?y=s0s(w,S,N,a,l,d==="preserveStartEnd"):y=t0s(w,S,N,a,l),y.filter(function(C){return C.isShow}))}var r0s=["viewBox"],n0s=["viewBox"],a0s=["ticks"];function hA(t){"@babel/helpers - typeof";return hA=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},hA(t)}function lM(){return lM=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 i0s(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 o0s(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function l7e(t,s){for(var r=0;r0?d(this.props):d(_)),l<=0||i<=0||!b||!b.length?null:xt.createElement(No,{className:bi("recharts-cartesian-axis",u),ref:function(w){n.layerReference=w}},o&&this.renderAxisLine(),this.renderTicks(b,this.state.fontSize,this.state.letterSpacing),Ru.renderCallByParent(this.props))}}],[{key:"renderTickItem",value:function(n,a,o){var l,i=bi(a.className,"recharts-cartesian-axis-tick-value");return xt.isValidElement(n)?l=xt.cloneElement(n,Qd(Qd({},a),{},{className:i})):di(n)?l=n(Qd(Qd({},a),{},{className:i})):l=xt.createElement(cC,lM({},a,{className:"recharts-cartesian-axis-tick-value"}),o),l}}])}(k.Component);ISe(_E,"displayName","CartesianAxis");ISe(_E,"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 p0s=["x1","y1","x2","y2","key"],f0s=["offset"];function hC(t){"@babel/helpers - typeof";return hC=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},hC(t)}function c7e(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 Eh(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 _0s=function(s){var r=s.fill;if(!r||r==="none")return null;var n=s.fillOpacity,a=s.x,o=s.y,l=s.width,i=s.height,d=s.ry;return xt.createElement("rect",{x:a,y:o,ry:d,width:l,height:i,stroke:"none",fill:r,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function hat(t,s){var r;if(xt.isValidElement(t))r=xt.cloneElement(t,s);else if(di(t))r=t(s);else{var n=s.x1,a=s.y1,o=s.x2,l=s.y2,i=s.key,d=d7e(s,p0s),u=Ua(d,!1);u.offset;var p=d7e(u,f0s);r=xt.createElement("line",M4({},p,{x1:n,y1:a,x2:o,y2:l,fill:"none",key:i}))}return r}function b0s(t){var s=t.x,r=t.width,n=t.horizontal,a=n===void 0?!0:n,o=t.horizontalPoints;if(!a||!o||!o.length)return null;var l=o.map(function(i,d){var u=Eh(Eh({},t),{},{x1:s,y1:i,x2:s+r,y2:i,key:"line-".concat(d),index:d});return hat(a,u)});return xt.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,d){var u=Eh(Eh({},t),{},{x1:i,y1:s,x2:i,y2:s+r,key:"line-".concat(d),index:d});return hat(a,u)});return xt.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function j0s(t){var s=t.horizontalFill,r=t.fillOpacity,n=t.x,a=t.y,o=t.width,l=t.height,i=t.horizontalPoints,d=t.horizontal,u=d===void 0?!0:d;if(!u||!s||!s.length)return null;var p=i.map(function(y){return Math.round(y+a-a)}).sort(function(y,_){return y-_});a!==p[0]&&p.unshift(0);var f=p.map(function(y,_){var b=!p[_+1],N=b?a+l-y:p[_+1]-y;if(N<=0)return null;var w=_%s.length;return xt.createElement("rect",{key:"react-".concat(_),y,x:n,height:N,width:o,stroke:"none",fill:s[w],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return xt.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},f)}function N0s(t){var s=t.vertical,r=s===void 0?!0:s,n=t.verticalFill,a=t.fillOpacity,o=t.x,l=t.y,i=t.width,d=t.height,u=t.verticalPoints;if(!r||!n||!n.length)return null;var p=u.map(function(y){return Math.round(y+o-o)}).sort(function(y,_){return y-_});o!==p[0]&&p.unshift(0);var f=p.map(function(y,_){var b=!p[_+1],N=b?o+i-y:p[_+1]-y;if(N<=0)return null;var w=_%n.length;return xt.createElement("rect",{key:"react-".concat(_),x:y,y:l,width:N,height:d,stroke:"none",fill:n[w],fillOpacity:a,className:"recharts-cartesian-grid-bg"})});return xt.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},f)}var k0s=function(s,r){var n=s.xAxis,a=s.width,o=s.height,l=s.offset;return ont(PSe(Eh(Eh(Eh({},_E.defaultProps),n),{},{ticks:Vv(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.left,l.left+l.width,r)},S0s=function(s,r){var n=s.yAxis,a=s.width,o=s.height,l=s.offset;return ont(PSe(Eh(Eh(Eh({},_E.defaultProps),n),{},{ticks:Vv(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.top,l.top+l.height,r)},k5={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function mat(t){var s,r,n,a,o,l,i=MSe(),d=TSe(),u=mys(),p=Eh(Eh({},t),{},{stroke:(s=t.stroke)!==null&&s!==void 0?s:k5.stroke,fill:(r=t.fill)!==null&&r!==void 0?r:k5.fill,horizontal:(n=t.horizontal)!==null&&n!==void 0?n:k5.horizontal,horizontalFill:(a=t.horizontalFill)!==null&&a!==void 0?a:k5.horizontalFill,vertical:(o=t.vertical)!==null&&o!==void 0?o:k5.vertical,verticalFill:(l=t.verticalFill)!==null&&l!==void 0?l:k5.verticalFill,x:sn(t.x)?t.x:u.left,y:sn(t.y)?t.y:u.top,width:sn(t.width)?t.width:u.width,height:sn(t.height)?t.height:u.height}),f=p.x,y=p.y,_=p.width,b=p.height,N=p.syncWithTicks,w=p.horizontalValues,S=p.verticalValues,C=dys(),A=uys();if(!sn(_)||_<=0||!sn(b)||b<=0||!sn(f)||f!==+f||!sn(y)||y!==+y)return null;var I=p.verticalCoordinatesGenerator||k0s,L=p.horizontalCoordinatesGenerator||S0s,O=p.horizontalPoints,V=p.verticalPoints;if((!O||!O.length)&&di(L)){var q=w&&w.length,B=L({yAxis:A?Eh(Eh({},A),{},{ticks:q?w:A.ticks}):void 0,width:i,height:d,offset:u},q?!0:N);Rg(Array.isArray(B),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(hC(B),"]")),Array.isArray(B)&&(O=B)}if((!V||!V.length)&&di(I)){var U=S&&S.length,te=I({xAxis:C?Eh(Eh({},C),{},{ticks:U?S:C.ticks}):void 0,width:i,height:d,offset:u},U?!0:N);Rg(Array.isArray(te),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(hC(te),"]")),Array.isArray(te)&&(V=te)}return xt.createElement("g",{className:"recharts-cartesian-grid"},xt.createElement(_0s,{fill:p.fill,fillOpacity:p.fillOpacity,x:p.x,y:p.y,width:p.width,height:p.height,ry:p.ry}),xt.createElement(b0s,M4({},p,{offset:u,horizontalPoints:O,xAxis:C,yAxis:A})),xt.createElement(w0s,M4({},p,{offset:u,verticalPoints:V,xAxis:C,yAxis:A})),xt.createElement(j0s,M4({},p,{horizontalPoints:O})),xt.createElement(N0s,M4({},p,{verticalPoints:V})))}mat.displayName="CartesianGrid";var C0s=["type","layout","connectNulls","ref"],M0s=["key"];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 u7e(t,s){if(t==null)return{};var r=T0s(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 T0s(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 C8(){return C8=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){_=[].concat(S5(d.slice(0,b)),[f-N]);break}var w=_.length%2===0?[0,y]:[y];return[].concat(S5(s.repeat(d,p)),S5(_),w).map(function(S){return"".concat(S,"px")}).join(", ")}),vg(r,"id",hE("recharts-line-")),vg(r,"pathRef",function(l){r.mainCurve=l}),vg(r,"handleAnimationEnd",function(){r.setState({isAnimationFinished:!0}),r.props.onAnimationEnd&&r.props.onAnimationEnd()}),vg(r,"handleAnimationStart",function(){r.setState({isAnimationFinished:!1}),r.props.onAnimationStart&&r.props.onAnimationStart()}),r}return z0s(s,t),D0s(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,d=o.yAxis,u=o.layout,p=o.children,f=mf(p,yO);if(!f)return null;var y=function(N,w){return{x:N.x,y:N.y,value:N.value,errorVal:ou(N.payload,w)}},_={clipPath:n?"url(#clipPath-".concat(a,")"):null};return xt.createElement(No,_,f.map(function(b){return xt.cloneElement(b,{key:"bar-".concat(b.props.dataKey),data:l,xAxis:i,yAxis:d,layout:u,dataPointFormatter:y})}))}},{key:"renderDots",value:function(n,a,o){var l=this.props.isAnimationActive;if(l&&!this.state.isAnimationFinished)return null;var i=this.props,d=i.dot,u=i.points,p=i.dataKey,f=Ua(this.props,!1),y=Ua(d,!0),_=u.map(function(N,w){var S=Up(Up(Up({key:"dot-".concat(w),r:3},f),y),{},{index:w,cx:N.x,cy:N.y,value:N.value,dataKey:p,payload:N.payload,points:u});return s.renderDotItem(d,S)}),b={clipPath:n?"url(#clipPath-".concat(a?"":"dots-").concat(o,")"):null};return xt.createElement(No,C8({className:"recharts-line-dots",key:"dots"},b),_)}},{key:"renderCurveStatically",value:function(n,a,o,l){var i=this.props,d=i.type,u=i.layout,p=i.connectNulls;i.ref;var f=u7e(i,C0s),y=Up(Up(Up({},Ua(f,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:a?"url(#clipPath-".concat(o,")"):null,points:n},l),{},{type:d,layout:u,connectNulls:p});return xt.createElement(Qce,C8({},y,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(n,a){var o=this,l=this.props,i=l.points,d=l.strokeDasharray,u=l.isAnimationActive,p=l.animationBegin,f=l.animationDuration,y=l.animationEasing,_=l.animationId,b=l.animateNewValues,N=l.width,w=l.height,S=this.state,C=S.prevPoints,A=S.totalLength;return xt.createElement(v0,{begin:p,duration:f,isActive:u,easing:y,from:{t:0},to:{t:1},key:"line-".concat(_),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(I){var L=I.t;if(C){var O=C.length/i.length,V=i.map(function(Y,J){var X=Math.floor(J*O);if(C[X]){var ce=C[X],ie=Xp(ce.x,Y.x),ae=Xp(ce.y,Y.y);return Up(Up({},Y),{},{x:ie(L),y:ae(L)})}if(b){var oe=Xp(N*2,Y.x),me=Xp(w/2,Y.y);return Up(Up({},Y),{},{x:oe(L),y:me(L)})}return Up(Up({},Y),{},{x:Y.x,y:Y.y})});return o.renderCurveStatically(V,n,a)}var q=Xp(0,A),B=q(L),U;if(d){var te="".concat(d).split(/[,\s]+/gim).map(function(Y){return parseFloat(Y)});U=o.getStrokeDasharray(B,A,te)}else U=o.generateSimpleStrokeDasharray(A,B);return o.renderCurveStatically(i,n,a,{strokeDasharray:U})})}},{key:"renderCurve",value:function(n,a){var o=this.props,l=o.points,i=o.isAnimationActive,d=this.state,u=d.prevPoints,p=d.totalLength;return i&&l&&l.length&&(!u&&p>0||!gO(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,d=a.className,u=a.xAxis,p=a.yAxis,f=a.top,y=a.left,_=a.width,b=a.height,N=a.isAnimationActive,w=a.id;if(o||!i||!i.length)return null;var S=this.state.isAnimationFinished,C=i.length===1,A=bi("recharts-line",d),I=u&&u.allowDataOverflow,L=p&&p.allowDataOverflow,O=I||L,V=vi(w)?this.id:w,q=(n=Ua(l,!1))!==null&&n!==void 0?n:{r:3,strokeWidth:2},B=q.r,U=B===void 0?3:B,te=q.strokeWidth,Y=te===void 0?2:te,J=vYt(l)?l:{},X=J.clipDot,ce=X===void 0?!0:X,ie=U*2+Y;return xt.createElement(No,{className:A},I||L?xt.createElement("defs",null,xt.createElement("clipPath",{id:"clipPath-".concat(V)},xt.createElement("rect",{x:I?y:y-_/2,y:L?f:f-b/2,width:I?_:_*2,height:L?b:b*2})),!ce&&xt.createElement("clipPath",{id:"clipPath-dots-".concat(V)},xt.createElement("rect",{x:y-ie/2,y:f-ie/2,width:_+ie,height:b+ie}))):null,!C&&this.renderCurve(O,V),this.renderErrorBar(O,V),(C||l)&&this.renderDots(O,ce,V),(!N||S)&&i1.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(S5(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 Mvs(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 Tvs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function Avs(t,s){for(var r=0;rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r0?l:s&&s.length&&sn(a)&&sn(o)?s.slice(a,o+1):[]};function Tat(t){return t==="number"?[0,"auto"]:void 0}var Mwe=function(s,r,n,a){var o=s.graphicalItems,l=s.tooltipAxis,i=Nme(r,s);return n<0||!o||!o.length||n>=i.length?null:o.reduce(function(d,u){var p,f=(p=u.props.data)!==null&&p!==void 0?p:r;f&&s.dataStartIndex+s.dataEndIndex!==0&&s.dataEndIndex-s.dataStartIndex>=n&&(f=f.slice(s.dataStartIndex,s.dataEndIndex+1));var y;if(l.dataKey&&!l.allowDuplicatedCategory){var _=f===void 0?i:f;y=bce(_,l.dataKey,a)}else y=f&&f[n]||i[n];return y?[].concat(gA(d),[hnt(u,y)]):d},[])},v7e=function(s,r,n,a){var o=a||{x:s.chartX,y:s.chartY},l=qvs(o,n),i=s.orderedTooltipTicks,d=s.tooltipAxis,u=s.tooltipTicks,p=_us(l,i,u,d);if(p>=0&&u){var f=u[p]&&u[p].value,y=Mwe(s,r,p,f),_=Uvs(n,i,p,o);return{activeTooltipIndex:p,activeLabel:f,activePayload:y,activeCoordinate:_}}return null},Vvs=function(s,r){var n=r.axes,a=r.graphicalItems,o=r.axisType,l=r.axisIdKey,i=r.stackGroups,d=r.dataStartIndex,u=r.dataEndIndex,p=s.layout,f=s.children,y=s.stackOffset,_=int(p,o);return n.reduce(function(b,N){var w,S=N.type.defaultProps!==void 0?gr(gr({},N.type.defaultProps),N.props):N.props,C=S.type,A=S.dataKey,I=S.allowDataOverflow,L=S.allowDuplicatedCategory,O=S.scale,V=S.ticks,q=S.includeHidden,B=S[l];if(b[B])return b;var U=Nme(s.data,{graphicalItems:a.filter(function(ge){var je,qe=l in ge.props?ge.props[l]:(je=ge.type.defaultProps)===null||je===void 0?void 0:je[l];return qe===B}),dataStartIndex:d,dataEndIndex:u}),te=U.length,Y,J,X;xvs(S.domain,I,C)&&(Y=qbe(S.domain,null,I),_&&(C==="number"||O!=="auto")&&(X=j8(U,A,"category")));var ce=Tat(C);if(!Y||Y.length===0){var ie,ae=(ie=S.domain)!==null&&ie!==void 0?ie:ce;if(A){if(Y=j8(U,A,C),C==="category"&&_){var oe=cYt(Y);L&&oe?(J=Y,Y=lde(0,te)):L||(Y=$Oe(ae,Y,N).reduce(function(ge,je){return ge.indexOf(je)>=0?ge:[].concat(gA(ge),[je])},[]))}else if(C==="category")L?Y=Y.filter(function(ge){return ge!==""&&!vi(ge)}):Y=$Oe(ae,Y,N).reduce(function(ge,je){return ge.indexOf(je)>=0||je===""||vi(je)?ge:[].concat(gA(ge),[je])},[]);else if(C==="number"){var me=kus(U,a.filter(function(ge){var je,qe,Me=l in ge.props?ge.props[l]:(je=ge.type.defaultProps)===null||je===void 0?void 0:je[l],ke="hide"in ge.props?ge.props.hide:(qe=ge.type.defaultProps)===null||qe===void 0?void 0:qe.hide;return Me===B&&(q||!ke)}),A,o,p);me&&(Y=me)}_&&(C==="number"||O!=="auto")&&(X=j8(U,A,"category"))}else _?Y=lde(0,te):i&&i[B]&&i[B].hasStack&&C==="number"?Y=y==="expand"?[0,1]:unt(i[B].stackGroups,d,u):Y=ant(U,a.filter(function(ge){var je=l in ge.props?ge.props[l]:ge.type.defaultProps[l],qe="hide"in ge.props?ge.props.hide:ge.type.defaultProps.hide;return je===B&&(q||!qe)}),C,p,!0);if(C==="number")Y=kwe(f,Y,B,o,V),ae&&(Y=qbe(ae,Y,I));else if(C==="category"&&ae){var ve=ae,he=Y.every(function(ge){return ve.indexOf(ge)>=0});he&&(Y=ve)}}return gr(gr({},b),{},Ya({},B,gr(gr({},S),{},{axisType:o,domain:Y,categoricalDomain:X,duplicateDomain:J,originalDomain:(w=S.domain)!==null&&w!==void 0?w:ce,isCategorical:_,layout:p})))},{})},Hvs=function(s,r){var n=r.graphicalItems,a=r.Axis,o=r.axisType,l=r.axisIdKey,i=r.stackGroups,d=r.dataStartIndex,u=r.dataEndIndex,p=s.layout,f=s.children,y=Nme(s.data,{graphicalItems:n,dataStartIndex:d,dataEndIndex:u}),_=y.length,b=int(p,o),N=-1;return n.reduce(function(w,S){var C=S.type.defaultProps!==void 0?gr(gr({},S.type.defaultProps),S.props):S.props,A=C[l],I=Tat("number");if(!w[A]){N++;var L;return b?L=lde(0,_):i&&i[A]&&i[A].hasStack?(L=unt(i[A].stackGroups,d,u),L=kwe(f,L,A,o)):(L=qbe(I,ant(y,n.filter(function(O){var V,q,B=l in O.props?O.props[l]:(V=O.type.defaultProps)===null||V===void 0?void 0:V[l],U="hide"in O.props?O.props.hide:(q=O.type.defaultProps)===null||q===void 0?void 0:q.hide;return B===A&&!U}),"number",p),a.defaultProps.allowDataOverflow),L=kwe(f,L,A,o)),gr(gr({},w),{},Ya({},A,gr(gr({axisType:o},a.defaultProps),{},{hide:!0,orientation:hf(Bvs,"".concat(o,".").concat(N%2),null),domain:L,originalDomain:I,isCategorical:b,layout:p})))}return w},{})},Gvs=function(s,r){var n=r.axisType,a=n===void 0?"xAxis":n,o=r.AxisComp,l=r.graphicalItems,i=r.stackGroups,d=r.dataStartIndex,u=r.dataEndIndex,p=s.children,f="".concat(a,"Id"),y=mf(p,o),_={};return y&&y.length?_=Vvs(s,{axes:y,graphicalItems:l,axisType:a,axisIdKey:f,stackGroups:i,dataStartIndex:d,dataEndIndex:u}):l&&l.length&&(_=Hvs(s,{Axis:o,graphicalItems:l,axisType:a,axisIdKey:f,stackGroups:i,dataStartIndex:d,dataEndIndex:u})),_},Wvs=function(s){var r=K_(s),n=Vv(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:X4e(n,function(a){return a.coordinate}),tooltipAxis:r,tooltipAxisBandSize:Zce(r,n)}},_7e=function(s){var r=s.children,n=s.defaultShowTooltip,a=Wp(r,oA),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}},Kvs=function(s){return!s||!s.length?!1:s.some(function(r){var n=n1(r&&r.type);return n&&n.indexOf("Bar")>=0})},b7e=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"}},Zvs=function(s,r){var n=s.props,a=s.graphicalItems,o=s.xAxisMap,l=o===void 0?{}:o,i=s.yAxisMap,d=i===void 0?{}:i,u=n.width,p=n.height,f=n.children,y=n.margin||{},_=Wp(f,oA),b=Wp(f,eT),N=Object.keys(d).reduce(function(L,O){var V=d[O],q=V.orientation;return!V.mirror&&!V.hide?gr(gr({},L),{},Ya({},q,L[q]+V.width)):L},{left:y.left||0,right:y.right||0}),w=Object.keys(l).reduce(function(L,O){var V=l[O],q=V.orientation;return!V.mirror&&!V.hide?gr(gr({},L),{},Ya({},q,hf(L,"".concat(q))+V.height)):L},{top:y.top||0,bottom:y.bottom||0}),S=gr(gr({},w),N),C=S.bottom;_&&(S.bottom+=_.props.height||oA.defaultProps.height),b&&r&&(S=jus(S,a,n,r));var A=u-S.left-S.right,I=p-S.top-S.bottom;return gr(gr({brushBottom:C},S),{},{width:Math.max(A,0),height:Math.max(I,0)})},Yvs=function(s,r){if(r==="xAxis")return s[r].width;if(r==="yAxis")return s[r].height},LSe=function(s){var r=s.chartName,n=s.GraphicalChild,a=s.defaultTooltipEventType,o=a===void 0?"axis":a,l=s.validateTooltipEventTypes,i=l===void 0?["axis"]:l,d=s.axisComponents,u=s.legendContent,p=s.formatAxisMap,f=s.defaultProps,y=function(S,C){var A=C.graphicalItems,I=C.stackGroups,L=C.offset,O=C.updateId,V=C.dataStartIndex,q=C.dataEndIndex,B=S.barSize,U=S.layout,te=S.barGap,Y=S.barCategoryGap,J=S.maxBarSize,X=b7e(U),ce=X.numericAxisName,ie=X.cateAxisName,ae=Kvs(A),oe=[];return A.forEach(function(me,ve){var he=Nme(S.data,{graphicalItems:[me],dataStartIndex:V,dataEndIndex:q}),ge=me.type.defaultProps!==void 0?gr(gr({},me.type.defaultProps),me.props):me.props,je=ge.dataKey,qe=ge.maxBarSize,Me=ge["".concat(ce,"Id")],ke=ge["".concat(ie,"Id")],Re={},Ve=d.reduce(function(ot,He){var Je=C["".concat(He.axisType,"Map")],ut=ge["".concat(He.axisType,"Id")];Je&&Je[ut]||He.axisType==="zAxis"||uC();var mt=Je[ut];return gr(gr({},ot),{},Ya(Ya({},He.axisType,mt),"".concat(He.axisType,"Ticks"),Vv(mt)))},Re),Ne=Ve[ie],Ue=Ve["".concat(ie,"Ticks")],Ie=I&&I[Me]&&I[Me].hasStack&&Lus(me,I[Me].stackGroups),ye=n1(me.type).indexOf("Bar")>=0,ct=Zce(Ne,Ue),fe=[],$e=ae&&bus({barSize:B,stackGroups:I,totalSize:Yvs(Ve,ie)});if(ye){var Ye,tt,Te=vi(qe)?J:qe,We=(Ye=(tt=Zce(Ne,Ue,!0))!==null&&tt!==void 0?tt:Te)!==null&&Ye!==void 0?Ye:0;fe=wus({barGap:te,barCategoryGap:Y,bandSize:We!==ct?We:ct,sizeList:$e[ke],maxBarSize:Te}),We!==ct&&(fe=fe.map(function(ot){return gr(gr({},ot),{},{position:gr(gr({},ot.position),{},{offset:ot.position.offset-We/2})})}))}var Ke=me&&me.type&&me.type.getComposedData;Ke&&oe.push({props:gr(gr({},Ke(gr(gr({},Ve),{},{displayedData:he,props:S,dataKey:je,item:me,bandSize:ct,barPosition:fe,offset:L,stackedData:Ie,layout:U,dataStartIndex:V,dataEndIndex:q}))),{},Ya(Ya(Ya({key:me.key||"item-".concat(ve)},ce,Ve[ce]),ie,Ve[ie]),"animationId",O)),childIndex:wYt(me,S.children),item:me})}),oe},_=function(S,C){var A=S.props,I=S.dataStartIndex,L=S.dataEndIndex,O=S.updateId;if(!LDe({props:A}))return null;var V=A.children,q=A.layout,B=A.stackOffset,U=A.data,te=A.reverseStackOrder,Y=b7e(q),J=Y.numericAxisName,X=Y.cateAxisName,ce=mf(V,n),ie=Pus(U,ce,"".concat(J,"Id"),"".concat(X,"Id"),B,te),ae=d.reduce(function(ge,je){var qe="".concat(je.axisType,"Map");return gr(gr({},ge),{},Ya({},qe,Gvs(A,gr(gr({},je),{},{graphicalItems:ce,stackGroups:je.axisType===J&&ie,dataStartIndex:I,dataEndIndex:L}))))},{}),oe=Zvs(gr(gr({},ae),{},{props:A,graphicalItems:ce}),C==null?void 0:C.legendBBox);Object.keys(ae).forEach(function(ge){ae[ge]=p(A,ae[ge],oe,ge.replace("Map",""),r)});var me=ae["".concat(X,"Map")],ve=Wvs(me),he=y(A,gr(gr({},ae),{},{dataStartIndex:I,dataEndIndex:L,updateId:O,graphicalItems:ce,stackGroups:ie,offset:oe}));return gr(gr({formattedGraphicalItems:he,graphicalItems:ce,offset:oe,stackGroups:ie},ve),ae)},b=function(w){function S(C){var A,I,L;return Tvs(this,S),L=Pvs(this,S,[C]),Ya(L,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),Ya(L,"accessibilityManager",new fvs),Ya(L,"handleLegendBBoxUpdate",function(O){if(O){var V=L.state,q=V.dataStartIndex,B=V.dataEndIndex,U=V.updateId;L.setState(gr({legendBBox:O},_({props:L.props,dataStartIndex:q,dataEndIndex:B,updateId:U},gr(gr({},L.state),{},{legendBBox:O}))))}}),Ya(L,"handleReceiveSyncEvent",function(O,V,q){if(L.props.syncId===O){if(q===L.eventEmitterSymbol&&typeof L.props.syncMethod!="function")return;L.applySyncEvent(V)}}),Ya(L,"handleBrushChange",function(O){var V=O.startIndex,q=O.endIndex;if(V!==L.state.dataStartIndex||q!==L.state.dataEndIndex){var B=L.state.updateId;L.setState(function(){return gr({dataStartIndex:V,dataEndIndex:q},_({props:L.props,dataStartIndex:V,dataEndIndex:q,updateId:B},L.state))}),L.triggerSyncEvent({dataStartIndex:V,dataEndIndex:q})}}),Ya(L,"handleMouseEnter",function(O){var V=L.getMouseInfo(O);if(V){var q=gr(gr({},V),{},{isTooltipActive:!0});L.setState(q),L.triggerSyncEvent(q);var B=L.props.onMouseEnter;di(B)&&B(q,O)}}),Ya(L,"triggeredAfterMouseMove",function(O){var V=L.getMouseInfo(O),q=V?gr(gr({},V),{},{isTooltipActive:!0}):{isTooltipActive:!1};L.setState(q),L.triggerSyncEvent(q);var B=L.props.onMouseMove;di(B)&&B(q,O)}),Ya(L,"handleItemMouseEnter",function(O){L.setState(function(){return{isTooltipActive:!0,activeItem:O,activePayload:O.tooltipPayload,activeCoordinate:O.tooltipPosition||{x:O.cx,y:O.cy}}})}),Ya(L,"handleItemMouseLeave",function(){L.setState(function(){return{isTooltipActive:!1}})}),Ya(L,"handleMouseMove",function(O){O.persist(),L.throttleTriggeredAfterMouseMove(O)}),Ya(L,"handleMouseLeave",function(O){L.throttleTriggeredAfterMouseMove.cancel();var V={isTooltipActive:!1};L.setState(V),L.triggerSyncEvent(V);var q=L.props.onMouseLeave;di(q)&&q(V,O)}),Ya(L,"handleOuterEvent",function(O){var V=bYt(O),q=hf(L.props,"".concat(V));if(V&&di(q)){var B,U;/.*touch.*/i.test(V)?U=L.getMouseInfo(O.changedTouches[0]):U=L.getMouseInfo(O),q((B=U)!==null&&B!==void 0?B:{},O)}}),Ya(L,"handleClick",function(O){var V=L.getMouseInfo(O);if(V){var q=gr(gr({},V),{},{isTooltipActive:!0});L.setState(q),L.triggerSyncEvent(q);var B=L.props.onClick;di(B)&&B(q,O)}}),Ya(L,"handleMouseDown",function(O){var V=L.props.onMouseDown;if(di(V)){var q=L.getMouseInfo(O);V(q,O)}}),Ya(L,"handleMouseUp",function(O){var V=L.props.onMouseUp;if(di(V)){var q=L.getMouseInfo(O);V(q,O)}}),Ya(L,"handleTouchMove",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&L.throttleTriggeredAfterMouseMove(O.changedTouches[0])}),Ya(L,"handleTouchStart",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&L.handleMouseDown(O.changedTouches[0])}),Ya(L,"handleTouchEnd",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&L.handleMouseUp(O.changedTouches[0])}),Ya(L,"handleDoubleClick",function(O){var V=L.props.onDoubleClick;if(di(V)){var q=L.getMouseInfo(O);V(q,O)}}),Ya(L,"handleContextMenu",function(O){var V=L.props.onContextMenu;if(di(V)){var q=L.getMouseInfo(O);V(q,O)}}),Ya(L,"triggerSyncEvent",function(O){L.props.syncId!==void 0&&n0e.emit(a0e,L.props.syncId,O,L.eventEmitterSymbol)}),Ya(L,"applySyncEvent",function(O){var V=L.props,q=V.layout,B=V.syncMethod,U=L.state.updateId,te=O.dataStartIndex,Y=O.dataEndIndex;if(O.dataStartIndex!==void 0||O.dataEndIndex!==void 0)L.setState(gr({dataStartIndex:te,dataEndIndex:Y},_({props:L.props,dataStartIndex:te,dataEndIndex:Y,updateId:U},L.state)));else if(O.activeTooltipIndex!==void 0){var J=O.chartX,X=O.chartY,ce=O.activeTooltipIndex,ie=L.state,ae=ie.offset,oe=ie.tooltipTicks;if(!ae)return;if(typeof B=="function")ce=B(oe,O);else if(B==="value"){ce=-1;for(var me=0;me=0){var Ie,ye;if(J.dataKey&&!J.allowDuplicatedCategory){var ct=typeof J.dataKey=="function"?Ue:"payload.".concat(J.dataKey.toString());Ie=bce(me,ct,ce),ye=ve&&he&&bce(he,ct,ce)}else Ie=me==null?void 0:me[X],ye=ve&&he&&he[X];if(ke||Me){var fe=O.props.activeIndex!==void 0?O.props.activeIndex:X;return[k.cloneElement(O,gr(gr(gr({},B.props),Ve),{},{activeIndex:fe})),null,null]}if(!vi(Ie))return[Ne].concat(gA(L.renderActivePoints({item:B,activePoint:Ie,basePoint:ye,childIndex:X,isRange:ve})))}else{var $e,Ye=($e=L.getItemByXY(L.state.activeCoordinate))!==null&&$e!==void 0?$e:{graphicalItem:Ne},tt=Ye.graphicalItem,Te=tt.item,We=Te===void 0?O:Te,Ke=tt.childIndex,ot=gr(gr(gr({},B.props),Ve),{},{activeIndex:Ke});return[k.cloneElement(We,ot),null,null]}return ve?[Ne,null,null]:[Ne,null]}),Ya(L,"renderCustomized",function(O,V,q){return k.cloneElement(O,gr(gr({key:"recharts-customized-".concat(q)},L.props),L.state))}),Ya(L,"renderMap",{CartesianGrid:{handler:g9,once:!0},ReferenceArea:{handler:L.renderReferenceElement},ReferenceLine:{handler:g9},ReferenceDot:{handler:L.renderReferenceElement},XAxis:{handler:g9},YAxis:{handler:g9},Brush:{handler:L.renderBrush,once:!0},Bar:{handler:L.renderGraphicChild},Line:{handler:L.renderGraphicChild},Area:{handler:L.renderGraphicChild},Radar:{handler:L.renderGraphicChild},RadialBar:{handler:L.renderGraphicChild},Scatter:{handler:L.renderGraphicChild},Pie:{handler:L.renderGraphicChild},Funnel:{handler:L.renderGraphicChild},Tooltip:{handler:L.renderCursor,once:!0},PolarGrid:{handler:L.renderPolarGrid,once:!0},PolarAngleAxis:{handler:L.renderPolarAxis},PolarRadiusAxis:{handler:L.renderPolarAxis},Customized:{handler:L.renderCustomized}}),L.clipPathId="".concat((A=C.id)!==null&&A!==void 0?A:hE("recharts"),"-clip"),L.throttleTriggeredAfterMouseMove=srt(L.triggeredAfterMouseMove,(I=C.throttleDelay)!==null&&I!==void 0?I:1e3/60),L.state={},L}return Dvs(S,w),Evs(S,[{key:"componentDidMount",value:function(){var A,I;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(A=this.props.margin.left)!==null&&A!==void 0?A:0,top:(I=this.props.margin.top)!==null&&I!==void 0?I:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var A=this.props,I=A.children,L=A.data,O=A.height,V=A.layout,q=Wp(I,tp);if(q){var B=q.props.defaultIndex;if(!(typeof B!="number"||B<0||B>this.state.tooltipTicks.length-1)){var U=this.state.tooltipTicks[B]&&this.state.tooltipTicks[B].value,te=Mwe(this.state,L,B,U),Y=this.state.tooltipTicks[B].coordinate,J=(this.state.offset.top+O)/2,X=V==="horizontal",ce=X?{x:Y,y:J}:{y:Y,x:J},ie=this.state.formattedGraphicalItems.find(function(oe){var me=oe.item;return me.type.name==="Scatter"});ie&&(ce=gr(gr({},ce),ie.props.points[B].tooltipPosition),te=ie.props.points[B].tooltipPayload);var ae={activeTooltipIndex:B,isTooltipActive:!0,activeLabel:U,activePayload:te,activeCoordinate:ce};this.setState(ae),this.renderCursor(q),this.accessibilityManager.setIndex(B)}}}},{key:"getSnapshotBeforeUpdate",value:function(A,I){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==I.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==A.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==A.margin){var L,O;this.accessibilityManager.setDetails({offset:{left:(L=this.props.margin.left)!==null&&L!==void 0?L:0,top:(O=this.props.margin.top)!==null&&O!==void 0?O:0}})}return null}},{key:"componentDidUpdate",value:function(A){rbe([Wp(A.children,tp)],[Wp(this.props.children,tp)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var A=Wp(this.props.children,tp);if(A&&typeof A.props.shared=="boolean"){var I=A.props.shared?"axis":"item";return i.indexOf(I)>=0?I:o}return o}},{key:"getMouseInfo",value:function(A){if(!this.container)return null;var I=this.container,L=I.getBoundingClientRect(),O=Kis(L),V={chartX:Math.round(A.pageX-O.left),chartY:Math.round(A.pageY-O.top)},q=L.width/I.offsetWidth||1,B=this.inRange(V.chartX,V.chartY,q);if(!B)return null;var U=this.state,te=U.xAxisMap,Y=U.yAxisMap,J=this.getTooltipEventType(),X=v7e(this.state,this.props.data,this.props.layout,B);if(J!=="axis"&&te&&Y){var ce=K_(te).scale,ie=K_(Y).scale,ae=ce&&ce.invert?ce.invert(V.chartX):null,oe=ie&&ie.invert?ie.invert(V.chartY):null;return gr(gr({},V),{},{xValue:ae,yValue:oe},X)}return X?gr(gr({},V),X):null}},{key:"inRange",value:function(A,I){var L=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,O=this.props.layout,V=A/L,q=I/L;if(O==="horizontal"||O==="vertical"){var B=this.state.offset,U=V>=B.left&&V<=B.left+B.width&&q>=B.top&&q<=B.top+B.height;return U?{x:V,y:q}:null}var te=this.state,Y=te.angleAxisMap,J=te.radiusAxisMap;if(Y&&J){var X=K_(Y);return VOe({x:V,y:q},X)}return null}},{key:"parseEventsOfWrapper",value:function(){var A=this.props.children,I=this.getTooltipEventType(),L=Wp(A,tp),O={};L&&I==="axis"&&(L.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 V=wce(this.props,this.handleOuterEvent);return gr(gr({},V),O)}},{key:"addListener",value:function(){n0e.on(a0e,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){n0e.removeListener(a0e,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(A,I,L){for(var O=this.state.formattedGraphicalItems,V=0,q=O.length;V{const{data:C,error:A}=await G.from("email_campaigns").select("*").eq("status","sent").order("sent_at",{ascending:!0});if(A)throw A;return C}}),{data:n}=gt({queryKey:["campaign-agent-profiles"],queryFn:async()=>{const{data:C,error:A}=await G.from("profiles").select("id, name, email");if(A)throw A;return C}});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(C=>[C.id,C])),l=a.reduce((C,A)=>C+(A.sent_count||0),0),i=a.reduce((C,A)=>C+(A.open_count||0),0),d=a.reduce((C,A)=>C+(A.click_count||0),0),u=a.reduce((C,A)=>C+(A.bounce_count||0),0),p=a.reduce((C,A)=>C+(A.complaint_count||0),0),f=l>0?(i/l*100).toFixed(1):"0.0",y=l>0?(d/l*100).toFixed(1):"0.0",_=[{label:"Campaigns Sent",value:a.length,icon:_n,color:"text-foreground"},{label:"Total Emails Sent",value:l,icon:ir,color:"text-green-600"},{label:"Avg Open Rate",value:`${f}%`,icon:jn,color:"text-blue-600"},{label:"Avg Click Rate",value:`${y}%`,icon:au,color:"text-purple-600"},{label:"Total Bounces",value:u,icon:Dc,color:"text-orange-600"},{label:"Complaints",value:p,icon:Qo,color:"text-destructive"}],b=new Map;a.forEach(C=>{var L,O;const A=C.user_id,I=b.get(A)||{name:((L=o.get(A))==null?void 0:L.name)||((O=o.get(A))==null?void 0:O.email)||"Unknown",campaigns:0,sent:0,opens:0,clicks:0};I.campaigns++,I.sent+=C.sent_count||0,I.opens+=C.open_count||0,I.clicks+=C.click_count||0,b.set(A,I)});const N=[...b.entries()].map(([C,A])=>({id:C,...A,openRate:A.sent>0?+(A.opens/A.sent*100).toFixed(1):0})).sort((C,A)=>A.sent-C.sent),w=N.slice(0,6).map(C=>({name:C.name,value:C.sent})),S=a.map(C=>{var A;return{name:C.name.length>20?C.name.slice(0,20)+"…":C.name,agent:((A=o.get(C.user_id))==null?void 0:A.name)||"Unknown",openRate:C.sent_count>0?+(C.open_count/C.sent_count*100).toFixed(1):0,clickRate:C.sent_count>0?+(C.click_count/C.sent_count*100).toFixed(1):0,sent:C.sent_count,date:C.sent_at?vs(new Date(C.sent_at),"MMM d"):""}});return e.jsx("div",{className:"space-y-6",children:a.length===0?e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(_n,{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:_.map(C=>e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx(C.icon,{className:`h-5 w-5 mx-auto mb-1 ${C.color}`}),e.jsx("p",{className:"text-2xl font-bold",children:C.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C.label})]})},C.label))}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Open & Click Rates by Campaign"})}),e.jsx(Oe,{children:e.jsx("div",{className:"h-[280px]",children:e.jsx(tT,{width:"100%",height:"100%",children:e.jsxs(Aat,{data:S,children:[e.jsx(mC,{dataKey:"date",fontSize:11}),e.jsx(pC,{fontSize:11,unit:"%"}),e.jsx(tp,{formatter:C=>`${C}%`}),e.jsx(_1,{dataKey:"openRate",fill:"hsl(220, 70%, 50%)",name:"Open Rate",radius:[2,2,0,0]}),e.jsx(_1,{dataKey:"clickRate",fill:"hsl(270, 70%, 50%)",name:"Click Rate",radius:[2,2,0,0]})]})})})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Send Volume by Agent"})}),e.jsx(Oe,{children:e.jsx("div",{className:"h-[280px]",children:e.jsx(tT,{width:"100%",height:"100%",children:e.jsxs(Eat,{children:[e.jsx(M0,{data:w,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:100,label:({name:C,percent:A})=>`${C} (${(A*100).toFixed(0)}%)`,fontSize:11,children:w.map((C,A)=>e.jsx(hO,{fill:w7e[A%w7e.length]},A))}),e.jsx(tp,{})]})})})})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Send Volume Trend"})}),e.jsx(Oe,{children:e.jsx("div",{className:"h-[240px]",children:e.jsx(tT,{width:"100%",height:"100%",children:e.jsxs(Xvs,{data:S,children:[e.jsx(mC,{dataKey:"date",fontSize:11}),e.jsx(pC,{fontSize:11}),e.jsx(tp,{}),e.jsx(vO,{type:"monotone",dataKey:"sent",stroke:"hsl(142, 71%, 45%)",strokeWidth:2,name:"Emails Sent",dot:{r:4}})]})})})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Agent Performance"})}),e.jsx(Oe,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-left text-muted-foreground",children:[e.jsx("th",{className:"pb-2 font-medium",children:"Agent"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Campaigns"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Sent"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Opens"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Clicks"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Open Rate"})]})}),e.jsx("tbody",{children:N.map(C=>e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30",children:[e.jsx("td",{className:"py-2.5 font-medium",children:C.name}),e.jsx("td",{className:"py-2.5 text-center",children:C.campaigns}),e.jsx("td",{className:"py-2.5 text-center",children:C.sent}),e.jsx("td",{className:"py-2.5 text-center",children:C.opens}),e.jsx("td",{className:"py-2.5 text-center",children:C.clicks}),e.jsx("td",{className:"py-2.5 text-center",children:e.jsxs(Qe,{variant:"outline",children:[C.openRate,"%"]})})]},C.id))})]})})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Campaign Leaderboard"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-2",children:[...a].sort((C,A)=>{const I=C.sent_count>0?C.open_count/C.sent_count:0;return(A.sent_count>0?A.open_count/A.sent_count:0)-I}).slice(0,10).map((C,A)=>{const I=C.sent_count>0?(C.open_count/C.sent_count*100).toFixed(1):"0.0",L=C.sent_count>0?(C.click_count/C.sent_count*100).toFixed(1):"0.0",O=o.get(C.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/${C.id}`),children:[e.jsxs("span",{className:"text-lg font-bold text-muted-foreground w-6",children:["#",A+1]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:C.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(O==null?void 0:O.name)||"Unknown"," · ",C.sent_at?vs(new Date(C.sent_at),"MMM d, yyyy"):""," · ",C.sent_count," sent"]})]}),e.jsxs("div",{className:"flex gap-3 text-xs",children:[e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(jn,{className:"h-3 w-3"})," ",I,"%"]}),e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(au,{className:"h-3 w-3"})," ",L,"%"]})]})]},C.id)})})})]})]})})}const Jvs=()=>e.jsx(Ds,{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(ta,{defaultValue:"analytics",className:"space-y-4",children:[e.jsxs(Jn,{children:[e.jsx(cs,{value:"analytics",children:"Analytics"}),e.jsx(cs,{value:"content",children:"Content"}),e.jsx(cs,{value:"email-campaigns",children:"Email Campaigns"}),e.jsx(cs,{value:"activity",children:"Activity"}),e.jsx(cs,{value:"shares",children:"Shares"})]}),e.jsx(Ss,{value:"analytics",className:"space-y-4",children:e.jsx(SGt,{})}),e.jsx(Ss,{value:"content",className:"space-y-4",children:e.jsx(MGt,{})}),e.jsx(Ss,{value:"email-campaigns",className:"space-y-4",children:e.jsx(Qvs,{})}),e.jsx(Ss,{value:"activity",className:"space-y-4",children:e.jsx(kGt,{})}),e.jsx(Ss,{value:"shares",className:"space-y-4",children:e.jsx($tt,{})})]})]})});function e1s(){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,d]=k.useState(null),[u,p]=k.useState(""),[f,y]=k.useState([]),[_,b]=k.useState([]),[N,w]=k.useState([]),[S,C]=k.useState(!1),[A,I]=k.useState(null),[L,O]=k.useState(""),{data:V,isLoading:q}=gt({queryKey:["brokerage-resources"],queryFn:async()=>{const{data:ye,error:ct}=await G.from("brokerage_resources").select("*").order("publish_date",{ascending:!1});if(ct)throw ct;return ye}}),{data:B}=gt({queryKey:["brokerage-resource-pdfs"],queryFn:async()=>{const{data:ye,error:ct}=await G.from("brokerage_resource_pdfs").select("*").order("sort_order",{ascending:!0});if(ct)throw ct;return ye}}),{data:U}=gt({queryKey:["brokerage-resource-videos"],queryFn:async()=>{const{data:ye,error:ct}=await G.from("brokerage_resource_videos").select("*").order("sort_order",{ascending:!0});if(ct)throw ct;return ye}}),{data:te}=gt({queryKey:["brokerage-resource-links"],queryFn:async()=>{const{data:ye,error:ct}=await G.from("brokerage_resource_links").select("*").order("sort_order",{ascending:!0});if(ct)throw ct;return ye}}),{data:Y,isLoading:J}=gt({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:ye,error:ct}=await G.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(ct)throw ct;return ye}}),X=()=>{l({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),d(null),p(""),y([]),b([]),w([]),a(null),O("")},ce=ye=>{a(ye),l({title:ye.title,description:ye.description||"",publish_date:ye.publish_date.split("T")[0],is_published:ye.is_published,category_id:ye.category_id||""}),p(ye.preview_image_url||""),O("");const ct=(B==null?void 0:B.filter(Ye=>Ye.resource_id===ye.id))||[];y(ct.map(Ye=>({id:Ye.id,name:Ye.name,file_url:Ye.file_url,file_size:Ye.file_size,sort_order:Ye.sort_order})));const fe=(U==null?void 0:U.filter(Ye=>Ye.resource_id===ye.id))||[];b(fe.map(Ye=>({id:Ye.id,title:Ye.title,video_url:Ye.video_url,sort_order:Ye.sort_order})));const $e=(te==null?void 0:te.filter(Ye=>Ye.resource_id===ye.id))||[];w($e.map(Ye=>({id:Ye.id,title:Ye.title,canva_share_link:Ye.canva_share_link,sort_order:Ye.sort_order}))),r(!0)},ie=ye=>{var fe;const ct=(fe=ye.target.files)==null?void 0:fe[0];ct&&(d(ct),p(URL.createObjectURL(ct)))},ae=()=>{y([...f,{name:"",file_url:"",sort_order:f.length}])},oe=ye=>{y(f.filter((ct,fe)=>fe!==ye))},me=(ye,ct,fe)=>{const $e=[...f];if(ct==="file"&&fe instanceof File){const Ye=fe.name.replace(/\.[^/.]+$/,"");$e[ye]={...$e[ye],file:fe,file_size:fe.size,name:$e[ye].name||Ye}}else $e[ye]={...$e[ye],[ct]:fe};y($e)},ve=()=>{b([..._,{title:"",video_url:"",sort_order:_.length}])},he=ye=>{b(_.filter((ct,fe)=>fe!==ye))},ge=(ye,ct,fe)=>{const $e=[..._];ct==="file"&&fe instanceof File?$e[ye]={...$e[ye],file:fe}:$e[ye]={...$e[ye],[ct]:fe},b($e)},je=()=>{w([...N,{title:"",canva_share_link:"",sort_order:N.length}])},qe=ye=>{w(N.filter((ct,fe)=>fe!==ye))},Me=(ye,ct,fe)=>{const $e=[...N];$e[ye]={...$e[ye],[ct]:fe},w($e)},ke=async(ye,ct)=>{try{const fe=await G.functions.invoke("bunny-upload",{body:{action:"create",title:ye.name}});if(fe.error)throw fe.error;const{videoId:$e,uploadUrl:Ye,libraryId:tt}=fe.data,Te=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:$e,libraryId:tt}});if(Te.error)throw Te.error;const{uploadUrl:We,apiKey:Ke}=Te.data,ot=new XMLHttpRequest;return ot.open("PUT",We,!0),ot.setRequestHeader("AccessKey",Ke),ot.upload.onprogress=He=>{if(He.lengthComputable){const Je=Math.round(He.loaded/He.total*100),ut=[..._];ut[ct]={...ut[ct],uploadProgress:Je},b(ut)}},await new Promise((He,Je)=>{ot.onload=()=>ot.status>=200&&ot.status<300?He():Je(new Error("Upload failed")),ot.onerror=()=>Je(new Error("Upload failed")),ot.send(ye)}),`https://iframe.mediadelivery.net/embed/${tt}/${$e}`}catch(fe){throw console.error("Bunny upload error:",fe),fe}},Re=Pt({mutationFn:async ye=>{const{data:ct,error:fe}=await G.from("brokerage_resource_categories").insert({name:ye,sort_order:(Y==null?void 0:Y.length)||0}).select().single();if(fe)throw fe;return ct},onSuccess:ye=>{t.invalidateQueries({queryKey:["brokerage-resource-categories"]}),l({...o,category_id:ye.id}),O(""),pe.success("Category created")},onError:ye=>{pe.error("Failed to create category: "+ye.message)}}),Ve=Pt({mutationFn:async()=>{C(!0);let ye=(n==null?void 0:n.preview_image_url)||null;if(i){const $e=i.name.split(".").pop(),Ye=`${Date.now()}.${$e}`,{error:tt}=await G.storage.from("brokerage-resources").upload(`previews/${Ye}`,i);if(tt)throw tt;const{data:Te}=G.storage.from("brokerage-resources").getPublicUrl(`previews/${Ye}`);ye=Te.publicUrl}const ct={title:o.title,description:o.description||null,preview_image_url:ye,publish_date:o.publish_date,is_published:o.is_published,category_id:o.category_id||null};let fe;if(n){const{error:$e}=await G.from("brokerage_resources").update(ct).eq("id",n.id);if($e)throw $e;fe=n.id;const Ye=(B==null?void 0:B.filter(mt=>mt.resource_id===n.id).map(mt=>mt.id))||[],tt=f.filter(mt=>mt.id).map(mt=>mt.id),Te=Ye.filter(mt=>!tt.includes(mt));Te.length>0&&await G.from("brokerage_resource_pdfs").delete().in("id",Te);const We=(U==null?void 0:U.filter(mt=>mt.resource_id===n.id).map(mt=>mt.id))||[],Ke=_.filter(mt=>mt.id).map(mt=>mt.id),ot=We.filter(mt=>!Ke.includes(mt));ot.length>0&&await G.from("brokerage_resource_videos").delete().in("id",ot);const He=(te==null?void 0:te.filter(mt=>mt.resource_id===n.id).map(mt=>mt.id))||[],Je=N.filter(mt=>mt.id).map(mt=>mt.id),ut=He.filter(mt=>!Je.includes(mt));ut.length>0&&await G.from("brokerage_resource_links").delete().in("id",ut)}else{const{data:$e,error:Ye}=await G.from("brokerage_resources").insert(ct).select().single();if(Ye)throw Ye;fe=$e.id}for(let $e=0;$e{t.invalidateQueries({queryKey:["brokerage-resources"]}),t.invalidateQueries({queryKey:["brokerage-resource-pdfs"]}),t.invalidateQueries({queryKey:["brokerage-resource-videos"]}),t.invalidateQueries({queryKey:["brokerage-resource-links"]}),pe.success(n?"Resource updated":"Resource created"),r(!1),X(),C(!1)},onError:ye=>{pe.error("Failed to save resource: "+ye.message),C(!1)}}),Ne=Pt({mutationFn:async ye=>{const{error:ct}=await G.from("brokerage_resources").delete().eq("id",ye);if(ct)throw ct},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-resources"]}),t.invalidateQueries({queryKey:["brokerage-resource-pdfs"]}),t.invalidateQueries({queryKey:["brokerage-resource-videos"]}),t.invalidateQueries({queryKey:["brokerage-resource-links"]}),pe.success("Resource deleted")},onError:ye=>{pe.error("Failed to delete: "+ye.message)}}),Ue=ye=>{if(ye.preventDefault(),!o.title){pe.error("Please enter a title");return}Ve.mutate()},Ie=ye=>{const ct=(B==null?void 0:B.filter(Ye=>Ye.resource_id===ye).length)||0,fe=(U==null?void 0:U.filter(Ye=>Ye.resource_id===ye).length)||0,$e=(te==null?void 0:te.filter(Ye=>Ye.resource_id===ye).length)||0;return{pdfCount:ct,videoCount:fe,linkCount:$e}};return e.jsx(Ds,{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(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Resources"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(V==null?void 0:V.length)||0})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(V==null?void 0:V.filter(ye=>ye.is_published).length)||0})})]})]}),e.jsxs(W,{onClick:()=>{X(),r(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Resource"]})]}),e.jsx(Pe,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Category"}),e.jsx(St,{children:"Content"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:q?e.jsx(Ps,{children:e.jsx(ht,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):(V==null?void 0:V.length)===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No brokerage resources yet. Create your first one!"})}):V==null?void 0:V.map(ye=>{const{pdfCount:ct,videoCount:fe,linkCount:$e}=Ie(ye.id),Ye=Y==null?void 0:Y.find(tt=>tt.id===ye.category_id);return e.jsxs(Ps,{children:[e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[ye.preview_image_url?e.jsx("img",{src:ye.preview_image_url,alt:ye.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(dh,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:ye.title}),ye.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:ye.description})]})]})}),e.jsx(ht,{children:Ye?e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-muted",children:Ye.name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(ht,{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(vn,{className:"h-3.5 w-3.5"}),ct]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(yn,{className:"h-3.5 w-3.5"}),fe]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(vo,{className:"h-3.5 w-3.5"}),$e]})]})}),e.jsx(ht,{children:vs(new Date(ye.publish_date),"MMM d, yyyy")}),e.jsx(ht,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${ye.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:ye.is_published?"Published":"Draft"})}),e.jsx(ht,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>{const tt=(B==null?void 0:B.filter(Ke=>Ke.resource_id===ye.id))||[],Te=(U==null?void 0:U.filter(Ke=>Ke.resource_id===ye.id))||[],We=(te==null?void 0:te.filter(Ke=>Ke.resource_id===ye.id))||[];I({...ye,pdfs:tt,videos:Te,links:We})},children:e.jsx(jn,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>ce(ye),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource?")&&Ne.mutate(ye.id)},children:e.jsx(vr,{className:"h-4 w-4 text-destructive"})})]})})]},ye.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(ks,{children:e.jsx(_s,{children:n?"Edit Brokerage Resource":"Add Brokerage Resource"})}),e.jsxs("form",{onSubmit:Ue,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{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(dh,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(De,{type:"file",accept:"image/*",onChange:ie})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"title",children:"Title *"}),e.jsx(De,{id:"title",value:o.title,onChange:ye=>l({...o,title:ye.target.value}),placeholder:"Resource Title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{className:"flex items-center gap-2",children:[e.jsx(mh,{className:"h-4 w-4"}),"Category"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs($s,{value:o.category_id,onValueChange:ye=>l({...o,category_id:ye}),children:[e.jsx(zs,{className:"flex-1",children:e.jsx(Vs,{placeholder:"Select a category"})}),e.jsx(Bs,{children:Y==null?void 0:Y.map(ye=>e.jsx(vt,{value:ye.id,children:ye.name},ye.id))})]}),o.category_id&&e.jsx(W,{type:"button",variant:"ghost",size:"icon",onClick:()=>l({...o,category_id:""}),children:e.jsx(kr,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{placeholder:"Or create new category...",value:L,onChange:ye=>O(ye.target.value),className:"flex-1"}),e.jsxs(W,{type:"button",variant:"outline",size:"sm",disabled:!L.trim()||Re.isPending,onClick:()=>Re.mutate(L.trim()),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Description"}),e.jsx(Wg,{content:o.description,onChange:ye=>l({...o,description:ye}),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(xe,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(De,{id:"publish_date",type:"date",value:o.publish_date,onChange:ye=>l({...o,publish_date:ye.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Published"}),e.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[e.jsx(Ar,{checked:o.is_published,onCheckedChange:ye=>l({...o,is_published:ye})}),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(xe,{className:"flex items-center gap-2",children:[e.jsx(vn,{className:"h-4 w-4"}),"PDF Documents (",f.length,")"]}),e.jsxs(W,{type:"button",variant:"outline",size:"sm",onClick:ae,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add PDF"]})]}),f.map((ye,ct)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/50",children:[e.jsx(De,{placeholder:"PDF Name",value:ye.name,onChange:fe=>me(ct,"name",fe.target.value),className:"flex-1"}),e.jsx(De,{type:"file",accept:".pdf",onChange:fe=>{var Ye;const $e=(Ye=fe.target.files)==null?void 0:Ye[0];$e&&me(ct,"file",$e)},className:"flex-1"}),ye.file_url&&!ye.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Uploaded"}),e.jsx(W,{type:"button",variant:"ghost",size:"icon",onClick:()=>oe(ct),children:e.jsx(kr,{className:"h-4 w-4"})})]},ct))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(xe,{className:"flex items-center gap-2",children:[e.jsx(yn,{className:"h-4 w-4"}),"Videos (",_.length,")"]}),e.jsxs(W,{type:"button",variant:"outline",size:"sm",onClick:ve,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Video"]})]}),_.map((ye,ct)=>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(De,{placeholder:"Video Title",value:ye.title,onChange:fe=>ge(ct,"title",fe.target.value),className:"flex-1"}),e.jsx(W,{type:"button",variant:"ghost",size:"icon",onClick:()=>he(ct),children:e.jsx(kr,{className:"h-4 w-4"})})]}),e.jsx(De,{type:"file",accept:"video/*",onChange:fe=>{var Ye;const $e=(Ye=fe.target.files)==null?void 0:Ye[0];$e&&ge(ct,"file",$e)}}),ye.uploadProgress!==void 0&&ye.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:`${ye.uploadProgress}%`}})}),ye.video_url&&!ye.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Video uploaded"})]},ct))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(xe,{className:"flex items-center gap-2",children:[e.jsx(vo,{className:"h-4 w-4"}),"Canva Links (",N.length,")"]}),e.jsxs(W,{type:"button",variant:"outline",size:"sm",onClick:je,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),N.map((ye,ct)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/50",children:[e.jsx(De,{placeholder:"Link Title",value:ye.title,onChange:fe=>Me(ct,"title",fe.target.value),className:"flex-1"}),e.jsx(De,{placeholder:"Canva Share Link",value:ye.canva_share_link,onChange:fe=>Me(ct,"canva_share_link",fe.target.value),className:"flex-1"}),e.jsx(W,{type:"button",variant:"ghost",size:"icon",onClick:()=>qe(ct),children:e.jsx(kr,{className:"h-4 w-4"})})]},ct))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(W,{type:"submit",disabled:Ve.isPending||S,children:Ve.isPending||S?"Saving...":n?"Update":"Create"})]})]})]})}),e.jsx(fs,{open:!!A,onOpenChange:()=>I(null),children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(_s,{children:A==null?void 0:A.title})}),A&&e.jsxs("div",{className:"space-y-4",children:[A.preview_image_url&&e.jsx("img",{src:A.preview_image_url,alt:A.title,className:"w-full h-48 object-cover rounded-lg"}),A.description&&e.jsx("p",{className:"text-muted-foreground",children:A.description}),A.pdfs&&A.pdfs.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(vn,{className:"h-4 w-4"}),"PDF Documents (",A.pdfs.length,")"]}),e.jsx("div",{className:"space-y-1",children:A.pdfs.map(ye=>e.jsx("a",{href:ye.file_url,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:ye.name},ye.id))})]}),A.videos&&A.videos.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(yn,{className:"h-4 w-4"}),"Videos (",A.videos.length,")"]}),e.jsx("div",{className:"space-y-2",children:A.videos.map(ye=>e.jsx("div",{className:"p-2 border rounded",children:e.jsx("p",{className:"font-medium text-sm",children:ye.title})},ye.id))})]}),A.links&&A.links.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(vo,{className:"h-4 w-4"}),"Canva Links (",A.links.length,")"]}),e.jsx("div",{className:"space-y-1",children:A.links.map(ye=>e.jsx("a",{href:ye.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:ye.title},ye.id))})]})]})]})})]})})}const Pat=[{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 t1s(){const[t,s]=k.useState([]),[r,n]=k.useState(!0),[a,o]=k.useState(!1),[l,i]=k.useState(!1),[d,u]=k.useState(null),[p,f]=k.useState(!1),[y,_]=k.useState(!1),[b,N]=k.useState(""),[w,S]=k.useState(""),[C,A]=k.useState(""),[I,L]=k.useState(""),[O,V]=k.useState("Learn More"),[q,B]=k.useState("top"),[U,te]=k.useState(""),[Y,J]=k.useState(!0),[X,ce]=k.useState(""),[ie,ae]=k.useState("");k.useEffect(()=>{oe()},[]);const oe=async()=>{try{const{data:Re,error:Ve}=await G.from("dashboard_banners").select("*").order("placement").order("sort_order");if(Ve)throw Ve;s(Re||[])}catch(Re){pe.error("Failed to load banners: "+Re.message)}finally{n(!1)}},me=()=>{N(""),S(""),A(""),L(""),V("Learn More"),B("top"),te(""),J(!0),ce(""),ae(""),u(null)},ve=Re=>{u(Re),N(Re.title),S(Re.description||""),A(Re.image_url),L(Re.link_url||""),V(Re.link_text||"Learn More"),B(Re.placement),te(Re.section_after||""),J(Re.is_active),ce(Re.start_date?vs(new Date(Re.start_date),"yyyy-MM-dd'T'HH:mm"):""),ae(Re.end_date?vs(new Date(Re.end_date),"yyyy-MM-dd'T'HH:mm"):""),o(!0)},he=async Re=>{var Ne;const Ve=(Ne=Re.target.files)==null?void 0:Ne[0];if(Ve){f(!0);try{const Ue=Ve.name.split(".").pop(),Ie=`${Date.now()}.${Ue}`,{error:ye}=await G.storage.from("banner-images").upload(Ie,Ve);if(ye)throw ye;const{data:{publicUrl:ct}}=G.storage.from("banner-images").getPublicUrl(Ie);A(ct),pe.success("Image uploaded successfully")}catch(Ue){pe.error("Failed to upload image: "+Ue.message)}finally{f(!1)}}},ge=async()=>{if(!b.trim()||!C){pe.error("Please fill in required fields (title and image)");return}_(!0);try{const Re={title:b.trim(),description:w.trim()||null,image_url:C,link_url:I.trim()||null,link_text:O.trim()||"Learn More",placement:q,section_after:q==="between"?U:null,is_active:Y,start_date:X?new Date(X).toISOString():null,end_date:ie?new Date(ie).toISOString():null};if(d){const{error:Ve}=await G.from("dashboard_banners").update(Re).eq("id",d.id);if(Ve)throw Ve;pe.success("Banner updated successfully")}else{const Ve=t.filter(Ue=>Ue.placement===q).length,{error:Ne}=await G.from("dashboard_banners").insert({...Re,sort_order:Ve});if(Ne)throw Ne;pe.success("Banner created successfully")}o(!1),me(),oe()}catch(Re){pe.error("Failed to save banner: "+Re.message)}finally{_(!1)}},je=async()=>{if(d)try{const{error:Re}=await G.from("dashboard_banners").delete().eq("id",d.id);if(Re)throw Re;pe.success("Banner deleted successfully"),i(!1),u(null),oe()}catch(Re){pe.error("Failed to delete banner: "+Re.message)}},qe=async Re=>{try{const{error:Ve}=await G.from("dashboard_banners").update({is_active:!Re.is_active}).eq("id",Re.id);if(Ve)throw Ve;pe.success(Re.is_active?"Banner deactivated":"Banner activated"),oe()}catch(Ve){pe.error("Failed to update banner: "+Ve.message)}},Me=t.filter(Re=>Re.placement==="top"),ke=t.filter(Re=>Re.placement==="between");return r?e.jsx(Ds,{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(Ds,{title:"Dashboard Management",description:"Configure dashboard modules and banners",children:[e.jsxs("div",{className:"space-y-8",children:[e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(qo,{className:"h-5 w-5"}),"Hero Banners (Top of Dashboard)"]}),e.jsx(dr,{children:"These banners appear in a rotating carousel at the top of the dashboard"})]}),e.jsxs(fs,{open:a&&q==="top",onOpenChange:Re=>{Re||me(),o(Re),Re&&B("top")},children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{onClick:()=>{me(),B("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(ks,{children:[e.jsxs(_s,{children:[d?"Edit":"Create"," Banner"]}),e.jsx(Ir,{children:"Configure the banner's content and display settings"})]}),e.jsx(j7e,{title:b,setTitle:N,description:w,setDescription:S,imageUrl:C,linkUrl:I,setLinkUrl:L,linkText:O,setLinkText:V,placement:q,setPlacement:B,sectionAfter:U,setSectionAfter:te,isActive:Y,setIsActive:J,startDate:X,setStartDate:ce,endDate:ie,setEndDate:ae,handleImageUpload:he,uploading:p,showPlacementOptions:!1}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>{o(!1),me()},children:"Cancel"}),e.jsx(W,{onClick:ge,disabled:y,children:y?"Saving...":d?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(Oe,{children:Me.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No hero banners yet. Add your first banner above."}):e.jsx("div",{className:"space-y-3",children:Me.map(Re=>e.jsx(N7e,{banner:Re,onEdit:()=>ve(Re),onDelete:()=>{u(Re),i(!0)},onToggleActive:()=>qe(Re)},Re.id))})})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(qo,{className:"h-5 w-5"}),"Section Banners"]}),e.jsx(dr,{children:"These banners appear between dashboard content sections"})]}),e.jsxs(fs,{open:a&&q==="between",onOpenChange:Re=>{Re||me(),o(Re),Re&&B("between")},children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{onClick:()=>{me(),B("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(ks,{children:[e.jsxs(_s,{children:[d?"Edit":"Create"," Section Banner"]}),e.jsx(Ir,{children:"Configure where this banner appears between sections"})]}),e.jsx(j7e,{title:b,setTitle:N,description:w,setDescription:S,imageUrl:C,linkUrl:I,setLinkUrl:L,linkText:O,setLinkText:V,placement:q,setPlacement:B,sectionAfter:U,setSectionAfter:te,isActive:Y,setIsActive:J,startDate:X,setStartDate:ce,endDate:ie,setEndDate:ae,handleImageUpload:he,uploading:p,showPlacementOptions:!0}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>{o(!1),me()},children:"Cancel"}),e.jsx(W,{onClick:ge,disabled:y,children:y?"Saving...":d?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(Oe,{children:ke.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:ke.map(Re=>e.jsx(N7e,{banner:Re,onEdit:()=>ve(Re),onDelete:()=>{u(Re),i(!0)},onToggleActive:()=>qe(Re),showSection:!0},Re.id))})})]})]}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ps,{children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Delete Banner"}),e.jsxs(Ir,{children:['Are you sure you want to delete "',d==null?void 0:d.title,'"? This action cannot be undone.']})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(W,{variant:"destructive",onClick:je,children:"Delete"})]})]})})]})}function j7e({title:t,setTitle:s,description:r,setDescription:n,imageUrl:a,linkUrl:o,setLinkUrl:l,linkText:i,setLinkText:d,placement:u,setPlacement:p,sectionAfter:f,setSectionAfter:y,isActive:_,setIsActive:b,startDate:N,setStartDate:w,endDate:S,setEndDate:C,handleImageUpload:A,uploading:I,showPlacementOptions:L}){return e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"title",children:"Title *"}),e.jsx(De,{id:"title",placeholder:"Banner headline...",value:t,onChange:O=>s(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"description",children:"Description"}),e.jsx(_r,{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(xe,{children:"Banner Image *"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(De,{type:"file",accept:"image/*",onChange:A,disabled:I,className:"flex-1"}),I&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),a&&e.jsx("div",{className:"mt-2 relative rounded-lg overflow-hidden border",children:e.jsx("img",{src:a,alt:"Preview",className:"w-full h-40 object-cover"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"linkUrl",children:"Link URL (optional)"}),e.jsx(De,{id:"linkUrl",placeholder:"https://...",value:o,onChange:O=>l(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"linkText",children:"Button Text"}),e.jsx(De,{id:"linkText",placeholder:"Learn More",value:i,onChange:O=>d(O.target.value)})]})]}),L&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Placement"}),e.jsxs($s,{value:f,onValueChange:y,children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select section placement..."})}),e.jsx(Bs,{children:Pat.map(O=>e.jsx(vt,{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(xe,{htmlFor:"startDate",className:"flex items-center gap-2",children:[e.jsx(cn,{className:"h-4 w-4"}),"Start Date (optional)"]}),e.jsx(De,{id:"startDate",type:"datetime-local",value:N,onChange:O=>w(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{htmlFor:"endDate",className:"flex items-center gap-2",children:[e.jsx(cn,{className:"h-4 w-4"}),"End Date (optional)"]}),e.jsx(De,{id:"endDate",type:"datetime-local",value:S,onChange:O=>C(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(Ar,{id:"isActive",checked:_,onCheckedChange:b}),e.jsx(xe,{htmlFor:"isActive",children:"Active"})]})})]})}function N7e({banner:t,onEdit:s,onDelete:r,onToggleActive:n,showSection:a=!1}){var d;const o=(d=Pat.find(u=>u.value===t.section_after))==null?void 0:d.label,[l,i]=k.useState(null);return k.useEffect(()=>{(async()=>{const{count:p}=await G.from("content_engagement_logs").select("*",{count:"exact",head:!0}).eq("resource_id",t.id).eq("action_type","click_link");i(p??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(mu,{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(Qe,{variant:"secondary",children:"Inactive"}),t.start_date&&new Date(t.start_date)>new Date&&e.jsx(Qe,{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(Tm,{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(W,{variant:"ghost",size:"icon",children:e.jsx(Yr,{className:"h-4 w-4"})})}),e.jsx(W,{variant:"ghost",size:"icon",onClick:n,children:t.is_active?e.jsx(jn,{className:"h-4 w-4"}):e.jsx(pp,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",onClick:s,children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(vr,{className:"h-4 w-4 text-destructive"})})]})]})}const y9={open:{label:"Open",icon:nn,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:Fl,color:"bg-blue-500"},resolved:{label:"Resolved",icon:si,color:"bg-green-500"},closed:{label:"Closed",icon:Jl,color:"bg-muted-foreground"}},k7e={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function s1s(){var O,V;const{user:t}=Us(),s=Qt(),[r,n]=k.useState(null),[a,o]=k.useState(""),[l,i]=k.useState("all"),[d,u]=k.useState("all"),[p,f]=k.useState(!1),{data:y=[],isLoading:_}=gt({queryKey:["admin-support-tickets",l,d],queryFn:async()=>{let q=G.from("support_tickets").select("*, profiles!support_tickets_user_id_fkey(name, email)").order("created_at",{ascending:!1});l!=="all"&&(q=q.eq("status",l)),d!=="all"&&(q=q.eq("category",d));const{data:B,error:U}=await q;if(U)throw U;return B}}),{data:b=[]}=gt({queryKey:["admin-users-notifications"],queryFn:async()=>{const{data:q,error:B}=await G.from("user_roles").select("user_id").eq("role","admin");if(B)throw B;const U=q.map(ie=>ie.user_id),{data:te,error:Y}=await G.from("profiles").select("id, name, email").in("id",U);if(Y)throw Y;const{data:J,error:X}=await G.from("support_notification_settings").select("user_id, receive_notifications");if(X)throw X;const ce=new Map((J==null?void 0:J.map(ie=>[ie.user_id,ie.receive_notifications]))||[]);return te.map(ie=>({...ie,receives_notifications:ce.get(ie.id)||!1}))}}),{data:N=[]}=gt({queryKey:["admin-ticket-replies",r==null?void 0:r.id],queryFn:async()=>{if(!r)return[];const{data:q,error:B}=await G.from("support_ticket_replies").select("*, profiles(name)").eq("ticket_id",r.id).order("created_at",{ascending:!0});if(B)throw B;return q},enabled:!!r}),w=Pt({mutationFn:async({userId:q,enabled:B})=>{const{data:U}=await G.from("support_notification_settings").select("id").eq("user_id",q).maybeSingle();if(U){const{error:te}=await G.from("support_notification_settings").update({receive_notifications:B}).eq("user_id",q);if(te)throw te}else{const{error:te}=await G.from("support_notification_settings").insert({user_id:q,receive_notifications:B});if(te)throw te}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-users-notifications"]}),pe.success("Notification settings updated")},onError:()=>{pe.error("Failed to update settings")}}),S=Pt({mutationFn:async({ticketId:q,status:B})=>{const{error:U}=await G.from("support_tickets").update({status:B}).eq("id",q);if(U)throw U},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]}),r&&n({...r,status:r.status}),pe.success("Status updated")},onError:()=>{pe.error("Failed to update status")}}),C=Pt({mutationFn:async({ticketId:q,assignedTo:B})=>{const{error:U}=await G.from("support_tickets").update({assigned_to:B}).eq("id",q);if(U)throw U},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]}),pe.success("Ticket assigned")},onError:()=>{pe.error("Failed to assign ticket")}}),A=Pt({mutationFn:async q=>{var U,te;if(!r||!t)throw new Error("Missing data");const{error:B}=await G.from("support_ticket_replies").insert({ticket_id:r.id,user_id:t.id,content:q,is_admin_reply:!0});if(B)throw B;try{await G.functions.invoke("support-reply-notify",{body:{ticketId:r.id,ticketSubject:r.subject,replyContent:q,userEmail:(U=r.profiles)==null?void 0:U.email,userName:(te=r.profiles)==null?void 0:te.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(""),pe.success("Reply sent!")},onError:()=>{pe.error("Failed to send reply")}}),I=()=>{a.trim()&&A.mutate(a)};k.useEffect(()=>{const q=G.channel("admin-tickets").on("postgres_changes",{event:"*",schema:"public",table:"support_tickets"},()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]})}).subscribe();return()=>{G.removeChannel(q)}},[s]);const L=y.filter(q=>q.status==="open").length;return r?(y9[r.status].icon,e.jsx(Ds,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>n(null),children:e.jsx(Oa,{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(Qe,{variant:"secondary",children:k7e[r.category]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["from ",((O=r.profiles)==null?void 0:O.name)||"Unknown"," (",(V=r.profiles)==null?void 0:V.email,")"]})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm",children:"Status"})}),e.jsx(Oe,{children:e.jsxs($s,{value:r.status,onValueChange:q=>{S.mutate({ticketId:r.id,status:q}),n({...r,status:q})},children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"open",children:"Open"}),e.jsx(vt,{value:"in_progress",children:"In Progress"}),e.jsx(vt,{value:"resolved",children:"Resolved"}),e.jsx(vt,{value:"closed",children:"Closed"})]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm",children:"Assigned To"})}),e.jsx(Oe,{children:e.jsxs($s,{value:r.assigned_to||"unassigned",onValueChange:q=>{const B=q==="unassigned"?null:q;C.mutate({ticketId:r.id,assignedTo:B}),n({...r,assigned_to:B})},children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Unassigned"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"unassigned",children:"Unassigned"}),b.map(q=>e.jsx(vt,{value:q.id,children:q.name},q.id))]})]})})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(dr,{children:["Created on ",vs(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"Conversation"})}),e.jsxs(Oe,{children:[e.jsx(Ja,{className:"h-[300px] pr-4",children:N.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:N.map(q=>{var B,U;return e.jsxs("div",{className:`p-4 rounded-lg ${q.is_admin_reply?"bg-primary/10 ml-4":"bg-muted mr-4"}`,children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsx("span",{className:"font-medium text-sm",children:q.is_admin_reply?`${((B=q.profiles)==null?void 0:B.name)||"Admin"} (Support)`:((U=q.profiles)==null?void 0:U.name)||"User"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:vs(new Date(q.created_at),"MMM d, h:mm a")})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:q.content})]},q.id)})})}),e.jsx(ho,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(_r,{placeholder:"Type your reply...",value:a,onChange:q=>o(q.target.value),className:"min-h-[80px]"}),e.jsx(W,{onClick:I,disabled:!a.trim()||A.isPending,className:"self-end",children:e.jsx(_n,{className:"h-4 w-4"})})]})]})]})]})})):e.jsx(Ds,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Support Tickets"}),e.jsxs("p",{className:"text-muted-foreground",children:["Manage support requests from agents",L>0&&e.jsxs(Qe,{variant:"destructive",className:"ml-2",children:[L," open"]})]})]}),e.jsxs(fs,{open:p,onOpenChange:f,children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{variant:"outline",children:[e.jsx(So,{className:"h-4 w-4 mr-2"}),"Notification Settings"]})}),e.jsxs(ps,{children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Email Notification Settings"}),e.jsx(Ir,{children:"Choose which admins receive email notifications for new support tickets."})]}),e.jsx("div",{className:"space-y-4 mt-4",children:b.map(q=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ai,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:q.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:q.email})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[q.receives_notifications?e.jsx(Sm,{className:"h-4 w-4 text-primary"}):e.jsx(Wv,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Ar,{checked:q.receives_notifications,onCheckedChange:B=>w.mutate({userId:q.id,enabled:B})})]})]},q.id))})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[e.jsx(ta,{value:l,onValueChange:i,className:"w-auto",children:e.jsxs(Jn,{children:[e.jsx(cs,{value:"all",children:"All"}),e.jsx(cs,{value:"open",children:"Open"}),e.jsx(cs,{value:"in_progress",children:"In Progress"}),e.jsx(cs,{value:"resolved",children:"Resolved"}),e.jsx(cs,{value:"closed",children:"Closed"})]})}),e.jsxs($s,{value:d,onValueChange:u,children:[e.jsx(zs,{className:"w-[180px]",children:e.jsx(Vs,{placeholder:"All Categories"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Categories"}),e.jsx(vt,{value:"general",children:"General Support"}),e.jsx(vt,{value:"technology",children:"Technology Support"}),e.jsx(vt,{value:"crm",children:"CRM Support"}),e.jsx(vt,{value:"marketing",children:"Marketing Support"})]})]})]}),e.jsx("div",{className:"mt-4",children:_?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading tickets..."}):y.length===0?e.jsx(Pe,{children:e.jsxs(Oe,{className:"text-center py-12",children:[e.jsx(Fl,{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:y.map(q=>{var U,te;const B=y9[q.status].icon;return e.jsx(Pe,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(q),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium truncate",children:q.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[e.jsx(Qe,{variant:"outline",className:"text-xs",children:k7e[q.category]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(U=q.profiles)==null?void 0:U.name," • ",vs(new Date(q.created_at),"MMM d, yyyy")]}),q.assigned_to&&e.jsxs(Qe,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Ai,{className:"h-3 w-3"}),((te=b.find(Y=>Y.id===q.assigned_to))==null?void 0:te.name)||"Assigned"]})]})]}),e.jsxs(Qe,{className:y9[q.status].color,children:[e.jsx(B,{className:"h-3 w-3 mr-1"}),y9[q.status].label]})]})})},q.id)})})})]})]})})}const Iat=xh.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 r1s({content:t,onChange:s,variables:r}){const n=Oke({extensions:[zke,Zke.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),Yke.configure({types:["heading","paragraph"]}),Xke,Iat],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(W,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleBold().run(),className:n.isActive("bold")?"bg-muted":"",children:e.jsx(K4,{className:"h-4 w-4"})}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleItalic().run(),className:n.isActive("italic")?"bg-muted":"",children:e.jsx(rS,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleBulletList().run(),className:n.isActive("bulletList")?"bg-muted":"",children:e.jsx(Dh,{className:"h-4 w-4"})}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleOrderedList().run(),className:n.isActive("orderedList")?"bg-muted":"",children:e.jsx(Xy,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("left").run(),className:n.isActive({textAlign:"left"})?"bg-muted":"",children:e.jsx(H4,{className:"h-4 w-4"})}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("center").run(),className:n.isActive({textAlign:"center"})?"bg-muted":"",children:e.jsx(V4,{className:"h-4 w-4"})}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("right").run(),className:n.isActive({textAlign:"right"})?"bg-muted":"",children:e.jsx(G4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",onClick:o,className:n.isActive("link")?"bg-muted":"",children:e.jsx(vo,{className:"h-4 w-4"})}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleCodeBlock().run(),className:n.isActive("codeBlock")?"bg-muted":"",children:e.jsx(Y4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().undo().run(),disabled:!n.can().undo(),children:e.jsx(wS,{className:"h-4 w-4"})}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().redo().run(),disabled:!n.can().redo(),children:e.jsx(fS,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1"}),r.length>0&&e.jsxs(Hd,{children:[e.jsx(Gd,{asChild:!0,children:e.jsxs(W,{type:"button",variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(FM,{className:"h-4 w-4"}),"Insert Variable"]})}),e.jsx(Nd,{align:"end",className:"w-64",children:r.map(l=>e.jsxs(_a,{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(Dke,{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(Qe,{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 n1s(){const t=Qt(),[s,r]=k.useState(null),[n,a]=k.useState(null),[o,l]=k.useState(""),[i,d]=k.useState(""),[u,p]=k.useState(""),[f,y]=k.useState(!0),[_,b]=k.useState("visual"),{data:N,isLoading:w}=gt({queryKey:["email-templates"],queryFn:async()=>{const{data:L,error:O}=await G.from("email_templates").select("*").order("name");if(O)throw O;return L.map(V=>({...V,available_variables:V.available_variables||[]}))}}),S=Pt({mutationFn:async L=>{const{error:O}=await G.from("email_templates").update({subject:L.subject,body_html:L.body_html,description:L.description,is_active:L.is_active}).eq("id",L.id);if(O)throw O},onSuccess:()=>{t.invalidateQueries({queryKey:["email-templates"]}),pe.success("Email template updated successfully"),r(null)},onError:L=>{pe.error("Failed to update template: "+L.message)}}),C=L=>{r(L),l(L.subject),d(L.body_html),p(L.description||""),y(L.is_active),b("visual")},A=()=>{s&&S.mutate({id:s.id,subject:o,body_html:i,description:u,is_active:f})},I=(L,O)=>{let V=L;return O.forEach(q=>{const B=`{{${q.key}}}`,U=`[${q.label}]`;V=V.replace(new RegExp(B.replace(/[{}]/g,"\\$&"),"g"),U)}),V};return s?e.jsxs(Ds,{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(W,{variant:"ghost",onClick:()=>r(null),children:[e.jsx(Oa,{className:"h-4 w-4 mr-2"}),"Back to Templates"]}),e.jsx("div",{className:"flex-1"}),e.jsxs(W,{variant:"outline",onClick:()=>a(s),children:[e.jsx(jn,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(W,{onClick:A,disabled:S.isPending,children:[e.jsx(bc,{className:"h-4 w-4 mr-2"}),S.isPending?"Saving...":"Save Changes"]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(tr,{className:"h-5 w-5"}),s.name]}),e.jsxs(dr,{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(xe,{htmlFor:"active-toggle",children:"Active"}),e.jsx(Ar,{id:"active-toggle",checked:f,onCheckedChange:y})]})]})}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"description",children:"Description"}),e.jsx(_r,{id:"description",value:u,onChange:L=>p(L.target.value),placeholder:"Brief description of when this email is sent",rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"subject",children:"Email Subject"}),e.jsx(De,{id:"subject",value:o,onChange:L=>l(L.target.value),placeholder:"Email subject line"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["You can use variables like ","{{name}}"," in the subject"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{children:"Email Body"}),e.jsx(ta,{value:_,onValueChange:L=>b(L),children:e.jsxs(Jn,{className:"h-8",children:[e.jsxs(cs,{value:"visual",className:"text-xs px-3 h-6",children:[e.jsx(hS,{className:"h-3 w-3 mr-1"}),"Visual"]}),e.jsxs(cs,{value:"html",className:"text-xs px-3 h-6",children:[e.jsx(Y4,{className:"h-3 w-3 mr-1"}),"HTML"]})]})})]}),_==="visual"?e.jsx(r1s,{content:i,onChange:d,variables:s.available_variables}):e.jsx(_r,{value:i,onChange:L=>d(L.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(ks,{children:[e.jsx(_s,{children:"Email Preview"}),e.jsxs(Ir,{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(Ds,{title:"Email Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Email Templates"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Manage and customize system email templates"})]}),w?e.jsx("div",{className:"grid gap-4",children:[...Array(4)].map((L,O)=>e.jsx(Pe,{children:e.jsxs(Dt,{children:[e.jsx(Ms,{className:"h-5 w-48"}),e.jsx(Ms,{className:"h-4 w-96"})]})},O))}):e.jsx("div",{className:"grid gap-4",children:N==null?void 0:N.map(L=>e.jsxs(Pe,{className:"hover:shadow-md transition-shadow",children:[e.jsx(Dt,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(zt,{className:"flex items-center gap-2 text-lg",children:[e.jsx(tr,{className:"h-5 w-5 text-muted-foreground"}),L.name,!L.is_active&&e.jsx(Qe,{variant:"secondary",children:"Inactive"})]}),e.jsx(dr,{children:L.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>a(L),children:[e.jsx(jn,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(W,{size:"sm",onClick:()=>C(L),children:[e.jsx(Wc,{className:"h-4 w-4 mr-2"}),"Edit"]})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Subject:"}),e.jsx("code",{className:"bg-muted px-2 py-0.5 rounded text-sm",children:L.subject})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Variables:"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:L.available_variables.map(O=>e.jsx(Qe,{variant:"outline",className:"font-mono text-xs",children:`{{${O.key}}}`},O.key))})]})]})})]},L.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(ks,{children:[e.jsxs(_s,{children:["Email Preview: ",n==null?void 0:n.name]}),e.jsxs(Ir,{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,d]=k.useState(!1),[u,p]=k.useState(!1),[f,y]=k.useState({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),[_,b]=k.useState({name:"",description:"",icon:"📧"}),{data:N=[]}=gt({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:U,error:te}=await G.from("email_template_categories").select("*").order("sort_order");if(te)throw te;return U}}),{data:w=[],isLoading:S}=gt({queryKey:["agent-email-templates-admin"],queryFn:async()=>{const{data:U,error:te}=await G.from("agent_email_templates").select("*, category:email_template_categories(*)").order("sort_order");if(te)throw te;return U}}),C=Pt({mutationFn:async U=>{const te={title:U.title,subject:U.subject,body:U.body,description:U.description||null,tone:U.tone||null,category_id:U.category_id||null,is_active:U.is_active};if(U.id){const{error:Y}=await G.from("agent_email_templates").update(te).eq("id",U.id);if(Y)throw Y}else{const{error:Y}=await G.from("agent_email_templates").insert(te);if(Y)throw Y}},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),d(!1),pe.success(n?"Template updated":"Template created")},onError:()=>pe.error("Failed to save template")}),A=Pt({mutationFn:async U=>{const{error:te}=await G.from("agent_email_templates").delete().eq("id",U);if(te)throw te},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),pe.success("Template deleted")}}),I=Pt({mutationFn:async U=>{const te={name:U.name,description:U.description||null,icon:U.icon};if(U.id){const{error:Y}=await G.from("email_template_categories").update(te).eq("id",U.id);if(Y)throw Y}else{const Y=N.length>0?Math.max(...N.map(X=>X.sort_order))+1:0,{error:J}=await G.from("email_template_categories").insert({...te,sort_order:Y});if(J)throw J}},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-template-categories"]}),p(!1),pe.success(o?"Category updated":"Category created")},onError:()=>pe.error("Failed to save category")}),L=Pt({mutationFn:async U=>{const{error:te}=await G.from("email_template_categories").delete().eq("id",U);if(te)throw te},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-template-categories"]}),pe.success("Category deleted")}}),O=()=>{a(null),y({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),d(!0)},V=U=>{a(U),y({title:U.title,subject:U.subject,body:U.body,description:U.description||"",tone:U.tone||"",category_id:U.category_id||"",is_active:U.is_active}),d(!0)},q=()=>{l(null),b({name:"",description:"",icon:"📧"}),p(!0)},B=U=>{l(U),b({name:U.name,description:U.description||"",icon:U.icon}),p(!0)};return e.jsx(Ds,{children:e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(Hu,{title:"Agent Email Templates",description:"Manage email templates that agents use when composing emails from Mission Control."}),e.jsxs(ta,{value:s,onValueChange:r,children:[e.jsxs(Jn,{children:[e.jsxs(cs,{value:"templates",className:"gap-2",children:[e.jsx(tr,{className:"h-4 w-4"})," Templates"]}),e.jsxs(cs,{value:"categories",className:"gap-2",children:[e.jsx(Mm,{className:"h-4 w-4"})," Categories"]})]}),e.jsxs(Ss,{value:"templates",className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(W,{onClick:O,className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"})," Add Template"]})}),e.jsx(Pe,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Template"}),e.jsx(St,{className:"hidden md:table-cell",children:"Category"}),e.jsx(St,{className:"hidden md:table-cell",children:"Tone"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:S?e.jsx(Ps,{children:e.jsx(ht,{colSpan:5,className:"text-center py-8",children:e.jsx(us,{className:"h-6 w-6 animate-spin mx-auto"})})}):w.length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No templates yet. Create your first one!"})}):w.map(U=>e.jsxs(Ps,{children:[e.jsx(ht,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:U.title}),e.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-[300px]",children:U.subject})]})}),e.jsx(ht,{className:"hidden md:table-cell",children:U.category?e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[U.category.icon," ",U.category.name]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(ht,{className:"hidden md:table-cell",children:U.tone?e.jsx(Qe,{variant:"secondary",children:U.tone}):"—"}),e.jsx(ht,{children:e.jsx(Qe,{variant:U.is_active?"default":"secondary",children:U.is_active?"Active":"Inactive"})}),e.jsx(ht,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>V(U),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&A.mutate(U.id)},children:e.jsx(vr,{className:"h-4 w-4"})})]})})]},U.id))})]})})})]}),e.jsxs(Ss,{value:"categories",className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(W,{onClick:q,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:N.map(U=>e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx("span",{className:"text-lg",children:U.icon})," ",U.name]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>B(U),children:e.jsx(ga,{className:"h-3.5 w-3.5"})}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:()=>{confirm("Delete this category?")&&L.mutate(U.id)},children:e.jsx(vr,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:U.description||"No description"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[w.filter(te=>te.category_id===U.id).length," templates"]})]})]},U.id))})]})]}),e.jsx(fs,{open:i,onOpenChange:d,children:e.jsxs(ps,{className:"sm:max-w-[700px] max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(_s,{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(xe,{children:"Title"}),e.jsx(De,{value:f.title,onChange:U=>y(te=>({...te,title:U.target.value})),placeholder:"e.g. Quick Check-in"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Category"}),e.jsxs($s,{value:f.category_id,onValueChange:U=>y(te=>({...te,category_id:U})),children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select category"})}),e.jsx(Bs,{children:N.map(U=>e.jsxs(vt,{value:U.id,children:[U.icon," ",U.name]},U.id))})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Subject Line"}),e.jsx(De,{value:f.subject,onChange:U=>y(te=>({...te,subject:U.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(xe,{children:"Email Body"}),e.jsx(_r,{value:f.body,onChange:U=>y(te=>({...te,body:U.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(xe,{children:"Description (internal)"}),e.jsx(De,{value:f.description,onChange:U=>y(te=>({...te,description:U.target.value})),placeholder:"Short description for admin reference"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Tone"}),e.jsx(De,{value:f.tone,onChange:U=>y(te=>({...te,tone:U.target.value})),placeholder:"e.g. Warm & Casual"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ar,{checked:f.is_active,onCheckedChange:U=>y(te=>({...te,is_active:U}))}),e.jsx(xe,{children:"Active"})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(W,{onClick:()=>C.mutate({...f,id:n==null?void 0:n.id}),disabled:C.isPending||!f.title||!f.subject||!f.body,children:[C.isPending&&e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),n?"Save Changes":"Create Template"]})]})]})}),e.jsx(fs,{open:u,onOpenChange:p,children:e.jsxs(ps,{className:"sm:max-w-[450px]",children:[e.jsx(ks,{children:e.jsx(_s,{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(xe,{children:"Icon"}),e.jsx(De,{value:_.icon,onChange:U=>b(te=>({...te,icon:U.target.value})),className:"text-center text-lg"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Name"}),e.jsx(De,{value:_.name,onChange:U=>b(te=>({...te,name:U.target.value})),placeholder:"e.g. Check-in & Stay in Touch"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Description"}),e.jsx(De,{value:_.description,onChange:U=>b(te=>({...te,description:U.target.value})),placeholder:"Brief description of this category"})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>p(!1),children:"Cancel"}),e.jsxs(W,{onClick:()=>I.mutate({..._,id:o==null?void 0:o.id}),disabled:I.isPending||!_.name,children:[I.isPending&&e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),o?"Save Changes":"Create Category"]})]})]})})]})})}const i1s=({brokerageId:t})=>{var Lr,$t;const{toast:s}=ja(),r=wr(),[n,a]=k.useState([]),[o,l]=k.useState(!0),[i,d]=k.useState(""),[u,p]=k.useState("all"),[f,y]=k.useState(new Set),[_,b]=k.useState(!1),[N,w]=k.useState({}),[S,C]=k.useState(!1),[A,I]=k.useState(!1),[L,O]=k.useState({email:"",name:"",password:"",phone:""}),[V,q]=k.useState(!1),[B,U]=k.useState(null),[te,Y]=k.useState(!1),[J,X]=k.useState(!1),[ce,ie]=k.useState(!1),[ae,oe]=k.useState(""),[me,ve]=k.useState(!1),[he,ge]=k.useState([]),[je,qe]=k.useState(!1),[Me,ke]=k.useState(!1),[Re,Ve]=k.useState(null),[Ne,Ue]=k.useState({name:"",phone:"",email:""}),[Ie,ye]=k.useState(!1),[ct,fe]=k.useState(!1),[$e,Ye]=k.useState(null),[tt,Te]=k.useState("asc"),[We,Ke]=k.useState(!1),[ot,He]=k.useState(null),[Je,ut]=k.useState(!1),[mt,et]=k.useState(null),[Ze,kt]=k.useState(""),[Ut,Nt]=k.useState(!1),[es,ds]=k.useState(null);k.useEffect(()=>{lr(),js()},[t]);const js=async()=>{try{const{data:Se,error:Fe}=await G.from("brokerage_manager_assignments").select("user_id").eq("brokerage_id",t);if(Fe)throw Fe;ge((Se==null?void 0:Se.map(Xe=>Xe.user_id))||[])}catch(Se){console.error("Error loading brokerage managers:",Se)}},lr=async()=>{try{l(!0);const{data:Se,error:Fe}=await G.functions.invoke("get-brokerage-agents",{body:{brokerageId:t}});if(Fe)throw Fe;const Xe=Se.agents||[];if(a(Xe),Xe.length>0){const yt=Xe.map(At=>At.id),{data:bt}=await G.from("agent_assistant_assignments").select("agent_id, assistant_id").in("agent_id",yt);if(bt&&bt.length>0){const At=bt.map(Xt=>Xt.assistant_id),{data:Gt}=await G.from("profiles").select("id, name, email").in("id",At),Vt={};for(const Xt of bt){const Is=Gt==null?void 0:Gt.find(bs=>bs.id===Xt.assistant_id);Is&&(Vt[Xt.agent_id]={name:Is.name||"",email:Is.email||""})}w(Vt)}else w({})}}catch(Se){console.error("Error loading agents:",Se),s({title:"Error",description:"Failed to load agents",variant:"destructive"})}finally{l(!1)}},Lt=async()=>{if(!L.email||!L.name||!L.password){s({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}I(!0);try{const{data:{session:Se}}=await G.auth.getSession(),Fe=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Se==null?void 0:Se.access_token}`},body:JSON.stringify({...L,brokerageId:t})}),Xe=await Fe.json();if(!Fe.ok)throw new Error(Xe.error||"Failed to create agent");s({title:"Success",description:`Agent ${L.email} created successfully`}),O({email:"",name:"",password:"",phone:""}),C(!1),lr()}catch(Se){console.error("Error creating agent:",Se),s({title:"Error",description:Se.message||"Failed to create agent",variant:"destructive"})}finally{I(!1)}},Es=async Se=>{try{const{data:{session:Fe}}=await G.auth.getSession(),Xe=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Fe==null?void 0:Fe.access_token}`},body:JSON.stringify({userId:Se})}),yt=await Xe.json();if(!Xe.ok)throw new Error(yt.error||"Failed to resend welcome email");s({title:"Success",description:"Welcome email sent successfully"})}catch(Fe){console.error("Error resending welcome email:",Fe),s({title:"Error",description:Fe.message||"Failed to resend welcome email",variant:"destructive"})}},fr=async(Se,Fe)=>{try{const{error:Xe}=await G.functions.invoke("send-password-reset",{body:{email:Se,redirectTo:window.location.origin}});if(Xe)throw Xe;s({title:"Password Reset Sent",description:`Password reset email sent to ${Fe}`})}catch(Xe){console.error("Error sending password reset:",Xe),s({title:"Error",description:Xe.message||"Failed to send password reset email",variant:"destructive"})}},Hs=Se=>{U(Se),q(!0)},mr=Se=>{Ve(Se),Ue({name:Se.name,phone:Se.phone||"",email:Se.email}),ke(!0)},an=async()=>{if(!Re)return;if(!Ne.name.trim()){s({title:"Error",description:"Name is required",variant:"destructive"});return}const Se=Ne.email.trim().toLowerCase()!==Re.email.toLowerCase();ye(!0);try{if(Se){if(!Ne.email.trim())throw new Error("Email is required");fe(!0);const{data:{session:Xe}}=await G.auth.getSession(),yt=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Xe==null?void 0:Xe.access_token}`},body:JSON.stringify({agentId:Re.id,newEmail:Ne.email.trim(),brokerageId:t})}),bt=await yt.json();if(fe(!1),!yt.ok)throw new Error(bt.error||"Failed to update email")}const{error:Fe}=await G.from("profiles").update({name:Ne.name.trim(),phone:Ne.phone.trim()||null}).eq("id",Re.id);if(Fe)throw Fe;s({title:"Success",description:"Agent profile updated successfully"}),ke(!1),Ve(null),lr()}catch(Fe){console.error("Error updating agent:",Fe),s({title:"Error",description:Fe.message||"Failed to update agent",variant:"destructive"})}finally{ye(!1),fe(!1)}},Cr=async()=>{if(!ae){s({title:"Error",description:"Please select an agent to promote",variant:"destructive"});return}ve(!0);try{const{data:{session:Se}}=await G.auth.getSession(),Fe=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Se==null?void 0:Se.access_token}`},body:JSON.stringify({userId:ae,role:"brokerage_manager",action:"add",brokerageId:t})}),Xe=await Fe.json();if(!Fe.ok)throw new Error(Xe.error||"Failed to add brokerage manager");s({title:"Success",description:"Brokerage manager added successfully"}),ie(!1),oe(""),js()}catch(Se){console.error("Error adding brokerage manager:",Se),s({title:"Error",description:Se.message||"Failed to add brokerage manager",variant:"destructive"})}finally{ve(!1)}},Fr=async Se=>{try{const{data:{session:Fe}}=await G.auth.getSession(),Xe=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Fe==null?void 0:Fe.access_token}`},body:JSON.stringify({userId:Se,role:"brokerage_manager",action:"remove",brokerageId:t})}),yt=await Xe.json();if(!Xe.ok)throw new Error(yt.error||"Failed to remove brokerage manager");s({title:"Success",description:"Brokerage manager role removed"}),js()}catch(Fe){console.error("Error removing brokerage manager:",Fe),s({title:"Error",description:Fe.message||"Failed to remove brokerage manager",variant:"destructive"})}},$r=Se=>he.includes(Se),nr=Se=>{et(Se),kt(""),ut(!0)},cr=async()=>{if(!(!mt||!Ze)){if(Ze.length<6){s({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}Nt(!0);try{const{data:{session:Se}}=await G.auth.getSession(),Fe=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Se==null?void 0:Se.access_token}`},body:JSON.stringify({agentId:mt.id,brokerageId:t,action:"set_password",newPassword:Ze})}),Xe=await Fe.json();if(!Fe.ok)throw new Error(Xe.error||"Failed to set password");s({title:"Success",description:`Password set for ${mt.name}`}),ut(!1),et(null),kt("")}catch(Se){console.error("Error setting password:",Se),s({title:"Error",description:Se.message||"Failed to set password",variant:"destructive"})}finally{Nt(!1)}}},Br=async Se=>{ds(Se.id);try{const{data:{session:Fe}}=await G.auth.getSession(),Xe=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Fe==null?void 0:Fe.access_token}`},body:JSON.stringify({agentId:Se.id,brokerageId:t,action:"claim_account"})}),yt=await Xe.json();if(!Xe.ok)throw new Error(yt.error||"Failed to claim account");s({title:"Success",description:`Account claimed for ${Se.name}`}),lr()}catch(Fe){console.error("Error claiming account:",Fe),s({title:"Error",description:Fe.message||"Failed to claim account",variant:"destructive"})}finally{ds(null)}},Kr=async()=>{if(B){Y(!0);try{const{data:{session:Se}}=await G.auth.getSession(),Fe=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/remove-agent",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Se==null?void 0:Se.access_token}`},body:JSON.stringify({userId:B.id,brokerageId:t})}),Xe=await Fe.json();if(!Fe.ok)throw new Error(Xe.error||"Failed to remove agent");s({title:"Success",description:`${B.name} has been removed from your brokerage`}),q(!1),U(null),lr()}catch(Se){console.error("Error removing agent:",Se),s({title:"Error",description:Se.message||"Failed to remove agent",variant:"destructive"})}finally{Y(!1)}}},Sn=Se=>{const Fe=Se.trim().split(" ");return Fe.length>1?Fe[Fe.length-1].toLowerCase():Se.toLowerCase()},ai=Se=>{$e===Se?Te(tt==="asc"?"desc":"asc"):(Ye(Se),Te("asc"))},as=Se=>$e!==Se?e.jsx(td,{className:"ml-1 h-4 w-4"}):tt==="asc"?e.jsx(uu,{className:"ml-1 h-4 w-4"}):e.jsx(Ih,{className:"ml-1 h-4 w-4"}),qn=n.filter(Se=>{if(u==="active"&&!Se.claimed||u==="pending"&&Se.claimed)return!1;if(!i)return!0;const Fe=i.toLowerCase();return Se.name.toLowerCase().includes(Fe)||Se.email.toLowerCase().includes(Fe)}),un=[...qn].sort((Se,Fe)=>{if(!$e)return 0;let Xe=0;return $e==="name"?Xe=Sn(Se.name).localeCompare(Sn(Fe.name)):$e==="status"&&(Xe=Se.claimed===Fe.claimed?0:Se.claimed?-1:1),tt==="asc"?Xe:-Xe});qn.filter(Se=>Se.claimed&&!$r(Se.id));const qr=Se=>{y(Fe=>{const Xe=new Set(Fe);return Xe.has(Se)?Xe.delete(Se):Xe.add(Se),Xe})},Zr=()=>{f.size===un.length?y(new Set):y(new Set(un.map(Se=>Se.id)))},La=()=>{y(new Set)},Yt=async()=>{const Se=Array.from(f);if(Se.length===0)return;b(!0);let Fe=0,Xe=0;try{const{data:{session:yt}}=await G.auth.getSession();for(const bt of Se)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${yt==null?void 0:yt.access_token}`},body:JSON.stringify({userId:bt})})).ok?Fe++:Xe++}catch{Xe++}Fe>0?s({title:"Success",description:`Welcome emails sent to ${Fe} agent${Fe>1?"s":""}${Xe>0?` (${Xe} failed)`:""}`}):s({title:"Error",description:"Failed to send welcome emails",variant:"destructive"}),La()}catch(yt){console.error("Error bulk sending welcome emails:",yt),s({title:"Error",description:yt.message||"Failed to send welcome emails",variant:"destructive"})}finally{b(!1)}};return o?e.jsx(Pe,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Agents"}),e.jsx(dr,{children:"Manage your brokerage's agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(W,{variant:"outline",onClick:()=>ie(!0),children:[e.jsx(zu,{className:"mr-2 h-4 w-4"}),"Add Brokerage Manager"]}),e.jsxs(W,{variant:"outline",onClick:()=>X(!0),children:[e.jsx(Zv,{className:"mr-2 h-4 w-4"}),"Import CSV"]}),e.jsxs(W,{onClick:()=>C(!0),children:[e.jsx(Jo,{className:"mr-2 h-4 w-4"}),"Add Agent"]})]})]})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"mb-4 flex flex-col gap-4 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ln,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search agents...",value:i,onChange:Se=>d(Se.target.value),className:"pl-9"})]}),e.jsxs($s,{value:u,onValueChange:Se=>p(Se),children:[e.jsx(zs,{className:"w-[160px]",children:e.jsx(Vs,{placeholder:"Filter by status"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Agents"}),e.jsx(vt,{value:"active",children:"Active"}),e.jsx(vt,{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(W,{size:"sm",variant:"outline",onClick:()=>{const Fe=n.filter(Xe=>f.has(Xe.id)&&Xe.email).map(Xe=>({email:Xe.email,name:Xe.name}));sessionStorage.setItem("campaign_direct_recipients",JSON.stringify(Fe)),r("/admin/email-campaigns/new?directMode=1",{state:{directRecipients:Fe}})},disabled:_,children:[e.jsx(uh,{className:"mr-2 h-4 w-4"}),"Email Agents (",f.size,")"]}),e.jsxs(W,{size:"sm",variant:"outline",onClick:Yt,disabled:_,children:[e.jsx(tr,{className:"mr-2 h-4 w-4"}),_?"Sending...":"Resend Welcome Email"]}),e.jsx(W,{size:"sm",variant:"ghost",onClick:La,children:"Clear"})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{className:"w-[40px]",children:e.jsx(Ri,{checked:un.length>0&&f.size===un.length,onCheckedChange:Zr,"aria-label":"Select all"})}),e.jsx(St,{children:e.jsxs(W,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>ai("name"),children:["Name (Last)",as("name")]})}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:e.jsxs(W,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>ai("status"),children:["Status",as("status")]})}),e.jsx(St,{children:"Actions"})]})}),e.jsx(Rn,{children:un.length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:5,className:"text-center text-muted-foreground",children:"No agents found"})}):un.map(Se=>e.jsxs(Ps,{children:[e.jsx(ht,{children:e.jsx(Ri,{checked:f.has(Se.id),onCheckedChange:()=>qr(Se.id),"aria-label":`Select ${Se.name}`})}),e.jsx(ht,{className:"font-medium",children:Se.name}),e.jsx(ht,{children:Se.email}),e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[Se.claimed?e.jsx(Qe,{variant:"default",children:"Active"}):e.jsx(Qe,{variant:"secondary",children:"Pending"}),$r(Se.id)&&e.jsxs(Qe,{variant:"outline",className:"border-primary text-primary",children:[e.jsx(t1,{className:"mr-1 h-3 w-3"}),"Manager"]}),N[Se.id]&&e.jsxs(Qe,{variant:"outline",className:"text-xs",children:[e.jsx(ir,{className:"mr-1 h-3 w-3"}),"Asst: ",N[Se.id].name||N[Se.id].email]})]})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[e.jsx(W,{size:"sm",variant:"ghost",onClick:()=>{He(Se),Ke(!0)},title:"Send celebration",className:"text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",children:e.jsx(qd,{className:"h-4 w-4"})}),e.jsx(W,{size:"sm",variant:"ghost",onClick:()=>mr(Se),title:"Edit agent",children:e.jsx(ga,{className:"h-4 w-4"})}),!Se.claimed&&e.jsxs(e.Fragment,{children:[e.jsx(W,{size:"sm",variant:"ghost",onClick:()=>Es(Se.id),title:"Resend welcome email",children:e.jsx(tr,{className:"h-4 w-4"})}),e.jsx(W,{size:"sm",variant:"ghost",onClick:()=>Br(Se),title:"Claim account for agent",disabled:es===Se.id,className:"text-green-600 hover:text-green-700 hover:bg-green-50",children:e.jsx(n0,{className:"h-4 w-4"})})]}),e.jsx(W,{size:"sm",variant:"ghost",onClick:()=>nr(Se),title:"Set password",className:"text-blue-600 hover:text-blue-700 hover:bg-blue-50",children:e.jsx(ad,{className:"h-4 w-4"})}),e.jsx(W,{size:"sm",variant:"ghost",onClick:()=>fr(Se.email,Se.name),title:"Send password reset email",children:e.jsx(nS,{className:"h-4 w-4"})}),$r(Se.id)&&e.jsx(W,{size:"sm",variant:"ghost",onClick:()=>Fr(Se.id),title:"Remove manager role",className:"text-orange-500 hover:text-orange-600",children:e.jsx(zu,{className:"h-4 w-4"})}),e.jsx(W,{size:"sm",variant:"ghost",onClick:()=>Hs(Se),className:"text-destructive hover:text-destructive",title:"Remove agent",children:e.jsx(vr,{className:"h-4 w-4"})})]})})]},Se.id))})]})})]})]}),e.jsx(fs,{open:S,onOpenChange:C,children:e.jsxs(ps,{children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Add New Agent"}),e.jsx(Ir,{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(xe,{htmlFor:"name",children:"Name"}),e.jsx(De,{id:"name",value:L.name,onChange:Se=>O({...L,name:Se.target.value}),placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"email",children:"Email"}),e.jsx(De,{id:"email",type:"email",value:L.email,onChange:Se=>O({...L,email:Se.target.value}),placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(De,{id:"phone",type:"tel",value:L.phone,onChange:Se=>O({...L,phone:Se.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"password",children:"Temporary Password"}),e.jsx(De,{id:"password",type:"password",value:L.password,onChange:Se=>O({...L,password:Se.target.value}),placeholder:"Temporary password"})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),e.jsx(W,{onClick:Lt,disabled:A,children:A?"Creating...":"Create Agent"})]})]})}),e.jsx(fs,{open:V,onOpenChange:q,children:e.jsxs(ps,{children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Remove Agent"}),e.jsxs(Ir,{children:["Are you sure you want to remove ",e.jsx("strong",{children:B==null?void 0:B.name})," from your brokerage? This will revoke their access to the dashboard."]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>q(!1),children:"Cancel"}),e.jsx(W,{variant:"destructive",onClick:Kr,disabled:te,children:te?"Removing...":"Remove Agent"})]})]})}),e.jsx(utt,{open:J,onOpenChange:X,fixedBrokerageId:t,onSuccess:lr}),e.jsx(fs,{open:ce,onOpenChange:ie,children:e.jsxs(ps,{children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Add Brokerage Manager"}),e.jsx(Ir,{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(xe,{children:"Select Agent"}),e.jsxs(mo,{open:je,onOpenChange:qe,children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{variant:"outline",role:"combobox","aria-expanded":je,className:"w-full justify-between",children:[ae?((Lr=n.find(Se=>Se.id===ae))==null?void 0:Lr.name)+" ("+(($t=n.find(Se=>Se.id===ae))==null?void 0:$t.email)+")":"Select an agent to promote...",e.jsx(gx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(no,{className:"w-full p-0",align:"start",children:e.jsxs(Sx,{children:[e.jsx(Cx,{placeholder:"Search by name or email..."}),e.jsxs(Mx,{className:"max-h-[200px]",children:[e.jsx(Tx,{children:"No eligible agents found."}),e.jsx(Ax,{children:n.filter(Se=>!$r(Se.id)).map(Se=>e.jsxs(cp,{value:`${Se.name} ${Se.email}`,onSelect:()=>{oe(Se.id),qe(!1)},children:[e.jsx(Zn,{className:`mr-2 h-4 w-4 ${ae===Se.id?"opacity-100":"opacity-0"}`}),Se.name," (",Se.email,")"]},Se.id))})]})]})})]}),n.filter(Se=>!$r(Se.id)).length===0&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"All agents are already brokerage managers."})]})}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>ie(!1),children:"Cancel"}),e.jsx(W,{onClick:Cr,disabled:me||!ae,children:me?"Adding...":"Add as Manager"})]})]})}),e.jsx(fs,{open:Me,onOpenChange:ke,children:e.jsxs(ps,{children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Edit Agent"}),e.jsxs(Ir,{children:["Update profile information for ",Re==null?void 0:Re.name]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"edit-name",children:"Name"}),e.jsx(De,{id:"edit-name",value:Ne.name,onChange:Se=>Ue({...Ne,name:Se.target.value}),placeholder:"Agent name"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"edit-email",children:"Email"}),e.jsx(De,{id:"edit-email",type:"email",value:Ne.email,onChange:Se=>Ue({...Ne,email:Se.target.value}),placeholder:"agent@example.com"}),Ne.email.trim().toLowerCase()!==(Re==null?void 0:Re.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(xe,{htmlFor:"edit-phone",children:"Phone"}),e.jsx(De,{id:"edit-phone",type:"tel",value:Ne.phone,onChange:Se=>Ue({...Ne,phone:Se.target.value}),placeholder:"555-123-4567"})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>ke(!1),children:"Cancel"}),e.jsx(W,{onClick:an,disabled:Ie||ct,children:ct?"Updating email...":Ie?"Saving...":"Save Changes"})]})]})}),ot&&e.jsx(htt,{open:We,onOpenChange:Se=>{Ke(Se),Se||He(null)},userId:ot.id,userName:ot.name}),e.jsx(fs,{open:Je,onOpenChange:ut,children:e.jsxs(ps,{children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Set Password"}),e.jsxs(Ir,{children:["Set a new password for ",mt==null?void 0:mt.name,". They will be able to log in with this password immediately."]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"new-password",children:"New Password"}),e.jsx(De,{id:"new-password",type:"password",value:Ze,onChange:Se=>kt(Se.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(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>ut(!1),children:"Cancel"}),e.jsx(W,{onClick:cr,disabled:Ut||!Ze||Ze.length<6,children:Ut?"Setting...":"Set Password"})]})]})})]})},o1s={academy_video:"Academy Video",template:"Template",toolbox:"Toolbox Resource",newsletter:"Newsletter",social_swag:"Social Swag",event:"Event"},l1s={view:"Viewed",click_canva:"Opened Canva",click_pdf:"Downloaded PDF",click_video:"Watched Video",click_link:"Clicked Link",register:"Registered"},c1s=t=>{switch(t){case"academy_video":return e.jsx(yn,{className:"h-4 w-4"});case"template":return e.jsx(vn,{className:"h-4 w-4"});case"toolbox":return e.jsx(vn,{className:"h-4 w-4"});case"newsletter":return e.jsx(Jv,{className:"h-4 w-4"});case"social_swag":return e.jsx(Or,{className:"h-4 w-4"});case"event":return e.jsx(cn,{className:"h-4 w-4"});default:return e.jsx(Yr,{className:"h-4 w-4"})}},d1s=({brokerageId:t})=>{const{toast:s}=ja(),[r,n]=k.useState([]),[a,o]=k.useState([]),[l,i]=k.useState([]),[d,u]=k.useState(!0),[p,f]=k.useState(null);k.useEffect(()=>{y()},[t]);const y=async()=>{try{u(!0);const{data:N,error:w}=await G.from("profiles").select("id, name, email").eq("brokerage_id",t);if(w)throw w;const S=N.map(te=>te.id),C=new Map(N.map(te=>[te.id,te]));if(S.length===0){n([]),o([]),i([]);return}const{data:A,error:I}=await G.from("activity_logs").select("*").in("user_id",S).order("launched_at",{ascending:!1});if(I)throw I;const L=A.map(te=>{var Y,J;return{id:te.id,user_id:te.user_id,app_name:te.app_name,launched_at:te.launched_at,user_name:((Y=C.get(te.user_id))==null?void 0:Y.name)||"Unknown",user_email:((J=C.get(te.user_id))==null?void 0:J.email)||"Unknown"}});n(L);const{data:O,error:V}=await G.from("content_engagement_logs").select("*").in("user_id",S).order("created_at",{ascending:!1});if(V)throw V;const q=(O||[]).map(te=>{var Y,J;return{id:te.id,user_id:te.user_id,resource_type:te.resource_type,resource_id:te.resource_id,resource_title:te.resource_title,action_type:te.action_type,created_at:te.created_at,user_name:((Y=C.get(te.user_id))==null?void 0:Y.name)||"Unknown",user_email:((J=C.get(te.user_id))==null?void 0:J.email)||"Unknown"}});o(q);const B=new Map;N.forEach(te=>{B.set(te.id,{user_id:te.id,user_name:te.name,user_email:te.email,app_launches:0,content_views:0,last_activity:""})}),L.forEach(te=>{const Y=B.get(te.user_id);Y&&(Y.app_launches++,(!Y.last_activity||new Date(te.launched_at)>new Date(Y.last_activity))&&(Y.last_activity=te.launched_at))}),q.forEach(te=>{const Y=B.get(te.user_id);Y&&(Y.content_views++,(!Y.last_activity||new Date(te.created_at)>new Date(Y.last_activity))&&(Y.last_activity=te.created_at))});const U=Array.from(B.values()).filter(te=>te.app_launches>0||te.content_views>0).sort((te,Y)=>new Date(Y.last_activity).getTime()-new Date(te.last_activity).getTime());i(U)}catch(N){console.error("Error loading activity:",N),s({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{u(!1)}},_=N=>r.filter(w=>w.user_id===N),b=N=>a.filter(w=>w.user_id===N);return d?e.jsx(Pe,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"Agent Activity"}),e.jsx(dr,{children:"Track app usage and content engagement - click an agent for details"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Agent"}),e.jsx(St,{className:"text-center",children:"App Launches"}),e.jsx(St,{className:"text-center",children:"Content Views"}),e.jsx(St,{children:"Last Active"})]})}),e.jsx(Rn,{children:l.length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:4,className:"text-center text-muted-foreground",children:"No activity yet"})}):l.map(N=>e.jsxs(Ps,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>f({id:N.user_id,name:N.user_name,email:N.user_email}),children:[e.jsx(ht,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:N.user_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:N.user_email})]})}),e.jsx(ht,{className:"text-center",children:e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(Co,{className:"h-3 w-3"}),N.app_launches]})}),e.jsx(ht,{className:"text-center",children:e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[e.jsx(vn,{className:"h-3 w-3"}),N.content_views]})}),e.jsx(ht,{className:"text-sm text-muted-foreground",children:N.last_activity&&Nl(new Date(N.last_activity),{addSuffix:!0})})]},N.user_id))})]})})})]}),e.jsx(fs,{open:!!p,onOpenChange:N=>!N&&f(null),children:e.jsxs(ps,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(ks,{children:[e.jsxs(_s,{children:[p==null?void 0:p.name,"'s Activity"]}),e.jsx(Ir,{children:p==null?void 0:p.email})]}),e.jsxs(ta,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(Jn,{className:"grid w-full grid-cols-2",children:[e.jsx(cs,{value:"content",children:"Content Engagement"}),e.jsx(cs,{value:"apps",children:"App Launches"})]}),e.jsx(Ss,{value:"content",className:"flex-1 overflow-auto",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Resource"}),e.jsx(St,{children:"Type"}),e.jsx(St,{children:"Action"}),e.jsx(St,{children:"Time"})]})}),e.jsx(Rn,{children:p&&b(p.id).length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement yet"})}):p&&b(p.id).map(N=>e.jsxs(Ps,{children:[e.jsx(ht,{className:"max-w-[200px] truncate font-medium",children:N.resource_title}),e.jsx(ht,{children:e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[c1s(N.resource_type),o1s[N.resource_type]||N.resource_type]})}),e.jsx(ht,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:l1s[N.action_type]||N.action_type})}),e.jsx(ht,{className:"text-sm text-muted-foreground",children:Nl(new Date(N.created_at),{addSuffix:!0})})]},N.id))})]})})}),e.jsx(Ss,{value:"apps",className:"flex-1 overflow-auto",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"App"}),e.jsx(St,{children:"Time"})]})}),e.jsx(Rn,{children:p&&_(p.id).length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches yet"})}):p&&_(p.id).map(N=>e.jsxs(Ps,{children:[e.jsx(ht,{children:e.jsx(Qe,{variant:"outline",children:N.app_name})}),e.jsx(ht,{className:"text-sm text-muted-foreground",children:Nl(new Date(N.launched_at),{addSuffix:!0})})]},N.id))})]})})})]})]})})]})},u1s=({brokerageId:t})=>{const{toast:s}=ja(),[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:d}=await G.from("profiles").select("id").eq("brokerage_id",t);if(d)throw d;const u=i.map(L=>L.id),p=u.length;if(u.length===0){o(!1);return}const{data:f,error:y}=await G.from("profiles").select("id, email").in("id",u);if(y)throw y;const{count:_}=await G.from("profiles").select("*",{count:"exact",head:!0}).eq("brokerage_id",t).not("last_login","is",null),b=_||0,N=p-b,{count:w}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u),S=new Date;S.setDate(S.getDate()-7);const{count:C}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u).gte("launched_at",S.toISOString()),A=new Date;A.setMonth(A.getMonth()-1);const{count:I}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u).gte("launched_at",A.toISOString());n({totalAgents:p,activeAgents:b,pendingAgents:N,totalLaunches:w||0,launchesThisWeek:C||0,launchesThisMonth:I||0})}catch(i){console.error("Error loading analytics:",i),s({title:"Error",description:"Failed to load analytics",variant:"destructive"})}finally{o(!1)}};return a?e.jsx(Pe,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total Agents"}),e.jsx(ir,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.totalAgents}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[r.activeAgents," active, ",r.pendingAgents," pending"]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Active Agents"}),e.jsx(si,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.activeAgents}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r.totalAgents>0?`${Math.round(r.activeAgents/r.totalAgents*100)}% of total`:"0% of total"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(nn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.pendingAgents}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Awaiting setup"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(lh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.totalLaunches}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"All time"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"This Week"}),e.jsx(lh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.launchesThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 7 days"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"This Month"}),e.jsx(lh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.launchesThisMonth}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 30 days"})]})]})]})},h1s=({brokerageId:t})=>{const[s,r]=k.useState([]),[n,a]=k.useState(!0),[o,l]=k.useState(!1),[i,d]=k.useState(!1),[u,p]=k.useState({description:"",maxUses:""});k.useEffect(()=>{f()},[t]);const f=async()=>{try{const{data:S,error:C}=await G.from("invite_codes").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(C)throw C;r(S||[])}catch(S){console.error("Error loading invite codes:",S),pe.error("Failed to load invite links")}finally{a(!1)}},y=()=>Math.random().toString(36).substring(2,8).toUpperCase(),_=async()=>{l(!0);try{const S=y(),{error:C}=await G.from("invite_codes").insert({code:S,description:u.description||null,max_uses:u.maxUses?parseInt(u.maxUses):null,brokerage_id:t,is_active:!0});if(C)throw C;pe.success("Invite link created!"),d(!1),p({description:"",maxUses:""}),f()}catch(S){console.error("Error creating invite code:",S),pe.error("Failed to create invite link")}finally{l(!1)}},b=async S=>{try{const{error:C}=await G.from("invite_codes").delete().eq("id",S);if(C)throw C;pe.success("Invite link deleted"),r(s.filter(A=>A.id!==S))}catch(C){console.error("Error deleting invite code:",C),pe.error("Failed to delete invite link")}},N=async(S,C)=>{try{const{error:A}=await G.from("invite_codes").update({is_active:!C}).eq("id",S);if(A)throw A;r(s.map(I=>I.id===S?{...I,is_active:!C}:I)),pe.success(`Invite link ${C?"deactivated":"activated"}`)}catch(A){console.error("Error toggling invite code:",A),pe.error("Failed to update invite link")}},w=S=>{const C=`${window.location.origin}/join?code=${S}`;navigator.clipboard.writeText(C),pe.success("Link copied to clipboard!")};return n?e.jsx(Pe,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx(us,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}):e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(vo,{className:"h-5 w-5"}),"Agent Invite Links"]}),e.jsx(dr,{children:"Create shareable links for agents to join your brokerage"})]}),e.jsxs(fs,{open:i,onOpenChange:d,children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{size:"sm",children:[e.jsx(qs,{className:"mr-2 h-4 w-4"}),"Create Link"]})}),e.jsxs(ps,{children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Create Invite Link"}),e.jsx(Ir,{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(xe,{htmlFor:"description",children:"Description (optional)"}),e.jsx(De,{id:"description",placeholder:"e.g., New agent recruiting campaign",value:u.description,onChange:S=>p({...u,description:S.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"maxUses",children:"Max Uses (optional)"}),e.jsx(De,{id:"maxUses",type:"number",placeholder:"Leave empty for unlimited",value:u.maxUses,onChange:S=>p({...u,maxUses:S.target.value})})]}),e.jsx(W,{onClick:_,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Invite Link"})]})]})]})]}),e.jsx(Oe,{children:s.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(vo,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No 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(S=>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:S.code}),e.jsx(Qe,{variant:S.is_active?"default":"secondary",children:S.is_active?"Active":"Inactive"})]}),S.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:S.description}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[S.uses_count," uses",S.max_uses&&` / ${S.max_uses} max`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>w(S.code),title:"Copy link",children:e.jsx(Va,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>N(S.id,S.is_active),title:S.is_active?"Deactivate":"Activate",children:S.is_active?"Disable":"Enable"}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>b(S.id),className:"text-destructive hover:text-destructive",title:"Delete",children:e.jsx(vr,{className:"h-4 w-4"})})]})]},S.id))})})]})},m1s=({open:t,onOpenChange:s,referralCode:r,brokerageId:n,senderName:a,brokerageName:o,onInvitesSent:l})=>{const[i,d]=k.useState(""),[u,p]=k.useState([]),[f,y]=k.useState(""),[_,b]=k.useState(!1),N=I=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(I),w=()=>{const I=i.trim().toLowerCase();if(I&&N(I)&&!u.includes(I)){if(u.length>=10){pe.error("Maximum 10 emails per invite");return}p([...u,I]),d("")}else I&&!N(I)?pe.error("Please enter a valid email address"):u.includes(I)&&pe.error("Email already added")},S=I=>{p(u.filter(L=>L!==I))},C=I=>{(I.key==="Enter"||I.key===",")&&(I.preventDefault(),w())},A=async()=>{if(u.length===0){pe.error("Please add at least one email address");return}b(!0);try{const{data:I,error:L}=await G.functions.invoke("send-referral-invite",{body:{emails:u,personalMessage:f.trim()||void 0,referralCode:r,brokerageId:n,senderName:a,brokerageName:o}});if(L)throw L;I.successCount===I.totalCount?pe.success(`${I.successCount} invite${I.successCount>1?"s":""} sent successfully!`):pe.warning(`${I.successCount} of ${I.totalCount} invites sent. Some failed.`),p([]),y(""),s(!1),l==null||l()}catch(I){console.error("Error sending invites:",I),pe.error("Failed to send invites. Please try again.")}finally{b(!1)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-[550px]",children:[e.jsxs(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(tr,{className:"h-5 w-5 text-primary"}),"Invite Broker Friends"]}),e.jsx(Ir,{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(hi,{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(xe,{htmlFor:"email",children:"Email Addresses (up to 10)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{id:"email",type:"email",placeholder:"Enter email and press Enter",value:i,onChange:I=>d(I.target.value),onKeyDown:C,onBlur:w}),e.jsx(W,{type:"button",variant:"secondary",onClick:w,children:"Add"})]}),u.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:u.map(I=>e.jsxs(Qe,{variant:"secondary",className:"flex items-center gap-1 pr-1",children:[I,e.jsx("button",{type:"button",onClick:()=>S(I),className:"ml-1 rounded-full p-0.5 hover:bg-muted",children:e.jsx(kr,{className:"h-3 w-3"})})]},I))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"message",children:"Personal Message (optional)"}),e.jsx(_r,{id:"message",placeholder:"Add a personal note that will appear at the top of the email...",value:f,onChange:I=>y(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(Or,{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(W,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(W,{onClick:A,disabled:u.length===0||_,children:_?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent mr-2"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(_n,{className:"h-4 w-4 mr-2"}),"Send ",u.length>0&&`(${u.length})`," Invite",u.length!==1?"s":""]})})]})]})})},p1s=({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:d,error:u}=await G.from("referral_invites").select("*").eq("referrer_brokerage_id",t).order("sent_at",{ascending:!1}).limit(20);if(u)throw u;n(d||[])}catch(d){console.error("Error fetching invites:",d)}finally{o(!1)}},i=d=>{switch(d){case"signed_up":return e.jsxs(Qe,{className:"bg-green-100 text-green-800 gap-1",children:[e.jsx(si,{className:"h-3 w-3"}),"Signed Up"]});case"expired":return e.jsxs(Qe,{variant:"outline",className:"text-muted-foreground gap-1",children:[e.jsx(Jl,{className:"h-3 w-3"}),"Expired"]});default:return e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[e.jsx(nn,{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(tr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No invites sent yet"}),e.jsx("p",{className:"text-xs",children:"Start inviting broker friends to earn rewards!"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium mb-3",children:"Recent Invites"}),r.map(d=>e.jsxs("div",{className:"flex items-center justify-between p-2.5 bg-muted/30 rounded-lg",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:d.recipient_email}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Sent ",vs(new Date(d.sent_at),"MMM d, yyyy")]})]}),i(d.status)]},d.id))]})},f1s=()=>{const{brokerageId:t,user:s}=Us(),[r,n]=k.useState(null),[a,o]=k.useState(""),[l,i]=k.useState(""),[d,u]=k.useState([]),[p,f]=k.useState(!0),[y,_]=k.useState(!1),[b,N]=k.useState(0);k.useEffect(()=>{t&&w()},[t]);const w=async()=>{try{const[O,V]=await Promise.all([G.from("brokerages").select("name").eq("id",t).single(),s?G.from("profiles").select("name").eq("id",s.id).single():Promise.resolve({data:null})]);O.data&&o(O.data.name),V.data&&i(V.data.name||"A LevelUp Member");const{data:q}=await G.from("referral_codes").select("code").eq("brokerage_id",t).single();if(q)n(q.code);else{const U=`REF${t==null?void 0:t.slice(0,8).toUpperCase()}`;await G.from("referral_codes").insert({brokerage_id:t,code:U}),n(U)}const{data:B}=await G.from("referrals").select(` *, referred_user:profiles!referred_user_id(name, email), referred_brokerage:brokerages!referred_brokerage_id(name) `).eq("referrer_brokerage_id",t).order("created_at",{ascending:!1});u(B||[])}catch(O){console.error("Error fetching referral data:",O)}finally{f(!1)}},S=()=>{const O=`https://dashboard.relevelup.com/?ref=${r}`;navigator.clipboard.writeText(O),pe.success("Referral link copied to clipboard!")},C=d.filter(O=>O.status==="qualified").length,A=d.filter(O=>O.status==="pending").length,I=C*25,L=Math.max(0,Math.ceil((299-I)/25));return p?null:e.jsxs(e.Fragment,{children:[e.jsxs(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(hi,{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(si,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm font-medium",children:"Active"})]})]}),L>0&&I<299&&e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm font-medium",children:["Refer ",L," more = ",e.jsx("span",{className:"text-primary",children:"FREE membership!"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your membership could cost $0/month"})]}),I>=299&&e.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[e.jsx(Or,{className:"h-5 w-5"}),e.jsx("span",{className:"font-bold",children:"FREE Membership Unlocked!"})]})]})})]})}),e.jsxs(Oe,{className:"pt-6 space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs(W,{onClick:()=>_(!0),className:"w-full",size:"lg",children:[e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Invite Broker Friends"]}),e.jsxs(W,{onClick:S,variant:"outline",className:"w-full",size:"lg",children:[e.jsx(Va,{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(_c,{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(ir,{className:"h-5 w-5 mx-auto text-primary mb-1"}),e.jsx("p",{className:"text-2xl font-bold",children:C}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Qualified Referrals"})]}),e.jsxs("div",{className:"text-center p-4 bg-amber-50 dark:bg-amber-950/20 rounded-lg border border-amber-200 dark:border-amber-900",children:[e.jsx(nn,{className:"h-5 w-5 mx-auto text-amber-600 mb-1"}),e.jsx("p",{className:"text-2xl font-bold text-amber-700 dark:text-amber-400",children:A}),e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-500",children:"Pending (30 days)"})]})]}),e.jsxs("div",{className:"bg-muted/30 rounded-lg p-4",children:[e.jsx("h4",{className:"font-semibold text-sm mb-3",children:"How It Works"}),e.jsxs("div",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center text-xs shrink-0",children:"1"}),e.jsx("p",{children:"Share your referral link or send an invite email to broker friends"})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center text-xs shrink-0",children:"2"}),e.jsx("p",{children:"They sign up and subscribe to LevelUp"})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center text-xs shrink-0",children:"3"}),e.jsx("p",{children:"After 30 days, you get $25/month off your membership - forever!"})]})]})]}),e.jsx(p1s,{brokerageId:t,refreshTrigger:b}),d.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Your Referrals"}),d.slice(0,5).map(O=>{var V,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:((V=O.referred_brokerage)==null?void 0:V.name)||((q=O.referred_user)==null?void 0:q.email)||"Pending setup"}),e.jsxs(Qe,{variant:O.status==="qualified"?"default":O.status==="pending"?"secondary":"destructive",className:O.status==="qualified"?"bg-green-600":"",children:[O.status==="qualified"&&e.jsx(si,{className:"h-3 w-3 mr-1"}),O.status]})]},O.id)})]})]})]}),e.jsx(m1s,{open:y,onOpenChange:_,referralCode:r||"",brokerageId:t||"",senderName:l||"A LevelUp Member",brokerageName:a,onInvitesSent:()=>N(O=>O+1)})]})},x1s=({brokerageId:t})=>{const s=wr(),{teams:r,isLoading:n}=TC(t),{data:a,isLoading:o}=gt({queryKey:["team-aggregate-stats",t,r.map(p=>p.id)],queryFn:async()=>{if(r.length===0)return[];const p=r.map(O=>O.id),{data:f}=await G.from("team_members").select("team_id, user_id, role").in("team_id",p);if(!f||f.length===0)return r.map(O=>({team_id:O.id,team_name:O.name,member_count:0,leader_name:null,leader_avatar:null,total_contacts:0,total_deals:0,total_videos:0}));const y=f.map(O=>O.user_id),_=f.filter(O=>O.role==="team_leader").map(O=>O.user_id),{data:b}=await G.from("profiles").select("id, name, avatar_url").in("id",_),N=new Map((b||[]).map(O=>[O.id,O])),{data:w}=await G.from("innercircle_contacts").select("owner_user_id").in("owner_user_id",y),{data:S}=await G.from("deal_pipeline").select("owner_user_id").in("owner_user_id",y),{data:C}=await G.from("agent_videos").select("owner_user_id").in("owner_user_id",y).eq("is_deleted",!1),A=new Map;(w||[]).forEach(O=>{A.set(O.owner_user_id,(A.get(O.owner_user_id)||0)+1)});const I=new Map;(S||[]).forEach(O=>{I.set(O.owner_user_id,(I.get(O.owner_user_id)||0)+1)});const L=new Map;return(C||[]).forEach(O=>{L.set(O.owner_user_id,(L.get(O.owner_user_id)||0)+1)}),r.map(O=>{const V=f.filter(X=>X.team_id===O.id),q=V.find(X=>X.role==="team_leader"),B=q?N.get(q.user_id):null,U=V.map(X=>X.user_id),te=U.reduce((X,ce)=>X+(A.get(ce)||0),0),Y=U.reduce((X,ce)=>X+(I.get(ce)||0),0),J=U.reduce((X,ce)=>X+(L.get(ce)||0),0);return{team_id:O.id,team_name:O.name,member_count:V.length,leader_name:(B==null?void 0:B.name)||null,leader_avatar:(B==null?void 0:B.avatar_url)||null,total_contacts:te,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(p=>e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(Ms,{className:"h-5 w-32"})}),e.jsx(Oe,{children:e.jsx(Ms,{className:"h-24 w-full"})})]},p))});if(r.length===0)return e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(ir,{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(W,{onClick:()=>s("/brokerage/teams"),children:"Manage Teams"})]})});const i=(a||[]).reduce((p,f)=>p+f.member_count,0),d=(a||[]).reduce((p,f)=>p+f.total_contacts,0),u=(a||[]).reduce((p,f)=>p+f.total_deals,0);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 grid-cols-2 md:grid-cols-4",children:[e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(ir,{className:"h-4 w-4"})," Teams"]}),e.jsx("p",{className:"text-2xl font-bold",children:r.length})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(ir,{className:"h-4 w-4"})," Total Members"]}),e.jsx("p",{className:"text-2xl font-bold",children:i})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Q4,{className:"h-4 w-4"})," Total Contacts"]}),e.jsx("p",{className:"text-2xl font-bold",children:d.toLocaleString()})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(dh,{className:"h-4 w-4"})," Total Deals"]}),e.jsx("p",{className:"text-2xl font-bold",children:u.toLocaleString()})]})})]}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:(a||[]).map(p=>e.jsxs(Pe,{className:"hover:shadow-md transition-shadow",children:[e.jsxs(Dt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(zt,{className:"text-lg",children:p.team_name}),e.jsxs(Qe,{variant:"secondary",children:[p.member_count," members"]})]}),p.leader_name&&e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsxs(Nn,{className:"h-6 w-6",children:[e.jsx(Ma,{src:p.leader_avatar||""}),e.jsx(kn,{className:"text-xs",children:p.leader_name.charAt(0).toUpperCase()})]}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(Cm,{className:"h-3 w-3 text-amber-500"}),p.leader_name]})]})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:p.total_contacts.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Contacts"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:p.total_deals.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Deals"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:p.total_videos.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Videos"})]})]})})]},p.team_id))}),e.jsx("div",{className:"flex justify-end",children:e.jsx(W,{variant:"outline",onClick:()=>s("/brokerage/teams"),children:"Manage Teams →"})})]})},g1s=()=>{const{user:t,isBrokerageManager:s,brokerageId:r,isAdmin:n,managedBrokerages:a,selectedBrokerageId:o,setSelectedBrokerageId:l}=Us(),i=wr(),{toast:d}=ja(),[u,p]=k.useState(""),[f,y]=k.useState(!0),_=o||(a.length>0?a[0].id:r);k.useEffect(()=>{if(!t||!s&&!n){i("/dashboard");return}!o&&a.length>0&&l(a[0].id),_?b():a.length===0&&!r&&y(!1)},[t,s,n,_,i,a,o]);const b=async()=>{if(!_){y(!1);return}try{const{data:N,error:w}=await G.from("brokerages").select("name").eq("id",_).single();if(w)throw w;p(N.name)}catch(N){console.error("Error loading brokerage info:",N),d({title:"Error",description:"Failed to load brokerage information",variant:"destructive"})}finally{y(!1)}};return f?e.jsx(Ds,{title:"Manage Brokerages",description:"Loading brokerage information...",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):_?e.jsx(Ds,{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($s,{value:o||"",onValueChange:l,children:[e.jsxs(zs,{className:"w-[280px]",children:[e.jsx(pa,{className:"mr-2 h-4 w-4"}),e.jsx(Vs,{placeholder:"Select brokerage"})]}),e.jsx(Bs,{children:a.map(N=>e.jsx(vt,{value:N.id,children:N.name},N.id))})]})]}),e.jsxs(ta,{defaultValue:"agents",className:"space-y-4",children:[e.jsxs(Jn,{className:"grid w-full grid-cols-4 md:grid-cols-8",children:[e.jsx(cs,{value:"agents",children:"Agents"}),e.jsx(cs,{value:"teams",children:"Teams"}),e.jsx(cs,{value:"invite",children:"Invite Links"}),e.jsx(cs,{value:"referrals",children:"Referrals"}),e.jsx(cs,{value:"leaderboard",children:"Leaderboard"}),e.jsx(cs,{value:"activity",children:"Activity"}),e.jsx(cs,{value:"analytics",children:"Analytics"}),e.jsx(cs,{value:"shares",children:"Shares"})]}),e.jsx(Ss,{value:"agents",className:"space-y-4",children:e.jsx(i1s,{brokerageId:_})}),e.jsx(Ss,{value:"teams",className:"space-y-4",children:e.jsx(x1s,{brokerageId:_})}),e.jsx(Ss,{value:"invite",className:"space-y-4",children:e.jsx(h1s,{brokerageId:_})}),e.jsx(Ss,{value:"referrals",className:"space-y-4",children:e.jsx(f1s,{})}),e.jsx(Ss,{value:"leaderboard",className:"space-y-4",children:e.jsx(Aet,{brokerageId:_,title:`${u} Event Leaderboard`,showUserStats:!1})}),e.jsx(Ss,{value:"activity",className:"space-y-4",children:e.jsx(d1s,{brokerageId:_})}),e.jsx(Ss,{value:"analytics",className:"space-y-4",children:e.jsx(u1s,{brokerageId:_})}),e.jsx(Ss,{value:"shares",className:"space-y-4",children:e.jsx($tt,{brokerageOnly:!0,brokerageId:_})})]})]})}):e.jsx(Ds,{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(pa,{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 y1s({brokerageId:t,canManage:s}){const{user:r}=Us(),[n,a]=k.useState([]),[o,l]=k.useState(!0),[i,d]=k.useState(!1),[u,p]=k.useState(null),[f,y]=k.useState(null),[_,b]=k.useState(!1),[N,w]=k.useState(""),[S,C]=k.useState(""),[A,I]=k.useState(!1),L=async()=>{try{const{data:U,error:te}=await G.from("brokerage_announcements").select("*").eq("brokerage_id",t).order("is_pinned",{ascending:!1}).order("pinned_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1});if(te)throw te;const Y=U;if(Y&&Y.length>0){const J=[...new Set(Y.map(ae=>ae.created_by))],{data:X}=await G.from("profiles").select("id, name, avatar_url").in("id",J),ce=new Map((X==null?void 0:X.map(ae=>[ae.id,ae]))||[]),ie=Y.map(ae=>({...ae,author:ce.get(ae.created_by)||{name:"Unknown",avatar_url:null}}));a(ie)}else a([])}catch(U){console.error("Error fetching announcements:",U)}finally{l(!1)}};k.useEffect(()=>{L()},[t]);const O=()=>{w(""),C(""),I(!1),p(null)},V=U=>{U?(p(U),w(U.title),C(U.content),I(U.is_pinned)):O(),d(!0)},q=async()=>{if(!N.trim()||!S.trim()){pe.error("Please fill in all fields");return}b(!0);try{if(u){const{error:U}=await G.from("brokerage_announcements").update({title:N.trim(),content:S.trim(),is_pinned:A,pinned_at:A?new Date().toISOString():null}).eq("id",u.id);if(U)throw U;pe.success("Announcement updated")}else{const{error:U}=await G.from("brokerage_announcements").insert({brokerage_id:t,created_by:r==null?void 0:r.id,title:N.trim(),content:S.trim(),is_pinned:A,pinned_at:A?new Date().toISOString():null});if(U)throw U;pe.success("Announcement created")}d(!1),O(),L()}catch(U){console.error("Error saving announcement:",U),pe.error("Failed to save announcement")}finally{b(!1)}},B=async()=>{if(f)try{const{error:U}=await G.from("brokerage_announcements").delete().eq("id",f);if(U)throw U;pe.success("Announcement deleted"),L()}catch(U){console.error("Error deleting announcement:",U),pe.error("Failed to delete announcement")}finally{y(null)}};return o?e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(uh,{className:"h-5 w-5"}),"Announcements"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"animate-pulse space-y-3",children:e.jsx("div",{className:"h-20 bg-muted rounded"})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(uh,{className:"h-5 w-5 text-primary"}),"Announcements"]}),s&&e.jsxs(W,{size:"sm",onClick:()=>V(),className:"gap-1",children:[e.jsx(qs,{className:"h-4 w-4"}),"New"]})]}),e.jsx(Oe,{children:n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No announcements yet"}):e.jsx("div",{className:"space-y-4",children:n.map(U=>{var te,Y,J,X;return e.jsx("div",{className:`p-4 rounded-lg border ${U.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:[U.is_pinned&&e.jsx(Tb,{className:"h-3.5 w-3.5 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold truncate",children:U.title})]}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:U.content}),e.jsxs("div",{className:"flex items-center gap-2 mt-3 text-xs text-muted-foreground",children:[e.jsxs(Nn,{className:"h-5 w-5",children:[e.jsx(Ma,{src:((te=U.author)==null?void 0:te.avatar_url)||void 0}),e.jsx(kn,{className:"text-[10px]",children:((J=(Y=U.author)==null?void 0:Y.name)==null?void 0:J.charAt(0))||"?"})]}),e.jsx("span",{children:(X=U.author)==null?void 0:X.name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:vs(new Date(U.created_at),"MMM d, yyyy")})]})]}),s&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>V(U),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>y(U.id),children:e.jsx(vr,{className:"h-4 w-4"})})]})]})},U.id)})})})]}),e.jsx(fs,{open:i,onOpenChange:d,children:e.jsxs(ps,{children:[e.jsx(ks,{children:e.jsx(_s,{children:u?"Edit Announcement":"New Announcement"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"title",children:"Title"}),e.jsx(De,{id:"title",value:N,onChange:U=>w(U.target.value),placeholder:"Announcement title..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"content",children:"Content"}),e.jsx(_r,{id:"content",value:S,onChange:U=>C(U.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(Ar,{id:"pinned",checked:A,onCheckedChange:I}),e.jsxs(xe,{htmlFor:"pinned",className:"flex items-center gap-1 cursor-pointer",children:[e.jsx(Tb,{className:"h-4 w-4"}),"Pin to top"]})]})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(W,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(W,{onClick:q,disabled:_,children:_?"Saving...":u?"Update":"Create"})]})]})]})}),e.jsx(Rl,{open:!!f,onOpenChange:()=>y(null),children:e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Delete Announcement"}),e.jsx(bl,{children:"Are you sure you want to delete this announcement? This action cannot be undone."})]}),e.jsxs(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:B,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function v1s({brokerageId:t,canManage:s=!1}){const{startImpersonation:r,isLoading:n}=mue(),{user:a}=Us(),[o,l]=k.useState([]),[i,d]=k.useState(!0),[u,p]=k.useState(""),[f,y]=k.useState(new Set);k.useEffect(()=>{(async()=>{try{const{data:N,error:w}=await G.from("profiles").select("id, name, email, phone, avatar_url, title, bio, areas_served, years_experience, instagram_url, facebook_url, linkedin_url").eq("brokerage_id",t).order("name");if(w)throw w;if(l(N||[]),N&&N.length>0){const S=N.map(A=>A.id),{data:C}=await G.from("agent_assistant_assignments").select("agent_id").in("agent_id",S);C&&y(new Set(C.map(A=>A.agent_id)))}}catch(N){console.error("Error fetching agents:",N)}finally{d(!1)}})()},[t]);const _=o.filter(b=>{var N,w;return b.name.toLowerCase().includes(u.toLowerCase())||b.email.toLowerCase().includes(u.toLowerCase())||((N=b.title)==null?void 0:N.toLowerCase().includes(u.toLowerCase()))||((w=b.areas_served)==null?void 0:w.toLowerCase().includes(u.toLowerCase()))});return i?e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(ir,{className:"h-5 w-5"}),"Agent Roster"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[1,2,3,4].map(b=>e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"h-48 bg-muted rounded-lg"})},b))})})]}):e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 space-y-0",children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(ir,{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(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search agents...",value:u,onChange:b=>p(b.target.value),className:"pl-9"})]})]}),e.jsx(Oe,{children:_.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:_.map(b=>e.jsx(_1s,{agent:b,hasAssistant:f.has(b.id),canImpersonate:s&&b.id!==(a==null?void 0:a.id),onImpersonate:()=>r(b.id,"/my-brokerage"),impersonationLoading:n},b.id))})})]})}function _1s({agent:t,hasAssistant:s,canImpersonate:r,onImpersonate:n,impersonationLoading:a}){const o=t.name.split(" ").map(l=>l[0]).join("").toUpperCase().slice(0,2);return e.jsxs("div",{className:"group relative bg-card border rounded-xl p-4 hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"flex flex-col items-center text-center mb-3",children:[e.jsxs(Nn,{className:"h-20 w-20 mb-3 ring-2 ring-background shadow-md",children:[e.jsx(Ma,{src:t.avatar_url||void 0,alt:t.name}),e.jsx(kn,{className:"text-lg bg-primary/10 text-primary",children:o})]}),e.jsx("h3",{className:"font-semibold text-sm leading-tight",children:t.name}),t.title&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:t.title}),s&&e.jsx(Qe,{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(Ia,{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(ec,{children:[e.jsx(tc,{asChild:!0,children:e.jsx(W,{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(lS,{className:"h-4 w-4"})})}),e.jsxs(Dl,{children:["Login as ",t.name]})]}),t.phone&&e.jsx(W,{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(In,{className:"h-4 w-4"})})}),e.jsx(W,{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(tr,{className:"h-4 w-4"})})}),t.linkedin_url&&e.jsx(W,{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(gp,{className:"h-4 w-4"})})}),t.instagram_url&&e.jsx(W,{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 b1s({brokerageId:t}){const[s,r]=k.useState([]),[n,a]=k.useState(!0);if(k.useEffect(()=>{(async()=>{try{const{data:d,error:u}=await G.from("profiles").select("id, name, avatar_url").eq("brokerage_id",t);if(u)throw u;if(!d||d.length===0){r([]),a(!1);return}const p=d.map(N=>N.id),{data:f,error:y}=await G.from("agent_attendance_stats").select("user_id, total_points").in("user_id",p).order("total_points",{ascending:!1});if(y)throw y;const _=new Map(d.map(N=>[N.id,N])),b=(f||[]).filter(N=>N.total_points>0).map(N=>{const w=_.get(N.user_id);return{user_id:N.user_id,total_points:N.total_points,name:(w==null?void 0:w.name)||"Unknown",avatar_url:(w==null?void 0:w.avatar_url)||null}});r(b)}catch(d){console.error("Error fetching leaderboard:",d)}finally{a(!1)}})()},[t]),n)return e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Fi,{className:"h-5 w-5"}),"Team Leaderboard"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"animate-pulse space-y-3",children:[1,2,3].map(i=>e.jsx("div",{className:"h-12 bg-muted rounded"},i))})})]});const o=i=>i===1?"text-yellow-500":i===2?"text-gray-400":i===3?"text-amber-600":"text-muted-foreground",l=i=>i<=3?e.jsx(Qv,{className:Ot("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(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Fi,{className:"h-5 w-5 text-primary"}),"Team Leaderboard"]})}),e.jsx(Oe,{children:s.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No points earned yet. Attend events to earn points!"}):e.jsx("div",{className:"space-y-2",children:s.slice(0,10).map((i,d)=>{const u=i.name.split(" ").map(f=>f[0]).join("").toUpperCase().slice(0,2),p=d+1;return e.jsxs("div",{className:Ot("flex items-center gap-3 p-2 rounded-lg",p<=3&&"bg-muted/50"),children:[e.jsx("div",{className:"w-6 flex justify-center",children:l(p)}),e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:i.avatar_url||void 0}),e.jsx(kn,{className:"text-xs",children:u})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:i.name}),e.jsxs("span",{className:"text-sm font-semibold text-primary",children:[i.total_points.toLocaleString()," pts"]})]},i.user_id)})})})]})}function w1s({brokerageId:t}){const s=wr(),[r,n]=k.useState([]),[a,o]=k.useState(!0);k.useEffect(()=>{(async()=>{try{const{data:d,error:u}=await G.from("profiles").select("id, name, avatar_url").eq("brokerage_id",t);if(u)throw u;if(!d||d.length===0){n([]),o(!1);return}const p=d.map(N=>N.id),f=new Map(d.map(N=>[N.id,N])),{data:y,error:_}=await G.from("listings").select(` id, slug, property_address, city, price, property_type, agent_id, listing_photos(photo_url) `).in("agent_id",p).eq("status","active").order("created_at",{ascending:!1}).limit(6);if(_)throw _;const b=(y||[]).map(N=>({id:N.id,slug:N.slug,property_address:N.property_address,city:N.city,price:N.price,property_type:N.property_type,agent_id:N.agent_id,agent:f.get(N.agent_id)||null,photos:N.listing_photos||[]}));n(b)}catch(d){console.error("Error fetching listings:",d)}finally{o(!1)}})()},[t]);const l=i=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(i);return a?e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Mn,{className:"h-5 w-5"}),"Brokerage Listings"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[1,2].map(i=>e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"h-32 bg-muted rounded-lg"})},i))})})]}):e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Mn,{className:"h-5 w-5 text-primary"}),"Brokerage Listings"]}),e.jsxs(W,{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(Oe,{children:[r.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Mn,{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(W,{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(Mn,{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(W,{variant:"ghost",size:"sm",className:"w-full mt-3",onClick:()=>s("/mission-control/listings"),children:["View All Listings",e.jsx(Yr,{className:"h-3 w-3 ml-1"})]})]})]})}function j1s(){const{user:t,isAdmin:s,isBrokerageManager:r}=Us(),n=wr(),[a,o]=k.useState(!0),[l,i]=k.useState(null),[d,u]=k.useState(""),[p,f]=k.useState(0),[y,_]=k.useState(!1),[b,N]=k.useState(!1);return k.useEffect(()=>{(async()=>{if(t)try{const{data:S}=await G.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle();if(!(S!=null&&S.brokerage_id)){o(!1);return}i(S.brokerage_id);const{data:C}=await G.from("brokerages").select("name").eq("id",S.brokerage_id).maybeSingle();C&&u(C.name);const{count:A}=await G.from("profiles").select("id",{count:"exact",head:!0}).eq("brokerage_id",S.brokerage_id);if(f(A||0),s)_(!0),N(!0);else if(r){const{data:I}=await G.from("brokerage_manager_assignments").select("id").eq("user_id",t.id).eq("brokerage_id",S.brokerage_id).maybeSingle();_(!!I),N(!!I)}}catch(S){console.error("Error fetching brokerage info:",S)}finally{o(!1)}})()},[t,s,r]),a?e.jsx(Ds,{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(Ds,{title:d||"My Brokerage",description:"Team Hub",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2 bg-muted/50 rounded-lg px-4 py-2",children:[e.jsx(ir,{className:"h-5 w-5 text-primary"}),e.jsxs("span",{className:"font-medium",children:[p," ",p===1?"Agent":"Agents"]})]}),b&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(W,{variant:"outline",onClick:()=>n("/brokerage-content"),children:[e.jsx(ch,{className:"h-4 w-4 mr-2"}),"Brokerage Content"]}),e.jsxs(W,{onClick:()=>n(`/mission-control/listings/new?brokerage=${l}`),children:[e.jsx(Mn,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]})]}),e.jsx(y1s,{brokerageId:l,canManage:y}),e.jsx(v1s,{brokerageId:l,canManage:y}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsx(b1s,{brokerageId:l}),e.jsx(w1s,{brokerageId:l})]})]})}):e.jsx(Ds,{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(pa,{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 N1s(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 k1s(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 S7e={video:{icon:Co,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:vn,label:"Document",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},link:{icon:Do,label:"Link",color:"bg-green-500/10 text-green-600 dark:text-green-400"},event:{icon:cn,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:zl,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function S1s({item:t,canManage:s}){const[r,n]=k.useState(!1),[a,o]=k.useState(null),l=zLt(),i=wr(),d=S7e[t.content_type]||S7e.link,u=d.icon,p=k.useMemo(()=>t.thumbnail_url?t.thumbnail_url:t.content_type==="graphic"&&t.file_url?t.file_url:t.content_type==="video"?N1s(t.url):null,[t]);k.useEffect(()=>{p||!t.url||t.content_type!=="video"||!k1s(t.url)||fetch(`https://www.youtube.com/oembed?url=${encodeURIComponent(t.url)}&format=json`).then(b=>b.ok?b.json():null).then(b=>{b!=null&&b.thumbnail_url&&o(b.thumbnail_url)}).catch(()=>{})},[t.url,t.content_type,p]);const f=p||a,y=()=>{i(`/brokerage-content/${t.id}`)},_=async()=>{try{await l.mutateAsync(t.id),pe.success("Content deleted")}catch{pe.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:y,children:[f?e.jsx("div",{className:"aspect-video bg-muted/50 overflow-hidden",children:e.jsx("img",{src:f,alt:t.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",referrerPolicy:"no-referrer"})}):e.jsx("div",{className:"aspect-video bg-muted/30 flex items-center justify-center",children:e.jsx(u,{className:"h-12 w-12 text-muted-foreground/30"})}),e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs(Qe,{variant:"secondary",className:`text-[10px] px-1.5 py-0 ${d.color}`,children:[e.jsx(u,{className:"h-3 w-3 mr-1"}),d.label]}),t.category&&e.jsxs(Qe,{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:["📅 ",vs(new Date(t.event_date),"MMM d, yyyy · h:mm a")]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-2",children:["Added ",vs(new Date(t.created_at),"MMM d, yyyy")]})]}),s&&e.jsxs(Hd,{children:[e.jsx(Gd,{asChild:!0,onClick:b=>b.stopPropagation(),children:e.jsx(W,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(ix,{className:"h-4 w-4"})})}),e.jsx(Nd,{align:"end",children:e.jsxs(_a,{onClick:b=>{b.stopPropagation(),n(!0)},className:"text-destructive",children:[e.jsx(vr,{className:"h-4 w-4 mr-2"}),"Delete"]})})]})]})})]}),e.jsx(Rl,{open:r,onOpenChange:n,children:e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Delete Content"}),e.jsxs(bl,{children:['Are you sure you want to delete "',t.title,'"? This cannot be undone.']})]}),e.jsxs(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:_,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function C1s(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 C7e=[{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 M1s({brokerageId:t,categories:s}){var ge;const{user:r}=Us(),[n,a]=k.useState(!1),[o,l]=k.useState(!1),[i,d]=k.useState(""),[u,p]=k.useState("📁"),[f,y]=k.useState(!1);k.useRef(null);const[_,b]=k.useState("video"),[N,w]=k.useState(""),[S,C]=k.useState(""),[A,I]=k.useState(""),[L,O]=k.useState(""),[V,q]=k.useState(""),[B,U]=k.useState(""),[te,Y]=k.useState(""),J=FLt(),X=BLt(t),ce=$Lt(),ie=qLt(t),ae=()=>{b("video"),w(""),C(""),I(""),O(""),q(""),U(""),Y("")},oe=async(je,qe)=>{var ke;const Me=(ke=je.target.files)==null?void 0:ke[0];if(Me){y(!0);try{const Re=Me.name.split(".").pop(),Ve=`${t}/${Date.now()}-${Math.random().toString(36).slice(2)}.${Re}`,{error:Ne}=await G.storage.from("brokerage-content").upload(Ve,Me);if(Ne)throw Ne;const{data:{publicUrl:Ue}}=G.storage.from("brokerage-content").getPublicUrl(Ve);qe==="file"?(O(Ue),_==="graphic"&&!V&&q(Ue)):q(Ue),pe.success("File uploaded")}catch(Re){pe.error(Re.message||"Upload failed")}finally{y(!1)}}},me=async()=>{if(!N.trim()){pe.error("Title is required");return}if(r)try{await J.mutateAsync({brokerage_id:t,category_id:te||null,content_type:_,title:N.trim(),description:S.trim()||null,url:A.trim()||null,file_url:L.trim()||null,thumbnail_url:V.trim()||null,event_date:B?new Date(B).toISOString():null,created_by:r.id}),pe.success("Content added!"),ae(),a(!1)}catch(je){pe.error(je.message||"Failed to add content")}},ve=async()=>{if(i.trim())try{await X.mutateAsync({name:i.trim(),icon:u,sort_order:s.length}),d(""),p("📁"),pe.success("Category created")}catch(je){pe.error(je.message||"Failed to create category")}},he=async()=>{try{await ie.mutateAsync(),pe.success("Default categories created")}catch{pe.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(mi,{asChild:!0,children:e.jsxs(W,{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(ks,{children:e.jsx(_s,{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(xe,{children:"Content Type"}),e.jsxs($s,{value:_,onValueChange:b,children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsx(Bs,{children:C7e.map(je=>e.jsx(vt,{value:je.value,children:je.label},je.value))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(ge=C7e.find(je=>je.value===_))==null?void 0:ge.hint})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Category"}),e.jsxs($s,{value:te,onValueChange:Y,children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select category (optional)"})}),e.jsx(Bs,{children:s.map(je=>e.jsxs(vt,{value:je.id,children:[je.icon," ",je.name]},je.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Title *"}),e.jsx(De,{value:N,onChange:je=>w(je.target.value),placeholder:"Content title"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Description"}),e.jsx(_r,{value:S,onChange:je=>C(je.target.value),placeholder:"Brief description...",rows:2})]}),["video","link","graphic","event"].includes(_)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:_==="video"?"Video URL":_==="graphic"?"Canva / Image URL":_==="event"?"Event Link (Zoom, etc.)":"URL"}),e.jsx(De,{value:A,onChange:je=>{const qe=je.target.value;if(I(qe),_==="video"&&!V){const Me=C1s(qe);Me&&q(Me)}},placeholder:"https://..."})]}),["pdf","graphic"].includes(_)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:_==="pdf"?"Upload PDF":"Upload Image"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{type:"file",accept:_==="pdf"?".pdf,.doc,.docx":"image/*",onChange:je=>oe(je,"file"),disabled:f}),f&&e.jsx(us,{className:"h-4 w-4 animate-spin"})]}),L&&e.jsx("p",{className:"text-xs text-green-600",children:"✓ File uploaded"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Thumbnail Image (optional)"}),e.jsx(De,{type:"file",accept:"image/*",onChange:je=>oe(je,"thumbnail"),disabled:f}),V&&e.jsxs("div",{className:"relative w-20 h-20 rounded overflow-hidden",children:[e.jsx("img",{src:V,className:"w-full h-full object-cover",alt:"thumb"}),e.jsx("button",{onClick:()=>q(""),className:"absolute top-0 right-0 bg-background/80 rounded-bl p-0.5",children:e.jsx(kr,{className:"h-3 w-3"})})]})]}),_==="event"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Event Date & Time"}),e.jsx(De,{type:"datetime-local",value:B,onChange:je=>U(je.target.value)})]}),e.jsxs(W,{onClick:me,disabled:J.isPending||!N.trim(),className:"w-full",children:[J.isPending?e.jsx(us,{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(mi,{asChild:!0,children:e.jsxs(W,{variant:"outline",size:"sm",children:[e.jsx(So,{className:"h-4 w-4 mr-2"}),"Categories"]})}),e.jsxs(ps,{className:"max-w-md",children:[e.jsx(ks,{children:e.jsx(_s,{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(W,{variant:"outline",size:"sm",onClick:he,disabled:ie.isPending,children:[ie.isPending?e.jsx(us,{className:"h-4 w-4 animate-spin mr-2"}):null,"Create Default Categories"]})]}),s.map(je=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg border",children:[e.jsxs("span",{className:"text-sm",children:[je.icon," ",je.name]}),!je.is_default&&e.jsx(W,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:async()=>{await ce.mutateAsync(je.id),pe.success("Category deleted")},children:e.jsx(kr,{className:"h-4 w-4"})})]},je.id)),e.jsxs("div",{className:"flex gap-2 pt-2 border-t",children:[e.jsx(De,{value:u,onChange:je=>p(je.target.value),className:"w-14 text-center",maxLength:2}),e.jsx(De,{value:i,onChange:je=>d(je.target.value),placeholder:"New category name",className:"flex-1",onKeyDown:je=>je.key==="Enter"&&ve()}),e.jsx(W,{size:"sm",onClick:ve,disabled:!i.trim(),children:"Add"})]})]})]})]})]})}function T1s(){const{user:t,isAdmin:s,isBrokerageManager:r}=Us(),[n,a]=k.useState(!0),[o,l]=k.useState(null),[i,d]=k.useState(""),[u,p]=k.useState(!1),[f,y]=k.useState(null),[_,b]=k.useState("");k.useEffect(()=>{(async()=>{if(t)try{const{data:I}=await G.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle();if(!(I!=null&&I.brokerage_id)){a(!1);return}l(I.brokerage_id);const{data:L}=await G.from("brokerages").select("name").eq("id",I.brokerage_id).maybeSingle();if(L&&d(L.name),s)p(!0);else if(r){const{data:O}=await G.from("brokerage_manager_assignments").select("id").eq("user_id",t.id).eq("brokerage_id",I.brokerage_id).maybeSingle();p(!!O)}}catch(I){console.error("Error fetching brokerage info:",I)}finally{a(!1)}})()},[t,s,r]);const{data:N=[]}=DLt(o),{data:w=[],isLoading:S}=RLt(o,f),C=k.useMemo(()=>{if(!_.trim())return w;const A=_.toLowerCase();return w.filter(I=>{var L;return I.title.toLowerCase().includes(A)||((L=I.description)==null?void 0:L.toLowerCase().includes(A))||I.content_type.toLowerCase().includes(A)})},[w,_]);return n?e.jsx(Ds,{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(Ds,{title:`${i} Content`,description:"Brokerage Content Hub",children:e.jsxs("div",{className:"space-y-6",children:[u&&o&&e.jsx(M1s,{brokerageId:o,categories:N}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search content...",value:_,onChange:A=>b(A.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(W,{variant:f===null?"default":"outline",size:"sm",onClick:()=>y(null),children:"All"}),N.map(A=>e.jsxs(W,{variant:f===A.id?"default":"outline",size:"sm",onClick:()=>y(A.id),children:[e.jsx("span",{className:"mr-1",children:A.icon}),A.name]},A.id))]})]}),S?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):C.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(Mm,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),e.jsx("p",{className:"text-muted-foreground font-medium",children:_.trim()?"No matching content found":"No content yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:_.trim()?"Try a different search term or category.":u?"Add your first piece of content above.":"Your brokerage hasn't added content yet."})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:C.map(A=>e.jsx(S1s,{item:A,canManage:u},A.id))})]})}):e.jsx(Ds,{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(pa,{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 M7e={video:{icon:Co,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:vn,label:"Document",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},link:{icon:Do,label:"Link",color:"bg-green-500/10 text-green-600 dark:text-green-400"},event:{icon:cn,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:zl,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function A1s(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 E1s(t){try{const s=new URL(t).hostname.replace("www.","");return["youtube.com","youtu.be","m.youtube.com"].includes(s)}catch{return!1}}function P1s(t){try{return new URL(t).hostname.includes("vimeo.com")}catch{return!1}}function I1s(t){try{const s=t.match(/vimeo\.com\/(\d+)/);if(s)return`https://player.vimeo.com/video/${s[1]}`}catch{}return null}function L1s(){const{contentId:t}=io(),{data:s,isLoading:r}=gt({queryKey:["brokerage-content-detail",t],queryFn:async()=>{const{data:u,error:p}=await G.from("brokerage_content").select(` *, category:brokerage_content_categories(*) `).eq("id",t).single();if(p)throw p;return u},enabled:!!t});if(r)return e.jsx(Ds,{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(Ds,{title:"Brokerage Content",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(pa,{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(W,{asChild:!0,className:"mt-4",children:e.jsx(da,{to:"/brokerage-content",children:"Back to Content"})})]})});const n=M7e[s.content_type]||M7e.link,a=n.icon,o=s.url||s.file_url,l=o&&E1s(o)?A1s(o):null,i=o&&P1s(o)?I1s(o):null,d=l||i;return e.jsx(Ds,{title:s.title,children:e.jsxs("div",{className:"space-y-6 max-w-4xl mx-auto",children:[e.jsx(W,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(da,{to:"/brokerage-content",children:[e.jsx(Oa,{className:"h-4 w-4"}),"Back to Content"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Qe,{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(Qe,{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 ",vs(new Date(s.created_at),"MMMM d, yyyy")]})]}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:s.title}),d&&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:d,className:"absolute top-0 left-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:s.title})})}),s.content_type==="graphic"&&s.file_url&&!d&&e.jsx(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"})}),!d&&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(Oe,{className:"pt-6",children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.description})})}),s.content_type==="event"&&s.event_date&&e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-6 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(cn,{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:vs(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(W,{asChild:!0,size:"lg",children:e.jsxs("a",{href:s.file_url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Qa,{className:"h-4 w-4 mr-2"}),s.content_type==="pdf"?"Download Document":"Download File"]})}),s.url&&e.jsx(W,{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(Yr,{className:"h-4 w-4 mr-2"}),d?"Open on YouTube":s.content_type==="event"?"Join Event":s.content_type==="graphic"?"Open in Canva":"Open Link"]})})]})]})})}function D1s(){const t=wr(),[s,r]=k.useState(""),[n,a]=k.useState("grid"),{data:o,isLoading:l}=gt({queryKey:["newsletters"],queryFn:async()=>{const{data:A,error:I}=await G.from("newsletter_content").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(I)throw I;return A}}),{data:i}=gt({queryKey:["newsletter-likes-all"],queryFn:async()=>{const{data:A}=await G.from("newsletter_likes").select("newsletter_id");return A||[]}}),{data:d}=gt({queryKey:["newsletter-comments-all"],queryFn:async()=>{const{data:A}=await G.from("newsletter_comments").select("newsletter_id");return A||[]}}),{data:u}=gt({queryKey:["newsletter-resource-counts"],queryFn:async()=>{const[A,I,L,O]=await Promise.all([G.from("newsletter_canva_links").select("newsletter_id"),G.from("newsletter_pdfs").select("newsletter_id"),G.from("newsletter_videos").select("newsletter_id"),G.from("newsletter_drive_links").select("newsletter_id")]);return{canva:A.data||[],pdfs:I.data||[],videos:L.data||[],drives:O.data||[]}}}),p=A=>(i==null?void 0:i.filter(I=>I.newsletter_id===A).length)||0,f=A=>(d==null?void 0:d.filter(I=>I.newsletter_id===A).length)||0,y=A=>{var I;return((I=u==null?void 0:u.canva)==null?void 0:I.filter(L=>L.newsletter_id===A).length)||0},_=A=>{var I;return((I=u==null?void 0:u.pdfs)==null?void 0:I.filter(L=>L.newsletter_id===A).length)||0},b=A=>{var I;return((I=u==null?void 0:u.videos)==null?void 0:I.filter(L=>L.newsletter_id===A).length)||0},N=A=>{var I;return((I=u==null?void 0:u.drives)==null?void 0:I.filter(L=>L.newsletter_id===A).length)||0},w=A=>y(A)+_(A)+b(A)+N(A),S=o==null?void 0:o.filter(A=>{var I;return A.title.toLowerCase().includes(s.toLowerCase())||((I=A.description)==null?void 0:I.toLowerCase().includes(s.toLowerCase()))}),C=A=>{t(`/newsletters/${A}`)};return e.jsx(Ds,{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(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search newsletters...",value:s,onChange:A=>r(A.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex gap-2",children:[s&&e.jsx(W,{variant:"outline",size:"sm",onClick:()=>r(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(W,{variant:n==="grid"?"secondary":"outline",size:"icon",onClick:()=>a("grid"),className:"rounded-full",children:e.jsx(xp,{className:"h-4 w-4"})}),e.jsx(W,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(Dh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[(S==null?void 0:S.length)||0," item",(S==null?void 0:S.length)!==1?"s":""," found"]}),l&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:[...Array(8)].map((A,I)=>e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-0",children:[e.jsx(Ms,{className:"aspect-[3/2] w-full"}),e.jsxs("div",{className:"p-4 space-y-2",children:[e.jsx(Ms,{className:"h-5 w-3/4"}),e.jsx(Ms,{className:"h-4 w-full"})]})]})},I))}),!l&&(S==null?void 0:S.length)===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(vn,{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(W,{variant:"outline",onClick:()=>r(""),children:"Clear Search"})]}),!l&&S&&S.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:S.map(A=>{const I=w(A.id),L=y(A.id),O=_(A.id),V=b(A.id);return n==="grid"?e.jsxs(Pe,{className:"group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer border-border/50",onClick:()=>C(A.id),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:A.preview_image_url?e.jsx("img",{src:A.preview_image_url,alt:A.title,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:e.jsx(vn,{className:"h-16 w-16"})})}),e.jsxs(Oe,{className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1",children:A.title}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-1 text-xs text-muted-foreground",children:[e.jsx(cn,{className:"h-3 w-3"}),vs(new Date(A.publish_date),"MMM d, yyyy")]})]}),A.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:A.description.replace(/<[^>]*>/g,"")}),I>0&&e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[L>0&&e.jsxs(Qe,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(zl,{className:"h-3 w-3"})," ",L," Template",L>1?"s":""]}),O>0&&e.jsxs(Qe,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(Qa,{className:"h-3 w-3"})," ",O," PDF",O>1?"s":""]}),V>0&&e.jsxs(Qe,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(Co,{className:"h-3 w-3"})," ",V," Video",V>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(Bu,{className:"h-3 w-3"})," ",p(A.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Fl,{className:"h-3 w-3"})," ",f(A.id)]})]})]})]},A.id):e.jsx(Pe,{className:"group overflow-hidden hover:shadow-md transition-all duration-200 cursor-pointer border-border/50",onClick:()=>C(A.id),children:e.jsxs("div",{className:"flex flex-row",children:[e.jsx("div",{className:"relative overflow-hidden bg-muted w-40 sm:w-48 shrink-0",children:A.preview_image_url?e.jsx("img",{src:A.preview_image_url,alt:A.title,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground min-h-[100px]",children:e.jsx(vn,{className:"h-10 w-10"})})}),e.jsxs(Oe,{className:"p-4 flex-1 flex flex-col justify-center gap-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1",children:A.title}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 text-xs text-muted-foreground",children:[e.jsx(cn,{className:"h-3 w-3"}),vs(new Date(A.publish_date),"MMM d, yyyy")]})]}),A.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:A.description.replace(/<[^>]*>/g,"")}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[I>0&&e.jsxs("span",{children:[I," resource",I>1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Bu,{className:"h-3 w-3"})," ",p(A.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Fl,{className:"h-3 w-3"})," ",f(A.id)]})]})]})]})},A.id)})})]})})}function R1s({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(Oe,{className:"p-4 space-y-2",children:[o.title&&e.jsx("h4",{className:"font-semibold text-foreground",children:o.title}),o.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:o.description})]})]},l))},n)})})}function O1s(){const{id:t}=io(),s=wr(),{user:r}=Us(),{toast:n}=ja(),a=Qt(),{trackEngagement:o}=QA(),[l,i]=k.useState(""),{data:d,isLoading:u}=gt({queryKey:["newsletter",t],queryFn:async()=>{const{data:L,error:O}=await G.from("newsletter_content").select("*").eq("id",t).single();if(O)throw O;return L},enabled:!!t});k.useEffect(()=>{d&&o("newsletter",d.id,d.title,"view")},[d==null?void 0:d.id]);const{data:p}=gt({queryKey:["newsletter-drives",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_drive_links").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:f}=gt({queryKey:["newsletter-pdfs",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_pdfs").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:y}=gt({queryKey:["newsletter-videos",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_videos").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:_}=gt({queryKey:["newsletter-canva-links",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_canva_links").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:b}=gt({queryKey:["newsletter-likes",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_likes").select("*").eq("newsletter_id",t);return L||[]},enabled:!!t}),{data:N}=gt({queryKey:["newsletter-comments",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_comments").select("*, profiles:user_id(name)").eq("newsletter_id",t).order("created_at",{ascending:!1});return L||[]},enabled:!!t}),w=b==null?void 0:b.some(L=>L.user_id===(r==null?void 0:r.id)),S=Pt({mutationFn:async()=>{w?await G.from("newsletter_likes").delete().eq("newsletter_id",t).eq("user_id",r==null?void 0:r.id):await G.from("newsletter_likes").insert({newsletter_id:t,user_id:r==null?void 0:r.id})},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-likes",t]})}}),C=Pt({mutationFn:async L=>{const{error:O}=await G.from("newsletter_comments").insert({newsletter_id:t,user_id:r==null?void 0:r.id,content:L});if(O)throw O},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",t]}),i(""),n({title:"Comment added"})}}),A=Pt({mutationFn:async L=>{const{error:O}=await G.from("newsletter_comments").delete().eq("id",L);if(O)throw O},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",t]}),n({title:"Comment deleted"})}}),I=L=>{if(L.includes("player.mediadelivery.net")||L.includes("iframe.mediadelivery.net")){const O=L.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(L.includes("youtube.com")||L.includes("youtu.be")){const O=L.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:L,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-primary hover:underline",children:[e.jsx(Co,{className:"h-4 w-4"})," Watch Video"]})};return u?e.jsx(Ds,{title:"",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ms,{className:"h-8 w-32"}),e.jsx(Ms,{className:"h-64 w-full"}),e.jsx(Ms,{className:"h-32 w-full"})]})}):d?e.jsx(Ds,{title:"",description:"",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs(W,{variant:"ghost",onClick:()=>s("/newsletters"),className:"mb-4",children:[e.jsx(Oa,{className:"mr-2 h-4 w-4"})," Back to Newsletters"]}),d.preview_image_url&&e.jsx("img",{src:d.preview_image_url,alt:d.title,className:"w-full h-64 md:h-80 object-cover rounded-lg"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:d.title}),e.jsx("p",{className:"text-muted-foreground mt-1",children:vs(new Date(d.publish_date),"MMMM d, yyyy")})]}),d.description&&e.jsx("div",{className:"text-lg text-muted-foreground prose prose-sm max-w-none dark:prose-invert [&_p]:mb-4 [&_p:last-child]:mb-0 whitespace-pre-line",dangerouslySetInnerHTML:{__html:d.description}}),e.jsx(R1s,{rows:d.content_blocks||[]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(sE,{resourceType:"newsletter",resourceId:d.id,resourceTitle:d.title}),e.jsxs(W,{variant:w?"default":"outline",size:"sm",onClick:()=>S.mutate(),children:[e.jsx(Xa,{className:`h-4 w-4 mr-1 ${w?"fill-current":""}`}),(b==null?void 0:b.length)||0," ",(b==null?void 0:b.length)===1?"Like":"Likes"]})]}),_&&_.length>0&&e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"Canva Templates"})}),e.jsx(Oe,{className:"space-y-2",children:_.map(L=>e.jsxs("a",{href:L.canva_share_link,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("newsletter",d.id,d.title,"click_canva"),className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx(zl,{className:"h-5 w-5 text-purple-500"}),e.jsx("span",{className:"font-medium",children:L.title}),e.jsx(Yr,{className:"h-4 w-4 text-muted-foreground ml-auto"})]},L.id))})]}),p&&p.length>0&&e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"Google Drive Files"})}),e.jsx(Oe,{className:"space-y-2",children:p.map(L=>e.jsxs("a",{href:L.drive_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("newsletter",d.id,d.title,"click_link"),className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx(Yr,{className:"h-5 w-5 text-primary"}),e.jsx("span",{className:"font-medium",children:L.title})]},L.id))})]}),f&&f.length>0&&e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"PDF Downloads"})}),e.jsx(Oe,{className:"space-y-2",children:f.map(L=>e.jsxs("a",{href:L.file_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("newsletter",d.id,d.title,"click_pdf"),className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx(vn,{className:"h-5 w-5 text-red-500"}),e.jsx("span",{className:"font-medium flex-1",children:L.name}),e.jsx(Qa,{className:"h-4 w-4 text-muted-foreground"})]},L.id))})]}),y&&y.length>0&&e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"Videos"})}),e.jsx(Oe,{className:"space-y-6",children:y.map(L=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium",children:L.title}),I(L.video_url)]},L.id))})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"text-lg",children:["Comments (",(N==null?void 0:N.length)||0,")"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(_r,{placeholder:"Write a comment...",value:l,onChange:L=>i(L.target.value),className:"flex-1"}),e.jsx(W,{onClick:()=>l.trim()&&C.mutate(l),disabled:!l.trim()||C.isPending,children:e.jsx(_n,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"space-y-4",children:N==null?void 0:N.map(L=>{var O,V,q;return e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Nn,{className:"h-8 w-8",children:e.jsx(kn,{children:((V=(O=L.profiles)==null?void 0:O.name)==null?void 0:V[0])||"U"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium text-sm",children:((q=L.profiles)==null?void 0:q.name)||"User"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:vs(new Date(L.created_at),"MMM d, yyyy")}),L.user_id===(r==null?void 0:r.id)&&e.jsx(W,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>A.mutate(L.id),children:e.jsx(vr,{className:"h-3 w-3"})})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:L.content})]})]},L.id)})})]})]})]})}):e.jsx(Ds,{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(W,{variant:"link",onClick:()=>s("/newsletters"),children:"Back to Newsletters"})]})})}function F1s({rows:t,onChange:s}){const[r,n]=k.useState(null),a=()=>{s([...t,{columns:[{title:"",description:""},{title:"",description:""},{title:"",description:""}]}])},o=u=>{s(t.filter((p,f)=>f!==u))},l=(u,p,f,y)=>{const _=[...t];_[u]={..._[u],columns:_[u].columns.map((b,N)=>N===p?{...b,[f]:y}:b)},s(_)},i=async(u,p,f)=>{var b;const y=(b=f.target.files)==null?void 0:b[0];if(!y)return;const _=`${u}-${p}`;n(_);try{const N=`content-blocks/${Date.now()}-${y.name}`,{error:w}=await G.storage.from("newsletter-content").upload(N,y);if(!w){const{data:S}=G.storage.from("newsletter-content").getPublicUrl(N);l(u,p,"image_url",S.publicUrl)}}finally{n(null)}},d=(u,p)=>{l(u,p,"image_url","")};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{className:"text-base font-medium",children:"Content Blocks (3-Column Rows)"}),e.jsxs(W,{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,p)=>e.jsxs(Pe,{className:"relative",children:[e.jsx(W,{type:"button",variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-6 w-6 text-muted-foreground hover:text-destructive",onClick:()=>o(p),children:e.jsx(kr,{className:"h-4 w-4"})}),e.jsxs(Oe,{className:"p-4 pt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(mu,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["Row ",p+1]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:u.columns.map((f,y)=>{const _=`${p}-${y}`;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 ",y+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(W,{type:"button",variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>d(p,y),children:e.jsx(kr,{className:"h-3 w-3"})})]}):e.jsxs("div",{children:[e.jsx(De,{type:"file",accept:"image/*",className:"hidden",id:`block-img-${_}`,onChange:b=>i(p,y,b)}),e.jsx(W,{type:"button",variant:"outline",size:"sm",className:"w-full text-xs h-8",disabled:r===_,asChild:!0,children:e.jsx("label",{htmlFor:`block-img-${_}`,className:"cursor-pointer",children:r===_?"Uploading...":e.jsxs(e.Fragment,{children:[e.jsx(qo,{className:"h-3 w-3 mr-1"})," Image"]})})})]}),e.jsx(De,{placeholder:"Title",value:f.title,onChange:b=>l(p,y,"title",b.target.value),className:"h-8 text-sm"}),e.jsx(_r,{placeholder:"Description",value:f.description,onChange:b=>l(p,y,"description",b.target.value),className:"text-sm min-h-[60px] resize-none"})]},y)})})]})]},p))]})}function z1s(){const{toast:t}=ja(),s=Qt(),[r,n]=k.useState(!1),[a,o]=k.useState(null),[l,i]=k.useState({title:"",description:"",publish_date:vs(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),[d,u]=k.useState(null),[p,f]=k.useState(null),[y,_]=k.useState([]),[b,N]=k.useState([]),[w,S]=k.useState([]),[C,A]=k.useState([]),[I,L]=k.useState([]),[O,V]=k.useState([]),[q,B]=k.useState(!1),{data:U,isLoading:te}=gt({queryKey:["admin-newsletters"],queryFn:async()=>{const{data:Me,error:ke}=await G.from("newsletter_content").select("*").order("publish_date",{ascending:!1});if(ke)throw ke;return Me}}),Y=Pt({mutationFn:async Me=>{const{data:ke,error:Re}=await G.from("newsletter_content").insert({title:Me.title,description:Me.description||null,preview_image_url:Me.preview_image_url,publish_date:Me.publish_date,is_published:Me.is_published,content_blocks:Me.content_blocks}).select().single();if(Re)throw Re;return ke},onSuccess:async Me=>{await ce(Me.id),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter created successfully"}),Me.is_published&&AVt(Me.title,Me.id),oe()},onError:Me=>{t({title:"Error creating newsletter",description:Me.message,variant:"destructive"})}}),J=Pt({mutationFn:async Me=>{const{error:ke}=await G.from("newsletter_content").update({title:Me.title,description:Me.description||null,preview_image_url:Me.preview_image_url,publish_date:Me.publish_date,is_published:Me.is_published,content_blocks:Me.content_blocks}).eq("id",Me.id);if(ke)throw ke;return Me.id},onSuccess:async Me=>{await ce(Me),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter updated successfully"}),oe()},onError:Me=>{t({title:"Error updating newsletter",description:Me.message,variant:"destructive"})}}),X=Pt({mutationFn:async Me=>{const{error:ke}=await G.from("newsletter_content").delete().eq("id",Me);if(ke)throw ke},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter deleted successfully"})},onError:Me=>{t({title:"Error deleting newsletter",description:Me.message,variant:"destructive"})}}),ce=async Me=>{await G.from("newsletter_drive_links").delete().eq("newsletter_id",Me),await G.from("newsletter_pdfs").delete().eq("newsletter_id",Me),await G.from("newsletter_videos").delete().eq("newsletter_id",Me),await G.from("newsletter_canva_links").delete().eq("newsletter_id",Me);for(const ke of O){const Re=`${Me}/${Date.now()}-${ke.file.name}`,{error:Ve}=await G.storage.from("newsletter-content").upload(Re,ke.file);if(!Ve){const{data:Ne}=G.storage.from("newsletter-content").getPublicUrl(Re);b.push({name:ke.name,file_url:Ne.publicUrl,file_size:ke.file.size,sort_order:b.length})}}y.length>0&&await G.from("newsletter_drive_links").insert(y.map((ke,Re)=>({newsletter_id:Me,title:ke.title,drive_url:ke.drive_url,sort_order:Re}))),b.length>0&&await G.from("newsletter_pdfs").insert(b.map((ke,Re)=>({newsletter_id:Me,name:ke.name,file_url:ke.file_url,file_size:ke.file_size||null,sort_order:Re}))),w.length>0&&await G.from("newsletter_videos").insert(w.map((ke,Re)=>({newsletter_id:Me,title:ke.title,video_url:ke.video_url,sort_order:Re}))),C.length>0&&await G.from("newsletter_canva_links").insert(C.map((ke,Re)=>({newsletter_id:Me,title:ke.title,canva_share_link:ke.canva_share_link,sort_order:Re})))},ie=async Me=>{o(Me),i({title:Me.title,description:Me.description||"",publish_date:vs(new Date(Me.publish_date),"yyyy-MM-dd'T'HH:mm"),is_published:Me.is_published}),f(Me.preview_image_url),L(Me.content_blocks||[]);const[ke,Re,Ve,Ne]=await Promise.all([G.from("newsletter_drive_links").select("*").eq("newsletter_id",Me.id).order("sort_order"),G.from("newsletter_pdfs").select("*").eq("newsletter_id",Me.id).order("sort_order"),G.from("newsletter_videos").select("*").eq("newsletter_id",Me.id).order("sort_order"),G.from("newsletter_canva_links").select("*").eq("newsletter_id",Me.id).order("sort_order")]);_(ke.data||[]),N(Re.data||[]),S(Ve.data||[]),A(Ne.data||[]),V([]),n(!0)},ae=async Me=>{const[ke,Re,Ve,Ne]=await Promise.all([G.from("newsletter_drive_links").select("*").eq("newsletter_id",Me.id).order("sort_order"),G.from("newsletter_pdfs").select("*").eq("newsletter_id",Me.id).order("sort_order"),G.from("newsletter_videos").select("*").eq("newsletter_id",Me.id).order("sort_order"),G.from("newsletter_canva_links").select("*").eq("newsletter_id",Me.id).order("sort_order")]);o(null),i({title:`${Me.title} (Copy)`,description:Me.description||"",publish_date:vs(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),f(Me.preview_image_url),L(Me.content_blocks||[]),_((ke.data||[]).map(({id:Ue,...Ie})=>Ie)),N((Re.data||[]).map(({id:Ue,...Ie})=>Ie)),S((Ve.data||[]).map(({id:Ue,...Ie})=>Ie)),A((Ne.data||[]).map(({id:Ue,...Ie})=>Ie)),V([]),n(!0)},oe=()=>{n(!1),o(null),i({title:"",description:"",publish_date:vs(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),u(null),f(null),_([]),N([]),S([]),A([]),L([]),V([])},me=async Me=>{var Re;const ke=(Re=Me.target.files)==null?void 0:Re[0];ke&&(u(ke),f(URL.createObjectURL(ke)))},ve=async()=>{if(!l.title){t({title:"Title is required",variant:"destructive"});return}B(!0);let Me=p;if(d){const ke=`previews/${Date.now()}-${d.name}`,{error:Re}=await G.storage.from("newsletter-content").upload(ke,d);if(!Re){const{data:Ve}=G.storage.from("newsletter-content").getPublicUrl(ke);Me=Ve.publicUrl}}a?J.mutate({id:a.id,...l,preview_image_url:Me,content_blocks:I}):Y.mutate({...l,preview_image_url:Me,content_blocks:I}),B(!1)},he=()=>_([...y,{title:"",drive_url:"",sort_order:y.length}]),ge=()=>S([...w,{title:"",video_url:"",sort_order:w.length}]),je=()=>A([...C,{title:"",canva_share_link:"",sort_order:C.length}]),qe=Me=>{const ke=Me.target.files;if(!ke)return;const Re=Array.from(ke).map(Ve=>({file:Ve,name:Ve.name.replace(/\.[^/.]+$/,"")}));V([...O,...Re])};return e.jsx(Ds,{title:"Newsletter Content",description:"Manage monthly newsletter templates and resources",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Hu,{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(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Total"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(U==null?void 0:U.length)||0})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(U==null?void 0:U.filter(Me=>Me.is_published).length)||0})})]})]}),e.jsxs(fs,{open:r,onOpenChange:Me=>!Me&&oe(),children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{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(ks,{children:e.jsx(_s,{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(xe,{children:"Title *"}),e.jsx(De,{value:l.title,onChange:Me=>i({...l,title:Me.target.value}),placeholder:"Newsletter title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Publish Date"}),e.jsx(De,{type:"datetime-local",value:l.publish_date,onChange:Me=>i({...l,publish_date:Me.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Description"}),e.jsx(Wg,{content:l.description,onChange:Me=>i({...l,description:Me}),placeholder:"Newsletter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Preview Image"}),e.jsxs("div",{className:"flex items-center gap-4",children:[p&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:p,alt:"Preview",className:"h-20 w-32 object-cover rounded-md"}),e.jsx(W,{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(kr,{className:"h-3 w-3"})})]}),e.jsxs("div",{children:[e.jsx(De,{type:"file",accept:"image/*",onChange:me,className:"hidden",id:"preview-upload"}),e.jsx(W,{variant:"outline",asChild:!0,children:e.jsxs("label",{htmlFor:"preview-upload",className:"cursor-pointer",children:[e.jsx(Ra,{className:"mr-2 h-4 w-4"})," Upload Image"]})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ar,{checked:l.is_published,onCheckedChange:Me=>i({...l,is_published:Me})}),e.jsx(xe,{children:"Published"})]}),e.jsx(F1s,{rows:I,onChange:L}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{className:"text-base font-medium",children:"Canva Links"}),e.jsxs(W,{type:"button",variant:"outline",size:"sm",onClick:je,children:[e.jsx(qs,{className:"mr-1 h-3 w-3"})," Add Canva Link"]})]}),C.map((Me,ke)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(De,{placeholder:"Link title",value:Me.title,onChange:Re=>{const Ve=[...C];Ve[ke].title=Re.target.value,A(Ve)},className:"w-1/3"}),e.jsx(De,{placeholder:"Canva share link",value:Me.canva_share_link,onChange:Re=>{const Ve=[...C];Ve[ke].canva_share_link=Re.target.value,A(Ve)},className:"flex-1"}),e.jsx(W,{type:"button",variant:"ghost",size:"icon",onClick:()=>A(C.filter((Re,Ve)=>Ve!==ke)),children:e.jsx(kr,{className:"h-4 w-4"})})]},ke))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{className:"text-base font-medium",children:"Google Drive Links"}),e.jsxs(W,{type:"button",variant:"outline",size:"sm",onClick:he,children:[e.jsx(qs,{className:"mr-1 h-3 w-3"})," Add Link"]})]}),y.map((Me,ke)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(De,{placeholder:"Link title",value:Me.title,onChange:Re=>{const Ve=[...y];Ve[ke].title=Re.target.value,_(Ve)},className:"w-1/3"}),e.jsx(De,{placeholder:"Google Drive URL",value:Me.drive_url,onChange:Re=>{const Ve=[...y];Ve[ke].drive_url=Re.target.value,_(Ve)},className:"flex-1"}),e.jsx(W,{type:"button",variant:"ghost",size:"icon",onClick:()=>_(y.filter((Re,Ve)=>Ve!==ke)),children:e.jsx(kr,{className:"h-4 w-4"})})]},ke))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{className:"text-base font-medium",children:"PDF Files"}),e.jsxs("div",{children:[e.jsx(De,{type:"file",accept:".pdf",multiple:!0,onChange:qe,className:"hidden",id:"pdf-upload"}),e.jsx(W,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("label",{htmlFor:"pdf-upload",className:"cursor-pointer",children:[e.jsx(Ra,{className:"mr-1 h-3 w-3"})," Upload PDF"]})})]})]}),b.map((Me,ke)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(vn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm",children:Me.name}),e.jsx(W,{type:"button",variant:"ghost",size:"icon",onClick:()=>N(b.filter((Re,Ve)=>Ve!==ke)),children:e.jsx(kr,{className:"h-4 w-4"})})]},`existing-${ke}`)),O.map((Me,ke)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(vn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(De,{value:Me.name,onChange:Re=>{const Ve=[...O];Ve[ke].name=Re.target.value,V(Ve)},className:"flex-1 h-8",placeholder:"PDF name"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"(new)"}),e.jsx(W,{type:"button",variant:"ghost",size:"icon",onClick:()=>V(O.filter((Re,Ve)=>Ve!==ke)),children:e.jsx(kr,{className:"h-4 w-4"})})]},`pending-${ke}`))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{className:"text-base font-medium",children:"Video Links"}),e.jsxs(W,{type:"button",variant:"outline",size:"sm",onClick:ge,children:[e.jsx(qs,{className:"mr-1 h-3 w-3"})," Add Video"]})]}),w.map((Me,ke)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(De,{placeholder:"Video title",value:Me.title,onChange:Re=>{const Ve=[...w];Ve[ke].title=Re.target.value,S(Ve)},className:"w-1/3"}),e.jsx(De,{placeholder:"Video URL",value:Me.video_url,onChange:Re=>{const Ve=[...w];Ve[ke].video_url=Re.target.value,S(Ve)},className:"flex-1"}),e.jsx(W,{type:"button",variant:"ghost",size:"icon",onClick:()=>S(w.filter((Re,Ve)=>Ve!==ke)),children:e.jsx(kr,{className:"h-4 w-4"})})]},ke))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(W,{variant:"outline",onClick:oe,children:"Cancel"}),e.jsx(W,{onClick:ve,disabled:q||Y.isPending||J.isPending,children:q?"Uploading...":a?"Update":"Create"})]})]})]})]})]}),e.jsx(Pe,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:te?e.jsx(Ps,{children:e.jsx(ht,{colSpan:4,className:"text-center py-8",children:"Loading..."})}):(U==null?void 0:U.length)===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:4,className:"text-center py-8 text-muted-foreground",children:"No newsletters yet. Create your first one!"})}):U==null?void 0:U.map(Me=>e.jsxs(Ps,{children:[e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Me.preview_image_url?e.jsx("img",{src:Me.preview_image_url,alt:Me.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(vn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Me.title}),Me.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Me.description.replace(/<[^>]*>/g,"")})]})]})}),e.jsx(ht,{children:vs(new Date(Me.publish_date),"MMM d, yyyy")}),e.jsx(ht,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${Me.is_published?"bg-green-100 text-green-800 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:Me.is_published?"Published":"Draft"})}),e.jsx(ht,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>ie(Me),title:"Edit",children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>ae(Me),title:"Duplicate",children:e.jsx(Va,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",title:"Delete",onClick:()=>{confirm("Are you sure you want to delete this newsletter?")&&X.mutate(Me.id)},children:e.jsx(vr,{className:"h-4 w-4"})})]})})]},Me.id))})]})})})]})})}const T7e={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 B1s(){const{user:t}=Us(),{toast:s}=ja(),r=wr(),n=Qt(),[a,o]=k.useState(""),[l,i]=k.useState("popular"),[d,u]=k.useState(!1),[p,f]=k.useState(""),[y,_]=k.useState(""),[b,N]=k.useState(!1),{data:w=[],isLoading:S}=gt({queryKey:["wishlist-items",l,b],queryFn:async()=>{let O=G.from("wishlist_items").select("*");b&&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:V,error:q}=await O;if(q)throw q;const B=[...new Set((V==null?void 0:V.map(ie=>ie.user_id))||[])],{data:U}=await G.from("profiles").select("id, name").in("id",B),te=new Map((U==null?void 0:U.map(ie=>[ie.id,ie]))||[]);let Y=[];if(t){const{data:ie}=await G.from("wishlist_votes").select("item_id").eq("user_id",t.id);Y=(ie==null?void 0:ie.map(ae=>ae.item_id))||[]}const J=(V==null?void 0:V.map(ie=>ie.id))||[],{data:X}=await G.from("wishlist_comments").select("item_id").in("item_id",J),ce=new Map;return X==null||X.forEach(ie=>{ce.set(ie.item_id,(ce.get(ie.item_id)||0)+1)}),V==null?void 0:V.map(ie=>{const ae=te.get(ie.user_id),oe=(ae==null?void 0:ae.name)||"Unknown";return{...ie,user_name:oe,user_initials:oe.split(" ").map(me=>me[0]).join("").toUpperCase().slice(0,2),has_voted:Y.includes(ie.id),comment_count:ce.get(ie.id)||0}})}}),C=Pt({mutationFn:async({title:O,description:V})=>{const{error:q}=await G.from("wishlist_items").insert({user_id:t.id,title:O,description:V});if(q)throw q},onSuccess:()=>{n.invalidateQueries({queryKey:["wishlist-items"]}),u(!1),f(""),_(""),s({title:"Idea submitted!",description:"Your idea has been added to the wishlist."})},onError:O=>{s({title:"Error",description:O.message,variant:"destructive"})}}),A=Pt({mutationFn:async({itemId:O,hasVoted:V})=>{if(V){const{error:q}=await G.from("wishlist_votes").delete().eq("item_id",O).eq("user_id",t.id);if(q)throw q;return{itemId:O,wasAdded:!1}}else{const{error:q}=await G.from("wishlist_votes").insert({item_id:O,user_id:t.id});if(q)throw q;return{itemId:O,wasAdded:!0}}},onSuccess:async O=>{if(n.invalidateQueries({queryKey:["wishlist-items"]}),O!=null&&O.wasAdded){const V=w.find(B=>B.id===O.itemId),q=((V==null?void 0:V.vote_count)||0)+1;G.functions.invoke("wishlist-notify",{body:{itemId:O.itemId,voteCount:q}}).catch(console.error)}},onError:O=>{s({title:"Error",description:O.message,variant:"destructive"})}}),I=w.filter(O=>O.title.toLowerCase().includes(a.toLowerCase())||O.description.toLowerCase().includes(a.toLowerCase())),L=()=>{if(!p.trim()||!y.trim()){s({title:"Error",description:"Please fill in both title and description.",variant:"destructive"});return}C.mutate({title:p.trim(),description:y.trim()})};return e.jsx(Ds,{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(Cb,{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:d,onOpenChange:u,children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"}),"Add Idea"]})}),e.jsxs(ps,{children:[e.jsx(ks,{children:e.jsx(_s,{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(xe,{htmlFor:"title",children:"Title"}),e.jsx(De,{id:"title",placeholder:"Give your idea a clear title...",value:p,onChange:O=>f(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"description",children:"Description"}),e.jsx(_r,{id:"description",placeholder:"Describe your idea in detail. What problem does it solve? How would it help agents?",value:y,onChange:O=>_(O.target.value),rows:4})]}),e.jsx(W,{onClick:L,className:"w-full",disabled:C.isPending,children:C.isPending?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Submitting..."]}):"Submit Idea"})]})]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 mb-6",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search ideas...",value:a,onChange:O=>o(O.target.value),className:"pl-10"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(ta,{value:l,onValueChange:O=>i(O),children:e.jsxs(Jn,{children:[e.jsx(cs,{value:"popular",children:"Most Popular"}),e.jsx(cs,{value:"latest",children:"Latest"}),e.jsx(cs,{value:"trending",children:"Trending"})]})})})]}),e.jsx("div",{className:"flex items-center gap-2 mb-4",children:e.jsx(W,{variant:b?"default":"outline",size:"sm",onClick:()=>N(!b),children:b?"Show All Ideas":"My Ideas"})}),S?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(us,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):I.length===0?e.jsxs("div",{className:"text-center py-12 bg-muted/30 rounded-lg",children:[e.jsx(Cb,{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(W,{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:V=>{V.stopPropagation(),A.mutate({itemId:O.id,hasVoted:O.has_voted||!1})},className:Ot("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(uu,{className:Ot("h-4 w-4",O.has_voted&&"fill-current")}),e.jsx("span",{className:"text-sm font-semibold",children:O.vote_count})]}),e.jsx(Nn,{className:"h-10 w-10 bg-primary/20",children:e.jsx(kn,{className:"bg-primary/20 text-primary text-sm font-medium",children:O.user_initials})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:O.title}),e.jsx(Qe,{className:Ot("text-xs",T7e[O.status].color),children:T7e[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(wi,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:O.comment_count})]})]})},O.id))})]})})}const A7e={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 $1s(){const{itemId:t}=io(),s=wr(),{user:r}=Us(),{toast:n}=ja(),a=Qt(),[o,l]=k.useState(""),{data:i=!1}=gt({queryKey:["user-is-admin",r==null?void 0:r.id],queryFn:async()=>{if(!r)return!1;const{data:w,error:S}=await G.from("user_roles").select("role").eq("user_id",r.id).eq("role","admin").maybeSingle();return!S&&!!w},enabled:!!r}),{data:d,isLoading:u}=gt({queryKey:["wishlist-item",t],queryFn:async()=>{const{data:w,error:S}=await G.from("wishlist_items").select("*").eq("id",t).single();if(S)throw S;const{data:C}=await G.from("profiles").select("name").eq("id",w.user_id).single();let A=!1;if(r){const{data:I}=await G.from("wishlist_votes").select("id").eq("item_id",t).eq("user_id",r.id).maybeSingle();A=!!I}return{...w,user_name:(C==null?void 0:C.name)||"Unknown",user_initials:((C==null?void 0:C.name)||"U").split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),has_voted:A}}}),{data:p=[],isLoading:f}=gt({queryKey:["wishlist-comments",t],queryFn:async()=>{const{data:w,error:S}=await G.from("wishlist_comments").select("*").eq("item_id",t).order("created_at",{ascending:!0});if(S)throw S;const C=[...new Set((w==null?void 0:w.map(L=>L.user_id))||[])],{data:A}=await G.from("profiles").select("id, name").in("id",C),I=new Map((A==null?void 0:A.map(L=>[L.id,L]))||[]);return w==null?void 0:w.map(L=>{const O=I.get(L.user_id),V=(O==null?void 0:O.name)||"Unknown";return{...L,user_name:V,user_initials:V.split(" ").map(q=>q[0]).join("").toUpperCase().slice(0,2)}})}}),y=Pt({mutationFn:async w=>{if(w){const{error:S}=await G.from("wishlist_votes").delete().eq("item_id",t).eq("user_id",r.id);if(S)throw S;return{wasAdded:!1}}else{const{error:S}=await G.from("wishlist_votes").insert({item_id:t,user_id:r.id});if(S)throw S;return{wasAdded:!0}}},onSuccess:async w=>{if(a.invalidateQueries({queryKey:["wishlist-item",t]}),a.invalidateQueries({queryKey:["wishlist-items"]}),w!=null&&w.wasAdded&&d){const S=(d.vote_count||0)+1;G.functions.invoke("wishlist-notify",{body:{itemId:t,voteCount:S}}).catch(console.error)}},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),_=Pt({mutationFn:async w=>{const{error:S}=await G.from("wishlist_comments").insert({item_id:t,user_id:r.id,content:w});if(S)throw S},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),l(""),n({title:"Comment added!"})},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),b=Pt({mutationFn:async w=>{const{error:S}=await G.from("wishlist_comments").delete().eq("id",w);if(S)throw S},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),n({title:"Comment deleted"})},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),N=()=>{o.trim()&&_.mutate(o.trim())};return u?e.jsx(Ds,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx(Ms,{className:"h-8 w-32 mb-6"}),e.jsx(Ms,{className:"h-48 w-full mb-6"}),e.jsx(Ms,{className:"h-32 w-full"})]})}):d?e.jsx(Ds,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsxs(W,{variant:"ghost",size:"sm",onClick:()=>s("/wishlist"),className:"mb-4",children:[e.jsx(Oa,{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:()=>y.mutate(d.has_voted),className:Ot("flex flex-col items-center justify-center min-w-[60px] py-3 px-4 rounded-lg border transition-colors",d.has_voted?"bg-primary/10 border-primary text-primary":"bg-muted/50 border-border hover:bg-muted"),children:[e.jsx(uu,{className:Ot("h-5 w-5",d.has_voted&&"fill-current")}),e.jsx("span",{className:"text-lg font-bold",children:d.vote_count}),e.jsx("span",{className:"text-xs",children:"votes"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h1",{className:"text-xl font-bold",children:d.title}),e.jsx(Qe,{className:Ot("text-xs",A7e[d.status].color),children:A7e[d.status].label})]}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap mb-4",children:d.description}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Nn,{className:"h-6 w-6",children:e.jsx(kn,{className:"bg-primary/20 text-primary text-xs",children:d.user_initials})}),e.jsx("span",{children:d.user_name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:new Date(d.created_at).toLocaleDateString()})]})]})]})}),e.jsxs("div",{className:"bg-card border rounded-lg p-6",children:[e.jsxs("h2",{className:"text-lg font-semibold mb-4",children:["Comments (",p.length,")"]}),e.jsxs("div",{className:"flex gap-3 mb-6",children:[e.jsx(fce,{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(W,{onClick:N,disabled:!o.trim()||_.isPending,size:"icon",className:"h-auto",children:_.isPending?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(_n,{className:"h-4 w-4"})})]}),f?e.jsx("div",{className:"space-y-4",children:[1,2].map(w=>e.jsx(Ms,{className:"h-20 w-full"},w))}):p.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No comments yet. Be the first to share your thoughts!"}):e.jsx("div",{className:"space-y-4",children:p.map(w=>e.jsxs("div",{className:"flex gap-3 p-3 bg-muted/30 rounded-lg",children:[e.jsx(Nn,{className:"h-8 w-8",children:e.jsx(kn,{className:"bg-primary/20 text-primary text-xs",children:w.user_initials})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium text-sm",children:w.user_name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(w.created_at).toLocaleDateString()})]}),e.jsx(h4e,{content:w.content,className:"text-sm text-foreground"})]}),(r==null?void 0:r.id)===w.user_id&&e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>b.mutate(w.id),children:e.jsx(vr,{className:"h-4 w-4"})})]},w.id))})]})]})}):e.jsx(Ds,{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(W,{variant:"link",onClick:()=>s("/wishlist"),children:"Go back to Wishlist"})]})})}const E7e={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"}},P7e=["open","under_review","planned","in_progress","launched","declined"];function q1s(){const{toast:t}=ja(),s=wr(),r=Qt(),[n,a]=k.useState(""),[o,l]=k.useState("all"),[i,d]=k.useState(!1),[u,p]=k.useState(null),{data:f=[],isLoading:y}=gt({queryKey:["admin-wishlist-items"],queryFn:async()=>{const{data:S,error:C}=await G.from("wishlist_items").select("*").order("vote_count",{ascending:!1});if(C)throw C;const A=[...new Set((S==null?void 0:S.map(B=>B.user_id))||[])],{data:I}=await G.from("profiles").select("id, name, email").in("id",A),L=new Map((I==null?void 0:I.map(B=>[B.id,B]))||[]),O=(S==null?void 0:S.map(B=>B.id))||[],{data:V}=await G.from("wishlist_comments").select("item_id").in("item_id",O),q=new Map;return V==null||V.forEach(B=>{q.set(B.item_id,(q.get(B.item_id)||0)+1)}),S==null?void 0:S.map(B=>{const U=L.get(B.user_id);return{...B,user_name:(U==null?void 0:U.name)||"Unknown",user_email:(U==null?void 0:U.email)||"",comment_count:q.get(B.id)||0}})}}),_=Pt({mutationFn:async({itemId:S,status:C})=>{const{error:A}=await G.from("wishlist_items").update({status:C}).eq("id",S);if(A)throw A},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),t({title:"Status updated!"})},onError:S=>{t({title:"Error",description:S.message,variant:"destructive"})}}),b=Pt({mutationFn:async S=>{const{error:C}=await G.from("wishlist_items").delete().eq("id",S);if(C)throw C},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),d(!1),p(null),t({title:"Item deleted!"})},onError:S=>{t({title:"Error",description:S.message,variant:"destructive"})}}),N=f.filter(S=>{const C=S.title.toLowerCase().includes(n.toLowerCase())||S.description.toLowerCase().includes(n.toLowerCase())||S.user_name.toLowerCase().includes(n.toLowerCase()),A=o==="all"||S.status===o;return C&&A}),w={total:f.length,open:f.filter(S=>S.status==="open").length,inProgress:f.filter(S=>S.status==="in_progress").length,launched:f.filter(S=>S.status==="launched").length,highVotes:f.filter(S=>S.vote_count>=10).length};return e.jsx(Ds,{title:"Admin - Wishlist",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>s("/admin"),children:e.jsx(Oa,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Wishlist Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Review and manage community ideas"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Ideas"}),e.jsx("p",{className:"text-2xl font-bold",children:w.total})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Open"}),e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:w.open})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"In Progress"}),e.jsx("p",{className:"text-2xl font-bold text-orange-600",children:w.inProgress})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Launched"}),e.jsx("p",{className:"text-2xl font-bold text-green-600",children:w.launched})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"10+ Votes"}),e.jsx("p",{className:"text-2xl font-bold text-primary",children:w.highVotes})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search ideas, users...",value:n,onChange:S=>a(S.target.value),className:"pl-10"})]}),e.jsxs($s,{value:o,onValueChange:S=>l(S),children:[e.jsx(zs,{className:"w-[180px]",children:e.jsx(Vs,{placeholder:"Filter by status"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Statuses"}),P7e.map(S=>e.jsx(vt,{value:S,children:E7e[S].label},S))]})]})]}),y?e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(S=>e.jsx(Ms,{className:"h-16 w-full"},S))}):e.jsx("div",{className:"bg-card border rounded-lg overflow-hidden",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{className:"w-[60px]",children:"Votes"}),e.jsx(St,{children:"Title"}),e.jsx(St,{className:"hidden md:table-cell",children:"Submitted By"}),e.jsx(St,{className:"hidden sm:table-cell",children:"Comments"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Rn,{children:N.length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No items found"})}):N.map(S=>e.jsxs(Ps,{className:Ot(S.vote_count>=10&&"bg-primary/5"),children:[e.jsx(ht,{children:e.jsx(Qe,{variant:S.vote_count>=10?"default":"secondary",children:S.vote_count})}),e.jsx(ht,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium line-clamp-1",children:S.title}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:S.description})]})}),e.jsx(ht,{className:"hidden md:table-cell",children:e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",children:S.user_name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S.user_email})]})}),e.jsx(ht,{className:"hidden sm:table-cell",children:S.comment_count}),e.jsx(ht,{children:e.jsxs($s,{value:S.status,onValueChange:C=>_.mutate({itemId:S.id,status:C}),children:[e.jsx(zs,{className:"w-[140px] h-8",children:e.jsx(Vs,{})}),e.jsx(Bs,{children:P7e.map(C=>e.jsx(vt,{value:C,children:E7e[C].label},C))})]})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>window.open(`/wishlist/${S.id}`,"_blank"),children:e.jsx(Yr,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{p(S.id),d(!0)},children:e.jsx(vr,{className:"h-4 w-4"})})]})})]},S.id))})]})}),e.jsx(fs,{open:i,onOpenChange:d,children:e.jsxs(ps,{children:[e.jsx(ks,{children:e.jsx(_s,{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(W,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(W,{variant:"destructive",onClick:()=>u&&b.mutate(u),disabled:b.isPending,children:b.isPending?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})})}function U1s(){const{user:t}=Us(),[s,r]=k.useState([]),[n,a]=k.useState(!0),[o,l]=k.useState(!1),[i,d]=k.useState(null),[u,p]=k.useState(!1),[f,y]=k.useState(null),[_,b]=k.useState(""),[N,w]=k.useState(""),[S,C]=k.useState(""),[A,I]=k.useState(""),[L,O]=k.useState(""),[V,q]=k.useState(!1),[B,U]=k.useState(""),[te,Y]=k.useState("once"),[J,X]=k.useState([]),[ce,ie]=k.useState([]),[ae,oe]=k.useState(!1),[me,ve]=k.useState(!1),[he,ge]=k.useState([]),[je,qe]=k.useState({total:0,dismissed:0});k.useEffect(()=>{Me()},[]);const Me=async()=>{const{data:Je,error:ut}=await G.from("levelup_briefs").select("*").order("created_at",{ascending:!1});ut?(pe.error("Failed to fetch briefs"),console.error(ut)):r(Je||[]),a(!1)},ke=()=>{b(""),w(""),C(""),I(""),O(""),q(!1),U(new Date().toISOString().slice(0,16)),Y("once"),X([]),ie([]),d(null)},Re=()=>{ke(),l(!0)},Ve=async Je=>{d(Je),b(Je.title),w(Je.description||""),C(Je.video_url||""),I(Je.graphic_url||""),O(Je.graphic_link_url||""),q(Je.is_published),U(Je.publish_date.slice(0,16)),Y(Je.show_frequency);const{data:ut}=await G.from("levelup_brief_links").select("*").eq("brief_id",Je.id).order("sort_order");X((ut==null?void 0:ut.map(et=>({title:et.title,url:et.url})))||[]);const{data:mt}=await G.from("levelup_brief_polls").select("*").eq("brief_id",Je.id).order("sort_order");if(mt){const et=[];for(const Ze of mt){const{data:kt}=await G.from("levelup_brief_poll_options").select("*").eq("poll_id",Ze.id).order("sort_order");et.push({question:Ze.question,poll_type:Ze.poll_type,options:(kt==null?void 0:kt.map(Ut=>Ut.option_text))||[]})}ie(et)}l(!0)},Ne=async Je=>{var mt;const ut=(mt=Je.target.files)==null?void 0:mt[0];if(ut){oe(!0);try{const et=await G.functions.invoke("bunny-upload",{body:{action:"create",title:ut.name.replace(/\.[^/.]+$/,"")}});if(et.error)throw et.error;const{videoId:Ze,libraryId:kt}=et.data,Ut=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Ze}});if(Ut.error)throw Ut.error;const{uploadUrl:Nt,apiKey:es}=Ut.data,ds=new XMLHttpRequest;await new Promise((lr,Lt)=>{ds.upload.addEventListener("progress",Es=>{if(Es.lengthComputable){const fr=Math.round(Es.loaded/Es.total*100);console.log("Upload progress:",fr)}}),ds.addEventListener("load",()=>{ds.status>=200&&ds.status<300?lr():Lt(new Error(`Upload failed with status ${ds.status}`))}),ds.addEventListener("error",()=>Lt(new Error("Upload failed"))),ds.open("PUT",Nt),ds.setRequestHeader("AccessKey",es),ds.send(ut)});const js=`https://player.mediadelivery.net/embed/${kt}/${Ze}`;C(js),pe.success("Video uploaded successfully! It may take a few minutes to process.")}catch(et){console.error("Upload error:",et),pe.error("Failed to upload video")}finally{oe(!1)}}},Ue=async()=>{if(!_.trim()){pe.error("Title is required");return}try{let Je;if(i){const{error:ut}=await G.from("levelup_briefs").update({title:_,description:N||null,video_url:S||null,graphic_url:A||null,graphic_link_url:L||null,is_published:V,publish_date:B,show_frequency:te}).eq("id",i.id);if(ut)throw ut;Je=i.id,await G.from("levelup_brief_links").delete().eq("brief_id",Je);const{data:mt}=await G.from("levelup_brief_polls").select("id").eq("brief_id",Je);if(mt)for(const et of mt)await G.from("levelup_brief_poll_options").delete().eq("poll_id",et.id);await G.from("levelup_brief_polls").delete().eq("brief_id",Je)}else{const{data:ut,error:mt}=await G.from("levelup_briefs").insert({title:_,description:N||null,video_url:S||null,graphic_url:A||null,graphic_link_url:L||null,is_published:V,publish_date:B,show_frequency:te,created_by:t==null?void 0:t.id}).select().single();if(mt)throw mt;Je=ut.id}if(J.length>0){const ut=J.map((mt,et)=>({brief_id:Je,title:mt.title,url:mt.url,sort_order:et}));await G.from("levelup_brief_links").insert(ut)}for(let ut=0;ut0){const kt=mt.options.map((Ut,Nt)=>({poll_id:et.id,option_text:Ut,sort_order:Nt}));await G.from("levelup_brief_poll_options").insert(kt)}}pe.success(i?"Brief updated":"Brief created"),l(!1),ke(),Me()}catch(Je){console.error("Error saving brief:",Je),pe.error("Failed to save brief")}},Ie=async Je=>{if(confirm("Are you sure you want to delete this brief?"))try{const{error:ut}=await G.from("levelup_briefs").delete().eq("id",Je);if(ut)throw ut;pe.success("Brief deleted"),Me()}catch(ut){console.error("Error deleting brief:",ut),pe.error("Failed to delete brief")}},ye=async Je=>{y(Je);const{count:ut}=await G.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",Je.id),{count:mt}=await G.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",Je.id).not("dismissed_at","is",null);qe({total:ut||0,dismissed:mt||0});const{data:et}=await G.from("levelup_brief_polls").select("*").eq("brief_id",Je.id).order("sort_order");if(et){const Ze=[];for(const kt of et){const{data:Ut}=await G.from("levelup_brief_poll_options").select("*").eq("poll_id",kt.id).order("sort_order"),{data:Nt}=await G.from("levelup_brief_poll_responses").select("option_id, user_id").eq("poll_id",kt.id),es=[...new Set((Nt==null?void 0:Nt.map(Es=>Es.user_id))||[])];let ds={};if(es.length>0){const{data:Es}=await G.from("profiles").select("id, name, email").in("id",es);Es&&Es.forEach(fr=>{ds[fr.id]=fr.name||fr.email||"Unknown"})}const js=(Nt||[]).map(Es=>({optionId:Es.option_id,userName:ds[Es.user_id]||"Unknown",userId:Es.user_id})),lr={};let Lt=0;Ut&&Ut.forEach(Es=>{const fr=(Nt==null?void 0:Nt.filter(Hs=>Hs.option_id===Es.id).length)||0;lr[Es.id]=fr,Lt+=fr}),Ze.push({...kt,options:Ut||[],results:lr,respondents:js,totalResponses:kt.poll_type==="single"?new Set(Nt==null?void 0:Nt.map(Es=>Es.user_id)).size:Lt})}ge(Ze)}p(!0)},ct=()=>{X([...J,{title:"",url:""}])},fe=(Je,ut,mt)=>{const et=[...J];et[Je][ut]=mt,X(et)},$e=Je=>{X(J.filter((ut,mt)=>mt!==Je))},Ye=()=>{ie([...ce,{question:"",poll_type:"single",options:["",""]}])},tt=(Je,ut)=>{const mt=[...ce];mt[Je].question=ut,ie(mt)},Te=(Je,ut)=>{const mt=[...ce];mt[Je].poll_type=ut,ie(mt)},We=Je=>{const ut=[...ce];ut[Je].options.push(""),ie(ut)},Ke=(Je,ut,mt)=>{const et=[...ce];et[Je].options[ut]=mt,ie(et)},ot=(Je,ut)=>{const mt=[...ce];mt[Je].options=mt[Je].options.filter((et,Ze)=>Ze!==ut),ie(mt)},He=Je=>{ie(ce.filter((ut,mt)=>mt!==Je))};return e.jsxs(Ds,{title:"The LevelUp Brief",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(Hu,{title:"The LevelUp Brief",description:"Create engaging popup briefs for your agents",children:e.jsxs(W,{onClick:Re,children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create Brief"]})}),e.jsx(Pe,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Frequency"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:n?e.jsx(Ps,{children:e.jsx(ht,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):s.length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No briefs created yet"})}):s.map(Je=>e.jsxs(Ps,{children:[e.jsx(ht,{className:"font-medium",children:Je.title}),e.jsx(ht,{children:e.jsx(Qe,{variant:Je.is_published?"default":"secondary",children:Je.is_published?"Published":"Draft"})}),e.jsx(ht,{className:"capitalize",children:Je.show_frequency.replace("_"," ")}),e.jsx(ht,{children:vs(new Date(Je.publish_date),"MMM d, yyyy h:mm a")}),e.jsx(ht,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>ye(Je),children:e.jsx(so,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>Ve(Je),children:e.jsx(Wc,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>Ie(Je.id),children:e.jsx(vr,{className:"h-4 w-4 text-destructive"})})]})})]},Je.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(ks,{children:e.jsx(_s,{children:i?"Edit Brief":"Create New Brief"})}),e.jsxs(ta,{defaultValue:"content",className:"w-full",children:[e.jsxs(Jn,{className:"grid w-full grid-cols-4",children:[e.jsx(cs,{value:"content",children:"Content"}),e.jsx(cs,{value:"media",children:"Media"}),e.jsx(cs,{value:"links",children:"Links"}),e.jsx(cs,{value:"polls",children:"Polls"})]}),e.jsxs(Ss,{value:"content",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Title *"}),e.jsx(De,{value:_,onChange:Je=>b(Je.target.value),placeholder:"What's happening at LevelUp..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Description"}),e.jsx(Wg,{content:N,onChange:Je=>w(Je),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(xe,{children:"Publish Date"}),e.jsx(De,{type:"datetime-local",value:B,onChange:Je=>U(Je.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Show Frequency"}),e.jsxs($s,{value:te,onValueChange:Y,children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"once",children:"Once (until dismissed)"}),e.jsx(vt,{value:"every_login",children:"Every login"}),e.jsx(vt,{value:"daily",children:"Daily"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ar,{checked:V,onCheckedChange:q}),e.jsx(xe,{children:"Publish immediately"})]})]}),e.jsxs(Ss,{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(xe,{children:"Upload Video to Bunny.net"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(De,{type:"file",accept:"video/*",onChange:Ne,disabled:ae})}),ae&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Or paste embed URL"}),e.jsx(De,{value:S,onChange:Je=>C(Je.target.value),placeholder:"https://iframe.mediadelivery.net/embed/..."})]}),S&&e.jsx("div",{className:"aspect-video rounded-lg overflow-hidden bg-muted",children:e.jsx("iframe",{src:S,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(xe,{children:"Upload Image"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(De,{type:"file",accept:"image/*",onChange:async Je=>{var mt;const ut=(mt=Je.target.files)==null?void 0:mt[0];if(ut){ve(!0);try{const et=ut.name.split(".").pop(),Ze=`brief-graphics/${Date.now()}.${et}`,{error:kt}=await G.storage.from("banner-images").upload(Ze,ut,{upsert:!0});if(kt)throw kt;const{data:Ut}=G.storage.from("banner-images").getPublicUrl(Ze);I(Ut.publicUrl),pe.success("Image uploaded!")}catch(et){console.error(et),pe.error("Failed to upload image")}finally{ve(!1)}}},disabled:me})}),me&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Or paste Image URL"}),e.jsx(De,{value:A,onChange:Je=>I(Je.target.value),placeholder:"https://example.com/image.png"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Click-through Link (optional)"}),e.jsx(De,{value:L,onChange:Je=>O(Je.target.value),placeholder:"https://example.com/landing-page"})]}),A&&e.jsx("div",{className:"rounded-lg overflow-hidden bg-muted border",children:e.jsx("img",{src:A,alt:"Brief graphic preview",className:"w-full object-contain max-h-64"})})]})]}),e.jsxs(Ss,{value:"links",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(xe,{children:"Quick Links"}),e.jsxs(W,{variant:"outline",size:"sm",onClick:ct,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),J.map((Je,ut)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsx(De,{value:Je.title,onChange:mt=>fe(ut,"title",mt.target.value),placeholder:"Link title",className:"flex-1"}),e.jsx(De,{value:Je.url,onChange:mt=>fe(ut,"url",mt.target.value),placeholder:"https://...",className:"flex-[2]"}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>$e(ut),children:e.jsx(vr,{className:"h-4 w-4 text-destructive"})})]},ut)),J.length===0&&e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No links added yet"})]}),e.jsxs(Ss,{value:"polls",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(xe,{children:"Polls"}),e.jsxs(W,{variant:"outline",size:"sm",onClick:Ye,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Poll"]})]}),ce.map((Je,ut)=>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(De,{value:Je.question,onChange:mt=>tt(ut,mt.target.value),placeholder:"Poll question...",className:"flex-1 mr-2"}),e.jsxs($s,{value:Je.poll_type,onValueChange:mt=>Te(ut,mt),children:[e.jsx(zs,{className:"w-32",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"single",children:"Single"}),e.jsx(vt,{value:"multi",children:"Multi-select"})]})]}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>He(ut),children:e.jsx(vr,{className:"h-4 w-4 text-destructive"})})]}),e.jsxs("div",{className:"space-y-2 pl-4",children:[Je.options.map((mt,et)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{value:mt,onChange:Ze=>Ke(ut,et,Ze.target.value),placeholder:`Option ${et+1}`}),Je.options.length>2&&e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>ot(ut,et),children:e.jsx(vr,{className:"h-4 w-4 text-muted-foreground"})})]},et)),e.jsxs(W,{variant:"ghost",size:"sm",onClick:()=>We(ut),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Option"]})]})]})},ut)),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(W,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(W,{onClick:Ue,children:i?"Update Brief":"Create Brief"})]})]})}),e.jsx(fs,{open:u,onOpenChange:p,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(ks,{children:e.jsxs(_s,{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(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Views"})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-2xl font-bold",children:je.total})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Dismissed"})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-2xl font-bold",children:je.dismissed})})]})]}),he.length>0?e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-semibold",children:"Poll Results"}),he.map(Je=>e.jsxs(Pe,{className:"p-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:Je.question}),e.jsx("div",{className:"space-y-2",children:Je.options.map(ut=>{const mt=Je.results[ut.id]||0,et=Je.totalResponses>0?Math.round(mt/Je.totalResponses*100):0;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:ut.option_text}),e.jsxs("span",{className:"text-muted-foreground",children:[mt," (",et,"%)"]})]}),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:`${et}%`}})}),mt>0&&e.jsx("div",{className:"flex flex-wrap gap-1 pt-1",children:(Je.respondents||[]).filter(Ze=>Ze.optionId===ut.id).map((Ze,kt)=>e.jsx(Qe,{variant:"secondary",className:"text-xs font-normal",children:Ze.userName},kt))})]},ut.id)})})]},Je.id))]}):e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No polls in this brief"})]})]})})]})}const V1s=()=>{const{user:t}=Us(),{toast:s}=ja(),r=Qt(),[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,d]=k.useState({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,p]=k.useState(null),[f,y]=k.useState(""),{data:_=[],isLoading:b}=gt({queryKey:["additional-services-admin"],queryFn:async()=>{const{data:L,error:O}=await G.from("additional_services").select("*").order("publish_date",{ascending:!1});if(O)throw O;return L}}),N=Pt({mutationFn:async L=>{let O=L.existingImageUrl;if(L.image){const q=L.image.name.split(".").pop(),B=`${Date.now()}-${Math.random().toString(36).substring(7)}.${q}`,{error:U}=await G.storage.from("service-images").upload(B,L.image);if(U)throw U;const{data:te}=G.storage.from("service-images").getPublicUrl(B);O=te.publicUrl}const V={name:L.item.name,description:L.item.description||null,preview_image_url:O,signup_link_url:L.item.signup_link_url,publish_date:L.item.publish_date?new Date(L.item.publish_date).toISOString():new Date().toISOString(),is_published:L.item.is_published,created_by:t==null?void 0:t.id};if(L.itemId){const{error:q}=await G.from("additional_services").update(V).eq("id",L.itemId);if(q)throw q}else{const{error:q}=await G.from("additional_services").insert(V);if(q)throw q}},onSuccess:()=>{r.invalidateQueries({queryKey:["additional-services-admin"]}),r.invalidateQueries({queryKey:["additional-services"]}),s({title:o?"Service updated":"Service created"}),a(!1),S()},onError:L=>{s({title:"Error saving service",description:L.message,variant:"destructive"})}}),w=Pt({mutationFn:async L=>{const{error:O}=await G.from("additional_services").delete().eq("id",L);if(O)throw O},onSuccess:()=>{r.invalidateQueries({queryKey:["additional-services-admin"]}),r.invalidateQueries({queryKey:["additional-services"]}),s({title:"Service deleted"})},onError:L=>{s({title:"Error deleting service",description:L.message,variant:"destructive"})}}),S=()=>{d({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),p(null),y(""),l(null)},C=L=>{l(L),d({name:L.name,description:L.description||"",signup_link_url:L.signup_link_url,publish_date:L.publish_date?new Date(L.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:L.is_published}),y(L.preview_image_url||""),a(!0)},A=L=>{var V;const O=(V=L.target.files)==null?void 0:V[0];O&&(p(O),y(URL.createObjectURL(O)))},I=L=>{if(L.preventDefault(),!i.name.trim()){s({title:"Name is required",variant:"destructive"});return}if(!i.signup_link_url.trim()){s({title:"Signup link URL is required",variant:"destructive"});return}N.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(Ds,{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(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Services"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.length})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.filter(L=>L.is_published).length})})]})]}),e.jsxs(fs,{open:n,onOpenChange:L=>{a(L),L||S()},children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{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(ks,{children:e.jsx(_s,{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(xe,{htmlFor:"name",children:"Name *"}),e.jsx(De,{id:"name",value:i.name,onChange:L=>d({...i,name:L.target.value}),placeholder:"Enter service name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Description"}),e.jsx(Wg,{content:i.description,onChange:L=>d({...i,description:L}),placeholder:"Enter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"signup_link_url",children:"Signup Link URL *"}),e.jsx(De,{id:"signup_link_url",type:"url",value:i.signup_link_url,onChange:L=>d({...i,signup_link_url:L.target.value}),placeholder:"https://example.com/signup"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(De,{id:"publish_date",type:"date",value:i.publish_date,onChange:L=>d({...i,publish_date:L.target.value})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ar,{id:"is_published",checked:i.is_published,onCheckedChange:L=>d({...i,is_published:L})}),e.jsx(xe,{htmlFor:"is_published",children:"Published"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{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(W,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{p(null),y("")},children:e.jsx(kr,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[e.jsx(qo,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx(De,{type:"file",accept:"image/*",onChange:A,className:"cursor-pointer"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(W,{type:"submit",disabled:N.isPending,children:N.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(Pe,{children:e.jsx(Oe,{className:"p-0",children:b?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):_.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'No services yet. Click "Add Service" to create your first one.'}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{className:"w-16",children:"Preview"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Signup Link"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:_.map(L=>e.jsxs(Ps,{children:[e.jsx(ht,{children:L.preview_image_url?e.jsx("img",{src:L.preview_image_url,alt:"",className:"w-12 h-12 object-cover rounded"}):e.jsx("div",{className:"w-12 h-12 bg-muted rounded flex items-center justify-center",children:e.jsx(qo,{className:"h-5 w-5 text-muted-foreground"})})}),e.jsx(ht,{className:"font-medium",children:L.name}),e.jsx(ht,{children:e.jsxs("a",{href:L.signup_link_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline flex items-center gap-1",children:[e.jsx(Yr,{className:"h-3 w-3"}),"Link"]})}),e.jsx(ht,{children:new Date(L.publish_date).toLocaleDateString()}),e.jsx(ht,{children:e.jsx(Qe,{variant:L.is_published?"default":"secondary",children:L.is_published?"Published":"Draft"})}),e.jsx(ht,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>C(L),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this service?")&&w.mutate(L.id)},children:e.jsx(vr,{className:"h-4 w-4 text-destructive"})})]})})]},L.id))})]})})})]})})};function H1s(){const{toast:t}=ja(),[s,r]=k.useState([]),[n,a]=k.useState(!0),[o,l]=k.useState(!1),[i,d]=k.useState(!1),[u,p]=k.useState({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""});k.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:w,error:S}=await G.functions.invoke("stripe-manage-coupons",{body:{action:"list"}});if(S)throw S;r(w.coupons||[])}catch(w){console.error("Error fetching coupons:",w),t({title:"Error",description:"Failed to load coupons",variant:"destructive"})}finally{a(!1)}},y=async()=>{if(!u.name){t({title:"Error",description:"Please enter a coupon name",variant:"destructive"});return}if(u.discountType==="percent"&&!u.percentOff){t({title:"Error",description:"Please enter a percent off value",variant:"destructive"});return}if(u.discountType==="amount"&&!u.amountOff){t({title:"Error",description:"Please enter an amount off value",variant:"destructive"});return}if(u.duration==="repeating"&&!u.durationInMonths){t({title:"Error",description:"Please enter duration in months",variant:"destructive"});return}l(!0);try{const w={action:"create",name:u.name,duration:u.duration,promotion_code:u.promotionCode.trim()||void 0};u.discountType==="percent"?w.percent_off=parseFloat(u.percentOff):(w.amount_off=Math.round(parseFloat(u.amountOff)*100),w.currency="usd"),u.duration==="repeating"&&(w.duration_in_months=parseInt(u.durationInMonths));const{data:S,error:C}=await G.functions.invoke("stripe-manage-coupons",{body:w});if(C)throw C;t({title:"Success",description:"Coupon created successfully"}),d(!1),p({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""}),f()}catch(w){console.error("Error creating coupon:",w),t({title:"Error",description:w.message||"Failed to create coupon",variant:"destructive"})}finally{l(!1)}},_=async w=>{if(confirm("Are you sure you want to delete this coupon?"))try{const{error:S}=await G.functions.invoke("stripe-manage-coupons",{body:{action:"delete",couponId:w}});if(S)throw S;t({title:"Success",description:"Coupon deleted successfully"}),f()}catch(S){console.error("Error deleting coupon:",S),t({title:"Error",description:S.message||"Failed to delete coupon",variant:"destructive"})}},b=w=>w.percent_off?`${w.percent_off}% off`:w.amount_off?`$${(w.amount_off/100).toFixed(2)} off`:"N/A",N=w=>{switch(w.duration){case"once":return"Once";case"forever":return"Forever";case"repeating":return`${w.duration_in_months} months`;default:return w.duration}};return e.jsx(Ds,{title:"Subscription Discounts",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Hu,{title:"Subscription Discounts",description:"Create and manage discount coupons for subscriptions",children:e.jsxs(fs,{open:i,onOpenChange:d,children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{children:[e.jsx(qs,{className:"mr-2 h-4 w-4"}),"Create Coupon"]})}),e.jsxs(ps,{children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Create New Coupon"}),e.jsx(Ir,{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(xe,{children:"Promotion Code (what users will type)"}),e.jsx(De,{placeholder:"e.g., BROKERAGE50",value:u.promotionCode,onChange:w=>p({...u,promotionCode:w.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"")}),className:"font-mono uppercase"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Letters and numbers only. This is the code users enter at checkout."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Coupon Name (internal label)"}),e.jsx(De,{placeholder:"e.g., 50% Off Brokerage Launch",value:u.name,onChange:w=>p({...u,name:w.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Discount Type"}),e.jsxs($s,{value:u.discountType,onValueChange:w=>{const S=w==="amount"&&u.duration==="forever"?"once":u.duration;p({...u,discountType:w,duration:S})},children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"percent",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx(LM,{className:"mr-2 h-4 w-4"}),"Percentage Off"]})}),e.jsx(vt,{value:"amount",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx(_c,{className:"mr-2 h-4 w-4"}),"Fixed Amount Off"]})})]})]})]}),u.discountType==="percent"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Percent Off"}),e.jsxs("div",{className:"relative",children:[e.jsx(De,{type:"number",min:"1",max:"100",placeholder:"20",value:u.percentOff,onChange:w=>p({...u,percentOff:w.target.value})}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"%"})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{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(De,{type:"number",min:"1",placeholder:"10.00",className:"pl-7",value:u.amountOff,onChange:w=>p({...u,amountOff:w.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Duration"}),e.jsxs($s,{value:u.duration,onValueChange:w=>p({...u,duration:w}),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"once",children:"Once (first payment only)"}),e.jsx(vt,{value:"repeating",children:"Multiple months"}),e.jsxs(vt,{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(xe,{children:"Number of Months"}),e.jsx(De,{type:"number",min:"1",placeholder:"3",value:u.durationInMonths,onChange:w=>p({...u,durationInMonths:w.target.value})})]}),e.jsx(W,{onClick:y,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Coupon"})]})]})]})}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"Active Coupons"}),e.jsx(dr,{children:"Share coupon codes with users to give them discounts on subscriptions"})]}),e.jsx(Oe,{children:n?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(us,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):s.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No coupons created yet. Create your first coupon to get started."}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Promo Code"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Discount"}),e.jsx(St,{children:"Duration"}),e.jsx(St,{children:"Redemptions"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:s.map(w=>{var S;return e.jsxs(Ps,{children:[e.jsx(ht,{className:"font-mono font-medium",children:((S=w.promotion_codes)==null?void 0:S.length)>0?w.promotion_codes.join(", "):e.jsx("span",{className:"text-muted-foreground text-xs",children:"No promo code"})}),e.jsx(ht,{children:w.name||"-"}),e.jsx(ht,{children:b(w)}),e.jsx(ht,{children:N(w)}),e.jsx(ht,{children:w.times_redeemed}),e.jsx(ht,{children:e.jsx(Qe,{variant:w.valid?"default":"secondary",children:w.valid?"Active":"Inactive"})}),e.jsx(ht,{className:"text-right",children:e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>_(w.id),children:e.jsx(vr,{className:"h-4 w-4 text-destructive"})})})]},w.id)})})]})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{children:"How to Use Coupons"})}),e.jsxs(Oe,{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{children:"1. Create a coupon above with your desired discount."}),e.jsx("p",{children:'2. Share the coupon code (shown in the "Code" column) with users.'}),e.jsx("p",{children:"3. Users can enter the code during checkout to receive the discount."}),e.jsx("p",{children:"4. Alternatively, you can create a promotion code in Stripe dashboard for public-facing promotions."})]})]})]})})}const o0e={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 G1s(){const[t,s]=k.useState(""),[r,n]=k.useState("all"),[a,o]=k.useState("all"),[l,i]=k.useState(null),{data:d,isLoading:u,refetch:p}=gt({queryKey:["admin-subscriptions"],queryFn:async()=>{const{data:S,error:C}=await G.from("profiles").select(` *, brokerages:brokerage_id (id, name) `).order("created_at",{ascending:!1});if(C)throw C;return S}}),{data:f}=gt({queryKey:["admin-brokerages-subscriptions"],queryFn:async()=>{const{data:S,error:C}=await G.from("brokerages").select("*").order("name");if(C)throw C;return await Promise.all((S||[]).map(async I=>{const{data:L}=await G.from("profiles").select("id, name, email, subscription_status, subscription_product_id").eq("brokerage_id",I.id),{data:O}=await G.from("user_roles").select("user_id").eq("role","brokerage_manager"),V=(O==null?void 0:O.map(U=>U.user_id))||[],q=(L==null?void 0:L.filter(U=>V.includes(U.id)))||[],B=(L==null?void 0:L.length)||0;return{...I,managers:q,agentCount:B}}))}}),{data:y}=gt({queryKey:["admin-website-subscriptions"],queryFn:async()=>{const{data:S,error:C}=await G.from("local_move_subscriptions").select("*").order("created_at",{ascending:!1});if(C)throw C;return S}}),_=S=>{if(S.is_grandfathered)return{status:"Grandfathered",badge:"Legacy",variant:"secondary"};if(S.brokerage_id&&!S.subscription_product_id)return{status:"Brokerage",badge:"Team Member",variant:"outline"};if(S.is_trial&&S.trial_expires_at)return new Date(S.trial_expires_at)>new Date?{status:"Trial",badge:"Active Trial",variant:"default"}:{status:"Trial Expired",badge:"Expired",variant:"destructive"};if(S.subscription_status==="active"||S.subscription_status==="trialing"){const C=o0e[S.subscription_product_id];return{status:(C==null?void 0:C.name)||"Active",badge:S.subscription_status==="trialing"?"Trial":"Active",variant:"default"}}return S.subscription_status==="canceled"||S.subscription_status==="past_due"?{status:"Canceled",badge:"Inactive",variant:"destructive"}:{status:"None",badge:"No Subscription",variant:"outline"}},b=d==null?void 0:d.filter(S=>{var A,I;if(!(((A=S.name)==null?void 0:A.toLowerCase().includes(t.toLowerCase()))||((I=S.email)==null?void 0:I.toLowerCase().includes(t.toLowerCase()))))return!1;if(a!=="all"){const L=S.subscription_source||"platform";if(a==="platform"&&L==="local_move_website"||a==="local_move_website"&&L!=="local_move_website")return!1}switch(_(S),r){case"active":return S.subscription_status==="active";case"trialing":return S.subscription_status==="trialing"||S.is_trial&&new Date(S.trial_expires_at)>new Date;case"grandfathered":return S.is_grandfathered;case"brokerage":return S.brokerage_id&&!S.subscription_product_id&&!S.is_grandfathered;case"expired":return S.subscription_status==="canceled"||S.subscription_status==="past_due"||S.is_trial&&new Date(S.trial_expires_at)<=new Date;case"none":return!S.subscription_status||S.subscription_status==="none";default:return!0}}),N={totalUsers:(d==null?void 0:d.length)||0,activeSubscriptions:(d==null?void 0:d.filter(S=>S.subscription_status==="active").length)||0,trials:(d==null?void 0:d.filter(S=>S.subscription_status==="trialing"||S.is_trial&&new Date(S.trial_expires_at)>new Date).length)||0,grandfathered:(d==null?void 0:d.filter(S=>S.is_grandfathered).length)||0,brokerageMembers:(d==null?void 0:d.filter(S=>S.brokerage_id&&!S.subscription_product_id&&!S.is_grandfathered).length)||0,individualSubscribers:(d==null?void 0:d.filter(S=>S.subscription_status==="active"&&S.subscription_product_id==="prod_Tc07cYplXUGNkm").length)||0,brokerageSubscribers:(d==null?void 0:d.filter(S=>S.subscription_status==="active"&&(S.subscription_product_id==="prod_Tc08MupgoVySDG"||S.subscription_product_id==="prod_Tc09N1tJ4RrAFn")).length)||0},w=S=>{window.open(`https://dashboard.stripe.com/customers/${S}`,"_blank")};return e.jsx(Ds,{title:"Subscription Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Hu,{title:"Subscription Management",description:"Track and manage all subscriptions",children:e.jsxs(W,{onClick:()=>p(),variant:"outline",size:"sm",children:[e.jsx(Zi,{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(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ir,{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:N.totalUsers})]})}),e.jsx(Pe,{className:"border-green-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yx,{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:N.activeSubscriptions})]})}),e.jsx(Pe,{className:"border-blue-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(nn,{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:N.trials})]})}),e.jsx(Pe,{className:"border-purple-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cm,{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:N.grandfathered})]})}),e.jsx(Pe,{className:"border-orange-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pa,{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:N.brokerageMembers})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(n0,{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:N.individualSubscribers})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pa,{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:N.brokerageSubscribers})]})})]}),e.jsxs(ta,{defaultValue:"users",className:"space-y-4",children:[e.jsxs(Jn,{children:[e.jsx(cs,{value:"users",children:"All Users"}),e.jsx(cs,{value:"brokerages",children:"Brokerages"}),e.jsxs(cs,{value:"websites",className:"gap-2",children:[e.jsx(nd,{className:"h-4 w-4"}),"Website Subscriptions",y&&y.length>0&&e.jsx(Qe,{variant:"secondary",className:"ml-1",children:y.length})]})]}),e.jsxs(Ss,{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(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name or email...",value:t,onChange:S=>s(S.target.value),className:"pl-9"})]}),e.jsxs($s,{value:a,onValueChange:S=>o(S),children:[e.jsx(zs,{className:"w-[200px]",children:e.jsx(Vs,{placeholder:"Source"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Sources"}),e.jsx(vt,{value:"platform",children:"Platform"}),e.jsx(vt,{value:"local_move_website",children:"Local Move Website"})]})]}),e.jsxs($s,{value:r,onValueChange:S=>n(S),children:[e.jsx(zs,{className:"w-[200px]",children:e.jsx(Vs,{placeholder:"Filter by status"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Statuses"}),e.jsx(vt,{value:"active",children:"Active Subscriptions"}),e.jsx(vt,{value:"trialing",children:"Trials"}),e.jsx(vt,{value:"grandfathered",children:"Grandfathered"}),e.jsx(vt,{value:"brokerage",children:"Brokerage Members"}),e.jsx(vt,{value:"expired",children:"Expired/Canceled"}),e.jsx(vt,{value:"none",children:"No Subscription"})]})]})]}),e.jsx(Pe,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"User"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Plan"}),e.jsx(St,{children:"Brokerage"}),e.jsx(St,{children:"End Date"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:u?e.jsx(Ps,{children:e.jsx(ht,{colSpan:6,className:"text-center py-8",children:"Loading subscriptions..."})}):(b==null?void 0:b.length)===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No users found"})}):b==null?void 0:b.map(S=>{var I,L;const C=_(S),A=o0e[S.subscription_product_id];return e.jsxs(Ps,{children:[e.jsx(ht,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:S.email})]})}),e.jsx(ht,{children:e.jsx(Qe,{variant:C.variant,children:C.badge})}),e.jsx(ht,{children:e.jsx("span",{className:"text-sm",children:S.is_grandfathered?"Legacy Access":S.brokerage_id&&!S.subscription_product_id?"Brokerage Subscription":(A==null?void 0:A.name)||C.status})}),e.jsx(ht,{children:(I=S.brokerages)!=null&&I.name?e.jsx("span",{className:"text-sm",children:S.brokerages.name}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(ht,{children:S.subscription_end_date?e.jsx("span",{className:"text-sm",children:vs(new Date(S.subscription_end_date),"MMM d, yyyy")}):S.trial_expires_at?e.jsxs("span",{className:"text-sm text-blue-600",children:["Trial: ",vs(new Date(S.trial_expires_at),"MMM d, yyyy")]}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(ht,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[S.stripe_customer_id&&e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>w(S.stripe_customer_id),children:e.jsx(Yr,{className:"h-4 w-4"})}),e.jsxs(fs,{children:[e.jsx(mi,{asChild:!0,children:e.jsx(W,{variant:"outline",size:"sm",onClick:()=>i(S),children:"Details"})}),e.jsxs(ps,{children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Subscription Details"}),e.jsxs(Ir,{children:[S.name," (",S.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(Qe,{variant:C.variant,className:"mt-1",children:C.badge})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Plan"}),e.jsx("p",{className:"font-medium",children:S.is_grandfathered?"Grandfathered (Legacy)":S.brokerage_id&&!S.subscription_product_id?"Brokerage Subscription":(A==null?void 0:A.name)||"None"})]}),S.brokerage_id&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Brokerage"}),e.jsx("p",{className:"font-medium",children:((L=S.brokerages)==null?void 0:L.name)||"Unknown"})]}),S.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:vs(new Date(S.subscription_end_date),"MMMM d, yyyy")})]}),S.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:vs(new Date(S.trial_expires_at),"MMMM d, yyyy")})]}),S.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:S.stripe_customer_id})]})]}),S.stripe_customer_id&&e.jsxs(W,{className:"w-full",onClick:()=>w(S.stripe_customer_id),children:[e.jsx(Yr,{className:"h-4 w-4 mr-2"}),"View in Stripe Dashboard"]})]})]})]})]})})]},S.id)})})]})})})]}),e.jsx(Ss,{value:"brokerages",className:"space-y-4",children:e.jsx("div",{className:"grid gap-4",children:f==null?void 0:f.map(S=>{var A,I;const C=(A=S.managers)==null?void 0:A.some(L=>L.subscription_status==="active"&&(L.subscription_product_id==="prod_Tc08MupgoVySDG"||L.subscription_product_id==="prod_Tc09N1tJ4RrAFn"));return e.jsxs(Pe,{children:[e.jsx(Dt,{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(pa,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:S.name}),e.jsxs(dr,{children:[S.agentCount," agents"]})]})]}),e.jsx(Qe,{variant:C?"default":"outline",children:C?"Active Subscription":"No Active Subscription"})]})}),e.jsx(Oe,{children:((I=S.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:"}),S.managers.map(L=>{const O=o0e[L.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:L.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:L.email})]}),e.jsx("div",{className:"text-right",children:O?e.jsxs("div",{children:[e.jsx(Qe,{variant:"default",children:O.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:O.price})]}):e.jsx(Qe,{variant:"outline",children:"No Subscription"})})]},L.id)})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No managers assigned"})})]},S.id)})})}),e.jsx(Ss,{value:"websites",className:"space-y-4",children:e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(nd,{className:"h-5 w-5 text-primary"}),"Local Move Website Subscriptions"]}),e.jsx(dr,{children:"$249 setup fee + $99/mo subscriptions from TheLocalMove.com agent websites"})]}),e.jsx(Oe,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Agent"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Setup Fee"}),e.jsx(St,{children:"Monthly"}),e.jsx(St,{children:"Next Renewal"}),e.jsx(St,{children:"Started"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:y?y.length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No website subscriptions yet"})}):y.map(S=>e.jsxs(Ps,{children:[e.jsx(ht,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.agent_name||"—"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:S.agent_email})]})}),e.jsx(ht,{children:e.jsx(Qe,{variant:S.status==="active"?"default":S.status==="canceled"?"destructive":"outline",children:S.status})}),e.jsx(ht,{children:S.setup_fee_paid?e.jsxs(Qe,{variant:"secondary",children:["Paid · $",(S.setup_fee_amount_cents/100).toFixed(0)]}):e.jsx(Qe,{variant:"outline",children:"Unpaid"})}),e.jsxs(ht,{className:"font-medium",children:["$",(S.monthly_amount_cents/100).toFixed(0),"/mo"]}),e.jsx(ht,{children:S.current_period_end?e.jsx("span",{className:"text-sm",children:vs(new Date(S.current_period_end),"MMM d, yyyy")}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(ht,{children:e.jsx("span",{className:"text-sm",children:vs(new Date(S.created_at),"MMM d, yyyy")})}),e.jsx(ht,{className:"text-right",children:S.stripe_customer_id&&e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>w(S.stripe_customer_id),children:e.jsx(Yr,{className:"h-4 w-4"})})})]},S.id)):e.jsx(Ps,{children:e.jsx(ht,{colSpan:7,className:"text-center py-8",children:"Loading…"})})})]})})]})})]})]})})}function W1s(){const[t,s]=k.useState([]),[r,n]=k.useState(!0),[a,o]=k.useState(""),[l,i]=k.useState("all"),[d,u]=k.useState({total:0,qualified:0,pending:0,cancelled:0,totalDiscounts:0});k.useEffect(()=>{p()},[]);const p=async()=>{try{const{data:b,error:N}=await G.from("referrals").select(` *, referrer_brokerage:brokerages!referrer_brokerage_id(name), referred_brokerage:brokerages!referred_brokerage_id(name), referred_user:profiles!referred_user_id(name, email) `).order("created_at",{ascending:!1});if(N)throw N;s(b||[]);const w=(b==null?void 0:b.filter(A=>A.status==="qualified").length)||0,S=(b==null?void 0:b.filter(A=>A.status==="pending").length)||0,C=(b==null?void 0:b.filter(A=>A.status==="cancelled").length)||0;u({total:(b==null?void 0:b.length)||0,qualified:w,pending:S,cancelled:C,totalDiscounts:w*25})}catch(b){console.error("Error fetching referrals:",b),pe.error("Failed to load referrals")}finally{n(!1)}},f=async()=>{try{pe.loading("Processing qualifications...");const{error:b}=await G.functions.invoke("process-referral-qualifications");if(b)throw b;pe.dismiss(),pe.success("Qualifications processed successfully"),p()}catch(b){pe.dismiss(),console.error("Error processing qualifications:",b),pe.error("Failed to process qualifications")}},y=t.filter(b=>{var S,C,A,I,L,O;const N=((C=(S=b.referrer_brokerage)==null?void 0:S.name)==null?void 0:C.toLowerCase().includes(a.toLowerCase()))||((I=(A=b.referred_brokerage)==null?void 0:A.name)==null?void 0:I.toLowerCase().includes(a.toLowerCase()))||((O=(L=b.referred_user)==null?void 0:L.email)==null?void 0:O.toLowerCase().includes(a.toLowerCase())),w=l==="all"||b.status===l;return N&&w}),_=b=>{switch(b){case"qualified":return e.jsxs(Qe,{className:"bg-green-100 text-green-800",children:[e.jsx(si,{className:"h-3 w-3 mr-1"}),"Qualified"]});case"pending":return e.jsxs(Qe,{variant:"secondary",children:[e.jsx(nn,{className:"h-3 w-3 mr-1"}),"Pending"]});case"cancelled":return e.jsxs(Qe,{variant:"destructive",children:[e.jsx(Jl,{className:"h-3 w-3 mr-1"}),"Cancelled"]});default:return e.jsx(Qe,{children:b})}};return e.jsx(Ds,{title:"Referral Program",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Hu,{title:"Referral Program",description:"Track and manage brokerage referrals",children:e.jsxs(W,{onClick:f,variant:"outline",children:[e.jsx(Zi,{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(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ir,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:d.total}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Referrals"})]})]})})}),e.jsx(Pe,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(si,{className:"h-5 w-5 text-green-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:d.qualified}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Qualified"})]})]})})}),e.jsx(Pe,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(nn,{className:"h-5 w-5 text-amber-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:d.pending}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Pending"})]})]})})}),e.jsx(Pe,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Jl,{className:"h-5 w-5 text-red-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:d.cancelled}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Cancelled"})]})]})})}),e.jsx(Pe,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_c,{className:"h-5 w-5 text-green-600"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",children:["$",d.totalDiscounts]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Monthly Discounts"})]})]})})})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"All Referrals"}),e.jsx(dr,{children:"View and manage all referral relationships"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex gap-4 mb-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by brokerage or email...",value:a,onChange:b=>o(b.target.value),className:"pl-10"})]}),e.jsxs($s,{value:l,onValueChange:i,children:[e.jsx(zs,{className:"w-[180px]",children:e.jsx(Vs,{placeholder:"Filter by status"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Statuses"}),e.jsx(vt,{value:"pending",children:"Pending"}),e.jsx(vt,{value:"qualified",children:"Qualified"}),e.jsx(vt,{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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Referrer"}),e.jsx(St,{children:"Referred"}),e.jsx(St,{children:"Signup Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Qualified Date"}),e.jsx(St,{children:"Discount"})]})}),e.jsx(Rn,{children:y.length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No referrals found"})}):y.map(b=>{var N,w,S,C;return e.jsxs(Ps,{children:[e.jsx(ht,{className:"font-medium",children:((N=b.referrer_brokerage)==null?void 0:N.name)||"Unknown"}),e.jsx(ht,{children:e.jsxs("div",{children:[e.jsx("p",{children:((w=b.referred_brokerage)==null?void 0:w.name)||((S=b.referred_user)==null?void 0:S.name)||"Pending setup"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(C=b.referred_user)==null?void 0:C.email})]})}),e.jsx(ht,{children:vs(new Date(b.signup_date),"MMM d, yyyy")}),e.jsx(ht,{children:_(b.status)}),e.jsx(ht,{children:b.qualified_date?vs(new Date(b.qualified_date),"MMM d, yyyy"):"-"}),e.jsx(ht,{children:b.discount_applied?e.jsx(Qe,{variant:"outline",className:"text-green-600",children:"$25/mo applied"}):e.jsx("span",{className:"text-muted-foreground",children:"-"})})]},b.id)})})]})]})]})]})})}const l0e=[{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"}],K1s=[{value:"brokerage_manager",label:"Brokerage Manager"},{value:"agent",label:"Agent"}];function Z1s(){const[t,s]=k.useState([]),[r,n]=k.useState(!0),[a,o]=k.useState(!1),[l,i]=k.useState(null),[d,u]=k.useState({title:"",description:"",action_type:"view_template",target_role:"agent",is_active:!0});k.useEffect(()=>{p()},[]);const p=async()=>{try{const{data:C,error:A}=await G.from("onboarding_checklist_items").select("*").order("target_role").order("sort_order");if(A)throw A;s(C||[])}catch(C){console.error("Error fetching checklist items:",C),pe.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)},y=C=>{i(C),u({title:C.title,description:C.description||"",action_type:C.action_type,target_role:C.target_role,is_active:C.is_active}),o(!0)},_=async()=>{if(!d.title.trim()){pe.error("Title is required");return}try{if(l){const{error:C}=await G.from("onboarding_checklist_items").update({title:d.title,description:d.description||null,action_type:d.action_type,target_role:d.target_role,is_active:d.is_active}).eq("id",l.id);if(C)throw C;pe.success("Checklist item updated")}else{const C=t.filter(I=>I.target_role===d.target_role).reduce((I,L)=>Math.max(I,L.sort_order),-1),{error:A}=await G.from("onboarding_checklist_items").insert({title:d.title,description:d.description||null,action_type:d.action_type,target_role:d.target_role,is_active:d.is_active,sort_order:C+1});if(A)throw A;pe.success("Checklist item created")}o(!1),p()}catch(C){console.error("Error saving checklist item:",C),pe.error("Failed to save checklist item")}},b=async C=>{if(confirm("Are you sure you want to delete this checklist item?"))try{const{error:A}=await G.from("onboarding_checklist_items").delete().eq("id",C);if(A)throw A;pe.success("Checklist item deleted"),p()}catch(A){console.error("Error deleting checklist item:",A),pe.error("Failed to delete checklist item")}},N=async C=>{try{const{error:A}=await G.from("onboarding_checklist_items").update({is_active:!C.is_active}).eq("id",C.id);if(A)throw A;pe.success(C.is_active?"Item deactivated":"Item activated"),p()}catch(A){console.error("Error toggling item:",A),pe.error("Failed to update item")}},w=t.filter(C=>C.target_role==="brokerage_manager"),S=t.filter(C=>C.target_role==="agent");return e.jsxs(Ds,{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(W,{onClick:f,className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"}),"Add Item"]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Qe,{variant:"secondary",children:"Brokerage Manager"}),"Checklist Items"]})}),e.jsx(Oe,{children:w.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for brokerage managers"}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{className:"w-12",children:"#"}),e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Action Type"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:w.map((C,A)=>{var I;return e.jsxs(Ps,{children:[e.jsx(ht,{className:"text-muted-foreground",children:A+1}),e.jsx(ht,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:C.title}),C.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:C.description})]})}),e.jsx(ht,{children:e.jsx(Qe,{variant:"outline",children:((I=l0e.find(L=>L.value===C.action_type))==null?void 0:I.label)||C.action_type})}),e.jsx(ht,{children:e.jsx(Ar,{checked:C.is_active,onCheckedChange:()=>N(C)})}),e.jsx(ht,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>y(C),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>b(C.id),children:e.jsx(vr,{className:"h-4 w-4 text-destructive"})})]})})]},C.id)})})]})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Qe,{variant:"secondary",children:"Agent"}),"Checklist Items"]})}),e.jsx(Oe,{children:S.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for agents"}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{className:"w-12",children:"#"}),e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Action Type"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:S.map((C,A)=>{var I;return e.jsxs(Ps,{children:[e.jsx(ht,{className:"text-muted-foreground",children:A+1}),e.jsx(ht,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:C.title}),C.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:C.description})]})}),e.jsx(ht,{children:e.jsx(Qe,{variant:"outline",children:((I=l0e.find(L=>L.value===C.action_type))==null?void 0:I.label)||C.action_type})}),e.jsx(ht,{children:e.jsx(Ar,{checked:C.is_active,onCheckedChange:()=>N(C)})}),e.jsx(ht,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>y(C),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>b(C.id),children:e.jsx(vr,{className:"h-4 w-4 text-destructive"})})]})})]},C.id)})})]})})]})]}),e.jsx(fs,{open:a,onOpenChange:o,children:e.jsxs(ps,{children:[e.jsx(ks,{children:e.jsx(_s,{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(xe,{htmlFor:"title",children:"Title *"}),e.jsx(De,{id:"title",value:d.title,onChange:C=>u({...d,title:C.target.value}),placeholder:"e.g., Watch your first academy video"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"description",children:"Description"}),e.jsx(_r,{id:"description",value:d.description,onChange:C=>u({...d,description:C.target.value}),placeholder:"Optional description for the checklist item",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Target Role"}),e.jsxs($s,{value:d.target_role,onValueChange:C=>u({...d,target_role:C}),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsx(Bs,{children:K1s.map(C=>e.jsx(vt,{value:C.value,children:C.label},C.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Action Type"}),e.jsxs($s,{value:d.action_type,onValueChange:C=>u({...d,action_type:C}),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsx(Bs,{children:l0e.map(C=>e.jsx(vt,{value:C.value,children:C.label},C.value))})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ar,{id:"is_active",checked:d.is_active,onCheckedChange:C=>u({...d,is_active:C})}),e.jsx(xe,{htmlFor:"is_active",children:"Active"})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(W,{onClick:_,children:l?"Save Changes":"Create Item"})]})]})})]})}function Y1s(){const[t,s]=k.useState(""),[r,n]=k.useState("all"),[a,o]=k.useState("name"),[l,i]=k.useState("asc"),[d,u]=k.useState(""),[p,f]=k.useState(""),[y,_]=k.useState(""),[b,N]=k.useState(""),{data:w}=gt({queryKey:["admin-brokerages"],queryFn:async()=>{const{data:U,error:te}=await G.from("brokerages").select("id, name").order("name");if(te)throw te;return U}}),S=async U=>{let Y=[],J=0,X=!0;for(;X;){const{data:ce,error:ie}=await U(J,J+1e3-1);if(ie)throw ie;ce&&ce.length>0?(Y=[...Y,...ce],J+=1e3,X=ce.length===1e3):X=!1}return Y},{data:C,isLoading:A}=gt({queryKey:["admin-agent-os-user-stats"],queryFn:async()=>{const U=await S((Ve,Ne)=>G.from("profiles").select("id, name, email, brokerage_id, created_at").range(Ve,Ne)),{data:te}=await G.from("brokerages").select("id, name"),Y=new Map((te==null?void 0:te.map(Ve=>[Ve.id,Ve.name]))||[]),[{data:J},{data:X},{data:ce},{data:ie},{data:ae},{data:oe},{data:me}]=await Promise.all([G.rpc("get_admin_contact_counts"),G.rpc("get_admin_video_counts"),G.rpc("get_admin_popby_counts"),G.rpc("get_admin_listing_counts"),G.rpc("get_admin_deal_counts"),G.rpc("get_admin_portal_counts"),G.rpc("get_admin_sendable_card_counts")]),ve=new Map;J==null||J.forEach(Ve=>ve.set(Ve.owner_user_id,Ve.contact_count));const he=new Map;X==null||X.forEach(Ve=>he.set(Ve.owner_user_id,Ve.video_count));const ge=new Map;ce==null||ce.forEach(Ve=>ge.set(Ve.owner_user_id,Ve.popby_count));const je=new Map;ie==null||ie.forEach(Ve=>je.set(Ve.agent_id,Ve.listing_count));const qe=new Map;ae==null||ae.forEach(Ve=>qe.set(Ve.owner_user_id,Ve.deal_count));const Me=new Map;oe==null||oe.forEach(Ve=>Me.set(Ve.owner_user_id,{total:Ve.portal_count,active:Ve.active_portal_count}));const ke=new Map;return me==null||me.forEach(Ve=>ke.set(Ve.owner_user_id,{total:Ve.card_count,sent:Ve.sent_card_count,views:Ve.total_card_views})),U.map(Ve=>{const Ne=Me.get(Ve.id),Ue=ke.get(Ve.id);return{id:Ve.id,name:Ve.name||"Unknown",email:Ve.email||"",brokerage_id:Ve.brokerage_id,brokerage_name:Ve.brokerage_id&&Y.get(Ve.brokerage_id)||null,contact_count:ve.get(Ve.id)||0,video_count:he.get(Ve.id)||0,popby_count:ge.get(Ve.id)||0,listing_count:je.get(Ve.id)||0,deal_count:qe.get(Ve.id)||0,portal_count:(Ne==null?void 0:Ne.total)||0,active_portal_count:(Ne==null?void 0:Ne.active)||0,card_count:(Ue==null?void 0:Ue.total)||0,sent_card_count:(Ue==null?void 0:Ue.sent)||0,total_card_views:(Ue==null?void 0:Ue.views)||0,created_at:Ve.created_at}})}}),I=k.useMemo(()=>{if(!C)return[];let U=C.filter(te=>{const Y=t.toLowerCase(),J=!t||te.name.toLowerCase().includes(Y)||te.email.toLowerCase().includes(Y),X=r==="all"||r==="none"&&!te.brokerage_id||te.brokerage_id===r,ce=parseInt(d)||0,ie=parseInt(p)||0,ae=parseInt(y)||0,oe=parseInt(b)||0,me=te.contact_count>=ce&&te.video_count>=ie&&te.popby_count>=ae&&te.listing_count>=oe;return J&&X&&me});return U.sort((te,Y)=>{let J=0;return a==="name"?J=te.name.localeCompare(Y.name):J=te[a]-Y[a],l==="asc"?J:-J}),U},[C,t,r,a,l,d,p,y,b]),L=U=>{a===U?i(l==="asc"?"desc":"asc"):(o(U),i("desc"))},O=()=>{const U=["Name","Email","Brokerage","Contacts","Videos","Popbys","Listings","Deals","Portals (Active)","Cards Created","Cards Sent","Card Views"],te=I.map(ie=>[ie.name,ie.email,ie.brokerage_name||"None",ie.contact_count,ie.video_count,ie.popby_count,ie.listing_count,ie.deal_count,`${ie.portal_count} (${ie.active_portal_count})`,ie.card_count,ie.sent_card_count,ie.total_card_views]),Y=[U.join(","),...te.map(ie=>ie.map(ae=>`"${ae}"`).join(","))].join(` `),J=new Blob([Y],{type:"text/csv"}),X=URL.createObjectURL(J),ce=document.createElement("a");ce.href=X,ce.download=`agent-os-user-stats-${new Date().toISOString().split("T")[0]}.csv`,ce.click(),URL.revokeObjectURL(X)},V=k.useMemo(()=>I.length?I.reduce((U,te)=>({contacts:U.contacts+te.contact_count,videos:U.videos+te.video_count,popbys:U.popbys+te.popby_count,listings:U.listings+te.listing_count,deals:U.deals+te.deal_count,portals:U.portals+te.portal_count,activePortals:U.activePortals+te.active_portal_count,cards:U.cards+te.card_count,sentCards:U.sentCards+te.sent_card_count,cardViews:U.cardViews+te.total_card_views}),{contacts:0,videos:0,popbys:0,listings:0,deals:0,portals:0,activePortals:0,cards:0,sentCards:0,cardViews:0}):{contacts:0,videos:0,popbys:0,listings:0,deals:0,portals:0,activePortals:0,cards:0,sentCards:0,cardViews:0},[I]),q=k.useMemo(()=>I.length?{portals:I.filter(U=>U.portal_count>0).length,cards:I.filter(U=>U.card_count>0).length}:{portals:0,cards:0},[I]),B=({field:U,children:te})=>e.jsx(St,{className:"cursor-pointer hover:bg-muted/50 select-none",onClick:()=>L(U),children:e.jsxs("div",{className:"flex items-center gap-1",children:[te,e.jsx(td,{className:`h-3 w-3 ${a===U?"text-primary":"text-muted-foreground"}`})]})});return e.jsx(S1,{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(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Kv,{className:"h-4 w-4 text-blue-500"}),"Client Portals"]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:q.portals}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Agents Using"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:V.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:V.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(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(tr,{className:"h-4 w-4 text-violet-500"}),"Card Studio"]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-4 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:q.cards}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Agents Using"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:V.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:V.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:V.cardViews}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Views"})]})]})})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(ir,{className:"h-5 w-5"}),"User Activity Analytics"]}),e.jsx(dr,{children:"View all users and their Agent OS usage metrics"})]}),e.jsxs(W,{variant:"outline",size:"sm",onClick:O,children:[e.jsx(Qa,{className:"h-4 w-4 mr-2"}),"Export CSV"]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-6",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name or email...",value:t,onChange:U=>s(U.target.value),className:"pl-9"})]})}),e.jsx("div",{children:e.jsxs($s,{value:r,onValueChange:n,children:[e.jsxs(zs,{children:[e.jsx(pa,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(Vs,{placeholder:"Brokerage"})]}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Brokerages"}),e.jsx(vt,{value:"none",children:"No Brokerage"}),w==null?void 0:w.map(U=>e.jsx(vt,{value:U.id,children:U.name},U.id))]})]})}),e.jsx("div",{children:e.jsx(De,{type:"number",placeholder:"Min contacts",value:d,onChange:U=>u(U.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(De,{type:"number",placeholder:"Min videos",value:p,onChange:U=>f(U.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(De,{type:"number",placeholder:"Min popbys",value:y,onChange:U=>_(U.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:V.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:V.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:V.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:V.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:V.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:V.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:V.cards.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Cards"})]})]}),A?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(us,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"rounded-md border overflow-x-auto",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(B,{field:"name",children:"Name"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Brokerage"}),e.jsx(B,{field:"contact_count",children:"Contacts"}),e.jsx(B,{field:"video_count",children:"Videos"}),e.jsx(B,{field:"popby_count",children:"Popbys"}),e.jsx(B,{field:"listing_count",children:"Listings"}),e.jsx(B,{field:"deal_count",children:"Deals"}),e.jsx(B,{field:"portal_count",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Kv,{className:"h-3 w-3 text-blue-500"}),"Portals"]})}),e.jsx(B,{field:"card_count",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(tr,{className:"h-3 w-3 text-violet-500"}),"Cards"]})})]})}),e.jsx(Rn,{children:I.length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No users found matching your filters"})}):I.map(U=>e.jsxs(Ps,{children:[e.jsx(ht,{className:"font-medium",children:U.name}),e.jsx(ht,{className:"text-muted-foreground",children:U.email}),e.jsx(ht,{children:U.brokerage_name?e.jsx(Qe,{variant:"secondary",children:U.brokerage_name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(ht,{children:e.jsx(Qe,{variant:U.contact_count>0?"default":"outline",children:U.contact_count})}),e.jsx(ht,{children:e.jsx(Qe,{variant:U.video_count>0?"default":"outline",children:U.video_count})}),e.jsx(ht,{children:e.jsx(Qe,{variant:U.popby_count>0?"default":"outline",children:U.popby_count})}),e.jsx(ht,{children:e.jsx(Qe,{variant:U.listing_count>0?"default":"outline",children:U.listing_count})}),e.jsx(ht,{children:e.jsx(Qe,{variant:U.deal_count>0?"default":"outline",children:U.deal_count})}),e.jsx(ht,{children:U.portal_count>0?e.jsxs(ec,{children:[e.jsx(tc,{children:e.jsxs(Qe,{variant:"default",className:"bg-blue-600 hover:bg-blue-700",children:[U.portal_count,U.active_portal_count>0&&e.jsxs("span",{className:"ml-1 opacity-75",children:["(",U.active_portal_count," active)"]})]})}),e.jsxs(Dl,{children:[e.jsxs("p",{children:[U.portal_count," total portals"]}),e.jsxs("p",{children:[U.active_portal_count," currently active"]})]})]}):e.jsx(Qe,{variant:"outline",children:"0"})}),e.jsx(ht,{children:U.card_count>0?e.jsxs(ec,{children:[e.jsx(tc,{children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Qe,{variant:"default",className:"bg-violet-600 hover:bg-violet-700",children:U.card_count}),U.sent_card_count>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-emerald-600",children:[e.jsx(_n,{className:"h-3 w-3"}),U.sent_card_count]}),U.total_card_views>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-muted-foreground",children:[e.jsx(jn,{className:"h-3 w-3"}),U.total_card_views]})]})}),e.jsxs(Dl,{children:[e.jsxs("p",{children:[U.card_count," cards created"]}),e.jsxs("p",{children:[U.sent_card_count," sent"]}),e.jsxs("p",{children:[U.total_card_views," total views"]})]})]}):e.jsx(Qe,{variant:"outline",children:"0"})})]},U.id))})]})})]})]})]})})}function X1s(){ja(),Qt();const[t,s]=k.useState("user-analytics"),{data:r}=gt({queryKey:["admin-feature-flags"],queryFn:async()=>{const{data:_,error:b}=await G.from("feature_flags").select("*").order("key");if(b)throw b;return _}}),{data:n,isLoading:a}=gt({queryKey:["admin-relationship-types"],queryFn:async()=>{const{data:_,error:b}=await G.from("relationship_types").select("*").order("sort_order");if(b)throw b;return _}}),{data:o,isLoading:l}=gt({queryKey:["admin-action-types"],queryFn:async()=>{const{data:_,error:b}=await G.from("action_types").select("*").order("sort_order");if(b)throw b;return _}}),{data:i,isLoading:d}=gt({queryKey:["admin-action-scripts"],queryFn:async()=>{const{data:_,error:b}=await G.from("action_scripts").select("*, action_type:action_types(*)");if(b)throw b;return _}}),{data:u,isLoading:p}=gt({queryKey:["admin-touchpoint-plans"],queryFn:async()=>{const{data:_,error:b}=await G.from("touchpoint_plans").select("*").order("name");if(b)throw b;return _}}),{data:f,isLoading:y}=gt({queryKey:["admin-popby-items"],queryFn:async()=>{const{data:_,error:b}=await G.from("popby_items").select("*").is("owner_user_id",null).order("name");if(b)throw b;return _}});return e.jsx(Ds,{title:"Agent OS Control Center",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Hu,{title:"Agent OS Control Center",description:"Manage InnerCircle settings, scripts, and touchpoint plans"}),e.jsxs(ta,{value:t,onValueChange:s,children:[e.jsxs(Jn,{className:"grid w-full grid-cols-9",children:[e.jsxs(cs,{value:"user-analytics",className:"gap-2",children:[e.jsx(so,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Users"})]}),e.jsxs(cs,{value:"relationship-types",className:"gap-2",children:[e.jsx(ir,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Relationships"})]}),e.jsxs(cs,{value:"action-types",className:"gap-2",children:[e.jsx(In,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Actions"})]}),e.jsxs(cs,{value:"scripts",className:"gap-2",children:[e.jsx(vn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Scripts"})]}),e.jsxs(cs,{value:"video-scripts",className:"gap-2",children:[e.jsx(Rd,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Video Scripts"})]}),e.jsxs(cs,{value:"plans",className:"gap-2",children:[e.jsx(cn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Plans"})]}),e.jsxs(cs,{value:"popbys",className:"gap-2",children:[e.jsx(hi,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Popbys"})]}),e.jsxs(cs,{value:"settings",className:"gap-2",children:[e.jsx(So,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Settings"})]}),e.jsxs(cs,{value:"feature-flags",className:"gap-2",children:[e.jsx(Yv,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Flags"})]})]}),e.jsx(Ss,{value:"user-analytics",className:"mt-6",children:e.jsx(Y1s,{})}),e.jsx(Ss,{value:"relationship-types",className:"mt-6",children:e.jsx(Q1s,{types:n||[],isLoading:a})}),e.jsx(Ss,{value:"action-types",className:"mt-6",children:e.jsx(J1s,{types:o||[],isLoading:l})}),e.jsx(Ss,{value:"scripts",className:"mt-6",children:e.jsx(e_s,{scripts:i||[],actionTypes:o||[],isLoading:d})}),e.jsx(Ss,{value:"video-scripts",className:"mt-6",children:e.jsx(n_s,{})}),e.jsx(Ss,{value:"plans",className:"mt-6",children:e.jsx(t_s,{plans:u||[],actionTypes:o||[],scripts:i||[],isLoading:p})}),e.jsx(Ss,{value:"popbys",className:"mt-6",children:e.jsx(r_s,{items:f||[],isLoading:y})}),e.jsx(Ss,{value:"settings",className:"mt-6",children:e.jsx(a_s,{})}),e.jsx(Ss,{value:"feature-flags",className:"mt-6",children:e.jsx(s_s,{flags:r||[]})})]})]})})}function Q1s({types:t,isLoading:s}){const{toast:r}=ja(),n=Qt(),[a,o]=k.useState(null),[l,i]=k.useState(!1),d=Pt({mutationFn:async p=>{if(p.id){const{error:f}=await G.from("relationship_types").update({name:p.name,description:p.description,icon:p.icon}).eq("id",p.id);if(f)throw f}else{const{error:f}=await G.from("relationship_types").insert([{name:p.name,description:p.description,icon:p.icon,sort_order:t.length}]);if(f)throw f}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-relationship-types"]}),i(!1),o(null),r({title:"Saved successfully"})},onError:p=>{r({title:"Error",description:p.message,variant:"destructive"})}}),u=async p=>{await G.from("relationship_types").update({active:!p.active}).eq("id",p.id),n.invalidateQueries({queryKey:["admin-relationship-types"]})};return e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Relationship Types"}),e.jsx(dr,{children:"Define the relationship categories for InnerCircle contacts"})]}),e.jsxs(W,{onClick:()=>{o(null),i(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Type"]})]}),e.jsx(Oe,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(us,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{className:"w-12"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-24",children:"Actions"})]})}),e.jsx(Rn,{children:t.map(p=>e.jsxs(Ps,{children:[e.jsx(ht,{children:e.jsx(mu,{className:"h-4 w-4 text-muted-foreground cursor-grab"})}),e.jsx(ht,{className:"font-medium",children:p.name}),e.jsx(ht,{className:"text-muted-foreground",children:p.description}),e.jsx(ht,{children:e.jsx(Ar,{checked:p.active,onCheckedChange:()=>u(p)})}),e.jsx(ht,{children:e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>{o(p),i(!0)},children:e.jsx(ga,{className:"h-4 w-4"})})})]},p.id))})]})}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ps,{children:[e.jsx(ks,{children:e.jsxs(_s,{children:[a?"Edit":"Add"," Relationship Type"]})}),e.jsxs("form",{onSubmit:p=>{p.preventDefault();const f=new FormData(p.currentTarget);d.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(xe,{htmlFor:"name",children:"Name"}),e.jsx(De,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"description",children:"Description"}),e.jsx(_r,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"icon",children:"Icon"}),e.jsx(De,{id:"icon",name:"icon",defaultValue:(a==null?void 0:a.icon)||"",placeholder:"e.g., star, heart, user"})]})]}),e.jsxs(gn,{className:"mt-4",children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(W,{type:"submit",disabled:d.isPending,children:[d.isPending&&e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function J1s({types:t,isLoading:s}){const{toast:r}=ja(),n=Qt(),[a,o]=k.useState(null),[l,i]=k.useState(!1),d=Pt({mutationFn:async p=>{if(p.id){const{error:f}=await G.from("action_types").update({name:p.name,description:p.description,icon:p.icon,color:p.color}).eq("id",p.id);if(f)throw f}else{const{error:f}=await G.from("action_types").insert([{name:p.name,description:p.description,icon:p.icon,color:p.color,sort_order:t.length}]);if(f)throw f}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-action-types"]}),i(!1),o(null),r({title:"Saved successfully"})},onError:p=>{r({title:"Error",description:p.message,variant:"destructive"})}}),u=async p=>{await G.from("action_types").update({active:!p.active}).eq("id",p.id),n.invalidateQueries({queryKey:["admin-action-types"]})};return e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Action Types"}),e.jsx(dr,{children:"Define the types of touchpoint actions agents can take"})]}),e.jsxs(W,{onClick:()=>{o(null),i(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Action"]})]}),e.jsx(Oe,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(us,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{children:"Color"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-24",children:"Actions"})]})}),e.jsx(Rn,{children:t.map(p=>e.jsxs(Ps,{children:[e.jsx(ht,{className:"font-medium",children:p.name}),e.jsx(ht,{className:"text-muted-foreground",children:p.description}),e.jsx(ht,{children:p.color&&e.jsx("div",{className:"w-6 h-6 rounded",style:{backgroundColor:p.color}})}),e.jsx(ht,{children:e.jsx(Ar,{checked:p.active,onCheckedChange:()=>u(p)})}),e.jsx(ht,{children:e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>{o(p),i(!0)},children:e.jsx(ga,{className:"h-4 w-4"})})})]},p.id))})]})}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ps,{children:[e.jsx(ks,{children:e.jsxs(_s,{children:[a?"Edit":"Add"," Action Type"]})}),e.jsxs("form",{onSubmit:p=>{p.preventDefault();const f=new FormData(p.currentTarget);d.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(xe,{htmlFor:"name",children:"Name"}),e.jsx(De,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"description",children:"Description"}),e.jsx(_r,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"icon",children:"Icon"}),e.jsx(De,{id:"icon",name:"icon",defaultValue:(a==null?void 0:a.icon)||"",placeholder:"e.g., phone, message"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"color",children:"Color"}),e.jsx(De,{id:"color",name:"color",type:"color",defaultValue:(a==null?void 0:a.color)||"#6366f1"})]})]}),e.jsxs(gn,{className:"mt-4",children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(W,{type:"submit",disabled:d.isPending,children:[d.isPending&&e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function e_s({scripts:t,actionTypes:s,isLoading:r}){const{toast:n}=ja(),a=Qt(),[o,l]=k.useState(null),[i,d]=k.useState(!1),u=Pt({mutationFn:async f=>{if(f.id){const{error:y}=await G.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(y)throw y}else{const{error:y}=await G.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(y)throw y}},onSuccess:()=>{a.invalidateQueries({queryKey:["admin-action-scripts"]}),d(!1),l(null),n({title:"Saved successfully"})},onError:f=>{n({title:"Error",description:f.message,variant:"destructive"})}}),p=Pt({mutationFn:async f=>{const{error:y}=await G.from("action_scripts").delete().eq("id",f);if(y)throw y},onSuccess:()=>{a.invalidateQueries({queryKey:["admin-action-scripts"]}),n({title:"Deleted successfully"})}});return e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Script Library"}),e.jsx(dr,{children:"Create and manage scripts for each action type"})]}),e.jsxs(W,{onClick:()=>{l(null),d(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),e.jsx(Oe,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(us,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Action Type"}),e.jsx(St,{children:"Tone"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-24",children:"Actions"})]})}),e.jsx(Rn,{children:t.map(f=>{var y;return e.jsxs(Ps,{children:[e.jsx(ht,{className:"font-medium",children:f.title}),e.jsx(ht,{children:e.jsx(Qe,{variant:"outline",children:((y=f.action_type)==null?void 0:y.name)||"Unknown"})}),e.jsx(ht,{className:"text-muted-foreground",children:f.tone}),e.jsx(ht,{children:e.jsx(Qe,{variant:f.active?"default":"secondary",children:f.active?"Active":"Inactive"})}),e.jsxs(ht,{className:"flex gap-1",children:[e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>{l(f),d(!0)},children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>p.mutate(f.id),children:e.jsx(vr,{className:"h-4 w-4 text-destructive"})})]})]},f.id)})})]})}),e.jsx(fs,{open:i,onOpenChange:d,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(ks,{children:e.jsxs(_s,{children:[o?"Edit":"Add"," Script"]})}),e.jsxs("form",{onSubmit:f=>{f.preventDefault();const y=new FormData(f.currentTarget);u.mutate({id:o==null?void 0:o.id,title:y.get("title"),action_type_id:y.get("action_type_id"),tone:y.get("tone"),script_body:y.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(xe,{htmlFor:"title",children:"Title"}),e.jsx(De,{id:"title",name:"title",defaultValue:o==null?void 0:o.title,required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"action_type_id",children:"Action Type"}),e.jsxs($s,{name:"action_type_id",defaultValue:o==null?void 0:o.action_type_id,children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select action type"})}),e.jsx(Bs,{children:s.map(f=>e.jsx(vt,{value:f.id,children:f.name},f.id))})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"tone",children:"Tone (optional)"}),e.jsx(De,{id:"tone",name:"tone",defaultValue:(o==null?void 0:o.tone)||"",placeholder:"e.g., Friendly, Professional, Casual"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"script_body",children:"Script Body"}),e.jsx(_r,{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(gn,{className:"mt-4",children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(W,{type:"submit",disabled:u.isPending,children:[u.isPending&&e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function t_s({plans:t,actionTypes:s,scripts:r,isLoading:n}){const{toast:a}=ja(),o=Qt(),[l,i]=k.useState(null),[d,u]=k.useState(!1),[p,f]=k.useState(null),[y,_]=k.useState(!1),[b,N]=k.useState(null),[w,S]=k.useState(null),{data:C}=gt({queryKey:["plan-items",p],queryFn:async()=>{if(!p)return[];const{data:B,error:U}=await G.from("touchpoint_plan_items").select("*").eq("plan_id",p).order("month_number");if(U)throw U;return B},enabled:!!p}),A=Pt({mutationFn:async B=>{if(B.id){const{error:U}=await G.from("touchpoint_plans").update({name:B.name,description:B.description,active:B.active}).eq("id",B.id);if(U)throw U}else{const{error:U}=await G.from("touchpoint_plans").insert([{name:B.name,description:B.description,active:!0}]);if(U)throw U}},onSuccess:()=>{o.invalidateQueries({queryKey:["admin-touchpoint-plans"]}),u(!1),i(null),a({title:"Saved successfully"})},onError:B=>{a({title:"Error",description:B.message,variant:"destructive"})}}),I=Pt({mutationFn:async B=>{if(B.id){const{error:U}=await G.from("touchpoint_plan_items").update({action_type_id:B.action_type_id,default_script_id:B.default_script_id,notes:B.notes}).eq("id",B.id);if(U)throw U}else{const{error:U}=await G.from("touchpoint_plan_items").insert([{plan_id:B.plan_id,month_number:B.month_number,action_type_id:B.action_type_id,default_script_id:B.default_script_id,notes:B.notes}]);if(U)throw U}},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",p]}),a({title:"Item saved"})}}),L=Pt({mutationFn:async B=>{const{error:U}=await G.from("touchpoint_plan_items").delete().eq("id",B);if(U)throw U},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",p]})}}),O=Pt({mutationFn:async B=>{const{data:U,error:te}=await G.from("action_scripts").insert([{...B,active:!0}]).select().single();if(te)throw te;return U},onSuccess:async B=>{o.invalidateQueries({queryKey:["admin-action-scripts"]}),b&&await I.mutateAsync({id:b.itemId,plan_id:p,month_number:b.month,action_type_id:b.actionTypeId,default_script_id:B.id}),_(!1),N(null),a({title:"Script created and assigned"})},onError:B=>{a({title:"Error",description:B.message,variant:"destructive"})}}),V=(B,U,te)=>{N({month:B,actionTypeId:U,itemId:te}),_(!0)},q=B=>r.find(U=>U.id===B);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Touchpoint Plans"}),e.jsx(dr,{children:"Create annual touchpoint plans that agents can apply to their contacts"})]}),e.jsxs(W,{onClick:()=>{i(null),u(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Plan"]})]}),e.jsx(Oe,{children:n?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(us,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:t.map(B=>e.jsxs(Pe,{className:`cursor-pointer transition-colors ${p===B.id?"border-primary":""}`,onClick:()=>f(B.id),children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(zt,{className:"text-base",children:B.name}),e.jsx(W,{variant:"ghost",size:"icon",onClick:U=>{U.stopPropagation(),i(B),u(!0)},children:e.jsx(ga,{className:"h-4 w-4"})})]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:B.description}),e.jsx(Qe,{variant:B.active?"default":"secondary",className:"mt-2",children:B.active?"Active":"Inactive"})]})]},B.id))})})]}),p&&e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"Plan Schedule"}),e.jsx(dr,{children:"Configure the monthly touchpoint schedule. Select an action type for each month, then assign or create a script."})]}),e.jsx(Oe,{children:e.jsx("div",{className:"grid gap-3",children:Array.from({length:12},(B,U)=>U+1).map(B=>{const U=C==null?void 0:C.find(J=>J.month_number===B),te=U!=null&&U.default_script_id?q(U.default_script_id):null,Y=r.filter(J=>J.action_type_id===(U==null?void 0:U.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 ",B]}),e.jsxs($s,{value:(U==null?void 0:U.action_type_id)||"none",onValueChange:J=>{J==="none"&&U?L.mutate(U.id):J!=="none"&&I.mutate({id:U==null?void 0:U.id,plan_id:p,month_number:B,action_type_id:J,default_script_id:null})},children:[e.jsx(zs,{className:"w-40",children:e.jsx(Vs,{placeholder:"No action"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"none",children:"No action"}),s.filter(J=>J.active).map(J=>e.jsx(vt,{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))]})]}),U&&e.jsxs(e.Fragment,{children:[e.jsxs($s,{value:U.default_script_id||"none",onValueChange:J=>{S(null),I.mutate({id:U.id,default_script_id:J==="none"?null:J})},children:[e.jsx(zs,{className:"w-56",children:e.jsx(Vs,{placeholder:"Select script"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"none",children:"No default script"}),Y.map(J=>e.jsxs(vt,{value:J.id,children:[J.title," ",J.tone&&`(${J.tone})`]},J.id))]})]}),e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>V(B,U.action_type_id,U.id),children:[e.jsx(qs,{className:"h-3 w-3 mr-1"}),"New Script"]}),te&&e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>S((w==null?void 0:w.id)===te.id?null:te),children:(w==null?void 0:w.id)===te.id?"Hide":"Preview"})]})]}),w&&(U==null?void 0:U.default_script_id)===w.id&&e.jsxs("div",{className:"ml-24 p-3 bg-muted rounded-lg text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Qe,{variant:"outline",children:w.title}),w.tone&&e.jsx(Qe,{variant:"secondary",children:w.tone})]}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:w.script_body})]})]},B)})})})]}),e.jsx(fs,{open:d,onOpenChange:u,children:e.jsxs(ps,{children:[e.jsx(ks,{children:e.jsxs(_s,{children:[l?"Edit":"Add"," Touchpoint Plan"]})}),e.jsxs("form",{onSubmit:B=>{B.preventDefault();const U=new FormData(B.currentTarget);A.mutate({id:l==null?void 0:l.id,name:U.get("name"),description:U.get("description"),active:!0})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"name",children:"Name"}),e.jsx(De,{id:"name",name:"name",defaultValue:l==null?void 0:l.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"description",children:"Description"}),e.jsx(_r,{id:"description",name:"description",defaultValue:(l==null?void 0:l.description)||"",rows:3})]})]}),e.jsxs(gn,{className:"mt-4",children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>u(!1),children:"Cancel"}),e.jsxs(W,{type:"submit",disabled:A.isPending,children:[A.isPending&&e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})}),e.jsx(fs,{open:y,onOpenChange:_,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Create New Script"}),e.jsxs(Ir,{children:["Create a script for Month ",b==null?void 0:b.month,". Use ","{{FirstName}}",", ","{{LastName}}",", and ","{{AgentName}}"," as placeholders."]})]}),e.jsxs("form",{onSubmit:B=>{B.preventDefault();const U=new FormData(B.currentTarget);O.mutate({title:U.get("title"),action_type_id:b.actionTypeId,tone:U.get("tone"),script_body:U.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(xe,{htmlFor:"script_title",children:"Title"}),e.jsx(De,{id:"script_title",name:"title",placeholder:"e.g., Warm Check-In",required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"script_tone",children:"Tone"}),e.jsx(De,{id:"script_tone",name:"tone",placeholder:"e.g., Friendly, Professional"})]})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"script_body",children:"Script Body"}),e.jsx(_r,{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(gn,{className:"mt-4",children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsxs(W,{type:"submit",disabled:O.isPending,children:[O.isPending&&e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Create & Assign"]})]})]})]})})]})}function s_s({flags:t}){const{toast:s}=ja(),r=Qt(),n=async(a,o)=>{const{error:l}=await G.from("feature_flags").update({...o,updated_at:new Date().toISOString()}).eq("id",a.id);l?s({title:"Error",description:l.message,variant:"destructive"}):(r.invalidateQueries({queryKey:["admin-feature-flags"]}),s({title:"Flag updated"}))};return e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"Feature Flags"}),e.jsx(dr,{children:"Control which features are enabled for members"})]}),e.jsx(Oe,{children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Flag"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Notes"}),e.jsx(St,{children:"Last Updated"})]})}),e.jsx(Rn,{children:t.map(a=>e.jsxs(Ps,{children:[e.jsx(ht,{className:"font-mono text-sm",children:a.key}),e.jsx(ht,{children:e.jsx(Ar,{checked:a.enabled,onCheckedChange:o=>n(a,{enabled:o})})}),e.jsx(ht,{children:e.jsx(De,{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(ht,{className:"text-muted-foreground text-sm",children:new Date(a.updated_at).toLocaleDateString()})]},a.id))})]})})]})}function r_s({items:t,isLoading:s}){const{toast:r}=ja(),n=Qt(),[a,o]=k.useState(null),[l,i]=k.useState(!1),d=Pt({mutationFn:async f=>{if(f.id){const{error:y}=await G.from("popby_items").update({name:f.name,description:f.description}).eq("id",f.id);if(y)throw y}else{const{error:y}=await G.from("popby_items").insert([{name:f.name,description:f.description,owner_user_id:null}]);if(y)throw y}},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 G.from("popby_items").update({is_active:!f.is_active}).eq("id",f.id),n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]})},p=async f=>{await G.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(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Popby Ideas"}),e.jsx(dr,{children:"Manage global popby ideas that all agents can see"})]}),e.jsxs(W,{onClick:()=>{o(null),i(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsx(Oe,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(us,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):t.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(hi,{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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-24",children:"Actions"})]})}),e.jsx(Rn,{children:t.map(f=>e.jsxs(Ps,{children:[e.jsx(ht,{className:"font-medium",children:f.name}),e.jsx(ht,{className:"text-muted-foreground",children:f.description}),e.jsx(ht,{children:e.jsx(Ar,{checked:f.is_active,onCheckedChange:()=>u(f)})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>{o(f),i(!0)},children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>p(f.id),children:e.jsx(vr,{className:"h-4 w-4 text-destructive"})})]})})]},f.id))})]})}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ps,{children:[e.jsx(ks,{children:e.jsxs(_s,{children:[a?"Edit":"Add"," Popby Idea"]})}),e.jsxs("form",{onSubmit:f=>{f.preventDefault();const y=new FormData(f.currentTarget);d.mutate({id:a==null?void 0:a.id,name:y.get("name"),description:y.get("description")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"name",children:"Name"}),e.jsx(De,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0,placeholder:"e.g., Homemade Cookies"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"description",children:"Description"}),e.jsx(_r,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||"",placeholder:"Brief description of the popby idea..."})]})]}),e.jsxs(gn,{className:"mt-4",children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(W,{type:"submit",disabled:d.isPending,children:[d.isPending&&e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function n_s(){var _;const{toast:t}=ja(),s=Qt(),[r,n]=k.useState(null),[a,o]=k.useState(!1),{data:l,isLoading:i}=gt({queryKey:["admin-video-script-categories"],queryFn:async()=>{const{data:b,error:N}=await G.from("video_script_categories").select("*").order("sort_order");if(N)throw N;return b}}),{data:d,isLoading:u}=gt({queryKey:["admin-video-scripts"],queryFn:async()=>{const{data:b,error:N}=await G.from("video_scripts").select("*, category:video_script_categories(*)").order("title");if(N)throw N;return b}}),p=Pt({mutationFn:async b=>{var N,w;if(b.id){const{error:S}=await G.from("video_scripts").update({title:b.title,script_text:b.script_text,category_id:b.category_id,tags:((N=b.tags)==null?void 0:N.split(",").map(C=>C.trim()).filter(Boolean))||[]}).eq("id",b.id);if(S)throw S}else{const{error:S}=await G.from("video_scripts").insert([{title:b.title,script_text:b.script_text,category_id:b.category_id||null,tags:((w=b.tags)==null?void 0:w.split(",").map(C=>C.trim()).filter(Boolean))||[]}]);if(S)throw S}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-video-scripts"]}),o(!1),n(null),t({title:"Video script saved!"})},onError:b=>t({title:"Error",description:b.message,variant:"destructive"})}),f=async b=>{await G.from("video_scripts").update({is_active:!b.is_active}).eq("id",b.id),s.invalidateQueries({queryKey:["admin-video-scripts"]})},y=async b=>{confirm("Delete this video script?")&&(await G.from("video_scripts").delete().eq("id",b),s.invalidateQueries({queryKey:["admin-video-scripts"]}),t({title:"Script deleted"}))};return e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Video Scripts"}),e.jsx(dr,{children:"Manage teleprompter scripts for Quick Video Touch"})]}),e.jsxs(W,{onClick:()=>{n(null),o(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),e.jsx(Oe,{children:u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(us,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Category"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-24",children:"Actions"})]})}),e.jsx(Rn,{children:d==null?void 0:d.map(b=>{var N;return e.jsxs(Ps,{children:[e.jsx(ht,{className:"font-medium",children:b.title}),e.jsx(ht,{className:"text-muted-foreground",children:((N=b.category)==null?void 0:N.name)||"Uncategorized"}),e.jsx(ht,{children:e.jsx(Ar,{checked:b.is_active,onCheckedChange:()=>f(b)})}),e.jsxs(ht,{className:"flex gap-1",children:[e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>{n(b),o(!0)},children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>y(b.id),children:e.jsx(vr,{className:"h-4 w-4"})})]})]},b.id)})})]})}),e.jsx(fs,{open:a,onOpenChange:o,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(ks,{children:e.jsxs(_s,{children:[r?"Edit":"Add"," Video Script"]})}),e.jsxs("form",{onSubmit:b=>{b.preventDefault();const N=new FormData(b.currentTarget);p.mutate({id:r==null?void 0:r.id,title:N.get("title"),script_text:N.get("script_text"),category_id:N.get("category_id")||null,tags:N.get("tags")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"title",children:"Title"}),e.jsx(De,{id:"title",name:"title",defaultValue:r==null?void 0:r.title,required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"category_id",children:"Category"}),e.jsxs($s,{name:"category_id",defaultValue:(r==null?void 0:r.category_id)||"",children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select category"})}),e.jsx(Bs,{children:l==null?void 0:l.map(b=>e.jsx(vt,{value:b.id,children:b.name},b.id))})]})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"script_text",children:"Script Text"}),e.jsx(_r,{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(xe,{htmlFor:"tags",children:"Tags (comma-separated)"}),e.jsx(De,{id:"tags",name:"tags",defaultValue:((_=r==null?void 0:r.tags)==null?void 0:_.join(", "))||"",placeholder:"birthday, follow-up, thank-you"})]})]}),e.jsxs(gn,{className:"mt-4",children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsxs(W,{type:"submit",disabled:p.isPending,children:[p.isPending&&e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function a_s(){const{toast:t}=ja(),[s,r]=k.useState(""),[n,a]=k.useState(!0),[o,l]=k.useState(!1);k.useEffect(()=>{(async()=>{a(!0);try{const{data:u}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();u!=null&&u.value&&r(u.value)}catch(u){console.error("Error fetching settings:",u)}a(!1)})()},[]);const i=async()=>{l(!0);try{await G.from("settings").upsert({key:"mapbox_public_token",value:s.trim()}),t({title:"Mapbox token saved!"})}catch{t({title:"Error saving token",variant:"destructive"})}l(!1)};return n?e.jsx(Pe,{children:e.jsx(Oe,{className:"flex justify-center py-8",children:e.jsx(us,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}):e.jsx("div",{className:"space-y-6",children:e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Ia,{className:"h-5 w-5"}),"Popby Map Settings"]}),e.jsx(dr,{children:"Configure the map feature for popbys"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"mapbox-token",children:"Mapbox Public Token"}),e.jsx(De,{id:"mapbox-token",placeholder:"pk.eyJ1I...",value:s,onChange:d=>r(d.target.value)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your token at"," ",e.jsx("a",{href:"https://mapbox.com/",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"mapbox.com"}),". This token will be used by all agents for the popby map feature."]})]}),e.jsxs(W,{onClick:i,disabled:o,children:[o&&e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Token"]}),s&&e.jsx(Qe,{variant:"secondary",className:"ml-2",children:"Token configured"})]})]})})}const i_s=()=>{const[t,s]=k.useState(""),[r,n]=k.useState("grid"),a=wr(),{data:o=[],isLoading:l}=gt({queryKey:["additional-services"],queryFn:async()=>{const{data:d,error:u}=await G.from("additional_services").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(u)throw u;return d}}),i=o.filter(d=>{var p;return d.name.toLowerCase().includes(t.toLowerCase())||((p=d.description)==null?void 0:p.toLowerCase().includes(t.toLowerCase()))});return e.jsx(Ds,{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(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search services...",value:t,onChange:d=>s(d.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex gap-2",children:[t&&e.jsx(W,{variant:"outline",size:"sm",onClick:()=>s(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(W,{variant:r==="grid"?"secondary":"outline",size:"icon",onClick:()=>n("grid"),className:"rounded-full",children:e.jsx(xp,{className:"h-4 w-4"})}),e.jsx(W,{variant:r==="list"?"secondary":"outline",size:"icon",onClick:()=>n("list"),className:"rounded-full",children:e.jsx(Dh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[i.length," service",i.length!==1?"s":""," found"]}),l&&e.jsx("div",{className:r==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:[...Array(4)].map((d,u)=>e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(Ms,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(Ms,{className:"h-5 w-3/4 mb-2"}),e.jsx(Ms,{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(W,{variant:"outline",onClick:()=>s(""),children:"Clear Search"})]}),!l&&i.length>0&&e.jsx("div",{className:r==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:i.map(d=>e.jsxs(Pe,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${r==="list"?"flex flex-row":""}`,onClick:()=>a(`/additional-services/${d.id}`),children:[e.jsx("div",{className:`relative overflow-hidden bg-muted ${r==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:d.preview_image_url?e.jsx("img",{src:d.preview_image_url,alt:d.name,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:e.jsx(Or,{className:"h-8 w-8"})})}),e.jsxs(Oe,{className:`p-4 flex flex-col ${r==="list"?"flex-1":""}`,children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:d.name}),d.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 flex-1",children:Qde(d.description)})]})]},d.id))})]})})},o_s=()=>{const{serviceId:t}=io(),s=wr(),{data:r,isLoading:n}=gt({queryKey:["additional-service",t],queryFn:async()=>{const{data:a,error:o}=await G.from("additional_services").select("*").eq("id",t).eq("is_published",!0).single();if(o)throw o;return a},enabled:!!t});return n?e.jsx(Ds,{title:"Loading...",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsx(Ms,{className:"h-8 w-48"}),e.jsx(Ms,{className:"h-64 w-full rounded-lg"}),e.jsx(Ms,{className:"h-24 w-full"})]})}):r?e.jsx(Ds,{title:r.name,children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs(W,{variant:"ghost",onClick:()=>s("/additional-services"),className:"gap-2",children:[e.jsx(Oa,{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(Or,{className:"h-16 w-16"})})})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:r.name}),e.jsxs("div",{className:"flex items-center text-sm text-muted-foreground",children:[e.jsx(cn,{className:"h-4 w-4 mr-1"}),"Published ",vs(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(W,{size:"lg",className:"gap-2",onClick:()=>window.open(r.signup_link_url,"_blank"),children:[e.jsx(Yr,{className:"h-5 w-5"}),"Sign Up Now"]})})]})})]})}):e.jsx(Ds,{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(W,{onClick:()=>s("/additional-services"),children:[e.jsx(Oa,{className:"h-4 w-4 mr-2"}),"Back to Services"]})]})})},vI=[{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 l_s(){const[t,s]=k.useState(vI[0].id),r=vI.find(n=>n.id===t)||vI[0];return e.jsx(Ds,{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(vM,{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($s,{value:t,onValueChange:s,children:[e.jsx(zs,{className:"w-full",children:e.jsx(Vs,{placeholder:"Select a tool"})}),e.jsx(Bs,{children:vI.map(n=>e.jsx(vt,{value:n.id,children:n.name},n.id))})]})}),e.jsx("div",{className:"hidden md:block",children:e.jsx(ta,{value:t,onValueChange:s,className:"w-full",children:e.jsx(Jn,{className:"w-full flex-wrap h-auto gap-1 bg-muted p-1",children:vI.map(n=>e.jsx(cs,{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 I7e="agent-os-onboarding-completed",v9=[{icon:e0,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:Oh,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:ir,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:_d,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:hi,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:so,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"]}],c_s=()=>{const[t,s]=k.useState(!1),[r,n]=k.useState(0),[a,o]=k.useState(!1);k.useEffect(()=>{if(!localStorage.getItem(I7e)){const b=setTimeout(()=>s(!0),500);return()=>clearTimeout(b)}},[]);const l=()=>{r{n(r+1),o(!1)},150)):d()},i=()=>{d()},d=()=>{localStorage.setItem(I7e,"true"),s(!1)},u=v9[r],p=u.icon,f=r===v9.length-1,y=_=>{_||d(),s(_)};return e.jsx(fs,{open:t,onOpenChange:y,children:e.jsxs(ps,{className:"sm:max-w-lg overflow-hidden p-0 gap-0",children:[e.jsxs("div",{className:`relative bg-gradient-to-br ${u.bgGradient} p-8 pb-12 transition-all duration-500`,children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[e.jsx("div",{className:"absolute -top-4 -right-4 w-32 h-32 bg-white/10 rounded-full blur-2xl animate-pulse"}),e.jsx("div",{className:"absolute -bottom-8 -left-8 w-40 h-40 bg-white/10 rounded-full blur-3xl animate-pulse",style:{animationDelay:"1s"}}),e.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-64 h-64 bg-white/5 rounded-full blur-3xl"})]}),e.jsxs("div",{className:`relative mx-auto flex h-20 w-20 items-center justify-center transition-all duration-300 ${a?"scale-75 opacity-0":"scale-100 opacity-100"}`,children:[e.jsx("div",{className:"absolute inset-0 bg-white/20 rounded-2xl blur-xl"}),e.jsx("div",{className:"relative flex h-20 w-20 items-center justify-center rounded-2xl bg-white/20 backdrop-blur-sm border border-white/30 shadow-2xl",children:e.jsx(p,{className:`h-10 w-10 ${u.iconColor} drop-shadow-lg`})})]}),r===0&&e.jsxs("div",{className:"absolute top-4 right-4 px-3 py-1 rounded-full bg-white/20 backdrop-blur-sm border border-white/30 text-white text-xs font-medium flex items-center gap-1.5",children:[e.jsx(Or,{className:"h-3 w-3"}),"Beta"]})]}),e.jsxs("div",{className:"p-6 pt-4",children:[e.jsxs(ks,{className:"text-center sm:text-center pb-2",children:[e.jsx(_s,{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(Ir,{className:`text-base pt-2 transition-all duration-300 delay-75 ${a?"translate-y-2 opacity-0":"translate-y-0 opacity-100"}`,children:u.description})]}),u.highlights&&e.jsx("div",{className:`space-y-2.5 py-4 transition-all duration-300 delay-100 ${a?"translate-y-2 opacity-0":"translate-y-0 opacity-100"}`,children:u.highlights.map((_,b)=>e.jsxs("div",{className:"flex items-center gap-3 group",style:{transitionDelay:`${150+b*50}ms`},children:[e.jsx("div",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-gradient-to-br ${u.bgGradient} shadow-sm`,children:e.jsx(Zn,{className:"h-3.5 w-3.5 text-white"})}),e.jsx("span",{className:"text-sm text-muted-foreground group-hover:text-foreground transition-colors",children:_})]},b))}),e.jsx("div",{className:"flex justify-center gap-2 py-4",children:v9.map((_,b)=>e.jsx("button",{onClick:()=>{b!==r&&(o(!0),setTimeout(()=>{n(b),o(!1)},150))},className:`h-2 rounded-full transition-all duration-300 ${b===r?"w-8 bg-gradient-to-r "+u.bgGradient:b{const{user:t}=Us();return gt({queryKey:["contact-snoozes",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_snoozes").select("*").gte("snoozed_until",new Date().toISOString());if(r)throw r;return s},enabled:!!t})},u_s=()=>{const t=Qt(),{user:s}=Us();return Pt({mutationFn:async({contactId:r,days:n})=>{if(!(s!=null&&s.id))throw new Error("Not authenticated");const a=ml(new Date,n);await G.from("contact_snoozes").delete().eq("contact_id",r);const{error:o}=await G.from("contact_snoozes").insert({contact_id:r,owner_user_id:s.id,snoozed_until:a.toISOString()});if(o)throw o},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-snoozes"]}),t.invalidateQueries({queryKey:["today-actions"]}),t.invalidateQueries({queryKey:["popby-logs"]}),fn({title:"Touch snoozed!",description:"Contact has been snoozed."})},onError:r=>{fn({title:"Error snoozing contact",description:r.message,variant:"destructive"})}})},h_s=()=>{const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("contact_snoozes").delete().eq("contact_id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-snoozes"]}),fn({title:"Snooze cancelled"})},onError:s=>{fn({title:"Error cancelling snooze",description:s.message,variant:"destructive"})}})},m_s=[{label:"1 week",days:7},{label:"2 weeks",days:14},{label:"1 month",days:30}];function kme({open:t,onOpenChange:s,contactId:r,contactName:n}){const[a,o]=k.useState(null),l=u_s(),i=async()=>{a&&(await l.mutateAsync({contactId:r,days:a}),o(null),s(!1))},d=u=>vs(ml(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(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(nn,{className:"h-5 w-5"}),"Snooze Touch"]}),e.jsxs(Ir,{children:["Postpone the next scheduled touch for ",n,". Select how long to snooze."]})]}),e.jsx("div",{className:"space-y-3 py-4",children:m_s.map(u=>e.jsxs("button",{type:"button",onClick:()=>o(u.days),className:Ot("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(cn,{className:"h-3.5 w-3.5"}),"Until ",d(u.days)]})]},u.days))}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(W,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(W,{onClick:i,disabled:!a||l.isPending,children:l.isPending?"Snoozing...":"Snooze Touch"})]})]})})}const p_s={Crown:Cm,FileText:vn,Users:ir,Globe:nd,Star:Gn,Phone:In,MessageSquare:wi,PenTool:Mb,Video:yn,Gift:hi};function f_s({actions:t,onMarkComplete:s,onViewScript:r,isLoading:n,buildSmsLink:a,buildEmailLink:o,onGmailCompose:l}){const i=wr(),[d,u]=k.useState("name"),[p,f]=k.useState("asc"),[y,_]=k.useState(null),[b,N]=k.useState(""),w=L=>{d===L?f(O=>O==="asc"?"desc":"asc"):(u(L),f("asc"))},S=k.useMemo(()=>[...t].sort((L,O)=>{var q,B;let V=0;switch(d){case"name":{const U=`${L.contact.first_name} ${L.contact.last_name||""}`.toLowerCase(),te=`${O.contact.first_name} ${O.contact.last_name||""}`.toLowerCase();V=U.localeCompare(te);break}case"relationship_type":V=(L.relationshipTypeName||"").localeCompare(O.relationshipTypeName||"");break;case"action_type":V=(((q=L.actionType)==null?void 0:q.name)||"").localeCompare(((B=O.actionType)==null?void 0:B.name)||"");break;case"last_touch":V=(L.monthNumber||0)-(O.monthNumber||0);break}return p==="asc"?V:-V}),[t,d,p]),C=L=>p_s[L||"Phone"]||In,A=({field:L,children:O})=>e.jsxs(W,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>w(L),children:[O,d===L?p==="asc"?e.jsx(uu,{className:"ml-2 h-4 w-4"}):e.jsx(Ih,{className:"ml-2 h-4 w-4"}):e.jsx(td,{className:"ml-2 h-4 w-4 opacity-50"})]}),I=(L,O,V)=>{_(L),N(`${O} ${V||""}`.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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{className:"bg-muted/50",children:[e.jsx(St,{className:"w-[180px]",children:e.jsx(A,{field:"name",children:"Contact"})}),e.jsx(St,{className:"w-[130px]",children:e.jsx(A,{field:"relationship_type",children:"Type"})}),e.jsx(St,{className:"w-[120px]",children:e.jsx(A,{field:"action_type",children:"Action"})}),e.jsx(St,{className:"w-[130px]",children:"Phone"}),e.jsx(St,{className:"w-[200px]",children:"Quick Actions"})]})}),e.jsx(Rn,{children:S.map((L,O)=>{var Y,J,X,ce,ie,ae;const V=L.isSpecialDate,q=L.specialDateType,B=V?q==="birthday"?Fu:Mn:C(((Y=L.actionType)==null?void 0:Y.icon)||null),U=L.contact.phone,te=L.contact.email;return e.jsxs(Ps,{className:Ot("hover:bg-muted/50 transition-colors",V&&q==="birthday"&&"bg-pink-50/50 dark:bg-pink-950/20",V&&q==="anniversary"&&"bg-purple-50/50 dark:bg-purple-950/20"),children:[e.jsx(ht,{className:"font-medium",children:e.jsx("div",{children:e.jsxs("button",{onClick:()=>i(`/mission-control/contacts/${L.contact.id}`),className:"truncate max-w-[160px] text-left hover:text-primary hover:underline transition-colors",children:[L.contact.first_name," ",L.contact.last_name]})})}),e.jsx(ht,{children:L.relationshipTypeName?e.jsx(Qe,{variant:"secondary",className:"text-xs",children:L.relationshipTypeName}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(ht,{children:e.jsx("div",{className:"flex items-center gap-1.5",children:V?e.jsx(Qe,{className:Ot("gap-1",q==="birthday"&&"bg-pink-500 hover:bg-pink-600",q==="anniversary"&&"bg-purple-500 hover:bg-purple-600"),children:q==="birthday"?e.jsxs(e.Fragment,{children:[e.jsx(Fu,{className:"h-3 w-3"})," Birthday"]}):e.jsxs(e.Fragment,{children:[e.jsx(Mn,{className:"h-3 w-3"})," Anniversary"]})}):e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(B,{className:"h-3 w-3"}),(J=L.actionType)==null?void 0:J.name]})})}),e.jsx(ht,{children:U?e.jsx("span",{className:"text-sm font-mono",children:L.contact.phone}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[U&&e.jsx("a",{href:`tel:${L.contact.phone}`,className:"p-1.5 rounded bg-primary/10 hover:bg-primary/20 text-primary transition-colors",title:"Call",children:e.jsx(In,{className:"h-3.5 w-3.5"})}),U&&e.jsx("a",{href:a(L.contact.phone,(X=L.script)==null?void 0:X.script_body,L.contact),className:"p-1.5 rounded bg-emerald-500/10 hover:bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 transition-colors",title:"Text",children:e.jsx(wi,{className:"h-3.5 w-3.5"})}),te&&(l?e.jsx("button",{onClick:()=>l({id:L.contact.id,first_name:L.contact.first_name,last_name:L.contact.last_name,email:L.contact.email}),className:"p-1.5 rounded bg-sky-500/10 hover:bg-sky-500/20 text-sky-600 dark:text-sky-400 transition-colors",title:"Compose Email",children:e.jsx(tr,{className:"h-3.5 w-3.5"})}):e.jsx("a",{href:o(L.contact.email,(ce=L.script)==null?void 0:ce.script_body,(ie=L.script)==null?void 0:ie.email_subject,(ae=L.actionType)==null?void 0:ae.name,L.contact),className:"p-1.5 rounded bg-sky-500/10 hover:bg-sky-500/20 text-sky-600 dark:text-sky-400 transition-colors",title:"Email",children:e.jsx(tr,{className:"h-3.5 w-3.5"})})),V&&e.jsxs("button",{onClick:()=>{const oe=`${L.contact.first_name}${L.contact.last_name?" "+L.contact.last_name:""}`,me=q==="birthday"?"birthday":"home_anniversary",ve=new URLSearchParams({cardType:me,contactId:L.contact.id,name:oe,...L.contact.address?{address:L.contact.address}:{},...q==="anniversary"&&L.contact.home_anniversary?{date:L.contact.home_anniversary}:{}});i(`/mission-control/card-studio?${ve.toString()}`)},className:Ot("h-7 px-2 rounded text-xs font-semibold flex items-center gap-1 transition-colors",q==="birthday"?"bg-pink-500/15 hover:bg-pink-500/25 text-pink-600 dark:text-pink-400":"bg-purple-500/15 hover:bg-purple-500/25 text-purple-600 dark:text-purple-400"),title:`Send ${q==="birthday"?"Birthday":"Anniversary"} Card`,children:[e.jsx(tr,{className:"h-3.5 w-3.5"}),"Send Card"]}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:()=>I(L.contact.id,L.contact.first_name,L.contact.last_name),title:"Snooze",children:e.jsx(hh,{className:"h-3.5 w-3.5"})}),e.jsxs(W,{variant:"default",size:"sm",className:"h-7 px-2 text-xs ml-1",onClick:()=>{var oe;return s(L.contact.id,L.actionType.id,(oe=L.script)==null?void 0:oe.id)},disabled:n,children:[e.jsx($n,{className:"h-3.5 w-3.5 mr-1"}),"Done"]})]})})]},`${L.contact.id}-${O}`)})})]})}),e.jsx(kme,{open:!!y,onOpenChange:L=>!L&&_(null),contactId:y||"",contactName:b})]})}function Om(){const{data:t,isLoading:s}=gt({queryKey:["gmail-integration"],queryFn:async()=>{const{data:a,error:o}=await G.from("gmail_integrations").select("*").maybeSingle();if(o)throw o;return a}}),r=!!(t!=null&&t.is_active),n=(t==null?void 0:t.gmail_email)||null;return{isGmailConnected:r,gmailEmail:n,isLoading:s}}function x_s({onSelect:t}){const[s,r]=k.useState(null),{data:n=[],isLoading:a}=gt({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:d,error:u}=await G.from("email_template_categories").select("*").order("sort_order");if(u)throw u;return d}}),{data:o=[],isLoading:l}=gt({queryKey:["agent-email-templates",s],queryFn:async()=>{let d=G.from("agent_email_templates").select("*").eq("is_active",!0).order("sort_order");s&&(d=d.eq("category_id",s));const{data:u,error:p}=await d;if(p)throw p;return u}}),i=n.find(d=>d.id===s);return a?e.jsx("div",{className:"flex items-center justify-center py-6",children:e.jsx(us,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):s?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{onClick:()=>r(null),className:"flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(Xo,{className:"h-3.5 w-3.5"}),"Back to categories"]}),e.jsxs("p",{className:"text-xs font-medium flex items-center gap-1.5",children:[e.jsx("span",{children:i==null?void 0:i.icon})," ",i==null?void 0:i.name]}),l?e.jsx("div",{className:"flex items-center justify-center py-6",children:e.jsx(us,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):o.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No templates in this category"}):e.jsx(Ja,{className:"max-h-[280px]",children:e.jsx("div",{className:"space-y-1",children:o.map(d=>e.jsxs("button",{onClick:()=>t(d),className:"w-full p-2.5 rounded-lg border hover:bg-accent transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"font-medium text-sm",children:d.title}),d.tone&&e.jsx(Qe,{variant:"secondary",className:"text-[10px] shrink-0",children:d.tone})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:d.subject})]},d.id))})})]}):e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground px-1 mb-2",children:"Select a category"}),e.jsx("div",{className:"max-h-[200px] overflow-y-auto space-y-1 pr-1",children:n.map(d=>e.jsxs("button",{onClick:()=>r(d.id),className:"w-full flex items-center justify-between p-2.5 rounded-lg border hover:bg-accent transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"text-lg",children:d.icon}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:d.name}),d.description&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:d.description})]})]}),e.jsx(xa,{className:"h-4 w-4 text-muted-foreground shrink-0"})]},d.id))})]})}function Sme(){var a;const{user:t}=Us(),{data:s,isLoading:r}=gt({queryKey:["mass-email-settings",t==null?void 0:t.id],enabled:!!t,staleTime:60*1e3,queryFn:async()=>{var u,p,f,y;const[o,l]=await Promise.all([G.from("mass_email_settings").select("reply_to_email, display_name").eq("user_id",t.id).maybeSingle(),G.from("profiles").select("email, name").eq("id",t.id).maybeSingle()]),i=o.data,d=l.data;return{reply_to_email:((u=i==null?void 0:i.reply_to_email)==null?void 0:u.trim())||((p=d==null?void 0:d.email)==null?void 0:p.trim())||t.email||null,display_name:((f=i==null?void 0:i.display_name)==null?void 0:f.trim())||((y=d==null?void 0:d.name)==null?void 0:y.trim())||null}}});return{isReady:!!((a=s==null?void 0:s.reply_to_email)!=null&&a.trim()),isLoading:r,settings:s}}function Cme(){const{user:t}=Us(),s=Qt(),{data:r,isLoading:n}=gt({queryKey:["contact-intake-page",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return null;const{data:u,error:p}=await G.from("contact_intake_pages").select("*").eq("user_id",t.id).maybeSingle();if(p)throw p;return u},enabled:!!(t!=null&&t.id)}),a=Pt({mutationFn:async u=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:p,error:f}=await G.from("contact_intake_pages").insert({user_id:t.id,slug:u.toLowerCase().replace(/[^a-z0-9-]/g,"-")}).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["contact-intake-page"]}),pe.success("Connect page created!")},onError:u=>{var p;(p=u.message)!=null&&p.includes("duplicate")?pe.error("That slug is already taken. Try another."):pe.error("Failed to create page")}}),o=Pt({mutationFn:async u=>{if(!(r!=null&&r.id))throw new Error("No intake page");const{error:p}=await G.from("contact_intake_pages").update({...u,updated_at:new Date().toISOString()}).eq("id",r.id);if(p)throw p},onSuccess:()=>{s.invalidateQueries({queryKey:["contact-intake-page"]}),pe.success("Page updated!")},onError:()=>pe.error("Failed to update page")}),{data:l=[],isLoading:i}=gt({queryKey:["contact-intake-submissions",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:u,error:p}=await G.from("contact_intake_submissions").select("*").eq("agent_user_id",t.id).order("created_at",{ascending:!1}).limit(100);if(p)throw p;return u},enabled:!!(t!=null&&t.id)}),d=Pt({mutationFn:async u=>{if(!(r!=null&&r.id))throw new Error("No intake page. Create your Connect page first.");const{data:p,error:f}=await G.from("contact_intake_tokens").insert({contact_id:u,intake_page_id:r.id}).select("token").single();if(f)throw f;return`${window.location.origin}/connect/${r.slug}?t=${p.token}`}});return{intakePage:r,isLoading:n,createPage:a,updatePage:o,submissions:l,loadingSubmissions:i,generateUpdateLink:d}}const g_s=5*1024*1024,vv=50,y_s=["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 v_s(t){return t<1024?t+" B":t<1024*1024?(t/1024).toFixed(1)+" KB":(t/(1024*1024)).toFixed(1)+" MB"}function __s(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 v_(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 E1({open:t,onOpenChange:s,contact:r,bulkContacts:n,defaultSubject:a="",defaultBody:o="",gmailEmail:l,onSendComplete:i}){const{user:d}=Us(),u=Qt(),{isReady:p,settings:f}=Sme(),{intakePage:y}=Cme(),_=y?`https://contacts.relevelup.com/${y.slug}`:null,b=!!n&&n.length>0,N=p&&(b||!l),w=b?n:r?[r]:[],S=w[0],C=b?Math.ceil(w.length/vv):1,A=b&&w.length>vv,[I,L]=k.useState((S==null?void 0:S.email)||""),[O,V]=k.useState(a),[q,B]=k.useState(o),[U,te]=k.useState(!1),[Y,J]=k.useState(!1),[X,ce]=k.useState([]),[ie,ae]=k.useState(a),[oe,me]=k.useState(o),[ve,he]=k.useState("composing"),[ge,je]=k.useState(0),[qe,Me]=k.useState(0),[ke,Re]=k.useState(0),[Ve,Ne]=k.useState(0),Ue=k.useRef(!1),[Ie,ye]=k.useState(null);k.useEffect(()=>{t&&(L((S==null?void 0:S.email)||""),ae(a),me(o),V(v_(a,S||{first_name:""})),B(v_(o,S||{first_name:""})),J(!a&&!o),ce([]),he("composing"),je(0),Me(0),Re(0),Ne(0),Ue.current=!1,ye(null))},[t,S,a,o]);const ct=async et=>{const Ze=et.target.files;if(!Ze)return;const kt=X.reduce((Nt,es)=>Nt+es.size,0),Ut=[];for(const Nt of Array.from(Ze)){if(!y_s.includes(Nt.type)){pe.error(`${Nt.name}: Unsupported file type`);continue}if(kt+Nt.size>g_s){pe.error("Total attachments exceed 5MB limit");break}try{const es=await __s(Nt);Ut.push({name:Nt.name,type:Nt.type,size:Nt.size,data:es})}catch{pe.error(`Failed to read ${Nt.name}`)}}ce(Nt=>[...Nt,...Ut]),et.target.value=""},fe=et=>{ce(Ze=>Ze.filter((kt,Ut)=>Ut!==et))},$e=et=>{ae(et.subject),me(et.body),V(v_(et.subject,S||{first_name:""})),B(v_(et.body,S||{first_name:""})),J(!1)},Ye=et=>et.split(/\n\n+/).map(Ze=>`

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

`).join(""),tt=async et=>{const Ze=v_(ie,et),kt=v_(oe,et),Ut=Ye(kt);try{if(N){const Nt=(f==null?void 0:f.display_name)||"ReLevelUp",es=`${Nt.toLowerCase().replace(/[^a-z]/g,".")}@send.relevelup.com`,ds=`${Nt} <${es}>`,{data:js,error:lr}=await G.functions.invoke("ses-send-campaign",{body:{action:"test_send",to:et.email,from_email:ds,subject:Ze,body_html:Ut,reply_to:(f==null?void 0:f.reply_to_email)||void 0}});if(lr)throw lr;if(!(js!=null&&js.success))throw new Error((js==null?void 0:js.error)||"Failed to send")}else{const{data:Nt,error:es}=await G.functions.invoke("gmail-send",{body:{to:et.email,subject:Ze,body:Ut,contactId:et.id,attachments:X.map(({name:ds,type:js,data:lr})=>({name:ds,type:js,data:lr}))}});if(es)throw es;if(!(Nt!=null&&Nt.success))throw new Error((Nt==null?void 0:Nt.error)||"Failed to send")}return d&&await G.from("bulk_email_sends").insert({user_id:d.id,contact_id:et.id,contact_email:et.email,subject:Ze,source:N?"ses_bulk":"sphere_gaps"}),!0}catch(Nt){return console.error("Send error:",Nt),pe.error("Failed to send to "+et.first_name+": "+(Nt instanceof Error?Nt.message:"Unknown error")),!1}},Te=()=>{const et=ge*vv;return w.slice(et,et+vv)},We=async()=>{if(!O||!q){pe.error("Please fill in subject and message");return}const et=Te();te(!0),he("sending");let Ze=0,kt=0;for(let Nt=0;NtsetTimeout(ds,150));Me(Nt=>Nt+Ze),Re(Nt=>Nt+kt),te(!1),u.invalidateQueries({queryKey:["bulk-email-sends"]}),ge>=C-1||Ue.current?he("all_done"):he("batch_complete")},Ke=async()=>{if(!O||!q){pe.error("Please fill in subject and message");return}if(!b){te(!0);const et=await tt(S);te(!1),et&&(u.invalidateQueries({queryKey:["bulk-email-sends"]}),pe.success("Email sent successfully!"),s(!1),i==null||i());return}await We()},ot=async()=>{je(et=>et+1),Ne(0),await new Promise(et=>setTimeout(et,50)),await We()};k.useEffect(()=>{},[ge]);const He=()=>{if(U){Ue.current=!0;return}s(!1),i==null||i()},Je=ge*vv,ut=Math.min(Je+vv,w.length),mt=b&&w.length>0?Math.round((qe+ke)/w.length*100):0;return e.jsx(fs,{open:t,onOpenChange:He,children:e.jsxs(ps,{className:"sm:max-w-[600px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(tr,{className:`h-5 w-5 ${N?"text-orange-500":"text-red-500"}`}),b?`Send to ${w.length} Contacts`:"Compose Email"]}),N?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,b&&ve==="composing"&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Composing email for ",e.jsxs("span",{className:"font-medium",children:[w.length," contacts"]}),". You'll review each personalized email before sending."]})]}),ve==="sending"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(us,{className:"h-8 w-8 animate-spin mx-auto text-primary"}),e.jsxs("p",{className:"font-medium",children:["Sending batch ",ge+1," of ",C,"..."]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Ve," of ",Te().length," in this batch"]})]}),e.jsx(xi,{value:Ve/Te().length*100,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Overall: ",qe+ke," / ",w.length]}),e.jsxs("span",{children:[qe," sent • ",ke," failed"]})]}),e.jsx(W,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{Ue.current=!0},children:"Stop Sending"})]}),ve==="batch_complete"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx($n,{className:"h-8 w-8 text-emerald-500 mx-auto"}),e.jsxs("p",{className:"font-medium",children:["Batch ",ge+1," Complete!"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[qe," sent, ",ke," failed so far"]})]}),e.jsx(xi,{value:mt,className:"h-2"}),e.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:[w.length-qe-ke," contacts remaining (",C-ge-1," batches left)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{variant:"outline",className:"flex-1",onClick:He,children:"Done for Now"}),e.jsxs(W,{className:"flex-1 gap-2",onClick:ot,children:[e.jsx(_n,{className:"h-4 w-4"}),"Send Next ",Math.min(vv,w.length-ut)," Contacts"]})]})]}),ve==="all_done"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx($n,{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:[qe," emails sent successfully",ke>0&&e.jsxs("span",{className:"text-destructive",children:[" • ",ke," failed"]})]})]}),e.jsx(W,{className:"w-full",onClick:He,children:"Close"})]}),ve==="composing"&&e.jsxs("div",{className:"space-y-4",children:[Y?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(vn,{className:"h-4 w-4"})," Choose a Template"]}),e.jsxs(W,{variant:"ghost",size:"sm",onClick:()=>J(!1),className:"h-7 px-2 text-xs",children:[e.jsx(kr,{className:"h-3 w-3 mr-1"})," Write from scratch"]})]}),e.jsx(x_s,{onSelect:$e})]}):e.jsxs(W,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>J(!0),children:[e.jsx(vn,{className:"h-4 w-4"}),"Browse Templates"]}),e.jsx(ho,{}),!b&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{htmlFor:"gmail-to",children:"To"}),e.jsx(De,{id:"gmail-to",value:I,onChange:et=>L(et.target.value),placeholder:"recipient@example.com"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{htmlFor:"gmail-subject",children:"Subject"}),e.jsx(De,{id:"gmail-subject",value:O,onChange:et=>{V(et.target.value),ae(et.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(xe,{htmlFor:"gmail-body",children:"Message"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Qe,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>{B(et=>et+"{{first_name}}"),me(et=>et+"{{first_name}}")},children:"{{first_name}}"}),e.jsx(Qe,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>{B(et=>et+"{{last_name}}"),me(et=>et+"{{last_name}}")},children:"{{last_name}}"}),_&&e.jsx(Qe,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-primary/10 border-primary/40 text-primary",onClick:()=>{const et=` When you get a sec, can you share your latest contact info with me? It only takes about a minute: ${_} `;B(Ze=>Ze+et),me(Ze=>Ze+et)},title:"Insert your Connect Page link",children:"+ Connect Page"})]})]}),e.jsx(_r,{id:"gmail-body",value:q,onChange:et=>{B(et.target.value),me(et.target.value)},placeholder:"Write your message...",rows:10,className:"resize-y"}),b&&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(W,{type:"button",variant:"outline",size:"sm",className:"gap-2",onClick:()=>{var et;return(et=document.getElementById("gmail-attachments"))==null?void 0:et.click()},disabled:U,children:[e.jsx(mS,{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:ct})]}),X.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:X.map((et,Ze)=>e.jsxs(Qe,{variant:"secondary",className:"gap-1.5 pl-2 pr-1 py-1",children:[e.jsx(mS,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-[140px] truncate text-xs",children:et.name}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["(",v_s(et.size),")"]}),e.jsx("button",{type:"button",onClick:()=>fe(Ze),className:"ml-0.5 rounded-full p-0.5 hover:bg-muted",children:e.jsx(kr,{className:"h-3 w-3"})})]},Ze))})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(W,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),b?e.jsxs(W,{onClick:()=>{ye(w[0]||null),he("reviewing")},disabled:!O||!q,className:"gap-2",children:["Review Emails",e.jsx(Wa,{className:"h-4 w-4"})]}):e.jsxs(W,{onClick:Ke,disabled:U||!O||!q,className:"gap-2",children:[U?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(_n,{className:"h-4 w-4"}),U?"Sending...":"Send Email"]})]})]}),ve==="reviewing"&&b&&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."]}),A&&e.jsxs("p",{className:"text-xs text-amber-600 bg-amber-500/10 rounded-md px-2.5 py-1.5",children:["📦 ",w.length," contacts will be sent in ",C," batches of up to ",vv,". You'll confirm before each batch."]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(xe,{children:["Recipients (",w.length,")"]}),e.jsx("div",{className:"bg-muted p-1.5 rounded-md space-y-0.5 max-h-32 overflow-y-auto",children:w.map(et=>e.jsxs("div",{className:`text-sm px-2 py-1 rounded cursor-pointer transition-colors ${(Ie==null?void 0:Ie.id)===et.id?"bg-primary/10 text-primary font-medium":"text-muted-foreground hover:bg-accent hover:text-foreground"}`,onClick:()=>ye(et),children:[et.first_name," ",et.last_name," — ",et.email]},et.id))})]}),Ie&&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(tr,{className:"h-3.5 w-3.5"}),"Preview for ",Ie.first_name," ",Ie.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:"})," ",Ie.email]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Subject:"})," ",v_(ie,Ie)]})]}),e.jsx(ho,{}),e.jsx("div",{className:"text-sm whitespace-pre-wrap bg-background rounded p-2.5 max-h-40 overflow-y-auto border",children:v_(oe,Ie)})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsxs(W,{variant:"outline",onClick:()=>{he("composing"),ye(null)},children:[e.jsx(Oa,{className:"h-4 w-4 mr-1"}),"Back to Edit"]}),e.jsxs(W,{onClick:Ke,disabled:U,className:"gap-2",children:[U?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(_n,{className:"h-4 w-4"}),A?`Send First ${vv}`:`Send to ${w.length}`]})]})]})]})})}function b_s(){const t=wr(),{data:s}=qh(),{data:r}=WR(),n=ahe(),{isGmailConnected:a,gmailEmail:o}=Om(),[l,i]=k.useState(null),[d,u]=k.useState(!1),[p,f]=k.useState(new Set),y=Em(new Date),_=ml(y,30),b=I=>{if(!I)return null;const L=I.split(/[-/T]/);if(L.length<3)return null;const O=parseInt(L[1],10)-1,V=parseInt(L[2],10);return isNaN(O)||isNaN(V)?null:new Date(y.getFullYear(),O,V)},N=k.useMemo(()=>{if(!s)return[];const I=[];for(const L of s){if(L.birthday){const O=b(L.birthday);O&&(il(O,y)||ZS(O,y)&&YS(O,_))&&I.push({contact:L,type:"birthday",date:O,daysUntil:sf(O,y),dateStr:L.birthday})}if(L.home_anniversary){const O=b(L.home_anniversary);O&&(il(O,y)||ZS(O,y)&&YS(O,_))&&I.push({contact:L,type:"anniversary",date:O,daysUntil:sf(O,y),dateStr:L.home_anniversary})}}return I.sort((L,O)=>L.daysUntil-O.daysUntil),I},[s]),w=async I=>{const L=(r==null?void 0:r.find(O=>O.name==="Call"))||(r==null?void 0:r[0]);if(L)try{await n.mutateAsync({contactId:I.contact.id,actionTypeId:L.id,notes:`${I.type==="birthday"?"Birthday":"Home Anniversary"} outreach`}),f(O=>new Set(O).add(`${I.contact.id}-${I.type}`)),fn({title:"Touch logged!",description:`Logged outreach for ${I.contact.first_name}`})}catch{fn({title:"Error",description:"Failed to log touch",variant:"destructive"})}},S=I=>{const L=`${I.contact.first_name}${I.contact.last_name?" "+I.contact.last_name:""}`,O=I.type==="birthday"?"birthday":"home_anniversary",V=new URLSearchParams({cardType:O,contactId:I.contact.id,name:L,...I.contact.address?{address:I.contact.address}:{},...I.type==="anniversary"&&I.dateStr?{date:I.dateStr}:{}});t(`/mission-control/card-studio?${V.toString()}`)},C=I=>I===0?"Today!":I===1?"Tomorrow":`${I} days`,A=I=>I===0?"bg-red-500/15 text-red-600 dark:text-red-400 border-red-500/30":I<=3?"bg-amber-500/15 text-amber-600 dark:text-amber-400 border-amber-500/30":I<=7?"bg-blue-500/15 text-blue-600 dark:text-blue-400 border-blue-500/30":"bg-muted text-muted-foreground border-border";return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(_d,{className:"h-5 w-5 text-primary"}),"Upcoming Milestones",e.jsx(Qe,{variant:"secondary",className:"text-xs font-normal",children:"Next 30 days"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[N.length," event",N.length!==1?"s":""]})]})}),e.jsxs(Oe,{className:"space-y-2",children:[N.length===0&&e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Fu,{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."})]}),N.map((I,L)=>{var B,U;const O=`${I.contact.id}-${I.type}`,V=p.has(O),q=`${((B=I.contact.first_name)==null?void 0:B[0])||""}${((U=I.contact.last_name)==null?void 0:U[0])||""}`.toUpperCase();return e.jsxs("div",{className:Ot("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(Nn,{className:Ot("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(kn,{className:Ot("text-xs font-medium",I.type==="birthday"?"bg-pink-100 text-pink-700 dark:bg-pink-900/40 dark:text-pink-300":"bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300"),children:q})}),e.jsx("span",{className:"absolute -bottom-1.5 -right-1.5 text-base leading-none drop-shadow-sm",children:I.type==="birthday"?"🎂":"🏠"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium text-sm truncate",children:[I.contact.first_name," ",I.contact.last_name||""]}),e.jsx(Qe,{variant:"outline",className:Ot("text-[10px] shrink-0 whitespace-nowrap",A(I.daysUntil)),children:C(I.daysUntil)})]}),e.jsxs("div",{className:Ot("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(Fu,{className:"h-3 w-3"})," Birthday"]}):e.jsxs(e.Fragment,{children:[e.jsx(Mn,{className:"h-3 w-3"})," Home Anniversary"]}),e.jsx("span",{children:"·"}),e.jsx("span",{children:vs(I.date,"MMM d")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 mt-2 pl-[52px]",children:[I.contact.phone&&e.jsx(W,{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(In,{className:"h-3.5 w-3.5"})})}),I.contact.phone&&e.jsx(W,{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(wi,{className:"h-3.5 w-3.5"})})}),I.contact.email&&e.jsx(W,{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(tr,{className:"h-3.5 w-3.5"})}),e.jsx(W,{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(yn,{className:"h-3.5 w-3.5"})}),e.jsxs(W,{variant:"ghost",size:"sm",className:Ot("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:()=>S(I),children:[e.jsx(Or,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Card"})]}),e.jsx(W,{variant:"ghost",size:"icon",className:Ot("h-7 w-7",V&&"text-green-600"),title:"Log a touch",disabled:V||n.isPending,onClick:()=>w(I),children:e.jsx($n,{className:"h-3.5 w-3.5"})}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"View contact",onClick:()=>t(`/mission-control/contacts/${I.contact.id}`),children:e.jsx(jn,{className:"h-3.5 w-3.5"})})]})]},`${O}-${L}`)})]})]}),a&&l&&e.jsx(E1,{open:d,onOpenChange:u,contact:l,gmailEmail:o})]})}function w_s(t){const[s,r]=k.useState([]),[n,a]=k.useState(!1),{data:o,isLoading:l}=gt({queryKey:["active-visitors",t],queryFn:async()=>{if(!t)return[];try{await G.rpc("cleanup_stale_visitors")}catch{}const{data:p}=await G.from("lead_site_active_visitors").select("*").eq("lead_site_id",t).gte("last_seen_at",new Date(Date.now()-2*60*1e3).toISOString()).order("last_seen_at",{ascending:!1});if(!p)return[];const f=p.map(b=>b.contact_id).filter(Boolean);let y={};if(f.length>0){const{data:b}=await G.from("innercircle_contacts").select("id, first_name, last_name, email, phone").in("id",f);(b||[]).forEach(N=>{y[N.id]=N})}const _=p.map(b=>b.auth_user_id).filter(Boolean);if(_.length>0){const{data:b}=await G.from("lead_site_consumer_profiles").select("user_id, name, phone, contact_id").eq("lead_site_id",t).in("user_id",_);(b||[]).forEach(N=>{const w=p.find(S=>S.auth_user_id===N.user_id);w&&!w.contact_id&&N.contact_id&&(w.contact_id=N.contact_id),w&&!y[w.contact_id||""]&&N.name&&(y[w.contact_id||w.auth_user_id||""]={first_name:N.name.split(" ")[0],last_name:N.name.split(" ").slice(1).join(" ")||null,email:null,phone:N.phone})})}return p.map(b=>{var N,w;return{...b,contact_name:y[b.contact_id||b.auth_user_id||""]?`${y[b.contact_id||b.auth_user_id||""].first_name} ${y[b.contact_id||b.auth_user_id||""].last_name||""}`.trim():null,contact_email:((N=y[b.contact_id||b.auth_user_id||""])==null?void 0:N.email)||null,contact_phone:((w=y[b.contact_id||b.auth_user_id||""])==null?void 0:w.phone)||null}})},enabled:!!t,refetchInterval:6e4});k.useEffect(()=>{if(!t)return;const p=G.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(y=>y.find(b=>b.id===f.new.id)?y:[f.new,...y]):f.eventType==="UPDATE"?r(y=>y.map(_=>_.id===f.new.id?{..._,...f.new}:_)):f.eventType==="DELETE"&&r(y=>y.filter(_=>_.id!==f.old.id))}).subscribe(f=>{f==="SUBSCRIBED"&&a(!0)});return()=>{G.removeChannel(p)}},[t]);const i=n&&s.length>0?j_s([...s,...o||[]]):o||[],d=Date.now(),u=i.filter(p=>d-new Date(p.last_seen_at).getTime()<2*60*1e3);return{activeVisitors:u,isLoading:l,count:u.length}}function j_s(t){const s=new Set;return t.filter(r=>s.has(r.id)?!1:(s.add(r.id),!0))}const N_s={property_view:{label:"Viewed",icon:jn,color:"text-blue-500",bgColor:"bg-blue-500/10"},new_lead:{label:"New Lead",icon:Jo,color:"text-emerald-500",bgColor:"bg-emerald-500/10"},saved_listing:{label:"Saved",icon:Xa,color:"text-rose-500",bgColor:"bg-rose-500/10"}};function k_s(){const{user:t}=Us(),s=wr(),{isGmailConnected:r,gmailEmail:n}=Om(),{leadSite:a}=CC(),{count:o}=w_s(a==null?void 0:a.id),[l,i]=k.useState(!1),[d,u]=k.useState(null),{data:p,isLoading:f}=gt({queryKey:["lead-site-activity",t==null?void 0:t.id],queryFn:async()=>{const{data:S,error:C}=await G.rpc("get_lead_site_activity",{_user_id:t.id});if(C)throw C;return S},enabled:!!t,refetchInterval:6e4});if(f||!(p!=null&&p.has_site))return null;const y=(p.activities||[]).filter(S=>S.visitor_name&&S.visitor_name!=="Site Visitor"),_=y.filter(S=>S.activity_type==="new_lead"),b=(p.activities||[]).filter(S=>S.activity_type==="property_view").length,N=(p.activities||[]).filter(S=>S.activity_type==="saved_listing").length,w=S=>{if(S.visitor_email)if(r){const C=(S.visitor_name||"").split(" ");u({id:S.contact_id||"",first_name:C[0]||"",last_name:C.slice(1).join(" ")||null,email:S.visitor_email}),i(!0)}else window.location.href=`mailto:${S.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(W,{variant:"ghost",size:"sm",className:"text-primary gap-1",onClick:()=>s("/mission-control/website-activity"),children:["View All",e.jsx(Wa,{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(Jo,{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:_.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(jn,{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:b}),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(Xa,{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:N}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Saved"})]})]})]}),y.length>0?e.jsxs("div",{className:"space-y-2",children:[y.slice(0,5).map((S,C)=>{const A=N_s[S.activity_type],I=A.icon,L=Nl(new Date(S.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 ${A.bgColor}`,children:e.jsx(I,{className:`h-3.5 w-3.5 ${A.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:()=>{S.contact_id&&s(`/mission-control/contacts/${S.contact_id}`)},children:S.visitor_name}),e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{children:A.label}),S.mls_number&&e.jsxs("span",{children:["· MLS# ",S.mls_number]}),S.lead_type&&e.jsxs("span",{children:["· ",S.lead_type]}),e.jsxs("span",{children:["· ",L]})]})]}),e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[S.visitor_email&&e.jsx(W,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-primary",onClick:()=>w(S),children:e.jsx(tr,{className:"h-3.5 w-3.5"})}),S.visitor_phone&&e.jsxs(e.Fragment,{children:[e.jsx(W,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-primary",onClick:()=>window.location.href=`tel:${S.visitor_phone}`,children:e.jsx(In,{className:"h-3.5 w-3.5"})}),e.jsx(W,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-primary",onClick:()=>window.location.href=`sms:${S.visitor_phone}`,children:e.jsx(wi,{className:"h-3.5 w-3.5"})})]}),S.contact_id&&e.jsx(W,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>s(`/mission-control/contacts/${S.contact_id}`),children:e.jsx(xa,{className:"h-3.5 w-3.5"})})]})]},`${S.activity_type}-${S.occurred_at}-${C}`)}),y.length>5&&e.jsxs(W,{variant:"outline",className:"w-full text-xs",onClick:()=>s("/mission-control/website-activity"),children:["View ",y.length-5," more activities",e.jsx(Wa,{className:"h-3.5 w-3.5 ml-1"})]})]}):e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-6 text-center",children:[e.jsx(lh,{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:b>0?`${b} anonymous listing views recorded.`:"Lead engagement will appear here as visitors interact with your site."}),e.jsxs(W,{variant:"outline",size:"sm",className:"mt-3",onClick:()=>s("/mission-control/website-activity"),children:["View Full Activity",e.jsx(Wa,{className:"h-3.5 w-3.5 ml-1"})]})]})}),r&&d&&e.jsx(E1,{open:l,onOpenChange:i,contact:d,gmailEmail:n})]})}const L7e={Crown:Cm,FileText:vn,Users:ir,Globe:nd,Star:Gn,Phone:In,MessageSquare:wi,PenTool:Mb,Video:yn,Gift:hi},S_s={"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 C_s(){var Ke,ot,He,Je,ut,mt;const t=wr(),{user:s}=Us(),{data:r}=Nf(),{data:n}=_Xe(),{data:a}=qh(),{data:o}=WR(),{data:l}=kXe(),i=ILt(),d=oke(),u=ELt(90),p=ahe(),[f,y]=k.useState(null),[_,b]=k.useState(null),[N,w]=k.useState(!1),[S,C]=k.useState(""),[A,I]=k.useState(!1),[L,O]=k.useState(""),[V,q]=k.useState(jle()),[B,U]=k.useState("cards"),[te,Y]=k.useState(!1),[J,X]=k.useState(null),[ce,ie]=k.useState(null),[ae,oe]=k.useState(""),{isGmailConnected:me,gmailEmail:ve}=Om(),he=()=>{const et=parseInt(L,10);if(isNaN(et)||et<1){fn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}q(et),NXe(et),I(!1),fn({title:"Goal updated",description:`Weekly touch goal set to ${et}`})},ge=()=>{O(V.toString()),I(!0)};k.useEffect(()=>{(async()=>{if(!(s!=null&&s.id))return;const{data:Ze}=await G.from("profiles").select("name").eq("id",s.id).single();Ze!=null&&Ze.name&&C(Ze.name.split(" ")[0])})()},[s==null?void 0:s.id]),k.useEffect(()=>{i.mutate()},[]);const je=Em(new Date),qe=ml(je,7),Me=et=>{if(!et)return null;const Ze=et.split(/[-/T]/);if(Ze.length<3)return null;const kt=parseInt(Ze[1],10)-1,Ut=parseInt(Ze[2],10);return isNaN(kt)||isNaN(Ut)?null:new Date(je.getFullYear(),kt,Ut)},ke=(a==null?void 0:a.filter(et=>{const Ze=Me(et.birthday),kt=Me(et.home_anniversary);return Ze&&il(Ze,je)||kt&&il(kt,je)}))||[];a!=null&&a.filter(et=>{if(!et.birthday&&!et.home_anniversary)return!1;const Ze=kt=>{if(!kt)return!1;const Ut=Me(kt);return Ut?ZS(Ut,je)&&YS(Ut,qe):!1};return Ze(et.birthday)||Ze(et.home_anniversary)}).slice(0,5);const Re=[],Ve=(o==null?void 0:o.find(et=>et.name==="Call"))||(o==null?void 0:o[0]);for(const et of ke){const Ze=Me(et.birthday),kt=Me(et.home_anniversary),Ut=Ze&&il(Ze,je),Nt=kt&&il(kt,je);Ut&&Re.push({contact:et,actionType:Ve||{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=(ot=(Ke=et.tags)==null?void 0:Ke[0])==null?void 0:ot.relationship_type)==null?void 0:He.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"birthday"}),Nt&&Re.push({contact:et,actionType:Ve||{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:((mt=(ut=(Je=et.tags)==null?void 0:Je[0])==null?void 0:ut.relationship_type)==null?void 0:mt.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"anniversary"})}const Ue=l!==void 0?l||[]:(a==null?void 0:a.slice(0,5).map((et,Ze)=>{var Ut,Nt,es;const kt=o==null?void 0:o[Ze%((o==null?void 0:o.length)||1)];return kt?{contact:et,actionType:kt,planName:"Quick Touch",relationshipTypeName:((es=(Nt=(Ut=et.tags)==null?void 0:Ut[0])==null?void 0:Nt.relationship_type)==null?void 0:es.name)||"",monthNumber:0}:null}).filter(Boolean))||[],Ie=[...Re,...Ue],ye=async(et,Ze,kt)=>{await p.mutateAsync({contactId:et,actionTypeId:Ze,scriptUsedId:kt}),w(!1),b(null)},ct=et=>{et.script?(b(et),w(!0)):ye(et.contact.id,et.actionType.id)},fe=et=>L7e[et||"Phone"]||In,$e=et=>L7e[et||"Users"]||ir,Ye=(et,Ze)=>et.replace(/\{\{FirstName\}\}/g,Ze.first_name).replace(/\{\{LastName\}\}/g,Ze.last_name||"").replace(/\{\{AgentName\}\}/g,S||"there"),tt=(et,Ze)=>({Call:`Thinking of you, ${Ze}!`,Text:`Quick hello, ${Ze}`,Email:`Checking in, ${Ze}`,"Handwritten Note":`A note for ${Ze}`,Video:`Video message for ${Ze}`,Gift:`Something special for you, ${Ze}`})[et]||`Hello ${Ze}!`,Te=(et,Ze,kt)=>{const Ut=`sms:${et}`;if(Ze&&kt){const Nt=Ye(Ze,kt);return`${Ut}?body=${encodeURIComponent(Nt)}`}return Ut},We=(et,Ze,kt,Ut,Nt)=>{const es=`mailto:${et}`,ds=[];if(Nt){const js=kt||tt(Ut||"Email",Nt.first_name);if(ds.push(`subject=${encodeURIComponent(js)}`),Ze){const lr=Ye(Ze,Nt);ds.push(`body=${encodeURIComponent(lr)}`)}}return ds.length>0?`${es}?${ds.join("&")}`:es};return e.jsxs(e.Fragment,{children:[e.jsxs(Ds,{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(k_s,{}),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(et=>et.active).map(et=>{const Ze=$e(et.icon),kt=(n==null?void 0:n[et.id])||0,Ut=f===et.id,Nt=S_s[et.name]||"bg-secondary text-secondary-foreground";return e.jsxs("button",{onClick:()=>{Ut?(y(null),t("/mission-control/contacts")):(y(et.id),t(`/mission-control/contacts?type=${et.id}`))},className:` flex items-center gap-2 px-4 py-3 rounded-lg border transition-all ${Ut?Nt:"bg-card hover:bg-accent"} `,children:[e.jsx(Ze,{className:"h-5 w-5"}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:et.name}),e.jsxs("div",{className:`text-sm ${Ut?"opacity-90":"text-muted-foreground"}`,children:[kt," Contacts"]})]})]},et.id)})})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsxs(W,{onClick:()=>t("/mission-control/video/record"),className:"w-full bg-gradient-to-r from-primary to-primary/80",children:[e.jsx(Rd,{className:"h-4 w-4 mr-1"}),"Quick Video"]}),e.jsxs(W,{onClick:()=>t("/mission-control/contacts"),className:"w-full",variant:"outline",children:["View Contacts",e.jsx(xa,{className:"h-4 w-4 ml-1"})]}),e.jsx(W,{variant:"outline",onClick:()=>t("/mission-control/video-library"),className:"w-full",children:"Video Library"}),e.jsx(W,{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(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(Or,{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(W,{variant:B==="cards"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>U("cards"),title:"Card view",children:e.jsx(xp,{className:"h-4 w-4"})}),e.jsx(W,{variant:B==="table"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>U("table"),title:"Table view",children:e.jsx(Dh,{className:"h-4 w-4"})})]})]}),e.jsx(Pe,{children:e.jsx(Oe,{className:"p-4",children:Ie.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No actions scheduled for today."}),e.jsx("p",{className:"text-sm mt-1",children:"Add contacts and enable touchpoint plans to get started."}),e.jsx(W,{variant:"outline",className:"mt-4",onClick:()=>t("/mission-control/plans"),children:"Manage Plans"})]}):B==="table"?e.jsx(f_s,{actions:Ie,onMarkComplete:ye,onViewScript:ct,isLoading:p.isPending,buildSmsLink:Te,buildEmailLink:We,onGmailCompose:me?et=>{X(et),Y(!0)}:void 0}):e.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[Ie.map((et,Ze)=>{var Lt,Es,fr,Hs,mr,an,Cr;const kt=et.isSpecialDate,Ut=et.specialDateType,Nt=kt?Ut==="birthday"?Fu:Mn:fe(((Lt=et.actionType)==null?void 0:Lt.icon)||null),es=et.contact.phone,ds=et.contact.email,js=kt?Ut==="birthday"?"#EC4899":"#8B5CF6":((Es=et.actionType)==null?void 0:Es.color)||"#3B82F6",lr=kt?Ut==="birthday"?"🎂 Birthday Today!":"🏠 Home Anniversary!":(fr=et.actionType)==null?void 0:fr.name;return e.jsxs("div",{className:`flex-shrink-0 w-[260px] border rounded-lg overflow-hidden ${kt?"ring-2 ring-offset-2":""}`,style:kt?{"--tw-ring-color":js}:void 0,children:[e.jsxs("div",{className:"p-3 text-white flex items-center gap-2",style:{backgroundColor:js},children:[e.jsx(Nt,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm",children:lr})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("button",{onClick:()=>t(`/mission-control/contacts/${et.contact.id}`),className:"font-medium text-sm hover:text-primary hover:underline transition-colors text-left",children:[et.contact.first_name," ",et.contact.last_name]}),e.jsxs("div",{className:"flex gap-1.5",children:[es&&e.jsxs(e.Fragment,{children:[e.jsxs("a",{href:`tel:${et.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(In,{className:"h-3 w-3"}),"Call"]}),e.jsxs("a",{href:Te(et.contact.phone,(Hs=et.script)==null?void 0:Hs.script_body,et.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(wi,{className:"h-3 w-3"}),"Text"]})]}),ds&&(me?e.jsxs("button",{onClick:()=>{X({id:et.contact.id,first_name:et.contact.first_name,last_name:et.contact.last_name,email:et.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(tr,{className:"h-3 w-3"}),"Email"]}):e.jsxs("a",{href:We(et.contact.email,(mr=et.script)==null?void 0:mr.script_body,(an=et.script)==null?void 0:an.email_subject,(Cr=et.actionType)==null?void 0:Cr.name,et.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(tr,{className:"h-3 w-3"}),"Email"]}))]}),kt&&e.jsxs("button",{onClick:()=>{const Fr=`${et.contact.first_name}${et.contact.last_name?" "+et.contact.last_name:""}`,$r=Ut==="birthday"?"birthday":"home_anniversary",nr=new URLSearchParams({cardType:$r,contactId:et.contact.id,name:Fr,...et.contact.address?{address:et.contact.address}:{},...Ut==="anniversary"&&et.contact.home_anniversary?{date:et.contact.home_anniversary}:{}});t(`/mission-control/card-studio?${nr.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(tr,{className:"h-3 w-3"}),"Send ",Ut==="birthday"?"Birthday":"Anniversary"," Card"]}),!es&&!ds&&e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No contact info"}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[et.relationshipTypeName&&e.jsx(Qe,{variant:"secondary",className:"text-xs",children:et.relationshipTypeName}),et.monthNumber>0&&e.jsxs(Qe,{variant:"outline",className:"text-xs",children:["Month ",et.monthNumber]})]}),et.script&&e.jsx(W,{size:"sm",variant:"outline",className:"w-full",onClick:()=>ct(et),children:"View Script"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs(W,{size:"sm",variant:"outline",className:"flex-1 gap-1",onClick:()=>{ie(et.contact.id),oe(`${et.contact.first_name} ${et.contact.last_name||""}`.trim())},children:[e.jsx(hh,{className:"h-3.5 w-3.5"}),"Snooze"]}),e.jsx(W,{size:"sm",className:"flex-1",onClick:()=>{var Fr;return ye(et.contact.id,et.actionType.id,(Fr=et.script)==null?void 0:Fr.id)},disabled:p.isPending,children:"Mark Complete"})]})]})]},et.contact.id+Ze)}),e.jsx("div",{className:"flex-shrink-0 w-[100px] border rounded-lg flex items-center justify-center",children:e.jsxs(Hd,{children:[e.jsx(Gd,{asChild:!0,children:e.jsxs(W,{variant:"ghost",className:"h-full w-full",children:[e.jsx(Zp,{className:"h-5 w-5 mr-2"}),"More"]})}),e.jsx(Nd,{children:e.jsx(_a,{onClick:()=>t("/mission-control/contacts"),children:"View all contacts"})})]})})]})})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zt,{className:"text-lg",children:"Momentum"}),e.jsxs(fs,{open:A,onOpenChange:I,children:[e.jsx(mi,{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(So,{className:"h-4 w-4 text-muted-foreground hover:text-primary"})})}),e.jsxs(ps,{className:"sm:max-w-[360px]",children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Set Weekly Goal"}),e.jsx(Ir,{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(xe,{htmlFor:"weekly-goal-ic",children:"Weekly touch goal"}),e.jsx(De,{id:"weekly-goal-ic",type:"number",min:"1",value:L,onChange:et=>O(et.target.value),placeholder:"20",onKeyDown:et=>{et.key==="Enter"&&he()}})]}),e.jsx(W,{onClick:he,className:"w-full",children:"Save Goal"})]})]})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(xi,{value:Math.min(d.actionsThisWeek/V*100,100),className:"h-3 w-full max-w-full"}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(rd,{className:"h-5 w-5 text-orange-500"}),e.jsxs("span",{className:"font-medium",children:[d.actionsThisWeek," / ",V]}),e.jsx("span",{className:"text-muted-foreground",children:"Actions Completed This Week"})]}),d.streak>0&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-lg",children:"🔥"}),e.jsx("span",{className:"font-medium",children:"Great Job!"}),e.jsxs("span",{className:"text-muted-foreground",children:["Keep Your Streak Going! (",d.streak," days)"]})]}),u.count>0&&e.jsxs("button",{onClick:()=>t("/mission-control/contacts?filter=not-touched-90"),className:"flex items-start gap-2 text-sm pt-2 border-t w-full text-left hover:bg-accent/50 -mx-4 px-4 py-2 rounded-md transition-colors",children:[e.jsx(nn,{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(xa,{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(BXe,{}),e.jsx(b_s,{})]})]}),e.jsx(fs,{open:N,onOpenChange:w,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(ks,{children:e.jsx(_s,{className:"flex items-center gap-2",children:_&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:_.actionType.color||"#3B82F6"}}),_.actionType.name," Script"]})})}),_&&_.script&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["For: ",e.jsxs("span",{className:"font-medium text-foreground",children:[_.contact.first_name," ",_.contact.last_name]})]}),e.jsx("div",{className:"bg-muted p-4 rounded-lg",children:e.jsx("p",{className:"whitespace-pre-wrap",children:Ye(_.script.script_body,_.contact)})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{variant:"outline",className:"flex-1",onClick:()=>w(!1),children:"Close"}),e.jsx(W,{className:"flex-1",onClick:()=>{var et;return ye(_.contact.id,_.actionType.id,(et=_.script)==null?void 0:et.id)},disabled:p.isPending,children:"Mark Complete"})]})]})]})}),e.jsx(c_s,{})]}),me&&J&&e.jsx(E1,{open:te,onOpenChange:Y,contact:J,gmailEmail:ve}),e.jsx(kme,{open:!!ce,onOpenChange:et=>!et&&ie(null),contactId:ce||"",contactName:ae})]})}var Lat="Toggle",DSe=k.forwardRef((t,s)=>{const{pressed:r,defaultPressed:n,onPressedChange:a,...o}=t,[l,i]=Uu({prop:r,onChange:a,defaultProp:n??!1,caller:Lat});return e.jsx(Jr.button,{type:"button","aria-pressed":l,"data-state":l?"on":"off","data-disabled":t.disabled?"":void 0,...o,ref:s,onClick:Mr(t.onClick,()=>{t.disabled||i(!l)})})});DSe.displayName=Lat;var Dat=DSe,Cw="ToggleGroup",[Rat,kAs]=qc(Cw,[pw]),Oat=pw(),RSe=xt.forwardRef((t,s)=>{const{type:r,...n}=t;if(r==="single"){const a=n;return e.jsx(M_s,{...a,ref:s})}if(r==="multiple"){const a=n;return e.jsx(T_s,{...a,ref:s})}throw new Error(`Missing prop \`type\` expected on \`${Cw}\``)});RSe.displayName=Cw;var[Fat,zat]=Rat(Cw),M_s=xt.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=Uu({prop:r,defaultProp:n??"",onChange:a,caller:Cw});return e.jsx(Fat,{scope:t.__scopeToggleGroup,type:"single",value:xt.useMemo(()=>l?[l]:[],[l]),onItemActivate:i,onItemDeactivate:xt.useCallback(()=>i(""),[i]),children:e.jsx(Bat,{...o,ref:s})})}),T_s=xt.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=Uu({prop:r,defaultProp:n??[],onChange:a,caller:Cw}),d=xt.useCallback(p=>i((f=[])=>[...f,p]),[i]),u=xt.useCallback(p=>i((f=[])=>f.filter(y=>y!==p)),[i]);return e.jsx(Fat,{scope:t.__scopeToggleGroup,type:"multiple",value:l,onItemActivate:d,onItemDeactivate:u,children:e.jsx(Bat,{...o,ref:s})})});RSe.displayName=Cw;var[A_s,E_s]=Rat(Cw),Bat=xt.forwardRef((t,s)=>{const{__scopeToggleGroup:r,disabled:n=!1,rovingFocus:a=!0,orientation:o,dir:l,loop:i=!0,...d}=t,u=Oat(r),p=mw(l),f={role:"group",dir:p,...d};return e.jsx(A_s,{scope:r,rovingFocus:a,disabled:n,children:a?e.jsx(fue,{asChild:!0,...u,orientation:o,dir:p,loop:i,children:e.jsx(Jr.div,{...f,ref:s})}):e.jsx(Jr.div,{...f,ref:s})})}),wde="ToggleGroupItem",$at=xt.forwardRef((t,s)=>{const r=zat(wde,t.__scopeToggleGroup),n=E_s(wde,t.__scopeToggleGroup),a=Oat(t.__scopeToggleGroup),o=r.value.includes(t.value),l=n.disabled||t.disabled,i={...t,pressed:o,disabled:l},d=xt.useRef(null);return n.rovingFocus?e.jsx(xue,{asChild:!0,...a,focusable:!l,active:o,ref:d,children:e.jsx(D7e,{...i,ref:s})}):e.jsx(D7e,{...i,ref:s})});$at.displayName=wde;var D7e=xt.forwardRef((t,s)=>{const{__scopeToggleGroup:r,value:n,...a}=t,o=zat(wde,r),l={role:"radio","aria-checked":t.pressed,"aria-pressed":void 0},i=o.type==="single"?l:void 0;return e.jsx(DSe,{...i,...a,ref:s,onPressedChange:d=>{d?o.onItemActivate(n):o.onItemDeactivate(n)}})}),qat=RSe,Uat=$at;const Vat=bC("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"}}),P_s=k.forwardRef(({className:t,variant:s,size:r,...n},a)=>e.jsx(Dat,{ref:a,className:Ot(Vat({variant:s,size:r,className:t})),...n}));P_s.displayName=Dat.displayName;const Hat=k.createContext({size:"default",variant:"default"}),Gat=k.forwardRef(({className:t,variant:s,size:r,children:n,...a},o)=>e.jsx(qat,{ref:o,className:Ot("flex items-center justify-center gap-1",t),...a,children:e.jsx(Hat.Provider,{value:{variant:s,size:r},children:n})}));Gat.displayName=qat.displayName;const Wat=k.forwardRef(({className:t,children:s,variant:r,size:n,...a},o)=>{const l=k.useContext(Hat);return e.jsx(Uat,{ref:o,className:Ot(Vat({variant:l.variant||r,size:l.size||n}),t),...a,children:s})});Wat.displayName=Uat.displayName;const I_s=[{value:"bidirectional",label:"Two-Way",icon:td,tooltip:"Sync contacts in both directions"},{value:"push_only",label:"Push Only",icon:uu,tooltip:"Only push Agent OS → BoldTrail"},{value:"pull_only",label:"Pull Only",icon:Ih,tooltip:"Only pull BoldTrail → Agent OS"}];function Twe({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(Gat,{type:"single",value:t,onValueChange:a=>{a&&s(a)},className:"justify-start",children:I_s.map(a=>e.jsxs(ec,{children:[e.jsx(tc,{asChild:!0,children:e.jsxs(Wat,{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(Dl,{children:a.tooltip})]},a.value))})]})}function R7e(){const t=Qt(),[s,r]=k.useState(!1),[n,a]=k.useState(null),[o,l]=k.useState(!1),[i,d]=k.useState(!1),[u,p]=k.useState(null),[f,y]=k.useState(null),[_,b]=k.useState(0),N=k.useRef(!1),{data:w}=gt({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:B,error:U}=await G.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(U)throw U;return B}}),S=(w==null?void 0:w.sync_direction)||"bidirectional",C=u??S,A=Pt({mutationFn:async()=>{const{data:B,error:U}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync_preview"}});if(U)throw U;if(B!=null&&B.error)throw new Error(B.error);return B},onSuccess:B=>{p(null),a(B),r(!0)},onError:B=>{pe.error(B.message||"Failed to generate sync preview")}}),I=Pt({mutationFn:async()=>{N.current=!1,y("Initializing sync..."),b(5);const{data:B,error:U}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:C}});if(U)throw U;if(B!=null&&B.error)throw new Error(B.error);const te=B;let Y=te.sync_log_id,J=te.next_phase,X=te.next_offset,ce=te.push_total||0,ie=te.pull_total||0,ae=te.update_total||0,oe=0,me=0,ve=0;for(;J!=="finalize"&&!N.current;){const je=ce+ie+ae;J==="fetch_bt"?y("Fetching BoldTrail contacts..."):J==="analyze"?(y("Analyzing contacts..."),b(15)):J==="push"?(y(`Pushing contacts to BoldTrail... (${oe}/${ce})`),b(je>0?oe/je*90:0)):J==="pull"?(y(`Pulling contacts from BoldTrail... (${me}/${ie})`),b(je>0?(ce+me)/je*90:0)):J==="update"&&(y(`Updating existing contacts... (${ve}/${ae})`),b(je>0?(ce+ie+ve)/je*90:0));const{data:qe,error:Me}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:J,offset:X,sync_log_id:Y,sync_direction:C}});if(Me)throw Me;if(qe!=null&&qe.error)throw new Error(qe.error);const ke=qe;oe+=ke.chunk_pushed||0,me+=ke.chunk_pulled||0,ve+=ke.chunk_updated||0,ke.push_total!==void 0&&(ce=ke.push_total||0),ke.pull_total!==void 0&&(ie=ke.pull_total||0),ke.update_total!==void 0&&(ae=ke.update_total||0),ke.progress&&y(ke.progress),J=ke.next_phase,X=ke.next_offset}y("Finalizing sync..."),b(95);const{data:he,error:ge}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:Y,sync_direction:C}});if(ge)throw ge;return b(100),he},onSuccess:B=>{y(null),b(0),r(!1),t.invalidateQueries({queryKey:["boldtrail-status"]}),t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),t.invalidateQueries({queryKey:["contacts-last-touch"]});const U=[`Pushed ${B.contacts_pushed||0}`,`pulled ${B.contacts_pulled||0}`,`updated ${B.contacts_updated||0}`,`skipped ${B.contacts_skipped||0} duplicates`];pe.success(`Sync complete! ${U.join(", ")}.`)},onError:B=>{y(null),b(0),pe.error(B.message||"Sync failed")}});if(!(w!=null&&w.connected))return null;const L=C==="pull_only"?0:(n==null?void 0:n.to_push)??0,O=C==="push_only"?0:(n==null?void 0:n.to_pull)??0,V=(n==null?void 0:n.to_update)??0,q=L>0||O>0||V>0;return e.jsxs(e.Fragment,{children:[e.jsxs(ec,{children:[e.jsx(tc,{asChild:!0,children:e.jsx(W,{variant:"outline",size:"icon",onClick:()=>A.mutate(),disabled:A.isPending,className:"shrink-0",children:A.isPending?e.jsx(Zi,{className:"h-4 w-4 animate-spin"}):e.jsx(td,{className:"h-4 w-4 text-emerald-600"})})}),e.jsx(Dl,{children:"Sync with BoldTrail"})]}),e.jsx(fs,{open:s,onOpenChange:B=>{I.isPending||r(B)},children:e.jsxs(ps,{className:"sm:max-w-lg",children:[e.jsxs(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(td,{className:"h-5 w-5 text-emerald-600"}),"Sync Preview"]}),e.jsx(Ir,{children:"Review what will happen when you sync your contacts."})]}),n&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(Twe,{value:C,onChange:p,size:"sm"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:`rounded-lg border p-3 text-center ${C==="pull_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-emerald-600",children:L}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(uu,{className:"h-3 w-3"})," Push to BoldTrail"]})]}),e.jsxs("div",{className:`rounded-lg border p-3 text-center ${C==="push_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:O}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Ih,{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:V}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(DM,{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(ir,{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"]}),V>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(DM,{className:"h-3 w-3 inline mr-1"}),V," contacts have missing fields that will be filled from the other system"]}),L>0&&e.jsxs(lf,{open:o,onOpenChange:l,children:[e.jsx(cf,{asChild:!0,children:e.jsxs(W,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(uu,{className:"h-3 w-3 text-emerald-600"}),L," contacts to push to BoldTrail"]}),e.jsx(Bi,{className:`h-3 w-3 transition-transform ${o?"rotate-180":""}`})]})}),e.jsx(df,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[n.push_preview.map((B,U)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:B.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:B.email})]},U)),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(lf,{open:i,onOpenChange:d,children:[e.jsx(cf,{asChild:!0,children:e.jsxs(W,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ih,{className:"h-3 w-3 text-blue-600"}),O," contacts to pull from BoldTrail"]}),e.jsx(Bi,{className:`h-3 w-3 transition-transform ${i?"rotate-180":""}`})]})}),e.jsx(df,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[n.pull_preview.map((B,U)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:B.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:B.email})]},U)),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"]})]})})]}),!q&&!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(xi,{value:_||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(W,{variant:"outline",onClick:()=>r(!1),disabled:I.isPending,children:"Cancel"}),e.jsxs(W,{onClick:()=>I.mutate(),disabled:I.isPending||!q,className:"gap-2",children:[I.isPending?e.jsx(Zi,{className:"h-4 w-4 animate-spin"}):e.jsx(td,{className:"h-4 w-4"}),I.isPending?"Syncing...":"Sync Now"]})]})]})]})})]})}const L_s=()=>{const{user:t}=Us();return gt({queryKey:["popby-items",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("popby_items").select("*").or(`owner_user_id.is.null,owner_user_id.eq.${t==null?void 0:t.id}`).eq("is_active",!0).order("name");if(r)throw r;return s},enabled:!!t})},Mme=t=>{const{user:s}=Us();return gt({queryKey:["popby-logs",s==null?void 0:s.id,t],queryFn:async()=>{let r=G.from("popby_logs").select("*").order("completed_at",{ascending:!1});if(t){const o=new Date;o.setDate(o.getDate()-t),r=r.gte("completed_at",o.toISOString())}const{data:n,error:a}=await r;if(a)throw a;return n},enabled:!!s})},OSe=()=>{const{user:t}=Us();return gt({queryKey:["relationship-type-popby-defaults",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("relationship_type_popby_defaults").select("*");if(r)throw r;return s},enabled:!!t})},Kat=()=>{const{user:t}=Us();return gt({queryKey:["contact-popby-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_popby_settings").select("*");if(r)throw r;return s},enabled:!!t})},D_s=()=>{const{data:t}=qh();Nf();const{data:s}=Mme(),{data:r}=Kat(),{data:n}=OSe(),a=new Map;s==null||s.forEach(u=>{const p=a.get(u.contact_id);(!p||new Date(u.completed_at)>new Date(p))&&a.set(u.contact_id,u.completed_at)});const o=new Map;n==null||n.forEach(u=>o.set(u.relationship_type_id,u.frequency_days));const l=new Map;r==null||r.filter(u=>u.is_active).forEach(u=>{l.set(u.contact_id,u.frequency_days)});const i=Em(new Date);return(t||[]).map(u=>{let p=90;if(l.has(u.id))p=l.get(u.id);else if(u.tags&&u.tags.length>0){const N=u.tags.map(w=>o.get(w.relationship_type_id)).filter(w=>w!==void 0);N.length>0&&(p=Math.min(...N))}const f=a.get(u.id)||null,y=f?$g(i,Em(new Date(f))):null,_=y===null||y>=p,b=_&&y!==null?y-p:0;return{...u,lastPopby:f,daysSinceLastPopby:y,frequencyDays:p,isDue:_,daysOverdue:b}}).sort((u,p)=>p.daysOverdue-u.daysOverdue)},Zat=()=>D_s().filter(s=>s.isDue),R_s=()=>{const t=Qt(),{user:s}=Us();return Pt({mutationFn:async r=>{const{error:n}=await G.from("popby_items").insert({...r,owner_user_id:s==null?void 0:s.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["popby-items"]}),fn({title:"Popby item created!"})},onError:r=>{fn({title:"Error creating popby item",description:r.message,variant:"destructive"})}})},O_s=()=>{const t=Qt(),{user:s}=Us();return Pt({mutationFn:async r=>{const{error:n}=await G.from("popby_logs").insert({...r,owner_user_id:s==null?void 0:s.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["popby-logs"]}),fn({title:"Popby logged!"})},onError:r=>{fn({title:"Error logging popby",description:r.message,variant:"destructive"})}})},F_s=()=>{const t=Qt(),{user:s}=Us();return Pt({mutationFn:async r=>{const{error:n}=await G.from("relationship_type_popby_defaults").upsert({...r,owner_user_id:s==null?void 0:s.id},{onConflict:"relationship_type_id,owner_user_id"});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["relationship-type-popby-defaults"]}),fn({title:"Frequency updated!"})},onError:r=>{fn({title:"Error updating frequency",description:r.message,variant:"destructive"})}})},z_s=()=>{const{data:t}=Mme(30),s=Zat(),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 B_s(){const{user:t}=Us();return gt({queryKey:["contact-touch-logs",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_touch_logs").select("*").order("completed_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function Yat(t){const{data:s}=B_s(),{data:r}=Kat(),{data:n}=OSe(),{data:a}=d_s();return k.useMemo(()=>{const o=a==null?void 0:a.find(w=>w.contact_id===t.id),l=o?new Date(o.snoozed_until):null,i=Em(new Date);if(l&&!YS(l,i))return{nextTouchDate:l,daysUntil:$g(l,i),status:"snoozed",frequencyDays:90,lastTouchDate:null,snoozedUntil:l};const u=((s==null?void 0:s.filter(w=>w.contact_id===t.id))||[]).sort((w,S)=>new Date(S.completed_at).getTime()-new Date(w.completed_at).getTime())[0],p=u?new Date(u.completed_at):null;let f=90;const y=r==null?void 0:r.find(w=>w.contact_id===t.id&&w.is_active);if(y)f=y.frequency_days;else if(t.tags&&t.tags.length>0){const w=t.tags.map(S=>{const C=n==null?void 0:n.find(A=>A.relationship_type_id===S.relationship_type_id);return C==null?void 0:C.frequency_days}).filter(S=>S!==void 0);w.length>0&&(f=Math.min(...w))}if(!p)return{nextTouchDate:null,daysUntil:null,status:"never-touched",frequencyDays:f,lastTouchDate:null,snoozedUntil:null};const _=ml(Em(p),f),b=$g(_,i);let N;return b<0?N="overdue":b<=7?N="due-soon":N="on-track",{nextTouchDate:_,daysUntil:b,status:N,frequencyDays:f,lastTouchDate:p,snoozedUntil:null}},[t,s,r,n,a])}function Awe({contact:t}){const s=Yat(t),n=(()=>{switch(s.status){case"overdue":return{variant:"destructive",icon:ro,text:`${Math.abs(s.daysUntil)} days overdue`,className:""};case"due-soon":return{variant:"secondary",icon:nn,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:$n,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:hh,text:`Snoozed until ${vs(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:cn,text:"Never touched",className:"border-dashed"}}})(),a=n.icon;return e.jsxs(Qe,{variant:n.variant,className:Ot("gap-1",n.className),children:[e.jsx(a,{className:"h-3 w-3"}),n.text]})}function $_s({contact:t,onLogTouch:s,onSnooze:r}){const n=Yat(t),a=h_s(),[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"}},d=()=>{switch(n.status){case"overdue":return e.jsx(ro,{className:"h-5 w-5 text-destructive"});case"due-soon":return e.jsx(nn,{className:"h-5 w-5 text-amber-600 dark:text-amber-400"});case"on-track":return e.jsx($n,{className:"h-5 w-5 text-emerald-600 dark:text-emerald-400"});case"snoozed":return e.jsx(hh,{className:"h-5 w-5 text-slate-600 dark:text-slate-400"});case"never-touched":return e.jsx(cn,{className:"h-5 w-5 text-muted-foreground"})}},u=()=>{switch(n.status){case"overdue":return`${Math.abs(n.daysUntil)} days overdue`;case"due-soon":return n.daysUntil===0?"Due today!":`Due in ${n.daysUntil} days`;case"on-track":return`On track - ${n.daysUntil} days remaining`;case"snoozed":return`Snoozed for ${n.daysUntil} more days`;case"never-touched":return"No touches logged yet"}},p=async()=>{await a.mutateAsync(t.id)};return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(cn,{className:"h-4 w-4"}),"Next Touch"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d(),e.jsx("span",{className:Ot("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:"})," ",vs(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:"})," ",vs(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:"})," ",vs(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(W,{size:"sm",variant:"outline",className:"flex-1",onClick:p,disabled:a.isPending,children:[e.jsx(kr,{className:"h-4 w-4 mr-1"}),"Cancel Snooze"]}),s&&e.jsx(W,{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(W,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>l(!0),children:[e.jsx(hh,{className:"h-4 w-4 mr-1"}),"Snooze"]}),(n.status==="overdue"||n.status==="due-soon"||n.status==="never-touched")&&s&&e.jsx(W,{size:"sm",className:"flex-1",variant:n.status==="overdue"?"default":"outline",onClick:s,children:"Log Touch"})]})]})]}),e.jsx(kme,{open:o,onOpenChange:l,contactId:t.id,contactName:`${t.first_name} ${t.last_name||""}`.trim()})]})}const c0e=768;function bE(){const[t,s]=k.useState(void 0);return k.useEffect(()=>{const r=window.matchMedia(`(max-width: ${c0e-1}px)`),n=()=>{s(window.innerWidthr.removeEventListener("change",n)},[]),!!t}function q_s(){const{user:t}=Us(),{hasLeadSite:s,leadSite:r}=CC(),{data:n,isLoading:a}=gt({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 G.from("lead_site_visitors").select("contact_id").eq("lead_site_id",r.id).not("contact_id","is",null),{data:l}=await G.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(d=>{d.contact_id&&i.add(d.contact_id)}),(l||[]).forEach(d=>{d.contact_id&&i.add(d.contact_id)}),i},enabled:!!t&&s,staleTime:5*60*1e3});return{activeContactIds:n??new Set,hasLeadSite:s,isLoading:a}}const U_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"}},V_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 M8({score:t,showScore:s=!1,showTooltip:r=!0,size:n="sm",className:a}){const o=U_s[t.status],l=V_s[n],i=e.jsxs("div",{className:Ot("inline-flex items-center rounded-full font-medium",o.bgLightClass,o.textClass,l.badge,l.text,a),children:[e.jsx("span",{className:Ot("rounded-full",o.bgClass,l.dot)}),s?e.jsx("span",{children:t.score}):e.jsx("span",{children:o.label})]});return r?e.jsx(S1,{children:e.jsxs(ec,{children:[e.jsx(tc,{asChild:!0,children:i}),e.jsx(Dl,{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:Ot("font-bold",o.textClass),children:[t.score,"/100"]})]}),e.jsx(xi,{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 H_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}],_9=t=>{if(!t||!t.trim())return null;const s=t.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(s))return s;const r=s.match(/^(\d{1,2})[\/\-](\d{1,2})(?:[\/\-](\d{2,4}))?$/);if(r){const a=r[1].padStart(2,"0"),o=r[2].padStart(2,"0");let l="2000";r[3]&&(l=r[3].length===2?(parseInt(r[3])>50?"19":"20")+r[3]:r[3]);const i=parseInt(a),d=parseInt(o);if(i>=1&&i<=12&&d>=1&&d<=31)return`${l}-${a}-${o}`}const n=new Date(s);return isNaN(n.getTime())?null:n.toISOString().split("T")[0]},G_s=({open:t,onOpenChange:s,relationshipTypes:r,onSuccess:n})=>{const{user:a}=Us(),{toast:o}=ja(),l=k.useRef(null),[i,d]=k.useState("upload"),[u,p]=k.useState([]),[f,y]=k.useState([]),[_,b]=k.useState({}),[N,w]=k.useState([]),[S,C]=k.useState([]),[A,I]=k.useState(!1),[L,O]=k.useState(null),V=()=>{d("upload"),p([]),y([]),b({}),w([]),C([]),O(null),l.current&&(l.current.value="")},q=()=>{V(),s(!1)},B=ve=>{const he=ve.split(` `).map(Me=>Me.trim()).filter(Me=>Me);if(he.length===0)return{headers:[],data:[]};const ge=Me=>{const ke=[];let Re="",Ve=!1;for(let Ne=0;Ne{var je;const he=(je=ve.target.files)==null?void 0:je[0];if(!he)return;const ge=new FileReader;ge.onload=qe=>{var Ne;const Me=(Ne=qe.target)==null?void 0:Ne.result,{headers:ke,data:Re}=B(Me);if(ke.length===0){o({title:"No data found",description:"The CSV file appears to be empty.",variant:"destructive"});return}p(ke),y(Re);const Ve={};ke.forEach(Ue=>{const Ie=Ue.toLowerCase().replace(/[_\s-]/g,"");Ie.includes("firstname")||Ie==="first"?Ve.first_name=Ue:Ie.includes("lastname")||Ie==="last"?Ve.last_name=Ue:Ie.includes("spouse")&&Ie.includes("email")?Ve.spouse_email=Ue:Ie.includes("spouse")||Ie.includes("partner")?Ve.spouse_name=Ue:Ie.includes("email")?Ve.email=Ue:Ie.includes("phone")||Ie.includes("mobile")||Ie.includes("cell")?Ve.phone=Ue:Ie.includes("address")||Ie.includes("street")?Ve.address=Ue:Ie==="city"?Ve.city=Ue:Ie==="state"||Ie==="province"?Ve.state=Ue:Ie==="zip"||Ie==="zipcode"||Ie==="postalcode"?Ve.zip=Ue:Ie.includes("company")||Ie.includes("organization")||Ie.includes("business")?Ve.company_name=Ue:Ie.includes("jobtitle")||Ie.includes("title")&&!Ie.includes("spouse")?Ve.job_title=Ue:Ie.includes("birthday")||Ie.includes("dob")||Ie.includes("birthdate")?Ve.birthday=Ue:Ie.includes("anniversary")||Ie.includes("homeanniversary")?Ve.home_anniversary=Ue:(Ie.includes("notes")||Ie.includes("comment"))&&(Ve.notes=Ue)}),b(Ve),d("mapping")},ge.readAsText(he)},te=(ve,he)=>{b(ge=>{if(he==="none"){const{[ve]:je,...qe}=ge;return qe}return{...ge,[ve]:he}})},Y=ve=>{w(he=>he.includes(ve)?he.filter(ge=>ge!==ve):[...he,ve])},J=async()=>{if(!(a!=null&&a.id))return;const{data:ve}=await G.from("innercircle_contacts").select("id, email, phone").eq("owner_user_id",a.id),he=new Set((ve||[]).filter(qe=>qe.email).map(qe=>qe.email.toLowerCase())),ge=new Set((ve||[]).filter(qe=>qe.phone).map(qe=>qe.phone.replace(/[^0-9]/g,""))),je=f.map(qe=>{const Me=Ie=>{const ye=_[Ie];if(!ye)return"";const ct=u.indexOf(ye);return ct>=0?(qe[ct]||"").trim():""},ke=Me("first_name"),Re=Me("email"),Ve=Me("phone"),Ne=ke.length>0,Ue=!!(Re&&he.has(Re.toLowerCase())||Ve&&ge.has(Ve.replace(/[^0-9]/g,"")));return{first_name:ke,last_name:Me("last_name"),email:Re,phone:Ve,address:Me("address"),city:Me("city"),state:Me("state"),zip:Me("zip"),spouse_name:Me("spouse_name"),spouse_email:Me("spouse_email"),company_name:Me("company_name"),job_title:Me("job_title"),birthday:Me("birthday"),home_anniversary:Me("home_anniversary"),notes:Me("notes"),isValid:Ne,isDuplicate:Ue,error:Ne?void 0:"First name is required"}});C(je),d("preview")},X=ve=>{const he=ve.trim().split(/\s+/);return{first_name:he[0],last_name:he.length>1?he.slice(1).join(" "):null}},ce=async()=>{if(!(a!=null&&a.id))return;const ve=S.filter(qe=>qe.isValid);if(ve.length===0){o({title:"No valid contacts",description:"There are no valid contacts to import.",variant:"destructive"});return}I(!0);let he=0,ge=0,je=0;try{for(const qe of ve)try{let Me=null;if(qe.email){const{data:Ve}=await G.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",qe.email).maybeSingle();Me=Ve}if(!Me&&qe.phone){const Ve=qe.phone.replace(/[^0-9]/g,""),{data:Ne}=await G.from("innercircle_contacts").select("id, phone").eq("owner_user_id",a.id).not("phone","is",null);if(Ne){const Ue=Ne.find(Ie=>Ie.phone&&Ie.phone.replace(/[^0-9]/g,"")===Ve);Ue&&(Me={id:Ue.id})}}const ke={owner_user_id:a.id,first_name:qe.first_name,last_name:qe.last_name||null,email:qe.email||null,phone:qe.phone||null,address:qe.address||null,city:qe.city||null,state:qe.state||null,zip:qe.zip||null,spouse_name:qe.spouse_name||null,spouse_email:qe.spouse_email||null,company_name:qe.company_name||null,job_title:qe.job_title||null,birthday:_9(qe.birthday),home_anniversary:_9(qe.home_anniversary),notes:qe.notes||null};let Re=null;if(Me){const{data:Ve}=await G.from("innercircle_contacts").select("*").eq("id",Me.id).single();if(Ve){const Ne={},Ue=["last_name","email","phone","address","city","state","zip","spouse_name","spouse_email","company_name","job_title","birthday","home_anniversary","notes"];for(const Ie of Ue){const ye=Ve[Ie],ct=ke[Ie];(!ye||ye==="")&&ct&&(Ne[Ie]=ct)}Object.keys(Ne).length>0&&await G.from("innercircle_contacts").update(Ne).eq("id",Me.id)}Re=Me.id,ge++}else{const{data:Ve,error:Ne}=await G.from("innercircle_contacts").insert(ke).select("id").single();Ne?(console.error("Insert error for contact:",qe.first_name,Ne),je++):Ve?(Re=Ve.id,N.length>0&&await G.from("innercircle_contact_tags").insert(N.map(Ue=>({contact_id:Ve.id,relationship_type_id:Ue}))),he++):je++}if(Re&&qe.spouse_name){const Ve=X(qe.spouse_name);let Ne=null;if(qe.spouse_email){const{data:Ie}=await G.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",qe.spouse_email).maybeSingle();Ne=Ie}if(!Ne){const{data:Ie}=await G.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("first_name",Ve.first_name).eq("last_name",Ve.last_name||qe.last_name||"").maybeSingle();Ne=Ie}let Ue=null;if(Ne){Ue=Ne.id;const Ie=_9(qe.home_anniversary);Ie&&await G.from("innercircle_contacts").update({home_anniversary:Ie}).eq("id",Ne.id).is("home_anniversary",null)}else{const{data:Ie}=await G.from("innercircle_contacts").insert({owner_user_id:a.id,first_name:Ve.first_name,last_name:Ve.last_name||qe.last_name||null,email:qe.spouse_email||null,address:qe.address||null,city:qe.city||null,state:qe.state||null,zip:qe.zip||null,home_anniversary:_9(qe.home_anniversary),spouse_name:`${qe.first_name}${qe.last_name?" "+qe.last_name:""}`,spouse_email:qe.email||null,notes:`Spouse of ${qe.first_name} ${qe.last_name||""} (imported via CSV)`.trim()}).select("id").single();Ie&&(Ue=Ie.id,he++)}Ue&&(await G.from("innercircle_contacts").update({spouse_contact_id:Ue}).eq("id",Re),await G.from("innercircle_contacts").update({spouse_contact_id:Re}).eq("id",Ue))}}catch(Me){console.error("Error importing contact:",Me),je++}O({created:he,updated:ge,failed:je}),d("result"),(he>0||ge>0)&&n(),o({title:"Import Complete",description:`${he} created, ${ge} updated${je>0?`, ${je} failed`:""}.`})}catch(qe){console.error("Import error:",qe),o({title:"Import Failed",description:qe.message||"Failed to import contacts",variant:"destructive"})}finally{I(!1)}},ie=S.filter(ve=>ve.isValid).length,ae=S.filter(ve=>!ve.isValid).length,oe=S.filter(ve=>ve.isValid&&ve.isDuplicate).length,me=ie-oe;return e.jsx(fs,{open:t,onOpenChange:q,children:e.jsxs(ps,{className:"max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(Zv,{className:"h-5 w-5"}),"Import Contacts from CSV"]}),e.jsx(Ir,{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:U,className:"hidden"}),e.jsx(Ra,{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(W,{onClick:()=>{var ve;return(ve=l.current)==null?void 0:ve.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(W,{variant:"outline",size:"sm",onClick:()=>{const ve=`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`,he=new Blob([ve],{type:"text/csv"}),ge=URL.createObjectURL(he),je=document.createElement("a");je.href=ge,je.download="contact_import_template.csv",je.click(),URL.revokeObjectURL(ge)},children:[e.jsx(Qa,{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(xe,{className:"text-base font-medium",children:"Map CSV Columns to Contact Fields"}),e.jsx("div",{className:"grid gap-3",children:H_s.map(ve=>e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(xe,{className:"w-40 text-sm",children:[ve.label,ve.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs($s,{value:_[ve.key]||"none",onValueChange:he=>te(ve.key,he),children:[e.jsx(zs,{className:"w-48",children:e.jsx(Vs,{placeholder:"Select column..."})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"none",children:"-- Not mapped --"}),u.map(he=>e.jsx(vt,{value:he,children:he},he))]})]})]},ve.key))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(xe,{className:"text-base font-medium",children:"Apply Relationship Types (optional)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(ve=>e.jsx(Qe,{variant:N.includes(ve.id)?"default":"outline",className:"cursor-pointer",onClick:()=>Y(ve.id),children:ve.name},ve.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($n,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{children:[me," new"]})]}),oe>0&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(ro,{className:"h-4 w-4"}),e.jsxs("span",{children:[oe," existing (will merge gaps)"]})]}),ae>0&&e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(ro,{className:"h-4 w-4"}),e.jsxs("span",{children:[ae," 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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{className:"bg-muted/30",children:[e.jsx(St,{children:"First Name"}),e.jsx(St,{children:"Last Name"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Phone"}),e.jsx(St,{children:"Status"})]})}),e.jsx(Rn,{children:S.slice(0,100).map((ve,he)=>e.jsxs(Ps,{children:[e.jsx(ht,{children:ve.first_name}),e.jsx(ht,{children:ve.last_name}),e.jsx(ht,{children:ve.email}),e.jsx(ht,{children:ve.phone}),e.jsx(ht,{children:ve.isValid?ve.isDuplicate?e.jsx(Qe,{variant:"outline",className:"bg-accent text-accent-foreground",children:"Merge"}):e.jsx(Qe,{variant:"secondary",className:"bg-primary/10 text-primary",children:"New"}):e.jsx(Qe,{variant:"destructive",children:ve.error||"Invalid"})})]},he))})]}),S.length>100&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-2",children:["Showing first 100 of ",S.length," contacts"]})]})]}),i==="result"&&L&&e.jsxs("div",{className:"space-y-4 py-4 text-center",children:[e.jsx($n,{className:"h-12 w-12 mx-auto text-primary"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Import Complete"}),e.jsxs("p",{className:"text-muted-foreground",children:[L.created," created, ",L.updated," merged"]}),L.failed>0&&e.jsxs("p",{className:"text-destructive",children:[L.failed," failed to import"]})]}),e.jsxs(gn,{children:[i==="upload"&&e.jsx(W,{variant:"outline",onClick:q,children:"Cancel"}),i==="mapping"&&e.jsxs(e.Fragment,{children:[e.jsx(W,{variant:"outline",onClick:V,children:"Back"}),e.jsx(W,{onClick:J,disabled:!_.first_name,children:"Continue"})]}),i==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(W,{variant:"outline",onClick:()=>d("mapping"),children:"Back"}),e.jsx(W,{onClick:ce,disabled:A||ie===0,children:A?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${ie} Contact${ie!==1?"s":""}`})]}),i==="result"&&e.jsx(W,{onClick:q,children:"Done"})]})]})})};function W_s(){return"contacts"in navigator&&"ContactsManager"in window}function K_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="",d="",u="";for(const p of a){const f=p.replace(/^\s+/,"");if(f.startsWith("N:")||f.startsWith("N;")){const _=f.substring(f.indexOf(":")+1).split(";");l=(_[0]||"").trim(),o=(_[1]||"").trim()}if((f.startsWith("FN:")||f.startsWith("FN;"))&&!o){const _=f.substring(f.indexOf(":")+1).trim().split(" ");o=_[0]||"",l=_.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))&&!d&&(d=f.substring(f.indexOf(":")+1).trim()),(f.startsWith("ADR")||f.match(/^item\d+\.ADR/i))&&!u&&(u=f.substring(f.indexOf(":")+1).split(";").map(b=>b.trim()).filter(Boolean).join(", "))}(o||l)&&s.push({first_name:o,last_name:l,email:i,phone:d,address:u})}return s}function Z_s({open:t,onOpenChange:s,onComplete:r}){Us();const{data:n}=qh(),a=nhe(),o=k.useRef(null),[l,i]=k.useState("choose"),[d,u]=k.useState([]),[p,f]=k.useState(new Set),[y,_]=k.useState(0),[b,N]=k.useState(0),w=W_s(),S=k.useCallback(U=>{if(!n)return U;const te=new Set(n.filter(J=>J.email).map(J=>J.email.toLowerCase())),Y=new Set(n.filter(J=>J.phone).map(J=>J.phone.replace(/\D/g,"")));return U.map(J=>{var ie,ae;const X=(ie=J.email)==null?void 0:ie.toLowerCase(),ce=(ae=J.phone)==null?void 0:ae.replace(/\D/g,"");return X&&te.has(X)?{...J,isDuplicate:!0,duplicateField:"email"}:ce&&ce.length>=7&&Y.has(ce)?{...J,isDuplicate:!0,duplicateField:"phone"}:J})},[n]),C=async()=>{try{const U=["name","email","tel","address"],te=await navigator.contacts.select(U,{multiple:!0});if(!te||te.length===0)return;const Y=te.map(ce=>{var oe,me,ve,he;const ae=(((oe=ce.name)==null?void 0:oe[0])||"").split(" ");return{first_name:ae[0]||"",last_name:ae.slice(1).join(" "),email:((me=ce.email)==null?void 0:me[0])||"",phone:((ve=ce.tel)==null?void 0:ve[0])||"",address:(he=ce.address)!=null&&he[0]?[ce.address[0].streetAddress,ce.address[0].city,ce.address[0].region,ce.address[0].postalCode].filter(Boolean).join(", "):""}}),J=S(Y);u(J);const X=new Set;J.forEach((ce,ie)=>{ce.isDuplicate||X.add(ie)}),f(X),i("preview")}catch(U){console.error("Contact Picker error:",U),fn({title:"Could not access contacts",description:"Please try the file upload option instead.",variant:"destructive"})}},A=U=>{var J;const te=(J=U.target.files)==null?void 0:J[0];if(!te)return;const Y=new FileReader;Y.onload=X=>{var me;const ce=(me=X.target)==null?void 0:me.result,ie=K_s(ce);if(ie.length===0){fn({title:"No contacts found",description:"The file didn't contain any valid contacts.",variant:"destructive"});return}const ae=S(ie);u(ae);const oe=new Set;ae.forEach((ve,he)=>{ve.isDuplicate||oe.add(he)}),f(oe),i("preview")},Y.readAsText(te),o.current&&(o.current.value="")},I=async()=>{const U=d.filter((Y,J)=>p.has(J));if(U.length===0)return;i("importing");let te=0;for(const Y of U)try{await a.mutateAsync({first_name:Y.first_name,last_name:Y.last_name||void 0,email:Y.email||void 0,phone:Y.phone||void 0,address:Y.address||void 0}),te++,N(Math.round(te/U.length*100))}catch(J){console.error(`Failed to import ${Y.first_name} ${Y.last_name}:`,J)}_(te),i("done")},L=U=>{f(te=>{const Y=new Set(te);return Y.has(U)?Y.delete(U):Y.add(U),Y})},O=()=>{p.size===d.length?f(new Set):f(new Set(d.map((U,te)=>te)))},V=U=>{U||(i("choose"),u([]),f(new Set),_(0),N(0),l==="done"&&r()),s(U)},q=d.filter(U=>U.isDuplicate).length,B=p.size;return e.jsx(fs,{open:t,onOpenChange:V,children:e.jsxs(ps,{className:"sm:max-w-lg max-h-[90vh]",children:[e.jsxs(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(Ig,{className:"h-5 w-5 text-primary"}),l==="choose"&&"Import Phone Contacts",l==="preview"&&"Select Contacts to Import",l==="importing"&&"Importing Contacts...",l==="done"&&"Import Complete"]}),l==="choose"&&e.jsx(Ir,{children:"Add contacts from your phone directly into Agent OS."})]}),l==="choose"&&e.jsxs("div",{className:"space-y-4 pt-2",children:[w&&e.jsxs(W,{onClick:C,className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(Ig,{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:[w&&e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),w&&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(W,{variant:w?"outline":"default",onClick:()=>{var U;return(U=o.current)==null?void 0:U.click()},className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(Ra,{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:w?"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:o,type:"file",accept:".vcf,.vcard",onChange:A,className:"hidden"}),!w&&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"})]})]})]}),l==="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:[d.length," contact",d.length!==1?"s":""," found",q>0&&e.jsxs("span",{className:"text-amber-600 ml-1",children:["(",q," already exist)"]})]}),e.jsx(W,{variant:"ghost",size:"sm",onClick:O,children:p.size===d.length?"Deselect All":"Select All"})]}),e.jsx(Ja,{className:"h-[350px] rounded-md border",children:e.jsx("div",{className:"divide-y",children:d.map((U,te)=>e.jsxs("div",{className:`flex items-start gap-3 p-3 cursor-pointer hover:bg-accent/50 transition-colors ${U.isDuplicate?"opacity-60":""}`,onClick:()=>L(te),children:[e.jsx(Ri,{checked:p.has(te),onCheckedChange:()=>L(te),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:[U.first_name," ",U.last_name]}),U.isDuplicate&&e.jsxs(Qe,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-amber-500/10 text-amber-600 border-amber-200",children:["Exists (",U.duplicateField,")"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5 mt-0.5",children:[U.phone&&e.jsx("div",{children:U.phone}),U.email&&e.jsx("div",{className:"truncate",children:U.email})]})]})]},te))})}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>i("choose"),children:"Back"}),e.jsxs(W,{onClick:I,disabled:B===0,children:["Import ",B," Contact",B!==1?"s":""]})]})]}),l==="importing"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx(us,{className:"h-8 w-8 animate-spin text-primary"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:"Importing contacts..."}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[b,"% 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:`${b}%`}})})]}),l==="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(Zn,{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(W,{onClick:()=>V(!1),className:"mt-2",children:"Done"})]})]})})}function FSe(){const t=ya();return gt({queryKey:["drip-campaigns",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.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 Y_s(t){return gt({queryKey:["drip-campaign",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("drip_campaigns").select("*").eq("id",t).maybeSingle();if(r)throw r;return s},enabled:!!t})}function X_s(){const t=ya(),s=Qt();return Pt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.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 Xat(){const t=Qt();return Pt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.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 Q_s(){const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("drip_campaigns").delete().eq("id",s);if(r)throw r},onSuccess:()=>t.invalidateQueries({queryKey:["drip-campaigns"]})})}function J_s(){const t=ya(),s=Qt();return Pt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const[{data:n,error:a},{data:o,error:l}]=await Promise.all([G.from("drip_campaigns").select("*").eq("id",r).single(),G.from("drip_campaign_steps").select("*").eq("campaign_id",r).order("step_order")]);if(a)throw a;if(l)throw l;const{data:i,error:d}=await G.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(d)throw d;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:p}=await G.from("drip_campaign_steps").insert(u);if(p)throw p}return i},onSuccess:()=>s.invalidateQueries({queryKey:["drip-campaigns"]})})}function Qat(t){return gt({queryKey:["drip-campaign-steps",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("drip_campaign_steps").select("*").eq("campaign_id",t).order("step_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function ebs(){const t=Qt();return Pt({mutationFn:async s=>{const{data:r,error:n}=await G.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 tbs(){const t=Qt();return Pt({mutationFn:async({id:s,campaign_id:r,...n})=>{const{data:a,error:o}=await G.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 sbs(){const t=Qt();return Pt({mutationFn:async({id:s,campaign_id:r})=>{const{error:n}=await G.from("drip_campaign_steps").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>t.invalidateQueries({queryKey:["drip-campaign-steps",s]})})}function rbs(t){return gt({queryKey:["campaign-enrollments",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.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 nbs(t){return gt({queryKey:["campaign-enrollment-count",t],queryFn:async()=>{if(!t)return 0;const{count:s,error:r}=await G.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 Jat(){const t=Qt();return Pt({mutationFn:async({campaignId:s,contactIds:r})=>{const{data:n,error:a}=await G.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 abs(){const t=Qt();return Pt({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 G.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 ibs=[{key:"{{client_first_name}}",label:"Client First Name"},{key:"{{client_last_name}}",label:"Client Last Name"},{key:"{{agent_name}}",label:"Your Name"},{key:"{{agent_first_name}}",label:"Your First Name"},{key:"{{agent_phone}}",label:"Your Phone"},{key:"{{review_link}}",label:"Review Link"},{key:"{{lead_site_url}}",label:"Your Website"},{key:"{{lead_site_search_url}}",label:"Your Website — Search"},{key:"{{lead_site_valuation_url}}",label:"Your Website — Home Value"},{key:"{{lead_site_blog_url}}",label:"Your Website — Blog"}],Tme={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"},obs={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"},lbs=["🌱","💎","🏠","🔑","📧","💌","🎂","🥂","🤝","⭐","🎉","📞"];function eit({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,d=!!i,{data:u}=Y_s(i||void 0),{data:p,isLoading:f}=Qat(i||void 0),y=X_s(),_=Xat(),b=ebs(),[N,w]=k.useState(""),[S,C]=k.useState(""),[A,I]=k.useState("nurture"),[L,O]=k.useState("🌱"),[V,q]=k.useState("");k.useEffect(()=>{u?(w(u.name),C(u.description||""),I(u.category),O(u.icon),q(u.goal||"")):d||(w(""),C(""),I("nurture"),O("🌱"),q(""))},[u,d,t]);const B=obs[A],U=async()=>{if(!N.trim()){pe.error("Give your campaign a name");return}try{if(d&&i)await _.mutateAsync({id:i,name:N,description:S,category:A,icon:L,goal:V,cover_color:B}),pe.success("Campaign updated");else{const Y=await y.mutateAsync({name:N,description:S,category:A,icon:L,goal:V,cover_color:B});return pe.success("Campaign created — now add your first step!"),a(Y.id),l("steps"),Y}}catch(Y){pe.error(Y.message||"Failed to save")}},te=async()=>{if(!i){pe.error("Save the campaign first, then add steps");return}const Y=((p==null?void 0:p.length)||0)+1;try{await b.mutateAsync({campaign_id:i,step_order:Y,channel:"email",subject:"",body:"",delay_type:"relative",delay_days:Y===1?0:2,delay_hours:0})}catch{pe.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 ${B} 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:L}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(_s,{className:"text-lg font-bold text-white",children:d?"Edit Campaign":"Create New Campaign"}),e.jsx(Ir,{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(ta,{value:o,onValueChange:Y=>l(Y),className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs(Jn,{className:"mx-5 mt-4 grid grid-cols-2 w-fit",children:[e.jsx(cs,{value:"details",children:"Details"}),e.jsxs(cs,{value:"steps",disabled:!d,children:["Steps ",p&&p.length>0&&e.jsx(Qe,{variant:"secondary",className:"ml-1.5 text-[10px]",children:p.length})]})]}),e.jsx(Ss,{value:"details",className:"flex-1 overflow-hidden mt-0",children:e.jsx(Ja,{className:"h-full",children:e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Campaign Name *"}),e.jsx(De,{value:N,onChange:Y=>w(Y.target.value),placeholder:"e.g. New Buyer Lead — 7 Touch Nurture",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Description"}),e.jsx(_r,{value:S,onChange:Y=>C(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(xe,{className:"text-xs",children:"Goal (optional)"}),e.jsx(De,{value:V,onChange:Y=>q(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(xe,{className:"text-xs",children:"Category"}),e.jsxs($s,{value:A,onValueChange:Y=>I(Y),children:[e.jsx(zs,{className:"mt-1",children:e.jsx(Vs,{})}),e.jsx(Bs,{children:Object.entries(Tme).map(([Y,J])=>e.jsx(vt,{value:Y,children:J},Y))})]})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Icon"}),e.jsx("div",{className:"flex gap-1.5 flex-wrap mt-1",children:lbs.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 ${L===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:d?"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(Ss,{value:"steps",className:"flex-1 overflow-hidden mt-0",children:e.jsx(Ja,{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…"}):!p||p.length===0?e.jsxs("div",{className:"text-center py-10 border border-dashed rounded-xl",children:[e.jsx(Or,{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(W,{size:"sm",onClick:te,disabled:b.isPending,children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1.5"})," Add first step"]})]}):e.jsxs(e.Fragment,{children:[p.map((Y,J)=>e.jsx(cbs,{step:Y,index:J,totalSteps:p.length},Y.id)),e.jsxs(W,{variant:"outline",size:"sm",onClick:te,disabled:b.isPending,className:"w-full",children:[b.isPending?e.jsx(us,{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(gn,{className:"border-t p-4 shrink-0",children:[e.jsx(W,{variant:"outline",onClick:()=>s(!1),children:d?"Done":"Cancel"}),e.jsxs(W,{onClick:U,disabled:y.isPending||_.isPending,children:[(y.isPending||_.isPending)&&e.jsx(us,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),d?"Save Changes":"Create Campaign"]})]})]})})}function cbs({step:t,index:s,totalSteps:r}){const n=tbs(),a=sbs(),[o,l]=k.useState(!1),[i,d]=k.useState(t),[u,p]=k.useState(!1);k.useEffect(()=>d(t),[t]);const f=JSON.stringify(i)!==JSON.stringify(t),y=async()=>{p(!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}),pe.success(`Step ${s+1} saved`)}catch{pe.error("Failed to save step")}finally{p(!1)}},_=async()=>{if(confirm(`Delete step ${s+1}?`))try{await a.mutateAsync({id:t.id,campaign_id:t.campaign_id}),pe.success("Step deleted")}catch{pe.error("Failed to delete")}},b=w=>{d({...i,body:i.body+w})},N=()=>{if(i.delay_type==="calendar_anchor"){const S=i.anchor_field==="birthday"?"birthday":"home anniversary",C=i.anchor_offset_days||0;return C===0?`On their ${S}`:C<0?`${Math.abs(C)}d before ${S}`:`${C}d after ${S}`}if(s===0&&!i.delay_days&&!i.delay_hours)return"Sends immediately";const w=[];return i.delay_days&&w.push(`${i.delay_days}d`),i.delay_hours&&w.push(`${i.delay_hours}h`),s===0?`After ${w.join(" ")||"0"}`:`+${w.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(cn,{className:"h-3 w-3"}):e.jsx(nn,{className:"h-3 w-3"}),e.jsx("span",{children:N()}),e.jsx("span",{children:"·"}),i.channel==="email"?e.jsx(tr,{className:"h-3 w-3"}):e.jsx(wi,{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(af,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Bi,{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(xe,{className:"text-xs",children:"Channel"}),e.jsxs($s,{value:i.channel,onValueChange:w=>d({...i,channel:w}),children:[e.jsx(zs,{className:"mt-1 h-9",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"email",children:"📧 Email"}),e.jsx(vt,{value:"sms",children:"💬 SMS"})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Timing Type"}),e.jsxs($s,{value:i.delay_type,onValueChange:w=>d({...i,delay_type:w}),children:[e.jsx(zs,{className:"mt-1 h-9",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"relative",children:"⏱ Relative delay"}),e.jsx(vt,{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(xe,{className:"text-xs",children:"Days delay"}),e.jsx(De,{type:"number",min:0,value:i.delay_days,onChange:w=>d({...i,delay_days:parseInt(w.target.value)||0}),className:"mt-1 h-9"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Hours delay"}),e.jsx(De,{type:"number",min:0,max:23,value:i.delay_hours,onChange:w=>d({...i,delay_hours:parseInt(w.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(xe,{className:"text-xs",children:"Anchor"}),e.jsxs($s,{value:i.anchor_field||"birthday",onValueChange:w=>d({...i,anchor_field:w}),children:[e.jsx(zs,{className:"mt-1 h-9",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"birthday",children:"🎂 Birthday"}),e.jsx(vt,{value:"home_anniversary",children:"🏠 Home Anniversary"})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Offset (days, negative = before)"}),e.jsx(De,{type:"number",value:i.anchor_offset_days||0,onChange:w=>d({...i,anchor_offset_days:parseInt(w.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(xe,{className:"text-xs",children:"Subject Line"}),e.jsx(De,{value:i.subject,onChange:w=>d({...i,subject:w.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(xe,{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(_r,{value:i.body,onChange:w=>d({...i,body:w.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:"}),ibs.map(w=>e.jsx("button",{type:"button",onClick:()=>b(w.key),className:"text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary hover:bg-primary/20",children:w.label},w.key))]})]}),i.channel==="email"&&e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Video URL (optional)"}),e.jsx(De,{value:i.video_url||"",onChange:w=>d({...i,video_url:w.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(W,{variant:"ghost",size:"sm",onClick:_,className:"text-destructive hover:text-destructive",children:[e.jsx(vr,{className:"h-3.5 w-3.5 mr-1"})," Delete step"]}),e.jsxs(W,{size:"sm",onClick:y,disabled:!f||u,children:[u&&e.jsx(us,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Save step"]})]})]})]})}function dbs({open:t,onOpenChange:s,contactIds:r,onSuccess:n}){const{data:a,isLoading:o}=FSe(),l=Jat(),[i,d]=k.useState(""),[u,p]=k.useState(null),[f,y]=k.useState(!1),_=(a||[]).filter(w=>!w.is_starter),b=_.filter(w=>w.name.toLowerCase().includes(i.toLowerCase())||(w.description||"").toLowerCase().includes(i.toLowerCase())),N=async()=>{if(u)try{const w=await l.mutateAsync({campaignId:u,contactIds:r}),S=[`${w.enrolled} enrolled`];w.skipped>0&&S.push(`${w.skipped} skipped`),w.errors>0&&S.push(`${w.errors} errors`),pe.success(S.join(" · ")),s(!1),p(null),n==null||n()}catch(w){pe.error(w.message||"Failed to enroll contacts")}};return e.jsxs(fs,{open:t,onOpenChange:s,children:[e.jsxs(ps,{className:"max-w-md",children:[e.jsxs(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(Or,{className:"h-4 w-4 text-primary"}),"Enroll in Drip Campaign"]}),e.jsxs(Ir,{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(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(De,{placeholder:"Search campaigns...",value:i,onChange:w=>d(w.target.value),className:"pl-9 h-9"})]}),e.jsx(Ja,{className:"h-[320px] -mx-1 px-1",children:o?e.jsx("div",{className:"text-center py-8 text-sm text-muted-foreground",children:"Loading..."}):b.length===0?e.jsx("div",{className:"text-center py-8",children:_.length===0?e.jsxs(e.Fragment,{children:[e.jsx(Or,{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(W,{size:"sm",onClick:()=>y(!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:b.map(w=>e.jsxs("button",{onClick:()=>p(w.id),className:`w-full flex items-start gap-3 p-3 rounded-lg border text-left transition-all ${u===w.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 ${w.cover_color} flex items-center justify-center text-lg`,children:w.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:w.name}),w.is_active&&e.jsx(Qe,{variant:"outline",className:"text-[9px] bg-emerald-500/10 text-emerald-600 border-emerald-200 px-1 py-0",children:"Active"})]}),w.description&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-0.5",children:w.description})]}),u===w.id&&e.jsx(Zn,{className:"h-4 w-4 text-primary shrink-0 mt-1"})]},w.id))})})]}),e.jsxs(gn,{className:"gap-2 sm:gap-2",children:[_.length>0&&e.jsxs(W,{variant:"ghost",size:"sm",onClick:()=>y(!0),className:"mr-auto text-xs",children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1"})," New campaign"]}),e.jsx(W,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(W,{onClick:N,disabled:!u||l.isPending,children:[l.isPending&&e.jsx(us,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Enroll ",r.length," contact",r.length!==1?"s":""]})]})]}),e.jsx(eit,{open:f,onOpenChange:y})]})}function _O(){const t=ya();return gt({queryKey:["custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_custom_tags").select("*").eq("owner_user_id",t).order("name");if(r)throw r;return s},enabled:!!t})}function ubs(t){return gt({queryKey:["contact-custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_custom_tag_assignments").select("*, tag:contact_custom_tags(*)").eq("contact_id",t);if(r)throw r;return s},enabled:!!t})}function zSe(){const t=Qt(),s=ya();return Pt({mutationFn:async({name:r,color:n})=>{const{data:a,error:o}=await G.from("contact_custom_tags").insert({owner_user_id:s,name:r.trim(),color:n||"#6366F1"}).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["custom-tags"]})}})}function hbs(){const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("contact_custom_tags").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["custom-tags"]}),t.invalidateQueries({queryKey:["contact-custom-tags"]}),t.invalidateQueries({queryKey:["all-contact-custom-tags"]})}})}function mbs(){const t=Qt();return Pt({mutationFn:async({id:s,name:r,color:n})=>{const a={};r!==void 0&&(a.name=r.trim()),n!==void 0&&(a.color=n);const{error:o}=await G.from("contact_custom_tags").update(a).eq("id",s);if(o)throw o},onSuccess:()=>{t.invalidateQueries({queryKey:["custom-tags"]}),t.invalidateQueries({queryKey:["contact-custom-tags"]}),t.invalidateQueries({queryKey:["all-contact-custom-tags"]})}})}function tit(){const t=Qt();return Pt({mutationFn:async({contactId:s,tagId:r})=>{const{error:n}=await G.from("contact_custom_tag_assignments").insert({contact_id:s,tag_id:r});if(n)throw n},onSuccess:(s,{contactId:r})=>{t.invalidateQueries({queryKey:["contact-custom-tags",r]}),t.invalidateQueries({queryKey:["all-contact-custom-tags"]})}})}function pbs(){const t=Qt();return Pt({mutationFn:async({contactId:s,tagId:r})=>{const{error:n}=await G.from("contact_custom_tag_assignments").delete().eq("contact_id",s).eq("tag_id",r);if(n)throw n},onSuccess:(s,{contactId:r})=>{t.invalidateQueries({queryKey:["contact-custom-tags",r]}),t.invalidateQueries({queryKey:["all-contact-custom-tags"]})}})}function sit(){const t=ya();return gt({queryKey:["all-contact-custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_custom_tag_assignments").select("contact_id, tag_id, tag:contact_custom_tags(id, name, color)");if(r)throw r;return s},enabled:!!t})}function fbs({selectedIds:t,contacts:s,onClearSelection:r,onSendToLeadPond:n,showLeadPondAction:a,onTransfer:o,showTransferAction:l}){const i=wr(),{data:d}=Nf(),u=ike(),p=Qt(),{isGmailConnected:f}=Om(),{isReady:y}=Sme(),{data:_}=_O(),b=zSe(),N=tit(),[w,S]=k.useState(!1),[C,A]=k.useState(!1),[I,L]=k.useState(!1),[O,V]=k.useState(!1),[q,B]=k.useState(""),U=t.size;if(U===0)return null;const te=async oe=>{S(!0);try{const ve=Array.from(t).map(ge=>({contact_id:ge,relationship_type_id:oe})),{error:he}=await G.from("innercircle_contact_tags").upsert(ve,{onConflict:"contact_id,relationship_type_id",ignoreDuplicates:!0});if(he)throw he;p.invalidateQueries({queryKey:["innercircle-contacts"]}),p.invalidateQueries({queryKey:["innercircle-contact-counts"]}),fn({title:`Assigned type to ${U} contacts`}),r()}catch(me){fn({title:"Error assigning type",description:me.message,variant:"destructive"})}finally{S(!1)}},Y=async oe=>{S(!0);try{const me=Array.from(t);for(const ve of me)try{await N.mutateAsync({contactId:ve,tagId:oe})}catch{}p.invalidateQueries({queryKey:["all-contact-custom-tags"]}),fn({title:`Tagged ${U} contacts`}),V(!1),B("")}catch(me){fn({title:"Error adding tags",description:me.message,variant:"destructive"})}finally{S(!1)}},J=async()=>{if(q.trim()){S(!0);try{const oe=await b.mutateAsync({name:q.trim()});await Y(oe.id)}catch(oe){fn({title:"Error creating tag",description:oe.message,variant:"destructive"}),S(!1)}}},X=(_==null?void 0:_.filter(oe=>oe.name.toLowerCase().includes(q.toLowerCase())))||[],ce=_==null?void 0:_.find(oe=>oe.name.toLowerCase()===q.trim().toLowerCase()),ie=()=>{const oe=s.filter(Me=>t.has(Me.id)),me=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Notes","Relationship Types"],ve=oe.map(Me=>{var ke;return[Me.first_name,Me.last_name||"",Me.email||"",Me.phone||"",Me.address||"",Me.birthday||"",Me.home_anniversary||"",Me.notes||"",((ke=Me.tags)==null?void 0:ke.map(Re=>{var Ve;return(Ve=Re.relationship_type)==null?void 0:Ve.name}).join("; "))||""]}),he=[me.join(","),...ve.map(Me=>Me.map(ke=>`"${(ke||"").replace(/"/g,'""')}"`).join(","))].join(` `),ge=new Blob([he],{type:"text/csv"}),je=URL.createObjectURL(ge),qe=document.createElement("a");qe.href=je,qe.download=`contacts-export-${new Date().toISOString().slice(0,10)}.csv`,qe.click(),URL.revokeObjectURL(je),fn({title:`Exported ${U} contacts`})},ae=async()=>{if(confirm(`Are you sure you want to delete ${U} contacts? This cannot be undone.`)){S(!0);try{const oe=Array.from(t);for(const me of oe)await u.mutateAsync(me);r()}catch(oe){fn({title:"Error deleting contacts",description:oe.message,variant:"destructive"})}finally{S(!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(Qe,{variant:"secondary",className:"font-semibold",children:[U," selected"]}),e.jsxs($s,{onValueChange:te,disabled:w,children:[e.jsx(zs,{className:"w-[180px] h-8",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(mh,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm",children:"Assign Type"})]})}),e.jsx(Bs,{children:d==null?void 0:d.filter(oe=>oe.active).map(oe=>e.jsx(vt,{value:oe.id,children:oe.name},oe.id))})]}),e.jsxs(mo,{open:O,onOpenChange:V,children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{variant:"outline",size:"sm",disabled:w,children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1"}),"Add Tag"]})}),e.jsxs(no,{className:"w-56 p-2",align:"start",children:[e.jsx(De,{placeholder:"Search or create tag...",value:q,onChange:oe=>B(oe.target.value),onKeyDown:oe=>{oe.key==="Enter"&&q.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:[X.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)),q.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 "',q.trim(),'"']}),X.length===0&&!q.trim()&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-2",children:"Type to create a tag"})]})]})]}),f&&e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>A(!0),disabled:w,children:[e.jsx(tr,{className:"h-3.5 w-3.5 mr-1"}),"Email"]}),y&&e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>{const oe=Array.from(t).join(",");i(`/admin/email-campaigns/new?contactIds=${oe}`)},disabled:w,children:[e.jsx(uh,{className:"h-3.5 w-3.5 mr-1"}),"Mass Email"]}),e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>L(!0),disabled:w,children:[e.jsx(Or,{className:"h-3.5 w-3.5 mr-1"}),"Enroll in Campaign"]}),a&&n&&e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>n(Array.from(t)),disabled:w,children:[e.jsx(Ag,{className:"h-3.5 w-3.5 mr-1"}),"Send to Lead Pond"]}),l&&o&&e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>o(Array.from(t)),disabled:w,children:[e.jsx(Gv,{className:"h-3.5 w-3.5 mr-1"}),"Transfer"]}),e.jsxs(W,{variant:"outline",size:"sm",onClick:ie,disabled:w,children:[e.jsx(Qa,{className:"h-3.5 w-3.5 mr-1"}),"Export"]}),e.jsxs(W,{variant:"outline",size:"sm",onClick:ae,disabled:w,className:"text-destructive hover:text-destructive",children:[e.jsx(vr,{className:"h-3.5 w-3.5 mr-1"}),"Delete"]}),e.jsxs(W,{variant:"ghost",size:"sm",onClick:r,className:"ml-auto",children:[e.jsx(kr,{className:"h-3.5 w-3.5 mr-1"}),"Clear"]})]}),e.jsx(dbs,{open:I,onOpenChange:L,contactIds:Array.from(t),onSuccess:r}),e.jsx(E1,{open:C,onOpenChange:A,bulkContacts:Array.from(t).map(oe=>{const me=s.find(ve=>ve.id===oe);return me?{id:me.id,first_name:me.first_name,last_name:me.last_name,email:me.email||""}:null}).filter(oe=>oe!==null&&oe.email!==""),onSendComplete:()=>{A(!1),r()}})]})}function O7e({contact:t,onEdit:s,onDelete:r,onSnooze:n,onSendToLeadPond:a,showLeadPondAction:o,onTransfer:l,showTransferAction:i}){const d=wr(),{isReady:u}=Sme(),p=`${t.first_name} ${t.last_name||""}`.trim();return e.jsxs(Hd,{children:[e.jsx(Gd,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:f=>f.stopPropagation(),children:e.jsx(Zp,{className:"h-4 w-4"})})}),e.jsxs(Nd,{align:"end",onClick:f=>f.stopPropagation(),children:[e.jsxs(_a,{onClick:()=>d(`/mission-control/contacts/${t.id}?tab=activity&action=log`),children:[e.jsx(In,{className:"h-4 w-4 mr-2"}),"Log Touch"]}),e.jsxs(_a,{onClick:()=>d(`/mission-control/video?contactId=${t.id}`),children:[e.jsx(yn,{className:"h-4 w-4 mr-2"}),"Send Video"]}),e.jsxs(_a,{onClick:()=>d(`/mission-control/popbys?contactId=${t.id}`),children:[e.jsx(Ia,{className:"h-4 w-4 mr-2"}),"Schedule Pop-by"]}),u&&t.email&&e.jsxs(_a,{onClick:()=>d(`/admin/email-campaigns/new?contactIds=${t.id}`),children:[e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Mass Email"]}),e.jsxs(_a,{onClick:()=>n(t.id,p),children:[e.jsx(hh,{className:"h-4 w-4 mr-2"}),"Snooze"]}),o&&a&&e.jsxs(_a,{onClick:()=>a(t.id),children:[e.jsx(Ag,{className:"h-4 w-4 mr-2"}),"Send to Lead Pond"]}),i&&l&&e.jsxs(_a,{onClick:()=>l(t.id),children:[e.jsx(Gv,{className:"h-4 w-4 mr-2"}),"Transfer to Team Member"]}),e.jsxs(_a,{onClick:()=>s(t),children:[e.jsx(ga,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(_a,{onClick:()=>r(t.id),className:"text-destructive focus:text-destructive",children:[e.jsx(vr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})}function xbs(){const{user:t}=Us();return gt({queryKey:["contact-smart-lists",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_smart_lists").select("*").order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function gbs(){const t=Qt(),{user:s}=Us();return Pt({mutationFn:async({name:r,filters:n,sort_by:a})=>{const{data:o,error:l}=await G.from("contact_smart_lists").insert({owner_user_id:s.id,name:r,filters:n,sort_by:a}).select().single();if(l)throw l;return o},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-smart-lists"]}),fn({title:"Smart filter saved"})},onError:r=>{fn({title:"Error saving smart filter",description:r.message,variant:"destructive"})}})}function ybs(){const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("contact_smart_lists").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-smart-lists"]}),fn({title:"Smart filter deleted"})}})}function vbs({currentFilters:t,currentSortBy:s,onApplySmartList:r}){const{data:n}=xbs(),a=gbs(),o=ybs(),[l,i]=k.useState(!1),[d,u]=k.useState(""),p=t.search||t.type&&t.type!=="all"||t.status&&t.status!=="all",f=async()=>{d.trim()&&(await a.mutateAsync({name:d.trim(),filters:t,sort_by:s}),u(""),i(!1))};return e.jsxs(e.Fragment,{children:[e.jsxs(Hd,{children:[e.jsx(Gd,{asChild:!0,children:e.jsxs(W,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(Eg,{className:"h-3.5 w-3.5"}),"Smart Filters",n&&n.length>0&&e.jsx(Qe,{variant:"secondary",className:"h-5 px-1.5 text-[10px]",children:n.length}),e.jsx(Bi,{className:"h-3.5 w-3.5"})]})}),e.jsxs(Nd,{align:"start",className:"w-56",children:[n&&n.length>0?e.jsxs(e.Fragment,{children:[n.map(y=>e.jsxs(_a,{className:"flex items-center justify-between group",children:[e.jsx("span",{className:"flex-1 cursor-pointer",onClick:()=>r(y.filters,y.sort_by),children:y.name}),e.jsx(W,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100",onClick:_=>{_.stopPropagation(),o.mutate(y.id)},children:e.jsx(vr,{className:"h-3 w-3 text-destructive"})})]},y.id)),e.jsx(Yb,{})]}):e.jsx(_a,{disabled:!0,className:"text-muted-foreground text-xs",children:"No saved filters yet"}),p&&e.jsxs(_a,{onClick:()=>i(!0),children:[e.jsx(oL,{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(ks,{children:e.jsx(_s,{children:"Save Smart Filter"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(De,{placeholder:"e.g. Buyers in 40205",value:d,onChange:y=>u(y.target.value),onKeyDown:y=>y.key==="Enter"&&f(),autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(W,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(W,{onClick:f,disabled:!d.trim()||a.isPending,children:"Save"})]})]})]})})]})}function F7e(t){if(!t)return null;const s=ol(t);if(!s)return null;const r=new Date;r.setHours(0,0,0,0);const n=new Date(r.getFullYear(),s.getMonth(),s.getDate());return nt.relationshipScore.status==="at-risk"},{key:"never-contacted",title:"Never Contacted",subtitle:"No outreach yet",icon:Jo,gradient:"from-violet-500/15 via-purple-500/10 to-transparent",iconBg:"bg-violet-500/15",iconColor:"text-violet-600 dark:text-violet-400",match:t=>t.relationshipScore.daysSinceTouch===null},{key:"stale-90",title:"Stale 90+ Days",subtitle:"Time to reconnect",icon:nn,gradient:"from-amber-500/15 via-yellow-500/10 to-transparent",iconBg:"bg-amber-500/15",iconColor:"text-amber-600 dark:text-amber-400",match:t=>{const s=t.relationshipScore.daysSinceTouch;return s!==null&&s>90}},{key:"cooling",title:"Cooling Off",subtitle:"Engagement dropping",icon:qy,gradient:"from-cyan-500/15 via-sky-500/10 to-transparent",iconBg:"bg-cyan-500/15",iconColor:"text-cyan-600 dark:text-cyan-400",match:t=>t.relationshipScore.status==="cooling"},{key:"birthdays-soon",title:"Birthdays Soon",subtitle:"Next 30 days",icon:Fu,gradient:"from-pink-500/15 via-fuchsia-500/10 to-transparent",iconBg:"bg-pink-500/15",iconColor:"text-pink-600 dark:text-pink-400",match:(t,s)=>s.daysToBirthday!==null&&s.daysToBirthday<=30},{key:"anniversary-soon",title:"Home Anniversary",subtitle:"Next 30 days",icon:Mn,gradient:"from-emerald-500/15 via-green-500/10 to-transparent",iconBg:"bg-emerald-500/15",iconColor:"text-emerald-600 dark:text-emerald-400",match:(t,s)=>s.daysToAnniv!==null&&s.daysToAnniv<=30},{key:"has-deal",title:"Active Deal",subtitle:"In your pipeline",icon:dh,gradient:"from-teal-500/15 via-[#406E71]/10 to-transparent",iconBg:"bg-teal-500/15",iconColor:"text-teal-700 dark:text-teal-400",match:(t,s)=>s.hasDeal},{key:"website-active",title:"Active on Site",subtitle:"Browsing right now",icon:nd,gradient:"from-indigo-500/15 via-blue-500/10 to-transparent",iconBg:"bg-indigo-500/15",iconColor:"text-indigo-600 dark:text-indigo-400",match:()=>!1},{key:"vips",title:"VIPs",subtitle:"Top relationships",icon:Or,gradient:"from-amber-400/20 via-yellow-300/10 to-transparent",iconBg:"bg-amber-400/20",iconColor:"text-amber-600 dark:text-amber-300",match:t=>t.relationshipScore.score>=80},{key:"missing-info",title:"Missing Info",subtitle:"No email or phone",icon:Dc,gradient:"from-slate-500/15 via-zinc-500/10 to-transparent",iconBg:"bg-slate-500/15",iconColor:"text-slate-600 dark:text-slate-400",match:t=>{var s,r;return!((s=t.email)!=null&&s.trim())&&!((r=t.phone)!=null&&r.trim())}}];function _bs({contacts:t,contactDealsMap:s,websiteActiveIds:r,activeKey:n,onSelect:a}){const o=k.useRef(null),l=k.useMemo(()=>{const d={"needs-attention":0,cooling:0,"never-contacted":0,"stale-90":0,"birthdays-soon":0,"anniversary-soon":0,"has-deal":0,"website-active":r.size,"missing-info":0,vips:0};if(!t)return d;for(const u of t){const p={hasDeal:!!(s&&s[u.id]),daysToBirthday:F7e(u.birthday),daysToAnniv:F7e(u.home_anniversary)};for(const f of z7e)f.key!=="website-active"&&f.match(u,p)&&d[f.key]++}return d},[t,s,r]),i=d=>{var u;(u=o.current)==null||u.scrollBy({left:d,behavior:"smooth"})};return e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 px-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Or,{className:"h-4 w-4 text-[#406E71]"}),e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Smart Segments"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Auto-organized for you"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[n&&e.jsxs("button",{onClick:()=>a(null),className:"flex items-center gap-1 px-2 py-1 rounded-md text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[e.jsx(kr,{className:"h-3 w-3"}),"Clear"]}),e.jsx("button",{onClick:()=>i(-320),className:"hidden md:flex h-7 w-7 rounded-full items-center justify-center bg-muted/60 hover:bg-muted transition-colors","aria-label":"Scroll left",children:e.jsx(Xo,{className:"h-4 w-4"})}),e.jsx("button",{onClick:()=>i(320),className:"hidden md:flex h-7 w-7 rounded-full items-center justify-center bg-muted/60 hover:bg-muted transition-colors","aria-label":"Scroll right",children:e.jsx(xa,{className:"h-4 w-4"})})]})]}),e.jsx("div",{ref:o,style:{touchAction:"pan-x",WebkitOverflowScrolling:"touch"},className:"flex gap-3 overflow-x-auto overflow-y-hidden overscroll-x-contain pb-2 px-1 -mx-1 snap-x snap-mandatory scroll-smooth [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]",children:z7e.map(d=>{const u=d.icon,p=l[d.key],f=n===d.key,y=p===0;return e.jsxs("button",{onClick:()=>a(f?null:d.key),disabled:y&&!f,className:`group relative shrink-0 snap-start w-[180px] text-left rounded-xl border transition-all duration-200 overflow-hidden ${f?"border-[#406E71] ring-2 ring-[#406E71]/30 shadow-lg scale-[1.02] bg-card":y?"border-border/40 bg-card/50 opacity-50 cursor-not-allowed":"border-border hover:border-[#406E71]/50 hover:shadow-md hover:-translate-y-0.5 bg-card cursor-pointer"}`,children:[e.jsx("div",{className:`absolute inset-0 bg-gradient-to-br ${d.gradient} pointer-events-none`}),e.jsxs("div",{className:"relative p-3.5",children:[e.jsxs("div",{className:"flex items-start justify-between mb-2.5",children:[e.jsx("div",{className:`h-9 w-9 rounded-lg ${d.iconBg} flex items-center justify-center`,children:e.jsx(u,{className:`h-4.5 w-4.5 ${d.iconColor}`,strokeWidth:2.25})}),e.jsx("div",{className:"text-right",children:e.jsx("div",{className:"text-2xl font-bold leading-none text-foreground tabular-nums",children:p.toLocaleString()})})]}),e.jsx("div",{className:"text-sm font-semibold text-foreground leading-tight",children:d.title}),e.jsx("div",{className:"text-[11px] text-muted-foreground mt-0.5 leading-tight",children:d.subtitle})]})]},d.key)})})]})}const rit="innercircle_geocode_cache_v1";function bbs(){try{return JSON.parse(localStorage.getItem(rit)||"{}")}catch{return{}}}function wbs(t){try{localStorage.setItem(rit,JSON.stringify(t))}catch{}}function jbs(t){const s=[t.address,t.city,t.state,t.zip||t.zip_code].filter(Boolean);return s.length<2&&!t.address||s.length===0?null:s.join(", ")}function Nbs({open:t,onOpenChange:s,contacts:r,onCitySelect:n}){const a=k.useRef(null),o=k.useRef(null),[l,i]=k.useState(""),[d,u]=k.useState(!0),[p,f]=k.useState([]),[y,_]=k.useState({done:0,total:0}),[b,N]=k.useState(!1),[w,S]=k.useState("heat");k.useEffect(()=>{if(!t)return;let A=!1;return(async()=>{u(!0);const{data:I}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();A||(i((I==null?void 0:I.value)||""),u(!1))})(),()=>{A=!0}},[t]),k.useEffect(()=>{if(!t||!l)return;let A=!1;return(async()=>{const L=bbs(),O=r.map(X=>({c:X,addr:jbs(X)})).filter(X=>X.addr),V=[],q=[];for(const{c:X,addr:ce}of O){const ie=L[ce];ie!==null&&(ie?V.push({id:X.id,name:`${X.first_name||""} ${X.last_name||""}`.trim(),city:X.city||null,state:X.state||null,zip:X.zip||X.zip_code||null,lat:ie.lat,lng:ie.lng}):q.push({c:X,addr:ce}))}if(A||f(V),_({done:V.length,total:O.length}),q.length===0)return;N(!0);const B=6;let U=0;const te={...L},Y=[...V],J=async()=>{var X;for(;U{A=!0}},[t,l,r]);const C=k.useMemo(()=>{const A=new Map;for(const I of r){const L=(I.city||"").trim();if(!L)continue;const O=(I.state||"").trim()||null,V=`${L.toLowerCase()}|${O||""}`,q=A.get(V);q?q.count++:A.set(V,{city:L,state:O,count:1})}return Array.from(A.values()).sort((I,L)=>L.count-I.count)},[r]);return k.useEffect(()=>{if(!(!t||!l||!a.current||o.current))return Ko.accessToken=l,o.current=new Ko.Map({container:a.current,style:"mapbox://styles/mapbox/light-v11",center:[-98.5795,39.8283],zoom:3.5}),o.current.addControl(new Ko.NavigationControl,"top-right"),()=>{var A;(A=o.current)==null||A.remove(),o.current=null}},[t,l]),k.useEffect(()=>{const A=o.current;if(!A||p.length===0)return;const I=()=>{const O={type:"FeatureCollection",features:p.map(q=>({type:"Feature",properties:{id:q.id,name:q.name},geometry:{type:"Point",coordinates:[q.lng,q.lat]}}))},V=A.getSource("contacts-src");if(V?V.setData(O):(A.addSource("contacts-src",{type:"geojson",data:O}),A.addLayer({id:"contacts-heat",type:"heatmap",source:"contacts-src",maxzoom:15,paint:{"heatmap-weight":1,"heatmap-intensity":["interpolate",["linear"],["zoom"],0,1,15,3],"heatmap-color":["interpolate",["linear"],["heatmap-density"],0,"rgba(64,110,113,0)",.2,"rgba(64,110,113,0.4)",.4,"rgba(56,189,248,0.6)",.6,"rgba(250,204,21,0.7)",.8,"rgba(249,115,22,0.85)",1,"rgba(220,38,38,1)"],"heatmap-radius":["interpolate",["linear"],["zoom"],0,12,9,30,15,60],"heatmap-opacity":["interpolate",["linear"],["zoom"],13,1,15,.6]}}),A.addLayer({id:"contacts-points",type:"circle",source:"contacts-src",paint:{"circle-radius":["interpolate",["linear"],["zoom"],0,4,8,5,16,9],"circle-color":"#406E71","circle-stroke-color":"#ffffff","circle-stroke-width":1.5,"circle-opacity":.9}}),A.on("click","contacts-points",q=>{var te;const B=(te=q.features)==null?void 0:te[0];if(!B)return;const U=B.geometry.coordinates.slice();new Ko.Popup({offset:12}).setLngLat(U).setHTML(`
${B.properties.name||"Contact"}
`).addTo(A)}),A.on("mouseenter","contacts-points",()=>{A.getCanvas().style.cursor="pointer"}),A.on("mouseleave","contacts-points",()=>{A.getCanvas().style.cursor=""})),A.getLayer("contacts-heat")&&A.setLayoutProperty("contacts-heat","visibility",w==="heat"?"visible":"none"),A.getLayer("contacts-points")&&(A.setPaintProperty("contacts-points","circle-opacity",w==="points"?.9:0),A.setLayoutProperty("contacts-points","visibility","visible")),p.length>0&&!A._fitDone){const q=new Ko.LngLatBounds;p.forEach(B=>q.extend([B.lng,B.lat]));try{A.fitBounds(q,{padding:60,maxZoom:11,duration:600}),A._fitDone=!0}catch{}}};A.isStyleLoaded()?I():A.once("load",I)},[p,w]),e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-6xl w-[95vw] h-[90vh] p-0 flex flex-col",children:[e.jsx(ks,{className:"p-4 pb-2 border-b",children:e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(rd,{className:"h-5 w-5 text-orange-500"}),"Geographic Heat Map",e.jsxs(Qe,{variant:"secondary",className:"ml-2",children:[p.length," mapped · ",C.length," cities"]})]})}),e.jsxs("div",{className:"flex-1 flex flex-col md:flex-row min-h-0",children:[e.jsx("div",{className:"flex-1 relative min-h-[300px]",children:d?e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsx(us,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):l?e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:a,className:"absolute inset-0"}),e.jsxs("div",{className:"absolute top-3 left-3 flex flex-col gap-2 z-10",children:[e.jsxs("div",{className:"bg-background/95 backdrop-blur rounded-md shadow-md border p-1 flex",children:[e.jsxs(W,{size:"sm",variant:w==="heat"?"default":"ghost",onClick:()=>S("heat"),className:"h-8",children:[e.jsx(rd,{className:"h-3.5 w-3.5 mr-1"})," Heat"]}),e.jsxs(W,{size:"sm",variant:w==="points"?"default":"ghost",onClick:()=>S("points"),className:"h-8",children:[e.jsx(_L,{className:"h-3.5 w-3.5 mr-1"})," Pins"]})]}),b&&e.jsxs("div",{className:"bg-background/95 backdrop-blur rounded-md shadow-md border px-2.5 py-1.5 text-xs flex items-center gap-2",children:[e.jsx(us,{className:"h-3 w-3 animate-spin"}),"Mapping ",y.done," / ",y.total]})]})]}):e.jsxs("div",{className:"h-full flex flex-col items-center justify-center gap-3 p-6 text-center",children:[e.jsx(ro,{className:"h-10 w-10 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:"Mapbox token is not set. Contact your administrator."})]})]})}),e.jsxs("div",{className:"w-full md:w-72 border-t md:border-t-0 md:border-l flex flex-col bg-muted/30 min-h-[200px]",children:[e.jsxs("div",{className:"p-3 border-b bg-background",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-1.5",children:[e.jsx(Ia,{className:"h-4 w-4 text-primary"}),"Top Cities"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Tap a city to filter your contacts"})]}),e.jsx(Ja,{className:"flex-1",children:e.jsxs("div",{className:"p-2 space-y-1.5",children:[C.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground p-3 text-center",children:"No city data on your contacts yet. Add city/state to contacts to populate the map."}),C.slice(0,50).map((A,I)=>{var V;const L=((V=C[0])==null?void 0:V.count)||1,O=A.count/L*100;return e.jsx(Pe,{className:"cursor-pointer hover:border-primary transition-colors overflow-hidden",onClick:()=>{n==null||n(A.city,A.state),s(!1)},children:e.jsxs(Oe,{className:"p-2.5 relative",children:[e.jsx("div",{className:"absolute inset-y-0 left-0 bg-primary/10",style:{width:`${O}%`}}),e.jsxs("div",{className:"relative flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"text-sm font-medium truncate",children:[A.city,A.state?`, ${A.state}`:""]}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:I===0?"🔥 Hottest market":`Rank #${I+1}`})]}),e.jsx(Qe,{variant:"secondary",className:"shrink-0",children:A.count})]})]})},`${A.city}-${A.state}-${I}`)})]})})]})]})]})})}function l4(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 $7e({birthday:t,homeAnniversary:s,className:r,contactId:n,contactName:a,contactAddress:o}){const l=wr(),i=B7e(t,"birthday",7),d=B7e(s,"anniversary",7);if(!i&&!d)return null;const u=(p,f)=>{f.stopPropagation();const y=new URLSearchParams;n&&y.set("contactId",n),a&&y.set("name",a),o&&y.set("address",o),p==="home_anniversary"&&s&&y.set("date",s),y.set("cardType",p),l(`/mission-control/card-studio?${y.toString()}`)};return e.jsxs("div",{className:Ot("flex flex-wrap gap-1",r),children:[i&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(Qe,{variant:"secondary",className:Ot("text-[10px] gap-0.5 font-medium",i.daysUntil===0?"bg-pink-100 text-pink-700 dark:bg-pink-900/30 dark:text-pink-400 animate-pulse":"bg-pink-50 text-pink-600 dark:bg-pink-900/20 dark:text-pink-400"),children:i.label}),n&&e.jsxs("button",{onClick:p=>u("birthday",p),className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[9px] font-semibold bg-pink-500/15 text-pink-600 dark:text-pink-400 hover:bg-pink-500/25 transition-colors",title:"Send a birthday card",children:[e.jsx(tr,{className:"h-2.5 w-2.5"}),"Send Card"]})]}),d&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(Qe,{variant:"secondary",className:Ot("text-[10px] gap-0.5 font-medium",d.daysUntil===0?"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400 animate-pulse":"bg-blue-50 text-blue-600 dark:bg-blue-900/20 dark:text-blue-400"),children:d.label}),n&&e.jsxs("button",{onClick:p=>u("home_anniversary",p),className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[9px] font-semibold bg-blue-500/15 text-blue-600 dark:text-blue-400 hover:bg-blue-500/25 transition-colors",title:"Send an anniversary card",children:[e.jsx(tr,{className:"h-2.5 w-2.5"}),"Send Card"]})]})]})}function q7e({deal:t}){if(!t||!t.stage)return null;const{stage:s}=t;return e.jsxs(Qe,{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 U7e({count:t,className:s}){return!t||t<=0?null:e.jsxs(Qe,{variant:"outline",className:Ot("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(_S,{className:"h-2.5 w-2.5"}),t===1?"In drip":`${t} drips`]})}function kbs(){const t=ya();return gt({queryKey:["contacts-campaign-counts",t],queryFn:async()=>{if(!t)return{};const{data:s,error:r}=await G.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 Sbs(){const t=ya();return gt({queryKey:["contact-deals-map",t],queryFn:async()=>{const{data:s,error:r}=await G.from("deal_pipeline").select(` id, deal_name, contact_id, stage:deal_pipeline_stages(id, name, color, icon, is_won_stage, is_lost_stage) `).not("contact_id","is",null);if(r)throw r;const n={};return(s||[]).forEach(a=>{a.contact_id&&!n[a.contact_id]&&(n[a.contact_id]=a)}),n},enabled:!!t})}function Cbs({contactId:t,compact:s=!1}){const{data:r}=_O(),{data:n}=ubs(t),a=zSe(),o=tit(),l=pbs(),[i,d]=k.useState(!1),[u,p]=k.useState(""),f=k.useRef(null),y=new Set((n==null?void 0:n.map(S=>S.tag_id))||[]),_=(r==null?void 0:r.filter(S=>S.name.toLowerCase().includes(u.toLowerCase())))||[],b=r==null?void 0:r.find(S=>S.name.toLowerCase()===u.trim().toLowerCase()),N=async S=>{y.has(S.id)?await l.mutateAsync({contactId:t,tagId:S.id}):await o.mutateAsync({contactId:t,tagId:S.id})},w=async()=>{if(!(!u.trim()||b))try{const S=await a.mutateAsync({name:u.trim()});await o.mutateAsync({contactId:t,tagId:S.id}),p("")}catch{}};return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n==null?void 0:n.map(S=>{var C,A,I;return e.jsxs(Qe,{variant:"outline",className:"text-xs gap-1 pr-1",style:{borderColor:((C=S.tag)==null?void 0:C.color)||"#6366F1",color:((A=S.tag)==null?void 0:A.color)||"#6366F1"},children:[e.jsx(mh,{className:"h-2.5 w-2.5"}),(I=S.tag)==null?void 0:I.name,e.jsx("button",{onClick:L=>{L.stopPropagation(),l.mutate({contactId:t,tagId:S.tag_id})},className:"ml-0.5 rounded-full hover:bg-accent p-0.5",children:e.jsx(kr,{className:"h-2.5 w-2.5"})})]},S.id)}),e.jsxs(mo,{open:i,onOpenChange:d,children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{variant:"ghost",size:"sm",className:s?"h-6 w-6 p-0":"h-6 px-2 text-xs",onClick:S=>S.stopPropagation(),children:[e.jsx(qs,{className:"h-3 w-3"}),!s&&e.jsx("span",{className:"ml-1",children:"Tag"})]})}),e.jsxs(no,{className:"w-56 p-2",align:"start",onClick:S=>S.stopPropagation(),children:[e.jsx(De,{ref:f,placeholder:"Search or create tag...",value:u,onChange:S=>p(S.target.value),onKeyDown:S=>{S.key==="Enter"&&u.trim()&&!b?(S.preventDefault(),w()):S.key==="Enter"&&b&&!y.has(b.id)&&(S.preventDefault(),N(b))},className:"h-8 text-sm mb-2"}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:[_.map(S=>e.jsxs("button",{onClick:()=>N(S),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:S.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:S.name}),y.has(S.id)&&e.jsx(Zn,{className:"h-3.5 w-3.5 text-primary shrink-0"})]},S.id)),u.trim()&&!b&&e.jsxs("button",{onClick:w,className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors text-primary",children:[e.jsx(qs,{className:"h-3.5 w-3.5"}),'Create "',u.trim(),'"']}),_.length===0&&!u.trim()&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-2",children:"Type to create your first tag"})]})]})]})]})}function V7e({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(Qe,{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 b9=["#6366F1","#8B5CF6","#EC4899","#EF4444","#F97316","#F59E0B","#10B981","#14B8A6","#06B6D4","#3B82F6","#6B7280","#1F2937"];function Mbs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=_O(),a=zSe(),o=mbs(),l=hbs(),[i,d]=k.useState(""),[u,p]=k.useState(b9[0]),[f,y]=k.useState(null),[_,b]=k.useState(""),[N,w]=k.useState(""),S=async()=>{if(i.trim())try{await a.mutateAsync({name:i.trim(),color:u}),d(""),p(b9[0]),fn({title:"Tag created"})}catch(L){fn({title:"Error",description:L.message,variant:"destructive"})}},C=async L=>{if(_.trim())try{await o.mutateAsync({id:L,name:_.trim(),color:N}),y(null),fn({title:"Tag updated"})}catch(O){fn({title:"Error",description:O.message,variant:"destructive"})}},A=async(L,O)=>{if(confirm(`Delete tag "${O}"? It will be removed from all contacts.`))try{await l.mutateAsync(L),fn({title:"Tag deleted"})}catch(V){fn({title:"Error",description:V.message,variant:"destructive"})}},I=L=>{y(L.id),b(L.name),w(L.color)};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(ks,{children:e.jsx(_s,{children:"Manage Tags"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{placeholder:"New tag name...",value:i,onChange:L=>d(L.target.value),onKeyDown:L=>L.key==="Enter"&&S(),className:"flex-1 h-9"}),e.jsxs(W,{size:"sm",onClick:S,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:b9.map(L=>e.jsx("button",{onClick:()=>p(L),className:`h-6 w-6 rounded-full border-2 transition-transform ${u===L?"border-foreground scale-110":"border-transparent hover:scale-105"}`,style:{backgroundColor:L}},L))})]}),e.jsxs("div",{className:"mt-2 space-y-1 max-h-[320px] overflow-y-auto",children:[n&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Loading..."}),(r==null?void 0:r.length)===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No tags yet. Create one above!"}),r==null?void 0:r.map(L=>e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg hover:bg-accent/50 group",children:f===L.id?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-1",children:b9.map(O=>e.jsx("button",{onClick:()=>w(O),className:`h-5 w-5 rounded-full border-2 ${N===O?"border-foreground":"border-transparent"}`,style:{backgroundColor:O}},O))}),e.jsx(De,{value:_,onChange:O=>b(O.target.value),onKeyDown:O=>O.key==="Enter"&&C(L.id),className:"flex-1 h-8 text-sm",autoFocus:!0}),e.jsx(W,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>C(L.id),children:e.jsx(Zn,{className:"h-4 w-4 text-primary"})}),e.jsx(W,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>y(null),children:e.jsx(kr,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-3.5 w-3.5 rounded-full shrink-0",style:{backgroundColor:L.color}}),e.jsx("span",{className:"flex-1 text-sm",children:L.name}),e.jsx(W,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>I(L),children:e.jsx(ga,{className:"h-3.5 w-3.5"})}),e.jsx(W,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity text-destructive hover:text-destructive",onClick:()=>A(L.id,L.name),children:e.jsx(vr,{className:"h-3.5 w-3.5"})})]})},L.id))]})]})})}function Tbs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=JA(),a=lke(),o=f8t(),l=x8t(),[i,d]=k.useState(""),[u,p]=k.useState(null),[f,y]=k.useState(""),_=async()=>{if(i.trim())try{await a.mutateAsync(i.trim()),d("")}catch(S){pe.error(S.message||"Failed to add lead source")}},b=async S=>{if(f.trim())try{await o.mutateAsync({id:S,name:f.trim()}),p(null)}catch(C){pe.error(C.message||"Failed to update")}},N=async(S,C)=>{if(confirm(`Remove lead source "${C}"? Contacts using it will keep the label but it won't appear in new dropdowns.`))try{await l.mutateAsync(S)}catch(A){pe.error(A.message||"Failed to remove")}},w=S=>{p(S.id),y(S.name)};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(ks,{children:e.jsx(_s,{children:"Manage Lead Sources"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{placeholder:"New lead source name...",value:i,onChange:S=>d(S.target.value),onKeyDown:S=>S.key==="Enter"&&_(),className:"flex-1 h-9"}),e.jsxs(W,{size:"sm",onClick:_,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(S=>e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg hover:bg-accent/50 group",children:u===S.id?e.jsxs(e.Fragment,{children:[e.jsx(De,{value:f,onChange:C=>y(C.target.value),onKeyDown:C=>C.key==="Enter"&&b(S.id),className:"flex-1 h-8 text-sm",autoFocus:!0}),e.jsx(W,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>b(S.id),children:e.jsx(Zn,{className:"h-4 w-4 text-primary"})}),e.jsx(W,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>p(null),children:e.jsx(kr,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1 text-sm",children:S.name}),S.owner_user_id&&e.jsxs(e.Fragment,{children:[e.jsx(W,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>w(S),children:e.jsx(ga,{className:"h-3.5 w-3.5"})}),e.jsx(W,{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:()=>N(S.id,S.name),children:e.jsx(vr,{className:"h-3.5 w-3.5"})})]}),!S.owner_user_id&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Default"})]})},S.id))]})]})})}function nit({value:t,onChange:s,label:r="Lead Source"}){const{data:n}=JA(),a=lke(),[o,l]=k.useState(!1),[i,d]=k.useState(""),u=async()=>{if(i.trim())try{const p=await a.mutateAsync(i.trim());p&&(s(p.id),d(""),l(!1))}catch{}};return e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:r}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs($s,{value:t||"_none",onValueChange:p=>s(p==="_none"?"":p),children:[e.jsx(zs,{className:"flex-1",children:e.jsx(Vs,{placeholder:"Select lead source"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"_none",children:"No source"}),n==null?void 0:n.map(p=>e.jsx(vt,{value:p.id,children:p.name},p.id))]})]}),e.jsx(W,{type:"button",variant:"outline",size:"icon",className:"shrink-0",onClick:()=>l(!o),children:o?e.jsx(kr,{className:"h-4 w-4"}):e.jsx(qs,{className:"h-4 w-4"})})]}),o&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{placeholder:"New lead source name...",value:i,onChange:p=>d(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),u())},className:"flex-1"}),e.jsx(W,{type:"button",size:"sm",onClick:u,disabled:!i.trim()||a.isPending,children:"Add"})]})]})}function Ewe({contactId:t,currentSpouseContactId:s,currentSpouseName:r,currentSpouseEmail:n,onLink:a,onUnlink:o,isEditing:l}){const i=wr(),[d,u]=k.useState(!1),[p,f]=k.useState(""),{data:y}=gt({queryKey:["innercircle-contact-spouse",s],queryFn:async()=>{const{data:b,error:N}=await G.from("innercircle_contacts").select("id, first_name, last_name, email, phone, birthday").eq("id",s).maybeSingle();if(N)throw N;return b},enabled:!!s}),{data:_}=gt({queryKey:["spouse-search",p],queryFn:async()=>{let b=G.from("innercircle_contacts").select("id, first_name, last_name, email, phone").neq("id",t).order("first_name").limit(20);p.trim()&&(b=b.or(`first_name.ilike.%${p}%,last_name.ilike.%${p}%,email.ilike.%${p}%,phone.ilike.%${p}%`));const{data:N,error:w}=await b;if(w)throw w;return N},enabled:d});if(s&&y){const b=`${y.first_name} ${y.last_name||""}`.trim();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(xe,{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(Ai,{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/${y.id}`),className:"text-sm font-medium text-primary hover:underline truncate block",children:b}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:[y.phone,y.email].filter(Boolean).join(" · ")||"No contact info"})]}),l&&e.jsxs(W,{variant:"ghost",size:"sm",onClick:o,className:"shrink-0 h-7 px-2",children:[e.jsx(jS,{className:"h-3.5 w-3.5 mr-1"}),"Unlink"]}),!l&&e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>i(`/mission-control/contacts/${y.id}`),className:"shrink-0 h-7 px-2",children:e.jsx(Wa,{className:"h-3.5 w-3.5"})})]})]})}return!s&&(r||n)?e.jsxs("div",{className:"space-y-1",children:[e.jsx(xe,{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(Ai,{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(mo,{open:d,onOpenChange:u,children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{variant:"outline",size:"sm",className:"shrink-0 h-7 px-2",children:[e.jsx(Do,{className:"h-3.5 w-3.5 mr-1"}),"Link Contact"]})}),e.jsx(no,{className:"w-72 p-2",align:"end",children:e.jsx(H7e,{search:p,setSearch:f,results:_,onSelect:b=>{a(b),u(!1),f("")}})})]})]})]}):l?e.jsxs("div",{className:"space-y-1",children:[e.jsx(xe,{className:"text-sm font-medium",children:"Spouse / Partner"}),e.jsxs(mo,{open:d,onOpenChange:u,children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{variant:"outline",className:"w-full justify-start text-muted-foreground font-normal h-10",children:[e.jsx(Do,{className:"h-4 w-4 mr-2"}),"Link an existing contact as spouse..."]})}),e.jsx(no,{className:"w-72 p-2",align:"start",children:e.jsx(H7e,{search:p,setSearch:f,results:_,onSelect:b=>{a(b),u(!1),f("")}})})]})]}):null}function H7e({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(ln,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(De,{value:t,onChange:a=>s(a.target.value),placeholder:"Search contacts...",className:"pl-7 h-8 text-sm",autoFocus:!0})]}),e.jsx(Ja,{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 Abs(){var La;const t=wr(),[s,r]=Nc(),{user:n}=Us(),a=bE(),o=Qt(),l=s.get("type"),i=s.get("filter")??s.get("status"),d=s.get("new")==="true",{contactsWithScores:u,isLoading:p}=lhe(),{activeContactIds:f,hasLeadSite:y}=q_s(),{data:_}=kbs(),{data:b}=Nf(),{data:N}=Sbs(),{data:w}=_O(),{data:S}=sit(),[C,A]=k.useState(new Set),[I,L]=k.useState("any"),O=nhe(),V=ake(),q=ike(),B=bXe(),[U,te]=k.useState(""),[Y,J]=k.useState(!1),[X,ce]=k.useState(l||"all"),[ie,ae]=k.useState(i||"all"),[oe,me]=k.useState("date-added"),[ve,he]=k.useState(d),[ge,je]=k.useState(null),[qe,Me]=k.useState(!1),[ke,Re]=k.useState(!1),[Ve,Ne]=k.useState(null),[Ue,Ie]=k.useState(""),[ye,ct]=k.useState(new Set),[fe,$e]=k.useState(!1),Ye=Math.max(1,parseInt(s.get("page")||"1",10)||1),[tt,Te]=k.useState(Ye),We=k.useCallback(Yt=>{Te(Lr=>{const $t=typeof Yt=="function"?Yt(Lr):Yt;return r(Se=>{const Fe=new URLSearchParams(Se);return $t<=1?Fe.delete("page"):Fe.set("page",String($t)),Fe},{replace:!0}),$t})},[]),[Ke,ot]=k.useState(50),[He,Je]=k.useState("my"),[ut,mt]=k.useState(!1),[et,Ze]=k.useState(!1),{data:kt}=Px(),{addToLeadPond:Ut}=mtt(kt==null?void 0:kt.teamId),Nt=!!((La=kt==null?void 0:kt.team)!=null&&La.lead_pond_enabled&&(kt!=null&&kt.teamId)),es=!!(kt!=null&&kt.teamId),[ds,js]=k.useState([]),[lr,Lt]=k.useState(!1),Es=Yt=>{js([Yt]),Lt(!0)},fr=Yt=>{js(Yt),Lt(!0)},Hs=Yt=>{kt!=null&&kt.teamId&&Ut.mutate({contact_id:Yt,team_id:kt.teamId})},mr=Yt=>{kt!=null&&kt.teamId&&Yt.forEach(Lr=>{Ut.mutate({contact_id:Lr,team_id:kt.teamId})})},an=k.useCallback(Yt=>{$e(!1),ct(Lr=>{const $t=new Set(Lr);return $t.has(Yt)?$t.delete(Yt):$t.add(Yt),$t})},[]);k.useEffect(()=>{if(!(n!=null&&n.id))return;const Yt=G.channel(`innercircle_contacts_inserts_${n.id}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"innercircle_contacts",filter:`owner_user_id=eq.${n.id}`},()=>{o.invalidateQueries({queryKey:["innercircle-contacts"]}),o.invalidateQueries({queryKey:["innercircle-contact-counts"]})}).subscribe();return()=>{G.removeChannel(Yt)}},[o,n==null?void 0:n.id]),k.useEffect(()=>{i&&ae(i)},[i]);const[Cr,Fr]=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(()=>{d&&he(!0)},[d]),k.useEffect(()=>{var Yt;ge&&Fr({first_name:ge.first_name||"",last_name:ge.last_name||"",email:ge.email||"",phone:ge.phone||"",address:ge.address||"",city:ge.city||"",state:ge.state||"",zip_code:ge.zip_code||"",birthday:ge.birthday||"",home_anniversary:ge.home_anniversary||"",spouse_name:ge.spouse_name||"",spouse_email:ge.spouse_email||"",lead_source_id:ge.lead_source_id||"",notes:ge.notes||"",tagIds:((Yt=ge.tags)==null?void 0:Yt.map(Lr=>Lr.relationship_type_id))||[]})},[ge]);const $r=k.useMemo(()=>{if(!u)return[];let Yt=u.filter(Lr=>{var Xe,yt,bt,At,Gt;const $t=U===""||`${Lr.first_name} ${Lr.last_name}`.toLowerCase().includes(U.toLowerCase())||((Xe=Lr.email)==null?void 0:Xe.toLowerCase().includes(U.toLowerCase()))||((yt=Lr.phone)==null?void 0:yt.includes(U))||((bt=Lr.city)==null?void 0:bt.toLowerCase().includes(U.toLowerCase()))||((At=Lr.state)==null?void 0:At.toLowerCase().includes(U.toLowerCase())),Se=X==="all"||((Gt=Lr.tags)==null?void 0:Gt.some(Vt=>Vt.relationship_type_id===X)),Fe=C.size===0||(()=>{const Vt=(S==null?void 0:S.filter(Xt=>Xt.contact_id===Lr.id).map(Xt=>Xt.tag_id))||[];return I==="any"?Vt.some(Xt=>C.has(Xt)):Array.from(C).every(Xt=>Vt.includes(Xt))})();return $t&&Se&&Fe});return ie==="not-touched-90"?Yt=Yt.filter(Lr=>{const $t=Lr.relationshipScore.daysSinceTouch;return $t===null||$t>90}):ie==="at-risk"?Yt=Yt.filter(Lr=>Lr.relationshipScore.status==="at-risk"):ie==="cooling"?Yt=Yt.filter(Lr=>Lr.relationshipScore.status==="cooling"):ie==="warm"?Yt=Yt.filter(Lr=>Lr.relationshipScore.status==="warm"):ie==="has-deal"?Yt=Yt.filter(Lr=>N&&N[Lr.id]):ie==="no-deal"?Yt=Yt.filter(Lr=>!N||!N[Lr.id]):ie==="open-house"?Yt=Yt.filter(Lr=>{var Se;return(((Se=Lr.lead_source_ref)==null?void 0:Se.name)||Lr.lead_source)==="Open House"}):ie==="website-active"?Yt=Yt.filter(Lr=>f.has(Lr.id)):ie==="never-contacted"?Yt=Yt.filter(Lr=>Lr.relationshipScore.daysSinceTouch===null):ie==="vips"?Yt=Yt.filter(Lr=>Lr.relationshipScore.score>=80):ie==="missing-info"?Yt=Yt.filter(Lr=>{var $t,Se;return!(($t=Lr.email)!=null&&$t.trim())&&!((Se=Lr.phone)!=null&&Se.trim())}):ie==="birthdays-soon"?Yt=Yt.filter(Lr=>{const $t=l4(Lr.birthday);return $t!==null&&$t<=30}):ie==="anniversary-soon"&&(Yt=Yt.filter(Lr=>{const $t=l4(Lr.home_anniversary);return $t!==null&&$t<=30})),Yt=[...Yt].sort((Lr,$t)=>{switch(oe){case"important-dates":{const Se=l4(Lr.birthday),Fe=l4($t.birthday),Xe=l4(Lr.home_anniversary),yt=l4($t.home_anniversary),bt=[Se,Xe].filter(Gt=>Gt!==null).sort((Gt,Vt)=>(Gt??1/0)-(Vt??1/0))[0]??1/0,At=[Fe,yt].filter(Gt=>Gt!==null).sort((Gt,Vt)=>(Gt??1/0)-(Vt??1/0))[0]??1/0;return bt-At}case"last-touched":{const Se=Lr.relationshipScore.lastTouchDate,Fe=$t.relationshipScore.lastTouchDate;return!Se&&!Fe?0:Se?Fe?new Date(Se).getTime()-new Date(Fe).getTime():1:-1}case"next-touch":{const Se=Lr.relationshipScore.daysSinceTouch,Fe=$t.relationshipScore.daysSinceTouch;return Se===null&&Fe===null?0:Se===null?-1:Fe===null?1:Fe-Se}case"score":return Lr.relationshipScore.score-$t.relationshipScore.score;case"date-added":{const Se=Lr.created_at,Fe=$t.created_at;return!Se&&!Fe?0:Se?Fe?new Date(Fe).getTime()-new Date(Se).getTime():-1:1}case"name":default:{const Se=`${Lr.first_name||""} ${Lr.last_name||""}`.toLowerCase(),Fe=`${$t.first_name||""} ${$t.last_name||""}`.toLowerCase();return Se.localeCompare(Fe)}}}),Yt},[u,U,X,C,I,ie,oe,N,S,f]),nr=$r.length,cr=Math.max(1,Math.ceil(nr/Ke)),Br=Math.min(tt,cr),Kr=k.useMemo(()=>{const Yt=(Br-1)*Ke;return $r.slice(Yt,Yt+Ke)},[$r,Br,Ke]),Sn=k.useRef(!1);k.useEffect(()=>{if(!Sn.current){Sn.current=!0;return}We(1)},[U,X,C,I,ie,oe]);const ai=k.useCallback(()=>{$e(!1),ct(Yt=>Yt.size>0?new Set:new Set(Kr.map(Lr=>Lr.id)))},[Kr]),as=k.useCallback(()=>{$e(!0),ct(new Set($r.map(Yt=>Yt.id)))},[$r]),qn=k.useCallback((Yt,Lr)=>{te(Yt.search||""),ce(Yt.type||"all"),ae(Yt.status||"all"),me(Lr||"name")},[]),un=()=>{Fr({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]})},qr=async Yt=>{Yt.preventDefault();const Lr={...Cr,lead_source_id:Cr.lead_source_id||null};ge?(await V.mutateAsync({id:ge.id,...Lr}),je(null)):(await O.mutateAsync(Lr),he(!1)),un()},Zr=async Yt=>{confirm("Are you sure you want to delete this contact?")&&await q.mutateAsync(Yt)};return e.jsx(Ds,{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"})]}),kt&&e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsx("button",{onClick:()=>Je("my"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${He==="my"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"My Contacts"}),(kt.team.contact_visibility==="full_team"||kt.team.contact_visibility==="leader_only"&&kt.role==="team_leader")&&e.jsxs("button",{onClick:()=>Je("team"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${He==="team"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(ir,{className:"h-3.5 w-3.5"}),"Team"]}),kt.team.lead_pond_enabled&&e.jsxs("button",{onClick:()=>Je("lead-pond"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${He==="lead-pond"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Ag,{className:"h-3.5 w-3.5"}),"Lead Pond"]})]})]}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs(W,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control"),children:[e.jsx(Xo,{className:"h-4 w-4 mr-1"}),"Back"]})}),He==="team"?e.jsx(m4e,{}):He==="lead-pond"&&kt?e.jsx(p4e,{teamId:kt.teamId}):e.jsxs(e.Fragment,{children:[e.jsx(_bs,{contacts:u,contactDealsMap:N,websiteActiveIds:f,activeKey:{"at-risk":"needs-attention",cooling:"cooling","not-touched-90":"stale-90","never-contacted":"never-contacted","birthdays-soon":"birthdays-soon","anniversary-soon":"anniversary-soon","has-deal":"has-deal","website-active":"website-active",vips:"vips","missing-info":"missing-info"}[ie]??null,onSelect:Yt=>{const $t=Yt?{"needs-attention":"at-risk",cooling:"cooling","stale-90":"not-touched-90","never-contacted":"never-contacted","birthdays-soon":"birthdays-soon","anniversary-soon":"anniversary-soon","has-deal":"has-deal","website-active":"website-active",vips:"vips","missing-info":"missing-info"}[Yt]:"all";ae($t),We(1)}}),e.jsx(Pe,{children:e.jsx(Oe,{className:"p-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name, email, or phone...",value:U,onChange:Yt=>te(Yt.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"space-y-2 sm:space-y-0",children:[e.jsxs(W,{onClick:()=>J(!0),className:"sm:hidden w-full h-11 bg-gradient-to-r from-orange-500 to-red-500 hover:from-orange-600 hover:to-red-600 text-white border-0 shadow-sm",children:[e.jsx(rd,{className:"h-4 w-4 mr-2"}),"View Geographic Heat Map"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:hidden",children:[e.jsxs(W,{onClick:()=>he(!0),className:"h-10 w-full justify-center",children:[e.jsx(qs,{className:"h-4 w-4 mr-1.5"}),e.jsx("span",{className:"truncate",children:"Add Contact"})]}),e.jsxs(W,{variant:"outline",onClick:()=>Me(!0),className:"h-10 w-full justify-center",children:[e.jsx(Ra,{className:"h-4 w-4 mr-1.5"}),e.jsx("span",{className:"truncate",children:"Import CSV"})]}),e.jsxs(W,{variant:"outline",onClick:()=>Re(!0),className:"h-10 w-full justify-center",children:[e.jsx(Ig,{className:"h-4 w-4 mr-1.5"}),e.jsx("span",{className:"truncate",children:"From Phone"})]}),e.jsx("div",{className:"w-full [&>*]:w-full [&_button]:w-full [&_button]:h-10 [&_button]:justify-center",children:e.jsx(R7e,{})})]}),e.jsxs("div",{className:"hidden sm:flex items-center gap-2 flex-wrap",children:[e.jsxs(W,{onClick:()=>he(!0),className:"shrink-0",children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Contact"]}),e.jsxs(W,{variant:"outline",onClick:()=>Me(!0),className:"shrink-0",children:[e.jsx(Ra,{className:"h-4 w-4 mr-1"}),"Import CSV"]}),e.jsxs(W,{variant:"outline",onClick:()=>Re(!0),className:"shrink-0",children:[e.jsx(Ig,{className:"h-4 w-4 mr-1"}),"Import from Phone"]}),e.jsx(R7e,{}),e.jsxs(W,{variant:"outline",onClick:()=>J(!0),className:"shrink-0 border-orange-200 text-orange-700 hover:bg-orange-50 hover:text-orange-800 dark:border-orange-900 dark:text-orange-400",children:[e.jsx(rd,{className:"h-4 w-4 mr-1"}),"Heat Map"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs($s,{value:X,onValueChange:ce,children:[e.jsx(zs,{className:"w-[145px] h-9 text-sm",children:e.jsx(Vs,{placeholder:"Filter by type"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Types"}),b==null?void 0:b.filter(Yt=>Yt.active).map(Yt=>e.jsx(vt,{value:Yt.id,children:Yt.name},Yt.id))]})]}),w&&w.length>0&&e.jsxs(mo,{children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{variant:"outline",className:"h-9 justify-start text-sm",children:[e.jsx(mh,{className:"h-3.5 w-3.5 mr-1.5 shrink-0 text-muted-foreground"}),C.size===0?"Filter by Tags":`${C.size} tag${C.size>1?"s":""}`]})}),e.jsx(no,{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:()=>L("any"),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${I==="any"?"bg-background text-foreground shadow-sm":"text-muted-foreground"}`,children:"Any"}),e.jsx("button",{onClick:()=>L("all"),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${I==="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(Yt=>{const Lr=C.has(Yt.id);return e.jsxs("button",{onClick:()=>{A($t=>{const Se=new Set($t);return Se.has(Yt.id)?Se.delete(Yt.id):Se.add(Yt.id),Se})},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(Ri,{checked:Lr,className:"pointer-events-none"}),e.jsx("div",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:Yt.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:Yt.name})]},Yt.id)})}),C.size>0&&e.jsx(W,{variant:"ghost",size:"sm",className:"w-full text-xs",onClick:()=>A(new Set),children:"Clear tags"})]})})]}),e.jsxs(Hd,{children:[e.jsx(Gd,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0",title:"Settings",children:e.jsx(So,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxs(Nd,{align:"end",children:[e.jsxs(_a,{onClick:()=>mt(!0),children:[e.jsx(mh,{className:"h-4 w-4 mr-2"}),"Manage Tags"]}),e.jsxs(_a,{onClick:()=>Ze(!0),children:[e.jsx(Ag,{className:"h-4 w-4 mr-2"}),"Manage Lead Sources"]})]})]}),e.jsxs($s,{value:ie,onValueChange:ae,children:[e.jsx(zs,{className:"w-[145px] h-9 text-sm",children:e.jsx(Vs,{placeholder:"Filter by status"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Status"}),e.jsx(vt,{value:"warm",children:"🟢 Warm"}),e.jsx(vt,{value:"cooling",children:"🟡 Cooling Off"}),e.jsx(vt,{value:"at-risk",children:"🔴 At Risk"}),e.jsx(vt,{value:"has-deal",children:"📋 Has Deal"}),e.jsx(vt,{value:"no-deal",children:"📭 No Deal"}),e.jsx(vt,{value:"open-house",children:"🏠 Open House"}),y&&e.jsx(vt,{value:"website-active",children:"🌐 Website Active"})]})]}),e.jsxs($s,{value:oe,onValueChange:me,children:[e.jsx(zs,{className:"w-[165px] h-9 text-sm",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(td,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Vs,{placeholder:"Sort by"})]})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"name",children:"Name (A-Z)"}),e.jsx(vt,{value:"important-dates",children:"Important Dates"}),e.jsx(vt,{value:"last-touched",children:"Last Touched"}),e.jsx(vt,{value:"next-touch",children:"Next Touch Due"}),e.jsx(vt,{value:"score",children:"Relationship Score"}),e.jsx(vt,{value:"date-added",children:"Date Added"})]})]}),e.jsx(vbs,{currentFilters:{search:U,type:X,status:ie},currentSortBy:oe,onApplySmartList:qn})]})]})})}),e.jsx(fbs,{selectedIds:ye,contacts:$r,onClearSelection:()=>{ct(new Set),$e(!1)},showLeadPondAction:Nt,onSendToLeadPond:mr,showTransferAction:es,onTransfer:fr}),ye.size>0&&ye.size===Kr.length&&!fe&&nr>Ke&&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 ",Kr.length," contacts on this page are selected."]}),e.jsxs(W,{variant:"link",size:"sm",className:"h-auto p-0 font-semibold",onClick:as,children:["Select all ",nr.toLocaleString()," matching contacts"]})]}),fe&&e.jsxs("div",{className:"flex items-center justify-center gap-2 p-2 bg-primary/10 border border-primary/30 rounded-lg text-sm font-medium",children:["All ",nr.toLocaleString()," matching contacts are selected.",e.jsx(W,{variant:"link",size:"sm",className:"h-auto p-0",onClick:()=>{ct(new Set),$e(!1)},children:"Clear selection"})]}),nr>Ke&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-2 py-1",children:[e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Showing ",(Br-1)*Ke+1,"–",Math.min(Br*Ke,nr)," of ",nr.toLocaleString()," contacts"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(W,{variant:"outline",size:"sm",disabled:Br<=1,onClick:()=>We(1),children:"First"}),e.jsx(W,{variant:"outline",size:"sm",disabled:Br<=1,onClick:()=>We(Yt=>Yt-1),children:e.jsx(Xo,{className:"h-4 w-4"})}),e.jsxs("span",{className:"px-3 text-sm font-medium",children:["Page ",Br," of ",cr]}),e.jsx(W,{variant:"outline",size:"sm",disabled:Br>=cr,onClick:()=>We(Yt=>Yt+1),children:e.jsx(xa,{className:"h-4 w-4"})}),e.jsx(W,{variant:"outline",size:"sm",disabled:Br>=cr,onClick:()=>We(cr),children:"Last"})]})]}),a?e.jsx("div",{className:"space-y-3",children:p?e.jsx(Pe,{className:"p-6 text-center text-muted-foreground",children:"Loading contacts..."}):$r.length===0?e.jsx(Pe,{className:"p-6 text-center text-muted-foreground",children:U||X!=="all"||ie!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"}):Kr.map(Yt=>{var $t,Se,Fe;const{relationshipScore:Lr}=Yt;return e.jsx(Pe,{className:"cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>{const Xe=new URLSearchParams;U&&Xe.set("search",U),X!=="all"&&Xe.set("type",X),ie!=="all"&&Xe.set("filter",ie);const yt=Xe.toString();t(`/mission-control/contacts/${Yt.id}${yt?`?${yt}`:""}`)},children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 flex-wrap",children:[e.jsxs("h3",{className:"font-semibold text-base truncate",children:[Yt.first_name," ",Yt.last_name]}),e.jsx(U7e,{count:(_==null?void 0:_[Yt.id])??0}),e.jsx(xa,{className:"h-4 w-4 text-muted-foreground shrink-0 ml-auto"})]}),e.jsxs("div",{className:"space-y-1 text-sm mb-3",children:[Yt.email&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(tr,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:Yt.email})]}),Yt.phone&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(In,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{children:Yt.phone})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1 mb-2",children:[e.jsx(M8,{score:Lr,size:"sm"}),e.jsx(Awe,{contact:Yt}),((($t=Yt.lead_source_ref)==null?void 0:$t.name)||Yt.lead_source)&&e.jsx(Qe,{variant:"outline",className:"text-xs gap-1 border-primary/30 text-primary",children:((Se=Yt.lead_source_ref)==null?void 0:Se.name)||Yt.lead_source}),(Fe=Yt.tags)==null?void 0:Fe.map(Xe=>{var yt;return e.jsx(Qe,{variant:"secondary",className:"text-xs",children:(yt=Xe.relationship_type)==null?void 0:yt.name},Xe.id)}),e.jsx(V7e,{contactId:Yt.id,tags:S==null?void 0:S.filter(Xe=>Xe.contact_id===Yt.id)}),e.jsx(q7e,{deal:N==null?void 0:N[Yt.id]})]}),e.jsx($7e,{birthday:Yt.birthday,homeAnniversary:Yt.home_anniversary,className:"mb-2",contactId:Yt.id,contactName:`${Yt.first_name}${Yt.last_name?" "+Yt.last_name:""}`,contactAddress:[Yt.address,Yt.city,Yt.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[Lr.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(nn,{className:"h-3 w-3"}),vs(new Date(Lr.lastTouchDate),"MMM d")]}):e.jsx("span",{className:"italic",children:"Never contacted"}),Yt.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(cn,{className:"h-3 w-3"}),vs(ol(Yt.birthday),"MMM d")]}),Yt.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Mn,{className:"h-3 w-3"}),vs(ol(Yt.home_anniversary),"MMM d")]}),Yt.created_at&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(qs,{className:"h-3 w-3"}),"Added ",vs(new Date(Yt.created_at),"MMM d, yyyy")]})]})]}),e.jsx("div",{className:"ml-2",onClick:Xe=>Xe.stopPropagation(),children:e.jsx(O7e,{contact:Yt,onEdit:je,onDelete:Zr,onSnooze:(Xe,yt)=>{Ne(Xe),Ie(yt)},showLeadPondAction:Nt,onSendToLeadPond:Hs,showTransferAction:es,onTransfer:Es})})]})})},Yt.id)})}):e.jsx(Pe,{children:e.jsx(Oe,{className:"p-0 overflow-x-auto",children:e.jsxs(Ln,{className:"min-w-[800px]",children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{className:"w-[40px]",children:e.jsx(Ri,{checked:Kr.length>0&&Kr.every(Yt=>ye.has(Yt.id)),onCheckedChange:()=>ai()})}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Score"}),e.jsx(St,{children:"Contact Info"}),e.jsx(St,{children:"Types / Pipeline"}),e.jsx(St,{children:"Last Contact"}),e.jsx(St,{className:"cursor-pointer select-none",onClick:()=>me(oe==="date-added"?"name":"date-added"),children:e.jsxs("div",{className:"flex items-center gap-1",children:["Date Added",oe==="date-added"&&e.jsx(td,{className:"h-3 w-3"})]})}),e.jsx(St,{children:"Important Dates"}),e.jsx(St,{className:"w-[50px]",children:"Actions"})]})}),e.jsx(Rn,{children:p?e.jsx(Ps,{children:e.jsx(ht,{colSpan:10,className:"text-center py-8",children:"Loading contacts..."})}):$r.length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:U||X!=="all"||ie!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"})}):Kr.map(Yt=>{var Se,Fe,Xe;const{relationshipScore:Lr}=Yt,$t=N==null?void 0:N[Yt.id];return e.jsxs(Ps,{className:`cursor-pointer hover:bg-accent/50 ${ye.has(Yt.id)?"bg-accent/30":""}`,onClick:()=>{const yt=new URLSearchParams;U&&yt.set("search",U),X!=="all"&&yt.set("type",X),ie!=="all"&&yt.set("status",ie);const bt=yt.toString();t(`/mission-control/contacts/${Yt.id}${bt?`?${bt}`:""}`)},children:[e.jsx(ht,{onClick:yt=>yt.stopPropagation(),children:e.jsx(Ri,{checked:ye.has(Yt.id),onCheckedChange:()=>an(Yt.id)})}),e.jsx(ht,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{children:[Yt.first_name," ",Yt.last_name]}),e.jsx(U7e,{count:(_==null?void 0:_[Yt.id])??0})]})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(M8,{score:Lr,size:"sm"}),e.jsx(Awe,{contact:Yt})]})}),e.jsx(ht,{children:e.jsx(M8,{score:Lr,size:"sm",showScore:!0})}),e.jsx(ht,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[Yt.email&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(tr,{className:"h-3 w-3"}),Yt.email]}),Yt.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(In,{className:"h-3 w-3"}),Yt.phone]})]})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(((Se=Yt.lead_source_ref)==null?void 0:Se.name)||Yt.lead_source)&&e.jsx(Qe,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((Fe=Yt.lead_source_ref)==null?void 0:Fe.name)||Yt.lead_source}),(Xe=Yt.tags)==null?void 0:Xe.map(yt=>{var bt;return e.jsx(Qe,{variant:"secondary",className:"text-xs",children:(bt=yt.relationship_type)==null?void 0:bt.name},yt.id)}),e.jsx(V7e,{contactId:Yt.id,tags:S==null?void 0:S.filter(yt=>yt.contact_id===Yt.id)}),e.jsx(q7e,{deal:$t})]})}),e.jsx(ht,{children:e.jsx("div",{className:"text-sm",children:Lr.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(nn,{className:"h-3 w-3"}),vs(new Date(Lr.lastTouchDate),"MMM d, yyyy")]}):e.jsx("span",{className:"text-muted-foreground text-xs italic",children:"Never contacted"})})}),e.jsx(ht,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:Yt.created_at?vs(new Date(Yt.created_at),"MMM d, yyyy"):"—"})}),e.jsx(ht,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx($7e,{birthday:Yt.birthday,homeAnniversary:Yt.home_anniversary,contactId:Yt.id,contactName:`${Yt.first_name}${Yt.last_name?" "+Yt.last_name:""}`,contactAddress:[Yt.address,Yt.city,Yt.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Yt.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(cn,{className:"h-3 w-3"}),vs(ol(Yt.birthday),"MMM d")]}),Yt.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Mn,{className:"h-3 w-3"}),vs(ol(Yt.home_anniversary),"MMM d")]})]})]})}),e.jsx(ht,{children:e.jsx(O7e,{contact:Yt,onEdit:je,onDelete:Zr,onSnooze:(yt,bt)=>{Ne(yt),Ie(bt)},showLeadPondAction:Nt,onSendToLeadPond:Hs,showTransferAction:es,onTransfer:Es})})]},Yt.id)})})]})})}),nr>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 ",(Br-1)*Ke+1,"–",Math.min(Br*Ke,nr)," of ",nr.toLocaleString()," contacts"]}),e.jsxs($s,{value:String(Ke),onValueChange:Yt=>{ot(Number(Yt)),We(1)},children:[e.jsx(zs,{className:"w-[80px] h-8",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"50",children:"50"}),e.jsx(vt,{value:"100",children:"100"}),e.jsx(vt,{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(W,{variant:"outline",size:"sm",disabled:Br<=1,onClick:()=>We(1),children:"First"}),e.jsx(W,{variant:"outline",size:"sm",disabled:Br<=1,onClick:()=>We(Yt=>Yt-1),children:e.jsx(Xo,{className:"h-4 w-4"})}),e.jsxs("span",{className:"px-3 text-sm font-medium",children:["Page ",Br," of ",cr]}),e.jsx(W,{variant:"outline",size:"sm",disabled:Br>=cr,onClick:()=>We(Yt=>Yt+1),children:e.jsx(xa,{className:"h-4 w-4"})}),e.jsx(W,{variant:"outline",size:"sm",disabled:Br>=cr,onClick:()=>We(cr),children:"Last"})]})]}),e.jsx(fs,{open:ve||!!ge,onOpenChange:Yt=>{Yt||(he(!1),je(null),un())},children:e.jsxs(ps,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(_s,{children:ge?"Edit Contact":"Add Contact"})}),e.jsxs("form",{onSubmit:qr,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"first_name",children:"First Name *"}),e.jsx(De,{id:"first_name",value:Cr.first_name,onChange:Yt=>Fr({...Cr,first_name:Yt.target.value}),required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"last_name",children:"Last Name"}),e.jsx(De,{id:"last_name",value:Cr.last_name,onChange:Yt=>Fr({...Cr,last_name:Yt.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"email",children:"Email"}),e.jsx(De,{id:"email",type:"email",value:Cr.email,onChange:Yt=>Fr({...Cr,email:Yt.target.value})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"phone",children:"Phone"}),e.jsx(De,{id:"phone",value:Cr.phone,onChange:Yt=>Fr({...Cr,phone:Yt.target.value})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"address",children:"Address"}),e.jsx(De,{id:"address",value:Cr.address,onChange:Yt=>Fr({...Cr,address:Yt.target.value}),placeholder:"Street address"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"city",children:"City"}),e.jsx(De,{id:"city",value:Cr.city,onChange:Yt=>Fr({...Cr,city:Yt.target.value})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"state",children:"State"}),e.jsx(De,{id:"state",value:Cr.state,onChange:Yt=>Fr({...Cr,state:Yt.target.value})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"zip_code",children:"Zip"}),e.jsx(De,{id:"zip_code",value:Cr.zip_code,onChange:Yt=>Fr({...Cr,zip_code:Yt.target.value})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"birthday",children:"Birthday"}),e.jsx(De,{id:"birthday",type:"date",value:Cr.birthday,onChange:Yt=>Fr({...Cr,birthday:Yt.target.value})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(De,{id:"home_anniversary",type:"date",value:Cr.home_anniversary,onChange:Yt=>Fr({...Cr,home_anniversary:Yt.target.value})})]})]}),ge&&e.jsx(Ewe,{contactId:ge.id,currentSpouseContactId:(ge==null?void 0:ge.spouse_contact_id)||null,currentSpouseName:(ge==null?void 0:ge.spouse_name)||null,currentSpouseEmail:(ge==null?void 0:ge.spouse_email)||null,onLink:Yt=>B.mutate({contactId:ge.id,spouseContactId:Yt}),onUnlink:()=>B.mutate({contactId:ge.id,spouseContactId:null}),isEditing:!0}),e.jsx(nit,{value:Cr.lead_source_id,onChange:Yt=>Fr({...Cr,lead_source_id:Yt})}),e.jsxs("div",{children:[e.jsx(xe,{children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:b==null?void 0:b.filter(Yt=>Yt.active).map(Yt=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Ri,{checked:Cr.tagIds.includes(Yt.id),onCheckedChange:Lr=>{Fr(Lr?{...Cr,tagIds:[...Cr.tagIds,Yt.id]}:{...Cr,tagIds:Cr.tagIds.filter($t=>$t!==Yt.id)})}}),e.jsx("span",{className:"text-sm",children:Yt.name})]},Yt.id))})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"notes",children:"Notes"}),e.jsx(_r,{id:"notes",value:Cr.notes,onChange:Yt=>Fr({...Cr,notes:Yt.target.value}),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>{he(!1),je(null),un()},children:"Cancel"}),e.jsxs(W,{type:"submit",disabled:O.isPending||V.isPending,children:[ge?"Update":"Create"," Contact"]})]})]})]})}),e.jsx(G_s,{open:qe,onOpenChange:Me,relationshipTypes:(b==null?void 0:b.filter(Yt=>Yt.active))||[],onSuccess:()=>{Me(!1)}}),e.jsx(Z_s,{open:ke,onOpenChange:Re,onComplete:()=>Re(!1)}),e.jsx(kme,{open:!!Ve,onOpenChange:Yt=>{Yt||Ne(null)},contactId:Ve||"",contactName:Ue}),e.jsx(Mbs,{open:ut,onOpenChange:mt}),e.jsx(Tbs,{open:et,onOpenChange:Ze}),e.jsx(Nbs,{open:Y,onOpenChange:J,contacts:u||[],onCitySelect:Yt=>{te(Yt),We(1)}}),e.jsx(ptt,{open:lr,onOpenChange:Lt,contactIds:ds,contactNames:ds.map(Yt=>{const Lr=$r.find($t=>$t.id===Yt);return Lr?`${Lr.first_name} ${Lr.last_name||""}`.trim():""}),onComplete:()=>{js([]),ct(new Set),$e(!1)}})]})]})})}const Ebs="9a88a47c-cb2a-4401-a2b5-111a76b19f9d";function Pbs({open:t,onOpenChange:s,contact:r}){var Y;const{user:n}=Us(),a=wr(),o=Qt(),{intakePage:l,isLoading:i}=Cme(),{isGmailConnected:d,gmailEmail:u}=Om(),p=ahe(),{data:f}=gt({queryKey:["profile-for-invite",n==null?void 0:n.id],enabled:!!(n!=null&&n.id)&&t,queryFn:async()=>{const{data:J}=await G.from("profiles").select("name, email, avatar_url").eq("id",n.id).maybeSingle();return J}}),y=(f==null?void 0:f.name)||((Y=n==null?void 0:n.email)==null?void 0:Y.split("@")[0])||"Your Agent",_=y.split(" ")[0],b=l?`https://contacts.relevelup.com/${l.slug}`:"",N=k.useMemo(()=>`Hi ${r.first_name}, I'm updating my contact list and want to make sure I have your latest info — the best phone, email, address, and a couple of dates I love to remember (like your birthday and home anniversary). It only takes about a minute, and it helps me stay in touch the right way. Thanks so much!`,[r.first_name]),[w,S]=k.useState("gmail"),[C,A]=k.useState(""),[I,L]=k.useState(""),[O,V]=k.useState(!1);k.useEffect(()=>{t&&(A(`Quick favor, ${r.first_name} — can you update your info?`),L(N),S(d?"gmail":"system"))},[t,N,r.first_name,d]);const q=k.useMemo(()=>I.split(/\n\n+/).map(J=>`

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

`).join(""),[I]),B=()=>`
${f!=null&&f.avatar_url?`${y}`:`
${_.charAt(0)}
`}

A note from ${y}

${q}

Update Your Info

Takes about a minute — promise

Share My Info →

${b}

Sent with care by ${y}

Powered by ReLevelUp

`,U=async()=>{if(!l){pe.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>a("/mission-control/connect-page")}});return}if(!C.trim()||!I.trim()){pe.error("Subject and message are required");return}V(!0);const J=B();try{if(w==="gmail"&&d){const{data:X,error:ce}=await G.functions.invoke("gmail-send",{body:{to:r.email,subject:C,body:J,contactId:r.id}});if(ce)throw ce;if(!(X!=null&&X.success))throw new Error((X==null?void 0:X.error)||"Failed to send")}else{const{data:X,error:ce}=await G.functions.invoke("send-connect-invite",{body:{contactEmail:r.email,subject:C,htmlBody:J,replyToEmail:(f==null?void 0:f.email)||(n==null?void 0:n.email),agentName:y}});if(ce)throw ce;if(!(X!=null&&X.success))throw new Error((X==null?void 0:X.error)||"Failed to send")}try{await p.mutateAsync({contactId:r.id,actionTypeId:Ebs,notes:`Sent Connect Page invite — Subject: "${C}"`})}catch(X){console.warn("Failed to log activity:",X)}o.invalidateQueries({queryKey:["contact-touch-logs"]}),pe.success("Connect Page invite sent!"),s(!1)}catch(X){console.error("Send error:",X),pe.error(X instanceof Error?X.message:"Failed to send invite")}finally{V(!1)}},te=B();return e.jsx(fs,{open:t,onOpenChange:J=>!O&&s(J),children:e.jsxs(ps,{className:"sm:max-w-[720px] max-h-[92vh] overflow-y-auto",children:[e.jsxs(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(Or,{className:"h-5 w-5 text-primary"}),"Send Connect Page Invite"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Ask ",e.jsxs("span",{className:"font-medium",children:[r.first_name," ",r.last_name||""]})," to share their latest contact info — takes them about a minute."]})]}),i?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(us,{className:"h-6 w-6 animate-spin text-primary"})}):l?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Send From"}),e.jsx(ta,{value:w,onValueChange:J=>S(J),className:"mt-1.5",children:e.jsxs(Jn,{className:"grid w-full grid-cols-2",children:[e.jsxs(cs,{value:"gmail",disabled:!d,children:[e.jsx(tr,{className:"h-3.5 w-3.5 mr-1.5"}),d?`Gmail (${u})`:"Gmail (not connected)"]}),e.jsxs(cs,{value:"system",children:[e.jsx(Or,{className:"h-3.5 w-3.5 mr-1.5"}),"System Email"]})]})}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1.5",children:w==="gmail"?"Replies go directly to your Gmail inbox.":`Sent from notifications@dashboard.relevelup.com — replies go to ${(f==null?void 0:f.email)||(n==null?void 0:n.email)||"your account email"}.`})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"invite-subject",children:"Subject"}),e.jsx(De,{id:"invite-subject",value:C,onChange:J=>A(J.target.value),className:"mt-1.5"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"invite-message",children:"Personal Message"}),e.jsx(_r,{id:"invite-message",value:I,onChange:J=>L(J.target.value),rows:6,className:"mt-1.5 resize-none"}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1",children:"The Connect Page button is added below your message automatically."})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx(xe,{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Preview"}),e.jsxs("a",{href:b,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline flex items-center gap-1",children:["Open Connect Page ",e.jsx(Yr,{className:"h-3 w-3"})]})]}),e.jsx("div",{className:"rounded-lg border overflow-hidden bg-muted/30",children:e.jsx("iframe",{srcDoc:te,title:"Email preview",sandbox:"",className:"w-full h-[420px] bg-background"})})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(W,{variant:"outline",onClick:()=>s(!1),disabled:O,children:"Cancel"}),e.jsx(W,{onClick:U,disabled:O,children:O?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"h-4 w-4 mr-1.5 animate-spin"})," Sending…"]}):e.jsxs(e.Fragment,{children:[e.jsx(_n,{className:"h-4 w-4 mr-1.5"})," Send Invite"]})})]})]}):e.jsxs("div",{className:"space-y-4 py-6 text-center",children:[e.jsx(ro,{className:"h-10 w-10 text-amber-500 mx-auto"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"You haven't set up a Connect Page yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Create yours in one click — it only takes a moment."})]}),e.jsxs(W,{onClick:()=>a("/mission-control/connect-page"),children:[e.jsx(Do,{className:"h-4 w-4 mr-1"})," Set Up Connect Page"]})]})]})})}function Ibs(){return gt({queryKey:["video-script-categories"],queryFn:async()=>{const{data:t,error:s}=await G.from("video_script_categories").select("*").order("sort_order");if(s)throw s;return t}})}function Lbs(t){return gt({queryKey:["video-scripts",t],queryFn:async()=>{let s=G.from("video_scripts").select("*, category:video_script_categories(*)").eq("is_active",!0).order("title");const{data:r,error:n}=await s;if(n)throw n;return r}})}function Dbs(){const{user:t}=Us();return gt({queryKey:["user-video-scripts",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:s,error:r}=await G.from("user_video_scripts").select("*, category:video_script_categories(*)").eq("owner_user_id",t.id).order("title");if(r)throw r;return s},enabled:!!(t!=null&&t.id)})}function Rbs(){const{user:t}=Us(),s=Qt();return Pt({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await G.from("user_video_scripts").insert([{owner_user_id:t.id,source_script_id:r.id,category_id:r.category_id,title:r.title,script_text:r.script_text,tags:r.tags,is_custom:!1}]).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["user-video-scripts"]})}})}function Obs(t){const{user:s}=Us();return gt({queryKey:["agent-videos",s==null?void 0:s.id,t],queryFn:async()=>{if(!(s!=null&&s.id))return[];let r=G.from("agent_videos").select("*, contact:innercircle_contacts(id, first_name, last_name)").eq("owner_user_id",s.id).order("created_at",{ascending:!1});r=r.eq("is_deleted",!1);const{data:n,error:a}=await r;if(a)throw a;return n},enabled:!!(s!=null&&s.id)})}function Fbs(t){return gt({queryKey:["agent-video",t],queryFn:async()=>{const{data:s,error:r}=await G.from("agent_videos").select("*, contact:innercircle_contacts(id, first_name, last_name)").eq("id",t).single();if(r)throw r;return s},enabled:!!t})}function Mw(){const{user:t}=Us(),s=Qt();return Pt({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await G.from("agent_videos").insert([{owner_user_id:t.id,contact_id:r.contact_id,bunny_video_id:r.bunny_video_id,playback_url:r.playback_url,thumbnail_url:r.thumbnail_url,preview_url:r.preview_url,duration_seconds:r.duration_seconds,file_size_mb:r.file_size_mb||0,title:r.title,notes:r.notes,task_id:r.task_id,status:r.status||"processing",touch_type:r.touch_type||"video",page_template:"default"}]).select("*, share_token").single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["agent-videos"]}),s.invalidateQueries({queryKey:["storage-usage"]})}})}function zbs(){const t=Qt();return Pt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("agent_videos").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["agent-videos"]}),t.invalidateQueries({queryKey:["agent-video",s.id]})}})}function Bbs(){const t=Qt();return Pt({mutationFn:async({id:s,bunnyVideoId:r,hardDelete:n=!1})=>{if(console.log("Deleting video:",{id:s,bunnyVideoId:r,hardDelete:n}),r){console.log("Calling bunny-upload delete for videoId:",r);const{data:a,error:o}=await G.functions.invoke("bunny-upload",{body:{action:"delete",videoId:r,isAgentVideo:!0}});o?console.error("Failed to delete from Bunny:",o):console.log("Bunny delete response:",a)}else console.warn("No bunnyVideoId provided, skipping Bunny.net deletion");if(n){console.log("Hard deleting from database:",s);const{error:a}=await G.from("agent_videos").delete().eq("id",s);if(a)throw a}else{console.log("Soft deleting from database:",s);const{error:a}=await G.from("agent_videos").update({is_deleted:!0}).eq("id",s);if(a)throw a}console.log("Video deletion complete")},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-videos"]}),t.invalidateQueries({queryKey:["storage-usage"]})}})}function Ame(){const{user:t}=Us();return gt({queryKey:["storage-usage",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return null;const{data:s,error:r}=await G.from("agent_storage_usage").select("*").eq("user_id",t.id).maybeSingle();if(r)throw r;return s||{user_id:t.id,total_storage_mb:0,storage_tier:"basic",max_storage_mb:1024}},enabled:!!(t!=null&&t.id)})}function ait(){const{data:t,isLoading:s}=Ame(),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 wE(t){const{data:s,error:r}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:t,isAgentVideo:!0}});if(r)throw r;return s}async function jE(t){const{data:s,error:r}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:t,isAgentVideo:!0}});if(r)throw r;return s}async function nw(t){const{data:s,error:r}=await G.functions.invoke("bunny-upload",{body:{action:"status",videoId:t,isAgentVideo:!0}});if(r)throw r;return s}function $bs(){const{user:t}=Us(),s=Qt();return Pt({mutationFn:async({contactId:r,videoId:n,notes:a})=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:o}=await G.from("action_types").select("id").eq("name","Video").single();if(!o)throw new Error("Video action type not found");const{data:l,error:i}=await G.from("contact_touch_logs").insert([{owner_user_id:t.id,contact_id:r,action_type_id:o.id,notes:a||`Quick Video Touch - Video ID: ${n}`}]).select().single();if(i)throw i;return l},onSuccess:()=>{s.invalidateQueries({queryKey:["contact-touch-logs"]}),s.invalidateQueries({queryKey:["contacts"]})}})}function qbs(t){return gt({queryKey:["contact-video-replies",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("video_replies").select(` *, video:agent_videos(id, title, thumbnail_url, playback_url) `).eq("contact_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function Ubs(t){return gt({queryKey:["client-portal",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("client_portals").select("*").eq("deal_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t})}function BSe(){const t=ya(),s=Qt();return Pt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.from("client_portals").insert({deal_id:r.deal_id,owner_user_id:t,slug:"",is_enabled:r.is_enabled??!0,visibility:r.visibility||"private",require_onboarding:r.require_onboarding??!0,allow_spouse:r.allow_spouse??!1,client_name:r.client_name||null,client_email:r.client_email||null,client_phone:r.client_phone||null,invite_method:r.invite_method||"email"}).select().single();if(a)throw a;return n},onSuccess:(r,n)=>{s.invalidateQueries({queryKey:["client-portal",n.deal_id]})}})}function bO(){const t=Qt();return Pt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("client_portals").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["client-portal",s.deal_id]}),t.invalidateQueries({queryKey:["all-client-portals"]})}})}function Vbs(){const t=Qt();return Pt({mutationFn:async s=>{const{data:r,error:n}=await G.from("client_portals").update({archived_at:new Date().toISOString(),is_enabled:!1}).eq("id",s).select().single();if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["client-portal",s.deal_id]}),t.invalidateQueries({queryKey:["all-client-portals"]})}})}function Hbs(){const t=Qt();return Pt({mutationFn:async s=>{const{data:r,error:n}=await G.from("client_portals").update({archived_at:null}).eq("id",s).select().single();if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["client-portal",s.deal_id]}),t.invalidateQueries({queryKey:["all-client-portals"]})}})}function Gbs(){const t=Qt();return Pt({mutationFn:async({id:s,dealId:r})=>{await G.from("portal_updates").delete().eq("portal_id",s);const{error:n}=await G.from("client_portals").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["client-portal",s]}),t.invalidateQueries({queryKey:["all-client-portals"]})}})}function iit(){const t=Qt();return Pt({mutationFn:async s=>{const{data:r,error:n}=await G.from("portal_updates").insert({portal_id:s.portal_id,title:s.title,content:s.content||null,video_url:s.video_url||null,is_stage_change:s.is_stage_change||!1}).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["portal-updates",r.portal_id]})}})}function Wbs(){const t=ya();return gt({queryKey:["portal-custom-questions",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("portal_custom_questions").select("*").eq("owner_user_id",t).eq("is_active",!0).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function Kbs(){const t=ya(),s=Qt();return Pt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.from("portal_custom_questions").insert({owner_user_id:t,question_text:r.question_text,field_type:r.field_type,options:r.options||[],is_required:r.is_required||!1,sort_order:r.sort_order||0}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["portal-custom-questions"]})}})}function Zbs(){const t=Qt();return Pt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("portal_custom_questions").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["portal-custom-questions"]})}})}function Ybs(){const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("portal_custom_questions").update({is_active:!1}).eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["portal-custom-questions"]})}})}function o1(t){const s=window.location.hostname;return s==="localhost"||s.includes("lovable.app")?`${window.location.origin}/portal/${t}`:`https://clients.relevelup.com/${t}`}function Xbs({contactId:t}){const s=wr(),r=Qt(),[n,a]=k.useState(null),[o,l]=k.useState(!1),[i,d]=k.useState(!1),[u,p]=k.useState(""),[f,y]=k.useState(""),[_,b]=k.useState(null),N=bO(),w=iit(),{data:S,isLoading:C}=gt({queryKey:["contact-portals",t],queryFn:async()=>{const{data:q,error:B}=await G.from("deal_pipeline").select("id, deal_name, deal_type").eq("contact_id",t);if(B)throw B;if(!q||q.length===0)return[];const U=q.map(J=>J.id),{data:te,error:Y}=await G.from("client_portals").select("*").in("deal_id",U).is("archived_at",null);if(Y)throw Y;return(te||[]).map(J=>({...J,deal:q.find(X=>X.id===J.deal_id)}))},enabled:!!t}),A=(S==null?void 0:S.map(q=>q.id))||[],{data:I}=gt({queryKey:["contact-portal-updates",A],queryFn:async()=>{if(A.length===0)return{};const{data:q,error:B}=await G.from("portal_updates").select("*").in("portal_id",A).order("created_at",{ascending:!1});if(B)throw B;const U={};return(q||[]).forEach(te=>{U[te.portal_id]||(U[te.portal_id]=te)}),U},enabled:A.length>0}),L=q=>{navigator.clipboard.writeText(o1(q)),a(q),pe.success("Portal link copied!"),setTimeout(()=>a(null),2e3)},O=async q=>{u.trim()&&(await w.mutateAsync({portal_id:q,title:u,content:f||void 0}),d(!1),p(""),y(""),r.invalidateQueries({queryKey:["contact-portal-updates"]}),pe.success("Portal update posted!"))},V=async()=>{_&&(await N.mutateAsync({id:_.id,welcome_message:_.welcome_message,next_step_text:_.next_step_text,is_enabled:_.is_enabled,show_post_close_tips:_.show_post_close_tips,review_url:_.review_url}),l(!1),b(null),r.invalidateQueries({queryKey:["contact-portals",t]}),pe.success("Portal settings updated!"))};return C||!S||S.length===0?null:e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(nd,{className:"h-4 w-4"}),"Client Portal"]})}),e.jsx(Oe,{className:"space-y-3",children:S.map(q=>{var Y,J,X;const B=((Y=q.stage_mapping)==null?void 0:Y.length)>0?q.stage_mapping:FNe(((J=q.deal)==null?void 0:J.deal_type)||"buyer"),U=B==null?void 0:B[q.current_stage_index??0],te=I==null?void 0:I[q.id];return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:((X=q.deal)==null?void 0:X.deal_name)||"Portal"}),U&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Stage: ",U.label||U.name]})]}),e.jsx(Qe,{variant:q.is_enabled?"default":"secondary",className:"text-[10px] flex-shrink-0",children:q.is_enabled?"Active":"Disabled"})]}),te&&e.jsxs("div",{className:"bg-muted/50 rounded-md p-2",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:te.title}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:vs(new Date(te.created_at),"MMM d, yyyy")})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsxs(W,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>L(q.slug),children:[n===q.slug?e.jsx(Zn,{className:"h-3 w-3 mr-1"}):e.jsx(Va,{className:"h-3 w-3 mr-1"}),"Copy Link"]}),e.jsxs(W,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>window.open(o1(q.slug),"_blank"),children:[e.jsx(Yr,{className:"h-3 w-3 mr-1"}),"View"]}),e.jsxs(fs,{open:i,onOpenChange:d,children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>d(!0),children:[e.jsx(wi,{className:"h-3 w-3 mr-1"}),"Post Update"]})}),e.jsxs(ps,{children:[e.jsx(ks,{children:e.jsx(_s,{children:"Post Portal Update"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Title"}),e.jsx(De,{value:u,onChange:ce=>p(ce.target.value),placeholder:"e.g. Inspection completed!"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Details (optional)"}),e.jsx(_r,{value:f,onChange:ce=>y(ce.target.value),placeholder:"Add more details...",rows:3})]}),e.jsxs(W,{onClick:()=>O(q.id),disabled:!u.trim()||w.isPending,className:"w-full",children:[e.jsx(_n,{className:"h-4 w-4 mr-1"}),"Post Update"]})]})]})]}),e.jsxs(fs,{open:o,onOpenChange:l,children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{b({...q}),l(!0)},children:[e.jsx(So,{className:"h-3 w-3 mr-1"}),"Settings"]})}),e.jsxs(ps,{children:[e.jsx(ks,{children:e.jsx(_s,{children:"Portal Settings"})}),_&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{children:"Portal Enabled"}),e.jsx(Ar,{checked:_.is_enabled,onCheckedChange:ce=>b({..._,is_enabled:ce})})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Welcome Message"}),e.jsx(_r,{value:_.welcome_message||"",onChange:ce=>b({..._,welcome_message:ce.target.value}),placeholder:"Welcome to your home journey!",rows:2})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Next Step"}),e.jsx(De,{value:_.next_step_text||"",onChange:ce=>b({..._,next_step_text:ce.target.value}),placeholder:"What your client should do next..."})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Review URL"}),e.jsx(De,{value:_.review_url||"",onChange:ce=>b({..._,review_url:ce.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{children:"Show Post-Close Tips"}),e.jsx(Ar,{checked:_.show_post_close_tips,onCheckedChange:ce=>b({..._,show_post_close_tips:ce})})]}),e.jsx(ho,{}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{onClick:V,disabled:N.isPending,className:"flex-1",children:"Save Settings"}),e.jsxs(W,{variant:"outline",onClick:()=>s(`/mission-control/pipeline?deal=${q.deal_id}`),children:[e.jsx(Wa,{className:"h-4 w-4 mr-1"}),"Full Settings"]})]})]})]})]})]}),S.length>1&&e.jsx(ho,{})]},q.id)})})]})}function Qbs({contactId:t}){const{data:s}=gt({queryKey:["agent-lead-sites-slugs"],queryFn:async()=>{const{data:l,error:i}=await G.from("lead_sites").select("id, subdomain_slug").eq("is_active",!0);if(i)throw i;return new Map((l||[]).map(d=>[d.id,d.subdomain_slug]))},staleTime:6e5}),r=s&&s.size>0,{data:n,isLoading:a}=gt({queryKey:["contact-property-views",t],queryFn:async()=>{const{data:l,error:i}=await G.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(Dt,{className:"pb-2",children:e.jsxs(zt,{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(jn,{className:"h-4 w-4 text-primary"})}),"Property Activity",e.jsxs(Qe,{variant:"secondary",className:"text-xs ml-auto",children:[n.length," ",n.length===1?"property":"properties"]})]})}),e.jsx(Oe,{className:"pt-0",children:e.jsx("div",{className:"space-y-1",children:n.map(l=>{const i=o(l),d=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:d,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(Mn,{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:d})}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(nn,{className:"h-3 w-3"}),e.jsx("span",{title:vs(new Date(l.viewed_at),"PPp"),children:Nl(new Date(l.viewed_at),{addSuffix:!0})})]})]}),i&&e.jsx(Yr,{className:"h-3.5 w-3.5 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity"})]},l.mls_number)})})})]})}const Jbs=["Single Family","Condo","Townhouse","Multi-Family","Land","Commercial"];function G7e({value:t,onChange:s,onAdd:r,suggestions:n,placeholder:a,icon:o}){const[l,i]=k.useState(!1),d=k.useRef(null),u=k.useRef(null);k.useEffect(()=>{const f=y=>{u.current&&!u.current.contains(y.target)&&d.current&&!d.current.contains(y.target)&&i(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);const p=n.filter(f=>f.toLowerCase().includes(t.toLowerCase()));return e.jsxs("div",{className:"relative flex-1",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(De,{ref:d,value:t,onChange:f=>{s(f.target.value),i(!0)},onFocus:()=>i(!0),placeholder:a,onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),p.length>0?r(p[0]):r(t))}}),n.length>0&&e.jsx(Bi,{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(W,{type:"button",variant:"outline",size:"sm",onClick:()=>r(t),children:e.jsx(qs,{className:"h-4 w-4"})})]}),l&&p.length>0&&e.jsx("div",{ref:u,className:"absolute z-50 mt-1 w-full max-h-60 overflow-y-auto rounded-md border bg-popover shadow-md",children:p.map(f=>e.jsxs("button",{type:"button",className:"w-full text-left px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors flex items-center gap-2",onClick:()=>{r(f),i(!1)},children:[o||e.jsx(Ia,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),f]},f))})]})}function ews({contactId:t,contactName:s}){var B,U,te;const{user:r}=Us(),n=ya(),{hasLeadSite:a}=CC(),o=Qt(),[l,i]=k.useState(!1),[d,u]=k.useState(""),[p,f]=k.useState(""),{data:y}=gt({queryKey:["agent-lead-site-config",n],queryFn:async()=>{const{data:Y,error:J}=await G.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 X=Y.theme_config||{},ce=Array.isArray(X.searchCities)?X.searchCities:[];Y.mls_market_area&&!ce.includes(Y.mls_market_area)&&ce.unshift(Y.mls_market_area);const ie=Array.isArray(X.searchZipCodes)?X.searchZipCodes:[];return{cities:ce,zipCodes:ie}},enabled:!!n}),{data:_,isLoading:b}=gt({queryKey:["contact-property-alert",t],queryFn:async()=>{const{data:Y,error:J}=await G.from("contact_property_alerts").select("*").eq("contact_id",t).maybeSingle();if(J)throw J;return Y},enabled:!!t&&!!r}),[N,w]=k.useState({}),S=()=>{w({is_active:(_==null?void 0:_.is_active)??!0,min_price:(_==null?void 0:_.min_price)??null,max_price:(_==null?void 0:_.max_price)??null,min_beds:(_==null?void 0:_.min_beds)??null,min_baths:(_==null?void 0:_.min_baths)??null,min_sqft:(_==null?void 0:_.min_sqft)??null,max_sqft:(_==null?void 0:_.max_sqft)??null,cities:(_==null?void 0:_.cities)??[],zip_codes:(_==null?void 0:_.zip_codes)??[],property_types:(_==null?void 0:_.property_types)??[],frequency:(_==null?void 0:_.frequency)??"daily"}),i(!0)},C=Pt({mutationFn:async()=>{const Y={contact_id:t,owner_user_id:n,is_active:N.is_active??!0,min_price:N.min_price||null,max_price:N.max_price||null,min_beds:N.min_beds||null,min_baths:N.min_baths||null,min_sqft:N.min_sqft||null,max_sqft:N.max_sqft||null,cities:N.cities||[],zip_codes:N.zip_codes||[],property_types:N.property_types||[],frequency:N.frequency||"daily"};if(_!=null&&_.id){const{error:J}=await G.from("contact_property_alerts").update(Y).eq("id",_.id);if(J)throw J}else{const{error:J}=await G.from("contact_property_alerts").insert(Y);if(J)throw J}},onSuccess:()=>{o.invalidateQueries({queryKey:["contact-property-alert",t]}),i(!1),pe.success("Property alert saved!")},onError:Y=>{pe.error(Y.message||"Failed to save alert")}}),A=Pt({mutationFn:async()=>{if(!(_!=null&&_.id))return;const{error:Y}=await G.from("contact_property_alerts").delete().eq("id",_.id);if(Y)throw Y},onSuccess:()=>{o.invalidateQueries({queryKey:["contact-property-alert",t]}),i(!1),pe.success("Property alert removed")}}),I=Y=>{var X;const J=Y.trim();J&&!((X=N.cities)!=null&&X.includes(J))&&w(ce=>({...ce,cities:[...ce.cities||[],J]})),u("")},L=Y=>{var X;const J=Y.trim();J&&!((X=N.zip_codes)!=null&&X.includes(J))&&w(ce=>({...ce,zip_codes:[...ce.zip_codes||[],J]})),f("")},O=Y=>{w(J=>{const X=J.property_types||[];return{...J,property_types:X.includes(Y)?X.filter(ce=>ce!==Y):[...X,Y]}})};if(!a||b)return null;if(_&&!l)return e.jsxs(Pe,{className:"overflow-hidden",children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx("div",{className:`h-7 w-7 rounded-lg flex items-center justify-center ${_.is_active?"bg-green-500/10":"bg-muted"}`,children:_.is_active?e.jsx(Sm,{className:"h-4 w-4 text-green-600"}):e.jsx(Wv,{className:"h-4 w-4 text-muted-foreground"})}),"Property Alerts",e.jsxs(Qe,{variant:_.is_active?"default":"secondary",className:"text-xs ml-auto",children:[_.is_active?"Active":"Paused"," · ",_.frequency]})]})}),e.jsxs(Oe,{className:"pt-0 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5 text-xs",children:[_.min_price||_.max_price?e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(_c,{className:"h-3 w-3"}),_.min_price?`$${(_.min_price/1e3).toFixed(0)}k`:"$0"," - ",_.max_price?`$${(_.max_price/1e3).toFixed(0)}k`:"Any"]}):null,_.min_beds?e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(W4,{className:"h-3 w-3"}),_.min_beds,"+ beds"]}):null,_.min_baths?e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(nf,{className:"h-3 w-3"}),_.min_baths,"+ baths"]}):null,(B=_.cities)==null?void 0:B.map(Y=>e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(Ia,{className:"h-3 w-3"}),Y]},Y)),(U=_.zip_codes)==null?void 0:U.map(Y=>e.jsx(Qe,{variant:"outline",children:Y},Y)),(te=_.property_types)==null?void 0:te.map(Y=>e.jsx(Qe,{variant:"outline",children:Y},Y))]}),_.last_sent_at&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last sent: ",new Date(_.last_sent_at).toLocaleDateString()]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{variant:"outline",size:"sm",onClick:S,className:"flex-1",children:"Manage Alert"}),e.jsxs(W,{variant:"destructive",size:"sm",onClick:()=>A.mutate(),disabled:A.isPending,className:"flex-1",children:[A.isPending?e.jsx(us,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(kr,{className:"h-4 w-4 mr-1"}),"Remove Alert"]})]})]})]});const V=((y==null?void 0:y.cities)||[]).filter(Y=>{var J;return!((J=N.cities)!=null&&J.includes(Y))}),q=((y==null?void 0:y.zipCodes)||[]).filter(Y=>{var J;return!((J=N.zip_codes)!=null&&J.includes(Y))});return l?e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Sm,{className:"h-4 w-4 text-primary"}),_?"Edit":"Setup"," Property Alert for ",s]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{children:"Alert Active"}),e.jsx(Ar,{checked:N.is_active??!0,onCheckedChange:Y=>w(J=>({...J,is_active:Y}))})]}),e.jsxs("div",{children:[e.jsxs(xe,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(_c,{className:"h-3.5 w-3.5"})," Price Range"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(De,{type:"number",placeholder:"Min price",value:N.min_price??"",onChange:Y=>w(J=>({...J,min_price:Y.target.value?Number(Y.target.value):null}))}),e.jsx(De,{type:"number",placeholder:"Max price",value:N.max_price??"",onChange:Y=>w(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(xe,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(W4,{className:"h-3.5 w-3.5"})," Min Beds"]}),e.jsxs($s,{value:N.min_beds?String(N.min_beds):"any",onValueChange:Y=>w(J=>({...J,min_beds:Y==="any"?null:Number(Y)})),children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Any"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"any",children:"Any"}),[1,2,3,4,5].map(Y=>e.jsxs(vt,{value:String(Y),children:[Y,"+"]},Y))]})]})]}),e.jsxs("div",{children:[e.jsxs(xe,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(nf,{className:"h-3.5 w-3.5"})," Min Baths"]}),e.jsxs($s,{value:N.min_baths?String(N.min_baths):"any",onValueChange:Y=>w(J=>({...J,min_baths:Y==="any"?null:Number(Y)})),children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Any"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"any",children:"Any"}),[1,1.5,2,2.5,3,4].map(Y=>e.jsxs(vt,{value:String(Y),children:[Y,"+"]},Y))]})]})]})]}),e.jsxs("div",{children:[e.jsxs(xe,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(xS,{className:"h-3.5 w-3.5"})," Square Feet"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(De,{type:"number",placeholder:"Min sqft",value:N.min_sqft??"",onChange:Y=>w(J=>({...J,min_sqft:Y.target.value?Number(Y.target.value):null}))}),e.jsx(De,{type:"number",placeholder:"Max sqft",value:N.max_sqft??"",onChange:Y=>w(J=>({...J,max_sqft:Y.target.value?Number(Y.target.value):null}))})]})]}),e.jsxs("div",{children:[e.jsxs(xe,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(Ia,{className:"h-3.5 w-3.5"})," Cities"]}),e.jsx(G7e,{value:d,onChange:u,onAdd:I,suggestions:V,placeholder:"Type to search cities..."}),N.cities&&N.cities.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:N.cities.map(Y=>e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[Y,e.jsx("button",{onClick:()=>w(J=>{var X;return{...J,cities:(X=J.cities)==null?void 0:X.filter(ce=>ce!==Y)}}),children:e.jsx(kr,{className:"h-3 w-3"})})]},Y))})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"mb-1.5",children:"Zip Codes"}),e.jsx(G7e,{value:p,onChange:f,onAdd:L,suggestions:q,placeholder:"Type to search zip codes...",icon:e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:"#"})}),N.zip_codes&&N.zip_codes.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:N.zip_codes.map(Y=>e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[Y,e.jsx("button",{onClick:()=>w(J=>{var X;return{...J,zip_codes:(X=J.zip_codes)==null?void 0:X.filter(ce=>ce!==Y)}}),children:e.jsx(kr,{className:"h-3 w-3"})})]},Y))})]}),e.jsxs("div",{children:[e.jsxs(xe,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(Mn,{className:"h-3.5 w-3.5"})," Property Types"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Jbs.map(Y=>{var J;return e.jsx(Qe,{variant:(J=N.property_types)!=null&&J.includes(Y)?"default":"outline",className:"cursor-pointer",onClick:()=>O(Y),children:Y},Y)})})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"mb-1.5",children:"Frequency"}),e.jsxs($s,{value:N.frequency||"daily",onValueChange:Y=>w(J=>({...J,frequency:Y})),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"daily",children:"Daily"}),e.jsx(vt,{value:"weekly",children:"Weekly"})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(W,{onClick:()=>C.mutate(),disabled:C.isPending,className:"flex-1",children:[C.isPending?e.jsx(us,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(bc,{className:"h-4 w-4 mr-1"}),"Save Alert"]}),e.jsx(W,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),_&&e.jsx(W,{variant:"destructive",size:"icon",onClick:()=>A.mutate(),disabled:A.isPending,children:e.jsx(kr,{className:"h-4 w-4"})})]})]})]}):e.jsx(Pe,{className:"overflow-hidden",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("button",{onClick:S,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(Sm,{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 tws({contactId:t,contactName:s}){var ie;const{user:r}=Us(),n=ya(),{hasLeadSite:a}=CC(),o=Qt(),[l,i]=k.useState(!1),[d,u]=k.useState(""),[p,f]=k.useState([]),[y,_]=k.useState(!1),[b,N]=k.useState(!1),[w,S]=k.useState(!1),[C,A]=k.useState(""),I=k.useRef(null),L=k.useRef(null),{data:O}=gt({queryKey:["agent-lead-site-cities",n],queryFn:async()=>{const{data:ae,error:oe}=await G.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||!ae)return[];const me=ae.theme_config||{},ve=Array.isArray(me.searchCities)?me.searchCities:[];return ae.mls_market_area&&!ve.includes(ae.mls_market_area)&&ve.unshift(ae.mls_market_area),ve},enabled:!!n}),{data:V,isLoading:q}=gt({queryKey:["contact-market-report",t],queryFn:async()=>{const{data:ae,error:oe}=await G.from("innercircle_contacts").select("market_report_enabled, market_report_cities").eq("id",t).single();if(oe)throw oe;return ae},enabled:!!t&&!!r});k.useEffect(()=>{const ae=oe=>{L.current&&!L.current.contains(oe.target)&&I.current&&!I.current.contains(oe.target)&&N(!1)};return document.addEventListener("mousedown",ae),()=>document.removeEventListener("mousedown",ae)},[]);const B=()=>{_((V==null?void 0:V.market_report_enabled)??!1),f((V==null?void 0:V.market_report_cities)??[]),i(!0)},U=ae=>{const oe=(ae||d).trim();oe&&!p.includes(oe)&&f([...p,oe]),u(""),N(!1)},te=(O||[]).filter(ae=>!p.includes(ae)&&ae.toLowerCase().includes(d.toLowerCase())),Y=Pt({mutationFn:async()=>{const{data:ae,error:oe}=await G.functions.invoke("send-market-report",{body:{action:"preview",agentId:n,cities:(V==null?void 0:V.market_report_cities)??[]}});if(oe)throw new Error(oe.message||"Failed to generate preview");if(ae&&!ae.ok&&ae.error)throw new Error(ae.error);return ae},onSuccess:ae=>{A(ae.html),S(!0)},onError:ae=>{pe.error(ae.message||"Failed to generate preview")}}),J=Pt({mutationFn:async()=>{const{data:ae,error:oe}=await G.functions.invoke("send-market-report",{body:{action:"send",agentId:n,cities:(V==null?void 0:V.market_report_cities)??[],contactIds:[t]}});if(oe)throw new Error(oe.message||"Failed to send report");if(ae&&!ae.ok&&ae.error)throw new Error(ae.error);return ae},onSuccess:()=>{pe.success(`Market report sent to ${s}!`)},onError:ae=>{pe.error(ae.message||"Failed to send report")}}),X=Pt({mutationFn:async()=>{const{error:ae}=await G.from("innercircle_contacts").update({market_report_enabled:y,market_report_cities:p}).eq("id",t);if(ae)throw ae},onSuccess:()=>{o.invalidateQueries({queryKey:["contact-market-report",t]}),i(!1),pe.success(y?"Monthly market report enabled!":"Market report disabled")},onError:ae=>{pe.error(ae.message||"Failed to save")}}),ce=Pt({mutationFn:async()=>{const{error:ae}=await G.from("innercircle_contacts").update({market_report_enabled:!1,market_report_cities:[]}).eq("id",t);if(ae)throw ae},onSuccess:()=>{o.invalidateQueries({queryKey:["contact-market-report",t]}),i(!1),_(!1),f([]),pe.success("Market report removed")},onError:ae=>{pe.error(ae.message||"Failed to remove market report")}});return!a||q?null:V!=null&&V.market_report_enabled&&!l?e.jsxs(Pe,{className:"overflow-hidden",children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{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(so,{className:"h-4 w-4 text-primary"})}),"Monthly Market Report",e.jsx(Qe,{variant:"default",className:"text-xs ml-auto",children:"Active"})]})}),e.jsxs(Oe,{className:"pt-0 space-y-2",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5 text-xs",children:((ie=V.market_report_cities)==null?void 0:ie.length)>0?V.market_report_cities.map(ae=>e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(Ia,{className:"h-3 w-3"}),ae]},ae)):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(W,{variant:"outline",size:"sm",onClick:()=>Y.mutate(),disabled:Y.isPending,className:"flex-1",children:[Y.isPending?e.jsx(us,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(jn,{className:"h-4 w-4 mr-1"}),"Preview"]}),e.jsxs(W,{variant:"default",size:"sm",onClick:()=>J.mutate(),disabled:J.isPending,className:"flex-1",children:[J.isPending?e.jsx(us,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(_n,{className:"h-4 w-4 mr-1"}),"Send Now"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{variant:"outline",size:"sm",onClick:B,className:"flex-1",children:"Manage"}),e.jsxs(W,{variant:"destructive",size:"sm",onClick:()=>ce.mutate(),disabled:ce.isPending,className:"flex-1",children:[ce.isPending?e.jsx(us,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(kr,{className:"h-4 w-4 mr-1"}),"Remove"]})]}),e.jsx(fs,{open:w,onOpenChange:S,children:e.jsxs(ps,{className:"max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsx(ks,{children:e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(so,{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:C}})}),e.jsxs("div",{className:"flex gap-2 pt-4 border-t",children:[e.jsxs(W,{onClick:()=>{S(!1),J.mutate()},disabled:J.isPending,className:"flex-1",children:[J.isPending?e.jsx(us,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(_n,{className:"h-4 w-4 mr-1"}),"Send to ",s]}),e.jsx(W,{variant:"outline",onClick:()=>S(!1),children:"Close"})]})]})})]})]}):l?e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(so,{className:"h-4 w-4 text-primary"}),"Market Report for ",s]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{children:"Send Monthly Report"}),e.jsx(Ar,{checked:y,onCheckedChange:_})]}),y&&e.jsxs("div",{children:[e.jsxs(xe,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(Ia,{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(De,{ref:I,value:d,onChange:ae=>{u(ae.target.value),N(!0)},onFocus:()=>N(!0),placeholder:"Type to search cities...",onKeyDown:ae=>{ae.key==="Enter"&&(ae.preventDefault(),te.length>0?U(te[0]):U())}}),e.jsx(Bi,{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(W,{type:"button",variant:"outline",size:"sm",onClick:()=>U(),children:e.jsx(qs,{className:"h-4 w-4"})})]}),b&&te.length>0&&e.jsx("div",{ref:L,className:"absolute z-50 mt-1 w-full max-h-60 overflow-y-auto rounded-md border bg-popover shadow-md",children:te.map(ae=>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:()=>U(ae),children:[e.jsx(Ia,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),ae]},ae))})]}),p.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:p.map(ae=>e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[ae,e.jsx("button",{onClick:()=>f(p.filter(oe=>oe!==ae)),children:e.jsx(kr,{className:"h-3 w-3"})})]},ae))})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(W,{onClick:()=>X.mutate(),disabled:X.isPending,className:"flex-1",children:[X.isPending?e.jsx(us,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(bc,{className:"h-4 w-4 mr-1"}),"Save"]}),e.jsx(W,{variant:"outline",onClick:()=>i(!1),children:"Cancel"})]})]})]}):e.jsx(Pe,{className:"overflow-hidden",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("button",{onClick:B,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(so,{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 sws(t){return gt({queryKey:["contact-drip-activity",t],queryFn:async()=>{if(!t)return{enrollments:[],stepLogs:[]};const{data:s,error:r}=await G.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(d=>d.id),a=Array.from(new Set((s||[]).map(d=>d.campaign_id)));let o=new Map;if(a.length>0){const{data:d}=await G.from("drip_campaigns").select("id, name, description, is_active").in("id",a);(d||[]).forEach(u=>o.set(u.id,u))}const l=(s||[]).map(d=>({...d,campaign:o.get(d.campaign_id)||null}));let i=[];if(n.length>0){const{data:d,error:u}=await G.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=(d||[]).map(p=>{var f;return{...p,campaign:{name:((f=o.get(p.campaign_id))==null?void 0:f.name)??""}}})}return{enrollments:l,stepLogs:i}},enabled:!!t})}function rws(t){switch(t){case"active":return e.jsx(Qe,{variant:"secondary",className:"bg-emerald-500/10 text-emerald-600 border-emerald-500/20",children:"Active"});case"paused":return e.jsx(Qe,{variant:"secondary",className:"bg-amber-500/10 text-amber-600 border-amber-500/20",children:"Paused"});case"completed":return e.jsx(Qe,{variant:"secondary",className:"bg-sky-500/10 text-sky-600 border-sky-500/20",children:"Completed"});case"exited":return e.jsx(Qe,{variant:"outline",children:"Exited"});default:return e.jsx(Qe,{variant:"outline",children:t})}}function W7e(t){return t==="sent"?e.jsx($n,{className:"h-4 w-4 text-emerald-500"}):t==="failed"?e.jsx(Dc,{className:"h-4 w-4 text-destructive"}):t==="skipped"?e.jsx(hh,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(nn,{className:"h-4 w-4 text-muted-foreground"})}function nws({contactId:t}){const s=wr(),{data:r,isLoading:n}=sws(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(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2 text-base",children:[e.jsx(_S,{className:"h-5 w-5 text-emerald-500"}),"Drip Campaign Activity"]})}),e.jsxs(Oe,{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(d=>{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(_S,{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=d.campaign)==null?void 0:u.name)||"Untitled campaign"}),rws(d.status)]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Step ",d.current_step+1,d.next_send_at&&d.status==="active"&&e.jsxs(e.Fragment,{children:[" · Next: ",Nl(new Date(d.next_send_at),{addSuffix:!0})]}),d.completed_at&&e.jsxs(e.Fragment,{children:[" · Completed ",Nl(new Date(d.completed_at),{addSuffix:!0})]}),d.exited_at&&!d.completed_at&&e.jsxs(e.Fragment,{children:[" · ",d.exit_reason||"Exited"," ",Nl(new Date(d.exited_at),{addSuffix:!0})]})]})]}),e.jsx(xa,{className:"h-4 w-4 text-muted-foreground mt-1 flex-shrink-0"})]},d.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(d=>{var u,p;return e.jsxs(fs,{open:(a==null?void 0:a.id)===d.id,onOpenChange:f=>!f&&o(null),children:[e.jsx(mi,{asChild:!0,children:e.jsxs("button",{onClick:()=>o(d),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:W7e(d.status)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[d.channel==="sms"?e.jsx(wi,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}):e.jsx(tr,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),e.jsx("p",{className:"text-sm truncate",children:d.subject||`${d.channel.toUpperCase()} step ${d.step_order+1}`})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:[((u=d.campaign)==null?void 0:u.name)||"Campaign"," · ",vs(new Date(d.sent_at),"MMM d, h:mm a")]}),d.status==="failed"&&d.error_message&&e.jsx("p",{className:"text-xs text-destructive mt-0.5 truncate",children:d.error_message})]})]})}),e.jsxs(ps,{className:"max-w-lg",children:[e.jsx(ks,{children:e.jsxs(_s,{className:"flex items-center gap-2",children:[W7e(d.status),d.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:((p=d.campaign)==null?void 0:p.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:d.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:["#",d.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:d.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:d.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:vs(new Date(d.sent_at),"MMM d, yyyy h:mm a")})]}),d.error_message&&e.jsx("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 p-2 text-destructive text-xs",children:d.error_message})]})]})]},d.id)}),i.length>8&&e.jsx(W,{variant:"ghost",size:"sm",className:"w-full text-xs",onClick:()=>s("/mission-control/smart-drips"),children:"View all in Smart Drips"})]})]})]})]})}function aws({videoId:t}){var l;const{data:s,isLoading:r,error:n}=Fbs(t);if(r)return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ms,{className:"w-full aspect-video rounded-lg"}),e.jsx(Ms,{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(Dc,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-medium",children:"Video Unavailable"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"This video has been deleted or is no longer available."})]});const a=i=>{let d=i;return d.includes("iframe.mediadelivery.net/play/")&&(d=d.replace("/play/","/embed/"),d+=(d.includes("?")?"&":"?")+"autoplay=true&responsive=true"),d},o=(l=s.playback_url)==null?void 0:l.includes("iframe.mediadelivery.net");return e.jsxs("div",{className:"space-y-4",children:[s.playback_url?e.jsx("div",{className:"relative w-full aspect-video bg-black rounded-lg overflow-hidden",children:o?e.jsx("iframe",{src:a(s.playback_url),title:s.title||"Video preview",className:"absolute top-0 left-0 w-full h-full",style:{border:0},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0}):e.jsx("video",{src:s.playback_url,controls:!0,autoPlay:!0,className:"absolute top-0 left-0 w-full h-full object-contain"})}):e.jsx("div",{className:"w-full aspect-video bg-muted rounded-lg flex items-center justify-center",children:e.jsx("p",{className:"text-muted-foreground",children:"Video is still processing..."})}),s.title&&e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium",children:s.title}),s.notes&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.notes})]})]})}function iws({contactId:t}){const s=wr(),[r,n]=k.useState(!1),{data:a,isLoading:o}=gt({queryKey:["deal-tasks","contact",t],queryFn:async()=>{const{data:f,error:y}=await G.from("deal_tasks").select(` id, title, priority, status, due_date, completed_at, deal:deal_pipeline(id, deal_name) `).eq("contact_id",t).order("status").order("due_date",{ascending:!0,nullsFirst:!1});if(y)throw y;return f},enabled:!!t}),l=async(f,y)=>{const _=y==="done"?"todo":"done";await G.from("deal_tasks").update({status:_,completed_at:_==="done"?new Date().toISOString():null}).eq("id",f),window.dispatchEvent(new CustomEvent("refetch-contact-tasks"))},{refetch:i}=gt({queryKey:["deal-tasks","contact",t],queryFn:async()=>{const{data:f,error:y}=await G.from("deal_tasks").select(` id, title, priority, status, due_date, completed_at, deal:deal_pipeline(id, deal_name) `).eq("contact_id",t).order("status").order("due_date",{ascending:!0,nullsFirst:!1});if(y)throw y;return f},enabled:!!t}),d={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"},u=(a==null?void 0:a.filter(f=>f.status!=="done"))||[],p=(a==null?void 0:a.filter(f=>f.status==="done"))||[];return e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Zn,{className:"h-4 w-4"}),"Tasks",u.length>0&&e.jsx(Qe,{variant:"secondary",className:"text-xs",children:u.length})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/tasks"),children:"View All"}),e.jsx(W,{variant:"outline",size:"sm",onClick:()=>n(!0),children:e.jsx(qs,{className:"h-3.5 w-3.5"})})]})]})}),e.jsx(Oe,{className:"space-y-1",children:o?e.jsx(Ms,{className:"h-8 w-full"}):u.length===0&&p.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No tasks yet"}):e.jsxs(e.Fragment,{children:[u.map(f=>e.jsxs("button",{onClick:async()=>{await l(f.id,f.status),i()},className:"w-full text-left flex items-center gap-2 px-2 py-1.5 rounded hover:bg-muted/50 transition-colors group",children:[e.jsx("div",{className:"h-4 w-4 rounded-full border-2 border-muted-foreground/30 shrink-0 group-hover:border-primary"}),e.jsxs("span",{className:"text-sm flex-1 truncate",children:[d[f.priority]," ",f.title]}),f.due_date&&e.jsx("span",{className:"text-[10px] text-muted-foreground",children:vs(new Date(f.due_date),"MMM d")})]},f.id)),p.length>0&&e.jsx("div",{className:"pt-1 border-t mt-1",children:e.jsxs("p",{className:"text-[10px] text-muted-foreground px-2 py-1",children:[p.length," completed"]})})]})}),r&&e.jsx(ows,{contactId:t,open:r,onOpenChange:f=>{n(f),f||i()}})]})}function ows({contactId:t,open:s,onOpenChange:r}){const[n,a]=k.useState(""),[o,l]=k.useState("medium"),[i,d]=k.useState(),{data:u}=gt({queryKey:["session"],queryFn:async()=>{const{data:f}=await G.auth.getSession();return f.session}}),p=async()=>{var y;if(!n.trim()||!((y=u==null?void 0:u.user)!=null&&y.id))return;const{error:f}=await G.from("deal_tasks").insert([{owner_user_id:u.user.id,contact_id:t,title:n.trim(),priority:o,status:"todo",due_date:i?vs(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(ks,{children:e.jsx(_s,{children:"Add Task"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Title"}),e.jsx(De,{value:n,onChange:f=>a(f.target.value),placeholder:"Task title...",onKeyDown:f=>f.key==="Enter"&&p()})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(xe,{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(xe,{children:"Due Date"}),e.jsx(De,{type:"date",value:i?vs(i,"yyyy-MM-dd"):"",onChange:f=>d(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(W,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(W,{onClick:p,disabled:!n.trim(),children:"Create Task"})]})]})]})})}function lws({contactId:t}){const s=wr(),{data:r,isLoading:n}=gt({queryKey:["contact-linked-deals",t],queryFn:async()=>{const{data:a,error:o}=await G.from("deal_pipeline").select(` id, deal_name, deal_type, expected_price, property_address, stage:deal_pipeline_stages(id, name, color, icon, is_won_stage, is_lost_stage) `).eq("contact_id",t).order("updated_at",{ascending:!1});if(o)throw o;return a},enabled:!!t});return n||!r||r.length===0?null:e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(dh,{className:"h-4 w-4"}),"Linked Deals"]})}),e.jsx(Oe,{className:"space-y-2",children:r.map(a=>{const o=a.stage;return e.jsx("button",{onClick:()=>s(`/mission-control/pipeline?deal=${a.id}`),className:"w-full text-left p-3 rounded-lg border hover:bg-accent transition-colors group",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:a.deal_name}),a.property_address&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:a.property_address}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(Qe,{variant:"outline",className:"text-[10px] capitalize",children:a.deal_type}),o&&e.jsxs(Qe,{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(Wa,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors flex-shrink-0"})]})},a.id)})})]})}function cws(){var He,Je,ut,mt,et;const{contactId:t}=io(),s=wr(),[r]=Nc(),n=r.get("search")||"",a=r.get("type")||"all",o=r.get("status")||"all",{data:l,isLoading:i}=_Lt(t||""),{data:d}=Nf(),{data:u}=WR(),{data:p}=KR(3650),{data:f}=Mme(365),{data:y}=qbs(t),{contactsWithScores:_}=lhe(),b=ake(),N=ike(),w=ahe(),S=bXe(),[C,A]=k.useState(!1),[I,L]=k.useState({}),[O,V]=k.useState(!1),[q,B]=k.useState(null),[U,te]=k.useState(""),[Y,J]=k.useState(void 0),[X,ce]=k.useState(""),[ie,ae]=k.useState(null),[oe,me]=k.useState(!1),[ve,he]=k.useState(null),[ge,je]=k.useState(!1),{isGmailConnected:qe,gmailEmail:Me}=Om(),{data:ke}=gt({queryKey:["gmail-sent-emails",t],queryFn:async()=>{const{data:Ze,error:kt}=await G.from("gmail_sent_emails").select("*").eq("contact_id",t).order("sent_at",{ascending:!1});if(kt)throw kt;return Ze},enabled:!!t}),Re=Ze=>{if(!Ze)return null;const kt=Ze.match(/Video ID:\s*([a-f0-9-]+)/i);return kt?kt[1]:null},Ve=k.useMemo(()=>{if(!_)return[];let Ze=_.filter(kt=>{var es,ds,js;const Ut=n===""||`${kt.first_name} ${kt.last_name}`.toLowerCase().includes(n.toLowerCase())||((es=kt.email)==null?void 0:es.toLowerCase().includes(n.toLowerCase()))||((ds=kt.phone)==null?void 0:ds.includes(n)),Nt=a==="all"||((js=kt.tags)==null?void 0:js.some(lr=>lr.relationship_type_id===a));return Ut&&Nt});return o==="not-touched-90"?Ze=Ze.filter(kt=>{const Ut=kt.relationshipScore.daysSinceTouch;return Ut===null||Ut>90}):o==="at-risk"?Ze=Ze.filter(kt=>kt.relationshipScore.status==="at-risk"):o==="cooling"?Ze=Ze.filter(kt=>kt.relationshipScore.status==="cooling"):o==="warm"&&(Ze=Ze.filter(kt=>kt.relationshipScore.status==="warm")),Ze.map(kt=>kt.id)},[_,n,a,o]),Ne=Ve.indexOf(t||""),Ue=Ne>0?Ve[Ne-1]:null,Ie=Ne1&&Ne!==-1,ct=Ze=>{const kt=new URLSearchParams;n&&kt.set("search",n),a!=="all"&&kt.set("type",a),o!=="all"&&kt.set("status",o);const Ut=kt.toString();return`/mission-control/contacts/${Ze}${Ut?`?${Ut}`:""}`},fe=k.useMemo(()=>{const Ze=((p==null?void 0:p.filter(Ut=>Ut.contact_id===t))||[]).map(Ut=>{var js,lr,Lt;const Nt=Re(Ut.notes);let es=((js=Ut.action_type)==null?void 0:js.name)||"Touch",ds=Ut.notes;if(es==="Other"&&((lr=Ut.notes)!=null&&lr.startsWith("["))){const Es=Ut.notes.indexOf("]");Es>0&&(es=Ut.notes.substring(1,Es),ds=Ut.notes.substring(Es+1).replace(/^\s*—\s*/,"").trim()||null)}return{id:Ut.id,type:"touch",completed_at:Ut.completed_at,name:es,color:((Lt=Ut.action_type)==null?void 0:Lt.color)||"#3B82F6",notes:ds,videoId:Nt}}),kt=((f==null?void 0:f.filter(Ut=>Ut.contact_id===t))||[]).map(Ut=>({id:Ut.id,type:"popby",completed_at:Ut.completed_at,name:"Pop-by",color:"#F97316",notes:Ut.notes,videoId:null}));return[...Ze,...kt].sort((Ut,Nt)=>new Date(Nt.completed_at).getTime()-new Date(Ut.completed_at).getTime())},[p,f,t]),$e=()=>{var Ze;l&&(L({first_name:l.first_name||"",last_name:l.last_name||"",email:l.email||"",phone:l.phone||"",address:l.address||"",city:l.city||"",state:l.state||"",zip_code:l.zip_code||"",birthday:l.birthday||"",home_anniversary:l.home_anniversary||"",spouse_name:l.spouse_name||"",spouse_email:l.spouse_email||"",company_name:l.company_name||"",job_title:l.job_title||"",lead_source_id:l.lead_source_id||"",notes:l.notes||"",tagIds:((Ze=l.tags)==null?void 0:Ze.map(kt=>kt.relationship_type_id))||[]}),A(!0))},Ye=async()=>{await b.mutateAsync({id:t,...I,lead_source_id:I.lead_source_id||null}),A(!1)},tt=async()=>{confirm("Are you sure you want to delete this contact?")&&(await N.mutateAsync(t),s("/mission-control/contacts"))},We=((He=u==null?void 0:u.find(Ze=>Ze.id===q))==null?void 0:He.name)==="Other",Ke=async()=>{if(!q||We&&!X.trim())return;const Ze=Y?new Date(Y.getFullYear(),Y.getMonth(),Y.getDate(),12,0,0).toISOString():void 0,kt=We?`[${X.trim()}]${U?" — "+U:""}`:U;await w.mutateAsync({contactId:t,actionTypeId:q,notes:kt,completedAt:Ze}),V(!1),B(null),te(""),J(void 0),ce("")},ot=(Ze,kt)=>{qe&&l?(he({email:Ze,name:kt||`${l.first_name} ${l.last_name||""}`.trim()}),me(!0)):window.location.href=`mailto:${Ze}`};return i?e.jsx(Ds,{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(Ds,{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(W,{variant:"ghost",size:"sm",onClick:()=>{window.history.length>1?s(-1):s("/mission-control/contacts")},children:[e.jsx(Xo,{className:"h-4 w-4 mr-1"}),"Back to Contacts"]}),ye&&e.jsxs("div",{className:"flex items-center gap-1 ml-2 border-l pl-2",children:[e.jsxs(W,{variant:"ghost",size:"sm",onClick:()=>Ue&&s(ct(Ue)),disabled:!Ue,className:"px-2",children:[e.jsx(Xo,{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:[Ne+1," of ",Ve.length]}),e.jsxs(W,{variant:"ghost",size:"sm",onClick:()=>Ie&&s(ct(Ie)),disabled:!Ie,className:"px-2",children:[e.jsx("span",{className:"sr-only sm:not-sr-only sm:mr-1",children:"Next"}),e.jsx(xa,{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(W,{variant:"outline",onClick:()=>ot(l.email,`${l.first_name} ${l.last_name||""}`.trim()),children:[e.jsx(tr,{className:"h-4 w-4 mr-1"}),"Email"]}),l.email&&e.jsxs(W,{variant:"outline",onClick:()=>je(!0),className:"border-primary/40 text-primary hover:bg-primary/10",children:[e.jsx(Or,{className:"h-4 w-4 mr-1"}),"Send Connect Page"]}),e.jsxs(W,{variant:"default",onClick:()=>s(`/mission-control/video/record?contact_id=${t}`),className:"bg-gradient-to-r from-primary to-primary/80",children:[e.jsx(yn,{className:"h-4 w-4 mr-1"}),"Quick Video Touch"]}),e.jsxs(fs,{open:O,onOpenChange:V,children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{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(ks,{children:e.jsx(_s,{children:"Log an Action"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Action Type"}),e.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:u==null?void 0:u.filter(Ze=>Ze.active).map(Ze=>e.jsxs("button",{onClick:()=>B(Ze.id),className:` p-3 rounded-lg border text-left transition-all ${q===Ze.id?"border-primary bg-primary/10":"hover:bg-accent"} `,children:[e.jsx("div",{className:"font-medium",children:Ze.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:Ze.description})]},Ze.id))}),We&&e.jsxs("div",{className:"mt-3",children:[e.jsx(xe,{htmlFor:"custom-action-name",children:"What did you do?"}),e.jsx(De,{id:"custom-action-name",value:X,onChange:Ze=>ce(Ze.target.value),placeholder:"e.g. Met a client for lunch, Dropped off a gift...",className:"mt-1"})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Date (optional — backdate if needed)"}),e.jsxs(mo,{children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{variant:"outline",className:Ot("w-full justify-start text-left font-normal mt-2",!Y&&"text-muted-foreground"),children:[e.jsx(cn,{className:"h-4 w-4 mr-2"}),Y?vs(Y,"PPP"):"Today (default)"]})}),e.jsx(no,{className:"w-auto p-0",align:"start",children:e.jsx(uf,{mode:"single",selected:Y,onSelect:J,disabled:Ze=>Ze>new Date,initialFocus:!0,className:Ot("p-3 pointer-events-auto")})})]})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"action-notes",children:"Notes (optional)"}),e.jsx(_r,{id:"action-notes",value:U,onChange:Ze=>te(Ze.target.value),placeholder:"Add any notes about this interaction...",rows:3})]}),e.jsxs(W,{onClick:Ke,disabled:!q||We&&!X.trim()||w.isPending,className:"w-full",children:[e.jsx(Zn,{className:"h-4 w-4 mr-1"}),"Complete Action"]})]})]})]}),e.jsxs(W,{variant:"outline",onClick:$e,children:[e.jsx(Wc,{className:"h-4 w-4 mr-1"}),"Edit"]}),e.jsx(W,{variant:"destructive",size:"icon",onClick:tt,children:e.jsx(vr,{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||""]}),(((Je=l.lead_source_ref)==null?void 0:Je.name)||l.lead_source)&&e.jsx(Qe,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((ut=l.lead_source_ref)==null?void 0:ut.name)||l.lead_source})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mt-2 text-muted-foreground",children:[l.email&&e.jsxs("button",{onClick:()=>ot(l.email),className:"flex items-center gap-1 hover:text-primary transition-colors",children:[e.jsx(tr,{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(In,{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(Awe,{contact:l}),(mt=l.tags)==null?void 0:mt.map(Ze=>{const kt=d==null?void 0:d.find(Ut=>Ut.id===Ze.relationship_type_id);return kt?e.jsx(Qe,{variant:"secondary",className:"text-xs",children:kt.name},Ze.id):null})]}),e.jsx("div",{className:"mt-2",children:e.jsx(Cbs,{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(Dt,{children:e.jsx(zt,{children:"Contact Information"})}),e.jsx(Oe,{children:C?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"first_name",children:"First Name"}),e.jsx(De,{id:"first_name",value:I.first_name,onChange:Ze=>L({...I,first_name:Ze.target.value})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"last_name",children:"Last Name"}),e.jsx(De,{id:"last_name",value:I.last_name,onChange:Ze=>L({...I,last_name:Ze.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"email",children:"Email"}),e.jsx(De,{id:"email",type:"email",value:I.email,onChange:Ze=>L({...I,email:Ze.target.value})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"phone",children:"Phone"}),e.jsx(De,{id:"phone",value:I.phone,onChange:Ze=>L({...I,phone:Ze.target.value})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"address",children:"Street Address"}),e.jsx(De,{id:"address",value:I.address,onChange:Ze=>L({...I,address:Ze.target.value}),placeholder:"123 Main St"})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx(xe,{htmlFor:"city",children:"City"}),e.jsx(De,{id:"city",value:I.city,onChange:Ze=>L({...I,city:Ze.target.value}),placeholder:"City"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"state",children:"State"}),e.jsx(De,{id:"state",value:I.state,onChange:Ze=>L({...I,state:Ze.target.value}),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"zip_code",children:"Zip Code"}),e.jsx(De,{id:"zip_code",value:I.zip_code,onChange:Ze=>L({...I,zip_code:Ze.target.value}),placeholder:"12345"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"birthday",children:"Birthday"}),e.jsx(De,{id:"birthday",type:"date",value:I.birthday,onChange:Ze=>L({...I,birthday:Ze.target.value})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(De,{id:"home_anniversary",type:"date",value:I.home_anniversary,onChange:Ze=>L({...I,home_anniversary:Ze.target.value})})]})]}),e.jsx(ho,{}),e.jsx(Ewe,{contactId:t,currentSpouseContactId:(l==null?void 0:l.spouse_contact_id)||null,currentSpouseName:(l==null?void 0:l.spouse_name)||null,currentSpouseEmail:(l==null?void 0:l.spouse_email)||null,onLink:Ze=>S.mutate({contactId:t,spouseContactId:Ze}),onUnlink:()=>S.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(xe,{htmlFor:"company_name",children:"Company"}),e.jsx(De,{id:"company_name",value:I.company_name,onChange:Ze=>L({...I,company_name:Ze.target.value}),placeholder:"Enter company name"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"job_title",children:"Job Title"}),e.jsx(De,{id:"job_title",value:I.job_title,onChange:Ze=>L({...I,job_title:Ze.target.value}),placeholder:"Enter job title"})]})]}),e.jsx(nit,{value:I.lead_source_id||"",onChange:Ze=>L({...I,lead_source_id:Ze})}),e.jsxs("div",{children:[e.jsx(xe,{children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:d==null?void 0:d.filter(Ze=>Ze.active).map(Ze=>{var kt;return e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Ri,{checked:(kt=I.tagIds)==null?void 0:kt.includes(Ze.id),onCheckedChange:Ut=>{var Nt;L(Ut?{...I,tagIds:[...I.tagIds||[],Ze.id]}:{...I,tagIds:(Nt=I.tagIds)==null?void 0:Nt.filter(es=>es!==Ze.id)})}}),e.jsx("span",{className:"text-sm",children:Ze.name})]},Ze.id)})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"notes",children:"Notes"}),e.jsx(_r,{id:"notes",value:I.notes,onChange:Ze=>L({...I,notes:Ze.target.value}),rows:4})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{onClick:Ye,disabled:b.isPending,children:"Save Changes"}),e.jsx(W,{variant:"outline",onClick:()=>A(!1),children:"Cancel"})]})]}):e.jsxs("div",{className:"space-y-4",children:[fe.length>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 flex items-center gap-2",children:[e.jsx(cn,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"Last Contacted:"})," ",vs(new Date(fe[0].completed_at),"MMM d, yyyy")," ","(",fe[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(tr,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("button",{onClick:()=>ot(l.email),className:"text-primary hover:underline truncate text-left",children:l.email})]}),l.phone&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(In,{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(Ia,{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(cn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Birthday: ",vs(ol(l.birthday),"MMMM d")]})]}),l.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Home Anniversary: ",vs(ol(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: ",vs(new Date(l.created_at),"MMMM d, yyyy")]})]})]}),e.jsx(ho,{}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(Ewe,{contactId:t,currentSpouseContactId:(l==null?void 0:l.spouse_contact_id)||null,currentSpouseName:l.spouse_name||null,currentSpouseEmail:l.spouse_email||null,onLink:Ze=>S.mutate({contactId:t,spouseContactId:Ze}),onUnlink:()=>S.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(pa,{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(ho,{}),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:(et=l.tags)!=null&&et.length?l.tags.map(Ze=>{var kt;return e.jsx(Qe,{variant:"secondary",children:(kt=Ze.relationship_type)==null?void 0:kt.name},Ze.id)}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"No relationship types assigned"})})]}),l.notes&&e.jsxs(e.Fragment,{children:[e.jsx(ho,{}),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($_s,{contact:l,onLogTouch:()=>V(!0)}),e.jsx(lws,{contactId:t}),e.jsx(Xbs,{contactId:t}),e.jsx(Qbs,{contactId:t}),e.jsx(ews,{contactId:t,contactName:l.first_name}),e.jsx(tws,{contactId:t,contactName:l.first_name}),e.jsx(iws,{contactId:t}),e.jsx(nws,{contactId:t}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Activity Log"})}),e.jsx(Oe,{children:fe.length>0?e.jsx("div",{className:"space-y-4",children:fe.map(Ze=>{var kt;return e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0",children:[e.jsx("div",{className:"h-8 w-8 rounded-full flex items-center justify-center text-white text-xs",style:{backgroundColor:Ze.color},children:Ze.type==="popby"?e.jsx(hi,{className:"h-4 w-4"}):(kt=Ze.name)==null?void 0:kt.charAt(0)}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:Ze.name}),Ze.videoId&&e.jsxs(W,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>ae(Ze.videoId),children:[e.jsx(Co,{className:"h-3 w-3 mr-1"}),"Preview"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:vs(new Date(Ze.completed_at),"MMM d, yyyy h:mm a")}),Ze.notes&&!Ze.videoId&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Ze.notes})]})]},Ze.id)})}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No activity logged yet"})})]}),y&&y.length>0&&e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(wi,{className:"h-5 w-5 text-primary"}),"Video Replies"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:y.map(Ze=>{var kt,Ut;return e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0",children:[(kt=Ze.video)!=null&&kt.thumbnail_url?e.jsx("img",{src:Ze.video.thumbnail_url,alt:Ze.video.title||"Video",className:"h-12 w-16 object-cover rounded cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>ae(Ze.video_id)}):e.jsx("div",{className:"h-12 w-16 bg-muted rounded flex items-center justify-center cursor-pointer hover:bg-muted/80 transition-colors",onClick:()=>ae(Ze.video_id),children:e.jsx(yn,{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: ",((Ut=Ze.video)==null?void 0:Ut.title)||"Untitled Video"]}),e.jsxs(W,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs flex-shrink-0",onClick:()=>ae(Ze.video_id),children:[e.jsx(Co,{className:"h-3 w-3 mr-1"}),"Watch"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:vs(new Date(Ze.created_at),"MMM d, yyyy h:mm a")}),Ze.message&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:['"',Ze.message,'"']})]})]},Ze.id)})})})]}),ke&&ke.length>0&&e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(_n,{className:"h-5 w-5 text-sky-500"}),"Sent Emails"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:ke.map(Ze=>e.jsxs(fs,{children:[e.jsx(mi,{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(tr,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:Ze.subject}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["To: ",Ze.to_email," · ",vs(new Date(Ze.sent_at),"MMM d, yyyy h:mm a")]})]}),e.jsx(xa,{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(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(tr,{className:"h-5 w-5 text-sky-500"}),Ze.subject]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["To: ",Ze.to_email," · ",vs(new Date(Ze.sent_at),"MMM d, yyyy h:mm a")]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden rounded-lg border bg-white",children:e.jsx("iframe",{srcDoc:Ze.body,className:"w-full h-[400px] border-0",sandbox:"",title:`Email: ${Ze.subject}`})})]})]},Ze.id))})})]})]}),e.jsx(fs,{open:!!ie,onOpenChange:Ze=>!Ze&&ae(null),children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(ks,{children:e.jsx(_s,{children:"Video Preview"})}),ie&&e.jsx(aws,{videoId:ie})]})})]})]})}),qe&&l&&ve&&e.jsx(E1,{open:oe,onOpenChange:me,contact:{id:l.id,first_name:l.first_name,last_name:l.last_name,email:ve.email},gmailEmail:Me}),l&&l.email&&e.jsx(Pbs,{open:ge,onOpenChange:je,contact:{id:l.id,first_name:l.first_name,last_name:l.last_name,email:l.email}})]}):e.jsx(Ds,{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(W,{onClick:()=>s("/mission-control/contacts"),children:"Back to Contacts"})]})})}const K7e={Crown:Cm,FileText:vn,Users:ir,Globe:nd,Star:Gn,Phone:In,MessageSquare:wi,PenTool:Mb,Video:yn,Gift:hi},d0e=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function dws(){var ut,mt;const t=wr(),{user:s}=Us(),{data:r}=Nf(),{data:n}=wLt(),{data:a}=TLt(),{data:o}=_Xe(),{data:l}=WR(),{data:i}=bLt(),d=ALt(),u=jLt(),p=kLt(),f=SLt(),y=CLt(),_=MLt(),b=NLt(),[N,w]=k.useState(null),[S,C]=k.useState(!1),[A,I]=k.useState(null),[L,O]=k.useState(""),[V,q]=k.useState(""),[B,U]=k.useState([]),[te,Y]=k.useState(null),[J,X]=k.useState(null),[ce,ie]=k.useState(!1),[ae,oe]=k.useState(""),[me,ve]=k.useState(""),[he,ge]=k.useState(""),[je,qe]=k.useState(""),Me=(et,Ze)=>a==null?void 0:a.some(kt=>kt.plan_id===et&&kt.relationship_type_id===Ze&&kt.active),ke=et=>a==null?void 0:a.find(Ze=>Ze.relationship_type_id===et&&Ze.active),Re=async(et,Ze)=>{const kt=Me(et,Ze);await d.mutateAsync({planId:et,relationshipTypeId:Ze,active:!kt})},Ve=(n==null?void 0:n.filter(et=>et.active&&!et.owner_user_id))||[],Ne=(n==null?void 0:n.filter(et=>et.owner_user_id===(s==null?void 0:s.id)))||[],Ue=r==null?void 0:r.find(et=>et.id===N),Ie=N?ke(N):null,ye=n==null?void 0:n.find(et=>et.id===(Ie==null?void 0:Ie.plan_id)),ct=async()=>{if(!L.trim())return;const et=await u.mutateAsync({name:L,description:V});et&&B.length>0&&await y.mutateAsync({planId:et.id,items:B}),Ye()},fe=async()=>{!L.trim()||!A||(await p.mutateAsync({id:A,name:L,description:V}),await y.mutateAsync({planId:A,items:B}),Ye())},$e=et=>{var Ze;I(et.id),O(et.name),q(et.description||""),U(((Ze=et.items)==null?void 0:Ze.map(kt=>({month_number:kt.month_number,action_type_id:kt.action_type_id,default_script_id:kt.default_script_id||void 0,notes:kt.notes||void 0})))||[]),C(!0)},Ye=()=>{C(!1),I(null),O(""),q(""),U([])},tt=(et,Ze)=>{X(Ze)},Te=(et,Ze,kt)=>{U(Ut=>[...Ut.filter(es=>es.month_number!==et),{month_number:et,action_type_id:Ze,default_script_id:kt}]),Y(null),X(null)},We=et=>{U(Ze=>Ze.filter(kt=>kt.month_number!==et))},Ke=async()=>{if(!ae.trim()||!me.trim()||!J)return;const et=await _.mutateAsync({actionTypeId:J,title:ae,scriptBody:me,emailSubject:he||void 0,tone:je||void 0});et&&te!==null&&Te(te,J,et.id),ie(!1),oe(""),ve(""),ge(""),qe("")},ot=J?i==null?void 0:i.filter(et=>et.action_type_id===J&&et.active):[],He=et=>K7e[et||"Phone"]||In,Je=et=>K7e[et||"Users"]||ir;return e.jsxs(Ds,{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(W,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control"),children:[e.jsx(Xo,{className:"h-4 w-4 mr-1"}),"Back"]}),e.jsxs(W,{onClick:()=>C(!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(et=>et.active).map(et=>{const Ze=Je(et.icon),kt=(o==null?void 0:o[et.id])||0,Ut=ke(et.id),Nt=n==null?void 0:n.find(ds=>ds.id===(Ut==null?void 0:Ut.plan_id)),es=N===et.id;return e.jsxs("button",{onClick:()=>w(et.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(Ze,{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:et.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[kt," contacts"]})]}),Nt?e.jsxs(Qe,{variant:"secondary",className:"text-xs",children:[e.jsx(si,{className:"h-3 w-3 mr-1"}),Nt.name.split(" ")[0]]}):e.jsx(Qe,{variant:"outline",className:"text-xs text-muted-foreground",children:"No plan"})]},et.id)})]}),e.jsx("div",{className:"lg:col-span-2",children:N&&Ue?e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[(()=>{const et=Je(Ue.icon);return e.jsx(et,{className:"h-5 w-5"})})(),Ue.name," Touchpoint Plan"]}),e.jsxs(dr,{children:["Choose a plan for your ",Ue.name," contacts"]})]}),e.jsxs(Oe,{className:"space-y-6",children:[ye&&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(si,{className:"h-4 w-4 text-green-500"}),"Currently using: ",ye.name]}),ye.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:ye.description})]}),e.jsx(W,{variant:"outline",size:"sm",onClick:()=>Re(ye.id,N),children:"Disable"})]}),ye.items&&ye.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(cn,{className:"h-4 w-4"}),"12-Month Schedule"]}),e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-2",children:d0e.map((et,Ze)=>{var es,ds;const kt=((es=ye.items)==null?void 0:es.filter(js=>js.month_number===Ze+1))||[],Ut=(ds=kt[0])==null?void 0:ds.action_type,Nt=Ut?He(Ut.icon):null;return e.jsxs("div",{className:` p-2 rounded border text-center ${kt.length>0?"bg-primary/10 border-primary":"bg-muted"} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:et}),Nt&&e.jsx(Nt,{className:"h-4 w-4 mx-auto mt-1",style:{color:(Ut==null?void 0:Ut.color)||"#3B82F6"}})]},Ze)})})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:ye?"Switch to a Different Plan":"Choose a Plan"}),Ve.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"}),Ve.map(et=>{var kt;const Ze=(ye==null?void 0:ye.id)===et.id;return e.jsxs("div",{className:` flex items-center justify-between p-3 rounded-lg border ${Ze?"opacity-50":"hover:bg-accent"} `,children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:et.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((kt=et.items)==null?void 0:kt.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{size:"sm",variant:"ghost",title:"Duplicate as my own plan",disabled:b.isPending,onClick:()=>{const Ut=`${et.name} (Copy)`;b.mutate({sourcePlanId:et.id,newName:Ut})},children:e.jsx(Va,{className:"h-4 w-4"})}),e.jsx(W,{size:"sm",variant:Ze?"outline":"default",disabled:Ze||d.isPending,onClick:()=>Re(et.id,N),children:Ze?"Active":"Use This"})]})]},et.id)})]}),Ne.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"My Custom Plans"}),Ne.map(et=>{var kt;const Ze=(ye==null?void 0:ye.id)===et.id;return e.jsxs("div",{className:` flex items-center justify-between p-3 rounded-lg border ${Ze?"opacity-50":"hover:bg-accent"} `,children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:et.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((kt=et.items)==null?void 0:kt.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{size:"sm",variant:"ghost",title:"Edit plan",onClick:()=>$e(et),children:e.jsx(Ry,{className:"h-4 w-4"})}),e.jsx(W,{size:"sm",variant:"ghost",title:"Delete plan",onClick:()=>f.mutate(et.id),children:e.jsx(vr,{className:"h-4 w-4 text-destructive"})}),e.jsx(W,{size:"sm",variant:Ze?"outline":"default",disabled:Ze||d.isPending,onClick:()=>Re(et.id,N),children:Ze?"Active":"Use This"})]})]},et.id)})]}),Ve.length===0&&Ne.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(Oe,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(cn,{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(Oe,{className:"py-4",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("strong",{children:"How it works:"})," When you assign a plan to a contact group, those contacts will appear in your daily suggested actions based on the plan's schedule."]})})})]}),e.jsx(fs,{open:S,onOpenChange:et=>{et?C(!0):Ye()},children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(_s,{children:A?"Edit Touchpoint Plan":"Create Custom Touchpoint Plan"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"plan-name",children:"Plan Name"}),e.jsx(De,{id:"plan-name",value:L,onChange:et=>O(et.target.value),placeholder:"e.g., My VIP Plan"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"plan-description",children:"Description (optional)"}),e.jsx(_r,{id:"plan-description",value:V,onChange:et=>q(et.target.value),placeholder:"Describe your plan...",rows:2})]})]}),e.jsxs("div",{children:[e.jsx(xe,{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:d0e.map((et,Ze)=>{const kt=Ze+1,Ut=B.find(ds=>ds.month_number===kt),Nt=Ut?l==null?void 0:l.find(ds=>ds.id===Ut.action_type_id):null,es=Nt?He(Nt.icon):null;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>Y(te===kt?null:kt),className:` w-full p-3 rounded-lg border text-center transition-all ${Ut?"bg-primary/10 border-primary":"bg-muted hover:bg-accent"} ${te===kt?"ring-2 ring-primary":""} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground font-medium",children:et}),es?e.jsx(es,{className:"h-5 w-5 mx-auto mt-1",style:{color:(Nt==null?void 0:Nt.color)||"#3B82F6"}}):e.jsx(qs,{className:"h-5 w-5 mx-auto mt-1 text-muted-foreground/50"})]}),Ut&&e.jsx("button",{type:"button",onClick:ds=>{ds.stopPropagation(),We(kt)},className:"absolute -top-1 -right-1 p-1 bg-destructive text-destructive-foreground rounded-full",children:e.jsx(kr,{className:"h-3 w-3"})})]},Ze)})}),te!==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 ",d0e[te-1],":"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l==null?void 0:l.filter(et=>et.active).map(et=>{const Ze=He(et.icon);return e.jsxs("button",{type:"button",onClick:()=>tt(te,et.id),className:"flex items-center gap-2 px-3 py-2 rounded-lg border bg-background hover:bg-accent transition-colors",children:[e.jsx(Ze,{className:"h-4 w-4",style:{color:et.color||"#3B82F6"}}),e.jsx("span",{className:"text-sm",children:et.name})]},et.id)})})]}),te!==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(W,{variant:"ghost",size:"sm",onClick:()=>X(null),children:[e.jsx(Xo,{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:()=>Te(te,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"})]})}),ot==null?void 0:ot.map(et=>e.jsx("button",{type:"button",onClick:()=>Te(te,J,et.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:et.title}),et.tone&&e.jsx(Qe,{variant:"secondary",className:"text-xs mt-1",children:et.tone}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:[et.script_body.substring(0,100),"..."]})]})},et.id)),e.jsxs("button",{type:"button",onClick:()=>ie(!0),className:"w-full flex items-center gap-3 p-3 rounded-lg border border-dashed bg-background hover:bg-accent transition-colors text-left",children:[e.jsx(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"})]})]})]})]})]}),B.length>0&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[B.length," touchpoint",B.length!==1?"s":""," per year"]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:Ye,children:"Cancel"}),e.jsxs(W,{onClick:A?fe:ct,disabled:!L.trim()||u.isPending||p.isPending,children:[e.jsx(bc,{className:"h-4 w-4 mr-2"}),A?"Save Changes":"Create Plan"]})]})]})}),e.jsx(fs,{open:ce,onOpenChange:ie,children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsx(ks,{children:e.jsx(_s,{children:"Create Custom Script"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"script-title",children:"Script Title"}),e.jsx(De,{id:"script-title",value:ae,onChange:et=>oe(et.target.value),placeholder:"e.g., Friendly Check-in Call"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"script-tone",children:"Tone (optional)"}),e.jsxs($s,{value:je,onValueChange:qe,children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select tone..."})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"friendly",children:"Friendly"}),e.jsx(vt,{value:"professional",children:"Professional"}),e.jsx(vt,{value:"casual",children:"Casual"}),e.jsx(vt,{value:"formal",children:"Formal"})]})]})]}),((mt=(ut=l==null?void 0:l.find(et=>et.id===J))==null?void 0:ut.name)==null?void 0:mt.toLowerCase().includes("email"))&&e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"script-email-subject",children:"Email Subject"}),e.jsx(De,{id:"script-email-subject",value:he,onChange:et=>ge(et.target.value),placeholder:"e.g., Quick Hello!"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"script-body",children:"Script Content"}),e.jsx(_r,{id:"script-body",value:me,onChange:et=>ve(et.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(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>ie(!1),children:"Cancel"}),e.jsxs(W,{onClick:Ke,disabled:!ae.trim()||!me.trim()||_.isPending,children:[e.jsx(bc,{className:"h-4 w-4 mr-2"}),"Create & Use Script"]})]})]})})]})}function uws(t,s,r,n){const a=u=>u*Math.PI/180,l=a(r-t),i=a(n-s),d=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(d))}const oit="popby_geocode_cache_v1";function hws(){try{return JSON.parse(localStorage.getItem(oit)||"{}")}catch{return{}}}function mws(t){try{localStorage.setItem(oit,JSON.stringify(t))}catch{}}function pws({contacts:t,onLogPopby:s}){const[r,n]=k.useState(null),[a,o]=k.useState("idle"),[l,i]=k.useState(5),[d,u]=k.useState(""),[p,f]=k.useState(new Map),[y,_]=k.useState(!1);k.useEffect(()=>{(async()=>{const{data:C}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();C!=null&&C.value&&u(C.value)})()},[]);const b=k.useMemo(()=>t.filter(C=>C.isDue&&(C.address||C.city&&C.state||C.zip)),[t]),N=()=>{if(!("geolocation"in navigator)){o("unavailable");return}o("loading"),navigator.geolocation.getCurrentPosition(C=>{n({lat:C.coords.latitude,lng:C.coords.longitude}),o("ok")},()=>{o("denied")},{enableHighAccuracy:!0,timeout:1e4,maximumAge:6e4})};k.useEffect(()=>{if(!d||!r||b.length===0)return;let C=!1;const A=hws(),I=new Map;b.forEach(O=>{const V=[O.address,O.city,O.state,O.zip].filter(Boolean).join("|").toLowerCase();A[V]&&I.set(O.id,A[V])}),f(new Map(I));const L=b.filter(O=>!([O.address,O.city,O.state,O.zip].filter(Boolean).join("|").toLowerCase()in A));if(L.length!==0)return _(!0),(async()=>{const O=[...L],V=async()=>{var q,B;for(;O.length&&!C;){const U=O.shift(),te=[U.address,U.city,U.state,U.zip].filter(Boolean),Y=te.join("|").toLowerCase(),J=te.join(", ");try{const ce=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(J)}.json?limit=1&access_token=${d}`)).json();if((B=(q=ce==null?void 0:ce.features)==null?void 0:q[0])!=null&&B.center){const[ie,ae]=ce.features[0].center;A[Y]={lat:ae,lng:ie},I.set(U.id,{lat:ae,lng:ie})}else A[Y]=null}catch{}}};await Promise.all([V(),V(),V(),V()]),C||(mws(A),f(new Map(I)),_(!1))})(),()=>{C=!0}},[d,r,b]);const w=k.useMemo(()=>{if(!r)return[];const C=[];return b.forEach(A=>{const I=p.get(A.id);if(!I)return;const L=uws(r.lat,r.lng,I.lat,I.lng);L<=l&&C.push({...A,distanceMiles:L,lat:I.lat,lng:I.lng})}),C.sort((A,I)=>A.distanceMiles-I.distanceMiles)},[r,b,p,l]),S=C=>{const I=/iPad|iPhone|iPod/.test(navigator.userAgent)?`https://maps.apple.com/?daddr=${C.lat},${C.lng}`:`https://www.google.com/maps/dir/?api=1&destination=${C.lat},${C.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(Dt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3 flex-wrap",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2 text-lg",children:[e.jsx(AM,{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($s,{value:String(l),onValueChange:C=>i(Number(C)),children:[e.jsx(zs,{className:"w-[110px] h-9",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"2",children:"2 miles"}),e.jsx(vt,{value:"5",children:"5 miles"}),e.jsx(vt,{value:"10",children:"10 miles"}),e.jsx(vt,{value:"25",children:"25 miles"})]})]}),e.jsxs(W,{size:"sm",variant:a==="ok"?"outline":"default",onClick:N,disabled:a==="loading",children:[a==="loading"?e.jsx(Zi,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(AM,{className:"h-4 w-4 mr-1"}),a==="ok"?"Refresh":"Use my location"]})]})]})}),e.jsxs(Oe,{className:"space-y-3",children:[a==="idle"&&e.jsxs("div",{className:"text-center py-6 text-sm text-muted-foreground",children:[e.jsx(Ia,{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(ro,{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"&&!d&&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"&&d&&b.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"&&d&&b.length>0&&y&&w.length===0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ms,{className:"h-14 w-full"}),e.jsx(Ms,{className:"h-14 w-full"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Locating contacts…"})]}),a==="ok"&&d&&!y&&w.length===0&&b.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."]}),w.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Qe,{variant:"secondary",className:"font-medium",children:[w.length," nearby"]}),y&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Zi,{className:"h-3 w-3 animate-spin"})," still locating…"]})]}),e.jsx("div",{className:"space-y-2",children:w.map(C=>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:[C.first_name," ",C.last_name]}),e.jsx(Qe,{variant:"outline",className:"text-xs",children:C.distanceMiles<1?`${(C.distanceMiles*5280).toFixed(0)} ft`:`${C.distanceMiles.toFixed(1)} mi`}),C.daysOverdue>0&&e.jsxs(Qe,{variant:"destructive",className:"text-xs",children:[C.daysOverdue,"d overdue"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:[C.address,C.city,C.state].filter(Boolean).join(", ")})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[C.phone&&e.jsx(W,{size:"icon",variant:"ghost",asChild:!0,className:"h-9 w-9",title:"Call",children:e.jsx("a",{href:`tel:${C.phone}`,children:e.jsx(In,{className:"h-4 w-4"})})}),e.jsx(W,{size:"icon",variant:"ghost",onClick:()=>S(C),className:"h-9 w-9",title:"Directions",children:e.jsx(ML,{className:"h-4 w-4"})}),e.jsxs(W,{size:"sm",onClick:()=>s(C),children:[e.jsx(hi,{className:"h-4 w-4 mr-1"}),"Log"]})]})]},C.id))})]})]})]})}const fws="0dde5abb-0005-4c8c-a471-30d0cbc9e280",xws=[{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 gws(){const t=wr(),s=Zat(),{data:r}=L_s(),{data:n}=Nf(),{data:a}=OSe(),{data:o}=Mme(90),{data:l}=qh(),i=z_s(),d=O_s(),u=R_s(),p=F_s(),{data:f=[],isLoading:y}=gt({queryKey:["popby-templates"],queryFn:async()=>{const{data:ce,error:ie}=await G.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("category_id",fws).order("publish_date",{ascending:!1});if(ie)throw ie;const{data:ae}=await G.from("template_likes").select("template_id"),{data:oe}=await G.from("template_comments").select("template_id"),me=new Map;ae==null||ae.forEach(he=>{me.set(he.template_id,(me.get(he.template_id)||0)+1)});const ve=new Map;return oe==null||oe.forEach(he=>{ve.set(he.template_id,(ve.get(he.template_id)||0)+1)}),(ce||[]).map(he=>({...he,likesCount:me.get(he.id)||0,commentsCount:ve.get(he.id)||0}))}}),_=ce=>{const ie=l==null?void 0:l.find(ae=>ae.id===ce);return ie?`${ie.first_name} ${ie.last_name||""}`.trim():"Unknown"},b=ce=>{if(!ce)return null;const ie=r==null?void 0:r.find(ae=>ae.id===ce);return(ie==null?void 0:ie.name)||null},[N,w]=k.useState(null),[S,C]=k.useState(!1),[A,I]=k.useState(!1),[L,O]=k.useState(!1),[V,q]=k.useState({popby_item_id:"",notes:""}),[B,U]=k.useState({name:"",description:""}),te=async()=>{N&&(await d.mutateAsync({contact_id:N.id,popby_item_id:V.popby_item_id||void 0,notes:V.notes||void 0}),C(!1),w(null),q({popby_item_id:"",notes:""}))},Y=async()=>{B.name.trim()&&(await u.mutateAsync({name:B.name.trim(),description:B.description.trim()||void 0}),O(!1),U({name:"",description:""}))},J=async(ce,ie)=>{await p.mutateAsync({relationship_type_id:ce,frequency_days:parseInt(ie)})},X=ce=>{var ae;const ie=a==null?void 0:a.find(oe=>oe.relationship_type_id===ce);return((ae=ie==null?void 0:ie.frequency_days)==null?void 0:ae.toString())||"90"};return e.jsx(Ds,{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(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-primary",children:i.thisWeekCount}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"This Week"})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-emerald-500",children:i.thisMonthCount}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"This Month"})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-amber-500",children:i.dueCount}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Due Now"})]})})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(W,{onClick:()=>t("/mission-control/popbys/map"),children:[e.jsx(Ia,{className:"h-4 w-4 mr-2"}),"View Map"]}),e.jsxs(W,{variant:"outline",onClick:()=>I(!0),children:[e.jsx(So,{className:"h-4 w-4 mr-2"}),"Frequency Settings"]}),e.jsxs(W,{variant:"outline",onClick:()=>O(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsxs(ta,{defaultValue:"due",children:[e.jsxs(Jn,{children:[e.jsx(cs,{value:"due",children:"Due for Popby"}),e.jsx(cs,{value:"activity",children:"Recent Activity"}),e.jsx(cs,{value:"library",children:"Popby Library"}),e.jsx(cs,{value:"templates",children:"Popby Templates"})]}),e.jsxs(Ss,{value:"due",className:"space-y-4 mt-4",children:[e.jsx(pws,{contacts:s||[],onLogPopby:ce=>{w(ce),C(!0)}}),!s||s.length===0?e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(hi,{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(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium",children:[ce.first_name," ",ce.last_name]}),ce.daysOverdue>0&&e.jsxs(Qe,{variant:"destructive",className:"text-xs",children:[ce.daysOverdue,"+ days overdue"]}),ce.daysSinceLastPopby===null&&e.jsx(Qe,{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(Ia,{className:"h-3 w-3"}),ce.city||ce.address]}),ce.tags&&ce.tags.length>0&&e.jsx("span",{children:ce.tags.map(ie=>{var ae;return(ae=ie.relationship_type)==null?void 0:ae.name}).join(", ")})]}),ce.lastPopby&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Last popby: ",vs(new Date(ce.lastPopby),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[ce.phone&&e.jsx(W,{size:"sm",variant:"ghost",asChild:!0,children:e.jsx("a",{href:`tel:${ce.phone}`,children:e.jsx(In,{className:"h-4 w-4"})})}),e.jsxs(W,{size:"sm",onClick:()=>{w(ce),C(!0)},children:[e.jsx(si,{className:"h-4 w-4 mr-1"}),"Log Popby"]})]})]})})},ce.id))})]}),e.jsx(Ss,{value:"activity",className:"space-y-4 mt-4",children:!o||o.length===0?e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(nn,{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(Dt,{children:e.jsx(zt,{className:"text-lg",children:"Recent Popby Log"})}),e.jsx(Oe,{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(hi,{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:_(ce.contact_id)}),b(ce.popby_item_id)&&e.jsx(Qe,{variant:"secondary",className:"text-xs",children:b(ce.popby_item_id)})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:vs(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(Ss,{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(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(hi,{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(Qe,{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(Oe,{className:"p-4 flex items-center justify-center h-full min-h-[100px]",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(qs,{className:"h-8 w-8 mx-auto mb-2"}),e.jsx("p",{children:"Add New Popby Idea"})]})})})]})}),e.jsxs(Ss,{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"]}),y&&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,ie)=>e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(Ms,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(Ms,{className:"h-5 w-3/4 mb-2"}),e.jsx(Ms,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ms,{className:"h-5 w-16"}),e.jsx(Ms,{className:"h-5 w-20"})]})]})},ie))}),!y&&f.length===0&&e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(cl,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No popby templates available yet!"}),e.jsx("p",{className:"text-sm mt-1",children:"Check back soon for new templates."})]})}),!y&&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(Oe,{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:Qde(ce.description)}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:e.jsx(Qe,{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(Bu,{className:"h-3.5 w-3.5"}),ce.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Fl,{className:"h-3.5 w-3.5"}),ce.commentsCount]})]}),e.jsxs(W,{size:"sm",className:"w-full gap-2",onClick:ie=>{ie.stopPropagation(),t(`/templates/${ce.id}`)},children:[e.jsx(Yr,{className:"h-4 w-4"}),"View Template"]})]})]},ce.id))})]})]}),e.jsx(fs,{open:S,onOpenChange:C,children:e.jsxs(ps,{children:[e.jsx(ks,{children:e.jsxs(_s,{children:["Log Popby for ",N==null?void 0:N.first_name," ",N==null?void 0:N.last_name]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Popby Item (optional)"}),e.jsxs($s,{value:V.popby_item_id,onValueChange:ce=>q(ie=>({...ie,popby_item_id:ce})),children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select a popby item..."})}),e.jsx(Bs,{children:r==null?void 0:r.map(ce=>e.jsx(vt,{value:ce.id,children:ce.name},ce.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Notes (optional)"}),e.jsx(_r,{placeholder:"Any notes about this popby...",value:V.notes,onChange:ce=>q(ie=>({...ie,notes:ce.target.value}))})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),e.jsx(W,{onClick:te,disabled:d.isPending,children:"Log Popby"})]})]})}),e.jsx(fs,{open:A,onOpenChange:I,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(ks,{children:e.jsx(_s,{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(xe,{className:"font-medium",children:ce.name}),e.jsxs($s,{value:X(ce.id),onValueChange:ie=>J(ce.id,ie),children:[e.jsx(zs,{className:"w-[180px]",children:e.jsx(Vs,{})}),e.jsx(Bs,{children:xws.map(ie=>e.jsx(vt,{value:ie.value,children:ie.label},ie.value))})]})]},ce.id))]}),e.jsx(gn,{children:e.jsx(W,{onClick:()=>I(!1),children:"Done"})})]})}),e.jsx(fs,{open:L,onOpenChange:O,children:e.jsxs(ps,{children:[e.jsx(ks,{children:e.jsx(_s,{children:"Add Popby Idea"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Name *"}),e.jsx(De,{placeholder:"e.g., Homemade cookies",value:B.name,onChange:ce=>U(ie=>({...ie,name:ce.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Description"}),e.jsx(_r,{placeholder:"Optional description...",value:B.description,onChange:ce=>U(ie=>({...ie,description:ce.target.value}))})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),e.jsx(W,{onClick:Y,disabled:!B.name.trim()||u.isPending,children:"Add Item"})]})]})})]})})}const yws=kC({property_address:Xl().min(1,"Property address is required"),city:Xl().optional(),state:Xl().optional(),zip:Xl().optional(),transaction_type:ZWe(["buyer","seller"]),close_date:Xl().min(1,"Close date is required"),sale_price:e8().min(0,"Sale price must be positive"),commission_amount:e8().optional(),lead_source_id:Xl().optional(),client_type_id:Xl().optional(),contact_id:Xl().optional(),notes:Xl().optional(),is_win:x3t()});function lit({open:t,onOpenChange:s,transaction:r}){const[n,a]=k.useState(!1),[o,l]=k.useState(""),[i,d]=k.useState(!1),[u,p]=k.useState(""),f=ihe(),y=g8t(),{data:_}=JA(),{data:b}=Nf(),{data:N}=qh(),w=nhe(),S=lke(),{data:C}=ohe(),A=(C==null?void 0:C.show_commission)??!0,I=Zue({resolver:Yue(yws),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 L=async B=>{const U={property_address:B.property_address,transaction_type:B.transaction_type,close_date:B.close_date,sale_price:B.sale_price,is_win:B.is_win,commission_amount:B.commission_amount||null,lead_source_id:B.lead_source_id||null,client_type_id:B.client_type_id||null,contact_id:B.contact_id||null,city:B.city||null,state:B.state||null,zip:B.zip||null,notes:B.notes||null};r?await y.mutateAsync({id:r.id,...U}):await f.mutateAsync(U),s(!1)},O=async()=>{if(!o.trim())return;const[B,...U]=o.trim().split(" "),te=U.join(" ")||null,Y=await w.mutateAsync({first_name:B,last_name:te,tagIds:[]});Y&&(I.setValue("contact_id",Y.id),l(""),d(!1),a(!1))},V=async()=>{if(!u.trim())return;const B=await S.mutateAsync(u.trim());B&&(I.setValue("lead_source_id",B.id),p(""))},q=N==null?void 0:N.find(B=>B.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(ks,{children:e.jsx(_s,{children:r?"Edit Transaction":"Add Transaction"})}),e.jsx(Ja,{className:"max-h-[70vh] pr-4",children:e.jsx(Xue,{...I,children:e.jsxs("form",{onSubmit:I.handleSubmit(L),className:"space-y-4",children:[e.jsx(Ec,{control:I.control,name:"property_address",render:({field:B})=>e.jsxs(mc,{children:[e.jsx(pc,{children:"Property Address *"}),e.jsx(fc,{children:e.jsx(De,{placeholder:"123 Main St",...B})}),e.jsx(vm,{})]})}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(Ec,{control:I.control,name:"city",render:({field:B})=>e.jsxs(mc,{children:[e.jsx(pc,{children:"City"}),e.jsx(fc,{children:e.jsx(De,{placeholder:"City",...B})})]})}),e.jsx(Ec,{control:I.control,name:"state",render:({field:B})=>e.jsxs(mc,{children:[e.jsx(pc,{children:"State"}),e.jsx(fc,{children:e.jsx(De,{placeholder:"TX",...B})})]})}),e.jsx(Ec,{control:I.control,name:"zip",render:({field:B})=>e.jsxs(mc,{children:[e.jsx(pc,{children:"Zip"}),e.jsx(fc,{children:e.jsx(De,{placeholder:"75001",...B})})]})})]}),e.jsx(Ec,{control:I.control,name:"transaction_type",render:({field:B})=>e.jsxs(mc,{children:[e.jsx(pc,{children:"Transaction Type *"}),e.jsxs($s,{onValueChange:B.onChange,value:B.value,children:[e.jsx(fc,{children:e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select type"})})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"buyer",children:"Buyer"}),e.jsx(vt,{value:"seller",children:"Seller"})]})]}),e.jsx(vm,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Ec,{control:I.control,name:"close_date",render:({field:B})=>e.jsxs(mc,{children:[e.jsx(pc,{children:"Close Date *"}),e.jsx(fc,{children:e.jsx(De,{type:"date",...B})}),e.jsx(vm,{})]})}),e.jsx(Ec,{control:I.control,name:"sale_price",render:({field:B})=>e.jsxs(mc,{children:[e.jsx(pc,{children:"Sale Price *"}),e.jsx(fc,{children:e.jsx(De,{type:"number",placeholder:"0",...B,onChange:U=>B.onChange(Number(U.target.value))})}),e.jsx(vm,{})]})})]}),A&&e.jsx(Ec,{control:I.control,name:"commission_amount",render:({field:B})=>e.jsxs(mc,{children:[e.jsx(pc,{children:"Commission"}),e.jsx(fc,{children:e.jsx(De,{type:"number",placeholder:"0",...B,value:B.value??"",onChange:U=>B.onChange(U.target.value?Number(U.target.value):void 0)})})]})}),e.jsx(Ec,{control:I.control,name:"lead_source_id",render:({field:B})=>e.jsxs(mc,{children:[e.jsx(pc,{children:"Lead Source"}),e.jsxs($s,{onValueChange:B.onChange,value:B.value||"",children:[e.jsx(fc,{children:e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select source"})})}),e.jsx(Bs,{children:_==null?void 0:_.map(U=>e.jsx(vt,{value:U.id,children:U.name},U.id))})]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{placeholder:"Add custom source...",value:u,onChange:B=>p(B.target.value),className:"flex-1"}),e.jsx(W,{type:"button",variant:"outline",size:"icon",onClick:V,disabled:!u.trim(),children:e.jsx(qs,{className:"h-4 w-4"})})]}),e.jsx(Ec,{control:I.control,name:"client_type_id",render:({field:B})=>e.jsxs(mc,{children:[e.jsx(pc,{children:"Client Type"}),e.jsxs($s,{onValueChange:B.onChange,value:B.value||"",children:[e.jsx(fc,{children:e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select client type"})})}),e.jsx(Bs,{children:b==null?void 0:b.map(U=>e.jsx(vt,{value:U.id,children:U.name},U.id))})]})]})}),e.jsx(Ec,{control:I.control,name:"contact_id",render:({field:B})=>e.jsxs(mc,{children:[e.jsx(pc,{children:"Client Contact"}),e.jsxs(mo,{open:n,onOpenChange:a,children:[e.jsx(po,{asChild:!0,children:e.jsx(fc,{children:e.jsxs(W,{variant:"outline",role:"combobox",className:Ot("w-full justify-between",!B.value&&"text-muted-foreground"),children:[q?`${q.first_name} ${q.last_name||""}`.trim():"Select contact",e.jsx(gx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})})}),e.jsxs(no,{className:"w-full p-0",align:"start",children:[e.jsxs(Sx,{children:[e.jsx(Cx,{placeholder:"Search contacts..."}),e.jsxs(Mx,{children:[e.jsx(Tx,{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(W,{variant:"outline",size:"sm",className:"w-full",onClick:()=>d(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add New Contact"]})]})}),e.jsx(Ax,{children:N==null?void 0:N.map(U=>e.jsxs(cp,{value:`${U.first_name} ${U.last_name||""}`,onSelect:()=>{B.onChange(U.id),a(!1)},children:[e.jsx(Zn,{className:Ot("mr-2 h-4 w-4",U.id===B.value?"opacity-100":"opacity-0")}),U.first_name," ",U.last_name||""]},U.id))})]})]}),i&&e.jsxs("div",{className:"p-2 border-t space-y-2",children:[e.jsx(De,{placeholder:"Enter contact name...",value:o,onChange:U=>l(U.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{size:"sm",onClick:O,disabled:!o.trim()||w.isPending,children:"Add Contact"}),e.jsx(W,{size:"sm",variant:"outline",onClick:()=>{d(!1),l("")},children:"Cancel"})]})]})]})]})]})}),e.jsx(Ec,{control:I.control,name:"notes",render:({field:B})=>e.jsxs(mc,{children:[e.jsx(pc,{children:"Notes"}),e.jsx(fc,{children:e.jsx(_r,{placeholder:"Any notes about this transaction...",...B})})]})}),e.jsx(Ec,{control:I.control,name:"is_win",render:({field:B})=>e.jsxs(mc,{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(pc,{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(Ar,{checked:B.value,onCheckedChange:B.onChange})})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(W,{type:"submit",disabled:f.isPending||y.isPending,children:[r?"Update":"Add"," Transaction"]})]})]})})})]})})}function $Se({transactions:t,showCommission:s,isLoading:r,agentNameMap:n,readOnly:a}){const[o,l]=k.useState(null),[i,d]=k.useState(null),[u,p]=k.useState(""),[f,y]=k.useState("all"),[_,b]=k.useState("all"),[N,w]=k.useState("all"),[S,C]=k.useState(!1),A=y8t(),I=ihe(),{data:L}=JA();Nf();const O=bE(),V=U=>{const{id:te,created_at:Y,updated_at:J,lead_source:X,client_type:ce,contact:ie,...ae}=U;I.mutate(ae)},q=()=>{i&&(A.mutate(i),d(null))},B=t.filter(U=>{var ie,ae,oe,me;const te=u===""||U.property_address.toLowerCase().includes(u.toLowerCase())||((ae=(ie=U.contact)==null?void 0:ie.first_name)==null?void 0:ae.toLowerCase().includes(u.toLowerCase()))||((me=(oe=U.contact)==null?void 0:oe.last_name)==null?void 0:me.toLowerCase().includes(u.toLowerCase())),Y=f==="all"||U.transaction_type===f,J=_==="all"||U.lead_source_id===_,X=N==="all"||U.client_type_id===N,ce=!S||U.is_win;return te&&Y&&J&&X&&ce});return r?e.jsx(Pe,{children:e.jsx(Oe,{className:"p-6 space-y-4",children:[1,2,3].map(U=>e.jsx(Ms,{className:"h-16 w-full"},U))})}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs(zt,{children:["Transactions (",B.length,")"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(ln,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search...",value:u,onChange:U=>p(U.target.value),className:"pl-8 w-[150px]"})]}),e.jsxs($s,{value:f,onValueChange:y,children:[e.jsx(zs,{className:"w-[100px]",children:e.jsx(Vs,{placeholder:"Type"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Types"}),e.jsx(vt,{value:"buyer",children:"Buyer"}),e.jsx(vt,{value:"seller",children:"Seller"})]})]}),e.jsxs($s,{value:_,onValueChange:b,children:[e.jsx(zs,{className:"w-[130px]",children:e.jsx(Vs,{placeholder:"Lead Source"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Sources"}),L==null?void 0:L.map(U=>e.jsx(vt,{value:U.id,children:U.name},U.id))]})]}),e.jsxs(W,{variant:S?"default":"outline",size:"sm",onClick:()=>C(!S),children:[e.jsx(nc,{className:"h-4 w-4 mr-1"}),"Wins"]})]})]})}),e.jsx(Oe,{children:B.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No transactions found"}):O?e.jsx("div",{className:"space-y-3",children:B.map(U=>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:U.property_address}),U.is_win&&e.jsx(nc,{className:"h-4 w-4 text-yellow-500 flex-shrink-0"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[U.city,U.state?`, ${U.state}`:""]})]}),e.jsx(Qe,{variant:U.transaction_type==="buyer"?"default":"secondary",children:U.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: "}),AEe(U.close_date)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Price: "}),Il(U.sale_price)]}),s&&U.commission_amount&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Commission: "}),Il(U.commission_amount)]}),U.lead_source&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Source: "}),U.lead_source.name]}),U.contact&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Client: "}),U.contact.first_name," ",U.contact.last_name]}),n&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Agent: "}),n[U.owner_user_id]||"Unknown"]})]}),!a&&e.jsxs("div",{className:"flex justify-end gap-2 mt-3 pt-3 border-t",children:[e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>l(U),children:e.jsx(Wc,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>V(U),children:e.jsx(Va,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>d(U.id),children:e.jsx(vr,{className:"h-4 w-4 text-destructive"})})]})]},U.id))}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[n&&e.jsx(St,{children:"Agent"}),e.jsx(St,{children:"Property"}),e.jsx(St,{children:"Type"}),e.jsx(St,{children:"Close Date"}),e.jsx(St,{children:"Sale Price"}),s&&e.jsx(St,{children:"Commission"}),e.jsx(St,{children:"Lead Source"}),e.jsx(St,{children:"Client"}),!a&&e.jsx(St,{className:"w-[50px]"})]})}),e.jsx(Rn,{children:B.map(U=>{var te;return e.jsxs(Ps,{children:[n&&e.jsx(ht,{className:"font-medium text-sm",children:n[U.owner_user_id]||"Unknown"}),e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[U.is_win&&e.jsx(nc,{className:"h-4 w-4 text-yellow-500"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:U.property_address}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[U.city,U.state?`, ${U.state}`:""]})]})]})}),e.jsx(ht,{children:e.jsx(Qe,{variant:U.transaction_type==="buyer"?"default":"secondary",children:U.transaction_type})}),e.jsx(ht,{children:AEe(U.close_date)}),e.jsx(ht,{children:Il(U.sale_price)}),s&&e.jsx(ht,{children:U.commission_amount?Il(U.commission_amount):"-"}),e.jsx(ht,{children:((te=U.lead_source)==null?void 0:te.name)||"-"}),e.jsx(ht,{children:U.contact?`${U.contact.first_name} ${U.contact.last_name||""}`.trim():"-"}),!a&&e.jsx(ht,{children:e.jsxs(Hd,{children:[e.jsx(Gd,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",children:e.jsx(ix,{className:"h-4 w-4"})})}),e.jsxs(Nd,{align:"end",children:[e.jsxs(_a,{onClick:()=>l(U),children:[e.jsx(Wc,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(_a,{onClick:()=>V(U),children:[e.jsx(Va,{className:"h-4 w-4 mr-2"}),"Duplicate"]}),e.jsxs(_a,{onClick:()=>d(U.id),className:"text-destructive",children:[e.jsx(vr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},U.id)})})]})})})]}),e.jsx(lit,{open:!!o,onOpenChange:U=>!U&&l(null),transaction:o||void 0}),e.jsx(Rl,{open:!!i,onOpenChange:U=>!U&&d(null),children:e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Delete Transaction?"}),e.jsx(bl,{children:"This action cannot be undone. This will permanently delete this transaction."})]}),e.jsxs(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:q,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function cit({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=(y,_)=>{if(!_||_===0)return null;const b=Math.min(y/_*100,100),N=Math.max(_-y,0),w=l>0?N/l:0,S=o/12*100,C=b>=S?"ahead":b>=S*.8?"on-track":"behind";return{percent:b,remaining:N,pace:w,status:C}},d=i(s.totalTransactions,t.transactions_goal),u=i(s.totalVolume,t.volume_goal),p=n?i(s.totalCommission,t.gci_goal):null,f=y=>{switch(y){case"ahead":return e.jsxs(Qe,{className:"bg-green-500 text-white",children:[e.jsx(Qo,{className:"h-3 w-3 mr-1"}),"Ahead"]});case"on-track":return e.jsxs(Qe,{variant:"secondary",children:[e.jsx(Qy,{className:"h-3 w-3 mr-1"}),"On Track"]});case"behind":return e.jsxs(Qe,{variant:"destructive",children:[e.jsx(bS,{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(Dt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rh,{className:"h-5 w-5 text-primary"}),e.jsxs(zt,{children:[r," Goals Progress"]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[t.transactions_goal&&d&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"Transactions"}),f(d.status)]}),e.jsx(xi,{value:d.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[s.totalTransactions," of ",t.transactions_goal]}),e.jsxs("span",{children:[Math.round(d.percent),"%"]})]}),d.remaining>0&&l>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Need ",Math.ceil(d.pace),"/month to hit goal"]})]}),t.volume_goal&&u&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"Volume"}),f(u.status)]}),e.jsx(xi,{value:u.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[Il(s.totalVolume,!0)," of ",Il(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 ",Il(u.pace,!0),"/month"]})]}),n&&t.gci_goal&&p&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"GCI"}),f(p.status)]}),e.jsx(xi,{value:p.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[Il(s.totalCommission,!0)," of ",Il(t.gci_goal,!0)]}),e.jsxs("span",{children:[Math.round(p.percent),"%"]})]}),p.remaining>0&&l>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Need ",Il(p.pace,!0),"/month"]})]})]})})]})}const vws={light:"",dark:".dark"},dit=k.createContext(null);function uit(){const t=k.useContext(dit);if(!t)throw new Error("useChart must be used within a ");return t}const hit=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(dit.Provider,{value:{config:n},children:e.jsxs("div",{"data-chart":i,ref:o,className:Ot("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(_ws,{id:i,config:n}),e.jsx(tT,{children:r})]})})});hit.displayName="Chart";const _ws=({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(vws).map(([n,a])=>` ${a} [data-chart=${t}] { ${r.map(([o,l])=>{var d;const i=((d=l.theme)==null?void 0:d[n])||l.color;return i?` --color-${o}: ${i};`:null}).join(` `)} } `).join(` `)}}):null},mit=k.forwardRef(({active:t,payload:s,className:r,indicator:n="dot",hideLabel:a=!1,hideIndicator:o=!1,label:l,labelFormatter:i,labelClassName:d,formatter:u,color:p,nameKey:f,labelKey:y},_)=>{const{config:b}=uit(),N=k.useMemo(()=>{var L;if(a||!(s!=null&&s.length))return null;const[S]=s,C=`${y||S.dataKey||S.name||"value"}`,A=Pwe(b,S,C),I=!y&&typeof l=="string"?((L=b[l])==null?void 0:L.label)||l:A==null?void 0:A.label;return i?e.jsx("div",{className:Ot("font-medium",d),children:i(I,s)}):I?e.jsx("div",{className:Ot("font-medium",d),children:I}):null},[l,i,s,a,d,b,y]);if(!t||!(s!=null&&s.length))return null;const w=s.length===1&&n!=="dot";return e.jsxs("div",{ref:_,className:Ot("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",r),children:[w?null:N,e.jsx("div",{className:"grid gap-1.5",children:s.map((S,C)=>{const A=`${f||S.name||S.dataKey||"value"}`,I=Pwe(b,S,A),L=p||S.payload.fill||S.color;return e.jsx("div",{className:Ot("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&&(S==null?void 0:S.value)!==void 0&&S.name?u(S.value,S.name,S,C,S.payload):e.jsxs(e.Fragment,{children:[I!=null&&I.icon?e.jsx(I.icon,{}):!o&&e.jsx("div",{className:Ot("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":n==="dot","w-1":n==="line","w-0 border-[1.5px] border-dashed bg-transparent":n==="dashed","my-0.5":w&&n==="dashed"}),style:{"--color-bg":L,"--color-border":L}}),e.jsxs("div",{className:Ot("flex flex-1 justify-between leading-none",w?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[w?N:null,e.jsx("span",{className:"text-muted-foreground",children:(I==null?void 0:I.label)||S.name})]}),S.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:S.value.toLocaleString()})]})]})},S.dataKey)})})]})});mit.displayName="ChartTooltip";const bws=k.forwardRef(({className:t,hideIcon:s=!1,payload:r,verticalAlign:n="bottom",nameKey:a},o)=>{const{config:l}=uit();return r!=null&&r.length?e.jsx("div",{ref:o,className:Ot("flex items-center justify-center gap-4",n==="top"?"pb-3":"pt-3",t),children:r.map(i=>{const d=`${a||i.dataKey||"value"}`,u=Pwe(l,i,d);return e.jsxs("div",{className:Ot("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});bws.displayName="ChartLegend";function Pwe(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 w9=["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 qSe({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(Oe,{className:"py-12 text-center text-muted-foreground",children:"Add transactions to see your performance charts"})}):e.jsxs("div",{className:"grid gap-6",children:[r&&e.jsxs(Pe,{className:"overflow-hidden",children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Transactions by Month"})}),e.jsx(Oe,{className:"overflow-hidden",children:e.jsx(hit,{config:{count:{label:"Transactions",color:"hsl(var(--primary))"}},className:"h-[250px]",children:e.jsx(tT,{width:"100%",height:"100%",children:e.jsxs(Aat,{data:t.transactionsByMonth,margin:{top:5,right:10,left:0,bottom:5},children:[e.jsx(mat,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(mC,{dataKey:"month",tick:{fontSize:11},className:"fill-muted-foreground",interval:0}),e.jsx(pC,{allowDecimals:!1,tick:{fontSize:12},className:"fill-muted-foreground",width:30}),e.jsx(tp,{content:e.jsx(mit,{})}),e.jsx(_1,{dataKey:"count",fill:"hsl(var(--primary))",radius:[4,4,0,0],name:"Transactions"})]})})})})]}),n&&e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Lead Sources"})}),e.jsxs(Oe,{children:[e.jsx("div",{className:"h-[250px]",children:e.jsx(tT,{width:"100%",height:"100%",children:e.jsxs(Eat,{children:[e.jsx(M0,{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(hO,{fill:w9[o%w9.length]},`cell-${o}`))}),e.jsx(tp,{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:w9[o%w9.length]}}),e.jsx("span",{className:"text-muted-foreground",children:a.name})]},a.name))})]})]})]})}function wws(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=sNe(s,n,new Date);if(w1e(a))return vs(a,"yyyy-MM-dd")}catch{}try{const n=new Date(s);if(w1e(n))return vs(n,"yyyy-MM-dd")}catch{}return null}const jws=["property_address","city","state","zip","transaction_type","close_date","sale_price","commission_amount","lead_source","client_type","is_win","notes"];function Nws({open:t,onOpenChange:s}){const[r,n]=k.useState([]),[a,o]=k.useState(!1),[l,i]=k.useState(0),{data:d}=JA(),{data:u}=Nf(),p=ihe(),f=()=>{const S=jws.join(","),C=["123 Main St","Dallas","TX","75001","buyer","2024-06-15","450000","13500","Referral","Past Client","yes","Great transaction!"].join(","),A=`${S} ${C}`,I=new Blob([A],{type:"text/csv"}),L=URL.createObjectURL(I),O=document.createElement("a");O.href=L,O.download="transaction-import-template.csv",O.click(),URL.revokeObjectURL(L)},y=S=>{const C=S.split(` `).filter(I=>I.trim());if(C.length<2)return[];const A=C[0].split(",").map(I=>I.trim().toLowerCase().replace(/['"]/g,""));return C.slice(1).map((I,L)=>{var ae,oe,me,ve;const O=[];let V="",q=!1;for(const he of I)he==='"'?q=!q:he===","&&!q?(O.push(V.trim()),V=""):V+=he;O.push(V.trim());const B=he=>{var je;const ge=A.indexOf(he);return ge>=0?(je=O[ge])==null?void 0:je.replace(/^["']|["']$/g,"").trim():""},U=(ae=B("transaction_type"))==null?void 0:ae.toLowerCase(),te=(oe=B("sale_price"))==null?void 0:oe.replace(/[$,]/g,""),Y=(me=B("commission_amount"))==null?void 0:me.replace(/[$,]/g,""),J=(ve=B("is_win"))==null?void 0:ve.toLowerCase(),X=B("close_date"),ce=wws(X);let ie;return B("property_address")?["buyer","seller"].includes(U)?ce?(!te||isNaN(Number(te)))&&(ie="Invalid sale price"):ie=`Invalid date format: "${X}" - use MM/DD/YYYY or YYYY-MM-DD`:ie='Transaction type must be "buyer" or "seller"':ie="Missing property address",{property_address:B("property_address"),city:B("city"),state:B("state"),zip:B("zip"),transaction_type:U==="seller"?"seller":"buyer",close_date:ce||"",sale_price:Number(te)||0,commission_amount:Y?Number(Y):null,lead_source_name:B("lead_source"),client_type_name:B("client_type"),is_win:["yes","true","1"].includes(J),notes:B("notes"),error:ie}})},_=S=>{var I;const C=(I=S.target.files)==null?void 0:I[0];if(!C)return;const A=new FileReader;A.onload=L=>{var q;const O=(q=L.target)==null?void 0:q.result,V=y(O);n(V)},A.readAsText(C)},b=async()=>{const S=r.filter(I=>!I.error);if(S.length===0){pe.error("No valid transactions to import");return}o(!0),i(0);let C=0,A=0;for(let I=0;Iq.name.toLowerCase()===L.lead_source_name.toLowerCase()),V=u==null?void 0:u.find(q=>q.name.toLowerCase()===L.client_type_name.toLowerCase());await p.mutateAsync({property_address:L.property_address,city:L.city||null,state:L.state||null,zip:L.zip||null,transaction_type:L.transaction_type,close_date:L.close_date,sale_price:L.sale_price,commission_amount:L.commission_amount,lead_source_id:(O==null?void 0:O.id)||null,client_type_id:(V==null?void 0:V.id)||null,contact_id:null,notes:L.notes||null,is_win:L.is_win}),C++}catch(O){A++,console.error("Failed to import transaction:",O)}i(Math.round((I+1)/S.length*100))}o(!1),C>0&&pe.success(`Imported ${C} transaction${C>1?"s":""}`),A>0&&pe.error(`Failed to import ${A} transaction${A>1?"s":""}`),n([]),s(!1)},N=r.filter(S=>!S.error).length,w=r.filter(S=>S.error).length;return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh]",children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Import Transactions"}),e.jsx(Ir,{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(W,{variant:"outline",onClick:f,children:[e.jsx(Qa,{className:"h-4 w-4 mr-2"}),"Template"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"csv-file",children:"Upload CSV File"}),e.jsx(De,{id:"csv-file",type:"file",accept:".csv",onChange:_})]}),r.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Qe,{variant:"outline",children:[r.length," rows found"]}),N>0&&e.jsxs(Qe,{className:"bg-green-500 text-white",children:[e.jsx(Zn,{className:"h-3 w-3 mr-1"}),N," valid"]}),w>0&&e.jsxs(Qe,{variant:"destructive",children:[e.jsx(ro,{className:"h-3 w-3 mr-1"}),w," errors"]})]}),e.jsx(Ja,{className:"h-[200px] border rounded-lg",children:e.jsxs("div",{className:"p-2 space-y-2",children:[r.slice(0,10).map((S,C)=>e.jsxs("div",{className:`p-2 rounded text-sm ${S.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:S.property_address||"(no address)"}),e.jsx(Qe,{variant:S.transaction_type==="buyer"?"default":"secondary",children:S.transaction_type})]}),e.jsxs("div",{className:"text-muted-foreground",children:[S.close_date," • $",S.sale_price.toLocaleString()]}),S.error&&e.jsx(c4e,{variant:"destructive",className:"mt-1 py-1",children:e.jsx(d4e,{className:"text-xs",children:S.error})})]},C)),r.length>10&&e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["...and ",r.length-10," more"]})]})}),a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${l}%`}})}),e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:["Importing... ",l,"%"]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(W,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(W,{onClick:b,disabled:N===0||a,children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"}),"Import ",N," Transaction",N!==1?"s":""]})]})]})]})})}const kws=kC({transactions_goal:e8().min(0).optional(),volume_goal:e8().min(0).optional(),gci_goal:e8().min(0).optional()});function Sws({open:t,onOpenChange:s,year:r,existingGoals:n}){const a=v8t(),{data:o}=ohe(),l=(o==null?void 0:o.show_commission)??!0,i=Zue({resolver:Yue(kws),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 d=async u=>{await a.mutateAsync({year:r,transactions_goal:u.transactions_goal??null,volume_goal:u.volume_goal??null,gci_goal:l?u.gci_goal??null:null}),s(!1)};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsxs(ks,{children:[e.jsxs(_s,{children:[r," Goals"]}),e.jsx(Ir,{children:"Set your annual targets to track your progress throughout the year."})]}),e.jsx(Xue,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(d),className:"space-y-4",children:[e.jsx(Ec,{control:i.control,name:"transactions_goal",render:({field:u})=>e.jsxs(mc,{children:[e.jsx(pc,{children:"Transactions Goal"}),e.jsx(fc,{children:e.jsx(De,{type:"number",placeholder:"e.g., 24",...u,value:u.value??"",onChange:p=>u.onChange(p.target.value?Number(p.target.value):void 0)})}),e.jsx(Qie,{children:"Total number of deals you want to close"}),e.jsx(vm,{})]})}),e.jsx(Ec,{control:i.control,name:"volume_goal",render:({field:u})=>e.jsxs(mc,{children:[e.jsx(pc,{children:"Volume Goal ($)"}),e.jsx(fc,{children:e.jsx(De,{type:"number",placeholder:"e.g., 5000000",...u,value:u.value??"",onChange:p=>u.onChange(p.target.value?Number(p.target.value):void 0)})}),e.jsx(Qie,{children:"Total sales volume you want to achieve"}),e.jsx(vm,{})]})}),l&&e.jsx(Ec,{control:i.control,name:"gci_goal",render:({field:u})=>e.jsxs(mc,{children:[e.jsx(pc,{children:"GCI Goal ($)"}),e.jsx(fc,{children:e.jsx(De,{type:"number",placeholder:"e.g., 150000",...u,value:u.value??"",onChange:p=>u.onChange(p.target.value?Number(p.target.value):void 0)})}),e.jsx(Qie,{children:"Gross commission income target"}),e.jsx(vm,{})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(W,{type:"submit",disabled:a.isPending,children:"Save Goals"})]})]})})]})})}function USe({transactions:t,isLoading:s}){const r=k.useRef(null),n=k.useRef(null),a=k.useRef([]),o=k.useRef(null),{isAdmin:l}=Us(),[i,d]=k.useState(""),[u,p]=k.useState(!0),[f,y]=k.useState(0),[_,b]=k.useState(!1),N=t.filter(S=>S.latitude!=null&&S.longitude!=null),w=t.filter(S=>S.latitude==null||S.longitude==null);return k.useEffect(()=>{(async()=>{p(!0);try{const{data:C}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();C!=null&&C.value&&d(C.value)}catch(C){console.error("Error fetching mapbox token:",C)}p(!1)})()},[]),k.useEffect(()=>{if(!i||w.length===0||_)return;(async()=>{var A;b(!0);let C=0;for(const I of w){const L=[I.property_address,I.city,I.state,I.zip].filter(Boolean).join(", ");if(L)try{const V=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(L)}.json?access_token=${i}&limit=1`)).json();if((A=V.features)!=null&&A[0]){const[q,B]=V.features[0].center;await G.from("scorecard_transactions").update({latitude:B,longitude:q}).eq("id",I.id),I.latitude=B,I.longitude=q,C++}}catch(O){console.error("Geocode error:",O)}}y(C),b(!1)})()},[i,t]),k.useEffect(()=>{if(!r.current||!i||n.current)return;Ko.accessToken=i;const S=t.filter(I=>I.latitude!=null&&I.longitude!=null);let C=[-98.5795,39.8283],A=4;if(S.length>0){const I=S.reduce((O,V)=>O+V.longitude,0)/S.length,L=S.reduce((O,V)=>O+V.latitude,0)/S.length;C=[I,L],A=S.length===1?12:10}return n.current=new Ko.Map({container:r.current,style:"mapbox://styles/mapbox/light-v11",zoom:A,center:C}),n.current.addControl(new Ko.NavigationControl,"top-right"),()=>{var I;(I=n.current)==null||I.remove(),n.current=null}},[i]),k.useEffect(()=>{var C;if(!n.current||!i)return;a.current.forEach(A=>A.remove()),a.current=[],(C=o.current)==null||C.remove();const S=t.filter(A=>A.latitude!=null&&A.longitude!=null);if(S.forEach(A=>{var B;const I=A.transaction_type==="buyer",L=I?"#3B82F6":"#10B981",O=document.createElement("div");O.className="cursor-pointer",O.innerHTML=`
${I?'':''}
`;const V=new Ko.Popup({offset:25,closeButton:!0}).setHTML(`
${A.property_address}
${A.city?`
${A.city}${A.state?", "+A.state:""} ${A.zip||""}
`:""}
${I?"Buyer":"Seller"} $${Number(A.sale_price).toLocaleString()}
Closed: ${ol(A.close_date).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} ${(B=A.lead_source)!=null&&B.name?" · "+A.lead_source.name:""}
${A.contact?`
Client: ${A.contact.first_name} ${A.contact.last_name||""}
`:""}
`),q=new Ko.Marker(O).setLngLat([A.longitude,A.latitude]).setPopup(V).addTo(n.current);a.current.push(q)}),S.length>1){const A=new Ko.LngLatBounds;S.forEach(I=>A.extend([I.longitude,I.latitude])),n.current.fitBounds(A,{padding:60,maxZoom:13})}else S.length===1&&n.current.flyTo({center:[S[0].longitude,S[0].latitude],zoom:12})},[t,i,_]),u||s?e.jsx(Pe,{children:e.jsx(Oe,{className:"flex items-center justify-center h-[50vh]",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):i?t.length===0?e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[e.jsx(Ia,{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:[N.length," of ",t.length," mapped",_&&" · Geocoding..."]})]}),e.jsx("div",{ref:r,className:"w-full h-[55vh] rounded-lg shadow-lg border"})]}):e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[e.jsx(ro,{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 pit=()=>{const{data:t}=Px();return gt({queryKey:["team-scorecard-members",t==null?void 0:t.teamId],queryFn:async()=>{const{data:s,error:r}=await G.from("team_members").select("user_id").eq("team_id",t.teamId);if(r)throw r;const n=s.map(l=>l.user_id),{data:a,error:o}=await G.from("profiles").select("id, name, email, avatar_url").in("id",n);if(o)throw o;return a||[]},enabled:!!(t!=null&&t.teamId)&&(t==null?void 0:t.role)==="team_leader"})},Cws=t=>{const{data:s}=Px(),{data:r}=pit();return gt({queryKey:["team-scorecard-transactions",s==null?void 0:s.teamId,t],queryFn:async()=>{const n=r.map(l=>l.id),{data:a,error:o}=await G.from("scorecard_transactions").select(` *, lead_source:lead_sources(id, name), client_type:relationship_types(id, name), contact:innercircle_contacts(id, first_name, last_name) `).in("owner_user_id",n).gte("close_date",`${t}-01-01`).lte("close_date",`${t}-12-31`).order("close_date",{ascending:!1});if(o)throw o;return a},enabled:!!r&&r.length>0})};function Mws(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 Tws(t,s){return t?t.split(" ").map(r=>r[0]).join("").toUpperCase().slice(0,2):s[0].toUpperCase()}function Aws({year:t}){var y;const{data:s,isLoading:r}=pit(),{data:n,isLoading:a}=Cws(t),o=wr(),l=r||a,{aggregate:i,memberStats:d,topPerformer:u,agentNameMap:p,teamChartStats:f}=k.useMemo(()=>{if(!s||!n)return{aggregate:null,memberStats:[],topPerformer:null,agentNameMap:{},teamChartStats:null};const _=s.map(U=>Mws(U,n));_.sort((U,te)=>te.totalVolume-U.totalVolume);const b={};s.forEach(U=>{b[U.id]=U.name||U.email});const N=n.length,w=n.reduce((U,te)=>U+Number(te.sale_price),0),S=n.reduce((U,te)=>U+(Number(te.commission_amount)||0),0),C=n.filter(U=>U.transaction_type==="buyer").length,A=n.filter(U=>U.transaction_type==="seller").length,I={};n.forEach(U=>{var Y;const te=((Y=U.lead_source)==null?void 0:Y.name)||"Unknown";I[te]=(I[te]||0)+1});const L=Object.entries(I).sort((U,te)=>te[1]-U[1])[0],O={};n.forEach(U=>{const te=ol(U.close_date).toLocaleString("default",{month:"short"});O[te]=(O[te]||0)+1});const q=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(U=>({month:U,count:O[U]||0})),B=Object.entries(I).map(([U,te])=>({name:U,count:te})).sort((U,te)=>te.count-U.count);return{aggregate:{totalTxns:N,buyerCount:C,sellerCount:A,totalVolume:w,avgPrice:N>0?w/N:0,totalGCI:S,topSource:L?{name:L[0],count:L[1]}:null,memberCount:s.length},memberStats:_,topPerformer:_[0]||null,agentNameMap:b,teamChartStats:{transactionsByMonth:q,leadSourceBreakdown:B}}},[s,n]);return l?e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[1,2,3,4].map(_=>e.jsx(Ms,{className:"h-24"},_))}),e.jsx(Ms,{className:"h-64"})]}):!i||d.length===0?e.jsx(Pe,{className:"py-12",children:e.jsxs(Oe,{className:"text-center space-y-2",children:[e.jsx(ir,{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(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ir,{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(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Mn,{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(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(_c,{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:Il(i.totalVolume,!0)})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Qo,{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:Il(i.avgPrice,!0)})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(_c,{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:Il(i.totalGCI,!0)})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(nc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((y=i.topSource)==null?void 0:y.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(Oe,{className:"pt-4 flex items-center gap-4",children:[e.jsx("div",{className:"flex items-center justify-center h-10 w-10 rounded-full bg-primary/10",children:e.jsx(Fi,{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:Il(u.totalVolume,!0)})]})]})}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"Member Performance"})}),e.jsx(Oe,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Agent"}),e.jsx(St,{className:"text-center",children:"Transactions"}),e.jsx(St,{className:"text-center",children:"B / S"}),e.jsx(St,{className:"text-right",children:"Volume"}),e.jsx(St,{className:"text-right",children:"Avg Price"}),e.jsx(St,{className:"text-right",children:"GCI"}),e.jsx(St,{className:"text-right"})]})}),e.jsx(Rn,{children:d.map((_,b)=>e.jsxs(Ps,{children:[e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[b===0&&_.totalTransactions>0&&e.jsx(Fi,{className:"absolute -top-2 -right-2 h-3.5 w-3.5 text-amber-500"}),e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:_.member.avatar_url||void 0}),e.jsx(kn,{className:"text-xs",children:Tws(_.member.name,_.member.email)})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:_.member.name||_.member.email}),_.member.name&&e.jsx("p",{className:"text-xs text-muted-foreground",children:_.member.email})]})]})}),e.jsx(ht,{className:"text-center font-semibold",children:_.totalTransactions}),e.jsxs(ht,{className:"text-center text-sm",children:[_.buyerCount," / ",_.sellerCount]}),e.jsx(ht,{className:"text-right font-medium",children:Il(_.totalVolume,!0)}),e.jsx(ht,{className:"text-right text-sm",children:Il(_.averagePrice,!0)}),e.jsx(ht,{className:"text-right font-medium",children:Il(_.totalGCI,!0)}),e.jsx(ht,{className:"text-right",children:e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>o(`/mission-control/scorecard/${_.member.id}`),children:e.jsx(jn,{className:"h-4 w-4"})})})]},_.member.id))})]})})})]}),e.jsxs(ta,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(Jn,{children:[e.jsxs(cs,{value:"transactions",children:[e.jsx(Dh,{className:"h-4 w-4 mr-1"}),"All Transactions"]}),e.jsxs(cs,{value:"charts",children:[e.jsx(so,{className:"h-4 w-4 mr-1"}),"Charts"]}),e.jsxs(cs,{value:"map",children:[e.jsx(Ia,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(Ss,{value:"transactions",children:e.jsx($Se,{transactions:n||[],showCommission:!0,isLoading:a,agentNameMap:p,readOnly:!0})}),e.jsx(Ss,{value:"charts",children:f&&e.jsx(qSe,{stats:f,year:t})}),e.jsx(Ss,{value:"map",children:e.jsx(USe,{transactions:n||[],isLoading:a})})]})]})}const fit=new Date().getFullYear(),Z7e=Array.from({length:10},(t,s)=>fit-s);function Ews(){var U;const[t,s]=k.useState(fit),[r,n]=k.useState(!1),[a,o]=k.useState(!1),[l,i]=k.useState(!1),[d,u]=k.useState(!1),[p,f]=k.useState("my"),{data:y}=Px(),_=(y==null?void 0:y.role)==="team_leader",{data:b,isLoading:N}=cke(t),{yearStats:w,lifetimeStats:S,isLoading:C,showCommission:A}=zXe(t),{data:I,isLoading:L}=FXe(t),{data:O}=ohe(),V=_8t(),q=()=>{if(!b||b.length===0)return;const te=["Property Address","City","State","Zip","Transaction Type","Close Date","Sale Price",...A?["Commission"]:[],"Lead Source","Client Type","Contact Name","Is Win","Notes"],Y=b.map(ae=>{var oe,me;return[ae.property_address,ae.city||"",ae.state||"",ae.zip||"",ae.transaction_type,ae.close_date,ae.sale_price,...A?[ae.commission_amount||""]:[],((oe=ae.lead_source)==null?void 0:oe.name)||"",((me=ae.client_type)==null?void 0:me.name)||"",ae.contact?`${ae.contact.first_name} ${ae.contact.last_name||""}`.trim():"",ae.is_win?"Yes":"No",ae.notes||""]}),J=[te,...Y].map(ae=>ae.map(oe=>`"${String(oe).replace(/"/g,'""')}"`).join(",")).join(` `),X=new Blob([J],{type:"text/csv"}),ce=URL.createObjectURL(X),ie=document.createElement("a");ie.href=ce,ie.download=`transactions-${t}.csv`,ie.click(),URL.revokeObjectURL(ce)},B=!b||b.length===0;return e.jsxs(Ds,{title:"Scorecard",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Scorecard"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500/50 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),_&&e.jsxs("div",{className:"flex items-center gap-1 bg-muted rounded-lg p-1 w-fit",children:[e.jsx(W,{variant:p==="my"?"default":"ghost",size:"sm",onClick:()=>f("my"),className:"h-8",children:"My Scorecard"}),e.jsxs(W,{variant:p==="team"?"default":"ghost",size:"sm",onClick:()=>f("team"),className:"h-8",children:[e.jsx(ir,{className:"h-4 w-4 mr-1.5"}),"Team"]})]}),p==="team"&&_?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground",children:"Team Performance"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Aggregate stats and member comparison"})]}),e.jsxs($s,{value:String(t),onValueChange:te=>s(Number(te)),children:[e.jsx(zs,{className:"w-[120px]",children:e.jsx(Vs,{})}),e.jsx(Bs,{children:Z7e.map(te=>e.jsx(vt,{value:String(te),children:te},te))})]})]}),e.jsx(Aws,{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($s,{value:String(t),onValueChange:te=>s(Number(te)),children:[e.jsx(zs,{className:"w-[120px]",children:e.jsx(Vs,{})}),e.jsx(Bs,{children:Z7e.map(te=>e.jsx(vt,{value:String(te),children:te},te))})]}),e.jsx(W,{variant:"outline",size:"icon",onClick:()=>u(!d),children:e.jsx(So,{className:"h-4 w-4"})})]})]}),d&&e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsx(zt,{className:"text-lg",children:"Settings"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(xe,{children:"Show Commission"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Display commission fields and include in stats"})]}),e.jsx(Ar,{checked:(O==null?void 0:O.show_commission)??!0,onCheckedChange:te=>V.mutate({show_commission:te})})]})})]}),B&&!N?e.jsx(Pe,{className:"py-12",children:e.jsxs(Oe,{className:"text-center space-y-4",children:[e.jsx("div",{className:"w-16 h-16 mx-auto rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(so,{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(W,{onClick:()=>n(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Your First Transaction"]}),e.jsxs(W,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(Ra,{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(W,{variant:"link",className:"h-auto p-0",asChild:!0,children:e.jsxs("a",{href:"/templates/transaction-import-template.csv",download:!0,children:[e.jsx(Qa,{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(W,{onClick:()=>n(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Transaction"]}),e.jsxs(W,{variant:"outline",onClick:()=>i(!0),children:[e.jsx(Rh,{className:"h-4 w-4 mr-2"}),"Set Goals"]}),e.jsxs(W,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"}),"Import"]}),e.jsxs(W,{variant:"outline",onClick:q,disabled:B,children:[e.jsx(Qa,{className:"h-4 w-4 mr-2"}),"Export"]}),e.jsx(W,{variant:"ghost",size:"sm",asChild:!0,children:e.jsxs("a",{href:"/templates/transaction-import-template.csv",download:!0,children:[e.jsx(Qa,{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(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Mn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:w.totalTransactions}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[S.totalTransactions," lifetime"]})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ir,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Buyer/Seller"})]}),e.jsxs("p",{className:"text-2xl font-bold",children:[w.buyerCount,"/",w.sellerCount]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"B/S split"})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(_c,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Il(w.totalVolume,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Il(S.totalVolume,!0)," lifetime"]})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Qo,{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:Il(w.averagePrice,!0)})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(nc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((U=w.topLeadSource)==null?void 0:U.name)||"-"}),w.topLeadSource&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[w.topLeadSource.count," deals"]})]})}),A&&e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(_c,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"GCI"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Il(w.totalCommission,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Il(S.totalCommission,!0)," lifetime"]})]})}),A&&w.totalNetToAgent>0&&w.totalNetToAgent!==w.totalCommission&&e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-teal-600 dark:text-teal-400 mb-1",children:[e.jsx(_c,{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:Il(w.totalNetToAgent,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Il(S.totalNetToAgent,!0)," lifetime"]})]})})]}),I&&e.jsx(cit,{goals:I,stats:w,year:t,showCommission:A}),e.jsxs(ta,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(Jn,{children:[e.jsx(cs,{value:"transactions",children:"Transactions"}),e.jsx(cs,{value:"charts",children:"Charts"}),e.jsxs(cs,{value:"map",children:[e.jsx(Ia,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(Ss,{value:"transactions",children:e.jsx($Se,{transactions:b||[],showCommission:A,isLoading:N})}),e.jsx(Ss,{value:"charts",children:e.jsx(qSe,{stats:w,year:t})}),e.jsx(Ss,{value:"map",children:e.jsx(USe,{transactions:b||[],isLoading:N})})]})]})]})]}),e.jsx(lit,{open:r,onOpenChange:n}),e.jsx(Nws,{open:a,onOpenChange:o}),e.jsx(Sws,{open:l,onOpenChange:i,year:t,existingGoals:I})]})}function xit({open:t,onOpenChange:s,listingId:r,listingSlug:n,listingTitle:a}){const{user:o}=Us(),[l,i]=k.useState(null),[d,u]=k.useState(!1),[p,f]=k.useState(!1);k.useEffect(()=>{(async()=>{if(!(!t||!o)){u(!0);try{const{data:w,error:S}=await G.from("listing_shares").select("id, share_token, click_count, lead_count").eq("listing_id",r).eq("sharing_agent_id",o.id).order("created_at",{ascending:!1}).limit(1).maybeSingle();if(S)throw S;if(w&&w.share_token)i(w);else if(w&&!w.share_token){const{data:C,error:A}=await G.from("listing_shares").update({share_type:"referral_link"}).eq("id",w.id).select("id, share_token, click_count, lead_count").single();if(A)throw A;i(C)}else{const{data:C,error:A}=await G.from("listing_shares").insert({listing_id:r,sharing_agent_id:o.id,share_type:"referral_link"}).select("id, share_token, click_count, lead_count").single();if(A)throw A;i(C)}}catch(w){console.error("Error creating share link:",w),pe.error("Failed to generate share link")}finally{u(!1)}}})()},[t,o,r]);const y=l!=null&&l.share_token?`https://listings.relevelup.com/${n||r}?ref=${l.share_token}`:"",_=async()=>{try{await navigator.clipboard.writeText(y),f(!0),pe.success("Link copied to clipboard!"),setTimeout(()=>f(!1),2e3)}catch{pe.error("Failed to copy link")}},b=N=>{const w=encodeURIComponent(y),S=encodeURIComponent(`Check out this listing: ${a}`);switch(N){case"email":window.open(`mailto:?subject=${S}&body=${w}`);break;case"text":window.open(`sms:?body=${S}%20${w}`);break;case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${w}`,"_blank");break}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(Or,{className:"h-5 w-5 text-amber-500"}),"Share & Earn Leads"]}),e.jsx(Ir,{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(xe,{children:"Your Referral Link"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{value:d?"Generating...":y,readOnly:!0,className:"font-mono text-sm"}),e.jsx(W,{onClick:_,disabled:d||!y,variant:p?"default":"outline",children:p?e.jsx(Zn,{className:"h-4 w-4"}):e.jsx(Va,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Share via"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(W,{variant:"outline",className:"flex-1",onClick:()=>b("email"),disabled:d,children:[e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Email"]}),e.jsxs(W,{variant:"outline",className:"flex-1",onClick:()=>b("text"),disabled:d,children:[e.jsx(wi,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(W,{variant:"outline",className:"flex-1",onClick:()=>b("facebook"),disabled:d,children:[e.jsx(hu,{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(xe,{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(jn,{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(ir,{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 Pws={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},Iws={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},Lws={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function j9({listing:t,onClick:s,onEdit:r,onDelete:n,showActions:a}){var N,w;const{user:o}=Us(),{data:l}=PXe(t.id),i=EXe(),[d,u]=k.useState(!1),p=S=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(S),f=((N=t.photos)==null?void 0:N.find(S=>S.is_primary))||((w=t.photos)==null?void 0:w[0]),y=(o==null?void 0:o.id)===t.agent_id,_=async S=>{S.stopPropagation();try{const C=await i.mutateAsync(t.id);pe.success(C.saved?"Listing saved!":"Listing removed from saved")}catch{pe.error("Failed to save listing")}},b=S=>{if(S.stopPropagation(),o)u(!0);else{const C=`https://listings.relevelup.com/${t.slug||t.id}`;navigator.clipboard.writeText(C),pe.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(r0,{className:"h-12 w-12"})}),e.jsx(Qe,{className:`absolute top-2 left-2 ${Pws[t.status]} text-white border-0`,children:Iws[t.status]}),t.is_featured&&e.jsx("div",{className:"absolute top-2 right-2 p-1.5 bg-amber-500 rounded-full",children:e.jsx(Gn,{className:"h-4 w-4 text-white fill-white"})}),e.jsxs("div",{className:"absolute bottom-2 right-2 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(W,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:_,children:e.jsx(Xa,{className:`h-4 w-4 ${l?"fill-pink-500 text-pink-500":""}`})}),e.jsx(W,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:b,title:y?"Copy link":"Share & earn leads",children:y?e.jsx(id,{className:"h-4 w-4"}):e.jsx(Or,{className:"h-4 w-4 text-amber-500"})})]})]}),e.jsx(xit,{open:d,onOpenChange:u,listingId:t.id,listingSlug:t.slug||null,listingTitle:t.property_address||`${t.city}, ${t.state}`}),e.jsxs(Oe,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xl font-bold text-primary",children:p(t.price)}),t.open_to_referrals&&e.jsxs(Qe,{variant:"outline",className:"text-xs",children:[e.jsx(ir,{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(Ia,{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(Zy,{className:"h-4 w-4"}),t.bedrooms," bd"]}),t.bathrooms&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nf,{className:"h-4 w-4"}),t.bathrooms," ba"]}),t.square_footage&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(r0,{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(Qe,{variant:"secondary",className:"text-xs",children:Lws[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(jn,{className:"h-3 w-3"}),t.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(id,{className:"h-3 w-3"}),t.share_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Xa,{className:"h-3 w-3"}),t.save_count]})]}),a&&(r||n)&&e.jsxs("div",{className:"flex gap-2",children:[r&&e.jsxs(W,{variant:"outline",size:"sm",className:"flex-1",onClick:S=>{S.stopPropagation(),r()},children:[e.jsx(Wc,{className:"h-4 w-4 mr-2"}),"Edit"]}),n&&e.jsx(W,{variant:"destructive",size:"sm",onClick:S=>{S.stopPropagation(),n()},children:e.jsx(vr,{className:"h-4 w-4"})})]})]})]})}const Dws=[{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"}],Rws=[{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 Ows({filters:t,onFiltersChange:s,onClose:r}){const n=()=>{s({sortBy:"newest"})};return e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between pb-3",children:[e.jsx(zt,{className:"text-lg",children:"Filters"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{variant:"ghost",size:"sm",onClick:n,children:"Clear All"}),e.jsx(W,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(kr,{className:"h-4 w-4"})})]})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Status"}),e.jsxs($s,{value:t.status||"all",onValueChange:a=>s({...t,status:a==="all"?void 0:a}),children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"All statuses"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Statuses"}),Dws.map(a=>e.jsx(vt,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Property Type"}),e.jsxs($s,{value:t.propertyType||"all",onValueChange:a=>s({...t,propertyType:a==="all"?void 0:a}),children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"All types"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Types"}),Rws.map(a=>e.jsx(vt,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Min Price"}),e.jsx(De,{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(xe,{children:"Max Price"}),e.jsx(De,{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(xe,{children:"Open to Referrals Only"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show only listings accepting buyer referrals"})]}),e.jsx(Ar,{checked:t.openToReferrals||!1,onCheckedChange:a=>s({...t,openToReferrals:a||void 0})})]})]})]})}function Fws({leaderboard:t}){const s=n=>{switch(n){case 0:return e.jsx(Fi,{className:"h-5 w-5 text-amber-500"});case 1:return e.jsx(Qv,{className:"h-5 w-5 text-gray-400"});case 2:return e.jsx(nc,{className:"h-5 w-5 text-amber-700"});default:return e.jsx("span",{className:"text-sm font-medium text-muted-foreground w-5 text-center",children:n+1})}},r=(n,a)=>!n||n.length===0?e.jsx("div",{className:"py-8 text-center text-muted-foreground",children:"No data yet. Start sharing to climb the leaderboard!"}):e.jsx("div",{className:"space-y-2",children:n.map((o,l)=>e.jsxs("div",{className:`flex items-center gap-4 p-3 rounded-lg ${l===0?"bg-gradient-to-r from-amber-500/10 to-amber-500/5 border border-amber-500/20":"bg-muted/50"}`,children:[e.jsx("div",{className:"flex items-center justify-center w-8",children:s(l)}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"font-medium truncate",children:o.name})}),e.jsxs(Qe,{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(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Fi,{className:"h-5 w-5 text-amber-500"}),"Community Badges"]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"text-center p-4 rounded-lg bg-gradient-to-br from-emerald-500/10 to-emerald-500/5 border border-emerald-500/20",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-2 rounded-full bg-emerald-500/20 flex items-center justify-center",children:e.jsx(id,{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(Mn,{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(Qv,{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(Fi,{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(Dt,{children:e.jsx(zt,{children:"Community Leaderboard"})}),e.jsx(Oe,{children:e.jsxs(ta,{defaultValue:"sharers",children:[e.jsxs(Jn,{className:"w-full",children:[e.jsxs(cs,{value:"sharers",className:"flex-1",children:[e.jsx(id,{className:"h-4 w-4 mr-2"}),"Top Sharers"]}),e.jsxs(cs,{value:"listers",className:"flex-1",children:[e.jsx(Mn,{className:"h-4 w-4 mr-2"}),"Top Contributors"]})]}),e.jsx(Ss,{value:"sharers",className:"mt-4",children:r(t==null?void 0:t.topSharers,"shares")}),e.jsx(Ss,{value:"listers",className:"mt-4",children:r(t==null?void 0:t.topListers,"listings")})]})})]})]})}const Y7e={coming_soon:"#F59E0B",active:"#10B981",price_improvement:"#8B5CF6",under_contract:"#3B82F6",sold:"#A855F7"},X7e={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function zws(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function Bws({listings:t,isLoading:s}){const r=wr(),n=k.useRef(null),a=k.useRef(null),o=k.useRef([]),{isAdmin:l}=Us(),[i,d]=k.useState(""),[u,p]=k.useState(!0),[f,y]=k.useState(!1),_=t.filter(N=>N.latitude!=null&&N.longitude!=null),b=t.filter(N=>(N.latitude==null||N.longitude==null)&&(N.property_address||N.city));return k.useEffect(()=>{(async()=>{p(!0);try{const{data:w}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();w!=null&&w.value&&d(w.value)}catch(w){console.error("Error fetching mapbox token:",w)}p(!1)})()},[]),k.useEffect(()=>{if(!i||b.length===0||f)return;(async()=>{var w;y(!0);for(const S of b){const C=[S.property_address,S.city,S.state].filter(Boolean).join(", ");if(C)try{const I=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(C)}.json?access_token=${i}&limit=1`)).json();if((w=I.features)!=null&&w[0]){const[L,O]=I.features[0].center;await G.from("listings").update({latitude:O,longitude:L}).eq("id",S.id),S.latitude=O,S.longitude=L}}catch(A){console.error("Geocode error:",A)}}y(!1)})()},[i,t]),k.useEffect(()=>{if(!n.current||!i||a.current)return;Ko.accessToken=i;const N=t.filter(C=>C.latitude!=null&&C.longitude!=null);let w=[-98.5795,39.8283],S=4;if(N.length>0){const C=N.reduce((I,L)=>I+L.longitude,0)/N.length,A=N.reduce((I,L)=>I+L.latitude,0)/N.length;w=[C,A],S=N.length===1?12:10}return a.current=new Ko.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:S,center:w}),a.current.addControl(new Ko.NavigationControl,"top-right"),()=>{var C;(C=a.current)==null||C.remove(),a.current=null}},[i]),k.useEffect(()=>{if(!a.current||!i)return;o.current.forEach(w=>w.remove()),o.current=[];const N=t.filter(w=>w.latitude!=null&&w.longitude!=null);if(N.forEach(w=>{var O,V,q;const S=Y7e[w.status]||"#10B981",C=((O=w.photos)==null?void 0:O.find(B=>B.is_primary))||((V=w.photos)==null?void 0:V[0]),A=document.createElement("div");A.className="cursor-pointer",A.innerHTML=`
`;const I=new Ko.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${C!=null&&C.photo_url?``:""}
${zws(w.price)}
${w.property_address||""}
${w.city}, ${w.state}
${X7e[w.status]||w.status} ${w.bedrooms?`${w.bedrooms} bed`:""} ${w.bathrooms?`${w.bathrooms} bath`:""}
${(q=w.agent)!=null&&q.name?`
Listed by ${w.agent.name}
`:""}
Click to view details →
`),L=new Ko.Marker(A).setLngLat([w.longitude,w.latitude]).setPopup(I).addTo(a.current);o.current.push(L)}),N.length>1){const w=new Ko.LngLatBounds;N.forEach(S=>w.extend([S.longitude,S.latitude])),a.current.fitBounds(w,{padding:60,maxZoom:13})}else N.length===1&&a.current.flyTo({center:[N[0].longitude,N[0].latitude],zoom:12})},[t,i,f]),k.useEffect(()=>(window.__navigateToListing__=N=>{r(`/mission-control/listings/${N}`)},()=>{delete window.__navigateToListing__}),[r]),u||s?e.jsx(Pe,{children:e.jsx(Oe,{className:"flex items-center justify-center h-[60vh]",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):i?t.length===0?e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[e.jsx(Ia,{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(Y7e).map(([N,w])=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-3 h-3 rounded-full border-2 border-white shadow",style:{background:w}}),e.jsx("span",{className:"text-xs",children:X7e[N]})]},N)),e.jsxs("span",{className:"text-muted-foreground ml-auto text-xs",children:[_.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(Oe,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[e.jsx(ro,{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 $ws(){var B,U,te,Y,J,X,ce,ie;const t=wr(),{brokerageId:s}=Us(),{data:r,isLoading:n}=SXe(),[a,o]=k.useState("feed"),[l,i]=k.useState(!1),[d,u]=k.useState(""),[p,f]=k.useState({sortBy:"newest"}),{data:y,isLoading:_}=CXe({...p,city:d||p.city}),{data:b,isLoading:N}=s8t(),{data:w,isLoading:S}=MXe(),{data:C,isLoading:A}=i8t(),{data:I,isLoading:L}=c8t(),{data:O}=l8t(),V=AXe(),q=async ae=>{if(confirm("Are you sure you want to delete this listing? This action cannot be undone."))try{await V.mutateAsync(ae),pe.success("Listing deleted successfully")}catch{pe.error("Failed to delete listing")}};return n?e.jsx(Ds,{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(Ds,{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(W,{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(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(Mn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(y==null?void 0:y.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active Listings"})]})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-pink-500/10 rounded-lg",children:e.jsx(Xa,{className:"h-5 w-5 text-pink-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(b==null?void 0:b.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saved"})]})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-emerald-500/10 rounded-lg",children:e.jsx(Z4,{className:"h-5 w-5 text-emerald-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(w==null?void 0:w.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"My Listings"})]})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-sky-500/10 rounded-lg",children:e.jsx(ir,{className:"h-5 w-5 text-sky-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(((B=C==null?void 0:C.sent)==null?void 0:B.length)||0)+(((U=C==null?void 0:C.received)==null?void 0:U.length)||0)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Referrals"})]})]})})]}),e.jsxs(ta,{value:a,onValueChange:o,children:[e.jsxs(Jn,{className:"w-full justify-start overflow-x-auto",children:[e.jsx(cs,{value:"feed",children:"Community Feed"}),s&&e.jsx(cs,{value:"brokerage",children:"Brokerage"}),e.jsx(cs,{value:"my-listings",children:"My Listings"}),e.jsx(cs,{value:"saved",children:"Saved"}),e.jsx(cs,{value:"referrals",children:"Referrals"}),e.jsx(cs,{value:"map",children:"Map"}),e.jsx(cs,{value:"leaderboard",children:"Leaderboard"})]}),e.jsxs(Ss,{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(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by city or neighborhood...",value:d,onChange:ae=>u(ae.target.value),className:"pl-9"})]}),e.jsxs($s,{value:p.sortBy,onValueChange:ae=>f({...p,sortBy:ae}),children:[e.jsx(zs,{className:"w-[180px]",children:e.jsx(Vs,{placeholder:"Sort by"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"newest",children:"Newest First"}),e.jsx(vt,{value:"updated",children:"Recently Updated"}),e.jsx(vt,{value:"price_asc",children:"Price: Low to High"}),e.jsx(vt,{value:"price_desc",children:"Price: High to Low"})]})]}),e.jsxs(W,{variant:"outline",onClick:()=>i(!l),children:[e.jsx(Eg,{className:"h-4 w-4 mr-2"}),"Filters"]})]}),l&&e.jsx(Ows,{filters:p,onFiltersChange:f,onClose:()=>i(!1)}),_?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(6)].map((ae,oe)=>e.jsxs(Pe,{children:[e.jsx(Ms,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(Ms,{className:"h-5 w-3/4"}),e.jsx(Ms,{className:"h-4 w-1/2"}),e.jsx(Ms,{className:"h-4 w-1/4"})]})]},oe))}):(y==null?void 0:y.length)===0?e.jsx(Pe,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Mn,{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(W,{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:y==null?void 0:y.map(ae=>e.jsx(j9,{listing:ae,onClick:()=>t(`/mission-control/listings/${ae.id}`)},ae.id))})]}),e.jsx(Ss,{value:"my-listings",className:"space-y-4",children:S?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((ae,oe)=>e.jsxs(Pe,{children:[e.jsx(Ms,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(Ms,{className:"h-5 w-3/4"}),e.jsx(Ms,{className:"h-4 w-1/2"})]})]},oe))}):(w==null?void 0:w.length)===0?e.jsx(Pe,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Z4,{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(W,{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:w==null?void 0:w.map(ae=>e.jsx(j9,{listing:ae,showActions:!0,onClick:()=>t(`/mission-control/listings/${ae.id}`),onEdit:()=>t(`/mission-control/listings/${ae.id}/edit`),onDelete:()=>q(ae.id)},ae.id))})}),e.jsx(Ss,{value:"saved",className:"space-y-4",children:N?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((ae,oe)=>e.jsxs(Pe,{children:[e.jsx(Ms,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(Ms,{className:"h-5 w-3/4"}),e.jsx(Ms,{className:"h-4 w-1/2"})]})]},oe))}):(b==null?void 0:b.length)===0?e.jsx(Pe,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Xa,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No saved listings"}),e.jsx("p",{className:"text-muted-foreground",children:"Save listings to quickly access them later"})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:b==null?void 0:b.map(ae=>e.jsx(j9,{listing:ae.listing,onClick:()=>t(`/mission-control/listings/${ae.listing.id}`)},ae.id))})}),e.jsx(Ss,{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(id,{className:"h-4 w-4"}),"Referrals Sent (",((te=C==null?void 0:C.sent)==null?void 0:te.length)||0,")"]}),((Y=C==null?void 0:C.sent)==null?void 0:Y.length)===0?e.jsx(Pe,{children:e.jsx(Oe,{className:"py-8 text-center text-muted-foreground",children:"No referrals sent yet"})}):e.jsx("div",{className:"space-y-3",children:(J=C==null?void 0:C.sent)==null?void 0:J.map(ae=>{var oe,me;return e.jsx(Pe,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:ae.buyer_name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((oe=ae.listing)==null?void 0:oe.property_address)||((me=ae.listing)==null?void 0:me.city)})]}),e.jsx(Qe,{variant:ae.status==="closed"?"default":"secondary",children:ae.status.replace("_"," ")})]})})},ae.id)})})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold mb-3 flex items-center gap-2",children:[e.jsx(ir,{className:"h-4 w-4"}),"Referrals Received (",((X=C==null?void 0:C.received)==null?void 0:X.length)||0,")"]}),((ce=C==null?void 0:C.received)==null?void 0:ce.length)===0?e.jsx(Pe,{children:e.jsx(Oe,{className:"py-8 text-center text-muted-foreground",children:"No referrals received yet"})}):e.jsx("div",{className:"space-y-3",children:(ie=C==null?void 0:C.received)==null?void 0:ie.map(ae=>{var oe;return e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:ae.buyer_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["From: ",(oe=ae.sender)==null?void 0:oe.name]})]}),e.jsx(Qe,{variant:ae.status==="closed"?"default":"secondary",children:ae.status.replace("_"," ")})]}),e.jsx(W,{size:"sm",variant:"outline",className:"w-full mt-2",onClick:()=>t(`/mission-control/listings/${ae.listing_id}`),children:"View Listing"})]})},ae.id)})})]})]})}),s&&e.jsx(Ss,{value:"brokerage",className:"space-y-4",children:L?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((ae,oe)=>e.jsxs(Pe,{children:[e.jsx(Ms,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(Ms,{className:"h-5 w-3/4"}),e.jsx(Ms,{className:"h-4 w-1/2"})]})]},oe))}):(I==null?void 0:I.length)===0?e.jsx(Pe,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Z4,{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(W,{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(ae=>e.jsx(j9,{listing:ae,onClick:()=>t(`/mission-control/listings/${ae.id}`)},ae.id))})}),e.jsx(Ss,{value:"map",children:e.jsx(Bws,{listings:y||[],isLoading:_})}),e.jsx(Ss,{value:"leaderboard",children:e.jsx(Fws,{leaderboard:O})})]})]})}):e.jsx(Ds,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:e.jsx(Pe,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Mn,{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 qws(t){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t)}const Uws={single_family:"Single Family Home",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury Home",commercial:"Commercial",other:"Property"};function Vws({open:t,onOpenChange:s,listing:r}){const{user:n}=Us(),{data:a=[],isLoading:o}=qh(),{data:l=[]}=Nf(),[i,d]=k.useState(""),[u,p]=k.useState("all"),[f,y]=k.useState(new Set),[_,b]=k.useState(!1),[N,w]=k.useState(null);k.useEffect(()=>{t||(d(""),p("all"),y(new Set),b(!1))},[t]),k.useEffect(()=>{!t||!n||(async()=>{const{data:q}=await G.from("gmail_integrations").select("gmail_email").eq("user_id",n.id).maybeSingle();w((q==null?void 0:q.gmail_email)||null)})()},[t,n]);const S=k.useMemo(()=>a.filter(q=>q.email),[a]),C=k.useMemo(()=>{let q=S;if(u!=="all"&&(q=q.filter(B=>{var U;return(U=B.tags)==null?void 0:U.some(te=>te.relationship_type_id===u)})),i.trim()){const B=i.toLowerCase();q=q.filter(U=>`${U.first_name||""} ${U.last_name||""}`.toLowerCase().includes(B)||(U.email||"").toLowerCase().includes(B))}return q},[S,i,u]),A=()=>{f.size===C.length?y(new Set):y(new Set(C.map(q=>q.id)))},I=q=>{const B=new Set(f);B.has(q)?B.delete(q):B.add(q),y(B)},L=k.useMemo(()=>S.filter(q=>f.has(q.id)).map(q=>({id:q.id,first_name:q.first_name||"there",last_name:q.last_name,email:q.email})),[S,f]),{defaultSubject:O,defaultBody:V}=k.useMemo(()=>{var he,ge,je,qe;const q=r.property_address||`${r.city}, ${r.state}`,B=qws(r.price),U=Uws[r.property_type]||"home",te=r.bedrooms?`${r.bedrooms} bed`:"",Y=r.bathrooms?`${r.bathrooms} bath`:"",J=r.square_footage?`${r.square_footage.toLocaleString()} sqft`:"",X=[te,Y,J].filter(Boolean).join(" • "),ce=`https://listings.relevelup.com/${r.slug||r.id}`,ie=((ge=(he=r.photos)==null?void 0:he.find(Me=>Me.is_primary))==null?void 0:ge.photo_url)||((qe=(je=r.photos)==null?void 0:je[0])==null?void 0:qe.photo_url)||"",oe={active:"Just Listed",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"}[r.status]||"New Listing",me=`${oe}: ${q} — ${B}`,ve=`

Hi {{first_name}},

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

${ie?` ${q} `:""}
${oe}

${B}

${q}

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

${X?`

${X} • ${U}

`:""} 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:me,defaultBody:ve}},[r]);return _?e.jsx(E1,{open:_,onOpenChange:q=>{b(q),q||s(!1)},bulkContacts:L,defaultSubject:O,defaultBody:V,gmailEmail:N}):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(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(Or,{className:"h-5 w-5 text-amber-500"}),"Email this listing to your sphere"]}),e.jsx(Ir,{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(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search contacts...",value:i,onChange:q=>d(q.target.value),className:"pl-9"})]}),e.jsxs($s,{value:u,onValueChange:p,children:[e.jsx(zs,{className:"sm:w-[180px]",children:e.jsx(Vs,{placeholder:"Filter by tag"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All contacts"}),l.map(q=>e.jsx(vt,{value:q.id,children:q.name},q.id))]})]})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm border-y py-2",children:[e.jsxs("button",{type:"button",onClick:A,className:"flex items-center gap-2 text-primary hover:underline",children:[e.jsx(Ri,{checked:C.length>0&&f.size===C.length,className:"pointer-events-none"}),e.jsx("span",{children:f.size===C.length&&C.length>0?"Deselect all":`Select all (${C.length})`})]}),e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[e.jsx(ir,{className:"h-3 w-3"}),f.size," selected"]})]}),e.jsx(Ja,{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(us,{className:"h-5 w-5 animate-spin mr-2"}),"Loading your contacts..."]}):C.length===0?e.jsx("div",{className:"text-center py-12 text-muted-foreground text-sm",children:S.length===0?"No contacts with email addresses yet.":"No contacts match your search."}):e.jsx("div",{className:"space-y-1 py-2",children:C.map(q=>e.jsxs("label",{className:"flex items-center gap-3 p-2 rounded-md hover:bg-muted/50 cursor-pointer",children:[e.jsx(Ri,{checked:f.has(q.id),onCheckedChange:()=>I(q.id)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[q.first_name," ",q.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:q.email})]}),q.tags&&q.tags.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap justify-end max-w-[40%]",children:q.tags.slice(0,2).map(B=>{var U;return e.jsx(Qe,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:(U=B.relationship_type)==null?void 0:U.name},B.id)})})]},q.id))})}),e.jsx(ho,{}),e.jsxs("div",{className:"flex justify-between items-center gap-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:N?`Sending from ${N}`:"Connect Gmail in Settings to send"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(W,{onClick:()=>b(!0),disabled:f.size===0,className:"gap-2",children:[e.jsx(tr,{className:"h-4 w-4"}),"Compose Email (",f.size,")"]})]})]})]})})}function cx(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 Eme(){const t=ya();return gt({queryKey:["deal-pipeline-stages",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("deal_pipeline_stages").select("*").eq("owner_user_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function git(){const t=ya(),s=Qt();return Pt({mutationFn:async()=>{if(!t)throw new Error("Not authenticated");const{error:r}=await G.rpc("initialize_deal_pipeline_stages",{p_user_id:t});if(r)throw r},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-pipeline-stages"]})}})}function Pme(){const t=ya();return gt({queryKey:["deal-pipeline-deals",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("deal_pipeline").select(` *, contact:innercircle_contacts(id, first_name, last_name, email, phone), listing:listings(id, property_address, city, state, price, status, created_at) `).eq("owner_user_id",t).order("updated_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function yit(){const t=ya(),s=Qt();return Pt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.from("deal_pipeline").insert({deal_name:r.deal_name,deal_type:r.deal_type,stage_id:r.stage_id||null,contact_id:r.contact_id||null,listing_id:r.listing_id||null,property_address:r.property_address||null,city:r.city||null,state:r.state||null,zip_code:r.zip_code||null,expected_price:r.expected_price||null,expected_commission:r.expected_commission||null,commission_percentage:r.commission_percentage||3,target_close_date:r.target_close_date||null,contract_date:r.contract_date||null,listing_date:r.listing_date||null,priority:r.priority||"medium",probability:r.probability||50,notes:r.notes||null,owner_user_id:t}).select().single();if(a)throw a;return await G.from("deal_activities").insert([{deal_id:n.id,activity_type:"system",title:"Deal created",description:`Deal "${r.deal_name}" was created`}]),n},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-pipeline-deals"]}),s.invalidateQueries({queryKey:["deal-pipeline-stats"]})}})}function vit(){const t=Qt();return Pt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("deal_pipeline").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-pipeline-stats"]})}})}function Hws(){const t=Qt();return Pt({mutationFn:async({dealId:s,stageId:r,stageName:n})=>{const{data:a,error:o}=await G.from("deal_pipeline").update({stage_id:r}).eq("id",s).select().single();if(o)throw o;return await G.from("deal_activities").insert({deal_id:s,activity_type:"stage_change",title:`Moved to ${n}`,metadata:{new_stage_id:r,new_stage_name:n}}),a},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-activities"]})}})}function Gws(){const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("deal_pipeline").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-pipeline-stats"]})}})}function Wws(t){return gt({queryKey:["deal-activities",t],queryFn:async()=>{const{data:s,error:r}=await G.from("deal_activities").select("*").eq("deal_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function Kws(){const t=Qt();return Pt({mutationFn:async s=>{const{data:r,error:n}=await G.from("deal_activities").insert([{deal_id:s.deal_id,activity_type:s.activity_type,title:s.title,description:s.description||null}]).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-activities",r.deal_id]})}})}function Zws(t){return gt({queryKey:["deal-checklist",t],queryFn:async()=>{const{data:s,error:r}=await G.from("deal_checklist_items").select("*").eq("deal_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function Yws(){const t=Qt();return Pt({mutationFn:async({id:s,is_completed:r,deal_id:n})=>{const{data:a,error:o}=await G.from("deal_checklist_items").update({is_completed:r,completed_at:r?new Date().toISOString():null}).eq("id",s).select().single();if(o)throw o;return a},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-checklist",r.deal_id]})}})}function Xws(){const t=Qt();return Pt({mutationFn:async s=>{const{data:r,error:n}=await G.from("deal_checklist_items").insert([{deal_id:s.deal_id,title:s.title,description:s.description||null,due_date:s.due_date||null,sort_order:s.sort_order||0}]).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-checklist",r.deal_id]})}})}function Qws(){const t=ya();return gt({queryKey:["deal-pipeline-stats",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.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 d,u,p;return!((d=i.deal_pipeline_stages)!=null&&d.is_won_stage)&&!((u=i.deal_pipeline_stages)!=null&&u.is_lost_stage)&&((p=i.deal_pipeline_stages)==null?void 0:p.name)!=="Cancelled"}))||[],a=(s==null?void 0:s.filter(i=>{var d;return(d=i.deal_pipeline_stages)==null?void 0:d.is_won_stage}))||[],o=new Date().getFullYear(),l=a.filter(i=>{const d=i.actual_close_date;return d?new Date(d).getFullYear()===o:!0});return{totalDeals:(s==null?void 0:s.length)||0,activeDeals:n.length,wonDeals:a.length,pipelineValue:n.reduce((i,d)=>i+(d.expected_price||0),0),expectedCommission:n.reduce((i,d)=>i+(d.expected_commission||0),0),expectedNetToAgent:n.reduce((i,d)=>i+(cx(d)||0),0),wonValue:a.reduce((i,d)=>i+(d.expected_price||0),0),weightedGCI:n.reduce((i,d)=>{const u=(d.probability??50)/100;return i+(d.expected_commission||0)*u},0),weightedNet:n.reduce((i,d)=>{const u=(d.probability??50)/100;return i+(cx(d)||0)*u},0),ytdWonDeals:l.length,ytdWonGCI:l.reduce((i,d)=>i+(d.expected_commission||0),0),ytdWonNet:l.reduce((i,d)=>i+(cx(d)||0),0),projectedAnnualNet:l.reduce((i,d)=>i+(cx(d)||0),0)+n.reduce((i,d)=>{const u=(d.probability??50)/100;return i+(cx(d)||0)*u},0)}},enabled:!!t})}function Jws(t){const s=ya();return gt({queryKey:["deal-by-listing",t,s],queryFn:async()=>{if(!s||!t)return null;const{data:r,error:n}=await G.from("deal_pipeline").select(` *, deal_pipeline_stages(id, name, color) `).eq("owner_user_id",s).eq("listing_id",t).maybeSingle();if(n)throw n;return r},enabled:!!s&&!!t})}function e2s(){const t=Qt();return Pt({mutationFn:async({dealId:s,listingId:r})=>{const{data:n,error:a}=await G.from("deal_pipeline").update({listing_id:r}).eq("id",s).select().single();if(a)throw a;return await G.from("deal_activities").insert({deal_id:s,activity_type:"system",title:"Linked to Listing Exchange",description:"This deal is now synced with Listing Exchange",metadata:{listing_id:r}}),n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-by-listing",r.listingId]})}})}function t2s(){const t=Qt();return Pt({mutationFn:async({dealId:s,listingId:r})=>{const{data:n,error:a}=await G.from("deal_pipeline").update({listing_id:null}).eq("id",s).select().single();if(a)throw a;return{data:n,listingId:r}},onSuccess:s=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-by-listing",s.listingId]})}})}function s2s({listing:t}){const s=wr(),[r,n]=k.useState(""),[a,o]=k.useState(!1),{data:l,isLoading:i}=Jws(t.id),{data:d,isLoading:u}=Eme(),{data:p,isLoading:f}=Pme(),y=git(),_=e2s(),b=t2s(),N=yit(),w=(p==null?void 0:p.filter(L=>!L.listing_id))||[],S=L=>{if(!(d!=null&&d.length))return null;switch(L){case"coming_soon":case"active":case"price_improvement":return d.find(O=>O.name==="Active");case"under_contract":return d.find(O=>O.name==="Under Contract");case"sold":return d.find(O=>O.is_won_stage);default:return d.find(O=>O.name==="Active")}},C=async()=>{o(!0);try{d!=null&&d.length||await y.mutateAsync();const L=S(t.status);await N.mutateAsync({deal_name:t.property_address?`${t.property_address}, ${t.city}`:`${t.city}, ${t.state}`,deal_type:"seller",stage_id:(L==null?void 0:L.id)||null,listing_id:t.id,property_address:t.property_address,city:t.city,state:t.state,expected_price:t.price,expected_commission:t.price*.03,commission_percentage:3,priority:"medium",probability:50}),pe.success("Deal created and linked to listing!")}catch(L){console.error("Failed to create deal:",L),pe.error("Failed to create deal")}finally{o(!1)}},A=async()=>{if(!r){pe.error("Please select a deal");return}try{await _.mutateAsync({dealId:r,listingId:t.id}),pe.success("Listing linked to deal!"),n("")}catch{pe.error("Failed to link listing")}},I=async()=>{if(l)try{await b.mutateAsync({dealId:l.id,listingId:t.id}),pe.success("Listing unlinked from deal")}catch{pe.error("Failed to unlink listing")}};return i||u?e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2 text-base",children:[e.jsx(Yy,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(us,{className:"h-5 w-5 animate-spin text-muted-foreground"})})})]}):l?e.jsxs(Pe,{className:"border-primary/20 bg-primary/5",children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"flex items-center gap-2 text-base",children:[e.jsx(Do,{className:"h-4 w-4 text-primary"}),"Linked to Pipeline"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:l.deal_name}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:l.deal_pipeline_stages&&e.jsx(Qe,{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(W,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>s("/mission-control/pipeline"),children:["View Pipeline",e.jsx(Wa,{className:"h-3 w-3 ml-1"})]}),e.jsx(W,{variant:"ghost",size:"sm",onClick:I,disabled:b.isPending,children:b.isPending?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(jS,{className:"h-4 w-4"})})]})]})]}):e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"flex items-center gap-2 text-base",children:[e.jsx(Yy,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Link this listing to your pipeline to track the deal and sync status changes."}),e.jsxs(W,{onClick:C,disabled:a||N.isPending,className:"w-full",size:"sm",children:[a||N.isPending?e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create New Deal"]}),w.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-card px-2 text-muted-foreground",children:"or"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs($s,{value:r,onValueChange:n,children:[e.jsx(zs,{className:"flex-1 text-sm",children:e.jsx(Vs,{placeholder:"Link to existing deal..."})}),e.jsx(Bs,{children:w.map(L=>e.jsx(vt,{value:L.id,children:L.deal_name},L.id))})]}),e.jsx(W,{variant:"secondary",size:"icon",onClick:A,disabled:!r||_.isPending,children:_.isPending?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(Do,{className:"h-4 w-4"})})]})]})]})]})}const r2s={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"},Q7e={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function a2s(){var ce,ie,ae,oe,me,ve,he,ge,je;const{listingId:t}=io(),s=wr(),{user:r}=Us(),{data:n,isLoading:a}=TXe(t||""),{data:o}=PXe(t||""),{data:l}=n8t(t||""),i=EXe(),d=r8t(),u=a8t(),p=AXe(),f=o8t(),[y,_]=k.useState(!1),[b,N]=k.useState(!1),[w,S]=k.useState(!1),[C,A]=k.useState(!1),[I,L]=k.useState(null),[O,V]=k.useState({buyerName:"",buyerType:"",notes:""}),q=(r==null?void 0:r.id)===(n==null?void 0:n.agent_id),B=qe=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(qe),U=async qe=>{const Me=`https://listings.relevelup.com/${(n==null?void 0:n.slug)||(n==null?void 0:n.id)}`,ke=`Check out this listing: ${(n==null?void 0:n.property_address)||(n==null?void 0:n.city)}`;u.mutate({listingId:n.id,shareType:qe});try{switch(qe){case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(Me)}`,"_blank");break;case"copy":await navigator.clipboard.writeText(Me),pe.success("Link copied to clipboard!");break;case"text":window.open(`sms:?body=${encodeURIComponent(`${ke} ${Me}`)}`);break;case"email":window.open(`mailto:?subject=${encodeURIComponent(ke)}&body=${encodeURIComponent(`Check out this listing: ${Me}`)}`);break}}catch(Re){console.error("Share error:",Re),pe.error("Failed to share")}},te=async()=>{try{await p.mutateAsync(n.id),pe.success("Listing deleted"),s("/mission-control/listings")}catch{pe.error("Failed to delete listing")}},Y=async()=>{if(!O.buyerName.trim()){pe.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}),pe.success("Referral sent successfully!"),N(!1),V({buyerName:"",buyerType:"",notes:""})}catch{pe.error("Failed to send referral")}},J=qe=>{var Ie,ye;const Me=(n==null?void 0:n.property_address)||`${n==null?void 0:n.city}, ${n==null?void 0:n.state}`,ke=B((n==null?void 0:n.price)||0),Re=n!=null&&n.bedrooms?`${n.bedrooms}BD`:"",Ve=n!=null&&n.bathrooms?`${n.bathrooms}BA`:"",Ne=n!=null&&n.square_footage?`${n.square_footage.toLocaleString()}SF`:"",Ue=[Re,Ve,Ne].filter(Boolean).join(" | ");switch(qe){case"just_listed":return`🏡 JUST LISTED! ${Me} ${ke} ${Ue} ${(n==null?void 0:n.description)||"Schedule your showing today!"} #JustListed #RealEstate #HomeForSale #${(Ie=n==null?void 0:n.city)==null?void 0:Ie.replace(/\s/g,"")}`;case"price_improvement":return`📣 PRICE IMPROVEMENT! ${Me} Now ${ke}! ${Ue} Don't miss this opportunity! #PriceReduced #RealEstate #HomeForSale`;case"teaser":return`Looking for a ${Q7e[(n==null?void 0:n.property_type)||"single_family"].toLowerCase()} in ${n==null?void 0:n.city}? 👀 I've got just the one for you! ${Ue} DM me for details! 📩 #ComingSoon #RealEstate #${(ye=n==null?void 0:n.city)==null?void 0:ye.replace(/\s/g,"")}`;default:return""}};if(a)return e.jsx(Ds,{title:"Listing",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ms,{className:"h-10 w-32"}),e.jsx(Ms,{className:"h-[400px] w-full"}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsx(Ms,{className:"h-48"}),e.jsx(Ms,{className:"h-48"}),e.jsx(Ms,{className:"h-48"})]})]})});if(!n)return e.jsx(Ds,{title:"Listing Not Found",description:"",children:e.jsx(Pe,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing could not be found."}),e.jsx(W,{onClick:()=>s("/mission-control/listings"),children:"Back to Listings"})]})})});const X=((ce=n.photos)==null?void 0:ce.find(qe=>qe.is_primary))||((ie=n.photos)==null?void 0:ie[0]);return e.jsxs(Ds,{title:"",description:"",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs(W,{variant:"ghost",onClick:()=>s("/mission-control/listings"),children:[e.jsx(Oa,{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:()=>X&&L(X.photo_url),children:X?e.jsx("img",{src:X.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:(ae=n.photos)==null?void 0:ae.slice(1,5).map((qe,Me)=>e.jsx("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>L(qe.photo_url),children:e.jsx("img",{src:qe.photo_url,alt:`Photo ${Me+2}`,className:"w-full h-full object-cover"})},qe.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(Oe,{className:"p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Qe,{className:`${r2s[n.status]} text-white border-0`,children:n2s[n.status]}),n.is_featured&&e.jsxs(Qe,{variant:"outline",className:"border-amber-500 text-amber-500",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1 fill-amber-500"}),"Featured"]}),n.open_to_referrals&&e.jsxs(Qe,{variant:"outline",children:[e.jsx(ir,{className:"h-3 w-3 mr-1"}),"Open to Referrals"]})]}),e.jsx("h1",{className:"text-3xl font-bold text-primary mb-2",children:B(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(Ia,{className:"h-4 w-4"}),n.city,", ",n.state,n.neighborhood&&` • ${n.neighborhood}`]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{variant:"outline",size:"icon",onClick:()=>i.mutate(n.id),children:e.jsx(Xa,{className:`h-4 w-4 ${o?"fill-pink-500 text-pink-500":""}`})}),e.jsx(W,{variant:"outline",size:"icon",onClick:()=>d.mutate(n.id),children:l?e.jsx(Wv,{className:"h-4 w-4"}):e.jsx(Sm,{className:"h-4 w-4"})}),!q&&e.jsxs(W,{variant:"outline",className:"border-amber-500 text-amber-600 hover:bg-amber-50",onClick:()=>S(!0),children:[e.jsx(Or,{className:"h-4 w-4 mr-2"}),"Share & Earn Leads"]}),e.jsxs(Hd,{children:[e.jsx(Gd,{asChild:!0,children:e.jsxs(W,{variant:"outline",children:[e.jsx(id,{className:"h-4 w-4 mr-2"}),"Share"]})}),e.jsxs(Nd,{children:[e.jsxs(_a,{onClick:()=>U("copy"),children:[e.jsx(Va,{className:"h-4 w-4 mr-2"}),"Copy Link"]}),e.jsxs(_a,{onClick:()=>U("facebook"),children:[e.jsx(hu,{className:"h-4 w-4 mr-2"}),"Facebook"]}),e.jsxs(_a,{onClick:()=>U("text"),children:[e.jsx(wi,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(_a,{onClick:()=>U("email"),children:[e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Email"]})]})]}),q&&e.jsxs(e.Fragment,{children:[e.jsxs(W,{variant:"outline",onClick:()=>A(!0),className:"gap-2",children:[e.jsx(tr,{className:"h-4 w-4"}),"Email My Sphere"]}),e.jsxs(W,{variant:"outline",onClick:()=>s(`/mission-control/listings/${n.id}/edit`),children:[e.jsx(Wc,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsx(W,{variant:"destructive",size:"icon",onClick:()=>_(!0),children:e.jsx(vr,{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(Zy,{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(nf,{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(r0,{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(cn,{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(Qe,{variant:"secondary",children:[e.jsx(pa,{className:"h-3 w-3 mr-1"}),Q7e[n.property_type]]}),n.lot_size&&e.jsxs(Qe,{variant:"secondary",children:["Lot: ",n.lot_size]}),n.has_hoa&&e.jsx(Qe,{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(W,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:n.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Yr,{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(jn,{className:"h-4 w-4"}),n.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(id,{className:"h-4 w-4"}),n.share_count," shares"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Xa,{className:"h-4 w-4"}),n.save_count," saves"]})]})]})}),n.allow_sharing&&e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"Share Content"})}),e.jsx(Oe,{className:"space-y-4",children:["just_listed","price_improvement","teaser"].map(qe=>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:[qe.replace("_"," ")," Caption"]}),e.jsx(W,{size:"sm",variant:"ghost",onClick:()=>{navigator.clipboard.writeText(J(qe)),pe.success("Caption copied!")},children:e.jsx(Va,{className:"h-3 w-3"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:J(qe)})]},qe))})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"Listing Agent"})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx("span",{className:"text-lg font-semibold text-primary",children:((me=(oe=n.agent)==null?void 0:oe.name)==null?void 0:me.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((ve=n.agent)==null?void 0:ve.name)||"Unknown"}),((ge=(he=n.agent)==null?void 0:he.brokerage)==null?void 0:ge.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:n.agent.brokerage.name})]})]}),!q&&e.jsx("div",{className:"space-y-2",children:((je=n.agent)==null?void 0:je.email)&&e.jsx(W,{variant:"outline",className:"w-full",asChild:!0,children:e.jsxs("a",{href:`mailto:${n.agent.email}`,children:[e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Email Agent"]})})})]})]}),q&&e.jsx(s2s,{listing:n}),!q&&n.open_to_referrals&&e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(ir,{className:"h-5 w-5"}),"Send a Buyer"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Have a buyer interested in this property? Send a referral to the listing agent."}),e.jsx(W,{className:"w-full",onClick:()=>N(!0),children:"Send Referral"})]})]})]})]})]}),e.jsx(fs,{open:!!I,onOpenChange:()=>L(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:y,onOpenChange:_,children:e.jsxs(ps,{children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Delete Listing"}),e.jsx(Ir,{children:"Are you sure you want to delete this listing? This action cannot be undone."})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsx(W,{variant:"destructive",onClick:te,disabled:p.isPending,children:p.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(fs,{open:b,onOpenChange:N,children:e.jsxs(ps,{children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Send Buyer Referral"}),e.jsx(Ir,{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(xe,{children:"Buyer Name *"}),e.jsx(De,{value:O.buyerName,onChange:qe=>V({...O,buyerName:qe.target.value}),placeholder:"Enter buyer's name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Buyer Type"}),e.jsxs($s,{value:O.buyerType,onValueChange:qe=>V({...O,buyerType:qe}),children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select type"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"first_time",children:"First-Time Buyer"}),e.jsx(vt,{value:"investor",children:"Investor"}),e.jsx(vt,{value:"relocating",children:"Relocating"}),e.jsx(vt,{value:"upgrade",children:"Upgrading"}),e.jsx(vt,{value:"downsize",children:"Downsizing"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Notes"}),e.jsx(_r,{value:O.notes,onChange:qe=>V({...O,notes:qe.target.value}),placeholder:"Any additional information..."})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>N(!1),children:"Cancel"}),e.jsx(W,{onClick:Y,disabled:f.isPending,children:f.isPending?"Sending...":"Send Referral"})]})]})}),e.jsx(xit,{open:w,onOpenChange:S,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(Vws,{open:C,onOpenChange:A,listing:n})]})}function i2s({onImport:t}){const[s,r]=k.useState(""),[n,a]=k.useState([]),[o,l]=k.useState(!1),[i,d]=k.useState(!1),[u,p]=k.useState(null),f=k.useRef(),y=k.useRef(null);k.useEffect(()=>{const C=A=>{y.current&&!y.current.contains(A.target)&&d(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[]);const _=async C=>{if(C.trim().length<3){a([]),d(!1);return}l(!0);try{const{data:A,error:I}=await G.functions.invoke("mls-listing-search",{body:{query:C}});if(I)throw I;a((A==null?void 0:A.listings)||[]),d(!0)}catch(A){console.error("MLS search error:",A),a([])}finally{l(!1)}},b=C=>{r(C),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>_(C),400)},N=C=>{p(C.mlsNumber),t(C),d(!1),r(`${C.address}, ${C.city}`),pe.success(`Imported: ${C.address}`,{description:"Property details and photos have been auto-filled."}),p(null)},w=C=>C?`$${C.toLocaleString()}`:"",S=C=>{const A=(C||"").toLowerCase();return A.includes("single")||A.includes("detached")?"Single Family":A.includes("condo")?"Condo":A.includes("town")?"Townhouse":A.includes("land")||A.includes("lot")?"Land":A.includes("multi")?"Multi-Family":A.includes("commercial")?"Commercial":C||"Other"};return e.jsxs(Pe,{className:"border-primary/30 bg-primary/5",children:[e.jsxs(Dt,{className:"pb-3",children:[e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Qa,{className:"h-4 w-4 text-primary"}),"Import from MLS"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Search by address to auto-fill property details and photos from MLS"})]}),e.jsx(Oe,{children:e.jsxs("div",{ref:y,className:"relative",children:[e.jsxs("div",{className:"relative",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{value:s,onChange:C=>b(C.target.value),onFocus:()=>n.length>0&&d(!0),placeholder:"Start typing a property address...",className:"pl-9 pr-9"}),o&&e.jsx(us,{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([]),d(!1)},className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:e.jsx(kr,{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(C=>e.jsxs("button",{type:"button",onClick:()=>N(C),disabled:u===C.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:[C.photos[0]?e.jsx("img",{src:C.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(Ia,{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.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[C.city,", ",C.state," ",C.zip]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-semibold text-foreground",children:w(C.price)}),C.bedrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Zy,{className:"h-3 w-3"})," ",C.bedrooms]}),C.bathrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(nf,{className:"h-3 w-3"})," ",C.bathrooms]}),C.sqft>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(xS,{className:"h-3 w-3"})," ",C.sqft.toLocaleString()]})]})]}),e.jsxs("div",{className:"flex-shrink-0 flex flex-col items-end gap-1",children:[e.jsx(Qe,{variant:"outline",className:"text-[10px]",children:S(C.propertyType)}),C.photos.length>0&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[C.photos.length," photos"]})]})]},C.mlsNumber))})]})})]})}function o2s({photo:t,onRemove:s,onSetPrimary:r}){const{attributes:n,listeners:a,setNodeRef:o,transform:l,transition:i,isDragging:d}=C4e({id:t.id}),u={transform:iC.Transform.toString(l),transition:i};return e.jsxs("div",{ref:o,style:u,className:Ot("relative aspect-square rounded-lg overflow-hidden bg-muted group",d&&"opacity-50 ring-2 ring-primary z-50"),children:[e.jsx("img",{src:t.photo_url,alt:"",className:"w-full h-full object-cover"}),e.jsx("button",{type:"button",...n,...a,className:"absolute top-1 left-1 p-1 bg-black/60 text-white rounded cursor-grab active:cursor-grabbing opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(mu,{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(kr,{className:"h-3 w-3"})}),t.is_primary?e.jsxs("span",{className:"absolute bottom-1 left-1 text-[10px] bg-primary text-primary-foreground px-1.5 py-0.5 rounded flex items-center gap-0.5",children:[e.jsx(Gn,{className:"h-2.5 w-2.5 fill-current"})," Primary"]}):e.jsx("button",{type:"button",onClick:()=>r(t.id),className:"absolute bottom-1 left-1 text-[10px] bg-black/60 text-white px-1.5 py-0.5 rounded opacity-0 group-hover:opacity-100 transition-opacity hover:bg-black/80",children:"Set as Primary"})]})}function l2s({photos:t,uploading:s,onUpload:r,onRemove:n,onReorder:a,onSetPrimary:o}){const l=v4e(yce(oO,{activationConstraint:{distance:5}})),i=[...t].sort((u,p)=>(u.sort_order??0)-(p.sort_order??0)),d=u=>{const{active:p,over:f}=u;if(!f||p.id===f.id)return;const y=i.findIndex(S=>S.id===p.id),_=i.findIndex(S=>S.id===f.id),b=[...i],[N]=b.splice(y,1);b.splice(_,0,N);const w=b.map((S,C)=>({...S,sort_order:C}));a(w)};return e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Drag photos to reorder. Hover to set primary."}),e.jsx(N4e,{sensors:l,collisionDetection:_4e,onDragEnd:d,children:e.jsx(S4e,{items:i.map(u=>u.id),strategy:lO,children:e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[i.map(u=>e.jsx(o2s,{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(us,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Ra,{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 c2s({selectedVideoId:t,onVideoSelect:s,listingId:r}){const n=wr(),{user:a}=Us(),[o,l]=k.useState(!1),[i,d]=k.useState([]),[u,p]=k.useState(!1),[f,y]=k.useState(null),[_,b]=k.useState({});k.useEffect(()=>{t&&a?N():y(null)},[t,a]);const N=async()=>{if(!t)return;const{data:B,error:U}=await G.from("agent_videos").select("id, bunny_video_id, title, thumbnail_url, preview_url, playback_url, duration_seconds, status, created_at").eq("id",t).eq("is_deleted",!1).single();!U&&B&&(y(B),w(B))},w=async B=>{try{const{data:U,error:te}=await G.functions.invoke("bunny-upload",{body:{action:"asset-urls",videoId:B.bunny_video_id,isAgentVideo:!0}});!te&&(U!=null&&U.thumbnailUrl)&&b(Y=>({...Y,[B.id]:{thumbnailUrl:U.thumbnailUrl}}))}catch(U){console.warn("Failed to get signed URL",U)}},S=async()=>{if(a){p(!0);try{const{data:B,error:U}=await G.from("agent_videos").select("id, bunny_video_id, title, thumbnail_url, preview_url, playback_url, duration_seconds, status, created_at").eq("owner_user_id",a.id).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1});if(U)throw U;d(B||[]),B!=null&&B.length&&C(B)}catch(B){console.error("Error fetching videos:",B),pe.error("Failed to load videos")}finally{p(!1)}}},C=async B=>{var U;try{const te=B.map(ie=>ie.bunny_video_id),{data:Y,error:J}=await G.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:te,isAgentVideo:!0}});if(J)throw J;const X=(Y==null?void 0:Y.assets)||{},ce={};for(const ie of B)(U=X[ie.bunny_video_id])!=null&&U.thumbnailUrl&&(ce[ie.id]={thumbnailUrl:X[ie.bunny_video_id].thumbnailUrl});b(ie=>({...ie,...ce}))}catch(te){console.warn("Failed to bulk-fetch signed URLs",te)}},A=()=>{l(!0),S()},I=B=>{s(B.id),y(B),l(!1),pe.success("Video selected")},L=()=>{s(null),y(null)},O=()=>{const B=r?`/mission-control/listings/${r}/edit`:"/mission-control/listings/new";n(`/mission-control/video?returnUrl=${encodeURIComponent(B)}`)},V=B=>{if(!B)return"0:00";const U=Math.floor(B/60),te=B%60;return`${U}:${te.toString().padStart(2,"0")}`},q=B=>{var U;return((U=_[B.id])==null?void 0:U.thumbnailUrl)||B.thumbnail_url};return e.jsxs("div",{className:"space-y-3",children:[f?e.jsx(Pe,{className:"overflow-hidden",children:e.jsx(Oe,{className:"p-0",children:e.jsxs("div",{className:"flex items-start gap-4 p-4",children:[e.jsxs("div",{className:"relative w-32 h-20 bg-muted rounded-lg overflow-hidden flex-shrink-0",children:[q(f)?e.jsx("img",{src:q(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(yn,{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(Co,{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:V(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(W,{type:"button",variant:"outline",size:"sm",onClick:A,children:"Change"}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",onClick:L,className:"text-destructive hover:text-destructive",children:e.jsx(kr,{className:"h-4 w-4"})})]})]})})}):e.jsx(Pe,{className:"border-dashed",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(yn,{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(W,{type:"button",variant:"outline",onClick:A,className:"gap-2",children:[e.jsx(oS,{className:"h-4 w-4"}),"Select from Library"]}),e.jsxs(W,{type:"button",variant:"outline",onClick:O,className:"gap-2",children:[e.jsx(xx,{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(ks,{children:e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(oS,{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(us,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):i.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(yn,{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(W,{onClick:O,className:"gap-2",children:[e.jsx(xx,{className:"h-4 w-4"}),"Record Your First Video"]})]}):e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3 p-1",children:i.map(B=>e.jsxs("button",{type:"button",onClick:()=>I(B),className:`group relative rounded-lg overflow-hidden border-2 transition-all text-left ${t===B.id?"border-primary ring-2 ring-primary/20":"border-transparent hover:border-muted-foreground/30"}`,children:[e.jsxs("div",{className:"aspect-video bg-muted relative",children:[q(B)?e.jsx("img",{src:q(B),alt:B.title||"Video",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(yn,{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(Co,{className:"h-8 w-8 text-white opacity-0 group-hover:opacity-100 transition-opacity"})}),B.duration_seconds&&e.jsx("div",{className:"absolute bottom-1 right-1 bg-black/70 text-white text-[10px] px-1.5 py-0.5 rounded",children:V(B.duration_seconds)})]}),e.jsx("div",{className:"p-2 bg-card",children:e.jsx("p",{className:"text-xs font-medium truncate",children:B.title||"Untitled Video"})})]},B.id))})}),e.jsxs("div",{className:"flex justify-between items-center pt-4 border-t",children:[e.jsxs(W,{type:"button",variant:"ghost",onClick:O,className:"gap-2",children:[e.jsx(xx,{className:"h-4 w-4"}),"Record New Video"]}),e.jsx(W,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"})]})]})})]})}const d2s=[{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"}],u2s=[{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 h2s({id:t,url:s,index:r,onRemove:n}){const{attributes:a,listeners:o,setNodeRef:l,transform:i,transition:d,isDragging:u}=C4e({id:t}),p={transform:iC.Transform.toString(i),transition:d};return e.jsxs("div",{ref:l,style:p,className:`relative aspect-square rounded-lg overflow-hidden bg-muted group ${u?"opacity-50 ring-2 ring-primary z-50":""}`,children:[e.jsx("img",{src:s,alt:"",className:"w-full h-full object-cover"}),e.jsx("button",{type:"button",...a,...o,className:"absolute top-1 left-1 p-1 bg-black/60 text-white rounded cursor-grab active:cursor-grabbing opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(mu,{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(kr,{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(Gn,{className:"h-2.5 w-2.5 fill-current"})," Primary"]})]})}function m2s({photoUrls:t,pendingPhotos:s,onRemove:r,onReorder:n,uploading:a,onUpload:o}){const l=v4e(yce(oO,{activationConstraint:{distance:5}})),i=t.map((u,p)=>`pending-${p}`),d=u=>{const{active:p,over:f}=u;if(!f||p.id===f.id)return;const y=i.indexOf(p.id),_=i.indexOf(f.id),b=[...t],N=[...s],[w]=b.splice(y,1),[S]=N.splice(y,1);b.splice(_,0,w),N.splice(_,0,S),n(b,N)};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(N4e,{sensors:l,collisionDetection:_4e,onDragEnd:d,children:e.jsx(S4e,{items:i,strategy:lO,children:e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[t.map((u,p)=>e.jsx(h2s,{id:i[p],url:u,index:p,onRemove:r},i[p])),e.jsxs("label",{className:"aspect-square rounded-lg border-2 border-dashed border-muted-foreground/25 hover:border-muted-foreground/50 cursor-pointer flex flex-col items-center justify-center gap-2 text-muted-foreground",children:[a?e.jsx(us,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Ra,{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 J7e(){const{listingId:t}=io(),[s]=Nc(),r=s.get("brokerage"),n=wr(),{user:a}=Us(),{hasLeadSite:o}=CC(),l=!!t&&t!=="new",i=!!r&&!l,[d,u]=k.useState([]),{data:p,isLoading:f}=TXe(l?t:""),y=ZLt(),_=YLt(),b=XLt(),N=QLt(),w=JLt(),S=e8t(),C=t8t(),{data:A=[]}=gt({queryKey:["brokerage-agents",r],queryFn:async()=>{if(!r)return[];const{data:he,error:ge}=await G.from("profiles").select("id, name, email").eq("brokerage_id",r).order("name");if(ge)throw ge;return he||[]},enabled:i}),[I,L]=k.useState(""),[O,V]=k.useState(!1),[q,B]=k.useState([]),[U,te]=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 he,ge,je,qe,Me;p&&l&&J({property_address:p.property_address||"",city:p.city||"",state:p.state||"",neighborhood:p.neighborhood||"",price:((he=p.price)==null?void 0:he.toString())||"",property_type:p.property_type,status:p.status,bedrooms:((ge=p.bedrooms)==null?void 0:ge.toString())||"",bathrooms:((je=p.bathrooms)==null?void 0:je.toString())||"",square_footage:((qe=p.square_footage)==null?void 0:qe.toString())||"",lot_size:p.lot_size||"",year_built:((Me=p.year_built)==null?void 0:Me.toString())||"",has_hoa:p.has_hoa,description:p.description||"",agent_notes:p.agent_notes||"",agent_notes_public:p.agent_notes_public,mls_link:p.mls_link||"",video_link:p.video_link||"",video_id:p.video_id||null,allow_sharing:p.allow_sharing,open_to_referrals:p.open_to_referrals,open_to_social_promotion:p.open_to_social_promotion,share_with_brokerage:p.share_with_brokerage??!1,is_public:p.is_public})},[p,l]);const X=he=>{var Me,ke;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"},je=(he.propertyType||"").toLowerCase(),qe=((Me=Object.entries(ge).find(([Re])=>je.includes(Re)))==null?void 0:Me[1])||"other";J(Re=>({...Re,property_address:he.address||Re.property_address,city:he.city||Re.city,state:he.state||Re.state,price:he.price?String(he.price):Re.price,property_type:qe,bedrooms:he.bedrooms?String(he.bedrooms):Re.bedrooms,bathrooms:he.bathrooms?String(he.bathrooms):Re.bathrooms,square_footage:he.sqft?String(he.sqft):Re.square_footage,lot_size:he.lotSize?String(he.lotSize):Re.lot_size,year_built:he.yearBuilt?String(he.yearBuilt):Re.year_built,description:he.description||Re.description})),((ke=he.photos)==null?void 0:ke.length)>0&&(u(he.photos),U.forEach(Re=>URL.revokeObjectURL(Re)),B([]),te([]))},ce=he=>{if(!he)return;const ge=Array.from(he);B(qe=>[...qe,...ge]);const je=ge.map(qe=>URL.createObjectURL(qe));te(qe=>[...qe,...je])},ie=he=>{URL.revokeObjectURL(U[he]),B(ge=>ge.filter((je,qe)=>qe!==he)),te(ge=>ge.filter((je,qe)=>qe!==he))},ae=async he=>{var ge;if(!(!he||!p)){V(!0);try{for(const je of Array.from(he)){const qe=je.name.split(".").pop(),Me=`${a==null?void 0:a.id}/${p.id}/${Date.now()}.${qe}`,{error:ke}=await G.storage.from("listing-photos").upload(Me,je);if(ke)throw ke;const{data:{publicUrl:Re}}=G.storage.from("listing-photos").getPublicUrl(Me);await N.mutateAsync({listingId:p.id,photoUrl:Re,isPrimary:!((ge=p.photos)!=null&&ge.length)})}pe.success("Photos uploaded!")}catch(je){console.error("Upload error:",je),pe.error("Failed to upload photos")}finally{V(!1)}}},oe=async he=>{for(let ge=0;ge{if(p)try{await w.mutateAsync({photoId:he,listingId:p.id}),pe.success("Photo removed")}catch{pe.error("Failed to remove photo")}},ve=async he=>{if(he.preventDefault(),!Y.city.trim()||!Y.state.trim()||!Y.price){pe.error("Please fill in required fields (City, State, Price)");return}if(i&&!I){pe.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 b.mutateAsync({id:t,...ge}),pe.success("Listing updated!"),n(`/mission-control/listings/${t}`);else{V(!0);let je;if(i&&I?je=await _.mutateAsync({agentId:I,...ge}):je=await y.mutateAsync(ge),q.length>0)try{await oe(je.id),U.forEach(qe=>URL.revokeObjectURL(qe)),B([]),te([])}catch(qe){console.error("Photo upload error:",qe),pe.error("Listing created but some photos failed to upload")}if(d.length>0)try{for(let qe=0;qen(i?"/my-brokerage":"/mission-control/listings"),children:[e.jsx(Oa,{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(Dt,{children:e.jsx(zt,{children:"Assign to Agent *"})}),e.jsxs(Oe,{children:[e.jsxs($s,{value:I,onValueChange:L,children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select an agent..."})}),e.jsx(Bs,{children:A.map(he=>e.jsx(vt,{value:he.id,children:he.name||he.email},he.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(i2s,{onImport:X}),d.length>0&&e.jsxs(Pe,{className:"border-primary/30 bg-primary/5",children:[e.jsxs(Dt,{className:"pb-3",children:[e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Qa,{className:"h-4 w-4 text-primary"}),"MLS Photos (",d.length,")"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"These photos will be imported when you save the listing."})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-2",children:[d.slice(0,12).map((he,ge)=>e.jsx("div",{className:"aspect-square rounded overflow-hidden bg-muted",children:e.jsx("img",{src:he,alt:"",className:"w-full h-full object-cover"})},ge)),d.length>12&&e.jsxs("div",{className:"aspect-square rounded bg-muted flex items-center justify-center text-sm text-muted-foreground font-medium",children:["+",d.length-12]})]}),e.jsxs(W,{type:"button",variant:"ghost",size:"sm",className:"mt-2 text-destructive",onClick:()=>u([]),children:[e.jsx(kr,{className:"h-3 w-3 mr-1"})," Clear MLS photos"]})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Property Details"})}),e.jsx(Oe,{className:"space-y-4",children:e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"sm:col-span-2 space-y-2",children:[e.jsx(xe,{children:"Property Address"}),e.jsx(De,{value:Y.property_address,onChange:he=>J({...Y,property_address:he.target.value}),placeholder:"123 Main St"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"City *"}),e.jsx(De,{value:Y.city,onChange:he=>J({...Y,city:he.target.value}),placeholder:"City",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"State *"}),e.jsx(De,{value:Y.state,onChange:he=>J({...Y,state:he.target.value}),placeholder:"State",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Neighborhood"}),e.jsx(De,{value:Y.neighborhood,onChange:he=>J({...Y,neighborhood:he.target.value}),placeholder:"Neighborhood"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Price *"}),e.jsx(De,{type:"number",value:Y.price,onChange:he=>J({...Y,price:he.target.value}),placeholder:"500000",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Property Type"}),e.jsxs($s,{value:Y.property_type,onValueChange:he=>J({...Y,property_type:he}),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsx(Bs,{children:u2s.map(he=>e.jsx(vt,{value:he.value,children:he.label},he.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Status"}),e.jsxs($s,{value:Y.status,onValueChange:he=>J({...Y,status:he}),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsx(Bs,{children:d2s.map(he=>e.jsx(vt,{value:he.value,children:he.label},he.value))})]})]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Property Specs (Optional)"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Bedrooms"}),e.jsx(De,{type:"number",value:Y.bedrooms,onChange:he=>J({...Y,bedrooms:he.target.value}),placeholder:"3"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Bathrooms"}),e.jsx(De,{type:"number",step:"0.5",value:Y.bathrooms,onChange:he=>J({...Y,bathrooms:he.target.value}),placeholder:"2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Sq Ft"}),e.jsx(De,{type:"number",value:Y.square_footage,onChange:he=>J({...Y,square_footage:he.target.value}),placeholder:"2000"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Lot Size"}),e.jsx(De,{value:Y.lot_size,onChange:he=>J({...Y,lot_size:he.target.value}),placeholder:"0.25 acres"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Year Built"}),e.jsx(De,{type:"number",value:Y.year_built,onChange:he=>J({...Y,year_built:he.target.value}),placeholder:"2005"})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-6",children:[e.jsx(Ar,{checked:Y.has_hoa,onCheckedChange:he=>J({...Y,has_hoa:he})}),e.jsx(xe,{children:"Has HOA"})]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Description & Links"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Description"}),e.jsx(_r,{value:Y.description,onChange:he=>J({...Y,description:he.target.value}),placeholder:"Tell the story of this property...",rows:4})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Agent Notes"}),e.jsx(_r,{value:Y.agent_notes,onChange:he=>J({...Y,agent_notes:he.target.value}),placeholder:"Notes for other agents...",rows:2}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ar,{checked:Y.agent_notes_public,onCheckedChange:he=>J({...Y,agent_notes_public:he})}),e.jsx(xe,{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(xe,{children:"MLS Link"}),e.jsx(De,{value:Y.mls_link,onChange:he=>J({...Y,mls_link:he.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Video Link"}),e.jsx(De,{value:Y.video_link,onChange:he=>J({...Y,video_link:he.target.value}),placeholder:"YouTube or Vimeo URL"})]})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(yn,{className:"h-5 w-5"}),"Property Video"]})}),e.jsx(Oe,{children:e.jsx(c2s,{selectedVideoId:Y.video_id,onVideoSelect:he=>J({...Y,video_id:he}),listingId:l?t:void 0})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Photos"})}),e.jsx(Oe,{children:l&&(p!=null&&p.photos)?e.jsx(l2s,{photos:p.photos,uploading:O,onUpload:he=>ae(he),onRemove:he=>me(he),onReorder:he=>{S.mutate({photos:he.map(ge=>({id:ge.id,sort_order:ge.sort_order,is_primary:ge.is_primary}))})},onSetPrimary:he=>{p&&C.mutate({photoId:he,listingId:p.id})}}):e.jsx(m2s,{photoUrls:U,onRemove:ie,onReorder:(he,ge)=>{te(he),B(ge)},pendingPhotos:q,uploading:O,onUpload:ce})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Sharing & Collaboration"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Allow Sharing"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Other agents can share this listing"})]}),e.jsx(Ar,{checked:Y.allow_sharing,onCheckedChange:he=>J({...Y,allow_sharing:he})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Open to Referrals"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Accept buyer referrals"})]}),e.jsx(Ar,{checked:Y.open_to_referrals,onCheckedChange:he=>J({...Y,open_to_referrals:he})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Social Promotion"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Can be promoted on social media"})]}),e.jsx(Ar,{checked:Y.open_to_social_promotion,onCheckedChange:he=>J({...Y,open_to_social_promotion:he})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Share with Brokerage"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Visible to agents in your brokerage"})]}),e.jsx(Ar,{checked:Y.share_with_brokerage,onCheckedChange:he=>J({...Y,share_with_brokerage:he})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Make Public"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Publish on listings.relevelup.com to get leads"})]}),e.jsx(Ar,{checked:Y.is_public,onCheckedChange:he=>J({...Y,is_public:he})})]})]})]}),e.jsx(W,{type:"submit",className:"w-full",size:"lg",disabled:y.isPending||b.isPending,children:y.isPending||b.isPending?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):l?"Update Listing":"Create Listing"})]})]})]})})}let Ym=null;function p2s(){if(Ym)return Ym;try{const t=document.createElement("canvas"),s=t.getContext("webgl2")||t.getContext("webgl");if(!s)return Ym={canRunVirtualBg:!1,reason:"WebGL is not supported on this device"},Ym;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(d=>o.includes(d)))return Ym={canRunVirtualBg:!1,reason:"Your device uses a software renderer which may cause lag",renderer:n},Ym;const i=performance;return i.memory&&i.memory.jsHeapSizeLimit<256*1024*1024?(Ym={canRunVirtualBg:!1,reason:"Limited device memory detected",renderer:n},Ym):navigator.hardwareConcurrency&&navigator.hardwareConcurrency<2?(Ym={canRunVirtualBg:!1,reason:"Single-core device detected — virtual backgrounds may cause lag",renderer:n},Ym):(Ym={canRunVirtualBg:!0,renderer:n},Ym)}catch{return Ym={canRunVirtualBg:!0},Ym}}const f2s=[{type:"none",label:"Off"},{type:"blur",label:"Blur"}];function x2s({value:t,onChange:s,isLoading:r=!1,disabled:n=!1,className:a}){const o=k.useRef(null),[l,i]=k.useState(!1),[d]=k.useState(()=>p2s()),u=!d.canRunVirtualBg,{data:p=[],refetch:f}=gt({queryKey:["video-backgrounds"],queryFn:async()=>{const{data:{user:w}}=await G.auth.getUser();if(!w)return[];const{data:S,error:C}=await G.from("video_backgrounds").select("*").eq("is_active",!0).order("sort_order",{ascending:!0});return C?(console.error("Failed to load backgrounds:",C),[]):S||[]}}),y=p.map(w=>({type:"image",label:w.name,imageUrl:w.image_url,thumbnail:w.thumbnail_url||w.image_url})),_=[...f2s,...y],b=w=>w.type!==t.type?!1:w.type==="image"?w.imageUrl===t.imageUrl:!0,N=async w=>{var C;const S=(C=w.target.files)==null?void 0:C[0];if(S){if(!S.type.startsWith("image/")){pe.error("Please select an image file");return}if(S.size>5*1024*1024){pe.error("Image must be under 5MB");return}i(!0);try{const{data:{user:A}}=await G.auth.getUser();if(!A)throw new Error("Not authenticated");const I=S.name.split(".").pop()||"jpg",L=`${A.id}/${crypto.randomUUID()}.${I}`,{error:O}=await G.storage.from("video-backgrounds").upload(L,S,{contentType:S.type});if(O)throw O;const{data:V}=G.storage.from("video-backgrounds").getPublicUrl(L),q=V.publicUrl,{error:B}=await G.from("video_backgrounds").insert({name:S.name.replace(/\.[^.]+$/,""),image_url:q,thumbnail_url:q,category:"custom",is_stock:!1,user_id:A.id});if(B)throw B;await f(),s({type:"image",imageUrl:q,blurRadius:15}),pe.success("Background uploaded!")}catch(A){console.error("Upload error:",A),pe.error("Failed to upload background")}finally{i(!1),o.current&&(o.current.value="")}}};return e.jsxs("div",{className:Ot("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(Dc,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{children:d.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(us,{className:"h-3 w-3 animate-spin"}),e.jsx("span",{children:"Loading…"})]}),_.map((w,S)=>{const C=b(w);return e.jsxs("button",{type:"button",disabled:n,onClick:()=>s({type:w.type,imageUrl:w.imageUrl,blurRadius:15}),className:Ot("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",C?"border-primary bg-primary/10":"border-transparent bg-muted/50",n&&"opacity-50 cursor-not-allowed"),children:[e.jsxs("div",{className:"w-12 h-8 rounded flex items-center justify-center overflow-hidden bg-muted",children:[w.type==="none"&&e.jsx(iL,{className:"h-4 w-4 text-muted-foreground"}),w.type==="blur"&&e.jsx("div",{className:"w-full h-full bg-gradient-to-br from-primary/20 to-primary/40 flex items-center justify-center",children:e.jsx("span",{className:"text-[10px] font-medium text-primary",children:"Blur"})}),w.type==="image"&&w.thumbnail&&e.jsx("img",{src:w.thumbnail,alt:w.label,className:"w-full h-full object-cover"})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground truncate max-w-14",children:w.label})]},`${w.type}-${w.imageUrl||S}`)}),e.jsxs("button",{type:"button",disabled:n||l,onClick:()=>{var w;return(w=o.current)==null?void 0:w.click()},className:Ot("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(us,{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:N}),e.jsxs("button",{type:"button",disabled:n,onClick:()=>s({...t,mirror:!t.mirror}),className:Ot("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(fL,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Mirror"})]})]})]})}var yA=typeof self<"u"?self:{};function _it(t,s){e:{for(var r=["CLOSURE_FLAGS"],n=yA,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 wit(t){yA.setTimeout(()=>{throw t},0)}var Iwe,_2s=_it(610401301,!1),tze=_it(748402147,!0);function sze(){var t=yA.navigator;return t&&(t=t.userAgent)?t:""}const rze=yA.navigator;function Ime(t){return Ime[" "](t),t}Iwe=rze&&rze.userAgentData||null,Ime[" "]=function(){};const jit={};let $I=null;function b2s(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(;d>4),f!=64&&(l(p<<4&240|f>>2),y!=64&&l(f<<6&192|y))}}(t,function(o){n[a++]=o}),a!==r?n.subarray(0,a):n}function Nit(){if(!$I){$I={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),s=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){const n=t.concat(s[r].split(""));jit[r]=n;for(let a=0;a0)&&(sze().indexOf("Trident")!=-1||sze().indexOf("MSIE")!=-1))&&typeof btoa=="function";const nze=/[-_.]/g,j2s={"-":"+",_:"/",".":"="};function N2s(t){return j2s[t]||""}function Sit(t){if(!kit)return b2s(t);t=nze.test(t)?t.replace(nze,N2s):t,t=atob(t);const s=new Uint8Array(t.length);for(let r=0;r=s||(r[t]=n+1,Mit(t=Error(),"incident"),wit(t))}}function NE(){return typeof BigInt=="function"}var kE=typeof Symbol=="function"&&typeof Symbol()=="symbol";function T0(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 C2s=T0("jas",void 0,!0),aze=T0(void 0,"0di"),_I=T0(void 0,"1oa"),pf=T0(void 0,Symbol()),M2s=T0(void 0,"0ub"),T2s=T0(void 0,"0ubs"),Dwe=T0(void 0,"0ubsb"),A2s=T0(void 0,"0actk"),bA=T0("m_m","Pa",!0),ize=T0();const Tit={Ga:{value:0,configurable:!0,writable:!0,enumerable:!1}},Ait=Object.defineProperties,ba=kE?C2s:"Ga";var IC;const oze=[];function wO(t,s){kE||ba in t||Ait(t,Tit),t[ba]|=s}function yu(t,s){kE||ba in t||Ait(t,Tit),t[ba]=s}function jO(t){return wO(t,34),t}function cR(t){return wO(t,8192),t}yu(oze,7),IC=Object.freeze(oze);var wA={};function yf(t,s){return s===void 0?t.h!==xC&&!!(2&(0|t.v[ba])):!!(2&s)&&t.h!==xC}const xC={};function GSe(t,s){if(t!=null){if(typeof t=="string")t=t?new u0(t,vA):fC();else if(t.constructor!==u0)if(VSe(t))t=t.length?new u0(new Uint8Array(t),vA):fC();else{if(!s)throw Error();t=void 0}}return t}class lze{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 E2s=Object.freeze({});function Eit(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"),cze=Lme(t=>typeof t=="string"),I2s=Lme(t=>typeof t=="boolean"),Dme=typeof yA.BigInt=="function"&&typeof yA.BigInt(0)=="bigint";function ff(t){var s=t;if(cze(s)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(s))throw Error(String(s))}else if(P2s(s)&&!Number.isSafeInteger(s))throw Error(String(s));return Dme?BigInt(t):t=I2s(t)?t?"1":"0":cze(t)?t.trim()||"0":String(t)}var Rwe=Lme(t=>Dme?t>=D2s&&t<=O2s:t[0]==="-"?dze(t,L2s):dze(t,R2s));const L2s=Number.MIN_SAFE_INTEGER.toString(),D2s=Dme?BigInt(Number.MIN_SAFE_INTEGER):void 0,R2s=Number.MAX_SAFE_INTEGER.toString(),O2s=Dme?BigInt(Number.MAX_SAFE_INTEGER):void 0;function dze(t,s){if(t.length>s.length)return!1;if(t.lengtha)return!1;if(n>>0;Ic=s,Fd=(t-s)/4294967296>>>0}function jA(t){if(t<0){uze(-t);const[s,r]=ZSe(Ic,Fd);Ic=s>>>0,Fd=r>>>0}else uze(t)}function WSe(t){const s=z2s||(z2s=new DataView(new ArrayBuffer(8)));s.setFloat32(0,+t,!0),Fd=0,Ic=s.getUint32(0,!0)}function Iit(t,s){const r=4294967296*s+(t>>>0);return Number.isSafeInteger(r)?r:dR(t,s)}function B2s(t,s){return ff(NE()?BigInt.asUintN(64,(BigInt(s>>>0)<>>0)):dR(t,s))}function Lit(t,s){return NE()?ff(BigInt.asIntN(64,(BigInt.asUintN(32,BigInt(s))<>>=0,(s>>>=0)<=2097151)var r=""+(4294967296*s+t);else NE()?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+hze(r)+hze(t));return r}function hze(t){return t=String(t),"0000000".slice(t.length)+t}function KSe(t,s){if(2147483648&s)if(NE())t=""+(BigInt(0|s)<>>0));else{const[r,n]=ZSe(t,s);t="-"+dR(r,n)}else t=dR(t,s);return t}function Rme(t){if(t.length<16)jA(Number(t));else if(NE())t=BigInt(t),Ic=Number(t&BigInt(4294967295))>>>0,Fd=Number(t>>BigInt(32)&BigInt(4294967295));else{const s=+(t[0]==="-");Fd=Ic=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));Fd*=1e6,Ic=1e6*Ic+o,Ic>=4294967296&&(Fd+=Math.trunc(Ic/4294967296),Fd>>>=0,Ic>>>=0)}if(s){const[n,a]=ZSe(Ic,Fd);Ic=n,Fd=a}}}function ZSe(t,s){return s=~s,t?t=1+~t:s+=1,[t,s]}function Og(t){return Array.prototype.slice.call(t)}const NO=typeof BigInt=="function"?BigInt.asIntN:void 0,$2s=typeof BigInt=="function"?BigInt.asUintN:void 0,gC=Number.isSafeInteger,Ome=Number.isFinite,NA=Math.trunc,q2s=ff(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 Gy(t){return t==null||typeof t=="number"?t:t==="NaN"||t==="Infinity"||t==="-Infinity"?Number(t):void 0}function uR(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 Dit(t){return t==null||typeof t=="boolean"?t:typeof t=="number"?!!t:void 0}const U2s=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function kO(t){switch(typeof t){case"bigint":return!0;case"number":return Ome(t);case"string":return U2s.test(t);default:return!1}}function CE(t){if(t==null)return t;if(typeof t=="string"&&t)t=+t;else if(typeof t!="number")return;return Ome(t)?0|t:void 0}function Rit(t){if(t==null)return t;if(typeof t=="string"&&t)t=+t;else if(typeof t!="number")return;return Ome(t)?t>>>0:void 0}function Oit(t){const s=t.length;return(t[0]==="-"?s<20||s===20&&t<="-9223372036854775808":s<19||s===19&&t<="9223372036854775807")?t:(Rme(t),KSe(Ic,Fd))}function YSe(t){if(t=NA(t),!gC(t)){jA(t);var s=Ic,r=Fd;(t=2147483648&r)&&(r=~r>>>0,(s=1+~s>>>0)==0&&(r=r+1>>>0)),t=typeof(s=Iit(s,r))=="number"?t?-s:s:t?"-"+s:s}return t}function Fit(t){var s=NA(Number(t));return gC(s)?String(s):((s=t.indexOf("."))!==-1&&(t=t.substring(0,s)),Oit(t))}function zit(t){var s=NA(Number(t));return gC(s)?ff(s):((s=t.indexOf("."))!==-1&&(t=t.substring(0,s)),NE()?ff(NO(64,BigInt(t))):ff(Oit(t)))}function Bit(t){return gC(t)?t=ff(YSe(t)):(t=NA(t),gC(t)?t=String(t):(jA(t),t=KSe(Ic,Fd)),t=ff(t)),t}function jde(t){const s=typeof t;return t==null?t:s==="bigint"?ff(NO(64,t)):kO(t)?s==="string"?zit(t):Bit(t):void 0}function $it(t){if(typeof t!="string")throw Error();return t}function SO(t){if(t!=null&&typeof t!="string")throw Error();return t}function ph(t){return t==null||typeof t=="string"?t:void 0}function XSe(t,s,r,n){return t!=null&&t[bA]===wA?t:Array.isArray(t)?((n=(r=0|t[ba])|32&n|2&n)!==r&&yu(t,n),new s(t)):(r?2&n?((t=s[aze])||(jO((t=new s).v),t=s[aze]=t),s=t):s=new s:s=void 0,s)}function V2s(t,s,r){if(s)e:{if(!kO(s=t))throw Lwe("int64");switch(typeof s){case"string":s=zit(s);break e;case"bigint":s=ff(NO(64,s));break e;default:s=Bit(s)}}else s=jde(t);return(t=s)==null?r?q2s:void 0:t}const H2s={};let G2s=function(){try{return Ime(new class extends Map{constructor(){super()}}),!1}catch{return!0}}();class h0e{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 W2s=G2s?(Object.setPrototypeOf(h0e.prototype,Map.prototype),Object.defineProperties(h0e.prototype,{size:{value:0,configurable:!0,enumerable:!0,writable:!0}}),h0e):class extends Map{constructor(){super()}};function mze(t){return t}function m0e(t){if(2&t.J)throw Error("Cannot mutate an immutable Map")}var b1=class extends W2s{constructor(t,s,r=mze,n=mze){super(),this.J=0|t[ba],this.K=s,this.S=r,this.fa=this.K?K2s:n;for(let a=0;a{t.call(s,a.get(n),n,a)}):super.forEach(t,s)}set(t,s){return m0e(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 K2s(t,s,r,n,a,o){return t=XSe(t,n,r,o),a&&(t=JSe(t)),t}function Z2s(t){return[t,this.get(t)]}let Y2s;function pze(){return Y2s||(Y2s=new b1(jO([]),void 0,void 0,void 0,H2s))}function Fme(t){return pf?t[pf]:void 0}function Nde(t,s){for(const r in t)!isNaN(r)&&s(t,+r,t[r])}b1.prototype.toJSON=void 0;var Owe=class{};const X2s={Ka:!0};function Q2s(t,s){s<100||_A(T2s,1)}function zme(t,s,r,n){const a=n!==void 0;n=!!n;var o,l=pf;!a&&kE&&l&&(o=t[l])&&Nde(o,Q2s),l=[];var i=t.length;let d;o=4294967295;let u=!1;const p=!!(64&s),f=p?128&s?0:-1:void 0;1&s||(d=i&&t[i-1],d!=null&&typeof d=="object"&&d.constructor===Object?o=--i:d=void 0,!p||128&s||a||(u=!0,o=o-f+f)),s=void 0;for(var y=0;y=o){const b=y-f;(s??(s={}))[b]=_}else l[y]=_}if(d)for(let _ in d){if((i=d[_])==null||(i=r(i,n))==null)continue;let b;y=+_,p&&!Number.isNaN(y)&&(b=y+f){b[w]=Og(S)}),b.da=_.da,b}(t)),l}function J2s(t){return t[0]=hR(t[0]),t[1]=hR(t[1]),t}function hR(t){switch(typeof t){case"number":return Number.isFinite(t)?t:""+t;case"bigint":return Rwe(t)?Number(t):""+t;case"boolean":return t?1:0;case"object":if(Array.isArray(t)){var s=0|t[ba];return t.length===0&&1&s?void 0:zme(t,s,hR)}if(t!=null&&t[bA]===wA)return qit(t);if(t instanceof u0){if((s=t.g)==null)t="";else if(typeof s=="string")t=s;else{if(kit){for(var r="",n=0,a=s.length-10240;n>2];o=r[(3&o)<<4|l>>4],l=r[(15&l)<<2|i>>6],i=r[63&i],n[p++]=d+o+l+i}switch(d=0,i=a,s.length-u){case 2:i=r[(15&(d=s[u+1]))<<2]||a;case 1:s=s[u],n[p]=r[s>>2]+r[(3&s)<<4|d>>4]+i+a}s=n.join("")}t=t.g=s}return t}return t instanceof b1?t=t.size!==0?t.V(J2s):void 0:void 0}return t}let ejs,tjs;function qit(t){return zme(t=t.v,0|t[ba],hR)}function IS(t,s){return Uit(t,s[0],s[1])}function Uit(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[ba],tze&&1&a)throw Error("rfarr");if(2048&a&&!(2&a)&&function(){if(tze)throw Error("carr");_A(A2s,5)}(),256&a)throw Error("farr");if(64&a)return(a|n)!==a&&yu(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 d=r[l];if(d!=null&&typeof d=="object"&&d.constructor===Object){if((l-=s=128&a?0:-1)>=1024)throw Error("pvtlmt");for(var i in d)(o=+i)1024)throw Error("spvt");a=-16760833&a|(1023&i)<<14}}}return yu(t,64|a|n),t}function sjs(t,s){if(typeof t!="object")return t;if(Array.isArray(t)){var r=0|t[ba];return t.length===0&&1&r?void 0:fze(t,r,s)}if(t!=null&&t[bA]===wA)return xze(t);if(t instanceof b1){if(2&(s=t.J))return t;if(!t.size)return;if(r=jO(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 al(t,s,r,n){AE(t),xu(t=t.v,0|t[ba],s,r,n)}function xu(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[ba]))>>14&1023||536870912)?n!=null&&(t[l+(a?0:-1)]={[r]:n}):t[o]=n),s)}function T4(){return E2s===void 0?2:4}function A4(t,s,r,n,a){let o=t.v,l=0|o[ba];n=yf(t,l)?1:n,a=!!a||n===3,n===2&&TE(t)&&(o=t.v,l=0|o[ba]);let i=(t=tCe(o,s))===IC?7:0|t[ba],d=sCe(i,l);var u=!(4&d);if(u){4&d&&(t=Og(t),i=0,d=DS(d,l),l=xu(o,l,s,t));let p=0,f=0;for(;p{const i=XSe(l,r,!1,s);return o=i!==l&&i!=null,i}))!=null)return o&&!yf(n)&&LC(t,s),n}function ko(t,s,r,n){let a=t.v,o=0|a[ba];if((s=Zit(a,o,s,r,n))==null)return s;if(o=0|a[ba],!yf(t,o)){const l=JSe(s);l!==s&&(TE(t)&&(a=t.v,o=0|a[ba]),o=xu(a,o,r,s=l,n),LC(a,o))}return s}function Yit(t,s,r,n,a,o,l,i){var d=yf(t,r);o=d?1:o,l=!!l||o===3,d=i&&!d,(o===2||d)&&TE(t)&&(r=0|(s=t.v)[ba]);var u=(t=tCe(s,a))===IC?7:0|t[ba],p=sCe(u,r);if(i=!(4&p)){var f=t,y=r;const _=!!(2&p);_&&(y|=2);let b=!_,N=!0,w=0,S=0;for(;w32)for(a|=(127&r)>>4,o=3;o<32&&128&r;o+=7)r=l[i++],a|=(127&r)<>>0,a>>>0);throw Error()}function cCe(t){let s=0,r=t.g;const n=r+10,a=t.h;for(;r>>0}function Sde(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],RS(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 rjs(t){return aw(t)}function RS(t,s){if(t.g=s,s>t.l)throw Error()}function Qit(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 Jit(t,s){if(s==0)return fC();var r=Qit(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):F2s?t.slice(r,s):new Uint8Array(t.subarray(r,s))),r.length==0?fC():new u0(r,vA)}var gze=[];function eot(t,s,r,n){if(Cde.length){const a=Cde.pop();return a.o(n),a.g.init(t,s,r,n),a}return new njs(t,s,r,n)}function tot(t){t.g.clear(),t.l=-1,t.h=-1,Cde.length<100&&Cde.push(t)}function sot(t){var s=t.g;if(s.g==s.l)return!1;t.m=t.g.g;var r=_0(t.g);if(s=r>>>3,!((r&=7)>=0&&r<=5)||s<1)throw Error();return t.l=s,t.h=r,!0}function coe(t){switch(t.h){case 0:t.h!=0?coe(t):cCe(t.g);break;case 1:RS(t=t.g,t.g+8);break;case 2:if(t.h!=2)coe(t);else{var s=_0(t.g);RS(t=t.g,t.g+s)}break;case 5:RS(t=t.g,t.g+4);break;case 3:for(s=t.l;;){if(!sot(t))throw Error();if(t.h==4){if(t.l!=s)throw Error();break}coe(t)}break;default:throw Error()}}function CO(t,s,r){const n=t.g.l;var a=_0(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 dCe(t){var s=_0(t.g),r=Qit(t=t.g,s);if(t=t.h,g2s){var n,a=t;(n=u0e)||(n=u0e=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(N9===void 0){try{n.decode(new Uint8Array([128]))}catch{}try{n.decode(new Uint8Array([97])),N9=!0}catch{N9=!1}}throw!N9&&(u0e=void 0),i}}else{s=(o=r)+s,r=[];let i,d=null;for(;o=s?U2():(i=t[o++],l<194||(192&i)!=128?(o--,U2()):r.push((31&l)<<6|63&i)):l<240?o>=s-1?U2():(i=t[o++],(192&i)!=128||l===224&&i<160||l===237&&i>=160||(192&(n=t[o++]))!=128?(o--,U2()):r.push((15&l)<<12|(63&i)<<6|63&n)):l<=244?o>=s-2?U2():(i=t[o++],(192&i)!=128||i-144+(l<<28)>>30||(192&(n=t[o++]))!=128||(192&(a=t[o++]))!=128?(o--,U2()):(l=(7&l)<<18|(63&i)<<12|(63&n)<<6|63&a,l-=65536,r.push(55296+(l>>10&1023),56320+(1023&l)))):U2(),r.length>=8192&&(d=eze(d,r),r.length=0)}o=eze(d,r)}return o}function rot(t){const s=_0(t.g);return Jit(t.g,s)}function $me(t,s,r){var n=_0(t.g);for(n=t.g.g+n;t.g.g>>0,this.g=s>>>0}};let ajs;function vze(t){return t?/^-?\d+$/.test(t)?(Rme(t),new zwe(Ic,Fd)):null:ijs||(ijs=new zwe(0,0))}var zwe=class{constructor(t,s){this.h=t>>>0,this.g=s>>>0}};let ijs;function nT(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 PE(t,s){for(;s>127;)t.g.push(127&s|128),s>>>=7;t.g.push(s)}function qme(t,s){if(s>=0)PE(t,s);else{for(let r=0;r<9;r++)t.g.push(127&s|128),s>>=7;t.g.push(1)}}function uCe(t){var s=Ic;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 kA(t,s){s.length!==0&&(t.l.push(s),t.h+=s.length)}function Ox(t,s,r){PE(t.g,8*s+r)}function hCe(t,s){return Ox(t,s,2),s=t.g.end(),kA(t,s),s.push(t.h),s}function mCe(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 Ume(t,s,r){Ox(t,s,2),PE(t.g,r.length),kA(t,t.g.end()),kA(t,r)}function Mde(t,s,r,n){r!=null&&(s=hCe(t,s),n(r,t),mCe(t,s))}function A0(){const t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var pCe=A0(),not=A0(),fCe=A0(),xCe=A0(),gCe=A0(),aot=A0(),ojs=A0(),Vme=A0(),iot=A0(),oot=A0();function E0(t,s,r){var n=t.v;pf&&pf in n&&(n=n[pf])&&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 wa=class{constructor(t,s){this.v=Uit(t,s,void 0,2048)}toJSON(){return qit(this)}j(){var a;var t=qjs,s=this.v,r=t.g,n=pf;if(kE&&n&&((a=s[n])==null?void 0:a[r])!=null&&_A(M2s,3),s=t.g,ize&&pf&&ize===void 0&&(n=(r=this.v)[pf])&&(n=n.da))try{n(r,s,X2s)}catch(o){wit(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[ba];return eCe(this,t,s)?QSe(this,t,!0):new this.constructor(ME(t,s,!1))}};wa.prototype[bA]=wA,wa.prototype.toString=function(){return this.v.toString()};var IE=class{constructor(t,s,r){this.g=t,this.h=s,t=pCe,this.l=!!t&&r===t||!1}};function Hme(t,s){return new IE(t,s,pCe)}function lot(t,s,r,n,a){Mde(t,r,hot(s,n),a)}const ljs=Hme(function(t,s,r,n,a){return t.h===2&&(CO(t,aCe(s,n,r),a),!0)},lot),cjs=Hme(function(t,s,r,n,a){return t.h===2&&(CO(t,aCe(s,n,r),a),!0)},lot);var Gme=Symbol(),Wme=Symbol(),Bwe=Symbol(),_ze=Symbol(),bze=Symbol();let cot,dot;function DC(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 ejs||(ejs=[0,void 0,!0]);case"number":return f>0?void 0:f===0?tjs||(tjs=[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,cot??(cot=o),dot??(dot=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 d=0;da(o,l,i,n):a}function vCe(t,s,r,n,a){const o=r.g;let l,i;t[s]=(d,u,p)=>o(d,u,p,i||(i=DC(Wme,yCe,vCe,n).T),l||(l=_Ce(n)),a)}function _Ce(t){let s=t[Bwe];if(s!=null)return s;const r=DC(Wme,yCe,vCe,t);return s=r.ma?(n,a)=>cot(n,a,r):(n,a)=>{for(;sot(a)&&a.h!=4;){var o=a.l,l=r[o];if(l==null){var i=r.ba;i&&(i=i[o])&&(i=ujs(i))!=null&&(l=r[o]=i)}if(l==null||!l(a,n,o)){if(l=(i=a).m,coe(i),i.ha)var d=void 0;else d=i.g.g-l,i.g.g=l,d=Jit(i.g,d);l=void 0,i=n,d&&((l=i[pf]??(i[pf]=new Owe))[o]??(l[o]=[])).push(d)}}return(n=Fme(n))&&(n.da=r.qa[bze]),!0},t[Bwe]=s,t[bze]=djs.bind(t),s}function djs(t,s,r,n){var a=this[Wme];const o=this[Bwe],l=IS(void 0,a.T),i=Fme(t);if(i){var d=!1,u=a.ba;if(u){if(a=(p,f,y)=>{if(y.length!==0)if(u[f])for(const _ of y){p=eot(_);try{d=!0,o(l,p)}finally{tot(p)}}else n==null||n(t,f,y)},s==null)Nde(i,a);else if(i!=null){const p=i[s];p&&a(i,s,p)}if(d){let p=0|t[ba];if(2&p&&2048&p&&!(r!=null&&r.Ka))throw Error();const f=SE(p),y=(_,b)=>{if(w1(t,_,f)!=null){if((r==null?void 0:r.Qa)===1)return;throw Error()}b!=null&&(p=xu(t,p,_,b,f)),delete i[_]};s==null?Eit(l,0|l[ba],(_,b)=>{y(_,b)}):y(s,w1(l,s,f))}}}}function ujs(t){const s=(t=uot(t))[0].g;if(t=t[1]){const r=_Ce(t),n=DC(Wme,yCe,vCe,t).T;return(a,o,l)=>s(a,o,l,n,r)}return s}function Kme(t,s,r){t[s]=r.h}function Zme(t,s,r,n){let a,o;const l=r.h;t[s]=(i,d,u)=>l(i,d,u,o||(o=DC(Gme,Kme,Zme,n).T),a||(a=mot(n)))}function mot(t){let s=t[_ze];if(!s){const r=DC(Gme,Kme,Zme,t);s=(n,a)=>pot(n,a,r),t[_ze]=s}return s}function pot(t,s,r){Eit(t,0|t[ba],(n,a)=>{if(a!=null){var o=function(l,i){var d=l[i];if(d)return d;if((d=l.ba)&&(d=d[i])){var u=(d=uot(d))[0].h;if(d=d[1]){const p=mot(d),f=DC(Gme,Kme,Zme,d).T;d=l.ma?dot(f,p):(y,_,b)=>u(y,_,b,f,p)}else d=u;return l[i]=d}}(r,n);o?o(s,a,n):n<500||_A(Dwe,3)}}),(t=Fme(t))&&Nde(t,(n,a,o)=>{for(kA(s,s.g.end()),n=0;n{Mde(t,r,IS([l,o],n),a)});else if(Array.isArray(s)){for(let o=0;o>BigInt(32))),nT(t.g,r.h,r.g);break;default:r=vze(s),nT(t.g,r.h,r.g)}}function got(t,s,r){(s=CE(s))!=null&&s!=null&&(Ox(t,r,0),qme(t.g,s))}function yot(t,s,r){(s=Dit(s))!=null&&(Ox(t,r,0),t.g.g.push(s?1:0))}function vot(t,s,r){(s=ph(s))!=null&&Ume(t,r,bit(s))}function _ot(t,s,r,n,a){Mde(t,r,hot(s,n),a)}function bot(t,s,r){(s=s==null||typeof s=="string"||s instanceof u0?s:void 0)!=null&&Ume(t,r,oCe(s,!0).buffer)}function wot(t,s,r){(s=Rit(s))!=null&&s!=null&&(Ox(t,r,0),PE(t.g,s))}function jot(t,s,r){return(t.h===5||t.h===2)&&(s=EE(s,0|s[ba],r),t.h==2?$me(t,Sde,s):s.push(Sde(t.g)),!0)}var $d=Gh(function(t,s,r){return t.h===5&&(Wh(s,r,Sde(t.g)),!0)},fot,Vme),pjs=DE(jot,function(t,s,r){if((s=LE(Gy,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"))||(Rme(n),n=dR(Ic,Fd))),n;if(a==="number")return(n=NA(n))>=0&&gC(n)||(jA(n),n=Iit(Ic,Fd)),n}}(s),s!=null&&(typeof s=="string"&&yze(s),s!=null))switch(Ox(t,r,0),typeof s){case"number":t=t.g,jA(s),nT(t,Ic,Fd);break;case"bigint":r=BigInt.asUintN(64,s),r=new Fwe(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),nT(t.g,r.h,r.g);break;default:r=yze(s),nT(t.g,r.h,r.g)}},ojs),du=Gh(function(t,s,r){return t.h===0&&(Wh(s,r,aw(t.g)),!0)},got,xCe),MO=DE(function(t,s,r){return(t.h===0||t.h===2)&&(s=EE(s,0|s[ba],r),t.h==2?$me(t,aw,s):s.push(aw(t.g)),!0)},function(t,s,r){if((s=LE(CE,s))!=null&&s.length){r=hCe(t,r);for(let n=0;n{{const o={ea:!0};n&&Object.assign(o,n),r=eot(r,void 0,void 0,o);try{const l=new t,i=l.v;_Ce(s)(i,r);var a=l}finally{tot(r)}}return a}}function Yme(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}}}};pot(this.v,s,DC(Gme,Kme,Zme,t)),kA(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=Nze.createPolicy("goog#html",{createHTML:n,createScript:n,createScriptURL:n})}catch{}return r}()),t=(s=x0e)?s.createScriptURL(t):t,new class{constructor(r){this.g=r}toString(){return this.g+""}}(t)}function k9(t,...s){if(s.length===0)return kze(t[0]);let r=t[0];for(let n=0;n({index:mx(n,1)??0??-1,score:fd(n,2)??0,categoryName:ph(Oc(n,3))??""??"",displayName:ph(Oc(n,4))??""??""})),headIndex:s,headName:r}}function Gjs(t){const s={classifications:j1(t,Cjs,1).map(r=>{var n;return TCe(((n=ko(r,Pot,4))==null?void 0:n.g())??[],mx(r,2)??0,ph(Oc(r,3))??"")})};return function(r){return r==null?r:typeof r=="bigint"?(Rwe(r)?r=Number(r):(r=NO(64,r),r=Rwe(r)?Number(r):String(r)),r):kO(r)?typeof r=="number"?YSe(r):Fit(r):void 0}(Oc(t,2,void 0,void 0,jde))!=null&&(s.timestampMs=alt(Oc(t,2,void 0,void 0,jde)??Vit)),s}function ilt(t){var l,i;var s=A4(t,3,Gy,T4()),r=A4(t,2,CE,T4()),n=A4(t,1,ph,T4()),a=A4(t,9,ph,T4());const o={categories:[],keypoints:[]};for(let d=0;ds>127?s-256:s)}function Oze(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 clt(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 ka(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 zze(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]=clt(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 Bze(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 wy(t,s,r){t.i.simpleListeners=t.i.simpleListeners||{},t.i.simpleListeners[s]=r}function b_(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)}}z5.forVisionTasks=function(t,s=!1){return C9("vision",t??k9``,s)},z5.forTextTasks=function(t,s=!1){return C9("text",t??k9``,s)},z5.forGenAiTasks=function(t,s=!1){return C9("genai",t??k9``,s)},z5.forAudioTasks=function(t,s=!1){return C9("audio",t??k9``,s)},z5.isSimdSupported=function(t=!1){return olt(t)};async function Kjs(t,s,r,n){return t=await(async(a,o,l,i,d)=>{if(o&&await Fze(o),!self.ModuleFactory||l&&(await Fze(l),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&d&&((o=self.Module).locateFile=d.locateFile,d.mainScriptUrlOrBlob&&(o.mainScriptUrlOrBlob=d.mainScriptUrlOrBlob)),d=await self.ModuleFactory(self.Module||d),self.ModuleFactory=self.Module=void 0,new a(d,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 v0e(t,s){const r=ko(t.baseOptions,Tde,1)||new Tde;typeof s=="string"?(al(r,2,SO(s)),al(r,1)):s instanceof Uint8Array&&(al(r,1,GSe(s,!1)),al(r,2)),Ga(t.baseOptions,0,1,r)}function $ze(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 ia(t,s){t.C=Math.max(t.C,s)}function epe(t,s){t.B=new Np,vf(t.B,2,"PassThroughCalculator"),wc(t.B,"free_memory"),uo(t.B,"free_memory_unused_out"),Bc(s,"free_memory"),Fx(s,t.B)}function SA(t,s){wc(t.B,s),uo(t.B,s+"_unused_out")}function tpe(t){t.g.addBoolToStream(!0,"free_memory",t.C)}var Hwe=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 d=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=ko(this.baseOptions,Tde,1))!=null&&a.g()||(o=ko(this.baseOptions,Tde,1))!=null&&o.l()||(l=t.baseOptions)!=null&&l.modelAssetBuffer||(i=t.baseOptions)!=null&&i.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if(function(u,p){let f=ko(u.baseOptions,Pze,3);if(!f){var y=f=new Pze,_=new Sze;T8(y,4,doe,_)}"delegate"in p&&(p.delegate==="GPU"?(p=f,y=new _js,T8(p,2,doe,y)):(p=f,y=new Sze,T8(p,4,doe,y))),Ga(u.baseOptions,0,3,f)}(this,d),d.modelAssetPath)return fetch(d.modelAssetPath.toString()).then(u=>{if(u.ok)return u.arrayBuffer();throw Error(`Failed to fetch model: ${d.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),v0e(this,"/model.dat"),this.m(),this.L()});if(d.modelAssetBuffer instanceof Uint8Array)v0e(this,d.modelAssetBuffer);else if(d.modelAssetBuffer)return async function(u){const p=[];for(var f=0;;){const{done:y,value:_}=await u.read();if(y)break;p.push(_),f+=_.length}if(p.length===0)return new Uint8Array(0);if(p.length===1)return p[0];u=new Uint8Array(f),f=0;for(const y of p)u.set(y,f),f+=y.length;return u}(d.modelAssetBuffer).then(u=>{v0e(this,u),this.m(),this.L()})}return this.m(),this.L(),Promise.resolve()}L(){}ca(){let t;if(this.g.ca(s=>{t=bjs(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,$ze(this)}finishProcessing(){this.g.finishProcessing(),$ze(this)}close(){this.B=void 0,this.g.closeGraph()}};function $b(t,s){if(!t)throw Error(`Unable to obtain required WebGL resource: ${s}`);return t}Hwe.prototype.close=Hwe.prototype.close;class Zjs{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 qze(t,s,r){const n=t.g;if(r=$b(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 Uze(t,s){const r=t.g,n=$b(r.createVertexArray(),"Failed to create vertex array");r.bindVertexArray(n);const a=$b(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=$b(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 Zjs(r,n,a,o)}function ACe(t,s){if(t.g){if(s!==t.g)throw Error("Cannot change GL context once initialized")}else t.g=s}function Yjs(t,s,r,n){return ACe(t,s),t.h||(t.m(),t.D()),r?(t.u||(t.u=Uze(t,!0)),r=t.u):(t.A||(t.A=Uze(t,!1)),r=t.A),s.useProgram(t.h),r.bind(),t.l(),t=n(),r.g.bindVertexArray(null),t}function dlt(t,s,r){return ACe(t,s),t=$b(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 ult(t,s,r){ACe(t,s),t.B||(t.B=$b(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 Xjs(t){var s;(s=t.g)==null||s.bindFramebuffer(t.g.FRAMEBUFFER,null)}var hlt=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=$b(t.createProgram(),"Failed to create WebGL program"),this.X=qze(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=qze(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 Ov(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=Ov(t,1);if(!s){if(s=Ov(t,0))s=new Float32Array(s).map(n=>n/255);else{s=new Float32Array(t.width*t.height);const n=CA(t);var r=ECe(t);if(ult(r,n,mlt(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 mlt(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=CA(this),a=ECe(this);n.activeTexture(n.TEXTURE1),r=dlt(a,n,this.m?n.LINEAR:n.NEAREST),n.bindTexture(n.TEXTURE_2D,r);const o=plt(this);n.texImage2D(n.TEXTURE_2D,0,o,this.width,this.height,0,n.RED,n.FLOAT,null),n.bindTexture(n.TEXTURE_2D,null),ult(a,n,r),Yjs(a,n,!1,()=>{flt(this),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.drawArrays(n.TRIANGLE_FAN,0,4),Wwe(this)}),Xjs(a),Wwe(this)}}t.push(r)}return new Au(t,this.m,this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&CA(this).deleteTexture(Ov(this,2)),Vze=-1}};Au.prototype.close=Au.prototype.close,Au.prototype.clone=Au.prototype.clone,Au.prototype.getAsWebGLTexture=Au.prototype.N,Au.prototype.getAsFloat32Array=Au.prototype.ia,Au.prototype.getAsUint8Array=Au.prototype.ja,Au.prototype.hasWebGLTexture=Au.prototype.R,Au.prototype.hasFloat32Array=Au.prototype.ka,Au.prototype.hasUint8Array=Au.prototype.Fa;var Vze=250;function Zg(...t){return t.map(([s,r])=>({start:s,end:r}))}const Qjs=function(t){return class extends t{Ja(){this.i._registerModelResourcesGraphService()}}}((Hze=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:llt()?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?'),ka(this,n||"input_audio",o=>{ka(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){wy(this,"__graph_config__",s=>{t(s)}),ka(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),ka(this,n,l=>{this.i._addAudioToInputStream(this.g,s,r,l,a)})}addGpuBufferToStream(t,s,r){ka(this,s,n=>{const[a,o]=zze(this,t,n);this.i._addBoundTextureToStream(n,a,o,r)})}addBoolToStream(t,s,r){ka(this,s,n=>{this.i._addBoolToInputStream(t,n,r)})}addDoubleToStream(t,s,r){ka(this,s,n=>{this.i._addDoubleToInputStream(t,n,r)})}addFloatToStream(t,s,r){ka(this,s,n=>{this.i._addFloatToInputStream(t,n,r)})}addIntToStream(t,s,r){ka(this,s,n=>{this.i._addIntToInputStream(t,n,r)})}addUintToStream(t,s,r){ka(this,s,n=>{this.i._addUintToInputStream(t,n,r)})}addStringToStream(t,s,r){ka(this,s,n=>{ka(this,t,a=>{this.i._addStringToInputStream(a,n,r)})})}addStringRecordToStream(t,s,r){ka(this,s,n=>{Bze(this,Object.keys(t),a=>{Bze(this,Object.values(t),o=>{this.i._addFlatHashMapToInputStream(a,o,Object.keys(t).length,n,r)})})})}addProtoToStream(t,s,r,n){ka(this,r,a=>{ka(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){ka(this,t,r=>{this.i._addEmptyPacketToInputStream(r,s)})}addBoolVectorToStream(t,s,r){ka(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){ka(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){ka(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){ka(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){ka(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){ka(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)ka(this,o,l=>{this.i._addStringVectorEntry(a,l)});this.i._addStringVectorToInputStream(a,n,r)})}addBoolToInputSidePacket(t,s){ka(this,s,r=>{this.i._addBoolToInputSidePacket(t,r)})}addDoubleToInputSidePacket(t,s){ka(this,s,r=>{this.i._addDoubleToInputSidePacket(t,r)})}addFloatToInputSidePacket(t,s){ka(this,s,r=>{this.i._addFloatToInputSidePacket(t,r)})}addIntToInputSidePacket(t,s){ka(this,s,r=>{this.i._addIntToInputSidePacket(t,r)})}addUintToInputSidePacket(t,s){ka(this,s,r=>{this.i._addUintToInputSidePacket(t,r)})}addStringToInputSidePacket(t,s){ka(this,s,r=>{ka(this,t,n=>{this.i._addStringToInputSidePacket(n,r)})})}addProtoToInputSidePacket(t,s,r){ka(this,r,n=>{ka(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){ka(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){ka(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){ka(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){ka(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){ka(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){ka(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)ka(this,a,o=>{this.i._addStringVectorEntry(n,o)});this.i._addStringVectorToInputSidePacket(n,r)})}attachBoolListener(t,s){wy(this,t,s),ka(this,t,r=>{this.i._attachBoolListener(r)})}attachBoolVectorListener(t,s){b_(this,t,s),ka(this,t,r=>{this.i._attachBoolVectorListener(r)})}attachIntListener(t,s){wy(this,t,s),ka(this,t,r=>{this.i._attachIntListener(r)})}attachIntVectorListener(t,s){b_(this,t,s),ka(this,t,r=>{this.i._attachIntVectorListener(r)})}attachUintListener(t,s){wy(this,t,s),ka(this,t,r=>{this.i._attachUintListener(r)})}attachUintVectorListener(t,s){b_(this,t,s),ka(this,t,r=>{this.i._attachUintVectorListener(r)})}attachDoubleListener(t,s){wy(this,t,s),ka(this,t,r=>{this.i._attachDoubleListener(r)})}attachDoubleVectorListener(t,s){b_(this,t,s),ka(this,t,r=>{this.i._attachDoubleVectorListener(r)})}attachFloatListener(t,s){wy(this,t,s),ka(this,t,r=>{this.i._attachFloatListener(r)})}attachFloatVectorListener(t,s){b_(this,t,s),ka(this,t,r=>{this.i._attachFloatVectorListener(r)})}attachStringListener(t,s){wy(this,t,s),ka(this,t,r=>{this.i._attachStringListener(r)})}attachStringVectorListener(t,s){b_(this,t,s),ka(this,t,r=>{this.i._attachStringVectorListener(r)})}attachProtoListener(t,s,r){wy(this,t,s),ka(this,t,n=>{this.i._attachProtoListener(n,r||!1)})}attachProtoVectorListener(t,s,r){b_(this,t,s),ka(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?'),wy(this,t,(n,a)=>{n=new Float32Array(n.buffer,n.byteOffset,n.length/4),s(n,a)}),ka(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 Hze{get ga(){return this.i}pa(t,s,r){ka(this,s,n=>{const[a,o]=zze(this,t,n);this.ga._addBoundTextureAsImageToStream(n,a,o,r)})}Z(t,s){wy(this,t,s),ka(this,t,r=>{this.ga._attachImageListener(r)})}aa(t,s){b_(this,t,s),ka(this,t,r=>{this.ga._attachImageVectorListener(r)})}}));var Hze,Yg=class extends Qjs{};async function _o(t,s,r){return async function(n,a,o,l){return Kjs(n,a,o,l)}(t,r.canvas??(llt()?void 0:document.createElement("canvas")),s,r)}function xlt(t,s,r,n){if(t.U){const o=new Oot;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].");Pa(o,1,(a.left+a.right)/2),Pa(o,2,(a.top+a.bottom)/2),Pa(o,4,a.right-a.left),Pa(o,3,a.bottom-a.top)}else Pa(o,1,.5),Pa(o,2,.5),Pa(o,4,1),Pa(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(Pa(o,5,-Math.PI*r.rotationDegrees/180),(r==null?void 0:r.rotationDegrees)%180!=0){const[l,i]=clt(s);r=fd(o,3)*i/l,a=fd(o,4)*l/i,Pa(o,4,r),Pa(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 Xg(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'.");xlt(t,s,r,t.C+1)}function I0(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'.");xlt(t,s,r,n)}function MA(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 Au([a],r,!1,t.g.i.canvas,t.P,o,s),n?t.clone():t}var _f=class extends Hwe{constructor(t,s,r,n){super(t),this.g=t,this.X=s,this.U=r,this.oa=n,this.P=new hlt}l(t,s=!0){if("runningMode"in t&&al(this.baseOptions,2,uR(!!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()}};_f.prototype.close=_f.prototype.close;var Wf=class extends _f{constructor(t,s){super(new Yg(t,s),"image_in","norm_rect_in",!1),this.j={detections:[]},Ga(t=this.h=new Qme,0,1,s=new cd),Pa(this.h,2,.5),Pa(this.h,3,.3)}get baseOptions(){return ko(this.h,cd,1)}set baseOptions(t){Ga(this.h,0,1,t)}o(t){return"minDetectionConfidence"in t&&Pa(this.h,2,t.minDetectionConfidence??.5),"minSuppressionThreshold"in t&&Pa(this.h,3,t.minSuppressionThreshold??.3),this.l(t)}F(t,s){return this.j={detections:[]},Xg(this,t,s),this.j}G(t,s,r){return this.j={detections:[]},I0(this,t,r,s),this.j}m(){var t=new Sf;Bc(t,"image_in"),Bc(t,"norm_rect_in"),Lo(t,"detections");const s=new kf;E0(s,Ijs,this.h);const r=new Np;vf(r,2,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),wc(r,"IMAGE:image_in"),wc(r,"NORM_RECT:norm_rect_in"),uo(r,"DETECTIONS:detections"),r.o(s),Fx(t,r),this.g.attachProtoVectorListener("detections",(n,a)=>{for(const o of n)n=Lot(o),this.j.detections.push(ilt(n));ia(this,a)}),this.g.attachEmptyPacketListener("detections",n=>{ia(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Wf.prototype.detectForVideo=Wf.prototype.G,Wf.prototype.detect=Wf.prototype.F,Wf.prototype.setOptions=Wf.prototype.o,Wf.createFromModelPath=async function(t,s){return _o(Wf,t,{baseOptions:{modelAssetPath:s}})},Wf.createFromModelBuffer=function(t,s){return _o(Wf,t,{baseOptions:{modelAssetBuffer:s}})},Wf.createFromOptions=function(t,s){return _o(Wf,t,s)};var PCe=Zg([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]),ICe=Zg([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]),LCe=Zg([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),glt=Zg([474,475],[475,476],[476,477],[477,474]),DCe=Zg([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]),RCe=Zg([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),ylt=Zg([469,470],[470,471],[471,472],[472,469]),OCe=Zg([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]),vlt=[...PCe,...ICe,...LCe,...DCe,...RCe,...OCe],_lt=Zg([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 Gze(t){t.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var Vc=class extends _f{constructor(t,s){super(new Yg(t,s),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,Ga(t=this.h=new qot,0,1,s=new cd),this.A=new $ot,Ga(this.h,0,3,this.A),this.u=new Qme,Ga(this.h,0,2,this.u),N1(this.u,4,1),Pa(this.u,2,.5),Pa(this.A,2,.5),Pa(this.h,4,.5)}get baseOptions(){return ko(this.h,cd,1)}set baseOptions(t){Ga(this.h,0,1,t)}o(t){return"numFaces"in t&&N1(this.u,4,t.numFaces??1),"minFaceDetectionConfidence"in t&&Pa(this.u,2,t.minFaceDetectionConfidence??.5),"minTrackingConfidence"in t&&Pa(this.h,4,t.minTrackingConfidence??.5),"minFacePresenceConfidence"in t&&Pa(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 Gze(this),Xg(this,t,s),this.j}G(t,s,r){return Gze(this),I0(this,t,r,s),this.j}m(){var t=new Sf;Bc(t,"image_in"),Bc(t,"norm_rect"),Lo(t,"face_landmarks");const s=new kf;E0(s,Djs,this.h);const r=new Np;vf(r,2,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),wc(r,"IMAGE:image_in"),wc(r,"NORM_RECT:norm_rect"),uo(r,"NORM_LANDMARKS:face_landmarks"),r.o(s),Fx(t,r),this.g.attachProtoVectorListener("face_landmarks",(n,a)=>{for(const o of n)n=TO(o),this.j.faceLandmarks.push(Jme(n));ia(this,a)}),this.g.attachEmptyPacketListener("face_landmarks",n=>{ia(this,n)}),this.outputFaceBlendshapes&&(Lo(t,"blendshapes"),uo(r,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",(n,a)=>{if(this.outputFaceBlendshapes)for(const o of n)n=Xme(o),this.j.faceBlendshapes.push(TCe(n.g()??[]));ia(this,a)}),this.g.attachEmptyPacketListener("blendshapes",n=>{ia(this,n)})),this.outputFacialTransformationMatrixes&&(Lo(t,"face_geometry"),uo(r,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",(n,a)=>{if(this.outputFacialTransformationMatrixes)for(const o of n)(n=ko(n=Ljs(o),kjs,2))&&this.j.facialTransformationMatrixes.push({rows:mx(n,1)??0??0,columns:mx(n,2)??0??0,data:A4(n,3,Gy,T4()).slice()??[]});ia(this,a)}),this.g.attachEmptyPacketListener("face_geometry",n=>{ia(this,n)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Vc.prototype.detectForVideo=Vc.prototype.G,Vc.prototype.detect=Vc.prototype.F,Vc.prototype.setOptions=Vc.prototype.o,Vc.createFromModelPath=function(t,s){return _o(Vc,t,{baseOptions:{modelAssetPath:s}})},Vc.createFromModelBuffer=function(t,s){return _o(Vc,t,{baseOptions:{modelAssetBuffer:s}})},Vc.createFromOptions=function(t,s){return _o(Vc,t,s)},Vc.FACE_LANDMARKS_LIPS=PCe,Vc.FACE_LANDMARKS_LEFT_EYE=ICe,Vc.FACE_LANDMARKS_LEFT_EYEBROW=LCe,Vc.FACE_LANDMARKS_LEFT_IRIS=glt,Vc.FACE_LANDMARKS_RIGHT_EYE=DCe,Vc.FACE_LANDMARKS_RIGHT_EYEBROW=RCe,Vc.FACE_LANDMARKS_RIGHT_IRIS=ylt,Vc.FACE_LANDMARKS_FACE_OVAL=OCe,Vc.FACE_LANDMARKS_CONTOURS=vlt,Vc.FACE_LANDMARKS_TESSELATION=_lt;var FCe=Zg([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 Wze(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 Zze(t,s=!0){const r=[];for(const a of t){var n=Xme(a);t=[];for(const o of n.g())n=s&&mx(o,1)!=null?mx(o,1)??0:-1,t.push({score:fd(o,2)??0,index:n,categoryName:ph(Oc(o,3))??""??"",displayName:ph(Oc(o,4))??""??""});r.push(t)}return r}var Op=class extends _f{constructor(t,s){super(new Yg(t,s),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],Ga(t=this.j=new Hot,0,1,s=new cd),this.u=new kCe,Ga(this.j,0,2,this.u),this.D=new NCe,Ga(this.u,0,3,this.D),this.A=new Vot,Ga(this.u,0,2,this.A),this.h=new Rjs,Ga(this.j,0,3,this.h),Pa(this.A,2,.5),Pa(this.u,4,.5),Pa(this.D,2,.5)}get baseOptions(){return ko(this.j,cd,1)}set baseOptions(t){Ga(this.j,0,1,t)}o(t){var a,o,l,i;if(N1(this.A,3,t.numHands??1),"minHandDetectionConfidence"in t&&Pa(this.A,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&Pa(this.u,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&Pa(this.D,2,t.minHandPresenceConfidence??.5),t.cannedGesturesClassifierOptions){var s=new M5,r=s,n=Vwe(t.cannedGesturesClassifierOptions,(a=ko(this.h,M5,3))==null?void 0:a.l());Ga(r,0,2,n),Ga(this.h,0,3,s)}else t.cannedGesturesClassifierOptions===void 0&&((o=ko(this.h,M5,3))==null||o.g());return t.customGesturesClassifierOptions?(Ga(r=s=new M5,0,2,n=Vwe(t.customGesturesClassifierOptions,(l=ko(this.h,M5,4))==null?void 0:l.l())),Ga(this.h,0,4,s)):t.customGesturesClassifierOptions===void 0&&((i=ko(this.h,M5,4))==null||i.g()),this.l(t)}Ha(t,s){return Wze(this),Xg(this,t,s),Kze(this)}Ia(t,s,r){return Wze(this),I0(this,t,r,s),Kze(this)}m(){var t=new Sf;Bc(t,"image_in"),Bc(t,"norm_rect"),Lo(t,"hand_gestures"),Lo(t,"hand_landmarks"),Lo(t,"world_hand_landmarks"),Lo(t,"handedness");const s=new kf;E0(s,Ojs,this.j);const r=new Np;vf(r,2,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),wc(r,"IMAGE:image_in"),wc(r,"NORM_RECT:norm_rect"),uo(r,"HAND_GESTURES:hand_gestures"),uo(r,"LANDMARKS:hand_landmarks"),uo(r,"WORLD_LANDMARKS:world_hand_landmarks"),uo(r,"HANDEDNESS:handedness"),r.o(s),Fx(t,r),this.g.attachProtoVectorListener("hand_landmarks",(n,a)=>{for(const o of n){n=TO(o);const l=[];for(const i of j1(n,Rot,1))l.push({x:fd(i,1)??0,y:fd(i,2)??0,z:fd(i,3)??0,visibility:fd(i,4)??0});this.landmarks.push(l)}ia(this,a)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{ia(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,a)=>{for(const o of n){n=aT(o);const l=[];for(const i of j1(n,Dot,1))l.push({x:fd(i,1)??0,y:fd(i,2)??0,z:fd(i,3)??0,visibility:fd(i,4)??0});this.worldLandmarks.push(l)}ia(this,a)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{ia(this,n)}),this.g.attachProtoVectorListener("hand_gestures",(n,a)=>{this.gestures.push(...Zze(n,!1)),ia(this,a)}),this.g.attachEmptyPacketListener("hand_gestures",n=>{ia(this,n)}),this.g.attachProtoVectorListener("handedness",(n,a)=>{this.handedness.push(...Zze(n)),ia(this,a)}),this.g.attachEmptyPacketListener("handedness",n=>{ia(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};function Yze(t){return{landmarks:t.landmarks,worldLandmarks:t.worldLandmarks,handednesses:t.handedness,handedness:t.handedness}}Op.prototype.recognizeForVideo=Op.prototype.Ia,Op.prototype.recognize=Op.prototype.Ha,Op.prototype.setOptions=Op.prototype.o,Op.createFromModelPath=function(t,s){return _o(Op,t,{baseOptions:{modelAssetPath:s}})},Op.createFromModelBuffer=function(t,s){return _o(Op,t,{baseOptions:{modelAssetBuffer:s}})},Op.createFromOptions=function(t,s){return _o(Op,t,s)},Op.HAND_CONNECTIONS=FCe;var Fp=class extends _f{constructor(t,s){super(new Yg(t,s),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],Ga(t=this.h=new kCe,0,1,s=new cd),this.u=new NCe,Ga(this.h,0,3,this.u),this.j=new Vot,Ga(this.h,0,2,this.j),N1(this.j,3,1),Pa(this.j,2,.5),Pa(this.u,2,.5),Pa(this.h,4,.5)}get baseOptions(){return ko(this.h,cd,1)}set baseOptions(t){Ga(this.h,0,1,t)}o(t){return"numHands"in t&&N1(this.j,3,t.numHands??1),"minHandDetectionConfidence"in t&&Pa(this.j,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&Pa(this.h,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&Pa(this.u,2,t.minHandPresenceConfidence??.5),this.l(t)}F(t,s){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],Xg(this,t,s),Yze(this)}G(t,s,r){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],I0(this,t,r,s),Yze(this)}m(){var t=new Sf;Bc(t,"image_in"),Bc(t,"norm_rect"),Lo(t,"hand_landmarks"),Lo(t,"world_hand_landmarks"),Lo(t,"handedness");const s=new kf;E0(s,Fjs,this.h);const r=new Np;vf(r,2,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),wc(r,"IMAGE:image_in"),wc(r,"NORM_RECT:norm_rect"),uo(r,"LANDMARKS:hand_landmarks"),uo(r,"WORLD_LANDMARKS:world_hand_landmarks"),uo(r,"HANDEDNESS:handedness"),r.o(s),Fx(t,r),this.g.attachProtoVectorListener("hand_landmarks",(n,a)=>{for(const o of n)n=TO(o),this.landmarks.push(Jme(n));ia(this,a)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{ia(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,a)=>{for(const o of n)n=aT(o),this.worldLandmarks.push(E8(n));ia(this,a)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{ia(this,n)}),this.g.attachProtoVectorListener("handedness",(n,a)=>{var o=this.handedness,l=o.push;const i=[];for(const d of n){n=Xme(d);const u=[];for(const p of n.g())u.push({score:fd(p,2)??0,index:mx(p,1)??0??-1,categoryName:ph(Oc(p,3))??""??"",displayName:ph(Oc(p,4))??""??""});i.push(u)}l.call(o,...i),ia(this,a)}),this.g.attachEmptyPacketListener("handedness",n=>{ia(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Fp.prototype.detectForVideo=Fp.prototype.G,Fp.prototype.detect=Fp.prototype.F,Fp.prototype.setOptions=Fp.prototype.o,Fp.createFromModelPath=function(t,s){return _o(Fp,t,{baseOptions:{modelAssetPath:s}})},Fp.createFromModelBuffer=function(t,s){return _o(Fp,t,{baseOptions:{modelAssetBuffer:s}})},Fp.createFromOptions=function(t,s){return _o(Fp,t,s)},Fp.HAND_CONNECTIONS=FCe;var blt=Zg([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 Xze(t){t.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function Qze(t){try{if(!t.D)return t.h;t.D(t.h)}finally{tpe(t)}}function T9(t,s){t=TO(t),s.push(Jme(t))}var uc=class extends _f{constructor(t,s){super(new Yg(t,s),"input_frames_image",null,!1),this.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]},this.outputPoseSegmentationMasks=this.outputFaceBlendshapes=!1,Ga(t=this.j=new Yot,0,1,s=new cd),this.I=new NCe,Ga(this.j,0,2,this.I),this.W=new zjs,Ga(this.j,0,3,this.W),this.u=new Qme,Ga(this.j,0,4,this.u),this.O=new $ot,Ga(this.j,0,5,this.O),this.A=new Kot,Ga(this.j,0,6,this.A),this.M=new Zot,Ga(this.j,0,7,this.M),Pa(this.u,2,.5),Pa(this.u,3,.3),Pa(this.O,2,.5),Pa(this.A,2,.5),Pa(this.A,3,.3),Pa(this.M,2,.5),Pa(this.I,2,.5)}get baseOptions(){return ko(this.j,cd,1)}set baseOptions(t){Ga(this.j,0,1,t)}o(t){return"minFaceDetectionConfidence"in t&&Pa(this.u,2,t.minFaceDetectionConfidence??.5),"minFaceSuppressionThreshold"in t&&Pa(this.u,3,t.minFaceSuppressionThreshold??.3),"minFacePresenceConfidence"in t&&Pa(this.O,2,t.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in t&&(this.outputFaceBlendshapes=!!t.outputFaceBlendshapes),"minPoseDetectionConfidence"in t&&Pa(this.A,2,t.minPoseDetectionConfidence??.5),"minPoseSuppressionThreshold"in t&&Pa(this.A,3,t.minPoseSuppressionThreshold??.3),"minPosePresenceConfidence"in t&&Pa(this.M,2,t.minPosePresenceConfidence??.5),"outputPoseSegmentationMasks"in t&&(this.outputPoseSegmentationMasks=!!t.outputPoseSegmentationMasks),"minHandLandmarksConfidence"in t&&Pa(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,Xze(this),Xg(this,t,n),Qze(this)}G(t,s,r,n){const a=typeof r!="function"?r:{};return this.D=typeof r=="function"?r:n,Xze(this),I0(this,t,a,s),Qze(this)}m(){var t=new Sf;Bc(t,"input_frames_image"),Lo(t,"pose_landmarks"),Lo(t,"pose_world_landmarks"),Lo(t,"face_landmarks"),Lo(t,"left_hand_landmarks"),Lo(t,"left_hand_world_landmarks"),Lo(t,"right_hand_landmarks"),Lo(t,"right_hand_world_landmarks");const s=new kf,r=new wze;vf(r,1,"type.googleapis.com/mediapipe.tasks.vision.holistic_landmarker.proto.HolisticLandmarkerGraphOptions"),function(a,o){if(o!=null)if(Array.isArray(o))al(a,2,zme(o,0,hR));else{if(!(typeof o=="string"||o instanceof u0||VSe(o)))throw Error("invalid value in Any.value field: "+o+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");$_(a,2,GSe(o,!1),fC())}}(r,this.j.g());const n=new Np;vf(n,2,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),iCe(n,8,wze,r),wc(n,"IMAGE:input_frames_image"),uo(n,"POSE_LANDMARKS:pose_landmarks"),uo(n,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),uo(n,"FACE_LANDMARKS:face_landmarks"),uo(n,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),uo(n,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),uo(n,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),uo(n,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),n.o(s),Fx(t,n),epe(this,t),this.g.attachProtoListener("pose_landmarks",(a,o)=>{T9(a,this.h.poseLandmarks),ia(this,o)}),this.g.attachEmptyPacketListener("pose_landmarks",a=>{ia(this,a)}),this.g.attachProtoListener("pose_world_landmarks",(a,o)=>{var l=this.h.poseWorldLandmarks;a=aT(a),l.push(E8(a)),ia(this,o)}),this.g.attachEmptyPacketListener("pose_world_landmarks",a=>{ia(this,a)}),this.outputPoseSegmentationMasks&&(uo(n,"POSE_SEGMENTATION_MASK:pose_segmentation_mask"),SA(this,"pose_segmentation_mask"),this.g.Z("pose_segmentation_mask",(a,o)=>{this.h.poseSegmentationMasks=[MA(this,a,!0,!this.D)],ia(this,o)}),this.g.attachEmptyPacketListener("pose_segmentation_mask",a=>{this.h.poseSegmentationMasks=[],ia(this,a)})),this.g.attachProtoListener("face_landmarks",(a,o)=>{T9(a,this.h.faceLandmarks),ia(this,o)}),this.g.attachEmptyPacketListener("face_landmarks",a=>{ia(this,a)}),this.outputFaceBlendshapes&&(Lo(t,"extra_blendshapes"),uo(n,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",(a,o)=>{var l=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(a=Xme(a),l.push(TCe(a.g()??[]))),ia(this,o)}),this.g.attachEmptyPacketListener("extra_blendshapes",a=>{ia(this,a)})),this.g.attachProtoListener("left_hand_landmarks",(a,o)=>{T9(a,this.h.leftHandLandmarks),ia(this,o)}),this.g.attachEmptyPacketListener("left_hand_landmarks",a=>{ia(this,a)}),this.g.attachProtoListener("left_hand_world_landmarks",(a,o)=>{var l=this.h.leftHandWorldLandmarks;a=aT(a),l.push(E8(a)),ia(this,o)}),this.g.attachEmptyPacketListener("left_hand_world_landmarks",a=>{ia(this,a)}),this.g.attachProtoListener("right_hand_landmarks",(a,o)=>{T9(a,this.h.rightHandLandmarks),ia(this,o)}),this.g.attachEmptyPacketListener("right_hand_landmarks",a=>{ia(this,a)}),this.g.attachProtoListener("right_hand_world_landmarks",(a,o)=>{var l=this.h.rightHandWorldLandmarks;a=aT(a),l.push(E8(a)),ia(this,o)}),this.g.attachEmptyPacketListener("right_hand_world_landmarks",a=>{ia(this,a)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};uc.prototype.detectForVideo=uc.prototype.G,uc.prototype.detect=uc.prototype.F,uc.prototype.setOptions=uc.prototype.o,uc.createFromModelPath=function(t,s){return _o(uc,t,{baseOptions:{modelAssetPath:s}})},uc.createFromModelBuffer=function(t,s){return _o(uc,t,{baseOptions:{modelAssetBuffer:s}})},uc.createFromOptions=function(t,s){return _o(uc,t,s)},uc.HAND_CONNECTIONS=FCe,uc.POSE_CONNECTIONS=blt,uc.FACE_LANDMARKS_LIPS=PCe,uc.FACE_LANDMARKS_LEFT_EYE=ICe,uc.FACE_LANDMARKS_LEFT_EYEBROW=LCe,uc.FACE_LANDMARKS_LEFT_IRIS=glt,uc.FACE_LANDMARKS_RIGHT_EYE=DCe,uc.FACE_LANDMARKS_RIGHT_EYEBROW=RCe,uc.FACE_LANDMARKS_RIGHT_IRIS=ylt,uc.FACE_LANDMARKS_FACE_OVAL=OCe,uc.FACE_LANDMARKS_CONTOURS=vlt,uc.FACE_LANDMARKS_TESSELATION=_lt;var Kf=class extends _f{constructor(t,s){super(new Yg(t,s),"input_image","norm_rect",!0),this.j={classifications:[]},Ga(t=this.h=new Xot,0,1,s=new cd)}get baseOptions(){return ko(this.h,cd,1)}set baseOptions(t){Ga(this.h,0,1,t)}o(t){return Ga(this.h,0,2,Vwe(t,ko(this.h,wCe,2))),this.l(t)}sa(t,s){return this.j={classifications:[]},Xg(this,t,s),this.j}ta(t,s,r){return this.j={classifications:[]},I0(this,t,r,s),this.j}m(){var t=new Sf;Bc(t,"input_image"),Bc(t,"norm_rect"),Lo(t,"classifications");const s=new kf;E0(s,Bjs,this.h);const r=new Np;vf(r,2,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),wc(r,"IMAGE:input_image"),wc(r,"NORM_RECT:norm_rect"),uo(r,"CLASSIFICATIONS:classifications"),r.o(s),Fx(t,r),this.g.attachProtoListener("classifications",(n,a)=>{this.j=Gjs(Mjs(n)),ia(this,a)}),this.g.attachEmptyPacketListener("classifications",n=>{ia(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Kf.prototype.classifyForVideo=Kf.prototype.ta,Kf.prototype.classify=Kf.prototype.sa,Kf.prototype.setOptions=Kf.prototype.o,Kf.createFromModelPath=function(t,s){return _o(Kf,t,{baseOptions:{modelAssetPath:s}})},Kf.createFromModelBuffer=function(t,s){return _o(Kf,t,{baseOptions:{modelAssetBuffer:s}})},Kf.createFromOptions=function(t,s){return _o(Kf,t,s)};var zp=class extends _f{constructor(t,s){super(new Yg(t,s),"image_in","norm_rect",!0),this.h=new Qot,this.embeddings={embeddings:[]},Ga(t=this.h,0,1,s=new cd)}get baseOptions(){return ko(this.h,cd,1)}set baseOptions(t){Ga(this.h,0,1,t)}o(t){var s=this.h,r=ko(this.h,Eze,2);return r=r?r.clone():new Eze,t.l2Normalize!==void 0?al(r,1,uR(t.l2Normalize)):"l2Normalize"in t&&al(r,1),t.quantize!==void 0?al(r,2,uR(t.quantize)):"quantize"in t&&al(r,2),Ga(s,0,2,r),this.l(t)}za(t,s){return Xg(this,t,s),this.embeddings}Aa(t,s,r){return I0(this,t,r,s),this.embeddings}m(){var t=new Sf;Bc(t,"image_in"),Bc(t,"norm_rect"),Lo(t,"embeddings_out");const s=new kf;E0(s,$js,this.h);const r=new Np;vf(r,2,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),wc(r,"IMAGE:image_in"),wc(r,"NORM_RECT:norm_rect"),uo(r,"EMBEDDINGS:embeddings_out"),r.o(s),Fx(t,r),this.g.attachProtoListener("embeddings_out",(n,a)=>{n=Ejs(n),this.embeddings=function(o){return{embeddings:j1(o,Ajs,1).map(l=>{var u,p;const i={headIndex:mx(l,3)??0??-1,headName:ph(Oc(l,4))??""??""};var d=l.v;return Zit(d,0|d[ba],Aze,p0e(l,1))!==void 0?(l=A4(l=ko(l,Aze,p0e(l,1),void 0),1,Gy,T4()),i.floatEmbedding=l.slice()):(d=new Uint8Array(0),i.quantizedEmbedding=((p=(u=ko(l,Tjs,p0e(l,2),void 0))==null?void 0:u.na())==null?void 0:p.h())??d),i}),timestampMs:alt(Oc(o,2,void 0,void 0,jde)??Vit)}}(n),ia(this,a)}),this.g.attachEmptyPacketListener("embeddings_out",n=>{ia(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};zp.cosineSimilarity=function(t,s){if(t.floatEmbedding&&s.floatEmbedding)t=Oze(t.floatEmbedding,s.floatEmbedding);else{if(!t.quantizedEmbedding||!s.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");t=Oze(Rze(t.quantizedEmbedding),Rze(s.quantizedEmbedding))}return t},zp.prototype.embedForVideo=zp.prototype.Aa,zp.prototype.embed=zp.prototype.za,zp.prototype.setOptions=zp.prototype.o,zp.createFromModelPath=function(t,s){return _o(zp,t,{baseOptions:{modelAssetPath:s}})},zp.createFromModelBuffer=function(t,s){return _o(zp,t,{baseOptions:{modelAssetBuffer:s}})},zp.createFromOptions=function(t,s){return _o(zp,t,s)};var Kwe=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 Jjs(t){var r,n;const s=function(a){return j1(a,Np,1)}(t.ca()).filter(a=>(ph(Oc(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=ko(s[0],kf,7))==null?void 0:r.j())==null?void 0:n.g())??new Map).forEach((a,o)=>{t.u[Number(o)]=ph(Oc(a,1))??""})}function Jze(t){t.categoryMask=void 0,t.confidenceMasks=void 0,t.qualityScores=void 0}function e9e(t){try{const s=new Kwe(t.confidenceMasks,t.categoryMask,t.qualityScores);if(!t.j)return s;t.j(s)}finally{tpe(t)}}Kwe.prototype.close=Kwe.prototype.close;var cm=class extends _f{constructor(t,s){super(new Yg(t,s),"image_in","norm_rect",!1),this.u=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new MCe,this.A=new Jot,Ga(this.h,0,3,this.A),Ga(t=this.h,0,1,s=new cd)}get baseOptions(){return ko(this.h,cd,1)}set baseOptions(t){Ga(this.h,0,1,t)}o(t){return t.displayNamesLocale!==void 0?al(this.h,2,SO(t.displayNamesLocale)):"displayNamesLocale"in t&&al(this.h,2),"outputCategoryMask"in t&&(this.outputCategoryMask=t.outputCategoryMask??!1),"outputConfidenceMasks"in t&&(this.outputConfidenceMasks=t.outputConfidenceMasks??!0),super.l(t)}L(){Jjs(this)}segment(t,s,r){const n=typeof s!="function"?s:{};return this.j=typeof s=="function"?s:r,Jze(this),Xg(this,t,n),e9e(this)}La(t,s,r,n){const a=typeof r!="function"?r:{};return this.j=typeof r=="function"?r:n,Jze(this),I0(this,t,a,s),e9e(this)}Da(){return this.u}m(){var t=new Sf;Bc(t,"image_in"),Bc(t,"norm_rect");const s=new kf;E0(s,tlt,this.h);const r=new Np;vf(r,2,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),wc(r,"IMAGE:image_in"),wc(r,"NORM_RECT:norm_rect"),r.o(s),Fx(t,r),epe(this,t),this.outputConfidenceMasks&&(Lo(t,"confidence_masks"),uo(r,"CONFIDENCE_MASKS:confidence_masks"),SA(this,"confidence_masks"),this.g.aa("confidence_masks",(n,a)=>{this.confidenceMasks=n.map(o=>MA(this,o,!0,!this.j)),ia(this,a)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],ia(this,n)})),this.outputCategoryMask&&(Lo(t,"category_mask"),uo(r,"CATEGORY_MASK:category_mask"),SA(this,"category_mask"),this.g.Z("category_mask",(n,a)=>{this.categoryMask=MA(this,n,!1,!this.j),ia(this,a)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,ia(this,n)})),Lo(t,"quality_scores"),uo(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,a)=>{this.qualityScores=n,ia(this,a)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,ia(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};cm.prototype.getLabels=cm.prototype.Da,cm.prototype.segmentForVideo=cm.prototype.La,cm.prototype.segment=cm.prototype.segment,cm.prototype.setOptions=cm.prototype.o,cm.createFromModelPath=function(t,s){return _o(cm,t,{baseOptions:{modelAssetPath:s}})},cm.createFromModelBuffer=function(t,s){return _o(cm,t,{baseOptions:{modelAssetBuffer:s}})},cm.createFromOptions=function(t,s){return _o(cm,t,s)};var Zwe=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()}};Zwe.prototype.close=Zwe.prototype.close;var jy=class extends _f{constructor(t,s){super(new Yg(t,s),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new MCe,this.u=new Jot,Ga(this.h,0,3,this.u),Ga(t=this.h,0,1,s=new cd)}get baseOptions(){return ko(this.h,cd,1)}set baseOptions(t){Ga(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 slt,s.keypoint&&s.scribble)throw Error("Cannot provide both keypoint and scribble.");if(s.keypoint){var o=new y0e;$_(o,3,uR(!0),!1),$_(o,1,qI(s.keypoint.x),0),$_(o,2,qI(s.keypoint.y),0),T8(n,1,Uwe,o)}else{if(!s.scribble)throw Error("Must provide either a keypoint or a scribble.");{const i=new Ujs;for(o of s.scribble)$_(s=new y0e,3,uR(!0),!1),$_(s,1,qI(o.x),0),$_(s,2,qI(o.y),0),iCe(i,1,y0e,s);T8(n,2,Uwe,i)}}this.g.addProtoToStream(n.g(),"mediapipe.tasks.vision.interactive_segmenter.proto.RegionOfInterest","roi_in",r),Xg(this,t,a);e:{try{const i=new Zwe(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var l=i;break e}this.j(i)}finally{tpe(this)}l=void 0}return l}m(){var t=new Sf;Bc(t,"image_in"),Bc(t,"roi_in"),Bc(t,"norm_rect_in");const s=new kf;E0(s,tlt,this.h);const r=new Np;vf(r,2,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraphV2"),wc(r,"IMAGE:image_in"),wc(r,"ROI:roi_in"),wc(r,"NORM_RECT:norm_rect_in"),r.o(s),Fx(t,r),epe(this,t),this.outputConfidenceMasks&&(Lo(t,"confidence_masks"),uo(r,"CONFIDENCE_MASKS:confidence_masks"),SA(this,"confidence_masks"),this.g.aa("confidence_masks",(n,a)=>{this.confidenceMasks=n.map(o=>MA(this,o,!0,!this.j)),ia(this,a)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],ia(this,n)})),this.outputCategoryMask&&(Lo(t,"category_mask"),uo(r,"CATEGORY_MASK:category_mask"),SA(this,"category_mask"),this.g.Z("category_mask",(n,a)=>{this.categoryMask=MA(this,n,!1,!this.j),ia(this,a)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,ia(this,n)})),Lo(t,"quality_scores"),uo(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,a)=>{this.qualityScores=n,ia(this,a)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,ia(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};jy.prototype.segment=jy.prototype.segment,jy.prototype.setOptions=jy.prototype.o,jy.createFromModelPath=function(t,s){return _o(jy,t,{baseOptions:{modelAssetPath:s}})},jy.createFromModelBuffer=function(t,s){return _o(jy,t,{baseOptions:{modelAssetBuffer:s}})},jy.createFromOptions=function(t,s){return _o(jy,t,s)};var Zf=class extends _f{constructor(t,s){super(new Yg(t,s),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},Ga(t=this.h=new rlt,0,1,s=new cd)}get baseOptions(){return ko(this.h,cd,1)}set baseOptions(t){Ga(this.h,0,1,t)}o(t){return t.displayNamesLocale!==void 0?al(this.h,2,SO(t.displayNamesLocale)):"displayNamesLocale"in t&&al(this.h,2),t.maxResults!==void 0?N1(this.h,3,t.maxResults):"maxResults"in t&&al(this.h,3),t.scoreThreshold!==void 0?Pa(this.h,4,t.scoreThreshold):"scoreThreshold"in t&&al(this.h,4),t.categoryAllowlist!==void 0?kde(this.h,5,t.categoryAllowlist):"categoryAllowlist"in t&&al(this.h,5),t.categoryDenylist!==void 0?kde(this.h,6,t.categoryDenylist):"categoryDenylist"in t&&al(this.h,6),this.l(t)}F(t,s){return this.j={detections:[]},Xg(this,t,s),this.j}G(t,s,r){return this.j={detections:[]},I0(this,t,r,s),this.j}m(){var t=new Sf;Bc(t,"input_frame_gpu"),Bc(t,"norm_rect"),Lo(t,"detections");const s=new kf;E0(s,Vjs,this.h);const r=new Np;vf(r,2,"mediapipe.tasks.vision.ObjectDetectorGraph"),wc(r,"IMAGE:input_frame_gpu"),wc(r,"NORM_RECT:norm_rect"),uo(r,"DETECTIONS:detections"),r.o(s),Fx(t,r),this.g.attachProtoVectorListener("detections",(n,a)=>{for(const o of n)n=Lot(o),this.j.detections.push(ilt(n));ia(this,a)}),this.g.attachEmptyPacketListener("detections",n=>{ia(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Zf.prototype.detectForVideo=Zf.prototype.G,Zf.prototype.detect=Zf.prototype.F,Zf.prototype.setOptions=Zf.prototype.o,Zf.createFromModelPath=async function(t,s){return _o(Zf,t,{baseOptions:{modelAssetPath:s}})},Zf.createFromModelBuffer=function(t,s){return _o(Zf,t,{baseOptions:{modelAssetBuffer:s}})},Zf.createFromOptions=function(t,s){return _o(Zf,t,s)};var Ywe=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 t9e(t){t.landmarks=[],t.worldLandmarks=[],t.segmentationMasks=void 0}function s9e(t){try{const s=new Ywe(t.landmarks,t.worldLandmarks,t.segmentationMasks);if(!t.u)return s;t.u(s)}finally{tpe(t)}}Ywe.prototype.close=Ywe.prototype.close;var Bp=class extends _f{constructor(t,s){super(new Yg(t,s),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,Ga(t=this.h=new nlt,0,1,s=new cd),this.A=new Zot,Ga(this.h,0,3,this.A),this.j=new Kot,Ga(this.h,0,2,this.j),N1(this.j,4,1),Pa(this.j,2,.5),Pa(this.A,2,.5),Pa(this.h,4,.5)}get baseOptions(){return ko(this.h,cd,1)}set baseOptions(t){Ga(this.h,0,1,t)}o(t){return"numPoses"in t&&N1(this.j,4,t.numPoses??1),"minPoseDetectionConfidence"in t&&Pa(this.j,2,t.minPoseDetectionConfidence??.5),"minTrackingConfidence"in t&&Pa(this.h,4,t.minTrackingConfidence??.5),"minPosePresenceConfidence"in t&&Pa(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,t9e(this),Xg(this,t,n),s9e(this)}G(t,s,r,n){const a=typeof r!="function"?r:{};return this.u=typeof r=="function"?r:n,t9e(this),I0(this,t,a,s),s9e(this)}m(){var t=new Sf;Bc(t,"image_in"),Bc(t,"norm_rect"),Lo(t,"normalized_landmarks"),Lo(t,"world_landmarks"),Lo(t,"segmentation_masks");const s=new kf;E0(s,Hjs,this.h);const r=new Np;vf(r,2,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),wc(r,"IMAGE:image_in"),wc(r,"NORM_RECT:norm_rect"),uo(r,"NORM_LANDMARKS:normalized_landmarks"),uo(r,"WORLD_LANDMARKS:world_landmarks"),r.o(s),Fx(t,r),epe(this,t),this.g.attachProtoVectorListener("normalized_landmarks",(n,a)=>{this.landmarks=[];for(const o of n)n=TO(o),this.landmarks.push(Jme(n));ia(this,a)}),this.g.attachEmptyPacketListener("normalized_landmarks",n=>{this.landmarks=[],ia(this,n)}),this.g.attachProtoVectorListener("world_landmarks",(n,a)=>{this.worldLandmarks=[];for(const o of n)n=aT(o),this.worldLandmarks.push(E8(n));ia(this,a)}),this.g.attachEmptyPacketListener("world_landmarks",n=>{this.worldLandmarks=[],ia(this,n)}),this.outputSegmentationMasks&&(uo(r,"SEGMENTATION_MASK:segmentation_masks"),SA(this,"segmentation_masks"),this.g.aa("segmentation_masks",(n,a)=>{this.segmentationMasks=n.map(o=>MA(this,o,!0,!this.u)),ia(this,a)}),this.g.attachEmptyPacketListener("segmentation_masks",n=>{this.segmentationMasks=[],ia(this,n)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Bp.prototype.detectForVideo=Bp.prototype.G,Bp.prototype.detect=Bp.prototype.F,Bp.prototype.setOptions=Bp.prototype.o,Bp.createFromModelPath=function(t,s){return _o(Bp,t,{baseOptions:{modelAssetPath:s}})},Bp.createFromModelBuffer=function(t,s){return _o(Bp,t,{baseOptions:{modelAssetBuffer:s}})},Bp.createFromOptions=function(t,s){return _o(Bp,t,s)},Bp.POSE_CONNECTIONS=blt;let E4=null,UI=null;async function eNs(){return E4||UI||(UI=(async()=>{const t=await z5.forVisionTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm");return E4=await cm.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}),E4})(),UI)}function tNs(t,s,r,n,a){const o=new Float32Array(t.length);for(let l=0;l=0&&(i-=t[d+p]);const y=Math.min(f,r-1)-Math.max(p+1,0)+1;o[d+u]=i/y}}for(let l=0;l=0&&(i-=o[u*r+l]);const f=Math.min(p,n-1)-Math.max(u+1,0)+1;s[d*r+l]=i/f}}}function sNs(){E4&&(E4.close(),E4=null,UI=null)}function rNs(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),[d,u]=k.useState(null),[p,f]=k.useState(!1),[y,_]=k.useState(null),b=s.type!=="none"&&t!==null;return k.useEffect(()=>{if(s.type==="image"&&s.imageUrl){const N=new Image;N.crossOrigin="anonymous",N.src=s.imageUrl,N.onload=()=>{o.current=N}}else o.current=null},[s.type,s.imageUrl]),k.useEffect(()=>{if(!b||!t){a.current&&(a.current.srcObject=null,a.current=null);return}const N=document.createElement("video");return N.srcObject=t,N.muted=!0,N.playsInline=!0,N.autoplay=!0,N.play().catch(()=>{}),a.current=N,()=>{N.srcObject=null,a.current=null}},[b,t]),k.useEffect(()=>{if(!b){u(null),_(null);return}let N=!1;return(async()=>{f(!0),_(null);try{const S=await eNs();if(N)return;f(!1);const C=a.current;if(!C||(await new Promise(ge=>{if(C.videoWidth>0)return ge();C.onloadedmetadata=()=>ge(),setTimeout(ge,2e3)}),N))return;const A=C.videoWidth||640,I=C.videoHeight||480,L=r.current;if(!L)return;L.width=A,L.height=I;const O=L.getContext("2d",{willReadFrequently:!1});n.current||(n.current=document.createElement("canvas"));const V=n.current;V.width=A,V.height=I;const q=V.getContext("2d",{willReadFrequently:!0}),B=document.createElement("canvas");B.width=A,B.height=I;const U=B.getContext("2d"),te=L.captureStream(30);((t==null?void 0:t.getAudioTracks())||[]).forEach(ge=>te.addTrack(ge)),N||u(te);const J=s.blurRadius??15,X=s.mirror??!1,ce=new Float32Array(A*I),ie=new Float32Array(A*I),ae=new Float32Array(A*I);let oe=!1;const me=4,ve=.6,he=()=>{if(N||!a.current)return;const ge=performance.now();if(ge-i.current<30){l.current=requestAnimationFrame(he);return}i.current=ge;const je=a.current;if(je.readyState<2){l.current=requestAnimationFrame(he);return}try{const Me=S.segmentForVideo(je,ge).confidenceMasks;if(Me&&Me.length>0){ie.fill(0);for(let Ve=1;VeUe?(ct=Ve.height*Ue,Ie=(Ve.width-ct)/2):(fe=Ve.width/Ue,ye=(Ve.height-fe)/2),O.drawImage(Ve,Ie,ye,ct,fe,0,0,A,I)}q.clearRect(0,0,A,I),q.drawImage(je,0,0,A,I);const ke=q.getImageData(0,0,A,I),Re=ke.data;for(let Ve=0;Ve{N=!0,l.current&&cancelAnimationFrame(l.current),u(null)}},[b,s.type,s.blurRadius,s.imageUrl,t]),k.useEffect(()=>()=>{sNs()},[]),{canvasRef:r,compositedStream:d,isLoading:p,isActive:b,error:y}}function AO({maxDurationSeconds:t=600,onRecordingComplete:s,onError:r,onRecordingStateChange:n,className:a,teleprompterContent:o}){const l=k.useRef(null),i=k.useRef(null),d=k.useRef(null),[u,p]=k.useState(null),f=k.useRef([]),y=k.useRef(null),_=k.useRef(null),b=k.useRef(null),N=k.useRef(null),w=bE(),[S,C]=k.useState("camera"),A=k.useRef(null),I=k.useRef(null),L=k.useRef(null),O=k.useRef(null),V=k.useRef(null),[q,B]=k.useState(!0),[U,te]=k.useState(!0),[Y,J]=k.useState(null),[X,ce]=k.useState(!1),[ie,ae]=k.useState(!1),[oe,me]=k.useState(null),[ve,he]=k.useState(null),[ge,je]=k.useState(0),[qe,Me]=k.useState("user"),[ke,Re]=k.useState(0),[Ve,Ne]=k.useState(!1),[Ue,Ie]=k.useState(!0),[ye,ct]=k.useState(null),[fe,$e]=k.useState(!1),[Ye,tt]=k.useState(null),Te=k.useRef(null),[We,Ke]=k.useState(()=>{try{const nr=localStorage.getItem("video-bg-config");if(nr)return JSON.parse(nr)}catch{}return{type:"none"}});k.useEffect(()=>{try{localStorage.setItem("video-bg-config",JSON.stringify(We))}catch{}},[We]);const{canvasRef:ot,compositedStream:He,isLoading:Je,isActive:ut,error:mt}=rNs(u,We),et=k.useRef(r);et.current=r;const Ze=k.useCallback(nr=>{B(nr)},[]),kt=k.useRef(q),Ut=k.useCallback(()=>{L.current&&(cancelAnimationFrame(L.current),L.current=null),A.current&&(A.current.getTracks().forEach(nr=>nr.stop()),A.current=null),O.current&&(O.current.getTracks().forEach(nr=>nr.stop()),O.current=null),V.current&&(V.current.srcObject=null,V.current=null)},[]),Nt=k.useCallback(async()=>{var nr;try{const cr=await navigator.mediaDevices.getDisplayMedia({video:{width:{ideal:1920},height:{ideal:1080}},audio:!0});A.current=cr;let Br=null;try{Br=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 Kr=null;if(!Br)try{Kr=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{console.warn("[VideoRecorder] No mic audio")}const Sn=cr.getVideoTracks()[0],ai=Sn.getSettings(),as=ai.width||1920,qn=ai.height||1080,un=document.createElement("canvas");un.width=as,un.height=qn,I.current=un;const qr=un.getContext("2d");let Zr=null;Br&&(Zr=document.createElement("video"),Zr.srcObject=Br,Zr.muted=!0,Zr.playsInline=!0,Zr.autoplay=!0,await Zr.play(),V.current=Zr);const La=document.createElement("video");La.srcObject=cr,La.muted=!0,La.playsInline=!0,La.autoplay=!0,await La.play();const Yt=()=>{if(qr.drawImage(La,0,0,as,qn),Zr&&Zr.readyState>=2){const Xe=Math.round(as*.2),yt=Math.round(Xe*(Zr.videoHeight/Zr.videoWidth||.75)),bt=as-Xe-20,At=qn-yt-20,Gt=12;qr.save(),qr.beginPath(),qr.moveTo(bt+Gt,At),qr.lineTo(bt+Xe-Gt,At),qr.quadraticCurveTo(bt+Xe,At,bt+Xe,At+Gt),qr.lineTo(bt+Xe,At+yt-Gt),qr.quadraticCurveTo(bt+Xe,At+yt,bt+Xe-Gt,At+yt),qr.lineTo(bt+Gt,At+yt),qr.quadraticCurveTo(bt,At+yt,bt,At+yt-Gt),qr.lineTo(bt,At+Gt),qr.quadraticCurveTo(bt,At,bt+Gt,At),qr.closePath(),qr.clip(),qr.translate(bt+Xe,At),qr.scale(-1,1),qr.drawImage(Zr,0,0,Xe,yt),qr.restore(),qr.strokeStyle="rgba(255,255,255,0.6)",qr.lineWidth=2,qr.beginPath(),qr.moveTo(bt+Gt,At),qr.lineTo(bt+Xe-Gt,At),qr.quadraticCurveTo(bt+Xe,At,bt+Xe,At+Gt),qr.lineTo(bt+Xe,At+yt-Gt),qr.quadraticCurveTo(bt+Xe,At+yt,bt+Xe-Gt,At+yt),qr.lineTo(bt+Gt,At+yt),qr.quadraticCurveTo(bt,At+yt,bt,At+yt-Gt),qr.lineTo(bt,At+Gt),qr.quadraticCurveTo(bt,At,bt+Gt,At),qr.closePath(),qr.stroke()}L.current=requestAnimationFrame(Yt)};Yt();const Lr=un.captureStream(30),$t=[],Se=cr.getAudioTracks();if(Se.length&&$t.push(...Se),Br){const Xe=Br.getAudioTracks();Xe.length&&$t.push(...Xe)}else Kr&&$t.push(...Kr.getAudioTracks());const Fe=new MediaStream([...Lr.getVideoTracks(),...$t]);return O.current=Fe,Sn.onended=()=>{i.current&&i.current.state!=="inactive"&&i.current.stop(),Ut()},Fe}catch(cr){return console.error("[VideoRecorder] Screen capture error:",cr),cr.name!=="NotAllowedError"&&((nr=et.current)==null||nr.call(et,"Failed to start screen capture: "+(cr.message||"Unknown error"))),null}},[Ut]),es=k.useCallback(async()=>{var cr,Br;te(!0),ct(null);const nr=w&&q;console.log("[VideoRecorder] initCamera start",{isMobile:w,usePortraitMode:q,shouldBePortrait:nr,facingMode:qe});try{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Camera not available in this browser or context. Try opening in a new tab.");d.current&&(console.log("[VideoRecorder] stopping existing stream"),d.current.getTracks().forEach(qn=>qn.stop()));const Kr=w&&nr?{facingMode:{ideal:qe},width:{ideal:720},height:{ideal:1280}}:{facingMode:{ideal:qe},width:{ideal:1280},height:{ideal:720}};console.log("[VideoRecorder] requesting getUserMedia",Kr);const Sn=await navigator.mediaDevices.getUserMedia({video:Kr,audio:{echoCancellation:!0,noiseSuppression:!0}});if(console.log("[VideoRecorder] getUserMedia success"),Sn.getVideoTracks().length===0)throw new Error("Camera stream started but no video track was provided.");d.current=Sn,p(Sn),J(!0);const as=Sn.getVideoTracks()[0].getSettings();if(console.log("[VideoRecorder] Camera initialized with dimensions:",as.width,"x",as.height),l.current){const qn=l.current;qn.srcObject=Sn,qn.muted=!0,qn.playsInline=!0,qn.autoplay=!0,qn.setAttribute("muted",""),qn.setAttribute("playsinline",""),qn.setAttribute("autoplay","");try{(cr=qn.load)==null||cr.call(qn)}catch(qr){console.warn("[VideoRecorder] videoEl.load failed",qr)}const un=async()=>{try{return await qn.play(),console.log("[VideoRecorder] preview play ok"),$e(!1),setTimeout(()=>{console.debug("[VideoRecorder] preview metrics",{readyState:qn.readyState,videoWidth:qn.videoWidth,videoHeight:qn.videoHeight})},300),!0}catch(qr){return console.warn("[VideoRecorder] preview play blocked",qr),$e(!0),!1}};await new Promise(qr=>{let Zr=!1;const La=()=>{Zr||(Zr=!0,qr())},Yt=()=>{un().finally(La)};qn.onloadedmetadata=Yt,qn.onloadeddata=Yt,setTimeout(La,1500)})}try{_.current=new AudioContext;const qn=_.current.createMediaStreamSource(Sn);b.current=_.current.createAnalyser(),b.current.fftSize=256,qn.connect(b.current);const un=()=>{if(b.current){const qr=new Uint8Array(b.current.frequencyBinCount);b.current.getByteFrequencyData(qr);const Zr=qr.reduce((La,Yt)=>La+Yt)/qr.length;Re(Math.min(100,Zr/128*100))}N.current=requestAnimationFrame(un)};un()}catch(qn){console.warn("Audio context not available:",qn)}}catch(Kr){console.error("Camera initialization error:",Kr),J(!1);let Sn="Failed to access camera or microphone.";Kr.name==="NotAllowedError"?Sn="Camera permission denied. Please allow camera access in your browser settings.":Kr.name==="NotFoundError"?Sn="No camera found. Please connect a camera and try again.":Kr.name==="NotReadableError"?Sn="Camera is in use by another application. Please close other apps using the camera.":Kr.message&&(Sn=Kr.message),ct(Sn),(Br=et.current)==null||Br.call(et,Sn)}finally{te(!1)}},[qe,w,q]);k.useEffect(()=>{kt.current!==q&&Y&&!X&&!ve&&(kt.current=q,es())},[q,Y,X,ve,es]),k.useEffect(()=>(es(),()=>{d.current&&d.current.getTracks().forEach(nr=>nr.stop()),y.current&&clearInterval(y.current),N.current&&cancelAnimationFrame(N.current),_.current&&_.current.close(),Te.current&&clearInterval(Te.current),ve&&URL.revokeObjectURL(ve),Ut()}),[es,ve]),k.useEffect(()=>{if(U||Y!==!0||ve)return;const nr=d.current,cr=l.current;!nr||!cr||ut||(cr.srcObject!==nr&&(cr.srcObject=nr,cr.muted=!0,cr.playsInline=!0,cr.autoplay=!0,cr.setAttribute("muted",""),cr.setAttribute("playsinline",""),cr.setAttribute("autoplay","")),cr.play().then(()=>$e(!1)).catch(Br=>{$e(!0),console.warn("Live preview play blocked on mount:",Br)}))},[Y,U,ve,ut]),k.useEffect(()=>{n==null||n(X)},[X,n]);const ds=k.useCallback(async()=>{if(ve)return;const nr=l.current;if(nr)try{await nr.play(),$e(!1)}catch(cr){$e(!0),console.warn("Live preview still blocked (needs user gesture):",cr)}},[ve]),js=k.useCallback(()=>{i.current&&i.current.state!=="inactive"&&i.current.stop(),y.current&&(clearInterval(y.current),y.current=null),Ut(),ce(!1),ae(!1)},[Ut]),lr=k.useCallback(async()=>{let nr=null;if(S==="screen"){if(nr=await Nt(),!nr)return}else nr=ut&&He?He:d.current;if(!nr)return;ds(),f.current=[],je(0);const Br=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"].find(Sn=>MediaRecorder.isTypeSupported(Sn)),Kr=new MediaRecorder(nr,Br?{mimeType:Br,videoBitsPerSecond:S==="screen"?4e6:25e5}:{videoBitsPerSecond:S==="screen"?4e6:25e5});Kr.ondataavailable=Sn=>{Sn.data.size>0&&f.current.push(Sn.data)},Kr.onstop=()=>{var qn;const Sn=Kr.mimeType||Br||((qn=f.current[0])==null?void 0:qn.type)||"video/webm",ai=new Blob(f.current,{type:Sn});me(ai);const as=URL.createObjectURL(ai);he(as)},i.current=Kr,Kr.start(100),ce(!0),y.current=setInterval(()=>{je(Sn=>Sn>=t-1?(js(),t):Sn+1)},1e3)},[ds,t,js,ut,He,S,Nt]),Lt=k.useCallback(()=>{Te.current&&(clearInterval(Te.current),Te.current=null),tt(3);let nr=3;Te.current=setInterval(()=>{nr-=1,nr<=0?(Te.current&&clearInterval(Te.current),Te.current=null,tt(null),lr()):tt(nr)},1e3)},[lr]),Es=k.useCallback(()=>{i.current&&i.current.state==="recording"&&(i.current.pause(),ae(!0),y.current&&clearInterval(y.current))},[]),fr=k.useCallback(()=>{i.current&&i.current.state==="paused"&&(i.current.resume(),ae(!1),y.current=setInterval(()=>{je(nr=>nr>=t-1?(js(),t):nr+1)},1e3))},[t,js]),Hs=k.useCallback(()=>{ve&&URL.revokeObjectURL(ve),me(null),he(null),je(0),Ne(!1),Ie(!0),l.current&&d.current&&!ut&&(l.current.srcObject=d.current,l.current.muted=!0,ds())},[ds,ve,ut]),mr=k.useCallback(()=>{Me(nr=>nr==="user"?"environment":"user")},[]),an=k.useCallback(()=>{oe&&s(oe,ge)},[oe,ge,s]),Cr=k.useCallback(()=>{l.current&&ve&&(Ve?l.current.pause():(Ie(!1),l.current.muted=!1,l.current.play()),Ne(!Ve))},[ve,Ve]);k.useEffect(()=>{if(!ve)return;const nr=l.current;if(!nr)return;Ie(!1),nr.pause(),nr.removeAttribute("src"),nr.srcObject=null,nr.load(),nr.src=ve,nr.currentTime=0,nr.playsInline=!0,nr.muted=!1,nr.onended=()=>Ne(!1);const cr=()=>{var Sn;const Br=nr.error,Kr=Br?`Recorded video failed to play (code ${Br.code}). Likely unsupported format/codec in this browser.`:"Recorded video failed to play.";console.warn("[VideoRecorder] recorded playback error",Br),(Sn=et.current)==null||Sn.call(et,Kr)};return nr.addEventListener("error",cr),nr.load(),()=>{nr.removeEventListener("error",cr)}},[ve]);const Fr=nr=>{const cr=Math.floor(nr/60),Br=nr%60;return`${cr}:${Br.toString().padStart(2,"0")}`},$r=S==="screen"?"aspect-video":w&&q?"aspect-[9/16]":"aspect-video";return U?e.jsx("div",{className:Ot("flex items-center justify-center bg-black rounded-lg",$r,a),children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(us,{className:"h-12 w-12 animate-spin mx-auto mb-4"}),e.jsx("p",{children:"Initializing camera..."})]})}):Y===!1?e.jsx("div",{className:Ot("flex items-center justify-center bg-black rounded-lg",$r,a),children:e.jsxs("div",{className:"text-center text-white p-8 max-w-md",children:[e.jsx(ro,{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:ye||"Please allow camera and microphone access to record videos."}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(W,{onClick:()=>es(),variant:"secondary",className:"w-full",children:[e.jsx(Zi,{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:Ot("flex flex-col gap-2",a),children:[!X&&!ve&&e.jsxs("div",{className:"flex items-center justify-center gap-1 p-1 bg-muted rounded-lg",children:[e.jsxs(W,{variant:S==="camera"?"default":"ghost",size:"sm",className:"gap-1.5 flex-1",onClick:()=>C("camera"),children:[e.jsx(xx,{className:"h-4 w-4"}),"Camera"]}),e.jsxs(W,{variant:S==="screen"?"default":"ghost",size:"sm",className:"gap-1.5 flex-1",onClick:()=>C("screen"),children:[e.jsx(uS,{className:"h-4 w-4"}),"Screen"]})]}),S==="camera"&&!X&&!ve&&e.jsx(x2s,{value:We,onChange:Ke,isLoading:Je,disabled:X}),S==="camera"&&w&&!X&&!ve&&e.jsxs("div",{className:"flex items-center justify-center gap-3 py-2 bg-muted/50 rounded-lg",children:[e.jsx(hS,{className:Ot("h-4 w-4",q?"text-muted-foreground":"text-primary")}),e.jsx(xe,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Landscape"}),e.jsx(Ar,{id:"orientation-toggle",checked:q,onCheckedChange:Ze}),e.jsx(xe,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Portrait"}),e.jsx(Ig,{className:Ot("h-4 w-4",q?"text-primary":"text-muted-foreground")})]}),S==="screen"&&!X&&!ve&&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(uS,{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:Ot("relative bg-black rounded-lg overflow-hidden"),onPointerDown:()=>{ds()},children:[e.jsx("video",{ref:l,src:ve??void 0,className:Ot("w-full bg-black",q&&!ve?"object-contain":"object-cover",$r,!ve&&qe==="user"!==(We.mirror??!1)&&"scale-x-[-1]",ut&&!ve&&"hidden"),playsInline:!0,controls:!!ve,muted:ve?Ue:!0,autoPlay:!ve},ve??"live"),ut&&!ve&&e.jsx("canvas",{ref:ot,className:Ot("w-full bg-black",q?"object-contain":"object-cover",$r,qe==="user"!==(We.mirror??!1)&&"scale-x-[-1]")}),ut&&Je&&!ve&&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(us,{className:"h-8 w-8 animate-spin mx-auto mb-2"}),e.jsx("p",{className:"text-sm",children:"Loading virtual background…"})]})}),!ve&&fe&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40",children:e.jsx(W,{type:"button",variant:"secondary",onClick:()=>void ds(),className:"bg-white/20 hover:bg-white/30 text-white",children:"Tap to enable preview"})}),o&&!ve&&e.jsx("div",{className:"absolute inset-0 pointer-events-none",children:o}),Ye!==null&&!ve&&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:Ye},Ye),e.jsx("p",{className:"text-white/80 text-lg font-medium drop-shadow-md",children:"Get ready…"})]})}),X&&e.jsxs("div",{className:"absolute top-4 left-4 flex items-center gap-2 bg-black/50 px-3 py-1.5 rounded-full",children:[e.jsx("div",{className:Ot("w-3 h-3 rounded-full",ie?"bg-yellow-500":"bg-red-500 animate-pulse")}),e.jsxs("span",{className:"text-white text-sm font-medium",children:[Fr(ge)," / ",Fr(t)]})]}),X&&e.jsx("div",{className:"absolute top-0 left-0 right-0",children:e.jsx(xi,{value:ge/t*100,className:"h-1 rounded-none"})}),!ve&&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(CL,{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:`${ke}%`}})})]}),e.jsx("div",{className:"absolute bottom-4 left-0 right-0 flex justify-center gap-3 px-4",children:ve?e.jsxs(e.Fragment,{children:[e.jsxs(W,{variant:"secondary",size:"lg",className:"bg-white/20 hover:bg-white/30 text-white",onClick:Hs,children:[e.jsx(Zi,{className:"h-5 w-5 mr-2"}),"Re-record"]}),e.jsx(W,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:Cr,children:Ve?e.jsx(hh,{className:"h-5 w-5"}):e.jsx(Co,{className:"h-5 w-5"})}),e.jsxs(W,{size:"lg",className:"bg-green-500 hover:bg-green-600 text-white",onClick:an,children:[e.jsx(Zn,{className:"h-5 w-5 mr-2"}),"Use This Video"]})]}):e.jsxs(e.Fragment,{children:[S==="camera"?e.jsx(W,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:mr,disabled:X||Ye!==null,children:e.jsx(t0,{className:"h-5 w-5"})}):e.jsx("div",{className:"h-12 w-12"}),!X&&Ye===null?e.jsx(W,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:S==="screen"?lr:Lt,children:S==="screen"?e.jsx(uS,{className:"h-6 w-6"}):e.jsx(yn,{className:"h-6 w-6"})}):e.jsxs(e.Fragment,{children:[e.jsx(W,{size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:ie?fr:Es,children:ie?e.jsx(Co,{className:"h-5 w-5"}):e.jsx(hh,{className:"h-5 w-5"})}),e.jsx(W,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:js,children:e.jsx(r0,{className:"h-6 w-6 fill-current"})})]}),e.jsx("div",{className:"h-12 w-12"})]})})]})]})}const wlt="teleprompter_settings",_0e={scrollSpeed:30,fontSize:24,lineHeight:1.6,opacity:.85,position:"top",isMirrored:!1};function nNs(){try{const t=localStorage.getItem(wlt);return t?{..._0e,...JSON.parse(t)}:_0e}catch{return _0e}}function aNs(t){try{localStorage.setItem(wlt,JSON.stringify(t))}catch{}}function jlt({text:t,isVisible:s,onToggleVisibility:r,isRecording:n=!1,startCountdown:a=!1,onCountdownComplete:o,className:l}){const i=k.useRef(null),d=k.useRef(null),u=k.useRef(0),p=k.useRef(0),[f,y]=k.useState(nNs),{scrollSpeed:_,fontSize:b,lineHeight:N,opacity:w,position:S,isMirrored:C}=f,A=k.useCallback((Y,J)=>{y(X=>{const ce={...X,[Y]:J};return aNs(ce),ce})},[]),[I,L]=k.useState(!1),[O,V]=k.useState(null),q=k.useCallback(Y=>{if(!i.current)return;u.current===0&&(u.current=Y);const J=Y-u.current;u.current=Y,p.current+=_*J/1e3;const X=Math.floor(p.current);X>0&&(i.current.scrollTop+=X,p.current-=X);const{scrollTop:ce,scrollHeight:ie,clientHeight:ae}=i.current;if(ce+ae>=ie){L(!1);return}d.current=requestAnimationFrame(q)},[_]);k.useEffect(()=>(I?(u.current=0,p.current=0,d.current=requestAnimationFrame(q)):d.current&&cancelAnimationFrame(d.current),()=>{d.current&&cancelAnimationFrame(d.current)}),[I,q]),k.useEffect(()=>{if(n&&s)if(i.current&&(i.current.scrollTop=0),a){V(3);let Y=3;const J=setInterval(()=>{Y-=1,Y<=0?(clearInterval(J),V(null),o==null||o(),L(!0)):V(Y)},1e3);return()=>clearInterval(J)}else setTimeout(()=>L(!0),100);else n||(L(!1),V(null))},[n,s,a,o]);const B=k.useCallback(()=>{i.current&&(i.current.scrollTop=0),L(!1)},[]),U=k.useCallback(()=>{L(Y=>!Y)},[]);if(!s)return e.jsx("div",{className:Ot("absolute top-4 right-4 pointer-events-auto z-10",l),children:e.jsxs(W,{variant:"secondary",size:"sm",onClick:r,className:"bg-black/50 hover:bg-black/70 text-white border-0",children:[e.jsx(jn,{className:"h-4 w-4 mr-2"}),"Show Script"]})});const te={top:"top-0 pt-16",center:"top-1/2 -translate-y-1/2",bottom:"bottom-0 pb-24"};return e.jsxs("div",{className:Ot("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:Ot("absolute left-0 right-0 h-[60%] overflow-hidden pointer-events-auto",te[S],O!==null&&"opacity-30"),style:{opacity:O!==null?.3:w},children:e.jsxs("div",{ref:i,className:Ot("mx-auto max-w-2xl px-6 overflow-y-auto scrollbar-hide h-full",C&&"scale-x-[-1]"),style:{maskImage:"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)",WebkitMaskImage:"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)"},children:[e.jsx("div",{className:"h-full",style:{minHeight:"100%"}}),e.jsx("p",{className:"text-white text-center font-medium drop-shadow-lg",style:{fontSize:`${b}px`,lineHeight:N,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(mo,{children:[e.jsx(po,{asChild:!0,children:e.jsx(W,{variant:"secondary",size:"icon",className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:e.jsx(So,{className:"h-4 w-4"})})}),e.jsx(no,{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(xe,{className:"text-xs",children:"Scroll Speed"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:_})]}),e.jsx(Cg,{value:[_],onValueChange:([Y])=>A("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(xe,{className:"text-xs",children:"Font Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[b,"px"]})]}),e.jsx(Cg,{value:[b],onValueChange:([Y])=>A("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(xe,{className:"text-xs",children:"Line Spacing"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:N.toFixed(1)})]}),e.jsx(Cg,{value:[N*10],onValueChange:([Y])=>A("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(xe,{className:"text-xs",children:"Opacity"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Math.round(w*100),"%"]})]}),e.jsx(Cg,{value:[w*100],onValueChange:([Y])=>A("opacity",Y/100),min:30,max:100,step:5})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{className:"text-xs",children:"Position"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(W,{variant:S==="top"?"default":"outline",size:"sm",onClick:()=>A("position","top"),children:e.jsx(af,{className:"h-4 w-4"})}),e.jsx(W,{variant:S==="center"?"default":"outline",size:"sm",onClick:()=>A("position","center"),children:e.jsx(Qy,{className:"h-4 w-4"})}),e.jsx(W,{variant:S==="bottom"?"default":"outline",size:"sm",onClick:()=>A("position","bottom"),children:e.jsx(Bi,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{className:"text-xs",children:"Mirror Mode"}),e.jsx(Ar,{checked:C,onCheckedChange:Y=>A("isMirrored",Y)})]})]})})]}),e.jsx(W,{variant:"secondary",size:"icon",onClick:U,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:I?e.jsx(hh,{className:"h-4 w-4"}):e.jsx(Co,{className:"h-4 w-4"})}),e.jsx(W,{variant:"secondary",size:"icon",onClick:B,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:e.jsx(t0,{className:"h-4 w-4"})}),e.jsxs(W,{variant:"secondary",size:"sm",onClick:r,className:"bg-black/50 hover:bg-black/70 text-white border-0",children:[e.jsx(pp,{className:"h-4 w-4 mr-2"}),"Hide"]})]})]})}function iNs({onSelectScript:t,onCreateNew:s,selectedScriptId:r,className:n}){const{toast:a}=ja(),[o,l]=k.useState(""),[i,d]=k.useState(null),[u,p]=k.useState("levelup"),{data:f,isLoading:y}=Ibs(),{data:_,isLoading:b}=Lbs(),{data:N,isLoading:w}=Dbs(),S=Rbs(),C=k.useMemo(()=>_?_.filter(V=>{const q=!o||V.title.toLowerCase().includes(o.toLowerCase())||V.script_text.toLowerCase().includes(o.toLowerCase())||V.tags.some(U=>U.toLowerCase().includes(o.toLowerCase())),B=!i||V.category_id===i;return q&&B}):[],[_,o,i]),A=k.useMemo(()=>N?N.filter(V=>!o||V.title.toLowerCase().includes(o.toLowerCase())||V.script_text.toLowerCase().includes(o.toLowerCase())):[],[N,o]),I=V=>{t({title:V.title,text:V.script_text})},L=async V=>{try{await S.mutateAsync(V),a({title:"Script saved to My Scripts"})}catch{a({title:"Failed to save script",variant:"destructive"})}},O=y||b||w;return e.jsxs("div",{className:Ot("flex flex-col h-full",n),children:[e.jsx("div",{className:"p-4 border-b",children:e.jsxs("div",{className:"relative",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search scripts...",value:o,onChange:V=>l(V.target.value),className:"pl-9"})]})}),e.jsxs(ta,{value:u,onValueChange:V=>p(V),className:"flex-1 flex flex-col",children:[e.jsxs(Jn,{className:"mx-4 mt-4 grid grid-cols-2",children:[e.jsxs(cs,{value:"levelup",children:[e.jsx(vn,{className:"h-4 w-4 mr-2"}),"LevelUp Scripts"]}),e.jsxs(cs,{value:"my-scripts",children:[e.jsx(fx,{className:"h-4 w-4 mr-2"}),"My Scripts"]})]}),e.jsxs(Ss,{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(Qe,{variant:i?"outline":"default",className:"cursor-pointer",onClick:()=>d(null),children:"All"}),f==null?void 0:f.map(V=>e.jsx(Qe,{variant:i===V.id?"default":"outline",className:"cursor-pointer",onClick:()=>d(V.id),children:V.name},V.id))]}),e.jsx(Ja,{className:"flex-1 max-h-[50vh]",children:O?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(us,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):C.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(vn,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No scripts found"})]}):e.jsx("div",{className:"space-y-2",children:C.map(V=>e.jsxs(Pe,{className:Ot("cursor-pointer hover:bg-accent/50 transition-colors",r===V.id&&"ring-2 ring-primary"),onClick:()=>I(V),children:[e.jsx(Dt,{className:"p-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(zt,{className:"text-sm font-medium truncate",children:V.title}),V.category&&e.jsx(Qe,{variant:"secondary",className:"mt-1 text-xs",children:V.category.name})]}),e.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:q=>{q.stopPropagation(),L(V)},children:e.jsx(fx,{className:"h-4 w-4"})}),e.jsx(xa,{className:"h-4 w-4 text-muted-foreground"})]})]})}),e.jsx(Oe,{className:"p-3 pt-0",children:e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:V.script_text})})]},V.id))})})]}),e.jsxs(Ss,{value:"my-scripts",className:"flex-1 flex flex-col mt-0 p-4",children:[s&&e.jsxs(W,{variant:"outline",className:"mb-4",onClick:s,children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create New Script"]}),e.jsx(Ja,{className:"flex-1 max-h-[50vh]",children:w?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(us,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):A.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(fx,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No saved scripts"}),e.jsx("p",{className:"text-sm mt-1",children:"Save LevelUp scripts or create your own"})]}):e.jsx("div",{className:"space-y-2",children:A.map(V=>e.jsxs(Pe,{className:Ot("cursor-pointer hover:bg-accent/50 transition-colors",r===V.id&&"ring-2 ring-primary"),onClick:()=>I(V),children:[e.jsx(Dt,{className:"p-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(zt,{className:"text-sm font-medium truncate",children:V.title}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:V.is_custom?e.jsx(Qe,{variant:"outline",className:"text-xs",children:"Custom"}):e.jsx(Qe,{variant:"secondary",className:"text-xs",children:"Saved"})})]}),e.jsx(xa,{className:"h-4 w-4 text-muted-foreground ml-2"})]})}),e.jsx(Oe,{className:"p-3 pt-0",children:e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:V.script_text})})]},V.id))})})]})]})]})}function oNs({selectedTemplate:t,onSelect:s,contactName:r,saving:n=!1}){const[a,o]=k.useState(()=>{const i=GM(t);return new Set([i.category])}),l=i=>{o(d=>{const u=new Set(d);return u.has(i)?u.delete(i):u.add(i),u})};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"text-sm font-medium",children:"Share Page Template"}),n&&e.jsx(us,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),e.jsx("div",{className:"space-y-3",children:YIt.map(i=>{const d=XIt(i.id),u=a.has(i.id),p=d.some(f=>f.id===t);return e.jsxs(lf,{open:u,onOpenChange:()=>l(i.id),children:[e.jsxs(cf,{className:"flex items-center justify-between w-full p-2.5 rounded-lg bg-muted/50 hover:bg-muted transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:i.name}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",d.length,")"]}),p&&!u&&e.jsx("span",{className:"text-xs bg-primary/10 text-primary px-1.5 py-0.5 rounded-full",children:"✓"})]}),e.jsx(Bi,{className:Ot("h-4 w-4 text-muted-foreground transition-transform",u&&"rotate-180")})]}),e.jsx(df,{className:"pt-2",children:e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:d.map(f=>{const y=t===f.id;return e.jsxs("button",{type:"button",onClick:()=>s(f.id),disabled:n,className:Ot("relative rounded-lg border-2 p-2.5 text-left transition-all hover:shadow-sm disabled:opacity-50 disabled:cursor-not-allowed",y?"border-primary ring-1 ring-primary/20 bg-primary/5":"border-muted hover:border-muted-foreground/30"),children:[y&&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(Zn,{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: "',GM(t).headerText(r),'"']})]})}function Nlt({open:t,onOpenChange:s,video:r,contactName:n,onTemplateUpdated:a}){const[o,l]=k.useState(r.page_template||"default"),[i,d]=k.useState(!1),[u,p]=k.useState(!1),[f,y]=k.useState(r.page_template||"default"),[_,b]=k.useState([]),[N,w]=k.useState(r.contact_id&&n?{id:r.contact_id,name:n,email:null}:null),[S,C]=k.useState(!1),[A,I]=k.useState(!1),L=r.share_token?`https://video.relevelup.com/${r.share_token}`:"";k.useEffect(()=>{t&&_.length===0&&O()},[t]);const O=async()=>{I(!0);try{const{data:ce,error:ie}=await G.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(ie)throw ie;const ae=(ce||[]).map(oe=>({id:oe.id,name:[oe.first_name,oe.last_name].filter(Boolean).join(" ")||"Unnamed",email:oe.email||null}));b(ae)}catch(ce){console.error("Failed to fetch contacts:",ce)}finally{I(!1)}},V=async ce=>{w(ce),C(!1),d(!0);try{const{error:ie}=await G.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(ie)throw ie;pe.success(ce?`Assigned to ${ce.name}`:"Contact removed"),a==null||a()}catch(ie){console.error("Failed to update contact:",ie),pe.error("Failed to update contact")}finally{d(!1)}},q=async ce=>{l(ce),d(!0);try{const{error:ie}=await G.from("agent_videos").update({page_template:ce}).eq("id",r.id);if(ie)throw ie;y(ce),pe.success("Template saved!"),a==null||a()}catch(ie){console.error("Failed to save template:",ie),pe.error("Failed to save template"),l(f)}finally{d(!1)}},B=(N==null?void 0:N.name)||null,U=()=>{const ce=r.title||"Video Message",ie=r.share_token?`https://video.relevelup.com/thumb/${r.share_token}`:r.thumbnail_url||"";return``},te=async()=>{if(!r.thumbnail_url){pe.error("Video thumbnail not available yet");return}const ce=U(),ie=`Watch: ${r.title||"Video Message"} ${L}`;try{const ae=new Blob([ce],{type:"text/html"}),oe=new Blob([ie],{type:"text/plain"}),me=new ClipboardItem({"text/html":ae,"text/plain":oe});await navigator.clipboard.write([me]),pe.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(ie+` `+ce),pe.success("Copied! Paste into your email.")}},Y=async()=>{await navigator.clipboard.writeText(L),p(!0),pe.success("Share link copied!"),setTimeout(()=>p(!1),2e3)},J=()=>{const ie=GM(o).headerText(B),ae=o==="default"?`Check out this video: ${L}`:`${ie} Check out this special video: ${L}`;window.open(`sms:?body=${encodeURIComponent(ae)}`,"_self")},X=()=>{const ce=GM(o),ie=ce.headerText(B),ae=o==="default"?r.title||"Video Message":ie,oe=`${ce.subText} Watch the video: ${L}`,me=N!=null&&N.email?encodeURIComponent(N.email):"";window.open(`mailto:${me}?subject=${encodeURIComponent(ae)}&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(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(vo,{className:"h-5 w-5"}),"Share Video"]}),e.jsx(Ir,{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(xe,{className:"text-sm font-medium",children:"Personalize for Contact (Optional)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(mo,{open:S,onOpenChange:C,children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{variant:"outline",role:"combobox","aria-expanded":S,className:"flex-1 justify-between",disabled:i,children:[N?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Ai,{className:"h-4 w-4 text-muted-foreground"}),N.name]}):e.jsx("span",{className:"text-muted-foreground",children:"Select a contact..."}),e.jsx(gx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(no,{className:"w-[300px] p-0",align:"start",children:e.jsxs(Sx,{children:[e.jsx(Cx,{placeholder:"Search contacts..."}),e.jsxs(Mx,{children:[e.jsx(Tx,{children:A?"Loading...":"No contacts found."}),e.jsx(Ax,{children:_.map(ce=>e.jsxs(cp,{value:ce.name,onSelect:()=>V(ce),children:[e.jsx(Zn,{className:Ot("mr-2 h-4 w-4",(N==null?void 0:N.id)===ce.id?"opacity-100":"opacity-0")}),ce.name]},ce.id))})]})]})})]}),N&&e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>V(null),disabled:i,className:"shrink-0",children:e.jsx(kr,{className:"h-4 w-4"})})]}),N&&o!=="default"&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:['Page will show: "',GM(o).headerText(N.name),'"']})]}),e.jsx(oNs,{selectedTemplate:o,onSelect:q,contactName:B,saving:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Share Link"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{value:L,readOnly:!0,className:"font-mono text-sm"}),e.jsx(W,{onClick:Y,variant:u?"default":"outline",className:"shrink-0 gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(Zn,{className:"h-4 w-4"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(Va,{className:"h-4 w-4"}),"Copy"]})})]})]}),r.thumbnail_url&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Share for Email"}),e.jsxs(W,{variant:"outline",className:"w-full gap-2",onClick:te,children:[e.jsx(qo,{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(xe,{children:"Quick Share"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(W,{variant:"outline",className:"flex-1 gap-2",onClick:J,children:[e.jsx(wi,{className:"h-4 w-4"}),"Text"]}),e.jsxs(W,{variant:"outline",className:"flex-1 gap-2",onClick:X,children:[e.jsx(tr,{className:"h-4 w-4"}),"Email"]})]})]})]}),e.jsx(gn,{children:e.jsx(W,{variant:"outline",onClick:()=>s(!1),children:"Done"})})]})})}function lNs(){var Te;const t=wr(),[s]=Nc(),{toast:r}=ja(),n=s.get("contact_id"),a=s.get("task_id"),{canRecord:o,remainingMb:l,usagePercent:i,isNearLimit:d,storage:u}=ait(),{data:p}=qh(),f=Mw(),y=$bs(),[_,b]=k.useState("record"),[N,w]=k.useState(""),[S,C]=k.useState(!1),[A,I]=k.useState(!1),[L,O]=k.useState(!1),[V,q]=k.useState(null),[B,U]=k.useState(0),[te,Y]=k.useState(0),[J,X]=k.useState(null),[ce,ie]=k.useState(null),[ae,oe]=k.useState(n||""),[me,ve]=k.useState(""),[he,ge]=k.useState(""),[je,qe]=k.useState(null),[Me,ke]=k.useState(null),[Re,Ve]=k.useState(null),[Ne,Ue]=k.useState(!1),Ie=k.useCallback(async(We,Ke)=>{q(We),b("uploading");try{const{videoId:ot,uploadUrl:He}=await wE(me||"Quick Video Touch");X(ot);const{apiKey:Je}=await jE(ot),ut=new XMLHttpRequest;ut.upload.onprogress=kt=>{kt.lengthComputable&&U(kt.loaded/kt.total*100)},await new Promise((kt,Ut)=>{ut.onload=()=>{ut.status>=200&&ut.status<300?kt():Ut(new Error(`Upload failed: ${ut.status}`))},ut.onerror=()=>Ut(new Error("Upload failed")),ut.open("PUT",He),ut.setRequestHeader("AccessKey",Je),ut.send(We)}),b("processing");let mt=0;const et=Date.now(),Ze=90*1e3;for(;mt<4;){if(await new Promise(Ut=>setTimeout(Ut,3e3)),Date.now()-et>Ze){const Ut=We.size/1048576,Nt=`https://iframe.mediadelivery.net/play/${ot}/${ot}`;await f.mutateAsync({bunny_video_id:ot,playback_url:Nt,file_size_mb:Ut,title:me||"Quick Video Touch",notes:he||void 0,contact_id:ae&&ae!=="none"?ae: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 kt=await nw(ot);if(mt=kt.status,Y(kt.encodeProgress||0),mt===4)ie({playbackUrl:kt.directPlayUrl,thumbnailUrl:kt.thumbnailUrl,previewUrl:kt.previewUrl||null,duration:kt.length||Ke,fileSizeMb:(kt.storageSize||We.size)/(1024*1024)});else if(mt===5||mt===6)throw new Error("Video processing failed")}b("details")}catch(ot){console.error("Upload error:",ot),r({title:"Upload failed",description:"Please try recording again.",variant:"destructive"}),b("record")}},[me,r]),ye=async()=>{if(!(!J||!ce))try{const We=ae&&ae!=="none"?ae:null,Ke=await f.mutateAsync({bunny_video_id:J,contact_id:We,playback_url:ce.playbackUrl,thumbnail_url:ce.thumbnailUrl,preview_url:ce.previewUrl,duration_seconds:ce.duration,file_size_mb:ce.fileSizeMb,title:me||"Quick Video Touch",notes:he,task_id:a||null,status:"ready"});qe(Ke.id),ke(Ke.share_token||null),We&&await y.mutateAsync({contactId:We,videoId:Ke.id,notes:he}),r({title:"Video saved successfully!"}),b("share")}catch(We){console.error("Save video error:",We),r({title:"Failed to save video",description:(We==null?void 0:We.message)||"Please try again.",variant:"destructive"})}},ct=(We,Ke)=>{navigator.clipboard.writeText(Ke),Ve(We),setTimeout(()=>Ve(null),2e3),r({title:"Copied to clipboard!"})},fe=()=>Me?`https://video.relevelup.com/${Me}`:(ce==null?void 0:ce.playbackUrl)||"",$e=()=>{const We=p==null?void 0:p.find(ut=>ut.id===ae),Ke=We?`${We.first_name}`:"",ot=(We==null?void 0:We.phone)||"",He=(We==null?void 0:We.email)||"",Je=fe();return{text:`Hey${Ke?` ${Ke}`:""}! I recorded a quick video for you: ${Je}`,link:Je,contactPhone:ot,contactEmail:He}},Ye=()=>{const{text:We,contactPhone:Ke}=$e(),ot=Ke?`sms:${Ke}?body=${encodeURIComponent(We)}`:`sms:?body=${encodeURIComponent(We)}`;window.open(ot,"_self")},tt=()=>{const{link:We,contactEmail:Ke}=$e(),ot="Check out this video",He=`I recorded a quick video for you: ${We}`,Je=Ke?`mailto:${Ke}?subject=${encodeURIComponent(ot)}&body=${encodeURIComponent(He)}`:`mailto:?subject=${encodeURIComponent(ot)}&body=${encodeURIComponent(He)}`;window.open(Je,"_self")};return o?e.jsx(Ds,{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(W,{variant:"ghost",size:"icon",onClick:()=>t(-1),children:e.jsx(Oa,{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(W,{variant:"outline",size:"sm",onClick:()=>t("/mission-control/video-library"),className:"gap-1.5",children:[e.jsx(vn,{className:"h-4 w-4"}),"Video Library"]}),d&&e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm text-warning",children:["Storage: ",i.toFixed(0),"% used"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[l.toFixed(0)," MB remaining"]})]})]})]}),_==="record"&&e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2",children:[e.jsx(AO,{maxDurationSeconds:600,onRecordingComplete:Ie,onRecordingStateChange:O,className:"w-full",teleprompterContent:S&&N&&e.jsx(jlt,{text:N,isVisible:S,onToggleVisibility:()=>C(!1),isRecording:L,startCountdown:!1})}),!S&&N&&e.jsxs(W,{variant:"outline",className:"mt-4",onClick:()=>C(!0),children:[e.jsx(vn,{className:"h-4 w-4 mr-2"}),"Show Teleprompter"]})]}),e.jsxs(Pe,{className:"lg:col-span-1",children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-lg",children:"Teleprompter Script"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(_r,{placeholder:"Type or paste your script here...",value:N,onChange:We=>w(We.target.value),rows:6}),e.jsxs(ZA,{open:A,onOpenChange:I,children:[e.jsx(zNe,{asChild:!0,children:e.jsxs(W,{variant:"outline",className:"w-full",children:[e.jsx(vn,{className:"h-4 w-4 mr-2"}),"Browse Scripts"]})}),e.jsxs(SC,{side:"right",className:"w-[400px] sm:w-[540px] p-0",children:[e.jsx(YA,{className:"p-4 border-b",children:e.jsx(XA,{children:"Select a Script"})}),e.jsx(iNs,{onSelectScript:We=>{w(We.text),I(!1),C(!0)},className:"h-[calc(100vh-80px)]"})]})]}),N&&e.jsx(W,{className:"w-full",onClick:()=>C(!0),children:"Use Script"})]})]})]}),_==="uploading"&&e.jsx(Pe,{className:"max-w-md mx-auto",children:e.jsxs(Oe,{className:"pt-6 text-center",children:[e.jsx(Ra,{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(xi,{value:B,className:"mb-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[B.toFixed(0),"%"]})]})}),_==="processing"&&e.jsx(Pe,{className:"max-w-md mx-auto",children:e.jsxs(Oe,{className:"pt-6 text-center space-y-4",children:[e.jsx(us,{className:"h-12 w-12 mx-auto mb-4 text-primary animate-spin"}),e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Processing Video..."}),e.jsx(xi,{value:te,className:"mb-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[te.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.`})]})}),_==="details"&&e.jsxs(Pe,{className:"max-w-lg mx-auto",children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Video Details"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Title"}),e.jsx(De,{value:me,onChange:We=>ve(We.target.value),placeholder:"Quick Video Touch"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Attach to Contact (Optional)"}),e.jsxs($s,{value:ae,onValueChange:oe,children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"No contact - use anywhere"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"none",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(vo,{className:"h-4 w-4"}),"No contact - use anywhere"]})}),p==null?void 0:p.map(We=>e.jsx(vt,{value:We.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ai,{className:"h-4 w-4"}),We.first_name," ",We.last_name]})},We.id))]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Notes"}),e.jsx(_r,{value:he,onChange:We=>ge(We.target.value),placeholder:"Add notes about this video...",rows:3})]}),e.jsxs(W,{className:"w-full",onClick:ye,disabled:f.isPending,children:[f.isPending&&e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Video"]})]})]}),_==="share"&&e.jsxs(Pe,{className:"max-w-lg mx-auto",children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Zn,{className:"h-5 w-5 text-green-500"}),"Video Saved!"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Share your video with one click:"}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs(W,{variant:"outline",className:"justify-start",onClick:Ye,children:[e.jsx(wi,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),e.jsxs(W,{variant:"outline",className:"justify-start",onClick:tt,children:[e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(W,{variant:"outline",className:"justify-start",onClick:()=>ct("link",$e().link),children:[e.jsx(vo,{className:"h-4 w-4 mr-2"}),"Copy Video Link",Re==="link"&&e.jsx(Zn,{className:"h-4 w-4 ml-auto text-green-500"})]}),e.jsxs(W,{variant:"outline",className:"justify-start",onClick:()=>Ue(!0),children:[e.jsx(zl,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(W,{variant:"outline",onClick:()=>t("/mission-control/video-library"),children:"View Library"}),e.jsx(W,{onClick:()=>{b("record"),q(null),X(null),ie(null)},children:"Record Another"})]})]})]}),je&&Me&&e.jsx(Nlt,{open:Ne,onOpenChange:Ue,video:{id:je,share_token:Me,title:me||null,contact_id:ae||null,thumbnail_url:(ce==null?void 0:ce.thumbnailUrl)||null},contactName:((Te=p==null?void 0:p.find(We=>We.id===ae))==null?void 0:Te.first_name)||null})]})}):e.jsx(Ds,{title:"QuickVid",children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center py-12",children:[e.jsx(Dc,{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(W,{onClick:()=>t("/mission-control/video-library"),children:"Open Video Library"})]})})}function cNs({open:t,onOpenChange:s}){const{data:r}=qh(),{data:n}=Ame(),a=Mw(),o=k.useRef(null),[l,i]=k.useState(null),[d,u]=k.useState(""),[p,f]=k.useState(""),[y,_]=k.useState(""),[b,N]=k.useState(!1),[w,S]=k.useState(0),[C,A]=k.useState("idle"),I=(n==null?void 0:n.total_storage_mb)||0,O=((n==null?void 0:n.max_storage_mb)||1024)-I,V=te=>{var X;const Y=(X=te.target.files)==null?void 0:X[0];if(!Y)return;if(!Y.type.startsWith("video/")){pe.error("Please select a video file");return}const J=Y.size/(1024*1024);if(J>500){pe.error("Video file must be less than 500MB");return}if(J>O){pe.error(`Not enough storage. You have ${O.toFixed(1)} MB remaining.`);return}i(Y),d||u(Y.name.replace(/\.[^/.]+$/,""))},q=async()=>{if(!l){pe.error("Please select a video file");return}N(!0),S(0),A("creating");try{const{data:te,error:Y}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:d||l.name,isAgentVideo:!0}});if(Y)throw new Error(Y.message);const{videoId:J,libraryId:X}=te;A("uploading");const{data:ce,error:ie}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:J,isAgentVideo:!0}});if(ie)throw new Error(ie.message);await new Promise((me,ve)=>{const he=new XMLHttpRequest;he.upload.addEventListener("progress",ge=>{if(ge.lengthComputable){const je=Math.round(ge.loaded/ge.total*100);S(je)}}),he.addEventListener("load",()=>{he.status>=200&&he.status<300?me():ve(new Error(`Upload failed with status ${he.status}`))}),he.addEventListener("error",()=>ve(new Error("Upload failed"))),he.open("PUT",ce.uploadUrl),he.setRequestHeader("AccessKey",ce.apiKey),he.send(l)}),A("processing");const ae=l.size/(1024*1024),oe=`https://iframe.mediadelivery.net/embed/${X}/${J}`;await a.mutateAsync({bunny_video_id:J,playback_url:oe,file_size_mb:ae,title:d||l.name,notes:p||void 0,contact_id:y||void 0,status:"processing",touch_type:"video_upload"}),pe.success("Video uploaded successfully! Processing may take a few minutes."),B()}catch(te){console.error("Upload error:",te),pe.error(te instanceof Error?te.message:"Failed to upload video")}finally{N(!1),A("idle")}},B=()=>{b||(i(null),u(""),f(""),_(""),S(0),A("idle"),s(!1))},U=()=>{switch(C){case"creating":return"Preparing upload...";case"uploading":return`Uploading... ${w}%`;case"processing":return"Saving video...";default:return""}};return e.jsx(fs,{open:t,onOpenChange:B,children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Upload Video"}),e.jsx(Ir,{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(xe,{children:"Video File"}),l?e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg",children:[e.jsx(yn,{className:"h-8 w-8 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:l.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(l.size/(1024*1024)).toFixed(1)," MB"]})]}),!b&&e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:te=>{te.stopPropagation(),i(null)},children:e.jsx(kr,{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 te;return(te=o.current)==null?void 0:te.click()},children:[e.jsx(Ra,{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:V,disabled:b})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"title",children:"Title"}),e.jsx(De,{id:"title",value:d,onChange:te=>u(te.target.value),placeholder:"Enter video title",disabled:b})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Associate with Contact (optional)"}),e.jsxs($s,{value:y||"__none__",onValueChange:te=>_(te==="__none__"?"":te),disabled:b,children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select a contact"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"__none__",children:"No contact"}),r==null?void 0:r.map(te=>e.jsxs(vt,{value:te.id,children:[te.first_name," ",te.last_name||""]},te.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"notes",children:"Notes (optional)"}),e.jsx(_r,{id:"notes",value:p,onChange:te=>f(te.target.value),placeholder:"Add any notes about this video",rows:2,disabled:b})]}),b&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(us,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:U()})]}),e.jsx(xi,{value:C==="uploading"?w:C==="processing"?100:10})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:B,disabled:b,children:"Cancel"}),e.jsx(W,{onClick:q,disabled:!l||b,children:b?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"}),"Upload Video"]})})]})]})})}function dNs(t){return gt({queryKey:["video-share-recipients",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("video_share_recipients").select("*").eq("video_id",t).order("sent_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function uNs(){const{user:t}=Us();return gt({queryKey:["video-share-stats",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return null;const{data:s,error:r}=await G.from("video_share_recipients").select("*").eq("owner_user_id",t.id);if(r)throw r;const n=s;return{totalSent:n.length,totalOpened:n.filter(a=>a.opened_at).length,totalClicked:n.filter(a=>a.clicked_at).length,totalWatched:n.filter(a=>a.watched_at).length,openRate:n.length>0?Math.round(n.filter(a=>a.opened_at).length/n.length*100):0,clickRate:n.length>0?Math.round(n.filter(a=>a.clicked_at).length/n.length*100):0,watchRate:n.length>0?Math.round(n.filter(a=>a.watched_at).length/n.length*100):0}},enabled:!!(t!=null&&t.id)})}function hNs(){const{user:t}=Us();return gt({queryKey:["video-share-history",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:s,error:r}=await G.from("video_share_recipients").select(` *, agent_videos!inner(id, title, thumbnail_url, share_token, duration_seconds) `).eq("owner_user_id",t.id).order("sent_at",{ascending:!1}).limit(200);if(r)throw r;return s},enabled:!!(t!=null&&t.id)})}function mNs(){const{user:t}=Us(),s=Qt();return Pt({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await G.from("video_share_recipients").insert([{video_id:r.video_id,owner_user_id:t.id,recipient_email:r.recipient_email,recipient_name:r.recipient_name||null,contact_id:r.contact_id||null,sent_via:r.sent_via||"gmail",share_token:"placeholder"}]).select().single();if(a)throw a;return n},onSuccess:r=>{s.invalidateQueries({queryKey:["video-share-recipients",r.video_id]}),s.invalidateQueries({queryKey:["video-share-stats"]}),s.invalidateQueries({queryKey:["video-share-history"]})}})}function pNs(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=open`}function fNs(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=click`}function xNs({open:t,onOpenChange:s,video:r,gmailEmail:n,signedThumbnailUrl:a,onSendComplete:o}){const[l,i]=k.useState([]),[d,u]=k.useState(null),[p,f]=k.useState(!1),[y,_]=k.useState(!1),[b,N]=k.useState(""),[w,S]=k.useState(""),[C,A]=k.useState(""),[I,L]=k.useState(!1),O=mNs(),V=r.share_token?`https://video.relevelup.com/share/video/${r.share_token}`:"",q=r.share_token?`https://video.relevelup.com/thumb/${r.share_token}`:a||r.thumbnail_url||"",B=r.title||"Video Message";k.useEffect(()=>{t&&l.length===0&&U()},[t]),k.useEffect(()=>{if(t&&(S(`I recorded a video for you — ${B}`),A("Hey! I recorded a quick video just for you. Click below to watch it:"),u(null),N(""),r.contact_id)){const ie=l.find(ae=>ae.id===r.contact_id);ie&&(u(ie),N(ie.email||""))}},[t,r.contact_id,l]);const U=async()=>{_(!0);try{const{data:ie,error:ae}=await G.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(ae)throw ae;i(ie||[])}catch{console.error("Failed to fetch contacts")}finally{_(!1)}},te=ie=>{u(ie),f(!1),N(ie.email||""),A(`Hey ${ie.first_name}! I recorded a quick video just for you. Click below to watch it:`),S(`I recorded a video for you — ${B}`)},Y=()=>{u(null),N(""),A("Hey! I recorded a quick video just for you. Click below to watch it:")},J=ie=>`${ie.first_name} ${ie.last_name||""}`.trim(),X=ie=>{const ae=C.split(/\n\n+/).map(ve=>`

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

`).join(""),oe=ie?fNs(ie):V,me=ie?``:"";return`
${ae}

▶ Watch Video

${me}
`},ce=async()=>{if(!b){pe.error("Please enter a recipient email");return}if(!V){pe.error("Video does not have a share link");return}L(!0);try{let ie;try{const ve=d?J(d):b.split("@")[0];ie=(await O.mutateAsync({video_id:r.id,recipient_email:b,recipient_name:ve,contact_id:(d==null?void 0:d.id)||null,sent_via:"gmail"})).share_token}catch(ve){console.warn("Failed to create tracking record, sending without tracking:",ve)}const ae=X(ie),{data:oe,error:me}=await G.functions.invoke("gmail-send",{body:{to:b,subject:w,body:ae,contactId:(d==null?void 0:d.id)||null}});if(me)throw me;if(!(oe!=null&&oe.success))throw new Error((oe==null?void 0:oe.error)||"Failed to send");pe.success("Video email sent!"),s(!1),o==null||o()}catch(ie){console.error("Gmail send error:",ie),pe.error("Failed to send: "+(ie instanceof Error?ie.message:"Unknown error"))}finally{L(!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(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(tr,{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(xe,{children:"Send to Contact"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(mo,{open:p,onOpenChange:f,children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{variant:"outline",role:"combobox",className:"flex-1 justify-between",children:[d?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Ai,{className:"h-4 w-4 text-muted-foreground"}),J(d),d.email&&e.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",d.email,")"]})]}):e.jsx("span",{className:"text-muted-foreground",children:"Select a contact..."}),e.jsx(gx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(no,{className:"w-[350px] p-0",align:"start",children:e.jsxs(Sx,{children:[e.jsx(Cx,{placeholder:"Search contacts..."}),e.jsxs(Mx,{children:[e.jsx(Tx,{children:y?"Loading...":"No contacts found."}),e.jsx(Ax,{children:l.filter(ie=>ie.email).map(ie=>e.jsxs(cp,{value:`${ie.first_name} ${ie.last_name||""} ${ie.email||""}`,onSelect:()=>te(ie),children:[e.jsx(Zn,{className:Ot("mr-2 h-4 w-4",(d==null?void 0:d.id)===ie.id?"opacity-100":"opacity-0")}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:J(ie)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ie.email})]})]},ie.id))})]})]})})]}),d&&e.jsx(W,{variant:"ghost",size:"icon",onClick:Y,className:"shrink-0",children:e.jsx(kr,{className:"h-4 w-4"})})]})]}),!d&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{htmlFor:"video-to",children:"Or type email address"}),e.jsx(De,{id:"video-to",value:b,onChange:ie=>N(ie.target.value),placeholder:"recipient@example.com",type:"email"})]}),e.jsx(ho,{}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{htmlFor:"video-subject",children:"Subject"}),e.jsx(De,{id:"video-subject",value:w,onChange:ie=>S(ie.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{htmlFor:"video-message",children:"Personal Message"}),e.jsx(_r,{id:"video-message",value:C,onChange:ie=>A(ie.target.value),rows:4,className:"resize-y"})]}),e.jsxs("div",{className:"rounded-lg border bg-muted/30 p-3 space-y-2",children:[e.jsx(xe,{className:"text-xs text-muted-foreground",children:"Video Preview (embedded in email)"}),e.jsxs("div",{className:"relative rounded-lg overflow-hidden bg-black",style:{maxWidth:320},children:[q?e.jsx("img",{src:q,alt:B,className:"w-full aspect-video object-cover"}):e.jsx("div",{className:"w-full aspect-video flex items-center justify-center bg-muted",children:e.jsx(Co,{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(Co,{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(W,{variant:"outline",onClick:()=>s(!1),disabled:I,children:"Cancel"}),e.jsxs(W,{onClick:ce,disabled:I||!b||!w,className:"gap-2",children:[I?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(_n,{className:"h-4 w-4"}),I?"Sending...":"Send Video Email"]})]})]})]})})}const gNs=()=>{const{user:t}=Us();return gt({queryKey:["team-videos",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.rpc("get_team_videos",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})};function yNs({recipient:t}){return t.watched_at?e.jsxs(Qe,{className:"bg-emerald-100 text-emerald-800 text-[10px]",children:[e.jsx(Co,{className:"h-2.5 w-2.5 mr-0.5"}),"Watched"]}):t.clicked_at?e.jsxs(Qe,{className:"bg-blue-100 text-blue-800 text-[10px]",children:[e.jsx(au,{className:"h-2.5 w-2.5 mr-0.5"}),"Clicked"]}):t.opened_at?e.jsxs(Qe,{className:"bg-amber-100 text-amber-800 text-[10px]",children:[e.jsx(jn,{className:"h-2.5 w-2.5 mr-0.5"}),"Opened"]}):e.jsxs(Qe,{variant:"outline",className:"text-[10px]",children:[e.jsx(_n,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]})}function vNs({open:t,onOpenChange:s,videoId:r,videoTitle:n}){const{data:a=[],isLoading:o}=dNs(r);return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-2xl max-h-[80vh]",children:[e.jsx(ks,{children:e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(so,{className:"h-5 w-5"}),"Send Analytics: ",n]})}),o?e.jsx("div",{className:"space-y-2",children:[...Array(3)].map((l,i)=>e.jsx(Ms,{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(Ja,{className:"h-[400px]",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Recipient"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Sent"}),e.jsx(St,{children:"Last Activity"})]})}),e.jsx(Rn,{children:a.map(l=>e.jsxs(Ps,{children:[e.jsx(ht,{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(ht,{children:e.jsx(yNs,{recipient:l})}),e.jsx(ht,{className:"text-xs text-muted-foreground",children:vs(new Date(l.sent_at),"MMM d, h:mm a")}),e.jsx(ht,{className:"text-xs text-muted-foreground",children:l.last_activity_at?Nl(new Date(l.last_activity_at),{addSuffix:!0}):"—"})]},l.id))})]})})]})]})})}function _Ns(){const{data:t,isLoading:s}=uNs(),{data:r=[],isLoading:n}=hNs(),[a,o]=k.useState(null),l=s||n,i=r.reduce((d,u)=>{const p=u.agent_videos,f=(p==null?void 0:p.id)||u.video_id;return d[f]||(d[f]={videoId:f,title:(p==null?void 0:p.title)||"Untitled",thumbnailUrl:p==null?void 0:p.thumbnail_url,recipients:[]}),d[f].recipients.push(u),d},{});return l?e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:[...Array(4)].map((d,u)=>e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(Ms,{className:"h-4 w-20"})}),e.jsx(Oe,{children:e.jsx(Ms,{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(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total Sent"}),e.jsx(_n,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(t==null?void 0:t.totalSent)||0})})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Open Rate"}),e.jsx(jn,{className:"h-4 w-4 text-amber-500"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[(t==null?void 0:t.openRate)||0,"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(t==null?void 0:t.totalOpened)||0," opened"]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(au,{className:"h-4 w-4 text-blue-500"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[(t==null?void 0:t.clickRate)||0,"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(t==null?void 0:t.totalClicked)||0," clicked"]})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{className:"text-sm font-medium",children:"Send History by Video"}),e.jsx(dr,{children:"Click a video to see individual recipient tracking"})]}),e.jsx(Oe,{children:Object.keys(i).length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No tracked sends yet. Send a video via Gmail to start tracking."}):e.jsx("div",{className:"space-y-2",children:Object.values(i).map(d=>{const u=d.recipients.filter(f=>f.opened_at).length,p=d.recipients.filter(f=>f.clicked_at).length;return e.jsxs("button",{onClick:()=>o({id:d.videoId,title:d.title}),className:"w-full flex items-center gap-3 p-3 rounded-lg border hover:bg-muted/50 transition-colors text-left",children:[e.jsx("div",{className:"h-10 w-16 rounded bg-muted overflow-hidden flex-shrink-0",children:d.thumbnailUrl?e.jsx("img",{src:d.thumbnailUrl,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer",onError:f=>{const y=f.currentTarget;y.style.display="none",y.parentElement.innerHTML='
'}}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(yn,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:d.title}),e.jsxs("div",{className:"flex items-center gap-3 mt-0.5",children:[e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(_n,{className:"h-3 w-3"})," ",d.recipients.length]}),e.jsxs("span",{className:"text-xs text-amber-600 flex items-center gap-1",children:[e.jsx(jn,{className:"h-3 w-3"})," ",u]}),e.jsxs("span",{className:"text-xs text-blue-600 flex items-center gap-1",children:[e.jsx(au,{className:"h-3 w-3"})," ",p]})]})]}),e.jsx(Qo,{className:"h-4 w-4 text-muted-foreground"})]},d.videoId)})})})]}),e.jsx(vNs,{open:!!a,onOpenChange:d=>!d&&o(null),videoId:(a==null?void 0:a.id)||null,videoTitle:(a==null?void 0:a.title)||""})]})}function bNs({previewSrc:t,thumbnailSrc:s,alt:r,isHovered:n}){const[a,o]=k.useState(!1),[l,i]=k.useState(!1),d=n&&t&&!a,u=s&&!l;return!u&&!d?e.jsx("div",{className:"w-full h-full flex items-center justify-center absolute inset-0 bg-muted",children:e.jsx(yn,{className:"h-12 w-12 text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[u&&e.jsx("img",{src:s,alt:r,loading:"lazy",className:`w-full h-full object-cover absolute inset-0 transition-opacity duration-200 ${d?"opacity-0":"opacity-100"}`,onError:()=>i(!0)}),d&&e.jsx("img",{src:t,alt:r,className:"w-full h-full object-cover absolute inset-0",onError:()=>o(!0)})]})}function wNs({video:t,previewSrc:s,thumbnailSrc:r,onOpen:n,onDelete:a,onRename:o,onNavigateToContact:l,onGetEmbedCode:i,onCopyEmailHtml:d,onEmbedToCrm:u,onShareWithTemplate:p,onSendViaGmail:f,isGmailConnected:y,getContactName:_,getShareUrl:b,copyToClipboard:N,formatDuration:w}){const[S,C]=k.useState(!1);return e.jsxs(Pe,{className:"overflow-hidden group cursor-pointer",onClick:n,onMouseEnter:()=>C(!0),onMouseLeave:()=>C(!1),children:[e.jsxs("div",{className:"relative aspect-video bg-muted overflow-hidden",children:[e.jsx(bNs,{previewSrc:s,thumbnailSrc:r,alt:t.title||"Video preview",isHovered:S}),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(Co,{className:"h-6 w-6 text-primary ml-1"})})}),e.jsx("div",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-1.5 py-0.5 rounded",children:w(t.duration_seconds)}),t.status!=="ready"&&e.jsx(Qe,{variant:t.status==="processing"?"secondary":"destructive",className:"absolute top-2 left-2",children:t.status})]}),e.jsx(Oe,{className:"p-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"font-medium truncate",children:t.title||"Untitled Video"}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[e.jsx(Ai,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:_(t.contact_id)})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground mt-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(nn,{className:"h-3 w-3"}),e.jsx("span",{children:vs(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(jn,{className:"h-3 w-3"}),e.jsxs("span",{children:[t.view_count," ",t.view_count===1?"view":"views"]})]})]}),y&&t.share_token&&e.jsxs(W,{variant:"outline",size:"sm",className:"mt-2 gap-1.5 text-xs h-7",onClick:A=>{A.stopPropagation(),f==null||f()},children:[e.jsx(tr,{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(Ai,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:_(t.contact_id)})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground mt-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(nn,{className:"h-3 w-3"}),e.jsx("span",{children:vs(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(jn,{className:"h-3 w-3"}),e.jsxs("span",{children:[t.view_count," ",t.view_count===1?"view":"views"]})]})]})]}),e.jsxs(Hd,{children:[e.jsx(Gd,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:A=>A.stopPropagation(),children:e.jsx(ix,{className:"h-4 w-4"})})}),e.jsxs(Nd,{align:"end",className:"bg-popover",children:[e.jsxs(_a,{onClick:A=>{A.stopPropagation(),n()},children:[e.jsx(jn,{className:"h-4 w-4 mr-2"}),"Watch"]}),e.jsx(Yb,{}),e.jsxs(_a,{onClick:A=>{A.stopPropagation(),p()},children:[e.jsx(zl,{className:"h-4 w-4 mr-2"}),"Share with Template"]}),e.jsxs(_a,{onClick:A=>{A.stopPropagation(),N(b(t),"Share link")},children:[e.jsx(vo,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(_a,{onClick:A=>{A.stopPropagation(),i()},children:[e.jsx(Y4,{className:"h-4 w-4 mr-2"}),"Get Embed Code"]}),e.jsxs(_a,{onClick:A=>{A.stopPropagation(),d()},children:[e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(_a,{onClick:A=>{A.stopPropagation(),u()},children:[e.jsx(Yr,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),y&&t.share_token&&e.jsxs(_a,{onClick:A=>{A.stopPropagation(),f==null||f()},children:[e.jsx(_n,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]}),e.jsxs(_a,{onClick:A=>{A.stopPropagation(),o()},children:[e.jsx(ga,{className:"h-4 w-4 mr-2"}),"Rename"]}),e.jsx(Yb,{}),t.contact_id&&e.jsxs(_a,{onClick:A=>{A.stopPropagation(),l()},children:[e.jsx(Ai,{className:"h-4 w-4 mr-2"}),"View Contact"]}),e.jsxs(_a,{onClick:A=>{A.stopPropagation(),a()},className:"text-destructive",children:[e.jsx(vr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})})]})}function jNs(){var Ze,kt;const t=wr(),{data:s,isLoading:r,refetch:n}=Obs(),{data:a}=Ame(),{data:o}=qh(),l=Bbs(),i=zbs(),{isGmailConnected:d,gmailEmail:u}=Om(),{data:p}=Px(),{data:f=[],isLoading:y}=gNs(),[_,b]=k.useState("my"),[N,w]=k.useState(""),[S,C]=k.useState(null),[A,I]=k.useState(!1),[L,O]=k.useState(!1),[V,q]=k.useState(!1),[B,U]=k.useState(!1),[te,Y]=k.useState(!1),[J,X]=k.useState(""),[ce,ie]=k.useState(!1),[ae,oe]=k.useState(!1),[me,ve]=k.useState(!1),[he,ge]=k.useState(!1),[je,qe]=k.useState(""),[Me,ke]=k.useState({}),Re=Ut=>{if(!Ut)return"Unassigned";const Nt=o==null?void 0:o.find(es=>es.id===Ut);return Nt?`${Nt.first_name} ${Nt.last_name||""}`.trim():"Unknown"},Ve=Ut=>{if(!Ut)return"0:00";const Nt=Math.floor(Ut/60),es=Ut%60;return`${Nt}:${es.toString().padStart(2,"0")}`},Ne=s==null?void 0:s.filter(Ut=>{if(!N)return!0;const Nt=Re(Ut.contact_id).toLowerCase(),es=(Ut.title||"").toLowerCase(),ds=(Ut.notes||"").toLowerCase();return Nt.includes(N.toLowerCase())||es.includes(N.toLowerCase())||ds.includes(N.toLowerCase())}),[Ue,Ie]=k.useState(!1);k.useEffect(()=>{if(Ue)return;(async()=>{if(!(s!=null&&s.length))return;const Nt=s.filter(ds=>ds.status==="processing"&&ds.bunny_video_id);if(!Nt.length)return;let es=!1;for(const ds of Nt)try{const{data:js,error:lr}=await G.functions.invoke("bunny-upload",{body:{action:"status",videoId:ds.bunny_video_id,isAgentVideo:!0}});if(lr||!js)continue;js.status===4&&(await G.from("agent_videos").update({status:"ready",playback_url:js.directPlayUrl,thumbnail_url:js.thumbnailUrl,preview_url:js.previewUrl,duration_seconds:js.length||ds.duration_seconds,updated_at:new Date().toISOString()}).eq("id",ds.id),es=!0)}catch(js){console.warn("Reconcile check failed for video",ds.id,js)}Ie(!0),es&&n()})()},[s,Ue,n]),k.useEffect(()=>{(async()=>{if(!(s!=null&&s.length))return;const Nt=s.filter(Lt=>(Lt==null?void 0:Lt.bunny_video_id)&&!Me[Lt.id]);if(!Nt.length)return;const es=Nt.map(Lt=>Lt.bunny_video_id),{data:ds,error:js}=await G.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:es,isAgentVideo:!0}});if(js)throw js;const lr=(ds==null?void 0:ds.assets)||{};ke(Lt=>{const Es={...Lt};for(const fr of Nt)lr[fr.bunny_video_id]&&(Es[fr.id]={previewUrl:lr[fr.bunny_video_id].previewUrl,thumbnailUrl:lr[fr.bunny_video_id].thumbnailUrl});return Es})})().catch(Nt=>console.warn("Failed to load signed Bunny asset URLs",Nt))},[s,Me]);const ye=(a==null?void 0:a.total_storage_mb)||0,ct=(a==null?void 0:a.max_storage_mb)||1024,fe=ye/ct*100,$e=fe>=80,Ye=fe>=100,tt=async(Ut,Nt)=>{await navigator.clipboard.writeText(Ut),pe.success(`${Nt} copied to clipboard`)},Te=Ut=>Ut.share_token?`https://video.relevelup.com/${Ut.share_token}`:Ut.playback_url||"",We=Ut=>{const Nt=Te(Ut),es=o==null?void 0:o.find(fr=>fr.id===Ut.contact_id),ds=Re(Ut.contact_id),js=ds!=="Unassigned"?ds.split(" ")[0]:"",lr=(es==null?void 0:es.phone)||"",Lt=`Hey${js?` ${js}`:""}! I recorded a quick video message for you. Check it out: ${Nt}`,Es=lr?`sms:${lr}?body=${encodeURIComponent(Lt)}`:`sms:?body=${encodeURIComponent(Lt)}`;window.open(Es,"_self")},Ke=Ut=>{const Nt=o==null?void 0:o.find(Es=>Es.id===Ut.contact_id),es=(Nt==null?void 0:Nt.email)||"",ds=Te(Ut),js="Check out this video",lr=`I recorded a quick video for you: ${ds}`,Lt=es?`mailto:${es}?subject=${encodeURIComponent(js)}&body=${encodeURIComponent(lr)}`:`mailto:?subject=${encodeURIComponent(js)}&body=${encodeURIComponent(lr)}`;window.open(Lt,"_self")},ot=Ut=>{var js;const Nt=Te(Ut),es=Ut.title||"Video Message",ds=Ut.share_token?`https://video.relevelup.com/thumb/${Ut.share_token}`:((js=Me[Ut.id])==null?void 0:js.thumbnailUrl)||Ut.thumbnail_url||"";return``},He=async Ut=>{if(!Ut.thumbnail_url&&!Ut.share_token){pe.error("Video thumbnail not available yet");return}const Nt=ot(Ut),es=Te(Ut),ds=`Watch: ${Ut.title||"Video Message"} ${es}`;try{const js=new Blob([Nt],{type:"text/html"}),lr=new Blob([ds],{type:"text/plain"}),Lt=new ClipboardItem({"text/html":js,"text/plain":lr});await navigator.clipboard.write([Lt]),pe.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(ds+` `+Nt),pe.success("Copied! Paste into your email.")}},Je=async Ut=>{try{pe.loading("Preparing download...",{id:"download"});const{data:Nt,error:es}=await G.functions.invoke("bunny-upload",{body:{action:"download-url",videoId:Ut.bunny_video_id,isAgentVideo:!0}});if(es||!(Nt!=null&&Nt.downloadUrl))throw new Error((es==null?void 0:es.message)||"Failed to get download URL");const js=`${((Ut.title||"video").toString().trim()||"video").replace(/[\\/:*?"<>|]+/g,"-")}.mp4`,lr=await fetch(Nt.downloadUrl);if(!lr.ok)throw new Error("Failed to fetch video file");const Lt=await lr.blob(),Es=URL.createObjectURL(Lt),fr=document.createElement("a");fr.href=Es,fr.download=js,fr.rel="noreferrer",document.body.appendChild(fr),fr.click(),fr.remove(),URL.revokeObjectURL(Es),pe.success("Download started",{id:"download"})}catch(Nt){console.error("Download error:",Nt),pe.error("Could not force download (your browser may block it).",{id:"download"})}},ut=async Ut=>{C(Ut),ie(!0),X(""),Y(!0);try{const{data:Nt,error:es}=await G.functions.invoke("bunny-upload",{body:{action:"crm-embed",videoId:Ut.bunny_video_id,title:Ut.title,isAgentVideo:!0,shareToken:Ut.share_token}});if(es||!(Nt!=null&&Nt.html))throw new Error("Failed to generate CRM embed code");X(Nt.html)}catch(Nt){console.error("CRM embed error:",Nt),pe.error("Failed to generate CRM embed code"),Y(!1)}finally{ie(!1)}},mt=Ut=>{C(Ut),I(!0)},et=async()=>{if(S)try{await l.mutateAsync({id:S.id,bunnyVideoId:S.bunny_video_id,hardDelete:!0}),O(!1),C(null),pe.success("Video deleted successfully")}catch{pe.error("Failed to delete video")}};return e.jsx(Ds,{title:"Video Library",description:"Manage your video touches",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Video Library"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage and share your video touches"})]}),e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5 ml-2",children:[e.jsx("button",{onClick:()=>b("my"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${_==="my"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"My Videos"}),p&&((Ze=p.team)==null?void 0:Ze.shared_videos_enabled)&&e.jsxs("button",{onClick:()=>b("team"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${_==="team"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(ir,{className:"h-3.5 w-3.5"}),"Team"]}),e.jsxs("button",{onClick:()=>b("analytics"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${_==="analytics"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(so,{className:"h-3.5 w-3.5"}),"Analytics"]})]})]}),_==="my"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(W,{variant:"outline",onClick:()=>q(!0),children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"}),"Upload Video"]}),e.jsxs(W,{onClick:()=>t("/mission-control/video/record"),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Record New Video"]})]})]}),_==="team"?e.jsx(NNs,{videos:f,isLoading:y,searchTerm:N,setSearchTerm:w}):_==="analytics"?e.jsx(_Ns,{}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{className:$e?"border-amber-500":Ye?"border-destructive":"",children:e.jsxs(Oe,{className:"py-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(yL,{className:`h-5 w-5 ${Ye?"text-destructive":$e?"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:[ye.toFixed(1)," MB / ",ct>=1024?`${(ct/1024).toFixed(0)} GB`:`${ct} MB`]})]}),e.jsx(xi,{value:Math.min(fe,100),className:`h-2 ${Ye?"[&>div]:bg-destructive":$e?"[&>div]:bg-amber-500":""}`})]}),$e&&!Ye&&e.jsxs(Qe,{variant:"outline",className:"border-amber-500 text-amber-600",children:[e.jsx(ro,{className:"h-3 w-3 mr-1"}),"Near Limit"]}),Ye&&e.jsxs(Qe,{variant:"destructive",children:[e.jsx(ro,{className:"h-3 w-3 mr-1"}),"At Limit"]})]}),Ye&&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(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search videos by contact, title, or notes...",value:N,onChange:Ut=>w(Ut.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"})}):(Ne==null?void 0:Ne.length)===0?e.jsx(Pe,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(yn,{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(W,{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:Ne==null?void 0:Ne.map(Ut=>{var Nt,es;return e.jsx(wNs,{video:Ut,previewSrc:(Nt=Me[Ut.id])==null?void 0:Nt.previewUrl,thumbnailSrc:(es=Me[Ut.id])==null?void 0:es.thumbnailUrl,onOpen:()=>mt(Ut),onDelete:()=>{C(Ut),O(!0)},onRename:()=>{C(Ut),qe(Ut.title||""),ge(!0)},onNavigateToContact:()=>t(`/mission-control/contacts/${Ut.contact_id}`),onGetEmbedCode:()=>{C(Ut),U(!0)},onCopyEmailHtml:()=>He(Ut),onEmbedToCrm:()=>ut(Ut),onShareWithTemplate:()=>{C(Ut),oe(!0)},onSendViaGmail:()=>{C(Ut),ve(!0)},isGmailConnected:d,getContactName:Re,getShareUrl:Te,copyToClipboard:tt,formatDuration:Ve},Ut.id)})}),e.jsx(fs,{open:A,onOpenChange:I,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsxs(ks,{children:[e.jsx(_s,{children:(S==null?void 0:S.title)||"Video Preview"}),e.jsx(Ir,{children:(S==null?void 0:S.contact_id)&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ai,{className:"h-3 w-3"}),Re(S.contact_id)]})})]}),S&&e.jsxs("div",{className:"space-y-4",children:[S.status==="processing"?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-6 bg-muted/50 rounded-lg border border-dashed border-border text-center space-y-4",children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:"h-16 w-16 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(us,{className:"h-8 w-8 text-primary animate-spin"})})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Video is still processing"}),e.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:"Your video is being encoded and will be ready shortly. This usually takes 1–3 minutes. Check back soon!"})]}),e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>{I(!1),n()},children:[e.jsx(Zi,{className:"h-4 w-4 mr-2"}),"Refresh Library"]})]}):e.jsx("div",{className:"relative w-full",style:{paddingBottom:"56.25%"},children:S.playback_url?(()=>{let Ut=S.playback_url;return Ut.includes("iframe.mediadelivery.net/play/")&&(Ut=Ut.replace("/play/","/embed/"),Ut+=(Ut.includes("?")?"&":"?")+"autoplay=false&responsive=true"),Ut.includes("iframe.mediadelivery.net")?e.jsx("iframe",{src:Ut,title:S.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:S.playback_url,controls:!0,playsInline:!0,preload:"metadata",poster:S.thumbnail_url||void 0,className:"absolute top-0 left-0 w-full h-full rounded-lg object-cover",onError:()=>pe.error("Video preview failed to load")},S.playback_url)})():e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-muted rounded-lg",children:[e.jsx(yn,{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(W,{variant:"outline",onClick:()=>We(S),children:[e.jsx(wi,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),!d&&e.jsxs(W,{variant:"outline",onClick:()=>Ke(S),children:[e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(W,{variant:"outline",onClick:()=>tt(Te(S),"Share link"),children:[e.jsx(Va,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(W,{variant:"outline",onClick:()=>He(S),children:[e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(W,{variant:"outline",onClick:()=>Je(S),children:[e.jsx(Qa,{className:"h-4 w-4 mr-2"}),"Download Video"]}),e.jsxs(W,{variant:"outline",onClick:()=>{I(!1),ut(S)},children:[e.jsx(Yr,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),e.jsxs(W,{variant:"outline",onClick:()=>{I(!1),oe(!0)},children:[e.jsx(zl,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]}),d&&(S==null?void 0:S.share_token)&&e.jsxs(W,{variant:"outline",onClick:()=>{I(!1),ve(!0)},children:[e.jsx(_n,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]})]}),e.jsx("div",{className:"flex justify-end pt-2 border-t",children:e.jsxs(W,{variant:"destructive",onClick:()=>{I(!1),O(!0)},children:[e.jsx(vr,{className:"h-4 w-4 mr-2"}),"Delete Video"]})})]})]})}),e.jsx(fs,{open:L,onOpenChange:O,children:e.jsxs(ps,{children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Delete Video"}),e.jsx(Ir,{children:"Are you sure you want to delete this video? This action cannot be undone."})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),e.jsx(W,{variant:"destructive",onClick:et,disabled:l.isPending,children:l.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(cNs,{open:V,onOpenChange:q}),e.jsx(fs,{open:B,onOpenChange:U,children:e.jsxs(ps,{className:"sm:max-w-lg",children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Embed Video"}),e.jsx(Ir,{children:"Copy this code to embed the video on your website."})]}),S&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Embed Code"}),e.jsx(_r,{readOnly:!0,rows:5,value:``,className:"font-mono text-xs"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(W,{className:"flex-1",onClick:()=>{const Ut=``;tt(Ut,"Embed code")},children:[e.jsx(Va,{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."})]})]})}),S&&e.jsx(Nlt,{open:ae,onOpenChange:oe,video:S,contactName:Re(S.contact_id)}),S&&e.jsx(xNs,{open:me,onOpenChange:ve,video:S,gmailEmail:u,signedThumbnailUrl:(kt=Me[S.id])==null?void 0:kt.thumbnailUrl}),e.jsx(fs,{open:he,onOpenChange:ge,children:e.jsxs(ps,{className:"max-w-sm",children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Rename Video"}),e.jsx(Ir,{children:"Enter a new title for this video."})]}),e.jsx(De,{value:je,onChange:Ut=>qe(Ut.target.value),placeholder:"Video title",autoFocus:!0,onKeyDown:Ut=>{Ut.key==="Enter"&&je.trim()&&i.mutate({id:S.id,title:je.trim()},{onSuccess:()=>{pe.success("Video renamed"),ge(!1)}})}}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>ge(!1),children:"Cancel"}),e.jsx(W,{disabled:!je.trim()||i.isPending,onClick:()=>{i.mutate({id:S.id,title:je.trim()},{onSuccess:()=>{pe.success("Video renamed"),ge(!1)}})},children:i.isPending?"Saving...":"Save"})]})]})}),e.jsx(fs,{open:te,onOpenChange:Y,children:e.jsxs(ps,{className:"sm:max-w-lg",children:[e.jsxs(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(Yr,{className:"h-5 w-5"}),"Embed to CRM"]}),e.jsx(Ir,{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(us,{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(xe,{children:"CRM Email HTML"}),e.jsx(_r,{readOnly:!0,rows:12,value:J,className:"font-mono text-xs"})]}),e.jsxs(W,{className:"w-full",onClick:()=>{tt(J,"CRM embed code")},children:[e.jsx(Va,{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 NNs({videos:t,isLoading:s,searchTerm:r,setSearchTerm:n}){const a=k.useMemo(()=>{if(!r)return t;const i=r.toLowerCase();return t.filter(d=>(d.title||"").toLowerCase().includes(i)||(d.owner_name||"").toLowerCase().includes(i)||(d.recipient_name||"").toLowerCase().includes(i))},[t,r]),o=k.useMemo(()=>{const i=new Map;return a.forEach(d=>{const u=i.get(d.owner_user_id);u?u.videos.push(d):i.set(d.owner_user_id,{name:d.owner_name,avatar:d.owner_avatar_url,videos:[d]})}),Array.from(i.entries())},[a]),l=i=>{if(!i)return"0:00";const d=Math.floor(i/60),u=i%60;return`${d}:${u.toString().padStart(2,"0")}`};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{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(Oe,{className:"py-12 text-center",children:[e.jsx(ir,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No team videos"}),e.jsx("p",{className:"text-muted-foreground",children:t.length===0?"Your teammates haven't recorded any videos yet.":"No videos match your search."})]})}):e.jsx("div",{className:"space-y-6",children:o.map(([i,d])=>e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Nn,{className:"h-7 w-7",children:[e.jsx(Ma,{src:d.avatar||""}),e.jsx(kn,{children:(d.name||"?").charAt(0).toUpperCase()})]}),e.jsx("h3",{className:"font-semibold text-sm",children:d.name}),e.jsx(Qe,{variant:"secondary",className:"text-xs",children:d.videos.length})]}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:d.videos.map(u=>e.jsxs(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:p=>{p.target.style.display="none"}}):e.jsx(yn,{className:"h-10 w-10 text-muted-foreground"}),u.duration_seconds&&e.jsx("span",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-1.5 py-0.5 rounded",children:l(u.duration_seconds)})]}),e.jsxs(Oe,{className:"p-3",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:u.title||"Untitled"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[u.recipient_name&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ai,{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(jn,{className:"h-3 w-3"}),u.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nn,{className:"h-3 w-3"}),vs(new Date(u.created_at),"MMM d")]})]})]})]},u.id))})]},i))})]})}const kNs=()=>{const{user:t}=Us();return gt({queryKey:["team-deals",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.rpc("get_team_deals",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})},r9e=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function SNs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=kNs(),[a,o]=k.useState(""),[l,i]=k.useState("all"),d=k.useMemo(()=>{if(!r)return new Map;const b=new Map;let N=0;return r.forEach(w=>{b.has(w.owner_user_id)||(b.set(w.owner_user_id,{name:w.owner_name||"Unknown",avatar:w.owner_avatar_url,color:r9e[N%r9e.length]}),N++)}),b},[r]),u=k.useMemo(()=>Array.from(d.entries()).map(([b,N])=>({id:b,...N})),[d]),p=k.useMemo(()=>{if(!r)return[];let b=r;if(l!=="all"&&(b=b.filter(N=>N.owner_user_id===l)),a.trim()){const N=a.toLowerCase();b=b.filter(w=>{var S,C,A,I;return w.deal_name.toLowerCase().includes(N)||((S=w.contact_name)==null?void 0:S.toLowerCase().includes(N))||((C=w.property_address)==null?void 0:C.toLowerCase().includes(N))||((A=w.city)==null?void 0:A.toLowerCase().includes(N))||((I=w.owner_name)==null?void 0:I.toLowerCase().includes(N))})}return b},[r,a,l]),f=k.useMemo(()=>{const b=new Map;return p.forEach(N=>{const w=N.stage_name||"Unknown";b.has(w)||b.set(w,{name:w,color:N.stage_color,icon:N.stage_icon,deals:[],totalValue:0});const S=b.get(w);S.deals.push(N),S.totalValue+=N.sale_price||0}),Array.from(b.values())},[p]),y=b=>b>=1e6?`$${(b/1e6).toFixed(1)}M`:b>=1e3?`$${(b/1e3).toFixed(0)}K`:`$${b.toFixed(0)}`,_=b=>b?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(b):null;return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-[95vw] w-full max-h-[90vh] flex flex-col",children:[e.jsx(ks,{children:e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(ir,{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(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search deals...",value:a,onChange:b=>o(b.target.value),className:"pl-9"})]}),e.jsxs($s,{value:l,onValueChange:i,children:[e.jsx(zs,{className:"w-[180px]",children:e.jsx(Vs,{placeholder:"All Members"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Members"}),u.map(b=>e.jsx(vt,{value:b.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full inline-block",style:{backgroundColor:b.color}}),b.name]})},b.id))]})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-3 ml-auto text-xs text-muted-foreground",children:[u.slice(0,6).map(b=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:b.color}}),b.name.split(" ")[0]]},b.id)),u.length>6&&e.jsxs("span",{children:["+",u.length-6," more"]})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden mt-2",children:n?e.jsx("div",{className:"flex gap-4 h-full",children:[1,2,3,4].map(b=>e.jsxs("div",{className:"min-w-[260px] flex-1",children:[e.jsx(Ms,{className:"h-12 w-full mb-2 rounded-lg"}),e.jsx(Ms,{className:"h-24 w-full mb-2 rounded-lg"}),e.jsx(Ms,{className:"h-24 w-full rounded-lg"})]},b))}):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(ir,{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(b=>{const N=b.icon&&ije[b.icon]||sd;return e.jsxs("div",{className:"flex flex-col h-full min-w-[260px] max-w-[300px] flex-1 bg-muted/30 rounded-xl border border-border/50",children:[e.jsxs("div",{className:"p-3 border-b border-border/50 shrink-0",style:{borderTopColor:b.color||"hsl(var(--border))",borderTopWidth:3},children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-md flex items-center justify-center",style:{backgroundColor:b.color?`${b.color}20`:void 0},children:e.jsx(N,{className:"h-3.5 w-3.5",style:{color:b.color||void 0}})}),e.jsx("h3",{className:"font-semibold text-sm",children:b.name})]}),e.jsx(Qe,{variant:"secondary",className:"text-xs px-2",children:b.deals.length})]}),b.totalValue>0&&e.jsx("p",{className:"text-xs text-muted-foreground ml-8",children:y(b.totalValue)})]}),e.jsx(Ja,{className:"flex-1 p-2",children:e.jsx("div",{className:"space-y-2",children:b.deals.map(w=>{const S=d.get(w.owner_user_id);return e.jsx(CNs,{deal:w,ownerColor:(S==null?void 0:S.color)||"#888",ownerName:(S==null?void 0:S.name)||"Unknown",ownerAvatar:(S==null?void 0:S.avatar)||null,formatPrice:_},w.id)})})})]},b.name)})})}),e.jsxs("p",{className:"text-xs text-muted-foreground text-center pt-2 border-t shrink-0",children:[p.length," deal",p.length!==1?"s":""," across ",f.length," stage",f.length!==1?"s":""," from ",u.length," member",u.length!==1?"s":""]})]})})}function CNs({deal:t,ownerColor:s,ownerName:r,ownerAvatar:n,formatPrice:a}){const o={buyer:{label:"Buyer",className:"bg-blue-500/10 text-blue-600 border-blue-200"},seller:{label:"Seller",className:"bg-emerald-500/10 text-emerald-600 border-emerald-200"},dual:{label:"Dual",className:"bg-purple-500/10 text-purple-600 border-purple-200"},referral:{label:"Referral",className:"bg-orange-500/10 text-orange-600 border-orange-200"},lease:{label:"Lease",className:"bg-cyan-500/10 text-cyan-600 border-cyan-200"}},l=t.deal_type?o[t.deal_type]:null;return e.jsxs("div",{className:"rounded-lg border bg-card p-3 space-y-2 transition-all hover:shadow-sm",style:{borderLeftWidth:4,borderLeftColor:s},children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(Nn,{className:"h-4 w-4",children:[e.jsx(Ma,{src:n||""}),e.jsx(kn,{className:"text-[8px] font-semibold text-white",style:{backgroundColor:s},children:r.charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-[10px] font-medium truncate",style:{color:s},children:r})]}),e.jsxs("div",{className:"flex items-start justify-between gap-1",children:[e.jsx("h4",{className:"font-medium text-sm leading-tight line-clamp-2",children:t.deal_name}),l&&e.jsx(Qe,{variant:"outline",className:Ot("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(Mn,{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(_c,{className:"h-3 w-3 text-emerald-500 shrink-0"}),e.jsx("span",{className:"font-semibold text-foreground",children:a(t.sale_price)})]})]})}function MNs({members:t,enabledMembers:s,onToggleMember:r,isOpen:n,onToggleOpen:a}){const o=s.size;return e.jsxs("div",{className:Ot("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(W,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 px-2",onClick:a,children:[e.jsx(ir,{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(Xo,{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(Ja,{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:Ot("w-full flex items-center gap-2 px-2 py-2 rounded-lg text-left transition-colors",i?"bg-primary/10 hover:bg-primary/15":"hover:bg-muted/50"),children:[e.jsxs("div",{className:"relative",children:[e.jsxs(Nn,{className:"h-7 w-7",children:[e.jsx(Ma,{src:l.avatar_url||""}),e.jsx(kn,{className:"text-[10px] font-semibold text-white",style:{backgroundColor:l.color},children:l.name.charAt(0).toUpperCase()})]}),i&&e.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 rounded-full border-2 border-background",style:{backgroundColor:l.color}})]}),e.jsx("span",{className:Ot("text-xs truncate flex-1",i?"font-medium text-foreground":"text-muted-foreground"),children:l.name}),e.jsx(Ar,{checked:i,onCheckedChange:()=>r(l.id),className:"scale-75",onClick:d=>d.stopPropagation()})]},l.id)})}),t.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-4",children:"No team members"})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center pt-2 gap-2",children:[t.slice(0,5).map(l=>{const i=s.has(l.id);return e.jsx("button",{onClick:()=>r(l.id),className:"relative",title:l.name,children:e.jsxs(Nn,{className:Ot("h-7 w-7 transition-all",i?"ring-2 ring-offset-1 ring-offset-background":"opacity-50"),style:i?{"--tw-ring-color":l.color}:{},children:[e.jsx(Ma,{src:l.avatar_url||""}),e.jsx(kn,{className:"text-[10px] font-semibold text-white",style:{backgroundColor:l.color},children:l.name.charAt(0).toUpperCase()})]})},l.id)}),t.length>5&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",t.length-5]})]})]})}const n9e=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function TNs(){const t=ya(),{data:s}=Px(),r=(s==null?void 0:s.role)==="team_leader",n=s==null?void 0:s.teamId,a=gt({queryKey:["team-pipeline-members",n,t],queryFn:async()=>{const{data:o,error:l}=await G.from("team_members").select("user_id, role").eq("team_id",n).neq("user_id",t);if(l)throw l;if(!o||o.length===0)return[];const i=o.map(p=>p.user_id),{data:d,error:u}=await G.from("profiles").select("id, name, avatar_url").in("id",i);if(u)throw u;return(d||[]).map((p,f)=>({id:p.id,name:p.name||"Unknown",avatar_url:p.avatar_url,color:n9e[f%n9e.length]}))},enabled:!!n&&!!t&&r,staleTime:5*60*1e3});return{isTeamLeader:r,teamMembers:a.data||[],isLoadingMembers:a.isLoading}}function ANs(t){return gt({queryKey:["team-member-deals",t],queryFn:async()=>{if(t.length===0)return[];const{data:s,error:r}=await G.from("deal_pipeline").select(` *, contact:innercircle_contacts(id, first_name, last_name, email, phone), listing:listings(id, property_address, city, state, price, status, created_at), deal_pipeline_stages(name) `).in("owner_user_id",t).order("updated_at",{ascending:!1});if(r)throw r;return(s||[]).map(n=>{var a;return{...n,_stage_name:((a=n.deal_pipeline_stages)==null?void 0:a.name)||null}})},enabled:t.length>0})}function ENs(){const t=ya();return gt({queryKey:["all-deal-tags-map",t],queryFn:async()=>{if(!t)return{tags:[],byDeal:{},unique:[]};const{data:s,error:r}=await G.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,d)=>i.localeCompare(d));return{tags:n,byDeal:a,unique:l}},enabled:!!t})}function klt({stages:t,currentStageId:s,onStageSelect:r,disabled:n}){const[a,o]=k.useState(!1),l=t.find(d=>d.id===s),i=d=>{d.id!==s&&r(d.id,d.name),o(!1)};return e.jsxs(Hd,{open:a,onOpenChange:o,children:[e.jsx(Gd,{asChild:!0,children:e.jsxs(W,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5",disabled:n,onClick:d=>d.stopPropagation(),children:[l&&e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:l.color}}),e.jsx("span",{className:"max-w-[80px] truncate",children:(l==null?void 0:l.name)||"Move"}),e.jsx(xa,{className:"h-3 w-3 shrink-0"})]})}),e.jsx(Nd,{align:"end",className:"w-48 z-50 bg-popover",onClick:d=>d.stopPropagation(),children:t.map(d=>{const u=d.icon&&ije[d.icon]||sd,p=d.id===s;return e.jsxs(_a,{onClick:()=>i(d),className:Ot("flex items-center gap-2 cursor-pointer",p&&"bg-accent"),children:[e.jsx("div",{className:"w-5 h-5 rounded flex items-center justify-center shrink-0",style:{backgroundColor:`${d.color}20`},children:e.jsx(u,{className:"h-3 w-3",style:{color:d.color}})}),e.jsx("span",{className:"flex-1",children:d.name}),p&&e.jsx(Zn,{className:"h-4 w-4 text-primary"})]},d.id)})})]})}const PNs={buyer:{label:"Buyer",color:"bg-blue-500/10 text-blue-600 border-blue-200"},seller:{label:"Seller",color:"bg-emerald-500/10 text-emerald-600 border-emerald-200"},dual:{label:"Dual",color:"bg-purple-500/10 text-purple-600 border-purple-200"},referral:{label:"Referral",color:"bg-orange-500/10 text-orange-600 border-orange-200"},lease:{label:"Lease",color:"bg-cyan-500/10 text-cyan-600 border-cyan-200"}},INs={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 Slt({deal:t,onClick:s,isDragging:r,stages:n,onStageChange:a,showStagePicker:o=!1,isWonStage:l=!1,ownerInfo:i=null}){var C,A;const d=bE(),u=PNs[t.deal_type],p=INs[t.priority],f=k.useMemo(()=>t.target_close_date?$g(ol(t.target_close_date),new Date):null,[t.target_close_date]),y=f!==null&&f<0,_=f!==null&&f<=7&&f>=0,b=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 L=t.contract_date?ol(t.contract_date):new Date;return $g(L,ol(I))},[t]),N=l&&!t.scorecard_transaction_id,w=!!t.scorecard_transaction_id,S=I=>I?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(I):null;return e.jsx(Pe,{className:Ot("cursor-pointer transition-all duration-200 hover:shadow-md hover:border-primary/30 group overflow-hidden",r&&"opacity-50 rotate-2 shadow-xl",y&&"border-red-200 bg-red-50/30",N&&"border-amber-300 bg-amber-50/30 dark:bg-amber-950/20"),onClick:s,style:i?{borderLeftWidth:4,borderLeftColor:i.color}:void 0,children:e.jsxs(Oe,{className:"p-3 space-y-2.5",children:[i&&e.jsxs("div",{className:"flex items-center gap-1.5 -mt-0.5 mb-1",children:[e.jsxs(Nn,{className:"h-4 w-4",children:[e.jsx(Ma,{src:i.avatar_url||""}),e.jsx(kn,{className:"text-[8px] font-semibold text-white",style:{backgroundColor:i.color},children:i.name.charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-[10px] font-medium",style:{color:i.color},children:i.name})]}),e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("h4",{className:"font-medium text-sm leading-tight line-clamp-2 group-hover:text-primary transition-colors",children:t.deal_name})}),e.jsx(Qe,{variant:"outline",className:Ot("text-[10px] px-1.5 py-0 shrink-0",u.color),children:u.label})]}),t.contact&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(Nn,{className:"h-5 w-5",children:e.jsxs(kn,{className:"text-[10px] bg-primary/10 text-primary",children:[(C=t.contact.first_name)==null?void 0:C[0],(A=t.contact.last_name)==null?void 0:A[0]]})}),e.jsxs("span",{className:"truncate",children:[t.contact.first_name," ",t.contact.last_name]})]}),t.listing&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(Do,{className:"h-3 w-3 text-primary shrink-0"}),e.jsx("span",{className:"text-primary truncate",children:"Linked to Listing Exchange"})]}),N&&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(Fi,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate font-medium",children:"Add to Scorecard"})]}),w&&l&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400",children:[e.jsx($n,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:"Synced to Scorecard"})]}),b!==null&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(bM,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsxs("span",{className:Ot("font-medium",b>90?"text-red-600":b>60?"text-amber-600":"text-muted-foreground"),children:[b," DOM"]}),t.contract_date&&e.jsx("span",{className:"text-muted-foreground",children:"(final)"})]}),!t.listing&&(t.property_address||t.city)&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(Mn,{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(_c,{className:"h-3 w-3 text-emerald-500 shrink-0"}),e.jsx("span",{className:"font-semibold text-foreground",children:S(t.expected_price)}),t.expected_commission&&e.jsxs("span",{className:"text-muted-foreground",children:["• ",S(t.expected_commission)," GCI"]}),(()=>{const I=cx(t);return I!==null&&I!==t.expected_commission?e.jsxs("span",{className:"text-teal-600 dark:text-teal-400",children:["• ",S(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:Ot("flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px]",p.color),children:[e.jsx("div",{className:Ot("w-1.5 h-1.5 rounded-full",p.dot)}),e.jsx("span",{className:"capitalize",children:t.priority})]}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[t.probability,"%"]})]}),o&&d&&n&&a?e.jsx(klt,{stages:n,currentStageId:t.stage_id||"",onStageSelect:(I,L)=>a(t.id,I,L)}):t.target_close_date?e.jsxs("div",{className:Ot("flex items-center gap-1 text-[10px]",y&&"text-red-600",_&&!y&&"text-amber-600",!y&&!_&&"text-muted-foreground"),children:[y?e.jsx(ro,{className:"h-3 w-3"}):e.jsx(cn,{className:"h-3 w-3"}),e.jsx("span",{children:y?`${Math.abs(f)}d overdue`:_?`${f}d left`:vs(ol(t.target_close_date),"MMM d")})]}):null]})]})})}function LNs({stage:t,deals:s,onDealClick:r,onAddDeal:n,onDragStart:a,onDragOver:o,onDrop:l,isDragOver:i,isWonStage:d=!1,getOwnerInfo:u}){const p=k.useRef(null),f=s.reduce((w,S)=>w+(S.expected_price||0),0),y=s.reduce((w,S)=>w+(S.expected_commission||0),0),_=s.reduce((w,S)=>w+(cx(S)||0),0),b=w=>w>=1e6?`$${(w/1e6).toFixed(1)}M`:w>=1e3?`$${(w/1e3).toFixed(0)}K`:`$${w.toFixed(0)}`,N=t.icon&&ije[t.icon]||sd;return e.jsxs("div",{ref:p,className:Ot("flex flex-col h-full min-w-[280px] max-w-[320px] bg-muted/30 rounded-xl border border-border/50 transition-all duration-200",i&&"border-primary/50 bg-primary/5 ring-2 ring-primary/20"),onDragOver:w=>o(w,t.id),onDrop:w=>l(w,t.id),children:[e.jsxs("div",{className:"p-3 border-b border-border/50 shrink-0",style:{borderTopColor:t.color,borderTopWidth:3},children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color}20`},children:e.jsx(N,{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(Qe,{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:b(f)}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[b(y)," GCI"]}),_>0&&_!==y&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs("span",{className:"text-teal-600 dark:text-teal-400",children:[b(_)," Net"]})]})]})]}),e.jsx(Ja,{className:"flex-1 p-2",children:e.jsxs("div",{className:"space-y-2",children:[s.map(w=>e.jsx("div",{draggable:!0,onDragStart:S=>{S.dataTransfer.effectAllowed="move",a(w.id,t.id)},children:e.jsx(Slt,{deal:w,onClick:()=>r(w),isWonStage:d,ownerInfo:(u==null?void 0:u(w))||null})},w.id)),s.length===0&&e.jsxs("div",{className:"py-8 px-4 text-center text-muted-foreground text-sm",children:[e.jsx("p",{className:"mb-2",children:"No deals yet"}),e.jsx("p",{className:"text-xs",children:"Drag deals here or add new"})]})]})}),e.jsx("div",{className:"p-2 border-t border-border/50 shrink-0",children:e.jsxs(W,{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 DNs({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:Rh,color:"text-blue-500",bgColor:"bg-blue-500/10"},{label:"Weighted GCI",value:r((t==null?void 0:t.weightedGCI)||0),icon:RL,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:WL,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:cL,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:Qo,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(Oe,{className:"p-4",children:e.jsx("div",{className:"h-10 bg-muted rounded"})})},a))}):e.jsx(S1,{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(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:Ot("p-2 rounded-lg",a.bgColor),children:e.jsx(a.icon,{className:Ot("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(ec,{children:[e.jsx(tc,{asChild:!0,children:o}),e.jsx(Dl,{children:e.jsx("p",{children:a.tooltip})})]},a.label):o})})})}function RNs({formData:t,onChange:s,isEditing:r}){const{isAdmin:n}=Us(),[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(Or,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(Qe,{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(lf,{open:a,onOpenChange:o,children:e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs(cf,{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(Or,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),t.portal_enabled&&e.jsx(Qe,{className:"text-xs bg-emerald-500/10 text-emerald-600 border-emerald-200",variant:"outline",children:"Enabled"})]}),e.jsx(Bi,{className:Ot("h-4 w-4 text-muted-foreground transition-transform",a&&"rotate-180")})]}),e.jsx(df,{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(xe,{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(Ar,{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(xe,{className:"text-sm font-medium",children:"Portal Visibility"}),e.jsxs(eke,{value:t.visibility,onValueChange:i=>l({visibility:i}),className:"grid grid-cols-2 gap-3",children:[e.jsxs("label",{className:Ot("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(ble,{value:"private"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ad,{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:Ot("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(ble,{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(Ri,{id:"require_onboarding",checked:t.require_onboarding,onCheckedChange:i=>l({require_onboarding:!!i}),className:"mt-0.5"}),e.jsxs("div",{children:[e.jsx(xe,{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(Ri,{id:"allow_spouse",checked:t.allow_spouse,onCheckedChange:i=>l({allow_spouse:!!i})}),e.jsx(xe,{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(xe,{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(xe,{className:"text-xs text-muted-foreground",children:"Client Full Name"}),e.jsx(De,{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(xe,{className:"text-xs text-muted-foreground",children:"Email"}),e.jsx(De,{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(xe,{className:"text-xs text-muted-foreground",children:"Phone"}),e.jsx(De,{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(xe,{className:"text-xs text-muted-foreground",children:"Preferred Invite Method"}),e.jsxs($s,{value:t.invite_method,onValueChange:i=>l({invite_method:i}),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"email",children:"Email"}),e.jsxs(vt,{value:"sms",disabled:!t.client_phone,children:["SMS ",!t.client_phone&&"(add phone first)"]})]})]})]})]})]})]})]})})]})})}const ONs=[{value:"buyer",label:"Buyer"},{value:"seller",label:"Seller"},{value:"dual",label:"Dual Agency"},{value:"referral",label:"Referral"},{value:"lease",label:"Lease"}],FNs=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"urgent",label:"Urgent"}];function zNs({open:t,onOpenChange:s,deal:r,defaultStageId:n}){const{data:a}=Eme(),{data:o}=qh(),{data:l}=MXe(),i=nhe(),d=yit(),u=vit(),p=BSe(),[f,y]=k.useState({portal_enabled:!1,visibility:"private",require_onboarding:!0,allow_spouse:!1,client_name:"",client_email:"",client_phone:"",invite_method:"email"}),[_,b]=k.useState(""),[N,w]=k.useState(!1),[S,C]=k.useState(!1),[A,I]=k.useState({first_name:"",last_name:"",email:"",phone:""}),L=(l==null?void 0:l.filter(J=>((r==null?void 0:r.listing_id)===J.id,!0)))||[],[O,V]=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,X,ce,ie,ae,oe,me,ve;t&&(r?(V({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:((X=r.commission_percentage)==null?void 0:X.toString())||"3",brokerage_split_pct:((ce=r.brokerage_split_pct)==null?void 0:ce.toString())||"",team_split_pct:((ie=r.team_split_pct)==null?void 0:ie.toString())||"",referral_fee_pct:((ae=r.referral_fee_pct)==null?void 0:ae.toString())||"",franchise_fee_pct:((oe=r.franchise_fee_pct)==null?void 0:oe.toString())||"",transaction_fee:((me=r.transaction_fee)==null?void 0:me.toString())||"",commission_calc_method:r.commission_calc_method||"standard",target_close_date:r.target_close_date?ol(r.target_close_date):void 0,contract_date:r.contract_date?ol(r.contract_date):void 0,listing_date:r.listing_date?ol(r.listing_date):void 0,priority:r.priority,probability:r.probability.toString(),notes:r.notes||""}),r.contact&&b(`${r.contact.first_name} ${r.contact.last_name}`)):(V({deal_name:"",deal_type:"buyer",stage_id:n||((ve=a==null?void 0:a[0])==null?void 0:ve.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:""}),b(""),y({portal_enabled:!1,visibility:"private",require_onboarding:!0,allow_spouse:!1,client_name:"",client_email:"",client_phone:"",invite_method:"email"})))},[t,r,n,a]);const q=o==null?void 0:o.filter(J=>{var ce,ie,ae;const X=_.toLowerCase();return((ce=J.first_name)==null?void 0:ce.toLowerCase().includes(X))||((ie=J.last_name)==null?void 0:ie.toLowerCase().includes(X))||((ae=J.email)==null?void 0:ae.toLowerCase().includes(X))}).slice(0,5),B=()=>{const J=parseFloat(O.expected_price)||0,X=parseFloat(O.commission_percentage)||0;return J*(X/100)},U=()=>{const J=B();if(!J)return null;const X=parseFloat(O.brokerage_split_pct)||0,ce=parseFloat(O.team_split_pct)||0,ie=parseFloat(O.referral_fee_pct)||0,ae=parseFloat(O.franchise_fee_pct)||0,oe=parseFloat(O.transaction_fee)||0;if(O.commission_calc_method==="referral_first"){let ve=J;ie&&(ve-=J*ie/100);let he=ve;return X&&(he-=ve*X/100),ce&&(he-=J*ce/100),ae&&(he-=J*ae/100),oe&&(he-=oe),Math.max(0,he)}let me=J;return X&&(me=me*((100-X)/100)),ce&&(me=me*((100-ce)/100)),ie&&(me=me-J*ie/100),ae&&(me=me-J*ae/100),oe&&(me=me-oe),Math.max(0,me)},te=async J=>{var X,ce,ie;if(J.preventDefault(),!O.deal_name.trim()){pe.error("Please enter a deal name");return}try{const ae={deal_name:O.deal_name,deal_type:O.deal_type,stage_id:O.stage_id||null,contact_id:O.contact_id||null,listing_id:O.listing_id||null,property_address:O.property_address||null,city:O.city||null,state:O.state||null,zip_code:O.zip_code||null,expected_price:O.expected_price?parseFloat(O.expected_price):null,expected_commission:B()||null,commission_percentage:O.commission_percentage?parseFloat(O.commission_percentage):3,brokerage_split_pct:O.brokerage_split_pct?parseFloat(O.brokerage_split_pct):null,team_split_pct:O.team_split_pct?parseFloat(O.team_split_pct):null,referral_fee_pct:O.referral_fee_pct?parseFloat(O.referral_fee_pct):null,franchise_fee_pct:O.franchise_fee_pct?parseFloat(O.franchise_fee_pct):null,transaction_fee:O.transaction_fee?parseFloat(O.transaction_fee):null,commission_calc_method:O.commission_calc_method,target_close_date:((X=O.target_close_date)==null?void 0:X.toISOString().split("T")[0])||null,contract_date:((ce=O.contract_date)==null?void 0:ce.toISOString().split("T")[0])||null,listing_date:((ie=O.listing_date)==null?void 0:ie.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,...ae}),pe.success("Deal updated successfully");else{const oe=await d.mutateAsync(ae);if(pe.success("Deal created successfully"),f.portal_enabled&&(oe!=null&&oe.id))try{await p.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}),pe.success("Client portal created!")}catch{pe.error("Deal created, but portal setup failed")}}s(!1)}catch{pe.error("Failed to save deal")}},Y=d.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(ks,{children:[e.jsx(_s,{children:r?"Edit Deal":"Add New Deal"}),e.jsx(Ir,{children:r?"Update the deal details below.":"Enter the details for your new deal."})]}),e.jsxs("form",{onSubmit:te,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(xe,{htmlFor:"deal_name",children:"Deal Name *"}),e.jsx(De,{id:"deal_name",value:O.deal_name,onChange:J=>V(X=>({...X,deal_name:J.target.value})),placeholder:"e.g., Smith Family - 123 Main St"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Deal Type"}),e.jsxs($s,{value:O.deal_type,onValueChange:J=>V(X=>({...X,deal_type:J})),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsx(Bs,{children:ONs.map(J=>e.jsx(vt,{value:J.value,children:J.label},J.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Stage"}),e.jsxs($s,{value:O.stage_id||"none",onValueChange:J=>V(X=>({...X,stage_id:J==="none"?"":J})),children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select stage"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"none",children:"No Stage"}),a==null?void 0:a.map(J=>e.jsx(vt,{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(xe,{children:"Link to Contact"}),e.jsxs("div",{className:"relative",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{value:_,onChange:J=>{b(J.target.value),w(!0),C(!1),J.target.value||V(X=>({...X,contact_id:""}))},onFocus:()=>w(!0),placeholder:"Search contacts...",className:"pl-9"}),N&&_&&e.jsxs("div",{className:"absolute z-10 w-full mt-1 bg-background border rounded-lg shadow-lg max-h-60 overflow-y-auto",children:[q&&q.length>0?q.map(J=>e.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left hover:bg-muted flex items-center gap-2",onClick:()=>{V(X=>({...X,contact_id:J.id})),b(`${J.first_name} ${J.last_name}`),w(!1)},children:[e.jsx(Ai,{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=_.trim().split(/\s+/);I({first_name:J[0]||"",last_name:J.slice(1).join(" ")||"",email:"",phone:""}),C(!0),w(!1)},children:[e.jsx(Jo,{className:"h-4 w-4"}),e.jsxs("span",{children:['Create new contact "',_.trim(),'"']})]})]})]}),S&&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(Jo,{className:"h-3.5 w-3.5"}),"Quick Add Contact"]}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>C(!1),children:"Cancel"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(De,{placeholder:"First name *",value:A.first_name,onChange:J=>I(X=>({...X,first_name:J.target.value})),className:"h-8 text-sm"}),e.jsx(De,{placeholder:"Last name",value:A.last_name,onChange:J=>I(X=>({...X,last_name:J.target.value})),className:"h-8 text-sm"}),e.jsx(De,{placeholder:"Email",type:"email",value:A.email,onChange:J=>I(X=>({...X,email:J.target.value})),className:"h-8 text-sm"}),e.jsx(De,{placeholder:"Phone",type:"tel",value:A.phone,onChange:J=>I(X=>({...X,phone:J.target.value})),className:"h-8 text-sm"})]}),e.jsx(W,{type:"button",size:"sm",className:"w-full h-8",disabled:!A.first_name.trim()||i.isPending,onClick:async()=>{try{const J=await i.mutateAsync({first_name:A.first_name.trim(),last_name:A.last_name.trim()||null,email:A.email.trim()||null,phone:A.phone.trim()||null});J&&(V(X=>({...X,contact_id:J.id})),b(`${J.first_name} ${J.last_name||""}`.trim()),C(!1))}catch{}},children:i.isPending?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"h-3.5 w-3.5 mr-1 animate-spin"})," Creating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Jo,{className:"h-3.5 w-3.5 mr-1"})," Add & Link Contact"]})})]})]}),L.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{className:"flex items-center gap-2",children:[e.jsx(Do,{className:"h-4 w-4"}),"Link to Listing Exchange"]}),e.jsxs($s,{value:O.listing_id||"none",onValueChange:J=>{const X=J==="none"?"":J,ce=L.find(ie=>ie.id===X);V(ce?ie=>{var ae;return{...ie,listing_id:X,deal_type:"seller",property_address:ce.property_address||ie.property_address,city:ce.city||ie.city,state:ce.state||ie.state,expected_price:((ae=ce.price)==null?void 0:ae.toString())||ie.expected_price}}:ie=>({...ie,listing_id:X}))},children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select a listing to sync status..."})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"none",children:"None"}),L.map(J=>e.jsx(vt,{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(xe,{htmlFor:"property_address",children:"Address"}),e.jsx(De,{id:"property_address",value:O.property_address,onChange:J=>V(X=>({...X,property_address:J.target.value})),placeholder:"123 Main Street"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"city",children:"City"}),e.jsx(De,{id:"city",value:O.city,onChange:J=>V(X=>({...X,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(xe,{htmlFor:"state",children:"State"}),e.jsx(De,{id:"state",value:O.state,onChange:J=>V(X=>({...X,state:J.target.value})),maxLength:2,placeholder:"TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"zip_code",children:"ZIP"}),e.jsx(De,{id:"zip_code",value:O.zip_code,onChange:J=>V(X=>({...X,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(xe,{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(De,{id:"expected_price",type:"number",value:O.expected_price,onChange:J=>V(X=>({...X,expected_price:J.target.value})),className:"pl-7",placeholder:"500000"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"commission_percentage",children:"Commission %"}),e.jsxs("div",{className:"relative",children:[e.jsx(De,{id:"commission_percentage",type:"number",step:"0.1",value:O.commission_percentage,onChange:J=>V(X=>({...X,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(xe,{children:"Expected GCI"}),e.jsx(De,{value:B()?`$${B().toLocaleString()}`:"-",disabled:!0,className:"bg-muted"})]})]}),e.jsxs("details",{className:"group",children:[e.jsxs("summary",{className:"text-xs font-medium text-muted-foreground cursor-pointer hover:text-foreground flex items-center gap-1 py-1",children:[e.jsx("span",{className:"group-open:rotate-90 transition-transform text-[10px]",children:"▶"}),"Commission Splits (optional)"]}),e.jsxs("div",{className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/50",children:[e.jsx(xe,{className:"text-xs whitespace-nowrap",children:"Calculation Method:"}),e.jsxs($s,{value:O.commission_calc_method,onValueChange:J=>V(X=>({...X,commission_calc_method:J})),children:[e.jsx(zs,{className:"h-7 text-xs",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"standard",children:"Standard (all splits on GCI)"}),e.jsx(vt,{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(xe,{className:"text-xs",children:"Brokerage Split"}),e.jsxs("div",{className:"relative",children:[e.jsx(De,{type:"number",step:"1",min:"0",max:"100",value:O.brokerage_split_pct,onChange:J=>V(X=>({...X,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(xe,{className:"text-xs",children:"Team Split"}),e.jsxs("div",{className:"relative",children:[e.jsx(De,{type:"number",step:"1",min:"0",max:"100",value:O.team_split_pct,onChange:J=>V(X=>({...X,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(xe,{className:"text-xs",children:"Referral Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx(De,{type:"number",step:"1",min:"0",max:"100",value:O.referral_fee_pct,onChange:J=>V(X=>({...X,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(xe,{className:"text-xs",children:"Franchise Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx(De,{type:"number",step:"1",min:"0",max:"100",value:O.franchise_fee_pct,onChange:J=>V(X=>({...X,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(xe,{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(De,{type:"number",step:"1",min:"0",value:O.transaction_fee,onChange:J=>V(X=>({...X,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(xe,{className:"text-xs",children:"Net to Agent"}),e.jsx(De,{value:U()?`$${Math.round(U()).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(xe,{children:"Target Close Date"}),e.jsxs(mo,{children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{variant:"outline",className:Ot("w-full justify-start text-left font-normal",!O.target_close_date&&"text-muted-foreground"),children:[e.jsx(cn,{className:"mr-2 h-4 w-4"}),O.target_close_date?vs(O.target_close_date,"PPP"):"Pick a date"]})}),e.jsx(no,{className:"w-auto p-0",align:"start",children:e.jsx(uf,{mode:"single",selected:O.target_close_date,onSelect:J=>V(X=>({...X,target_close_date:J})),initialFocus:!0,className:"pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Contract Date"}),e.jsxs(mo,{children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{variant:"outline",className:Ot("w-full justify-start text-left font-normal",!O.contract_date&&"text-muted-foreground"),children:[e.jsx(cn,{className:"mr-2 h-4 w-4"}),O.contract_date?vs(O.contract_date,"PPP"):"Pick a date"]})}),e.jsx(no,{className:"w-auto p-0",align:"start",children:e.jsx(uf,{mode:"single",selected:O.contract_date,onSelect:J=>V(X=>({...X,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(xe,{children:"Listing Date (for Days on Market)"}),e.jsxs(mo,{children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{variant:"outline",className:Ot("w-full justify-start text-left font-normal",!O.listing_date&&"text-muted-foreground"),children:[e.jsx(cn,{className:"mr-2 h-4 w-4"}),O.listing_date?vs(O.listing_date,"PPP"):"Pick a date"]})}),e.jsx(no,{className:"w-auto p-0",align:"start",children:e.jsx(uf,{mode:"single",selected:O.listing_date,onSelect:J=>V(X=>({...X,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(xe,{children:"Priority"}),e.jsxs($s,{value:O.priority,onValueChange:J=>V(X=>({...X,priority:J})),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsx(Bs,{children:FNs.map(J=>e.jsx(vt,{value:J.value,children:J.label},J.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Win Probability"}),e.jsxs("div",{className:"relative",children:[e.jsx(De,{type:"number",min:"0",max:"100",value:O.probability,onChange:J=>V(X=>({...X,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(xe,{htmlFor:"notes",children:"Notes"}),e.jsx(_r,{id:"notes",value:O.notes,onChange:J=>V(X=>({...X,notes:J.target.value})),placeholder:"Add any additional notes about this deal...",rows:3})]}),!r&&e.jsx(RNs,{formData:f,onChange:y}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(W,{type:"submit",disabled:Y,children:[Y&&e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),r?"Update Deal":"Create Deal"]})]})]})]})})}function BNs({dealId:t}){const s=ya(),r=Qt(),[n,a]=k.useState(""),[o,l]=k.useState(!1),{data:i=[]}=gt({queryKey:["deal-tags",t],queryFn:async()=>{const{data:b,error:N}=await G.from("deal_tags").select("*").eq("deal_id",t).order("created_at");if(N)throw N;return b},enabled:!!t}),{data:d=[]}=gt({queryKey:["all-deal-tags",s],queryFn:async()=>{if(!s)return[];const{data:b,error:N}=await G.from("deal_tags").select("tag").eq("owner_user_id",s);if(N)throw N;return[...new Set(b.map(S=>S.tag))].sort()},enabled:!!s}),u=Pt({mutationFn:async b=>{if(!s)throw new Error("Not authenticated");const{error:N}=await G.from("deal_tags").insert({deal_id:t,owner_user_id:s,tag:b.trim()});if(N)throw N},onSuccess:()=>{r.invalidateQueries({queryKey:["deal-tags",t]}),r.invalidateQueries({queryKey:["all-deal-tags"]}),a("")}}),p=Pt({mutationFn:async b=>{const{error:N}=await G.from("deal_tags").delete().eq("id",b);if(N)throw N},onSuccess:()=>{r.invalidateQueries({queryKey:["deal-tags",t]})}}),f=()=>{const b=n.trim();b&&(i.some(N=>N.tag.toLowerCase()===b.toLowerCase())||u.mutate(b))},y=i.map(b=>b.tag.toLowerCase()),_=d.filter(b=>b.toLowerCase().includes(n.toLowerCase())&&!y.includes(b.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(b=>e.jsxs(Qe,{variant:"secondary",className:"gap-1 text-xs",children:[b.tag,e.jsx("button",{type:"button",onClick:()=>p.mutate(b.id),className:"ml-0.5 hover:text-destructive",children:e.jsx(kr,{className:"h-3 w-3"})})]},b.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(De,{value:n,onChange:b=>a(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),f()),b.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&&_.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:_.map(b=>e.jsx("button",{type:"button",className:"w-full px-3 py-2 text-left text-xs hover:bg-muted active:bg-muted",onClick:N=>{N.preventDefault(),u.mutate(b)},children:b},b))})]})]})}function $Ns(t){return gt({queryKey:["deal-files",t],queryFn:async()=>{const{data:s,error:r}=await G.from("deal_files").select("*").eq("deal_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function qNs(){const t=ya(),s=Qt();return Pt({mutationFn:async({dealId:r,file:n})=>{if(!t)throw new Error("Not authenticated");const a=n.name.split(".").pop(),o=`${t}/${r}/${crypto.randomUUID()}.${a}`,{error:l}=await G.storage.from("deal-files").upload(o,n);if(l)throw l;const{data:i,error:d}=await G.from("deal_files").insert({deal_id:r,owner_user_id:t,file_name:n.name,file_size:n.size,file_type:n.type||null,storage_path:o}).select().single();if(d)throw d;return i},onSuccess:(r,n)=>{s.invalidateQueries({queryKey:["deal-files",n.dealId]})}})}function UNs(){const t=Qt();return Pt({mutationFn:async({fileId:s,storagePath:r,dealId:n})=>{await G.storage.from("deal-files").remove([r]);const{error:a}=await G.from("deal_files").delete().eq("id",s);if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["deal-files",s]})}})}function VNs(){const t=Qt();return Pt({mutationFn:async({fileId:s,visible:r,dealId:n})=>{const{error:a}=await G.from("deal_files").update({visible_on_portal:r}).eq("id",s);if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["deal-files",s]})}})}async function HNs(t){const{data:s,error:r}=await G.storage.from("deal-files").createSignedUrl(t,3600);if(r)throw r;return s.signedUrl}const a9e={text:"Short Text",textarea:"Long Text",dropdown:"Dropdown",toggle:"Yes / No"};function GNs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=Wbs(),a=Kbs(),o=Zbs(),l=Ybs(),[i,d]=k.useState(!1),[u,p]=k.useState({question_text:"",field_type:"text",options:[],is_required:!1}),[f,y]=k.useState(""),_=async()=>{if(u.question_text.trim())try{await a.mutateAsync({question_text:u.question_text.trim(),field_type:u.field_type,options:u.field_type==="dropdown"?u.options:[],is_required:u.is_required,sort_order:((r==null?void 0:r.length)||0)+1}),p({question_text:"",field_type:"text",options:[],is_required:!1}),y(""),d(!1),pe.success("Question added")}catch{pe.error("Failed to add question")}},b=async C=>{try{await l.mutateAsync(C),pe.success("Question removed")}catch{pe.error("Failed to remove question")}},N=async(C,A)=>{try{await o.mutateAsync({id:C,is_required:A})}catch{pe.error("Failed to update question")}},w=()=>{f.trim()&&(p(C=>({...C,options:[...C.options,f.trim()]})),y(""))},S=C=>{p(A=>({...A,options:A.options.filter((I,L)=>L!==C)}))};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(ks,{children:[e.jsx(_s,{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(Ja,{className:"flex-1",children:e.jsxs("div",{className:"space-y-3 pr-2",children:[n&&e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(us,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),r==null?void 0:r.map(C=>{var A;return e.jsx("div",{className:"border rounded-lg p-3 space-y-2",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(mu,{className:"h-4 w-4 text-muted-foreground/40 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:C.question_text}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(Qe,{variant:"secondary",className:"text-xs",children:a9e[C.field_type]||C.field_type}),C.is_required&&e.jsx(Qe,{variant:"outline",className:"text-xs",children:"Required"})]}),C.field_type==="dropdown"&&((A=C.options)==null?void 0:A.length)>0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Options: ",C.options.join(", ")]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(Ar,{checked:C.is_required,onCheckedChange:I=>N(C.id,I),className:"scale-75"}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:()=>b(C.id),children:e.jsx(vr,{className:"h-3.5 w-3.5"})})]})]})},C.id)}),!n&&(r==null?void 0:r.length)===0&&!i&&e.jsxs("div",{className:"text-center py-8 border border-dashed rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"No custom questions yet"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add questions that clients will answer during onboarding."})]}),i&&e.jsxs("div",{className:"border-2 border-primary/20 rounded-lg p-4 space-y-3 bg-primary/5",children:[e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm font-medium",children:"Question"}),e.jsx(De,{value:u.question_text,onChange:C=>p(A=>({...A,question_text:C.target.value})),className:"mt-1",placeholder:"e.g., Do you have a home to sell first?",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm font-medium",children:"Answer Type"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:Object.entries(a9e).map(([C,A])=>e.jsx("button",{type:"button",onClick:()=>p(I=>({...I,field_type:C,options:[]})),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${u.field_type===C?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:A},C))})]}),u.field_type==="dropdown"&&e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm font-medium",children:"Options"}),e.jsxs("div",{className:"space-y-1.5 mt-1.5",children:[u.options.map((C,A)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"flex-1 text-sm bg-muted/50 rounded px-2 py-1",children:C}),e.jsx("button",{onClick:()=>S(A),className:"text-muted-foreground hover:text-destructive",children:e.jsx(kr,{className:"h-3.5 w-3.5"})})]},A)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{value:f,onChange:C=>y(C.target.value),onKeyDown:C=>C.key==="Enter"&&(C.preventDefault(),w()),placeholder:"Add option...",className:"h-8 text-sm"}),e.jsx(W,{variant:"outline",size:"sm",onClick:w,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(Ar,{checked:u.is_required,onCheckedChange:C=>p(A=>({...A,is_required:C}))}),e.jsx(xe,{className:"text-xs text-muted-foreground",children:"Required"})]})}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(W,{variant:"outline",size:"sm",onClick:()=>d(!1),className:"flex-1",children:"Cancel"}),e.jsxs(W,{size:"sm",onClick:_,disabled:!u.question_text.trim()||a.isPending,className:"flex-1",children:[a.isPending?e.jsx(us,{className:"h-3 w-3 mr-1 animate-spin"}):null,"Add Question"]})]})]})]})}),e.jsxs("div",{className:"flex justify-between pt-4 border-t shrink-0",children:[i?e.jsx("div",{}):e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>d(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Add Question"]}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>s(!1),children:"Done"})]})]})})}function WNs({portalId:t,ownerId:s,clientEmail:r,linkedPortalId:n,onLink:a}){const[o,l]=k.useState(""),[i,d]=k.useState(!1),{data:u,isLoading:p}=gt({queryKey:["all-owner-portals",s],queryFn:async()=>{const{data:b,error:N}=await G.from("client_portals").select(` id, slug, client_name, client_email, deal_id, archived_at, deal_pipeline (id, deal_name, deal_type, property_address) `).eq("owner_user_id",s).neq("id",t).is("archived_at",null).eq("is_enabled",!0);if(N)throw N;return b},enabled:i||!!n}),f=k.useMemo(()=>!n||!u?null:u.find(b=>b.id===n),[n,u]),y=k.useMemo(()=>!u||!r?[]:u.filter(b=>{var N;return((N=b.client_email)==null?void 0:N.toLowerCase())===r.toLowerCase()&&b.id!==t}),[u,r,t]),_=k.useMemo(()=>{if(!u||!o.trim())return[];const b=o.toLowerCase();return u.filter(N=>{var S,C,A,I;const w=N.deal_pipeline;return((S=N.client_name)==null?void 0:S.toLowerCase().includes(b))||((C=N.client_email)==null?void 0:C.toLowerCase().includes(b))||((A=w==null?void 0:w.deal_name)==null?void 0:A.toLowerCase().includes(b))||((I=w==null?void 0:w.property_address)==null?void 0:I.toLowerCase().includes(b))})},[u,o]);if(n){const b=f==null?void 0:f.deal_pipeline;return e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{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(Do,{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)||(b==null?void 0:b.deal_name)||"Linked Portal"}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[(b==null?void 0:b.deal_type)==="listing"?"🏠 Listing":"🔑 Purchase"," · ",(b==null?void 0:b.property_address)||"No address"]})]}),e.jsxs(W,{variant:"ghost",size:"sm",className:"text-xs text-destructive hover:text-destructive shrink-0",onClick:()=>a(null),children:[e.jsx(jS,{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(xe,{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(W,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>d(!i),children:[e.jsx(Do,{className:"h-3 w-3 mr-1"}),i?"Cancel":"Link"]})]}),!i&&y.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)"}),y.map(b=>{const N=b.deal_pipeline;return e.jsxs("button",{onClick:()=>a(b.id),className:"w-full flex items-center gap-2 bg-amber-50 border border-amber-200 rounded-lg p-2.5 hover:bg-amber-100 transition-colors text-left",children:[e.jsx(Qe,{variant:"outline",className:"text-[10px] shrink-0 bg-amber-100 border-amber-300 text-amber-700",children:(N==null?void 0:N.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:(N==null?void 0:N.deal_name)||b.client_name}),e.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:N==null?void 0:N.property_address})]}),e.jsx(Do,{className:"h-3.5 w-3.5 text-amber-600 shrink-0"})]},b.id)})]}),i&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(ln,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(De,{value:o,onChange:b=>l(b.target.value),placeholder:"Search by name, email, or address...",className:"pl-8 h-8 text-xs",autoFocus:!0})]}),p&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(us,{className:"h-4 w-4 animate-spin text-muted-foreground"})}),_.length>0&&e.jsx("div",{className:"space-y-1 max-h-[200px] overflow-y-auto",children:_.map(b=>{const N=b.deal_pipeline;return e.jsxs("button",{onClick:()=>{a(b.id),d(!1),l("")},className:"w-full flex items-center gap-2 border rounded-lg p-2 hover:bg-muted/50 transition-colors text-left",children:[e.jsx(Qe,{variant:"outline",className:"text-[10px] shrink-0",children:(N==null?void 0:N.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:(N==null?void 0:N.deal_name)||b.client_name}),e.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:b.client_email})]})]},b.id)})}),o&&_.length===0&&!p&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:"No portals found"})]})]})}function zCe({userId:t,onSelect:s,triggerLabel:r="Library",triggerSize:n="sm",triggerVariant:a="outline",triggerClassName:o}){const[l,i]=k.useState(!1),[d,u]=k.useState([]),[p,f]=k.useState(!1),[y,_]=k.useState("");k.useEffect(()=>{!l||!t||(f(!0),G.from("agent_videos").select("id, title, recipient_name, playback_url, thumbnail_url, created_at, duration_seconds").eq("owner_user_id",t).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1}).limit(50).then(({data:N})=>{u(N||[]),f(!1)}))},[l,t]);const b=d.filter(N=>!y||(N.title||N.recipient_name||"").toLowerCase().includes(y.toLowerCase()));return e.jsxs(fs,{open:l,onOpenChange:i,children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{variant:a,size:n,className:o||"gap-1.5 shrink-0",children:[e.jsx(Rd,{className:"h-3.5 w-3.5"}),r]})}),e.jsxs(ps,{className:"max-w-lg max-h-[70vh] flex flex-col",children:[e.jsxs(ks,{children:[e.jsx(_s,{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(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search videos...",value:y,onChange:N=>_(N.target.value),className:"pl-10"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto space-y-2 min-h-0",children:p?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"h-16 w-full"}),e.jsx(Ms,{className:"h-16 w-full"})]}):b.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:d.length===0?"No videos in your library yet":"No videos match your search"}):b.map(N=>e.jsxs("button",{onClick:()=>{s(N.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:N.thumbnail_url?e.jsx("img",{src:N.thumbnail_url,alt:"",className:"w-full h-full object-cover",referrerPolicy:"no-referrer",onError:w=>{const S=w.currentTarget.parentElement;if(S){w.currentTarget.remove();const C=document.createElement("span");C.innerHTML="🎬",C.className="text-lg",S.appendChild(C)}}}):e.jsx(yn,{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:N.title||N.recipient_name||"Untitled Video"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[N.duration_seconds?`${Math.round(N.duration_seconds)}s`:"",N.created_at?` · ${new Date(N.created_at).toLocaleDateString()}`:""]})]})]},N.id))})]})]})}function BCe({contactId:t,onVideoReady:s}){const[r,n]=k.useState(!1),[a,o]=k.useState("record"),[l,i]=k.useState(0),[d,u]=k.useState(0),p=Mw(),f=()=>{o("record"),i(0),u(0)},y=b=>{!b&&(a==="uploading"||a==="processing")||(n(b),b||f())},_=k.useCallback(async(b,N)=>{o("uploading");try{const w="Card Video",{videoId:S,libraryId:C}=await wE(w),{uploadUrl:A,apiKey:I}=await jE(S),L=new XMLHttpRequest;L.upload.onprogress=Y=>{Y.lengthComputable&&i(Y.loaded/Y.total*100)},await new Promise((Y,J)=>{L.onload=()=>L.status>=200&&L.status<300?Y():J(new Error("Upload failed")),L.onerror=()=>J(new Error("Upload failed")),L.open("PUT",A),L.setRequestHeader("AccessKey",I),L.send(b)}),o("processing");let O=0;const V=Date.now(),q=9e4,B=`https://iframe.mediadelivery.net/embed/${C}/${S}`;for(;O<4;){if(await new Promise(J=>setTimeout(J,3e3)),Date.now()-V>q){const J=b.size/1048576;await p.mutateAsync({bunny_video_id:S,playback_url:`https://iframe.mediadelivery.net/play/${C}/${S}`,file_size_mb:J,title:w,contact_id:t||void 0,status:"processing",touch_type:"video"}),s(B),pe.success("Video saved — still encoding. It will be ready shortly."),o("done"),setTimeout(()=>{n(!1),f()},1500);return}const Y=await nw(S);if(O=Y.status,u(Y.encodeProgress||0),O===5||O===6)throw new Error("Video processing failed")}const U=await nw(S),te=(U.storageSize||b.size)/(1024*1024);await p.mutateAsync({bunny_video_id:S,contact_id:t||void 0,playback_url:U.directPlayUrl||B,thumbnail_url:U.thumbnailUrl,preview_url:U.previewUrl||null,duration_seconds:U.length||N,file_size_mb:te,title:w,status:"ready",touch_type:"video"}),s(B),pe.success("Video recorded & added to your library!"),o("done"),setTimeout(()=>{n(!1),f()},1500)}catch(w){console.error("Recording upload error:",w),pe.error("Failed to process video. Please try again."),o("record")}},[t,s,p]);return e.jsxs(fs,{open:r,onOpenChange:y,children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{variant:"outline",size:"sm",className:"gap-1.5 w-full",children:[e.jsx(yn,{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(ks,{children:e.jsx(_s,{children:"Record a Video for Your Card"})}),a==="record"&&e.jsx(AO,{maxDurationSeconds:600,onRecordingComplete:_,onError:b=>pe.error(b)}),a==="uploading"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(us,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Uploading video..."}),e.jsx(xi,{value:l,className:"w-64"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Math.round(l),"%"]})]}),a==="processing"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(us,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Processing video..."}),e.jsx(xi,{value:d,className:"w-64"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Math.round(d),"%"]})]}),a==="done"&&e.jsxs("div",{className:"flex flex-col items-center gap-3 py-12",children:[e.jsx(si,{className:"h-12 w-12 text-emerald-500"}),e.jsx("p",{className:"text-sm font-medium",children:"Video attached to your card!"})]})]})]})}const KNs=t=>`portal-settings-draft:${t}`;function Clt({open:t,onOpenChange:s,portal:r,dealOwnerId:n}){const a=bO(),[o,l]=k.useState(!1),i=k.useMemo(()=>KNs(r.id),[r.id]),[d,u]=k.useState(!1),[p,f]=k.useState(r.next_step_text||""),[y,_]=k.useState(r.next_step_video_url||""),[b,N]=k.useState(r.inspection_date||""),[w,S]=k.useState(r.appraisal_date||""),[C,A]=k.useState(r.welcome_message||""),[I,L]=k.useState(r.review_url||""),[O,V]=k.useState(r.show_post_close_tips),[q,B]=k.useState(r.notify_client),[U,te]=k.useState(r.require_onboarding),[Y,J]=k.useState(r.allow_spouse),[X,ce]=k.useState(r.visibility),[ie,ae]=k.useState(r.stage_mapping||[]),[oe,me]=k.useState(null),[ve,he]=k.useState(r.linked_portal_id||null),[ge,je]=k.useState(r.referral_enabled??!0),[qe,Me]=k.useState(r.referral_reward_text||""),[ke,Re]=k.useState(r.referral_cta_headline||""),[Ve,Ne]=k.useState(r.homeowner_hub_video_url||""),Ue=()=>{f(r.next_step_text||""),_(r.next_step_video_url||""),N(r.inspection_date||""),S(r.appraisal_date||""),A(r.welcome_message||""),L(r.review_url||""),V(r.show_post_close_tips),B(r.notify_client),te(r.require_onboarding),J(r.allow_spouse),ce(r.visibility),ae(r.stage_mapping||[]),he(r.linked_portal_id||null),je(r.referral_enabled??!0),Me(r.referral_reward_text||""),Re(r.referral_cta_headline||""),Ne(r.homeowner_hub_video_url||"")};k.useEffect(()=>{u(!1);const tt=localStorage.getItem(i);if(tt)try{const Te=JSON.parse(tt);f(Te.nextStepText||""),_(Te.nextStepVideo||""),N(Te.inspectionDate||""),S(Te.appraisalDate||""),A(Te.welcomeMessage||""),L(Te.reviewUrl||""),V(!!Te.showPostClose),B(!!Te.notifyClient),te(!!Te.requireOnboarding),J(!!Te.allowSpouse),ce(Te.visibility||r.visibility),ae(Te.stageMapping||[]),he(Te.linkedPortalId??null),je(Te.referralEnabled??!0),Me(Te.referralRewardText||""),Re(Te.referralCtaHeadline||""),Ne(Te.homeownerHubVideoUrl||""),u(!0);return}catch{localStorage.removeItem(i)}Ue(),u(!0)},[i,r]),k.useEffect(()=>{if(!d)return;const tt={nextStepText:p,nextStepVideo:y,inspectionDate:b,appraisalDate:w,welcomeMessage:C,reviewUrl:I,showPostClose:O,notifyClient:q,requireOnboarding:U,allowSpouse:Y,visibility:X,stageMapping:ie,linkedPortalId:ve,referralEnabled:ge,referralRewardText:qe,referralCtaHeadline:ke,homeownerHubVideoUrl:Ve};p!==(r.next_step_text||"")||y!==(r.next_step_video_url||"")||b!==(r.inspection_date||"")||w!==(r.appraisal_date||"")||C!==(r.welcome_message||"")||I!==(r.review_url||"")||O!==r.show_post_close_tips||q!==r.notify_client||U!==r.require_onboarding||Y!==r.allow_spouse||X!==r.visibility||JSON.stringify(ie)!==JSON.stringify(r.stage_mapping||[])||ve!==(r.linked_portal_id||null)||ge!==(r.referral_enabled??!0)||qe!==(r.referral_reward_text||"")||ke!==(r.referral_cta_headline||"")||Ve!==(r.homeowner_hub_video_url||"")?localStorage.setItem(i,JSON.stringify(tt)):localStorage.removeItem(i)},[p,y,b,w,C,I,O,q,U,Y,X,ie,ve,ge,qe,ke,Ve,i,d,r]);const Ie=()=>{localStorage.removeItem(i),Ue()},ye=async()=>{try{await a.mutateAsync({id:r.id,next_step_text:p||null,next_step_video_url:y||null,inspection_date:b||null,appraisal_date:w||null,welcome_message:C||null,review_url:I||null,show_post_close_tips:O,notify_client:q,require_onboarding:U,allow_spouse:Y,visibility:X,stage_mapping:ie.length>0?ie:null,linked_portal_id:ve,referral_enabled:ge,referral_reward_text:qe||null,referral_cta_headline:ke||null,homeowner_hub_video_url:Ve||null});const tt=r.linked_portal_id;ve&&ve!==tt&&await G.from("client_portals").update({linked_portal_id:r.id}).eq("id",ve),!ve&&tt&&await G.from("client_portals").update({linked_portal_id:null}).eq("id",tt),localStorage.removeItem(i),pe.success("Portal settings saved"),s(!1)}catch{pe.error("Failed to save settings")}},ct=()=>{ae([...ie,{label:""}])},fe=tt=>{ae(ie.filter((Te,We)=>We!==tt)),oe===tt&&me(null)},$e=(tt,Te,We)=>{const Ke=[...ie];Ke[tt]={...Ke[tt],[Te]:We},ae(Ke)},Ye=()=>{const Te=FNe(null).map(We=>({label:We.label,description:We.description,stageId:void 0}));ae(Te)};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(ks,{children:e.jsx(_s,{children:"Portal Settings"})}),e.jsxs(ta,{defaultValue:"general",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(Jn,{className:"grid grid-cols-3 shrink-0",children:[e.jsx(cs,{value:"general",children:"General"}),e.jsx(cs,{value:"timeline",children:"Timeline"}),e.jsx(cs,{value:"content",children:"Content"})]}),e.jsxs(Ja,{className:"flex-1 mt-4",children:[e.jsxs(Ss,{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(xe,{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(tt=>e.jsx("button",{onClick:()=>ce(tt),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${X===tt?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:tt.charAt(0).toUpperCase()+tt.slice(1)},tt))})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(xe,{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(Ar,{checked:U,onCheckedChange:te})]}),U&&e.jsxs("div",{className:"flex items-center justify-between pl-4 border-l-2 border-primary/20",children:[e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm font-medium",children:"Custom Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Manage intake form questions"})]}),e.jsx(W,{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(xe,{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(Ar,{checked:Y,onCheckedChange:J})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(xe,{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(Ar,{checked:O,onCheckedChange:V})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(xe,{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(Ar,{checked:q,onCheckedChange:B})]}),e.jsx("div",{className:"border-t pt-4",children:e.jsx(WNs,{portalId:r.id,ownerId:n,clientEmail:r.client_email,linkedPortalId:ve,onLink:he})}),e.jsx("div",{children:e.jsx(De,{type:"date",value:b,onChange:tt=>N(tt.target.value),className:"mt-1"})}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm font-medium",children:"Appraisal Date"}),e.jsx(De,{type:"date",value:w,onChange:tt=>S(tt.target.value),className:"mt-1"})]})]}),e.jsx(Ss,{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(xe,{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(W,{variant:"outline",size:"sm",onClick:Ye,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.'}),ie.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(W,{variant:"outline",size:"sm",onClick:Ye,children:"Customize journey labels"})]}),e.jsx("div",{className:"space-y-2 mt-2",children:ie.map((tt,Te)=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mu,{className:"h-4 w-4 text-muted-foreground/50 flex-shrink-0"}),e.jsx(De,{value:tt.label,onChange:We=>$e(Te,"label",We.target.value),placeholder:`Stage ${Te+1} label`,className:"flex-1 h-9 text-sm"}),e.jsx(W,{variant:"ghost",size:"sm",className:"h-9 px-2 text-xs text-muted-foreground hover:text-primary",onClick:()=>me(oe===Te?null:Te),children:oe===Te?"Less":"More"}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-9 w-9 text-muted-foreground hover:text-destructive",onClick:()=>fe(Te),children:e.jsx(vr,{className:"h-3.5 w-3.5"})})]}),oe===Te&&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(xe,{className:"text-xs text-muted-foreground",children:"Description"}),e.jsx("textarea",{value:tt.description||"",onChange:We=>$e(Te,"description",We.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(xe,{className:"text-xs text-muted-foreground",children:"Video"}),tt.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:tt.video_url.length>40?tt.video_url.slice(0,40)+"...":tt.video_url}),e.jsx(W,{variant:"ghost",size:"sm",className:"h-7 text-xs text-destructive hover:text-destructive",onClick:()=>$e(Te,"video_url",""),children:"Remove"})]}):e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx(BCe,{onVideoReady:We=>$e(Te,"video_url",We)}),e.jsx(zCe,{userId:n,onSelect:We=>$e(Te,"video_url",We),triggerSize:"sm",triggerClassName:"gap-1.5 shrink-0 flex-1"}),e.jsxs(W,{variant:"ghost",size:"sm",className:"gap-1 text-xs text-muted-foreground flex-1",onClick:()=>{const We=prompt("Paste a YouTube or Loom URL:");We&&$e(Te,"video_url",We)},children:[e.jsx(vo,{className:"h-3 w-3"}),"Paste URL"]})]})]})]})]},Te))}),ie.length>0&&e.jsxs(W,{variant:"outline",size:"sm",onClick:ct,className:"mt-2 text-xs w-full",children:[e.jsx(qs,{className:"h-3 w-3 mr-1"})," Add Stage"]})]})}),e.jsxs(Ss,{value:"content",className:"space-y-4 mt-0 px-1",children:[e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm font-medium",children:"Welcome Message"}),e.jsx("textarea",{value:C,onChange:tt=>A(tt.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(xe,{className:"text-sm font-medium",children:"What's Next"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Tell your client what to expect next"}),e.jsx("textarea",{value:p,onChange:tt=>f(tt.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(xe,{className:"text-sm font-medium",children:"Next Step Video (optional)"}),e.jsx(De,{value:y,onChange:tt=>_(tt.target.value),className:"mt-1",placeholder:"YouTube or Loom URL"})]}),e.jsxs("div",{children:[e.jsx(xe,{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(De,{value:I,onChange:tt=>L(tt.target.value),className:"mt-1",placeholder:"https://g.page/r/..."})]}),e.jsxs("div",{className:"border-t pt-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-base",children:"🎁"}),e.jsx(xe,{className:"text-sm font-semibold",children:"Homeowner Hub & Referrals"})]}),e.jsx("p",{className:"text-xs text-muted-foreground -mt-2",children:'Shown automatically when the deal is in a "won" stage.'}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm font-medium",children:"Show Referral Card"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Big CTA asking client to refer friends"})]}),e.jsx(Ar,{checked:ge,onCheckedChange:je})]}),ge&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm font-medium",children:"Headline"}),e.jsx(De,{value:ke,onChange:tt=>Re(tt.target.value),className:"mt-1",placeholder:"Know someone buying or selling?"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm font-medium",children:"Reward (optional)"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"What the client gets for a successful referral"}),e.jsx(De,{value:qe,onChange:tt=>Me(tt.target.value),className:"mt-1",placeholder:"$250 gift card • Donation to your charity • Closing gift"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm font-medium",children:"Personal Welcome Video URL (optional)"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:'A "welcome home" video shown above the referral card'}),e.jsx(De,{value:Ve,onChange:tt=>Ne(tt.target.value),className:"mt-1",placeholder:"YouTube, Loom, or direct video URL"})]})]})]})]})]})]}),e.jsxs("div",{className:"flex justify-between gap-2 pt-4 border-t shrink-0",children:[e.jsx(W,{variant:"ghost",onClick:Ie,children:"Reset Draft"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{variant:"outline",onClick:()=>s(!1),children:"Close"}),e.jsxs(W,{onClick:ye,disabled:a.isPending,children:[a.isPending?e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(bc,{className:"h-4 w-4 mr-2"}),"Save Settings"]})]})]})]})}),e.jsx(GNs,{open:o,onOpenChange:l})]})}const ZNs=t=>`portal-update-draft:${t}`;function Mlt({open:t,onOpenChange:s,portalId:r,portalSlug:n,notifyClient:a}){const o=k.useMemo(()=>ZNs(r),[r]),[l,i]=k.useState(""),[d,u]=k.useState(""),[p,f]=k.useState(""),[y,_]=k.useState(!1),[b,N]=k.useState(a??!1),[w,S]=k.useState(!1),C=iit();k.useEffect(()=>{S(!1);const L=localStorage.getItem(o);if(L)try{const O=JSON.parse(L);i(O.title||""),u(O.content||""),f(O.videoUrl||""),_(!!O.isStageChange),N(typeof O.sendNotification=="boolean"?O.sendNotification:a??!1),S(!0);return}catch{localStorage.removeItem(o)}i(""),u(""),f(""),_(!1),N(a??!1),S(!0)},[o,a]),k.useEffect(()=>{if(!w)return;const L={title:l,content:d,videoUrl:p,isStageChange:y,sendNotification:b};l.trim()||d.trim()||p.trim()||y||b!==(a??!1)?localStorage.setItem(o,JSON.stringify(L)):localStorage.removeItem(o)},[l,d,p,y,b,w,o,a]);const A=()=>{localStorage.removeItem(o),i(""),u(""),f(""),_(!1),N(a??!1)},I=async()=>{if(l.trim())try{if(await C.mutateAsync({portal_id:r,title:l.trim(),content:d.trim()||void 0,video_url:p.trim()||void 0,is_stage_change:y}),b&&n)try{const L=o1(n);await G.functions.invoke("send-portal-notification",{body:{portal_id:r,update_title:l.trim(),update_content:d.trim()||null,portal_url:L}}),pe.success("Update posted & client notified")}catch(L){console.error("Notification failed:",L),pe.success("Update posted (notification failed to send)")}else pe.success("Update posted to portal");A(),s(!1)}catch{pe.error("Failed to post update")}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-md",children:[e.jsx(ks,{children:e.jsx(_s,{children:"Post Portal Update"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm font-medium",children:"Title *"}),e.jsx(De,{value:l,onChange:L=>i(L.target.value),className:"mt-1",placeholder:"Inspection cleared!"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm font-medium",children:"Message"}),e.jsx("textarea",{value:d,onChange:L=>u(L.target.value),className:"mt-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[80px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"Everything looked great during the inspection..."})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm font-medium",children:"Video URL (optional)"}),e.jsxs("div",{className:"relative mt-1",children:[e.jsx(De,{value:p,onChange:L=>f(L.target.value),className:"pl-9",placeholder:"YouTube or Loom link"}),e.jsx(yn,{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),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${y?"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:()=>N(!b),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors flex items-center gap-1.5 ${b?"bg-blue-500/10 text-blue-700 border-blue-200":"bg-background text-muted-foreground border-input"}`,children:[b?e.jsx(Sm,{className:"h-3 w-3"}):e.jsx(Wv,{className:"h-3 w-3"}),b?"Notify Client":"No Notification"]})]})]}),e.jsxs("div",{className:"flex justify-between gap-2 pt-2",children:[e.jsx(W,{variant:"ghost",onClick:A,children:"Clear Draft"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{variant:"outline",onClick:()=>s(!1),children:"Close"}),e.jsxs(W,{onClick:I,disabled:!l.trim()||C.isPending,children:[C.isPending?e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(_n,{className:"h-4 w-4 mr-2"}),"Post Update"]})]})]})]})})}function Tlt({open:t,onOpenChange:s,portal:r,dealName:n}){const a=bO(),{isGmailConnected:o,gmailEmail:l}=Om(),[i,d]=k.useState(r.client_name||""),[u,p]=k.useState(r.client_email||""),[f,y]=k.useState(!1),[_,b]=k.useState(!1),N=o1(r.slug),w=i.split(" ")[0]||"there",S=`Your Transaction Portal – ${n}`,C=`Hi ${w}, I've set up a dedicated portal where you can track the progress of your transaction in real-time. Here's your link: ${N} You can view your timeline, key dates, documents, and any updates I post along the way. Let me know if you have any questions!`,A=()=>{navigator.clipboard.writeText(N),b(!0),setTimeout(()=>b(!1),2e3),pe.success("Portal link copied!")},I=async()=>{if(!u.trim()){pe.error("Please enter the client email");return}y(!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 G.functions.invoke("gmail-send",{body:{to:u,subject:S,body:C.replace(/\n/g,"
")}});if(O)throw O;pe.success(`Invite sent to ${u}`),s(!1)}catch(O){pe.error(O.message||"Failed to send invite")}finally{y(!1)}},L=()=>{const O=encodeURIComponent(S),V=encodeURIComponent(C);window.open(`mailto:${u}?subject=${O}&body=${V}`,"_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(ks,{children:e.jsx(_s,{children:"Invite Client to Portal"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm font-medium",children:"Client Name"}),e.jsx(De,{value:i,onChange:O=>d(O.target.value),className:"mt-1",placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm font-medium",children:"Client Email"}),e.jsx(De,{type:"email",value:u,onChange:O=>p(O.target.value),className:"mt-1",placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(xe,{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:N})}),e.jsx(W,{variant:"outline",size:"icon",onClick:A,className:"shrink-0",children:_?e.jsx(Zn,{className:"h-4 w-4 text-emerald-600"}):e.jsx(Va,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[o?e.jsxs(W,{onClick:I,disabled:f||!u.trim(),className:"w-full",children:[f?e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Send via Gmail (",l,")"]}):e.jsxs(W,{onClick:L,disabled:!u.trim(),className:"w-full",variant:"outline",children:[e.jsx(Yr,{className:"h-4 w-4 mr-2"}),"Open in Email App"]}),e.jsxs(W,{variant:"ghost",onClick:A,className:"w-full text-muted-foreground",children:[e.jsx(Va,{className:"h-4 w-4 mr-2"}),"Just Copy Link"]})]})]})]})})}function YNs({deal:t}){const{isAdmin:s,user:r}=Us(),{data:n,isLoading:a}=Ubs(t.id),o=BSe(),l=bO(),[i,d]=k.useState(!1),[u,p]=k.useState(!1),[f,y]=k.useState(!1),[_,b]=k.useState(!1),N=`portal-management-ui:${t.id}`;if(k.useEffect(()=>{const O=sessionStorage.getItem(N);if(O)try{const V=JSON.parse(O);p(!!V.settingsOpen),y(!!V.composerOpen),b(!!V.inviteOpen)}catch{sessionStorage.removeItem(N)}},[N]),k.useEffect(()=>{u||f||_?sessionStorage.setItem(N,JSON.stringify({settingsOpen:u,composerOpen:f,inviteOpen:_})):sessionStorage.removeItem(N)},[u,f,_,N]),a)return e.jsx("div",{className:"border rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Or,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(us,{className:"h-3 w-3 animate-spin ml-auto"})]})});const w=async()=>{var O,V;d(!0);try{await o.mutateAsync({deal_id:t.id,visibility:"private",require_onboarding:!0,client_name:t.contact?`${t.contact.first_name} ${t.contact.last_name}`:void 0,client_email:((O=t.contact)==null?void 0:O.email)||void 0,client_phone:((V=t.contact)==null?void 0:V.phone)||void 0}),pe.success("Client portal enabled!")}catch{pe.error("Failed to create portal")}finally{d(!1)}},S=async O=>{if(n)try{await l.mutateAsync({id:n.id,is_enabled:O}),pe.success(O?"Portal enabled":"Portal disabled")}catch{pe.error("Failed to update portal")}},C=()=>{if(!n)return;const O=o1(n.slug);navigator.clipboard.writeText(O),pe.success("Portal link copied!")},A=()=>{if(!n)return;const O=o1(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(Or,{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(W,{onClick:w,disabled:i,size:"sm",className:"w-full",children:[i?e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Or,{className:"h-4 w-4 mr-2"}),"Enable Client Portal"]})]});const I=o1(n.slug),L=(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(Or,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(Qe,{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(Ar,{checked:n.is_enabled,onCheckedChange:S})]}),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(Qe,{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(W,{variant:"outline",size:"sm",onClick:C,className:"text-xs flex-1 min-w-0",children:[e.jsx(Va,{className:"h-3 w-3 mr-1 shrink-0"}),"Copy"]}),e.jsxs(W,{variant:"outline",size:"sm",onClick:A,className:"text-xs flex-1 min-w-0",children:[e.jsx(Yr,{className:"h-3 w-3 mr-1 shrink-0"}),"Preview"]}),e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>b(!0),className:"text-xs flex-1 min-w-0",children:[e.jsx(_n,{className:"h-3 w-3 mr-1 shrink-0"}),"Invite"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(W,{variant:"ghost",size:"sm",onClick:()=>y(!0),className:"text-xs text-muted-foreground flex-1 min-w-0",children:[e.jsx(IM,{className:"h-3 w-3 mr-1 shrink-0"}),"Post Update"]}),e.jsxs(W,{variant:"ghost",size:"sm",onClick:()=>p(!0),className:"text-xs text-muted-foreground flex-1 min-w-0",children:[e.jsx(So,{className:"h-3 w-3 mr-1 shrink-0"}),"Settings"]})]}),e.jsxs(da,{to:"/mission-control/portal-referrals",className:"mt-2 flex items-center justify-center gap-1.5 text-[11px] text-muted-foreground hover:text-primary transition-colors py-1.5",children:[e.jsx(hi,{className:"h-3 w-3"}),"View incoming referrals"]})]}),e.jsx(Clt,{open:u,onOpenChange:p,portal:n,dealOwnerId:L}),e.jsx(Mlt,{open:f,onOpenChange:y,portalId:n.id,portalSlug:n.slug,notifyClient:n.notify_client}),e.jsx(Tlt,{open:_,onOpenChange:b,portal:n,dealName:t.deal_name})]})}const XNs=["Client","Co-Buyer","Co-Seller","Spouse","Lender","Title Company","Inspector","Appraiser","Attorney","Contractor","Other"];function QNs(t){return gt({queryKey:["deal-contacts",t],queryFn:async()=>{const{data:s,error:r}=await G.from("deal_contacts").select(` id, deal_id, contact_id, role, created_at, contact:innercircle_contacts(id, first_name, last_name, email, phone) `).eq("deal_id",t).order("created_at");if(r)throw r;return s||[]},enabled:!!t})}function JNs(){const t=Qt();return Pt({mutationFn:async({dealId:s,contactId:r,role:n})=>{const{data:a,error:o}=await G.from("deal_contacts").insert({deal_id:s,contact_id:r,role:n}).select().single();if(o)throw o;return a},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-contacts",r.dealId]}),pe.success("Contact linked to deal")},onError:s=>{var r;(r=s.message)!=null&&r.includes("duplicate")?pe.error("This contact is already linked to this deal"):pe.error("Failed to link contact")}})}function eks(){const t=Qt();return Pt({mutationFn:async({id:s,dealId:r})=>{const{error:n}=await G.from("deal_contacts").delete().eq("id",s);if(n)throw n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-contacts",r.dealId]}),pe.success("Contact removed from deal")},onError:()=>{pe.error("Failed to remove contact")}})}function tks({dealId:t,primaryContactId:s}){const r=wr(),{data:n,isLoading:a}=QNs(t),{data:o}=qh(),l=JNs(),i=eks(),[d,u]=k.useState(!1),[p,f]=k.useState(""),[y,_]=k.useState("Client"),b=new Set((n==null?void 0:n.map(A=>A.contact_id))||[]);s&&b.add(s);const N=o==null?void 0:o.filter(A=>{var L,O,V;if(b.has(A.id))return!1;if(!p.trim())return!0;const I=p.toLowerCase();return((L=A.first_name)==null?void 0:L.toLowerCase().includes(I))||((O=A.last_name)==null?void 0:O.toLowerCase().includes(I))||((V=A.email)==null?void 0:V.toLowerCase().includes(I))}).slice(0,8),w=A=>{l.mutate({dealId:t,contactId:A,role:y}),u(!1),f("")},S=A=>{i.mutate({id:A,dealId:t})},C={Client:"bg-primary/10 text-primary","Co-Buyer":"bg-blue-500/10 text-blue-600","Co-Seller":"bg-emerald-500/10 text-emerald-600",Spouse:"bg-pink-500/10 text-pink-600",Lender:"bg-amber-500/10 text-amber-600","Title Company":"bg-purple-500/10 text-purple-600",Inspector:"bg-orange-500/10 text-orange-600",Appraiser:"bg-cyan-500/10 text-cyan-600",Attorney:"bg-slate-500/10 text-slate-600",Contractor:"bg-lime-500/10 text-lime-600",Other:"bg-muted text-muted-foreground"};return!(n!=null&&n.length)&&!d?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ir,{className:"h-4 w-4"}),"Additional Contacts"]})}),e.jsxs(mo,{open:d,onOpenChange:u,children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{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(no,{className:"w-80 p-3",align:"start",children:e.jsx(i9e,{search:p,setSearch:f,selectedRole:y,setSelectedRole:_,filteredContacts:N,onAdd:w})})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ir,{className:"h-4 w-4"}),"Linked Contacts",n&&n.length>0&&e.jsx(Qe,{variant:"secondary",className:"text-[10px] px-1.5",children:n.length})]}),e.jsxs(mo,{open:d,onOpenChange:u,children:[e.jsx(po,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"sm",className:"h-7 px-2",children:e.jsx(qs,{className:"h-3.5 w-3.5"})})}),e.jsx(no,{className:"w-80 p-3",align:"end",children:e.jsx(i9e,{search:p,setSearch:f,selectedRole:y,setSelectedRole:_,filteredContacts:N,onAdd:w})})]})]}),e.jsx("div",{className:"space-y-1.5",children:n==null?void 0:n.map(A=>{var I,L,O,V,q,B,U,te;return e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-muted/40 group",children:[e.jsx(Nn,{className:"h-7 w-7",children:e.jsxs(kn,{className:"text-[10px] bg-primary/10 text-primary",children:[(L=(I=A.contact)==null?void 0:I.first_name)==null?void 0:L[0],(V=(O=A.contact)==null?void 0:O.last_name)==null?void 0:V[0]]})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("button",{onClick:()=>r(`/mission-control/contacts/${A.contact_id}`),className:"text-sm font-medium hover:underline text-primary truncate block",children:[(q=A.contact)==null?void 0:q.first_name," ",(B=A.contact)==null?void 0:B.last_name]})}),e.jsx(Qe,{variant:"outline",className:`text-[10px] px-1.5 py-0 shrink-0 ${C[A.role]||C.Other}`,children:A.role}),e.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[((U=A.contact)==null?void 0:U.phone)&&e.jsx(W,{variant:"ghost",size:"icon",className:"h-6 w-6",asChild:!0,children:e.jsx("a",{href:`tel:${A.contact.phone}`,children:e.jsx(In,{className:"h-3 w-3"})})}),((te=A.contact)==null?void 0:te.email)&&e.jsx(W,{variant:"ghost",size:"icon",className:"h-6 w-6",asChild:!0,children:e.jsx("a",{href:`mailto:${A.contact.email}`,children:e.jsx(tr,{className:"h-3 w-3"})})}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>S(A.id),children:e.jsx(vr,{className:"h-3 w-3"})})]})]},A.id)})})]})}function i9e({search:t,setSearch:s,selectedRole:r,setSelectedRole:n,filteredContacts:a,onAdd:o}){return e.jsxs("div",{className:"space-y-3",children:[e.jsxs($s,{value:r,onValueChange:n,children:[e.jsx(zs,{className:"h-8 text-sm",children:e.jsx(Vs,{placeholder:"Role"})}),e.jsx(Bs,{children:XNs.map(l=>e.jsx(vt,{value:l,children:l},l))})]}),e.jsxs("div",{className:"relative",children:[e.jsx(ln,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(De,{value:t,onChange:l=>s(l.target.value),placeholder:"Search contacts...",className:"pl-7 h-8 text-sm",autoFocus:!0})]}),e.jsx(Ja,{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 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"}},rks={note:wi,call:In,email:tr,meeting:cn,stage_change:Yr,task_completed:$n,document:Mn,system:nn};function nks({deal:t,open:s,onOpenChange:r,onEdit:n,onAddToScorecard:a,isWonStage:o}){var Re,Ve;const{data:l,isLoading:i}=Wws((t==null?void 0:t.id)||""),{data:d,isLoading:u}=Zws((t==null?void 0:t.id)||""),p=Kws(),f=Xws(),y=Yws(),_=Gws(),{data:b,isLoading:N}=$Ns((t==null?void 0:t.id)||""),w=qNs(),S=UNs(),C=VNs(),A=k.useRef(null),[I,L]=k.useState(""),[O,V]=k.useState(""),[q,B]=k.useState(!1),[U,te]=k.useState(!1);if(!t)return null;const Y=sks[t.deal_type],J=(()=>{var Ie;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const Ne=((Ie=t.listing)==null?void 0:Ie.created_at)||t.listing_date;if(!Ne)return null;const Ue=t.contract_date?ol(t.contract_date):new Date;return $g(Ue,ol(Ne))})(),X=Ne=>Ne?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(Ne):"-",ce=async()=>{if(I.trim())try{await p.mutateAsync({deal_id:t.id,activity_type:"note",title:"Note added",description:I}),L(""),pe.success("Note added")}catch{pe.error("Failed to add note")}},ie=async()=>{if(O.trim())try{await f.mutateAsync({deal_id:t.id,title:O,sort_order:((d==null?void 0:d.length)||0)+1}),V(""),pe.success("Task added")}catch{pe.error("Failed to add task")}},ae=async(Ne,Ue)=>{try{await y.mutateAsync({id:Ne,is_completed:Ue,deal_id:t.id})}catch{pe.error("Failed to update task")}},oe=async()=>{try{await _.mutateAsync(t.id),pe.success("Deal deleted"),r(!1)}catch{pe.error("Failed to delete deal")}},me=(d==null?void 0:d.filter(Ne=>Ne.is_completed).length)||0,ve=(d==null?void 0:d.length)||0,he=(b==null?void 0:b.length)||0,ge=Ne=>Ne<1024?`${Ne} B`:Ne<1024*1024?`${(Ne/1024).toFixed(1)} KB`:`${(Ne/(1024*1024)).toFixed(1)} MB`,je=Ne=>Ne?Ne.startsWith("image/")?qo:Ne.includes("pdf")?vn:kM:kM,qe=async Ne=>{const Ue=Ne.target.files;if(!(!Ue||!t)){te(!0);try{for(const Ie of Array.from(Ue)){if(Ie.size>20*1024*1024){pe.error(`${Ie.name} exceeds 20MB limit`);continue}await w.mutateAsync({dealId:t.id,file:Ie})}pe.success("File(s) uploaded")}catch{pe.error("Failed to upload file")}finally{te(!1),A.current&&(A.current.value="")}}},Me=async(Ne,Ue)=>{if(t)try{await S.mutateAsync({fileId:Ne,storagePath:Ue,dealId:t.id}),pe.success("File deleted")}catch{pe.error("Failed to delete file")}},ke=async(Ne,Ue)=>{try{const Ie=await HNs(Ne),ye=document.createElement("a");ye.href=Ie,ye.download=Ue,ye.target="_blank",document.body.appendChild(ye),ye.click(),document.body.removeChild(ye)}catch{pe.error("Failed to download file")}};return e.jsxs(e.Fragment,{children:[e.jsx(ZA,{open:s,onOpenChange:r,children:e.jsxs(SC,{className:"w-full sm:max-w-xl p-0 flex flex-col",children:[e.jsx(YA,{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(Qe,{variant:"outline",className:Ot("text-xs",Y.color),children:Y.label}),e.jsxs(Qe,{variant:"secondary",className:"text-xs capitalize",children:[t.priority," priority"]})]}),e.jsx(XA,{className:"text-xl",children:t.deal_name}),e.jsx("div",{className:"mt-2",children:e.jsx(BNs,{dealId:t.id})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{variant:"outline",size:"icon",onClick:()=>n(t),children:e.jsx(Wc,{className:"h-4 w-4"})}),e.jsx(W,{variant:"outline",size:"icon",className:"text-destructive hover:bg-destructive/10",onClick:()=>B(!0),children:e.jsx(vr,{className:"h-4 w-4"})})]})]})}),e.jsx(Ja,{className:"flex-1",children:e.jsxs("div",{className:"p-6 space-y-6",children:[t.contact&&e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted/50 rounded-lg",children:[e.jsx(Nn,{className:"h-10 w-10",children:e.jsxs(kn,{className:"bg-primary/10 text-primary",children:[(Re=t.contact.first_name)==null?void 0:Re[0],(Ve=t.contact.last_name)==null?void 0:Ve[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(W,{variant:"outline",size:"icon",asChild:!0,children:e.jsx("a",{href:`tel:${t.contact.phone}`,children:e.jsx(In,{className:"h-4 w-4"})})}),t.contact.email&&e.jsx(W,{variant:"outline",size:"icon",asChild:!0,children:e.jsx("a",{href:`mailto:${t.contact.email}`,children:e.jsx(tr,{className:"h-4 w-4"})})})]})]}),e.jsx(tks,{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(Mn,{className:"h-4 w-4 text-muted-foreground mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:t.property_address||"Address TBD"}),e.jsx("p",{className:"text-muted-foreground",children:[t.city,t.state,t.zip_code].filter(Boolean).join(", ")})]})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Expected Price"}),e.jsx("p",{className:"text-lg font-bold",children:X(t.expected_price)})]}),e.jsxs("div",{className:"bg-emerald-500/10 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Expected GCI"}),e.jsx("p",{className:"text-lg font-bold text-emerald-600",children:X(t.expected_commission)})]}),(t.brokerage_split_pct||t.team_split_pct||t.referral_fee_pct||t.franchise_fee_pct||t.transaction_fee)&&e.jsxs("div",{className:"col-span-2 bg-muted/30 rounded-lg p-3 space-y-1.5",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-2",children:"Commission Splits"}),t.brokerage_split_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Brokerage Split"}),e.jsxs("span",{children:[t.brokerage_split_pct,"%",t.expected_commission?` (${X(t.expected_commission*t.brokerage_split_pct/100)})`:""]})]}),t.team_split_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Team Split"}),e.jsxs("span",{children:[t.team_split_pct,"%"]})]}),t.referral_fee_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Referral Fee"}),e.jsxs("span",{children:[t.referral_fee_pct,"%"]})]}),t.franchise_fee_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Franchise Fee"}),e.jsxs("span",{children:[t.franchise_fee_pct,"%"]})]}),t.transaction_fee!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Transaction Fee"}),e.jsx("span",{children:X(t.transaction_fee)})]}),t.net_commission!=null&&e.jsx(e.Fragment,{children:e.jsx("div",{className:"border-t pt-1.5 mt-1.5",children:e.jsxs("div",{className:"flex justify-between text-sm font-semibold",children:[e.jsx("span",{children:"Net to Agent"}),e.jsx("span",{className:"text-emerald-600",children:X(t.net_commission)})]})})})]}),o&&!t.scorecard_transaction_id&&a&&e.jsxs(W,{onClick:()=>a(t),className:"w-full bg-green-600 hover:bg-green-700",children:[e.jsx(Fi,{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($n,{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:Ot("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(cn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Close: ",vs(ol(t.target_close_date),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(_c,{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(YNs,{deal:t}),e.jsxs(ta,{defaultValue:"tasks",className:"w-full",children:[e.jsxs(Jn,{className:"w-full grid grid-cols-3",children:[e.jsxs(cs,{value:"tasks",className:"gap-1",children:[e.jsx($n,{className:"h-4 w-4"}),"Tasks ",ve>0&&`(${me}/${ve})`]}),e.jsxs(cs,{value:"files",className:"gap-1",children:[e.jsx(mS,{className:"h-4 w-4"}),"Files ",he>0&&`(${he})`]}),e.jsxs(cs,{value:"activity",className:"gap-1",children:[e.jsx(nn,{className:"h-4 w-4"}),"Activity"]})]}),e.jsxs(Ss,{value:"tasks",className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{placeholder:"Add a new task...",value:O,onChange:Ne=>V(Ne.target.value),onKeyDown:Ne=>Ne.key==="Enter"&&ie()}),e.jsx(W,{onClick:ie,disabled:!O.trim(),children:e.jsx(qs,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-2",children:[d==null?void 0:d.map(Ne=>e.jsxs("div",{className:Ot("flex items-center gap-3 p-3 rounded-lg border transition-colors",Ne.is_completed?"bg-muted/50 border-border":"bg-background"),children:[e.jsx(Ri,{checked:Ne.is_completed,onCheckedChange:Ue=>ae(Ne.id,!!Ue)}),e.jsx("span",{className:Ot("flex-1 text-sm",Ne.is_completed&&"line-through text-muted-foreground"),children:Ne.title}),Ne.due_date&&e.jsx("span",{className:"text-xs text-muted-foreground",children:vs(new Date(Ne.due_date),"MMM d")})]},Ne.id)),(d==null?void 0:d.length)===0&&e.jsx("p",{className:"text-center text-muted-foreground text-sm py-4",children:"No tasks yet. Add one above!"})]})]}),e.jsxs(Ss,{value:"files",className:"mt-4 space-y-3",children:[e.jsx("input",{type:"file",ref:A,className:"hidden",multiple:!0,onChange:qe,accept:".pdf,.doc,.docx,.xls,.xlsx,.jpg,.jpeg,.png,.webp,.gif,.txt,.csv"}),e.jsxs(W,{variant:"outline",className:"w-full border-dashed",onClick:()=>{var Ne;return(Ne=A.current)==null?void 0:Ne.click()},disabled:U,children:[U?e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Ra,{className:"h-4 w-4 mr-2"}),U?"Uploading...":"Upload Files"]}),e.jsxs("div",{className:"space-y-2",children:[b==null?void 0:b.map(Ne=>{const Ue=je(Ne.file_type);return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-background",children:[e.jsx("div",{className:"w-8 h-8 rounded bg-muted flex items-center justify-center shrink-0",children:e.jsx(Ue,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:Ne.file_name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ge(Ne.file_size)," · ",vs(new Date(Ne.created_at),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(S1,{children:e.jsxs(ec,{children:[e.jsx(tc,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",className:`h-8 w-8 transition-colors ${Ne.visible_on_portal?"text-primary bg-primary/10 hover:bg-primary/20":"text-muted-foreground/40 hover:text-muted-foreground"}`,onClick:()=>C.mutate({fileId:Ne.id,visible:!Ne.visible_on_portal,dealId:t.id}),children:Ne.visible_on_portal?e.jsx(jn,{className:"h-4 w-4"}):e.jsx(pp,{className:"h-4 w-4"})})}),e.jsx(Dl,{side:"top",children:Ne.visible_on_portal?"Visible on client portal":"Hidden from client portal"})]})}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>ke(Ne.storage_path,Ne.file_name),children:e.jsx(Qa,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>Me(Ne.id,Ne.storage_path),children:e.jsx(kr,{className:"h-4 w-4"})})]})]},Ne.id)}),(b==null?void 0:b.length)===0&&e.jsx("p",{className:"text-center text-muted-foreground text-sm py-4",children:"No files yet. Upload contracts, disclosures, or other documents."})]})]}),e.jsxs(Ss,{value:"activity",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_r,{placeholder:"Add a note...",value:I,onChange:Ne=>L(Ne.target.value),rows:2}),e.jsxs(W,{onClick:ce,disabled:!I.trim(),size:"sm",className:"w-full",children:[e.jsx(_n,{className:"h-4 w-4 mr-2"}),"Add Note"]})]}),e.jsxs("div",{className:"space-y-3",children:[l==null?void 0:l.map(Ne=>{const Ue=rks[Ne.activity_type]||nn;return e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center shrink-0",children:e.jsx(Ue,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:Ne.title}),Ne.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:Ne.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:Nl(new Date(Ne.created_at),{addSuffix:!0})})]})]},Ne.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(Rl,{open:q,onOpenChange:B,children:e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Delete Deal?"}),e.jsxs(bl,{children:['This will permanently delete "',t.deal_name,'" and all associated data. This action cannot be undone.']})]}),e.jsxs(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:oe,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function aks({open:t,onOpenChange:s,deal:r,onComplete:n}){const a=ihe(),o=vit(),{data:l}=JA(),{data:i}=Nf(),[d,u]=k.useState({property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:vs(new Date,"yyyy-MM-dd"),sale_price:0,commission_amount:0,lead_source_id:"",client_type_id:"",notes:""});k.useEffect(()=>{if(r&&t){const y=r.deal_type==="seller"?"seller":"buyer",_=r.expected_price||0,b=r.commission_percentage||3,N=r.expected_commission||_*b/100;u({property_address:r.property_address||r.deal_name||"",city:r.city||"",state:r.state||"",zip:r.zip_code||"",transaction_type:y,close_date:r.actual_close_date||r.target_close_date||vs(new Date,"yyyy-MM-dd"),sale_price:_,commission_amount:N,lead_source_id:"",client_type_id:"",notes:r.notes||""})}},[r,t]);const p=async y=>{if(y.preventDefault(),!!r)try{const _=await a.mutateAsync({property_address:d.property_address,city:d.city||null,state:d.state||null,zip:d.zip||null,transaction_type:d.transaction_type,close_date:d.close_date,sale_price:d.sale_price,commission_amount:d.commission_amount||null,brokerage_split_pct:r.brokerage_split_pct||null,team_split_pct:r.team_split_pct||null,franchise_fee_pct:r.franchise_fee_pct||null,referral_fee_pct:r.referral_fee_pct||null,transaction_fee:r.transaction_fee||null,lead_source_id:d.lead_source_id||null,client_type_id:d.client_type_id||null,contact_id:r.contact_id||null,notes:d.notes||null,is_win:!0});await o.mutateAsync({id:r.id,scorecard_transaction_id:_.id,actual_close_date:d.close_date}),pe.success("Deal added to Scorecard! 🎉"),s(!1),n==null||n()}catch(_){console.error("Error syncing to scorecard:",_),pe.error("Failed to add to scorecard")}},f=y=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:0}).format(y);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(ks,{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(Fi,{className:"h-6 w-6 text-green-600 dark:text-green-400"})}),e.jsx(_s,{className:"text-center text-xl",children:"Congratulations on Closing! 🎉"}),e.jsx(Ir,{className:"text-center",children:"Review and confirm the details before adding this deal to your Scorecard."})]}),e.jsxs("form",{onSubmit:p,className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{htmlFor:"property_address",className:"flex items-center gap-2",children:[e.jsx(Mn,{className:"h-4 w-4 text-muted-foreground"}),"Property Address *"]}),e.jsx(De,{id:"property_address",value:d.property_address,onChange:y=>u(_=>({..._,property_address:y.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(xe,{htmlFor:"city",children:"City"}),e.jsx(De,{id:"city",value:d.city,onChange:y=>u(_=>({..._,city:y.target.value})),placeholder:"City"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"state",children:"State"}),e.jsx(De,{id:"state",value:d.state,onChange:y=>u(_=>({..._,state:y.target.value})),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"zip",children:"Zip"}),e.jsx(De,{id:"zip",value:d.zip,onChange:y=>u(_=>({..._,zip:y.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(xe,{children:"Transaction Type *"}),e.jsxs($s,{value:d.transaction_type,onValueChange:y=>u(_=>({..._,transaction_type:y})),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"buyer",children:"Buyer"}),e.jsx(vt,{value:"seller",children:"Seller"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{htmlFor:"close_date",className:"flex items-center gap-2",children:[e.jsx(cn,{className:"h-4 w-4 text-muted-foreground"}),"Close Date *"]}),e.jsx(De,{id:"close_date",type:"date",value:d.close_date,onChange:y=>u(_=>({..._,close_date:y.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(xe,{htmlFor:"sale_price",className:"flex items-center gap-2",children:[e.jsx(_c,{className:"h-4 w-4 text-muted-foreground"}),"Sale Price *"]}),e.jsx(De,{id:"sale_price",type:"number",value:d.sale_price||"",onChange:y=>u(_=>({..._,sale_price:Number(y.target.value)})),placeholder:"450000",required:!0,min:0}),d.sale_price>0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:f(d.sale_price)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{htmlFor:"commission_amount",className:"flex items-center gap-2",children:[e.jsx(LM,{className:"h-4 w-4 text-muted-foreground"}),"GCI (Commission)"]}),e.jsx(De,{id:"commission_amount",type:"number",value:d.commission_amount||"",onChange:y=>u(_=>({..._,commission_amount:Number(y.target.value)})),placeholder:"13500",min:0}),d.commission_amount>0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:f(d.commission_amount)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Lead Source"}),e.jsxs($s,{value:d.lead_source_id,onValueChange:y=>u(_=>({..._,lead_source_id:y})),children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select source"})}),e.jsx(Bs,{children:l==null?void 0:l.map(y=>e.jsx(vt,{value:y.id,children:y.name},y.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Client Type"}),e.jsxs($s,{value:d.client_type_id,onValueChange:y=>u(_=>({..._,client_type_id:y})),children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select type"})}),e.jsx(Bs,{children:i==null?void 0:i.map(y=>e.jsx(vt,{value:y.id,children:y.name},y.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"notes",children:"Notes"}),e.jsx(_r,{id:"notes",value:d.notes,onChange:y=>u(_=>({..._,notes:y.target.value})),placeholder:"Any additional notes about this transaction...",rows:2})]}),e.jsxs(gn,{className:"gap-2 sm:gap-0 pt-4",children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Skip for now"}),e.jsx(W,{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(Wa,{className:"ml-2 h-4 w-4"})]})})]})]})]})})}const iks={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"}},o9e={urgent:0,high:1,medium:2,low:3};function oks({deals:t,stages:s,onDealClick:r,onStageChange:n}){const[a,o]=k.useState("target_close_date"),[l,i]=k.useState("asc"),d=_=>{a===_?i(b=>b==="asc"?"desc":"asc"):(o(_),i("asc"))},u=k.useMemo(()=>[...t].sort((_,b)=>{var w,S;let N=0;switch(a){case"deal_name":N=_.deal_name.localeCompare(b.deal_name);break;case"stage":{const C=((w=s.find(I=>I.id===_.stage_id))==null?void 0:w.sort_order)||0,A=((S=s.find(I=>I.id===b.stage_id))==null?void 0:S.sort_order)||0;N=C-A;break}case"expected_price":N=(_.expected_price||0)-(b.expected_price||0);break;case"expected_commission":N=(_.expected_commission||0)-(b.expected_commission||0);break;case"target_close_date":{const C=_.target_close_date?ol(_.target_close_date).getTime():1/0,A=b.target_close_date?ol(b.target_close_date).getTime():1/0;N=C-A;break}case"priority":N=o9e[_.priority]-o9e[b.priority];break}return l==="asc"?N:-N}),[t,s,a,l]),p=_=>_?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(_):"—",f=_=>_?s.find(b=>b.id===_):null,y=({field:_,children:b})=>e.jsxs(W,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>d(_),children:[b,a===_?l==="asc"?e.jsx(uu,{className:"ml-2 h-4 w-4"}):e.jsx(Ih,{className:"ml-2 h-4 w-4"}):e.jsx(td,{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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{className:"bg-muted/50",children:[e.jsx(St,{className:"w-[250px]",children:e.jsx(y,{field:"deal_name",children:"Deal Name"})}),e.jsx(St,{className:"w-[150px]",children:e.jsx(y,{field:"stage",children:"Stage"})}),e.jsx(St,{className:"w-[100px]",children:"Type"}),e.jsx(St,{className:"w-[120px]",children:e.jsx(y,{field:"expected_price",children:"Price"})}),e.jsx(St,{className:"w-[120px]",children:e.jsx(y,{field:"expected_commission",children:"GCI"})}),e.jsx(St,{className:"w-[130px]",children:e.jsx(y,{field:"target_close_date",children:"Close Date"})}),e.jsx(St,{className:"w-[100px]",children:e.jsx(y,{field:"priority",children:"Priority"})})]})}),e.jsx(Rn,{children:u.map(_=>{f(_.stage_id);const b=iks[_.deal_type],N=_.target_close_date?$g(ol(_.target_close_date),new Date):null,w=N!==null&&N<0,S=N!==null&&N<=7&&N>=0;return e.jsxs(Ps,{className:Ot("cursor-pointer hover:bg-muted/50 transition-colors",w&&"bg-red-50/50"),onClick:()=>r(_),children:[e.jsx(ht,{className:"font-medium",children:e.jsxs("div",{children:[e.jsx("p",{className:"truncate max-w-[230px]",children:_.deal_name}),_.contact&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[_.contact.first_name," ",_.contact.last_name]})]})}),e.jsx(ht,{onClick:C=>C.stopPropagation(),children:e.jsx(klt,{stages:s,currentStageId:_.stage_id||"",onStageSelect:(C,A)=>n(_.id,C,A)})}),e.jsx(ht,{children:e.jsx(Qe,{variant:"outline",className:Ot("text-xs",b.color),children:b.label})}),e.jsx(ht,{children:e.jsx("span",{className:"font-medium",children:p(_.expected_price)})}),e.jsx(ht,{children:e.jsx("span",{className:"text-emerald-600",children:p(_.expected_commission)})}),e.jsx(ht,{children:_.target_close_date?e.jsxs("div",{className:Ot("flex items-center gap-1 text-sm",w&&"text-red-600",S&&!w&&"text-amber-600"),children:[w&&e.jsx(ro,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:vs(ol(_.target_close_date),"MMM d, yyyy")})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(ht,{children:e.jsx(Qe,{variant:"outline",className:Ot("text-xs capitalize",_.priority==="urgent"&&"border-red-200 bg-red-50 text-red-700",_.priority==="high"&&"border-orange-200 bg-orange-50 text-orange-700",_.priority==="medium"&&"border-amber-200 bg-amber-50 text-amber-700",_.priority==="low"&&"border-slate-200 bg-slate-50 text-slate-600"),children:_.priority})})]},_.id)})})]})})}function lks(){const t=ya();return gt({queryKey:["deal-tasks",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("deal_tasks").select(` *, deal:deal_pipeline(id, deal_name, stage_id), contact:innercircle_contacts(id, first_name, last_name), stage:deal_pipeline_stages(id, name, color) `).eq("owner_user_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function cks(t){const s=ya();return gt({queryKey:["deal-tasks","deal",t,s],queryFn:async()=>{if(!s||!t)return[];const{data:r,error:n}=await G.from("deal_tasks").select(` *, stage:deal_pipeline_stages(id, name, color) `).eq("owner_user_id",s).eq("deal_id",t).order("sort_order",{ascending:!0});if(n)throw n;return r},enabled:!!s&&!!t})}function dks(){const t=ya(),s=Qt();return Pt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.from("deal_tasks").insert({owner_user_id:t,title:r.title,description:r.description||null,deal_id:r.deal_id||null,contact_id:r.contact_id||null,stage_id:r.stage_id||null,priority:r.priority||"medium",status:r.status||"todo",due_date:r.due_date||null,sort_order:r.sort_order||0}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-tasks"]})}})}function uks(){const t=Qt();return Pt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("deal_tasks").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function hks(){const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("deal_tasks").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function $Ce(){const t=Qt();return Pt({mutationFn:async({id:s,status:r})=>{const{data:n,error:a}=await G.from("deal_tasks").update({status:r,completed_at:r==="done"?new Date().toISOString():null}).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function mks(){const t=Qt();return Pt({mutationFn:async s=>{if(s.length===0)return;const{error:r}=await G.from("deal_tasks").update({status:"done",completed_at:new Date().toISOString()}).in("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function pks(t){const s=ya();return gt({queryKey:["deal-task-templates",s,t],queryFn:async()=>{if(!s)return[];let r=G.from("deal_task_templates").select("*").eq("owner_user_id",s).order("sort_order",{ascending:!0});t&&(r=r.eq("stage_id",t));const{data:n,error:a}=await r;if(a)throw a;return n},enabled:!!s})}function fks(){const t=ya(),s=Qt();return Pt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.from("deal_task_templates").insert({owner_user_id:t,stage_id:r.stage_id,title:r.title,description:r.description||null,priority:r.priority||"medium",default_due_offset_days:r.default_due_offset_days||null,sort_order:r.sort_order||0}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-task-templates"]})}})}function xks(){const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("deal_task_templates").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-task-templates"]})}})}function gks(){const t=ya(),s=Qt();return Pt({mutationFn:async({dealId:r,stageId:n})=>{if(!t)throw new Error("Not authenticated");const{data:a,error:o}=await G.from("deal_task_templates").select("*").eq("owner_user_id",t).eq("stage_id",n).order("sort_order");if(o)throw o;if(!a||a.length===0)return[];const{data:l}=await G.from("deal_tasks").select("title, stage_id").eq("deal_id",r).eq("stage_id",n),i=new Set((l||[]).map(f=>f.title)),d=a.filter(f=>!i.has(f.title)).map((f,y)=>({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:y,status:"todo"}));if(d.length===0)return[];const{data:u,error:p}=await G.from("deal_tasks").insert(d).select();if(p)throw p;return u},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-tasks"]})}})}const yks={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function vks({open:t,onOpenChange:s,dealId:r,dealName:n,fromStageName:a,toStageName:o,toStageId:l,onConfirm:i}){const{data:d,isLoading:u}=cks(t?r:void 0),p=mks(),f=gks(),[y,_]=k.useState(new Set),[b,N]=k.useState(!1),w=(d||[]).filter(I=>I.status!=="done");k.useEffect(()=>{w.length>0&&_(new Set(w.map(I=>I.id)))},[d]);const S=I=>{_(L=>{const O=new Set(L);return O.has(I)?O.delete(I):O.add(I),O})},C=async()=>{N(!0);try{const I=Array.from(y);I.length>0&&await p.mutateAsync(I),await i(),await f.mutateAsync({dealId:r,stageId:l}),s(!1)}catch(I){console.error("Stage move failed:",I),pe.error((I==null?void 0:I.message)||"Failed to move deal. Please try again.")}finally{N(!1)}},A=async()=>{N(!0);try{await i(),await f.mutateAsync({dealId:r,stageId:l}),s(!1)}catch(I){console.error("Stage move (skip) failed:",I),pe.error((I==null?void 0:I.message)||"Failed to move deal. Please try again.")}finally{N(!1)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"sm:max-w-[480px]",children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Move Deal"}),e.jsxs(Ir,{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(Qe,{variant:"outline",className:"text-sm",children:a}),e.jsx(Wa,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Qe,{className:"text-sm bg-primary",children:o})]}),u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(us,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):w.length>0?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You have ",e.jsx("span",{className:"font-medium text-foreground",children:w.length})," incomplete task",w.length!==1?"s":"",". Select which to mark as done:"]}),e.jsx(Ja,{className:"max-h-[250px]",children:e.jsx("div",{className:"space-y-1",children:w.map(I=>e.jsxs("label",{className:"flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-muted/50 cursor-pointer transition-colors",children:[e.jsx(Ri,{checked:y.has(I.id),onCheckedChange:()=>S(I.id)}),e.jsxs("span",{className:"text-sm flex-1",children:[yks[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(W,{variant:"ghost",size:"sm",onClick:()=>{y.size===w.length?_(new Set):_(new Set(w.map(I=>I.id)))},children:y.size===w.length?"Deselect All":"Select All"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{variant:"outline",size:"sm",onClick:A,disabled:b,children:"Skip"}),e.jsxs(W,{size:"sm",onClick:C,disabled:b,children:[b&&e.jsx(us,{className:"h-4 w-4 mr-1 animate-spin"}),y.size>0?`Complete ${y.size} & Move`:"Move Deal"]})]})]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"text-center py-4",children:[e.jsx($n,{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(W,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(W,{onClick:C,disabled:b,children:[b&&e.jsx(us,{className:"h-4 w-4 mr-1 animate-spin"}),"Move to ",o]})]})]})]})})}function _ks(){const t=ya();return gt({queryKey:["all-client-portals",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("client_portals").select("*").eq("owner_user_id",t);if(r)throw r;return s||[]},enabled:!!t})}function bks({dealId:t,dealName:s,contactName:r,portal:n,onSettingsOpen:a,onComposerOpen:o,onInviteOpen:l,onDeleteConfirm:i}){const d=BSe(),u=bO(),p=Vbs(),f=Hbs(),[y,_]=k.useState(!1),b=!!(n!=null&&n.archived_at),N=async()=>{_(!0);try{await d.mutateAsync({deal_id:t,visibility:"private",require_onboarding:!0}),pe.success("Portal enabled!")}catch{pe.error("Failed to create portal")}finally{_(!1)}},w=async L=>{if(n)try{await u.mutateAsync({id:n.id,is_enabled:L}),pe.success(L?"Portal enabled":"Portal disabled")}catch{pe.error("Failed to update portal")}},S=()=>{n&&(navigator.clipboard.writeText(o1(n.slug)),pe.success("Link copied!"))},C=()=>{n&&window.open(o1(n.slug),"_blank")},A=async()=>{if(n)try{await p.mutateAsync(n.id),pe.success("Portal archived")}catch{pe.error("Failed to archive portal")}},I=async()=>{if(n)try{await f.mutateAsync(n.id),pe.success("Portal restored")}catch{pe.error("Failed to restore portal")}};return n?b?e.jsxs("div",{className:"flex items-center gap-4 p-4 border rounded-lg opacity-60 bg-muted/30",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s}),e.jsx(Qe,{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(W,{variant:"ghost",size:"sm",onClick:I,className:"text-xs gap-1",children:[e.jsx(rL,{className:"h-3.5 w-3.5"}),"Restore"]}),e.jsxs(W,{variant:"ghost",size:"sm",onClick:()=>i(n),className:"text-xs gap-1 text-destructive hover:text-destructive",children:[e.jsx(vr,{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(Qe,{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(W,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:S,title:"Copy link",children:e.jsx(Va,{className:"h-3.5 w-3.5"})}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:C,title:"Preview",children:e.jsx(Yr,{className:"h-3.5 w-3.5"})}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(n,s),title:"Invite client",children:e.jsx(_n,{className:"h-3.5 w-3.5"})}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>o(n),title:"Post update",children:e.jsx(IM,{className:"h-3.5 w-3.5"})}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>a(n),title:"Settings",children:e.jsx(So,{className:"h-3.5 w-3.5"})}),e.jsxs(Hd,{children:[e.jsx(Gd,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(Zp,{className:"h-3.5 w-3.5"})})}),e.jsx(Nd,{align:"end",children:e.jsxs(_a,{onClick:A,children:[e.jsx(yM,{className:"h-4 w-4 mr-2"}),"Archive Portal"]})})]}),e.jsx(Ar,{checked:n.is_enabled,onCheckedChange:w,className:"ml-1"})]})]}):e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg border-dashed bg-muted/20",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r||"No contact"})]}),e.jsxs(W,{size:"sm",onClick:N,disabled:y,className:"shrink-0 ml-4",children:[y?e.jsx(us,{className:"h-3 w-3 animate-spin mr-1"}):e.jsx(Or,{className:"h-3 w-3 mr-1"}),"Enable Portal"]})]})}function wks(){const{data:t,isLoading:s}=Pme(),{data:r,isLoading:n}=_ks(),[a,o]=k.useState(""),[l,i]=k.useState("all"),d=Gbs(),[u,p]=k.useState(null),[f,y]=k.useState(null),[_,b]=k.useState(null),[N,w]=k.useState(null),S=ya(),C=s||n,A=new Map;r==null||r.forEach(U=>A.set(U.deal_id,U));const L=[...(t||[]).filter(U=>{var ce,ie,ae,oe,me;const te=A.get(U.id),Y=a.toLowerCase(),J=!Y||U.deal_name.toLowerCase().includes(Y)||((ie=(ce=U.contact)==null?void 0:ce.first_name)==null?void 0:ie.toLowerCase().includes(Y))||((oe=(ae=U.contact)==null?void 0:ae.last_name)==null?void 0:oe.toLowerCase().includes(Y))||((me=te==null?void 0:te.client_name)==null?void 0:me.toLowerCase().includes(Y));let X=!0;return l==="active"?X=!!(te!=null&&te.is_enabled)&&!(te!=null&&te.archived_at):l==="disabled"?X=!!te&&!te.is_enabled&&!te.archived_at:l==="archived"?X=!!(te!=null&&te.archived_at):l==="none"?X=!te:l==="all"&&(X=!(te!=null&&te.archived_at)||!te),J&&X})].sort((U,te)=>{const Y=A.get(U.id),J=A.get(te.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(U=>!U.archived_at).length)||0,V=(r==null?void 0:r.filter(U=>U.is_enabled&&!U.archived_at).length)||0,q=(r==null?void 0:r.filter(U=>U.archived_at).length)||0,B=async()=>{if(N)try{await d.mutateAsync({id:N.id,dealId:N.deal_id}),pe.success("Portal permanently deleted"),w(null)}catch{pe.error("Failed to delete portal")}};return C?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(us,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Or,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"font-medium",children:[O," Portals"]})]}),e.jsxs("span",{className:"text-muted-foreground",children:[V," active · ",O-V," disabled",q>0&&` · ${q} archived`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search deals or clients...",value:a,onChange:U=>o(U.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(kr,{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(U=>e.jsx(W,{variant:l===U?"secondary":"ghost",size:"sm",onClick:()=>i(U),className:"text-xs px-3 capitalize",children:U==="none"?"No Portal":U},U))})]}),e.jsx(Ja,{className:"h-[calc(100vh-22rem)]",children:e.jsxs("div",{className:"space-y-2 pb-4",children:[L.map(U=>{const te=A.get(U.id)||null,Y=U.contact?`${U.contact.first_name||""} ${U.contact.last_name||""}`.trim():"";return e.jsx(bks,{dealId:U.id,dealName:U.deal_name,contactName:Y,portal:te,onSettingsOpen:p,onComposerOpen:J=>y(J),onInviteOpen:(J,X)=>b({portal:J,dealName:X}),onDeleteConfirm:w},U.id)}),L.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-3 bg-muted rounded-full flex items-center justify-center",children:e.jsx(Or,{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(Clt,{open:!!u,onOpenChange:U=>!U&&p(null),portal:u,dealOwnerId:S||""}),f&&e.jsx(Mlt,{open:!!f,onOpenChange:U=>!U&&y(null),portalId:f.id,portalSlug:f.slug,notifyClient:f.notify_client}),_&&e.jsx(Tlt,{open:!!_,onOpenChange:U=>!U&&b(null),portal:_.portal,dealName:_.dealName}),e.jsx(Rl,{open:!!N,onOpenChange:U=>!U&&w(null),children:e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Permanently delete this portal?"}),e.jsx(bl,{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(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:B,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Permanently"})]})]})})]})}class jks 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(Ds,{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 bI="deal-pipeline-detail-sheet";function Nks(){var fr;const t=bE(),{data:s,isLoading:r}=Eme(),{data:n,isLoading:a,refetch:o}=Pme(),{data:l,isLoading:i}=Qws(),d=git(),u=Hws(),[p,f]=k.useState("board"),[y,_]=k.useState(!1),[b,N]=k.useState(!1),[w,S]=k.useState(null),[C,A]=k.useState(null),[I,L]=k.useState(null),[O,V]=k.useState(null),[q,B]=k.useState(!1),[U,te]=k.useState(null),[Y,J]=k.useState(""),[X,ce]=k.useState("all"),[ie,ae]=k.useState("all"),{data:oe}=ENs(),[me,ve]=k.useState(!1),[he,ge]=k.useState(!1),[je,qe]=k.useState(new Set),Me=k.useRef(!1),[ke,Re]=k.useState(null),{data:Ve}=Px(),{isTeamLeader:Ne,teamMembers:Ue}=TNs(),Ie=k.useMemo(()=>Array.from(je),[je]),{data:ye}=ANs(Ie),ct=k.useMemo(()=>{const Hs=new Map;return Ue.forEach(mr=>Hs.set(mr.id,{name:mr.name,avatar_url:mr.avatar_url,color:mr.color})),Hs},[Ue]),fe=k.useCallback(Hs=>Hs.owner_user_id&&ct.get(Hs.owner_user_id)||null,[ct]),$e=k.useCallback(Hs=>{qe(mr=>{const an=new Set(mr);return an.has(Hs)?an.delete(Hs):an.add(Hs),an})},[]);k.useEffect(()=>{!r&&s&&s.length===0&&d.mutate()},[r,s]);const[Ye,tt]=Nc(),Te=k.useRef(!1);k.useEffect(()=>{const Hs=Ye.get("deal");if(Hs&&n&&n.length>0&&!Te.current){const mr=n.find(an=>an.id===Hs);mr&&(Te.current=!0,S(mr),N(!0),Ye.delete("deal"),tt(Ye,{replace:!0}))}},[n,Ye]);const We=k.useMemo(()=>{if(!ye||!s)return[];const Hs=new Map(s.map(mr=>[mr.name,mr.id]));return ye.map(mr=>{const an=mr._stage_name&&Hs.get(mr._stage_name)||null;return{...mr,stage_id:an||mr.stage_id}})},[ye,s]),Ke=k.useMemo(()=>[...n||[],...We],[n,We]);k.useEffect(()=>{if(Me.current||Ke.length===0)return;Me.current=!0;const Hs=sessionStorage.getItem(bI);if(Hs)try{const mr=JSON.parse(Hs);if(!mr.open||!mr.dealId)return;const an=Ke.find(Cr=>Cr.id===mr.dealId);an&&(S(an),N(!0))}catch{sessionStorage.removeItem(bI)}},[Ke]),k.useEffect(()=>{b&&(w!=null&&w.id)?sessionStorage.setItem(bI,JSON.stringify({dealId:w.id,open:!0})):sessionStorage.removeItem(bI)},[b,w==null?void 0:w.id]);const ot=(oe==null?void 0:oe.byDeal)||{},He=(oe==null?void 0:oe.unique)||[],Je=Ke.filter(Hs=>{var nr,cr,Br,Kr,Sn,ai;const mr=Y.toLowerCase(),an=ot[Hs.id]||[],Cr=!mr||Hs.deal_name.toLowerCase().includes(mr)||((cr=(nr=Hs.contact)==null?void 0:nr.first_name)==null?void 0:cr.toLowerCase().includes(mr))||((Kr=(Br=Hs.contact)==null?void 0:Br.last_name)==null?void 0:Kr.toLowerCase().includes(mr))||((Sn=Hs.property_address)==null?void 0:Sn.toLowerCase().includes(mr))||((ai=Hs.city)==null?void 0:ai.toLowerCase().includes(mr))||an.some(as=>as.toLowerCase().includes(mr)),Fr=X==="all"||Hs.deal_type===X,$r=ie==="all"||an.includes(ie);return Cr&&Fr&&$r}),ut=k.useMemo(()=>{if(!s)return l||null;const Hs=new Set(s.filter(nr=>nr.is_won_stage).map(nr=>nr.id)),mr=new Set(s.filter(nr=>nr.is_lost_stage).map(nr=>nr.id)),an=Ke.filter(nr=>nr.stage_id&&!Hs.has(nr.stage_id)&&!mr.has(nr.stage_id)),Cr=Ke.filter(nr=>nr.stage_id&&Hs.has(nr.stage_id)),Fr=new Date().getFullYear(),$r=Cr.filter(nr=>nr.actual_close_date?new Date(nr.actual_close_date).getFullYear()===Fr:!0);return{totalDeals:Ke.length,activeDeals:an.length,wonDeals:Cr.length,pipelineValue:an.reduce((nr,cr)=>nr+(cr.expected_price||0),0),expectedCommission:an.reduce((nr,cr)=>nr+(cr.expected_commission||0),0),expectedNetToAgent:an.reduce((nr,cr)=>nr+(cx(cr)||0),0),wonValue:Cr.reduce((nr,cr)=>nr+(cr.expected_price||0),0),weightedGCI:an.reduce((nr,cr)=>nr+(cr.expected_commission||0)*((cr.probability??50)/100),0),weightedNet:an.reduce((nr,cr)=>nr+(cx(cr)||0)*((cr.probability??50)/100),0),ytdWonDeals:$r.length,ytdWonGCI:$r.reduce((nr,cr)=>nr+(cr.expected_commission||0),0),ytdWonNet:$r.reduce((nr,cr)=>nr+(cx(cr)||0),0),projectedAnnualNet:$r.reduce((nr,cr)=>nr+(cx(cr)||0),0)+an.reduce((nr,cr)=>nr+(cx(cr)||0)*((cr.probability??50)/100),0)}},[Ke,s,l]),mt=Hs=>{S(Hs),N(!0)},et=Hs=>{A(Hs||null),S(null),_(!0)},Ze=Hs=>{S(Hs),N(!1),_(!0)},kt=Hs=>{N(Hs),Hs||sessionStorage.removeItem(bI)},Ut=(Hs,mr)=>{L(Hs)},Nt=(Hs,mr)=>{Hs.preventDefault(),Hs.dataTransfer.dropEffect="move",V(mr)},es=async(Hs,mr)=>{if(Hs.preventDefault(),V(null),!I)return;const an=n==null?void 0:n.find($r=>$r.id===I),Cr=s==null?void 0:s.find($r=>$r.id===mr),Fr=s==null?void 0:s.find($r=>$r.id===(an==null?void 0:an.stage_id));if(!an||!Cr||an.stage_id===mr){L(null);return}Re({dealId:I,dealName:an.deal_name,fromStageName:(Fr==null?void 0:Fr.name)||"Unknown",toStageName:Cr.name,toStageId:mr,isWonStage:Cr.is_won_stage,deal:an}),L(null)},ds=async()=>{if(!ke)return;const{dealId:Hs,toStageId:mr,toStageName:an,isWonStage:Cr,deal:Fr}=ke;if(await u.mutateAsync({dealId:Hs,stageId:mr,stageName:an}),pe.success(`Moved to ${an}`),Cr&&!Fr.scorecard_transaction_id){const $r={...Fr,stage_id:mr};te($r),B(!0)}},js=k.useCallback(async(Hs,mr,an)=>{const Cr=n==null?void 0:n.find(nr=>nr.id===Hs),Fr=s==null?void 0:s.find(nr=>nr.id===mr),$r=s==null?void 0:s.find(nr=>nr.id===(Cr==null?void 0:Cr.stage_id));!Cr||!Fr||Cr.stage_id===mr||Re({dealId:Hs,dealName:Cr.deal_name,fromStageName:($r==null?void 0:$r.name)||"Unknown",toStageName:an,toStageId:mr,isWonStage:Fr.is_won_stage,deal:Cr})},[n,s]),lr=Hs=>Je.filter(mr=>mr.stage_id===Hs),Lt=r||a,Es=t?"list":p;return e.jsxs(Ds,{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(W,{variant:"outline",size:"icon",onClick:()=>o(),className:"shrink-0",children:e.jsx(Zi,{className:"h-4 w-4"})}),!t&&e.jsx(S1,{children:e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsxs(ec,{children:[e.jsx(tc,{asChild:!0,children:e.jsxs(W,{variant:p==="board"?"secondary":"ghost",size:"sm",onClick:()=>f("board"),className:"px-3 gap-1.5",children:[e.jsx(xp,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Board"})]})}),e.jsx(Dl,{children:"Kanban board view"})]}),e.jsxs(ec,{children:[e.jsx(tc,{asChild:!0,children:e.jsxs(W,{variant:p==="list"?"secondary":"ghost",size:"sm",onClick:()=>f("list"),className:"px-3 gap-1.5",children:[e.jsx(Dh,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"List"})]})}),e.jsx(Dl,{children:"Grouped list view"})]}),e.jsxs(ec,{children:[e.jsx(tc,{asChild:!0,children:e.jsxs(W,{variant:p==="table"?"secondary":"ghost",size:"sm",onClick:()=>f("table"),className:"px-3 gap-1.5",children:[e.jsx(RM,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Table"})]})}),e.jsx(Dl,{children:"Sortable table view"})]}),e.jsxs(ec,{children:[e.jsx(tc,{asChild:!0,children:e.jsxs(W,{variant:p==="portals"?"secondary":"ghost",size:"sm",onClick:()=>f("portals"),className:"px-3 gap-1.5",children:[e.jsx(Or,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Portals"})]})}),e.jsx(Dl,{children:"Client portal management"})]})]})}),Ve&&!Ne&&e.jsxs(W,{variant:"outline",onClick:()=>ve(!0),children:[e.jsx(ir,{className:"h-4 w-4 mr-2"}),"Team"]}),e.jsxs(W,{onClick:()=>et(),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Deal"]})]})]}),Es!=="portals"&&e.jsx(DNs,{stats:ut,isLoading:i}),Es!=="portals"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search deals, contacts, addresses, tags...",value:Y,onChange:Hs=>J(Hs.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(kr,{className:"h-4 w-4"})})]}),e.jsxs($s,{value:X,onValueChange:ce,children:[e.jsx(zs,{className:"w-[140px]",children:e.jsx(Vs,{placeholder:"All Types"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Types"}),e.jsx(vt,{value:"buyer",children:"Buyer"}),e.jsx(vt,{value:"seller",children:"Seller"}),e.jsx(vt,{value:"dual",children:"Dual"}),e.jsx(vt,{value:"referral",children:"Referral"}),e.jsx(vt,{value:"lease",children:"Lease"})]})]}),e.jsxs($s,{value:ie,onValueChange:ae,children:[e.jsxs(zs,{className:"w-[160px]",children:[e.jsx(mh,{className:"h-3.5 w-3.5 mr-1.5 text-muted-foreground"}),e.jsx(Vs,{placeholder:"All Tags"})]}),e.jsxs(Bs,{className:"max-h-[300px]",children:[e.jsx(vt,{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(Hs=>e.jsx(vt,{value:Hs,children:Hs},Hs))]})]}),ie!=="all"&&e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[e.jsx(mh,{className:"h-3 w-3"}),ie,e.jsx("button",{onClick:()=>ae("all"),className:"ml-1 hover:text-foreground","aria-label":"Clear tag filter",children:e.jsx(kr,{className:"h-3 w-3"})})]}),(Y||X!=="all"||ie!=="all")&&e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[Je.length," of ",(n==null?void 0:n.length)||0," deals"]})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[Ne&&!t&&Ue.length>0&&e.jsx(MNs,{members:Ue,enabledMembers:je,onToggleMember:$e,isOpen:he,onToggleOpen:()=>ge(Hs=>!Hs)}),e.jsx("div",{className:"flex-1 min-w-0 min-h-0 p-4 md:p-6 pt-4",children:Lt?e.jsx("div",{className:"flex gap-4 h-full",children:[1,2,3,4].map(Hs=>e.jsx("div",{className:"min-w-[280px] max-w-[320px] flex-shrink-0",children:e.jsx(Ms,{className:"h-full rounded-xl"})},Hs))}):Es==="board"?e.jsxs(Ja,{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(Hs=>e.jsx(LNs,{stage:Hs,deals:lr(Hs.id),onDealClick:mt,onAddDeal:et,onDragStart:Ut,onDragOver:Nt,onDrop:es,isDragOver:O===Hs.id,isWonStage:Hs.is_won_stage,getOwnerInfo:fe},Hs.id))}),e.jsx(zue,{orientation:"horizontal"})]}):Es==="table"?e.jsx(Ja,{className:"h-full",children:e.jsx(oks,{deals:Je,stages:s||[],onDealClick:mt,onStageChange:js})}):Es==="portals"?e.jsx(wks,{}):e.jsx(Ja,{className:"h-full",children:e.jsxs("div",{className:"space-y-6",children:[s==null?void 0:s.map(Hs=>{const mr=lr(Hs.id);return mr.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:Hs.color}}),e.jsx("h3",{className:"font-semibold",children:Hs.name}),e.jsxs("span",{className:"text-muted-foreground text-sm",children:["(",mr.length,")"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:mr.map(an=>e.jsx(Slt,{deal:an,onClick:()=>mt(an),stages:s,onStageChange:js,showStagePicker:!0,isWonStage:Hs.is_won_stage,ownerInfo:fe(an)},an.id))})]},Hs.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(xp,{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(W,{onClick:()=>et(),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Your First Deal"]})]}),((n==null?void 0:n.length)||0)>0&&Je.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(ln,{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(W,{variant:"outline",onClick:()=>{J(""),ce("all")},children:"Clear Filters"})]})]})})})]})]}),e.jsx(zNs,{open:y,onOpenChange:_,deal:w,defaultStageId:C}),e.jsx(nks,{deal:w,open:b,onOpenChange:kt,onEdit:Ze,isWonStage:w?(fr=s==null?void 0:s.find(Hs=>Hs.id===w.stage_id))==null?void 0:fr.is_won_stage:!1,onAddToScorecard:Hs=>{te(Hs),B(!0),N(!1)}}),e.jsx(aks,{open:q,onOpenChange:B,deal:U,onComplete:()=>{o(),te(null)}}),ke&&e.jsx(vks,{open:!!ke,onOpenChange:Hs=>{Hs||Re(null)},dealId:ke.dealId,dealName:ke.dealName,fromStageName:ke.fromStageName,toStageName:ke.toStageName,toStageId:ke.toStageId,onConfirm:ds}),e.jsx(SNs,{open:me,onOpenChange:ve})]})}function kks(){return e.jsx(jks,{children:e.jsx(Nks,{})})}function Alt({open:t,onOpenChange:s,editTask:r,defaultDealId:n,defaultStageId:a}){var J;const o=dks(),l=uks(),{data:i}=Pme(),d=ya(),{data:u}=gt({queryKey:["contacts-for-tasks",d],queryFn:async()=>{if(!d)return[];const{data:X,error:ce}=await G.from("innercircle_contacts").select("id, first_name, last_name").eq("owner_user_id",d).order("first_name").limit(500);if(ce)throw ce;return X},enabled:!!d&&t}),[p,f]=k.useState(""),[y,_]=k.useState(""),[b,N]=k.useState("none"),[w,S]=k.useState("none"),[C,A]=k.useState("medium"),[I,L]=k.useState("todo"),[O,V]=k.useState(),[q,B]=k.useState(!1),[U,te]=k.useState(!1);k.useEffect(()=>{r?(f(r.title),_(r.description||""),N(r.deal_id||"none"),S(r.contact_id||"none"),A(r.priority),L(r.status),V(r.due_date?xm(r.due_date):void 0)):(f(""),_(""),N(n||"none"),S("none"),A("medium"),L("todo"),V(void 0))},[r,t,n]);const Y=async()=>{if(!p.trim()){pe.error("Task title is required");return}try{const X={title:p.trim(),description:y.trim()||null,deal_id:b==="none"?null:b,contact_id:w==="none"?null:w,stage_id:a||null,priority:C,status:I,due_date:O?vs(O,"yyyy-MM-dd"):null};r?(await l.mutateAsync({id:r.id,...X}),pe.success("Task updated")):(await o.mutateAsync(X),pe.success("Task created")),s(!1)}catch{pe.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(ks,{children:e.jsx(_s,{children:r?"Edit Task":"New Task"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Title *"}),e.jsx(De,{value:p,onChange:X=>f(X.target.value),placeholder:"e.g., Send inspection report"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Description"}),e.jsx(_r,{value:y,onChange:X=>_(X.target.value),placeholder:"Optional details...",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Priority"}),e.jsxs($s,{value:C,onValueChange:X=>A(X),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"low",children:"🟢 Low"}),e.jsx(vt,{value:"medium",children:"🟡 Medium"}),e.jsx(vt,{value:"high",children:"🟠 High"}),e.jsx(vt,{value:"urgent",children:"🔴 Urgent"})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Status"}),e.jsxs($s,{value:I,onValueChange:X=>L(X),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"todo",children:"To Do"}),e.jsx(vt,{value:"in_progress",children:"In Progress"}),e.jsx(vt,{value:"done",children:"Done"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Due Date"}),e.jsxs(mo,{children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{variant:"outline",className:Ot("w-full justify-start text-left font-normal",!O&&"text-muted-foreground"),children:[e.jsx(cn,{className:"mr-2 h-4 w-4"}),O?vs(O,"PPP"):"Pick a date"]})}),e.jsx(no,{className:"w-auto p-0",align:"start",children:e.jsx(uf,{mode:"single",selected:O,onSelect:V,initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Link to Deal"}),e.jsxs(mo,{open:q,onOpenChange:B,children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{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(pa,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),b!=="none"?((J=i==null?void 0:i.find(X=>X.id===b))==null?void 0:J.deal_name)||"Select deal":"No Deal"]}),e.jsx(gx,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(no,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Sx,{children:[e.jsx(Cx,{placeholder:"Search deals..."}),e.jsxs(Mx,{children:[e.jsx(Tx,{children:"No deals found."}),e.jsxs(Ax,{children:[e.jsxs(cp,{value:"no-deal",onSelect:()=>{N("none"),B(!1)},children:[e.jsx(Zn,{className:Ot("mr-2 h-4 w-4",b==="none"?"opacity-100":"opacity-0")}),"No Deal"]}),i==null?void 0:i.map(X=>e.jsxs(cp,{value:X.deal_name,onSelect:()=>{N(X.id),B(!1)},children:[e.jsx(Zn,{className:Ot("mr-2 h-4 w-4",b===X.id?"opacity-100":"opacity-0")}),X.deal_name]},X.id))]})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Link to Contact"}),e.jsxs(mo,{open:U,onOpenChange:te,children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{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(Ai,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),w!=="none"?(()=>{const X=u==null?void 0:u.find(ce=>ce.id===w);return X?`${X.first_name} ${X.last_name}`:"Select contact"})():"No Contact"]}),e.jsx(gx,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(no,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Sx,{children:[e.jsx(Cx,{placeholder:"Search contacts..."}),e.jsxs(Mx,{children:[e.jsx(Tx,{children:"No contacts found."}),e.jsxs(Ax,{children:[e.jsxs(cp,{value:"no-contact",onSelect:()=>{S("none"),te(!1)},children:[e.jsx(Zn,{className:Ot("mr-2 h-4 w-4",w==="none"?"opacity-100":"opacity-0")}),"No Contact"]}),u==null?void 0:u.map(X=>e.jsxs(cp,{value:`${X.first_name} ${X.last_name}`,onSelect:()=>{S(X.id),te(!1)},children:[e.jsx(Zn,{className:Ot("mr-2 h-4 w-4",w===X.id?"opacity-100":"opacity-0")}),X.first_name," ",X.last_name]},X.id))]})]})]})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(W,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(W,{onClick:Y,disabled:o.isPending||l.isPending,children:r?"Save Changes":"Create Task"})]})]})]})})}const Sks={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 Cks({tasks:t}){const s=$Ce(),r=hks(),n=wr(),[a,o]=k.useState(null),l=async p=>{const f=p.status==="done"?"todo":"done";try{await s.mutateAsync({id:p.id,status:f})}catch{pe.error("Failed to update task")}},i=async p=>{try{await r.mutateAsync(p),pe.success("Task deleted")}catch{pe.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($n,{className:"h-12 w-12 text-muted-foreground/30 mb-3"}),e.jsx("p",{className:"text-muted-foreground font-medium",children:"No tasks found"}),e.jsx("p",{className:"text-muted-foreground/60 text-sm",children:"Create a new task to get started"})]});const d=new Map,u=[];return t.forEach(p=>{if(p.deal){const f=d.get(p.deal.id)||{dealName:p.deal.deal_name,tasks:[]};f.tasks.push(p),d.set(p.deal.id,f)}else u.push(p)}),e.jsxs("div",{className:"space-y-4",children:[u.length>0&&e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsx("div",{className:"bg-muted/30 px-4 py-2 border-b",children:e.jsx("h3",{className:"font-medium text-sm text-muted-foreground",children:"General Tasks"})}),u.map(p=>e.jsx(l9e,{task:p,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:f=>n(`/mission-control/pipeline?deal=${f}`)},p.id))]}),Array.from(d.entries()).map(([p,f])=>e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>n(`/mission-control/pipeline?deal=${p}`),className:"w-full bg-muted/30 px-4 py-2 border-b flex items-center gap-2 hover:bg-muted/50 transition-colors text-left",children:[e.jsx(pa,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("h3",{className:"font-medium text-sm",children:f.dealName}),e.jsxs(Qe,{variant:"secondary",className:"ml-auto text-xs",children:[f.tasks.filter(y=>y.status==="done").length,"/",f.tasks.length]}),e.jsx(xa,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),f.tasks.map(y=>e.jsx(l9e,{task:y,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:_=>n(`/mission-control/pipeline?deal=${_}`)},y.id))]},p)),a&&e.jsx(Alt,{open:!!a,onOpenChange:()=>o(null),editTask:a})]})}function l9e({task:t,onToggle:s,onDelete:r,onEdit:n,onNavigateDeal:a}){const o=t.status==="done",l=!o&&t.due_date&&a0(xm(t.due_date))&&!iu(xm(t.due_date)),i=!o&&t.due_date&&iu(xm(t.due_date)),d=Sks[t.priority];return e.jsxs("div",{className:Ot("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($n,{className:"h-5 w-5 text-emerald-500"}):e.jsx(sd,{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:Ot("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(Ai,{className:"h-2.5 w-2.5"}),t.contact.first_name," ",t.contact.last_name]})]})]}),e.jsxs(Qe,{variant:"outline",className:Ot("text-[10px] shrink-0",d.color),children:[d.dot," ",d.label]}),t.due_date&&e.jsxs("span",{className:Ot("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(nn,{className:"h-3 w-3"}),vs(xm(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(Wc,{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(vr,{className:"h-3.5 w-3.5 text-destructive"})})]})]})}const Mks=[{status:"todo",label:"To Do",icon:sd,color:"border-t-slate-400"},{status:"in_progress",label:"In Progress",icon:rp,color:"border-t-blue-500"},{status:"done",label:"Done",icon:$n,color:"border-t-emerald-500"}],Tks={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function Aks({tasks:t}){const s=$Ce(),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 d=t.find(u=>u.id===i);if(!(!d||d.status===l))try{await s.mutateAsync({id:i,status:l})}catch{pe.error("Failed to move task")}};return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:Mks.map(o=>e.jsxs("div",{className:Ot("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(Qe,{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(Eks,{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 Eks({task:t,onDragStart:s}){const r=t.status==="done",n=!r&&t.due_date&&a0(xm(t.due_date))&&!iu(xm(t.due_date)),a=!r&&t.due_date&&iu(xm(t.due_date));return e.jsx("div",{draggable:!0,onDragStart:o=>s(o,t.id),className:Ot("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:Tks[t.priority]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:Ot("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(pa,{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(Ai,{className:"h-2.5 w-2.5"}),t.contact.first_name," ",t.contact.last_name]})]}),t.due_date&&e.jsxs("div",{className:Ot("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(nn,{className:"h-2.5 w-2.5"}),n?"Overdue — ":a?"Due today — ":"",vs(xm(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 c9e={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function Pks({tasks:t}){const[s,r]=k.useState(new Date),n=$Ce(),a=gc(s),o=tx(s),l=zh(a),i=Lue(o),d=P4t({start:l,end:i}),u=k.useMemo(()=>{const y=new Map;return t.forEach(_=>{if(!_.due_date)return;const b=_.due_date,N=y.get(b)||[];N.push(_),y.set(b,N)}),y},[t]),p=k.useMemo(()=>t.filter(y=>!y.due_date),[t]),f=async y=>{const _=y.status==="done"?"todo":"done";try{await n.mutateAsync({id:y.id,status:_})}catch{pe.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(W,{variant:"ghost",size:"icon",onClick:()=>r(g4(s,1)),children:e.jsx(Xo,{className:"h-4 w-4"})}),e.jsx("h3",{className:"font-semibold",children:vs(s,"MMMM yyyy")}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>r(Am(s,1)),children:e.jsx(xa,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"grid grid-cols-7 text-center",children:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(y=>e.jsx("div",{className:"text-xs font-medium text-muted-foreground py-2",children:y},y))}),e.jsx("div",{className:"grid grid-cols-7 border-l border-t",children:d.map(y=>{const _=vs(y,"yyyy-MM-dd"),b=u.get(_)||[],N=Rue(y,s),w=iu(y);return e.jsxs("div",{className:Ot("border-r border-b min-h-[100px] p-1",!N&&"bg-muted/30",w&&"bg-primary/5"),children:[e.jsx("div",{className:Ot("text-xs font-medium mb-1 text-right px-1",!N&&"text-muted-foreground/40",w&&"text-primary font-bold"),children:vs(y,"d")}),e.jsxs("div",{className:"space-y-0.5",children:[b.slice(0,3).map(S=>e.jsxs("button",{onClick:()=>f(S),className:Ot("w-full text-left text-[10px] px-1 py-0.5 rounded truncate flex items-center gap-0.5 hover:bg-muted transition-colors",S.status==="done"?"text-muted-foreground line-through":"text-foreground"),children:[S.status==="done"?e.jsx($n,{className:"h-2.5 w-2.5 text-emerald-500 shrink-0"}):e.jsx(sd,{className:"h-2.5 w-2.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[c9e[S.priority]," ",S.title]})]},S.id)),b.length>3&&e.jsxs("p",{className:"text-[9px] text-muted-foreground text-center",children:["+",b.length-3," more"]})]})]},_)})}),p.length>0&&e.jsxs("div",{className:"border rounded-lg p-3",children:[e.jsxs("h4",{className:"text-sm font-medium text-muted-foreground mb-2",children:["No Due Date (",p.length,")"]}),e.jsx("div",{className:"space-y-1",children:p.map(y=>e.jsxs("button",{onClick:()=>f(y),className:Ot("w-full text-left text-xs px-2 py-1.5 rounded flex items-center gap-2 hover:bg-muted transition-colors",y.status==="done"&&"opacity-50 line-through"),children:[y.status==="done"?e.jsx($n,{className:"h-3.5 w-3.5 text-emerald-500 shrink-0"}):e.jsx(sd,{className:"h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[c9e[y.priority]," ",y.title]}),y.deal&&e.jsxs("span",{className:"text-muted-foreground ml-auto shrink-0",children:["• ",y.deal.deal_name]})]},y.id))})]})]})}const Iks={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function Lks({open:t,onOpenChange:s,stages:r}){var S;const[n,a]=k.useState(((S=r[0])==null?void 0:S.id)||""),{data:o,isLoading:l}=pks(n||void 0),i=fks(),d=xks(),[u,p]=k.useState(""),[f,y]=k.useState("medium"),[_,b]=k.useState(""),N=async()=>{if(!(!u.trim()||!n))try{await i.mutateAsync({stage_id:n,title:u.trim(),priority:f,default_due_offset_days:_?parseInt(_):null,sort_order:((o==null?void 0:o.length)||0)+1}),p(""),b(""),pe.success("Template added")}catch{pe.error("Failed to add template")}},w=async C=>{try{await d.mutateAsync(C),pe.success("Template deleted")}catch{pe.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(ks,{children:e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(pL,{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(xe,{children:"Pipeline Stage"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:r.filter(C=>!C.is_won_stage&&!C.is_lost_stage).map(C=>e.jsx("button",{onClick:()=>a(C.id),className:Ot("px-3 py-1.5 rounded-full text-xs font-medium border transition-colors",n===C.id?"border-primary bg-primary/10 text-primary":"border-border hover:bg-muted"),children:C.name},C.id))})]}),e.jsx(Ja,{className:"max-h-[250px]",children:e.jsxs("div",{className:"space-y-1.5",children:[o==null?void 0:o.map((C,A)=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border rounded-lg group",children:[e.jsx("span",{className:"text-xs",children:Iks[C.priority]}),e.jsx("span",{className:"text-sm flex-1 truncate",children:C.title}),C.default_due_offset_days&&e.jsxs(Qe,{variant:"outline",className:"text-[10px]",children:["+",C.default_due_offset_days,"d"]}),e.jsx("button",{onClick:()=>w(C.id),className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-destructive/10 rounded transition-opacity",children:e.jsx(vr,{className:"h-3.5 w-3.5 text-destructive"})})]},C.id)),(o==null?void 0:o.length)===0&&n&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No templates for this stage yet"})]})}),n&&e.jsxs("div",{className:"space-y-3 border-t pt-3",children:[e.jsx(xe,{className:"text-xs text-muted-foreground",children:"Add Template Task"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{placeholder:"Task title...",value:u,onChange:C=>p(C.target.value),className:"flex-1",onKeyDown:C=>C.key==="Enter"&&N()}),e.jsxs($s,{value:f,onValueChange:C=>y(C),children:[e.jsx(zs,{className:"w-[100px]",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"low",children:"🟢 Low"}),e.jsx(vt,{value:"medium",children:"🟡 Med"}),e.jsx(vt,{value:"high",children:"🟠 High"}),e.jsx(vt,{value:"urgent",children:"🔴 Urgent"})]})]})]}),e.jsxs("div",{className:"flex gap-2 items-end",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(xe,{className:"text-xs",children:"Due offset (days from entering stage)"}),e.jsx(De,{type:"number",placeholder:"e.g., 7",value:_,onChange:C=>b(C.target.value)})]}),e.jsxs(W,{onClick:N,disabled:!u.trim()||i.isPending,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add"]})]})]})]})})}function Dks(){const{data:t,isLoading:s}=lks(),{data:r}=Eme(),[n,a]=k.useState("list"),[o,l]=k.useState(""),[i,d]=k.useState("active"),[u,p]=k.useState("all"),[f,y]=k.useState("all"),[_,b]=k.useState(!1),[N,w]=k.useState(!1),S=k.useMemo(()=>{if(!t)return[];const I=new Map;return t.forEach(L=>{L.deal&&I.set(L.deal.id,L.deal.deal_name)}),Array.from(I,([L,O])=>({id:L,name:O}))},[t]),C=k.useMemo(()=>t?t.filter(I=>{var U,te,Y,J;const L=o.toLowerCase(),O=!L||I.title.toLowerCase().includes(L)||((te=(U=I.deal)==null?void 0:U.deal_name)==null?void 0:te.toLowerCase().includes(L))||`${((Y=I.contact)==null?void 0:Y.first_name)||""} ${((J=I.contact)==null?void 0:J.last_name)||""}`.toLowerCase().includes(L),V=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&&a0(xm(I.due_date))&&!iu(xm(I.due_date)),q=u==="all"||I.priority===u,B=f==="all"||f==="no_deal"&&!I.deal_id||I.deal_id===f;return O&&V&&q&&B}):[],[t,o,i,u,f]),A=k.useMemo(()=>{if(!t)return{total:0,overdue:0,dueToday:0,dueThisWeek:0,completed:0};const I=t.filter(L=>L.status!=="done");return{total:I.length,overdue:I.filter(L=>L.due_date&&a0(xm(L.due_date))&&!iu(xm(L.due_date))).length,dueToday:I.filter(L=>L.due_date&&iu(xm(L.due_date))).length,dueThisWeek:I.filter(L=>L.due_date&&MCt(xm(L.due_date))).length,completed:t.filter(L=>L.status==="done").length}},[t]);return e.jsx(Ds,{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(W,{variant:"outline",size:"sm",onClick:()=>w(!0),children:[e.jsx(Eg,{className:"h-4 w-4 mr-1"}),"Templates"]}),e.jsxs(W,{size:"sm",onClick:()=>b(!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:()=>d("active"),className:`p-3 rounded-lg border text-left transition-colors ${i==="active"?"border-primary bg-primary/5":"hover:bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-xs font-medium",children:[e.jsx(Dh,{className:"h-3.5 w-3.5"}),"Active"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:A.total})]}),e.jsxs("button",{onClick:()=>d("overdue"),className:`p-3 rounded-lg border text-left transition-colors ${i==="overdue"?"border-destructive bg-destructive/5":"hover:bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 text-destructive text-xs font-medium",children:[e.jsx(Dc,{className:"h-3.5 w-3.5"}),"Overdue"]}),e.jsx("p",{className:"text-xl font-bold mt-1 text-destructive",children:A.overdue})]}),e.jsxs("button",{onClick:()=>{d("active")},className:"p-3 rounded-lg border text-left hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 text-amber-600 text-xs font-medium",children:[e.jsx(nn,{className:"h-3.5 w-3.5"}),"Due Today"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:A.dueToday})]}),e.jsxs("button",{onClick:()=>{d("active")},className:"p-3 rounded-lg border text-left hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 text-blue-600 text-xs font-medium",children:[e.jsx(_d,{className:"h-3.5 w-3.5"}),"This Week"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:A.dueThisWeek})]}),e.jsxs("button",{onClick:()=>d("done"),className:`p-3 rounded-lg border text-left transition-colors ${i==="done"?"border-emerald-500 bg-emerald-500/5":"hover:bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 text-emerald-600 text-xs font-medium",children:[e.jsx($n,{className:"h-3.5 w-3.5"}),"Completed"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:A.completed})]})]}),e.jsxs("div",{className:"flex flex-col md:flex-row gap-3 items-start md:items-center",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search tasks...",value:o,onChange:I=>l(I.target.value),className:"pl-9"})]}),e.jsxs($s,{value:u,onValueChange:p,children:[e.jsx(zs,{className:"w-[130px]",children:e.jsx(Vs,{placeholder:"Priority"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Priorities"}),e.jsx(vt,{value:"urgent",children:"🔴 Urgent"}),e.jsx(vt,{value:"high",children:"🟠 High"}),e.jsx(vt,{value:"medium",children:"🟡 Medium"}),e.jsx(vt,{value:"low",children:"🟢 Low"})]})]}),e.jsxs($s,{value:f,onValueChange:y,children:[e.jsx(zs,{className:"w-[160px]",children:e.jsx(Vs,{placeholder:"Deal"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Deals"}),e.jsx(vt,{value:"no_deal",children:"No Deal"}),S.map(I=>e.jsx(vt,{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(Dh,{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(Yy,{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(_d,{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(Cks,{tasks:C}),n==="kanban"&&e.jsx(Aks,{tasks:C}),n==="calendar"&&e.jsx(Pks,{tasks:C})]}),e.jsx(Alt,{open:_,onOpenChange:b}),e.jsx(Lks,{open:N,onOpenChange:w,stages:r||[]})]})})}function Rks(){const t=ya();return gt({queryKey:["portal-referrals",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("portal_referrals").select("*, client_portals!inner(slug, client_name, deal_id)").eq("owner_user_id",t).order("created_at",{ascending:!1});if(r)throw r;return s||[]},enabled:!!t})}function Oks(){const t=Qt();return Pt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("portal_referrals").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["portal-referrals"]})}})}function Fks(){const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("portal_referrals").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["portal-referrals"]})}})}const zks=t=>new Intl.DateTimeFormat("en-US",{timeZone:"America/New_York",month:"short",day:"numeric",year:"numeric"}).format(new Date(t)),b0e=[{value:"new",label:"New",className:"bg-blue-500/10 text-blue-700 border-blue-200"},{value:"contacted",label:"Contacted",className:"bg-amber-500/10 text-amber-700 border-amber-200"},{value:"converted",label:"Converted 🎉",className:"bg-emerald-500/10 text-emerald-700 border-emerald-200"},{value:"lost",label:"Lost",className:"bg-slate-500/10 text-slate-700 border-slate-200"}],Bks={buying:"Buying",selling:"Selling",both:"Buying & Selling",unsure:"Not sure yet"};function $ks(){const{data:t=[],isLoading:s}=Rks(),r=Oks(),n=Fks(),[a,o]=k.useState("all"),[l,i]=k.useState({}),d=k.useMemo(()=>a==="all"?t:t.filter(_=>_.status===a),[t,a]),u=k.useMemo(()=>({total:t.length,new:t.filter(_=>_.status==="new").length,converted:t.filter(_=>_.status==="converted").length}),[t]),p=(_,b)=>{r.mutate({id:_.id,status:b}),pe.success("Status updated")},f=_=>{const b=l[_.id];r.mutate({id:_.id,agent_notes:b}),i(N=>{const{[_.id]:w,...S}=N;return S}),pe.success("Notes saved")},y=_=>{confirm(`Delete referral for ${_.friend_name}?`)&&n.mutate(_.id)};return e.jsxs("div",{className:"container max-w-5xl py-6 px-4",children:[e.jsx(kl,{children:e.jsx("title",{children:"Client Portal Referrals"})}),e.jsxs("div",{className:"flex items-start justify-between mb-6 flex-wrap gap-3",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(hi,{className:"h-6 w-6 text-primary"}),"Portal Referrals"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Referrals sent in by happy clients via their post-close portal."})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("div",{className:"bg-card border rounded-lg px-4 py-2 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:u.total}),e.jsx("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"Total"})]}),e.jsxs("div",{className:"bg-card border rounded-lg px-4 py-2 text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-blue-600",children:u.new}),e.jsx("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"New"})]}),e.jsxs("div",{className:"bg-card border rounded-lg px-4 py-2 text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-emerald-600",children:u.converted}),e.jsx("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"Closed"})]})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:[{v:"all",l:"All"},...b0e.map(_=>({v:_.value,l:_.label}))].map(_=>e.jsx("button",{onClick:()=>o(_.v),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${a===_.v?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:_.l},_.v))}),s?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(us,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):d.length===0?e.jsx(Pe,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(hi,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("p",{className:"text-sm font-medium",children:"No referrals yet"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Once your closed clients refer friends from their portal, they'll show up here."})]})}):e.jsx("div",{className:"space-y-3",children:d.map(_=>{var S,C;const b=b0e.find(A=>A.value===_.status),N=(S=_.client_portals)==null?void 0:S.slug,w=_.referrer_name||((C=_.client_portals)==null?void 0:C.client_name)||"Anonymous client";return e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between flex-wrap gap-2",children:[e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:_.friend_name}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1 flex items-center gap-1.5",children:[e.jsx(cn,{className:"h-3 w-3"}),"Referred by ",e.jsx("span",{className:"font-medium text-foreground",children:w})," ·"," ",zks(_.created_at)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Qe,{variant:"outline",className:b==null?void 0:b.className,children:(b==null?void 0:b.label)||_.status}),e.jsxs($s,{value:_.status,onValueChange:A=>p(_,A),children:[e.jsx(zs,{className:"h-8 w-[130px] text-xs",children:e.jsx(Vs,{})}),e.jsx(Bs,{children:b0e.map(A=>e.jsx(vt,{value:A.value,className:"text-xs",children:A.label},A.value))})]})]})]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[_.friend_interest&&e.jsx(Qe,{variant:"secondary",className:"text-xs",children:Bks[_.friend_interest]||_.friend_interest}),_.friend_email&&e.jsxs("a",{href:`mailto:${_.friend_email}`,className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:[e.jsx(tr,{className:"h-3 w-3"}),_.friend_email]}),_.friend_phone&&e.jsxs(e.Fragment,{children:[e.jsxs("a",{href:`tel:${_.friend_phone}`,className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:[e.jsx(In,{className:"h-3 w-3"}),_.friend_phone]}),e.jsxs("a",{href:`sms:${_.friend_phone}`,className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:[e.jsx(Fl,{className:"h-3 w-3"}),"Text"]})]})]}),_.friend_message&&e.jsxs("div",{className:"bg-muted/50 rounded-md p-3 text-sm",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground mb-1",children:"Note from referrer"}),e.jsxs("p",{className:"italic text-foreground",children:['"',_.friend_message,'"']})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground mb-1",children:"Your notes"}),l[_.id]!==void 0?e.jsxs("div",{className:"space-y-2",children:[e.jsx(_r,{value:l[_.id],onChange:A=>i(I=>({...I,[_.id]:A.target.value})),rows:3,className:"text-sm"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{size:"sm",onClick:()=>f(_),children:"Save"}),e.jsx(W,{size:"sm",variant:"ghost",onClick:()=>i(A=>{const{[_.id]:I,...L}=A;return L}),children:"Cancel"})]})]}):e.jsx("button",{onClick:()=>i(A=>({...A,[_.id]:_.agent_notes||""})),className:"text-sm text-left w-full p-2 rounded border border-dashed border-input hover:border-primary/50 hover:bg-muted/30 transition-colors",children:_.agent_notes||e.jsx("span",{className:"text-muted-foreground italic",children:"Click to add notes..."})})]}),e.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[N&&e.jsxs("a",{href:`/portal/${N}`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-primary inline-flex items-center gap-1",children:[e.jsx(Yr,{className:"h-3 w-3"}),"View source portal"]}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>y(_),className:"text-destructive hover:text-destructive ml-auto h-8",children:e.jsx(vr,{className:"h-3.5 w-3.5"})})]})]})]},_.id)})})]})}const Xwe=[{value:"video_intro",label:"Video Intro",icon:yn,description:"Add an intro video"},{value:"testimonials",label:"Testimonials",icon:SL,description:"Client testimonials carousel"},{value:"specialties",label:"Specialties",icon:mh,description:"Tags for your specialties"},{value:"custom_links",label:"Custom Links",icon:Do,description:"Custom CTA buttons"},{value:"social_media",label:"Social Media",icon:id,description:"Links to your social profiles"}],qks=["First-Time Buyers","Luxury Homes","Investment Properties","Relocation","New Construction","Condos & Townhomes","Waterfront","Commercial","Land & Lots","Senior Living","Military/VA","Short Sales & Foreclosures"],Uks={video_intro:{video_url:""},testimonials:{testimonials:[{name:"",quote:"",role:""}]},specialties:{tags:[]},custom_links:{links:[{label:"",url:""}]},social_media:{platforms:[]}};function Elt({cardId:t}){const{data:s,isLoading:r}=kkt(t),n=Skt(),a=Ckt(),o=Mkt(),[l,i]=k.useState(!1),[d,u]=k.useState(""),[p,f]=k.useState(null);if(r)return e.jsxs("div",{className:"space-y-3",children:[e.jsx(Ms,{className:"h-16 w-full"}),e.jsx(Ms,{className:"h-16 w-full"})]});const y=()=>{d&&n.mutate({card_id:t,block_type:d,sort_order:(s==null?void 0:s.length)||0,config:Uks[d]||{}},{onSuccess:()=>{i(!1),u("")}})},_=C=>{a.mutate({id:C.id,is_visible:!C.is_visible})},b=(C,A)=>{if(!s)return;const I=s.findIndex(V=>V.id===C.id),L=A==="up"?I-1:I+1;if(L<0||L>=s.length)return;const O=s[L];a.mutate({id:C.id,sort_order:O.sort_order}),a.mutate({id:O.id,sort_order:C.sort_order})},N=C=>{confirm("Remove this block from this card?")&&o.mutate(C.id)},w=(C,A)=>{a.mutate({id:C.id,config:A},{onSuccess:()=>f(null)})},S=C=>Xwe.find(A=>A.value===C);return e.jsxs("div",{className:"space-y-3",children:[!s||s.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-muted-foreground mb-4 text-sm",children:"No blocks yet. Add a block to customize this card."}),e.jsxs(W,{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((C,A)=>{const I=S(C.block_type),L=(I==null?void 0:I.icon)||mh;return e.jsx(Pe,{className:C.is_visible?"":"opacity-50",children:e.jsx(Oe,{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mu,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx(L,{className:"h-4 w-4 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-xs",children:(I==null?void 0:I.label)||C.block_type}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Vks(C)})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(W,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>b(C,"up"),disabled:A===0,children:e.jsx(uu,{className:"h-3 w-3"})}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>b(C,"down"),disabled:A===s.length-1,children:e.jsx(Ih,{className:"h-3 w-3"})}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>_(C),children:C.is_visible?e.jsx(jn,{className:"h-3 w-3"}):e.jsx(pp,{className:"h-3 w-3"})}),e.jsx(W,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>f(C),children:"Edit"}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:()=>N(C),children:e.jsx(vr,{className:"h-3 w-3"})})]})]})})},C.id)}),e.jsxs(W,{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(ks,{children:e.jsx(_s,{children:"Add Block"})}),e.jsx("div",{className:"grid gap-3",children:Xwe.map(C=>{const A=C.icon;return e.jsxs("button",{onClick:()=>u(C.value),className:`flex items-center gap-3 p-3 rounded-lg border text-left transition-colors ${d===C.value?"border-primary bg-primary/5":"border-border hover:bg-muted"}`,children:[e.jsx(A,{className:"h-5 w-5 text-primary flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:C.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C.description})]})]},C.value)})}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(W,{onClick:y,disabled:!d||n.isPending,children:"Add Block"})]})]})}),p&&e.jsx(Hks,{block:p,onSave:C=>w(p,C),onClose:()=>f(null)})]})}function Vks(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 Hks({block:t,onSave:s,onClose:r}){const[n,a]=k.useState(t.config),o=Xwe.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(ks,{children:e.jsxs(_s,{children:["Edit ",o==null?void 0:o.label]})}),t.block_type==="video_intro"&&e.jsx(Gks,{config:n,onChange:a,cardId:t.card_id}),t.block_type==="testimonials"&&e.jsx(Wks,{config:n,onChange:a}),t.block_type==="specialties"&&e.jsx(Kks,{config:n,onChange:a}),t.block_type==="custom_links"&&e.jsx(Zks,{config:n,onChange:a}),t.block_type==="social_media"&&e.jsx(Yks,{config:n,onChange:a}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:r,children:"Cancel"}),e.jsx(W,{onClick:()=>s(n),children:"Save"})]})]})})}function Gks({config:t,onChange:s,cardId:r}){var _,b;const[n,a]=k.useState(""),[o,l]=k.useState((_=t.video_url)!=null&&_.includes("youtube")||(b=t.video_url)!=null&&b.includes("youtu.be")?"youtube":"library"),{data:i}=gt({queryKey:["card-owner",r],queryFn:async()=>{const{data:N}=await G.from("agent_cards").select("user_id").eq("id",r).single();return N==null?void 0:N.user_id},enabled:!!r}),{data:d,isLoading:u}=gt({queryKey:["agent-videos-library",i],queryFn:async()=>{const{data:N,error:w}=await G.from("agent_videos").select("id, title, bunny_video_id, thumbnail_url, playback_url, created_at").eq("owner_user_id",i).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1});if(w)throw w;return N||[]},enabled:!!i}),p=(d==null?void 0:d.filter(N=>!n||(N.title||"").toLowerCase().includes(n.toLowerCase())))||[],f=t.bunny_video_id,y=N=>{var A;const w=(A=N.playback_url)==null?void 0:A.match(/\/(?:play|embed)\/(\d+)\//),C=`https://iframe.mediadelivery.net/embed/${w?w[1]:"570924"}/${N.bunny_video_id}?autoplay=false&responsive=true`;s({...t,video_url:C,bunny_video_id:N.bunny_video_id,video_source:"library"})};return e.jsx("div",{className:"space-y-4",children:e.jsxs(ta,{value:o,onValueChange:l,children:[e.jsxs(Jn,{className:"w-full",children:[e.jsx(cs,{value:"library",className:"flex-1",children:"Video Library"}),e.jsx(cs,{value:"youtube",className:"flex-1",children:"YouTube URL"})]}),e.jsxs(Ss,{value:"library",className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search videos...",value:n,onChange:N=>a(N.target.value),className:"pl-9"})]}),e.jsx(Ja,{className:"h-[240px]",children:u?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ms,{className:"h-14 w-full"}),e.jsx(Ms,{className:"h-14 w-full"})]}):p.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:(d==null?void 0:d.length)===0?"No videos in library yet":"No matching videos"}):e.jsx("div",{className:"space-y-1.5 pr-3",children:p.map(N=>e.jsxs("button",{onClick:()=>y(N),className:`w-full flex items-center gap-3 p-2 rounded-lg border text-left transition-colors ${f===N.bunny_video_id?"border-primary bg-primary/5":"border-border hover:bg-muted"}`,children:[N.thumbnail_url?e.jsx("img",{src:N.thumbnail_url,alt:"",className:"h-10 w-16 rounded object-cover flex-shrink-0 bg-muted",onError:w=>{var S;w.currentTarget.style.display="none",(S=w.currentTarget.nextElementSibling)==null||S.classList.remove("hidden")}}):null,e.jsx("div",{className:`h-10 w-16 rounded bg-muted flex items-center justify-center flex-shrink-0 ${N.thumbnail_url?"hidden":""}`,children:e.jsx(yn,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-medium truncate flex-1",children:N.title||"Untitled Video"}),f===N.bunny_video_id&&e.jsx(Zn,{className:"h-4 w-4 text-primary flex-shrink-0"})]},N.id))})})]}),e.jsx(Ss,{value:"youtube",className:"space-y-3 mt-3",children:e.jsxs("div",{children:[e.jsx(xe,{children:"YouTube URL"}),e.jsx(De,{placeholder:"https://www.youtube.com/watch?v=...",value:t.video_source==="youtube"&&t.video_url||"",onChange:N=>s({...t,video_url:N.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 Wks({config:t,onChange:s}){const r=t.testimonials||[],n=(l,i,d)=>{const u=[...r];u[l]={...u[l],[i]:d},s({...t,testimonials:u})},a=()=>s({...t,testimonials:[...r,{name:"",quote:"",role:""}]}),o=l=>s({...t,testimonials:r.filter((i,d)=>d!==l)});return e.jsxs("div",{className:"space-y-4",children:[r.map((l,i)=>e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(xe,{className:"text-xs font-medium",children:["Testimonial ",i+1]}),r.length>1&&e.jsx(W,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>o(i),children:e.jsx(vr,{className:"h-3 w-3"})})]}),e.jsx(De,{placeholder:"Client name",value:l.name,onChange:d=>n(i,"name",d.target.value)}),e.jsx(De,{placeholder:"Role/title (optional)",value:l.role||"",onChange:d=>n(i,"role",d.target.value)}),e.jsx("textarea",{className:"w-full min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm",placeholder:"Their testimonial quote...",value:l.quote,onChange:d=>n(i,"quote",d.target.value)})]})},i)),e.jsxs(W,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Add Testimonial"]})]})}function Kks({config:t,onChange:s}){const r=t.tags||[],[n,a]=k.useState(""),o=i=>{s({...t,tags:r.includes(i)?r.filter(d=>d!==i):[...r,i]})},l=()=>{n.trim()&&!r.includes(n.trim())&&(s({...t,tags:[...r,n.trim()]}),a(""))};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm mb-2 block",children:"Preset Specialties"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:qks.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(xe,{className:"text-sm mb-2 block",children:"Custom Tag"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{placeholder:"Add your own...",value:n,onChange:i=>a(i.target.value),onKeyDown:i=>i.key==="Enter"&&(i.preventDefault(),l())}),e.jsx(W,{variant:"outline",size:"sm",onClick:l,children:"Add"})]})]}),r.length>0&&e.jsxs("div",{children:[e.jsxs(xe,{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 Zks({config:t,onChange:s}){const r=t.links||[],n=(l,i,d)=>{const u=[...r];u[l]={...u[l],[i]:d},s({...t,links:u})},a=()=>s({...t,links:[...r,{label:"",url:""}]}),o=l=>s({...t,links:r.filter((i,d)=>d!==l)});return e.jsxs("div",{className:"space-y-3",children:[r.map((l,i)=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(De,{placeholder:"Button label",value:l.label,onChange:d=>n(i,"label",d.target.value)}),e.jsx(De,{placeholder:"https://...",value:l.url,onChange:d=>n(i,"url",d.target.value)})]}),r.length>1&&e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8 mt-1 text-destructive",onClick:()=>o(i),children:e.jsx(vr,{className:"h-3 w-3"})})]},i)),e.jsxs(W,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Add Link"]})]})}const d9e=[{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 Yks({config:t,onChange:s}){const r=t.platforms||[],n=d=>{r.find(u=>u.platform===d)||s({...t,platforms:[...r,{platform:d,url:""}]})},a=(d,u)=>{const p=[...r];p[d]={...p[d],url:u},s({...t,platforms:p})},o=d=>{s({...t,platforms:r.filter((u,p)=>p!==d)})},l=d9e.filter(d=>!r.find(u=>u.platform===d.value)),i=d=>{const u=b1e[d],p=d9e.find(f=>f.value===d);return{label:(p==null?void 0:p.label)||d,color:(u==null?void 0:u.color)||"#666",iconPath:u==null?void 0:u.icon}};return e.jsxs("div",{className:"space-y-4",children:[r.length>0&&e.jsx("div",{className:"space-y-3",children:r.map((d,u)=>{const p=i(d.platform);return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg flex items-center justify-center flex-shrink-0 border",style:{borderColor:p.color+"30",backgroundColor:p.color+"10"},children:p.iconPath&&e.jsx("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:p.color,children:e.jsx("path",{d:p.iconPath})})}),e.jsx("div",{className:"flex-1",children:e.jsx(De,{placeholder:`Your ${p.label} profile URL`,value:d.url,onChange:f=>a(u,f.target.value)})}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive flex-shrink-0",onClick:()=>o(u),children:e.jsx(vr,{className:"h-3.5 w-3.5"})})]},u)})}),l.length>0&&e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs text-muted-foreground mb-2 block",children:"Add a platform"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l.map(d=>{const u=b1e[d.value];return e.jsxs("button",{onClick:()=>n(d.value),className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-full border border-border bg-muted hover:bg-muted/80 transition-colors",children:[(u==null?void 0:u.icon)&&e.jsx("svg",{viewBox:"0 0 24 24",width:12,height:12,fill:u.color,children:e.jsx("path",{d:u.icon})}),d.label]},d.value)})})]}),r.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Tap a platform above to add your social media profile."})]})}var Xks=Object.defineProperty,Ade=Object.getOwnPropertySymbols,Plt=Object.prototype.hasOwnProperty,Ilt=Object.prototype.propertyIsEnumerable,u9e=(t,s,r)=>s in t?Xks(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,Qwe=(t,s)=>{for(var r in s||(s={}))Plt.call(s,r)&&u9e(t,r,s[r]);if(Ade)for(var r of Ade(s))Ilt.call(s,r)&&u9e(t,r,s[r]);return t},Jwe=(t,s)=>{var r={};for(var n in t)Plt.call(t,n)&&s.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&Ade)for(var n of Ade(t))s.indexOf(n)<0&&Ilt.call(t,n)&&(r[n]=t[n]);return r};/** * @license QR Code generator library (TypeScript) * Copyright (c) Project Nayuki. * SPDX-License-Identifier: MIT */var yC;(t=>{const s=class Vi{constructor(d,u,p,f){if(this.version=d,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],dVi.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=d*4+17;let y=[];for(let b=0;b7)throw new RangeError("Invalid value");let b,N;for(b=p;;b++){const A=Vi.getNumDataCodewords(b,u)*8,I=l.getTotalBits(d,b);if(I<=A){N=I;break}if(b>=f)throw new RangeError("Data too long")}for(const A of[Vi.Ecc.MEDIUM,Vi.Ecc.QUARTILE,Vi.Ecc.HIGH])_&&N<=Vi.getNumDataCodewords(b,A)*8&&(u=A);let w=[];for(const A of d){r(A.mode.modeBits,4,w),r(A.numChars,A.mode.numCharCountBits(b),w);for(const I of A.getData())w.push(I)}a(w.length==N);const S=Vi.getNumDataCodewords(b,u)*8;a(w.length<=S),r(0,Math.min(4,S-w.length),w),r(0,(8-w.length%8)%8,w),a(w.length%8==0);for(let A=236;w.lengthC[I>>>3]|=A<<7-(I&7)),new Vi(b,u,C,y)}getModule(d,u){return 0<=d&&d>>9)*1335;const f=(u<<10|p)^21522;a(f>>>15==0);for(let y=0;y<=5;y++)this.setFunctionModule(8,y,n(f,y));this.setFunctionModule(8,7,n(f,6)),this.setFunctionModule(8,8,n(f,7)),this.setFunctionModule(7,8,n(f,8));for(let y=9;y<15;y++)this.setFunctionModule(14-y,8,n(f,y));for(let y=0;y<8;y++)this.setFunctionModule(this.size-1-y,8,n(f,y));for(let y=8;y<15;y++)this.setFunctionModule(8,this.size-15+y,n(f,y));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let d=this.version;for(let p=0;p<12;p++)d=d<<1^(d>>>11)*7973;const u=this.version<<12|d;a(u>>>18==0);for(let p=0;p<18;p++){const f=n(u,p),y=this.size-11+p%3,_=Math.floor(p/3);this.setFunctionModule(y,_,f),this.setFunctionModule(_,y,f)}}drawFinderPattern(d,u){for(let p=-4;p<=4;p++)for(let f=-4;f<=4;f++){const y=Math.max(Math.abs(f),Math.abs(p)),_=d+f,b=u+p;0<=_&&_{(A!=N-y||L>=b)&&C.push(I[A])});return a(C.length==_),C}drawCodewords(d){if(d.length!=Math.floor(Vi.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let u=0;for(let p=this.size-1;p>=1;p-=2){p==6&&(p=5);for(let f=0;f>>3],7-(u&7)),u++)}}a(u==d.length*8)}applyMask(d){if(d<0||d>7)throw new RangeError("Mask value out of range");for(let u=0;u5&&d++):(this.finderPenaltyAddHistory(b,N),_||(d+=this.finderPenaltyCountPatterns(N)*Vi.PENALTY_N3),_=this.modules[y][w],b=1);d+=this.finderPenaltyTerminateAndCount(_,b,N)*Vi.PENALTY_N3}for(let y=0;y5&&d++):(this.finderPenaltyAddHistory(b,N),_||(d+=this.finderPenaltyCountPatterns(N)*Vi.PENALTY_N3),_=this.modules[w][y],b=1);d+=this.finderPenaltyTerminateAndCount(_,b,N)*Vi.PENALTY_N3}for(let y=0;y_+(b?1:0),u);const p=this.size*this.size,f=Math.ceil(Math.abs(u*20-p*10)/p)-1;return a(0<=f&&f<=9),d+=f*Vi.PENALTY_N4,a(0<=d&&d<=2568888),d}getAlignmentPatternPositions(){if(this.version==1)return[];{const d=Math.floor(this.version/7)+2,u=this.version==32?26:Math.ceil((this.version*4+4)/(d*2-2))*2;let p=[6];for(let f=this.size-7;p.lengthVi.MAX_VERSION)throw new RangeError("Version number out of range");let u=(16*d+128)*d+64;if(d>=2){const p=Math.floor(d/7)+2;u-=(25*p-10)*p-55,d>=7&&(u-=36)}return a(208<=u&&u<=29648),u}static getNumDataCodewords(d,u){return Math.floor(Vi.getNumRawDataModules(d)/8)-Vi.ECC_CODEWORDS_PER_BLOCK[u.ordinal][d]*Vi.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][d]}static reedSolomonComputeDivisor(d){if(d<1||d>255)throw new RangeError("Degree out of range");let u=[];for(let f=0;f0);for(const f of d){const y=f^p.shift();p.push(0),u.forEach((_,b)=>p[b]^=Vi.reedSolomonMultiply(_,y))}return p}static reedSolomonMultiply(d,u){if(d>>>8||u>>>8)throw new RangeError("Byte out of range");let p=0;for(let f=7;f>=0;f--)p=p<<1^(p>>>7)*285,p^=(u>>>f&1)*d;return a(p>>>8==0),p}finderPenaltyCountPatterns(d){const u=d[1];a(u<=this.size*3);const p=u>0&&d[2]==u&&d[3]==u*3&&d[4]==u&&d[5]==u;return(p&&d[0]>=u*4&&d[6]>=u?1:0)+(p&&d[6]>=u*4&&d[0]>=u?1:0)}finderPenaltyTerminateAndCount(d,u,p){return d&&(this.finderPenaltyAddHistory(u,p),u=0),u+=this.size,this.finderPenaltyAddHistory(u,p),this.finderPenaltyCountPatterns(p)}finderPenaltyAddHistory(d,u){u[0]==0&&(d+=this.size),u.pop(),u.unshift(d)}};s.MIN_VERSION=1,s.MAX_VERSION=40,s.PENALTY_N1=3,s.PENALTY_N2=3,s.PENALTY_N3=40,s.PENALTY_N4=10,s.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],s.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t.QrCode=s;function r(i,d,u){if(d<0||d>31||i>>>d)throw new RangeError("Value out of range");for(let p=d-1;p>=0;p--)u.push(i>>>p&1)}function n(i,d){return(i>>>d&1)!=0}function a(i){if(!i)throw new Error("Assertion error")}const o=class Hc{constructor(d,u,p){if(this.mode=d,this.numChars=u,this.bitData=p,u<0)throw new RangeError("Invalid argument");this.bitData=p.slice()}static makeBytes(d){let u=[];for(const p of d)r(p,8,u);return new Hc(Hc.Mode.BYTE,d.length,u)}static makeNumeric(d){if(!Hc.isNumeric(d))throw new RangeError("String contains non-numeric characters");let u=[];for(let p=0;p=1<{(s=>{const r=class{constructor(a,o){this.ordinal=a,this.formatBits=o}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),s.Ecc=r})(t.QrCode||(t.QrCode={}))})(yC||(yC={}));(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={}))})(yC||(yC={}));var uM=yC;/** * @license qrcode.react * Copyright (c) Paul O'Shannessy * SPDX-License-Identifier: ISC */var Qks={L:uM.QrCode.Ecc.LOW,M:uM.QrCode.Ecc.MEDIUM,Q:uM.QrCode.Ecc.QUARTILE,H:uM.QrCode.Ecc.HIGH},Llt=128,Dlt="L",Rlt="#FFFFFF",Olt="#000000",Flt=!1,zlt=1,Jks=4,e4s=0,t4s=.1;function Blt(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 $lt(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 s4s(t,s,r,n){if(n==null)return null;const a=t.length+r*2,o=Math.floor(s*t4s),l=a/s,i=(n.width||o)*l,d=(n.height||o)*l,u=n.x==null?t.length/2-i/2:n.x*l,p=n.y==null?t.length/2-d/2:n.y*l,f=n.opacity==null?1:n.opacity;let y=null;if(n.excavate){let b=Math.floor(u),N=Math.floor(p),w=Math.ceil(i+u-b),S=Math.ceil(d+p-N);y={x:b,y:N,w,h:S}}const _=n.crossOrigin;return{x:u,y:p,h:d,w:i,excavation:y,opacity:f,crossOrigin:_}}function r4s(t,s){return s!=null?Math.max(Math.floor(s),0):t?Jks:e4s}function qlt({value:t,level:s,minVersion:r,includeMargin:n,marginSize:a,imageSettings:o,size:l,boostLevel:i}){let d=xt.useMemo(()=>{const b=(Array.isArray(t)?t:[t]).reduce((N,w)=>(N.push(...uM.QrSegment.makeSegments(w)),N),[]);return uM.QrCode.encodeSegments(b,Qks[s],r,void 0,void 0,i)},[t,s,r,i]);const{cells:u,margin:p,numCells:f,calculatedImageSettings:y}=xt.useMemo(()=>{let _=d.getModules();const b=r4s(n,a),N=_.length+b*2,w=s4s(_,l,b,o);return{cells:_,margin:b,numCells:N,calculatedImageSettings:w}},[d,l,o,n,a]);return{qrcode:d,margin:p,cells:u,numCells:f,calculatedImageSettings:y}}var n4s=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),a4s=xt.forwardRef(function(s,r){const n=s,{value:a,size:o=Llt,level:l=Dlt,bgColor:i=Rlt,fgColor:d=Olt,includeMargin:u=Flt,minVersion:p=zlt,boostLevel:f,marginSize:y,imageSettings:_}=n,N=Jwe(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:w}=N,S=Jwe(N,["style"]),C=_==null?void 0:_.src,A=xt.useRef(null),I=xt.useRef(null),L=xt.useCallback(X=>{A.current=X,typeof r=="function"?r(X):r&&(r.current=X)},[r]),[O,V]=xt.useState(!1),{margin:q,cells:B,numCells:U,calculatedImageSettings:te}=qlt({value:a,level:l,minVersion:p,boostLevel:f,includeMargin:u,marginSize:y,imageSettings:_,size:o});xt.useEffect(()=>{if(A.current!=null){const X=A.current,ce=X.getContext("2d");if(!ce)return;let ie=B;const ae=I.current,oe=te!=null&&ae!==null&&ae.complete&&ae.naturalHeight!==0&&ae.naturalWidth!==0;oe&&te.excavation!=null&&(ie=$lt(B,te.excavation));const me=window.devicePixelRatio||1;X.height=X.width=o*me;const ve=o/U*me;ce.scale(ve,ve),ce.fillStyle=i,ce.fillRect(0,0,U,U),ce.fillStyle=d,n4s?ce.fill(new Path2D(Blt(ie,q))):B.forEach(function(he,ge){he.forEach(function(je,qe){je&&ce.fillRect(qe+q,ge+q,1,1)})}),te&&(ce.globalAlpha=te.opacity),oe&&ce.drawImage(ae,te.x+q,te.y+q,te.w,te.h)}}),xt.useEffect(()=>{V(!1)},[C]);const Y=Qwe({height:o,width:o},w);let J=null;return C!=null&&(J=xt.createElement("img",{src:C,key:C,style:{display:"none"},onLoad:()=>{V(!0)},ref:I,crossOrigin:te==null?void 0:te.crossOrigin})),xt.createElement(xt.Fragment,null,xt.createElement("canvas",Qwe({style:Y,height:o,width:o,ref:L,role:"img"},S)),J)});a4s.displayName="QRCodeCanvas";var EO=xt.forwardRef(function(s,r){const n=s,{value:a,size:o=Llt,level:l=Dlt,bgColor:i=Rlt,fgColor:d=Olt,includeMargin:u=Flt,minVersion:p=zlt,boostLevel:f,title:y,marginSize:_,imageSettings:b}=n,N=Jwe(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:w,cells:S,numCells:C,calculatedImageSettings:A}=qlt({value:a,level:l,minVersion:p,boostLevel:f,includeMargin:u,marginSize:_,imageSettings:b,size:o});let I=S,L=null;b!=null&&A!=null&&(A.excavation!=null&&(I=$lt(S,A.excavation)),L=xt.createElement("image",{href:b.src,height:A.h,width:A.w,x:A.x+w,y:A.y+w,preserveAspectRatio:"none",opacity:A.opacity,crossOrigin:A.crossOrigin}));const O=Blt(I,w);return xt.createElement("svg",Qwe({height:o,width:o,viewBox:`0 0 ${C} ${C}`,ref:r,role:"img"},N),!!y&&xt.createElement("title",null,y),xt.createElement("path",{fill:i,d:`M0,0 h${C}v${C}H0z`,shapeRendering:"crispEdges"}),xt.createElement("path",{fill:d,d:O,shapeRendering:"crispEdges"}),L)});EO.displayName="QRCodeSVG";function i4s({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 d=l.getContext("2d");if(!d)return;const u=new XMLSerializer().serializeToString(o),p=new Image;p.onload=()=>{d.fillStyle="#ffffff",d.fillRect(0,0,i,i),d.drawImage(p,0,0,i,i);const y=document.createElement("a");y.download=`${t}-qr-code.png`,y.href=l.toDataURL("image/png"),y.click(),pe.success("QR code downloaded!")},p.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(u)))},[t]);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(xe,{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(EO,{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(W,{variant:"outline",size:"sm",onClick:a,className:"gap-1.5",children:[e.jsx(Qa,{className:"h-3.5 w-3.5"}),"Download PNG"]})]})]})]})}function w0e(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 o4s(){const{user:t}=Us(),{data:s,isLoading:r}=wkt(t==null?void 0:t.id),n=bE(),[a,o]=k.useState(null),l=k.useMemo(()=>a||(s?w0e(s):null),[a,s]);if(r)return e.jsx(Ds,{children:e.jsxs("div",{className:"max-w-2xl mx-auto p-4 space-y-4",children:[e.jsx(Ms,{className:"h-8 w-48"}),e.jsx(Ms,{className:"h-32 w-full"}),e.jsx(Ms,{className:"h-32 w-full"})]})});if(!s)return e.jsx(Ds,{children:e.jsx(c4s,{userId:t==null?void 0:t.id})});const i=l||w0e(s),d=u=>{o(p=>{const f=p||w0e(s);return typeof u=="function"?u(f):u})};return e.jsx(Ds,{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(d4s,{card:s}),e.jsx(p4s,{card:s,form:i,setForm:d})]}),!n&&e.jsx("div",{className:"w-[400px] shrink-0","aria-hidden":"true"}),!n&&e.jsx("div",{className:"fixed right-8 top-[5.5rem] w-[400px] z-30",style:{height:"calc(100vh - 6.5rem)"},children:e.jsxs("div",{className:"rounded-xl border bg-muted/30 overflow-hidden h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b bg-card shrink-0",children:[e.jsx(hS,{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(l4s,{card:s,form:i})})]})})]})})}function l4s({card:t,form:s}){const{data:r}=gt({queryKey:["card-preview-profile",t.user_id],queryFn:async()=>{const{data:a}=await G.from("profiles").select("name, email, phone, avatar_url, brokerage_id").eq("id",t.user_id).single();let o=(a==null?void 0:a.avatar_url)||null;if(!o){const{data:l}=await G.storage.from("avatars").list(`${t.user_id}`);if(l&&l.length>0){const{data:i}=G.storage.from("avatars").getPublicUrl(`${t.user_id}/${l[0].name}`);o=`${i.publicUrl}?t=${Date.now()}`}}return{...a,avatar_url:o}}}),n=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(Wje,{card:n})})}function c4s({userId:t}){var d;const[s,r]=k.useState(""),n=_We(),{data:a}=gt({queryKey:["my-profile-for-card",t],queryFn:async()=>{if(!t)return null;const{data:u}=await G.from("profiles").select("name").eq("id",t).single();return u},enabled:!!t}),o=((d=a==null?void 0:a.name)==null?void 0:d.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""))||"",l=()=>{if(!t)return;const u=(s.trim()||o).toLowerCase().replace(/[^a-z0-9-]/g,"-");if(!u){pe.error("Please enter a URL slug for your card");return}n.mutate({user_id:t,slug:u,is_published:!0},{onSuccess:()=>pe.success("Your digital card has been created!")})},i=[{icon:nd,title:"Shareable Link",desc:"One link that works everywhere"},{icon:Oh,title:"Lead Capture",desc:"Collect leads automatically"},{icon:zu,title:"Always Up-to-Date",desc:"Edit anytime, changes are instant"},{icon:zl,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(Or,{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(Dt,{className:"text-center pb-2",children:[e.jsx(zt,{className:"text-xl",children:"Set Up Your Card"}),e.jsx(dr,{children:"Choose a URL slug — this is the link you'll share with clients"})]}),e.jsxs(Oe,{className:"p-6 pt-2 space-y-5",children:[e.jsxs("div",{children:[e.jsx(xe,{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(De,{value:s||o,onChange:u=>r(u.target.value),placeholder:"your-name",className:"rounded-l-none"})]})]}),e.jsxs(W,{onClick:l,disabled:n.isPending,className:"w-full h-11 text-base font-semibold",size:"lg",children:[e.jsx(Or,{className:"h-4 w-4 mr-2"}),n.isPending?"Creating...":"Create My Card"]})]})]})]})}function d4s({card:t}){const r=`https://cards.relevelup.com/${t.slug}`,n=()=>{navigator.clipboard.writeText(r),pe.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(Qe,{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(W,{variant:"outline",size:"sm",onClick:n,className:"gap-1.5",children:[e.jsx(Va,{className:"h-3.5 w-3.5"})," Copy Link"]}),e.jsx(W,{size:"sm",asChild:!0,className:"gap-1.5",children:e.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Yr,{className:"h-3.5 w-3.5"})," Preview"]})})]})]})})}function u4s({userId:t}){const s=Qt(),r=k.useRef(null),[n,a]=k.useState(!1),[o,l]=k.useState(""),{data:i,isLoading:d}=gt({queryKey:["card-editor-profile",t],queryFn:async()=>{const{data:te}=await G.from("profiles").select("name, email, phone, avatar_url").eq("id",t).single();let Y=(te==null?void 0:te.avatar_url)||null;if(!Y){const{data:J}=await G.storage.from("avatars").list(`${t}`);if(J&&J.length>0){const{data:X}=G.storage.from("avatars").getPublicUrl(`${t}/${J[0].name}`);Y=`${X.publicUrl}?t=${Date.now()}`,await G.from("profiles").update({avatar_url:Y}).eq("id",t)}}return{...te,avatar_url:Y}}}),[u,p]=k.useState(null),[f,y]=k.useState(null),[_,b]=k.useState(null),[N,w]=k.useState(!1),S=u??(i==null?void 0:i.name)??"",C=f??(i==null?void 0:i.phone)??"",A=_??(i==null?void 0:i.email)??"",I=i==null?void 0:i.avatar_url,L=((i==null?void 0:i.name)||"A").split(" ").map(te=>te[0]).join("").toUpperCase().slice(0,2),O=!(i!=null&&i.avatar_url)||!(i!=null&&i.phone),V=Pt({mutationFn:async te=>{const{error:Y}=await G.from("profiles").update(te).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"]}),pe.success("Profile updated!")},onError:()=>pe.error("Failed to update profile")}),q=()=>{const te={};if(u!==null&&u!==(i==null?void 0:i.name)&&(te.name=u),f!==null&&f!==(i==null?void 0:i.phone)&&(te.phone=f||null),_!==null&&_!==(i==null?void 0:i.email)&&(te.email=_),Object.keys(te).length===0){pe.info("No changes to save");return}V.mutate(te)},B=te=>{var X;const Y=(X=te.target.files)==null?void 0:X[0];if(!Y)return;if(!Y.type.startsWith("image/")){pe.error("Please select an image file");return}const J=new FileReader;J.onloadend=()=>{l(J.result),a(!0)},J.readAsDataURL(Y),te.target.value=""},U=async te=>{w(!0);try{const{data:Y}=await G.storage.from("avatars").list(`${t}`);Y&&Y.length>0&&await G.storage.from("avatars").remove(Y.map(ae=>`${t}/${ae.name}`));const J=`${t}/avatar.jpg`,{error:X}=await G.storage.from("avatars").upload(J,te,{upsert:!0,contentType:"image/jpeg"});if(X)throw X;const{data:ce}=G.storage.from("avatars").getPublicUrl(J),ie=ce.publicUrl+"?t="+Date.now();await G.from("profiles").update({avatar_url:ie}).eq("id",t),s.invalidateQueries({queryKey:["card-editor-profile",t]}),s.invalidateQueries({queryKey:["card-preview-profile",t]}),s.invalidateQueries({queryKey:["agent-card-user"]}),pe.success("Photo updated!")}catch{pe.error("Failed to upload photo")}finally{w(!1)}};return d?e.jsx(Ms,{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(Oe,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(xe,{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(ro,{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 te;return(te=r.current)==null?void 0:te.click()},children:[e.jsxs(Nn,{className:"h-16 w-16 ring-2 ring-muted",children:[e.jsx(Ma,{src:I||void 0,alt:S}),e.jsx(kn,{className:"text-lg font-semibold bg-primary/10 text-primary",children:L})]}),e.jsx("div",{className:"absolute inset-0 bg-black/40 rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(xx,{className:"h-5 w-5 text-white"})}),e.jsx("input",{ref:r,type:"file",accept:"image/*",className:"hidden",onChange:B})]}),e.jsxs("div",{className:"flex-1 space-y-0.5",children:[e.jsx("p",{className:"text-sm font-medium",children:N?"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(xe,{className:"text-xs font-medium text-muted-foreground",children:"Full Name"}),e.jsx(De,{value:S,onChange:te=>p(te.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(xe,{className:"text-xs font-medium text-muted-foreground",children:"Phone Number"}),e.jsx(De,{value:C,onChange:te=>y(te.target.value),placeholder:"(555) 123-4567",className:"h-10",type:"tel"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs font-medium text-muted-foreground",children:"Email"}),e.jsx(De,{value:A,onChange:te=>b(te.target.value),placeholder:"you@example.com",className:"h-10",type:"email"})]})]})]}),e.jsx(W,{variant:"outline",size:"sm",onClick:q,disabled:V.isPending,className:"w-full",children:V.isPending?"Saving...":"Update Profile Info"})]})}),e.jsx(e4e,{open:n,onClose:()=>a(!1),imageSrc:o,onCropComplete:U,aspectRatio:1})]})}function h4s({form:t,setForm:s,userId:r}){const[n,a]=k.useState(null),[o,l]=k.useState(t.brokerage_logo_url?"logo":"name"),[i,d]=k.useState(t.team_logo_url?"logo":"name"),u=_=>{l(_),s(_==="name"?b=>({...b,brokerage_logo_url:""}):b=>({...b,brokerage_display_name:""}))},p=_=>{d(_),s(_==="name"?b=>({...b,team_logo_url:""}):b=>({...b,team_name:""}))},f=async(_,b)=>{var w;const N=(w=_.target.files)==null?void 0:w[0];if(N){if(!N.type.startsWith("image/")){pe.error("Please select an image file");return}a(b);try{const S=N.name.split(".").pop()||"png",A=`${r}/${b==="brokerage_logo_url"?"brokerage-logo":"team-logo"}.${S}`,{error:I}=await G.storage.from("card-logos").upload(A,N,{upsert:!0});if(I)throw I;const{data:L}=G.storage.from("card-logos").getPublicUrl(A),O=L.publicUrl+"?t="+Date.now();s(b==="brokerage_logo_url"?V=>({...V,[b]:O,brokerage_display_name:""}):V=>({...V,[b]:O,team_name:""})),pe.success("Logo uploaded!")}catch{pe.error("Failed to upload logo")}finally{a(null),_.target.value=""}}},y=_=>{s(b=>({...b,[_]:""}))};return e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-5 space-y-5",children:[e.jsxs("div",{children:[e.jsx(xe,{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(xe,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Brokerage"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{type:"button",variant:o==="name"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>u("name"),children:"Use Name"}),e.jsx(W,{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(xe,{className:"text-xs font-medium text-muted-foreground",children:"Brokerage Name"}),e.jsx(De,{value:t.brokerage_display_name,onChange:_=>s(b=>({...b,brokerage_display_name:_.target.value})),placeholder:"e.g. Keller Williams Realty",className:"h-10"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(xe,{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:()=>y("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(xx,{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:_=>f(_,"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(xe,{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(Cg,{value:[t.brokerage_logo_size||56],onValueChange:([_])=>s(b=>({...b,brokerage_logo_size:_})),min:24,max:120,step:4})]})]})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(xe,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Team"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{type:"button",variant:i==="name"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>p("name"),children:"Use Name"}),e.jsx(W,{type:"button",variant:i==="logo"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>p("logo"),children:"Use Logo"})]}),i==="name"?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs font-medium text-muted-foreground",children:"Team Name"}),e.jsx(De,{value:t.team_name,onChange:_=>s(b=>({...b,team_name:_.target.value})),placeholder:"e.g. The Smith Group",className:"h-10"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(xe,{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:()=>y("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(xx,{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:_=>f(_,"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(xe,{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(Cg,{value:[t.team_logo_size||56],onValueChange:([_])=>s(b=>({...b,team_logo_size:_})),min:24,max:120,step:4})]})]})]})]})})}function m4s({form:t,setForm:s}){const r={accent:"#ff5722",dark:"#1a1a2e",button:"#ff5722"},n=t.bold_theme_colors||r,a=(i,d)=>{s(u=>({...u,bold_theme_colors:{...r,...u.bold_theme_colors,[i]:d}}))},o=()=>{s(i=>({...i,bold_theme_colors:null}))},l=[{key:"accent",label:"Accent Color",desc:"Page background, icons, highlights"},{key:"dark",label:"Dark Color",desc:"Header background, action buttons, social icons"},{key:"button",label:"CTA Button Color",desc:"Main call-to-action button"}];return e.jsxs("div",{className:"space-y-3 p-4 rounded-xl border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(xe,{className:"text-sm font-semibold flex items-center gap-1.5",children:[e.jsx(zl,{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(W,{variant:"ghost",size:"sm",className:"text-xs h-7",onClick:o,children:"Reset to Default"})]}),e.jsx("div",{className:"grid gap-3",children:l.map(({key:i,label:d,desc:u})=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("label",{className:"relative shrink-0",children:[e.jsx("input",{type:"color",value:n[i],onChange:p=>a(i,p.target.value),className:"sr-only"}),e.jsx("div",{className:"h-10 w-10 rounded-lg border-2 border-border cursor-pointer shadow-sm hover:scale-105 transition-transform",style:{backgroundColor:n[i]}})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:d}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u})]}),e.jsx(De,{value:n[i],onChange:p=>{const f=p.target.value;/^#[0-9a-fA-F]{0,6}$/.test(f)&&a(i,f)},className:"w-24 h-8 text-xs font-mono",placeholder:"#ff5722"})]},i))}),e.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Preview:"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"h-6 w-12 rounded",style:{backgroundColor:n.accent}}),e.jsx("div",{className:"h-6 w-12 rounded",style:{backgroundColor:n.dark}}),e.jsx("div",{className:"h-6 w-12 rounded",style:{backgroundColor:n.button}})]})]})]})}function p4s({card:t,form:s,setForm:r}){var N;const n=bWe(),a=Qt(),{data:o}=wWe(t.id),[l,i]=k.useState(t.slug),[d,u]=k.useState(!1),[p,f]=k.useState("idle"),y=k.useRef(JSON.stringify(s)),_=k.useRef(null);k.useEffect(()=>{const w=JSON.stringify(s);if(w!==y.current)return _.current&&clearTimeout(_.current),_.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:()=>{y.current=w,f("saved"),setTimeout(()=>f("idle"),2e3)},onError:()=>f("idle")})},1500),()=>{_.current&&clearTimeout(_.current)}},[s]);const b=async()=>{const w=l.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!w){pe.error("Please enter a valid URL");return}if(w===t.slug){pe.info("No changes to save");return}u(!0);try{const{data:S}=await G.from("agent_cards").select("id").eq("slug",w).neq("id",t.id).maybeSingle();if(S){pe.error("This URL is already taken. Try another one.");return}const{error:C}=await G.from("agent_cards").update({slug:w}).eq("id",t.id);if(C)throw C;i(w),a.invalidateQueries({queryKey:["agent-card"]}),pe.success("Card address updated!")}catch{pe.error("Failed to update card address")}finally{u(!1)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(ta,{defaultValue:"content",children:[e.jsxs(Jn,{className:"w-full h-11 p-1",children:[e.jsxs(cs,{value:"content",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(yx,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Content"]}),e.jsxs(cs,{value:"sections",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(jn,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Sections"]}),e.jsxs(cs,{value:"blocks",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Oh,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Blocks"]}),e.jsxs(cs,{value:"qrcode",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Jy,{className:"h-3.5 w-3.5 hidden sm:inline"}),"QR Code"]}),e.jsxs(cs,{value:"analytics",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Tm,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Analytics"]})]}),e.jsxs(Ss,{value:"content",className:"mt-4 space-y-4",children:[e.jsx(u4s,{userId:t.user_id}),e.jsx(h4s,{form:s,setForm:r,userId:t.user_id}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-5 space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx(xe,{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(Ar,{checked:s.is_published,onCheckedChange:w=>r(S=>({...S,is_published:w}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{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(De,{value:l,onChange:w=>i(w.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"your-name",className:"rounded-l-none h-10"})]}),e.jsx(W,{variant:"outline",size:"sm",onClick:b,disabled:d||l===t.slug,className:"shrink-0",children:d?"Saving...":"Update"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This is your unique card URL. Only letters, numbers, and dashes allowed."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-sm font-medium",children:"Card Email (Override)"}),e.jsx(De,{value:s.display_email,onChange:w=>r(S=>({...S,display_email:w.target.value})),placeholder:"you@yourbusiness.com",className:"h-11",type:"email"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional — use a different email on your card instead of your sign-in email."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-sm font-medium",children:"Theme"}),e.jsxs($s,{value:s.theme,onValueChange:w=>r(S=>({...S,theme:w})),children:[e.jsx(zs,{className:"h-11",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"standard",children:"✨ Standard — Modern & Clean"}),e.jsx(vt,{value:"luxury",children:"🌙 Luxury — Dark & Gold"}),e.jsx(vt,{value:"bold",children:"🔥 Bold — Vibrant & Punchy"}),e.jsx(vt,{value:"classic",children:"📋 Classic — Professional"})]})]})]}),s.theme==="bold"&&e.jsx(m4s,{form:s,setForm:r}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-sm font-medium",children:"Title / Tagline"}),e.jsx(De,{value:s.title,onChange:w=>r(S=>({...S,title:w.target.value})),placeholder:"e.g. Luxury Real Estate Specialist",className:"h-11"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Shown below your name on the card"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-sm font-medium",children:"Positioning Statement"}),e.jsx(De,{value:s.positioning_statement,onChange:w=>r(S=>({...S,positioning_statement:w.target.value})),placeholder:"Your home journey, handled with care.",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-sm font-medium",children:"Bio"}),e.jsx(_r,{value:s.bio,onChange:w=>r(S=>({...S,bio:w.target.value})),placeholder:"A short intro about you and what makes you different...",rows:3})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-sm font-medium",children:"Review Snippet"}),e.jsx(De,{value:s.review_snippet,onChange:w=>r(S=>({...S,review_snippet:w.target.value})),placeholder:"Best agent we've ever worked with...",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-sm font-medium",children:"Review Source URL"}),e.jsx(De,{value:s.review_source_url,onChange:w=>r(S=>({...S,review_source_url:w.target.value})),placeholder:"https://g.page/your-business/review",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-sm font-medium",children:"Booking URL"}),e.jsx(De,{value:s.booking_url,onChange:w=>r(S=>({...S,booking_url:w.target.value})),placeholder:"https://calendly.com/your-link",className:"h-11"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave empty to show a built-in lead form instead"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-sm font-medium",children:"Custom CTA Label"}),e.jsx(De,{value:s.custom_cta_label,onChange:w=>r(S=>({...S,custom_cta_label:w.target.value})),placeholder:"Book a Call",className:"h-11"})]})]})})]}),e.jsx(Ss,{value:"sections",className:"mt-4",children:e.jsx(Pe,{children:e.jsx(Oe,{className:"p-5 divide-y",children:[{key:"show_photo",label:"Photo",desc:"Uses the photo from your Profile Info above"},{key:"show_bio",label:"Bio Section",desc:"Display your bio on the card"},{key:"show_credentials",label:"Credentials",desc:"Show star rating and reviews"},{key:"show_social_links",label:"Social Links",desc:"Display your social media links"},{key:"show_save_contact",label:"Save Contact",desc:"Let visitors save you as a contact"},{key:"show_leave_review",label:"Leave Review",desc:"Link to your review page"},{key:"show_refer_friend",label:"Refer a Friend",desc:"Enable referral submissions"}].map(({key:w,label:S,desc:C})=>e.jsxs("div",{className:"flex items-center justify-between py-4 first:pt-0 last:pb-0",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(xe,{className:"text-sm font-medium",children:S}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C})]}),e.jsx(Ar,{checked:s[w],onCheckedChange:A=>r(I=>({...I,[w]:A}))})]},w))})})}),e.jsx(Ss,{value:"blocks",className:"mt-4",children:e.jsx(Elt,{cardId:t.id})}),e.jsx(Ss,{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:jn,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:Tm,color:"text-amber-600 bg-amber-100 dark:text-amber-400 dark:bg-amber-900/30"},{label:"Leads",value:((N=o==null?void 0:o.leads)==null?void 0:N.length)??0,icon:Jo,color:"text-emerald-600 bg-emerald-100 dark:text-emerald-400 dark:bg-emerald-900/30"}].map(w=>e.jsx(Pe,{className:"overflow-hidden",children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:`p-1.5 rounded-md ${w.color}`,children:e.jsx(w.icon,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:w.label})]}),e.jsx("div",{className:"text-2xl font-bold",children:w.value})]})},w.label))}),o&&o.leads.length>0&&e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsx(zt,{className:"text-base",children:"Recent Leads"})}),e.jsx(Oe,{className:"pt-0 space-y-2",children:o.leads.slice(0,5).map(w=>e.jsxs("div",{className:"flex items-center justify-between text-sm p-3 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:w.name}),w.phone&&e.jsx("span",{className:"text-muted-foreground ml-2",children:w.phone})]}),w.intent&&e.jsx(Qe,{variant:"secondary",className:"text-xs",children:w.intent})]},w.id))})]}),(!o||o.leads.length===0)&&e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-8 text-center",children:[e.jsx(Tm,{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(Ss,{value:"qrcode",className:"mt-4 space-y-4",children:e.jsx(Pe,{children:e.jsx(Oe,{className:"p-6",children:e.jsx(i4s,{slug:t.slug})})})})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-sm text-muted-foreground",children:[p==="saving"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-amber-400 animate-pulse"})," Saving..."]}),p==="saved"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-green-500"})," All changes saved"]}),p==="idle"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-muted-foreground/30"})," Changes auto-save"]})]})]})}function f4s(){const t=Qt(),[s,r]=k.useState(""),[n,a]=k.useState(!1),[o,l]=k.useState(!1),[i,d]=k.useState(null),[u,p]=k.useState(!1),[f,y]=k.useState(!1),[_,b]=k.useState(null),[N,w]=k.useState(null),[S,C]=k.useState(0),[A,I]=k.useState(""),[L,O]=k.useState(!1),{data:V,isLoading:q}=gt({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:me,error:ve}=await G.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(ve)throw ve;return me}}),B=Pt({mutationFn:async me=>{const{data:ve,error:he}=await G.functions.invoke("boldtrail-sync",{body:{action:"save_token",api_token:me}});if(he)throw he;if(ve!=null&&ve.error)throw new Error(ve.error);return ve},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),r(""),pe.success("BoldTrail connected successfully!")},onError:me=>{pe.error(me.message||"Failed to connect BoldTrail")}}),U=Pt({mutationFn:async()=>{const{data:me,error:ve}=await G.functions.invoke("boldtrail-sync",{body:{action:"disconnect"}});if(ve)throw ve;return me},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),pe.success("BoldTrail disconnected")},onError:()=>pe.error("Failed to disconnect")}),te=Pt({mutationFn:async me=>{const{data:ve,error:he}=await G.functions.invoke("boldtrail-sync",{body:{action:"save_direction",sync_direction:me}});if(he)throw he;if(ve!=null&&ve.error)throw new Error(ve.error);return ve},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),pe.success("Sync direction saved")},onError:me=>{pe.error(me.message||"Failed to save sync direction")}}),Y=Pt({mutationFn:async()=>{const{data:me,error:ve}=await G.functions.invoke("boldtrail-sync",{body:{action:"detect_owner"}});if(ve)throw ve;if(me!=null&&me.error)throw new Error(me.error);return me},onSuccess:me=>{if(t.invalidateQueries({queryKey:["boldtrail-status"]}),me.kvcore_user_id){const ve=me.detected_name||me.detected_email||`ID ${me.kvcore_user_id}`;pe.success(`Detected your BoldTrail account: ${ve}`)}else if(me.candidates&&me.candidates.length>0){const ve=me.candidates.slice(0,5).map(he=>`${he.id} (${he.count} contacts)`).join(", ");pe.warning(`Couldn't auto-detect your ID. Owner IDs found in your contacts: ${ve}. Pick yours and enter it below.`,{duration:12e3}),O(!0)}else pe.warning("Couldn't auto-detect your BoldTrail user ID. Please find it in BoldTrail (My Profile URL) and enter it manually."),O(!0)},onError:me=>pe.error(me.message||"Detection failed")}),J=Pt({mutationFn:async me=>{const{data:ve,error:he}=await G.functions.invoke("boldtrail-sync",{body:{action:"save_owner_settings",...me}});if(he)throw he;if(ve!=null&&ve.error)throw new Error(ve.error);return ve},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),pe.success("Settings saved"),O(!1)},onError:me=>pe.error(me.message||"Failed to save settings")}),X=Pt({mutationFn:async()=>{const{data:me,error:ve}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync_preview"}});if(ve)throw ve;if(me!=null&&me.error)throw new Error(me.error);return me},onSuccess:me=>{b(null),d(me),a(!0)},onError:me=>{pe.error(me.message||"Failed to generate sync preview")}}),ce=Pt({mutationFn:async()=>{w("Initializing sync..."),C(5);const{data:me,error:ve}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:oe}});if(ve)throw ve;if(me!=null&&me.error)throw new Error(me.error);const he=me;let ge=he.sync_log_id,je=he.next_phase,qe=he.next_offset,Me=he.push_total||0,ke=he.pull_total||0,Re=0,Ve=0;for(;je!=="finalize";){const Ie=Me+ke;je==="fetch_bt"?w("Fetching BoldTrail contacts..."):je==="analyze"?(w("Analyzing contacts..."),C(15)):je==="push"?(w(`Pushing contacts to BoldTrail... (${Re}/${Me})`),C(Ie>0?Re/Ie*100:0)):je==="pull"&&(w(`Pulling contacts from BoldTrail... (${Ve}/${ke})`),C(Ie>0?(Me+Ve)/Ie*100:0));const{data:ye,error:ct}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:je,offset:qe,sync_log_id:ge,sync_direction:oe}});if(ct)throw ct;if(ye!=null&&ye.error)throw new Error(ye.error);const fe=ye;Re+=fe.chunk_pushed||0,Ve+=fe.chunk_pulled||0,fe.push_total!==void 0&&(Me=fe.push_total||0),fe.pull_total!==void 0&&(ke=fe.pull_total||0),fe.progress&&w(fe.progress),je==="pull"&&ke>0?C(Math.min(95,Ve/ke*100)):je==="push"&&Me>0&&C(Math.min(95,Re/Me*100)),je=fe.next_phase,qe=fe.next_offset}w("Finalizing sync..."),C(95);const{data:Ne,error:Ue}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:ge,sync_direction:oe}});if(Ue)throw Ue;return C(100),Ne},onSuccess:me=>{w(null),C(0),a(!1),t.invalidateQueries({queryKey:["boldtrail-status"]}),t.invalidateQueries({queryKey:["contacts"]}),t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),t.invalidateQueries({queryKey:["contacts-last-touch"]}),pe.success(`Sync complete! Pushed ${me.contacts_pushed||0}, pulled ${me.contacts_pulled||0}, skipped ${me.contacts_skipped||0} duplicates.`)},onError:me=>{w(null),C(0),pe.error(me.message||"Sync failed")}}),ie=V==null?void 0:V.connected,ae=(V==null?void 0:V.sync_direction)||"bidirectional",oe=_??ae;return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Dt,{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(td,{className:"h-5 w-5 text-emerald-600"})}),e.jsxs("div",{children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:["BoldTrail",ie&&e.jsx(Qe,{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(rp,{className:"h-3.5 w-3.5"}),"Learn More"]})]}),e.jsx(dr,{children:"Sync contacts bidirectionally between Agent OS and your BoldTrail (kvCORE) CRM."})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(si,{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(si,{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(si,{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"})]}),ie?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"}),(V==null?void 0:V.last_sync_at)&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last sync: ",new Date(V.last_sync_at).toLocaleString(),V.last_sync_status&&e.jsx(Qe,{variant:V.last_sync_status==="success"?"default":"secondary",className:"ml-2 text-[10px]",children:V.last_sync_status})]}),(V==null?void 0:V.boldtrail_contact_count)!=null&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[V.boldtrail_contact_count," contacts in BoldTrail"]}),(V==null?void 0:V.last_sync_message)&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:V.last_sync_message})]}),e.jsxs(Rl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(vr,{className:"h-4 w-4"})})}),e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Disconnect BoldTrail?"}),e.jsx(bl,{children:"This will remove your API token. Previously synced contacts will remain in both systems."})]}),e.jsxs(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:()=>U.mutate(),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]})}),e.jsxs("div",{className:"rounded-lg border p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(n0,{className:"h-4 w-4 mt-0.5 text-emerald-600 shrink-0"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Only sync contacts I own in BoldTrail"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"If your token has access to the whole brokerage's contacts, turn this on to sync just the contacts assigned to you."})]}),e.jsx(Ar,{checked:!!(V!=null&&V.sync_only_owned),onCheckedChange:me=>J.mutate({sync_only_owned:me}),disabled:J.isPending})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(xe,{className:"text-xs",children:"Your BoldTrail Agent ID"}),L?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{type:"number",placeholder:"e.g. 12345",value:A,onChange:me=>I(me.target.value),className:"h-8 text-sm"}),e.jsx(W,{size:"sm",onClick:()=>{const me=A.trim()===""?null:Number(A);J.mutate({kvcore_user_id:me})},disabled:J.isPending,children:"Save"}),e.jsx(W,{size:"sm",variant:"ghost",onClick:()=>O(!1),children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-sm font-mono",children:(V==null?void 0:V.kvcore_user_id)??e.jsx("span",{className:"text-muted-foreground",children:"Not set"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(W,{size:"sm",variant:"outline",onClick:()=>Y.mutate(),disabled:Y.isPending,children:[Y.isPending?e.jsx(Zi,{className:"h-3 w-3 mr-1 animate-spin"}):null,"Auto-detect"]}),e.jsx(W,{size:"sm",variant:"ghost",onClick:()=>{var me;I(((me=V==null?void 0:V.kvcore_user_id)==null?void 0:me.toString())??""),O(!0)},children:"Edit"})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Your numeric BoldTrail (kvCORE) user ID. To find it: log into BoldTrail → click your avatar (top right) → ",e.jsx("strong",{children:"My Profile"}),". The ID appears in the page URL after ",e.jsx("code",{children:"/users/"})," (e.g. ",e.jsxs("code",{children:[".../users/",e.jsx("strong",{children:"12345"})]}),"). You can also open any contact you own in BoldTrail and look at the URL — your ID is shown as the assigned agent. Auto-detect tries to find it via your API token first."]})]})]}),e.jsx("div",{className:"rounded-lg border p-3",children:e.jsx(Twe,{value:ae,onChange:me=>te.mutate(me)})}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(W,{onClick:()=>X.mutate(),disabled:X.isPending||ce.isPending,variant:"outline",className:"gap-2",children:[X.isPending?e.jsx(Zi,{className:"h-4 w-4 animate-spin"}):e.jsx(jn,{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(De,{type:"password",placeholder:"Paste your BoldTrail API token",value:s,onChange:me=>r(me.target.value),className:"flex-1"}),e.jsxs(W,{onClick:()=>B.mutate(s),disabled:!s||s.length<10||B.isPending,children:[B.isPending?e.jsx(Zi,{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:me=>{ce.isPending||a(me)},children:e.jsxs(ps,{className:"sm:max-w-lg",children:[e.jsxs(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(td,{className:"h-5 w-5 text-emerald-600"}),"Sync Preview"]}),e.jsx(Ir,{children:"Review what will happen when you sync your contacts."})]}),i&&(()=>{const me=oe==="pull_only"?0:i.to_push,ve=oe==="push_only"?0:i.to_pull;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Twe,{value:oe,onChange:b,size:"sm"}),i.owner_filter_active&&e.jsxs("div",{className:"rounded-md border border-emerald-200 bg-emerald-50 p-2 text-xs text-emerald-900 flex items-start gap-2",children:[e.jsx(n0,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),e.jsxs("span",{children:["Owner filter is on. Only contacts assigned to your BoldTrail account",i.kvcore_user_id?` (ID ${i.kvcore_user_id})`:""," will be synced.",i.boldtrail_total_brokerage!=null&&e.jsxs(e.Fragment,{children:[" Brokerage total: ",e.jsx("strong",{children:i.boldtrail_total_brokerage.toLocaleString()}),"."]})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:`rounded-lg border p-3 text-center ${oe==="pull_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-emerald-600",children:me}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(uu,{className:"h-3 w-3"})," Push to BoldTrail"]})]}),e.jsxs("div",{className:`rounded-lg border p-3 text-center ${oe==="push_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:ve}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Ih,{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(ir,{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"]}),ce.isPending&&e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx(xi,{value:S||10,className:"h-2"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:N||"Sync in progress..."})]}),me>0&&e.jsxs(lf,{open:u,onOpenChange:p,children:[e.jsx(cf,{asChild:!0,children:e.jsxs(W,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(uu,{className:"h-3 w-3 text-emerald-600"}),me," contacts to push to BoldTrail"]}),e.jsx(Bi,{className:`h-3 w-3 transition-transform ${u?"rotate-180":""}`})]})}),e.jsx(df,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[i.push_preview.map((he,ge)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:he.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:he.email})]},ge)),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"]})]})})]}),ve>0&&e.jsxs(lf,{open:f,onOpenChange:y,children:[e.jsx(cf,{asChild:!0,children:e.jsxs(W,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ih,{className:"h-3 w-3 text-blue-600"}),ve," contacts to pull from BoldTrail"]}),e.jsx(Bi,{className:`h-3 w-3 transition-transform ${f?"rotate-180":""}`})]})}),e.jsx(df,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[i.pull_preview.map((he,ge)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:he.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:he.email})]},ge)),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"]})]})})]}),me===0&&ve===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(W,{variant:"outline",onClick:()=>a(!1),disabled:ce.isPending,children:"Cancel"}),e.jsxs(W,{onClick:()=>ce.mutate(),disabled:ce.isPending||me===0&&ve===0,className:"gap-2",children:[ce.isPending?e.jsx(Zi,{className:"h-4 w-4 animate-spin"}):e.jsx(td,{className:"h-4 w-4"}),ce.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(ks,{className:"p-6 pb-0",children:e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(td,{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 Ult(){const t=wr(),[s,r]=k.useState(""),[n,a]=k.useState(""),[o,l]=k.useState("Test from ReLevelUp"),[i,d]=k.useState(!1),{data:u,isLoading:p}=gt({queryKey:["ses-config"],queryFn:async()=>{const{data:{session:_}}=await G.auth.getSession();if(!_)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 ${_.access_token}`},body:JSON.stringify({action:"check_config"})})).json()}}),f=async()=>{if(!s||!n){pe.error("Please fill in From and To email addresses");return}d(!0);try{const{data:{session:_}}=await G.auth.getSession();if(!_)throw new Error("Not authenticated");const N=await(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ses-send-campaign",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${_.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();N.success?pe.success(`Test email sent! Message ID: ${N.messageId}`):pe.error(N.error||"Failed to send test email")}catch(_){pe.error(_.message||"Failed to send test email")}finally{d(!1)}},y=(u==null?void 0:u.configured)===!0;return e.jsxs(Pe,{children:[e.jsx(Dt,{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(tr,{className:"h-5 w-5 text-orange-600"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:"Amazon SES — Mass Email"}),e.jsx(dr,{children:"Send bulk email campaigns via Amazon SES"})]})]}),e.jsx(Qe,{variant:y?"default":"secondary",children:p?"Checking...":y?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(si,{className:"h-3 w-3"})," Connected"]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ro,{className:"h-3 w-3"})," Not Configured"]})})]})}),y&&e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsx("h4",{className:"font-medium text-sm",children:"Send Test Email"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'Verify your SES setup by sending a test email. The "From" address must be verified in SES or belong to a verified domain.'}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(xe,{className:"text-xs",children:"From Email"}),e.jsx(De,{placeholder:"notifications@mail.relevelup.com",value:n,onChange:_=>a(_.target.value),className:"text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(xe,{className:"text-xs",children:"To Email"}),e.jsx(De,{placeholder:"your@email.com",value:s,onChange:_=>r(_.target.value),className:"text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(xe,{className:"text-xs",children:"Subject"}),e.jsx(De,{value:o,onChange:_=>l(_.target.value),className:"text-sm"})]})]}),e.jsxs(W,{onClick:f,disabled:i,size:"sm",children:[i?e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(_n,{className:"h-4 w-4 mr-2"}),"Send Test"]})]}),e.jsxs(W,{onClick:()=>t("/admin/email-campaigns"),className:"w-full",children:[e.jsx(uh,{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)"]})]})]}),!y&&!p&&e.jsx(Oe,{children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["AWS SES credentials are not configured. Add ",e.jsx("code",{children:"AWS_SES_ACCESS_KEY_ID"}),", ",e.jsx("code",{children:"AWS_SES_SECRET_ACCESS_KEY"}),", and ",e.jsx("code",{children:"AWS_SES_REGION"})," as secrets to enable."]})})]})}async function j0e(t){const{data:{session:s}}=await G.auth.getSession();if(!s)throw new Error("Not authenticated");const r=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ses-verify-sender",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s.access_token}`},body:JSON.stringify(t)}),n=await r.json();if(!r.ok)throw new Error(n.error||"Request failed");return n}function x4s({status:t}){return t==="verified"?e.jsxs(Qe,{className:"bg-green-500/10 text-green-700 hover:bg-green-500/20 border-green-500/20",children:[e.jsx($n,{className:"h-3 w-3 mr-1"})," Verified"]}):t==="pending"?e.jsxs(Qe,{variant:"secondary",children:[e.jsx(nn,{className:"h-3 w-3 mr-1"})," Pending — check inbox"]}):t==="failed"||t==="temporary_failure"?e.jsxs(Qe,{variant:"destructive",children:[e.jsx(ro,{className:"h-3 w-3 mr-1"})," Failed"]}):e.jsxs(Qe,{variant:"outline",children:[e.jsx(ro,{className:"h-3 w-3 mr-1"})," Not started"]})}function Vlt({brokerageId:t,onVerifiedSelect:s}){const r=Qt(),[n,a]=k.useState(""),[o,l]=k.useState(""),[i,d]=k.useState(!1),[u,p]=k.useState(null),[f,y]=k.useState(null),{data:_,isLoading:b}=gt({queryKey:["brokerage-verified-senders",t],queryFn:async()=>{const{data:C,error:A}=await G.from("brokerage_verified_senders").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(A)throw A;return C||[]}}),N=Pt({mutationFn:async()=>j0e({action:"request_verification",brokerage_id:t,email:n,display_name:o||void 0}),onSuccess:()=>{r.invalidateQueries({queryKey:["brokerage-verified-senders",t]}),pe.success("Verification email sent",{description:`Check ${n} and click the AWS verification link.`}),a(""),l(""),d(!1)},onError:C=>pe.error(C.message)}),w=async C=>{var A,I;p(C.id);try{const L=await j0e({action:"check_status",sender_id:C.id});r.invalidateQueries({queryKey:["brokerage-verified-senders",t]}),((A=L.sender)==null?void 0:A.status)==="verified"?pe.success(`${C.email} is verified! 🎉`):pe.info(`Status: ${((I=L.sender)==null?void 0:I.status)||"unknown"}`)}catch(L){pe.error(L.message)}finally{p(null)}},S=Pt({mutationFn:async C=>j0e({action:"delete",sender_id:C}),onSuccess:()=>{r.invalidateQueries({queryKey:["brokerage-verified-senders",t]}),pe.success("Sender removed"),y(null)},onError:C=>pe.error(C.message)});return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-1",children:"Verified Sender Addresses"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Verify any email address (yours or your brokerage's) so recruiting emails can be sent from that address. Anyone managing this brokerage can use these senders."})]}),b?e.jsx("div",{className:"text-xs text-muted-foreground py-3",children:"Loading…"}):_&&_.length>0?e.jsx("div",{className:"space-y-2",children:_.map(C=>e.jsxs("div",{className:"flex items-center justify-between gap-3 p-3 rounded-lg border bg-card",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:"h-9 w-9 rounded-full bg-muted flex items-center justify-center shrink-0",children:e.jsx(tr,{className:"h-4 w-4 text-muted-foreground"})}),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:"text-sm font-medium truncate",children:C.email}),e.jsx(x4s,{status:C.status})]}),C.display_name&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:['"',C.display_name,'"']})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[C.status==="verified"&&s&&e.jsx(W,{size:"sm",variant:"outline",onClick:()=>s(C.email),children:"Use"}),C.status!=="verified"&&e.jsx(W,{size:"sm",variant:"ghost",onClick:()=>w(C),disabled:u===C.id,title:"Refresh status from AWS",children:u===C.id?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(Zi,{className:"h-4 w-4"})}),e.jsx(W,{size:"sm",variant:"ghost",onClick:()=>y(C),className:"text-destructive hover:text-destructive",children:e.jsx(vr,{className:"h-4 w-4"})})]})]},C.id))}):e.jsx("div",{className:"text-xs text-muted-foreground py-2 italic",children:"No verified senders yet. Add one below."}),i?e.jsxs("div",{className:"rounded-lg border p-4 space-y-3 bg-muted/30",children:[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(xe,{className:"text-xs",children:"Email Address *"}),e.jsx(De,{type:"email",value:n,onChange:C=>a(C.target.value),placeholder:"broker@yourbrokerage.com",className:"text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(xe,{className:"text-xs",children:"Display Name (optional)"}),e.jsx(De,{value:o,onChange:C=>l(C.target.value),placeholder:"John at Acme Realty",className:"text-sm"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"We'll ask AWS to send a verification email to this address. The owner must click the link before this sender can be used."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(W,{size:"sm",onClick:()=>N.mutate(),disabled:!n.trim()||N.isPending,children:[N.isPending?e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Send Verification Email"]}),e.jsx(W,{size:"sm",variant:"ghost",onClick:()=>{d(!1),a(""),l("")},children:"Cancel"})]})]}):e.jsxs(W,{size:"sm",variant:"outline",onClick:()=>d(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Add Sender Address"]}),e.jsx(Rl,{open:!!f,onOpenChange:C=>!C&&y(null),children:e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Remove this sender?"}),e.jsxs(bl,{children:['"',f==null?void 0:f.email,`" will be removed from your verified senders and from Amazon SES. You'd need to verify it again to use it.`]})]}),e.jsxs(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:()=>f&&S.mutate(f.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})})]})}function g4s(){var I,L,O,V,q;const{user:t,isBrokerageManager:s,isAdmin:r,managedBrokerages:n,selectedBrokerageId:a}=Us(),o=a||((I=n==null?void 0:n[0])==null?void 0:I.id)||null,l=(s||r)&&!!o,i=Qt(),[d,u]=k.useState(!1),[p,f]=k.useState(""),[y,_]=k.useState(""),{data:b}=gt({queryKey:["mass-email-settings",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:B,error:U}=await G.from("mass_email_settings").select("*").eq("user_id",t.id).maybeSingle();if(U)throw U;return B}}),{data:N}=gt({queryKey:["agent-profile-email",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:B,error:U}=await G.from("profiles").select("email, name").eq("id",t.id).single();if(U)throw U;return B}}),w=((L=b==null?void 0:b.reply_to_email)==null?void 0:L.trim())||((O=N==null?void 0:N.email)==null?void 0:O.trim())||"",S=((V=b==null?void 0:b.display_name)==null?void 0:V.trim())||((q=N==null?void 0:N.name)==null?void 0:q.trim())||"";k.useEffect(()=>{d||(f(w),_(S))},[d,w,S]);const C=Pt({mutationFn:async()=>{if(!t||!p.trim())throw new Error("Please enter a reply-to email");const B={reply_to_email:p.trim(),display_name:y.trim()||null,updated_at:new Date().toISOString()};if(b){const{error:U}=await G.from("mass_email_settings").update(B).eq("user_id",t.id);if(U)throw U}else{const{error:U}=await G.from("mass_email_settings").insert({user_id:t.id,...B});if(U)throw U}},onSuccess:()=>{i.invalidateQueries({queryKey:["mass-email-settings",t==null?void 0:t.id]}),i.invalidateQueries({queryKey:["mass-email-ready",t==null?void 0:t.id]}),i.invalidateQueries({queryKey:["mass-email-settings-check",t==null?void 0:t.id]}),pe.success("Reply-to email saved!"),u(!1)},onError:B=>pe.error(B.message)}),A=!!w;return e.jsxs(Pe,{children:[e.jsx(Dt,{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(_n,{className:"h-5 w-5 text-orange-600"})}),e.jsxs("div",{children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:["Mass Email",A?e.jsxs(Qe,{variant:"default",className:"text-xs bg-green-600",children:[e.jsx(si,{className:"h-3 w-3 mr-1"})," Set Up"]}):e.jsx(Qe,{variant:"secondary",className:"text-xs",children:"Setup Required"})]}),e.jsx(dr,{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.jsxs(Oe,{className:"space-y-3",children:[A&&!d?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:S||"No display name"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:w})]}),e.jsxs(W,{variant:"ghost",size:"sm",onClick:()=>u(!0),children:[e.jsx(ga,{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(xe,{className:"text-xs",children:"Display Name"}),e.jsx(De,{placeholder:"e.g. 🏡 Karen Hall",value:y,onChange:B=>_(B.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(xe,{className:"text-xs",children:"Reply-To Email *"}),e.jsx(De,{type:"email",placeholder:"your@email.com",value:p,onChange:B=>f(B.target.value)})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(W,{size:"sm",onClick:()=>C.mutate(),disabled:C.isPending||!p.trim(),children:[e.jsx(bc,{className:"h-4 w-4 mr-1"})," Save"]}),d&&e.jsxs(W,{size:"sm",variant:"outline",onClick:()=>{u(!1),f(w),_(S)},children:[e.jsx(kr,{className:"h-4 w-4 mr-1"})," Cancel"]})]})]}),l&&e.jsxs(e.Fragment,{children:[e.jsx(ho,{className:"my-2"}),e.jsxs("div",{className:"rounded-lg border bg-muted/30 p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"h-8 w-8 rounded-md bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(t1,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold",children:"Verified Sender Addresses"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Before you can send mass emails ",e.jsx("em",{children:"from"})," an address, AWS requires that address to be verified. Add the email you want to send from below and click the verification link AWS sends to that inbox."]})]})]}),e.jsx(Vlt,{brokerageId:o})]})]})]})]})}function y4s(){const{isAdmin:t}=Us(),s=Qt(),[r,n]=k.useState(!1),[a,o]=k.useState(!1),[l,i]=k.useState(!1),{data:d,isLoading:u}=gt({queryKey:["gmail-integration"],queryFn:async()=>{const{data:I,error:L}=await G.from("gmail_integrations").select("*").maybeSingle();if(L)throw L;return I}}),{data:p}=gt({queryKey:["social-accounts"],queryFn:async()=>{const{data:{user:I}}=await G.auth.getUser();if(!I)return[];const{data:L,error:O}=await G.from("social_accounts").select("*").eq("user_id",I.id).order("created_at",{ascending:!1});if(O)throw O;return L}}),f=async()=>{n(!0);try{const{data:I,error:L}=await G.functions.invoke("gmail-oauth",{body:{action:"get_auth_url"}});if(L)throw L;if(I!=null&&I.authUrl)window.location.href=I.authUrl;else throw new Error("Failed to get authorization URL")}catch(I){console.error("Gmail OAuth error:",I),pe.error("Failed to start Gmail connection"),n(!1)}},y=async()=>{o(!0);try{const{data:I,error:L}=await G.functions.invoke("meta-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/callback"}});if(L)throw L;if(I!=null&&I.authUrl)window.location.href=I.authUrl;else throw new Error("Failed to get authorization URL")}catch(I){console.error("Meta OAuth error:",I),pe.error("Failed to start connection. Make sure Meta App credentials are configured."),o(!1)}},_=async()=>{i(!0);try{const{data:I,error:L}=await G.functions.invoke("linkedin-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/linkedin-callback"}});if(L)throw L;if(I!=null&&I.authUrl)window.location.href=I.authUrl;else throw new Error("Failed to get LinkedIn authorization URL")}catch(I){console.error("LinkedIn OAuth error:",I),pe.error("Failed to start LinkedIn connection. Please try again."),i(!1)}},b=Pt({mutationFn:async I=>{const{error:L}=await G.from("gmail_integrations").delete().eq("id",I);if(L)throw L},onSuccess:()=>{s.invalidateQueries({queryKey:["gmail-integration"]}),pe.success("Gmail disconnected")},onError:()=>{pe.error("Failed to disconnect Gmail")}}),N=Pt({mutationFn:async I=>{const{error:L}=await G.from("social_accounts").delete().eq("id",I);if(L)throw L},onSuccess:()=>{s.invalidateQueries({queryKey:["social-accounts"]}),pe.success("Account disconnected")},onError:()=>{pe.error("Failed to disconnect account")}}),w=!!(d!=null&&d.is_active),S=(p==null?void 0:p.filter(I=>I.platform==="facebook"))||[],C=(p==null?void 0:p.filter(I=>I.platform==="instagram"))||[],A=(p==null?void 0:p.filter(I=>I.platform==="linkedin"))||[];return e.jsx(Ds,{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(Dt,{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(tr,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:["Gmail",w&&e.jsx(Qe,{variant:"default",className:"text-xs bg-green-600",children:"Connected"})]}),e.jsx(dr,{children:"Send emails directly from your contact pages and auto-log them as touchpoints."})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(si,{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(si,{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(si,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Quick compose from any contact detail page"})]}),w?e.jsxs("div",{className:"flex items-center justify-between mt-4 p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:d.gmail_email}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Gmail account"})]}),e.jsxs(Rl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(vr,{className:"h-4 w-4"})})}),e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Disconnect Gmail?"}),e.jsx(bl,{children:"This will remove your Gmail connection. You'll need to reconnect to send emails."})]}),e.jsxs(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:()=>b.mutate(d.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]}):e.jsxs(W,{className:"mt-4",onClick:f,disabled:r||u,children:[r?e.jsx(Zi,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Connect Gmail",e.jsx(Wa,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsxs(Pe,{className:t?"":"opacity-70",children:[e.jsx(Dt,{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(hu,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:["Facebook",t?S.length>0?e.jsx(Qe,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(Qe,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(ad,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(dr,{children:"Connect Facebook Pages to post content and reach your audience."})]})]})}),t&&e.jsxs(Oe,{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(Nn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:I.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(hu,{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(Rl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(vr,{className:"h-4 w-4"})})}),e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Disconnect Facebook?"}),e.jsx(bl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:()=>N.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}),e.jsxs(W,{onClick:y,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(Zi,{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(Dt,{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(zt,{className:"text-lg flex items-center gap-2",children:["Instagram",t?C.length>0?e.jsx(Qe,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(Qe,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(ad,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(dr,{children:"Connect Instagram Business accounts to schedule and publish posts."})]})]})}),t&&e.jsxs(Oe,{className:"space-y-3",children:[C.length>0&&e.jsx("div",{className:"space-y-2",children:C.map(I=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:I.profile_picture_url||""}),e.jsx(kn,{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(Rl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(vr,{className:"h-4 w-4"})})}),e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Disconnect Instagram?"}),e.jsx(bl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:()=>N.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}),e.jsxs(W,{onClick:y,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(Zi,{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(Dt,{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(gp,{className:"h-5 w-5 text-blue-700"})}),e.jsxs("div",{children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:["LinkedIn",t?A.length>0?e.jsx(Qe,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(Qe,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(ad,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(dr,{children:"Connect your LinkedIn profile to share content and grow your professional network."})]})]})}),t&&e.jsxs(Oe,{className:"space-y-3",children:[A.length>0&&e.jsx("div",{className:"space-y-2",children:A.map(I=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Nn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:I.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(gp,{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(Rl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(vr,{className:"h-4 w-4"})})}),e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Disconnect LinkedIn?"}),e.jsx(bl,{children:"This will remove your LinkedIn connection. You'll need to reconnect to post content."})]}),e.jsxs(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:()=>N.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}),e.jsxs(W,{onClick:_,disabled:l,variant:"outline",className:"gap-2",children:[l?e.jsx(Zi,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{className:"h-4 w-4"}),"Connect LinkedIn"]})]})]}),e.jsx(f4s,{}),e.jsx(g4s,{}),t&&e.jsx(Ult,{})]})})}function v4s(){const[t]=Nc(),s=wr(),[r,n]=k.useState("loading"),[a,o]=k.useState("Connecting your Gmail account...");return k.useEffect(()=>{(async()=>{const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),p=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),pe.error("Connection failed: "+(u||d));return}if(!i){n("error"),o("No authorization code received"),pe.error("No authorization code received");return}try{const{data:f,error:y}=await G.functions.invoke("gmail-oauth",{body:{action:"exchange_code",code:i,state:p}});if(y)throw y;if(f!=null&&f.success)n("success"),o(f.message||"Gmail connected successfully!"),pe.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"),pe.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(Dt,{className:"text-center",children:[r==="loading"&&e.jsx(us,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(si,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(Jl,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(zt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(dr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(W,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"Back to Integrations":"Try Again"})})]})})}function _4s(){const t=wr();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 b4s(){const[t]=Nc(),s=wr(),[r,n]=k.useState("loading"),[a,o]=k.useState("Processing your connection...");return k.useEffect(()=>{(async()=>{var f;const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),p=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),pe.error("Connection failed: "+(u||d));return}if(!i){n("error"),o("No authorization code received"),pe.error("No authorization code received");return}try{const{data:y,error:_}=await G.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p,callbackPath:"/mission-control/integrations/meta/callback"}});if(_)throw _;if(y!=null&&y.success)n("success"),o(`Successfully connected ${((f=y.accounts)==null?void 0:f.length)||0} account(s)!`),pe.success("Social accounts connected successfully!");else throw new Error((y==null?void 0:y.error)||"Unknown error")}catch(y){console.error("OAuth callback error:",y),n("error"),o(y instanceof Error?y.message:"Failed to connect accounts"),pe.error("Failed to connect: "+(y instanceof Error?y.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(Dt,{className:"text-center",children:[r==="loading"&&e.jsx(us,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(si,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(Jl,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(zt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(dr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(W,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Integrations":"Try Again"})})]})})}const Hlt=new Date().getFullYear(),w4s=Array.from({length:5},(t,s)=>Hlt-s);function j4s(){const[t,s]=k.useState(Hlt),r=wr(),{data:n,isLoading:a}=b8t();return a?e.jsx(Ds,{title:"Scorecard Admin",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ms,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(o=>e.jsx(Ms,{className:"h-24"},o))}),e.jsx(Ms,{className:"h-96"})]})}):e.jsx(Ds,{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($s,{value:String(t),onValueChange:o=>s(Number(o)),children:[e.jsx(zs,{className:"w-[120px]",children:e.jsx(Vs,{})}),e.jsx(Bs,{children:w4s.map(o=>e.jsx(vt,{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(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ir,{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(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(so,{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(Dt,{children:[e.jsx(zt,{children:"Agents with Scorecards"}),e.jsx(dr,{children:"Click to view individual agent scorecards"})]}),e.jsx(Oe,{children:!n||n.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(so,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents have added transactions yet"})]}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Agent"}),e.jsx(St,{children:"Email"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:n.map(o=>e.jsxs(Ps,{children:[e.jsx(ht,{className:"font-medium",children:o.name}),e.jsx(ht,{className:"text-muted-foreground",children:o.email}),e.jsx(ht,{className:"text-right",children:e.jsxs(W,{variant:"ghost",size:"sm",onClick:()=>r(`/admin/scorecard/${o.id}`),children:[e.jsx(jn,{className:"h-4 w-4 mr-2"}),"View Scorecard"]})})]},o.id))})]})})]})]})})}const Glt=new Date().getFullYear(),N4s=Array.from({length:10},(t,s)=>Glt-s);function h9e(){var N;const{userId:t}=io(),s=wr(),n=$l().pathname.startsWith("/mission-control"),[a,o]=k.useState(Glt),{data:l,isLoading:i}=gt({queryKey:["agent-profile",t],queryFn:async()=>{const{data:w,error:S}=await G.from("profiles").select("id, name, email").eq("id",t).single();if(S)throw S;return w},enabled:!!t}),{data:d,isLoading:u}=cke(a,t),{yearStats:p,lifetimeStats:f,isLoading:y,showCommission:_}=zXe(a,t),{data:b}=FXe(a,t);return i?e.jsx(Ds,{title:"Agent Scorecard",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ms,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(w=>e.jsx(Ms,{className:"h-24"},w))})]})}):e.jsx(Ds,{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(W,{variant:"ghost",size:"icon",onClick:()=>s(n?"/mission-control/scorecard":"/admin/scorecard"),children:e.jsx(Oa,{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($s,{value:String(a),onValueChange:w=>o(Number(w)),children:[e.jsx(zs,{className:"w-[120px]",children:e.jsx(Vs,{})}),e.jsx(Bs,{children:N4s.map(w=>e.jsx(vt,{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(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Mn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:p.totalTransactions}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[f.totalTransactions," lifetime"]})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ir,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Buyer/Seller"})]}),e.jsxs("p",{className:"text-2xl font-bold",children:[p.buyerCount,"/",p.sellerCount]})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(_c,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Il(p.totalVolume,!0)})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Qo,{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:Il(p.averagePrice,!0)})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(nc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((N=p.topLeadSource)==null?void 0:N.name)||"-"})]})})]}),b&&e.jsx(cit,{goals:b,stats:p,year:a,showCommission:_}),e.jsxs(ta,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(Jn,{children:[e.jsx(cs,{value:"transactions",children:"Transactions"}),e.jsx(cs,{value:"charts",children:"Charts"}),e.jsxs(cs,{value:"map",children:[e.jsx(Ia,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(Ss,{value:"transactions",children:e.jsx($Se,{transactions:d||[],showCommission:_,isLoading:u})}),e.jsx(Ss,{value:"charts",children:e.jsx(qSe,{stats:p,year:a})}),e.jsx(Ss,{value:"map",children:e.jsx(USe,{transactions:d||[],isLoading:u})})]})]})})}function k4s(){const t=Qt(),[s,r]=k.useState(""),[n,a]=k.useState("all");eYe();const{data:o,refetch:l}=gt({queryKey:["listing-exchange-flag"],queryFn:async()=>{const{data:I}=await G.from("feature_flags").select("enabled").eq("key","listing_exchange_enabled").single();return(I==null?void 0:I.enabled)??!1}}),{data:i,isLoading:d}=gt({queryKey:["admin-listings"],queryFn:async()=>{const{data:I,error:L}=await G.from("listings").select(` *, agent:profiles!listings_agent_id_fkey(id, name, email), photos:listing_photos(id, photo_url, is_primary) `).order("created_at",{ascending:!1});if(L)throw L;return I}}),{data:u}=gt({queryKey:["admin-listing-stats"],queryFn:async()=>{const{data:I}=await G.from("listings").select("id, is_approved, status"),{data:L}=await G.from("listing_shares").select("id"),{data:O}=await G.from("listing_views").select("id");return{total:(I==null?void 0:I.length)||0,pending:(I==null?void 0:I.filter(V=>!V.is_approved).length)||0,active:(I==null?void 0:I.filter(V=>V.status==="active").length)||0,totalShares:(L==null?void 0:L.length)||0,totalViews:(O==null?void 0:O.length)||0}}}),p=async(I,L,O="submit_url")=>{try{const{data:{session:V}}=await G.auth.getSession();if(!V)return;const{data:q,error:B}=await G.functions.invoke("google-indexing",{body:{action:O,listing_id:I,listing_slug:L}});if(B)throw B;if((q==null?void 0:q.configured)===!1)return;q!=null&&q.success&&pe.success("Submitted to Google for indexing")}catch(V){console.error("Google indexing submission failed:",V)}},f=Pt({mutationFn:async()=>{const{data:{session:I}}=await G.auth.getSession();if(!I)throw new Error("Not authenticated");const{data:L,error:O}=await G.functions.invoke("google-indexing",{body:{action:"submit_all"}});if(O)throw O;return L},onSuccess:I=>{if((I==null?void 0:I.configured)===!1){pe.error("Google Indexing API not configured. Add the GOOGLE_INDEXING_SERVICE_ACCOUNT secret.");return}pe.success(`Submitted ${(I==null?void 0:I.succeeded)||0} URLs to Google (${(I==null?void 0:I.failed)||0} failed)`)},onError:I=>{pe.error("Failed to submit to Google"),console.error(I)}}),y=Pt({mutationFn:async({id:I,approved:L,slug:O})=>{const{error:V}=await G.from("listings").update({is_approved:L}).eq("id",I);if(V)throw V;return{id:I,approved:L,slug:O}},onSuccess:I=>{t.invalidateQueries({queryKey:["admin-listings"]}),t.invalidateQueries({queryKey:["admin-listing-stats"]}),pe.success(I.approved?"Listing approved":"Listing unapproved"),I.approved?p(I.id,I.slug||null,"submit_url"):p(I.id,I.slug||null,"remove_url")}}),_=Pt({mutationFn:async({id:I,featured:L})=>{const{error:O}=await G.from("listings").update({is_featured:L}).eq("id",I);if(O)throw O},onSuccess:(I,{featured:L})=>{t.invalidateQueries({queryKey:["admin-listings"]}),pe.success(L?"Listing featured":"Listing unfeatured")}}),b=Pt({mutationFn:async I=>{const{error:L}=await G.from("listings").delete().eq("id",I);if(L)throw L},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-listings"]}),t.invalidateQueries({queryKey:["admin-listing-stats"]}),pe.success("Listing deleted")}}),N=Pt({mutationFn:async I=>{const{error:L}=await G.from("feature_flags").update({enabled:I}).eq("key","listing_exchange_enabled");if(L)throw L},onSuccess:()=>{l(),pe.success("Feature flag updated")}}),w=o??!1,S=i==null?void 0:i.filter(I=>{var V,q,B,U;const L=((V=I.city)==null?void 0:V.toLowerCase().includes(s.toLowerCase()))||((B=(q=I.agent)==null?void 0:q.name)==null?void 0:B.toLowerCase().includes(s.toLowerCase()))||((U=I.property_address)==null?void 0:U.toLowerCase().includes(s.toLowerCase())),O=n==="all"||n==="pending"&&!I.is_approved||n==="approved"&&I.is_approved;return L&&O}),C=I=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(I),A=I=>{const L={active:"bg-green-500/10 text-green-600 border-green-200",coming_soon:"bg-blue-500/10 text-blue-600 border-blue-200",price_improvement:"bg-amber-500/10 text-amber-600 border-amber-200",under_contract:"bg-purple-500/10 text-purple-600 border-purple-200",sold:"bg-gray-500/10 text-gray-600 border-gray-200"};return L[I]||L.active};return e.jsx(Ds,{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(W,{variant:"outline",size:"sm",onClick:()=>f.mutate(),disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(us,{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(Ar,{checked:w,onCheckedChange:I=>N.mutate(I)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pa,{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(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Qo,{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(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ir,{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(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(jn,{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(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(id,{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(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by city, address, or agent...",value:s,onChange:I=>r(I.target.value),className:"pl-9"})]}),e.jsx(ta,{value:n,onValueChange:I=>a(I),children:e.jsxs(Jn,{children:[e.jsx(cs,{value:"all",children:"All"}),e.jsx(cs,{value:"pending",children:"Pending"}),e.jsx(cs,{value:"approved",children:"Approved"})]})})]})})}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{children:["Listings (",(S==null?void 0:S.length)||0,")"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Property"}),e.jsx(St,{children:"Agent"}),e.jsx(St,{children:"Price"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-center",children:"Approved"}),e.jsx(St,{className:"text-center",children:"Featured"}),e.jsx(St,{children:"Views"}),e.jsx(St,{children:"Shares"}),e.jsx(St,{children:"Date"}),e.jsx(St,{})]})}),e.jsx(Rn,{children:d?e.jsx(Ps,{children:e.jsx(ht,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):(S==null?void 0:S.length)===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No listings found"})}):S==null?void 0:S.map(I=>{var L,O,V,q,B;return e.jsxs(Ps,{children:[e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[(O=(L=I.photos)==null?void 0:L[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(pa,{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:(V=I.property_type)==null?void 0:V.replace("_"," ")})]})]})}),e.jsx(ht,{children:e.jsx("p",{className:"text-sm",children:((q=I.agent)==null?void 0:q.name)||"Unknown"})}),e.jsx(ht,{className:"font-medium",children:C(I.price)}),e.jsx(ht,{children:e.jsx(Qe,{variant:"outline",className:A(I.status),children:(B=I.status)==null?void 0:B.replace("_"," ")})}),e.jsx(ht,{className:"text-center",children:e.jsx(Ar,{checked:I.is_approved??!1,onCheckedChange:U=>y.mutate({id:I.id,approved:U,slug:I.slug})})}),e.jsx(ht,{className:"text-center",children:e.jsx(Ar,{checked:I.is_featured??!1,onCheckedChange:U=>_.mutate({id:I.id,featured:U})})}),e.jsx(ht,{children:I.view_count||0}),e.jsx(ht,{children:I.share_count||0}),e.jsx(ht,{className:"text-sm text-muted-foreground",children:vs(new Date(I.created_at),"MMM d, yyyy")}),e.jsx(ht,{children:e.jsxs(Hd,{children:[e.jsx(Gd,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",children:e.jsx(Zp,{className:"h-4 w-4"})})}),e.jsxs(Nd,{align:"end",children:[e.jsxs(_a,{onClick:()=>window.open(`/mission-control/listings/${I.id}`,"_blank"),children:[e.jsx(jn,{className:"h-4 w-4 mr-2"}),"View Listing"]}),e.jsxs(_a,{onClick:()=>_.mutate({id:I.id,featured:!I.is_featured}),children:[e.jsx(Gn,{className:"h-4 w-4 mr-2"}),I.is_featured?"Unfeature":"Feature"]}),e.jsxs(_a,{className:"text-destructive",onClick:()=>{confirm("Are you sure you want to delete this listing?")&&b.mutate(I.id)},children:[e.jsx(kr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},I.id)})})]})})})]})]})})}const S4s=()=>{var f,y;const[t,s]=k.useState(""),[r,n]=k.useState(null),{data:a,isLoading:o}=gt({queryKey:["membership-reviews"],queryFn:async()=>{const{data:_,error:b}=await G.from("membership_reviews").select("*").order("created_at",{ascending:!1});if(b)throw b;const N=(_==null?void 0:_.map(C=>C.user_id))||[],{data:w}=await G.from("profiles").select("id, name, email").in("id",N);return _==null?void 0:_.map(C=>({...C,profiles:(w==null?void 0:w.find(A=>A.id===C.user_id))||null}))}}),l=a==null?void 0:a.filter(_=>{var N,w,S,C,A;const b=t.toLowerCase();return((w=(N=_.profiles)==null?void 0:N.name)==null?void 0:w.toLowerCase().includes(b))||((C=(S=_.profiles)==null?void 0:S.email)==null?void 0:C.toLowerCase().includes(b))||((A=_.review_text)==null?void 0:A.toLowerCase().includes(b))}),i=a!=null&&a.length?(a.reduce((_,b)=>_+b.rating,0)/a.length).toFixed(1):"0.0",d=a==null?void 0:a.reduce((_,b)=>(_[b.rating]=(_[b.rating]||0)+1,_),{}),u=(a==null?void 0:a.filter(_=>_.posted_to_google).length)||0,p=_=>e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(b=>e.jsx(Gn,{className:Ot("h-4 w-4",_>=b?"fill-yellow-400 text-yellow-400":"text-muted-foreground")},b))});return e.jsx(Ds,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Hu,{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(Dt,{className:"pb-2",children:[e.jsx(dr,{children:"Total Reviews"}),e.jsx(zt,{className:"text-3xl",children:(a==null?void 0:a.length)||0})]})}),e.jsx(Pe,{children:e.jsxs(Dt,{className:"pb-2",children:[e.jsx(dr,{children:"Average Rating"}),e.jsxs(zt,{className:"flex items-center gap-2 text-3xl",children:[i,e.jsx(Gn,{className:"h-6 w-6 fill-yellow-400 text-yellow-400"})]})]})}),e.jsx(Pe,{children:e.jsxs(Dt,{className:"pb-2",children:[e.jsx(dr,{children:"5-Star Reviews"}),e.jsx(zt,{className:"text-3xl",children:(d==null?void 0:d[5])||0})]})}),e.jsx(Pe,{children:e.jsxs(Dt,{className:"pb-2",children:[e.jsx(dr,{children:"Posted to Google"}),e.jsxs(zt,{className:"flex items-center gap-2 text-3xl",children:[u,e.jsx(Yr,{className:"h-5 w-5 text-muted-foreground"})]})]})})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name, email, or review...",value:t,onChange:_=>s(_.target.value),className:"pl-9"})]}),e.jsx(Pe,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Member"}),e.jsx(St,{children:"Rating"}),e.jsx(St,{className:"hidden md:table-cell",children:"Review"}),e.jsx(St,{children:"Google"}),e.jsx(St,{children:"Date"})]})}),e.jsx(Rn,{children:o?e.jsx(Ps,{children:e.jsx(ht,{colSpan:5,className:"text-center py-8",children:"Loading reviews..."})}):(l==null?void 0:l.length)===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No reviews found"})}):l==null?void 0:l.map(_=>{var b,N;return e.jsxs(Ps,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>n(_),children:[e.jsx(ht,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:((b=_.profiles)==null?void 0:b.name)||"Unknown"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:(N=_.profiles)==null?void 0:N.email})]})}),e.jsx(ht,{children:p(_.rating)}),e.jsx(ht,{className:"hidden md:table-cell max-w-xs",children:e.jsx("p",{className:"truncate text-sm text-muted-foreground",children:_.review_text||"-"})}),e.jsx(ht,{children:_.posted_to_google?e.jsx(Qe,{variant:"secondary",className:"bg-green-100 text-green-800",children:"Posted"}):e.jsx(Qe,{variant:"outline",children:"No"})}),e.jsx(ht,{className:"text-sm text-muted-foreground",children:vs(new Date(_.created_at),"MMM d, yyyy")})]},_.id)})})]})})}),e.jsx(fs,{open:!!r,onOpenChange:()=>n(null),children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsx(ks,{children:e.jsx(_s,{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"}),((y=r.profiles)==null?void 0:y.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(tr,{className:"h-3 w-3"}),r.profiles.email]})]}),e.jsxs("div",{className:"text-right",children:[p(r.rating),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[r.rating," out of 5 stars"]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"Review"}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:r.review_text||"No written review provided."})]}),e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(cn,{className:"h-4 w-4"}),vs(new Date(r.created_at),"MMMM d, yyyy 'at' h:mm a")]}),r.posted_to_google?e.jsxs(Qe,{variant:"secondary",className:"bg-green-100 text-green-800",children:[e.jsx(Yr,{className:"h-3 w-3 mr-1"}),"Posted to Google"]}):e.jsx(Qe,{variant:"outline",children:"Not posted to Google"})]})]})]})})]})})},C4s=[{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"}],M4s=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 T4s(){const t=Qt(),{user:s}=Us(),[r,n]=k.useState(!1),[a,o]=k.useState(!1),[l,i]=k.useState(!1),{data:d,isLoading:u}=gt({queryKey:["weekly-digest-settings"],queryFn:async()=>{const{data:q,error:B}=await G.from("weekly_digest_settings").select("*").single();if(B)throw B;return q}}),{data:p,isLoading:f}=gt({queryKey:["weekly-digest-logs"],queryFn:async()=>{const{data:q,error:B}=await G.from("weekly_digest_logs").select("*").order("sent_at",{ascending:!1}).limit(100);if(B)throw B;return q}}),{data:y}=gt({queryKey:["digest-subscriber-count"],queryFn:async()=>{const{count:q,error:B}=await G.from("profiles").select("id",{count:"exact",head:!0}).eq("digest_opt_out",!1).not("email","is",null);if(B)throw B;return q||0}}),{data:_,refetch:b}=gt({queryKey:["digest-queue-status"],queryFn:async()=>{const q=new Date;q.setUTCHours(0,0,0,0);const[B,U,te,Y]=await Promise.all([G.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","pending").gte("created_at",q.toISOString()),G.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","processing").gte("created_at",q.toISOString()),G.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","sent").gte("created_at",q.toISOString()),G.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","failed").gte("created_at",q.toISOString())]);return{pending:B.count||0,processing:U.count||0,sent:te.count||0,failed:Y.count||0,total:(B.count||0)+(U.count||0)+(te.count||0)+(Y.count||0)}},refetchInterval:5e3});k.useEffect(()=>{if(_&&(_.pending>0||_.processing>0)){const q=setInterval(()=>{b(),t.invalidateQueries({queryKey:["weekly-digest-logs"]}),t.invalidateQueries({queryKey:["digest-today-failed-count"]}),t.invalidateQueries({queryKey:["digest-today-missing-count"]})},5e3);return()=>clearInterval(q)}},[_,b,t]);const{data:N=0}=gt({queryKey:["digest-today-failed-count"],queryFn:async()=>{const q=new Date;q.setUTCHours(0,0,0,0);const{count:B,error:U}=await G.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","failed").gte("sent_at",q.toISOString());if(U)throw U;return B||0}}),w=Pt({mutationFn:async q=>{const{error:B}=await G.from("weekly_digest_settings").update(q).eq("id",d==null?void 0:d.id);if(B)throw B},onSuccess:()=>{t.invalidateQueries({queryKey:["weekly-digest-settings"]}),pe.success("Settings updated")},onError:q=>{pe.error("Failed to update settings: "+q.message)}}),S=async()=>{n(!0);try{const{data:q,error:B}=await G.functions.invoke("send-weekly-digest",{body:{manual:!0}});if(B)throw B;q.queued?pe.success(`${q.queued.toLocaleString()} emails queued! They'll be sent automatically (~80/minute).`):q.sent!==void 0&&pe.success(`Digest sent! ${q.sent} emails delivered, ${q.failed} failed`),b(),t.invalidateQueries({queryKey:["weekly-digest-logs"]})}catch(q){pe.error("Failed to send digest: "+q.message)}finally{n(!1)}},C=async()=>{var q,B,U,te,Y,J;if(!(s!=null&&s.email)){pe.error("No email found for your account");return}o(!0);try{const{data:X,error:ce}=await G.functions.invoke("send-weekly-digest",{body:{preview:!0,previewEmail:s.email}});if(ce)throw ce;const ie=X==null?void 0:X.resendId,ae=X==null?void 0:X.resendDetails,oe=ae==null?void 0:ae.status,me=((q=ae==null?void 0:ae.body)==null?void 0:q.status)||((U=(B=ae==null?void 0:ae.body)==null?void 0:B.data)==null?void 0:U.status),ve=((Y=(te=ae==null?void 0:ae.body)==null?void 0:te.error)==null?void 0:Y.message)||((J=ae==null?void 0:ae.body)==null?void 0:J.message);pe.success(ie?`Preview accepted by email provider (id: ${ie})${oe?`, status check: ${oe}`:""}${me?`, provider: ${me}`:""}${ve?` (${ve})`:""}. Check spam/promotions—delivery can take a few minutes.`:"Preview accepted by email provider. Check spam/promotions—delivery can take a few minutes.")}catch(X){pe.error("Failed to send preview: "+X.message)}finally{o(!1)}},A=async()=>{i(!0);try{const{data:q,error:B}=await G.functions.invoke("send-weekly-digest",{body:{retryFailed:!0}});if(B)throw B;q.queued===0||q.sent===0&&q.failed===0&&!q.queued?pe.info("No failed emails to retry"):q.queued?pe.success(`${q.queued} emails queued for retry!`):pe.success(`Retry complete! ${q.sent} emails delivered, ${q.failed} failed`),b(),t.invalidateQueries({queryKey:["weekly-digest-logs"]}),t.invalidateQueries({queryKey:["digest-today-failed-count"]}),t.invalidateQueries({queryKey:["digest-today-missing-count"]})}catch(q){pe.error("Failed to retry: "+q.message)}finally{i(!1)}},I=_!=null&&_.total?Math.round((_.sent+_.failed)/_.total*100):0,L=((_==null?void 0:_.pending)||0)>0||((_==null?void 0:_.processing)||0)>0,{data:O}=gt({queryKey:["digest-delivery-stats"],queryFn:async()=>{var J,X;const q=new Date;q.setUTCHours(0,0,0,0);const[B,U,te,Y]=await Promise.all([G.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","sent").gte("sent_at",q.toISOString()),G.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","failed").gte("sent_at",q.toISOString()),G.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("has_agent_os_activity",!0).gte("sent_at",q.toISOString()),G.from("weekly_digest_logs").select("sent_at").order("sent_at",{ascending:!1}).limit(1)]);return{totalSent:B.count||0,totalFailed:U.count||0,agentOsEngaged:te.count||0,lastSent:((X=(J=Y.data)==null?void 0:J[0])==null?void 0:X.sent_at)||null}},refetchInterval:L?5e3:!1}),V={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(Ds,{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(Ds,{title:"Weekly Digest",description:"Configure and manage automated weekly email digests for members",children:e.jsxs(ta,{defaultValue:"settings",className:"space-y-6",children:[e.jsxs(Jn,{children:[e.jsxs(cs,{value:"settings",className:"flex items-center gap-2",children:[e.jsx(So,{className:"h-4 w-4"}),"Settings"]}),e.jsxs(cs,{value:"stats",className:"flex items-center gap-2",children:[e.jsx(so,{className:"h-4 w-4"}),"Delivery Stats"]})]}),e.jsxs(Ss,{value:"settings",className:"space-y-6",children:[L&&_&&e.jsx(Pe,{className:"border-primary/50 bg-primary/5",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsx(us,{className:"h-5 w-5 animate-spin text-primary"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:"Sending emails..."}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[_.sent.toLocaleString()," sent, ",_.pending.toLocaleString()," pending",_.failed>0&&`, ${_.failed} failed`]})]}),e.jsxs("span",{className:"text-sm font-medium",children:[I,"%"]})]}),e.jsx(xi,{value:I,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Processing ~80 emails per minute. Estimated time remaining: ~",Math.ceil(_.pending/80)," min"]})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsx(Pe,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-primary/10",children:e.jsx(ir,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:y}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Subscribers"})]})]})})}),e.jsx(Pe,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-emerald-500/10",children:e.jsx($n,{className:"h-5 w-5 text-emerald-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:V.totalSent}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Delivered"})]})]})})}),e.jsx(Pe,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-destructive/10",children:e.jsx(Jl,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:V.totalFailed}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed"})]})]})})}),e.jsx(Pe,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-primary/10",children:e.jsx(nn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:V.lastSent?vs(new Date(V.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(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(nn,{className:"h-5 w-5"}),"Schedule"]}),e.jsx(dr,{children:"Configure when the digest is sent"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Enable Weekly Digest"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Send automated weekly emails to members"})]}),e.jsx(Ar,{checked:d==null?void 0:d.is_enabled,onCheckedChange:q=>w.mutate({is_enabled:q})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Cron Frequency"}),e.jsxs($s,{value:(d==null?void 0:d.cron_frequency)||"daily",onValueChange:q=>w.mutate({cron_frequency:q}),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"daily",children:"Daily (runs once at selected time)"}),e.jsx(vt,{value:"hourly",children:"Hourly (checks every hour)"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(d==null?void 0:d.cron_frequency)==="hourly"?"Cron runs every hour; digest sends when day & hour match.":"Cron runs once daily at the selected hour (UTC)."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Day of Week"}),e.jsxs($s,{value:String(d==null?void 0:d.send_day),onValueChange:q=>w.mutate({send_day:parseInt(q)}),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsx(Bs,{children:C4s.map(q=>e.jsx(vt,{value:q.value,children:q.label},q.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Time (UTC)"}),e.jsxs($s,{value:String(d==null?void 0:d.send_hour),onValueChange:q=>w.mutate({send_hour:parseInt(q)}),disabled:(d==null?void 0:d.cron_frequency)==="daily",children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsx(Bs,{children:M4s.map(q=>e.jsx(vt,{value:q.value,children:q.label},q.value))})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(W,{onClick:C,disabled:a,variant:"outline",className:"flex-1",children:[e.jsx(jn,{className:"h-4 w-4 mr-2"}),a?"Sending...":"Send Preview to Me"]}),e.jsxs(W,{onClick:S,disabled:r,className:"flex-1",children:[e.jsx(_n,{className:"h-4 w-4 mr-2"}),r?"Sending...":"Send to All"]})]}),N>0&&e.jsxs(W,{onClick:A,disabled:l,variant:"outline",className:"w-full",children:[e.jsx(Zi,{className:`h-4 w-4 mr-2 ${l?"animate-spin":""}`}),l?"Retrying...":`Retry ${N} Failed`]})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(vn,{className:"h-5 w-5"}),"Content Sections"]}),e.jsx(dr,{children:"Choose what to include in the digest"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(vn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(xe,{children:"New Resources"})]}),e.jsx(Ar,{checked:d==null?void 0:d.include_new_resources,onCheckedChange:q=>w.mutate({include_new_resources:q})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ir,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(xe,{children:"Community Highlights"})]}),e.jsx(Ar,{checked:d==null?void 0:d.include_community_posts,onCheckedChange:q=>w.mutate({include_community_posts:q})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(so,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(xe,{children:"Agent OS Stats"})]}),e.jsx(Ar,{checked:d==null?void 0:d.include_agent_os_stats,onCheckedChange:q=>w.mutate({include_agent_os_stats:q})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(cn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(xe,{children:"Upcoming Events"})]}),e.jsx(Ar,{checked:d==null?void 0:d.include_upcoming_events,onCheckedChange:q=>w.mutate({include_upcoming_events:q})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rh,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(xe,{children:"Goals Progress"})]}),e.jsx(Ar,{checked:d==null?void 0:d.include_goals_progress,onCheckedChange:q=>w.mutate({include_goals_progress:q})})]})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"Custom Introduction"}),e.jsx(dr,{children:"Personalize the intro message (optional)"})]}),e.jsx(Oe,{children:e.jsx(_r,{placeholder:"Here's what's new this week to help you grow your business...",value:(d==null?void 0:d.custom_intro_text)||"",onChange:q=>w.mutate({custom_intro_text:q.target.value||null}),rows:3})})]})]}),e.jsx(Ss,{value:"stats",children:e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(tr,{className:"h-5 w-5"}),"Delivery History"]}),e.jsx(dr,{children:"Recent digest emails sent to members"})]}),e.jsx(Oe,{children:f?e.jsx("div",{className:"animate-pulse space-y-2",children:[1,2,3,4,5].map(q=>e.jsx("div",{className:"h-12 bg-muted rounded"},q))}):p&&p.length>0?e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Sent At"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Resources"}),e.jsx(St,{children:"Agent OS"})]})}),e.jsx(Rn,{children:p.map(q=>e.jsxs(Ps,{children:[e.jsx(ht,{className:"font-medium",children:q.email_sent_to}),e.jsx(ht,{children:vs(new Date(q.sent_at),"MMM d, yyyy h:mm a")}),e.jsx(ht,{children:e.jsx(Qe,{variant:q.delivery_status==="sent"?"default":"destructive",children:q.delivery_status})}),e.jsx(ht,{children:q.resources_count}),e.jsx(ht,{children:q.has_agent_os_activity?e.jsx(Qe,{variant:"secondary",children:"Active"}):e.jsx(Qe,{variant:"outline",children:"Not Started"})})]},q.id))})]}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(tr,{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 A4s={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 E4s(){var ge,je,qe;const t=Qt(),[s,r]=k.useState(""),[n,a]=k.useState(null),[o,l]=k.useState(!1),[i,d]=k.useState(!1),[u,p]=k.useState(""),[f,y]=k.useState(""),[_,b]=k.useState(!0),[N,w]=k.useState(!1),[S,C]=k.useState(""),[A,I]=k.useState(null),{data:L,isLoading:O}=gt({queryKey:["admin-agent-points"],queryFn:async()=>{const{data:Me,error:ke}=await G.from("agent_attendance_stats").select("*").order("total_points",{ascending:!1});if(ke)throw ke;const Re=(Me==null?void 0:Me.map(Ue=>Ue.user_id))||[],{data:Ve}=await G.from("profiles").select("id, name, email").in("id",Re),Ne=new Map((Ve==null?void 0:Ve.map(Ue=>[Ue.id,{name:Ue.name,email:Ue.email}]))||[]);return Me==null?void 0:Me.map(Ue=>({...Ue,profile:Ne.get(Ue.user_id)||null}))}}),{data:V}=gt({queryKey:["all-profiles-for-points",L],queryFn:async()=>{const ke=[];let Re=0;for(;;){const{data:Ve,error:Ne}=await G.from("profiles").select("id, name, email").order("name").range(Re,Re+1e3-1);if(Ne)throw Ne;if(ke.push(...Ve),!Ve||Ve.length<1e3)break;Re+=1e3}return ke}}),B=((V==null?void 0:V.filter(Me=>!(L!=null&&L.some(ke=>ke.user_id===Me.id))))||[]).filter(Me=>{var Re,Ve;if(!S)return!0;const ke=S.toLowerCase();return((Re=Me.name)==null?void 0:Re.toLowerCase().includes(ke))||((Ve=Me.email)==null?void 0:Ve.toLowerCase().includes(ke))}),{data:U,isLoading:te}=gt({queryKey:["agent-point-history",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:Me,error:ke}=await G.from("agent_points").select("*").eq("user_id",n.user_id).order("created_at",{ascending:!1});if(ke)throw ke;return Me},enabled:!!(n!=null&&n.user_id)&&i}),{data:Y}=gt({queryKey:["agent-badges",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:Me,error:ke}=await G.from("agent_badges").select("*").eq("user_id",n.user_id).order("earned_at",{ascending:!1});if(ke)throw ke;return Me},enabled:!!(n!=null&&n.user_id)}),J=Pt({mutationFn:async({userId:Me,points:ke,reason:Re})=>{const{error:Ve}=await G.from("agent_points").insert({user_id:Me,points:ke,reason:Re});if(Ve)throw Ve;const{data:Ne}=await G.from("agent_attendance_stats").select("total_points, spendable_points").eq("user_id",Me).maybeSingle(),Ue=((Ne==null?void 0:Ne.total_points)||0)+ke,Ie=((Ne==null?void 0:Ne.spendable_points)||0)+ke,{error:ye}=await G.from("agent_attendance_stats").upsert({user_id:Me,total_points:Math.max(0,Ue),spendable_points:Math.max(0,Ie),updated_at:new Date().toISOString()},{onConflict:"user_id"});if(ye)throw ye},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-agent-points"]}),t.invalidateQueries({queryKey:["agent-point-history"]}),l(!1),p(""),y(""),pe.success(_?"Points awarded successfully!":"Points deducted successfully!")},onError:Me=>{console.error("Error modifying points:",Me),pe.error("Failed to modify points")}}),X=()=>{if(!n||!u||!f){pe.error("Please fill in all fields");return}const Me=parseInt(u);if(isNaN(Me)||Me<=0){pe.error("Please enter a valid positive number");return}J.mutate({userId:n.user_id,points:_?Me:-Me,reason:f})},ce=()=>{if(!A||!u||!f){pe.error("Please fill in all fields");return}const Me=parseInt(u);if(isNaN(Me)||Me<=0){pe.error("Please enter a valid positive number");return}J.mutate({userId:A.id,points:Me,reason:f},{onSuccess:()=>{w(!1),I(null),C("")}})},ie=(Me,ke)=>{a(Me),b(ke),l(!0)},ae=Me=>{a(Me),d(!0)},oe=L==null?void 0:L.filter(Me=>{var Ne,Ue,Ie,ye;const ke=((Ue=(Ne=Me.profile)==null?void 0:Ne.name)==null?void 0:Ue.toLowerCase())||"",Re=((ye=(Ie=Me.profile)==null?void 0:Ie.email)==null?void 0:ye.toLowerCase())||"",Ve=s.toLowerCase();return ke.includes(Ve)||Re.includes(Ve)}),me=(L==null?void 0:L.reduce((Me,ke)=>Me+ke.total_points,0))||0,ve=(L==null?void 0:L.length)||0,he=ve>0?Math.round(me/ve):0;return O?e.jsx(Ds,{title:"Agent Points",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ms,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-3 gap-4",children:[1,2,3].map(Me=>e.jsx(Ms,{className:"h-24"},Me))}),e.jsx(Ms,{className:"h-96"})]})}):e.jsx(Ds,{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(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(ir,{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:ve}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with points tracked"})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Fi,{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:me.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"awarded across all agents"})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Qo,{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:he}),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(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search agents...",value:s,onChange:Me=>r(Me.target.value),className:"pl-10"})]}),e.jsxs(W,{onClick:()=>w(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Award Points to New Agent"]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"Agent Leaderboard"}),e.jsx(dr,{children:"All agents with their points, events, and streaks"})]}),e.jsx(Oe,{children:!oe||oe.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Fi,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents with points yet"})]}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{className:"w-12",children:"#"}),e.jsx(St,{children:"Agent"}),e.jsx(St,{className:"text-center",children:"Total Points"}),e.jsx(St,{className:"text-center",children:"Spendable"}),e.jsx(St,{className:"text-center",children:"Events"}),e.jsx(St,{className:"text-center",children:"Streak"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:oe.map((Me,ke)=>{var Re,Ve,Ne,Ue;return e.jsxs(Ps,{children:[e.jsx(ht,{className:"font-medium",children:ke<3?e.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center ${ke===0?"bg-yellow-100 text-yellow-700":ke===1?"bg-gray-100 text-gray-600":"bg-amber-100 text-amber-700"}`,children:ke+1}):e.jsx("span",{className:"text-muted-foreground",children:ke+1})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Nn,{className:"h-8 w-8",children:e.jsx(kn,{children:((Ve=(Re=Me.profile)==null?void 0:Re.name)==null?void 0:Ve.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Ne=Me.profile)==null?void 0:Ne.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(Ue=Me.profile)==null?void 0:Ue.email})]})]})}),e.jsx(ht,{className:"text-center",children:e.jsxs(Qe,{variant:"secondary",className:"font-bold",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),Me.total_points]})}),e.jsx(ht,{className:"text-center",children:e.jsxs(Qe,{variant:"outline",className:"font-bold text-primary",children:[e.jsx(hi,{className:"h-3 w-3 mr-1"}),Me.spendable_points||0]})}),e.jsx(ht,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(cn,{className:"h-3 w-3 text-muted-foreground"}),Me.total_events_attended]})}),e.jsx(ht,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(rd,{className:"h-3 w-3 text-orange-500"}),Me.current_streak]})}),e.jsx(ht,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>ie(Me,!0),title:"Award points",children:e.jsx(qs,{className:"h-4 w-4 text-green-600"})}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>ie(Me,!1),title:"Deduct points",children:e.jsx(Qy,{className:"h-4 w-4 text-red-600"})}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>ae(Me),title:"View history",children:e.jsx(MM,{className:"h-4 w-4"})})]})})]},Me.user_id)})})]})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{children:[e.jsxs(ks,{children:[e.jsx(_s,{children:_?"Award Points":"Deduct Points"}),e.jsxs(Ir,{children:[_?"Award":"Deduct"," points ",_?"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(xe,{htmlFor:"points",children:"Points Amount"}),e.jsx(De,{id:"points",type:"number",min:"1",placeholder:"Enter points...",value:u,onChange:Me=>p(Me.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"reason",children:"Reason"}),e.jsx(_r,{id:"reason",placeholder:"Enter reason for this adjustment...",value:f,onChange:Me=>y(Me.target.value)})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(W,{onClick:X,disabled:J.isPending,className:_?"bg-green-600 hover:bg-green-700":"bg-red-600 hover:bg-red-700",children:J.isPending?"Saving...":_?"Award Points":"Deduct Points"})]})]})}),e.jsx(fs,{open:i,onOpenChange:d,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsxs(ks,{children:[e.jsxs(_s,{children:["Point History: ",(je=n==null?void 0:n.profile)==null?void 0:je.name]}),e.jsx(Ir,{children:"View all point transactions and badges for this agent"})]}),e.jsxs(ta,{defaultValue:"history",className:"w-full",children:[e.jsxs(Jn,{className:"grid w-full grid-cols-2",children:[e.jsx(cs,{value:"history",children:"Point History"}),e.jsx(cs,{value:"badges",children:"Badges"})]}),e.jsx(Ss,{value:"history",className:"mt-4",children:te?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(Me=>e.jsx(Ms,{className:"h-12"},Me))}):!U||U.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(MM,{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:U.map(Me=>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:Me.reason}),e.jsx("p",{className:"text-xs text-muted-foreground",children:vs(new Date(Me.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(Qe,{variant:Me.points>=0?"default":"destructive",className:Me.points>=0?"bg-green-100 text-green-800":"",children:[Me.points>=0?"+":"",Me.points]})]},Me.id))})}),e.jsx(Ss,{value:"badges",className:"mt-4",children:!Y||Y.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(nc,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No badges earned yet"})]}):e.jsx("div",{className:"grid grid-cols-2 gap-3",children:Y.map(Me=>e.jsxs("div",{className:`p-3 rounded-lg ${A4s[Me.badge_type]||"bg-gray-100"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(nc,{className:"h-5 w-5"}),e.jsx("span",{className:"font-medium",children:Me.badge_name})]}),Me.badge_description&&e.jsx("p",{className:"text-xs mt-1 opacity-80",children:Me.badge_description}),e.jsxs("p",{className:"text-xs mt-1 opacity-60",children:["Earned ",vs(new Date(Me.earned_at),"MMM d, yyyy")]})]},Me.id))})})]})]})}),e.jsx(fs,{open:N,onOpenChange:Me=>{w(Me),Me||(I(null),C(""),p(""),y(""))},children:e.jsxs(ps,{className:"max-w-md",children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Award Points to New Agent"}),e.jsx(Ir,{children:"Select an agent who doesn't have points yet and award them points"})]}),e.jsx("div",{className:"space-y-4 py-4",children:A?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted/50 rounded-lg",children:[e.jsx(Nn,{className:"h-10 w-10",children:e.jsx(kn,{children:((qe=A.name)==null?void 0:qe.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:A.name||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:A.email})]}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>I(null),children:"Change"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"new-points",children:"Points Amount"}),e.jsx(De,{id:"new-points",type:"number",min:"1",placeholder:"Enter points...",value:u,onChange:Me=>p(Me.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"new-reason",children:"Reason"}),e.jsx(_r,{id:"new-reason",placeholder:"Enter reason for awarding points...",value:f,onChange:Me=>y(Me.target.value)})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Search Agent"}),e.jsxs("div",{className:"relative",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name or email...",value:S,onChange:Me=>C(Me.target.value),className:"pl-10"})]})]}),e.jsx("div",{className:"max-h-60 overflow-y-auto border rounded-lg",children:B.length===0?e.jsxs("div",{className:"text-center py-4 text-muted-foreground",children:[e.jsx(ir,{className:"h-6 w-6 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:S?"No matching agents found":"All agents already have points"})]}):B.slice(0,20).map(Me=>{var ke;return e.jsxs("button",{onClick:()=>I(Me),className:"w-full flex items-center gap-3 p-3 hover:bg-muted/50 transition-colors border-b last:border-b-0 text-left",children:[e.jsx(Nn,{className:"h-8 w-8",children:e.jsx(kn,{children:((ke=Me.name)==null?void 0:ke.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:Me.name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Me.email})]})]},Me.id)})})]})}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),A&&e.jsxs(W,{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 P4s(){const{data:t,isLoading:s}=bkt(),[r,n]=k.useState(null),[a,o]=k.useState(!1),[l,i]=k.useState(""),[d,u]=k.useState("all"),[p,f]=k.useState("newest"),[y,_]=k.useState("table"),b=k.useMemo(()=>(t==null?void 0:t.map(A=>A.user_id))||[],[t]),N=k.useMemo(()=>(t==null?void 0:t.map(A=>A.id))||[],[t]),{data:w}=gt({queryKey:["card-profiles-lookup",b],queryFn:async()=>{if(b.length===0)return{};const{data:A}=await G.from("profiles").select("id, name, email").in("id",b),I={};return A==null||A.forEach(L=>{I[L.id]={name:L.name||"",email:L.email||""}}),I},enabled:b.length>0}),{data:S}=gt({queryKey:["card-stats-all",N],queryFn:async()=>{if(N.length===0)return{};const A={};N.forEach(O=>{A[O]={views:0,leads:0}});const{data:I}=await G.from("agent_card_interactions").select("card_id").in("card_id",N).eq("interaction_type","card_view");I==null||I.forEach(O=>{A[O.card_id]&&A[O.card_id].views++});const{data:L}=await G.from("agent_card_leads").select("card_id").in("card_id",N);return L==null||L.forEach(O=>{A[O.card_id]&&A[O.card_id].leads++}),A},enabled:N.length>0}),C=k.useMemo(()=>{if(!t)return[];let A=[...t];if(d==="live"?A=A.filter(I=>I.is_published):d==="draft"&&(A=A.filter(I=>!I.is_published)),l.trim()){const I=l.toLowerCase();A=A.filter(L=>{var V,q;const O=w==null?void 0:w[L.user_id];return L.slug.toLowerCase().includes(I)||((V=O==null?void 0:O.name)==null?void 0:V.toLowerCase().includes(I))||((q=O==null?void 0:O.email)==null?void 0:q.toLowerCase().includes(I))})}return p==="newest"?A.sort((I,L)=>new Date(L.created_at).getTime()-new Date(I.created_at).getTime()):p==="oldest"?A.sort((I,L)=>new Date(I.created_at).getTime()-new Date(L.created_at).getTime()):p==="name"?A.sort((I,L)=>{var O,V;return(((O=w==null?void 0:w[I.user_id])==null?void 0:O.name)||"").localeCompare(((V=w==null?void 0:w[L.user_id])==null?void 0:V.name)||"")}):p==="slug"?A.sort((I,L)=>I.slug.localeCompare(L.slug)):p==="views_desc"?A.sort((I,L)=>{var O,V;return(((O=S==null?void 0:S[L.id])==null?void 0:O.views)||0)-(((V=S==null?void 0:S[I.id])==null?void 0:V.views)||0)}):p==="views_asc"?A.sort((I,L)=>{var O,V;return(((O=S==null?void 0:S[I.id])==null?void 0:O.views)||0)-(((V=S==null?void 0:S[L.id])==null?void 0:V.views)||0)}):p==="leads_desc"?A.sort((I,L)=>{var O,V;return(((O=S==null?void 0:S[L.id])==null?void 0:O.leads)||0)-(((V=S==null?void 0:S[I.id])==null?void 0:V.leads)||0)}):p==="leads_asc"&&A.sort((I,L)=>{var O,V;return(((O=S==null?void 0:S[I.id])==null?void 0:O.leads)||0)-(((V=S==null?void 0:S[L.id])==null?void 0:V.leads)||0)}),A},[t,d,l,p,w]);return e.jsxs(Ds,{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(W,{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(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name, email, or slug...",value:l,onChange:A=>i(A.target.value),className:"pl-9"})]}),e.jsxs($s,{value:d,onValueChange:u,children:[e.jsx(zs,{className:"w-full sm:w-36",children:e.jsx(Vs,{placeholder:"Status"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All Status"}),e.jsx(vt,{value:"live",children:"Live"}),e.jsx(vt,{value:"draft",children:"Draft"})]})]}),e.jsxs($s,{value:p,onValueChange:f,children:[e.jsx(zs,{className:"w-full sm:w-44",children:e.jsx(Vs,{placeholder:"Sort by"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"newest",children:"Newest First"}),e.jsx(vt,{value:"oldest",children:"Oldest First"}),e.jsx(vt,{value:"name",children:"Name A–Z"}),e.jsx(vt,{value:"slug",children:"Slug A–Z"}),e.jsx(vt,{value:"views_desc",children:"Most Views"}),e.jsx(vt,{value:"views_asc",children:"Fewest Views"}),e.jsx(vt,{value:"leads_desc",children:"Most Leads"}),e.jsx(vt,{value:"leads_asc",children:"Fewest Leads"})]})]}),e.jsxs("div",{className:"flex border rounded-md",children:[e.jsx(W,{variant:y==="table"?"default":"ghost",size:"sm",onClick:()=>_("table"),className:"rounded-r-none",children:e.jsx(RM,{className:"h-4 w-4"})}),e.jsx(W,{variant:y==="grid"?"default":"ghost",size:"sm",onClick:()=>_("grid"),className:"rounded-l-none",children:e.jsx(xp,{className:"h-4 w-4"})})]})]}),!s&&t&&t.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",C.length," of ",t.length," cards"]}),s?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(A=>e.jsx(Ms,{className:"h-48"},A))}):C.length>0?y==="table"?e.jsx(I4s,{cards:C,cardProfiles:w,cardStats:S,onEdit:n,sortBy:p,setSortBy:f}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:C.map(A=>e.jsx(L4s,{card:A,onEdit:()=>n(A),stats:S==null?void 0:S[A.id]},A.id))}):t&&t.length>0?e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(ln,{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(Oe,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(ir,{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(W,{onClick:()=>o(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create Card"]})]})})]}),e.jsx(D4s,{open:a,onOpenChange:o}),r&&e.jsx(R4s,{card:r,open:!!r,onOpenChange:A=>!A&&n(null)})]})}function I4s({cards:t,cardProfiles:s,cardStats:r,onEdit:n,sortBy:a,setSortBy:o}){const l=d=>{a===`${d}_desc`?o(`${d}_asc`):o(`${d}_desc`)},i=({field:d})=>a===`${d}_desc`?e.jsx(Ih,{className:"h-3 w-3"}):a===`${d}_asc`?e.jsx(uu,{className:"h-3 w-3"}):e.jsx(td,{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(uu,{className:"h-3 w-3"})]})}),e.jsx("th",{className:"text-left p-3 font-medium text-muted-foreground hidden md:table-cell",children:"Slug"}),e.jsx("th",{className:"text-center p-3 font-medium text-muted-foreground",children:"Status"}),e.jsx("th",{className:"text-right p-3 font-medium",children:e.jsxs("button",{onClick:()=>l("views"),className:"flex items-center gap-1 ml-auto hover:text-foreground text-muted-foreground",children:["Views ",e.jsx(i,{field:"views"})]})}),e.jsx("th",{className:"text-right p-3 font-medium",children:e.jsxs("button",{onClick:()=>l("leads"),className:"flex items-center gap-1 ml-auto hover:text-foreground text-muted-foreground",children:["Leads ",e.jsx(i,{field:"leads"})]})}),e.jsx("th",{className:"text-right p-3 font-medium text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:t.map(d=>{const u=s==null?void 0:s[d.user_id],p=r==null?void 0:r[d.id],f=`https://cards.relevelup.com/${d.slug}`;return e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30 transition-colors",children:[e.jsx("td",{className:"p-3",children:e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:(u==null?void 0:u.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(u==null?void 0:u.email)||""})]})}),e.jsx("td",{className:"p-3 hidden md:table-cell",children:e.jsxs("span",{className:"text-xs text-muted-foreground font-mono",children:["/",d.slug]})}),e.jsx("td",{className:"p-3 text-center",children:e.jsx(Qe,{variant:d.is_published?"default":"secondary",className:"text-xs",children:d.is_published?"Live":"Draft"})}),e.jsx("td",{className:"p-3 text-right tabular-nums font-medium",children:(p==null?void 0:p.views)??0}),e.jsx("td",{className:"p-3 text-right tabular-nums font-medium",children:(p==null?void 0:p.leads)??0}),e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>n(d),className:"h-8 w-8 p-0",children:e.jsx(ga,{className:"h-3.5 w-3.5"})}),e.jsx(W,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{navigator.clipboard.writeText(f),pe.success("Link copied!")},children:e.jsx(Va,{className:"h-3.5 w-3.5"})}),e.jsx(W,{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(Yr,{className:"h-3.5 w-3.5"})})})]})})]},d.id)})})]})})})}function L4s({card:t,onEdit:s,stats:r}){const[n,a]=k.useState(null);k.useEffect(()=>{(async()=>{const{data:d}=await G.from("profiles").select("name").eq("id",t.user_id).single();let u=null;try{const{data:p}=await G.storage.from("avatars").list(`${t.user_id}`);if(p&&p.length>0){const{data:f}=G.storage.from("avatars").getPublicUrl(`${t.user_id}/${p[0].name}`);u=f.publicUrl}}catch{}a({name:(d==null?void 0:d.name)||"Unknown",avatar_url:u})})()},[t.user_id]);const o=`https://cards.relevelup.com/${t.slug}`,l=()=>{navigator.clipboard.writeText(o),pe.success("Link copied!")};return e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:(n==null?void 0:n.avatar_url)||void 0}),e.jsx(kn,{children:((n==null?void 0:n.name)||"U")[0]})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold truncate",children:(n==null?void 0:n.name)||"Loading..."}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:["/card/",t.slug]})]}),e.jsx(Qe,{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(jn,{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(ir,{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(W,{variant:"outline",size:"sm",onClick:s,className:"flex-1",children:[e.jsx(ga,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsx(W,{variant:"outline",size:"sm",onClick:l,children:e.jsx(Va,{className:"h-3 w-3"})}),e.jsx(W,{variant:"outline",size:"sm",asChild:!0,children:e.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:e.jsx(Yr,{className:"h-3 w-3"})})})]})]})})}function D4s({open:t,onOpenChange:s}){const[r,n]=k.useState(""),[a,o]=k.useState(""),[l,i]=k.useState(""),[d,u]=k.useState(!1),p=_We(),f=l.trim(),{data:y}=gt({queryKey:["profiles-search-for-cards",f],queryFn:async()=>{let C=G.from("profiles").select("id, name, email").order("name").limit(50);f.length>=2&&(C=C.or(`name.ilike.%${f}%,email.ilike.%${f}%`));const{data:A}=await C;return A||[]},enabled:t}),[_,b]=k.useState(null),N=(y==null?void 0:y.find(C=>C.id===r))||_,w=()=>{if(!r||!a.trim()){pe.error("Select an agent and enter a slug");return}p.mutate({user_id:r,slug:a.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-"),is_published:!0},{onSuccess:()=>{s(!1),n(""),o(""),i("")}})},S=C=>{var I;n(C),u(!1);const A=y==null?void 0:y.find(L=>L.id===C);A&&(b(A),o(((I=A.name)==null?void 0:I.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""))||""))};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(ps,{children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Create Agent Card"}),e.jsx(Ir,{children:"Select an agent and set their card URL slug."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Agent"}),e.jsxs(mo,{open:d,onOpenChange:u,children:[e.jsx(po,{asChild:!0,children:e.jsxs(W,{variant:"outline",role:"combobox","aria-expanded":d,className:"w-full justify-between font-normal",children:[N?`${N.name} (${N.email})`:"Search for an agent...",e.jsx(gx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(no,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Sx,{shouldFilter:!1,children:[e.jsx(Cx,{placeholder:"Search by name or email...",value:l,onValueChange:i}),e.jsxs(Mx,{children:[e.jsx(Tx,{children:"No agents found."}),e.jsx(Ax,{children:(y||[]).map(C=>e.jsxs(cp,{value:C.id,onSelect:S,children:[e.jsx(Zn,{className:Ot("mr-2 h-4 w-4",r===C.id?"opacity-100":"opacity-0")}),C.name," (",C.email,")"]},C.id))})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(xe,{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(De,{value:a,onChange:C=>o(C.target.value),placeholder:"john-doe"})]})]}),e.jsx(W,{onClick:w,disabled:p.isPending,className:"w-full",children:p.isPending?"Creating...":"Create Card"})]})]})})}function R4s({card:t,open:s,onOpenChange:r}){const n=bWe(),{data:a}=wWe(t.id),o=Qt(),[l,i]=k.useState(null),[d,u]=k.useState(!1),[p,f]=k.useState(!1),[y,_]=k.useState(""),[b,N]=k.useState(t.slug),[w,S]=k.useState(!1),[C,A]=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:U}=await G.storage.from("avatars").list(`${t.user_id}`);if(U&&U.length>0){const{data:te}=G.storage.from("avatars").getPublicUrl(`${t.user_id}/${U[0].name}`);i(`${te.publicUrl}?t=${Date.now()}`)}}catch{}})()},[t.user_id,s]);const I=B=>{var Y;const U=(Y=B.target.files)==null?void 0:Y[0];if(!U)return;if(!U.type.startsWith("image/")){pe.error("Please select an image file");return}if(U.size>5*1024*1024){pe.error("Image must be under 5MB");return}const te=new FileReader;te.onloadend=()=>{_(te.result),f(!0)},te.readAsDataURL(U),B.target.value=""},L=async B=>{u(!0);try{const{data:U}=await G.storage.from("avatars").list(`${t.user_id}`);U&&U.length>0&&await G.storage.from("avatars").remove(U.map(ce=>`${t.user_id}/${ce.name}`));const te=`${t.user_id}/avatar.jpg`,{error:Y}=await G.storage.from("avatars").upload(te,B,{upsert:!0,contentType:"image/jpeg"});if(Y)throw Y;const{data:J}=G.storage.from("avatars").getPublicUrl(te),X=`${J.publicUrl}?t=${Date.now()}`;i(X),await G.from("profiles").update({avatar_url:X}).eq("id",t.user_id),o.invalidateQueries({queryKey:["agent-card-public"]}),pe.success("Photo updated!")}catch(U){pe.error(U.message||"Upload failed")}finally{u(!1)}},O=async()=>{const B=b.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!B){pe.error("Please enter a valid URL");return}if(B===t.slug){pe.info("No changes to save");return}S(!0);try{const{data:U}=await G.from("agent_cards").select("id").eq("slug",B).neq("id",t.id).maybeSingle();if(U){pe.error("This URL is already taken. Try another one.");return}const{error:te}=await G.from("agent_cards").update({slug:B}).eq("id",t.id);if(te)throw te;N(B),o.invalidateQueries({queryKey:["agent-cards-admin"]}),pe.success("Card address updated!")}catch{pe.error("Failed to update card address")}finally{S(!1)}},V=async(B,U)=>{var Y;const te=(Y=B.target.files)==null?void 0:Y[0];if(te){if(!te.type.startsWith("image/")){pe.error("Please select an image file");return}try{const J=te.name.split(".").pop()||"png",X=U==="brokerage_logo_url"?"brokerage-logo":"team-logo",ce=`${t.user_id}/${X}.${J}`,{error:ie}=await G.storage.from("card-logos").upload(ce,te,{upsert:!0});if(ie)throw ie;const{data:ae}=G.storage.from("card-logos").getPublicUrl(ce),oe=ae.publicUrl+"?t="+Date.now();A(U==="brokerage_logo_url"?me=>({...me,[U]:oe,brokerage_display_name:""}):me=>({...me,[U]:oe,team_name:""})),pe.success("Logo uploaded!")}catch{pe.error("Failed to upload logo")}finally{B.target.value=""}}},q=()=>{n.mutate({id:t.id,...C,title:C.title||null,positioning_statement:C.positioning_statement||null,bio:C.bio||null,review_snippet:C.review_snippet||null,review_source_url:C.review_source_url||null,booking_url:C.booking_url||null,custom_cta_label:C.custom_cta_label||null,custom_cta_url:C.custom_cta_url||null,brokerage_display_name:C.brokerage_display_name||null,brokerage_logo_url:C.brokerage_logo_url||null,brokerage_logo_size:C.brokerage_logo_size,team_name:C.team_name||null,team_logo_url:C.team_logo_url||null,team_logo_size:C.team_logo_size},{onSuccess:()=>r(!1)})};return e.jsxs(e.Fragment,{children:[e.jsx(fs,{open:s,onOpenChange:r,children:e.jsxs(ps,{className:"max-w-2xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Edit Agent Card"}),e.jsxs(Ir,{children:["/card/",t.slug]})]}),e.jsxs(ta,{defaultValue:"content",children:[e.jsxs(Jn,{className:"w-full",children:[e.jsx(cs,{value:"content",className:"flex-1",children:"Content"}),e.jsx(cs,{value:"sections",className:"flex-1",children:"Sections"}),e.jsx(cs,{value:"blocks",className:"flex-1",children:"Blocks"}),e.jsx(cs,{value:"analytics",className:"flex-1",children:"Analytics"})]}),e.jsxs(Ss,{value:"content",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{children:"Published"}),e.jsx(Ar,{checked:C.is_published,onCheckedChange:B=>A(U=>({...U,is_published:B}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Agent Photo"}),e.jsxs("div",{className:"flex items-center gap-4 mt-1",children:[e.jsxs(Nn,{className:"h-16 w-16",children:[e.jsx(Ma,{src:l||void 0}),e.jsx(kn,{children:"?"})]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:I,disabled:d}),e.jsx(W,{variant:"outline",size:"sm",asChild:!0,disabled:d,children:e.jsx("span",{children:d?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"h-3 w-3 mr-1 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ra,{className:"h-3 w-3 mr-1"}),"Change Photo"]})})})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{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(De,{value:b,onChange:B=>N(B.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"agent-name",className:"rounded-l-none"})]}),e.jsx(W,{variant:"outline",size:"sm",onClick:O,disabled:w||b===t.slug,className:"shrink-0",children:w?"Saving...":"Update"})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Theme"}),e.jsxs($s,{value:C.theme,onValueChange:B=>A(U=>({...U,theme:B})),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"standard",children:"✨ Standard (Modern Clean)"}),e.jsx(vt,{value:"luxury",children:"🌙 Luxury (Dark & Gold)"}),e.jsx(vt,{value:"bold",children:"🔥 Bold (Vibrant & Punchy)"}),e.jsx(vt,{value:"classic",children:"📋 Classic (Professional)"})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Title / Tagline"}),e.jsx(De,{value:C.title,onChange:B=>A(U=>({...U,title:B.target.value})),placeholder:"e.g. Luxury Real Estate Specialist"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Shown below the agent's name on the card"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Positioning Statement"}),e.jsx(De,{value:C.positioning_statement,onChange:B=>A(U=>({...U,positioning_statement:B.target.value})),placeholder:"Your home journey, handled with care."})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Bio"}),e.jsx(_r,{value:C.bio,onChange:B=>A(U=>({...U,bio:B.target.value})),placeholder:"Short about me...",rows:3})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Review Snippet"}),e.jsx(De,{value:C.review_snippet,onChange:B=>A(U=>({...U,review_snippet:B.target.value})),placeholder:"Best agent we've ever worked with..."})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Review Source URL"}),e.jsx(De,{value:C.review_source_url,onChange:B=>A(U=>({...U,review_source_url:B.target.value})),placeholder:"https://g.page/your-business/review"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Booking URL (optional — if empty, shows lead form)"}),e.jsx(De,{value:C.booking_url,onChange:B=>A(U=>({...U,booking_url:B.target.value})),placeholder:"https://calendly.com/your-link"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Custom CTA Label (optional)"}),e.jsx(De,{value:C.custom_cta_label,onChange:B=>A(U=>({...U,custom_cta_label:B.target.value})),placeholder:"Book a Call"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Custom CTA URL (optional)"}),e.jsx(De,{value:C.custom_cta_url,onChange:B=>A(U=>({...U,custom_cta_url:B.target.value})),placeholder:"https://example.com/landing"})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(xe,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Brokerage Branding"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{value:C.brokerage_display_name,onChange:B=>A(U=>({...U,brokerage_display_name:B.target.value,brokerage_logo_url:""})),placeholder:"Brokerage name (or upload logo below)",disabled:!!C.brokerage_logo_url}),e.jsxs("div",{className:"flex items-center gap-3",children:[C.brokerage_logo_url&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:C.brokerage_logo_url,alt:"Brokerage logo",style:{height:`${C.brokerage_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>A(B=>({...B,brokerage_logo_url:""})),className:"absolute -top-1.5 -right-1.5 h-5 w-5 rounded-full bg-destructive text-destructive-foreground text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border text-xs font-medium hover:bg-muted transition-colors",children:[e.jsx(Ra,{className:"h-3.5 w-3.5"}),C.brokerage_logo_url?"Change Logo":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:B=>V(B,"brokerage_logo_url")})]})]}),C.brokerage_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[C.brokerage_logo_size||56,"px"]})]}),e.jsx(Cg,{value:[C.brokerage_logo_size||56],onValueChange:([B])=>A(U=>({...U,brokerage_logo_size:B})),min:24,max:120,step:4})]})]})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(xe,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Team Branding"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(De,{value:C.team_name,onChange:B=>A(U=>({...U,team_name:B.target.value,team_logo_url:""})),placeholder:"Team name (or upload logo below)",disabled:!!C.team_logo_url}),e.jsxs("div",{className:"flex items-center gap-3",children:[C.team_logo_url&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:C.team_logo_url,alt:"Team logo",style:{height:`${C.team_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>A(B=>({...B,team_logo_url:""})),className:"absolute -top-1.5 -right-1.5 h-5 w-5 rounded-full bg-destructive text-destructive-foreground text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border text-xs font-medium hover:bg-muted transition-colors",children:[e.jsx(Ra,{className:"h-3.5 w-3.5"}),C.team_logo_url?"Change Logo":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:B=>V(B,"team_logo_url")})]})]}),C.team_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[C.team_logo_size||56,"px"]})]}),e.jsx(Cg,{value:[C.team_logo_size||56],onValueChange:([B])=>A(U=>({...U,team_logo_size:B})),min:24,max:120,step:4})]})]})]})]}),e.jsx(Ss,{value:"sections",className:"space-y-4 mt-4",children:[{key:"show_photo",label:"Show Photo",hint:"Photo is pulled from the agent's profile."},{key:"show_bio",label:"Show Bio"},{key:"show_credentials",label:"Show Credentials"},{key:"show_social_links",label:"Show Social Links"},{key:"show_save_contact",label:"Save Contact Button"},{key:"show_leave_review",label:"Leave Review Button"},{key:"show_refer_friend",label:"Refer a Friend Button"}].map(({key:B,label:U,hint:te})=>e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{children:[e.jsx(xe,{children:U}),te&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[te," ",B==="show_photo"&&e.jsx("a",{href:"/profile",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:no-underline",children:"Update Profile"})]})]}),e.jsx(Ar,{checked:C[B],onCheckedChange:Y=>A(J=>({...J,[B]:Y}))})]},B))}),e.jsx(Ss,{value:"blocks",className:"mt-4",children:e.jsx(Elt,{cardId:t.id})}),e.jsx(Ss,{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(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:a.views}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Views"})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:a.clicks}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Clicks"})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:a.leads.length}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Leads"})]})})]}),a.leads.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold mb-2",children:"Recent Leads"}),e.jsx("div",{className:"space-y-2",children:a.leads.slice(0,5).map(B=>e.jsxs("div",{className:"text-sm p-2 bg-muted/50 rounded-lg",children:[e.jsx("span",{className:"font-medium",children:B.name}),B.phone&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",B.phone]}),B.intent&&e.jsx(Qe,{variant:"secondary",className:"ml-2 text-xs",children:B.intent})]},B.id))})]})]}):e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No analytics data yet"})})]}),e.jsx(W,{onClick:q,disabled:n.isPending,className:"w-full mt-4",children:n.isPending?"Saving...":"Save Changes"})]})}),e.jsx(e4e,{open:p,onClose:()=>f(!1),imageSrc:y,onCropComplete:L,aspectRatio:1})]})}const iT={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"},qCe={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 UCe(t=!0){return gt({queryKey:["marketplace-categories",t],queryFn:async()=>{let s=G.from("marketplace_categories").select("*").order("sort_order",{ascending:!0});t&&(s=s.eq("is_active",!0));const{data:r,error:n}=await s;if(n)throw n;return r}})}function O4s(){const t=Qt();return Pt({mutationFn:async s=>{const{data:r,error:n}=await G.from("marketplace_categories").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),pe.success("Category created successfully")},onError:s=>{pe.error("Failed to create category: "+s.message)}})}function F4s(){const t=Qt();return Pt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("marketplace_categories").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),pe.success("Category updated successfully")},onError:s=>{pe.error("Failed to update category: "+s.message)}})}function z4s(){const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("marketplace_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),pe.success("Category deleted successfully")},onError:s=>{pe.error("Failed to delete category: "+s.message)}})}function Wlt(t,s=!0){return gt({queryKey:["marketplace-products",t,s],queryFn:async()=>{let r=G.from("marketplace_products").select(` *, category:marketplace_categories(*), images:marketplace_product_images(*), video:marketplace_product_videos(*), variants:marketplace_product_variants(*) `).order("sort_order",{ascending:!0});t&&(r=r.eq("category_id",t)),s&&(r=r.eq("is_active",!0));const{data:n,error:a}=await r;if(a)throw a;return n}})}function B4s(t){return gt({queryKey:["marketplace-product",t],queryFn:async()=>{const{data:s,error:r}=await G.from("marketplace_products").select(` *, category:marketplace_categories(*), images:marketplace_product_images(*), video:marketplace_product_videos(*), variants:marketplace_product_variants(*) `).eq("id",t).single();if(r)throw r;return s},enabled:!!t})}function $4s(){const t=Qt();return Pt({mutationFn:async s=>{const{data:r,error:n}=await G.from("marketplace_products").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-products"]}),pe.success("Product created successfully")},onError:s=>{pe.error("Failed to create product: "+s.message)}})}function q4s(){const t=Qt();return Pt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("marketplace_products").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",r.id]}),pe.success("Product updated successfully")},onError:s=>{pe.error("Failed to update product: "+s.message)}})}function U4s(){const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("marketplace_products").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-products"]}),pe.success("Product deleted successfully")},onError:s=>{pe.error("Failed to delete product: "+s.message)}})}function V4s(){const t=Qt();return Pt({mutationFn:async s=>{const{data:r,error:n}=await G.from("marketplace_product_images").insert([s]).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",r.product_id]})}})}function H4s(){const t=Qt();return Pt({mutationFn:async({id:s,productId:r})=>{const{error:n}=await G.from("marketplace_product_images").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",s]}),pe.success("Image deleted successfully")},onError:s=>{pe.error("Failed to delete image: "+s.message)}})}function G4s(){const t=Qt();return Pt({mutationFn:async({imageId:s,productId:r})=>{const{error:n}=await G.from("marketplace_product_images").update({is_primary:!1}).eq("product_id",r);if(n)throw n;const{error:a}=await G.from("marketplace_product_images").update({is_primary:!0}).eq("id",s);if(a)throw a;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",s]}),pe.success("Primary image updated")},onError:s=>{pe.error("Failed to set primary image: "+s.message)}})}function W4s(){const t=Qt();return Pt({mutationFn:async s=>{const{data:r,error:n}=await G.from("marketplace_product_variants").insert([s]).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",r.product_id]}),pe.success("Variant added successfully")}})}function K4s(){const t=Qt();return Pt({mutationFn:async({id:s,productId:r})=>{const{error:n}=await G.from("marketplace_product_variants").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",s]}),pe.success("Variant deleted successfully")}})}function Z4s(){const t=Qt();return Pt({mutationFn:async({productId:s,videoUrl:r})=>{await G.from("marketplace_product_videos").delete().eq("product_id",s);const{data:n,error:a}=await G.from("marketplace_product_videos").insert({product_id:s,video_url:r}).select().single();if(a)throw a;return n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",r.productId]}),pe.success("Video updated successfully")}})}function Y4s(t){const{isAdmin:s}=Us();return gt({queryKey:["marketplace-orders",t,s],queryFn:async()=>{let r=G.from("marketplace_orders").select(` *, items:marketplace_order_items(*), status_history:marketplace_order_status_history(*) `).order("created_at",{ascending:!1});const{data:n,error:a}=await r;if(a)throw a;if(s&&n){const o=[...new Set(n.map(d=>d.user_id))],{data:l}=await G.from("profiles").select("id, name, email").in("id",o),i=new Map((l==null?void 0:l.map(d=>[d.id,d]))||[]);return n.map(d=>({...d,user:i.get(d.user_id)}))}return n}})}function X4s(){const{user:t}=Us();return gt({queryKey:["my-marketplace-orders",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("marketplace_orders").select(` *, items:marketplace_order_items(*), status_history:marketplace_order_status_history(*) `).eq("user_id",t.id).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!(t!=null&&t.id)})}function Q4s(t){return gt({queryKey:["marketplace-order",t],queryFn:async()=>{const{data:s,error:r}=await G.from("marketplace_orders").select(` *, items:marketplace_order_items(*), status_history:marketplace_order_status_history(*) `).eq("id",t).single();if(r)throw r;return s},enabled:!!t})}function J4s(){const t=Qt(),{user:s}=Us();return Pt({mutationFn:async({orderId:r,status:n,notes:a,trackingNumber:o,trackingUrl:l,previousStatus:i})=>{const d={status:n};o!==void 0&&(d.tracking_number=o),l!==void 0&&(d.tracking_url=l);const{error:u}=await G.from("marketplace_orders").update(d).eq("id",r);if(u)throw u;const{error:p}=await G.from("marketplace_order_status_history").insert({order_id:r,status:n,notes:a,created_by:s==null?void 0:s.id});if(p)throw p;if(["shipped","in_production","processing","completed"].includes(n)&&n!==i)try{await G.functions.invoke("marketplace-order-notify",{body:{orderId:r,notificationType:n==="shipped"?"shipped":"status_update",newStatus:n,trackingNumber:o,trackingUrl:l}})}catch(y){console.error("Failed to send notification email:",y)}},onSuccess:(r,n)=>{t.invalidateQueries({queryKey:["marketplace-orders"]}),t.invalidateQueries({queryKey:["marketplace-order",n.orderId]}),t.invalidateQueries({queryKey:["my-marketplace-orders"]}),pe.success("Order status updated")},onError:r=>{pe.error("Failed to update order: "+r.message)}})}function eSs(){const t=Qt();return Pt({mutationFn:async({itemId:s,proofUrl:r,proofNotes:n,orderId:a})=>{const{error:o}=await G.from("marketplace_order_items").update({proof_url:r,proof_notes:n,proof_status:"pending"}).eq("id",s);if(o)throw o;await G.from("marketplace_orders").update({status:"awaiting_proof_approval"}).eq("id",a);try{await G.functions.invoke("marketplace-order-notify",{body:{orderId:a,notificationType:"proof_ready"}})}catch(l){console.error("Failed to send proof notification:",l)}return a},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-orders"]}),t.invalidateQueries({queryKey:["marketplace-order",s]}),t.invalidateQueries({queryKey:["my-marketplace-orders"]}),pe.success("Proof uploaded & customer notified")}})}function tSs(){const t=Qt();return Pt({mutationFn:async({itemId:s,orderId:r})=>{const{error:n}=await G.from("marketplace_order_items").update({proof_status:"approved"}).eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-orders"]}),t.invalidateQueries({queryKey:["marketplace-order",s]}),t.invalidateQueries({queryKey:["my-marketplace-orders"]}),pe.success("Proof approved")}})}function sSs(){const t=Qt();return Pt({mutationFn:async({itemId:s,orderId:r,reason:n})=>{const{error:a}=await G.from("marketplace_order_items").update({proof_status:"rejected",proof_notes:n}).eq("id",s);if(a)throw a;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-orders"]}),t.invalidateQueries({queryKey:["marketplace-order",s]}),t.invalidateQueries({queryKey:["my-marketplace-orders"]}),pe.success("Proof rejected - please upload a new proof")}})}function rSs(){const{data:t,isLoading:s}=UCe(!1),r=O4s(),n=F4s(),a=z4s(),[o,l]=k.useState(!1),[i,d]=k.useState(null),[u,p]=k.useState({name:"",description:"",image_url:"",sort_order:0,is_active:!0}),f=()=>{p({name:"",description:"",image_url:"",sort_order:0,is_active:!0}),d(null)},y=N=>{d(N),p({name:N.name,description:N.description||"",image_url:N.image_url||"",sort_order:N.sort_order,is_active:N.is_active}),l(!0)},_=async N=>{N.preventDefault(),i?await n.mutateAsync({id:i.id,...u}):await r.mutateAsync(u),l(!1),f()},b=async N=>{confirm("Are you sure you want to delete this category?")&&await a.mutateAsync(N)};return s?e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(Ms,{className:"h-8 w-48"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(N=>e.jsx(Ms,{className:"h-12 w-full"},N))})})]}):e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{children:"Categories"}),e.jsxs(fs,{open:o,onOpenChange:N=>{l(N),N||f()},children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Category"]})}),e.jsxs(ps,{children:[e.jsx(ks,{children:e.jsx(_s,{children:i?"Edit Category":"Add Category"})}),e.jsxs("form",{onSubmit:_,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"name",children:"Name"}),e.jsx(De,{id:"name",value:u.name,onChange:N=>p({...u,name:N.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"description",children:"Description"}),e.jsx(_r,{id:"description",value:u.description,onChange:N=>p({...u,description:N.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"image_url",children:"Image URL"}),e.jsx(De,{id:"image_url",value:u.image_url,onChange:N=>p({...u,image_url:N.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(De,{id:"sort_order",type:"number",value:u.sort_order,onChange:N=>p({...u,sort_order:parseInt(N.target.value)||0})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ar,{id:"is_active",checked:u.is_active,onCheckedChange:N=>p({...u,is_active:N})}),e.jsx(xe,{htmlFor:"is_active",children:"Active"})]}),e.jsx(W,{type:"submit",className:"w-full",disabled:r.isPending||n.isPending,children:i?"Update Category":"Create Category"})]})]})]})]}),e.jsx(Oe,{children:t&&t.length>0?e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{children:"Sort Order"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:t.map(N=>e.jsxs(Ps,{children:[e.jsx(ht,{className:"font-medium",children:N.name}),e.jsx(ht,{className:"max-w-xs truncate",children:N.description}),e.jsx(ht,{children:N.sort_order}),e.jsx(ht,{children:e.jsx("span",{className:`px-2 py-1 rounded-full text-xs ${N.is_active?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"}`,children:N.is_active?"Active":"Inactive"})}),e.jsx(ht,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>y(N),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>b(N.id),disabled:a.isPending,children:e.jsx(vr,{className:"h-4 w-4 text-destructive"})})]})})]},N.id))})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first category to get started."})})]})}function nSs(){var he,ge;const{data:t,isLoading:s}=Wlt(void 0,!1),{data:r}=UCe(!1),n=$4s(),a=q4s(),o=U4s(),l=V4s(),i=H4s(),d=G4s(),u=W4s(),p=K4s(),f=Z4s(),[y,_]=k.useState(!1),[b,N]=k.useState(!1),[w,S]=k.useState(!1),[C,A]=k.useState(null),[I,L]=k.useState(null),[O,V]=k.useState(!1),[q,B]=k.useState({name:"",description:"",base_price:0,shipping_fee:0,category_id:"",allow_artwork_upload:!1,requires_proof_approval:!1,is_active:!0,sort_order:0}),[U,te]=k.useState({name:"",price_adjustment:0}),[Y,J]=k.useState(""),X=()=>{B({name:"",description:"",base_price:0,shipping_fee:0,category_id:"",allow_artwork_upload:!1,requires_proof_approval:!1,is_active:!0,sort_order:0}),A(null)},ce=je=>{A(je),B({name:je.name,description:je.description||"",base_price:Number(je.base_price),shipping_fee:Number(je.shipping_fee),category_id:je.category_id||"",allow_artwork_upload:je.allow_artwork_upload,requires_proof_approval:je.requires_proof_approval,is_active:je.is_active,sort_order:je.sort_order}),_(!0)},ie=async je=>{je.preventDefault();const qe={...q,category_id:q.category_id||null};C?await a.mutateAsync({id:C.id,...qe}):await n.mutateAsync(qe),_(!1),X()},ae=async je=>{confirm("Are you sure you want to delete this product?")&&await o.mutateAsync(je)},oe=async je=>{if(!I||!je.target.files||je.target.files.length===0)return;V(!0);const qe=je.target.files[0],Me=qe.name.split(".").pop(),ke=`products/${I.id}/${Date.now()}.${Me}`;try{const{error:Re}=await G.storage.from("marketplace").upload(ke,qe);if(Re)throw Re;const{data:{publicUrl:Ve}}=G.storage.from("marketplace").getPublicUrl(ke);await l.mutateAsync({product_id:I.id,image_url:Ve,is_primary:!I.images||I.images.length===0}),pe.success("Image uploaded successfully")}catch(Re){pe.error("Failed to upload image: "+Re.message)}finally{V(!1)}},me=async je=>{je.preventDefault(),I&&(await u.mutateAsync({product_id:I.id,name:U.name,price_adjustment:U.price_adjustment}),te({name:"",price_adjustment:0}))},ve=async()=>{!I||!Y||(await f.mutateAsync({productId:I.id,videoUrl:Y}),J(""))};return s?e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(Ms,{className:"h-8 w-48"})}),e.jsx(Oe,{children:e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(je=>e.jsx(Ms,{className:"h-64 w-full"},je))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{children:"Products"}),e.jsxs(fs,{open:y,onOpenChange:je=>{_(je),je||X()},children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{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(ks,{children:e.jsx(_s,{children:C?"Edit Product":"Add Product"})}),e.jsxs("form",{onSubmit:ie,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"name",children:"Product Name"}),e.jsx(De,{id:"name",value:q.name,onChange:je=>B({...q,name:je.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"category",children:"Category"}),e.jsxs($s,{value:q.category_id,onValueChange:je=>B({...q,category_id:je}),children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select category"})}),e.jsx(Bs,{children:r==null?void 0:r.map(je=>e.jsx(vt,{value:je.id,children:je.name},je.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"description",children:"Description"}),e.jsx(_r,{id:"description",value:q.description,onChange:je=>B({...q,description:je.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(xe,{htmlFor:"base_price",children:"Base Price ($)"}),e.jsx(De,{id:"base_price",type:"number",step:"0.01",min:"0",value:q.base_price,onChange:je=>B({...q,base_price:parseFloat(je.target.value)||0}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"shipping_fee",children:"Shipping Fee ($)"}),e.jsx(De,{id:"shipping_fee",type:"number",step:"0.01",min:"0",value:q.shipping_fee,onChange:je=>B({...q,shipping_fee:parseFloat(je.target.value)||0})})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(De,{id:"sort_order",type:"number",value:q.sort_order,onChange:je=>B({...q,sort_order:parseInt(je.target.value)||0})})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ar,{id:"allow_artwork_upload",checked:q.allow_artwork_upload,onCheckedChange:je=>B({...q,allow_artwork_upload:je})}),e.jsx(xe,{htmlFor:"allow_artwork_upload",children:"Allow customer to upload artwork"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ar,{id:"requires_proof_approval",checked:q.requires_proof_approval,onCheckedChange:je=>B({...q,requires_proof_approval:je})}),e.jsx(xe,{htmlFor:"requires_proof_approval",children:"Requires proof approval"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ar,{id:"is_active",checked:q.is_active,onCheckedChange:je=>B({...q,is_active:je})}),e.jsx(xe,{htmlFor:"is_active",children:"Active"})]})]}),e.jsx(W,{type:"submit",className:"w-full",disabled:n.isPending||a.isPending,children:C?"Update Product":"Create Product"})]})]})]})]}),e.jsx(Oe,{children:t&&t.length>0?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:t.map(je=>{var qe,Me;return e.jsxs(Pe,{className:"overflow-hidden",children:[e.jsxs("div",{className:"aspect-video bg-muted relative",children:[je.images&&je.images.length>0?e.jsx("img",{src:((qe=je.images.find(ke=>ke.is_primary))==null?void 0:qe.image_url)||je.images[0].image_url,alt:je.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"}),!je.is_active&&e.jsx(Qe,{variant:"secondary",className:"absolute top-2 right-2",children:"Inactive"})]}),e.jsxs(Oe,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold mb-1",children:je.name}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:((Me=je.category)==null?void 0:Me.name)||"No category"}),e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("span",{className:"font-bold",children:["$",Number(je.base_price).toFixed(2)]}),Number(je.shipping_fee)>0&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["+$",Number(je.shipping_fee).toFixed(2)," shipping"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mb-3",children:[je.allow_artwork_upload&&e.jsx(Qe,{variant:"outline",className:"text-xs",children:"Artwork Upload"}),je.requires_proof_approval&&e.jsx(Qe,{variant:"outline",className:"text-xs",children:"Proof Required"}),je.variants&&je.variants.length>0&&e.jsxs(Qe,{variant:"outline",className:"text-xs",children:[je.variants.length," Variants"]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>ce(je),children:[e.jsx(ga,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>{L(je),N(!0)},children:[e.jsx(Xv,{className:"h-3 w-3 mr-1"}),"Images"]}),e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>{L(je),S(!0)},children:[e.jsx(mh,{className:"h-3 w-3 mr-1"}),"Variants"]}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>ae(je.id),children:e.jsx(vr,{className:"h-3 w-3 text-destructive"})})]})]})]},je.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:b,onOpenChange:N,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsx(ks,{children:e.jsxs(_s,{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:(he=I==null?void 0:I.images)==null?void 0:he.map(je=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:je.image_url,alt:"",className:"w-full aspect-square object-cover rounded-lg"}),je.is_primary&&e.jsx(Qe,{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:[!je.is_primary&&e.jsx(W,{variant:"secondary",size:"icon",onClick:async()=>{var qe;await d.mutateAsync({imageId:je.id,productId:I.id}),L({...I,images:(qe=I.images)==null?void 0:qe.map(Me=>({...Me,is_primary:Me.id===je.id}))})},disabled:d.isPending,title:"Set as primary",children:e.jsx(Gn,{className:"h-4 w-4"})}),e.jsx(W,{variant:"destructive",size:"icon",onClick:async()=>{var Me;await i.mutateAsync({id:je.id,productId:I.id});const qe=t==null?void 0:t.find(ke=>ke.id===I.id);qe&&L({...qe,images:(Me=qe.images)==null?void 0:Me.filter(ke=>ke.id!==je.id)})},disabled:i.isPending,children:e.jsx(vr,{className:"h-4 w-4"})})]})]},je.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(Xv,{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(xe,{children:"Product Video (optional)"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(De,{placeholder:"Enter video URL (YouTube, Vimeo, etc.)",value:Y,onChange:je=>J(je.target.value)}),e.jsxs(W,{onClick:ve,disabled:!Y,children:[e.jsx(yn,{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:w,onOpenChange:S,children:e.jsxs(ps,{children:[e.jsx(ks,{children:e.jsxs(_s,{children:["Manage Variants - ",I==null?void 0:I.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("form",{onSubmit:me,className:"flex gap-2",children:[e.jsx(De,{placeholder:"Variant name (e.g., 500 count)",value:U.name,onChange:je=>te({...U,name:je.target.value}),required:!0}),e.jsx(De,{type:"number",step:"0.01",placeholder:"Price adj.",value:U.price_adjustment,onChange:je=>te({...U,price_adjustment:parseFloat(je.target.value)||0}),className:"w-32"}),e.jsx(W,{type:"submit",children:"Add"})]}),e.jsxs("div",{className:"space-y-2",children:[(ge=I==null?void 0:I.variants)==null?void 0:ge.map(je=>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:je.name}),e.jsxs("span",{className:"text-sm text-muted-foreground ml-2",children:[Number(je.price_adjustment)>=0?"+":"","$",Number(je.price_adjustment).toFixed(2)]})]}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>p.mutateAsync({id:je.id,productId:I.id}),children:e.jsx(vr,{className:"h-4 w-4 text-destructive"})})]},je.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 aSs=["pending_payment","order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed","cancelled","refunded"];function iSs(){var N,w,S;const{data:t,isLoading:s}=Y4s(),r=J4s(),n=eSs(),[a,o]=k.useState(null),[l,i]=k.useState(!1),[d,u]=k.useState({status:"",notes:"",trackingNumber:"",trackingUrl:""}),[p,f]=k.useState(!1),y=C=>{o(C),u({status:C.status,notes:"",trackingNumber:C.tracking_number||"",trackingUrl:C.tracking_url||""}),i(!0)},_=async()=>{a&&(await r.mutateAsync({orderId:a.id,status:d.status,notes:d.notes,trackingNumber:d.trackingNumber,trackingUrl:d.trackingUrl,previousStatus:a.status}),i(!1))},b=async(C,A)=>{if(!a||!C.target.files||C.target.files.length===0)return;f(!0);const I=C.target.files[0],L=I.name.split(".").pop(),O=`proofs/${a.id}/${A}/${Date.now()}.${L}`;try{const{error:V}=await G.storage.from("marketplace").upload(O,I);if(V)throw V;const{data:{publicUrl:q}}=G.storage.from("marketplace").getPublicUrl(O);await n.mutateAsync({itemId:A,proofUrl:q,orderId:a.id}),pe.success("Proof uploaded successfully")}catch(V){pe.error("Failed to upload proof: "+V.message)}finally{f(!1)}};return s?e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(Ms,{className:"h-8 w-48"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(C=>e.jsx(Ms,{className:"h-16 w-full"},C))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Orders"})}),e.jsx(Oe,{children:t&&t.length>0?e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Order #"}),e.jsx(St,{children:"Customer"}),e.jsx(St,{children:"Date"}),e.jsx(St,{children:"Total"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:t.map(C=>{var A,I;return e.jsxs(Ps,{children:[e.jsx(ht,{className:"font-mono",children:C.order_number}),e.jsx(ht,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((A=C.user)==null?void 0:A.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(I=C.user)==null?void 0:I.email})]})}),e.jsx(ht,{children:vs(new Date(C.created_at),"MMM d, yyyy")}),e.jsxs(ht,{className:"font-bold",children:["$",Number(C.total).toFixed(2)]}),e.jsx(ht,{children:e.jsx(Qe,{className:qCe[C.status],children:iT[C.status]})}),e.jsx(ht,{className:"text-right",children:e.jsxs(W,{variant:"ghost",size:"sm",onClick:()=>y(C),children:[e.jsx(jn,{className:"h-4 w-4 mr-1"}),"View"]})})]},C.id)})})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No orders yet."})})]}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(ps,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsxs(_s,{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:(N=a.user)==null?void 0:N.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(w=a.user)==null?void 0:w.email})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Shipping Address"}),e.jsx("p",{children:a.shipping_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[a.shipping_address,e.jsx("br",{}),a.shipping_city,", ",a.shipping_state," ",a.shipping_zip]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Order Items"}),e.jsx("div",{className:"space-y-3",children:(S=a.items)==null?void 0:S.map(C=>e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:C.product_name}),C.variant_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:C.variant_name})]}),e.jsxs("p",{className:"font-bold",children:["$",Number(C.unit_price).toFixed(2)," x ",C.quantity]})]}),C.artwork_url&&e.jsxs("div",{className:"mt-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"Customer Artwork:"}),e.jsx("a",{href:C.artwork_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-sm",children:"View Artwork"})]}),e.jsx("div",{className:"mt-3 pt-3 border-t",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Proof Status: "}),e.jsx(Qe,{variant:C.proof_status==="approved"?"default":"secondary",children:C.proof_status||"No proof yet"})]}),C.proof_url?e.jsx("a",{href:C.proof_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-sm",children:"View Proof"}):e.jsxs("div",{children:[e.jsx("input",{type:"file",accept:"image/*,.pdf",onChange:A=>b(A,C.id),className:"hidden",id:`proof-${C.id}`,disabled:p}),e.jsx("label",{htmlFor:`proof-${C.id}`,children:e.jsx(W,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("span",{children:[e.jsx(Ra,{className:"h-4 w-4 mr-1"}),p?"Uploading...":"Upload Proof"]})})})]})]})})]},C.id))})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Subtotal"}),e.jsxs("span",{children:["$",Number(a.subtotal).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Shipping"}),e.jsxs("span",{children:["$",Number(a.shipping_total).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between font-bold text-lg mt-2",children:[e.jsx("span",{children:"Total"}),e.jsxs("span",{children:["$",Number(a.total).toFixed(2)]})]})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Update Order Status"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Status"}),e.jsxs($s,{value:d.status,onValueChange:C=>u({...d,status:C}),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsx(Bs,{children:aSs.map(C=>e.jsx(vt,{value:C,children:iT[C]},C))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Tracking Number"}),e.jsx(De,{value:d.trackingNumber,onChange:C=>u({...d,trackingNumber:C.target.value}),placeholder:"Enter tracking number"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Tracking URL"}),e.jsx(De,{value:d.trackingUrl,onChange:C=>u({...d,trackingUrl:C.target.value}),placeholder:"https://..."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Notes (optional)"}),e.jsx(_r,{value:d.notes,onChange:C=>u({...d,notes:C.target.value}),placeholder:"Add a note about this status change..."})]}),e.jsxs(W,{onClick:_,disabled:r.isPending,className:"w-full",children:[e.jsx(cl,{className:"h-4 w-4 mr-2"}),"Update Status"]})]})]}),a.status_history&&a.status_history.length>0&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Status History"}),e.jsx("div",{className:"space-y-2",children:a.status_history.map(C=>e.jsxs("div",{className:"flex justify-between text-sm p-2 bg-muted rounded",children:[e.jsxs("div",{children:[e.jsx(Qe,{variant:"outline",children:iT[C.status]}),C.notes&&e.jsx("p",{className:"text-muted-foreground mt-1",children:C.notes})]}),e.jsx("span",{className:"text-muted-foreground",children:vs(new Date(C.created_at),"MMM d, h:mm a")})]},C.id))})]})]})]})})]})}function oSs(){const[t,s]=k.useState("products"),r=wr();return e.jsx(Ds,{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(W,{variant:"outline",onClick:()=>r("/marketplace"),children:[e.jsx(Yr,{className:"h-4 w-4 mr-2"}),"View Store"]})]}),e.jsxs(ta,{value:t,onValueChange:s,children:[e.jsxs(Jn,{className:"grid w-full grid-cols-3",children:[e.jsxs(cs,{value:"products",className:"flex items-center gap-2",children:[e.jsx(cl,{className:"h-4 w-4"}),"Products"]}),e.jsxs(cs,{value:"categories",className:"flex items-center gap-2",children:[e.jsx(Mm,{className:"h-4 w-4"}),"Categories"]}),e.jsxs(cs,{value:"orders",className:"flex items-center gap-2",children:[e.jsx(lp,{className:"h-4 w-4"}),"Orders"]})]}),e.jsx(Ss,{value:"products",children:e.jsx(nSs,{})}),e.jsx(Ss,{value:"categories",children:e.jsx(rSs,{})}),e.jsx(Ss,{value:"orders",children:e.jsx(iSs,{})})]})]})})}function Klt(){return gt({queryKey:["reward-categories"],queryFn:async()=>{const{data:t,error:s}=await G.from("reward_store_categories").select("*").order("sort_order",{ascending:!0});if(s)throw s;return t}})}function lSs(t){return gt({queryKey:["reward-items",t],queryFn:async()=>{let s=G.from("reward_store_items").select(` *, category:reward_store_categories(*) `).order("created_at",{ascending:!1});const{data:r,error:n}=await s;if(n)throw n;return r}})}function cSs(t){return gt({queryKey:["active-reward-items",t],queryFn:async()=>{let s=G.from("reward_store_items").select(` *, category:reward_store_categories(*) `).eq("is_active",!0).order("created_at",{ascending:!1});t&&(s=s.eq("category_id",t));const{data:r,error:n}=await s;if(n)throw n;return r}})}function dSs(t){return gt({queryKey:["user-purchases",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("reward_store_purchases").select(` *, item:reward_store_items(*) `).eq("user_id",t).order("purchased_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function uSs(){return gt({queryKey:["all-reward-purchases"],queryFn:async()=>{const{data:t,error:s}=await G.from("reward_store_purchases").select(` *, item:reward_store_items(*) `).order("purchased_at",{ascending:!1});if(s)throw s;if(!t||t.length===0)return[];const r=[...new Set(t.map(l=>l.user_id))],{data:n,error:a}=await G.from("profiles").select("id, name, email").in("id",r);if(a)throw a;const o=new Map((n==null?void 0:n.map(l=>[l.id,l]))||[]);return t.map(l=>({...l,user:o.get(l.user_id)||null}))}})}function hSs(t){return gt({queryKey:["spendable-points",t],queryFn:async()=>{if(!t)return 0;const{data:s,error:r}=await G.from("agent_attendance_stats").select("spendable_points").eq("user_id",t).single();if(r&&r.code!=="PGRST116")throw r;return(s==null?void 0:s.spendable_points)||0},enabled:!!t})}function mSs(){const t=Qt();return Pt({mutationFn:async s=>{const{data:r,error:n}=await G.rpc("purchase_reward_item",{p_item_id:s});if(n)throw n;const a=r;if(!a.success)throw new Error(a.error||"Purchase failed");return a},onSuccess:()=>{t.invalidateQueries({queryKey:["user-purchases"]}),t.invalidateQueries({queryKey:["spendable-points"]}),t.invalidateQueries({queryKey:["active-reward-items"]}),t.invalidateQueries({queryKey:["reward-items"]}),t.invalidateQueries({queryKey:["homereel-credits"]})}})}function pSs(){const t=Qt();return Pt({mutationFn:async s=>{const{data:r,error:n}=await G.from("reward_store_categories").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function fSs(){const t=Qt();return Pt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("reward_store_categories").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function xSs(){const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("reward_store_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function gSs(){const t=Qt();return Pt({mutationFn:async s=>{const{data:r,error:n}=await G.from("reward_store_items").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-items"]}),t.invalidateQueries({queryKey:["active-reward-items"]})}})}function ySs(){const t=Qt();return Pt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("reward_store_items").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-items"]}),t.invalidateQueries({queryKey:["active-reward-items"]})}})}function vSs(){const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("reward_store_items").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-items"]}),t.invalidateQueries({queryKey:["active-reward-items"]})}})}function _Ss(t){const s=t.match(/\/storage\/v1\/object\/public\/([^/]+)\/(.+)$/);return s?{bucket:s[1],path:s[2]}:null}async function N0e(t,s){const r=_Ss(t);if(r)try{const{data:n,error:a}=await G.storage.from(r.bucket).download(r.path);if(a){console.error("Error downloading file:",a),pe.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),pe.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),pe.error("Failed to download file")}}function Zlt(){return gt({queryKey:["point-reward-settings"],queryFn:async()=>{const{data:t,error:s}=await G.from("point_reward_settings").select("*").order("action_name");if(s)throw s;return t}})}function bSs(){const t=Qt();return Pt({mutationFn:async({id:s,points:r,is_active:n})=>{const a={points:r};n!==void 0&&(a.is_active=n);const{data:o,error:l}=await G.from("point_reward_settings").update(a).eq("id",s).select().single();if(l)throw l;return o},onSuccess:()=>{t.invalidateQueries({queryKey:["point-reward-settings"]})}})}function wSs(){const{user:t}=Us(),[s,r]=k.useState("items"),[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,d]=k.useState(""),[u,p]=k.useState(""),[f,y]=k.useState(""),[_,b]=k.useState(null),[N,w]=k.useState(!1),[S,C]=k.useState(null),[A,I]=k.useState(""),[L,O]=k.useState(""),[V,q]=k.useState(null),[B,U]=k.useState(""),[te,Y]=k.useState("file"),[J,X]=k.useState(""),[ce,ie]=k.useState(""),[ae,oe]=k.useState(""),[me,ve]=k.useState(!0),[he,ge]=k.useState(null),[je,qe]=k.useState(!1),[Me,ke]=k.useState(!1),Re=k.useRef(null),Ve=k.useRef(null),{data:Ne,isLoading:Ue}=Klt(),{data:Ie,isLoading:ye}=lSs(),{data:ct,isLoading:fe}=uSs(),{data:$e,isLoading:Ye}=Zlt(),tt=pSs(),Te=fSs(),We=xSs(),Ke=gSs(),ot=ySs(),He=vSs(),Je=bSs(),[ut,mt]=k.useState({}),et=Lt=>{Lt?(l(Lt),d(Lt.name),p(Lt.description||""),y(Lt.icon||"")):(l(null),d(""),p(""),y("")),a(!0)},Ze=async()=>{if(!i.trim()){pe.error("Please enter a category name");return}try{o?(await Te.mutateAsync({id:o.id,name:i,description:u||null,icon:f||null}),pe.success("Category updated successfully")):(await tt.mutateAsync({name:i,description:u||null,icon:f||null,sort_order:((Ne==null?void 0:Ne.length)||0)+1}),pe.success("Category created successfully")),a(!1)}catch(Lt){console.error("Error saving category:",Lt),pe.error("Failed to save category")}},kt=async()=>{if(_)try{await We.mutateAsync(_),pe.success("Category deleted successfully"),b(null)}catch(Lt){console.error("Error deleting category:",Lt),pe.error("Failed to delete category")}},Ut=Lt=>{var Es;Lt?(C(Lt),I(Lt.name),O(Lt.description||""),q(Lt.category_id),U(Lt.points_cost.toString()),Y(Lt.item_type),X(Lt.file_url||""),ie(Lt.preview_image_url||""),oe(((Es=Lt.max_quantity)==null?void 0:Es.toString())||""),ve(Lt.is_active)):(C(null),I(""),O(""),q(null),U(""),Y("file"),X(""),ie(""),oe(""),ve(!0)),w(!0)},Nt=async(Lt,Es)=>{Es==="file"?qe(!0):ke(!0);try{const fr=Lt.name.split(".").pop(),Hs=`${Date.now()}-${Math.random().toString(36).substring(7)}.${fr}`,mr=`${Es==="file"?"items":"previews"}/${Hs}`,{error:an}=await G.storage.from("reward-store").upload(mr,Lt);if(an)throw an;const{data:{publicUrl:Cr}}=G.storage.from("reward-store").getPublicUrl(mr);Es==="file"?X(Cr):ie(Cr),pe.success("File uploaded successfully")}catch(fr){console.error("Error uploading file:",fr),pe.error("Failed to upload file")}finally{Es==="file"?qe(!1):ke(!1)}},es=async()=>{if(!A.trim()){pe.error("Please enter an item name");return}if(!B||parseInt(B)<0){pe.error("Please enter a valid points cost");return}try{const Lt={name:A,description:L||null,category_id:V,points_cost:parseInt(B),item_type:te,file_url:J||null,preview_image_url:ce||null,max_quantity:ae?parseInt(ae):null,current_quantity:ae?parseInt(ae):null,is_active:me,created_by:t==null?void 0:t.id};S?(await ot.mutateAsync({id:S.id,...Lt,current_quantity:S.max_quantity!==(ae?parseInt(ae):null)?ae?parseInt(ae):null:S.current_quantity}),pe.success("Item updated successfully")):(await Ke.mutateAsync(Lt),pe.success("Item created successfully")),w(!1)}catch(Lt){console.error("Error saving item:",Lt),pe.error("Failed to save item")}},ds=async()=>{if(he)try{await He.mutateAsync(he),pe.success("Item deleted successfully"),ge(null)}catch(Lt){console.error("Error deleting item:",Lt),pe.error("Failed to delete item")}},js=async(Lt,Es)=>{const fr=ut[Lt];if(fr===void 0||fr===Es.toString())return;const Hs=parseInt(fr);if(isNaN(Hs)||Hs<0){pe.error("Please enter a valid positive number");return}try{await Je.mutateAsync({id:Lt,points:Hs}),pe.success("Points updated successfully"),mt(mr=>{const an={...mr};return delete an[Lt],an})}catch(mr){console.error("Error updating points:",mr),pe.error("Failed to update points")}};return Ue||ye||fe||Ye?e.jsx(Ds,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ms,{className:"h-8 w-64"}),e.jsx(Ms,{className:"h-96"})]})}):e.jsxs(Ds,{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(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(cl,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total Items"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(Ie==null?void 0:Ie.length)||0}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(Ie==null?void 0:Ie.filter(Lt=>Lt.is_active).length)||0," active"]})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Mm,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Categories"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(Ne==null?void 0:Ne.length)||0})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Gn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Avg. Cost"})]}),e.jsxs("p",{className:"text-2xl font-bold",children:[Ie&&Ie.length>0?Math.round(Ie.reduce((Lt,Es)=>Lt+Es.points_cost,0)/Ie.length):0," pts"]})]})})]}),e.jsxs(ta,{value:s,onValueChange:r,children:[e.jsxs(Jn,{children:[e.jsx(cs,{value:"items",children:"Items"}),e.jsx(cs,{value:"categories",children:"Categories"}),e.jsx(cs,{value:"purchases",children:"Purchases"}),e.jsx(cs,{value:"point-settings",children:"Point Settings"})]}),e.jsx(Ss,{value:"items",className:"mt-4",children:e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Store Items"}),e.jsx(dr,{children:"Manage rewards that agents can purchase"})]}),e.jsxs(W,{onClick:()=>Ut(),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Item"]})]}),e.jsx(Oe,{children:!Ie||Ie.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(hi,{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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Item"}),e.jsx(St,{children:"Category"}),e.jsx(St,{className:"text-center",children:"Cost"}),e.jsx(St,{className:"text-center",children:"Type"}),e.jsx(St,{className:"text-center",children:"Quantity"}),e.jsx(St,{className:"text-center",children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:Ie.map(Lt=>e.jsxs(Ps,{children:[e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Lt.preview_image_url?e.jsx("img",{src:Lt.preview_image_url,alt:Lt.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(hi,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:Lt.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:Lt.description||"No description"})]})]})}),e.jsx(ht,{children:Lt.category?e.jsx(Qe,{variant:"outline",children:Lt.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(ht,{className:"text-center",children:e.jsxs(Qe,{variant:"secondary",className:"font-bold",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),Lt.points_cost]})}),e.jsx(ht,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[Lt.item_type==="file"?e.jsx(vn,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(vo,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs capitalize",children:Lt.item_type})]})}),e.jsx(ht,{className:"text-center",children:Lt.max_quantity!==null?e.jsxs("span",{className:Lt.current_quantity===0?"text-red-500":"",children:[Lt.current_quantity,"/",Lt.max_quantity]}):e.jsx("span",{className:"text-muted-foreground",children:"Unlimited"})}),e.jsx(ht,{className:"text-center",children:e.jsx(Qe,{variant:Lt.is_active?"default":"secondary",children:Lt.is_active?"Active":"Inactive"})}),e.jsx(ht,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>Ut(Lt),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>ge(Lt.id),children:e.jsx(vr,{className:"h-4 w-4 text-destructive"})})]})})]},Lt.id))})]})})]})}),e.jsx(Ss,{value:"categories",className:"mt-4",children:e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Categories"}),e.jsx(dr,{children:"Organize your store items into categories"})]}),e.jsxs(W,{onClick:()=>et(),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(Oe,{children:!Ne||Ne.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Mm,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No categories yet. Add your first category!"})]}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{className:"text-center",children:"Items"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:Ne.map(Lt=>e.jsxs(Ps,{children:[e.jsxs(ht,{className:"font-medium",children:[Lt.icon&&e.jsx("span",{className:"mr-2",children:Lt.icon}),Lt.name]}),e.jsx(ht,{className:"text-muted-foreground",children:Lt.description||"—"}),e.jsx(ht,{className:"text-center",children:(Ie==null?void 0:Ie.filter(Es=>Es.category_id===Lt.id).length)||0}),e.jsx(ht,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>et(Lt),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>b(Lt.id),children:e.jsx(vr,{className:"h-4 w-4 text-destructive"})})]})})]},Lt.id))})]})})]})}),e.jsx(Ss,{value:"purchases",className:"mt-4",children:e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(lp,{className:"h-5 w-5"}),"Purchase History"]}),e.jsx(dr,{children:"View all reward redemptions by agents"})]}),e.jsx(Oe,{children:!ct||ct.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(lp,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No purchases yet."})]}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Date"}),e.jsx(St,{children:"Agent"}),e.jsx(St,{children:"Item"}),e.jsx(St,{className:"text-center",children:"Points Spent"})]})}),e.jsx(Rn,{children:ct.map(Lt=>{var Es,fr,Hs,mr;return e.jsxs(Ps,{children:[e.jsx(ht,{className:"text-muted-foreground",children:vs(new Date(Lt.purchased_at),"MMM d, yyyy 'at' h:mm a")}),e.jsx(ht,{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(Ai,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Es=Lt.user)==null?void 0:Es.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:((fr=Lt.user)==null?void 0:fr.email)||"—"})]})]})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[(Hs=Lt.item)!=null&&Hs.preview_image_url?e.jsx("img",{src:Lt.item.preview_image_url,alt:Lt.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(hi,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{children:((mr=Lt.item)==null?void 0:mr.name)||"Deleted item"})]})}),e.jsx(ht,{className:"text-center",children:e.jsxs(Qe,{variant:"secondary",className:"font-bold",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),Lt.points_spent]})})]},Lt.id)})})]})})]})})]})]}),e.jsx(fs,{open:n,onOpenChange:a,children:e.jsxs(ps,{children:[e.jsxs(ks,{children:[e.jsx(_s,{children:o?"Edit Category":"Add Category"}),e.jsx(Ir,{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(xe,{htmlFor:"categoryName",children:"Name"}),e.jsx(De,{id:"categoryName",value:i,onChange:Lt=>d(Lt.target.value),placeholder:"e.g., Templates, Resources"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"categoryDescription",children:"Description"}),e.jsx(_r,{id:"categoryDescription",value:u,onChange:Lt=>p(Lt.target.value),placeholder:"Optional description..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"categoryIcon",children:"Icon (emoji)"}),e.jsx(De,{id:"categoryIcon",value:f,onChange:Lt=>y(Lt.target.value),placeholder:"e.g., 📄, 🎁"})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(W,{onClick:Ze,disabled:tt.isPending||Te.isPending,children:tt.isPending||Te.isPending?"Saving...":"Save"})]})]})}),e.jsx(fs,{open:N,onOpenChange:w,children:e.jsxs(ps,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(ks,{children:[e.jsx(_s,{children:S?"Edit Item":"Add Item"}),e.jsx(Ir,{children:S?"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(xe,{htmlFor:"itemName",children:"Name *"}),e.jsx(De,{id:"itemName",value:A,onChange:Lt=>I(Lt.target.value),placeholder:"e.g., Premium Template Pack"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"itemDescription",children:"Description"}),e.jsx(_r,{id:"itemDescription",value:L,onChange:Lt=>O(Lt.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(xe,{htmlFor:"itemCategory",children:"Category"}),e.jsxs($s,{value:V||"none",onValueChange:Lt=>q(Lt==="none"?null:Lt),children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select category"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"none",children:"No category"}),Ne==null?void 0:Ne.map(Lt=>e.jsxs(vt,{value:Lt.id,children:[Lt.icon&&`${Lt.icon} `,Lt.name]},Lt.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"itemPointsCost",children:"Points Cost *"}),e.jsx(De,{id:"itemPointsCost",type:"number",min:"0",value:B,onChange:Lt=>U(Lt.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(xe,{htmlFor:"itemType",children:"Type"}),e.jsxs($s,{value:te,onValueChange:Y,children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"file",children:"File Download"}),e.jsx(vt,{value:"link",children:"External Link"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"itemMaxQuantity",children:"Max Quantity"}),e.jsx(De,{id:"itemMaxQuantity",type:"number",min:"1",value:ae,onChange:Lt=>oe(Lt.target.value),placeholder:"Leave empty for unlimited"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"File / Link URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{value:J,onChange:Lt=>X(Lt.target.value),placeholder:te==="file"?"Upload a file or paste URL":"Paste external link"}),te==="file"&&e.jsxs(e.Fragment,{children:[e.jsx(W,{type:"button",variant:"outline",size:"icon",onClick:()=>{var Lt;return(Lt=Re.current)==null?void 0:Lt.click()},disabled:je,children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx("input",{ref:Re,type:"file",className:"hidden",onChange:Lt=>{var fr;const Es=(fr=Lt.target.files)==null?void 0:fr[0];Es&&Nt(Es,"file")}})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Preview Image"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{value:ce,onChange:Lt=>ie(Lt.target.value),placeholder:"Upload an image or paste URL"}),e.jsx(W,{type:"button",variant:"outline",size:"icon",onClick:()=>{var Lt;return(Lt=Ve.current)==null?void 0:Lt.click()},disabled:Me,children:e.jsx(qo,{className:"h-4 w-4"})}),e.jsx("input",{ref:Ve,type:"file",accept:"image/*",className:"hidden",onChange:Lt=>{var fr;const Es=(fr=Lt.target.files)==null?void 0:fr[0];Es&&Nt(Es,"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(Ar,{id:"itemIsActive",checked:me,onCheckedChange:ve}),e.jsx(xe,{htmlFor:"itemIsActive",children:"Active (visible to agents)"})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),e.jsx(W,{onClick:es,disabled:Ke.isPending||ot.isPending,children:Ke.isPending||ot.isPending?"Saving...":"Save"})]})]})}),e.jsx(Rl,{open:!!_,onOpenChange:()=>b(null),children:e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Delete Category"}),e.jsx(bl,{children:"Are you sure you want to delete this category? Items in this category will become uncategorized."})]}),e.jsxs(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:kt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),e.jsx(Rl,{open:!!he,onOpenChange:()=>ge(null),children:e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Delete Item"}),e.jsx(bl,{children:"Are you sure you want to delete this item? This action cannot be undone."})]}),e.jsxs(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:ds,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),s==="point-settings"&&e.jsxs(Pe,{className:"mt-4",children:[e.jsx(Dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(So,{className:"h-5 w-5"}),e.jsxs("div",{children:[e.jsx(zt,{children:"Point Reward Settings"}),e.jsx(dr,{children:"Configure how many points agents earn for various actions. Adjust these values to run double-points promotions."})]})]})}),e.jsx(Oe,{children:!$e||$e.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(So,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No point settings configured."})]}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Action"}),e.jsx(St,{children:"Description"}),e.jsx(St,{className:"text-center w-32",children:"Points"}),e.jsx(St,{className:"text-right w-24",children:"Save"})]})}),e.jsx(Rn,{children:$e.map(Lt=>e.jsxs(Ps,{children:[e.jsx(ht,{children:e.jsx("p",{className:"font-medium",children:Lt.action_name})}),e.jsx(ht,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:Lt.description})}),e.jsx(ht,{className:"text-center",children:e.jsx(De,{type:"number",min:"0",className:"w-20 mx-auto text-center",value:ut[Lt.id]??Lt.points.toString(),onChange:Es=>mt(fr=>({...fr,[Lt.id]:Es.target.value}))})}),e.jsx(ht,{className:"text-right",children:e.jsx(W,{size:"sm",variant:"outline",disabled:ut[Lt.id]===void 0||ut[Lt.id]===Lt.points.toString()||Je.isPending,onClick:()=>js(Lt.id,Lt.points),children:e.jsx(bc,{className:"h-4 w-4"})})})]},Lt.id))})]})})]})]})}const m9e=()=>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"})]}),p9e=[{value:"template",label:"Templates"},{value:"brand",label:"Brand Assets"},{value:"listing",label:"Listing Assets"},{value:"social",label:"Social Media"},{value:"general",label:"General"}];function jSs(){const t=Qt(),[s,r]=k.useState(!1),[n,a]=k.useState(!1),[o,l]=k.useState(!1),[i,d]=k.useState({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""}),{data:u,isLoading:p}=gt({queryKey:["canva-integration"],queryFn:async()=>{const{data:C,error:A}=await G.from("canva_integration").select("*").eq("is_active",!0).maybeSingle();if(A)throw A;return C}}),{data:f}=gt({queryKey:["brokerages-list"],queryFn:async()=>{const{data:C,error:A}=await G.from("brokerages").select("id, name").order("name");if(A)throw A;return C}}),{data:y}=gt({queryKey:["canva-brokerage-folders"],queryFn:async()=>{const{data:C,error:A}=await G.from("canva_brokerage_folders").select("*, brokerages(name)").order("sort_order");if(A)throw A;return C}}),_=async()=>{var C;r(!0);try{const{data:A}=await G.auth.getSession(),I=(C=A==null?void 0:A.session)==null?void 0:C.access_token;if(!I)throw new Error("Not authenticated");const V=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/canva-oauth",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({action:"get_auth_url"})}),q=await V.json();if(!V.ok||q!=null&&q.error)throw new Error((q==null?void 0:q.error)||"Failed to get authorization URL");if(q!=null&&q.authUrl){localStorage.setItem("canva_code_verifier",q.codeVerifier),localStorage.setItem("canva_oauth_state",q.state);const B=window.open(q.authUrl,"canva-oauth","width=600,height=700,scrollbars=yes,resizable=yes");if(!B){pe.error("Popup was blocked. Please allow popups for this site and try again."),r(!1);return}const U=Y=>{var J,X;Y.origin===window.location.origin&&(((J=Y.data)==null?void 0:J.type)==="canva-oauth-success"?(window.removeEventListener("message",U),pe.success("Canva connected successfully!"),t.invalidateQueries({queryKey:["canva-integration"]}),r(!1)):((X=Y.data)==null?void 0:X.type)==="canva-oauth-error"&&(window.removeEventListener("message",U),pe.error("Canva connection failed: "+(Y.data.error||"Unknown error")),r(!1)))};window.addEventListener("message",U);const te=setInterval(()=>{B.closed&&(clearInterval(te),window.removeEventListener("message",U),t.invalidateQueries({queryKey:["canva-integration"]}),r(!1))},500)}else throw new Error("Failed to get authorization URL")}catch(A){console.error("Canva connect error:",A);const I=(A==null?void 0:A.message)||"";I.includes("CANVA_CLIENT_ID")?pe.error("Canva app credentials not configured yet."):pe.error(I||"Failed to start Canva connection"),r(!1)}},b=Pt({mutationFn:async C=>{var B;const{data:A}=await G.auth.getSession(),I=(B=A==null?void 0:A.session)==null?void 0:B.access_token;if(!I)throw new Error("Not authenticated");const V=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/canva-oauth",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({action:"disconnect",integrationId:C})}),q=await V.json();if(!V.ok||q!=null&&q.error)throw new Error((q==null?void 0:q.error)||"Failed to disconnect")},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-integration"]}),pe.success("Canva disconnected")},onError:C=>{pe.error(C.message||"Failed to disconnect Canva")}}),N=Pt({mutationFn:async C=>{const{error:A}=await G.from("canva_brokerage_folders").insert({brokerage_id:C.brokerage_id,folder_id:C.folder_id.trim(),folder_name:C.folder_name.trim(),folder_type:C.folder_type,description:C.description.trim()||null,sort_order:(y==null?void 0:y.length)||0});if(A)throw A},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-brokerage-folders"]}),pe.success("Folder added"),l(!1),d({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""})},onError:()=>pe.error("Failed to add folder")}),w=Pt({mutationFn:async C=>{const{error:A}=await G.from("canva_brokerage_folders").delete().eq("id",C);if(A)throw A},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-brokerage-folders"]}),pe.success("Folder removed")},onError:()=>pe.error("Failed to remove folder")}),S=!!u;return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Dt,{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(m9e,{})}),e.jsxs("div",{children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:["Canva Connect",S&&e.jsx(Qe,{variant:"default",className:"text-xs",children:"Connected"}),e.jsx(Qe,{variant:"outline",className:"text-xs",children:"Admin Only"})]}),e.jsx(dr,{children:"Auto-share brokerage asset folders with agents when they connect their Canva accounts."})]})]})})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(si,{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(si,{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(si,{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"})]}),S?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(Rl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(vr,{className:"h-4 w-4"})})}),e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Disconnect Canva?"}),e.jsx(bl,{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(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:()=>b.mutate(u.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]}),e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>a(!n),className:"w-full flex items-center justify-between p-3 text-sm font-medium hover:bg-muted transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mm,{className:"h-4 w-4 text-primary"}),"Brokerage Folder Mappings",y&&y.length>0&&e.jsx(Qe,{variant:"secondary",className:"text-xs",children:y.length})]}),n?e.jsx(af,{className:"h-4 w-4"}):e.jsx(Bi,{className:"h-4 w-4"})]}),n&&e.jsxs("div",{className:"border-t p-3 space-y-2",children:[y&&y.length>0?y.map(C=>{var A,I;return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-md bg-muted/50 text-sm",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium truncate",children:C.folder_name}),e.jsx(Qe,{variant:"outline",className:"text-xs shrink-0",children:((A=p9e.find(L=>L.value===C.folder_type))==null?void 0:A.label)||C.folder_type})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(I=C.brokerages)==null?void 0:I.name," · ID: ",e.jsx("span",{className:"font-mono",children:C.folder_id})]})]}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive shrink-0 ml-2",onClick:()=>w.mutate(C.id),children:e.jsx(kr,{className:"h-3.5 w-3.5"})})]},C.id)}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-2",children:"No folders mapped yet"}),e.jsxs(W,{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(W,{className:"mt-4",onClick:_,disabled:s||p,children:[s?e.jsx(Zi,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx("div",{className:"mr-2",children:e.jsx(m9e,{})}),"Connect Canva",e.jsx(Wa,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{children:[e.jsx(ks,{children:e.jsx(_s,{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(xe,{children:"Brokerage"}),e.jsxs($s,{value:i.brokerage_id,onValueChange:C=>d(A=>({...A,brokerage_id:C})),children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select a brokerage…"})}),e.jsx(Bs,{children:f==null?void 0:f.map(C=>e.jsx(vt,{value:C.id,children:C.name},C.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Canva Folder ID"}),e.jsx(De,{placeholder:"e.g. FABCdef123456",value:i.folder_id,onChange:C=>d(A=>({...A,folder_id:C.target.value}))}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Found in the Canva folder URL: canva.com/folder/",e.jsx("strong",{children:"FOLDER_ID"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Folder Display Name"}),e.jsx(De,{placeholder:"e.g. Brand Templates 2024",value:i.folder_name,onChange:C=>d(A=>({...A,folder_name:C.target.value}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Folder Type"}),e.jsxs($s,{value:i.folder_type,onValueChange:C=>d(A=>({...A,folder_type:C})),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsx(Bs,{children:p9e.map(C=>e.jsx(vt,{value:C.value,children:C.label},C.value))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(xe,{children:["Description ",e.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),e.jsx(De,{placeholder:"What's in this folder?",value:i.description,onChange:C=>d(A=>({...A,description:C.target.value}))})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(W,{onClick:()=>N.mutate(i),disabled:!i.brokerage_id||!i.folder_id||!i.folder_name||N.isPending,children:[N.isPending?e.jsx(Zi,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Add Folder"]})]})]})})]})}function NSs(){return e.jsx(Ds,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(Hu,{title:"Integrations",description:"Manage platform-level service connections"}),e.jsx(jSs,{}),e.jsx(Ult,{})]})})}const kSs={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 wI(t,s=18,r=10){return t.length<=s+r+3?t:`${t.slice(0,s)}…${t.slice(-r)}`}function SSs(){var te,Y,J,X,ce;const t=Qt(),[s,r]=k.useState("Test Push"),[n,a]=k.useState("Testing web push notification"),[o,l]=k.useState("/community"),[i,d]=k.useState(!1),[u,p]=k.useState(!1),[f,y]=k.useState({isSupported:typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window}),[_,b]=k.useState(null),[N,w]=k.useState(null),{data:S,isLoading:C}=gt({queryKey:["push-notification-settings"],queryFn:async()=>{const{data:ie,error:ae}=await G.from("push_notification_settings").select("*").order("setting_key");if(ae)throw ae;return ie}}),{data:A,isLoading:I}=gt({queryKey:["push-subscription-stats"],queryFn:async()=>{const{count:ie,error:ae}=await G.from("push_subscriptions").select("*",{count:"exact",head:!0});if(ae)throw ae;return{totalSubscriptions:ie||0}}}),L=Pt({mutationFn:async({settingKey:ie,isEnabled:ae})=>{const{error:oe}=await G.from("push_notification_settings").update({is_enabled:ae}).eq("setting_key",ie);if(oe)throw oe},onSuccess:()=>{t.invalidateQueries({queryKey:["push-notification-settings"]}),pe.success("Notification setting updated")},onError:ie=>{pe.error("Failed to update setting: "+ie.message)}}),O=k.useMemo(()=>{var ie,ae;return f.isSupported?`perm=${f.permission??"unknown"} · controller=${f.controllerPresent?"yes":"no"} · sw=${((ie=f.serviceWorker)==null?void 0:ie.activeState)??"unknown"} · sub=${(ae=f.subscription)!=null&&ae.endpoint?"yes":"no"}`:"Push not supported in this browser."},[f]);k.useEffect(()=>{let ie=!0;const ae=async()=>{var he,ge,je,qe,Me,ke,Re;const me="serviceWorker"in navigator&&"PushManager"in window,ve={isSupported:me,permission:typeof Notification<"u"?Notification.permission:void 0,controllerPresent:!!((he=navigator.serviceWorker)!=null&&he.controller)};if(!me){ie&&y(ve);return}try{const{data:Ve,error:Ne}=await G.functions.invoke("get-vapid-public-key",{body:{}});if(Ne)throw Ne;ve.vapidPublicKey=Ve==null?void 0:Ve.vapidPublicKey;const Ie=(await navigator.serviceWorker.getRegistrations()).find(ye=>{var fe,$e,Ye;return(((fe=ye.active)==null?void 0:fe.scriptURL)||(($e=ye.waiting)==null?void 0:$e.scriptURL)||((Ye=ye.installing)==null?void 0:Ye.scriptURL)||"").includes("/sw.js")});if(Ie){ve.pushWorkerScriptUrl=((ge=Ie.active)==null?void 0:ge.scriptURL)||((je=Ie.waiting)==null?void 0:je.scriptURL)||((qe=Ie.installing)==null?void 0:qe.scriptURL),ve.serviceWorker={scope:Ie.scope,activeState:(Me=Ie.active)==null?void 0:Me.state};const ye=await Ie.pushManager.getSubscription();if(ye){const ct=ye.toJSON();ve.subscription={endpoint:ct.endpoint,p256dh:(ke=ct.keys)==null?void 0:ke.p256dh,auth:(Re=ct.keys)==null?void 0:Re.auth}}}}catch(Ve){ve.error=(Ve==null?void 0:Ve.message)||String(Ve)}ie&&y(ve)};ae();const oe=window.setInterval(ae,4e3);return()=>{ie=!1,window.clearInterval(oe)}},[]);const V=async()=>{if(typeof Notification>"u"){pe.error("Notifications API not available in this browser.");return}try{if(Notification.permission!=="granted"&&await Notification.requestPermission()!=="granted"){pe.error("Notification permission not granted.");return}new Notification("Local notification test",{body:"If you see this, OS/browser notifications can display."}),pe.success("Triggered a local notification (not push).")}catch(ie){pe.error(`Local notification failed: ${(ie==null?void 0:ie.message)||String(ie)}`)}},q=async()=>{d(!0),b(null);try{const{data:ie,error:ae}=await G.functions.invoke("send-push-notification",{body:{title:s,body:n,url:o}});if(ae)throw ae;b({sent:ie==null?void 0:ie.sent,failed:ie==null?void 0:ie.failed,expiredCleaned:ie==null?void 0:ie.expiredCleaned,vapidPublicKey:ie==null?void 0:ie.vapidPublicKey}),(ie==null?void 0:ie.sent)>0?pe.success(`Test notification sent to ${ie.sent} subscriber(s)`):(ie==null?void 0:ie.failed)>0?pe.warning(`Notification failed for ${ie.failed} subscriber(s). ${ie.expired||0} expired subscriptions cleaned up.`):pe.info("No active subscriptions to send to")}catch(ie){console.error("Error sending test notification:",ie),b({error:(ie==null?void 0:ie.message)||String(ie)}),pe.error("Failed to send test notification: "+(ie.message||"Unknown error"))}finally{d(!1)}},B=async()=>{p(!0),w(null);try{const{data:ie,error:ae}=await G.functions.invoke("generate-vapid-keys",{body:{}});if(ae)throw ae;const oe=ie==null?void 0:ie.publicKey,me=ie==null?void 0:ie.privateKey;if(!oe||!me)throw new Error("generate-vapid-keys did not return keys");w({publicKey:oe,privateKey:me}),pe.success("Generated new VAPID keys. Update backend secrets, then clear + re-subscribe.")}catch(ie){console.error("Error generating VAPID keys:",ie),pe.error("Failed to generate VAPID keys: "+((ie==null?void 0:ie.message)||"Unknown error"))}finally{p(!1)}},U=Pt({mutationFn:async()=>{const{error:ie}=await G.from("push_subscriptions").delete().neq("id","00000000-0000-0000-0000-000000000000");if(ie)throw ie},onSuccess:()=>{pe.success("All subscriptions cleared. Users will need to re-enable notifications."),t.invalidateQueries({queryKey:["push-subscription-stats"]})},onError:ie=>{pe.error("Failed to clear subscriptions: "+ie.message)}});return e.jsx(Ds,{title:"Notification Settings",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Hu,{title:"Notification Settings",description:"Manage push notifications and test the notification system"}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(ir,{className:"h-5 w-5"}),"Push Notification Subscribers"]}),e.jsx(dr,{children:"Current active push notification subscriptions"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"text-4xl font-bold",children:I?"...":(A==null?void 0:A.totalSubscriptions)||0}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"active subscriptions"})]})})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(So,{className:"h-5 w-5"}),"Notification Types"]}),e.jsx(dr,{children:"Control which types of push notifications are sent to users"})]}),e.jsx(Oe,{children:C?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading settings..."}):e.jsx("div",{className:"space-y-4",children:S==null?void 0:S.map(ie=>{const ae=kSs[ie.setting_key]||{label:ie.setting_key,icon:"🔔"};return e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-2xl",children:ae.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:ae.label}),e.jsx("div",{className:"text-sm text-muted-foreground",children:ie.description})]})]}),e.jsx(Ar,{checked:ie.is_enabled,onCheckedChange:oe=>L.mutate({settingKey:ie.setting_key,isEnabled:oe}),disabled:L.isPending})]},ie.id)})})})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Sm,{className:"h-5 w-5"}),"Send Test Notification"]}),e.jsx(dr,{children:"Send a test push notification to all subscribed users"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 text-sm",children:[e.jsx("div",{className:"font-medium",children:"Client push debug"}),e.jsx("div",{className:"mt-1 text-muted-foreground",children:O}),f.error&&e.jsx("div",{className:"mt-2 text-destructive",children:f.error}),e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Backend VAPID public key"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:f.vapidPublicKey?wI(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: ",(te=f.serviceWorker)!=null&&te.scope?wI(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?wI(f.subscription.endpoint,40,12):"none"]}),e.jsxs("div",{children:["p256dh: ",(X=f.subscription)!=null&&X.p256dh?wI(f.subscription.p256dh,22,10):"none"]}),e.jsxs("div",{children:["auth: ",(ce=f.subscription)!=null&&ce.auth?wI(f.subscription.auth,22,10):"none"]})]})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(W,{variant:"outline",onClick:V,children:"Local notification test"}),e.jsx(W,{variant:"outline",onClick:()=>window.location.reload(),children:"Reload page"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"test-title",children:"Notification Title"}),e.jsx(De,{id:"test-title",value:s,onChange:ie=>r(ie.target.value),placeholder:"Enter notification title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"test-body",children:"Notification Body"}),e.jsx(_r,{id:"test-body",value:n,onChange:ie=>a(ie.target.value),placeholder:"Enter notification message",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"test-url",children:"Click URL (optional)"}),e.jsx(De,{id:"test-url",value:o,onChange:ie=>l(ie.target.value),placeholder:"/community or full URL"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Where users will be taken when they click the notification"})]}),e.jsxs(W,{onClick:q,disabled:i||!s||!n,className:"w-full sm:w-auto",children:[e.jsx(_n,{className:"h-4 w-4 mr-2"}),i?"Sending...":"Send Test Notification"]}),_&&e.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 text-sm",children:[e.jsx("div",{className:"font-medium",children:"Last send debug"}),_.error?e.jsxs("div",{className:"mt-1 text-destructive",children:["Error: ",_.error]}):e.jsxs("div",{className:"mt-1 space-y-1 text-muted-foreground",children:[e.jsxs("div",{children:["Result: ",_.sent??0," sent, ",_.failed??0," failed, ",_.expiredCleaned??0," expired cleaned"]}),_.vapidPublicKey?e.jsxs("div",{className:"break-all",children:["Backend VAPID public key: ",e.jsx("span",{className:"font-mono",children:_.vapidPublicKey})]}):e.jsx("div",{children:"Backend VAPID public key: (not returned)"})]})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2 text-destructive",children:[e.jsx(vr,{className:"h-5 w-5"}),"Subscription Maintenance"]}),e.jsx(dr,{children:"Clear all push subscriptions if VAPID keys were changed or subscriptions are invalid"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"If you've recently updated the VAPID keys, existing subscriptions will no longer work. Use this to clear all subscriptions so users can re-subscribe with the new keys."}),e.jsxs(W,{variant:"destructive",onClick:()=>U.mutate(),disabled:U.isPending,children:[e.jsx(vr,{className:"h-4 w-4 mr-2"}),U.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(W,{variant:"outline",onClick:B,disabled:u,children:u?"Generating…":"Generate VAPID keys"})}),N&&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:N.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:N.privateKey})]})]})]})]})]})]})})}function CSs(){const{toast:t}=ja(),[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:d,handleSort:u,sortData:p}=sO("presentation_count","desc"),f=p(s,{name:b=>{var N;return((N=b.name)==null?void 0:N.toLowerCase())||""},presentations:b=>b.presentation_count,views:b=>b.total_views,leads:b=>b.total_leads,cta_clicks:b=>b.total_cta_clicks,conversion:b=>b.total_views>0?b.total_leads/b.total_views*100:0});k.useEffect(()=>{y()},[]);const y=async()=>{try{l(!0);const{data:b,error:N}=await G.rpc("get_admin_presentation_stats");if(N)throw N;if(!b||b.length===0){l(!1);return}const w=b.map(L=>L.owner_user_id),{data:S,error:C}=await G.from("profiles").select("id, name, email, avatar_url").in("id",w);if(C)throw C;const A=new Map((S==null?void 0:S.map(L=>[L.id,L]))||[]),I=b.map(L=>{const O=A.get(L.owner_user_id);return{owner_user_id:L.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(L.presentation_count),total_views:Number(L.total_views),total_leads:Number(L.total_leads),total_cta_clicks:Number(L.total_cta_clicks)}});r(I),r(I),a({totalPresentations:I.reduce((L,O)=>L+O.presentation_count,0),totalViews:I.reduce((L,O)=>L+O.total_views,0),totalLeads:I.reduce((L,O)=>L+O.total_leads,0),totalCtaClicks:I.reduce((L,O)=>L+O.total_cta_clicks,0),agentsUsing:I.length})}catch(b){console.error("Error loading presentation stats:",b),t({title:"Error",description:"Failed to load presentation analytics",variant:"destructive"})}finally{l(!1)}},_=[{label:"Agents Using",value:n.agentsUsing,icon:ir,color:"text-blue-600"},{label:"Total Presentations",value:n.totalPresentations,icon:Pg,color:"text-violet-600"},{label:"Total Views",value:n.totalViews,icon:jn,color:"text-emerald-600"},{label:"Total Leads",value:n.totalLeads,icon:Jo,color:"text-amber-600"},{label:"CTA Clicks",value:n.totalCtaClicks,icon:Tm,color:"text-rose-600"}];return e.jsx(Ds,{title:"Presentation Analytics",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Presentation Analytics"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Track Smart Presentations usage and engagement across all agents"})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:_.map(b=>e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:b.label}),e.jsx(b.icon,{className:`h-4 w-4 ${b.color}`})]}),e.jsx(Oe,{children:o?e.jsx(Ms,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:b.value.toLocaleString()})})]},b.label))}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Qo,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(Oe,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((b,N)=>e.jsx(Ms,{className:"h-12 w-full"},N))}):s.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No presentations created yet."}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(Zo,{sortKey:"name",currentSortKey:i,currentDirection:d,onSort:u,children:"Agent"}),e.jsx(Zo,{sortKey:"presentations",currentSortKey:i,currentDirection:d,onSort:u,className:"text-center",children:"Presentations"}),e.jsx(Zo,{sortKey:"views",currentSortKey:i,currentDirection:d,onSort:u,className:"text-center",children:"Views"}),e.jsx(Zo,{sortKey:"leads",currentSortKey:i,currentDirection:d,onSort:u,className:"text-center",children:"Leads"}),e.jsx(Zo,{sortKey:"cta_clicks",currentSortKey:i,currentDirection:d,onSort:u,className:"text-center",children:"CTA Clicks"}),e.jsx(Zo,{sortKey:"conversion",currentSortKey:i,currentDirection:d,onSort:u,className:"text-center",children:"Conversion"})]})}),e.jsx(Rn,{children:f.map(b=>{var w,S;const N=b.total_views>0?(b.total_leads/b.total_views*100).toFixed(1):"0.0";return e.jsxs(Ps,{children:[e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-muted flex items-center justify-center overflow-hidden",children:b.avatar_url?e.jsx("img",{src:b.avatar_url,alt:"",className:"h-full w-full object-cover"}):e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:((S=(w=b.name)==null?void 0:w.charAt(0))==null?void 0:S.toUpperCase())||"?"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:b.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:b.email})]})]})}),e.jsx(ht,{className:"text-center font-medium",children:b.presentation_count}),e.jsx(ht,{className:"text-center",children:b.total_views.toLocaleString()}),e.jsx(ht,{className:"text-center",children:b.total_leads>0?e.jsx(Qe,{variant:"secondary",children:b.total_leads}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(ht,{className:"text-center",children:b.total_cta_clicks}),e.jsx(ht,{className:"text-center",children:e.jsxs("span",{className:Number(N)>0?"text-emerald-600 font-medium":"text-muted-foreground",children:[N,"%"]})})]},b.owner_user_id)})})]})})]})]})})}function MSs(){const{toast:t}=ja(),[s,r]=k.useState([]),[n,a]=k.useState({totalOpenHouses:0,totalVisitors:0,totalLeads:0,activeOpenHouses:0,agentsUsing:0}),[o,l]=k.useState(!0);k.useEffect(()=>{i()},[]);const i=async()=>{try{l(!0);const{data:u,error:p}=await G.rpc("get_admin_guest_book_stats");if(p)throw p;if(!u||u.length===0){l(!1);return}const f=u.map(w=>w.agent_id),{data:y,error:_}=await G.from("profiles").select("id, name, email, avatar_url").in("id",f);if(_)throw _;const b=new Map((y==null?void 0:y.map(w=>[w.id,w]))||[]),N=u.map(w=>{const S=b.get(w.agent_id);return{agent_id:w.agent_id,name:(S==null?void 0:S.name)||"Unknown",email:(S==null?void 0:S.email)||"",avatar_url:(S==null?void 0:S.avatar_url)||null,open_house_count:Number(w.open_house_count),total_visitors:Number(w.total_visitors),total_leads:Number(w.total_leads),active_count:Number(w.active_count)}});N.sort((w,S)=>S.total_visitors-w.total_visitors),r(N),a({totalOpenHouses:N.reduce((w,S)=>w+S.open_house_count,0),totalVisitors:N.reduce((w,S)=>w+S.total_visitors,0),totalLeads:N.reduce((w,S)=>w+S.total_leads,0),activeOpenHouses:N.reduce((w,S)=>w+S.active_count,0),agentsUsing:N.length})}catch(u){console.error("Error loading guest book stats:",u),t({title:"Error",description:"Failed to load guest book analytics",variant:"destructive"})}finally{l(!1)}},d=[{label:"Agents Using",value:n.agentsUsing,icon:ir,color:"text-blue-600"},{label:"Total Open Houses",value:n.totalOpenHouses,icon:Mn,color:"text-violet-600"},{label:"Active Now",value:n.activeOpenHouses,icon:si,color:"text-emerald-600"},{label:"Total Visitors",value:n.totalVisitors,icon:jn,color:"text-amber-600"},{label:"Leads Created",value:n.totalLeads,icon:Jo,color:"text-rose-600"}];return e.jsx(Ds,{title:"Guest Book Analytics",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Guest Book Analytics"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Track open house sign-in usage and lead generation across all agents"})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:d.map(u=>e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:u.label}),e.jsx(u.icon,{className:`h-4 w-4 ${u.color}`})]}),e.jsx(Oe,{children:o?e.jsx(Ms,{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(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Qo,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(Oe,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((u,p)=>e.jsx(Ms,{className:"h-12 w-full"},p))}):s.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No open houses created yet."}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Agent"}),e.jsx(St,{className:"text-center",children:"Open Houses"}),e.jsx(St,{className:"text-center",children:"Active"}),e.jsx(St,{className:"text-center",children:"Visitors"}),e.jsx(St,{className:"text-center",children:"Leads"}),e.jsx(St,{className:"text-center",children:"Conversion"})]})}),e.jsx(Rn,{children:s.map(u=>{var f,y;const p=u.total_visitors>0?(u.total_leads/u.total_visitors*100).toFixed(1):"0.0";return e.jsxs(Ps,{children:[e.jsx(ht,{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:((y=(f=u.name)==null?void 0:f.charAt(0))==null?void 0:y.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(ht,{className:"text-center font-medium",children:u.open_house_count}),e.jsx(ht,{className:"text-center",children:u.active_count>0?e.jsx(Qe,{variant:"secondary",className:"bg-emerald-100 text-emerald-700",children:u.active_count}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(ht,{className:"text-center",children:u.total_visitors.toLocaleString()}),e.jsx(ht,{className:"text-center",children:u.total_leads>0?e.jsx(Qe,{variant:"secondary",children:u.total_leads}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(ht,{className:"text-center",children:e.jsxs("span",{className:Number(p)>0?"text-emerald-600 font-medium":"text-muted-foreground",children:[p,"%"]})})]},u.agent_id)})})]})})]})]})})}function TSs(){const[t]=Nc(),s=wr(),[r,n]=k.useState("loading"),[a,o]=k.useState("Processing connection...");return k.useEffect(()=>{(async()=>{const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),p=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),pe.error("Failed to connect: "+(u||d));return}if(!i){n("error"),o("No authorization code received"),pe.error("Failed to connect: No authorization code");return}try{const{data:f,error:y}=await G.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p}});if(y)throw y;if(f!=null&&f.success)n("success"),o(f.message||"Accounts connected successfully!"),pe.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"),pe.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(Dt,{className:"text-center",children:[e.jsxs("div",{className:"mx-auto mb-4",children:[r==="loading"&&e.jsx(us,{className:"h-12 w-12 animate-spin text-primary"}),r==="success"&&e.jsx(si,{className:"h-12 w-12 text-green-500"}),r==="error"&&e.jsx(Jl,{className:"h-12 w-12 text-destructive"})]}),e.jsxs(zt,{children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(dr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:e.jsx(W,{onClick:()=>s("/admin/integrations"),children:r==="success"?"View Integrations":"Back to Integrations"})})]})})}function ASs(){const t=Qt(),[s,r]=k.useState(""),[n,a]=k.useState(""),[o,l]=k.useState([]),i=k.useRef(null),{data:d,isLoading:u}=gt({queryKey:["prospect-emails"],queryFn:async()=>{const{data:w,error:S}=await G.from("prospect_emails").select("*").order("sent_at",{ascending:!1});if(S)throw S;return w}}),p={total:(d==null?void 0:d.length)||0,sent:(d==null?void 0:d.filter(w=>w.status==="sent").length)||0,converted:(d==null?void 0:d.filter(w=>w.status==="converted").length)||0,conversionRate:d!=null&&d.length?Math.round(d.filter(w=>w.status==="converted").length/d.length*100):0},f=Pt({mutationFn:async w=>{const{data:S,error:C}=await G.functions.invoke("send-prospect-email",{body:{emails:w}});if(C)throw C;return S},onSuccess:w=>{t.invalidateQueries({queryKey:["prospect-emails"]}),pe.success(`${w.sent} email${w.sent>1?"s":""} sent successfully!`),r(""),a(""),l([])},onError:w=>{pe.error("Failed to send: "+w.message)}}),y=Pt({mutationFn:async()=>{var A,I;const{data:{user:w}}=await G.auth.getUser();if(!(w!=null&&w.email))throw new Error("Could not get your email");const{data:S,error:C}=await G.functions.invoke("send-prospect-email",{body:{emails:[{email:w.email,first_name:(I=(A=w.user_metadata)==null?void 0:A.name)==null?void 0:I.split(" ")[0]}],test_mode:!0}});if(C)throw C;return S},onSuccess:()=>{pe.success("Test email sent to your inbox!")},onError:w=>{pe.error("Failed to send test: "+w.message)}}),_=()=>{if(!s.trim()){pe.error("Please enter an email address");return}if(d==null?void 0:d.find(S=>S.email.toLowerCase()===s.trim().toLowerCase())){pe.error("This email has already been prospected");return}f.mutate([{email:s.trim(),first_name:n.trim()||void 0}])},b=w=>{var A;const S=(A=w.target.files)==null?void 0:A[0];if(!S)return;const C=new FileReader;C.onload=I=>{var B,U;const O=((B=I.target)==null?void 0:B.result).split(` `).filter(te=>te.trim()),V=[],q=(U=O[0])!=null&&U.toLowerCase().includes("email")?1:0;for(let te=q;tece.trim().replace(/"/g,"")),J=Y[0],X=Y[1];J&&J.includes("@")&&V.push({email:J,first_name:X||void 0})}l(V),pe.success(`${V.length} entries loaded from CSV`)},C.readAsText(S),i.current&&(i.current.value="")},N=()=>{if(o.length===0){pe.error("No entries to send");return}const w=new Set((d==null?void 0:d.map(C=>C.email.toLowerCase()))||[]),S=o.filter(C=>!w.has(C.email.toLowerCase()));if(S.length===0){pe.error("All emails have already been prospected");return}S.lengthy.mutate(),disabled:y.isPending,className:"gap-2 ml-4 shrink-0",children:[y.isPending?e.jsx(us,{className:"h-3 w-3 animate-spin"}):e.jsx(tr,{className:"h-3 w-3"}),"Send Test to Me"]})]})]}),e.jsx(Oe,{children:e.jsxs(ta,{defaultValue:"single",children:[e.jsxs(Jn,{className:"mb-4",children:[e.jsxs(cs,{value:"single",children:[e.jsx(_n,{className:"h-4 w-4 mr-2"}),"Single Send"]}),e.jsxs(cs,{value:"bulk",children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"}),"Bulk CSV"]})]}),e.jsx(Ss,{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(xe,{htmlFor:"prospect-email",className:"sr-only",children:"Email"}),e.jsx(De,{id:"prospect-email",type:"email",placeholder:"agent@example.com",value:s,onChange:w=>r(w.target.value),onKeyDown:w=>w.key==="Enter"&&_()})]}),e.jsxs("div",{className:"w-full sm:w-48",children:[e.jsx(xe,{htmlFor:"prospect-name",className:"sr-only",children:"First Name"}),e.jsx(De,{id:"prospect-name",placeholder:"First name (optional)",value:n,onChange:w=>a(w.target.value),onKeyDown:w=>w.key==="Enter"&&_()})]}),e.jsxs(W,{onClick:_,disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(_n,{className:"h-4 w-4"}),"Send Invite"]})]})}),e.jsx(Ss,{value:"bulk",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{ref:i,type:"file",accept:".csv",onChange:b,className:"hidden"}),e.jsxs(W,{variant:"outline",onClick:()=>{var w;return(w=i.current)==null?void 0:w.click()},className:"gap-2",children:[e.jsx(vn,{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(Qe,{variant:"secondary",className:"gap-1",children:[e.jsx(ir,{className:"h-3 w-3"}),o.length," entries ready"]}),e.jsxs(W,{variant:"ghost",size:"sm",onClick:()=>l([]),children:[e.jsx(kr,{className:"h-4 w-4"}),"Clear"]})]}),e.jsxs("div",{className:"max-h-40 overflow-y-auto border rounded-lg p-3 bg-muted/30 text-sm font-mono space-y-1",children:[o.slice(0,20).map((w,S)=>e.jsxs("div",{className:"text-muted-foreground",children:[w.email,w.first_name?` — ${w.first_name}`:""]},S)),o.length>20&&e.jsxs("div",{className:"text-muted-foreground/60",children:["...and ",o.length-20," more"]})]}),e.jsxs(W,{onClick:N,disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(_n,{className:"h-4 w-4"}),"Send ",o.length," Invites"]})]})]})})]})})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(tr,{className:"h-5 w-5"}),"Prospect Log"]}),e.jsx(dr,{children:"Track all sent invitations and their conversion status"})]}),e.jsx(Oe,{children:u?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((w,S)=>e.jsx(Ms,{className:"h-12 w-full"},S))}):d&&d.length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Email"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Name"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Sent"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Status"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Converted"})]})}),e.jsx("tbody",{children:d.map(w=>e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30",children:[e.jsx("td",{className:"py-3 px-4 text-sm font-medium text-foreground",children:w.email}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:w.first_name||"—"}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:vs(new Date(w.sent_at),"MMM d, yyyy")}),e.jsx("td",{className:"py-3 px-4",children:w.status==="converted"?e.jsxs(Qe,{className:"bg-green-500/10 text-green-700 hover:bg-green-500/20 border-0",children:[e.jsx($n,{className:"h-3 w-3 mr-1"}),"Converted"]}):e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[e.jsx(nn,{className:"h-3 w-3"}),"Sent"]})}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:w.converted_at?vs(new Date(w.converted_at),"MMM d, yyyy"):"—"})]},w.id))})]})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Rh,{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 PO(t){const s=Qt(),{toast:r}=ja(),n=gt({queryKey:["recruit-stages",t],queryFn:async()=>{if(!t)return[];const{data:d,error:u}=await G.from("recruit_pipeline_stages").select("*").eq("brokerage_id",t).order("sort_order");if(u)throw u;return d},enabled:!!t}),a=gt({queryKey:["recruit-prospects",t],queryFn:async()=>{if(!t)return[];const d=1e3;let u=[],p=0,f=!0;for(;f;){const{data:y,error:_}=await G.from("recruit_prospects").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1}).range(p,p+d-1);if(_)throw _;u=u.concat(y),f=y.length===d,p+=d}return u},enabled:!!t}),o=Pt({mutationFn:async d=>{const{data:{user:u}}=await G.auth.getUser();if(!u)throw new Error("Not authenticated");const p={first_name:d.first_name||"",last_name:d.last_name||null,email:d.email||null,phone:d.phone||null,current_brokerage:d.current_brokerage||null,license_number:d.license_number||null,experience_years:d.experience_years??null,annual_production:d.annual_production||null,source:d.source||"manual",notes:d.notes||null,stage_id:d.stage_id||null,brokerage_id:t,created_by:u.id,address:d.address||null,city:d.city||null,state:d.state||null,zip_code:d.zip_code||null,last_year_volume:d.last_year_volume||null,last_year_transactions:d.last_year_transactions??null,avg_sale_price:d.avg_sale_price||null,specialties:d.specialties||null,linkedin_url:d.linkedin_url||null,website_url:d.website_url||null,instagram_handle:d.instagram_handle||null,facebook_url:d.facebook_url||null,birthday:d.birthday||null,spouse_name:d.spouse_name||null,interests:d.interests||null,referred_by:d.referred_by||null},{data:f,error:y}=await G.from("recruit_prospects").insert(p).select().single();if(y)throw y;return f},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]}),r({title:"Prospect added"})},onError:d=>r({title:"Error",description:d.message,variant:"destructive"})}),l=Pt({mutationFn:async({id:d,...u})=>{const{data:p,error:f}=await G.from("recruit_prospects").update({...u,updated_at:new Date().toISOString()}).eq("id",d).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]})},onError:d=>r({title:"Error",description:d.message,variant:"destructive"})}),i=Pt({mutationFn:async d=>{const{error:u}=await G.from("recruit_prospects").delete().eq("id",d);if(u)throw u},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]}),r({title:"Prospect removed"})}});return{stages:n.data||[],prospects:a.data||[],isLoading:n.isLoading||a.isLoading,addProspect:o,updateProspect:l,deleteProspect:i}}function ESs(t){const s=Qt(),{toast:r}=ja(),n=gt({queryKey:["recruit-activities",t],queryFn:async()=>{if(!t)return[];const{data:o,error:l}=await G.from("recruit_activities").select("*").eq("prospect_id",t).order("created_at",{ascending:!1});if(l)throw l;return o},enabled:!!t}),a=Pt({mutationFn:async o=>{const{data:{user:l}}=await G.auth.getUser();if(!l)throw new Error("Not authenticated");const{data:i,error:d}=await G.from("recruit_activities").insert({...o,created_by:l.id}).select().single();if(d)throw d;return i},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-activities",t]}),r({title:"Activity logged"})},onError:o=>r({title:"Error",description:o.message,variant:"destructive"})});return{activities:n.data||[],isLoading:n.isLoading,addActivity:a}}const f9e=(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 Ylt({open:t,onOpenChange:s,stages:r,defaultStageId:n,onSubmit:a,isSubmitting:o}){const[l,i]=k.useState(f9e(n,r)),d=p=>f=>i(y=>({...y,[p]:f.target.value})),u=p=>{p.preventDefault(),a({...l,experience_years:l.experience_years?parseInt(l.experience_years):null,last_year_transactions:l.last_year_transactions?parseInt(l.last_year_transactions):null,stage_id:l.stage_id||null}),i(f9e(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(ks,{children:e.jsx(_s,{children:"Add Recruit Prospect"})}),e.jsxs("form",{onSubmit:u,className:"space-y-4",children:[e.jsxs(ta,{defaultValue:"basic",className:"w-full",children:[e.jsxs(Jn,{className:"grid w-full grid-cols-4",children:[e.jsx(cs,{value:"basic",children:"Basic Info"}),e.jsx(cs,{value:"production",children:"Production"}),e.jsx(cs,{value:"social",children:"Social & Web"}),e.jsx(cs,{value:"personal",children:"Personal"})]}),e.jsxs(Ss,{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(xe,{children:"First Name *"}),e.jsx(De,{required:!0,value:l.first_name,onChange:d("first_name")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Last Name"}),e.jsx(De,{value:l.last_name,onChange:d("last_name")})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Email"}),e.jsx(De,{type:"email",value:l.email,onChange:d("email")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Phone"}),e.jsx(De,{value:l.phone,onChange:d("phone")})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Current Brokerage"}),e.jsx(De,{value:l.current_brokerage,onChange:d("current_brokerage")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"License #"}),e.jsx(De,{value:l.license_number,onChange:d("license_number")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Experience (years)"}),e.jsx(De,{type:"number",min:"0",value:l.experience_years,onChange:d("experience_years")})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Address"}),e.jsx(De,{placeholder:"Street address",value:l.address,onChange:d("address")})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"City"}),e.jsx(De,{value:l.city,onChange:d("city")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"State"}),e.jsx(De,{value:l.state,onChange:d("state")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Zip"}),e.jsx(De,{value:l.zip_code,onChange:d("zip_code")})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Pipeline Stage"}),e.jsxs($s,{value:l.stage_id,onValueChange:p=>i(f=>({...f,stage_id:p})),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsx(Bs,{children:r.map(p=>e.jsx(vt,{value:p.id,children:p.name},p.id))})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Referred By"}),e.jsx(De,{placeholder:"Who referred this prospect?",value:l.referred_by,onChange:d("referred_by")})]})]}),e.jsxs(Ss,{value:"production",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Annual Production Volume"}),e.jsx(De,{placeholder:"e.g. $5M, 20 transactions",value:l.annual_production,onChange:d("annual_production")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Last Year Volume"}),e.jsx(De,{placeholder:"e.g. $8.2M",value:l.last_year_volume,onChange:d("last_year_volume")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Last Year Transactions"}),e.jsx(De,{type:"number",min:"0",placeholder:"e.g. 24",value:l.last_year_transactions,onChange:d("last_year_transactions")})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Avg Sale Price"}),e.jsx(De,{placeholder:"e.g. $350K",value:l.avg_sale_price,onChange:d("avg_sale_price")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Specialties / Niche"}),e.jsx(De,{placeholder:"e.g. Luxury, First-time buyers, Investment",value:l.specialties,onChange:d("specialties")})]})]}),e.jsxs(Ss,{value:"social",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"LinkedIn URL"}),e.jsx(De,{type:"url",placeholder:"https://linkedin.com/in/...",value:l.linkedin_url,onChange:d("linkedin_url")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Website URL"}),e.jsx(De,{type:"url",placeholder:"https://...",value:l.website_url,onChange:d("website_url")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Instagram Handle"}),e.jsx(De,{placeholder:"@handle",value:l.instagram_handle,onChange:d("instagram_handle")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Facebook URL"}),e.jsx(De,{type:"url",placeholder:"https://facebook.com/...",value:l.facebook_url,onChange:d("facebook_url")})]})]}),e.jsxs(Ss,{value:"personal",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Birthday"}),e.jsx(De,{type:"date",value:l.birthday,onChange:d("birthday")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Spouse / Partner Name"}),e.jsx(De,{value:l.spouse_name,onChange:d("spouse_name")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Interests / Hobbies"}),e.jsx(De,{placeholder:"Golf, travel, community events...",value:l.interests,onChange:d("interests")})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Notes"}),e.jsx(_r,{value:l.notes,onChange:d("notes"),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(W,{type:"submit",disabled:o,children:"Add Prospect"})]})]})]})})}const e2e=[{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 PSs(t){return gt({queryKey:["recruit-videos",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("recruit_videos").select(` *, prospect:recruit_prospects(id, first_name, last_name, email, phone, current_brokerage), video:agent_videos(id, title, thumbnail_url, playback_url, preview_url, duration_seconds, status) `).eq("brokerage_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function ISs(t){return gt({queryKey:["recruit-videos-prospect",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("recruit_videos").select(` *, video:agent_videos(id, title, thumbnail_url, playback_url, preview_url, duration_seconds, status) `).eq("prospect_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function Xlt(){const t=Qt(),{toast:s}=ja();return Pt({mutationFn:async r=>{const{data:{user:n}}=await G.auth.getUser();if(!n)throw new Error("Not authenticated");const{data:a,error:o}=await G.from("recruit_videos").insert({prospect_id:r.prospect_id,video_id:r.video_id,brokerage_id:r.brokerage_id,message:r.message||null,created_by:n.id}).select("*, prospect:recruit_prospects(id, first_name, last_name, email, phone, current_brokerage), video:agent_videos(id, title, thumbnail_url, playback_url, preview_url, duration_seconds, status)").single();if(o)throw o;return a},onSuccess:r=>{t.invalidateQueries({queryKey:["recruit-videos"]}),t.invalidateQueries({queryKey:["recruit-videos-prospect",r.prospect_id]}),s({title:"Video linked to prospect"})},onError:r=>s({title:"Error",description:r.message,variant:"destructive"})})}function Qlt(){const t=Qt();return Pt({mutationFn:async({id:s,sent_via:r})=>{const{error:n}=await G.from("recruit_videos").update({sent_at:new Date().toISOString(),sent_via:r,updated_at:new Date().toISOString()}).eq("id",s);if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["recruit-videos"]})}})}function Jlt(t){return gt({queryKey:["recruit-video-scripts",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("recruit_video_scripts").select("*").or(`brokerage_id.eq.${t},is_global.eq.true`).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function LSs(){const t=Qt(),{toast:s}=ja();return Pt({mutationFn:async r=>{const{data:{user:n}}=await G.auth.getUser();if(!n)throw new Error("Not authenticated");const{data:a,error:o}=await G.from("recruit_video_scripts").insert({...r,created_by:n.id}).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["recruit-video-scripts"]}),s({title:"Script saved"})},onError:r=>s({title:"Error",description:r.message,variant:"destructive"})})}function DSs(){const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("recruit_video_scripts").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["recruit-video-scripts"]})}})}function RSs({prospectId:t,prospectName:s,brokerageId:r}){var B;const{data:n=[],isLoading:a}=ISs(t),{data:o=[]}=Jlt(r),l=Xlt(),i=Mw(),d=Qlt(),[u,p]=k.useState("idle"),[f,y]=k.useState(0),[_,b]=k.useState(0),[N,w]=k.useState(""),[S,C]=k.useState(""),[A,I]=k.useState(!1),L=((B=o.find(U=>U.id===N))==null?void 0:B.script_text)||"",O=()=>{p("idle"),y(0),b(0),w(""),C("")},V=k.useCallback(async(U,te)=>{p("uploading");try{const Y=`Recruiting: ${s}`,{videoId:J,libraryId:X}=await wE(Y),{uploadUrl:ce,apiKey:ie}=await jE(J),ae=new XMLHttpRequest;ae.upload.onprogress=Me=>{Me.lengthComputable&&y(Me.loaded/Me.total*100)},await new Promise((Me,ke)=>{ae.onload=()=>ae.status>=200&&ae.status<300?Me():ke(new Error("Upload failed")),ae.onerror=()=>ke(new Error("Upload failed")),ae.open("PUT",ce),ae.setRequestHeader("AccessKey",ie),ae.send(U)}),p("processing");let oe=0;const me=Date.now(),ve=9e4,he=`https://iframe.mediadelivery.net/embed/${X}/${J}`;for(;oe<4&&(await new Promise(ke=>setTimeout(ke,3e3)),!(Date.now()-me>ve));){const Me=await nw(J);if(oe=Me.status,b(Me.encodeProgress||0),oe===5||oe===6)throw new Error("Video processing failed")}const ge=await nw(J),je=(ge.storageSize||U.size)/(1024*1024),qe=await i.mutateAsync({bunny_video_id:J,playback_url:ge.directPlayUrl||he,thumbnail_url:ge.thumbnailUrl,preview_url:ge.previewUrl||null,duration_seconds:ge.length||te,file_size_mb:je,title:Y,status:oe>=4?"ready":"processing",touch_type:"recruiting"});await l.mutateAsync({prospect_id:t,video_id:qe.id,brokerage_id:r,message:S||void 0}),p("done"),pe.success("Video recorded and linked to prospect!"),setTimeout(()=>{I(!1),O()},1500)}catch(Y){pe.error(Y.message||"Failed to upload video"),p("record")}},[t,s,r,S,i,l]),q=U=>{U&&(navigator.clipboard.writeText(`${window.location.origin}/recruit-video/${U}`),pe.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(yn,{className:"h-4 w-4"})," Video Outreach"]}),e.jsxs(fs,{open:A,onOpenChange:U=>{!U&&(u==="uploading"||u==="processing")||(I(U),U||O())},children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{size:"sm",variant:"outline",onClick:()=>p("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(ks,{children:e.jsxs(_s,{children:["Record Video for ",s]})}),u==="script"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Choose a Script (optional)"}),e.jsxs($s,{value:N,onValueChange:w,children:[e.jsx(zs,{className:"mt-1",children:e.jsx(Vs,{placeholder:"No script — speak freely"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"none",children:"No script"}),o.map(U=>{var te;return e.jsx(vt,{value:U.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[U.title,e.jsx(Qe,{variant:"outline",className:"text-[9px] ml-1",children:(te=e2e.find(Y=>Y.value===U.category))==null?void 0:te.label})]})},U.id)})]})]}),L&&e.jsx("div",{className:"mt-2 p-3 bg-muted/50 rounded-md text-sm max-h-32 overflow-y-auto whitespace-pre-wrap",children:L})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Personal Message (shown on landing page)"}),e.jsx(_r,{value:S,onChange:U=>C(U.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(W,{onClick:()=>p("record"),className:"w-full",children:[e.jsx(yn,{className:"h-4 w-4 mr-2"})," Start Recording"]})]}),u==="record"&&e.jsx(AO,{maxDurationSeconds:600,onRecordingComplete:V,teleprompterContent:L||void 0}),u==="uploading"&&e.jsxs("div",{className:"py-8 space-y-4 text-center",children:[e.jsx("p",{className:"font-medium",children:"Uploading video…"}),e.jsx(xi,{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(xi,{value:_,className:"mx-auto max-w-sm"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Math.round(_),"%"]})]}),u==="done"&&e.jsxs("div",{className:"py-8 text-center",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-emerald-100 flex items-center justify-center mx-auto mb-3",children:e.jsx(Co,{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(U=>{var te,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:(te=U.video)!=null&&te.thumbnail_url?e.jsx("img",{src:U.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(yn,{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=U.video)==null?void 0:Y.title)||"Untitled"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[U.view_count>0?e.jsxs(Qe,{variant:"secondary",className:"text-[9px] h-4",children:[e.jsx(jn,{className:"h-2.5 w-2.5 mr-0.5"}),U.view_count]}):U.sent_at?e.jsxs(Qe,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(_n,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]}):e.jsxs(Qe,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(nn,{className:"h-2.5 w-2.5 mr-0.5"}),"Draft"]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:vs(new Date(U.created_at),"MMM d")})]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(W,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>q(U.share_token),children:e.jsx(Va,{className:"h-3 w-3"})}),!U.sent_at&&e.jsx(W,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>d.mutate({id:U.id,sent_via:"email"}),children:e.jsx(_n,{className:"h-3 w-3"})})]})]},U.id)})})]})}function OSs(t){return gt({queryKey:["recruit-campaign-sends",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.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 x9e=[{value:"call",label:"Phone Call",icon:In},{value:"email",label:"Email",icon:tr},{value:"text",label:"Text Message",icon:wi},{value:"meeting",label:"Meeting",icon:cn},{value:"note",label:"Note",icon:vn},{value:"campaign_email",label:"Campaign Email",icon:_n}];function $p({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 A9({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(Yr,{className:"h-3 w-3 opacity-50"})]}):null}function Wl({label:t,value:s,onChange:r,type:n="text",placeholder:a}){return e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:t}),e.jsx(De,{type:n,value:s,onChange:o=>r(o.target.value),placeholder:a,className:"mt-1 h-8 text-sm"})]})}function ect({prospect:t,stages:s,brokerageId:r,open:n,onOpenChange:a,onUpdate:o,onDelete:l}){const{activities:i,addActivity:d}=ESs((t==null?void 0:t.id)||null),{data:u=[]}=OSs((t==null?void 0:t.id)||null),[p,f]=k.useState({type:"note",title:"",description:""}),[y,_]=k.useState(!1),[b,N]=k.useState(!1),[w,S]=k.useState({});if(!t)return null;const C=()=>{var Y,J;S({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||""}),N(!0)},A=()=>{const Y={id:t.id};for(const[J,X]of Object.entries(w))J==="experience_years"||J==="last_year_transactions"?Y[J]=X?parseInt(X):null:Y[J]=X||null;o(Y),N(!1)},I=()=>N(!1),L=Y=>J=>S(X=>({...X,[Y]:J})),O=()=>{p.title.trim()&&(d.mutate({prospect_id:t.id,activity_type:p.type,title:p.title,description:p.description||null}),f({type:"note",title:"",description:""}),_(!1))},V=s.find(Y=>Y.id===t.stage_id),q=t.address||t.city||t.state,B=t.last_year_volume||t.last_year_transactions||t.avg_sale_price||t.specialties||t.annual_production,U=t.linkedin_url||t.website_url||t.instagram_handle||t.facebook_url,te=t.birthday||t.spouse_name||t.interests||t.referred_by;return e.jsx(ZA,{open:n,onOpenChange:Y=>{Y||N(!1),a(Y)},children:e.jsx(SC,{className:"w-full sm:max-w-lg p-0",children:e.jsx(Ja,{className:"h-full",children:e.jsxs("div",{className:"p-6 space-y-5",children:[e.jsx(YA,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs(XA,{className:"text-xl",children:[t.first_name," ",t.last_name]}),V&&e.jsx(Qe,{variant:"outline",style:{borderColor:V.color,color:V.color},className:"mt-1",children:V.name})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[b?e.jsxs(e.Fragment,{children:[e.jsx(W,{variant:"ghost",size:"icon",onClick:I,children:e.jsx(kr,{className:"h-4 w-4"})}),e.jsx(W,{variant:"default",size:"icon",onClick:A,children:e.jsx(bc,{className:"h-4 w-4"})})]}):e.jsx(W,{variant:"ghost",size:"icon",onClick:C,title:"Edit prospect",children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsxs(Rl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(vr,{className:"h-4 w-4"})})}),e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Delete prospect?"}),e.jsx(bl,{children:"This will permanently remove this prospect and all their activity history."})]}),e.jsxs(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:()=>{l(t.id),a(!1)},children:"Delete"})]})]})]})]})]})}),!b&&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(tr,{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(In,{className:"h-3.5 w-3.5"})," ",t.phone]}),q&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Ia,{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(xe,{className:"text-xs text-muted-foreground",children:"Move to Stage"}),e.jsxs($s,{value:t.stage_id||"",onValueChange:Y=>o({id:t.id,stage_id:Y}),children:[e.jsx(zs,{className:"mt-1",children:e.jsx(Vs,{})}),e.jsx(Bs,{children:s.map(Y=>e.jsx(vt,{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(ta,{defaultValue:"details",className:"w-full",children:[e.jsxs(Jn,{className:"grid w-full grid-cols-4 h-8 text-xs",children:[e.jsx(cs,{value:"details",className:"text-xs",children:"Details"}),e.jsx(cs,{value:"production",className:"text-xs",children:"Production"}),e.jsx(cs,{value:"social",className:"text-xs",children:"Social"}),e.jsx(cs,{value:"personal",className:"text-xs",children:"Personal"})]}),b?e.jsxs(e.Fragment,{children:[e.jsxs(Ss,{value:"details",className:"mt-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Wl,{label:"First Name",value:w.first_name,onChange:L("first_name")}),e.jsx(Wl,{label:"Last Name",value:w.last_name,onChange:L("last_name")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Wl,{label:"Email",value:w.email,onChange:L("email"),type:"email"}),e.jsx(Wl,{label:"Phone",value:w.phone,onChange:L("phone")})]}),e.jsx(Wl,{label:"Current Brokerage",value:w.current_brokerage,onChange:L("current_brokerage")}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Wl,{label:"License #",value:w.license_number,onChange:L("license_number")}),e.jsx(Wl,{label:"Experience (years)",value:w.experience_years,onChange:L("experience_years"),type:"number"})]}),e.jsx(Wl,{label:"Address",value:w.address,onChange:L("address"),placeholder:"Street address"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(Wl,{label:"City",value:w.city,onChange:L("city")}),e.jsx(Wl,{label:"State",value:w.state,onChange:L("state")}),e.jsx(Wl,{label:"Zip",value:w.zip_code,onChange:L("zip_code")})]}),e.jsx(Wl,{label:"Source",value:w.source,onChange:L("source")}),e.jsx(Wl,{label:"Referred By",value:w.referred_by,onChange:L("referred_by")}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Notes"}),e.jsx(_r,{value:w.notes,onChange:Y=>S(J=>({...J,notes:Y.target.value})),rows:3,className:"mt-1 text-sm"})]})]}),e.jsxs(Ss,{value:"production",className:"mt-3 space-y-3",children:[e.jsx(Wl,{label:"Annual Production",value:w.annual_production,onChange:L("annual_production"),placeholder:"e.g. $5M"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Wl,{label:"Last Year Volume",value:w.last_year_volume,onChange:L("last_year_volume"),placeholder:"e.g. $8.2M"}),e.jsx(Wl,{label:"Last Year Transactions",value:w.last_year_transactions,onChange:L("last_year_transactions"),type:"number",placeholder:"e.g. 24"})]}),e.jsx(Wl,{label:"Avg Sale Price",value:w.avg_sale_price,onChange:L("avg_sale_price"),placeholder:"e.g. $350K"}),e.jsx(Wl,{label:"Specialties / Niche",value:w.specialties,onChange:L("specialties"),placeholder:"e.g. Luxury, Investment"})]}),e.jsxs(Ss,{value:"social",className:"mt-3 space-y-3",children:[e.jsx(Wl,{label:"LinkedIn URL",value:w.linkedin_url,onChange:L("linkedin_url"),type:"url",placeholder:"https://linkedin.com/in/..."}),e.jsx(Wl,{label:"Website URL",value:w.website_url,onChange:L("website_url"),type:"url",placeholder:"https://..."}),e.jsx(Wl,{label:"Instagram Handle",value:w.instagram_handle,onChange:L("instagram_handle"),placeholder:"@handle"}),e.jsx(Wl,{label:"Facebook URL",value:w.facebook_url,onChange:L("facebook_url"),type:"url",placeholder:"https://facebook.com/..."})]}),e.jsxs(Ss,{value:"personal",className:"mt-3 space-y-3",children:[e.jsx(Wl,{label:"Birthday",value:w.birthday,onChange:L("birthday"),type:"date"}),e.jsx(Wl,{label:"Spouse / Partner",value:w.spouse_name,onChange:L("spouse_name")}),e.jsx(Wl,{label:"Interests / Hobbies",value:w.interests,onChange:L("interests"),placeholder:"Golf, travel, community events..."})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ss,{value:"details",className:"mt-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx($p,{label:"Current Brokerage",value:t.current_brokerage}),e.jsx($p,{label:"License #",value:t.license_number}),e.jsx($p,{label:"Experience",value:t.experience_years!=null?`${t.experience_years} years`:null}),e.jsx($p,{label:"Referred By",value:t.referred_by}),e.jsx($p,{label:"Source",value:t.source})]}),t.notes&&e.jsxs("div",{className:"mt-3",children:[e.jsx(xe,{className:"text-xs text-muted-foreground",children:"Notes"}),e.jsx("p",{className:"text-sm mt-1 whitespace-pre-wrap",children:t.notes})]})]}),e.jsx(Ss,{value:"production",className:"mt-3",children:B?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx($p,{label:"Annual Production",value:t.annual_production}),e.jsx($p,{label:"Last Year Volume",value:t.last_year_volume}),e.jsx($p,{label:"Last Year Transactions",value:t.last_year_transactions}),e.jsx($p,{label:"Avg Sale Price",value:t.avg_sale_price}),e.jsx($p,{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(Ss,{value:"social",className:"mt-3",children:U?e.jsxs("div",{className:"space-y-2",children:[e.jsx(A9,{label:"LinkedIn",url:t.linkedin_url,icon:gp}),e.jsx(A9,{label:"Website",url:t.website_url,icon:nd}),t.instagram_handle&&e.jsx(A9,{label:t.instagram_handle,url:`https://instagram.com/${t.instagram_handle.replace("@","")}`,icon:pu}),e.jsx(A9,{label:"Facebook",url:t.facebook_url,icon:hu})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No social profiles added yet"})}),e.jsx(Ss,{value:"personal",className:"mt-3",children:te?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx($p,{label:"Birthday",value:t.birthday?vs(new Date(t.birthday+"T00:00:00"),"MMMM d, yyyy"):null,icon:hi}),e.jsx($p,{label:"Spouse / Partner",value:t.spouse_name,icon:Xa}),e.jsx("div",{className:"col-span-2",children:e.jsx($p,{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(RSs,{prospectId:t.id,prospectName:`${t.first_name} ${t.last_name||""}`,brokerageId:r}),e.jsx(ho,{}),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(W,{size:"sm",variant:"outline",onClick:()=>_(!y),children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1"})," Log Activity"]})]}),y&&e.jsxs("div",{className:"border rounded-lg p-3 mb-4 space-y-3 bg-muted/30",children:[e.jsxs($s,{value:p.type,onValueChange:Y=>f(J=>({...J,type:Y})),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsx(Bs,{children:x9e.map(Y=>e.jsx(vt,{value:Y.value,children:Y.label},Y.value))})]}),e.jsx(De,{placeholder:"Subject / Title",value:p.title,onChange:Y=>f(J=>({...J,title:Y.target.value}))}),e.jsx(_r,{placeholder:"Details (optional)",value:p.description,onChange:Y=>f(J=>({...J,description:Y.target.value})),rows:2}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(W,{size:"sm",variant:"ghost",onClick:()=>_(!1),children:"Cancel"}),e.jsx(W,{size:"sm",onClick:O,disabled:!p.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,X)=>new Date(X.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,ie=x9e.find(oe=>oe.value===ce.activity_type),ae=(ie==null?void 0:ie.icon)||vn;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(ae,{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:vs(new Date(ce.created_at),"MMM d, yyyy h:mm a")})]})]},`activity-${ce.id}`)}const X=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(_n,{className:"h-3.5 w-3.5 text-primary"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"font-medium",children:["Campaign Email #",X.email_number]}),e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:X.subject}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-1.5",children:[X.status==="failed"?e.jsx(Qe,{variant:"destructive",className:"text-[10px] px-1.5 py-0 h-4",children:"Failed"}):e.jsxs(Qe,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 border-green-500 text-green-600",children:[e.jsx(_n,{className:"h-2.5 w-2.5 mr-0.5"})," Sent"]}),X.opened_at?e.jsxs(Qe,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 border-blue-500 text-blue-600",children:[e.jsx(jn,{className:"h-2.5 w-2.5 mr-0.5"})," Opened ",vs(new Date(X.opened_at),"MMM d, h:mm a")]}):X.status!=="failed"?e.jsx(Qe,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 text-muted-foreground",children:"Not opened"}):null,X.clicked_at&&e.jsxs(Qe,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 border-purple-500 text-purple-600",children:[e.jsx(au,{className:"h-2.5 w-2.5 mr-0.5"})," Clicked ",vs(new Date(X.clicked_at),"MMM d, h:mm a")]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:vs(new Date(X.sent_at||X.created_at),"MMM d, yyyy h:mm a")})]})]},`send-${X.id}`)})})()})]})]})})})})}const FSs=["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 tct({open:t,onOpenChange:s,brokerageId:r,stages:n}){var U;const{toast:a}=ja(),o=Qt(),l=k.useRef(null),[i,d]=k.useState([]),[u,p]=k.useState([]),[f,y]=k.useState({}),[_,b]=k.useState(((U=n[0])==null?void 0:U.id)||""),[N,w]=k.useState(!1),[S,C]=k.useState("upload"),[A,I]=k.useState(0),L=()=>{d([]),p([]),y({}),C("upload"),I(0)},O=te=>{var X;const Y=(X=te.target.files)==null?void 0:X[0];if(!Y)return;const J=new FileReader;J.onload=ce=>{var ge;const ae=((ge=ce.target)==null?void 0:ge.result).split(/\r?\n/).filter(je=>je.trim());if(ae.length<2){a({title:"Invalid CSV",description:"File must have a header row and at least one data row",variant:"destructive"});return}const oe=V(ae[0]);p(oe);const me={},ve=new Set;oe.forEach((je,qe)=>{const Me=je.toLowerCase().replace(/[^a-z0-9]/g,"");let ke=null;/^firstname$/.test(Me)||Me==="first"?ke="first_name":/^lastname$/.test(Me)||Me==="last"?ke="last_name":/^email$/.test(Me)||Me==="emailaddress"?ke="email":/^mobile$|^phone$|^cellphone$|^mobilephone$/.test(Me)?ke="phone":/officename|currentbrokerage|brokerage|company/.test(Me)?ke="current_brokerage":/membernumber|licensenumber|license/.test(Me)?ke="license_number":/experienceyears|yearsexperience/.test(Me)?ke="experience_years":/^totalvolume$|annualproduction/.test(Me)?ke="annual_production":/^address$/.test(Me)?ke="address":/^city$/.test(Me)?ke="city":/^state$/.test(Me)?ke="state":/^postalcode$|^zip$|^zipcode$/.test(Me)?ke="zip_code":/listsidevolume|lastyearvolume/.test(Me)?ke="last_year_volume":/^totalcount$|lastyeartransactions/.test(Me)?ke="last_year_transactions":/avgsaleprice|averageprice/.test(Me)?ke="avg_sale_price":/linkedin/.test(Me)?ke="linkedin_url":/website/.test(Me)?ke="website_url":/specialt/.test(Me)?ke="specialties":/referr/.test(Me)?ke="referred_by":/^notes$|^note$/.test(Me)&&(ke="notes"),ke&&!ve.has(ke)&&(me[String(qe)]=ke,ve.add(ke))}),y(me);const he=ae.slice(1).map(je=>{const qe=V(je),Me={};return oe.forEach((ke,Re)=>{Me[String(Re)]=qe[Re]||""}),Me});d(he),C("map")},J.readAsText(Y)},V=te=>{const Y=[];let J="",X=!1;for(const ce of te)ce==='"'?X=!X:ce===","&&!X?(Y.push(J.trim()),J=""):J+=ce;return Y.push(J.trim()),Y},q=async()=>{w(!0);try{const{data:{user:te}}=await G.auth.getUser();if(!te)throw new Error("Not authenticated");const Y=i.map(X=>{const ce={brokerage_id:r,created_by:te.id,stage_id:_,source:"csv_import",first_name:"Unknown"},ie=ce;return Object.entries(f).forEach(([ae,oe])=>{var ve;const me=(ve=X[ae])==null?void 0:ve.trim();me&&(oe==="experience_years"||oe==="last_year_transactions"?ie[oe]=parseInt(me.replace(/[^0-9.-]/g,""))||null:oe==="annual_production"||oe==="last_year_volume"||oe==="avg_sale_price"?ie[oe]=me.replace(/[^0-9.$,.-]/g,""):ie[oe]=me)}),ce});let J=0;for(let X=0;X{const te=`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([te],{type:"text/csv"}),J=URL.createObjectURL(Y),X=document.createElement("a");X.href=J,X.download="recruit-prospects-template.csv",X.click(),URL.revokeObjectURL(J)};return e.jsx(fs,{open:t,onOpenChange:te=>{te||L(),s(te)},children:e.jsxs(ps,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(_s,{children:"Import Prospects from CSV"})}),S==="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(Zv,{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(W,{onClick:()=>{var te;return(te=l.current)==null?void 0:te.click()},children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"})," Choose File"]})]}),e.jsx(W,{variant:"link",className:"text-xs",onClick:B,children:"Download CSV template"})]}),S==="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($s,{value:_,onValueChange:b,children:[e.jsx(zs,{className:"w-[180px]",children:e.jsx(Vs,{})}),e.jsx(Bs,{children:n.map(te=>e.jsx(vt,{value:te.id,children:te.name},te.id))})]})]})]}),e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{className:"w-[140px]",children:"CSV Column"}),e.jsx(St,{className:"w-[160px]",children:"Map To"}),e.jsx(St,{children:"Preview"})]})}),e.jsx(Rn,{children:u.map((te,Y)=>{var J;return e.jsxs(Ps,{children:[e.jsx(ht,{className:"font-medium text-xs",children:te}),e.jsx(ht,{children:e.jsxs($s,{value:f[String(Y)]||"skip",onValueChange:X=>y(ce=>({...ce,[String(Y)]:X==="skip"?"":X})),children:[e.jsx(zs,{className:"h-8 text-xs",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"skip",children:"— Skip —"}),FSs.map(X=>e.jsx(vt,{value:X,children:X.replace(/_/g," ")},X))]})]})}),e.jsx(ht,{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(ro,{className:"h-4 w-4"}),' Map at least "first name" to proceed']}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(W,{variant:"outline",onClick:()=>{L()},children:"Back"}),e.jsx(W,{onClick:q,disabled:N||!Object.values(f).includes("first_name"),children:N?"Importing...":`Import ${i.length} Prospects`})]})]}),S==="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(Zn,{className:"h-6 w-6 text-green-600"})}),e.jsxs("p",{className:"font-semibold",children:[A," prospects imported successfully!"]}),e.jsx(W,{onClick:()=>{L(),s(!1)},children:"Close"})]})]})})}function sct({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=PO(t),[i,d]=k.useState(!1),[u,p]=k.useState(),[f,y]=k.useState(null),[_,b]=k.useState(!1),[N,w]=k.useState(!1),[S,C]=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 A=B=>r.filter(U=>U.stage_id===B),I=(B,U)=>{C(U),B.dataTransfer.effectAllowed="move"},L=B=>{B.preventDefault(),B.dataTransfer.dropEffect="move"},O=(B,U)=>{B.preventDefault(),S&&(o.mutate({id:S,stage_id:U}),C(null))},V=B=>{p(B),d(!0)},q=B=>{y(B),b(!0)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.length," prospect",r.length!==1?"s":""]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(W,{variant:"outline",onClick:()=>w(!0),children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(W,{onClick:()=>{p(void 0),d(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"})," Add Prospect"]})]})]}),e.jsxs(Ja,{className:"w-full",children:[e.jsx("div",{className:"flex gap-4 pb-4",style:{minWidth:s.length*300},children:s.map(B=>{const U=A(B.id);return e.jsxs("div",{className:"w-[280px] flex-shrink-0 flex flex-col",onDragOver:L,onDrop:te=>O(te,B.id),children:[e.jsxs("div",{className:"flex items-center justify-between mb-3 px-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-3 rounded-full",style:{backgroundColor:B.color}}),e.jsx("h3",{className:"font-semibold text-sm",children:B.name}),e.jsx(Qe,{variant:"secondary",className:"text-xs h-5 px-1.5",children:U.length})]}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>V(B.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:U.map(te=>e.jsx(Pe,{className:"p-3 cursor-pointer hover:shadow-md transition-shadow border-l-4 group",style:{borderLeftColor:B.color},draggable:!0,onDragStart:Y=>I(Y,te.id),onClick:()=>q(te),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(mu,{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(Ai,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsxs("span",{className:"font-medium text-sm truncate",children:[te.first_name," ",te.last_name]})]}),te.current_brokerage&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(pa,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:te.current_brokerage})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[te.email&&e.jsx(tr,{className:"h-3 w-3 text-muted-foreground"}),te.phone&&e.jsx(In,{className:"h-3 w-3 text-muted-foreground"}),te.experience_years!=null&&e.jsxs(Qe,{variant:"secondary",className:"text-[10px] h-4 px-1",children:[te.experience_years,"yr"]})]})]})]})},te.id))})]},B.id)})}),e.jsx(zue,{orientation:"horizontal"})]}),e.jsx(Ylt,{open:i,onOpenChange:d,stages:s,defaultStageId:u,onSubmit:B=>a.mutate(B),isSubmitting:a.isPending}),e.jsx(ect,{prospect:f,stages:s,brokerageId:t,open:_,onOpenChange:b,onUpdate:B=>{o.mutate(B),y(U=>U?{...U,...B}:null)},onDelete:B=>l.mutate(B)}),e.jsx(tct,{open:N,onOpenChange:w,brokerageId:t,stages:s})]})}function Ede({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=PO(t),{user:i}=Us(),d=Qt(),[u,p]=k.useState(!1),[f,y]=k.useState(null),[_,b]=k.useState(!1),[N,w]=k.useState(!1),[S,C]=k.useState(""),[A,I]=k.useState("all"),[L,O]=k.useState("all"),[V,q]=k.useState("all"),[B,U]=k.useState(null),[te,Y]=k.useState("asc"),[J,X]=k.useState(new Set),[ce,ie]=k.useState(!1),[ae,oe]=k.useState(""),me=k.useMemo(()=>{const ye=new Set;return r.forEach(ct=>{ct.current_brokerage&&ye.add(ct.current_brokerage)}),Array.from(ye).sort()},[r]),{data:ve=[]}=gt({queryKey:["recruit-campaigns-list",t],queryFn:async()=>{const{data:ye,error:ct}=await G.from("recruit_campaigns").select("id, name, warmth_level").or(`brokerage_id.is.null,brokerage_id.eq.${t}`).order("name");if(ct)throw ct;return ye}}),{data:he=[]}=gt({queryKey:["recruit-campaign-assignments-lookup",t],queryFn:async()=>{let ct=[],fe=0;for(;;){const{data:$e,error:Ye}=await G.from("recruit_campaign_assignments").select("prospect_id, campaign_id, status").eq("brokerage_id",t).range(fe,fe+1e3-1);if(Ye)throw Ye;if(ct=ct.concat($e??[]),!$e||$e.length<1e3)break;fe+=1e3}return ct}}),ge=k.useMemo(()=>{const ye=new Map;return he.forEach(ct=>{ye.has(ct.prospect_id)||ye.set(ct.prospect_id,new Set),ye.get(ct.prospect_id).add(ct.campaign_id)}),ye},[he]),je=ye=>{B===ye?Y(ct=>ct==="asc"?"desc":"asc"):(U(ye),Y("asc"))},qe=({column:ye})=>B!==ye?e.jsx(td,{className:"h-3.5 w-3.5 ml-1 text-muted-foreground/50"}):te==="asc"?e.jsx(uu,{className:"h-3.5 w-3.5 ml-1 text-primary"}):e.jsx(Ih,{className:"h-3.5 w-3.5 ml-1 text-primary"}),Me=ye=>s.find(ct=>ct.id===ye),ke=k.useMemo(()=>{let ye=r.filter(ct=>{var Te,We,Ke;const fe=!S||`${ct.first_name} ${ct.last_name}`.toLowerCase().includes(S.toLowerCase())||((Te=ct.email)==null?void 0:Te.toLowerCase().includes(S.toLowerCase()))||((We=ct.current_brokerage)==null?void 0:We.toLowerCase().includes(S.toLowerCase())),$e=A==="all"||ct.stage_id===A,Ye=L==="all"||ct.current_brokerage===L;let tt=!0;return V==="in_campaign"?tt=ge.has(ct.id):V==="not_in_campaign"?tt=!ge.has(ct.id):V!=="all"&&(tt=((Ke=ge.get(ct.id))==null?void 0:Ke.has(V))??!1),fe&&$e&&Ye&&tt});return B&&(ye=[...ye].sort((ct,fe)=>{var Te,We;let $e=null,Ye=null;switch(B){case"name":$e=`${ct.first_name} ${ct.last_name||""}`.toLowerCase(),Ye=`${fe.first_name} ${fe.last_name||""}`.toLowerCase();break;case"stage":$e=((Te=Me(ct.stage_id))==null?void 0:Te.sort_order)??999,Ye=((We=Me(fe.stage_id))==null?void 0:We.sort_order)??999;break;case"brokerage":$e=(ct.current_brokerage||"").toLowerCase(),Ye=(fe.current_brokerage||"").toLowerCase();break;case"experience":$e=ct.experience_years??-1,Ye=fe.experience_years??-1;break;case"production":$e=(ct.annual_production||"").toLowerCase(),Ye=(fe.annual_production||"").toLowerCase();break;case"source":$e=(ct.source||"").toLowerCase(),Ye=(fe.source||"").toLowerCase();break;default:return 0}if($e===Ye)return 0;if($e==null)return 1;if(Ye==null)return-1;const tt=$e0&&ke.every(ye=>J.has(ye.id)),Ve=ke.some(ye=>J.has(ye.id)),Ne=()=>{X(Re?new Set:new Set(ke.map(ye=>ye.id)))},Ue=ye=>{X(ct=>{const fe=new Set(ct);return fe.has(ye)?fe.delete(ye):fe.add(ye),fe})},Ie=Pt({mutationFn:async()=>{if(!ae||!(i!=null&&i.id))throw new Error("Select a campaign");const ye=new Set(he.filter($e=>$e.campaign_id===ae).map($e=>$e.prospect_id)),ct=Array.from(J).filter($e=>!ye.has($e)).map($e=>({prospect_id:$e,campaign_id:ae,brokerage_id:t,assigned_by:i.id,status:"active",current_email_number:0}));if(ct.length===0)throw new Error("All selected prospects are already in this campaign");const{error:fe}=await G.from("recruit_campaign_assignments").insert(ct);if(fe)throw fe;return ct.length},onSuccess:ye=>{pe.success(`${ye} prospect(s) added to campaign`),ie(!1),X(new Set),oe(""),d.invalidateQueries({queryKey:["recruit-campaign-assignments-lookup"]})},onError:ye=>pe.error(ye.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(ln,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search prospects...",value:S,onChange:ye=>C(ye.target.value),className:"pl-8"})]}),e.jsxs("div",{className:"flex gap-2",children:[J.size>0&&e.jsxs(W,{variant:"secondary",onClick:()=>ie(!0),className:"gap-1.5",children:[e.jsx(_n,{className:"h-4 w-4"})," Add ",J.size," to Campaign"]}),e.jsxs(W,{variant:"outline",onClick:()=>w(!0),children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(W,{onClick:()=>p(!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(Eg,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs($s,{value:A,onValueChange:I,children:[e.jsx(zs,{className:"w-[160px] h-8 text-xs",children:e.jsx(Vs,{placeholder:"All stages"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All stages"}),s.map(ye=>e.jsx(vt,{value:ye.id,children:ye.name},ye.id))]})]}),e.jsxs($s,{value:L,onValueChange:O,children:[e.jsxs(zs,{className:"w-[200px] h-8 text-xs",children:[e.jsx(pa,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx(Vs,{placeholder:"All brokerages"})]}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All brokerages"}),me.map(ye=>e.jsx(vt,{value:ye,children:ye},ye))]})]}),e.jsxs($s,{value:V,onValueChange:q,children:[e.jsxs(zs,{className:"w-[200px] h-8 text-xs",children:[e.jsx(tr,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx(Vs,{placeholder:"Campaign status"})]}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All contacts"}),e.jsx(vt,{value:"in_campaign",children:"In any campaign"}),e.jsx(vt,{value:"not_in_campaign",children:"Not in any campaign"}),ve.map(ye=>e.jsxs(vt,{value:ye.id,children:["In: ",ye.name]},ye.id))]})]}),(A!=="all"||L!=="all"||V!=="all")&&e.jsx(W,{variant:"ghost",size:"sm",className:"h-8 text-xs text-muted-foreground",onClick:()=>{I("all"),O("all"),q("all")},children:"Clear filters"})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{className:"w-[40px]",children:e.jsx(Ri,{checked:Re,onCheckedChange:Ne,"aria-label":"Select all",...Ve&&!Re?{"data-state":"indeterminate"}:{}})}),e.jsx(St,{className:"cursor-pointer select-none",onClick:()=>je("name"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Name ",e.jsx(qe,{column:"name"})]})}),e.jsx(St,{className:"cursor-pointer select-none",onClick:()=>je("stage"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Stage ",e.jsx(qe,{column:"stage"})]})}),e.jsx(St,{className:"hidden md:table-cell cursor-pointer select-none",onClick:()=>je("brokerage"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Brokerage ",e.jsx(qe,{column:"brokerage"})]})}),e.jsx(St,{className:"hidden md:table-cell",children:"Contact"}),e.jsx(St,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>je("experience"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Experience ",e.jsx(qe,{column:"experience"})]})}),e.jsx(St,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>je("production"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Production ",e.jsx(qe,{column:"production"})]})}),e.jsx(St,{className:"hidden lg:table-cell",children:"Campaigns"}),e.jsx(St,{className:"w-[50px]"})]})}),e.jsx(Rn,{children:ke.length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:9,className:"text-center text-muted-foreground py-8",children:"No prospects found"})}):ke.map(ye=>{const ct=Me(ye.stage_id),fe=ge.get(ye.id),$e=(fe==null?void 0:fe.size)??0;return e.jsxs(Ps,{className:"cursor-pointer",onClick:()=>{y(ye),b(!0)},children:[e.jsx(ht,{onClick:Ye=>Ye.stopPropagation(),children:e.jsx(Ri,{checked:J.has(ye.id),onCheckedChange:()=>Ue(ye.id),"aria-label":`Select ${ye.first_name}`})}),e.jsxs(ht,{className:"font-medium",children:[ye.first_name," ",ye.last_name]}),e.jsx(ht,{children:ct?e.jsxs(Qe,{variant:"outline",className:"text-xs gap-1 whitespace-nowrap",style:{borderColor:ct.color,color:ct.color,backgroundColor:`${ct.color}10`},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:ct.color}}),ct.name]}):e.jsx("span",{className:"text-muted-foreground text-xs",children:"—"})}),e.jsx(ht,{className:"hidden md:table-cell",children:ye.current_brokerage?e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(pa,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate max-w-[150px]",children:ye.current_brokerage})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(ht,{className:"hidden md:table-cell",children:e.jsxs("div",{className:"flex items-center gap-2",children:[ye.email&&e.jsx(tr,{className:"h-3.5 w-3.5 text-muted-foreground"}),ye.phone&&e.jsx(In,{className:"h-3.5 w-3.5 text-muted-foreground"}),!ye.email&&!ye.phone&&e.jsx("span",{className:"text-muted-foreground",children:"—"})]})}),e.jsx(ht,{className:"hidden lg:table-cell",children:ye.experience_years!=null?`${ye.experience_years} yr`:"—"}),e.jsx(ht,{className:"hidden lg:table-cell",children:ye.annual_production||"—"}),e.jsx(ht,{className:"hidden lg:table-cell",children:$e>0?e.jsxs(Qe,{variant:"secondary",className:"text-xs",children:[$e," campaign",$e>1?"s":""]}):e.jsx("span",{className:"text-muted-foreground text-xs",children:"None"})}),e.jsx(ht,{children:e.jsx(W,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:Ye=>{Ye.stopPropagation(),l.mutate(ye.id)},children:e.jsx(vr,{className:"h-3.5 w-3.5"})})})]},ye.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 · "]}),ke.length," of ",r.length," prospects"]}),e.jsx(fs,{open:ce,onOpenChange:ie,children:e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsx(ks,{children:e.jsx(_s,{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(xe,{children:"Campaign"}),e.jsxs($s,{value:ae,onValueChange:oe,children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select a campaign..."})}),e.jsx(Bs,{children:ve.map(ye=>e.jsxs(vt,{value:ye.id,children:[ye.name," ",e.jsxs("span",{className:"text-muted-foreground ml-1",children:["(",ye.warmth_level,")"]})]},ye.id))})]})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>ie(!1),children:"Cancel"}),e.jsx(W,{onClick:()=>Ie.mutate(),disabled:!ae||Ie.isPending,children:Ie.isPending?"Adding...":"Add to Campaign"})]})]})}),e.jsx(Ylt,{open:u,onOpenChange:p,stages:s,onSubmit:ye=>a.mutate(ye),isSubmitting:a.isPending}),e.jsx(ect,{prospect:f,stages:s,brokerageId:t,open:_,onOpenChange:b,onUpdate:ye=>{o.mutate(ye),y(ct=>ct?{...ct,...ye}:null)},onDelete:ye=>l.mutate(ye)}),e.jsx(tct,{open:N,onOpenChange:w,brokerageId:t,stages:s})]})}function rct({brokerageId:t}){const{stages:s,prospects:r,isLoading:n}=PO(t),a=k.useMemo(()=>{if(!s.length||!r.length)return null;const o=r.length,l=s.find(S=>S.name==="Signed"),i=s.find(S=>S.name==="Onboarded"),d=r.filter(S=>S.stage_id===(l==null?void 0:l.id)||S.stage_id===(i==null?void 0:i.id)).length,u=o>0?(d/o*100).toFixed(1):"0",p=new Date,f=o>0?Math.round(r.reduce((S,C)=>S+$g(p,new Date(C.created_at)),0)/o):0,y=s.map(S=>({...S,count:r.filter(C=>C.stage_id===S.id).length})),_={};r.forEach(S=>{const C=S.source||"unknown";_[C]=(_[C]||0)+1});const b=Object.entries(_).sort((S,C)=>C[1]-S[1]),N=new Date;N.setDate(N.getDate()-30);const w=r.filter(S=>new Date(S.created_at)>=N).length;return{total:o,signed:d,conversionRate:u,avgDays:f,byStage:y,bySrc:b,recentCount:w}},[s,r]);return n?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):a?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Pe,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-blue-500/10 flex items-center justify-center",children:e.jsx(ir,{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(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-green-500/10 flex items-center justify-center",children:e.jsx(Qo,{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(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-amber-500/10 flex items-center justify-center",children:e.jsx(nn,{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(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-violet-500/10 flex items-center justify-center",children:e.jsx(Rh,{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(Dt,{children:e.jsx(zt,{className:"text-base",children:"Pipeline Breakdown"})}),e.jsx(Oe,{className:"space-y-3",children:a.byStage.map(o=>{const l=a.total>0?o.count/a.total*100:0;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:o.color}}),e.jsx("span",{children:o.name})]}),e.jsx("span",{className:"font-medium",children:o.count})]}),e.jsx("div",{className:"h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${l}%`,backgroundColor:o.color}})})]},o.id)})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Lead Sources"})}),e.jsxs(Oe,{className:"space-y-3",children:[a.bySrc.map(([o,l])=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Qe,{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 g9e=[{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 nct({brokerageId:t}){const{toast:s}=ja(),[r,n]=k.useState(null),[a,o]=k.useState(null),l=(d,u)=>{navigator.clipboard.writeText(d),n(u),s({title:"Copied to clipboard!"}),setTimeout(()=>n(null),2e3)},i=[...new Set(g9e.map(d=>d.category))];return e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pre-built email templates for recruiting outreach. Click to expand and copy."}),i.map(d=>e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"font-semibold text-sm flex items-center gap-2",children:[e.jsx(tr,{className:"h-4 w-4"})," ",d]}),g9e.filter(u=>u.category===d).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(Dt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{className:"text-sm",children:u.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Subject: ",u.subject]})]}),e.jsx(Qe,{variant:"secondary",className:"text-[10px]",children:u.category})]})}),a===u.id&&e.jsxs(Oe,{className:"pt-0 space-y-3",children:[e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Subject Line:"}),e.jsx("p",{className:"text-sm mb-3",children:u.subject}),e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Body:"}),e.jsx("pre",{className:"text-sm whitespace-pre-wrap font-sans",children:u.body})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(W,{size:"sm",variant:"outline",onClick:p=>{p.stopPropagation(),l(u.subject,u.id+"-subject")},children:[r===u.id+"-subject"?e.jsx(Zn,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(Va,{className:"h-3.5 w-3.5 mr-1"}),"Copy Subject"]}),e.jsxs(W,{size:"sm",onClick:p=>{p.stopPropagation(),l(u.body,u.id+"-body")},children:[r===u.id+"-body"?e.jsx(Zn,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(Va,{className:"h-3.5 w-3.5 mr-1"}),"Copy Body"]})]})]})]},u.id))]},d))]})}const y9e={call:In,email:tr,text:wi,meeting:cn,note:vn};function act({brokerageId:t}){const{data:s,isLoading:r}=gt({queryKey:["recruit-activity-report",t],queryFn:async()=>{const{data:n,error:a}=await G.from("recruit_prospects").select("id, created_by").eq("brokerage_id",t);if(a)throw a;const o=(n==null?void 0:n.map(_=>_.id))||[];if(o.length===0)return{recruiters:[],recentActivities:[]};const{data:l,error:i}=await G.from("recruit_activities").select("*").in("prospect_id",o).order("created_at",{ascending:!1});if(i)throw i;const d=[...new Set([...n.map(_=>_.created_by),...(l||[]).map(_=>_.created_by)])],{data:u}=await G.from("profiles").select("id, name, email").in("id",d),p=Object.fromEntries((u||[]).map(_=>[_.id,_])),f=qie(new Date,30);return{recruiters:d.map(_=>{var C,A;const b=(l||[]).filter(I=>I.created_by===_),N=b.filter(I=>new Date(I.created_at)>=f),w={};N.forEach(I=>{w[I.activity_type]=(w[I.activity_type]||0)+1});const S=n.filter(I=>I.created_by===_).length;return{id:_,name:((C=p[_])==null?void 0:C.name)||"Unknown",email:((A=p[_])==null?void 0:A.email)||"",totalActivities:b.length,recentActivities:N.length,byType:w,prospectsCreated:S}}).sort((_,b)=>b.recentActivities-_.recentActivities),recentActivities:(l||[]).slice(0,20)}},enabled:!!t});return r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):s!=null&&s.recruiters.length?e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Recruiter Leaderboard (Last 30 Days)"})}),e.jsx(Oe,{className:"space-y-4",children:s.recruiters.map((n,a)=>e.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg bg-muted/30",children:[e.jsx("div",{className:"flex items-center justify-center h-8 w-8 rounded-full bg-primary/10 text-primary font-bold text-sm",children:a+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ai,{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=y9e[o]||vn;return e.jsxs(Qe,{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(Dt,{children:e.jsx(zt,{className:"text-base",children:"Recent Activity"})}),e.jsx(Oe,{className:"space-y-3",children:s.recentActivities.map(n=>{const a=y9e[n.activity_type]||vn;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:vs(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 ict({brokerageId:t}){const{toast:s}=ja(),r=Qt(),[n,a]=k.useState(!1),[o,l]=k.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),{data:i=[],isLoading:d}=gt({queryKey:["recruit-referrals",t],queryFn:async()=>{const{data:w,error:S}=await G.from("recruit_referrals").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(S)throw S;return w}}),u=[...new Set(i.map(w=>w.referred_by))],{data:p=[]}=gt({queryKey:["referral-profiles",u],queryFn:async()=>{if(!u.length)return[];const{data:w}=await G.from("profiles").select("id, name, email").in("id",u);return w||[]},enabled:u.length>0}),f=Object.fromEntries(p.map(w=>[w.id,w])),y=Pt({mutationFn:async w=>{const{data:{user:S}}=await G.auth.getUser();if(!S)throw new Error("Not authenticated");const{error:C}=await G.from("recruit_referrals").insert({brokerage_id:t,referred_by:S.id,referee_first_name:w.first_name,referee_last_name:w.last_name||null,referee_email:w.email||null,referee_phone:w.phone||null,referee_current_brokerage:w.current_brokerage||null,notes:w.notes||null});if(C)throw C},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-referrals",t]}),s({title:"Referral submitted!"}),l({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),a(!1)},onError:w=>s({title:"Error",description:w.message,variant:"destructive"})}),_=Pt({mutationFn:async({id:w,status:S,incentive_status:C})=>{const A={updated_at:new Date().toISOString()};S&&(A.status=S),C&&(A.incentive_status=C);const{error:I}=await G.from("recruit_referrals").update(A).eq("id",w);if(I)throw I},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-referrals",t]})}),b=w=>w==="approved"||w==="signed"?e.jsx(Zn,{className:"h-3 w-3"}):w==="rejected"?e.jsx(Jl,{className:"h-3 w-3"}):e.jsx(nn,{className:"h-3 w-3"}),N=w=>w==="approved"||w==="signed"||w==="paid"?"bg-green-500/10 text-green-600 border-green-200":w==="rejected"?"bg-red-500/10 text-red-600 border-red-200":"bg-amber-500/10 text-amber-600 border-amber-200";return d?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[i.length," referral",i.length!==1?"s":""]}),e.jsxs(W,{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(Jo,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No referrals yet. Agents can refer potential recruits here."})]}):e.jsx("div",{className:"space-y-3",children:i.map(w=>{var S;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:[w.referee_first_name," ",w.referee_last_name]}),e.jsxs(Qe,{variant:"outline",className:N(w.status),children:[b(w.status)," ",w.status]}),w.incentive_status&&e.jsxs(Qe,{variant:"outline",className:N(w.incentive_status),children:[e.jsx(hi,{className:"h-3 w-3 mr-1"})," ",w.incentive_status]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5",children:[w.referee_email&&e.jsx("p",{children:w.referee_email}),w.referee_phone&&e.jsx("p",{children:w.referee_phone}),w.referee_current_brokerage&&e.jsxs("p",{children:["Currently at: ",w.referee_current_brokerage]}),e.jsxs("p",{children:["Referred by: ",((S=f[w.referred_by])==null?void 0:S.name)||"Unknown"," • ",vs(new Date(w.created_at),"MMM d, yyyy")]})]}),w.notes&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 italic",children:w.notes})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsxs($s,{value:w.status,onValueChange:C=>_.mutate({id:w.id,status:C}),children:[e.jsx(zs,{className:"h-7 text-xs w-[110px]",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"pending",children:"Pending"}),e.jsx(vt,{value:"contacted",children:"Contacted"}),e.jsx(vt,{value:"approved",children:"Approved"}),e.jsx(vt,{value:"signed",children:"Signed"}),e.jsx(vt,{value:"rejected",children:"Rejected"})]})]}),e.jsxs($s,{value:w.incentive_status||"pending",onValueChange:C=>_.mutate({id:w.id,incentive_status:C}),children:[e.jsx(zs,{className:"h-7 text-xs w-[100px]",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"pending",children:"Unpaid"}),e.jsx(vt,{value:"paid",children:"Paid"}),e.jsx(vt,{value:"n/a",children:"N/A"})]})]})]})]})},w.id)})}),e.jsx(fs,{open:n,onOpenChange:a,children:e.jsxs(ps,{children:[e.jsx(ks,{children:e.jsx(_s,{children:"Submit a Recruit Referral"})}),e.jsxs("form",{onSubmit:w=>{w.preventDefault(),y.mutate(o)},className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"First Name *"}),e.jsx(De,{required:!0,value:o.first_name,onChange:w=>l(S=>({...S,first_name:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Last Name"}),e.jsx(De,{value:o.last_name,onChange:w=>l(S=>({...S,last_name:w.target.value}))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Email"}),e.jsx(De,{type:"email",value:o.email,onChange:w=>l(S=>({...S,email:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Phone"}),e.jsx(De,{value:o.phone,onChange:w=>l(S=>({...S,phone:w.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Current Brokerage"}),e.jsx(De,{value:o.current_brokerage,onChange:w=>l(S=>({...S,current_brokerage:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Notes"}),e.jsx(_r,{value:o.notes,onChange:w=>l(S=>({...S,notes:w.target.value})),rows:2})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(W,{type:"submit",disabled:y.isPending,children:"Submit"})]})]})]})})]})}function oct({brokerageId:t}){const{toast:s}=ja(),r=Qt(),[n,a]=k.useState(!1),{data:o}=gt({queryKey:["brokerage-recruit-form",t],queryFn:async()=>{const{data:y,error:_}=await G.from("brokerages").select("id, name, recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(_)throw _;return y}}),{data:l=[]}=gt({queryKey:["recruit-interest-submissions",t],queryFn:async()=>{const{data:y,error:_}=await G.from("recruit_interest_submissions").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(_)throw _;return y}}),i=Pt({mutationFn:async y=>{const{error:_}=await G.from("brokerages").update({recruit_form_enabled:y}).eq("id",t);if(_)throw _},onSuccess:()=>{r.invalidateQueries({queryKey:["brokerage-recruit-form",t]}),s({title:o!=null&&o.recruit_form_enabled?"Form disabled":"Form enabled"})}}),d=Pt({mutationFn:async({id:y,status:_})=>{const{error:b}=await G.from("recruit_interest_submissions").update({status:_}).eq("id",y);if(b)throw b},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-interest-submissions",t]})}),u=`https://bestbrokerage.relevelup.com/join-brokerage/${(o==null?void 0:o.recruit_form_slug)||""}`,p=()=>{navigator.clipboard.writeText(u),a(!0),s({title:"Link copied!"}),setTimeout(()=>a(!1),2e3)},f=y=>y==="contacted"||y==="converted"?"bg-green-500/10 text-green-600":y==="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(Dt,{children:e.jsx(zt,{className:"text-base",children:"Public Interest Form"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(xe,{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(Ar,{checked:(o==null?void 0:o.recruit_form_enabled)||!1,onCheckedChange:y=>i.mutate(y)})]}),(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(W,{size:"sm",variant:"outline",onClick:p,children:n?e.jsx(Zn,{className:"h-3.5 w-3.5"}):e.jsx(Va,{className:"h-3.5 w-3.5"})}),e.jsx(W,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:e.jsx(Yr,{className:"h-3.5 w-3.5"})})})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"text-base",children:["Interest Submissions (",l.length,")"]})}),e.jsx(Oe,{children:l.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Jo,{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(y=>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:[y.first_name," ",y.last_name]}),e.jsx(Qe,{variant:"outline",className:f(y.status),children:y.status})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 text-xs text-muted-foreground",children:[y.email&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(tr,{className:"h-3 w-3"}),y.email]}),y.phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(In,{className:"h-3 w-3"}),y.phone]}),y.current_brokerage&&e.jsxs("span",{children:["From: ",y.current_brokerage]}),y.experience_years&&e.jsxs("span",{children:[y.experience_years,"yr exp"]})]}),y.why_interested&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1 italic",children:['"',y.why_interested,'"']}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:vs(new Date(y.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs($s,{value:y.status,onValueChange:_=>d.mutate({id:y.id,status:_}),children:[e.jsx(zs,{className:"h-7 text-xs w-[110px]",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"new",children:"New"}),e.jsx(vt,{value:"contacted",children:"Contacted"}),e.jsx(vt,{value:"converted",children:"Converted"}),e.jsx(vt,{value:"dismissed",children:"Dismissed"})]})]})]},y.id))})})]})]})}function lct({brokerageId:t}){const{toast:s}=ja(),r=Qt(),[n,a]=k.useState(!1),[o,l]=k.useState({prospect_id:"",title:"",description:"",due_date:vs(ml(new Date,1),"yyyy-MM-dd'T'HH:mm")}),[i,d]=k.useState("pending"),{data:u=[]}=gt({queryKey:["recruit-prospects-list",t],queryFn:async()=>{const{data:L,error:O}=await G.from("recruit_prospects").select("id, first_name, last_name").eq("brokerage_id",t).order("first_name");if(O)throw O;return L}}),{data:p=[],isLoading:f}=gt({queryKey:["recruit-follow-ups",t],queryFn:async()=>{const L=u.map(q=>q.id);if(!L.length)return[];const{data:O,error:V}=await G.from("recruit_follow_ups").select("*").in("prospect_id",L).order("due_date");if(V)throw V;return O},enabled:u.length>0}),y=Object.fromEntries(u.map(L=>[L.id,L])),_=Pt({mutationFn:async L=>{const{data:{user:O}}=await G.auth.getUser();if(!O)throw new Error("Not authenticated");const{error:V}=await G.from("recruit_follow_ups").insert({prospect_id:L.prospect_id,assigned_to:O.id,title:L.title,description:L.description||null,due_date:new Date(L.due_date).toISOString()});if(V)throw V},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-follow-ups",t]}),s({title:"Follow-up scheduled"}),l({prospect_id:"",title:"",description:"",due_date:vs(ml(new Date,1),"yyyy-MM-dd'T'HH:mm")}),a(!1)},onError:L=>s({title:"Error",description:L.message,variant:"destructive"})}),b=Pt({mutationFn:async({id:L,completed:O})=>{const{error:V}=await G.from("recruit_follow_ups").update({completed_at:O?new Date().toISOString():null}).eq("id",L);if(V)throw V},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-follow-ups",t]})}),N=p.filter(L=>i==="pending"?!L.completed_at:i==="completed"?!!L.completed_at:!0),w=N.filter(L=>!L.completed_at&&a0(new Date(L.due_date))&&!iu(new Date(L.due_date))),S=N.filter(L=>!L.completed_at&&iu(new Date(L.due_date))),C=N.filter(L=>!L.completed_at&&!a0(new Date(L.due_date))&&!iu(new Date(L.due_date))),A=N.filter(L=>!!L.completed_at),I=L=>{const O=y[L.prospect_id],V=!L.completed_at&&a0(new Date(L.due_date))&&!iu(new Date(L.due_date));return e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(Ri,{checked:!!L.completed_at,onCheckedChange:q=>b.mutate({id:L.id,completed:q}),className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:`text-sm font-medium ${L.completed_at?"line-through text-muted-foreground":""}`,children:L.title}),L.description&&e.jsx("p",{className:"text-xs text-muted-foreground",children:L.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-xs text-muted-foreground",children:[O&&e.jsxs(Qe,{variant:"secondary",className:"text-[10px]",children:[O.first_name," ",O.last_name]}),e.jsxs("span",{className:`flex items-center gap-1 ${V?"text-destructive font-medium":""}`,children:[V?e.jsx(ro,{className:"h-3 w-3"}):e.jsx(cn,{className:"h-3 w-3"}),vs(new Date(L.due_date),"MMM d, h:mm a")]}),L.is_automated&&e.jsx(Qe,{variant:"outline",className:"text-[10px]",children:"Auto"})]})]})]},L.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(L=>e.jsxs(W,{size:"sm",variant:i===L?"default":"outline",onClick:()=>d(L),className:"capitalize text-xs",children:[L," ",L==="pending"&&w.length+S.length+C.length>0&&`(${w.length+S.length+C.length})`]},L))}),e.jsxs(W,{size:"sm",onClick:()=>a(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Add Follow-up"]})]}),i!=="completed"&&w.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-destructive flex items-center gap-1",children:[e.jsx(ro,{className:"h-3.5 w-3.5"})," Overdue (",w.length,")"]}),w.map(I)]}),i!=="completed"&&S.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(nn,{className:"h-3.5 w-3.5"})," Today (",S.length,")"]}),S.map(I)]}),i!=="completed"&&C.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(cn,{className:"h-3.5 w-3.5"})," Upcoming (",C.length,")"]}),C.map(I)]}),i!=="pending"&&A.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(Zn,{className:"h-3.5 w-3.5"})," Completed (",A.length,")"]}),A.map(I)]}),N.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(ks,{children:e.jsx(_s,{children:"Schedule Follow-up"})}),e.jsxs("form",{onSubmit:L=>{L.preventDefault(),_.mutate(o)},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Prospect *"}),e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm",required:!0,value:o.prospect_id,onChange:L=>l(O=>({...O,prospect_id:L.target.value})),children:[e.jsx("option",{value:"",children:"Select prospect..."}),u.map(L=>e.jsxs("option",{value:L.id,children:[L.first_name," ",L.last_name]},L.id))]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Task *"}),e.jsx(De,{required:!0,value:o.title,onChange:L=>l(O=>({...O,title:L.target.value})),placeholder:"e.g. Follow-up call"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Details"}),e.jsx(_r,{value:o.description,onChange:L=>l(O=>({...O,description:L.target.value})),rows:2})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Due Date *"}),e.jsx(De,{type:"datetime-local",required:!0,value:o.due_date,onChange:L=>l(O=>({...O,due_date:L.target.value}))})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(W,{type:"submit",disabled:_.isPending,children:"Schedule"})]})]})]})})]})}const zSs=[{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 cct({brokerageId:t}){const{toast:s}=ja(),r=Qt(),[n,a]=k.useState(null),{data:o,isLoading:l}=gt({queryKey:["recruit-landing-settings",t],queryFn:async()=>{const{data:w,error:S}=await G.from("recruit_landing_page_settings").select("*").eq("brokerage_id",t).maybeSingle();if(S)throw S;return w}}),[i,d]=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:zSs,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&&d({id:o.id,brokerage_id:o.brokerage_id,hero_headline:o.hero_headline,hero_subtext:o.hero_subtext||"",hero_image_url:o.hero_image_url,logo_url:o.logo_url,primary_color:o.primary_color,accent_color:o.accent_color,benefits:o.benefits||[],testimonials:o.testimonials||[],gallery_images:o.gallery_images||[],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=Pt({mutationFn:async()=>{const w={brokerage_id:t,hero_headline:i.hero_headline,hero_subtext:i.hero_subtext,hero_image_url:i.hero_image_url,logo_url:i.logo_url,primary_color:i.primary_color,accent_color:i.accent_color,benefits:JSON.parse(JSON.stringify(i.benefits)),testimonials:JSON.parse(JSON.stringify(i.testimonials)),gallery_images:JSON.parse(JSON.stringify(i.gallery_images)),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:S}=await G.from("recruit_landing_page_settings").update(w).eq("id",i.id);if(S)throw S}else{const{error:S}=await G.from("recruit_landing_page_settings").insert(w);if(S)throw S}},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-landing-settings",t]}),s({title:"Landing page saved!"})},onError:w=>s({title:"Error",description:w.message,variant:"destructive"})}),p=async(w,S)=>{const C=w.name.split(".").pop(),A=`${t}/${S}-${Date.now()}.${C}`,{error:I}=await G.storage.from("recruit-landing").upload(A,w);if(I)throw I;const{data:{publicUrl:L}}=G.storage.from("recruit-landing").getPublicUrl(A);return L},f=async(w,S)=>{var A;const C=(A=w.target.files)==null?void 0:A[0];if(C){a(S);try{const I=await p(C,S);d(L=>({...L,[S]:I})),s({title:"Image uploaded!"})}catch(I){s({title:"Upload failed",description:I.message,variant:"destructive"})}finally{a(null)}}},y=async w=>{var C;const S=(C=w.target.files)==null?void 0:C[0];if(S){a("gallery");try{const A=await p(S,"gallery");d(I=>({...I,gallery_images:[...I.gallery_images,A]})),s({title:"Gallery image added!"})}catch(A){s({title:"Upload failed",description:A.message,variant:"destructive"})}finally{a(null)}}},_=async(w,S)=>{var A;const C=(A=w.target.files)==null?void 0:A[0];if(C){a(`testimonial-${S}`);try{const I=await p(C,`testimonial-${S}`);d(L=>{const O=[...L.testimonials];return O[S]={...O[S],photo_url:I},{...L,testimonials:O}})}catch(I){s({title:"Upload failed",description:I.message,variant:"destructive"})}finally{a(null)}}},{data:b}=gt({queryKey:["brokerage-slug-for-landing",t],queryFn:async()=>{const{data:w,error:S}=await G.from("brokerages").select("recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(S)throw S;return w}}),N=`https://bestbrokerage.relevelup.com/join-brokerage/${(b==null?void 0:b.recruit_form_slug)||""}`;return l?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-6",children:[(b==null?void 0:b.recruit_form_enabled)&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted/50 rounded-lg border",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Live page:"}),e.jsx("code",{className:"text-xs flex-1 truncate",children:N}),e.jsx(W,{size:"sm",variant:"outline",asChild:!0,children:e.jsxs("a",{href:N,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Yr,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Branding"})}),e.jsx(Oe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(xe,{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(W,{variant:"outline",size:"sm",asChild:!0,disabled:n==="logo_url",children:e.jsxs("span",{children:[e.jsx(Ra,{className:"h-3.5 w-3.5 mr-1"}),n==="logo_url"?"Uploading...":"Upload Logo"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:w=>f(w,"logo_url")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Primary Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:i.primary_color,onChange:w=>d(S=>({...S,primary_color:w.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(De,{value:i.primary_color,onChange:w=>d(S=>({...S,primary_color:w.target.value})),className:"font-mono text-xs"})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Accent Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:i.accent_color,onChange:w=>d(S=>({...S,accent_color:w.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(De,{value:i.accent_color,onChange:w=>d(S=>({...S,accent_color:w.target.value})),className:"font-mono text-xs"})]})]})]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Hero Section"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Headline"}),e.jsx(De,{value:i.hero_headline,onChange:w=>d(S=>({...S,hero_headline:w.target.value})),placeholder:"Join Our Team"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Subtext"}),e.jsx(_r,{value:i.hero_subtext,onChange:w=>d(S=>({...S,hero_subtext:w.target.value})),rows:2,placeholder:"Take your career to the next level..."})]}),e.jsxs("div",{children:[e.jsx(xe,{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(W,{variant:"outline",size:"sm",asChild:!0,disabled:n==="hero_image_url",children:e.jsxs("span",{children:[e.jsx(Ra,{className:"h-3.5 w-3.5 mr-1"}),n==="hero_image_url"?"Uploading...":"Upload Image"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:w=>f(w,"hero_image_url")})]}),i.hero_image_url&&e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>d(w=>({...w,hero_image_url:null})),children:e.jsx(vr,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{className:"text-base",children:"Benefits / Why Join Us"}),e.jsxs(W,{size:"sm",variant:"outline",onClick:()=>d(w=>({...w,benefits:[...w.benefits,{title:"",description:"",icon:"✨"}]})),children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(Oe,{className:"space-y-3",children:[i.benefits.map((w,S)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(mu,{className:"h-4 w-4 mt-2 text-muted-foreground"}),e.jsx(De,{value:w.icon,onChange:C=>{const A=[...i.benefits];A[S]={...w,icon:C.target.value},d(I=>({...I,benefits:A}))},className:"w-14 text-center"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(De,{value:w.title,onChange:C=>{const A=[...i.benefits];A[S]={...w,title:C.target.value},d(I=>({...I,benefits:A}))},placeholder:"Benefit title"}),e.jsx(De,{value:w.description,onChange:C=>{const A=[...i.benefits];A[S]={...w,description:C.target.value},d(I=>({...I,benefits:A}))},placeholder:"Short description"})]}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>d(C=>({...C,benefits:C.benefits.filter((A,I)=>I!==S)})),children:e.jsx(vr,{className:"h-3.5 w-3.5 text-destructive"})})]},S)),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(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{className:"text-base",children:"Testimonials"}),e.jsxs(W,{size:"sm",variant:"outline",onClick:()=>d(w=>({...w,testimonials:[...w.testimonials,{name:"",role:"",quote:""}]})),children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(Oe,{className:"space-y-3",children:[i.testimonials.map((w,S)=>{var C;return e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[w.photo_url?e.jsx("img",{src:w.photo_url,alt:w.name,className:"h-10 w-10 rounded-full object-cover"}):e.jsx("div",{className:"h-10 w-10 rounded-full bg-muted flex items-center justify-center text-xs text-muted-foreground",children:((C=w.name)==null?void 0:C[0])||"?"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("span",{className:"text-[10px] text-primary hover:underline",children:n===`testimonial-${S}`?"...":"Photo"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:A=>_(A,S)})]})]}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(De,{value:w.name,onChange:A=>{const I=[...i.testimonials];I[S]={...w,name:A.target.value},d(L=>({...L,testimonials:I}))},placeholder:"Name"}),e.jsx(De,{value:w.role,onChange:A=>{const I=[...i.testimonials];I[S]={...w,role:A.target.value},d(L=>({...L,testimonials:I}))},placeholder:"Role / Title"})]}),e.jsx(_r,{value:w.quote,onChange:A=>{const I=[...i.testimonials];I[S]={...w,quote:A.target.value},d(L=>({...L,testimonials:I}))},placeholder:"What they say about working here...",rows:2})]}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>d(A=>({...A,testimonials:A.testimonials.filter((I,L)=>L!==S)})),children:e.jsx(vr,{className:"h-3.5 w-3.5 text-destructive"})})]},S)}),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(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{className:"text-base",children:"Team & Culture Gallery"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(W,{size:"sm",variant:"outline",asChild:!0,disabled:n==="gallery",children:e.jsxs("span",{children:[e.jsx(qo,{className:"h-3.5 w-3.5 mr-1"}),n==="gallery"?"Uploading...":"Add Photo"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:y})]})]}),e.jsx(Oe,{children:i.gallery_images.length>0?e.jsx("div",{className:"grid grid-cols-3 md:grid-cols-4 gap-2",children:i.gallery_images.map((w,S)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:w,alt:`Gallery ${S+1}`,className:"h-24 w-full object-cover rounded-lg"}),e.jsx(W,{variant:"destructive",size:"sm",className:"absolute top-1 right-1 h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>d(C=>({...C,gallery_images:C.gallery_images.filter((A,I)=>I!==S)})),children:e.jsx(vr,{className:"h-3 w-3"})})]},S))}):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(Dt,{children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Or,{className:"h-4 w-4 text-primary"})," Form Style & Trust"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Application Form Style"}),e.jsxs($s,{value:i.form_style,onValueChange:w=>d(S=>({...S,form_style:w})),children:[e.jsx(zs,{className:"mt-1.5",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"classic",children:"Classic — single-page form (all fields visible)"}),e.jsx(vt,{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(ad,{className:"h-4 w-4 mt-0.5 text-primary"}),e.jsxs("div",{children:[e.jsx(xe,{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(Ar,{checked:i.confidential_messaging,onCheckedChange:w=>d(S=>({...S,confidential_messaging:w}))})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(_M,{className:"h-4 w-4 text-primary"})," Split & Income Calculator"]}),e.jsx(Ar,{checked:i.calculator_enabled,onCheckedChange:w=>d(S=>({...S,calculator_enabled:w}))})]}),i.calculator_enabled&&e.jsxs(Oe,{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(xe,{className:"text-xs",children:"Calculator Headline"}),e.jsx(De,{value:i.calculator_config.headline||"",onChange:w=>d(S=>({...S,calculator_config:{...S.calculator_config,headline:w.target.value}})),placeholder:"See What You Could Earn With Us"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Subtext"}),e.jsx(De,{value:i.calculator_config.subtext||"",onChange:w=>d(S=>({...S,calculator_config:{...S.calculator_config,subtext:w.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(xe,{className:"text-xs",children:"Your Split %"}),e.jsx(De,{type:"number",value:i.calculator_config.commission_split_pct??80,onChange:w=>d(S=>({...S,calculator_config:{...S.calculator_config,commission_split_pct:parseFloat(w.target.value)||0}}))}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:"Agent keeps"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Cap Amount ($)"}),e.jsx(De,{type:"number",value:i.calculator_config.cap_amount??16e3,onChange:w=>d(S=>({...S,calculator_config:{...S.calculator_config,cap_amount:parseFloat(w.target.value)||0}}))}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:"Annual cap"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Monthly Fee ($)"}),e.jsx(De,{type:"number",value:i.calculator_config.monthly_fee??99,onChange:w=>d(S=>({...S,calculator_config:{...S.calculator_config,monthly_fee:parseFloat(w.target.value)||0}}))})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Per-Txn Fee ($)"}),e.jsx(De,{type:"number",value:i.calculator_config.transaction_fee??0,onChange:w=>d(S=>({...S,calculator_config:{...S.calculator_config,transaction_fee:parseFloat(w.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(xe,{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(Ar,{checked:i.calculator_config.show_email_capture!==!1,onCheckedChange:w=>d(S=>({...S,calculator_config:{...S.calculator_config,show_email_capture:w}}))})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(J4,{className:"h-4 w-4 text-primary"})," Lead Magnet (Gated PDF)"]}),e.jsx(Ar,{checked:i.lead_magnet_enabled,onCheckedChange:w=>d(S=>({...S,lead_magnet_enabled:w}))})]}),i.lead_magnet_enabled&&e.jsxs(Oe,{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(xe,{className:"text-xs",children:"Title"}),e.jsx(De,{value:i.lead_magnet_config.title||"",onChange:w=>d(S=>({...S,lead_magnet_config:{...S.lead_magnet_config,title:w.target.value}})),placeholder:"Get the Full Comp Plan PDF"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Description"}),e.jsx(_r,{rows:2,value:i.lead_magnet_config.description||"",onChange:w=>d(S=>({...S,lead_magnet_config:{...S.lead_magnet_config,description:w.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(xe,{className:"text-xs",children:"Button Text"}),e.jsx(De,{value:i.lead_magnet_config.button_text||"",onChange:w=>d(S=>({...S,lead_magnet_config:{...S.lead_magnet_config,button_text:w.target.value}})),placeholder:"Email Me the PDF"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"PDF / File URL"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(De,{value:i.lead_magnet_config.pdf_url||"",onChange:w=>d(S=>({...S,lead_magnet_config:{...S.lead_magnet_config,pdf_url:w.target.value||null}})),placeholder:"https://...",className:"flex-1"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(W,{variant:"outline",size:"sm",asChild:!0,disabled:n==="lead_magnet_pdf",children:e.jsxs("span",{children:[e.jsx(Ra,{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 w=>{var C;const S=(C=w.target.files)==null?void 0:C[0];if(S){a("lead_magnet_pdf");try{const A=await p(S,"lead-magnet");d(I=>({...I,lead_magnet_config:{...I.lead_magnet_config,pdf_url:A}})),s({title:"PDF uploaded!"})}catch(A){s({title:"Upload failed",description:A.message,variant:"destructive"})}finally{a(null)}}}})]})]})]})]})]})]}),e.jsx(BSs,{brokerageId:t}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(W,{onClick:()=>u.mutate(),disabled:u.isPending,size:"lg",children:[e.jsx(bc,{className:"h-4 w-4 mr-2"}),u.isPending?"Saving...":"Save Landing Page"]})})]})}function BSs({brokerageId:t}){const{data:s=[]}=gt({queryKey:["lead-magnet-downloads",t],queryFn:async()=>{const{data:r,error:n}=await G.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(Dt,{children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Qa,{className:"h-4 w-4 text-primary"})," Lead Magnet Downloads (",s.length,")"]})}),e.jsx(Oe,{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:[vs(new Date(r.created_at),"MMM d, yyyy h:mm a")," · via ",r.source]})]})},r.id))})})]})}function $Ss(t){if(!t)return"—";const s=Math.floor(t/60),r=t%60;return s>0?`${s}m ${r}s`:`${r}s`}function qSs({video:t}){return t.cta_clicked_at?e.jsx(Qe,{className:"bg-emerald-500/10 text-emerald-600 border-emerald-200",children:"CTA Clicked"}):t.view_count>0?e.jsxs(Qe,{className:"bg-blue-500/10 text-blue-600 border-blue-200",children:[e.jsx(jn,{className:"h-3 w-3 mr-1"}),t.view_count," views"]}):t.sent_at?e.jsxs(Qe,{variant:"secondary",children:[e.jsx(_n,{className:"h-3 w-3 mr-1"}),"Sent"]}):e.jsxs(Qe,{variant:"outline",children:[e.jsx(nn,{className:"h-3 w-3 mr-1"}),"Draft"]})}function dct({brokerageId:t}){const{data:s=[],isLoading:r}=PSs(t),{data:n=[]}=Jlt(t),a=LSs(),o=DSs(),l=Qlt(),[i,d]=k.useState(""),[u,p]=k.useState(!1),[f,y]=k.useState({title:"",script_text:"",category:"general"}),_=s.filter(C=>{var I,L,O,V;return i?`${((I=C.prospect)==null?void 0:I.first_name)||""} ${((L=C.prospect)==null?void 0:L.last_name)||""}`.toLowerCase().includes(i.toLowerCase())||((V=(O=C.video)==null?void 0:O.title)==null?void 0:V.toLowerCase().includes(i.toLowerCase())):!0}),b={total:s.length,sent:s.filter(C=>C.sent_at).length,viewed:s.filter(C=>C.view_count>0).length,ctaClicked:s.filter(C=>C.cta_clicked_at).length},N=k.useCallback(C=>{if(!C)return;const A=`${window.location.origin}/recruit-video/${C}`;navigator.clipboard.writeText(A),pe.success("Share link copied")},[]),w=k.useCallback((C,A)=>{l.mutate({id:C,sent_via:A})},[l]),S=()=>{!f.title.trim()||!f.script_text.trim()||a.mutate({brokerage_id:t,...f},{onSuccess:()=>{y({title:"",script_text:"",category:"general"}),p(!1)}})};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[{label:"Total Videos",value:b.total,icon:yn,color:"text-primary"},{label:"Sent",value:b.sent,icon:_n,color:"text-blue-500"},{label:"Viewed",value:b.viewed,icon:jn,color:"text-amber-500"},{label:"CTA Clicked",value:b.ctaClicked,icon:$n,color:"text-emerald-500"}].map(C=>e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:`h-10 w-10 rounded-lg bg-muted flex items-center justify-center ${C.color}`,children:e.jsx(C.icon,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:C.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C.label})]})]})},C.label))}),e.jsxs(ta,{defaultValue:"videos",className:"space-y-4",children:[e.jsxs(Jn,{children:[e.jsxs(cs,{value:"videos",children:[e.jsx(yn,{className:"h-4 w-4 mr-1.5"}),"All Videos"]}),e.jsxs(cs,{value:"scripts",children:[e.jsx(vn,{className:"h-4 w-4 mr-1.5"}),"Script Library"]}),e.jsxs(cs,{value:"analytics",children:[e.jsx(so,{className:"h-4 w-4 mr-1.5"}),"Engagement"]})]}),e.jsx(Ss,{value:"videos",children:e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(zt,{className:"text-lg",children:"Video Outreach"}),e.jsxs("div",{className:"relative w-64",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name or title...",value:i,onChange:C=>d(C.target.value),className:"pl-9"})]})]})}),e.jsx(Oe,{children:r?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):_.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(yn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No video outreach yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Record a personalized video from any prospect's profile card"})]}):e.jsx("div",{className:"space-y-3",children:_.map(C=>{var A,I,L,O,V,q;return e.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg border bg-card hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"relative h-16 w-28 rounded-md overflow-hidden bg-muted flex-shrink-0",children:[(A=C.video)!=null&&A.thumbnail_url?e.jsx("img",{src:C.video.thumbnail_url,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer"}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(yn,{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:$Ss(((I=C.video)==null?void 0:I.duration_seconds)??null)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("p",{className:"font-medium truncate",children:[(L=C.prospect)==null?void 0:L.first_name," ",(O=C.prospect)==null?void 0:O.last_name]}),e.jsx(qSs,{video:C})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:((V=C.video)==null?void 0:V.title)||"Untitled video"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[vs(new Date(C.created_at),"MMM d, yyyy"),((q=C.prospect)==null?void 0:q.current_brokerage)&&` · ${C.prospect.current_brokerage}`]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>N(C.share_token),title:"Copy share link",children:e.jsx(Va,{className:"h-4 w-4"})}),!C.sent_at&&e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>w(C.id,"email"),title:"Mark as sent",children:e.jsx(_n,{className:"h-4 w-4"})}),C.share_token&&e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>window.open(`/recruit-video/${C.share_token}`,"_blank"),title:"Preview landing page",children:e.jsx(Yr,{className:"h-4 w-4"})})]})]},C.id)})})})]})}),e.jsx(Ss,{value:"scripts",children:e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(zt,{className:"text-lg",children:"Recruiting Scripts"}),e.jsxs(fs,{open:u,onOpenChange:p,children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{size:"sm",children:[e.jsx(qs,{className:"h-4 w-4 mr-1.5"}),"New Script"]})}),e.jsxs(ps,{children:[e.jsx(ks,{children:e.jsx(_s,{children:"Create Recruiting Script"})}),e.jsxs("div",{className:"space-y-4 mt-2",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Title"}),e.jsx(De,{value:f.title,onChange:C=>y(A=>({...A,title:C.target.value})),placeholder:"e.g., Why Switch to Our Brokerage"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Category"}),e.jsxs($s,{value:f.category,onValueChange:C=>y(A=>({...A,category:C})),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsx(Bs,{children:e2e.map(C=>e.jsx(vt,{value:C.value,children:C.label},C.value))})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Script"}),e.jsx(_r,{value:f.script_text,onChange:C=>y(A=>({...A,script_text:C.target.value})),placeholder:"Hi [Name], I noticed you've been doing great work at [Brokerage]...",rows:8})]}),e.jsx(W,{onClick:S,disabled:!f.title.trim()||!f.script_text.trim(),className:"w-full",children:"Save Script"})]})]})]})]})}),e.jsx(Oe,{children:n.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(vn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No scripts yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Create teleprompter scripts for common recruiting conversations"})]}):e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:n.map(C=>{var I;const A=((I=e2e.find(L=>L.value===C.category))==null?void 0:I.label)||C.category;return e.jsx(Pe,{className:"relative group",children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(Qe,{variant:"outline",className:"text-[10px] mb-2",children:A}),e.jsx("h4",{className:"font-medium text-sm",children:C.title})]}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity text-destructive",onClick:()=>o.mutate(C.id),children:e.jsx(vr,{className:"h-3.5 w-3.5"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 line-clamp-3",children:C.script_text}),C.is_global&&e.jsx(Qe,{variant:"secondary",className:"mt-2 text-[10px]",children:"Template"})]})},C.id)})})})]})}),e.jsx(Ss,{value:"analytics",children:e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"Engagement Funnel"})}),e.jsxs(Oe,{children:[e.jsx("div",{className:"space-y-4",children:[{label:"Videos Created",count:b.total,pct:100,color:"bg-primary"},{label:"Sent to Prospects",count:b.sent,pct:b.total?Math.round(b.sent/b.total*100):0,color:"bg-blue-500"},{label:"Viewed by Prospect",count:b.viewed,pct:b.sent?Math.round(b.viewed/b.sent*100):0,color:"bg-amber-500"},{label:"CTA Clicked",count:b.ctaClicked,pct:b.viewed?Math.round(b.ctaClicked/b.viewed*100):0,color:"bg-emerald-500"}].map(C=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:C.label}),e.jsxs("span",{className:"font-medium",children:[C.count," (",C.pct,"%)"]})]}),e.jsx("div",{className:"h-3 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${C.color} rounded-full transition-all`,style:{width:`${C.pct}%`}})})]},C.label))}),s.filter(C=>C.view_count>0).length>0&&e.jsxs("div",{className:"mt-8",children:[e.jsx("h4",{className:"font-medium text-sm mb-3",children:"Most Engaged Prospects"}),e.jsx("div",{className:"space-y-2",children:s.filter(C=>C.view_count>0).sort((C,A)=>A.view_count-C.view_count).slice(0,5).map(C=>{var A,I;return e.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded-md bg-muted/30",children:[e.jsxs("span",{className:"font-medium",children:[(A=C.prospect)==null?void 0:A.first_name," ",(I=C.prospect)==null?void 0:I.last_name]}),e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(jn,{className:"h-3.5 w-3.5"})," ",C.view_count]}),C.cta_clicked_at&&e.jsx($n,{className:"h-4 w-4 text-emerald-500"})]})]},C.id)})})]})]})]})})]})]})}function uct({brokerageId:t}){const{toast:s}=ja(),r=Qt(),{stages:n,prospects:a}=PO(t),[o,l]=k.useState(!1),[i,d]=k.useState({title:"",target_count:"10",target_stage_id:"",period_start:vs(new Date,"yyyy-MM-dd"),period_end:vs(new Date(new Date().getFullYear(),new Date().getMonth()+3,0),"yyyy-MM-dd")}),{data:u=[],isLoading:p}=gt({queryKey:["recruit-goals",t],queryFn:async()=>{const{data:b,error:N}=await G.from("recruit_goals").select("*").eq("brokerage_id",t).order("period_end",{ascending:!1});if(N)throw N;return b}}),f=Pt({mutationFn:async b=>{const{data:{user:N}}=await G.auth.getUser();if(!N)throw new Error("Not authenticated");const{error:w}=await G.from("recruit_goals").insert({brokerage_id:t,title:b.title,target_count:parseInt(b.target_count),target_stage_id:b.target_stage_id||null,period_start:b.period_start,period_end:b.period_end,created_by:N.id});if(w)throw w},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-goals",t]}),s({title:"Goal created"}),l(!1)},onError:b=>s({title:"Error",description:b.message,variant:"destructive"})}),y=Pt({mutationFn:async b=>{const{error:N}=await G.from("recruit_goals").delete().eq("id",b);if(N)throw N},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-goals",t]}),s({title:"Goal removed"})}}),_=b=>{const N=n.find(S=>S.id===b.target_stage_id);return{count:a.filter(S=>gg(new Date(S.created_at),{start:new Date(b.period_start),end:new Date(b.period_end)})?b.target_stage_id?S.stage_id===b.target_stage_id:!0:!1).length,stage:N}};return p?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[u.length," goal",u.length!==1?"s":""]}),e.jsxs(W,{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(Rh,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No goals set. Create a recruiting target to track progress."})]}):e.jsx("div",{className:"grid md:grid-cols-2 gap-4",children:u.map(b=>{const{count:N,stage:w}=_(b),S=Math.min(100,N/b.target_count*100),C=gg(new Date,{start:new Date(b.period_start),end:new Date(b.period_end)});return e.jsxs(Pe,{className:C?"":"opacity-60",children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{className:"text-sm",children:b.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[vs(new Date(b.period_start),"MMM d")," – ",vs(new Date(b.period_end),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[C?e.jsx(Qe,{className:"text-[10px]",children:"Active"}):e.jsx(Qe,{variant:"secondary",className:"text-[10px]",children:"Ended"}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground",onClick:()=>y.mutate(b.id),children:e.jsx(vr,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(Oe,{className:"space-y-2",children:[w&&e.jsxs(Qe,{variant:"outline",className:"text-[10px]",style:{borderColor:w.color,color:w.color},children:["Stage: ",w.name]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"font-bold text-lg",children:N}),e.jsxs("span",{className:"text-muted-foreground",children:["/ ",b.target_count]})]}),e.jsx(xi,{value:S,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[S.toFixed(0),"% complete"]})]})]},b.id)})}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{children:[e.jsx(ks,{children:e.jsx(_s,{children:"Create Recruiting Goal"})}),e.jsxs("form",{onSubmit:b=>{b.preventDefault(),f.mutate(i)},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Goal Title *"}),e.jsx(De,{required:!0,value:i.title,onChange:b=>d(N=>({...N,title:b.target.value})),placeholder:"e.g. Q2 Recruiting Target"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Target Count *"}),e.jsx(De,{type:"number",min:"1",required:!0,value:i.target_count,onChange:b=>d(N=>({...N,target_count:b.target.value}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Target Stage (optional)"}),e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:i.target_stage_id,onChange:b=>d(N=>({...N,target_stage_id:b.target.value})),children:[e.jsx("option",{value:"",children:"All stages (total prospects)"}),n.map(b=>e.jsx("option",{value:b.id,children:b.name},b.id))]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Count prospects that reach this stage"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Start Date"}),e.jsx(De,{type:"date",required:!0,value:i.period_start,onChange:b=>d(N=>({...N,period_start:b.target.value}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"End Date"}),e.jsx(De,{type:"date",required:!0,value:i.period_end,onChange:b=>d(N=>({...N,period_end:b.target.value}))})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(W,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(W,{type:"submit",disabled:f.isPending,children:"Create Goal"})]})]})]})})]})}const USs={first_name:"Sarah",brokerage_name:"ABC Realty",city:"Austin",sender_name:"Jeremy"};function hct({email:t,mergeValues:s=USs,selectedSubjectIndex:r,onClose:n}){var d;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=((d=t.subject_line_options)==null?void 0:d.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(ks,{className:"px-6 pt-6 pb-4 border-b",children:[e.jsxs(_s,{className:"text-base",children:["Email #",t.email_number," — ",t.title]}),e.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[e.jsxs(Qe,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(nn,{className:"h-3 w-3"}),t.email_number===1?"Sent immediately":`Day ${t.delay_days}`]}),o.length>1&&e.jsxs(Qe,{variant:"secondary",className:"text-xs",children:[o.length," subject variants"]})]})]}),e.jsxs("div",{className:"space-y-0",children:[o.length>1&&e.jsxs("div",{className:"px-6 py-3 border-b bg-muted/20",children:[e.jsx("p",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-2",children:"Subject Line Options"}),e.jsx("div",{className:"flex flex-col gap-1.5",children:o.map((u,p)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-[10px] font-bold uppercase px-1.5 py-0.5 rounded ${p===l?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"}`,children:p===l?"Selected":p===0?"Primary":`Alt ${p}`}),e.jsx("span",{className:"text-sm",children:a(u)})]},p))})]}),e.jsxs("div",{className:"border-b",children:[e.jsxs("div",{className:"px-6 py-2 flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium w-14",children:"From:"}),e.jsxs("span",{children:[s.sender_name," "]})]}),e.jsxs("div",{className:"px-6 py-2 flex items-center gap-2 text-xs text-muted-foreground border-t",children:[e.jsx("span",{className:"font-medium w-14",children:"To:"}),e.jsxs("span",{children:[s.first_name," "]})]}),e.jsxs("div",{className:"px-6 py-2 flex items-center gap-2 text-xs border-t",children:[e.jsx("span",{className:"font-medium w-14 text-muted-foreground",children:"Subject:"}),e.jsx("span",{className:"font-medium",children:a(i)})]})]}),e.jsx("div",{className:"bg-white px-8 py-6",children:e.jsx("div",{className:"prose prose-sm max-w-none [&_p]:my-3 [&_p+p]:mt-4 [&_br]:block [&_br]:mt-2",style:{fontSize:"15px",lineHeight:"1.75",color:"#1a1a1a"},dangerouslySetInnerHTML:{__html:a(t.body_html)}})})]})]})})}function VCe({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}=gt({queryKey:["brokerage-recruit-settings",t],queryFn:async()=>{const{data:d,error:u}=await G.from("brokerage_recruit_settings").select("*").eq("brokerage_id",t).maybeSingle();if(u)throw u;return d}}),{data:o}=gt({queryKey:["brokerage-detail",t],queryFn:async()=>{const{data:d,error:u}=await G.from("brokerages").select("name, city, state").eq("id",t).single();if(u)throw u;return d}});k.useEffect(()=>{a?n({...a,merge_fields:a.merge_fields||{city:"",broker_name:""}}):o&&n(d=>({...d,merge_fields:{...d.merge_fields,brokerage_name:o.name,city:o.city||""}}))},[a,o]);const l=Pt({mutationFn:async()=>{const d={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 G.from("brokerage_recruit_settings").update(d).eq("id",a.id);if(u)throw u}else{const{error:u}=await G.from("brokerage_recruit_settings").insert(d);if(u)throw u}},onSuccess:()=>{s.invalidateQueries({queryKey:["brokerage-recruit-settings",t]}),pe.success("Recruiting email settings saved!")},onError:d=>pe.error(d.message)}),i=(d,u)=>{n(p=>({...p,merge_fields:{...p.merge_fields,[d]: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(xe,{className:"text-xs",children:"Sender Display Name"}),e.jsx(De,{value:r.sender_name,onChange:d=>n({...r,sender_name:d.target.value}),placeholder:"e.g. Jeremy at LevelUp"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(xe,{className:"text-xs",children:"Sender Email Address"}),e.jsx(De,{value:r.sender_email,onChange:d=>n({...r,sender_email:d.target.value}),placeholder:"recruiting@relevelup.com"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Must be a verified SES identity. Verify your own address below to send from it."})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(xe,{className:"text-xs",children:"Reply-To Email (optional)"}),e.jsx(De,{value:r.reply_to_email,onChange:d=>n({...r,reply_to_email:d.target.value}),placeholder:"jeremy@relevelup.com"})]})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(t1,{className:"h-4 w-4 text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Sender Verification (Amazon SES)"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-4",children:["Verify any email address with AWS so recruiting emails can be sent from that address (e.g. your own broker email, instead of ",e.jsx("code",{className:"px-1 py-0.5 rounded bg-muted text-[10px]",children:"recruiting@relevelup.com"}),")."]}),e.jsx(Vlt,{brokerageId:t,onVerifiedSelect:d=>{n(u=>({...u,sender_email:d})),pe.success(`Sender set to ${d}`)}})]}),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(xe,{className:"text-xs",children:"{{brokerage_name}}"}),e.jsx(De,{value:r.merge_fields.brokerage_name||"",onChange:d=>i("brokerage_name",d.target.value),placeholder:(o==null?void 0:o.name)||"Brokerage Name"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(xe,{className:"text-xs",children:"{{city}}"}),e.jsx(De,{value:r.merge_fields.city||"",onChange:d=>i("city",d.target.value),placeholder:"e.g. Austin"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(xe,{className:"text-xs",children:"{{sender_name}}"}),e.jsx(De,{value:r.merge_fields.sender_name||"",onChange:d=>i("sender_name",d.target.value),placeholder:"e.g. Jeremy"})]})]})]}),e.jsxs(W,{onClick:()=>l.mutate(),disabled:l.isPending,className:"w-full",children:[e.jsx(bc,{className:"h-4 w-4 mr-1"})," Save Settings"]})]})}const VSs=qg.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",jc(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()}}}),v9e=[{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 Qu({onClick:t,active:s,disabled:r,icon:n,tooltip:a}){return e.jsxs(ec,{children:[e.jsx(tc,{asChild:!0,children:e.jsx(W,{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(Dl,{side:"bottom",className:"text-xs",children:a})]})}function HSs({content:t,onChange:s}){const r=Oke({extensions:[zke.configure({heading:{levels:[1,2,3]}}),VSs,Zke.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}}),Yke.configure({types:["heading","paragraph"]}),Xke,Iat],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(S1,{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(Qu,{onClick:()=>r.chain().focus().toggleBold().run(),active:r.isActive("bold"),icon:K4,tooltip:"Bold"}),e.jsx(Qu,{onClick:()=>r.chain().focus().toggleItalic().run(),active:r.isActive("italic"),icon:rS,tooltip:"Italic"}),e.jsx(Qu,{onClick:()=>r.chain().focus().toggleUnderline().run(),active:r.isActive("underline"),icon:VL,tooltip:"Underline"}),e.jsx(Qu,{onClick:()=>r.chain().focus().toggleStrike().run(),active:r.isActive("strike"),icon:BL,tooltip:"Strikethrough"}),e.jsx(ho,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(Qu,{onClick:()=>r.chain().focus().toggleHeading({level:1}).run(),active:r.isActive("heading",{level:1}),icon:SM,tooltip:"Heading 1"}),e.jsx(Qu,{onClick:()=>r.chain().focus().toggleHeading({level:2}).run(),active:r.isActive("heading",{level:2}),icon:CM,tooltip:"Heading 2"}),e.jsx(Qu,{onClick:()=>r.chain().focus().toggleHeading({level:3}).run(),active:r.isActive("heading",{level:3}),icon:vL,tooltip:"Heading 3"}),e.jsx(ho,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(Qu,{onClick:()=>r.chain().focus().toggleBulletList().run(),active:r.isActive("bulletList"),icon:Dh,tooltip:"Bullet List"}),e.jsx(Qu,{onClick:()=>r.chain().focus().toggleOrderedList().run(),active:r.isActive("orderedList"),icon:Xy,tooltip:"Numbered List"}),e.jsx(Qu,{onClick:()=>r.chain().focus().toggleBlockquote().run(),active:r.isActive("blockquote"),icon:pS,tooltip:"Blockquote"}),e.jsx(Qu,{onClick:()=>r.chain().focus().setHorizontalRule().run(),icon:Qy,tooltip:"Divider"}),e.jsx(ho,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(Qu,{onClick:()=>r.chain().focus().setTextAlign("left").run(),active:r.isActive({textAlign:"left"}),icon:H4,tooltip:"Align Left"}),e.jsx(Qu,{onClick:()=>r.chain().focus().setTextAlign("center").run(),active:r.isActive({textAlign:"center"}),icon:V4,tooltip:"Align Center"}),e.jsx(Qu,{onClick:()=>r.chain().focus().setTextAlign("right").run(),active:r.isActive({textAlign:"right"}),icon:G4,tooltip:"Align Right"}),e.jsx(ho,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(Qu,{onClick:n,active:r.isActive("link"),icon:vo,tooltip:"Insert Link"}),e.jsx(ho,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(Qu,{onClick:()=>r.chain().focus().undo().run(),disabled:!r.can().undo(),icon:wS,tooltip:"Undo"}),e.jsx(Qu,{onClick:()=>r.chain().focus().redo().run(),disabled:!r.can().redo(),icon:fS,tooltip:"Redo"}),e.jsx("div",{className:"flex-1"}),e.jsx(W,{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(Hd,{children:[e.jsx(Gd,{asChild:!0,children:e.jsxs(W,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1.5 text-xs font-medium",children:[e.jsx(FM,{className:"h-3.5 w-3.5"}),"Merge Tags"]})}),e.jsx(Nd,{align:"end",className:"w-56",children:v9e.map(o=>e.jsxs(_a,{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(Dke,{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:"}),v9e.map(o=>e.jsx(Qe,{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 GSs({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(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(Qo,{className:"h-5 w-5 text-primary"}),r," — Engagement Stats"]}),e.jsx(Ir,{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(_n,{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(E9,{icon:tr,color:"text-blue-500",label:"Total Sent",value:n.sent.toLocaleString()}),e.jsx(E9,{icon:jn,color:"text-amber-500",label:"Opens",value:`${n.opened.toLocaleString()}`,sub:`${n.openRate.toFixed(1)}% open rate`}),e.jsx(E9,{icon:Tm,color:"text-green-500",label:"Clicks",value:`${n.clicked.toLocaleString()}`,sub:`${n.clickRate.toFixed(1)}% click rate`}),e.jsx(E9,{icon:Dc,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(nn,{className:"h-3 w-3"})," Last sent: ",vs(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(Oe,{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(Qe,{variant:"outline",className:"text-[10px] gap-1",children:[e.jsx(tr,{className:"h-2.5 w-2.5"})," ",a.sent_count.toLocaleString()," sent"]}),e.jsxs(Qe,{variant:"outline",className:"text-[10px] gap-1 border-amber-500/30 text-amber-600",children:[e.jsx(jn,{className:"h-2.5 w-2.5"})," ",a.opened_count.toLocaleString()," (",o.toFixed(1),"%)"]}),e.jsxs(Qe,{variant:"outline",className:"text-[10px] gap-1 border-green-500/30 text-green-600",children:[e.jsx(Tm,{className:"h-2.5 w-2.5"})," ",a.clicked_count.toLocaleString()," (",l.toFixed(1),"%)"]}),a.failed_count>0&&e.jsxs(Qe,{variant:"outline",className:"text-[10px] gap-1 border-destructive/30 text-destructive",children:[e.jsx(Dc,{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 E9({icon:t,color:s,label:r,value:n,sub:a}){return e.jsx(Pe,{children:e.jsx(Oe,{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 gt({queryKey:["recruit-campaign-stats",t],enabled:!!t,staleTime:6e4,queryFn:async()=>{const{data:s,error:r}=await G.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 _9e={cold:{icon:qy,color:"text-blue-500",bg:"bg-blue-50 dark:bg-blue-950/30",label:"Cold — Curiosity"},warm:{icon:s1,color:"text-amber-500",bg:"bg-amber-50 dark:bg-amber-950/30",label:"Warm — Growth"},hot:{icon:rd,color:"text-red-500",bg:"bg-red-50 dark:bg-red-950/30",label:"Hot — Private Invite"}};function pct({brokerageId:t}){var Re,Ve,Ne,Ue;const{user:s}=Us(),r=Qt(),[n,a]=k.useState(null),[o,l]=k.useState(null),[i,d]=k.useState(null),[u,p]=k.useState(!1),[f,y]=k.useState(!1),[_,b]=k.useState("editor"),[N,w]=k.useState(null),[S,C]=k.useState(null),{data:A={}}=mct(t),[I,L]=k.useState({name:"",description:"",theme:"",goal:"",primary_cta:"Learn more",warmth_level:"warm",sender_name:"",sender_email:"",reply_to_email:""}),{data:O}=gt({queryKey:["brokerage-detail",t],queryFn:async()=>{const{data:Ie,error:ye}=await G.from("brokerages").select("name, city, state").eq("id",t).single();if(ye)throw ye;return Ie}}),{data:V}=gt({queryKey:["brokerage-recruit-settings",t],queryFn:async()=>{const{data:Ie,error:ye}=await G.from("brokerage_recruit_settings").select("*").eq("brokerage_id",t).maybeSingle();if(ye)throw ye;return Ie}}),q={first_name:"Sarah",brokerage_name:((Re=V==null?void 0:V.merge_fields)==null?void 0:Re.brokerage_name)||(O==null?void 0:O.name)||"Your Brokerage",city:((Ve=V==null?void 0:V.merge_fields)==null?void 0:Ve.city)||(O==null?void 0:O.city)||"Your City",sender_name:((Ne=V==null?void 0:V.merge_fields)==null?void 0:Ne.sender_name)||(V==null?void 0:V.sender_name)||"Your Name"},B=Ie=>Ie.replace(/\{\{first_name\}\}/g,q.first_name).replace(/\{\{brokerage_name\}\}/g,q.brokerage_name).replace(/\{\{city\}\}/g,q.city).replace(/\{\{sender_name\}\}/g,q.sender_name),{data:U=[],isLoading:te}=gt({queryKey:["recruit-campaigns",t],queryFn:async()=>{const{data:Ie,error:ye}=await G.from("recruit_campaigns").select("*").or(`brokerage_id.is.null,brokerage_id.eq.${t}`).order("sort_order");if(ye)throw ye;return Ie}}),{data:Y={}}=gt({queryKey:["recruit-campaign-emails",t],enabled:U.length>0,queryFn:async()=>{const Ie=U.map($e=>$e.id),{data:ye,error:ct}=await G.from("recruit_campaign_emails").select("*").in("campaign_id",Ie).order("email_number");if(ct)throw ct;const fe={};return ye.forEach($e=>{fe[$e.campaign_id]||(fe[$e.campaign_id]=[]),fe[$e.campaign_id].push($e)}),fe}}),J=Object.values(Y).flat().map(Ie=>Ie.id),{data:X=[]}=gt({queryKey:["recruit-subject-overrides",t],enabled:J.length>0,queryFn:async()=>{const{data:Ie,error:ye}=await G.from("recruit_brokerage_subject_overrides").select("*").eq("brokerage_id",t);if(ye)throw ye;return Ie}}),ce={};X.forEach(Ie=>{ce[Ie.campaign_email_id]=Ie.selected_subject_index});const ie=Pt({mutationFn:async({campaignEmailId:Ie,selectedIndex:ye})=>{const{error:ct}=await G.from("recruit_brokerage_subject_overrides").upsert({brokerage_id:t,campaign_email_id:Ie,selected_subject_index:ye,updated_at:new Date().toISOString()},{onConflict:"brokerage_id,campaign_email_id"});if(ct)throw ct},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-subject-overrides",t]}),pe.success("Subject line updated for your brokerage")},onError:Ie=>pe.error(Ie.message)}),ae=Pt({mutationFn:async Ie=>{const{error:ye}=await G.from("recruit_campaign_emails").update({title:Ie.title,subject_line:Ie.subject_line,subject_line_options:Ie.subject_line_options,body_html:Ie.body_html,body_text:Ie.body_text,delay_days:Ie.delay_days,updated_at:new Date().toISOString()}).eq("id",Ie.id);if(ye)throw ye},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),pe.success("Email template saved!"),l(null)},onError:Ie=>pe.error(Ie.message)}),oe=Pt({mutationFn:async()=>{const Ie=I.name.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),{data:ye,error:ct}=await G.from("recruit_campaigns").insert({name:I.name,slug:Ie,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:U.length+1}).select().single();if(ct)throw ct;const fe=[{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:$e}=await G.from("recruit_campaign_emails").insert(fe.map(Ye=>({campaign_id:ye.id,...Ye,body_html:"

Hi {{first_name}},

Write your message here...

Best,
{{sender_name}}

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

Hi {{first_name}},

Write your message here...

Best,
{{sender_name}}

",body_text:"",delay_days:fe+7,is_active:!0});if(Ye)throw Ye},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),pe.success("Email added to campaign!")},onError:Ie=>pe.error(Ie.message)}),he=Pt({mutationFn:async Ie=>{const{error:ye}=await G.from("recruit_campaigns").delete().eq("id",Ie);if(ye)throw ye},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaigns"]}),r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),pe.success("Campaign deleted")},onError:Ie=>pe.error(Ie.message)}),ge=Pt({mutationFn:async Ie=>{const{error:ye}=await G.from("recruit_campaign_emails").delete().eq("id",Ie);if(ye)throw ye},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),pe.success("Email removed from campaign")},onError:Ie=>pe.error(Ie.message)}),je=Pt({mutationFn:async({emailId:Ie,delay_days:ye})=>{const{error:ct}=await G.from("recruit_campaign_emails").update({delay_days:ye,updated_at:new Date().toISOString()}).eq("id",Ie);if(ct)throw ct},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),pe.success("Send delay updated")},onError:Ie=>pe.error(Ie.message)});if(te)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 qe=U.filter(Ie=>!Ie.brokerage_id),Me=U.filter(Ie=>Ie.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(W,{variant:"outline",size:"sm",onClick:()=>p(!0),className:"gap-1.5",children:[e.jsx(So,{className:"h-4 w-4"})," Default Settings"]}),e.jsxs(W,{size:"sm",onClick:()=>y(!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(Oe,{className:"py-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Or,{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(So,{className:"inline h-3.5 w-3.5"})," icon on any campaign to customize."]})]})]})})}),Me.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(bL,{className:"h-4 w-4"})," Your Custom Campaigns"]}),e.jsx("div",{className:"space-y-3",children:Me.map(Ie=>ke(Ie,!0))})]}),qe.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(Or,{className:"h-4 w-4"})," System Campaigns"]}),e.jsx("div",{className:"space-y-3",children:qe.map(Ie=>ke(Ie,!1))})]}),U.length===0&&e.jsx(Pe,{children:e.jsxs(Oe,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(tr,{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(W,{className:"mt-4",onClick:()=>y(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Create Campaign"]})]})}),e.jsx(GSs,{open:!!S,onClose:()=>C(null),campaignName:(S==null?void 0:S.name)||"",stat:S&&A[S.id]||null}),i&&e.jsx(hct,{email:i,mergeValues:q,selectedSubjectIndex:ce[i.id],onClose:()=>d(null)}),e.jsx(fs,{open:!!o,onOpenChange:Ie=>!Ie&&l(null),children:e.jsxs(ps,{className:"max-w-4xl max-h-[90vh] overflow-y-auto p-0",children:[e.jsxs(ks,{className:"px-6 pt-6 pb-4 border-b",children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(tS,{className:"h-5 w-5 text-primary"}),"Edit Email #",o==null?void 0:o.email_number]}),e.jsx(Ir,{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(xe,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Email Title"}),e.jsx(De,{value:o.title,onChange:Ie=>l({...o,title:Ie.target.value}),className:"h-9"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Delay (days after previous)"}),e.jsx(De,{type:"number",min:0,max:90,value:o.delay_days,onChange:Ie=>l({...o,delay_days:parseInt(Ie.target.value)||7}),className:"h-9"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Subject Line"}),e.jsx(De,{value:o.subject_line,onChange:Ie=>l({...o,subject_line:Ie.target.value}),placeholder:"e.g. Hey {{first_name}}, quick question...",className:"h-9"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(xe,{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(_r,{value:((Ue=o.subject_line_options)==null?void 0:Ue.join(` `))||"",onChange:Ie=>l({...o,subject_line_options:Ie.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(xe,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Email Body"}),e.jsx(ta,{value:_,onValueChange:Ie=>b(Ie),children:e.jsxs(Jn,{className:"h-7",children:[e.jsx(cs,{value:"editor",className:"text-xs px-3 h-6",children:"Editor"}),e.jsx(cs,{value:"preview",className:"text-xs px-3 h-6",children:"Preview"})]})})]}),_==="editor"?e.jsx(HSs,{content:o.body_html,onChange:Ie=>l({...o,body_html:Ie})}):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:[q.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:[q.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:B(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:B(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(W,{variant:"outline",size:"sm",onClick:()=>l(null),children:"Cancel"}),e.jsxs(W,{size:"sm",onClick:()=>ae.mutate(o),disabled:ae.isPending,className:"gap-1.5",children:[e.jsx(bc,{className:"h-3.5 w-3.5"})," Save Changes"]})]})]})]})]})}),e.jsx(fs,{open:f,onOpenChange:y,children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(qs,{className:"h-5 w-5 text-primary"})," Create Custom Campaign"]}),e.jsx(Ir,{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(xe,{className:"text-xs font-medium",children:"Campaign Name *"}),e.jsx(De,{value:I.name,onChange:Ie=>L({...I,name:Ie.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(xe,{className:"text-xs font-medium",children:"Warmth Level"}),e.jsxs($s,{value:I.warmth_level,onValueChange:Ie=>L({...I,warmth_level:Ie}),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"cold",children:"❄️ Cold — Curiosity"}),e.jsx(vt,{value:"warm",children:"☀️ Warm — Growth"}),e.jsx(vt,{value:"hot",children:"🔥 Hot — Private Invite"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs font-medium",children:"Primary CTA"}),e.jsx(De,{value:I.primary_cta,onChange:Ie=>L({...I,primary_cta:Ie.target.value}),placeholder:"Learn more"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs font-medium",children:"Description"}),e.jsx(_r,{value:I.description,onChange:Ie=>L({...I,description:Ie.target.value}),placeholder:"What is this campaign about?",rows:2})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs font-medium",children:"Goal"}),e.jsx(De,{value:I.goal,onChange:Ie=>L({...I,goal:Ie.target.value}),placeholder:"e.g. Convert warm leads to meetings"})]}),e.jsxs(lf,{children:[e.jsx(cf,{asChild:!0,children:e.jsxs(W,{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(tr,{className:"h-3.5 w-3.5"})," Email Settings Override"]}),e.jsx(Bi,{className:"h-3.5 w-3.5"})]})}),e.jsxs(df,{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(xe,{className:"text-xs",children:"Sender Name"}),e.jsx(De,{value:I.sender_name,onChange:Ie=>L({...I,sender_name:Ie.target.value}),placeholder:"e.g. Jeremy at LevelUp"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs",children:"Sender Email"}),e.jsx(De,{value:I.sender_email,onChange:Ie=>L({...I,sender_email:Ie.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(xe,{className:"text-xs",children:"Reply-To Email"}),e.jsx(De,{value:I.reply_to_email,onChange:Ie=>L({...I,reply_to_email:Ie.target.value}),placeholder:"e.g. jeremy@mybrokerage.com"})]})]})]}),e.jsxs(W,{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:!!N,onOpenChange:Ie=>!Ie&&w(null),children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(So,{className:"h-5 w-5 text-primary"})," Campaign Email Settings"]}),e.jsx(Ir,{children:"Override the default sender for this campaign. Leave blank to use brokerage defaults."})]}),N&&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(xe,{className:"text-xs font-medium",children:"Campaign Name"}),e.jsx(De,{value:N.name,onChange:Ie=>w({...N,name:Ie.target.value})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs font-medium",children:"Warmth Level"}),e.jsxs($s,{value:N.warmth_level,onValueChange:Ie=>w({...N,warmth_level:Ie}),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"cold",children:"❄️ Cold"}),e.jsx(vt,{value:"warm",children:"☀️ Warm"}),e.jsx(vt,{value:"hot",children:"🔥 Hot"})]})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs font-medium",children:"Goal"}),e.jsx(De,{value:N.goal||"",onChange:Ie=>w({...N,goal:Ie.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(tr,{className:"h-4 w-4 text-primary"})," Email Sender Override"]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs",children:"Sender Name"}),e.jsx(De,{value:N.sender_name||"",onChange:Ie=>w({...N,sender_name:Ie.target.value}),placeholder:"Uses brokerage default"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs",children:"Sender Email"}),e.jsx(De,{value:N.sender_email||"",onChange:Ie=>w({...N,sender_email:Ie.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(xe,{className:"text-xs",children:"Reply-To Email"}),e.jsx(De,{value:N.reply_to_email||"",onChange:Ie=>w({...N,reply_to_email:Ie.target.value}),placeholder:"Uses brokerage default"})]})]}),e.jsxs(W,{className:"w-full",onClick:()=>me.mutate(N),disabled:me.isPending,children:[e.jsx(bc,{className:"h-4 w-4 mr-1"})," Save Campaign Settings"]})]})]})}),e.jsx(fs,{open:u,onOpenChange:p,children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Default Recruiting Email Settings"}),e.jsx(Ir,{children:"These defaults apply to campaigns without their own overrides."})]}),e.jsx(VCe,{brokerageId:t})]})})]});function ke(Ie,ye){const ct=_9e[Ie.warmth_level]||_9e.cold,fe=ct.icon,$e=Y[Ie.id]||[],Ye=n===Ie.id,tt=!!(Ie.sender_name||Ie.sender_email||Ie.reply_to_email),Te=A[Ie.id];return e.jsxs(Pe,{className:"overflow-hidden transition-shadow hover:shadow-md",children:[e.jsx(Dt,{className:"cursor-pointer hover:bg-muted/40 transition-colors py-4",onClick:()=>a(Ye?null:Ie.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 ${ct.bg} flex items-center justify-center`,children:e.jsx(fe,{className:`h-5 w-5 ${ct.color}`})}),e.jsxs("div",{children:[e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[Ie.name,e.jsx(Qe,{variant:Ie.is_active?"default":"secondary",className:"text-[10px] px-1.5",children:Ie.is_active?"Active":"Draft"}),ye&&e.jsx(Qe,{variant:"outline",className:"text-[10px] px-1.5",children:"Custom"}),tt&&e.jsxs(Qe,{variant:"outline",className:"text-[10px] px-1.5 border-primary/30 text-primary",children:[e.jsx(tr,{className:"h-2.5 w-2.5 mr-0.5"})," Custom Sender"]})]}),e.jsx(dr,{className:"text-xs mt-0.5",children:Ie.theme||Ie.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:We=>{We.stopPropagation(),w({...Ie})},children:e.jsx(So,{className:"h-4 w-4 text-muted-foreground"})}),ye&&e.jsx(W,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:We=>{We.stopPropagation(),confirm("Delete this campaign and all its emails? This cannot be undone.")&&he.mutate(Ie.id)},children:e.jsx(vr,{className:"h-4 w-4"})}),Te&&Te.sent>0&&e.jsxs("div",{className:"hidden md:flex items-center gap-1.5",children:[e.jsxs(Qe,{variant:"outline",className:"text-[10px] gap-1 font-medium",title:"Total emails sent",children:[e.jsx(tr,{className:"h-2.5 w-2.5"})," ",Te.sent.toLocaleString()]}),e.jsxs(Qe,{variant:"outline",className:"text-[10px] gap-1 border-amber-500/30 text-amber-600 font-medium",title:`${Te.openRate.toFixed(1)}% open rate`,children:[e.jsx(jn,{className:"h-2.5 w-2.5"})," ",Te.opened.toLocaleString()," (",Te.openRate.toFixed(0),"%)"]}),e.jsxs(Qe,{variant:"outline",className:"text-[10px] gap-1 border-green-500/30 text-green-600 font-medium",title:`${Te.clickRate.toFixed(1)}% click rate`,children:[e.jsx(Tm,{className:"h-2.5 w-2.5"})," ",Te.clicked.toLocaleString()," (",Te.clickRate.toFixed(1),"%)"]})]}),e.jsxs(W,{variant:"outline",size:"sm",className:"h-7 px-2 gap-1 text-xs",onClick:We=>{We.stopPropagation(),C(Ie)},title:"View detailed engagement stats",children:[e.jsx(so,{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(tr,{className:"h-3.5 w-3.5"}),e.jsxs("span",{children:[$e.length," emails"]})]}),e.jsx("div",{className:"h-7 w-7 rounded-md flex items-center justify-center",children:Ye?e.jsx(af,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Bi,{className:"h-4 w-4 text-muted-foreground"})})]})]})}),Ye&&e.jsxs(Oe,{className:"pt-0 pb-4 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 p-3 rounded-lg bg-muted/40 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Goal"}),e.jsx("p",{className:"mt-0.5",children:Ie.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:Ie.primary_cta||"—"})]})]}),tt&&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(tr,{className:"h-3 w-3"})," Campaign Sender Override"]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs text-muted-foreground",children:[Ie.sender_name&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Name:"})," ",Ie.sender_name]}),Ie.sender_email&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Email:"})," ",Ie.sender_email]}),Ie.reply_to_email&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Reply-To:"})," ",Ie.reply_to_email]})]})]}),e.jsx("div",{className:"relative",children:$e.map((We,Ke)=>{var ot,He;return e.jsxs("div",{className:"relative flex gap-4 pb-4 last:pb-0",children:[Ke<$e.length-1&&e.jsx("div",{className:"absolute left-[19px] top-10 bottom-0 w-px bg-border"}),e.jsx("div",{className:`relative z-10 h-10 w-10 rounded-full ${ct.bg} border-2 border-background flex items-center justify-center shrink-0 shadow-sm`,children:e.jsx("span",{className:`text-sm font-bold ${ct.color}`,children:We.email_number})}),e.jsx("div",{className:"flex-1 border rounded-lg p-3 hover:bg-muted/20 transition-colors group",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("p",{className:"font-medium text-sm",children:We.title}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-0.5 flex items-center gap-2 flex-wrap",children:[ye?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nn,{className:"h-3 w-3"}),We.email_number===1?"Sent immediately":e.jsxs("span",{className:"inline-flex items-center gap-1",children:["Send after",e.jsx("input",{type:"number",min:0,max:90,className:"w-12 h-5 text-xs text-center border rounded bg-background px-1",defaultValue:We.delay_days,onClick:Je=>Je.stopPropagation(),onBlur:Je=>{const ut=parseInt(Je.target.value)||0;ut!==We.delay_days&&je.mutate({emailId:We.id,delay_days:ut})},onKeyDown:Je=>{Je.key==="Enter"&&Je.target.blur()}}),"days"]})]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nn,{className:"h-3 w-3"}),We.email_number===1?"Sent immediately":`Day ${We.delay_days}`]}),e.jsx("span",{className:"text-border",children:"•"}),e.jsxs("span",{className:"truncate",children:["Subject: ",B(((ot=We.subject_line_options)==null?void 0:ot.length)>0&&We.subject_line_options[ce[We.id]??0]||We.subject_line)]})]}),((He=We.subject_line_options)==null?void 0:He.length)>1&&e.jsx("div",{className:"mt-2",children:e.jsxs($s,{value:String(ce[We.id]??0),onValueChange:Je=>ie.mutate({campaignEmailId:We.id,selectedIndex:parseInt(Je)}),children:[e.jsx(zs,{className:"h-7 text-xs w-full max-w-sm",children:e.jsx(Vs,{placeholder:"Choose subject line"})}),e.jsx(Bs,{children:We.subject_line_options.map((Je,ut)=>e.jsxs(vt,{value:String(ut),className:"text-xs",children:[e.jsxs("span",{className:"font-medium mr-1.5",children:[ut===0?"Primary":`Alt ${ut}`,":"]}),B(Je)]},ut))})]})})]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:[e.jsx(W,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>d(We),children:e.jsx(jn,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{l({...We}),b("editor")},children:e.jsx(ga,{className:"h-4 w-4"})}),ye&&$e.length>1&&e.jsx(W,{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(We.id)},children:e.jsx(vr,{className:"h-4 w-4"})})]})]})})]},We.id)})}),ye&&e.jsxs(W,{variant:"outline",size:"sm",className:"w-full gap-1.5",onClick:()=>ve.mutate(Ie.id),disabled:ve.isPending,children:[e.jsx(qs,{className:"h-3.5 w-3.5"})," Add Email to Sequence"]})]})]},Ie.id)}}const b9e={active:{icon:Co,color:"bg-green-500/10 text-green-600",label:"Active"},paused:{icon:hh,color:"bg-amber-500/10 text-amber-600",label:"Paused"},completed:{icon:si,color:"bg-blue-500/10 text-blue-600",label:"Completed"},cancelled:{icon:Jl,color:"bg-red-500/10 text-red-600",label:"Cancelled"}},w9e={sent:{icon:tr,color:"text-blue-500"},opened:{icon:jn,color:"text-amber-500"},clicked:{icon:Tm,color:"text-green-500"},failed:{icon:Dc,color:"text-destructive"}};function fct({brokerageId:t}){var Re,Ve,Ne,Ue,Ie;const{user:s}=Us(),r=Qt(),[n,a]=k.useState(!1),[o,l]=k.useState(""),[i,d]=k.useState(new Set),[u,p]=k.useState("assignments"),[f,y]=k.useState(null),[_,b]=k.useState(""),[N,w]=k.useState("all"),[S,C]=k.useState("all"),{data:A={}}=gt({queryKey:["recruit-campaign-emails-for-preview",t],queryFn:async()=>{const{data:ye,error:ct}=await G.from("recruit_campaign_emails").select("*").order("email_number");if(ct)throw ct;const fe={};return(ye??[]).forEach($e=>{fe[$e.campaign_id]||(fe[$e.campaign_id]=[]),fe[$e.campaign_id].push($e)}),fe}}),{data:I}=gt({queryKey:["brokerage-detail",t],queryFn:async()=>{const{data:ye,error:ct}=await G.from("brokerages").select("name, city, state").eq("id",t).single();if(ct)throw ct;return ye}}),{data:L}=gt({queryKey:["brokerage-recruit-settings",t],queryFn:async()=>{const{data:ye,error:ct}=await G.from("brokerage_recruit_settings").select("*").eq("brokerage_id",t).maybeSingle();if(ct)throw ct;return ye}}),{data:O=[]}=gt({queryKey:["recruit-subject-overrides",t],queryFn:async()=>{const{data:ye,error:ct}=await G.from("recruit_brokerage_subject_overrides").select("*").eq("brokerage_id",t);if(ct)throw ct;return ye}}),V={};O.forEach(ye=>{V[ye.campaign_email_id]=ye.selected_subject_index});const q={first_name:((Re=f==null?void 0:f.prospect)==null?void 0:Re.first_name)||"Sarah",brokerage_name:((Ve=L==null?void 0:L.merge_fields)==null?void 0:Ve.brokerage_name)||(I==null?void 0:I.name)||"Your Brokerage",city:((Ne=L==null?void 0:L.merge_fields)==null?void 0:Ne.city)||(I==null?void 0:I.city)||"Your City",sender_name:((Ue=L==null?void 0:L.merge_fields)==null?void 0:Ue.sender_name)||(L==null?void 0:L.sender_name)||"Your Name"},B=ye=>{const ct=A[ye.campaign_id]||[],fe=ye.current_email_number+1;return ct.find($e=>$e.email_number===fe)||null},{data:U=[],isLoading:te}=gt({queryKey:["recruit-campaign-assignments",t],queryFn:async()=>{let ct=[],fe=0;for(;;){const{data:$e,error:Ye}=await G.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(fe,fe+1e3-1);if(Ye)throw Ye;if(ct=ct.concat($e??[]),!$e||$e.length<1e3)break;fe+=1e3}return ct}}),{data:Y=[]}=gt({queryKey:["recruit-campaign-sends",t],queryFn:async()=>{const{data:ye,error:ct}=await G.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(ct)throw ct;return ye}}),{data:J=[]}=gt({queryKey:["recruit-campaigns"],queryFn:async()=>{const{data:ye,error:ct}=await G.from("recruit_campaigns").select("id, name, warmth_level").eq("is_active",!0).order("sort_order");if(ct)throw ct;return ye}}),{data:X=[]}=gt({queryKey:["recruit-prospects-for-assign",t],queryFn:async()=>{let ct=[],fe=0;for(;;){const{data:$e,error:Ye}=await G.from("recruit_prospects").select("id, first_name, last_name, email").eq("brokerage_id",t).order("first_name").range(fe,fe+1e3-1);if(Ye)throw Ye;if(ct=ct.concat($e??[]),!$e||$e.length<1e3)break;fe+=1e3}return ct}}),ce=new Set(U.map(ye=>`${ye.prospect_id}-${ye.campaign_id}`)),ie=Pt({mutationFn:async()=>{if(!o||i.size===0)throw new Error("Select a campaign and at least one prospect");const ye=new Date,ct=Array.from(i).filter($e=>!ce.has(`${$e}-${o}`)).map($e=>({prospect_id:$e,campaign_id:o,brokerage_id:t,assigned_by:s.id,status:"active",current_email_number:0,next_send_at:ye.toISOString(),started_at:ye.toISOString()}));if(ct.length===0)throw new Error("All selected prospects are already assigned to this campaign");const{error:fe}=await G.from("recruit_campaign_assignments").insert(ct);if(fe)throw fe},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),pe.success(`Campaign assigned to ${i.size} prospect(s)!`),a(!1),l(""),d(new Set)},onError:ye=>pe.error(ye.message)}),ae=Pt({mutationFn:async({id:ye,newStatus:ct})=>{const{error:fe}=await G.from("recruit_campaign_assignments").update({status:ct,updated_at:new Date().toISOString()}).eq("id",ye);if(fe)throw fe},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),pe.success("Assignment updated")}}),oe=Pt({mutationFn:async()=>{const{data:ye,error:ct}=await G.functions.invoke("ses-recruit-drip",{body:{action:"process_drips"}});if(ct)throw ct;return ye},onSuccess:ye=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),r.invalidateQueries({queryKey:["recruit-campaign-sends",t]}),pe.success(`Wave sent! ${ye.sent} emails delivered, ${ye.skipped} skipped, ${ye.failed} failed`)},onError:ye=>pe.error(`Send failed: ${ye.message}`)}),me=U.filter(ye=>ye.status==="active").length;U.filter(ye=>ye.status==="completed").length;const ve=U.filter(ye=>ye.status==="active"&&ye.next_send_at&&new Date(ye.next_send_at)<=new Date).length,{data:he={}}=mct(t),ge=U.reduce((ye,ct)=>ye+Math.max(0,ct.current_email_number||0),0),je=Object.values(he).reduce((ye,ct)=>ye+ct.opened,0),qe=Object.values(he).reduce((ye,ct)=>ye+ct.clicked,0);Object.values(he).reduce((ye,ct)=>ye+ct.failed,0);const Me=ge>0?Math.round(je/ge*100):0,ke=ge>0?qe/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:[ve>0&&e.jsxs(W,{variant:"outline",onClick:()=>oe.mutate(),disabled:oe.isPending,className:"border-amber-500/50 text-amber-600 hover:bg-amber-500/10",children:[e.jsx(Oh,{className:"h-4 w-4 mr-1"}),oe.isPending?"Sending...":`Send Next Wave (${ve})`]}),e.jsxs(W,{onClick:()=>a(!0),children:[e.jsx(_n,{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(Oe,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(ir,{className:"h-7 w-7 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:U.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Assigned"})]})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(Co,{className:"h-7 w-7 text-green-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:me}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active"})]})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(tr,{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(Oe,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(jn,{className:"h-7 w-7 text-amber-500"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xl font-bold",children:[Me,"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Open Rate (",je.toLocaleString(),")"]})]})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(Tm,{className:"h-7 w-7 text-green-500"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xl font-bold",children:[ke.toFixed(1),"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Click Rate (",qe.toLocaleString(),")"]})]})]})})]}),e.jsxs(ta,{value:u,onValueChange:p,children:[e.jsxs(Jn,{children:[e.jsxs(cs,{value:"assignments",children:["Active Drips (",me,")"]}),e.jsxs(cs,{value:"history",children:["Send History (",ge.toLocaleString(),")"]})]}),e.jsx(Ss,{value:"assignments",className:"mt-4",children:te?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"})}):U.length===0?e.jsx(Pe,{children:e.jsxs(Oe,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(_n,{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:U.map(ye=>{var Te,We,Ke,ot;const ct=b9e[ye.status]||b9e.active,fe=ct.icon,Ye=(A[ye.campaign_id]||[]).length||4,tt=B(ye);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(Qe,{className:`text-xs ${ct.color} border-0`,children:[e.jsx(fe,{className:"h-3 w-3 mr-1"}),ct.label]}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(Te=ye.prospect)==null?void 0:Te.first_name," ",(We=ye.prospect)==null?void 0:We.last_name,e.jsx("span",{className:"text-muted-foreground font-normal ml-2",children:(Ke=ye.prospect)==null?void 0:Ke.email})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(ot=ye.campaign)==null?void 0:ot.name," · Email ",ye.current_email_number,"/",Ye,ye.next_send_at&&ye.status==="active"&&e.jsxs(e.Fragment,{children:[" ","· ",e.jsx(nn,{className:"h-3 w-3 inline"})," Next: ",vs(new Date(ye.next_send_at),"MMM d, h:mm a"),new Date(ye.next_send_at)<=new Date&&e.jsx(Qe,{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:[tt&&e.jsx(W,{variant:"ghost",size:"sm",title:"Preview next email",onClick:()=>y(ye),children:e.jsx(jn,{className:"h-3.5 w-3.5"})}),ye.status==="active"&&e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>ae.mutate({id:ye.id,newStatus:"paused"}),children:e.jsx(hh,{className:"h-3.5 w-3.5"})}),ye.status==="paused"&&e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>ae.mutate({id:ye.id,newStatus:"active"}),children:e.jsx(Co,{className:"h-3.5 w-3.5"})}),(ye.status==="active"||ye.status==="paused")&&e.jsx(W,{variant:"ghost",size:"sm",className:"text-destructive",onClick:()=>ae.mutate({id:ye.id,newStatus:"cancelled"}),children:e.jsx(Jl,{className:"h-3.5 w-3.5"})})]})]},ye.id)})})}),e.jsxs(Ss,{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($s,{value:N,onValueChange:w,children:[e.jsx(zs,{className:"w-[220px] h-8 text-xs",children:e.jsx(Vs,{placeholder:"All campaigns"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All campaigns"}),J.map(ye=>e.jsx(vt,{value:ye.id,children:ye.name},ye.id))]})]}),e.jsxs($s,{value:S,onValueChange:C,children:[e.jsx(zs,{className:"w-[160px] h-8 text-xs",children:e.jsx(Vs,{placeholder:"All statuses"})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All statuses"}),e.jsx(vt,{value:"sent",children:"Sent (no engagement)"}),e.jsx(vt,{value:"opened",children:"Opened"}),e.jsx(vt,{value:"clicked",children:"Clicked"})]})]}),(N!=="all"||S!=="all")&&e.jsx(W,{variant:"ghost",size:"sm",className:"h-8 text-xs",onClick:()=>{w("all"),C("all")},children:"Clear"})]}),(()=>{var ct;const ye=Y.filter(fe=>{var $e;return!(N!=="all"&&(($e=fe.campaign_email)==null?void 0:$e.campaign_id)!==N||S==="opened"&&!fe.opened_at||S==="clicked"&&!fe.clicked_at||S==="sent"&&(fe.opened_at||fe.clicked_at))});return ye.length===0?e.jsx(Pe,{children:e.jsxs(Oe,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(tr,{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 ",ye.length," of ",Y.length," recent sends",N!=="all"&&` · ${(ct=J.find(fe=>fe.id===N))==null?void 0:ct.name}`]}),e.jsx("div",{className:"space-y-1",children:ye.map(fe=>{var Te,We,Ke;const $e=w9e[fe.status]||w9e.sent,Ye=$e.icon,tt=(Te=J.find(ot=>{var He;return ot.id===((He=fe.campaign_email)==null?void 0:He.campaign_id)}))==null?void 0:Te.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(Ye,{className:`h-4 w-4 flex-shrink-0 ${$e.color}`}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm truncate",children:[(We=fe.prospect)==null?void 0:We.first_name," ",(Ke=fe.prospect)==null?void 0:Ke.last_name,e.jsxs("span",{className:"text-muted-foreground font-normal ml-2",children:["Email #",fe.email_number]}),tt&&e.jsx(Qe,{variant:"outline",className:"ml-2 text-[10px] px-1.5 py-0 font-normal",children:tt})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:fe.subject})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground flex-shrink-0",children:[fe.opened_at&&e.jsxs("span",{className:"flex items-center gap-1 text-amber-500",children:[e.jsx(jn,{className:"h-3 w-3"})," ",vs(new Date(fe.opened_at),"MMM d")]}),fe.clicked_at&&e.jsxs("span",{className:"flex items-center gap-1 text-green-500",children:[e.jsx(Tm,{className:"h-3 w-3"})," ",vs(new Date(fe.clicked_at),"MMM d")]}),e.jsx("span",{children:vs(new Date(fe.sent_at),"MMM d, h:mm a")})]})]},fe.id)})})]})})()]})]}),e.jsx(fs,{open:n,onOpenChange:ye=>{a(ye),ye||(b(""),d(new Set),l(""))},children:e.jsxs(ps,{className:"max-w-lg max-h-[85vh] flex flex-col p-0",children:[e.jsxs(ks,{className:"px-6 pt-6 pb-4",children:[e.jsx(_s,{children:"Assign Campaign to Prospects"}),e.jsx(Ir,{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(xe,{className:"text-sm font-medium",children:"1. Select Campaign"}),e.jsxs($s,{value:o,onValueChange:l,children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Choose a campaign..."})}),e.jsx(Bs,{children:J.map(ye=>e.jsx(vt,{value:ye.id,children:ye.name},ye.id))})]})]}),o&&(()=>{const ye=_.toLowerCase(),ct=X.filter(Ye=>`${Ye.first_name} ${Ye.last_name}`.toLowerCase().includes(ye)||Ye.email.toLowerCase().includes(ye)),fe=ct.filter(Ye=>!ce.has(`${Ye.id}-${o}`)),$e=fe.length>0&&fe.every(Ye=>i.has(Ye.id));return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{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(ln,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name or email...",value:_,onChange:Ye=>b(Ye.target.value),className:"pl-9 h-9"})]}),e.jsxs(W,{variant:"outline",size:"sm",className:"h-9 whitespace-nowrap",onClick:()=>{if($e){const Ye=new Set(i);fe.forEach(tt=>Ye.delete(tt.id)),d(Ye)}else{const Ye=new Set(i);fe.forEach(tt=>Ye.add(tt.id)),d(Ye)}},children:[e.jsx(uL,{className:"h-3.5 w-3.5 mr-1"}),$e?"Deselect All":`Select All (${fe.length})`]})]}),e.jsx("div",{className:"border rounded-lg max-h-60 overflow-y-auto divide-y",children:ct.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:_?"No prospects match your search":"No prospects found for this brokerage"}):ct.map(Ye=>{const tt=ce.has(`${Ye.id}-${o}`);return e.jsxs("label",{className:`flex items-center gap-3 p-2.5 hover:bg-muted/50 cursor-pointer ${tt?"opacity-40":""}`,children:[e.jsx(Ri,{checked:i.has(Ye.id),disabled:tt,onCheckedChange:Te=>{const We=new Set(i);Te?We.add(Ye.id):We.delete(Ye.id),d(We)}}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[Ye.first_name," ",Ye.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Ye.email})]}),tt&&e.jsx(Qe,{variant:"outline",className:"text-[10px] shrink-0",children:"Already assigned"})]},Ye.id)})}),ct.length>0&&e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Showing ",ct.length," of ",X.length," prospects",fe.length0&&e.jsx(Pe,{className:"bg-primary/5 border-primary/20",children:e.jsxs(Oe,{className:"pt-3 pb-2 text-sm space-y-1",children:[e.jsxs("p",{className:"font-medium text-primary",children:["✅ Ready to assign ",i.size," prospect",i.size>1?"s":""]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["• Campaign: ",e.jsx("strong",{children:(Ie=J.find(ye=>ye.id===o))==null?void 0:Ie.name})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"• First email sends immediately · follow-ups every 7 days"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"• You can pause or cancel any assignment at any time"})]})})]}),e.jsxs(gn,{className:"px-6 py-4 border-t",children:[e.jsx(W,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsxs(W,{onClick:()=>ie.mutate(),disabled:ie.isPending||!o||i.size===0,children:[e.jsx(_n,{className:"h-4 w-4 mr-1"}),ie.isPending?"Assigning...":`Assign & Start (${i.size})`]})]})]})}),f&&(()=>{const ye=B(f);return ye?e.jsx(hct,{email:ye,mergeValues:q,selectedSubjectIndex:V[ye.id],onClose:()=>y(null)}):null})()]})}function xct({brokerageId:t}){const s=Qt(),[r,n]=k.useState([]),[a,o]=k.useState([]),[l,i]=k.useState(!1),d=k.useRef(!1),{data:u,isLoading:p}=gt({queryKey:["recruit-stages-editor",t],queryFn:async()=>{const{data:w,error:S}=await G.from("recruit_pipeline_stages").select("*").eq("brokerage_id",t).order("sort_order");if(S)throw S;return w},enabled:!!t});k.useEffect(()=>{if(u){if(d.current){d.current=!1;return}n(u.map(w=>({id:w.id,name:w.name,color:w.color,sort_order:w.sort_order}))),o([]),i(!1)}},[u]);const f=Pt({mutationFn:async()=>{for(const C of a){const{error:A}=await G.from("recruit_pipeline_stages").delete().eq("id",C);if(A)throw A}const w=r.filter(C=>C.id&&!C.isNew),S=r.filter(C=>!C.id||C.isNew);for(const C of w){const{error:A}=await G.from("recruit_pipeline_stages").update({name:C.name,color:C.color,sort_order:C.sort_order}).eq("id",C.id);if(A)throw A}if(S.length>0){const{error:C}=await G.from("recruit_pipeline_stages").insert(S.map(A=>({brokerage_id:t,name:A.name,color:A.color,sort_order:A.sort_order})));if(C)throw C}},onSuccess:()=>{o([]),s.invalidateQueries({queryKey:["recruit-stages-editor",t]}),s.invalidateQueries({queryKey:["recruit-stages",t]}),pe.success("Pipeline stages saved!"),i(!1)},onError:w=>pe.error(w.message)}),y=(w,S,C)=>{n(A=>A.map((I,L)=>L===w?{...I,[S]:C}:I)),i(!0)},_=()=>{const w=r.length>0?Math.max(...r.map(S=>S.sort_order)):0;n(S=>[...S,{name:"",color:"#6366f1",sort_order:w+1,isNew:!0}]),i(!0)},b=w=>{const S=r[w];S.id&&!S.isNew&&o(C=>[...C,S.id]),n(C=>C.filter((A,I)=>I!==w)),i(!0)},N=(w,S)=>{const C=w+S;if(C<0||C>=r.length)return;const A=[...r];[A[w],A[C]]=[A[C],A[w]],A.forEach((I,L)=>I.sort_order=L+1),n(A),i(!0)};return p?e.jsx("div",{className:"text-sm text-muted-foreground py-8 text-center",children:"Loading stages…"}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"Pipeline Stages"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Customize the recruiting pipeline stages for this brokerage. Changes will apply to the Kanban board and all prospect tracking."})]}),e.jsx("div",{className:"space-y-2",children:r.map((w,S)=>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:()=>N(S,-1),disabled:S===0,className:"text-muted-foreground hover:text-foreground disabled:opacity-30 text-xs",children:"▲"}),e.jsx("button",{type:"button",onClick:()=>N(S,1),disabled:S===r.length-1,className:"text-muted-foreground hover:text-foreground disabled:opacity-30 text-xs",children:"▼"})]}),e.jsx(mu,{className:"h-4 w-4 text-muted-foreground/50 shrink-0"}),e.jsx("input",{type:"color",value:w.color,onChange:C=>y(S,"color",C.target.value),className:"h-8 w-8 rounded cursor-pointer border-0 p-0 shrink-0"}),e.jsx(De,{value:w.name,onChange:C=>y(S,"name",C.target.value),placeholder:"Stage name…",className:"flex-1"}),e.jsx("span",{className:"text-xs text-muted-foreground w-6 text-center shrink-0",children:S+1}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>b(S),className:"text-destructive hover:text-destructive shrink-0 h-8 w-8",children:e.jsx(vr,{className:"h-4 w-4"})})]},w.id||`new-${S}`))}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(W,{variant:"outline",size:"sm",onClick:_,className:"gap-1",children:[e.jsx(qs,{className:"h-4 w-4"})," Add Stage"]}),l&&e.jsxs(W,{size:"sm",onClick:()=>f.mutate(),disabled:f.isPending,className:"gap-1",children:[e.jsx(bc,{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 WSs({brokerageId:t}){const{data:s=[],isLoading:r}=gt({queryKey:["recruit-unsubscribed",t],queryFn:async()=>{const{data:n,error:a}=await G.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(gS,{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(Qe,{variant:"secondary",className:"text-base px-3 py-1",children:[s.length," total"]})]}),s.length===0?e.jsx(Pe,{children:e.jsxs(Oe,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(gS,{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(Dt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs(zt,{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(tr,{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(cn,{className:"h-3 w-3"}),n.unsubscribed_at&&vs(new Date(n.unsubscribed_at),"MMM d, yyyy")]})]})}),n.unsubscribe_reason&&e.jsx(Oe,{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 KSs({brokerageId:t,trigger:s,initialProspectId:r,open:n,onOpenChange:a}){const[o,l]=k.useState(!1),i=n??o,d=a??l,[u,p]=k.useState("pick-recipients"),[f,y]=k.useState(new Set(r?[r]:[])),[_,b]=k.useState("all"),[N,w]=k.useState(""),[S,C]=k.useState(null),[A,I]=k.useState(""),[L,O]=k.useState(0),[V,q]=k.useState(0),[B,U]=k.useState(""),[te,Y]=k.useState(""),[J,X]=k.useState(null),{prospects:ce,stages:ie}=PO(t),ae=Xlt(),oe=Mw(),{data:me=[]}=gt({queryKey:["brokerage-recruit-video-pool",t],queryFn:async()=>{const{data:Ne,error:Ue}=await G.from("agent_videos").select("id, title, thumbnail_url, duration_seconds, created_at, owner_user_id").eq("touch_type","recruiting").eq("status","ready").eq("is_deleted",!1).order("created_at",{ascending:!1}).limit(50);if(Ue)throw Ue;return Ne??[]},enabled:i&&u==="pick-video"}),ve=k.useCallback(()=>{p("pick-recipients"),y(new Set(r?[r]:[])),b("all"),w(""),C(null),I(""),O(0),q(0),U(""),Y(""),X(null)},[r]),he=Ne=>{!Ne&&(u==="uploading"||u==="processing"||u==="sending")||(d(Ne),Ne||setTimeout(ve,200))},ge=k.useMemo(()=>ce.filter(Ne=>{if(!Ne.email||_!=="all"&&Ne.stage_id!==_)return!1;if(N){const Ue=N.toLowerCase();if(!`${Ne.first_name} ${Ne.last_name??""}`.toLowerCase().includes(Ue)&&!Ne.email.toLowerCase().includes(Ue))return!1}return!0}),[ce,_,N]),je=Ne=>{y(Ue=>{const Ie=new Set(Ue);return Ie.has(Ne)?Ie.delete(Ne):Ie.add(Ne),Ie})},qe=()=>{f.size===ge.length?y(new Set):y(new Set(ge.map(Ne=>Ne.id)))},Me=k.useCallback(async(Ne,Ue)=>{p("uploading");try{const Ie=`Recruiting blast (${f.size} recipients)`,{videoId:ye,libraryId:ct}=await wE(Ie),{uploadUrl:fe,apiKey:$e}=await jE(ye),Ye=new XMLHttpRequest;Ye.upload.onprogress=ut=>{ut.lengthComputable&&O(ut.loaded/ut.total*100)},await new Promise((ut,mt)=>{Ye.onload=()=>Ye.status>=200&&Ye.status<300?ut():mt(new Error("Upload failed")),Ye.onerror=()=>mt(new Error("Upload failed")),Ye.open("PUT",fe),Ye.setRequestHeader("AccessKey",$e),Ye.send(Ne)}),p("processing");const tt=`https://iframe.mediadelivery.net/embed/${ct}/${ye}`;let Te=0;const We=Date.now(),Ke=9e4;for(;Te<4&&(await new Promise(mt=>setTimeout(mt,3e3)),!(Date.now()-We>Ke));){const ut=await nw(ye);if(Te=ut.status,q(ut.encodeProgress||0),Te===5||Te===6)throw new Error("Video processing failed")}const ot=await nw(ye),He=(ot.storageSize||Ne.size)/(1024*1024),Je=await oe.mutateAsync({bunny_video_id:ye,playback_url:ot.directPlayUrl||tt,thumbnail_url:ot.thumbnailUrl,preview_url:ot.previewUrl||null,duration_seconds:ot.length||Ue,file_size_mb:He,title:Ie,status:Te>=4?"ready":"processing",touch_type:"recruiting"});C(Je.id),I(Ie),p("compose")}catch(Ie){pe.error((Ie==null?void 0:Ie.message)||"Failed to upload video"),p("pick-video")}},[f.size,oe]),ke=k.useCallback(async()=>{if(!(!S||f.size===0)){p("sending");try{const Ne=[];for(const ye of f){const ct=await ae.mutateAsync({prospect_id:ye,video_id:S,brokerage_id:t,message:te||void 0});Ne.push(ct.id)}const{data:Ue,error:Ie}=await G.functions.invoke("send-recruit-video-email",{body:{recruit_video_ids:Ne,brokerage_id:t,subject_override:B||void 0,message_override:te||void 0}});if(Ie)throw new Error(Ie.message);X({sent:(Ue==null?void 0:Ue.sent)??0,total:(Ue==null?void 0:Ue.total)??Ne.length}),p("done"),pe.success(`Sent ${(Ue==null?void 0:Ue.sent)??0} of ${(Ue==null?void 0:Ue.total)??Ne.length} videos`)}catch(Ne){pe.error((Ne==null?void 0:Ne.message)||"Failed to send"),p("compose")}}},[S,f,t,te,B,ae]),Re=f.size,Ve=ce.filter(Ne=>!Ne.email).length;return e.jsxs(fs,{open:i,onOpenChange:he,children:[s&&e.jsx(mi,{asChild:!0,children:s}),e.jsxs(ps,{className:"max-w-3xl max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsx(ks,{children:e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(yn,{className:"h-5 w-5 text-primary"}),"Send Recruiting Video",Re>0&&e.jsxs(Qe,{variant:"secondary",className:"ml-2",children:[e.jsx(ir,{className:"h-3 w-3 mr-1"}),Re," ",Re===1?"recipient":"recipients"]})]})}),u==="pick-recipients"&&e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search prospects...",value:N,onChange:Ne=>w(Ne.target.value),className:"pl-9"})]}),e.jsxs($s,{value:_,onValueChange:b,children:[e.jsx(zs,{className:"w-48",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"all",children:"All stages"}),ie.map(Ne=>e.jsx(vt,{value:Ne.id,children:Ne.name},Ne.id))]})]})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsxs("button",{onClick:qe,className:"hover:underline",children:[f.size===ge.length&&ge.length>0?"Deselect all":"Select all"," ","(",ge.length,")"]}),Ve>0&&e.jsxs("span",{children:[Ve," prospect(s) hidden — no email on file"]})]}),e.jsx(Ja,{className:"flex-1 border rounded-md",children:ge.length===0?e.jsx("div",{className:"p-8 text-center text-sm text-muted-foreground",children:"No prospects match. Make sure prospects have email addresses."}):e.jsx("div",{className:"divide-y",children:ge.map(Ne=>{const Ue=f.has(Ne.id),Ie=ie.find(ye=>ye.id===Ne.stage_id);return e.jsxs("label",{className:"flex items-center gap-3 p-3 hover:bg-muted/30 cursor-pointer",children:[e.jsx(Ri,{checked:Ue,onCheckedChange:()=>je(Ne.id)}),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:[Ne.first_name," ",Ne.last_name]}),Ie&&e.jsx(Qe,{variant:"outline",className:"text-[10px]",style:{borderColor:Ie.color,color:Ie.color},children:Ie.name})]}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[Ne.email," ",Ne.current_brokerage&&`· ${Ne.current_brokerage}`]})]})]},Ne.id)})})}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>he(!1),children:"Cancel"}),e.jsx(W,{disabled:Re===0,onClick:()=>p("pick-video"),children:"Next: Choose Video"})]})]}),u==="pick-video"&&e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(ta,{defaultValue:"record",className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs(Jn,{className:"self-start",children:[e.jsxs(cs,{value:"record",children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1"}),"Record New"]}),e.jsxs(cs,{value:"library",children:[e.jsx(oS,{className:"h-3.5 w-3.5 mr-1"}),"Use Existing"]})]}),e.jsx(Ss,{value:"record",className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"text-center py-8 space-y-4",children:[e.jsx(Rd,{className:"h-12 w-12 mx-auto text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Record a fresh video"}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["Same video sent to all ",Re," ",Re===1?"recipient":"recipients"," — each gets their own tracked link."]})]}),e.jsxs(W,{onClick:()=>p("record"),children:[e.jsx(yn,{className:"h-4 w-4 mr-2"}),"Start Recording"]})]})}),e.jsx(Ss,{value:"library",className:"flex-1 overflow-auto",children:me.length===0?e.jsx("div",{className:"text-center py-8 text-sm text-muted-foreground",children:"No recruiting videos in library yet."}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3 p-1",children:me.map(Ne=>e.jsxs("button",{onClick:()=>{C(Ne.id),I(Ne.title||"Untitled"),p("compose")},className:"text-left group rounded-md border overflow-hidden hover:border-primary transition-colors",children:[e.jsx("div",{className:"aspect-video bg-muted relative",children:Ne.thumbnail_url?e.jsx("img",{src:Ne.thumbnail_url,alt:"",className:"w-full h-full object-cover",referrerPolicy:"no-referrer"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(yn,{className:"h-8 w-8 text-muted-foreground"})})}),e.jsx("div",{className:"p-2",children:e.jsx("p",{className:"text-xs font-medium truncate",children:Ne.title||"Untitled"})})]},Ne.id))})})]}),e.jsx(gn,{children:e.jsx(W,{variant:"outline",onClick:()=>p("pick-recipients"),children:"Back"})})]}),u==="record"&&e.jsxs("div",{className:"flex-1 overflow-auto",children:[e.jsx(AO,{maxDurationSeconds:600,onRecordingComplete:Me}),e.jsx("div",{className:"mt-2 flex justify-start",children:e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>p("pick-video"),children:"← Back"})})]}),(u==="uploading"||u==="processing")&&e.jsxs("div",{className:"py-12 space-y-4 text-center",children:[e.jsx(us,{className:"h-8 w-8 animate-spin mx-auto text-primary"}),e.jsx("p",{className:"font-medium",children:u==="uploading"?"Uploading video…":"Processing video…"}),e.jsx(xi,{value:u==="uploading"?L:V,className:"mx-auto max-w-sm"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Math.round(u==="uploading"?L:V),"%"]})]}),u==="compose"&&e.jsxs("div",{className:"flex-1 overflow-auto space-y-4",children:[e.jsxs("div",{className:"rounded-md border p-3 bg-muted/30 flex items-center gap-3",children:[e.jsx($n,{className:"h-4 w-4 text-primary"}),e.jsxs("div",{className:"flex-1 text-sm",children:[e.jsx("span",{className:"font-medium",children:A})," selected · sending to ",e.jsx("strong",{children:Re})," recipient",Re===1?"":"s"]})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Subject (optional override)"}),e.jsx(De,{value:B,onChange:Ne=>U(Ne.target.value),placeholder:"[First Name], I made you a quick video 🎥",className:"mt-1"}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1",children:"Leave blank to use the default personalized subject."})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Personal message shown in the email & on the landing page"}),e.jsx(_r,{value:te,onChange:Ne=>Y(Ne.target.value),placeholder:"Hey there — wanted to share a quick thought on what we're building here...",rows:5,className:"mt-1"})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>p("pick-video"),children:"Back"}),e.jsxs(W,{onClick:ke,disabled:!S||Re===0,children:[e.jsx(_n,{className:"h-4 w-4 mr-2"})," Send to ",Re," ",Re===1?"prospect":"prospects"]})]})]}),u==="sending"&&e.jsxs("div",{className:"py-12 text-center space-y-3",children:[e.jsx(us,{className:"h-8 w-8 animate-spin mx-auto text-primary"}),e.jsxs("p",{className:"font-medium",children:["Sending to ",Re," recipient",Re===1?"":"s","…"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Each prospect gets their own tracked share link."})]}),u==="done"&&J&&e.jsxs("div",{className:"py-12 text-center space-y-4",children:[e.jsx("div",{className:`h-16 w-16 rounded-full mx-auto flex items-center justify-center ${J.sent===J.total?"bg-primary/10":"bg-muted"}`,children:J.sent===J.total?e.jsx($n,{className:"h-8 w-8 text-primary"}):e.jsx(ro,{className:"h-8 w-8 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-semibold text-lg",children:[J.sent," of ",J.total," sent"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"View engagement under the Video Outreach tab."})]}),e.jsx(W,{onClick:()=>he(!1),children:"Done"})]})]})]})}function ZSs(){var i;const[t,s]=k.useState(""),[r,n]=k.useState("board"),{data:a=[],isLoading:o}=gt({queryKey:["all-brokerages"],queryFn:async()=>{const{data:d,error:u}=await G.from("brokerages").select("id, name").order("name");if(u)throw u;return d}}),l=t||((i=a[0])==null?void 0:i.id)||"";return o?e.jsx(Ds,{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(Ds,{title:"Recruiting",description:"Agent Recruiting Pipeline",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",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($s,{value:l,onValueChange:s,children:[e.jsxs(zs,{className:"w-[280px]",children:[e.jsx(pa,{className:"mr-2 h-4 w-4"}),e.jsx(Vs,{placeholder:"Select brokerage"})]}),e.jsx(Bs,{children:a.map(d=>e.jsx(vt,{value:d.id,children:d.name},d.id))})]})]}):e.jsx("div",{}),l&&e.jsx(KSs,{brokerageId:l,trigger:e.jsxs(W,{size:"sm",className:"gap-1.5",children:[e.jsx(yn,{className:"h-4 w-4"})," Record & Send Video"]})})]}),l?e.jsxs(ta,{defaultValue:"pipeline",className:"space-y-4",children:[e.jsxs(Jn,{className:"flex-wrap h-auto gap-1",children:[e.jsx(cs,{value:"pipeline",children:"Pipeline"}),e.jsxs(cs,{value:"contacts",children:[e.jsx(ir,{className:"h-3.5 w-3.5 mr-1"}),"Contacts"]}),e.jsxs(cs,{value:"video-outreach",children:[e.jsx(yn,{className:"h-3.5 w-3.5 mr-1"}),"Video Outreach"]}),e.jsx(cs,{value:"follow-ups",children:"Follow-ups"}),e.jsx(cs,{value:"referrals",children:"Referrals"}),e.jsx(cs,{value:"interest",children:"Interest Form"}),e.jsx(cs,{value:"landing-page",children:"Landing Page"}),e.jsx(cs,{value:"goals",children:"Goals"}),e.jsx(cs,{value:"metrics",children:"Metrics"}),e.jsx(cs,{value:"templates",children:"Email Templates"}),e.jsxs(cs,{value:"campaigns",children:[e.jsx(tr,{className:"h-3.5 w-3.5 mr-1"}),"Campaigns"]}),e.jsxs(cs,{value:"drip-assignments",children:[e.jsx(_n,{className:"h-3.5 w-3.5 mr-1"}),"Drip Assignments"]}),e.jsx(cs,{value:"activity",children:"Recruiter Activity"}),e.jsxs(cs,{value:"email-settings",children:[e.jsx(So,{className:"h-3.5 w-3.5 mr-1"}),"Email Settings"]}),e.jsxs(cs,{value:"pipeline-stages",children:[e.jsx(vS,{className:"h-3.5 w-3.5 mr-1"}),"Pipeline Stages"]}),e.jsxs(cs,{value:"unsubscribed",children:[e.jsx(gS,{className:"h-3.5 w-3.5 mr-1"}),"Unsubscribed"]})]}),e.jsxs(Ss,{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(W,{variant:r==="board"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>n("board"),children:[e.jsx(xp,{className:"h-3.5 w-3.5"})," Board"]}),e.jsxs(W,{variant:r==="table"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>n("table"),children:[e.jsx(OM,{className:"h-3.5 w-3.5"})," Table"]})]})}),r==="board"?e.jsx(sct,{brokerageId:l}):e.jsx(Ede,{brokerageId:l})]}),e.jsx(Ss,{value:"contacts",children:e.jsx(Ede,{brokerageId:l})}),e.jsx(Ss,{value:"video-outreach",children:e.jsx(dct,{brokerageId:l})}),e.jsx(Ss,{value:"follow-ups",children:e.jsx(lct,{brokerageId:l})}),e.jsx(Ss,{value:"referrals",children:e.jsx(ict,{brokerageId:l})}),e.jsx(Ss,{value:"interest",children:e.jsx(oct,{brokerageId:l})}),e.jsx(Ss,{value:"landing-page",children:e.jsx(cct,{brokerageId:l})}),e.jsx(Ss,{value:"goals",children:e.jsx(uct,{brokerageId:l})}),e.jsx(Ss,{value:"metrics",children:e.jsx(rct,{brokerageId:l})}),e.jsx(Ss,{value:"templates",children:e.jsx(nct,{brokerageId:l})}),e.jsx(Ss,{value:"campaigns",children:e.jsx(pct,{brokerageId:l})}),e.jsx(Ss,{value:"drip-assignments",children:e.jsx(fct,{brokerageId:l})}),e.jsx(Ss,{value:"activity",children:e.jsx(act,{brokerageId:l})}),e.jsx(Ss,{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(VCe,{brokerageId:l})]})}),e.jsx(Ss,{value:"pipeline-stages",children:e.jsx("div",{className:"max-w-2xl",children:e.jsx(xct,{brokerageId:l})})}),e.jsx(Ss,{value:"unsubscribed",children:e.jsx(WSs,{brokerageId:l})})]}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(pa,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages found. Create a brokerage first."})]})]})})}function YSs(){var l;const{managedBrokerages:t,selectedBrokerageId:s,setSelectedBrokerageId:r}=Us(),[n,a]=k.useState("board"),o=s||((l=t[0])==null?void 0:l.id)||"";return t.length===0?e.jsx(Ds,{title:"Recruiting",description:"Agent Recruiting Pipeline",children:e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(pa,{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(Ds,{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($s,{value:o,onValueChange:r,children:[e.jsxs(zs,{className:"w-[280px]",children:[e.jsx(pa,{className:"mr-2 h-4 w-4"}),e.jsx(Vs,{placeholder:"Select brokerage"})]}),e.jsx(Bs,{children:t.map(i=>e.jsx(vt,{value:i.id,children:i.name},i.id))})]})]}),o?e.jsxs(ta,{defaultValue:"pipeline",className:"space-y-4",children:[e.jsxs(Jn,{className:"flex-wrap h-auto gap-1",children:[e.jsx(cs,{value:"pipeline",children:"Pipeline"}),e.jsxs(cs,{value:"contacts",children:[e.jsx(ir,{className:"h-3.5 w-3.5 mr-1"}),"Contacts"]}),e.jsxs(cs,{value:"video-outreach",children:[e.jsx(yn,{className:"h-3.5 w-3.5 mr-1"}),"Video Outreach"]}),e.jsx(cs,{value:"follow-ups",children:"Follow-ups"}),e.jsx(cs,{value:"referrals",children:"Referrals"}),e.jsx(cs,{value:"interest",children:"Interest Form"}),e.jsx(cs,{value:"landing-page",children:"Landing Page"}),e.jsx(cs,{value:"goals",children:"Goals"}),e.jsx(cs,{value:"metrics",children:"Metrics"}),e.jsx(cs,{value:"templates",children:"Email Templates"}),e.jsxs(cs,{value:"campaigns",children:[e.jsx(tr,{className:"h-3.5 w-3.5 mr-1"}),"Campaigns"]}),e.jsxs(cs,{value:"drip-assignments",children:[e.jsx(_n,{className:"h-3.5 w-3.5 mr-1"}),"Drip Assignments"]}),e.jsx(cs,{value:"activity",children:"Recruiter Activity"}),e.jsxs(cs,{value:"email-settings",children:[e.jsx(So,{className:"h-3.5 w-3.5 mr-1"}),"Email Settings"]}),e.jsxs(cs,{value:"pipeline-stages",children:[e.jsx(vS,{className:"h-3.5 w-3.5 mr-1"}),"Pipeline Stages"]})]}),e.jsxs(Ss,{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(W,{variant:n==="board"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>a("board"),children:[e.jsx(xp,{className:"h-3.5 w-3.5"})," Board"]}),e.jsxs(W,{variant:n==="table"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>a("table"),children:[e.jsx(OM,{className:"h-3.5 w-3.5"})," Table"]})]})}),n==="board"?e.jsx(sct,{brokerageId:o}):e.jsx(Ede,{brokerageId:o})]}),e.jsx(Ss,{value:"contacts",children:e.jsx(Ede,{brokerageId:o})}),e.jsx(Ss,{value:"video-outreach",children:e.jsx(dct,{brokerageId:o})}),e.jsx(Ss,{value:"follow-ups",children:e.jsx(lct,{brokerageId:o})}),e.jsx(Ss,{value:"referrals",children:e.jsx(ict,{brokerageId:o})}),e.jsx(Ss,{value:"interest",children:e.jsx(oct,{brokerageId:o})}),e.jsx(Ss,{value:"landing-page",children:e.jsx(cct,{brokerageId:o})}),e.jsx(Ss,{value:"goals",children:e.jsx(uct,{brokerageId:o})}),e.jsx(Ss,{value:"metrics",children:e.jsx(rct,{brokerageId:o})}),e.jsx(Ss,{value:"templates",children:e.jsx(nct,{brokerageId:o})}),e.jsx(Ss,{value:"campaigns",children:e.jsx(pct,{brokerageId:o})}),e.jsx(Ss,{value:"drip-assignments",children:e.jsx(fct,{brokerageId:o})}),e.jsx(Ss,{value:"activity",children:e.jsx(act,{brokerageId:o})}),e.jsx(Ss,{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(VCe,{brokerageId:o})]})}),e.jsx(Ss,{value:"pipeline-stages",children:e.jsx("div",{className:"max-w-2xl",children:e.jsx(xct,{brokerageId:o})})})]}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(pa,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages found."})]})]})})}function XSs(){const[t,s]=k.useState(""),{data:r,isLoading:n}=gt({queryKey:["admin-brokerage-content-activity"],queryFn:async()=>{const{data:i}=await G.from("brokerages").select("id, name");if(!i)return[];const{data:d}=await G.from("brokerage_content").select("id, brokerage_id, content_type, created_at"),{data:u}=await G.from("brokerage_content_categories").select("id, brokerage_id"),p=d||[],f=u||[],y=i.map(_=>{const b=p.filter(S=>S.brokerage_id===_.id),N=f.filter(S=>S.brokerage_id===_.id),w=b.length>0?b.reduce((S,C)=>C.created_at>S?C.created_at:S,b[0].created_at):null;return{brokerage_id:_.id,brokerage_name:_.name,total_items:b.length,videos:b.filter(S=>S.content_type==="video").length,pdfs:b.filter(S=>S.content_type==="pdf").length,links:b.filter(S=>S.content_type==="link"||S.content_type==="canva_link").length,events:b.filter(S=>S.content_type==="event").length,graphics:b.filter(S=>S.content_type==="graphic").length,latest_item_date:w,categories:N.length}});return y.sort((_,b)=>b.total_items-_.total_items),y}}),a=(r||[]).filter(i=>i.brokerage_name.toLowerCase().includes(t.toLowerCase())),o=a.reduce((i,d)=>i+d.total_items,0),l=a.filter(i=>i.total_items>0).length;return e.jsx(Ds,{title:"Brokerage Content Activity",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Hu,{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(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Active Brokerages"})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-2xl font-bold",children:l}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with content uploaded"})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Content Items"})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-2xl font-bold",children:o}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"across all brokerages"})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Brokerages"})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-2xl font-bold",children:a.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"registered"})]})]})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search brokerages...",value:t,onChange:i=>s(i.target.value),className:"pl-9"})]}),e.jsx(Pe,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Brokerage"}),e.jsx(St,{className:"text-center",children:"Total"}),e.jsx(St,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(yn,{className:"h-3 w-3"})," Videos"]})}),e.jsx(St,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(vn,{className:"h-3 w-3"})," PDFs"]})}),e.jsx(St,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Do,{className:"h-3 w-3"})," Links"]})}),e.jsx(St,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(_d,{className:"h-3 w-3"})," Events"]})}),e.jsx(St,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(qo,{className:"h-3 w-3"})," Graphics"]})}),e.jsx(St,{className:"text-center",children:"Categories"}),e.jsx(St,{children:"Last Upload"})]})}),e.jsx(Rn,{children:n?e.jsx(Ps,{children:e.jsx(ht,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):a.length===0?e.jsx(Ps,{children:e.jsx(ht,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"No brokerages found"})}):a.map(i=>e.jsxs(Ps,{className:i.total_items===0?"opacity-50":"",children:[e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pa,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:i.brokerage_name})]})}),e.jsx(ht,{className:"text-center",children:i.total_items>0?e.jsx(Qe,{variant:"secondary",className:"font-bold",children:i.total_items}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(ht,{className:"text-center",children:i.videos||"–"}),e.jsx(ht,{className:"text-center",children:i.pdfs||"–"}),e.jsx(ht,{className:"text-center",children:i.links||"–"}),e.jsx(ht,{className:"text-center",children:i.events||"–"}),e.jsx(ht,{className:"text-center",children:i.graphics||"–"}),e.jsx(ht,{className:"text-center",children:i.categories||"–"}),e.jsx(ht,{children:i.latest_item_date?e.jsx("span",{className:"text-sm text-muted-foreground",children:vs(new Date(i.latest_item_date),"MMM d, yyyy")}):e.jsx("span",{className:"text-muted-foreground",children:"–"})})]},i.brokerage_id))})]})})})]})})}function QSs(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 JSs=(()=>{let t=0;const s=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${s()}${t}`)})();function qb(t){const s=[];for(let r=0,n=t.length;rqp||t.height>qp)&&(t.width>qp&&t.height>qp?t.width>t.height?(t.height*=qp/t.width,t.width=qp):(t.width*=qp/t.height,t.height=qp):t.width>qp?(t.height*=qp/t.width,t.width=qp):(t.width*=qp/t.height,t.height=qp))}function Ide(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 nCs(t){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then(s=>`data:image/svg+xml;charset=utf-8,${s}`)}async function aCs(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),nCs(a)}const _p=(t,s)=>{if(t instanceof s)return!0;const r=Object.getPrototypeOf(t);return r===null?!1:r.constructor.name===s.name||_p(r,s)};function iCs(t){const s=t.getPropertyValue("content");return`${t.cssText} content: '${s.replace(/'|"/g,"")}';`}function oCs(t,s){return gct(s).map(r=>{const n=t.getPropertyValue(r),a=t.getPropertyPriority(r);return`${r}: ${n}${a?" !important":""};`}).join(" ")}function lCs(t,s,r,n){const a=`.${t}:${s}`,o=r.cssText?iCs(r):oCs(r,n);return document.createTextNode(`${a}{${o}}`)}function j9e(t,s,r,n){const a=window.getComputedStyle(t,r),o=a.getPropertyValue("content");if(o===""||o==="none")return;const l=JSs();try{s.className=`${s.className} ${l}`}catch{return}const i=document.createElement("style");i.appendChild(lCs(l,r,a,n)),s.appendChild(i)}function cCs(t,s,r){j9e(t,s,":before",r),j9e(t,s,":after",r)}const N9e="application/font-woff",k9e="image/jpeg",dCs={woff:N9e,woff2:N9e,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:k9e,jpeg:k9e,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function uCs(t){const s=/\.([^./]*?)$/g.exec(t);return s?s[1]:""}function HCe(t){const s=uCs(t).toLowerCase();return dCs[s]||""}function hCs(t){return t.split(/,/)[1]}function t2e(t){return t.search(/^(data:)/)!==-1}function mCs(t,s){return`data:${s};base64,${t}`}async function vct(t,s,r){const n=await fetch(t,s);if(n.status===404)throw new Error(`Resource "${n.url}" not found`);const a=await n.blob();return new Promise((o,l)=>{const i=new FileReader;i.onerror=l,i.onloadend=()=>{try{o(r({res:n,result:i.result}))}catch(d){l(d)}},i.readAsDataURL(a)})}const k0e={};function pCs(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 GCe(t,s,r){const n=pCs(t,s,r.includeQueryParams);if(k0e[n]!=null)return k0e[n];r.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+new Date().getTime());let a;try{const o=await vct(t,r.fetchRequestInit,({res:l,result:i})=>(s||(s=l.headers.get("Content-Type")||""),hCs(i)));a=mCs(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 k0e[n]=a,a}async function fCs(t){const s=t.toDataURL();return s==="data:,"?t.cloneNode(!1):Ide(s)}async function xCs(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 Ide(i)}const r=t.poster,n=HCe(r),a=await GCe(r,n,s);return Ide(a)}async function gCs(t,s){var r;try{if(!((r=t==null?void 0:t.contentDocument)===null||r===void 0)&&r.body)return await spe(t.contentDocument.body,s,!0)}catch{}return t.cloneNode(!1)}async function yCs(t,s){return _p(t,HTMLCanvasElement)?fCs(t):_p(t,HTMLVideoElement)?xCs(t,s):_p(t,HTMLIFrameElement)?gCs(t,s):t.cloneNode(_ct(t))}const vCs=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SLOT",_ct=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SVG";async function _Cs(t,s,r){var n,a;if(_ct(s))return s;let o=[];return vCs(t)&&t.assignedNodes?o=qb(t.assignedNodes()):_p(t,HTMLIFrameElement)&&(!((n=t.contentDocument)===null||n===void 0)&&n.body)?o=qb(t.contentDocument.body.childNodes):o=qb(((a=t.shadowRoot)!==null&&a!==void 0?a:t).childNodes),o.length===0||_p(t,HTMLVideoElement)||await o.reduce((l,i)=>l.then(()=>spe(i,r)).then(d=>{d&&s.appendChild(d)}),Promise.resolve()),s}function bCs(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):gct(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`),_p(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 wCs(t,s){_p(t,HTMLTextAreaElement)&&(s.innerHTML=t.value),_p(t,HTMLInputElement)&&s.setAttribute("value",t.value)}function jCs(t,s){if(_p(t,HTMLSelectElement)){const r=s,n=Array.from(r.children).find(a=>t.value===a.getAttribute("value"));n&&n.setAttribute("selected","")}}function NCs(t,s,r){return _p(s,Element)&&(bCs(t,s,r),cCs(t,s,r),wCs(t,s),jCs(t,s)),s}async function kCs(t,s){const r=t.querySelectorAll?t.querySelectorAll("use"):[];if(r.length===0)return t;const n={};for(let o=0;oyCs(n,s)).then(n=>_Cs(t,n,s)).then(n=>NCs(t,n,s)).then(n=>kCs(n,s))}const bct=/url\((['"]?)([^'"]+?)\1\)/g,SCs=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,CCs=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function MCs(t){const s=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${s})(['"]?\\))`,"g")}function TCs(t){const s=[];return t.replace(bct,(r,n,a)=>(s.push(a),r)),s.filter(r=>!t2e(r))}async function ACs(t,s,r,n,a){try{const o=r?QSs(s,r):s,l=HCe(s);let i;return a||(i=await GCe(o,l,n)),t.replace(MCs(s),`$1${i}$3`)}catch{}return t}function ECs(t,{preferredFontFormat:s}){return s?t.replace(CCs,r=>{for(;;){const[n,,a]=SCs.exec(r)||[];if(!a)return"";if(a===s)return`src: ${n};`}}):t}function wct(t){return t.search(bct)!==-1}async function jct(t,s,r){if(!wct(t))return t;const n=ECs(t,r);return TCs(n).reduce((o,l)=>o.then(i=>ACs(i,l,s,r)),Promise.resolve(n))}async function A5(t,s,r){var n;const a=(n=s.style)===null||n===void 0?void 0:n.getPropertyValue(t);if(a){const o=await jct(a,null,r);return s.style.setProperty(t,o,s.style.getPropertyPriority(t)),!0}return!1}async function PCs(t,s){await A5("background",t,s)||await A5("background-image",t,s),await A5("mask",t,s)||await A5("-webkit-mask",t,s)||await A5("mask-image",t,s)||await A5("-webkit-mask-image",t,s)}async function ICs(t,s){const r=_p(t,HTMLImageElement);if(!(r&&!t2e(t.src))&&!(_p(t,SVGImageElement)&&!t2e(t.href.baseVal)))return;const n=r?t.src:t.href.baseVal,a=await GCe(n,HCe(n),s);await new Promise((o,l)=>{t.onload=o,t.onerror=s.onImageErrorHandler?(...d)=>{try{o(s.onImageErrorHandler(...d))}catch(u){l(u)}}:l;const i=t;i.decode&&(i.decode=o),i.loading==="lazy"&&(i.loading="eager"),r?(t.srcset="",t.src=a):t.href.baseVal=a})}async function LCs(t,s){const n=qb(t.childNodes).map(a=>Nct(a,s));await Promise.all(n).then(()=>t)}async function Nct(t,s){_p(t,Element)&&(await PCs(t,s),await ICs(t,s),await LCs(t,s))}function DCs(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 S9e={};async function C9e(t){let s=S9e[t];if(s!=null)return s;const n=await(await fetch(t)).text();return s={url:t,cssText:n},S9e[t]=s,s}async function M9e(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),vct(i,s.fetchRequestInit,({result:d})=>(r=r.replace(l,`url(${d})`),[l,d]))});return Promise.all(o).then(()=>r)}function T9e(t){if(t==null)return[];const s=[],r=/(\/\*[\s\S]*?\*\/)/gi;let n=t.replace(r,"");const a=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const d=a.exec(n);if(d===null)break;s.push(d[0])}n=n.replace(a,"");const o=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,l="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",i=new RegExp(l,"gi");for(;;){let d=o.exec(n);if(d===null){if(d=i.exec(n),d===null)break;o.lastIndex=i.lastIndex}else i.lastIndex=o.lastIndex;s.push(d[0])}return s}async function RCs(t,s){const r=[],n=[];return t.forEach(a=>{if("cssRules"in a)try{qb(a.cssRules||[]).forEach((o,l)=>{if(o.type===CSSRule.IMPORT_RULE){let i=l+1;const d=o.href,u=C9e(d).then(p=>M9e(p,s)).then(p=>T9e(p).forEach(f=>{try{a.insertRule(f,f.startsWith("@import")?i+=1:a.cssRules.length)}catch(y){console.error("Error inserting rule from remote css",{rule:f,error:y})}})).catch(p=>{console.error("Error loading remote css",p.toString())});n.push(u)}})}catch(o){const l=t.find(i=>i.href==null)||document.styleSheets[0];a.href!=null&&n.push(C9e(a.href).then(i=>M9e(i,s)).then(i=>T9e(i).forEach(d=>{l.insertRule(d,l.cssRules.length)})).catch(i=>{console.error("Error loading remote stylesheet",i)})),console.error("Error inlining remote css file",o)}}),Promise.all(n).then(()=>(t.forEach(a=>{if("cssRules"in a)try{qb(a.cssRules||[]).forEach(o=>{r.push(o)})}catch(o){console.error(`Error while reading CSS rules from ${a.href}`,o)}}),r))}function OCs(t){return t.filter(s=>s.type===CSSRule.FONT_FACE_RULE).filter(s=>wct(s.style.getPropertyValue("src")))}async function FCs(t,s){if(t.ownerDocument==null)throw new Error("Provided element is not within a Document");const r=qb(t.ownerDocument.styleSheets),n=await RCs(r,s);return OCs(n)}function kct(t){return t.trim().replace(/["']/g,"")}function zCs(t){const s=new Set;function r(n){(n.style.fontFamily||getComputedStyle(n).fontFamily).split(",").forEach(o=>{s.add(kct(o))}),Array.from(n.children).forEach(o=>{o instanceof HTMLElement&&r(o)})}return r(t),s}async function BCs(t,s){const r=await FCs(t,s),n=zCs(t);return(await Promise.all(r.filter(o=>n.has(kct(o.style.fontFamily))).map(o=>{const l=o.parentStyleSheet?o.parentStyleSheet.href:null;return jct(o.cssText,l,s)}))).join(` `)}async function $Cs(t,s){const r=s.fontEmbedCSS!=null?s.fontEmbedCSS:s.skipFonts?null:await BCs(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 qCs(t,s={}){const{width:r,height:n}=yct(t,s),a=await spe(t,s,!0);return await $Cs(a,s),await Nct(a,s),DCs(a,s),await aCs(a,r,n)}async function UCs(t,s={}){const{width:r,height:n}=yct(t,s),a=await qCs(t,s),o=await Ide(a),l=document.createElement("canvas"),i=l.getContext("2d"),d=s.pixelRatio||sCs(),u=s.canvasWidth||r,p=s.canvasHeight||n;return l.width=u*d,l.height=p*d,s.skipAutoScale||rCs(l),l.style.width=`${u}`,l.style.height=`${p}`,s.backgroundColor&&(i.fillStyle=s.backgroundColor,i.fillRect(0,0,l.width,l.height)),i.drawImage(o,0,0,l.width,l.height),l}async function VCs(t,s={}){return(await UCs(t,s)).toDataURL()}const TA=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),rpe={"just-listed":"JUST LISTED","just-sold":"JUST SOLD","open-house":"OPEN HOUSE","price-drop":"PRICE DROP"},P9={"instagram-square":{width:1080,height:1080},"instagram-story":{width:1080,height:1920},"facebook-post":{width:1200,height:630}},HCs=({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})]})]}),Sct=xt.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,d=(f=t.photos)==null?void 0:f[a],u=rpe[s],p=[t.bedrooms?`${t.bedrooms} Bed`:null,t.bathrooms?`${t.bathrooms} Bath`:null,t.sqft?`${t.sqft.toLocaleString()} Sq Ft`:null].filter(Boolean).join(" • ");return e.jsxs("div",{ref:o,style:{width:l.w,height:l.h,transform:`scale(${i})`,transformOrigin:"top left",position:"relative",overflow:"hidden",fontFamily:"'Georgia', 'Times New Roman', serif",color:"#FFFFFF"},children:[d&&e.jsx("img",{src:d,alt:"",crossOrigin:"anonymous",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),e.jsx("div",{style:{position:"absolute",inset:0,background:"linear-gradient(180deg, rgba(10,10,30,0.3) 0%, rgba(10,10,30,0.85) 100%)"}}),e.jsxs("div",{style:{position:"relative",height:"100%",display:"flex",flexDirection:"column",justifyContent:"space-between",padding:l.w*.06},children:[e.jsx("div",{children:e.jsx("div",{style:{display:"inline-block",background:"linear-gradient(135deg, #C9A84C, #E8D48B)",color:"#1A1A2E",padding:`${l.w*.012}px ${l.w*.035}px`,fontSize:l.w*.032,fontWeight:700,letterSpacing:"0.25em",textTransform:"uppercase"},children:u})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:l.w*.07,fontWeight:700,lineHeight:1.1,marginBottom:l.w*.015,textShadow:"0 2px 12px rgba(0,0,0,0.5)"},children:TA(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.028,color:"#C9A84C",marginBottom:l.w*.01},children:["Sold for ",TA(t.soldPrice)]}),e.jsx("div",{style:{fontSize:l.w*.028,opacity:.9,marginBottom:l.w*.008},children:t.address}),e.jsxs("div",{style:{fontSize:l.w*.022,opacity:.7,marginBottom:l.w*.02},children:[t.city,", ",t.state," ",t.zip]}),e.jsx("div",{style:{display:"flex",gap:l.w*.015,fontSize:l.w*.022,letterSpacing:"0.05em",borderTop:"1px solid rgba(201,168,76,0.4)",paddingTop:l.w*.02},children:e.jsx("span",{children:p})}),s==="open-house"&&e.jsx("div",{style:{marginTop:l.w*.02,background:"rgba(201,168,76,0.15)",border:"1px solid rgba(201,168,76,0.4)",padding:`${l.w*.01}px ${l.w*.02}px`,fontSize:l.w*.024,letterSpacing:"0.1em",display:"inline-block"},children:"SAT & SUN • 1–4 PM"}),e.jsx(HCs,{branding:n,dim:l})]})]})]})});Sct.displayName="LuxuryDarkTemplate";const GCs=({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})]})]}),Cct=xt.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var _;const l=r==="instagram-story"?{w:1080,h:1920}:r==="facebook-post"?{w:1200,h:630}:{w:1080,h:1080},i=400/l.w,d=(_=t.photos)==null?void 0:_[a],u=rpe[s],p=r==="instagram-story",f=r==="facebook-post",y=s==="just-sold"?"#7C3AED":s==="open-house"?"#2563EB":s==="price-drop"?"#DC2626":"#059669";return e.jsxs("div",{ref:o,style:{width:l.w,height:l.h,transform:`scale(${i})`,transformOrigin:"top left",position:"relative",overflow:"hidden",fontFamily:"'Helvetica Neue', Arial, sans-serif",color:"#1A1A1A",background:"#FFFFFF",display:"flex",flexDirection:f?"row":"column"},children:[e.jsxs("div",{style:{width:f?"55%":"100%",height:f?"100%":p?"50%":"52%",position:"relative",overflow:"hidden",flexShrink:0},children:[d&&e.jsx("img",{src:d,alt:"",crossOrigin:"anonymous",style:{width:"100%",height:"100%",objectFit:"cover"}}),e.jsx("div",{style:{position:"absolute",top:l.w*.04,left:0,background:y,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:y,marginBottom:l.w*.012},children:TA(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:`${y}10`,border:`2px solid ${y}`,borderRadius:l.w*.01,padding:`${l.w*.01}px ${l.w*.02}px`,fontSize:l.w*.022,fontWeight:700,color:y,display:"inline-block",marginBottom:l.w*.015},children:"SAT & SUN • 1–4 PM"}),e.jsx(GCs,{branding:n,dim:l,accentColor:y})]})]})});Cct.displayName="ModernCleanTemplate";const WCs=({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})]})]}),Mct=xt.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,d=(y=t.photos)==null?void 0:y[a],u=rpe[s],p={"just-listed":"linear-gradient(135deg, #059669, #10B981)","just-sold":"linear-gradient(135deg, #7C3AED, #A855F7)","open-house":"linear-gradient(135deg, #2563EB, #3B82F6)","price-drop":"linear-gradient(135deg, #DC2626, #F43F5E)"},f=[t.bedrooms?`${t.bedrooms} BD`:null,t.bathrooms?`${t.bathrooms} BA`:null,t.sqft?`${t.sqft.toLocaleString()} SF`:null].filter(Boolean).join(" | ");return e.jsxs("div",{ref:o,style:{width:l.w,height:l.h,transform:`scale(${i})`,transformOrigin:"top left",position:"relative",overflow:"hidden",fontFamily:"'Arial Black', 'Helvetica Neue', sans-serif",color:"#FFFFFF"},children:[d&&e.jsx("img",{src:d,alt:"",crossOrigin:"anonymous",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),e.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.4)"}}),e.jsxs("div",{style:{position:"relative",height:"100%",display:"flex",flexDirection:"column",padding:l.w*.05},children:[e.jsx("div",{style:{background:p[s],padding:`${l.w*.025}px ${l.w*.04}px`,fontSize:l.w*.055,fontWeight:900,letterSpacing:"0.08em",alignSelf:"flex-start",borderRadius:l.w*.01,boxShadow:"0 8px 32px rgba(0,0,0,0.3)",transform:"rotate(-2deg)",marginBottom:l.w*.03},children:u}),e.jsx("div",{style:{flex:1}}),e.jsxs("div",{style:{background:"rgba(0,0,0,0.65)",backdropFilter:"blur(10px)",borderRadius:l.w*.015,padding:l.w*.04},children:[e.jsx("div",{style:{fontSize:l.w*.08,fontWeight:900,lineHeight:1,marginBottom:l.w*.01},children:TA(t.price)}),e.jsx("div",{style:{fontSize:l.w*.028,fontWeight:700,marginBottom:l.w*.005},children:t.address}),e.jsxs("div",{style:{fontSize:l.w*.022,opacity:.8,marginBottom:l.w*.015},children:[t.city,", ",t.state," ",t.zip]}),e.jsx("div",{style:{display:"inline-block",background:"rgba(255,255,255,0.15)",borderRadius:l.w*.008,padding:`${l.w*.01}px ${l.w*.02}px`,fontSize:l.w*.022,fontWeight:700,letterSpacing:"0.08em"},children:f}),s==="open-house"&&e.jsx("div",{style:{marginTop:l.w*.015,background:p["open-house"],borderRadius:l.w*.008,padding:`${l.w*.012}px ${l.w*.025}px`,fontSize:l.w*.024,fontWeight:800,display:"inline-block",marginLeft:l.w*.01},children:"SAT & SUN 1–4 PM"}),e.jsx(WCs,{branding:n,dim:l})]})]})]})});Mct.displayName="BoldColorfulTemplate";const KCs=({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})]})]}),Tct=xt.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,d=(f=t.photos)==null?void 0:f[a],u=rpe[s],p=r==="instagram-story";return e.jsx("div",{ref:o,style:{width:l.w,height:l.h,transform:`scale(${i})`,transformOrigin:"top left",position:"relative",overflow:"hidden",fontFamily:"'Georgia', 'Times New Roman', serif",color:"#1A1A1A",background:"#F5F0EB"},children:e.jsxs("div",{style:{display:"flex",flexDirection:p?"column":"row",height:"100%"},children:[e.jsxs("div",{style:{width:p?"100%":"42%",height:p?"40%":"100%",display:"flex",flexDirection:"column",justifyContent:"center",padding:l.w*.05,order:p?2:1},children:[e.jsx("div",{style:{fontSize:l.w*.016,letterSpacing:"0.3em",textTransform:"uppercase",color:"#8B7355",borderBottom:"2px solid #8B7355",paddingBottom:l.w*.01,marginBottom:l.w*.025,display:"inline-block",alignSelf:"flex-start"},children:u}),e.jsx("div",{style:{fontSize:l.w*(p?.06:.055),fontWeight:700,lineHeight:1.1,marginBottom:l.w*.015,fontStyle:"italic"},children:TA(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.02,color:"#8B7355",marginBottom:l.w*.01},children:["Sold: ",TA(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(KCs,{branding:n,dim:l})]}),e.jsxs("div",{style:{width:p?"100%":"58%",height:p?"60%":"100%",position:"relative",overflow:"hidden",order:p?1:2},children:[d&&e.jsx("img",{src:d,alt:"",crossOrigin:"anonymous",style:{width:"100%",height:"100%",objectFit:"cover"}}),e.jsx("div",{style:{position:"absolute",inset:l.w*.02,border:"1px solid rgba(255,255,255,0.4)",pointerEvents:"none"}})]})]})})});Tct.displayName="EditorialTemplate";const ZCs=[{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:"📉"}],A9e=[{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(hu,{className:"h-4 w-4"})}],YCs=[{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:"📰"}],E9e=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),P9e={"luxury-dark":Sct,"modern-clean":Cct,"bold-colorful":Mct,editorial:Tct};function XCs(){const[t,s]=k.useState(""),[r,n]=k.useState("address"),[a,o]=k.useState(!1),[l,i]=k.useState([]),[d,u]=k.useState(null),[p,f]=k.useState(0),[y,_]=k.useState("just-listed"),[b,N]=k.useState(["instagram-square"]),[w,S]=k.useState("luxury-dark"),[C,A]=k.useState(!1),[I,L]=k.useState(""),[O,V]=k.useState(""),[q,B]=k.useState(""),[U,te]=k.useState(!1),[Y,J]=k.useState(!1),[X,ce]=k.useState([]),[ie,ae]=k.useState("search"),oe=k.useRef({});k.useEffect(()=>{(async()=>{const{data:{user:Ve}}=await G.auth.getUser();if(!Ve)return;const{data:Ne}=await G.from("profiles").select("name, avatar_url, brokerages(name)").eq("id",Ve.id).single();if(Ne){L(Ne.name||""),B(Ne.avatar_url||"");const Ue=Ne.brokerages;V((Ue==null?void 0:Ue.name)||"")}})()},[]);const me=async()=>{var Re;if(t.trim()){o(!0),i([]);try{const{data:Ve,error:Ne}=await G.functions.invoke("repliers-mls-search",{body:{searchType:r,query:t.trim()}});if(Ne)throw Ne;if(Ve.error)throw new Error(Ve.error);i(Ve.listings||[]),((Re=Ve.listings)==null?void 0:Re.length)===0&&pe.info("No listings found. Try a different search.")}catch(Ve){pe.error(Ve.message||"Search failed")}finally{o(!1)}}},ve=Re=>{var Ve;u(Re),f(0),ae("customize"),Re.soldDate||(Ve=Re.status)!=null&&Ve.toLowerCase().includes("sold")?_("just-sold"):_("just-listed")},he=Re=>{N(Ve=>Ve.includes(Re)?Ve.filter(Ne=>Ne!==Re):[...Ve,Re])},ge=k.useCallback(async()=>{if(!(!d||b.length===0)){te(!0),ce([]),ae("generate");try{await new Promise(Ve=>setTimeout(Ve,500));const Re=[];for(const Ve of b){const Ne=`${w}-${Ve}`,Ue=oe.current[Ne];if(!Ue)continue;const Ie=P9[Ve],ye=await VCs(Ue,{width:Ie.width,height:Ie.height,pixelRatio:1,cacheBust:!0,style:{transform:"none",transformOrigin:"top left"}});Re.push({format:Ve,imageUrl:ye})}ce(Re),pe.success(`Generated ${Re.length} social post${Re.length>1?"s":""}!`)}catch(Re){pe.error(Re.message||"Generation failed")}finally{te(!1)}}},[d,b,w,p,C,I,O,q,y]),je=async()=>{if(!(!d||b.length===0)){te(!0),ce([]),ae("generate");try{const Re={...d,photos:d.photos.length>0?[d.photos[p]]:[]},Ve=[];for(const Ne of b){const{data:Ue,error:Ie}=await G.functions.invoke("generate-listing-social-post",{body:{listing:Re,postType:y,format:Ne,branding:C?{enabled:!0,agentName:I,brokerage:O}:{enabled:!1}}});if(Ie)throw Ie;if(Ue.error)throw new Error(Ue.error);Ve.push({format:Ne,imageUrl:Ue.imageUrl})}ce(Ve),pe.success(`Generated ${Ve.length} AI post${Ve.length>1?"s":""}!`)}catch(Re){pe.error(Re.message||"AI generation failed")}finally{te(!1)}}},qe=()=>Y?je():ge(),Me=(Re,Ve)=>{var Ue;const Ne=document.createElement("a");Ne.href=Re,Ne.download=`${((Ue=d==null?void 0:d.address)==null?void 0:Ue.replace(/\s+/g,"-"))||"listing"}-${y}-${Ve}.png`,document.body.appendChild(Ne),Ne.click(),document.body.removeChild(Ne)},ke=d?{listing:d,postType:y,format:"instagram-square",branding:C?{enabled:!0,agentName:I,brokerage:O,agentPhotoUrl:q||void 0}:{enabled:!1},selectedPhotoIndex:p}:null;return e.jsx(Ds,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(Hu,{title:"Social Post Generator",description:"Search MLS listings and generate stunning social media posts"}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsxs("button",{onClick:()=>ae("search"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full transition-colors ${ie==="search"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:text-foreground"}`,children:[e.jsx(ln,{className:"h-3.5 w-3.5"})," 1. Find Listing"]}),e.jsx(xa,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("button",{onClick:()=>d&&ae("customize"),disabled:!d,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full transition-colors ${ie==="customize"?"bg-primary text-primary-foreground":d?"bg-muted text-muted-foreground hover:text-foreground":"bg-muted text-muted-foreground/50 cursor-not-allowed"}`,children:[e.jsx(Or,{className:"h-3.5 w-3.5"})," 2. Customize"]}),e.jsx(xa,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full ${ie==="generate"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground/50"}`,children:[e.jsx(qo,{className:"h-3.5 w-3.5"})," 3. Generate"]})]}),ie==="search"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(ln,{className:"h-5 w-5 text-primary"})," Search MLS Listings ",e.jsx(IXe,{})]}),e.jsx(dr,{children:"Find a listing by MLS number or property address using Repliers.io"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(ta,{value:r,onValueChange:Re=>n(Re),children:e.jsxs(Jn,{children:[e.jsxs(cs,{value:"address",children:[e.jsx(Ia,{className:"h-4 w-4 mr-1.5"})," Address"]}),e.jsxs(cs,{value:"mls",children:[e.jsx(mh,{className:"h-4 w-4 mr-1.5"})," MLS #"]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(De,{value:t,onChange:Re=>s(Re.target.value),placeholder:r==="mls"?"Enter MLS number...":"Enter property address...",className:"flex-1",onKeyDown:Re=>Re.key==="Enter"&&me()}),e.jsxs(W,{onClick:me,disabled:a||!t.trim(),children:[a?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(ln,{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((Re,Ve)=>{var Ne;return e.jsx(Pe,{className:"cursor-pointer hover:border-primary/50 hover:shadow-md transition-all group",onClick:()=>ve(Re),children:e.jsx(Oe,{className:"p-0",children:e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"w-32 h-28 flex-shrink-0 bg-muted rounded-l-lg overflow-hidden",children:(Ne=Re.photos)!=null&&Ne[0]?e.jsx("img",{src:Re.photos[0],alt:Re.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(Mn,{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:E9e(Re.price)}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:Re.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Re.city,", ",Re.state," ",Re.zip]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1.5 text-xs text-muted-foreground",children:[Re.bedrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(W4,{className:"h-3 w-3"})," ",Re.bedrooms]}),Re.bathrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(nf,{className:"h-3 w-3"})," ",Re.bathrooms]}),Re.sqft>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(jL,{className:"h-3 w-3"})," ",Re.sqft.toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(Qe,{variant:"outline",className:"text-[10px]",children:Re.mlsNumber}),e.jsx(Qe,{variant:"outline",className:"text-[10px]",children:Re.status})]})]})]})})},Re.mlsNumber||Ve)})})]})]}),ie==="customize"&&d&&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(Dt,{className:"pb-3",children:e.jsx(zt,{className:"text-base",children:"Selected Listing"})}),e.jsxs(Oe,{className:"space-y-3",children:[d.photos.length>0&&e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-[4/3] rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:d.photos[p],alt:"Listing photo",className:"w-full h-full object-cover"})}),d.photos.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsx(W,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>f(Re=>Math.max(0,Re-1)),disabled:p===0,children:e.jsx(Xo,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[p+1," of ",d.photos.length]}),e.jsx(W,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>f(Re=>Math.min(d.photos.length-1,Re+1)),disabled:p===d.photos.length-1,children:e.jsx(xa,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-lg",children:E9e(d.price)}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[d.city,", ",d.state," ",d.zip]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[d.bedrooms>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-sm font-semibold",children:d.bedrooms}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Beds"})]}),d.bathrooms>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-sm font-semibold",children:d.bathrooms}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Baths"})]}),d.sqft>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-sm font-semibold",children:d.sqft.toLocaleString()}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Sq Ft"})]})]}),e.jsxs(W,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{ae("search"),u(null)},children:[e.jsx(t0,{className:"h-3.5 w-3.5 mr-1.5"})," Choose Different Listing"]})]})]}),e.jsxs(Pe,{className:"lg:col-span-2",children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Or,{className:"h-5 w-5 text-primary"})," Customize Your Post"]}),e.jsx(dr,{children:"Choose template, post type, format, and branding"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zl,{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(Ar,{checked:Y,onCheckedChange:J}),Y&&e.jsx(Iv,{className:"h-4 w-4 text-purple-500"})]})]}),!Y&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(zl,{className:"h-4 w-4"})," Template Style"]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:YCs.map(Re=>e.jsxs("button",{onClick:()=>S(Re.value),className:`flex flex-col items-center gap-1 px-3 py-3 rounded-lg border-2 transition-all text-center ${w===Re.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-2xl",children:Re.preview}),e.jsx("span",{className:"text-sm font-medium",children:Re.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground leading-tight",children:Re.description})]},Re.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{className:"text-sm font-medium",children:"Post Type"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:ZCs.map(Re=>e.jsxs("button",{onClick:()=>_(Re.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm font-medium ${y===Re.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-lg",children:Re.icon})," ",Re.label]},Re.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{className:"text-sm font-medium",children:"Output Formats"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:A9e.map(Re=>e.jsxs("button",{onClick:()=>he(Re.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm ${b.includes(Re.value)?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[Re.icon,e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium",children:Re.label}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:Re.dimensions})]})]},Re.value))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(xe,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Ai,{className:"h-4 w-4"})," Agent Branding"]}),e.jsx(Ar,{checked:C,onCheckedChange:A})]}),C&&e.jsxs("div",{className:"space-y-3 pl-6 border-l-2 border-primary/20",children:[q&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:q,alt:"Agent",className:"w-12 h-12 rounded-full object-cover border-2 border-primary/30"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Profile photo will appear on the post"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(xe,{className:"text-xs text-muted-foreground",children:"Agent Name"}),e.jsx(De,{value:I,onChange:Re=>L(Re.target.value),placeholder:"Jane Smith"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(xe,{className:"text-xs text-muted-foreground",children:"Brokerage (optional)"}),e.jsx(De,{value:O,onChange:Re=>V(Re.target.value),placeholder:"XYZ Realty"})]})]})]})]}),!Y&&ke&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{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*(P9[b[0]||"instagram-square"].height/P9[b[0]||"instagram-square"].width)},children:(()=>{const Re=P9e[w],Ve=b[0]||"instagram-square";return e.jsx(Re,{...ke,format:Ve})})()})})]}),e.jsx(W,{onClick:qe,disabled:b.length===0||U,size:"lg",className:"w-full gap-2",children:U?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"h-5 w-5 animate-spin"})," Generating ",b.length," post",b.length>1?"s":"","..."]}):e.jsxs(e.Fragment,{children:[Y?e.jsx(Iv,{className:"h-5 w-5"}):e.jsx(Or,{className:"h-5 w-5"}),"Generate ",b.length," Social Post",b.length>1?"s":"",Y&&e.jsx(Qe,{variant:"outline",className:"ml-2 text-[10px]",children:"Uses Credits"})]})})]})]})]}),ie==="generate"&&e.jsxs("div",{className:"space-y-4",children:[U&&e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(us,{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"})]})}),X.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Generated Posts"}),e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>ae("customize"),children:[e.jsx(t0,{className:"h-3.5 w-3.5 mr-1.5"})," Regenerate"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:X.map((Re,Ve)=>{const Ne=A9e.find(Ue=>Ue.value===Re.format);return e.jsxs(Pe,{className:"overflow-hidden",children:[e.jsx("div",{className:"bg-muted/30 p-1",children:e.jsx("img",{src:Re.imageUrl,alt:`${Re.format} social post`,className:"w-full rounded"})}),e.jsxs(Oe,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[Ne==null?void 0:Ne.icon,e.jsx("span",{className:"text-sm font-medium",children:Ne==null?void 0:Ne.label})]}),e.jsx(Qe,{variant:"outline",className:"text-[10px]",children:Ne==null?void 0:Ne.dimensions})]}),e.jsxs(W,{size:"sm",className:"w-full gap-1.5",onClick:()=>Me(Re.imageUrl,Re.format),children:[e.jsx(Qa,{className:"h-3.5 w-3.5"})," Download"]})]})]},Ve)})})]})]}),ie==="generate"&&!Y&&d&&ke&&e.jsx("div",{style:{position:"absolute",left:"-9999px",top:0},"aria-hidden":!0,children:b.map(Re=>{const Ve=P9e[w],Ne=P9[Re];return e.jsx("div",{style:{width:Ne.width,height:Ne.height},children:e.jsx(Ve,{ref:Ue=>{oe.current[`${w}-${Re}`]=Ue},...ke,format:Re})},`${w}-${Re}`)})})]})})}function QCs(){return gt({queryKey:["lms-courses-admin"],queryFn:async()=>{const{data:t,error:s}=await G.from("lms_courses").select("*, modules:lms_modules(count), access:lms_course_access(*)").order("sort_order");if(s)throw s;return t}})}function JCs(t){return gt({queryKey:["lms-course-admin",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("lms_courses").select("*, modules:lms_modules(*, resources:lms_module_resources(*)), access:lms_course_access(*)").eq("id",t).single();if(r)throw r;return s!=null&&s.modules&&(s.modules.sort((n,a)=>n.sort_order-a.sort_order),s.modules.forEach(n=>{n.resources&&n.resources.sort((a,o)=>a.sort_order-o.sort_order)})),s},enabled:!!t})}function e3s(){const t=Qt();return Pt({mutationFn:async s=>{const{data:r,error:n}=await G.from("lms_courses").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>t.invalidateQueries({queryKey:["lms-courses"]})})}function Act(){const t=Qt();return Pt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("lms_courses").update({...r,updated_at:new Date().toISOString()}).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-courses"]}),t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-courses-admin"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function t3s(){const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("lms_courses").delete().eq("id",s);if(r)throw r},onSuccess:()=>t.invalidateQueries({queryKey:["lms-courses"]})})}function s3s(){const t=Qt();return Pt({mutationFn:async s=>{const{data:r,error:n}=await G.from("lms_modules").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function r3s(){const t=Qt();return Pt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("lms_modules").update({...r,updated_at:new Date().toISOString()}).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function n3s(){const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("lms_modules").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function a3s(){const t=Qt();return Pt({mutationFn:async s=>{const{data:r,error:n}=await G.from("lms_module_resources").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function i3s(){const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("lms_module_resources").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function o3s(){const t=Qt();return Pt({mutationFn:async({courseId:s,accessRules:r})=>{const{error:n}=await G.from("lms_course_access").delete().eq("course_id",s);if(n)throw n;if(r.length>0){const a=r.map(l=>({...l,course_id:s})),{error:o}=await G.from("lms_course_access").insert(a);if(o)throw o}},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-courses"]}),t.invalidateQueries({queryKey:["lms-course"]})}})}function l3s(){return gt({queryKey:["lms-courses-agent"],queryFn:async()=>{const{data:t,error:s}=await G.from("lms_courses").select("*, modules:lms_modules(id)").eq("is_published",!0).order("sort_order");if(s)throw s;return t}})}function c3s(t){return gt({queryKey:["lms-course-agent",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("lms_courses").select("*, modules:lms_modules(*, resources:lms_module_resources(*))").eq("id",t).single();if(r)throw r;return s!=null&&s.modules&&(s.modules.sort((n,a)=>n.sort_order-a.sort_order),s.modules.forEach(n=>{n.resources&&n.resources.sort((a,o)=>a.sort_order-o.sort_order)})),s},enabled:!!t})}function Ect(t){return gt({queryKey:["lms-progress",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("lms_progress").select("*").eq("course_id",t);if(r)throw r;return s},enabled:!!t})}function d3s(){const t=Qt();return Pt({mutationFn:async({courseId:s,moduleId:r,userId:n})=>{const{data:a,error:o}=await G.from("lms_progress").upsert({user_id:n,course_id:s,module_id:r,completed:!0,completed_at:new Date().toISOString()},{onConflict:"user_id,module_id"}).select().single();if(o)throw o;return a},onSuccess:()=>t.invalidateQueries({queryKey:["lms-progress"]})})}function u3s(){const{user:t}=Us(),s=wr(),{data:r,isLoading:n}=QCs(),a=e3s(),o=Act(),l=t3s(),[i,d]=k.useState(!1),[u,p]=k.useState(""),[f,y]=k.useState(""),[_,b]=k.useState(!0),N=async()=>{if(!(!u.trim()||!t))try{const C=await a.mutateAsync({title:u.trim(),description:f.trim()||void 0,is_sequential:_,created_by:t.id});pe.success("Course created"),d(!1),p(""),y(""),b(!0),s(`/admin/lms/${C.id}`)}catch{pe.error("Failed to create course")}},w=async C=>{try{await o.mutateAsync({id:C.id,is_published:!C.is_published}),pe.success(C.is_published?"Course unpublished":"Course published")}catch{pe.error("Failed to update course")}},S=async C=>{if(confirm("Delete this course and all its modules? This cannot be undone."))try{await l.mutateAsync(C),pe.success("Course deleted")}catch{pe.error("Failed to delete")}};return e.jsxs(Ds,{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(Lh,{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(W,{variant:"outline",onClick:()=>s("/admin/lms/stats"),children:[e.jsx(so,{className:"h-4 w-4 mr-2"}),"Analytics"]}),e.jsxs(W,{onClick:()=>d(!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(C=>e.jsx(Pe,{className:"animate-pulse",children:e.jsxs(Dt,{children:[e.jsx("div",{className:"h-5 bg-muted rounded w-2/3"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2 mt-2"})]})},C))}):r!=null&&r.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:r.map(C=>{var O,V;const A=((V=(O=C.modules)==null?void 0:O[0])==null?void 0:V.count)??0,I=C.access||[],L=I.length===0?"No access set":I.some(q=>q.access_type==="all")?"All agents":`${I.length} rule(s)`;return e.jsxs(Pe,{className:"group hover:shadow-md transition-all hover:border-primary/50 cursor-pointer",onClick:()=>s(`/admin/lms/${C.id}`),children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(zt,{className:"text-base truncate",children:C.title}),C.description&&e.jsx(dr,{className:"mt-1 line-clamp-2",children:C.description})]}),e.jsx(Qe,{variant:C.is_published?"default":"secondary",className:"ml-2 shrink-0",children:C.is_published?"Published":"Draft"})]})}),e.jsxs(Oe,{className:"pt-0",children:[e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ch,{className:"h-3.5 w-3.5"}),A," module",A!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[C.is_sequential?e.jsx(Xy,{className:"h-3.5 w-3.5"}):e.jsx(yS,{className:"h-3.5 w-3.5"}),C.is_sequential?"Sequential":"Free order"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ir,{className:"h-3.5 w-3.5"}),L]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-3 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsxs(W,{size:"sm",variant:"ghost",onClick:q=>{q.stopPropagation(),w(C)},children:[C.is_published?e.jsx(pp,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(jn,{className:"h-3.5 w-3.5 mr-1"}),C.is_published?"Unpublish":"Publish"]}),e.jsx(W,{size:"sm",variant:"ghost",className:"text-destructive",onClick:q=>{q.stopPropagation(),S(C.id)},children:e.jsx(vr,{className:"h-3.5 w-3.5"})}),e.jsx("div",{className:"flex-1"}),e.jsx(Wa,{className:"h-4 w-4 text-muted-foreground"})]})]})]},C.id)})}):e.jsx(Pe,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(ch,{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(W,{onClick:()=>d(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create Course"]})]})})]}),e.jsx(fs,{open:i,onOpenChange:d,children:e.jsxs(ps,{children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Create New Course"}),e.jsx(Ir,{children:"Set up a new training course for your agents"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Course Title"}),e.jsx(De,{value:u,onChange:C=>p(C.target.value),placeholder:"e.g. LevelUp Onboarding"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Description"}),e.jsx(_r,{value:f,onChange:C=>y(C.target.value),placeholder:"What will agents learn?",rows:3})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Sequential Learning"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Agents must complete modules in order"})]}),e.jsx(Ar,{checked:_,onCheckedChange:b})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(W,{onClick:N,disabled:!u.trim()||a.isPending,children:a.isPending?"Creating...":"Create Course"})]})]})})]})}function h3s(){const{courseId:t}=io(),s=wr(),{data:r,isLoading:n}=JCs(t),a=Act(),o=s3s(),l=r3s(),i=n3s(),d=a3s(),u=i3s(),p=o3s(),{data:f}=gt({queryKey:["all-brokerages"],queryFn:async()=>{const{data:He}=await G.from("brokerages").select("id, name").order("name");return He||[]}}),[y,_]=k.useState(null),[b,N]=k.useState(!1),[w,S]=k.useState({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),[C,A]=k.useState(null),[I,L]=k.useState({title:"",resource_type:"link",url:""}),[O,V]=k.useState(new Set),[q,B]=k.useState(null),[U,te]=k.useState(0),[Y,J]=k.useState(!1),X=k.useRef(null),ce=k.useRef(null),[ie,ae]=k.useState(!1),[oe,me]=k.useState(""),[ve,he]=k.useState(""),[ge,je]=k.useState(""),[qe,Me]=k.useState(!1);if(n)return e.jsx(Ds,{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(Ds,{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(W,{variant:"outline",className:"mt-4",onClick:()=>s("/admin/lms"),children:[e.jsx(Oa,{className:"h-4 w-4 mr-2"})," Back to Courses"]})]})});const ke=r.modules||[],Re=r.access||[],Ve=Re.some(He=>He.access_type==="all"),Ne=Re.filter(He=>He.access_type==="brokerage").map(He=>He.brokerage_id),Ue=(f||[]).filter(He=>He.name.toLowerCase().includes(oe.toLowerCase())),Ie=He=>{const Je=new Set(O);Je.has(He)?Je.delete(He):Je.add(He),V(Je)},ye=async()=>{if(!q)return null;J(!0),te(0);try{const{data:He,error:Je}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:q.name}});if(Je)throw new Error(Je.message);const{videoId:ut,libraryId:mt}=He,{data:et,error:Ze}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:ut,libraryId:mt}});if(Ze)throw new Error(Ze.message);const kt=new XMLHttpRequest;return await new Promise((Ut,Nt)=>{kt.upload.onprogress=es=>{es.lengthComputable&&te(Math.round(es.loaded/es.total*100))},kt.onload=()=>kt.status>=200&&kt.status<300?Ut():Nt(new Error(`Upload failed: ${kt.status}`)),kt.onerror=()=>Nt(new Error("Upload failed")),kt.open("PUT",et.uploadUrl),kt.setRequestHeader("AccessKey",et.apiKey),kt.send(q)}),`https://iframe.mediadelivery.net/embed/${mt}/${ut}`}catch(He){return console.error("Bunny upload error:",He),pe.error("Video upload failed"),null}finally{J(!1),te(0)}},ct=async()=>{if(w.title.trim())try{let He=w.video_url.trim()||void 0;if(q){const Je=await ye();if(!Je)return;He=Je}await o.mutateAsync({course_id:r.id,title:w.title.trim(),description:w.description.trim()||void 0,video_url:He,text_content:w.text_content.trim()||void 0,duration_minutes:w.duration_minutes?parseInt(w.duration_minutes):void 0,sort_order:ke.length}),pe.success("Module added"),N(!1),S({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),B(null)}catch{pe.error("Failed to add module")}},fe=async()=>{if(y)try{let He=w.video_url.trim()||null;if(q){const Je=await ye();if(!Je)return;He=Je}await l.mutateAsync({id:y.id,title:w.title.trim(),description:w.description.trim()||null,video_url:He,text_content:w.text_content.trim()||null,duration_minutes:w.duration_minutes?parseInt(w.duration_minutes):null}),pe.success("Module updated"),_(null),B(null)}catch{pe.error("Failed to update")}},$e=async He=>{if(confirm("Delete this module?"))try{await i.mutateAsync(He),pe.success("Module deleted")}catch{pe.error("Failed to delete")}},Ye=async He=>{if(I.title.trim())try{await d.mutateAsync({module_id:He,title:I.title.trim(),resource_type:I.resource_type,url:I.url.trim()||void 0}),pe.success("Resource added"),A(null),L({title:"",resource_type:"link",url:""})}catch{pe.error("Failed to add resource")}},tt=async()=>{try{await p.mutateAsync({courseId:r.id,accessRules:[{access_type:"all"}]}),pe.success("Access updated: All brokerages / all agents")}catch{pe.error("Failed to update access")}},Te=async He=>{const Je=Re.filter(Ze=>Ze.access_type==="brokerage").map(Ze=>Ze.brokerage_id),ut=Je.includes(He);let mt;ut?mt=Je.filter(Ze=>Ze!==He):mt=[...Je,He];const et=mt.map(Ze=>({access_type:"brokerage",brokerage_id:Ze}));try{await p.mutateAsync({courseId:r.id,accessRules:et}),pe.success(ut?"Brokerage removed":"Brokerage added")}catch{pe.error("Failed to update access")}},We=async()=>{try{await p.mutateAsync({courseId:r.id,accessRules:[]}),pe.success("Access cleared")}catch{pe.error("Failed")}},Ke=async(He,Je)=>{const ut=Je==="up"?He-1:He+1;if(!(ut<0||ut>=ke.length))try{await Promise.all([l.mutateAsync({id:ke[He].id,sort_order:ut}),l.mutateAsync({id:ke[ut].id,sort_order:He})])}catch{pe.error("Failed to reorder")}},ot=async()=>{try{await a.mutateAsync({id:r.id,title:ve,description:ge||null}),pe.success("Course updated"),Me(!1)}catch{pe.error("Failed to update")}};return e.jsxs(Ds,{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(W,{variant:"ghost",size:"icon",onClick:()=>s("/admin/lms"),children:e.jsx(Oa,{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(Qe,{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(Xy,{className:"h-3.5 w-3.5"}):e.jsx(yS,{className:"h-3.5 w-3.5"}),r.is_sequential?"Sequential":"Free order"]}),e.jsxs("span",{children:[ke.length," module",ke.length!==1?"s":""]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>{he(r.title),je(r.description||""),Me(!0)},children:[e.jsx(ga,{className:"h-3.5 w-3.5 mr-1"})," Edit"]}),e.jsxs(W,{variant:r.is_published?"secondary":"default",size:"sm",onClick:()=>a.mutateAsync({id:r.id,is_published:!r.is_published}).then(()=>pe.success(r.is_published?"Unpublished":"Published")),children:[r.is_published?e.jsx(pp,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(jn,{className:"h-3.5 w-3.5 mr-1"}),r.is_published?"Unpublish":"Publish"]})]})]}),e.jsxs(ta,{defaultValue:"modules",className:"w-full",children:[e.jsxs(Jn,{children:[e.jsx(cs,{value:"modules",children:"Modules"}),e.jsx(cs,{value:"access",children:"Access & Permissions"}),e.jsx(cs,{value:"settings",children:"Settings"})]}),e.jsxs(Ss,{value:"modules",className:"mt-6 space-y-4",children:[ke.map((He,Je)=>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:()=>Ie(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:ut=>{ut.stopPropagation(),Ke(Je,"up")},disabled:Je===0,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(af,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:ut=>{ut.stopPropagation(),Ke(Je,"down")},disabled:Je===ke.length-1,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(Bi,{className:"h-3.5 w-3.5"})})]})}),e.jsx(Qe,{variant:"outline",className:"shrink-0 font-mono text-xs",children:Je+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(yn,{className:"h-3 w-3"})," Video"]}),He.text_content&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(vn,{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(Do,{className:"h-3 w-3"})," ",He.resources.length," resource(s)"]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(W,{size:"sm",variant:"ghost",onClick:ut=>{var mt;ut.stopPropagation(),_(He),S({title:He.title,description:He.description||"",video_url:He.video_url||"",text_content:He.text_content||"",duration_minutes:((mt=He.duration_minutes)==null?void 0:mt.toString())||""})},children:e.jsx(ga,{className:"h-3.5 w-3.5"})}),e.jsx(W,{size:"sm",variant:"ghost",className:"text-destructive",onClick:ut=>{ut.stopPropagation(),$e(He.id)},children:e.jsx(vr,{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(W,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>{A(He.id),L({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(ut=>e.jsxs("div",{className:"flex items-center gap-2 text-sm bg-background rounded p-2 border",children:[e.jsx(Qe,{variant:"outline",className:"text-[10px]",children:ut.resource_type}),e.jsx("span",{className:"flex-1 truncate",children:ut.title}),ut.url&&e.jsx("a",{href:ut.url,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline text-xs",children:"Open"}),e.jsx(W,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-destructive",onClick:()=>u.mutateAsync(ut.id),children:e.jsx(kr,{className:"h-3 w-3"})})]},ut.id))}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"No resources yet"})]})]})]},He.id)),e.jsxs(W,{variant:"outline",className:"w-full border-dashed",onClick:()=>{N(!0),S({title:"",description:"",video_url:"",text_content:"",duration_minutes:""})},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"})," Add Module"]})]}),e.jsx(Ss,{value:"access",className:"mt-6 space-y-4",children:e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Who can access this course?"})}),e.jsxs(Oe,{className:"space-y-5",children:[e.jsxs("div",{className:Ot("flex items-center gap-3 p-4 rounded-xl border-2 cursor-pointer transition-all",Ve?"border-primary bg-primary/5":"border-muted hover:border-muted-foreground/30"),onClick:tt,children:[e.jsx("div",{className:Ot("h-10 w-10 rounded-full flex items-center justify-center shrink-0",Ve?"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(Ar,{checked:Ve,onCheckedChange:tt})]}),!Ve&&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:Ne.length===0?"No brokerages selected — agents won't see this course":`${Ne.length} brokerage${Ne.length!==1?"s":""} selected`})]}),Ne.length>0&&e.jsx(W,{size:"sm",variant:"ghost",className:"text-xs text-muted-foreground",onClick:We,children:"Clear all"})]}),e.jsx(De,{placeholder:"Search brokerages...",value:oe,onChange:He=>me(He.target.value),className:"h-9"}),e.jsx("div",{className:"border rounded-lg divide-y max-h-[360px] overflow-auto",children:Ue.length===0?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No brokerages found"}):Ue.map(He=>{const Je=Ne.includes(He.id);return e.jsxs("div",{className:Ot("flex items-center gap-3 px-3 py-2.5 cursor-pointer transition-colors",Je?"bg-primary/5":"hover:bg-muted/50"),onClick:()=>Te(He.id),children:[e.jsx("div",{className:Ot("h-5 w-5 rounded border-2 flex items-center justify-center shrink-0 transition-colors",Je?"bg-primary border-primary":"border-muted-foreground/30"),children:Je&&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(pa,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:He.name}),Je&&e.jsx(Qe,{variant:"secondary",className:"text-[10px] shrink-0",children:"Active"})]},He.id)})})]})]})]})}),e.jsxs(Ss,{value:"settings",className:"mt-6 space-y-4",children:[e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Course Thumbnail"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-start gap-6",children:[r.thumbnail_url?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:r.thumbnail_url,alt:"Course thumbnail",className:"w-48 h-28 object-cover rounded-lg border"}),e.jsx("button",{onClick:()=>a.mutateAsync({id:r.id,thumbnail_url:null}).then(()=>pe.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(kr,{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(Xv,{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 ut;const Je=(ut=He.target.files)==null?void 0:ut[0];if(!(!Je||!r)){ae(!0);try{const mt=Je.name.split(".").pop(),et=`${r.id}/thumbnail.${mt}`,{error:Ze}=await G.storage.from("lms-thumbnails").upload(et,Je,{upsert:!0});if(Ze)throw Ze;const{data:kt}=G.storage.from("lms-thumbnails").getPublicUrl(et),Ut=`${kt.publicUrl}?t=${Date.now()}`;await a.mutateAsync({id:r.id,thumbnail_url:Ut}),pe.success("Thumbnail uploaded")}catch{pe.error("Failed to upload thumbnail")}finally{ae(!1),ce.current&&(ce.current.value="")}}}}),e.jsxs(W,{variant:"outline",size:"sm",disabled:ie,onClick:()=>{var He;return(He=ce.current)==null?void 0:He.click()},children:[ie?e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Ra,{className:"h-4 w-4 mr-2"}),ie?"Uploading...":"Upload Thumbnail"]})]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Course Settings"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Sequential Learning"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Agents must complete modules in order before advancing"})]}),e.jsx(Ar,{checked:r.is_sequential,onCheckedChange:He=>a.mutateAsync({id:r.id,is_sequential:He}).then(()=>pe.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(Ar,{checked:r.is_published,onCheckedChange:He=>a.mutateAsync({id:r.id,is_published:He}).then(()=>pe.success("Updated"))})]})]})]})]})]})]}),e.jsx(fs,{open:b||!!y,onOpenChange:He=>{He||(N(!1),_(null))},children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(ks,{children:[e.jsx(_s,{children:y?"Edit Module":"Add Module"}),e.jsx(Ir,{children:"Configure the module content"})]}),e.jsxs("div",{className:"space-y-4 max-h-[60vh] overflow-auto",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Title"}),e.jsx(De,{value:w.title,onChange:He=>S(Je=>({...Je,title:He.target.value})),placeholder:"Module title"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Description"}),e.jsx(_r,{value:w.description,onChange:He=>S(Je=>({...Je,description:He.target.value})),placeholder:"Brief description",rows:2})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Video"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:Ot("border-2 border-dashed rounded-lg p-4 text-center cursor-pointer transition-colors hover:border-primary/50",q?"border-primary bg-primary/5":"border-muted-foreground/25"),onClick:()=>{var He;return(He=X.current)==null?void 0:He.click()},children:[e.jsx("input",{ref:X,type:"file",accept:"video/*",className:"hidden",onChange:He=>{var ut;const Je=(ut=He.target.files)==null?void 0:ut[0];Je&&(B(Je),S(mt=>({...mt,video_url:""})))}}),q?e.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm",children:[e.jsx(yn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-primary",children:q.name}),e.jsx(W,{type:"button",size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:He=>{He.stopPropagation(),B(null)},children:e.jsx(kr,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"flex flex-col items-center gap-1 text-muted-foreground",children:[e.jsx(Ra,{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(us,{className:"h-3.5 w-3.5 animate-spin"}),e.jsxs("span",{children:["Uploading to Bunny.net... ",U,"%"]})]}),e.jsx(xi,{value:U,className:"h-1.5"})]}),!q&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("div",{className:"flex-1 h-px bg-border"}),e.jsx("span",{children:"or paste a URL"}),e.jsx("div",{className:"flex-1 h-px bg-border"})]}),e.jsx(De,{value:w.video_url,onChange:He=>S(Je=>({...Je,video_url:He.target.value})),placeholder:"YouTube, Vimeo, or Bunny.net URL"})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Text Content"}),e.jsx(_r,{value:w.text_content,onChange:He=>S(Je=>({...Je,text_content:He.target.value})),placeholder:"Additional text content, instructions, notes...",rows:4})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Duration (minutes)"}),e.jsx(De,{type:"number",value:w.duration_minutes,onChange:He=>S(Je=>({...Je,duration_minutes:He.target.value})),placeholder:"e.g. 15"})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>{N(!1),_(null),B(null)},children:"Cancel"}),e.jsxs(W,{onClick:y?fe:ct,disabled:!w.title.trim()||Y,children:[Y?e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(bc,{className:"h-4 w-4 mr-2"}),Y?"Uploading...":y?"Save Changes":"Add Module"]})]})]})}),e.jsx(fs,{open:!!C,onOpenChange:He=>{He||A(null)},children:e.jsxs(ps,{children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Add Resource"}),e.jsx(Ir,{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(xe,{children:"Title"}),e.jsx(De,{value:I.title,onChange:He=>L(Je=>({...Je,title:He.target.value})),placeholder:"Resource title"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Type"}),e.jsxs($s,{value:I.resource_type,onValueChange:He=>L(Je=>({...Je,resource_type:He})),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"link",children:"Link"}),e.jsx(vt,{value:"pdf",children:"PDF"}),e.jsx(vt,{value:"template",children:"Template"}),e.jsx(vt,{value:"worksheet",children:"Worksheet"})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"URL"}),e.jsx(De,{value:I.url,onChange:He=>L(Je=>({...Je,url:He.target.value})),placeholder:"https://..."})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>A(null),children:"Cancel"}),e.jsx(W,{onClick:()=>C&&Ye(C),disabled:!I.title.trim(),children:"Add Resource"})]})]})}),e.jsx(fs,{open:qe,onOpenChange:Me,children:e.jsxs(ps,{children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Edit Course"}),e.jsx(Ir,{children:"Update the course title and description"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Title"}),e.jsx(De,{value:ve,onChange:He=>he(He.target.value)})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Description"}),e.jsx(_r,{value:ge,onChange:He=>je(He.target.value),rows:3})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>Me(!1),children:"Cancel"}),e.jsx(W,{onClick:ot,disabled:!ve.trim(),children:"Save"})]})]})})]})}function m3s(){return gt({queryKey:["lms-stats-overview"],queryFn:async()=>{const{data:t,error:s}=await G.rpc("get_lms_stats");if(s)throw s;return t}})}function p3s(){return gt({queryKey:["lms-stats-courses"],queryFn:async()=>{const{data:t,error:s}=await G.rpc("get_lms_course_stats");if(s)throw s;return t||[]}})}function f3s(t){return gt({queryKey:["lms-stats-agents",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.rpc("get_lms_agent_progress",{p_course_id:t});if(r)throw r;return s||[]},enabled:!!t})}function x3s(){const t=wr(),{data:s,isLoading:r}=m3s(),{data:n,isLoading:a}=p3s(),[o,l]=k.useState(null),{data:i,isLoading:d}=f3s(o),[u,p]=k.useState(""),f=n==null?void 0:n.find(b=>b.course_id===o),y=i==null?void 0:i.filter(b=>{var N,w;return!u||((N=b.agent_name)==null?void 0:N.toLowerCase().includes(u.toLowerCase()))||((w=b.email)==null?void 0:w.toLowerCase().includes(u.toLowerCase()))}),_=[{label:"Total Courses",value:(s==null?void 0:s.total_courses)??0,icon:ch,color:"text-primary"},{label:"Published",value:(s==null?void 0:s.published_courses)??0,icon:$n,color:"text-emerald-500"},{label:"Enrolled Agents",value:(s==null?void 0:s.total_enrollments)??0,icon:ir,color:"text-blue-500"},{label:"Modules Completed",value:(s==null?void 0:s.total_completions)??0,icon:Fi,color:"text-amber-500"},{label:"Active (30d)",value:(s==null?void 0:s.active_learners)??0,icon:Qo,color:"text-violet-500"},{label:"Total Modules",value:(s==null?void 0:s.total_modules)??0,icon:so,color:"text-rose-500"}];return e.jsx(Ds,{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(W,{variant:"ghost",size:"icon",onClick:()=>t("/admin/lms"),children:e.jsx(Oa,{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(Lh,{className:"h-7 w-7 text-primary"}),"LevelUp U — Analytics"]}),e.jsx("p",{className:"text-muted-foreground text-sm mt-0.5",children:"Track enrollment, progress, and completion across all courses"})]})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-6 gap-3",children:_.map(b=>e.jsx(Pe,{className:Ot("transition-all",r&&"animate-pulse"),children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(b.icon,{className:Ot("h-4 w-4",b.color)}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:b.label})]}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:r?"—":b.value})]})},b.label))}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-5 gap-6",children:[e.jsxs("div",{className:"xl:col-span-2 space-y-3",children:[e.jsxs("h2",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(so,{className:"h-5 w-5 text-primary"}),"Course Breakdown"]}),a?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(b=>e.jsx(Pe,{className:"animate-pulse",children:e.jsx(Oe,{className:"p-4",children:e.jsx("div",{className:"h-16 bg-muted rounded"})})},b))}):n!=null&&n.length?e.jsx("div",{className:"space-y-2",children:n.map(b=>{const N=o===b.course_id;return e.jsx(Pe,{className:Ot("cursor-pointer transition-all hover:shadow-md",N?"border-primary ring-1 ring-primary/30 shadow-md":"hover:border-primary/40"),onClick:()=>l(N?null:b.course_id),children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-semibold text-sm text-foreground truncate",children:b.course_title}),e.jsx(Qe,{variant:b.is_published?"default":"secondary",className:"shrink-0 text-[10px] px-1.5 py-0",children:b.is_published?"Live":"Draft"})]})}),e.jsx(xa,{className:Ot("h-4 w-4 text-muted-foreground transition-transform shrink-0 ml-2",N&&"rotate-90")})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-foreground",children:b.enrolled_agents}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Enrolled"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-foreground",children:b.total_completions}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Completed"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-foreground",children:b.total_modules}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Modules"})]})]}),e.jsxs("div",{className:"mt-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[e.jsx("span",{className:"text-muted-foreground",children:"Avg. Completion"}),e.jsxs("span",{className:"font-semibold text-foreground",children:[b.avg_completion_pct,"%"]})]}),e.jsx(xi,{value:b.avg_completion_pct,className:"h-2"})]})]})},b.course_id)})}):e.jsx(Pe,{className:"border-dashed",children:e.jsx(Oe,{className:"py-10 text-center",children:e.jsx("p",{className:"text-muted-foreground text-sm",children:"No courses created yet"})})})]}),e.jsxs("div",{className:"xl:col-span-3 space-y-3",children:[e.jsxs("h2",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(n0,{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(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{value:u,onChange:b=>p(b.target.value),placeholder:"Search agents...",className:"pl-9"})]}),d?e.jsx("div",{className:"space-y-2",children:[1,2,3,4].map(b=>e.jsx(Pe,{className:"animate-pulse",children:e.jsx(Oe,{className:"p-4",children:e.jsx("div",{className:"h-12 bg-muted rounded"})})},b))}):y!=null&&y.length?e.jsx("div",{className:"space-y-2 max-h-[600px] overflow-y-auto pr-1",children:y.map((b,N)=>{const w=b.completion_pct>=100;return e.jsx(Pe,{className:Ot("transition-all",w&&"border-emerald-200 bg-emerald-50/30 dark:border-emerald-900/40 dark:bg-emerald-950/10"),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:Ot("flex items-center justify-center w-7 h-7 rounded-full text-xs font-bold shrink-0",N===0?"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400":N===1?"bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-400":N===2?"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400":"bg-muted text-muted-foreground"),children:N+1}),e.jsxs(Nn,{className:"h-9 w-9 shrink-0",children:[e.jsx(Ma,{src:b.avatar_url||void 0}),e.jsx(kn,{className:"text-xs bg-primary/10 text-primary",children:(b.agent_name||b.email||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:b.agent_name||b.email}),w&&e.jsxs(Qe,{variant:"default",className:"text-[10px] px-1.5 py-0 bg-emerald-500 hover:bg-emerald-600 shrink-0",children:[e.jsx($n,{className:"h-3 w-3 mr-0.5"})," Complete"]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-muted-foreground mt-0.5",children:[e.jsxs("span",{children:[b.modules_completed,"/",b.total_modules," modules"]}),b.last_activity&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nn,{className:"h-3 w-3"}),vs(new Date(b.last_activity),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"text-right shrink-0 w-20",children:[e.jsxs("p",{className:Ot("text-sm font-bold",w?"text-emerald-600 dark:text-emerald-400":"text-foreground"),children:[b.completion_pct,"%"]}),e.jsx(xi,{value:b.completion_pct,className:"h-1.5 mt-1"})]})]})})},b.user_id)})}):e.jsx(Pe,{className:"border-dashed",children:e.jsx(Oe,{className:"py-10 text-center",children:e.jsx("p",{className:"text-muted-foreground text-sm",children:u?"No agents match your search":"No agents have started this course yet"})})})]}):e.jsx(Pe,{className:"border-dashed",children:e.jsxs(Oe,{className:"py-16 text-center",children:[e.jsx(ir,{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 g3s(){const{user:t}=Us(),s=wr(),{data:r,isLoading:n}=l3s();return e.jsx(Ds,{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(Lh,{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(Oe,{className:"p-6",children:[e.jsx("div",{className:"h-5 bg-muted rounded w-2/3"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2 mt-3"})]})},a))}):r!=null&&r.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:r.map(a=>e.jsx(y3s,{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(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(ch,{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 y3s({course:t,userId:s,onClick:r}){var i;const n=((i=t.modules)==null?void 0:i.length)??0,{data:a}=Ect(t.id),o=(a==null?void 0:a.filter(d=>d.completed).length)??0,l=n>0?Math.round(o/n*100):0;return e.jsxs(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(Lh,{className:"h-10 w-10 text-primary/40"})}),e.jsxs(Oe,{className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground group-hover:text-primary transition-colors line-clamp-1",children:t.title}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:t.description})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ch,{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(Xy,{className:"h-3.5 w-3.5"}):e.jsx(yS,{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(xi,{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(xa,{className:"h-3.5 w-3.5"})]})})]})]})}function v3s(){const{courseId:t}=io(),s=wr(),{user:r}=Us(),{data:n,isLoading:a}=c3s(t),{data:o}=Ect(t),l=d3s(),[i,d]=k.useState(null),u=(n==null?void 0:n.modules)||[],p=new Set((o==null?void 0:o.filter(C=>C.completed).map(C=>C.module_id))||[]),f=p.size,y=u.length>0?Math.round(f/u.length*100):0;k.useEffect(()=>{if(u.length>0&&!i){const C=u.find(A=>!p.has(A.id));d((C==null?void 0:C.id)||u[0].id)}},[u,i,p]);const _=u.find(C=>C.id===i),b=u.findIndex(C=>C.id===i),N=(C,A)=>{if(!(n!=null&&n.is_sequential)||A===0)return!1;for(let I=0;I{if(!(!_||!r||!t))try{await l.mutateAsync({courseId:t,moduleId:_.id,userId:r.id}),pe.success("Module completed! 🎉"),b{const A=C.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/);if(A)return`https://www.youtube.com/embed/${A[1]}`;const I=C.match(/vimeo\.com\/(\d+)/);if(I)return`https://player.vimeo.com/video/${I[1]}`;const L=C.match(/(?:iframe\.mediadelivery\.net|video\.bunnycdn\.com)\/(?:play|embed)\/(\d+)\/([a-f0-9-]+)/);return L?`https://iframe.mediadelivery.net/embed/${L[1]}/${L[2]}?responsive=true`:C};return a?e.jsx(Ds,{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(Ds,{title:n.title,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>s("/levelup-u"),children:e.jsx(Oa,{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:[y,"%"]})]})]}),e.jsx("div",{className:"w-32",children:e.jsx(xi,{value:y,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(Oe,{className:"p-0",children:[e.jsx("div",{className:"p-3 border-b",children:e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Modules"})}),e.jsx(Ja,{className:"max-h-[calc(100vh-280px)]",children:e.jsx("div",{className:"p-1",children:u.map((C,A)=>{const I=N(C,A),L=p.has(C.id),O=C.id===i;return e.jsxs("button",{disabled:I,onClick:()=>!I&&d(C.id),className:Ot("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(ad,{className:"h-4 w-4 text-muted-foreground"}):L?e.jsx($n,{className:"h-4 w-4 text-green-500"}):e.jsx(sd,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:Ot("font-medium truncate",O&&"text-primary"),children:[A+1,". ",C.title]}),C.duration_minutes&&e.jsxs("span",{className:"text-[11px] text-muted-foreground flex items-center gap-0.5 mt-0.5",children:[e.jsx(nn,{className:"h-3 w-3"})," ",C.duration_minutes," min"]})]})]},C.id)})})})]})}),e.jsx("div",{className:"space-y-4",children:_?e.jsxs(e.Fragment,{children:[_.video_url&&e.jsx(Pe,{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-video bg-black",children:e.jsx("iframe",{src:S(_.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(Oe,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:_.title}),_.description&&e.jsx("p",{className:"text-muted-foreground mt-1",children:_.description})]}),p.has(_.id)?e.jsxs(Qe,{className:"bg-green-500/15 text-green-600 border-green-500/30 shrink-0",children:[e.jsx($n,{className:"h-3.5 w-3.5 mr-1"})," Completed"]}):e.jsxs(W,{size:"sm",onClick:w,disabled:l.isPending,children:[e.jsx($n,{className:"h-4 w-4 mr-1"}),"Mark Complete"]})]}),_.text_content&&e.jsx("div",{className:"prose prose-sm max-w-none text-foreground border-t pt-4 whitespace-pre-wrap",children:_.text_content}),_.resources&&_.resources.length>0&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Resources"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:_.resources.map(C=>e.jsxs("a",{href:C.url||C.file_url||"#",target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 p-3 rounded-lg border hover:bg-muted/50 transition-colors text-sm",children:[C.resource_type==="pdf"?e.jsx(vn,{className:"h-4 w-4 text-red-500 shrink-0"}):C.resource_type==="template"?e.jsx(Lh,{className:"h-4 w-4 text-purple-500 shrink-0"}):e.jsx(Do,{className:"h-4 w-4 text-blue-500 shrink-0"}),e.jsx("span",{className:"flex-1 truncate",children:C.title}),e.jsx(Yr,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"})]},C.id))})]}),e.jsxs("div",{className:"flex items-center justify-between border-t pt-4",children:[e.jsxs(W,{variant:"outline",size:"sm",disabled:b===0,onClick:()=>b>0&&d(u[b-1].id),children:[e.jsx(Oa,{className:"h-3.5 w-3.5 mr-1"})," Previous"]}),bd(u[b+1].id),children:["Next ",e.jsx(xa,{className:"h-3.5 w-3.5 ml-1"})]}):y===100&&e.jsx(Qe,{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(Oe,{className:"flex items-center justify-center py-16 text-muted-foreground",children:"Select a module to begin"})})})]})]})}):e.jsx(Ds,{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(W,{variant:"outline",className:"mt-4",onClick:()=>s("/levelup-u"),children:[e.jsx(Oa,{className:"h-4 w-4 mr-2"})," Back"]})]})})}function _3s({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(hr.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(hr.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(hr.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(hr.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(hr.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(Wa,{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(hr.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 bf({children:t,className:s="",delay:r=0,direction:n="up"}){const a=k.useRef(null),o=REt(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(hr.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 b3s({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(bf,{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(bf,{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 w3s({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(bf,{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(ir,{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(bf,{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(kr,{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 j3s({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(bf,{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(bf,{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(pS,{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 N3s({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(bf,{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(bf,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"First Name *"}),e.jsx(De,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"Last Name"}),e.jsx(De,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"Email *"}),e.jsx(De,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"Phone"}),e.jsx(De,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"Current Brokerage"}),e.jsx(De,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"License #"}),e.jsx(De,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"Years Experience"}),e.jsx(De,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"Annual Production"}),e.jsx(De,{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(xe,{className:"text-gray-700 text-sm font-medium",children:"Why are you interested?"}),e.jsx(_r,{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(W,{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(Wa,{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(zu,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Your information is confidential and will not be shared."})]})]})})]})]})}function k3s({form:t,setForm:s,onSubmit:r,isPending:n,primaryColor:a,accentColor:o,showConfidentialBadges:l=!0}){const[i,d]=k.useState(1),[u,p]=k.useState(""),f=3,y=!!t.first_name&&!!t.email,_=b=>{p(b),s(N=>({...N,why_interested:b})),setTimeout(()=>d(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(bf,{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(ad,{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(bf,{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(b=>e.jsx("div",{className:"h-1 flex-1 rounded-full transition-colors duration-500",style:{backgroundColor:b<=i?a:"#e5e7eb"}},b)),e.jsxs("span",{className:"text-xs text-gray-400 ml-2",children:[i,"/",f]})]}),e.jsxs(DNe,{mode:"wait",children:[i===1&&e.jsxs(hr.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(b=>e.jsxs("button",{type:"button",onClick:()=>_(b.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:b.icon}),e.jsx("span",{className:"font-medium text-gray-700 group-hover:text-gray-900 flex-1",children:b.label}),e.jsx(Wa,{className:"h-4 w-4 text-gray-300 group-hover:text-gray-500 group-hover:translate-x-1 transition-all"})]},b.val))]},"step1"),i===2&&e.jsxs(hr.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(xe,{className:"text-gray-700 text-sm font-medium",children:"First Name *"}),e.jsx(De,{required:!0,value:t.first_name,onChange:b=>s(N=>({...N,first_name:b.target.value})),className:"h-11",placeholder:"John"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-gray-700 text-sm font-medium",children:"Last Name"}),e.jsx(De,{value:t.last_name,onChange:b=>s(N=>({...N,last_name:b.target.value})),className:"h-11",placeholder:"Smith"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-gray-700 text-sm font-medium",children:"Email *"}),e.jsx(De,{type:"email",required:!0,value:t.email,onChange:b=>s(N=>({...N,email:b.target.value})),className:"h-11",placeholder:"john@email.com"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-gray-700 text-sm font-medium",children:"Phone (preferred)"}),e.jsx(De,{value:t.phone,onChange:b=>s(N=>({...N,phone:b.target.value})),className:"h-11",placeholder:"(555) 123-4567"})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(W,{type:"button",variant:"ghost",onClick:()=>d(1),className:"h-11",children:[e.jsx(Oa,{className:"h-4 w-4 mr-1"})," Back"]}),e.jsxs(W,{type:"button",disabled:!y,onClick:()=>d(3),className:"flex-1 h-11 text-white font-semibold",style:{background:`linear-gradient(135deg, ${a}, ${o})`},children:["Continue ",e.jsx(Wa,{className:"h-4 w-4 ml-1"})]})]})]},"step2"),i===3&&e.jsxs(hr.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(xe,{className:"text-gray-700 text-sm font-medium",children:"Current Brokerage"}),e.jsx(De,{value:t.current_brokerage,onChange:b=>s(N=>({...N,current_brokerage:b.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(xe,{className:"text-gray-700 text-sm font-medium",children:"Years Experience"}),e.jsx(De,{type:"number",min:"0",value:t.experience_years,onChange:b=>s(N=>({...N,experience_years:b.target.value})),className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-gray-700 text-sm font-medium",children:"Annual Production"}),e.jsx(De,{value:t.annual_production,onChange:b=>s(N=>({...N,annual_production:b.target.value})),className:"h-11",placeholder:"e.g. $5M"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-gray-700 text-sm font-medium",children:"Anything else?"}),e.jsx(_r,{value:t.why_interested,onChange:b=>s(N=>({...N,why_interested:b.target.value})),rows:2,className:"resize-none",placeholder:"Optional message..."})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(W,{type:"button",variant:"ghost",onClick:()=>d(2),className:"h-11",children:[e.jsx(Oa,{className:"h-4 w-4 mr-1"})," Back"]}),e.jsx(W,{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(Zn,{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(zu,{className:"h-3 w-3"})," Confidential"]}),e.jsxs("div",{className:"flex items-center gap-1 justify-center",children:[e.jsx(wi,{className:"h-3 w-3"})," Text first"]}),e.jsxs("div",{className:"flex items-center gap-1 justify-center",children:[e.jsx(In,{className:"h-3 w-3"})," No spam"]})]})]})})]})]})}function S3s({config:t,primaryColor:s,accentColor:r,brokerageId:n,brokerageName:a}){const{toast:o}=ja(),[l,i]=k.useState("250000"),[d,u]=k.useState("70"),[p,f]=k.useState("150"),[y,_]=k.useState(""),[b,N]=k.useState(!1),[w,S]=k.useState(!1),C=t.commission_split_pct??80,A=t.cap_amount??16e3,I=t.monthly_fee??99,L=t.transaction_fee??0,O=k.useMemo(()=>{const B=parseFloat(l)||0,U=parseFloat(d)||0,te=parseFloat(p)||0,Y=B*(U/100)-te*12,J=1-C/100,X=B*J,ce=Math.min(X,A),ie=B-ce-I*12-L,ae=ie-Y;return{currentNet:Y,newNet:ie,diff:ae}},[l,d,p,C,A,I,L]),V=B=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(B),q=async B=>{if(B.preventDefault(),!!y){S(!0);try{const{error:U}=await G.from("recruit_lead_magnet_downloads").insert({brokerage_id:n,email:y,source:"calculator"});if(U)throw U;N(!0),o({title:"Sent!",description:"Check your email for the full breakdown."})}catch(U){o({title:"Error",description:U.message,variant:"destructive"})}finally{S(!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(bf,{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(ad,{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(bf,{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(_M,{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(xe,{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(De,{type:"number",value:l,onChange:B=>i(B.target.value),className:"pl-7 h-11 text-base",placeholder:"250,000"})]})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-gray-600 text-sm",children:"Your Current Commission Split (%)"}),e.jsx(De,{type:"number",value:d,onChange:B=>u(B.target.value),className:"mt-1.5 h-11 text-base",placeholder:"70"})]}),e.jsxs("div",{children:[e.jsx(xe,{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(De,{type:"number",value:p,onChange:B=>f(B.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(Qo,{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:V(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:V(O.newNet)})]})]}),e.jsxs(hr.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?"+":"",V(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&&!b&&e.jsxs("form",{onSubmit:q,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(De,{type:"email",required:!0,value:y,onChange:B=>_(B.target.value),placeholder:"you@email.com",className:"bg-white/95 border-0 text-gray-900 h-10 text-sm"}),e.jsx(W,{type:"submit",disabled:w,className:"h-10 bg-white text-gray-900 hover:bg-white/90 text-sm font-semibold",children:"Send"})]})]}),b&&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(Zn,{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 C3s({config:t,primaryColor:s,accentColor:r,brokerageId:n}){const{toast:a}=ja(),[o,l]=k.useState(""),[i,d]=k.useState(""),[u,p]=k.useState(!1),[f,y]=k.useState(!1),_=async b=>{b.preventDefault(),y(!0);try{const{error:N}=await G.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(N)throw N;p(!0),t.pdf_url&&window.open(t.pdf_url,"_blank","noopener,noreferrer")}catch(N){a({title:"Error",description:N.message,variant:"destructive"})}finally{y(!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(bf,{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(J4,{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(ad,{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(Zn,{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:_,className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsx(De,{value:i,onChange:b=>d(b.target.value),placeholder:"First name (optional)",className:"h-11"}),e.jsx(De,{type:"email",required:!0,value:o,onChange:b=>l(b.target.value),placeholder:"your@email.com",className:"h-11"})]}),e.jsxs(W,{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(J4,{className:"h-4 w-4 mr-2"}),f?"Sending...":t.button_text||"Email Me the PDF"]})]})]})]})})})})})}function M3s(){const{slug:t}=io(),{toast:s}=ja(),[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 B=()=>{['[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(X=>X.style.display="none"))};B();const U=[setTimeout(B,500),setTimeout(B,1500),setTimeout(B,3e3)],te=new MutationObserver(B);return te.observe(document.body,{childList:!0,subtree:!0}),()=>{document.body.classList.remove("recruit-landing-page"),U.forEach(clearTimeout),te.disconnect()}},[]);const{data:l,isLoading:i,error:d}=gt({queryKey:["recruit-form-brokerage",t],queryFn:async()=>{const{data:B,error:U}=await G.from("brokerages").select("id, name, recruit_form_enabled").eq("recruit_form_slug",t).single();if(U)throw U;return B},enabled:!!t}),{data:u}=gt({queryKey:["recruit-landing-public",l==null?void 0:l.id],queryFn:async()=>{const{data:B,error:U}=await G.from("recruit_landing_page_settings").select("*").eq("brokerage_id",l.id).single();if(U&&U.code!=="PGRST116")throw U;return B},enabled:!!(l!=null&&l.id)}),p=Pt({mutationFn:async()=>{const B={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:U}=await G.from("recruit_interest_submissions").insert(B);if(U)throw U;G.functions.invoke("recruit-lead-notify",{body:{lead:B,brokerage_id:l.id}}).catch(te=>console.error("Lead notification error:",te))},onSuccess:()=>n(!0),onError:B=>s({title:"Error",description:B.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(d||!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(pa,{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,y=(f==null?void 0:f.primary_color)||"#406E71",_=(f==null?void 0:f.accent_color)||"#2a4c64",b=(f==null?void 0:f.benefits)||[],N=(f==null?void 0:f.testimonials)||[],w=(f==null?void 0:f.gallery_images)||[],S=(f==null?void 0:f.hero_headline)||`Join ${l.name}`,C=(f==null?void 0:f.hero_subtext)||"Take your real estate career to the next level with a brokerage that invests in your growth.",A=(f==null?void 0:f.calculator_enabled)===!0,I=(f==null?void 0:f.calculator_config)||{},L=(f==null?void 0:f.lead_magnet_enabled)===!0,O=(f==null?void 0:f.lead_magnet_config)||{},V=(f==null?void 0:f.form_style)||"classic",q=(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(hr.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, ${y}, ${_})`},children:e.jsx(Zn,{className:"h-10 w-10 text-white"})}),e.jsx("h2",{className:"text-3xl font-bold mb-3 tracking-tight",style:{color:_},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:_},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:y}})]})}):e.jsxs("div",{className:"min-h-screen bg-white",style:{"--recruit-primary":y,"--recruit-accent":_},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:_},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, ${y}, ${_})`},children:["Apply Now ",e.jsx(Wa,{className:"h-3.5 w-3.5"})]})]})}),e.jsx(_3s,{headline:S,subtext:C,primaryColor:y,accentColor:_,heroImageUrl:f==null?void 0:f.hero_image_url,logoUrl:f==null?void 0:f.logo_url,brokerageName:l.name}),e.jsx(b3s,{benefits:b,accentColor:_,primaryColor:y}),e.jsx(w3s,{images:w,primaryColor:y,accentColor:_}),e.jsx(j3s,{testimonials:N,primaryColor:y,accentColor:_}),A&&e.jsx(S3s,{config:I,primaryColor:y,accentColor:_,brokerageId:l.id,brokerageName:l.name}),L&&e.jsx(C3s,{config:O,primaryColor:y,accentColor:_,brokerageId:l.id}),V==="multi_step"?e.jsx(k3s,{form:a,setForm:o,onSubmit:()=>p.mutate(),isPending:p.isPending,primaryColor:y,accentColor:_,showConfidentialBadges:q}):e.jsx(N3s,{form:a,setForm:o,onSubmit:()=>p.mutate(),isPending:p.isPending,primaryColor:y,accentColor:_}),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 T3s(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 A3s(){var y,_,b,N;const{shareToken:t}=io(),s=k.useRef(!1),{data:r,isLoading:n,error:a}=gt({queryKey:["public-recruit-video",t],queryFn:async()=>{var L;if(!t)throw new Error("No token");const{data:w,error:S}=await G.from("recruit_videos").select(` *, prospect:recruit_prospects(first_name, last_name), video:agent_videos(id, title, playback_url, thumbnail_url, duration_seconds, owner_user_id) `).eq("share_token",t).single();if(S)throw S;const{data:C}=await G.from("profiles").select("name, avatar_url, title").eq("id",(L=w.video)==null?void 0:L.owner_user_id).single(),{data:A}=await G.from("brokerages").select("name").eq("id",w.brokerage_id).single(),{data:I}=await G.from("recruit_landing_page_settings").select("logo_url, primary_color, accent_color, hero_headline").eq("brokerage_id",w.brokerage_id).maybeSingle();return{rv:w,profile:C,brokerage:A,settings:I}},enabled:!!t});if(k.useEffect(()=>{var w;!((w=r==null?void 0:r.rv)!=null&&w.id)||s.current||(s.current=!0,G.rpc("log_recruit_video_view",{p_recruit_video_id:r.rv.id,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null}).then(()=>{}))},[(y=r==null?void 0:r.rv)==null?void 0:y.id]),n)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})});if(a||!r)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx("p",{className:"text-muted-foreground",children:"This video is no longer available."})});const{rv:o,profile:l,brokerage:i,settings:d}=r,u=(d==null?void 0:d.primary_color)||"#3b82f6",p=((_=o.prospect)==null?void 0:_.first_name)||"there",f=(b=o.video)!=null&&b.playback_url?T3s(o.video.playback_url):null;return e.jsxs(e.Fragment,{children:[e.jsx(kl,{children:e.jsx("title",{children:i!=null&&i.name?`${i.name} — A Message For You`:"Personal Video Message"})}),e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 to-slate-100",children:[e.jsx("header",{className:"border-b bg-white/80 backdrop-blur-sm",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-4 py-4 flex items-center gap-3",children:[(d==null?void 0:d.logo_url)&&e.jsx("img",{src:d.logo_url,alt:"",className:"h-8 object-contain"}),e.jsx("span",{className:"font-semibold text-sm",style:{color:u},children:(i==null?void 0:i.name)||"Recruiting"})]})}),e.jsxs("main",{className:"max-w-3xl mx-auto px-4 py-8 space-y-6",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsxs("h1",{className:"text-2xl font-bold text-foreground",children:["Hey ",p,", ",l==null?void 0:l.name," has a message for you"]}),o.message&&e.jsx("p",{className:"text-muted-foreground max-w-xl mx-auto",children:o.message})]}),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:((N=l==null?void 0:l.name)==null?void 0:N.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(W,{size:"lg",className:"text-white shadow-lg hover:shadow-xl transition-shadow px-8",style:{backgroundColor:u},onClick:()=>{G.from("recruit_videos").update({cta_clicked_at:new Date().toISOString()}).eq("id",o.id).then(()=>{})},children:[e.jsx(cn,{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 E3s="relzejiswnotikjgvjhz",I9e=`https://${E3s}.supabase.co/functions/v1/recruit-unsubscribe`;function P3s(){const[t]=Nc(),s=t.get("token")||"",[r,n]=k.useState(!0),[a,o]=k.useState(!1),[l,i]=k.useState(!1),[d,u]=k.useState(""),[p,f]=k.useState({});k.useEffect(()=>{document.body.classList.add("recruit-unsubscribe-page");const _=()=>{['[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(S=>document.querySelectorAll(S).forEach(C=>C.style.display="none"))};_();const b=[setTimeout(_,500),setTimeout(_,1500),setTimeout(_,3e3)],N=new MutationObserver(_);return N.observe(document.body,{childList:!0,subtree:!0}),()=>{document.body.classList.remove("recruit-unsubscribe-page"),b.forEach(clearTimeout),N.disconnect()}},[]),k.useEffect(()=>{if(!s){f({error:"Missing unsubscribe token in link."}),n(!1);return}fetch(`${I9e}?token=${encodeURIComponent(s)}`).then(async _=>{const b=await _.json();if(!_.ok)throw new Error(b.error||"Lookup failed");f(b),b.already_unsubscribed&&i(!0)}).catch(_=>f({error:_.message||"Could not load status"})).finally(()=>n(!1))},[s]);const y=async()=>{o(!0);try{const _=await fetch(I9e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:s,reason:d.trim()||null})}),b=await _.json();if(!_.ok)throw new Error(b.error||"Failed");i(!0)}catch(_){f({...p,error:_.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(us,{className:"h-8 w-8 animate-spin"}),e.jsx("p",{className:"text-sm",children:"Loading…"})]}):p.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(ro,{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:p.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($n,{className:"h-7 w-7 text-emerald-500"})}),e.jsxs("h1",{className:"text-xl font-semibold text-slate-800",children:["You're unsubscribed",p.first_name?`, ${p.first_name}`:""]}),e.jsxs("p",{className:"text-sm text-slate-500",children:["You won't receive any more recruiting emails from ",p.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(t1,{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(t1,{className:"h-7 w-7 text-slate-500"})}),e.jsxs("h1",{className:"text-xl font-semibold text-slate-800",children:["Unsubscribe",p.first_name?`, ${p.first_name}`:"","?"]}),e.jsxs("p",{className:"text-sm text-slate-500",children:["You'll be removed from ",p.brokerage_name||"this brokerage","'s recruiting emails immediately. Everything stays confidential."]}),p.email&&e.jsx("p",{className:"text-xs text-slate-400",children:p.email})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"reason",className:"text-xs text-slate-500",children:"Optional — what's the main reason? (helps us improve)"}),e.jsx(_r,{id:"reason",value:d,onChange:_=>u(_.target.value),placeholder:"e.g. Not currently looking, too many emails, already moved…",rows:3,className:"resize-none"})]}),e.jsx(W,{onClick:y,disabled:a,className:"w-full h-11",variant:"default",children:a?e.jsxs(e.Fragment,{children:[e.jsx(us,{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 I3s(){const t=wr(),s=Qt(),{isAdmin:r}=Us(),[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,d]=k.useState(null),{data:u,isLoading:p}=gt({queryKey:["my-social-accounts"],queryFn:async()=>{const{data:{user:L},error:O}=await G.auth.getUser();if(O)throw O;if(!L)return[];const{data:V,error:q}=await G.from("social_accounts").select("*").eq("user_id",L.id).order("created_at",{ascending:!1});if(q)throw q;return V}}),f=Pt({mutationFn:async L=>{const{data:{user:O},error:V}=await G.auth.getUser();if(V)throw V;if(!O)throw new Error("Not authenticated");const{error:q}=await G.from("social_accounts").delete().eq("id",L).eq("user_id",O.id);if(q)throw q},onSuccess:()=>{s.invalidateQueries({queryKey:["my-social-accounts"]}),s.invalidateQueries({queryKey:["social-accounts-for-post"]}),pe.success("Account disconnected successfully")},onError:()=>{pe.error("Failed to disconnect account")}}),y=async()=>{a(!0);try{const{data:L,error:O}=await G.functions.invoke("meta-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/callback"}});if(O)throw O;if(L!=null&&L.authUrl)window.location.href=L.authUrl;else throw new Error("Failed to get authorization URL")}catch(L){console.error("Meta OAuth error:",L),pe.error("Failed to start connection. Please try again."),a(!1)}},_=async()=>{a(!0);try{const{data:L,error:O}=await G.functions.invoke("linkedin-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/linkedin-callback"}});if(O)throw O;if(L!=null&&L.authUrl)window.location.href=L.authUrl;else throw new Error("Failed to get LinkedIn authorization URL")}catch(L){console.error("LinkedIn OAuth error:",L),pe.error("Failed to start LinkedIn connection. Please try again."),a(!1)}},b=async()=>{a(!0);try{const{data:L,error:O}=await G.functions.invoke("google-business-oauth",{body:{action:"get_auth_url"}});if(O)throw O;if(L!=null&&L.authUrl)window.location.href=L.authUrl;else throw new Error("Failed to get Google authorization URL")}catch(L){console.error("Google OAuth error:",L),pe.error("Failed to start Google connection. Please try again."),a(!1)}},N=(u==null?void 0:u.filter(L=>L.platform==="facebook"))||[],w=(u==null?void 0:u.filter(L=>L.platform==="instagram"))||[],S=(u==null?void 0:u.filter(L=>L.platform==="linkedin"))||[],C=(u==null?void 0:u.filter(L=>L.platform==="google_business"))||[],A=((u==null?void 0:u.length)||0)>0,I=async(L,O)=>{l(L),d(null);try{const{data:V,error:q}=await G.functions.invoke("meta-api-test",{body:{testType:"all",accountId:L}});if(q)throw q;d(V.results||[]),pe.success(V.summary||"API tests completed")}catch(V){console.error("Meta API test error:",V),pe.error("Failed to run API tests")}finally{l(null)}};return e.jsx(Ds,{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(Qe,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(Or,{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(W,{variant:"ghost",onClick:()=>t("/social-swag-2"),className:"gap-2",children:[e.jsx(Oa,{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(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("div",{className:"rounded-full bg-amber-100 dark:bg-amber-900/30 p-4 mb-4",children:e.jsx(nn,{className:"h-10 w-10 text-amber-600 dark:text-amber-400"})}),e.jsx(Qe,{variant:"secondary",className:"mb-3 bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400",children:"Coming Soon"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Social Connections Coming Soon!"}),e.jsx("p",{className:"text-muted-foreground max-w-md",children:"We're putting the finishing touches on this feature. Soon you'll be able to connect your social accounts and post directly from Social Swag with one click."})]})}),r&&e.jsxs(e.Fragment,{children:[A&&e.jsx(Pe,{className:"border-green-200 bg-green-50 dark:bg-green-950/20 dark:border-green-900",children:e.jsxs(Oe,{className:"flex items-center gap-4 p-4",children:[e.jsx("div",{className:"rounded-full bg-green-500 p-2",children:e.jsx(si,{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(Dt,{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(hu,{className:"h-6 w-6 text-blue-600"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:"Facebook"}),e.jsx(dr,{children:"Connect your Facebook Pages"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Zi,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):N.length>0?e.jsx("div",{className:"space-y-3",children:N.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:L.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(hu,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:L.page_name||L.platform_username||"Facebook Page"}),e.jsx(Qe,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(Rl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(vr,{className:"h-4 w-4"})})}),e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Disconnect Facebook?"}),e.jsx(bl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:()=>f.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No Facebook pages connected yet"}),e.jsxs(W,{onClick:y,disabled:n,className:"w-full gap-2",variant:N.length>0?"outline":"default",children:[n?e.jsx(Zi,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{className:"h-4 w-4"}),N.length>0?"Connect Another Page":"Connect Facebook Page"]})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{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(zt,{className:"text-lg",children:"Instagram"}),e.jsx(dr,{children:"Connect Instagram Business accounts"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Zi,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):w.length>0?e.jsx("div",{className:"space-y-3",children:w.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:L.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(pu,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:["@",L.platform_username||"Instagram Account"]}),e.jsx(Qe,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(Rl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(vr,{className:"h-4 w-4"})})}),e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Disconnect Instagram?"}),e.jsx(bl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:()=>f.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No Instagram accounts connected yet"}),e.jsxs(W,{onClick:y,disabled:n,className:"w-full gap-2",variant:w.length>0?"outline":"default",children:[n?e.jsx(Zi,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{className:"h-4 w-4"}),w.length>0?"Connect Another Account":"Connect Instagram"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Instagram Business accounts must be connected to a Facebook Page"})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{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(gp,{className:"h-6 w-6 text-blue-700"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:"LinkedIn"}),e.jsx(dr,{children:"Connect your LinkedIn profile"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Zi,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):S.length>0?e.jsx("div",{className:"space-y-3",children:S.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:L.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(gp,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:L.platform_username||"LinkedIn Account"}),e.jsx(Qe,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(Rl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(vr,{className:"h-4 w-4"})})}),e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Disconnect LinkedIn?"}),e.jsx(bl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:()=>f.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No LinkedIn account connected yet"}),e.jsxs(W,{onClick:_,disabled:n,className:"w-full gap-2",variant:S.length>0?"outline":"default",children:[n?e.jsx(Zi,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{className:"h-4 w-4"}),S.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(Qe,{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(Qe,{variant:"secondary",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",children:"Admin Testing"})}),e.jsx(Dt,{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(Ia,{className:"h-6 w-6 text-red-600"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:"Google Business"}),e.jsx(dr,{children:"Connect your Google Business Profile"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Zi,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):C.length>0?e.jsx("div",{className:"space-y-3",children:C.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:L.profile_picture_url||""}),e.jsx(kn,{children:e.jsx(Ia,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:L.page_name||L.platform_username||"Google Business"}),e.jsx(Qe,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(Rl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(vr,{className:"h-4 w-4"})})}),e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Disconnect Google Business?"}),e.jsx(bl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:()=>f.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:r?"No Google Business account connected yet":"Google Business Profile integration is coming soon!"}),e.jsxs(W,{onClick:r?b:void 0,disabled:!r||n,className:"w-full gap-2",variant:C.length>0?"outline":"default",children:[n?e.jsx(Zi,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{className:"h-4 w-4"}),C.length>0?"Reconnect Google Business":"Connect Google Business"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Post updates directly to your Google Business Profile"})]})]})]}),r&&(N.length>0||w.length>0)&&e.jsxs(Pe,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-900",children:[e.jsx(Dt,{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(Sb,{className:"h-6 w-6 text-amber-600"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:"Meta API Testing (Admin Only)"}),e.jsx(dr,{children:"Run API tests to trigger all required permissions for Meta App Review"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:['Click "Run Tests" on an account to trigger API calls for: ',e.jsx("strong",{children:"public_profile"}),", ",e.jsx("strong",{children:"pages_show_list"}),", ",e.jsx("strong",{children:"pages_read_engagement"}),", ",e.jsx("strong",{children:"instagram_basic"}),", ",e.jsx("strong",{children:"pages_manage_posts"}),", and ",e.jsx("strong",{children:"instagram_content_publish"}),"."]}),e.jsxs("div",{className:"space-y-3",children:[N.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-background p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(hu,{className:"h-5 w-5 text-blue-600"}),e.jsx("span",{className:"font-medium",children:L.page_name||"Facebook Page"})]}),e.jsx(W,{size:"sm",variant:"outline",onClick:()=>I(L.id),disabled:o===L.id,children:o===L.id?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Sb,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-fb-${L.id}`)),w.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-background p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(pu,{className:"h-5 w-5 text-pink-600"}),e.jsxs("span",{className:"font-medium",children:["@",L.platform_username||"Instagram"]})]}),e.jsx(W,{size:"sm",variant:"outline",onClick:()=>I(L.id),disabled:o===L.id,children:o===L.id?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Sb,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-ig-${L.id}`))]}),i&&i.length>0&&e.jsxs("div",{className:"mt-4 rounded-lg border bg-background p-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Test Results"}),e.jsx("div",{className:"space-y-2",children:i.map((L,O)=>e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[L.status==="success"?e.jsx($n,{className:"h-4 w-4 text-green-600 mt-0.5 shrink-0"}):L.status==="pending"?e.jsx(us,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}):e.jsx(Jl,{className:"h-4 w-4 text-red-600 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-mono text-xs bg-muted px-1 rounded",children:L.test}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:L.details})]})]},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(Dt,{children:e.jsx(zt,{className:"text-lg",children:"How it works"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground text-sm font-medium",children:"1"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Connect your accounts"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Link your Facebook, Instagram, or LinkedIn account"})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground text-sm font-medium",children:"2"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Browse Social Swag"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Find the perfect image and caption for your post"})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground text-sm font-medium",children:"3"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Post with one click"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:'Click "Create Post" to share directly to your accounts'})]})]})]})})]})]})]})})}function L3s(){const[t]=Nc(),s=wr(),[r,n]=k.useState("loading"),[a,o]=k.useState("Processing your connection...");return k.useEffect(()=>{(async()=>{var f;const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),p=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),pe.error("Connection failed: "+(u||d));return}if(!i){n("error"),o("No authorization code received"),pe.error("No authorization code received");return}try{const{data:y,error:_}=await G.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p,callbackPath:"/social-connections/callback"}});if(_)throw _;if(y!=null&&y.success)n("success"),o(`Successfully connected ${((f=y.accounts)==null?void 0:f.length)||0} account(s)!`),pe.success("Social accounts connected successfully!");else throw new Error((y==null?void 0:y.error)||"Unknown error")}catch(y){console.error("OAuth callback error:",y),n("error"),o(y instanceof Error?y.message:"Failed to connect accounts"),pe.error("Failed to connect: "+(y instanceof Error?y.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(Dt,{className:"text-center",children:[r==="loading"&&e.jsx(us,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(si,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(Jl,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(zt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(dr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(W,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function D3s(){const[t]=Nc(),s=wr(),[r,n]=k.useState("loading"),[a,o]=k.useState("Connecting your Google Business Profile...");return k.useEffect(()=>{(async()=>{const i=t.get("code"),d=t.get("error"),u=t.get("error_description"),p=t.get("state");if(d){n("error"),o(u||"Authorization was denied"),pe.error("Connection failed: "+(u||d));return}if(!i){n("error"),o("No authorization code received"),pe.error("No authorization code received");return}try{const{data:f,error:y}=await G.functions.invoke("google-business-oauth",{body:{action:"exchange_code",code:i,state:p}});if(y)throw y;if(f!=null&&f.success)n("success"),o(f.message||"Successfully connected Google Business Profile!"),pe.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"),pe.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(Dt,{className:"text-center",children:[r==="loading"&&e.jsx(us,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(si,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(Jl,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(zt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(dr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(W,{onClick:()=>s("/social-connections"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function R3s(){const[t]=Nc(),s=wr(),[r,n]=k.useState("loading"),[a,o]=k.useState("Connecting your LinkedIn account...");return k.useEffect(()=>{(async()=>{var f;const i=t.get("code"),d=t.get("state"),u=t.get("error"),p=t.get("error_description");if(u){console.error("LinkedIn OAuth error:",u,p),n("error"),o(p||"Failed to connect LinkedIn account"),pe.error(p||"Failed to connect LinkedIn");return}if(!i){n("error"),o("No authorization code received"),pe.error("No authorization code received");return}try{const{data:y,error:_}=await G.functions.invoke("linkedin-oauth",{body:{action:"exchange_code",code:i,state:d,callbackPath:"/social-connections/linkedin-callback"}});if(_)throw _;if(y!=null&&y.success)n("success"),o(`Successfully connected ${((f=y.accounts)==null?void 0:f.length)||1} LinkedIn account`),pe.success("LinkedIn connected successfully!");else throw new Error((y==null?void 0:y.error)||"Failed to connect LinkedIn account")}catch(y){console.error("LinkedIn callback error:",y),n("error"),o(y instanceof Error?y.message:"Failed to connect LinkedIn account"),pe.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(Dt,{className:"text-center",children:[e.jsxs("div",{className:"mx-auto mb-4 rounded-full bg-blue-600/10 p-4 w-fit",children:[r==="loading"&&e.jsx(us,{className:"h-8 w-8 animate-spin text-blue-600"}),r==="success"&&e.jsx(si,{className:"h-8 w-8 text-green-600"}),r==="error"&&e.jsx(Jl,{className:"h-8 w-8 text-red-600"})]}),e.jsxs(zt,{className:"flex items-center justify-center gap-2",children:[e.jsx(gp,{className:"h-5 w-5 text-blue-600"}),r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(dr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:e.jsx(W,{onClick:()=>s("/social-connections"),disabled:r==="loading",children:r==="success"?"Continue":"Back to Connections"})})]})})}function O3s(){const t=wr(),[s,r]=k.useState(null),{data:n,isLoading:a}=Wlt(s||void 0,!0),{data:o,isLoading:l}=UCe(!0),{cartItems:i}=she(),d=i.reduce((p,f)=>p+f.quantity,0),u=p=>{t(`/marketplace/${p.id}`)};return a||l?e.jsx(Ds,{title:"Marketplace",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex gap-2 overflow-x-auto pb-2",children:[1,2,3].map(p=>e.jsx(Ms,{className:"h-10 w-24 flex-shrink-0"},p))}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:[1,2,3,4].map(p=>e.jsx(Ms,{className:"h-72 w-full"},p))})]})}):e.jsx(Ds,{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(W,{variant:"outline",onClick:()=>t("/marketplace/cart"),className:"relative",children:[e.jsx(lp,{className:"h-4 w-4 mr-2"}),"Cart",d>0&&e.jsx(Qe,{className:"absolute -top-2 -right-2 h-5 w-5 flex items-center justify-center p-0 text-xs",children:d})]})]}),o&&o.length>0&&e.jsxs("div",{className:"flex gap-2 overflow-x-auto pb-2",children:[e.jsx(W,{variant:s===null?"default":"outline",size:"sm",onClick:()=>r(null),children:"All"}),o.map(p=>e.jsx(W,{variant:s===p.id?"default":"outline",size:"sm",onClick:()=>r(p.id),children:p.name},p.id))]}),n&&n.length>0?e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:n.map(p=>{var f;return e.jsxs(Pe,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>u(p),children:[e.jsxs("div",{className:"aspect-square bg-muted relative",children:[p.images&&p.images.length>0?e.jsx("img",{src:((f=p.images.find(y=>y.is_primary))==null?void 0:f.image_url)||p.images[0].image_url,alt:p.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(cl,{className:"h-12 w-12 text-muted-foreground"})}),p.category&&e.jsx(Qe,{className:"absolute top-2 left-2",variant:"secondary",children:p.category.name})]}),e.jsxs(Oe,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold mb-1 line-clamp-1",children:p.name}),p.description&&e.jsx("p",{className:"text-sm text-muted-foreground mb-2 line-clamp-2",children:p.description}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"font-bold text-lg",children:["$",Number(p.base_price).toFixed(2)]}),p.variants&&p.variants.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[p.variants.length," options"]})]})]})]},p.id)})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(cl,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No products available yet."})]})]})})}const Pct=k.forwardRef(({...t},s)=>e.jsx("nav",{ref:s,"aria-label":"breadcrumb",...t}));Pct.displayName="Breadcrumb";const Ict=k.forwardRef(({className:t,...s},r)=>e.jsx("ol",{ref:r,className:Ot("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",t),...s}));Ict.displayName="BreadcrumbList";const uoe=k.forwardRef(({className:t,...s},r)=>e.jsx("li",{ref:r,className:Ot("inline-flex items-center gap-1.5",t),...s}));uoe.displayName="BreadcrumbItem";const s2e=k.forwardRef(({asChild:t,className:s,...r},n)=>{const a=t?tje:"a";return e.jsx(a,{ref:n,className:Ot("transition-colors hover:text-foreground",s),...r})});s2e.displayName="BreadcrumbLink";const Lct=k.forwardRef(({className:t,...s},r)=>e.jsx("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:Ot("font-normal text-foreground",t),...s}));Lct.displayName="BreadcrumbPage";const r2e=({children:t,className:s,...r})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:Ot("[&>svg]:size-3.5",s),...r,children:t??e.jsx(xa,{})});r2e.displayName="BreadcrumbSeparator";function F3s(){var J,X;const{productId:t}=io(),s=wr(),{data:r,isLoading:n}=B4s(t||""),{addToCart:a,cartItems:o}=she(),[l,i]=k.useState(null),[d,u]=k.useState(1),[p,f]=k.useState(0),[y,_]=k.useState(null),[b,N]=k.useState(!1),[w,S]=k.useState(!1),C=(J=r==null?void 0:r.variants)==null?void 0:J.find(ce=>ce.id===l),A=((X=r==null?void 0:r.variants)==null?void 0:X.filter(ce=>ce.is_active))||[],I=Number((r==null?void 0:r.base_price)||0),L=C?Number(C.price_adjustment):0,O=I+L,V=Number((r==null?void 0:r.shipping_fee)||0),q=o.reduce((ce,ie)=>ce+ie.quantity,0),B=async ce=>{if(!ce.target.files||ce.target.files.length===0)return;N(!0);const ie=ce.target.files[0],ae=ie.name.split(".").pop(),oe=`artwork/${Date.now()}-${Math.random().toString(36).substring(7)}.${ae}`;try{const{error:me}=await G.storage.from("marketplace").upload(oe,ie);if(me)throw me;const{data:{publicUrl:ve}}=G.storage.from("marketplace").getPublicUrl(oe);_(ve),pe.success("Artwork uploaded successfully")}catch(me){pe.error("Failed to upload artwork: "+me.message)}finally{N(!1)}},U=()=>{if(r){if(A.length>0&&!l){pe.error("Please select an option");return}a(r,C||void 0,d,y||void 0),S(!0),pe.success("Added to cart!"),setTimeout(()=>S(!1),2e3)}},te=()=>{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(Ds,{title:"Product",children:e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[e.jsx(Ms,{className:"aspect-square w-full"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ms,{className:"h-8 w-3/4"}),e.jsx(Ms,{className:"h-6 w-1/4"}),e.jsx(Ms,{className:"h-24 w-full"}),e.jsx(Ms,{className:"h-12 w-full"})]})]})}):r?e.jsxs(Ds,{title:r.name,children:[e.jsx(Pct,{className:"mb-6",children:e.jsxs(Ict,{children:[e.jsx(uoe,{children:e.jsx(s2e,{asChild:!0,children:e.jsx(da,{to:"/marketplace",children:"Marketplace"})})}),r.category&&e.jsxs(e.Fragment,{children:[e.jsx(r2e,{}),e.jsx(uoe,{children:e.jsx(s2e,{asChild:!0,children:e.jsx(da,{to:`/marketplace?category=${r.category.id}`,children:r.category.name})})})]}),e.jsx(r2e,{}),e.jsx(uoe,{children:e.jsx(Lct,{children:r.name})})]})}),e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"relative aspect-square bg-muted rounded-lg overflow-hidden flex items-center justify-center",children:r.images&&r.images.length>0?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:r.images[p].image_url,alt:r.name,className:"max-w-full max-h-full object-contain"}),r.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(W,{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(Xo,{className:"h-6 w-6"})}),e.jsx(W,{variant:"ghost",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 bg-background/80 hover:bg-background",onClick:te,children:e.jsx(xa,{className:"h-6 w-6"})})]})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(cl,{className:"h-24 w-24 text-muted-foreground"})})}),r.images&&r.images.length>1&&e.jsx("div",{className:"flex gap-2 overflow-x-auto pb-2",children:r.images.map((ce,ie)=>e.jsx("button",{onClick:()=>f(ie),className:`w-16 h-16 flex-shrink-0 rounded-md overflow-hidden border-2 ${ie===p?"border-primary":"border-transparent"}`,children:e.jsx("img",{src:ce.image_url,alt:"",className:"w-full h-full object-cover"})},ce.id))}),r.video&&e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("h4",{className:"font-medium mb-2",children:"Product Video"}),e.jsx("div",{className:"aspect-video",children:e.jsx("iframe",{src:r.video.video_url,className:"w-full h-full rounded-lg",allowFullScreen:!0})})]})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[r.category&&e.jsx(Qe,{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)]}),V>0&&e.jsxs("span",{className:"text-muted-foreground",children:["+ $",V.toFixed(2)," shipping"]})]})]}),r.description&&e.jsx("div",{className:"prose prose-sm max-w-none",children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})}),A.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(xe,{children:"Select Option"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:A.map(ce=>e.jsxs(W,{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(xe,{children:"Upload Your Artwork (Optional)"}),y?e.jsxs("div",{className:"relative inline-block",children:[e.jsx("img",{src:y,alt:"Your artwork",className:"h-24 w-auto rounded-lg border"}),e.jsx(W,{variant:"ghost",size:"sm",className:"absolute -top-2 -right-2",onClick:()=>_(null),children:"×"})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6",children:[e.jsx("input",{type:"file",accept:"image/*,.pdf,.ai,.eps",onChange:B,className:"hidden",id:"artwork-upload",disabled:b}),e.jsxs("label",{htmlFor:"artwork-upload",className:"flex flex-col items-center cursor-pointer",children:[e.jsx(Ra,{className:"h-8 w-8 text-muted-foreground mb-2"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:b?"Uploading...":"Click to upload artwork"}),e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"Supported: JPG, PNG, PDF, AI, EPS"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(xe,{children:"Quantity"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{variant:"outline",size:"icon",onClick:()=>u(ce=>Math.max(1,ce-1)),children:"-"}),e.jsx(De,{type:"number",value:d,onChange:ce=>u(Math.max(1,parseInt(ce.target.value)||1)),className:"w-20 text-center",min:"1"}),e.jsx(W,{variant:"outline",size:"icon",onClick:()=>u(ce=>ce+1),children:"+"})]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(W,{size:"lg",className:"flex-1",onClick:U,disabled:w,children:w?e.jsxs(e.Fragment,{children:[e.jsx(Zn,{className:"h-5 w-5 mr-2"}),"Added!"]}):e.jsxs(e.Fragment,{children:[e.jsx(lp,{className:"h-5 w-5 mr-2"}),"Add to Cart"]})}),e.jsxs(W,{variant:"outline",size:"lg",onClick:()=>s("/marketplace/cart"),className:"relative",children:[e.jsx(lp,{className:"h-5 w-5"}),q>0&&e.jsx(Qe,{className:"absolute -top-2 -right-2 h-5 w-5 flex items-center justify-center p-0 text-xs",children:q})]})]}),r.requires_proof_approval&&e.jsx("p",{className:"text-sm text-muted-foreground bg-muted p-3 rounded-lg",children:"📋 This product requires proof approval before production. You'll receive a proof to review after your order is placed."})]})]})]}):e.jsx(Ds,{title:"Product Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(cl,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Product not found"}),e.jsx(W,{onClick:()=>s("/marketplace"),children:"Back to Marketplace"})]})})}function z3s(){const t=wr(),{cartItems:s,removeFromCart:r,updateQuantity:n,getItemPrice:a,getSubtotal:o,getShippingTotal:l,getTotal:i,clearCart:d}=she(),[u,p]=k.useState(!1),[f,y]=k.useState(""),_=async()=>{if(s.length===0){pe.error("Your cart is empty");return}p(!0);try{const{data:b,error:N}=await G.functions.invoke("marketplace-checkout",{body:{items:s.map(w=>{var S;return{product_id:w.product.id,variant_id:((S=w.variant)==null?void 0:S.id)||null,quantity:w.quantity,artwork_url:w.artworkUrl||null}}),notes:f.trim()||null}});if(N)throw N;if(b!=null&&b.url)d(),window.open(b.url,"_blank");else throw new Error("No checkout URL received")}catch(b){pe.error("Checkout failed: "+b.message)}finally{p(!1)}};return s.length===0?e.jsx(Ds,{title:"Shopping Cart",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(s0,{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(W,{onClick:()=>t("/marketplace"),children:"Browse Marketplace"})]})}):e.jsx(Ds,{title:"Shopping Cart",children:e.jsxs("div",{className:"grid gap-8 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-4",children:[s.map(b=>{var N,w;return e.jsx(Pe,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"w-24 h-24 flex-shrink-0 bg-muted rounded-lg overflow-hidden",children:b.product.images&&b.product.images.length>0?e.jsx("img",{src:((N=b.product.images.find(S=>S.is_primary))==null?void 0:N.image_url)||b.product.images[0].image_url,alt:b.product.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(s0,{className:"h-8 w-8 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold line-clamp-1",children:b.product.name}),b.variant&&e.jsx("p",{className:"text-sm text-muted-foreground",children:b.variant.name}),e.jsxs("p",{className:"font-medium mt-1",children:["$",a(b).toFixed(2),Number(b.product.shipping_fee)>0&&e.jsxs("span",{className:"text-sm text-muted-foreground ml-2",children:["+ $",Number(b.product.shipping_fee).toFixed(2)," shipping"]})]}),b.artworkUrl&&e.jsx("div",{className:"mt-2",children:e.jsx("span",{className:"text-xs text-muted-foreground",children:"Artwork uploaded ✓"})})]}),e.jsxs("div",{className:"flex flex-col items-end gap-2",children:[e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{var S;return r(b.product.id,(S=b.variant)==null?void 0:S.id)},children:e.jsx(vr,{className:"h-4 w-4 text-destructive"})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(W,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>{var S;return n(b.product.id,(S=b.variant)==null?void 0:S.id,b.quantity-1)},disabled:b.quantity<=1,children:e.jsx(Qy,{className:"h-3 w-3"})}),e.jsx(De,{type:"number",value:b.quantity,onChange:S=>{var C;return n(b.product.id,(C=b.variant)==null?void 0:C.id,parseInt(S.target.value)||1)},className:"w-14 h-8 text-center text-sm",min:"1"}),e.jsx(W,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>{var S;return n(b.product.id,(S=b.variant)==null?void 0:S.id,b.quantity+1)},children:e.jsx(qs,{className:"h-3 w-3"})})]})]})]})})},`${b.product.id}-${((w=b.variant)==null?void 0:w.id)||"base"}`)}),e.jsx(W,{variant:"ghost",className:"text-destructive",onClick:d,children:"Clear Cart"})]}),e.jsx("div",{children:e.jsxs(Pe,{className:"sticky top-4",children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Order Summary"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsxs("span",{children:["Subtotal (",s.reduce((b,N)=>b+N.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(ho,{}),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(ho,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"orderNotes",children:"Order Notes (Optional)"}),e.jsx(_r,{id:"orderNotes",placeholder:"Add any special instructions, design notes, or comments for your order...",value:f,onChange:b=>y(b.target.value),rows:3,className:"resize-none"})]}),e.jsx(W,{className:"w-full",size:"lg",onClick:_,disabled:u,children:u?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"h-5 w-5 mr-2 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:["Checkout",e.jsx(Wa,{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 B3s(){const t=wr(),{data:s,isLoading:r}=X4s();return r?e.jsx(Ds,{title:"My Orders",children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(n=>e.jsx(Ms,{className:"h-32 w-full"},n))})}):!s||s.length===0?e.jsx(Ds,{title:"My Orders",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(cl,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No orders yet"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Start shopping to see your orders here!"}),e.jsx(W,{onClick:()=>t("/marketplace"),children:"Browse Marketplace"})]})}):e.jsx(Ds,{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(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold",children:n.order_number}),e.jsx("span",{className:"text-muted-foreground text-sm ml-2",children:vs(new Date(n.created_at),"MMM d, yyyy")})]}),e.jsx(Qe,{className:qCe[n.status],children:iT[n.status]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex -space-x-2",children:[(a=n.items)==null?void 0:a.slice(0,3).map((i,d)=>e.jsxs("div",{className:"w-10 h-10 bg-muted rounded border-2 border-background flex items-center justify-center text-xs font-medium",style:{zIndex:3-d},children:[i.quantity,"×"]},i.id)),n.items&&n.items.length>3&&e.jsxs("div",{className:"w-10 h-10 bg-muted rounded border-2 border-background flex items-center justify-center text-xs font-medium",children:["+",n.items.length-3]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",children:((o=n.items)==null?void 0:o.length)===1?n.items[0].product_name:`${(l=n.items)==null?void 0:l.length} items`}),e.jsxs("p",{className:"font-semibold",children:["$",Number(n.total).toFixed(2)]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n.tracking_url&&e.jsxs(W,{variant:"outline",size:"sm",onClick:i=>{i.stopPropagation(),window.open(n.tracking_url,"_blank")},children:[e.jsx(Yr,{className:"h-4 w-4 mr-1"}),"Track"]}),e.jsx(xa,{className:"h-5 w-5 text-muted-foreground"})]})]})]})},n.id)})})})}const L9e=["order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed"];function $3s({currentStatus:t,statusHistory:s}){const r=L9e.indexOf(t);return e.jsx("div",{className:"space-y-3",children:L9e.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($n,{className:"h-4 w-4"}):i?e.jsx(nn,{className:"h-4 w-4"}):e.jsx("span",{className:"text-xs",children:a+1})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:`font-medium ${d?"text-muted-foreground":""}`,children:iT[n]}),o&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[vs(new Date(o.created_at),"MMM d, yyyy h:mm a"),o.notes&&` — ${o.notes}`]})]})]},n)})})}function q3s(){var S;const{orderId:t}=io(),s=wr(),{data:r,isLoading:n,refetch:a}=Q4s(t||""),o=tSs(),l=sSs(),[i,d]=k.useState(!1),[u,p]=k.useState(null),[f,y]=k.useState(""),[_,b]=k.useState(null),N=async C=>{b(C);try{await o.mutateAsync({orderId:t,itemId:C}),pe.success("Proof approved!"),a()}catch{pe.error("Failed to approve proof")}finally{b(null)}},w=async()=>{if(u){b(u);try{await l.mutateAsync({orderId:t,itemId:u,reason:f}),pe.success("Revision requested"),d(!1),y(""),p(null),a()}catch{pe.error("Failed to request revision")}finally{b(null)}}};return n?e.jsx(Ds,{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(Ms,{className:"h-64 w-full"}),e.jsx(Ms,{className:"h-48 w-full"})]}),e.jsx(Ms,{className:"h-96 w-full"})]})}):r?e.jsxs(Ds,{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(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{children:"Order Status"}),e.jsx(Qe,{className:qCe[r.status],children:iT[r.status]})]}),e.jsx(Oe,{children:e.jsx($3s,{currentStatus:r.status,statusHistory:r.status_history})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Items"})}),e.jsx(Oe,{className:"space-y-4",children:(S=r.items)==null?void 0:S.map(C=>e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold",children:C.product_name}),C.variant_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:C.variant_name}),e.jsxs("p",{className:"text-sm",children:["Qty: ",C.quantity," × $",Number(C.unit_price).toFixed(2)]})]}),e.jsxs("p",{className:"font-semibold",children:["$",(Number(C.unit_price)*C.quantity).toFixed(2)]})]}),C.artwork_url&&e.jsxs("div",{className:"mb-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Your Artwork:"}),e.jsxs("a",{href:C.artwork_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-primary hover:underline",children:[e.jsx(kb,{className:"h-4 w-4"}),"View Artwork",e.jsx(Yr,{className:"h-3 w-3"})]})]}),C.proof_url&&e.jsxs("div",{className:"bg-muted rounded-lg p-3",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Proof Ready for Review"}),e.jsxs("a",{href:C.proof_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-primary hover:underline mb-3",children:[e.jsx(kb,{className:"h-4 w-4"}),"View Proof",e.jsx(Yr,{className:"h-3 w-3"})]}),C.proof_status==="pending"&&e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsxs(W,{size:"sm",onClick:()=>N(C.id),disabled:_===C.id,children:[_===C.id?e.jsx(us,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Bu,{className:"h-4 w-4 mr-1"}),"Approve"]}),e.jsxs(W,{size:"sm",variant:"outline",onClick:()=>{p(C.id),d(!0)},disabled:_===C.id,children:[e.jsx($L,{className:"h-4 w-4 mr-1"}),"Request Changes"]})]}),C.proof_status==="approved"&&e.jsxs(Qe,{className:"bg-green-100 text-green-800",children:[e.jsx($n,{className:"h-3 w-3 mr-1"}),"Proof Approved"]}),C.proof_status==="rejected"&&C.proof_notes&&e.jsxs("div",{className:"mt-2",children:[e.jsx(Qe,{variant:"destructive",className:"mb-2",children:"Revision Requested"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:C.proof_notes})]})]})]},C.id))})]}),r.shipping_name&&e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(UL,{className:"h-5 w-5"}),"Shipping"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"font-medium",children:r.shipping_name}),e.jsxs("p",{className:"text-muted-foreground",children:[r.shipping_address,e.jsx("br",{}),r.shipping_city,", ",r.shipping_state," ",r.shipping_zip]}),r.tracking_number&&e.jsxs("div",{className:"mt-4 p-3 bg-muted rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Tracking Number:"}),e.jsx("p",{className:"font-mono font-medium",children:r.tracking_number}),r.tracking_url&&e.jsxs(W,{variant:"link",className:"p-0 h-auto mt-1",onClick:()=>window.open(r.tracking_url,"_blank"),children:["Track Package",e.jsx(Yr,{className:"h-3 w-3 ml-1"})]})]})]})]})]}),e.jsx("div",{children:e.jsxs(Pe,{className:"sticky top-4",children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Order Summary"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Placed on ",vs(new Date(r.created_at),"MMMM d, yyyy")]}),e.jsx(ho,{}),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(ho,{}),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(ho,{}),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:d,children:e.jsxs(ps,{children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Request Changes"}),e.jsx(Ir,{children:"Please describe what changes you'd like made to the proof."})]}),e.jsx(_r,{placeholder:"Describe the changes needed...",value:f,onChange:C=>y(C.target.value),rows:4}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(W,{onClick:w,disabled:!f.trim()||_!==null,children:[_?e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Submit Request"]})]})]})})]}):e.jsx(Ds,{title:"Order Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(cl,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Order not found"}),e.jsx(W,{onClick:()=>s("/marketplace/orders"),children:"View All Orders"})]})})}function U3s(){const t=wr(),[s]=Nc();return s.get("session_id"),k.useEffect(()=>{localStorage.removeItem("marketplace-cart")},[]),e.jsx(Ds,{title:"Order Confirmed",children:e.jsx("div",{className:"max-w-lg mx-auto text-center py-8",children:e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-8 pb-6",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-6",children:e.jsx($n,{className:"h-8 w-8 text-green-600"})}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Thank You for Your Order!"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Your order has been confirmed and is being processed. You'll receive an email confirmation shortly."}),e.jsxs("div",{className:"bg-muted rounded-lg p-4 mb-6 text-left",children:[e.jsxs("h3",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(cl,{className:"h-4 w-4"}),"What happens next?"]}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("li",{children:"• We'll review your order and prepare it for production"}),e.jsx("li",{children:"• If your order requires a proof, you'll receive it for approval"}),e.jsx("li",{children:"• Once approved, we'll begin production and ship when ready"}),e.jsx("li",{children:"• You'll receive tracking info when your order ships"})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(W,{className:"flex-1",onClick:()=>t("/marketplace/orders"),children:["View My Orders",e.jsx(Wa,{className:"h-4 w-4 ml-2"})]}),e.jsx(W,{variant:"outline",className:"flex-1",onClick:()=>t("/marketplace"),children:"Continue Shopping"})]})]})})})})}function V3s(){const{user:t}=Us(),[s,r]=k.useState("store"),[n,a]=k.useState(null),[o,l]=k.useState(null),[i,d]=k.useState(!1),[u,p]=k.useState(5),[f,y]=k.useState(""),[_,b]=k.useState(!1),[N,w]=k.useState(!1),[S,C]=k.useState(""),[A,I]=k.useState(null),[L,O]=k.useState(!1),{hasSubmittedReview:V,submitReview:q,markPostedToGoogle:B}=XYe(),{data:U}=Zlt(),{data:te,isLoading:Y}=Klt(),{data:J,isLoading:X}=cSs(n),{data:ce,isLoading:ie}=dSs(t==null?void 0:t.id),{data:ae=0}=hSs(t==null?void 0:t.id),oe=mSs(),me=new Set((ce==null?void 0:ce.map(ke=>ke.item_id))||[]),ve=async()=>{if(o)try{const ke=await oe.mutateAsync(o.id);o.item_type==="reelflow_credits"?pe.success(`🎬 ${o.max_quantity} ReelFlow credits added to your balance!`):pe.success(`Successfully purchased "${o.name}"!`),l(null)}catch(ke){pe.error(ke.message||"Failed to purchase item")}},he=async()=>{if(!f.trim()){pe.error("Please write a review");return}b(!0);const ke=await q(u,f);b(!1),ke.success?(pe.success("Thank you for your review! You earned 25 points!"),C(f),w(!0),y(""),p(5)):pe.error(ke.error||"Failed to submit review")},ge=()=>{navigator.clipboard.writeText(S),pe.success("Review copied to clipboard!")},je=()=>{B(),window.open("https://g.page/r/CT8bqTBTm7nJEBM/review","_blank")},qe=()=>{w(!1),d(!1),C("")};return Y||X||ie?e.jsx(Ds,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ms,{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(ke=>e.jsx(Ms,{className:"h-64"},ke))})]})}):e.jsxs(Ds,{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(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/20 flex items-center justify-center",children:e.jsx(Gn,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your Spendable Points"}),e.jsx("p",{className:"text-3xl font-bold text-primary",children:ae.toLocaleString()})]})]}),e.jsxs("div",{className:"flex items-center gap-6 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Fi,{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(rd,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{children:"Streak bonuses add extra points!"})]})]})]})})}),e.jsx(lf,{open:L,onOpenChange:O,children:e.jsxs(Pe,{className:"border-primary/20",children:[e.jsx(cf,{asChild:!0,children:e.jsx(Dt,{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(Fi,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-base",children:"How to Earn Points"}),e.jsx(dr,{children:"See all the ways you can earn spendable points"})]})]}),L?e.jsx(af,{className:"h-5 w-5 text-muted-foreground"}):e.jsx(Bi,{className:"h-5 w-5 text-muted-foreground"})]})})}),e.jsx(df,{children:e.jsx(Oe,{className:"pt-0",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[U==null?void 0:U.filter(ke=>ke.is_active).map(ke=>{const Re=Ve=>{switch(Ve){case"event_attendance":return e.jsx(cn,{className:"h-5 w-5"});case"leave_review":return e.jsx(Gn,{className:"h-5 w-5"});case"add_listing":return e.jsx(Mn,{className:"h-5 w-5"});case"first_contact":return e.jsx(ir,{className:"h-5 w-5"});case"first_video":return e.jsx(yn,{className:"h-5 w-5"});case"first_community_post":return e.jsx(wi,{className:"h-5 w-5"});default:return e.jsx(hi,{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:Re(ke.action_key)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:ke.action_name}),ke.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:ke.description})]}),e.jsxs(Qe,{variant:"secondary",className:"font-bold shrink-0",children:["+",ke.points]})]},ke.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(rd,{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(Qe,{variant:"outline",className:"font-bold shrink-0 border-orange-500/50 text-orange-600",children:"+Bonus"})]})]})})})]})}),!V&&e.jsx(Pe,{className:"bg-gradient-to-r from-yellow-500/10 to-orange-500/10 border-yellow-500/20",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-yellow-500/20 flex items-center justify-center",children:e.jsx(wi,{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(W,{onClick:()=>d(!0),className:"bg-yellow-600 hover:bg-yellow-700",children:[e.jsx(Gn,{className:"h-4 w-4 mr-2"}),"Leave Review"]})]})})}),e.jsxs(ta,{value:s,onValueChange:r,children:[e.jsxs(Jn,{children:[e.jsxs(cs,{value:"store",className:"flex items-center gap-2",children:[e.jsx(s0,{className:"h-4 w-4"}),"Store"]}),e.jsxs(cs,{value:"my-rewards",className:"flex items-center gap-2",children:[e.jsx(cl,{className:"h-4 w-4"}),"My Rewards",ce&&ce.length>0&&e.jsx(Qe,{variant:"secondary",className:"ml-1",children:ce.length})]})]}),e.jsxs(Ss,{value:"store",className:"mt-6",children:[te&&te.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[e.jsx(W,{variant:n===null?"default":"outline",size:"sm",onClick:()=>a(null),children:"All"}),te.map(ke=>e.jsxs(W,{variant:n===ke.id?"default":"outline",size:"sm",onClick:()=>a(ke.id),children:[ke.icon&&`${ke.icon} `,ke.name]},ke.id))]}),!J||J.length===0?e.jsx(Pe,{children:e.jsx(Oe,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(hi,{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(ke=>{const Re=ke.item_type==="reelflow_credits",Ve=!Re&&me.has(ke.id),Ne=!Re&&ke.max_quantity!==null&&ke.current_quantity===0,Ue=ae>=ke.points_cost;return e.jsxs(Pe,{className:`overflow-hidden transition-all cursor-pointer hover:shadow-lg ${Ve?"ring-2 ring-green-500/50 bg-green-500/5":""}`,onClick:()=>I(ke),children:[ke.preview_image_url?e.jsxs("div",{className:"aspect-video relative overflow-hidden bg-muted",children:[e.jsx("img",{src:ke.preview_image_url,alt:ke.name,className:"w-full h-full object-cover"}),Ve&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(Qe,{className:"bg-green-500 text-white",children:[e.jsx($n,{className:"h-3 w-3 mr-1"}),"Owned"]})}),Ne&&!Ve&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(Qe,{variant:"destructive",children:"Sold Out"})})]}):e.jsxs("div",{className:"aspect-video bg-muted flex items-center justify-center relative",children:[e.jsx(hi,{className:"h-12 w-12 text-muted-foreground/50"}),Ve&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(Qe,{className:"bg-green-500 text-white",children:[e.jsx($n,{className:"h-3 w-3 mr-1"}),"Owned"]})})]}),e.jsxs(Dt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(zt,{className:"text-lg",children:ke.name}),e.jsxs(Qe,{variant:"secondary",className:"font-bold shrink-0",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),ke.points_cost]})]}),ke.category&&e.jsxs(Qe,{variant:"outline",className:"w-fit",children:[ke.category.icon&&`${ke.category.icon} `,ke.category.name]})]}),e.jsxs(Oe,{children:[e.jsx(dr,{className:"mb-4 line-clamp-2",children:ke.description||"No description available"}),ke.max_quantity!==null&&!Ve&&!Re&&e.jsxs("p",{className:"text-xs text-muted-foreground mb-3",children:[ke.current_quantity," of ",ke.max_quantity," remaining"]}),Re&&e.jsxs("p",{className:"text-xs text-violet-600 font-medium mb-3",children:["🎬 Grants ",ke.max_quantity," ReelFlow credits per purchase"]}),Ve?e.jsx(W,{className:"w-full",onClick:Ie=>{Ie.stopPropagation(),ke.file_url&&N0e(ke.file_url,ke.name)},disabled:!ke.file_url,children:ke.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(Qa,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(Yr,{className:"h-4 w-4 mr-2"}),"Access"]})}):e.jsx(W,{className:"w-full",onClick:Ie=>{Ie.stopPropagation(),l(ke)},disabled:Ne||!Ue,children:Ne?"Sold Out":Ue?e.jsxs(e.Fragment,{children:[e.jsx(s0,{className:"h-4 w-4 mr-2"}),"Purchase"]}):`Need ${ke.points_cost-ae} more pts`})]})]},ke.id)})})]}),e.jsx(Ss,{value:"my-rewards",className:"mt-6",children:!ce||ce.length===0?e.jsx(Pe,{children:e.jsx(Oe,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(cl,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No rewards yet"}),e.jsx("p",{className:"text-sm",children:"Purchase items from the store to see them here!"})]})})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:ce.map(ke=>{var Re,Ve,Ne,Ue,Ie,ye,ct;return e.jsxs(Pe,{className:"overflow-hidden",children:[(Re=ke.item)!=null&&Re.preview_image_url?e.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted",children:e.jsx("img",{src:ke.item.preview_image_url,alt:((Ve=ke.item)==null?void 0:Ve.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(hi,{className:"h-12 w-12 text-muted-foreground/50"})}),e.jsxs(Dt,{className:"pb-2",children:[e.jsx(zt,{className:"text-lg",children:((Ne=ke.item)==null?void 0:Ne.name)||"Unknown Item"}),e.jsxs(dr,{className:"text-xs",children:["Purchased for ",ke.points_spent," points • ",new Date(ke.purchased_at).toLocaleDateString()]})]}),e.jsx(Oe,{children:((Ue=ke.item)==null?void 0:Ue.item_type)==="reelflow_credits"?e.jsxs(W,{className:"w-full",variant:"outline",disabled:!0,children:[e.jsx($n,{className:"h-4 w-4 mr-2 text-green-500"}),(Ie=ke.item)==null?void 0:Ie.max_quantity," Credits Applied"]}):e.jsx(W,{className:"w-full",onClick:()=>{var fe,$e;(fe=ke.item)!=null&&fe.file_url&&N0e(ke.item.file_url,($e=ke.item)==null?void 0:$e.name)},disabled:!((ye=ke.item)!=null&&ye.file_url),children:((ct=ke.item)==null?void 0:ct.item_type)==="file"?e.jsxs(e.Fragment,{children:[e.jsx(Qa,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(Yr,{className:"h-4 w-4 mr-2"}),"Access"]})})})]},ke.id)})})})]})]}),e.jsx(Rl,{open:!!o,onOpenChange:()=>l(null),children:e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Confirm Purchase"}),e.jsxs(bl,{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:[ae," points"]}),". After this purchase, you'll have"," ",e.jsxs("strong",{children:[ae-((o==null?void 0:o.points_cost)||0)," points"]})," remaining."]})]}),e.jsxs(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:ve,disabled:oe.isPending,children:oe.isPending?"Purchasing...":"Confirm Purchase"})]})]})}),e.jsx(fs,{open:i,onOpenChange:ke=>{!ke&&N?qe():d(ke)},children:e.jsx(ps,{children:N?e.jsxs(e.Fragment,{children:[e.jsxs(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx($n,{className:"h-5 w-5 text-green-500"}),"Thank You for Your Review!"]}),e.jsx(Ir,{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:['"',S,'"']})]}),e.jsxs(W,{variant:"outline",className:"w-full",onClick:ge,children:[e.jsx(Va,{className:"h-4 w-4 mr-2"}),"Copy Review to Clipboard"]})]}),e.jsxs(gn,{className:"flex-col sm:flex-row gap-2",children:[e.jsx(W,{variant:"outline",onClick:qe,children:"Maybe Later"}),e.jsxs(W,{onClick:je,className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(Yr,{className:"h-4 w-4 mr-2"}),"Leave Google Review"]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"Leave a Review"}),e.jsx(Ir,{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(ke=>e.jsx("button",{type:"button",onClick:()=>p(ke),className:"focus:outline-none",children:e.jsx(Gn,{className:`h-8 w-8 transition-colors ${u>=ke?"fill-yellow-400 text-yellow-400":"text-muted-foreground hover:text-yellow-400"}`})},ke))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Your Review"}),e.jsx(_r,{placeholder:"What do you love about LevelUp? How has it helped your business?",value:f,onChange:ke=>y(ke.target.value),rows:4})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(W,{onClick:he,disabled:_,className:"bg-yellow-600 hover:bg-yellow-700",children:_?"Submitting...":"Submit & Earn 25 Points"})]})]})})}),e.jsx(fs,{open:!!A,onOpenChange:()=>I(null),children:e.jsxs(ps,{className:"max-w-lg",children:[e.jsxs(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[A==null?void 0:A.name,e.jsxs(Qe,{variant:"secondary",className:"font-bold",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),A==null?void 0:A.points_cost]})]}),(A==null?void 0:A.category)&&e.jsxs(Qe,{variant:"outline",className:"w-fit",children:[A.category.icon&&`${A.category.icon} `,A.category.name]})]}),(A==null?void 0:A.preview_image_url)&&e.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted rounded-lg",children:e.jsx("img",{src:A.preview_image_url,alt:A.name,className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:(A==null?void 0:A.description)||"No description available"}),(A==null?void 0:A.item_type)==="reelflow_credits"&&e.jsxs("p",{className:"text-sm text-violet-600 font-medium",children:["🎬 Grants ",A==null?void 0:A.max_quantity," ReelFlow credits per purchase"]}),(A==null?void 0:A.item_type)!=="reelflow_credits"&&(A==null?void 0:A.max_quantity)!==null&&!me.has((A==null?void 0:A.id)||"")&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[A==null?void 0:A.current_quantity," of ",A==null?void 0:A.max_quantity," remaining"]})]}),e.jsx(gn,{children:A&&A.item_type!=="reelflow_credits"&&me.has(A.id)?e.jsx(W,{className:"w-full",onClick:()=>{A.file_url&&N0e(A.file_url,A.name)},disabled:!A.file_url,children:A.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(Qa,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(Yr,{className:"h-4 w-4 mr-2"}),"Access"]})}):A&&e.jsx(W,{className:"w-full",onClick:()=>{I(null),l(A)},disabled:A.item_type!=="reelflow_credits"&&A.max_quantity!==null&&A.current_quantity===0||ae{t&&ie()},[t==null?void 0:t.id]);const ie=async()=>{if(!t)return;i(!0),S(!1),N(!0);const{data:Ie}=await G.from("point_reward_settings").select("action_key, points").in("action_key",["referral_signup","referral_paid"]);Ie==null||Ie.forEach($e=>{$e.action_key==="referral_signup"&&f($e.points),$e.action_key==="referral_paid"&&_($e.points)});const{data:ye}=await G.from("profiles").select("name").eq("id",t.id).maybeSingle();ye!=null&&ye.name&&A(ye.name);let{data:ct}=await G.from("agent_referral_codes").select("code").eq("user_id",t.id).maybeSingle();if(!ct){const{data:$e}=await G.rpc("generate_agent_referral_code",{_user_id:t.id}),Ye=$e||`agent${t.id.slice(0,6)}`,{data:tt,error:Te}=await G.from("agent_referral_codes").insert({user_id:t.id,code:Ye}).select("code").maybeSingle();!Te&&tt&&(ct=tt)}o((ct==null?void 0:ct.code)??null);const{data:fe}=await G.from("agent_referrals").select("id, referred_user_id, status, signed_up_at, qualified_at, signup_points_awarded, paid_points_awarded").eq("referrer_user_id",t.id).order("signed_up_at",{ascending:!1});if(fe&&fe.length>0){const $e=fe.map(Te=>Te.referred_user_id),{data:Ye}=await G.from("profiles").select("id, name, email").in("id",$e),tt=new Map((Ye==null?void 0:Ye.map(Te=>[Te.id,Te]))??[]);u(fe.map(Te=>({...Te,referred_profile:tt.get(Te.referred_user_id)??null})))}else u([]);i(!1)},ae=k.useMemo(()=>a?`${H3s}/trial?ref=${a}`:"",[a]),oe=d.length,me=d.filter(Ie=>Ie.status==="qualified").length,ve=d.filter(Ie=>Ie.signup_points_awarded).length*p+d.filter(Ie=>Ie.paid_points_awarded).length*y,he=async()=>{ae&&(await navigator.clipboard.writeText(ae),pe.success("Referral link copied!"))},ge=()=>{const Ie=encodeURIComponent("Join me on LevelUp"),ye=encodeURIComponent(`Hi — I've been using LevelUp to grow my real estate business and thought you'd love it too. Sign up using my link and we'll both get a head start: ${ae} Let me know if you have any questions!`);window.location.href=`mailto:?subject=${Ie}&body=${ye}`},je=()=>{const Ie=encodeURIComponent(`Hey! I think you'd love LevelUp for your business — sign up with my link: ${ae}`);window.location.href=`sms:?&body=${Ie}`},qe=async()=>{if(navigator.share&&ae)try{await navigator.share({title:"Join me on LevelUp",text:"I use LevelUp to grow my real estate business — try it with my link:",url:ae})}catch{}else he()},Me=Ie=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(Ie.trim()),ke=Ie=>{const ye=(Ie??O).trim().replace(/,$/,"");if(!ye)return;const ct=ye.split(/[\s,;]+/).filter(Boolean),fe=[...q];let $e=0;for(const Ye of ct){if(!Me(Ye)){pe.error(`Invalid email: ${Ye}`);continue}fe.includes(Ye)||(fe.push(Ye),$e++)}B(fe),$e>0&&V("")},Re=Ie=>B(q.filter(ye=>ye!==Ie)),Ve=()=>{J(`${C?C.split(" ")[0]+" invited you to":"Join me on"} LevelUp`),te("I've been using LevelUp to grow my real estate business and it's been a game changer. I think you'd love it too — sign up with my link and we'll both get a head start."),L(!0)},Ne=Ie=>{const ye=Ie.replace(/&/g,"&").replace(//g,">").replace(/\n/g,"
"),ct=C||"A fellow agent",fe="https://relzejiswnotikjgvjhz.supabase.co/storage/v1/object/public/email-assets/levelup-logo-email.png",$e=ae;return`
LevelUp
You're Invited

${ct} thinks you'd love LevelUp 🎉

${ye}

What you get
  • AI tools built for real estate agents
  • Lead generation, marketing & CRM in one place
  • Branded lead sites, video tools & more
Start Your Free Trial →

Or copy & paste this link:
${$e}

Sent by ${ct} via LevelUp · relevelup.com

`.trim()},Ue=async()=>{if(q.length===0&&(O.trim()&&ke(),q.length===0)){pe.error("Add at least one recipient");return}if(!Y.trim()){pe.error("Subject is required");return}ce(!0);const Ie=Ne(U);let ye=0,ct=0;for(const fe of q)try{const{data:$e,error:Ye}=await G.functions.invoke("gmail-send",{body:{to:fe,subject:Y,body:Ie,source:"referral_invite"}});if(Ye||$e!=null&&$e.error)throw new Error((Ye==null?void 0:Ye.message)||($e==null?void 0:$e.error));ye++}catch($e){console.error("Gmail send failed for",fe,$e),ct++}ce(!1),ye>0?(pe.success(`Invite sent to ${ye} ${ye===1?"person":"people"}`+(ct>0?` (${ct} failed)`:"")),B([]),V(""),L(!1)):pe.error("Failed to send invites")};return!w&&!b?e.jsx(Ds,{title:"Refer & Earn",children:e.jsxs("div",{className:"container max-w-3xl mx-auto p-4 md:p-8",children:[e.jsx(kl,{children:e.jsx("title",{children:"Refer & Earn | LevelUp"})}),e.jsxs(Pe,{className:"border-2 border-dashed",children:[e.jsxs(Dt,{className:"text-center",children:[e.jsx("div",{className:"mx-auto h-14 w-14 rounded-full bg-muted flex items-center justify-center mb-3",children:e.jsx(ad,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx(zt,{children:"Refer & Earn is for active members"}),e.jsx(dr,{children:"Activate your subscription to unlock your personal referral link and start earning points."})]}),e.jsx(Oe,{className:"flex justify-center",children:e.jsx(W,{onClick:()=>s("/subscription"),children:"View Subscription"})})]})]})}):e.jsxs(Ds,{title:"Refer & Earn",children:[e.jsxs("div",{className:"container max-w-5xl mx-auto p-4 md:p-8 space-y-6",children:[e.jsxs(kl,{children:[e.jsx("title",{children:"Refer & Earn | LevelUp"}),e.jsx("meta",{name:"description",content:"Invite peers to LevelUp and earn points for every agent who joins."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hi,{className:"h-7 w-7 text-primary"}),e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Refer & Earn"})]}),e.jsxs("p",{className:"text-muted-foreground",children:["Share LevelUp with peers, mentees, or fellow agents. Earn"," ",e.jsxs("span",{className:"font-semibold text-foreground",children:[p," points"]})," when they sign up and"," ",e.jsxs("span",{className:"font-semibold text-foreground",children:[y," more"]})," when they activate a paid plan."]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx(ir,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:oe}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Friends signed up"})]})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx($n,{className:"h-5 w-5 text-emerald-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:me}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Activated paid plan"})]})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx(Fi,{className:"h-5 w-5 text-amber-500"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:ve.toLocaleString()}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Points earned"})]})]})})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Or,{className:"h-5 w-5 text-primary"}),"Your referral link"]}),e.jsx(dr,{children:"Anyone who signs up through this link is credited to you."})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(De,{readOnly:!0,value:l?"Loading…":ae,className:"font-mono text-sm",onFocus:Ie=>Ie.currentTarget.select()}),e.jsxs(W,{onClick:he,disabled:!ae,children:[e.jsx(Va,{className:"h-4 w-4 mr-2"}),"Copy link"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[r&&e.jsxs(W,{size:"sm",onClick:Ve,disabled:!ae,className:"bg-primary hover:bg-primary/90",children:[e.jsx(_n,{className:"h-4 w-4 mr-2"})," Send via Gmail"]}),e.jsxs(W,{variant:"outline",size:"sm",onClick:ge,disabled:!ae,children:[e.jsx(tr,{className:"h-4 w-4 mr-2"})," Email"]}),e.jsxs(W,{variant:"outline",size:"sm",onClick:je,disabled:!ae,children:[e.jsx(wi,{className:"h-4 w-4 mr-2"})," Text"]}),e.jsxs(W,{variant:"outline",size:"sm",onClick:qe,disabled:!ae,children:[e.jsx(id,{className:"h-4 w-4 mr-2"})," More…"]})]}),!r&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["💡 ",e.jsx("button",{onClick:()=>s("/integrations"),className:"underline hover:text-foreground",children:"Connect Gmail"})," to send branded invite emails directly from your inbox."]}),a&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Your code: ",e.jsx("span",{className:"font-mono font-semibold text-foreground",children:a})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"Your Referrals"}),e.jsx(dr,{children:"Track who joined and when they upgrade."})]}),e.jsx(Oe,{children:l?e.jsx("p",{className:"text-sm text-muted-foreground py-6 text-center",children:"Loading…"}):d.length===0?e.jsxs("div",{className:"text-center py-10 space-y-2",children:[e.jsx(ir,{className:"h-10 w-10 mx-auto text-muted-foreground/50"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No referrals yet. Share your link to get started!"})]}):e.jsx("div",{className:"divide-y",children:d.map(Ie=>{var fe,$e;const ye=((fe=Ie.referred_profile)==null?void 0:fe.name)||(($e=Ie.referred_profile)==null?void 0:$e.email)||"New agent",ct=new Intl.DateTimeFormat("en-US",{timeZone:"America/New_York",month:"short",day:"numeric",year:"numeric"}).format(new Date(Ie.signed_up_at));return e.jsxs("div",{className:"py-3 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium truncate",children:ye}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Joined ",ct]})]}),Ie.status==="qualified"?e.jsxs(Qe,{className:"bg-emerald-100 text-emerald-700 border-emerald-200 hover:bg-emerald-100",children:[e.jsx($n,{className:"h-3 w-3 mr-1"})," Paid · +",p+y," pts"]}):e.jsxs(Qe,{variant:"secondary",children:[e.jsx(nn,{className:"h-3 w-3 mr-1"})," Signed up · +",p," pts"]})]},Ie.id)})})})]}),e.jsx(Pe,{className:"bg-muted/30",children:e.jsxs(Oe,{className:"p-6",children:[e.jsxs("h3",{className:"font-semibold mb-3 flex items-center gap-2",children:[e.jsx(Or,{className:"h-4 w-4 text-primary"})," How it works"]}),e.jsxs("ol",{className:"text-sm text-muted-foreground space-y-2 list-decimal list-inside",children:[e.jsx("li",{children:"Share your unique link with peers, mentees, or other agents."}),e.jsxs("li",{children:["They sign up — you instantly earn ",e.jsxs("strong",{className:"text-foreground",children:[p," points"]}),"."]}),e.jsxs("li",{children:["When they activate a paid plan, you earn another ",e.jsxs("strong",{className:"text-foreground",children:[y," points"]}),"."]}),e.jsxs("li",{children:["Redeem points in the ",e.jsx("a",{href:"/reward-store",className:"text-primary underline",children:"Reward Store"}),"."]})]})]})}),e.jsx(ho,{className:"opacity-0"})]}),e.jsx(fs,{open:I,onOpenChange:L,children:e.jsxs(ps,{className:"sm:max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(_n,{className:"h-5 w-5 text-primary"})," Send referral invites via Gmail"]}),e.jsxs(Ir,{children:["Sending from ",e.jsx("span",{className:"font-medium text-foreground",children:n}),". We'll deliver a branded LevelUp invite with your personal note."]})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Recipients"}),e.jsxs("div",{className:"flex flex-wrap gap-1.5 p-2 border rounded-md min-h-[44px] bg-background",children:[q.map(Ie=>e.jsxs(Qe,{variant:"secondary",className:"gap-1 pr-1",children:[Ie,e.jsx("button",{type:"button",onClick:()=>Re(Ie),className:"hover:bg-muted-foreground/20 rounded-full p-0.5","aria-label":`Remove ${Ie}`,children:e.jsx(kr,{className:"h-3 w-3"})})]},Ie)),e.jsx("input",{type:"email",value:O,onChange:Ie=>V(Ie.target.value),onKeyDown:Ie=>{Ie.key==="Enter"||Ie.key===","||Ie.key===" "?(Ie.preventDefault(),ke()):Ie.key==="Backspace"&&!O&&q.length>0&&B(q.slice(0,-1))},onBlur:()=>O.trim()&&ke(),onPaste:Ie=>{const ye=Ie.clipboardData.getData("text");/[\s,;]/.test(ye)&&(Ie.preventDefault(),ke(ye))},placeholder:q.length===0?"name@example.com, another@example.com":"Add another…",className:"flex-1 min-w-[160px] bg-transparent outline-none text-sm"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Press Enter, comma, or space to add. You can paste multiple emails at once."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"email-subject",children:"Subject"}),e.jsx(De,{id:"email-subject",value:Y,onChange:Ie=>J(Ie.target.value),placeholder:"Subject line"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"personal-note",children:"Your personal note"}),e.jsx(_r,{id:"personal-note",value:U,onChange:Ie=>te(Ie.target.value),rows:4,placeholder:"Write a quick note explaining why they'd love LevelUp…"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Preview"}),e.jsxs("div",{className:"border rounded-md overflow-hidden bg-muted/30",children:[e.jsxs("div",{className:"px-3 py-2 bg-muted/60 border-b text-xs text-muted-foreground flex items-center justify-between",children:[e.jsxs("span",{className:"truncate",children:["From: ",n]}),e.jsxs("span",{className:"truncate ml-2",children:["Subject: ",Y||"(no subject)"]})]}),e.jsx("iframe",{title:"Email preview",srcDoc:Ne(U),className:"w-full h-[420px] bg-white"})]})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>L(!1),disabled:X,children:"Cancel"}),e.jsxs(W,{onClick:Ue,disabled:X,children:[e.jsx(_n,{className:"h-4 w-4 mr-2"}),X?"Sending…":`Send${q.length>0?` to ${q.length}`:""}`]})]})]})})]})}const Dct=()=>{const{user:t}=Us(),s=Qt(),r=gt({queryKey:["smart-presentations",t==null?void 0:t.id],queryFn:async()=>{const{data:u,error:p}=await G.from("smart_presentations").select("*").eq("owner_user_id",t.id).neq("status","archived").order("created_at",{ascending:!1});if(p)throw p;return u||[]},enabled:!!t}),n=gt({queryKey:["smart-presentation-templates",t==null?void 0:t.id],queryFn:async()=>{const{data:u,error:p}=await G.from("smart_presentation_templates").select("*").eq("is_active",!0).order("created_at",{ascending:!0});if(p)throw p;return u||[]},enabled:!!t}),a=Pt({mutationFn:async u=>{const{data:p,error:f}=await G.from("smart_presentations").insert({owner_user_id:t.id,...u}).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]})}}),o=Pt({mutationFn:async({id:u,...p})=>{const{data:f,error:y}=await G.from("smart_presentations").update(p).eq("id",u).select().single();if(y)throw y;return f},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]})}}),l=Pt({mutationFn:async u=>{const{data:p,error:f}=await G.from("smart_presentations").update({status:"published",published_at:new Date().toISOString()}).eq("id",u).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]}),pe.success("Presentation published!")}}),i=Pt({mutationFn:async u=>{const{error:p}=await G.from("smart_presentations").update({status:"archived"}).eq("id",u);if(p)throw p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]}),pe.success("Presentation archived")}}),d=Pt({mutationFn:async u=>{const{error:p}=await G.from("smart_presentation_templates").insert({owner_user_id:t.id,name:u.title+" Template",description:"Created from "+u.title,template_type:"custom",icon:"📄",sections:u.sections,cta_config:{type:u.cta_type,label:u.cta_label},is_system:!1});if(p)throw p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentation-templates"]}),pe.success("Saved as template!")}});return{presentations:r.data||[],templates:n.data||[],isLoading:r.isLoading,templatesLoading:n.isLoading,createPresentation:a,updatePresentation:o,publishPresentation:l,archivePresentation:i,saveAsTemplate:d}},W3s=()=>{const t=wr(),{presentations:s,isLoading:r,archivePresentation:n,saveAsTemplate:a}=Dct(),o=i=>i.status==="draft"?e.jsx(Qe,{variant:"outline",className:"text-xs",children:"Draft"}):i.view_count>1?e.jsx(Qe,{className:"text-xs bg-emerald-100 text-emerald-700 border-emerald-200",children:"Revisited"}):i.view_count===1?e.jsx(Qe,{className:"text-xs bg-blue-100 text-blue-700 border-blue-200",children:"Opened"}):e.jsx(Qe,{variant:"secondary",className:"text-xs",children:"Not Opened"}),l=i=>{const d=`https://presentations.relevelup.com/${i}`;navigator.clipboard.writeText(d),pe.success("Link copied!")};return e.jsx(Ds,{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(W,{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(Ms,{className:"h-20 w-full rounded-lg"},i))}):s.length===0?e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(Pg,{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(W,{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(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(vn,{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 ",vs(new Date(i.created_at),"MMM d, yyyy")]}),i.view_count>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(jn,{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(W,{variant:"outline",size:"sm",onClick:()=>l(i.share_token),children:[e.jsx(Va,{className:"h-3.5 w-3.5 mr-1"}),"Copy Link"]}),i.status==="published"&&e.jsx(W,{variant:"outline",size:"sm",onClick:()=>t(`/mission-control/presentations/${i.id}?edit=true`),children:"Edit"}),e.jsx(W,{variant:"outline",size:"sm",onClick:()=>t(`/mission-control/presentations/${i.id}`),children:i.status==="draft"?"Edit":"View"}),e.jsxs(Hd,{children:[e.jsx(Gd,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(ix,{className:"h-4 w-4"})})}),e.jsxs(Nd,{align:"end",children:[i.status==="published"&&i.share_token&&e.jsxs(_a,{onClick:()=>window.open(`https://presentations.relevelup.com/${i.share_token}`,"_blank"),children:[e.jsx(Yr,{className:"h-4 w-4 mr-2"}),"Preview Link"]}),e.jsxs(_a,{onClick:()=>a.mutate(i),children:[e.jsx(vn,{className:"h-4 w-4 mr-2"}),"Save as Template"]}),e.jsxs(_a,{onClick:()=>n.mutate(i.id),className:"text-destructive",children:[e.jsx(yM,{className:"h-4 w-4 mr-2"}),"Archive"]})]})]})]})]})})]})})},i.id))})]})})},D9e={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."}]},K3s=[{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 Z3s(t){const s=D9e[t];if(s)return s;const r=t.toLowerCase();for(const[n,a]of Object.entries(D9e))if(r.includes(n.toLowerCase())||n.toLowerCase().includes(r))return a;return K3s}function Y3s({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=k.useState(!1),[o,l]=k.useState("script"),[i,d]=k.useState(0),[u,p]=k.useState(0),{canRecord:f}=ait(),y=Mw(),[_,b]=k.useState(""),[N,w]=k.useState(!1),[S,C]=k.useState(!0),[A,I]=k.useState(!1),[L,O]=k.useState(null),V=Z3s(t),q=()=>{l("script"),d(0),p(0),b(""),w(!1),C(!0),I(!1),O(null)},B=X=>{!X&&(o==="uploading"||o==="processing")||(a(X),X||q())},U=X=>{O(X),b(V[X].text),w(!1)},te=()=>{l("record"),C(_.trim().length>0)},Y=()=>{b(""),C(!1),l("record")},J=k.useCallback(async(X,ce)=>{l("uploading");try{const ie=t||"Presentation Video",{videoId:ae,uploadUrl:oe,libraryId:me}=await wE(ie),{apiKey:ve}=await jE(ae),he=new XMLHttpRequest;he.upload.onprogress=ke=>{ke.lengthComputable&&d(ke.loaded/ke.total*100)},await new Promise((ke,Re)=>{he.onload=()=>he.status>=200&&he.status<300?ke():Re(new Error("Upload failed")),he.onerror=()=>Re(new Error("Upload failed")),he.open("PUT",oe),he.setRequestHeader("AccessKey",ve),he.send(X)}),l("processing");let ge=0;const je=Date.now(),qe=9e4;let Me=null;for(;ge<4;){if(await new Promise(Re=>setTimeout(Re,3e3)),Date.now()-je>qe){const Re=X.size/1048576,Ve=`https://iframe.mediadelivery.net/embed/${me}/${ae}?responsive=true`;await y.mutateAsync({bunny_video_id:ae,playback_url:Ve,file_size_mb:Re,title:ie,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(Ve),pe.success("Video saved — still encoding. It will be ready shortly."),l("done"),setTimeout(()=>a(!1),1500);return}const ke=await nw(ae);if(ge=ke.status,p(ke.encodeProgress||0),ge===4)Me={playbackUrl:ke.directPlayUrl,thumbnailUrl:ke.thumbnailUrl,previewUrl:ke.previewUrl||null,duration:ke.length||ce,fileSizeMb:(ke.storageSize||X.size)/(1024*1024)};else if(ge===5||ge===6)throw new Error("Video processing failed")}if(!Me)throw new Error("No video data");await y.mutateAsync({bunny_video_id:ae,contact_id:s||void 0,playback_url:Me.playbackUrl,thumbnail_url:Me.thumbnailUrl,preview_url:Me.previewUrl,duration_seconds:Me.duration,file_size_mb:Me.fileSizeMb,title:ie,status:"ready",touch_type:"presentation"}),r(Me.playbackUrl),pe.success("Video recorded, saved to library & attached!"),l("done"),setTimeout(()=>a(!1),1500)}catch(ie){console.error("Recording upload error:",ie),pe.error("Failed to process video. Please try again."),l("record")}},[t,s,r,y]);return e.jsxs(fs,{open:n,onOpenChange:B,children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Record a video",children:[e.jsx(yn,{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(ks,{children:e.jsxs(_s,{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:V.map((X,ce)=>e.jsxs("button",{onClick:()=>U(ce),className:Ot("text-left p-3 rounded-lg border transition-all hover:bg-accent/50",L===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(vn,{className:"h-3.5 w-3.5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:X.label})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 ml-5.5",children:X.text})]},ce))})]}),_&&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"}),!N&&e.jsxs(W,{variant:"ghost",size:"sm",onClick:()=>w(!0),className:"h-7 text-xs gap-1",children:[e.jsx(ga,{className:"h-3 w-3"}),"Edit"]})]}),N?e.jsx(_r,{value:_,onChange:X=>b(X.target.value),rows:5,placeholder:"Type your script here...",className:"text-sm"}):e.jsx("div",{className:"p-3 rounded-lg bg-muted/50 text-sm text-foreground leading-relaxed",children:_})]}),!_&&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(_r,{value:_,onChange:X=>{b(X.target.value),O(null)},rows:4,placeholder:"Type your own script here...",className:"text-sm"})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(W,{variant:"ghost",size:"sm",onClick:Y,className:"text-muted-foreground",children:"Skip — no teleprompter"}),e.jsx(W,{onClick:te,disabled:!1,children:_.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(Dc,{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."}),_.trim()&&e.jsxs(W,{variant:"ghost",size:"sm",onClick:()=>C(!S),className:"h-7 text-xs gap-1",children:[S?e.jsx(pp,{className:"h-3 w-3"}):e.jsx(jn,{className:"h-3 w-3"}),S?"Hide Script":"Show Script"]})]}),e.jsx(AO,{maxDurationSeconds:600,onRecordingComplete:J,onRecordingStateChange:I,onError:X=>pe.error(X),teleprompterContent:_.trim()?e.jsx(jlt,{text:_,isVisible:S,onToggleVisibility:()=>C(!S),isRecording:A,startCountdown:!1}):void 0}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>l("script"),className:"text-xs text-muted-foreground",children:"← Back to script"})]}):o==="uploading"?e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(us,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(xi,{value:i,className:"h-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground text-center",children:["Uploading... ",Math.round(i),"%"]})]})]}):o==="processing"?e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(us,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(xi,{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(si,{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 X3s({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,d]=k.useState("idle"),[u,p]=k.useState(0),f=k.useRef(null),y=Mw(),{data:_}=Ame(),b=(_==null?void 0:_.total_storage_mb)||0,w=((_==null?void 0:_.max_storage_mb)||1024)-b,S=()=>{l(null),d("idle"),p(0)},C=V=>{!V&&i!=="idle"&&i!=="done"||(a(V),V||S())},A=V=>{var U;const q=(U=V.target.files)==null?void 0:U[0];if(!q)return;if(!q.type.startsWith("video/")){pe.error("Please select a video file");return}const B=q.size/(1024*1024);if(B>500){pe.error("Video file must be less than 500MB");return}if(B>w){pe.error(`Not enough storage. You have ${w.toFixed(1)} MB remaining.`);return}l(q)},I=k.useCallback(async()=>{if(o){d("creating"),p(0);try{const V=t||o.name,{data:q,error:B}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:V,isAgentVideo:!0}});if(B)throw new Error(B.message);const{videoId:U,libraryId:te}=q;d("uploading");const{data:Y,error:J}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:U,isAgentVideo:!0}});if(J)throw new Error(J.message);await new Promise((ie,ae)=>{const oe=new XMLHttpRequest;oe.upload.addEventListener("progress",me=>{me.lengthComputable&&p(Math.round(me.loaded/me.total*100))}),oe.addEventListener("load",()=>oe.status>=200&&oe.status<300?ie():ae(new Error(`Upload failed (${oe.status})`))),oe.addEventListener("error",()=>ae(new Error("Upload failed"))),oe.open("PUT",Y.uploadUrl),oe.setRequestHeader("AccessKey",Y.apiKey),oe.send(o)}),d("processing");const X=o.size/(1024*1024),ce=`https://iframe.mediadelivery.net/embed/${te}/${U}`;await y.mutateAsync({bunny_video_id:U,playback_url:ce,file_size_mb:X,title:V,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(ce),d("done"),pe.success("Video uploaded & attached to section!"),setTimeout(()=>a(!1),1200)}catch(V){console.error("Upload error:",V),pe.error(V instanceof Error?V.message:"Failed to upload video"),d("idle")}}},[o,t,s,r,y]),L=()=>{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:C,children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Upload a video file",children:[e.jsx(Ra,{className:"h-3.5 w-3.5"}),"Upload"]})}),e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsx(ks,{children:e.jsxs(_s,{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(yn,{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(W,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(null),children:e.jsx(kr,{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 V;return(V=f.current)==null?void 0:V.click()},children:[e.jsx(Ra,{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:A,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(us,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:L()})]}),e.jsx(xi,{value:i==="uploading"?u:i==="processing"?100:10})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>C(!1),disabled:O,children:"Cancel"}),e.jsx(W,{onClick:I,disabled:!o||O,children:O?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"}),"Upload & Attach"]})})]})]})]})}const R9e=[{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"}],O9e=()=>{const t=wr(),{id:s}=io(),{user:r}=Us(),{templates:n,templatesLoading:a,createPresentation:o,updatePresentation:l,publishPresentation:i}=Dct(),{isGmailConnected:d,gmailEmail:u}=Om(),[p,f]=k.useState(!1),[y,_]=k.useState("client"),[b,N]=k.useState(!1),[w,S]=k.useState(""),[C,A]=k.useState([]),[I,L]=k.useState(!1),[O,V]=k.useState(null),[q,B]=k.useState(!1),[U,te]=k.useState(""),[Y,J]=k.useState(""),[X,ce]=k.useState(""),[ie,ae]=k.useState("buyer"),[oe,me]=k.useState(""),[ve,he]=k.useState(null),[ge,je]=k.useState(""),[qe,Me]=k.useState([]),[ke,Re]=k.useState("schedule_call"),[Ve,Ne]=k.useState("Schedule a Call"),[Ue,Ie]=k.useState(""),[ye,ct]=k.useState(""),[fe,$e]=k.useState(null),[Ye,tt]=k.useState(s||null),[Te,We]=k.useState(null),[Ke,ot]=k.useState(!1),He=async(Lt,Es)=>{if(!r)return;const fr=5*1024*1024;if(Lt.size>fr){pe.error("Image must be under 5MB");return}if(!Lt.type.startsWith("image/")){pe.error("Please upload an image file");return}$e(Es);try{const Hs=Lt.name.split(".").pop()||"jpg",mr=`${r.id}/${Date.now()}.${Hs}`,{error:an}=await G.storage.from("listing-photos").upload(mr,Lt);if(an)throw an;const{data:{publicUrl:Cr}}=G.storage.from("listing-photos").getPublicUrl(mr);kt(Es,{image_url:Cr}),pe.success("Image uploaded")}catch{pe.error("Failed to upload image")}finally{$e(null)}};k.useEffect(()=>{s&&Je(s)},[s]);const Je=async Lt=>{const{data:Es,error:fr}=await G.from("smart_presentations").select("*").eq("id",Lt).single();if(fr||!Es)return;const Hs=Es;if(N(!0),je(Hs.title),te(Hs.client_name||""),me(Hs.property_address||""),Me(Hs.sections||[]),Re(Hs.cta_type||"schedule_call"),Ne(Hs.cta_label||"Schedule a Call"),Ie(Hs.cta_url||""),ct(Hs.heading||""),We(Hs.share_token),ot(Hs.status==="published"),tt(Hs.id),_("builder"),Hs.contact_id){const{data:mr}=await G.from("innercircle_contacts").select("id, first_name, last_name, email, phone").eq("id",Hs.contact_id).maybeSingle();mr&&(V(mr),J(mr.email||""),ce(mr.phone||""))}};k.useEffect(()=>{if(!r||w.length<1){A([]);return}const Lt=setTimeout(async()=>{L(!0);const{data:Es}=await G.from("innercircle_contacts").select("id, first_name, last_name, email, phone, lead_source").eq("owner_user_id",r.id).or(`first_name.ilike.%${w}%,last_name.ilike.%${w}%,email.ilike.%${w}%`).limit(10);A(Es||[]),L(!1)},300);return()=>clearTimeout(Lt)},[w,r]);const ut=Lt=>{V(Lt),te(`${Lt.first_name} ${Lt.last_name||""}`.trim()),J(Lt.email||""),ce(Lt.phone||""),B(!1)},mt=async()=>{if(!U.trim()){pe.error("Client name is required");return}const Lt=U.trim().split(" "),Es=Lt[0],fr=Lt.slice(1).join(" ")||null,{data:Hs,error:mr}=await G.from("innercircle_contacts").insert({owner_user_id:r.id,first_name:Es,last_name:fr,email:Y||null,phone:X||null,lead_source:"Smart Presentation"}).select().single();if(mr){pe.error("Failed to create client");return}V(Hs),pe.success("Client created & saved to Agent OS"),_("template")},et=Lt=>{he(Lt);const Es=(Lt.sections||[]).map(fr=>({...fr,is_visible:!0,video_url:"",text:""}));if(Me(Es),je(Lt.name+(U?` for ${U}`:"")),Lt.cta_config){const fr=Lt.cta_config;Re(fr.type||"schedule_call"),Ne(fr.label||"Schedule a Call")}_("builder")},Ze=()=>{Me([{title:"Welcome",description:"A personal welcome",type:"video",icon:"👋",is_visible:!0}]),je(U?`Presentation for ${U}`:"New Presentation"),_("builder")},kt=(Lt,Es)=>{Me(fr=>fr.map((Hs,mr)=>mr===Lt?{...Hs,...Es}:Hs))},Ut=Lt=>{kt(Lt,{is_visible:!qe[Lt].is_visible})},Nt=()=>{Me(Lt=>[...Lt,{title:"New Section",description:"",type:"video",icon:"📝",is_visible:!0}])},es=Lt=>{Me(Es=>Es.filter((fr,Hs)=>Hs!==Lt))},ds=async()=>{if(!ge.trim()){pe.error("Title is required");return}try{if(Ye){const Lt=await l.mutateAsync({id:Ye,title:ge,sections:qe,client_name:U,property_address:oe||null,cta_type:ke,cta_label:Ve,cta_url:Ue||null,heading:ye||null});pe.success("Saved")}else{const Lt=await o.mutateAsync({title:ge,contact_id:(O==null?void 0:O.id)||void 0,client_name:U,property_address:oe||void 0,template_id:(ve==null?void 0:ve.id)||void 0,sections:qe,cta_type:ke,cta_label:Ve,cta_url:Ue||void 0,heading:ye||void 0});tt(Lt.id),We(Lt.share_token),pe.success("Presentation created!")}}catch(Lt){console.error("Failed to save presentation:",Lt);const Es=(Lt==null?void 0:Lt.message)||(Lt==null?void 0:Lt.toString())||"Unknown error";pe.error(`Failed to save: ${Es}`)}},js=async()=>{try{await ds();const Lt=Ye;if(Lt){const Es=await i.mutateAsync(Lt);We(Es.share_token),ot(!0),_("share")}}catch(Lt){console.error("Failed to publish presentation:",Lt),pe.error(`Failed to publish: ${(Lt==null?void 0:Lt.message)||"Unknown error"}`)}},lr=Te?`https://presentations.relevelup.com/${Te}`:"";return e.jsx(Ds,{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(W,{variant:"ghost",size:"icon",onClick:()=>t("/mission-control/presentations"),children:e.jsx(Oa,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-serif font-bold text-foreground",children:b?"Edit Presentation":"Create Smart Presentation"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[y==="client"&&"Who is this presentation for?",y==="template"&&"Choose a starting template",y==="builder"&&"Customize your presentation",y==="share"&&"Share with your client"]})]})]}),!b&&e.jsx("div",{className:"flex items-center gap-2",children:["client","template","builder","share"].map((Lt,Es)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:Ot("w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors",y===Lt?"bg-primary text-primary-foreground":Es<["client","template","builder","share"].indexOf(y)?"bg-emerald-100 text-emerald-700":"bg-muted text-muted-foreground"),children:Es<["client","template","builder","share"].indexOf(y)?e.jsx(Zn,{className:"h-4 w-4"}):Es+1}),e.jsx("span",{className:"text-sm font-medium capitalize hidden sm:inline",children:Lt}),Es<3&&e.jsx("div",{className:"w-8 h-px bg-border"})]},Lt))}),y==="client"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("button",{onClick:()=>{V(null),te(""),J(""),ce(""),B(!1),_("template")},className:"w-full group flex items-center justify-between gap-4 rounded-xl border border-dashed border-primary/30 bg-primary/5 hover:bg-primary/10 transition-all p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(_n,{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(Wa,{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(Dt,{className:"pb-3",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(ln,{className:"h-4 w-4 text-muted-foreground"}),"Select Existing Client"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name or email...",value:w,onChange:Lt=>S(Lt.target.value),className:"pl-10"})]}),e.jsxs("div",{className:"space-y-2 max-h-56 overflow-y-auto",children:[I&&e.jsx(Ms,{className:"h-12 w-full"}),C.map(Lt=>e.jsxs("button",{onClick:()=>ut(Lt),className:Ot("w-full text-left p-3 rounded-lg border transition-colors",(O==null?void 0:O.id)===Lt.id?"border-primary bg-primary/5":"border-border hover:border-primary/50"),children:[e.jsxs("p",{className:"font-medium text-sm",children:[Lt.first_name," ",Lt.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Lt.email||Lt.phone||"No contact info"})]},Lt.id)),!w&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"Start typing to search your contacts"}),w&&C.length===0&&!I&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No clients found"})]}),O&&e.jsxs(W,{onClick:()=>_("template"),className:"w-full gap-2",children:["Continue with ",O.first_name,e.jsx(Wa,{className:"h-4 w-4"})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Jo,{className:"h-4 w-4 text-muted-foreground"}),"Add New Client"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx(xe,{className:"text-xs",children:"Name *"}),e.jsx(De,{value:U,onChange:Lt=>{te(Lt.target.value),B(!0),V(null)},placeholder:"Sarah & Mike Johnson"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Email"}),e.jsx(De,{value:Y,onChange:Lt=>J(Lt.target.value),placeholder:"Optional",type:"email"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Phone"}),e.jsx(De,{value:X,onChange:Lt=>ce(Lt.target.value),placeholder:"Optional"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Client Type"}),e.jsxs($s,{value:ie,onValueChange:ae,children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"buyer",children:"Buyer"}),e.jsx(vt,{value:"seller",children:"Seller"}),e.jsx(vt,{value:"recruit",children:"Recruit"}),e.jsx(vt,{value:"other",children:"Other"})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Property Address"}),e.jsx(De,{value:oe,onChange:Lt=>me(Lt.target.value),placeholder:"Optional"})]})]}),q&&U&&e.jsxs(W,{onClick:mt,className:"w-full gap-2",children:["Create Client & Continue",e.jsx(Wa,{className:"h-4 w-4"})]})]})]})]})]}),y==="template"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs(ta,{defaultValue:"system",children:[e.jsxs(Jn,{children:[e.jsx(cs,{value:"mine",children:"My Core Templates"}),e.jsx(cs,{value:"system",children:"LevelUp Smart Templates"}),e.jsx(cs,{value:"blank",children:"+ Start Blank"})]}),e.jsx(Ss,{value:"mine",className:"mt-4",children:a?e.jsx("div",{className:"grid grid-cols-2 gap-4",children:[1,2].map(Lt=>e.jsx(Ms,{className:"h-32"},Lt))}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(Lt=>!Lt.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(Lt=>!Lt.is_system).map(Lt=>e.jsx(F9e,{template:Lt,onSelect:et},Lt.id))})}),e.jsx(Ss,{value:"system",className:"mt-4",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(Lt=>Lt.is_system).map(Lt=>e.jsx(F9e,{template:Lt,onSelect:et},Lt.id))})}),e.jsx(Ss,{value:"blank",className:"mt-4",children:e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"Start with a blank canvas and add your own sections."}),e.jsx(W,{onClick:Ze,children:"Start from Scratch"})]})})})]}),e.jsxs(W,{variant:"outline",onClick:()=>_("client"),className:"gap-2",children:[e.jsx(Oa,{className:"h-4 w-4"}),"Back"]})]}),y==="builder"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Presentation Title"}),e.jsx(De,{value:ge,onChange:Lt=>je(Lt.target.value)})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Page Heading"}),e.jsx(De,{value:ye,onChange:Lt=>ct(Lt.target.value),placeholder:U?`Welcome, ${U}!`:"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(xe,{children:"Client Name"}),e.jsx(De,{value:U,onChange:Lt=>te(Lt.target.value)})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Property Address"}),e.jsx(De,{value:oe,onChange:Lt=>me(Lt.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(W,{variant:"outline",size:"sm",onClick:Nt,children:"+ Add Section"})]}),e.jsx("div",{className:"space-y-3",children:qe.map((Lt,Es)=>e.jsx(Pe,{className:Ot(!Lt.is_visible&&"opacity-50"),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1 pt-1",children:[e.jsx(mu,{className:"h-4 w-4 text-muted-foreground cursor-grab"}),e.jsx("span",{className:"text-lg",children:Lt.icon})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(De,{value:Lt.title,onChange:fr=>kt(Es,{title:fr.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(W,{variant:"ghost",size:"icon",onClick:()=>Ut(Es),children:Lt.is_visible?e.jsx(jn,{className:"h-4 w-4"}):e.jsx(pp,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"icon",onClick:()=>es(Es),className:"text-destructive hover:text-destructive",children:e.jsx(vr,{className:"h-4 w-4"})})]})]}),e.jsx(De,{value:Lt.description||"",onChange:fr=>kt(Es,{description:fr.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(xe,{className:"text-xs",children:"Video URL"}),e.jsx(De,{value:Lt.video_url||"",onChange:fr=>kt(Es,{video_url:fr.target.value}),placeholder:"Paste a YouTube or video URL...",className:"text-sm"})]}),e.jsx(Y3s,{sectionTitle:Lt.title,contactId:O==null?void 0:O.id,onVideoReady:fr=>kt(Es,{video_url:fr})}),e.jsx(X3s,{sectionTitle:Lt.title,contactId:O==null?void 0:O.id,onVideoReady:fr=>kt(Es,{video_url:fr})}),e.jsx(zCe,{userId:r==null?void 0:r.id,onSelect:fr=>kt(Es,{video_url:fr})})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Image (optional — shown if no video is set)"}),Lt.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:Lt.image_url,alt:"",className:"w-full max-h-40 object-cover"}),e.jsx(W,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>kt(Es,{image_url:""}),children:e.jsx(kr,{className:"h-3.5 w-3.5"})})]}):e.jsxs("label",{className:"mt-1 flex items-center gap-2 cursor-pointer rounded-lg border border-dashed border-border hover:border-primary/50 p-3 transition-colors",children:[fe===Es?e.jsx(us,{className:"h-4 w-4 animate-spin text-muted-foreground"}):e.jsx(Xv,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:fe===Es?"Uploading...":"Click to upload an image"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",disabled:fe===Es,onChange:fr=>{var mr;const Hs=(mr=fr.target.files)==null?void 0:mr[0];Hs&&He(Hs,Es),fr.target.value=""}})]})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Text (optional)"}),e.jsx(Wg,{content:Lt.text||"",onChange:fr=>kt(Es,{text:fr}),placeholder:"Add supporting text...",minHeight:"80px",compact:!0})]})]})]})})},Es))})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Call to Action"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"CTA Type"}),e.jsxs($s,{value:ke,onValueChange:Lt=>{Re(Lt);const Es=R9e.find(fr=>fr.value===Lt);Es&&Ne(Es.label)},children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsx(Bs,{children:R9e.map(Lt=>e.jsx(vt,{value:Lt.value,children:Lt.label},Lt.value))})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Button Label"}),e.jsx(De,{value:Ve,onChange:Lt=>Ne(Lt.target.value)})]}),e.jsxs("div",{children:[e.jsxs(xe,{children:["Link URL ",e.jsx("span",{className:"text-muted-foreground",children:"(optional — leave blank to show a lead capture form instead)"})]}),e.jsx(De,{value:Ue,onChange:Lt=>Ie(Lt.target.value),placeholder:"https://calendly.com/..."}),!Ue&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Without a URL, clients will see a contact form — their info gets added to your contacts and you'll receive an email notification."})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[!b&&e.jsxs(W,{variant:"outline",onClick:()=>_("template"),className:"gap-2",children:[e.jsx(Oa,{className:"h-4 w-4"}),"Back"]}),e.jsxs("div",{className:"flex gap-3 ml-auto",children:[e.jsx(W,{variant:"outline",onClick:ds,disabled:o.isPending||l.isPending,children:"Save Draft"}),e.jsxs(W,{onClick:js,disabled:i.isPending,className:"gap-2",children:[e.jsx(_n,{className:"h-4 w-4"}),Ke?"Update & Reshare":"Publish & Share"]})]})]})]}),y==="share"&&Te&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex flex-col items-center py-12 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-emerald-100 flex items-center justify-center mb-4",children:e.jsx(Zn,{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 ",U||"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(De,{value:lr,readOnly:!0,className:"text-center font-mono text-sm"}),e.jsx(W,{onClick:()=>{navigator.clipboard.writeText(lr),pe.success("Link copied!")},children:e.jsx(Va,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex gap-3 mt-6",children:[e.jsxs(W,{variant:"outline",className:"gap-2",onClick:()=>{const Lt=`Hi ${U||""}! I put together something for you — check it out: ${lr}`;navigator.clipboard.writeText(Lt),pe.success("Message copied!")},children:[e.jsx(wi,{className:"h-4 w-4"}),"Copy Text Message"]}),e.jsxs(W,{variant:"outline",className:"gap-2",onClick:()=>{d?f(!0):window.open(`mailto:${Y||""}?subject=${encodeURIComponent(ge)}&body=${encodeURIComponent(`Hi ${(O==null?void 0:O.first_name)||(U==null?void 0:U.split(" ")[0])||""}, I put together a personalized presentation for you: ${lr} Looking forward to connecting!`)}`)},children:[e.jsx(tr,{className:"h-4 w-4"}),"Send Email"]})]}),d&&e.jsx(E1,{open:p,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:(U==null?void 0:U.split(" ")[0])||"",last_name:(U==null?void 0:U.split(" ").slice(1).join(" "))||"",email:Y}:void 0,defaultSubject:ge,defaultBody:`Hi ${(O==null?void 0:O.first_name)||(U==null?void 0:U.split(" ")[0])||""}, I put together a personalized presentation for you: ${lr} Looking forward to connecting!`,gmailEmail:u})]})}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs(W,{variant:"outline",onClick:()=>_("builder"),children:[e.jsx(Oa,{className:"h-4 w-4 mr-2"}),"Edit Presentation"]}),e.jsx(W,{onClick:()=>t("/mission-control/presentations"),children:"Done"})]})]})]})})},F9e=({template:t,onSelect:s})=>e.jsx(Pe,{className:"hover:shadow-sm transition-shadow",children:e.jsxs(Oe,{className:"p-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-2xl",children:t.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold",children:t.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:t.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx(Qe,{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(W,{className:"w-full mt-4",size:"sm",onClick:()=>s(t),children:"Use Template"})]})}),Q3s=()=>{var N;const{shareToken:t}=io(),[s,r]=k.useState(null),[n,a]=k.useState(!0),[o,l]=k.useState(0),[i,d]=k.useState(!1);k.useEffect(()=>(document.body.classList.add("presentation-page"),()=>{document.body.classList.remove("presentation-page")}),[]),k.useEffect(()=>{t&&u()},[t]);const u=async()=>{const{data:w,error:S}=await G.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(S||!w){d(!0),a(!1);return}const{data:C}=await G.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",w.owner_user_id).single();let A;if(C!=null&&C.brokerage_id){const{data:L}=await G.from("brokerages").select("name").eq("id",C.brokerage_id).single();A=(L==null?void 0:L.name)||void 0}let I=null;if(w.contact_id){const{data:L}=await G.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",w.contact_id).single();I=L}r({...w,owner_name:C==null?void 0:C.name,owner_email:C==null?void 0:C.email,owner_phone:C==null?void 0:C.phone,owner_avatar:C==null?void 0:C.avatar_url,owner_title:(C==null?void 0:C.title)||void 0,brokerage_name:A,contact_name:I?[I.first_name,I.last_name].filter(Boolean).join(" "):void 0,contact_email:(I==null?void 0:I.email)||void 0,contact_phone:(I==null?void 0:I.phone)||void 0}),a(!1);try{await G.rpc("log_presentation_view",{p_presentation_id:w.id,p_section_index:0,p_cta_clicked:!1,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch{}},p=async()=>{if(s){try{await G.rpc("log_presentation_view",{p_presentation_id:s.id,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}s.cta_url&&window.open(s.cta_url,"_blank")}};if(n)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"space-y-4 w-full max-w-2xl px-4",children:[e.jsx(Ms,{className:"h-12 w-3/4 mx-auto"}),e.jsx(Ms,{className:"h-64 w-full"}),e.jsx(Ms,{className:"h-8 w-1/2 mx-auto"})]})});if(i||!s)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Presentation Not Found"}),e.jsx("p",{className:"text-gray-500",children:"This presentation may have been removed or is no longer available."})]})});const f=s.sections.filter(w=>w.is_visible!==!1),y=f[o],_=w=>{const S=w.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(S)return`https://www.youtube.com/embed/${S[1]}?rel=0`;if(w.includes("iframe.mediadelivery.net/play/")){const I=w.replace("/play/","/embed/"),L=I.includes("?")?"&":"?";return`${I}${L}responsive=true`}if(w.includes("iframe.mediadelivery.net")){if(w.match(/\/embed\/(\d+)\/([a-f0-9-]+)/)){const L=w.includes("?")?"&":"?";return`${w}${L}responsive=true`}return""}const C=w.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(C)return`https://www.loom.com/embed/${C[1]}`;const A=w.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return A?`https://iframe.mediadelivery.net/embed/${A[1]}/${A[2]}?responsive=true`:w},b=!!((N=s.cta_url)!=null&&N.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:[y!=null&&y.video_url&&_(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:_(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:f.map((w,S)=>e.jsx("button",{onClick:()=>l(S),className:Ot("w-full text-left p-4 rounded-xl border transition-all",o===S?"border-blue-500 bg-blue-50 shadow-sm":"border-gray-200 bg-white hover:border-blue-200 hover:bg-blue-50/50"),children: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(S+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})]})]})},S))})]}),e.jsxs("div",{className:"mt-12 max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6 text-center",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-20 w-20 rounded-full object-cover mx-auto mb-3 border-2 border-gray-100"}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-sm text-gray-500",children:s.owner_title}),s.brokerage_name&&e.jsx("p",{className:"text-sm text-gray-500",children:s.brokerage_name}),e.jsxs("div",{className:"mt-3 flex flex-col items-center gap-1 text-sm text-gray-600",children:[s.owner_phone&&e.jsx("a",{href:`tel:${s.owner_phone}`,className:"hover:text-blue-600 transition-colors",children:s.owner_phone}),s.owner_email&&e.jsx("a",{href:`mailto:${s.owner_email}`,className:"hover:text-blue-600 transition-colors",children:s.owner_email})]})]}),s.cta_label&&e.jsxs("div",{className:"text-center mt-8 py-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Ready to Get Started?"}),b?e.jsxs(W,{size:"lg",onClick:p,className:"text-lg px-8 py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",children:[s.cta_label,e.jsx(Yr,{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(jWe,{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 J3s({openHouseId:t,enableSurvey:s,onToggleSurvey:r}){const{data:n,isLoading:a}=r4t(t),o=o4t(),l=l4t(),i=c4t(),d=d4t(),[u,p]=k.useState(""),[f,y]=k.useState("rating"),_=async S=>{r(S),S&&(!n||n.length===0)&&await d.mutateAsync(t)},b=async()=>{if(!u.trim())return;const S=(n==null?void 0:n.reduce((C,A)=>Math.max(C,A.sort_order),0))??0;await o.mutateAsync({open_house_id:t,question_type:f,question_text:u.trim(),sort_order:S+1}),p("")},N=async S=>{await l.mutateAsync({id:S.id,open_house_id:t,is_active:!S.is_active})},w=async S=>{await i.mutateAsync({id:S.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(xe,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Nb,{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(Ar,{checked:s,onCheckedChange:_})]}),s&&e.jsx("div",{className:"space-y-3 pt-2 border-t border-border",children:a?e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(us,{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(S=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border border-border bg-muted/20",children:[e.jsx(mu,{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:S.question_text}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:S.question_type.replace("_"," ")})]}),e.jsx(Ar,{checked:S.is_active,onCheckedChange:()=>N(S),className:"scale-75"}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>w(S),children:e.jsx(vr,{className:"h-3.5 w-3.5"})})]},S.id))}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(xe,{className:"text-xs text-muted-foreground",children:"Add Question"}),e.jsx(De,{value:u,onChange:S=>p(S.target.value),placeholder:"e.g. How did you hear about this listing?",className:"mt-1 h-9 text-sm",onKeyDown:S=>S.key==="Enter"&&b()})]}),e.jsxs($s,{value:f,onValueChange:y,children:[e.jsx(zs,{className:"w-28 h-9 text-xs",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"rating",children:"Rating"}),e.jsx(vt,{value:"open_text",children:"Text"})]})]}),e.jsx(W,{size:"sm",variant:"outline",onClick:b,disabled:!u.trim()||o.isPending,className:"h-9",children:e.jsx(qs,{className:"h-3.5 w-3.5"})})]})]})})]})}function e5s({open:t,onOpenChange:s,openHouse:r}){const n=kWe(),{user:a}=Us(),o=k.useRef(null),l=k.useRef(null),[i,d]=k.useState(r.auto_forward_to_card??!1),[u,p]=k.useState(r.disclosure_pdf_url??""),[f,y]=k.useState(r.enable_survey??!1),[_,b]=k.useState(r.ask_visitor_intent??!0),[N,w]=k.useState(r.photo_url??""),[S,C]=k.useState(!1),[A,I]=k.useState(!1),[L,O]=k.useState(!1),V=async Y=>{var oe;const J=(oe=Y.target.files)==null?void 0:oe[0];if(!J||!a)return;if(J.size>10*1024*1024){fn({title:"Image must be under 10MB",variant:"destructive"});return}if(!J.type.startsWith("image/")){fn({title:"Please upload an image file",variant:"destructive"});return}I(!0);const X=J.name.split(".").pop()||"jpg",ce=`${a.id}/${r.id}-${Date.now()}.${X}`,{error:ie}=await G.storage.from("open-house-photos").upload(ce,J,{upsert:!0});if(ie){fn({title:"Upload failed",description:ie.message,variant:"destructive"}),I(!1);return}const{data:ae}=G.storage.from("open-house-photos").getPublicUrl(ce);w(ae.publicUrl),I(!1),fn({title:"Photo updated!"})},q=()=>{w(""),l.current&&(l.current.value="")},B=async Y=>{var ae;const J=(ae=Y.target.files)==null?void 0:ae[0];if(!J||!a)return;if(J.size>20*1024*1024){fn({title:"File must be under 20MB",variant:"destructive"});return}if(J.type!=="application/pdf"){fn({title:"Only PDF files are accepted",variant:"destructive"});return}C(!0);const X=`${a.id}/disclosures/${r.id}-${Date.now()}.pdf`,{error:ce}=await G.storage.from("open-house-photos").upload(X,J,{upsert:!0});if(ce){fn({title:"Upload failed",description:ce.message,variant:"destructive"}),C(!1);return}const{data:ie}=G.storage.from("open-house-photos").getPublicUrl(X);p(ie.publicUrl),C(!1),fn({title:"PDF uploaded!"})},U=()=>{p(""),o.current&&(o.current.value="")},te=async()=>{O(!0);try{await n.mutateAsync({id:r.id,auto_forward_to_card:i,disclosure_pdf_url:u||null,enable_survey:f,ask_visitor_intent:_,photo_url:N||null}),fn({title:"Settings saved!"}),s(!1)}catch{fn({title:"Failed to save",variant:"destructive"})}finally{O(!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(ks,{children:[e.jsx(_s,{children:"Guest Book Settings"}),e.jsx(Ir,{className:"truncate",children:r.property_address})]}),e.jsxs("div",{className:"space-y-6 pt-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{className:"text-sm font-medium",children:"Property Photo"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Shown on the sign-in screen and printable QR sheet"}),e.jsx("input",{ref:l,type:"file",accept:"image/*",onChange:V,className:"hidden"}),N?e.jsxs("div",{className:"relative rounded-lg overflow-hidden border border-border",children:[e.jsx("img",{src:N,alt:"Property",className:"w-full h-40 object-cover"}),e.jsxs("div",{className:"absolute top-2 right-2 flex gap-2",children:[e.jsxs(W,{variant:"secondary",size:"sm",className:"h-8",onClick:()=>{var Y;return(Y=l.current)==null?void 0:Y.click()},disabled:A,children:[A?e.jsx(us,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ra,{className:"h-3.5 w-3.5 mr-1"}),A?"":"Replace"]}),e.jsx(W,{variant:"secondary",size:"icon",className:"h-8 w-8",onClick:q,children:e.jsx(kr,{className:"h-4 w-4"})})]})]}):e.jsx("button",{type:"button",onClick:()=>{var Y;return(Y=l.current)==null?void 0:Y.click()},disabled:A,className:"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:A?e.jsx(us,{className:"h-5 w-5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(qo,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Upload property photo (max 10MB)"})]})})]}),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(xe,{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(Ar,{checked:i,onCheckedChange:d})]})}),!i&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{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:B,className:"hidden"}),u?e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border bg-muted/30",children:[e.jsx(vn,{className:"h-5 w-5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm truncate flex-1",children:"Disclosure PDF uploaded"}),e.jsx(W,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:U,children:e.jsx(kr,{className:"h-4 w-4"})})]}):e.jsx("button",{type:"button",onClick:()=>{var Y;return(Y=o.current)==null?void 0:Y.click()},disabled:S,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:S?e.jsx(us,{className:"h-5 w-5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Ra,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Upload PDF (max 20MB)"})]})})]}),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(xe,{className:"text-sm font-medium",children:'Ask "What brings you here?"'}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show the buying / selling / browsing question after sign-in. Turn off to let visitors check in without picking an option."})]}),e.jsx(Ar,{checked:_,onCheckedChange:b})]})}),e.jsx(J3s,{openHouseId:r.id,enableSurvey:f,onToggleSurvey:y}),e.jsx(W,{onClick:te,disabled:L,className:"w-full",children:L?"Saving...":"Save Settings"})]})]})})}const Rct={5:"Excellent",4:"Good",3:"Neutral",2:"Bad",1:"Very Bad"};function t5s({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:Rct[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 s5s({openHouseId:t}){const{data:s,isLoading:r}=i4t(t),{data:n}=NWe(t),a=k.useMemo(()=>{const f={};return n==null||n.forEach(y=>{f[y.id]=y}),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"),d=o.filter(f=>f.question_type!=="rating"),u=[...new Set(l.map(f=>f.visitor_id))],p=u.length;return p===0?e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Nb,{className:"h-4 w-4"}),"Survey Results"]})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No survey responses yet."})})]}):e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Nb,{className:"h-4 w-4"}),"Survey Results",e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-auto",children:[p," respondent",p!==1?"s":""]})]})}),e.jsx(Oe,{children:e.jsxs(ta,{defaultValue:"summary",children:[e.jsxs(Jn,{className:"mb-4",children:[e.jsxs(cs,{value:"summary",className:"text-xs gap-1",children:[e.jsx(so,{className:"h-3.5 w-3.5"})," Summary"]}),e.jsxs(cs,{value:"individual",className:"text-xs gap-1",children:[e.jsx(Ai,{className:"h-3.5 w-3.5"})," Per Visitor"]})]}),e.jsxs(Ss,{value:"summary",className:"space-y-6",children:[i.map(f=>e.jsx(t5s,{question:f,responses:l},f.id)),d.map(f=>{const y=l.filter(_=>_.question_id===f.id&&_.text_value);return y.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:y.map(_=>{const b=a[_.visitor_id];return e.jsxs("div",{className:"text-sm p-2 bg-muted/30 rounded-lg",children:[e.jsxs("span",{className:"text-muted-foreground text-xs",children:[b?`${b.first_name} ${b.last_name||""}`.trim():"Visitor",":"]}),e.jsx("p",{className:"mt-0.5",children:_.text_value})]},_.id)})})]},f.id)})]}),e.jsx(Ss,{value:"individual",className:"space-y-4",children:u.map(f=>{const y=a[f],_=l.filter(b=>b.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:[y?`${y.first_name} ${y.last_name||""}`.trim():"Unknown Visitor",(y==null?void 0:y.email)&&e.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:y.email})]}),e.jsx("div",{className:"space-y-1",children:_.map(b=>{const N=o.find(w=>w.id===b.question_id);return N?e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:N.question_text}),e.jsx("span",{className:"font-medium",children:b.rating_value!=null?Rct[b.rating_value]||b.rating_value:b.text_value})]},b.id):null})})]},f)})})]})})]})}const n2e="guestbook.relevelup.com";function r5s(){const{data:t,isLoading:s}=Jkt(),r=e4t(),n=kWe(),a=t4t(),[o,l]=k.useState(!1),[i,d]=k.useState(null),{user:u}=Us(),p=ya(),[f,y]=k.useState(null),[_,b]=k.useState(null),[N,w]=k.useState(!1),S=k.useRef(null),[C,A]=k.useState({property_address:"",city:"",state:"",zip:"",event_date:vs(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below.",event_type:"property"}),I=q=>{var U;const B=(U=q.target.files)==null?void 0:U[0];if(B){if(B.size>5*1024*1024){fn({title:"Photo must be under 5MB",variant:"destructive"});return}y(B),b(URL.createObjectURL(B))}},L=()=>{y(null),b(null),S.current&&(S.current.value="")},O=async()=>{if(!C.property_address){fn({title:C.event_type==="community"?"Event name is required":"Address is required",variant:"destructive"});return}let q;if(f&&u){w(!0);const B=f.name.split(".").pop(),U=`${p}/${Date.now()}.${B}`,{error:te}=await G.storage.from("open-house-photos").upload(U,f,{upsert:!0});if(te){fn({title:"Photo upload failed",description:te.message,variant:"destructive"}),w(!1);return}const{data:Y}=G.storage.from("open-house-photos").getPublicUrl(U);q=Y.publicUrl,w(!1)}await r.mutateAsync({...C,photo_url:q}),l(!1),A({property_address:"",city:"",state:"",zip:"",event_date:vs(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below.",event_type:"property"}),L()},V=q=>{navigator.clipboard.writeText(`https://${n2e}/${q}`),fn({title:"Link copied!"})};return e.jsxs(Ds,{title:"Guest Book",children:[e.jsx(kl,{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(mi,{asChild:!0,children:e.jsxs(W,{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(ks,{children:[e.jsx(_s,{children:"Create Open House"}),e.jsx(Ir,{children:"Set up a new open house sign-in page"})]}),e.jsxs("div",{className:"space-y-4 pt-2 overflow-y-auto flex-1 pr-1",children:[e.jsx("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border bg-muted/30",children:e.jsxs("div",{className:"flex gap-1 flex-1",children:[e.jsx("button",{type:"button",onClick:()=>A(q=>({...q,event_type:"property"})),className:`flex-1 px-3 py-2 rounded-md text-sm font-medium transition-colors ${C.event_type==="property"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Single Property"}),e.jsx("button",{type:"button",onClick:()=>A(q=>({...q,event_type:"community"})),className:`flex-1 px-3 py-2 rounded-md text-sm font-medium transition-colors ${C.event_type==="community"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Community Event"})]})}),e.jsxs("div",{children:[e.jsx(xe,{children:C.event_type==="community"?"Event Name *":"Property Address *"}),e.jsx(De,{value:C.property_address,onChange:q=>A(B=>({...B,property_address:q.target.value})),placeholder:C.event_type==="community"?"Spring Festival at Riverside Estates":"123 Main Street"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"City"}),e.jsx(De,{value:C.city,onChange:q=>A(B=>({...B,city:q.target.value})),placeholder:"Austin"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"State"}),e.jsx(De,{value:C.state,onChange:q=>A(B=>({...B,state:q.target.value})),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"ZIP"}),e.jsx(De,{value:C.zip,onChange:q=>A(B=>({...B,zip:q.target.value})),placeholder:"78701"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Date"}),e.jsx(De,{type:"date",value:C.event_date,onChange:q=>A(B=>({...B,event_date:q.target.value}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Start Time"}),e.jsx(De,{type:"time",value:C.start_time,onChange:q=>A(B=>({...B,start_time:q.target.value}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"End Time"}),e.jsx(De,{type:"time",value:C.end_time,onChange:q=>A(B=>({...B,end_time:q.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Welcome Message"}),e.jsx(_r,{value:C.agent_greeting,onChange:q=>A(B=>({...B,agent_greeting:q.target.value})),placeholder:"Welcome! Please sign in below."})]}),e.jsxs("div",{children:[e.jsx(xe,{children:C.event_type==="community"?"Event Photo":"Property Photo"}),e.jsx("input",{ref:S,type:"file",accept:"image/*",onChange:I,className:"hidden"}),_?e.jsxs("div",{className:"relative mt-1 rounded-xl overflow-hidden border border-border",children:[e.jsx("img",{src:_,alt:"Property preview",className:"w-full h-40 object-cover"}),e.jsx("button",{type:"button",onClick:L,className:"absolute top-2 right-2 bg-black/60 hover:bg-black/80 text-white rounded-full p-1 transition-colors",children:e.jsx(kr,{className:"h-4 w-4"})})]}):e.jsxs("button",{type:"button",onClick:()=>{var q;return(q=S.current)==null?void 0:q.click()},className:"mt-1 w-full h-32 rounded-xl border-2 border-dashed border-muted-foreground/25 hover:border-muted-foreground/50 flex flex-col items-center justify-center gap-2 text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(Xv,{className:"h-6 w-6"}),e.jsxs("span",{className:"text-sm",children:["Add a ",C.event_type==="community"?"cover":"property"," photo"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Max 5MB"})]})]}),e.jsx(W,{onClick:O,disabled:r.isPending||N,className:"w-full",children:N?"Uploading photo...":r.isPending?"Creating...":C.event_type==="community"?"Create Community Event":"Create Open House"})]})]})]})]}),s?e.jsx("div",{className:"grid gap-4",children:[1,2].map(q=>e.jsx(Pe,{className:"animate-pulse",children:e.jsxs(Dt,{children:[e.jsx("div",{className:"h-5 bg-muted rounded w-48"}),e.jsx("div",{className:"h-4 bg-muted rounded w-32 mt-2"})]})},q))}):t!=null&&t.length?e.jsx("div",{className:"space-y-4",children:t.map(q=>e.jsx(n5s,{openHouse:q,isExpanded:i===q.id,onToggle:()=>d(i===q.id?null:q.id),onCopyLink:()=>V(q.slug||""),onToggleActive:()=>n.mutate({id:q.id,is_active:!q.is_active}),onDelete:()=>a.mutate(q.id)},q.id))}):e.jsx(Pe,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(Jy,{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(W,{onClick:()=>l(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create Your First Open House"]})]})})]})]})}function n5s({openHouse:t,isExpanded:s,onToggle:r,onCopyLink:n,onToggleActive:a,onDelete:o}){const{data:l}=NWe(s?t.id:void 0),{data:i}=gt({queryKey:["agent-profile-flyer",t.agent_id],queryFn:async()=>{const{data:L,error:O}=await G.from("profiles").select("name, avatar_url, phone, title, brokerages:brokerage_id(name)").eq("id",t.agent_id).single();if(O)throw O;const V=L.brokerages;return{...L,brokerage_name:(V==null?void 0:V.name)||null}},enabled:!!t.agent_id}),[d,u]=k.useState(!1),[p,f]=k.useState(!1),[y,_]=k.useState(!1),b=k.useRef(null),N=`https://${n2e}/${t.slug}`,w=L=>{if(!L)return"";const[O,V]=L.split(":"),q=parseInt(O),B=q>=12?"PM":"AM";return`${q>12?q-12:q||12}:${V} ${B}`},S=()=>{if(!(l!=null&&l.length))return;const L=["First Name","Last Name","Email","Phone","Intent","Wants Market Updates","Message","Signed In"],O=l.map(te=>[te.first_name,te.last_name||"",te.email||"",te.phone||"",te.visitor_intent||"",te.wants_market_updates?"Yes":"No",(te.message||"").replace(/"/g,'""'),vs(new Date(te.created_at),"MM/dd/yyyy h:mm a")]),V=[L,...O].map(te=>te.map(Y=>`"${Y}"`).join(",")).join(` `),q=new Blob([V],{type:"text/csv"}),B=URL.createObjectURL(q),U=document.createElement("a");U.href=B,U.download=`${t.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-visitors.csv`,U.click(),URL.revokeObjectURL(B)},C=k.useCallback(()=>{if(!b.current)return;const L=b.current.querySelector("svg");if(!L)return;const O=new XMLSerializer().serializeToString(L),V=document.createElement("canvas");V.width=1024,V.height=1024;const q=V.getContext("2d"),B=new Image;B.onload=()=>{q==null||q.drawImage(B,0,0,1024,1024);const U=document.createElement("a");U.download=`${t.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-qr.png`,U.href=V.toDataURL("image/png"),U.click()},B.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(O)))},[t.property_address]),A=k.useCallback(()=>{var ye;if(!b.current)return;const L=b.current.querySelector("svg");if(!L)return;const O=new XMLSerializer().serializeToString(L),V="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(O))),q=vs(new Date(t.event_date+"T00:00:00"),"EEEE, MMMM d, yyyy"),B=t.start_time?`${w(t.start_time)}${t.end_time?" – "+w(t.end_time):""}`:"",U=[t.city,t.state].filter(Boolean).join(", "),te=t.agent_greeting||"Welcome! Please sign in below.",Y=!!t.photo_url,J=!!i,X=Y||J,ce=Y&&J,ie=ce?"0.35in 0.75in 0.3in":"0.55in 0.75in 0.45in",ae=ce?"28px":"34px",oe=ce?"0.2in 0.75in":X?"0.3in 0.75in":"0.4in 0.75in",me=X?"0.15in":"0.3in",ve=X?"0.15in":"0.3in",he=ce?"14px 36px":"22px 44px",ge=ce?"20px":"24px",je=X?"0.2in":"0.35in",qe=ce?"1.8in":"2.4in",Me=X?"0.15in":"0.3in",ke=ce?"140px":X?"160px":"200px",Re=ce?"16px":"24px",Ve=ce?"10px 20px":"16px 28px",Ne=ce?"44px":"56px",Ue="0.15in",Ie=window.open("","_blank");Ie&&(Ie.document.write(` Open House – ${t.property_address}
${t.event_type==="community"?"Community Event":"Open House"}
${t.property_address}
${U?`
${U}${t.zip?" "+t.zip:""}
`:""}
Date
${q}
${B?`
Time
${B}
`:""}
${te}
${i?`
${i.avatar_url?`${i.name}`:`
${((ye=i.name)==null?void 0:ye.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
`),Ie.document.close(),setTimeout(()=>{Ie.focus(),Ie.print()},500))},[t,N,i]),I=async()=>{_(!0);try{const{error:L}=await G.functions.invoke("guestbook-email-link",{body:{openHouseId:t.id}});if(L)throw L;fn({title:"Email sent!",description:"Check your inbox for the guest book link."})}catch(L){fn({title:"Failed to send",description:L.message,variant:"destructive"})}finally{_(!1)}};return e.jsxs(Pe,{className:`transition-all ${t.is_active?"border-primary/30":"opacity-75"}`,children:[e.jsx(Dt,{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(zt,{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(Qe,{variant:t.is_active?"default":"secondary",className:"shrink-0 text-[11px]",children:t.is_active?"Active":"Inactive"}),t.agent_name&&e.jsxs(Qe,{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(Ai,{className:"h-3 w-3"}),t.agent_name]}),t.event_type==="community"&&e.jsxs(Qe,{variant:"outline",className:"shrink-0 gap-1 text-[11px]",children:[e.jsx(pa,{className:"h-3 w-3"}),"Community"]})]})]}),e.jsx(W,{variant:"ghost",size:"icon",onClick:r,className:"shrink-0 -mr-2 -mt-1",children:s?e.jsx(af,{className:"h-4 w-4"}):e.jsx(Bi,{className:"h-4 w-4"})})]}),e.jsxs(dr,{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(Ia,{className:"h-3 w-3"}),t.city,t.state?`, ${t.state}`:""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(cn,{className:"h-3 w-3"}),vs(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(nn,{className:"h-3 w-3"}),w(t.start_time),t.end_time?` – ${w(t.end_time)}`:""]}),e.jsxs("span",{className:"flex items-center gap-1 font-medium",children:[e.jsx(ir,{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(Jy,{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(W,{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(e1,{className:"h-3.5 w-3.5"}),"Live"]}),e.jsxs(W,{variant:"outline",size:"sm",onClick:n,title:"Copy link",className:"shrink-0 gap-1.5 h-8 text-xs",children:[e.jsx(Va,{className:"h-3.5 w-3.5"}),"Copy"]}),e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>u(!0),title:"QR Code",className:"shrink-0 gap-1.5 h-8 text-xs",children:[e.jsx(Jy,{className:"h-3.5 w-3.5"}),"QR"]}),e.jsx(W,{variant:"outline",size:"sm",onClick:()=>f(!0),title:"Settings",className:"shrink-0 h-8 text-xs",children:e.jsx(So,{className:"h-3.5 w-3.5"})}),e.jsx(W,{variant:"outline",size:"sm",onClick:()=>window.open(N,"_blank"),title:"Preview",className:"shrink-0 h-8 text-xs",children:e.jsx(Yr,{className:"h-3.5 w-3.5"})}),e.jsx(W,{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(pp,{className:"h-3.5 w-3.5"}):e.jsx(jn,{className:"h-3.5 w-3.5"})}),e.jsx(W,{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(vr,{className:"h-3.5 w-3.5"})})]})]})}),s&&e.jsxs(Oe,{className:"pt-0",children:[e.jsx(ho,{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://",n2e,"/",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(W,{variant:"outline",size:"sm",onClick:S,className:"h-7 text-xs gap-1",children:[e.jsx(Qa,{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(L=>e.jsxs("tr",{className:"border-t border-border/50",children:[e.jsxs("td",{className:"p-2 font-medium",children:[L.first_name,L.last_name?` ${L.last_name}`:""]}),e.jsxs("td",{className:"p-2 text-muted-foreground hidden sm:table-cell",children:[L.email&&e.jsx("div",{className:"truncate max-w-[180px]",children:L.email}),L.phone&&e.jsx("div",{className:"text-xs",children:L.phone})]}),e.jsx("td",{className:"p-2 hidden md:table-cell",children:L.visitor_intent?e.jsx(Qe,{variant:"outline",className:"text-xs capitalize",children:L.visitor_intent}):L.partial_signin?e.jsx(Qe,{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:vs(new Date(L.created_at),"h:mm a")})]},L.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(s5s,{openHouseId:t.id})})]}),e.jsx(fs,{open:d,onOpenChange:u,children:e.jsxs(ps,{className:"sm:max-w-sm",children:[e.jsxs(ks,{children:[e.jsx(_s,{children:"QR Code"}),e.jsx(Ir,{className:"truncate",children:t.property_address})]}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[e.jsx("div",{ref:b,className:"bg-white p-4 rounded-xl",children:e.jsx(EO,{value:N,size:240,level:"H"})}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:N}),e.jsxs("div",{className:"flex gap-2 w-full",children:[e.jsxs(W,{variant:"outline",className:"flex-1",onClick:C,children:[e.jsx(Qa,{className:"h-4 w-4 mr-2"}),"Download"]}),e.jsxs(W,{variant:"outline",className:"flex-1",onClick:A,children:[e.jsx(PL,{className:"h-4 w-4 mr-2"}),"Print Flyer"]})]}),e.jsxs(W,{variant:"default",className:"w-full",onClick:I,disabled:y,children:[e.jsx(tr,{className:"h-4 w-4 mr-2"}),y?"Sending...":"Email Link to Me"]})]})]})}),e.jsx(e5s,{open:p,onOpenChange:f,openHouse:t})]})}function a5s(){const{slug:t}=io();return t?e.jsx(YZe,{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 Oct({photoUrl:t,videoUrl:s,onPhotoChange:r,onVideoChange:n,contactId:a}){const{user:o}=Us(),l=Mw(),i=k.useRef(null),d=k.useRef(null),[u,p]=k.useState(!1),[f,y]=k.useState(!1),[_,b]=k.useState(0),N=async S=>{if(o){p(!0);try{const C=S.name.split(".").pop()||"jpg",A=`${o.id}/card-${Date.now()}.${C}`,{error:I}=await G.storage.from("listing-photos").upload(A,S);if(I)throw I;const{data:{publicUrl:L}}=G.storage.from("listing-photos").getPublicUrl(A);r(L),pe.success("Photo uploaded")}catch(C){pe.error(C.message||"Failed to upload photo")}finally{p(!1)}}},w=async S=>{if(o){if(S.size>500*1024*1024){pe.error("Video must be under 500MB");return}y(!0),b(0);try{const{videoId:C,libraryId:A}=await wE(`Card Video - ${Date.now()}`),{uploadUrl:I,apiKey:L}=await jE(C);await new Promise((q,B)=>{const U=new XMLHttpRequest;U.upload.addEventListener("progress",te=>{te.lengthComputable&&b(Math.round(te.loaded/te.total*100))}),U.addEventListener("load",()=>{U.status>=200&&U.status<300?q():B(new Error("Upload failed"))}),U.addEventListener("error",()=>B(new Error("Upload failed"))),U.open("PUT",I),U.setRequestHeader("AccessKey",L),U.send(S)});const O=`https://iframe.mediadelivery.net/embed/${A}/${C}`;n(O);const V=parseFloat((S.size/(1024*1024)).toFixed(2));await l.mutateAsync({bunny_video_id:C,playback_url:`https://iframe.mediadelivery.net/play/${A}/${C}`,file_size_mb:V,title:"Card Video",status:"processing",touch_type:"video",contact_id:a||void 0}),pe.success("Video uploaded & added to your library")}catch(C){pe.error(C.message||"Failed to upload video")}finally{y(!1),b(0)}}};return e.jsxs("div",{className:"space-y-3",children:[e.jsx(xe,{children:"Media (optional)"}),e.jsxs(ta,{defaultValue:"photo",className:"w-full",children:[e.jsxs(Jn,{className:"grid w-full grid-cols-2",children:[e.jsxs(cs,{value:"photo",className:"gap-1.5 text-xs",children:[e.jsx(qo,{className:"h-3.5 w-3.5"}),"Photo"]}),e.jsxs(cs,{value:"video",className:"gap-1.5 text-xs",children:[e.jsx(yn,{className:"h-3.5 w-3.5"}),"Video"]})]}),e.jsxs(Ss,{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(W,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7",onClick:()=>r(null),children:e.jsx(kr,{className:"h-3.5 w-3.5"})})]}):e.jsx("button",{onClick:()=>{var S;return(S=i.current)==null?void 0:S.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(us,{className:"h-6 w-6 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(xx,{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:S=>{var A;const C=(A=S.target.files)==null?void 0:A[0];C&&N(C),S.target.value=""}})]}),e.jsxs(Ss,{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(W,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7",onClick:()=>n(null),children:e.jsx(kr,{className:"h-3.5 w-3.5"})})]}):e.jsx("button",{onClick:()=>{var S;return(S=d.current)==null?void 0:S.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(us,{className:"h-6 w-6 animate-spin"}),e.jsxs("span",{className:"text-xs",children:["Uploading... ",_,"%"]}),e.jsx("div",{className:"w-32 h-1.5 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${_}%`}})})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ra,{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(BCe,{contactId:a,onVideoReady:S=>n(S)})}),e.jsx("input",{ref:d,type:"file",accept:"video/*",className:"hidden",onChange:S=>{var A;const C=(A=S.target.files)==null?void 0:A[0];C&&w(C),S.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 i5s=[{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 o5s({onSelect:t}){return e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:i5s.map((s,r)=>e.jsxs(hr.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 RE={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 z9e({initialOpen:t,initialCardType:s,initialContactId:r,initialRecipientName:n,initialAddress:a,initialDate:o,onOpenChange:l}){const{user:i}=Us(),d=Qt(),[u,p]=k.useState(!1),[f,y]=k.useState("type"),[_,b]=k.useState(""),[N,w]=k.useState(null),[S,C]=k.useState(!1),[A,I]=k.useState("home_anniversary"),[L,O]=k.useState(""),[V,q]=k.useState(""),[B,U]=k.useState(""),[te,Y]=k.useState(""),[J,X]=k.useState("elegant"),[ce,ie]=k.useState(null),[ae,oe]=k.useState(null),me=k.useState(!1);!me[0]&&t&&s&&(me[1](!0),p(!0),I(s),r&&w(r),n&&O(n),a&&q(a),o&&U(o),y(n?"details":"contact"));const{data:ve}=gt({queryKey:["contacts-for-card",i==null?void 0:i.id,_],queryFn:async()=>{let Ue=G.from("innercircle_contacts").select("id, first_name, last_name, address, city, state, home_anniversary, email, phone").eq("owner_user_id",i.id).order("first_name").limit(20);_&&(Ue=Ue.or(`first_name.ilike.%${_}%,last_name.ilike.%${_}%`));const{data:Ie,error:ye}=await Ue;if(ye)throw ye;return Ie},enabled:!!(i!=null&&i.id)&&u}),{data:he}=gt({queryKey:["agent-profile-card",i==null?void 0:i.id],queryFn:async()=>{const{data:Ue,error:Ie}=await G.from("profiles").select("name, email, phone, avatar_url, brokerage:brokerages(name)").eq("id",i.id).single();if(Ie)throw Ie;return Ue},enabled:!!(i!=null&&i.id)}),ge=Ue=>{w(Ue.id),O(`${Ue.first_name}${Ue.last_name?" "+Ue.last_name:""}`),q([Ue.address,Ue.city,Ue.state].filter(Boolean).join(", ")),U(Ue.home_anniversary||""),y("details")},je=Ue=>{I(Ue),y("contact")},qe=async()=>{var Ue;if(!(!i||!he)){C(!0);try{const Ie={owner_user_id:i.id,contact_id:N,card_type:A,template:J,recipient_name:L,property_address:V||null,home_anniversary_date:B||null,custom_message:te||null,property_photo_url:ce||null,video_url:ae||null,agent_name:he.name||"Agent",agent_photo_url:he.avatar_url,agent_phone:he.phone,agent_email:he.email,agent_brokerage:((Ue=he.brokerage)==null?void 0:Ue.name)||null},{error:ye}=await G.from("sendable_cards").insert(Ie);if(ye)throw ye;pe.success("Card created! Copy the link to share it."),d.invalidateQueries({queryKey:["sendable-cards"]}),Me()}catch(Ie){pe.error(Ie.message||"Failed to create card")}finally{C(!1)}}},Me=()=>{p(!1),y("type"),I("home_anniversary"),b(""),w(null),O(""),q(""),U(""),Y(""),X("elegant"),ie(null),oe(null)},ke={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"},Re=RE[A],Ve=A==="home_anniversary",Ne=["home_anniversary","just_listed","just_sold"].includes(A);return e.jsxs(fs,{open:u,onOpenChange:Ue=>{Ue?p(!0):(Me(),l==null||l(!1))},children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{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(ks,{children:e.jsx(_s,{children:f==="type"?"What type of card?":f==="contact"?`${ke[A]} — Choose a Contact`:`${ke[A]} — Customize`})}),f==="type"&&e.jsx(o5s,{onSelect:je}),f==="contact"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(W,{variant:"ghost",size:"sm",className:"gap-1.5 -ml-2 text-muted-foreground",onClick:()=>y("type"),children:[e.jsx(Oa,{className:"h-3.5 w-3.5"})," Back to card types"]}),e.jsxs("div",{className:"relative",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search contacts...",value:_,onChange:Ue=>b(Ue.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:[ve==null?void 0:ve.map(Ue=>e.jsxs("button",{onClick:()=>ge(Ue),className:"w-full flex items-center gap-3 p-3 rounded-lg hover:bg-accent text-left transition-colors",children:[e.jsx("div",{className:"h-9 w-9 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(Ai,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[Ue.first_name," ",Ue.last_name]}),Ue.address&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate flex items-center gap-1",children:[e.jsx(Mn,{className:"h-3 w-3"}),Ue.address]})]}),Ue.home_anniversary&&A==="home_anniversary"&&e.jsx("span",{className:"text-[10px] text-emerald-600 bg-emerald-500/10 px-2 py-0.5 rounded-full shrink-0",children:"Anniversary set"})]},Ue.id)),(ve==null?void 0:ve.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(W,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{y("details")},children:"Skip — enter details manually"})})]}),f==="details"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(W,{variant:"ghost",size:"sm",className:"gap-1.5 -ml-2 text-muted-foreground",onClick:()=>y("contact"),children:[e.jsx(Oa,{className:"h-3.5 w-3.5"})," Back"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Recipient Name"}),e.jsx(De,{value:L,onChange:Ue=>O(Ue.target.value),placeholder:"John & Jane Smith"})]}),Ne&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Property Address"}),e.jsx(De,{value:V,onChange:Ue=>q(Ue.target.value),placeholder:"123 Main St, Austin, TX"})]}),Ve&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Home Anniversary Date"}),e.jsx(De,{type:"date",value:B,onChange:Ue=>U(Ue.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Personal Message (optional)"}),e.jsx(_r,{value:te,onChange:Ue=>Y(Ue.target.value),placeholder:Re.defaultMessage,rows:3})]}),e.jsx(Oct,{photoUrl:ce,videoUrl:ae,onPhotoChange:ie,onVideoChange:oe,contactId:N}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Template Style"}),e.jsx("div",{className:"grid grid-cols-5 gap-2",children:[{key:"elegant",label:"Elegant",gradient:"bg-gradient-to-br from-slate-100 to-blue-100 dark:from-slate-800 dark:to-slate-700"},{key:"bold",label:"Bold",gradient:"bg-gradient-to-br from-violet-500 to-fuchsia-500"},{key:"warm",label:"Warm",gradient:"bg-gradient-to-br from-amber-200 to-orange-300"},{key:"glass",label:"Glass",gradient:"bg-gradient-to-br from-slate-900 via-blue-900/50 to-slate-900 border border-white/10"},{key:"cinematic",label:"Cinema",gradient:"bg-gradient-to-br from-slate-950 via-blue-950 to-slate-950"}].map(({key:Ue,label:Ie,gradient:ye})=>e.jsxs("button",{onClick:()=>X(Ue),className:`p-2 rounded-lg border-2 transition-all text-center ${J===Ue?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("div",{className:`h-10 rounded-md mb-1.5 ${ye}`}),e.jsx("span",{className:"text-[10px] font-medium",children:Ie})]},Ue))})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(W,{variant:"outline",onClick:()=>y("contact"),className:"flex-1",children:"Back"}),e.jsx(W,{onClick:qe,disabled:!L||S,className:"flex-1 gap-2",children:S?"Creating...":"Create Card"})]})]})]})]})}const l5s={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 c5s({card:t}){Us();const{isGmailConnected:s}=Om(),r=Qt(),[n,a]=k.useState(!1),[o,l]=k.useState("");k.useEffect(()=>{n&&t.contact_id&&!o&&G.from("innercircle_contacts").select("email").eq("id",t.contact_id).maybeSingle().then(({data:b})=>{b!=null&&b.email&&l(b.email)})},[n,t.contact_id]);const i={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}!`},[d,u]=k.useState(i[t.card_type]||`A Special Card for ${t.recipient_name}!`),[p,f]=k.useState(""),y=`https://cardstudio.relevelup.com/c/${t.share_token}`,_=Pt({mutationFn:async()=>{var C;if(!o)throw new Error("Recipient email is required");const b=`
${p?`

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


`:""}

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

${t.property_address?`

${t.property_address}

`:""}
`,{data:N}=await G.auth.getSession(),w=(C=N==null?void 0:N.session)==null?void 0:C.access_token,S=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/gmail-send",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${w}`},body:JSON.stringify({to:o,subject:d,body:b,contactId:t.contact_id||void 0})});if(!S.ok){const A=await S.json();throw new Error(A.error||"Failed to send")}return S.json()},onSuccess:async()=>{await G.from("sendable_cards").update({sent_at:new Date().toISOString(),sent_via:"gmail"}).eq("id",t.id),r.invalidateQueries({queryKey:["sendable-cards"]}),pe.success(`Card sent to ${o}!`),a(!1)},onError:b=>{pe.error(b.message||"Failed to send email")}});return s?e.jsxs(fs,{open:n,onOpenChange:a,children:[e.jsx(mi,{asChild:!0,children:e.jsx(W,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(_n,{className:"h-3 w-3"})})}),e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsx(ks,{children:e.jsx(_s,{children:"Send Card via Gmail"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"To"}),e.jsx(De,{type:"email",value:o,onChange:b=>l(b.target.value),placeholder:"recipient@email.com"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Subject"}),e.jsx(De,{value:d,onChange:b=>u(b.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Personal Note (optional)"}),e.jsx(_r,{value:p,onChange:b=>f(b.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(W,{onClick:()=>_.mutate(),disabled:!o||_.isPending,className:"w-full gap-2",children:_.isPending?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"h-4 w-4 animate-spin"})," Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(_n,{className:"h-4 w-4"})," Send Card"]})})]})]})]}):e.jsx(W,{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(_n,{className:"h-3 w-3"})})}function d5s({card:t}){const s=Qt(),[r,n]=k.useState(!1),[a,o]=k.useState(!1),[l,i]=k.useState(t.recipient_name),[d,u]=k.useState(t.property_address||""),[p,f]=k.useState(t.home_anniversary_date||""),[y,_]=k.useState(t.custom_message||""),[b,N]=k.useState(t.template),[w,S]=k.useState(t.property_photo_url),[C,A]=k.useState(t.video_url||null),I=O=>{O&&(i(t.recipient_name),u(t.property_address||""),f(t.home_anniversary_date||""),_(t.custom_message||""),N(t.template),S(t.property_photo_url),A(t.video_url||null)),n(O)},L=async()=>{if(!l.trim()){pe.error("Recipient name is required");return}o(!0);try{const{error:O}=await G.from("sendable_cards").update({recipient_name:l.trim(),property_address:d.trim()||null,home_anniversary_date:p||null,custom_message:y.trim()||null,template:b,property_photo_url:w||null,video_url:C||null}).eq("id",t.id);if(O)throw O;s.invalidateQueries({queryKey:["sendable-cards"]}),pe.success("Card updated"),n(!1)}catch(O){pe.error(O.message||"Failed to update card")}finally{o(!1)}};return e.jsxs(fs,{open:r,onOpenChange:I,children:[e.jsx(mi,{asChild:!0,children:e.jsx(W,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(ga,{className:"h-3 w-3"})})}),e.jsxs(ps,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(ks,{children:e.jsx(_s,{children:"Edit Card"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Recipient Name"}),e.jsx(De,{value:l,onChange:O=>i(O.target.value),placeholder:"John & Jane Smith"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Property Address"}),e.jsx(De,{value:d,onChange:O=>u(O.target.value),placeholder:"123 Main St, Austin, TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Home Anniversary Date"}),e.jsx(De,{type:"date",value:p,onChange:O=>f(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Personal Message (optional)"}),e.jsx(_r,{value:y,onChange:O=>_(O.target.value),placeholder:"Wishing you many more happy years in your beautiful home!",rows:3})]}),e.jsx(Oct,{photoUrl:w,videoUrl:C,onPhotoChange:S,onVideoChange:A,contactId:t.contact_id}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Template Style"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:["elegant","bold","warm"].map(O=>e.jsxs("button",{onClick:()=>N(O),className:`p-3 rounded-lg border-2 transition-all text-center ${b===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(W,{onClick:L,disabled:!l.trim()||a,className:"w-full gap-2",children:a?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"h-4 w-4 animate-spin"})," Saving..."]}):"Save Changes"})]})]})]})}function u5s(){const{user:t}=Us(),s=Qt(),[r,n]=k.useState(""),[a,o]=Nc(),l=a.get("cardType"),i=a.get("contactId"),d=a.get("name"),u=a.get("address"),p=a.get("date"),f=!!l,{data:y,isLoading:_}=gt({queryKey:["sendable-cards",t==null?void 0:t.id],queryFn:async()=>{const{data:A,error:I}=await G.from("sendable_cards").select("*").eq("owner_user_id",t.id).order("created_at",{ascending:!1});if(I)throw I;return A},enabled:!!(t!=null&&t.id)}),b=Pt({mutationFn:async A=>{const{error:I}=await G.from("sendable_cards").delete().eq("id",A);if(I)throw I},onSuccess:()=>{s.invalidateQueries({queryKey:["sendable-cards"]}),pe.success("Card deleted")}}),N=A=>{const I=`https://cardstudio.relevelup.com/c/${A}`;navigator.clipboard.writeText(I),pe.success("Share link copied!")},w=y==null?void 0:y.filter(A=>{var I;return!r||A.recipient_name.toLowerCase().includes(r.toLowerCase())||((I=A.property_address)==null?void 0:I.toLowerCase().includes(r.toLowerCase()))}),S={elegant:"Elegant",bold:"Bold",warm:"Warm"},C={home_anniversary:"Home Anniversary",just_listed:"Just Listed",just_sold:"Just Sold",congratulations:"Congratulations",birthday:"Birthday",holiday:"Holiday",thank_you:"Thank You",thinking_of_you:"Thinking of You"};return e.jsx(Ds,{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(z9e,{initialOpen:f,initialCardType:l,initialContactId:i||void 0,initialRecipientName:d||void 0,initialAddress:u||void 0,initialDate:p||void 0,onOpenChange:()=>o({})})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search cards...",value:r,onChange:A=>n(A.target.value),className:"pl-9"})]}),_?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3].map(A=>e.jsx(Pe,{className:"animate-pulse",children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("div",{className:"h-40 bg-muted rounded-lg mb-3"}),e.jsx("div",{className:"h-4 bg-muted rounded w-2/3 mb-2"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2"})]})},A))}):w!=null&&w.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:w.map(A=>e.jsxs(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 ${A.template==="elegant"?"bg-gradient-to-br from-slate-50 via-slate-100 to-slate-200 dark:from-slate-900 dark:via-slate-800 dark:to-slate-700":A.template==="bold"?"bg-gradient-to-br from-violet-600 via-fuchsia-500 to-pink-500":"bg-gradient-to-br from-amber-100 via-orange-200 to-rose-200 dark:from-amber-900 dark:via-orange-800 dark:to-rose-800"}`,children:[A.template==="elegant"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"absolute top-0 left-0 w-full h-full opacity-10",children:[e.jsx("div",{className:"absolute top-3 left-3 w-16 h-16 border-t-2 border-l-2 border-primary/40 rounded-tl-lg"}),e.jsx("div",{className:"absolute bottom-3 right-3 w-16 h-16 border-b-2 border-r-2 border-primary/40 rounded-br-lg"})]}),e.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-32 h-32 rounded-full border border-primary/10"})]}),A.template==="bold"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute -top-8 -right-8 w-32 h-32 rounded-full bg-white/10 blur-sm"}),e.jsx("div",{className:"absolute -bottom-6 -left-6 w-24 h-24 rounded-full bg-white/10 blur-sm"}),e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_center,rgba(255,255,255,0.15)_0%,transparent_70%)]"})]}),A.template==="warm"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute -top-4 -left-4 w-28 h-28 rounded-full bg-orange-400/15 blur-md"}),e.jsx("div",{className:"absolute -bottom-6 -right-6 w-32 h-32 rounded-full bg-rose-400/15 blur-md"})]}),e.jsxs("div",{className:"text-center px-4 relative z-10",children:[e.jsx("div",{className:"text-3xl mb-1.5 opacity-80",children:A.card_type==="home_anniversary"?"🏡":A.card_type==="birthday"?"🎂":A.card_type==="just_sold"?"🎉":A.card_type==="just_listed"?"🏠":A.card_type==="thank_you"?"💐":A.card_type==="congratulations"?"🏆":A.card_type==="holiday"?"🎄":A.card_type==="thinking_of_you"?"💭":"✉️"}),e.jsx("p",{className:`text-[10px] uppercase tracking-[0.2em] mb-1 ${A.template==="bold"?"text-white/70":"text-muted-foreground"}`,children:C[A.card_type]||A.card_type}),e.jsx("p",{className:`font-semibold text-base ${A.template==="bold"?"text-white":"text-foreground"}`,children:A.recipient_name}),A.property_address&&e.jsx("p",{className:`text-xs mt-1 ${A.template==="bold"?"text-white/60":"text-muted-foreground"}`,children:A.property_address})]}),e.jsx("div",{className:"absolute top-2 right-2 z-10",children:e.jsx(Qe,{variant:A.template==="bold"?"outline":"secondary",className:`text-[10px] ${A.template==="bold"?"border-white/30 text-white/80":""}`,children:S[A.template]||A.template})})]}),e.jsxs(Oe,{className:"p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(jn,{className:"h-3 w-3"}),A.view_count," views"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Nl(new Date(A.created_at),{addSuffix:!0})})]}),A.sent_at&&e.jsxs("p",{className:"text-[10px] text-emerald-600 mb-2",children:["Sent ",vs(new Date(A.sent_at),"MMM d, yyyy")," via ",A.sent_via]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(W,{variant:"outline",size:"sm",className:"flex-1 gap-1 text-xs",onClick:()=>N(A.share_token),children:[e.jsx(Va,{className:"h-3 w-3"}),"Copy Link"]}),e.jsx(d5s,{card:A}),e.jsx(c5s,{card:A}),e.jsx(W,{variant:"outline",size:"sm",className:"gap-1 text-xs",onClick:()=>window.open(`https://cardstudio.relevelup.com/c/${A.share_token}`,"_blank"),children:e.jsx(Yr,{className:"h-3 w-3"})}),e.jsx(W,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive gap-1 text-xs",onClick:()=>b.mutate(A.id),children:e.jsx(vr,{className:"h-3 w-3"})})]})]})]},A.id))}):e.jsx(Pe,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx("div",{className:"h-16 w-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(tr,{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(z9e,{initialOpen:f,initialCardType:l,initialContactId:i||void 0,initialRecipientName:d||void 0,initialAddress:u||void 0,initialDate:p||void 0,onOpenChange:()=>o({})})]})})]})})}function jI({delay:t,x:s,y:r,size:n}){return e.jsx(hr.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 h5s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:y}=t,_=RE[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(hr.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(hr.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(jI,{delay:0,x:"15%",y:"20%",size:8}),e.jsx(jI,{delay:1,x:"80%",y:"30%",size:6}),e.jsx(jI,{delay:2,x:"60%",y:"70%",size:10}),e.jsx(jI,{delay:.5,x:"25%",y:"80%",size:7}),e.jsx(jI,{delay:1.5,x:"70%",y:"15%",size:5})]}),e.jsxs(hr.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(hr.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(hr.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(hr.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(hr.div,{className:"absolute inset-0 rounded-2xl border-2 border-slate-200/50 dark:border-slate-600/50",animate:{scale:[1,1.15,1],opacity:[.5,0,.5]},transition:{duration:2.5,repeat:1/0,ease:"easeInOut"}}),e.jsx("span",{className:"text-4xl",children:_.icon})]}),s==="home_anniversary"&&a!==null&&a>0&&e.jsx(hr.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(hr.h1,{className:"text-4xl font-light text-slate-800 dark:text-slate-100 mb-1 tracking-tight",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{duration:.5,delay:.7},children:_.title[0]}),_.title[1]&&e.jsx(hr.h2,{className:"text-4xl font-bold text-slate-800 dark:text-slate-100 mb-8 tracking-tight",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{duration:.5,delay:.85},children:_.title[1]}),e.jsxs(hr.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(hr.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(hr.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"})}),y&&e.jsx(hr.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:`${y}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(hr.p,{className:"text-sm text-slate-500 dark:text-slate-400 leading-relaxed max-w-xs mx-auto mb-8 italic",initial:{opacity:0},animate:{opacity:1},transition:{duration:.6,delay:1.3},children:o||_.defaultMessage}),e.jsxs(hr.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(hr.img,{src:i,alt:l,className:"h-12 w-12 rounded-full object-cover ring-2 ring-slate-200 dark:ring-slate-700 shadow-md",whileHover:{scale:1.1}}):e.jsx("div",{className:"h-12 w-12 rounded-full bg-gradient-to-br from-slate-200 to-blue-100 dark:from-slate-700 dark:to-slate-600 flex items-center justify-center shadow-md",children:e.jsx("span",{className:"text-sm font-semibold text-slate-600 dark:text-slate-300",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700 dark:text-slate-200",children:l}),p&&e.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3 mt-4",children:[d&&e.jsxs(hr.a,{href:`tel:${d}`,className:"flex items-center gap-1.5 px-4 py-2 rounded-full bg-slate-100 dark:bg-slate-800 text-xs font-medium text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors shadow-sm",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(In,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(hr.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(tr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(hr.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 S0e({delay:t,x:s,y:r,color:n,size:a}){return e.jsx(hr.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 NI({delay:t,x:s,y:r}){return e.jsx(hr.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 B9e={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 m5s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:y}=t,_=RE[s],b=B9e[s]||B9e.home_anniversary;return e.jsxs("div",{className:`min-h-screen bg-gradient-to-br ${b.bg} flex items-center justify-center p-4 overflow-hidden relative`,children:[e.jsx(S0e,{delay:0,x:"10%",y:"10%",color:b.orbs[0],size:200}),e.jsx(S0e,{delay:1,x:"70%",y:"60%",color:b.orbs[1],size:180}),e.jsx(S0e,{delay:2,x:"50%",y:"20%",color:b.orbs[2],size:150}),e.jsx(NI,{delay:0,x:"20%",y:"25%"}),e.jsx(NI,{delay:.8,x:"75%",y:"15%"}),e.jsx(NI,{delay:1.6,x:"85%",y:"65%"}),e.jsx(NI,{delay:2.4,x:"10%",y:"75%"}),e.jsx(NI,{delay:.4,x:"45%",y:"85%"}),e.jsxs(hr.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(hr.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(hr.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(hr.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(hr.div,{className:"absolute inset-0 rounded-2xl bg-gradient-to-br from-violet-500 to-fuchsia-500",animate:{scale:[1,1.3,1],opacity:[.6,0,.6]},transition:{duration:2,repeat:1/0,ease:"easeInOut"}}),e.jsx("span",{className:"text-4xl relative z-10",children:_.icon})]}),s==="home_anniversary"&&a!==null&&a>0&&e.jsxs(hr.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(hr.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(hr.h1,{className:"text-5xl font-black text-transparent bg-clip-text bg-gradient-to-r from-violet-200 via-white to-fuchsia-200 mb-2 leading-tight",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.7},children:_.title[0]}),_.title[1]&&e.jsx(hr.h2,{className:"text-5xl font-black text-transparent bg-clip-text bg-gradient-to-r from-fuchsia-300 via-violet-200 to-purple-300 mb-2 leading-tight",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.85},children:_.title[1]}),e.jsx(hr.div,{className:"text-3xl mb-4",initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.4,delay:1,type:"spring",stiffness:300},children:_.emojis.slice(0,3).join("")}),e.jsxs(hr.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(Mn,{className:"h-3.5 w-3.5"}),n]})]}),f&&e.jsx(hr.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"})}),y&&e.jsx(hr.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:`${y}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(hr.div,{className:"bg-white/5 rounded-2xl p-5 border border-white/10 mb-8 backdrop-blur-sm",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.3},children:e.jsx("p",{className:"text-sm text-violet-100/80 leading-relaxed",children:o||_.defaultMessage})}),e.jsxs(hr.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(hr.img,{src:i,alt:l,className:"h-12 w-12 rounded-xl object-cover ring-2 ring-violet-500/40 shadow-lg",whileHover:{scale:1.1}}):e.jsx("div",{className:"h-12 w-12 rounded-xl bg-gradient-to-br from-violet-500 to-fuchsia-500 flex items-center justify-center shadow-lg",children:e.jsx("span",{className:"text-sm font-bold text-white",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-bold text-white",children:l}),p&&e.jsx("p",{className:"text-xs text-violet-300/60",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-5",children:[d&&e.jsxs(hr.a,{href:`tel:${d}`,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r from-violet-500/30 to-fuchsia-500/30 text-xs font-semibold text-white hover:from-violet-500/50 hover:to-fuchsia-500/50 transition-all border border-white/15 shadow-lg",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(In,{className:"h-3.5 w-3.5"})," Call Me"]}),u&&e.jsxs(hr.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(tr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(hr.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 p5s({emoji:t,delay:s,x:r,duration:n}){return e.jsx(hr.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 $9e={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 f5s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:y}=t,_=RE[s],b=$9e[s]||$9e.home_anniversary;return e.jsxs("div",{className:`min-h-screen bg-gradient-to-b ${b.bg} flex items-center justify-center p-4 overflow-hidden relative`,children:[_.emojis.map((N,w)=>e.jsx(p5s,{emoji:N,delay:w*1.2,x:`${15+w*14}%`,duration:5+w%3},w)),e.jsx(hr.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(hr.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(hr.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(hr.div,{className:`h-28 bg-gradient-to-r ${b.header} relative overflow-hidden`,children:[e.jsx(hr.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(hr.div,{className:"absolute top-3 left-10 text-5xl",animate:{rotate:[0,10,-5,0],y:[0,-3,0]},transition:{duration:3,repeat:1/0,ease:"easeInOut"},children:_.emojis[0]}),e.jsx(hr.div,{className:"absolute top-2 right-14 text-3xl",animate:{scale:[1,1.3,1],rotate:[0,15,0]},transition:{duration:2,repeat:1/0,ease:"easeInOut",delay:.5},children:_.emojis[1]}),e.jsx(hr.div,{className:"absolute bottom-2 left-1/2 -translate-x-1/2 text-3xl",animate:{y:[0,-5,0],scale:[1,1.1,1]},transition:{duration:2.5,repeat:1/0,ease:"easeInOut",delay:1},children:_.emojis[2]})]}),e.jsxs("div",{className:"px-8 py-8 text-center -mt-10 relative",children:[e.jsx(hr.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(hr.div,{animate:{scale:[1,1.2,1]},transition:{duration:1.5,repeat:1/0,ease:"easeInOut"},children:e.jsx("span",{className:"text-3xl",children:_.icon})})}),s==="home_anniversary"&&a!==null&&a>0&&e.jsx(hr.div,{className:"mb-3",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{delay:.6},children:e.jsxs("span",{className:`inline-flex items-baseline gap-1.5 ${b.accent}`,children:[e.jsx(hr.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(hr.h1,{className:`text-3xl font-bold ${b.accent} mb-1`,initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.9},children:[_.title.join(" ")," ",_.emojis[4]]}),e.jsxs(hr.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1.1},children:[e.jsx("p",{className:`text-lg font-semibold ${b.text} mb-1`,children:r}),n&&e.jsxs("p",{className:`text-sm ${b.text} opacity-70 flex items-center justify-center gap-1 mb-5`,children:[e.jsx(Ia,{className:"h-3 w-3"}),n]})]}),f&&e.jsx(hr.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"})}),y&&e.jsx(hr.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:`${y}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(hr.div,{className:"bg-gradient-to-br from-amber-50 to-orange-50 rounded-2xl p-5 mb-6 border border-amber-100 shadow-inner",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.3},children:e.jsxs("p",{className:`text-sm ${b.text} leading-relaxed italic`,children:['"',o||_.defaultMessage,'"']})}),e.jsxs(hr.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(hr.img,{src:i,alt:l,className:"h-12 w-12 rounded-full object-cover ring-2 ring-amber-200 shadow-md",whileHover:{scale:1.1}}):e.jsx("div",{className:`h-12 w-12 rounded-full bg-gradient-to-br ${b.header} flex items-center justify-center shadow-md`,children:e.jsx("span",{className:"text-sm font-bold text-white",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:`text-sm font-bold ${b.accent}`,children:l}),p&&e.jsx("p",{className:`text-xs ${b.text} opacity-60`,children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4",children:[d&&e.jsxs(hr.a,{href:`tel:${d}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${b.header} text-xs font-semibold text-white shadow-md`,whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(In,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(hr.a,{href:`mailto:${u}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${b.header} text-xs font-semibold text-white shadow-md`,whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(tr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(hr.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 I9({delay:t,x:s,y:r,size:n,color:a}){return e.jsx(hr.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 C0e({delay:t,x:s,y:r,size:n}){return e.jsx(hr.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 q9e={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 x5s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:y}=t,_=RE[s],b=q9e[s]||q9e.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(I9,{delay:0,x:"5%",y:"10%",size:300,color:b.mesh[0]}),e.jsx(I9,{delay:2,x:"60%",y:"50%",size:250,color:b.mesh[1]}),e.jsx(I9,{delay:4,x:"30%",y:"70%",size:200,color:b.mesh[2]}),e.jsx(I9,{delay:1,x:"80%",y:"15%",size:180,color:b.mesh[0]}),e.jsx(C0e,{delay:0,x:"15%",y:"20%",size:100}),e.jsx(C0e,{delay:3,x:"70%",y:"60%",size:140}),e.jsx(C0e,{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(hr.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(hr.div,{className:`relative rounded-[28px] overflow-hidden backdrop-blur-2xl bg-white/[0.06] border border-white/[0.12] shadow-2xl ${b.glow}`,initial:{scale:.92},animate:{scale:1},transition:{duration:.6,delay:.2,type:"spring",stiffness:120},children:[e.jsx("div",{className:"relative h-[2px] bg-gradient-to-r from-transparent via-white/20 to-transparent overflow-hidden",children:e.jsx(hr.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(hr.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(hr.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(hr.span,{className:"text-5xl",animate:{scale:[1,1.08,1]},transition:{duration:2,repeat:1/0,ease:"easeInOut"},children:_.icon})]}),s==="home_anniversary"&&a!==null&&a>0&&e.jsxs(hr.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(hr.span,{className:"text-3xl font-black text-white",initial:{opacity:0},animate:{opacity:1},transition:{delay:.8},children:a}),e.jsx("span",{className:`text-[10px] font-bold uppercase tracking-[0.2em] ${b.accent}`,children:a===1?"Year":"Years"})]}),e.jsx(hr.h1,{className:"text-4xl font-extralight text-white/90 mb-1 tracking-tight",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{duration:.6,delay:.7},children:_.title[0]}),_.title[1]&&e.jsx(hr.h2,{className:"text-4xl font-bold text-white mb-6 tracking-tight",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{duration:.6,delay:.85},children:_.title[1]}),e.jsxs(hr.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(Ia,{className:"h-3 w-3"})," ",n]})]}),e.jsx(hr.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(hr.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"})}),y&&e.jsx(hr.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:`${y}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(hr.div,{className:"bg-white/[0.04] rounded-2xl p-5 border border-white/[0.08] mb-8 backdrop-blur-sm",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.3},children:e.jsxs("p",{className:"text-sm text-white/60 leading-relaxed italic",children:['"',o||_.defaultMessage,'"']})}),e.jsxs(hr.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(hr.img,{src:i,alt:l,className:"h-12 w-12 rounded-2xl object-cover ring-1 ring-white/10",whileHover:{scale:1.08}}):e.jsx("div",{className:"h-12 w-12 rounded-2xl bg-white/[0.08] border border-white/[0.1] flex items-center justify-center",children:e.jsx("span",{className:"text-sm font-semibold text-white/60",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-semibold text-white/80",children:l}),p&&e.jsx("p",{className:"text-xs text-white/30",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4",children:[d&&e.jsxs(hr.a,{href:`tel:${d}`,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-white/[0.06] border border-white/[0.1] text-xs font-medium text-white/70 hover:bg-white/[0.12] transition-colors backdrop-blur-sm",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(In,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(hr.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(tr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(hr.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 M0e({delay:t,x:s,angle:r,color:n}){return e.jsx(hr.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 L9({delay:t,x:s}){return e.jsx(hr.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 U9e={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 g5s(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:y}=t,_=RE[s],b=U9e[s]||U9e.home_anniversary;return e.jsxs("div",{className:`min-h-screen bg-gradient-to-b ${b.gradient} flex items-center justify-center p-4 overflow-hidden relative`,children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,rgba(255,255,255,0.04)_0%,transparent_60%)]"}),e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_bottom,rgba(0,0,0,0.6)_0%,transparent_60%)]"}),e.jsx(M0e,{delay:0,x:"20%",angle:15,color:b.stripe}),e.jsx(M0e,{delay:2,x:"75%",angle:-12,color:b.stripe}),e.jsx(M0e,{delay:4,x:"50%",angle:5,color:b.stripe}),e.jsx(L9,{delay:0,x:"30%"}),e.jsx(L9,{delay:1.5,x:"60%"}),e.jsx(L9,{delay:3,x:"45%"}),e.jsx(L9,{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(hr.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0},animate:{opacity:1},transition:{duration:1.2},children:[e.jsx(hr.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(hr.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(hr.div,{className:`h-20 w-20 mx-auto rounded-2xl bg-gradient-to-br ${b.accent} flex items-center justify-center shadow-2xl`,animate:{boxShadow:["0 0 40px rgba(255,255,255,0.05)","0 0 80px rgba(255,255,255,0.1)","0 0 40px rgba(255,255,255,0.05)"]},transition:{duration:3,repeat:1/0,ease:"easeInOut"},children:e.jsx("span",{className:"text-4xl",children:_.icon})})}),s==="home_anniversary"&&a!==null&&a>0&&e.jsxs(hr.div,{className:"mb-6",initial:{opacity:0},animate:{opacity:1},transition:{delay:.7},children:[e.jsx(hr.span,{className:`text-6xl font-black bg-gradient-to-r ${b.accent} bg-clip-text text-transparent`,initial:{scale:.5,opacity:0},animate:{scale:1,opacity:1},transition:{delay:.9,type:"spring"},children:a}),e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.4em] text-white/30 mt-1",children:a===1?"Year":"Years"})]}),e.jsx("div",{className:"overflow-hidden mb-2",children:e.jsx(hr.h1,{className:"text-5xl font-thin text-white/90 tracking-wide",initial:{y:"100%"},animate:{y:0},transition:{duration:.7,delay:.8,ease:[.16,1,.3,1]},children:_.title[0]})}),_.title[1]&&e.jsx("div",{className:"overflow-hidden mb-8",children:e.jsx(hr.h2,{className:`text-5xl font-black bg-gradient-to-r ${b.accent} bg-clip-text text-transparent`,initial:{y:"100%"},animate:{y:0},transition:{duration:.7,delay:.95,ease:[.16,1,.3,1]},children:_.title[1]})}),e.jsxs(hr.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(Ia,{className:"h-3 w-3"})," ",n]})]}),e.jsxs(hr.div,{className:"flex items-center justify-center gap-3 my-8",initial:{opacity:0},animate:{opacity:1},transition:{delay:1.2},children:[e.jsx(hr.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(hr.span,{className:"text-white/10 text-xs",animate:{rotate:[0,360]},transition:{duration:20,repeat:1/0,ease:"linear"},children:"✦"}),e.jsx(hr.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(hr.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"})]}),y&&e.jsx(hr.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:`${y}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(hr.p,{className:"text-sm text-white/40 leading-relaxed max-w-xs mx-auto mb-10 font-light",initial:{opacity:0},animate:{opacity:1},transition:{delay:1.4,duration:.8},children:o||_.defaultMessage}),e.jsxs(hr.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(hr.img,{src:i,alt:l,className:"h-12 w-12 rounded-full object-cover ring-2 ring-white/10 shadow-xl",whileHover:{scale:1.1}}):e.jsx("div",{className:`h-12 w-12 rounded-full bg-gradient-to-br ${b.accent} flex items-center justify-center shadow-xl`,children:e.jsx("span",{className:"text-sm font-bold text-slate-900",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium text-white/70",children:l}),p&&e.jsx("p",{className:"text-[11px] text-white/25",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[d&&e.jsxs(hr.a,{href:`tel:${d}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${b.accent} text-xs font-semibold text-slate-900 shadow-lg`,whileHover:{scale:1.05,boxShadow:"0 10px 40px rgba(255,255,255,0.15)"},whileTap:{scale:.95},children:[e.jsx(In,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(hr.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(tr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})}),e.jsx(hr.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 Fct(){const{shareToken:t}=io(),{data:s,isLoading:r,error:n}=gt({queryKey:["public-sendable-card",t],queryFn:async()=>{const{data:l,error:i}=await G.from("sendable_cards").select("*").eq("share_token",t).single();if(i)throw i;return l},enabled:!!t});if(k.useEffect(()=>{t&&G.rpc("log_sendable_card_view",{p_share_token:t}).then(({error:l})=>{l&&console.error("Error tracking view:",l)})},[t]),r)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"animate-pulse space-y-4 text-center",children:[e.jsx("div",{className:"h-8 w-48 bg-muted rounded mx-auto"}),e.jsx("div",{className:"h-4 w-32 bg-muted rounded mx-auto"})]})});if(n||!s)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Card not found"}),e.jsx("p",{className:"text-muted-foreground",children:"This card may have been removed or the link is invalid."})]})});const a=s.home_anniversary_date?Math.floor((Date.now()-ol(s.home_anniversary_date).getTime())/(365.25*24*60*60*1e3)):null,o={cardType:s.card_type||"home_anniversary",recipientName:s.recipient_name,propertyAddress:s.property_address,anniversaryYears:a,customMessage:s.custom_message,agentName:s.agent_name,agentPhotoUrl:s.agent_photo_url,agentPhone:s.agent_phone,agentEmail:s.agent_email,agentBrokerage:s.agent_brokerage,propertyPhotoUrl:s.property_photo_url,videoUrl:s.video_url||null};switch(s.template){case"bold":return e.jsx(m5s,{...o});case"warm":return e.jsx(f5s,{...o});case"glass":return e.jsx(x5s,{...o});case"cinematic":return e.jsx(g5s,{...o});case"elegant":default:return e.jsx(h5s,{...o})}}function y5s(){const t=ya();return gt({queryKey:["drip-settings",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("drip_settings").select("*").eq("user_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t})}function v5s(){const t=ya(),s=Qt();return Pt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n}=await G.from("drip_settings").select("id").eq("user_id",t).maybeSingle();if(n){const{data:a,error:o}=await G.from("drip_settings").update(r).eq("user_id",t).select().single();if(o)throw o;return a}else{const{data:a,error:o}=await G.from("drip_settings").insert({user_id:t,is_globally_enabled:r.is_globally_enabled??!1,append_signature:r.append_signature??!0}).select().single();if(o)throw o;return a}},onSuccess:()=>{s.invalidateQueries({queryKey:["drip-settings"]})}})}function _5s(){const t=wr(),{isGmailConnected:s,gmailEmail:r}=Om(),{data:n,isLoading:a}=y5s(),o=v5s(),[l,i]=k.useState(!1),[d,u]=k.useState(!0),[p,f]=k.useState(!1);k.useEffect(()=>{n&&(i(n.is_globally_enabled),u(n.append_signature))},[n]);const y=async b=>{if(b&&!s){pe.error("Connect your Gmail account first before enabling Smart Drips");return}i(b);try{await o.mutateAsync({is_globally_enabled:b}),pe.success(b?"Smart Drips enabled globally":"Smart Drips paused globally")}catch{i(!b),pe.error("Failed to update settings")}},_=async b=>{u(b);try{await o.mutateAsync({append_signature:b}),pe.success(b?"Signature will be appended to drip emails":"Signature disabled for drip emails")}catch{u(!b),pe.error("Failed to update settings")}};return e.jsxs(fs,{open:p,onOpenChange:f,children:[e.jsx(mi,{asChild:!0,children:e.jsxs(W,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(So,{className:"h-3.5 w-3.5"}),"Settings"]})}),e.jsxs(ps,{className:"sm:max-w-md",children:[e.jsxs(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(So,{className:"h-5 w-5 text-primary"}),"Smart Drip Settings"]}),e.jsx(Ir,{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(tr,{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(Qe,{variant:"outline",className:"gap-1 text-emerald-600 border-emerald-200 bg-emerald-500/10 text-[10px]",children:[e.jsx($n,{className:"h-3 w-3"}),"Active"]}):e.jsxs(W,{variant:"outline",size:"sm",className:"text-xs gap-1",onClick:()=>{f(!1),t("/mission-control/integrations")},children:[e.jsx(Yr,{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(ho,{}),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(EL,{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(Ar,{checked:l,onCheckedChange:y,disabled:a||o.isPending})]}),e.jsx(ho,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-full ${d?"bg-primary/10":"bg-muted"}`,children:e.jsx(Ry,{className:`h-4 w-4 ${d?"text-primary":"text-muted-foreground"}`})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Append Email Signature"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d?"Your signature from Profile settings will be added":"Drip emails will send without a signature"})]})]}),e.jsx(Ar,{checked:d,onCheckedChange:_,disabled:a||o.isPending})]}),d&&e.jsxs(W,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>{f(!1),t("/profile")},children:[e.jsx(Ry,{className:"h-3 w-3 mr-1"}),"Edit your email signature in Profile settings"]})]})]})]})}function b5s(){const t=ya();return gt({queryKey:["drip-templates",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("drip_templates").select("*").or(`owner_user_id.eq.${t},is_starter.eq.true`).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function w5s(){const t=ya();return gt({queryKey:["drip-pipeline-stages",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("deal_pipeline_stages").select("*").eq("owner_user_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function j5s(){const t=ya(),s=Qt();return Pt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.from("drip_templates").insert({owner_user_id:t,stage_id:r.stage_id,title:r.title||"",subject:r.subject||"",body:r.body||"",video_url:r.video_url||null,channel:r.channel||"email",delay_type:r.delay_type||"instant",delay_minutes:r.delay_minutes||0,is_enabled:!1,deal_type:r.deal_type||null,sort_order:r.sort_order||0}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["drip-templates"]})}})}function N5s(){const t=Qt();return Pt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("drip_templates").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["drip-templates"]})}})}function k5s(){const t=Qt();return Pt({mutationFn:async s=>{const{error:r}=await G.from("drip_templates").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["drip-templates"]})}})}function S5s(){const t=ya(),s=Qt();return Pt({mutationFn:async({templateId:r,stageId:n})=>{if(!t)throw new Error("Not authenticated");const{data:a,error:o}=await G.from("drip_templates").select("*").eq("id",r).single();if(o)throw o;const{data:l,error:i}=await G.from("drip_templates").insert({owner_user_id:t,stage_id:n,title:a.title,subject:a.subject,body:a.body,video_url:a.video_url,channel:a.channel,delay_type:a.delay_type,delay_minutes:a.delay_minutes,is_enabled:!1,is_starter:!1,deal_type:a.deal_type}).select().single();if(i)throw i;return l},onSuccess:()=>{s.invalidateQueries({queryKey:["drip-templates"]})}})}const C5s=[{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 M5s({open:t,onOpenChange:s,campaignId:r,campaignName:n}){const{data:a,isLoading:o}=rbs(r||void 0),l=abs(),i=Jat(),d=async(f,y)=>{try{await l.mutateAsync({id:f,status:y}),pe.success(`Enrollment ${y}`)}catch{pe.error("Failed to update")}},u=async f=>{if(r)try{const y=await i.mutateAsync({campaignId:r,contactIds:[f]});y.enrolled>0?pe.success("Contact re-enrolled — first email queued"):y.skipped>0?pe.message("Already active in this campaign"):pe.error("Could not re-enroll")}catch{pe.error("Failed to re-enroll")}},p=f=>{const y={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(Qe,{variant:"outline",className:`text-[10px] capitalize ${y[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(_s,{className:"flex items-center gap-2",children:[e.jsx(ir,{className:"h-4 w-4 text-primary"}),"Enrollments — ",n||"Campaign"]}),e.jsx(Ir,{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(Ms,{className:"h-14"},f))}):!a||a.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(ir,{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 y,_,b,N;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:[(y=f.contact)==null?void 0:y.first_name," ",(_=f.contact)==null?void 0:_.last_name]}),p(f.status)]}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-muted-foreground mt-0.5",children:[((b=f.contact)==null?void 0:b.email)&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(tr,{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: ",vs(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(W,{size:"sm",variant:"ghost",onClick:()=>d(f.id,"paused"),title:"Pause",children:e.jsx(hh,{className:"h-3.5 w-3.5"})}),f.status==="paused"&&e.jsx(W,{size:"sm",variant:"ghost",onClick:()=>d(f.id,"active"),title:"Resume",children:e.jsx(Co,{className:"h-3.5 w-3.5"})}),(f.status==="active"||f.status==="paused")&&e.jsx(W,{size:"sm",variant:"ghost",onClick:()=>d(f.id,"exited"),title:"Exit",children:e.jsx(kr,{className:"h-3.5 w-3.5 text-destructive"})}),(f.status==="exited"||f.status==="completed")&&((N=f.contact)==null?void 0:N.id)&&e.jsxs(W,{size:"sm",variant:"outline",className:"h-7 text-[11px] gap-1",onClick:()=>u(f.contact.id),disabled:i.isPending,children:[e.jsx(t0,{className:"h-3 w-3"}),"Re-enroll"]})]},f.id)})})})})]})})}function T5s(){var A;const{data:t,isLoading:s}=FSe(),{hasLeadSite:r}=CC(),n=J_s(),a=Q_s(),o=Xat(),[l,i]=k.useState(null),[d,u]=k.useState(!1),[p,f]=k.useState(null),[y,_]=k.useState(null),b=(t||[]).filter(I=>!I.is_starter),N=(t||[]).filter(I=>I.is_starter).filter(I=>!I.requires_lead_site||r),w=async I=>{try{await n.mutateAsync(I),pe.success("Campaign added to your library — customize and activate it!"),i(null)}catch(L){pe.error(L.message||"Failed to copy campaign")}},S=async I=>{try{await o.mutateAsync({id:I.id,is_active:!I.is_active}),pe.success(I.is_active?"Campaign paused":"Campaign activated")}catch{pe.error("Failed to update")}},C=async I=>{if(confirm("Delete this campaign? Active enrollments will be removed."))try{await a.mutateAsync(I),pe.success("Campaign deleted")}catch{pe.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(I=>e.jsx(Ms,{className:"h-44 rounded-xl"},I))}):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(sS,{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(Rh,{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(_n,{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(ir,{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(W,{size:"sm",onClick:()=>{f(null),u(!0)},children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1.5"})," New Campaign"]})]}),b.length===0?e.jsxs("div",{className:"text-center py-10 border border-dashed rounded-xl bg-muted/20",children:[e.jsx(Or,{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(W,{size:"sm",onClick:()=>{f(null),u(!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:b.map(I=>e.jsx(A5s,{campaign:I,onPreview:()=>i(I.id),onToggleActive:()=>S(I),onDelete:()=>C(I.id),onEdit:()=>{f(I.id),u(!0)},onViewEnrollments:()=>_(I.id)},I.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(Or,{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(Qe,{variant:"outline",className:"text-[10px]",children:[N.length," templates"]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:N.map(I=>e.jsx(E5s,{campaign:I,onPreview:()=>i(I.id)},I.id))})]}),e.jsx(P5s,{campaignId:l,open:!!l,onOpenChange:I=>!I&&i(null),onClone:w,isCloning:n.isPending,onEdit:I=>{i(null),f(I),u(!0)}}),e.jsx(eit,{open:d,onOpenChange:u,campaignId:p}),e.jsx(M5s,{open:!!y,onOpenChange:I=>!I&&_(null),campaignId:y,campaignName:(A=b.find(I=>I.id===y))==null?void 0:A.name})]})}function A5s({campaign:t,onPreview:s,onToggleActive:r,onDelete:n,onEdit:a,onViewEnrollments:o}){const i=nbs(t.id).data??0,d=!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(Qe,{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(Qe,{variant:"outline",className:"text-[9px] mt-2",children:Tme[t.category]}),d&&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(Dc,{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(W,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:a,children:[e.jsx(ga,{className:"h-3 w-3 mr-1"})," Edit"]}),e.jsx(W,{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 E5s({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(Qe,{className:"absolute top-2 right-2 bg-white/90 text-foreground hover:bg-white text-[10px]",children:[e.jsx(Or,{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(Qe,{variant:"outline",className:"text-[9px] mt-2",children:Tme[t.category]})]})]})}function P5s({campaignId:t,open:s,onOpenChange:r,onClone:n,isCloning:a,onEdit:o}){const{data:l}=FSe(),{data:i}=Qat(t||void 0),[d,u]=k.useState(new Set),p=l==null?void 0:l.find(_=>_.id===t);if(!p)return null;const f=_=>{u(b=>{const N=new Set(b);return N.has(_)?N.delete(_):N.add(_),N})},y=(_,b)=>{if(_.delay_type==="calendar_anchor"){const w=_.anchor_field==="birthday"?"birthday":"home anniversary",S=_.anchor_offset_days||0;return S===0?`On their ${w}`:S<0?`${Math.abs(S)} days before ${w}`:`${S} days after ${w}`}if(b===0&&_.delay_days===0&&_.delay_hours===0)return"Sends immediately";const N=[];return _.delay_days&&N.push(`${_.delay_days}d`),_.delay_hours&&N.push(`${_.delay_hours}h`),b===0?`After ${N.join(" ")}`:`+${N.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 ${p.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:p.icon}),e.jsxs("div",{className:"flex-1",children:[e.jsx(_s,{className:"text-xl font-bold text-white",children:p.name}),e.jsx(Ir,{className:"text-white/90 mt-1",children:p.description}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsx(Qe,{className:"bg-white/20 text-white border-white/20 hover:bg-white/20",children:Tme[p.category]}),e.jsxs(Qe,{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"}),p.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((_,b)=>{const N=d.has(_.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:b+1}),bf(_.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:[_.delay_type==="calendar_anchor"?e.jsx(cn,{className:"h-3 w-3"}):e.jsx(nn,{className:"h-3 w-3"}),e.jsx("span",{children:y(_,b)}),e.jsx("span",{children:"·"}),e.jsx(tr,{className:"h-3 w-3"}),e.jsx("span",{className:"capitalize",children:_.channel})]}),e.jsx("p",{className:"font-medium text-sm",children:_.subject}),N?e.jsx("p",{className:"text-xs text-muted-foreground mt-2 whitespace-pre-line",children:_.body}):e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1 whitespace-pre-line",children:_.body}),_.body&&_.body.length>160&&e.jsx("span",{className:"text-[10px] text-primary mt-1.5 inline-block",children:N?"Show less":"Show full email"})]})})]},_.id)})]})}),e.jsxs(gn,{className:"border-t p-4 shrink-0",children:[e.jsx(W,{variant:"outline",onClick:()=>r(!1),children:"Close"}),!p.is_starter&&o&&e.jsxs(W,{variant:"secondary",onClick:()=>o(p.id),children:[e.jsx(ga,{className:"h-3.5 w-3.5 mr-1.5"})," Edit Campaign"]}),p.is_starter&&e.jsxs(W,{onClick:()=>n(p.id),disabled:a,children:[a?e.jsx(us,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):e.jsx(Va,{className:"h-3.5 w-3.5 mr-1.5"}),"Copy to my campaigns"]})]})]})})}function I5s(){const t=ya(),s=wr(),{isGmailConnected:r,gmailEmail:n,isLoading:a}=Om(),{data:o,isLoading:l}=b5s(),{data:i,isLoading:d}=w5s(),u=j5s(),p=N5s(),f=k5s(),y=S5s(),[_,b]=k.useState(null),[N,w]=k.useState(null),S=(o==null?void 0:o.filter(B=>!B.is_starter&&B.owner_user_id===t))||[],C=(o==null?void 0:o.filter(B=>B.is_starter))||[],A=B=>S.filter(U=>U.stage_id===B),I=async B=>{try{await p.mutateAsync({id:B.id,is_enabled:!B.is_enabled}),pe.success(B.is_enabled?"Drip disabled":"Drip enabled")}catch{pe.error("Failed to update")}},L=async B=>{try{const U=i==null?void 0:i.find(te=>te.id===B);await u.mutateAsync({stage_id:B,title:`${(U==null?void 0:U.name)||"Stage"} follow-up`,subject:"",body:"",channel:"email",delay_type:"instant",delay_minutes:0}),b(B),pe.success("Drip template created")}catch{pe.error("Failed to create template")}},O=async B=>{try{await f.mutateAsync(B),pe.success("Template deleted")}catch{pe.error("Failed to delete")}},V=async B=>{if(!i||i.length===0){pe.error("No pipeline stages found");return}const U=i[0].id;try{await y.mutateAsync({templateId:B,stageId:U}),pe.success("Template copied to your drips!")}catch{pe.error("Failed to copy template")}},q=l||d;return e.jsx(Ds,{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(Oh,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"text-2xl font-bold",children:"Smart Drips"}),e.jsx(Qe,{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(_5s,{})]}),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(sS,{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(tr,{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(sS,{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(W,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>s("/mission-control/integrations"),children:[e.jsx(tr,{className:"h-3 w-3 mr-1.5"}),"Connect Gmail"]})]})]})),e.jsxs(ta,{defaultValue:"my-drips",children:[e.jsxs(Jn,{className:"grid grid-cols-3 w-full max-w-lg mb-6",children:[e.jsx(cs,{value:"my-drips",children:"Stage Drips"}),e.jsxs(cs,{value:"campaigns",children:["Campaigns",e.jsx(Qe,{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(cs,{value:"starters",children:["Stage Starters",C.length>0&&e.jsx(Qe,{variant:"secondary",className:"ml-1.5 text-[10px] px-1.5 py-0",children:C.length})]})]}),e.jsx(Ss,{value:"campaigns",children:e.jsx(T5s,{})}),e.jsx(Ss,{value:"my-drips",children:q?e.jsx("div",{className:"space-y-3",children:[1,2,3,4].map(B=>e.jsx(Ms,{className:"h-16 w-full rounded-xl"},B))}):!i||i.length===0?e.jsxs("div",{className:"text-center py-12 border border-dashed rounded-xl",children:[e.jsx(Oh,{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(B=>!B.is_won_stage&&!B.is_lost_stage).map(B=>{const U=A(B.id),te=_===B.id,Y=U.some(J=>J.is_enabled);return e.jsxs("div",{className:"border rounded-xl overflow-hidden",children:[e.jsxs("button",{onClick:()=>b(te?null:B.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:B.color||"#94A3B8"}}),e.jsx("span",{className:"font-medium text-sm flex-1",children:B.name}),U.length>0&&e.jsxs(Qe,{variant:"outline",className:`text-[10px] ${Y?"bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-muted-foreground"}`,children:[U.length," drip",U.length!==1?"s":"",Y&&" · Active"]}),te?e.jsx(Bi,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(xa,{className:"h-4 w-4 text-muted-foreground"})]}),te&&e.jsx("div",{className:"border-t bg-muted/10 p-4 space-y-3",children:U.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(W,{variant:"outline",size:"sm",onClick:()=>L(B.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:[U.map(J=>e.jsx(V9e,{template:J,isEditing:N===J.id,onToggleEdit:()=>w(N===J.id?null:J.id),onToggleEnabled:()=>I(J),onUpdate:X=>p.mutateAsync({id:J.id,...X}),onDelete:()=>O(J.id),userId:t||""},J.id)),e.jsxs(W,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>L(B.id),children:[e.jsx(qs,{className:"h-3 w-3 mr-1"})," Add another drip"]})]})})]},B.id)}),i.filter(B=>B.is_won_stage||B.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(B=>B.is_won_stage||B.is_lost_stage).map(B=>{const U=A(B.id),te=_===B.id,Y=U.some(J=>J.is_enabled);return e.jsxs("div",{className:"border rounded-xl overflow-hidden mb-2",children:[e.jsxs("button",{onClick:()=>b(te?null:B.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:B.color||"#94A3B8"}}),e.jsx("span",{className:"font-medium text-sm flex-1",children:B.name}),U.length>0&&e.jsxs(Qe,{variant:"outline",className:`text-[10px] ${Y?"bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-muted-foreground"}`,children:[U.length," drip",U.length!==1?"s":"",Y&&" · Active"]}),te?e.jsx(Bi,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(xa,{className:"h-4 w-4 text-muted-foreground"})]}),te&&e.jsx("div",{className:"border-t bg-muted/10 p-4 space-y-3",children:U.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(W,{variant:"outline",size:"sm",onClick:()=>L(B.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:[U.map(J=>e.jsx(V9e,{template:J,isEditing:N===J.id,onToggleEdit:()=>w(N===J.id?null:J.id),onToggleEnabled:()=>I(J),onUpdate:X=>p.mutateAsync({id:J.id,...X}),onDelete:()=>O(J.id),userId:t||""},J.id)),e.jsxs(W,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>L(B.id),children:[e.jsx(qs,{className:"h-3 w-3 mr-1"})," Add another drip"]})]})})]},B.id)})]})]})}),e.jsx(Ss,{value:"starters",children:C.length===0?e.jsxs("div",{className:"text-center py-12 border border-dashed rounded-xl",children:[e.jsx(Or,{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:C.map(B=>e.jsx(L5s,{template:B,onCopy:()=>V(B.id),isCopying:y.isPending},B.id))})})]})]})})}function V9e({template:t,isEditing:s,onToggleEdit:r,onToggleEnabled:n,onUpdate:a,onDelete:o,userId:l}){const[i,d]=k.useState(t.title),[u,p]=k.useState(t.subject),[f,y]=k.useState(t.body),[_,b]=k.useState(t.video_url||""),[N,w]=k.useState(t.channel),[S,C]=k.useState(t.delay_type),[A,I]=k.useState(t.delay_minutes),[L,O]=k.useState(!1),V=async()=>{O(!0);try{await a({title:i,subject:u,body:f,video_url:_||null,channel:N,delay_type:S,delay_minutes:A}),pe.success("Drip saved"),r()}catch{pe.error("Failed to save")}finally{O(!1)}},q=B=>{y(U=>U+B)};return e.jsxs("div",{className:"border rounded-lg bg-background overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",role:"button",onClick:r,children:[e.jsx("p",{className:"text-sm font-medium truncate",children:t.title||"Untitled drip"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.channel==="sms"?e.jsx(wi,{className:"h-3 w-3 text-muted-foreground"}):e.jsx(tr,{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(yn,{className:"h-3 w-3 text-primary"})]})]}),e.jsx(Ar,{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(xe,{className:"text-xs font-medium",children:"Title (internal)"}),e.jsx(De,{value:i,onChange:B=>d(B.target.value),className:"mt-1 h-8 text-sm",placeholder:"e.g. Buyer intro video"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(xe,{className:"text-xs font-medium",children:"Channel"}),e.jsx("div",{className:"flex gap-1 mt-1",children:["email","sms"].map(B=>e.jsxs("button",{onClick:()=>w(B),className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${N===B?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:[B==="sms"?e.jsx(wi,{className:"h-3 w-3"}):e.jsx(tr,{className:"h-3 w-3"}),B==="sms"?"SMS":"Email"]},B))})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx(xe,{className:"text-xs font-medium",children:"Timing"}),e.jsxs("div",{className:"flex gap-1 mt-1",children:[e.jsx("button",{onClick:()=>C("instant"),className:`flex-1 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${S==="instant"?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:"Instant"}),e.jsxs("button",{onClick:()=>C("scheduled"),className:`flex-1 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${S==="scheduled"?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:[e.jsx(nn,{className:"h-3 w-3 mr-1 inline"}),"Delay"]})]})]})]}),S==="scheduled"&&e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs font-medium",children:"Delay"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(De,{type:"number",min:1,value:A>=60?Math.round(A/60):A,onChange:B=>{const U=parseInt(B.target.value)||0;I(A>=60?U*60:U)},className:"h-8 w-20 text-sm"}),e.jsx("div",{className:"flex gap-1",children:[{label:"Minutes",mins:A<60?A:30},{label:"Hours",mins:A>=60?A:60},{label:"Days",mins:A>=1440?A:1440}].map(B=>e.jsx("button",{className:`px-2 py-1 rounded text-xs border transition-colors ${B.label==="Minutes"&&A<60||B.label==="Hours"&&A>=60&&A<1440||B.label==="Days"&&A>=1440?"bg-primary/10 text-primary border-primary/30":"text-muted-foreground border-input"}`,onClick:()=>{B.label==="Minutes"?I(30):B.label==="Hours"?I(60):I(1440)},children:B.label},B.label))})]})]}),N==="email"&&e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs font-medium",children:"Subject Line"}),e.jsx(De,{value:u,onChange:B=>p(B.target.value),className:"mt-1 h-8 text-sm",placeholder:"e.g. Next steps for your home purchase"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx(xe,{className:"text-xs font-medium",children:N==="sms"?"Message":"Email Body"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Insert:"}),e.jsxs("select",{className:"text-[10px] border rounded px-1 py-0.5 bg-background text-muted-foreground",value:"",onChange:B=>{B.target.value&&q(B.target.value),B.target.value=""},children:[e.jsx("option",{value:"",children:"Merge variable..."}),C5s.map(B=>e.jsx("option",{value:B.key,children:B.label},B.key))]})]})]}),e.jsx("textarea",{value:f,onChange:B=>y(B.target.value),placeholder:N==="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(xe,{className:"text-xs font-medium",children:"Attached Video"}),_?e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 text-xs text-muted-foreground truncate bg-muted/50 rounded px-2 py-1.5 border border-input",children:[e.jsx(yn,{className:"h-3 w-3 inline mr-1 text-primary"}),_.length>50?_.slice(0,50)+"...":_]}),e.jsx(W,{variant:"ghost",size:"sm",className:"h-7 text-xs text-destructive",onClick:()=>b(""),children:"Remove"})]}):e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx(BCe,{onVideoReady:B=>b(B)}),e.jsx(zCe,{userId:l,onSelect:B=>b(B),triggerSize:"sm",triggerClassName:"gap-1.5 flex-1"}),e.jsxs(W,{variant:"ghost",size:"sm",className:"gap-1 text-xs text-muted-foreground flex-1",onClick:()=>{const B=prompt("Paste a YouTube or Loom URL:");B&&b(B)},children:[e.jsx(vo,{className:"h-3 w-3"})," Paste URL"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs(W,{variant:"ghost",size:"sm",className:"text-xs text-destructive hover:text-destructive",onClick:o,children:[e.jsx(vr,{className:"h-3 w-3 mr-1"})," Delete"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{variant:"outline",size:"sm",className:"text-xs",onClick:r,children:"Cancel"}),e.jsx(W,{size:"sm",className:"text-xs",onClick:V,disabled:L,children:L?"Saving...":"Save Drip"})]})]})]})]})}function L5s({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(Qe,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:l}),e.jsxs(Qe,{variant:"outline",className:"text-[10px] gap-1",children:[t.channel==="sms"?e.jsx(wi,{className:"h-3 w-3"}):e.jsx(tr,{className:"h-3 w-3"}),t.channel==="sms"?"SMS":"Email"]}),e.jsxs(Qe,{variant:"outline",className:"text-[10px] gap-1",children:[e.jsx(nn,{className:"h-3 w-3"}),t.delay_type==="instant"?"Instant":i.replace("Sends ","")]}),n?e.jsx(Bi,{className:"h-4 w-4 text-muted-foreground ml-1"}):e.jsx(xa,{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(nn,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:i})]}),e.jsxs(W,{onClick:d=>{d.stopPropagation(),s()},size:"sm",className:"w-full gap-1.5",disabled:r,children:[e.jsx(Va,{className:"h-3.5 w-3.5"}),"Use This Template"]})]})]})}const zct=()=>{const t=$l();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 D5s(){return k.useEffect(()=>(document.body.classList.add("cardstudio-page"),()=>{document.body.classList.remove("cardstudio-page")}),[]),e.jsxs(Hoe,{children:[e.jsx(ys,{path:"/c/:shareToken",element:e.jsx(Fct,{})}),e.jsx(ys,{path:"*",element:e.jsx(zct,{})})]})}const T0e={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function Bct({slugOverride:t}){const s=io(),r=t||s.slug,[n,a]=k.useState("types"),[o,l]=k.useState(null),[i,d]=k.useState(null),[u,p]=k.useState(null),[f,y]=k.useState(new Date),[_,b]=k.useState({name:"",email:"",phone:"",message:""}),[N,w]=k.useState(!1),{data:S,isLoading:C}=gt({queryKey:["public-booking-settings",r],queryFn:async()=>{const{data:X,error:ce}=await G.from("agent_booking_settings").select("*").eq("slug",r).eq("is_active",!0).single();if(ce)throw ce;return X},enabled:!!r}),{data:A}=gt({queryKey:["public-booking-profile",S==null?void 0:S.user_id],queryFn:async()=>{const{data:X,error:ce}=await G.from("profiles").select("name, avatar_url, email, phone, title, bio").eq("id",S.user_id).single();if(ce)throw ce;return X},enabled:!!(S!=null&&S.user_id)}),{data:I=[]}=gt({queryKey:["public-booking-types",S==null?void 0:S.user_id],queryFn:async()=>{const{data:X,error:ce}=await G.from("agent_booking_types").select("id, name, description, duration_minutes, color, icon, qualification_enabled").eq("user_id",S.user_id).eq("is_active",!0).order("sort_order");if(ce)throw ce;return X},enabled:!!(S!=null&&S.user_id)}),{data:L=[]}=gt({queryKey:["public-availability",S==null?void 0:S.user_id],queryFn:async()=>{const{data:X,error:ce}=await G.from("agent_availability_slots").select("day_of_week, start_time, end_time").eq("user_id",S.user_id).eq("is_active",!0);if(ce)throw ce;return X},enabled:!!(S!=null&&S.user_id)}),{data:O=[]}=gt({queryKey:["public-blocked-dates",S==null?void 0:S.user_id],queryFn:async()=>{const{data:X,error:ce}=await G.from("agent_blocked_dates").select("blocked_date").eq("user_id",S.user_id);if(ce)throw ce;return X.map(ie=>ie.blocked_date)},enabled:!!(S!=null&&S.user_id)}),{data:V=[]}=gt({queryKey:["public-existing-bookings",S==null?void 0:S.user_id,i],queryFn:async()=>{if(!i)return[];const X=vs(i,"yyyy-MM-dd"),{data:ce,error:ie}=await G.from("bookings").select("start_time, end_time").eq("agent_user_id",S.user_id).eq("booking_date",X).eq("status","confirmed");if(ie)throw ie;return ce},enabled:!!(S!=null&&S.user_id)&&!!i}),q=k.useMemo(()=>[...new Set(L.map(X=>X.day_of_week))],[L]),B=X=>{const ce=Em(new Date),ie=ml(ce,(S==null?void 0:S.max_advance_days)||30),ae=ml(ce,0);return YS(X,ae)||ZS(X,ie)||O.includes(vs(X,"yyyy-MM-dd"))?!1:q.includes(X.getDay())},U=k.useMemo(()=>{if(!i||!o||!S)return[];const X=L.filter(ve=>ve.day_of_week===i.getDay()),ce=o.duration_minutes,ie=S.buffer_minutes||0,ae=[],oe=new Date,me=(S.min_notice_hours||2)*60*60*1e3;for(const ve of X){const[he,ge]=ve.start_time.split(":").map(Number),[je,qe]=ve.end_time.split(":").map(Number);let Me=JL(QL(i,he),ge);const ke=JL(QL(i,je),qe);for(;J5(Me,ce)<=ke;){const Re=vs(Me,"HH:mm"),Ve=vs(J5(Me,ce),"HH:mm");Me.getTime()-oe.getTime()>=me&&(V.some(Ue=>{const Ie=Ue.start_time.slice(0,5),ye=Ue.end_time.slice(0,5);return ReIe})||ae.push(Re)),Me=J5(Me,ce+ie)}}return ae},[i,o,L,S,V]),te=k.useMemo(()=>{const X=f.getFullYear(),ce=f.getMonth(),ie=new Date(X,ce,1),ae=new Date(X,ce+1,0),oe=ie.getDay(),me=[];for(let ve=0;ve{if(!(!o||!i||!u||!_.name||!S)){w(!0);try{const X=vs(J5(JL(QL(new Date,parseInt(u.split(":")[0])),parseInt(u.split(":")[1])),o.duration_minutes),"HH:mm"),{error:ce}=await G.from("bookings").insert({agent_user_id:S.user_id,booking_type_id:o.id,booking_date:vs(i,"yyyy-MM-dd"),start_time:u,end_time:X,guest_name:_.name,guest_email:_.email||null,guest_phone:_.phone||null,guest_message:_.message||null});if(ce)throw ce;G.functions.invoke("booking-notify",{body:{agentUserId:S.user_id,guestName:_.name,guestEmail:_.email||null,guestPhone:_.phone||null,guestMessage:_.message||null,bookingTypeName:o.name,bookingDate:vs(i,"yyyy-MM-dd"),startTime:u,endTime:X,durationMinutes:o.duration_minutes,meetingLink:S.meeting_link||null}}).catch(ie=>console.error("Booking notify error:",ie)),a("confirmed")}catch(X){pe.error("Failed to book: "+X.message)}finally{w(!1)}}},J=X=>{const[ce,ie]=X.split(":").map(Number),ae=ce>=12?"PM":"AM";return`${ce%12||12}:${ie.toString().padStart(2,"0")} ${ae}`};return C?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-[#f0f4f8] via-white to-[#e8f0f8] flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-[#406E71] border-t-transparent"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Loading booking page..."})]})}):S?e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-[#f0f4f8] via-white to-[#e8f0f8]",children:[e.jsx("div",{className:"h-1.5 bg-gradient-to-r from-[#406E71] via-[#5a9a9d] to-[#2a4c64]"}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 py-6 sm:py-10",children:[e.jsxs("div",{className:"bg-white rounded-2xl shadow-lg shadow-slate-200/60 border border-slate-100 overflow-hidden mb-6",children:[e.jsx("div",{className:"relative bg-gradient-to-r from-[#406E71] to-[#2a4c64] px-6 pt-6 pb-12",children:e.jsxs("div",{className:"absolute inset-0 opacity-10",children:[e.jsx("div",{className:"absolute top-2 right-8 w-20 h-20 rounded-full border-2 border-white/30"}),e.jsx("div",{className:"absolute bottom-4 left-12 w-10 h-10 rounded-full border border-white/20"})]})}),e.jsx("div",{className:"relative -mt-10 px-6",children:e.jsxs("div",{className:"flex items-end gap-4",children:[A!=null&&A.avatar_url?e.jsx("img",{src:A.avatar_url,alt:(A==null?void 0:A.name)||"Agent",className:"w-20 h-20 sm:w-24 sm:h-24 rounded-2xl object-cover border-4 border-white shadow-md"}):e.jsx("div",{className:"w-20 h-20 sm:w-24 sm:h-24 rounded-2xl bg-gradient-to-br from-[#406E71] to-[#2a4c64] border-4 border-white shadow-md flex items-center justify-center",children:e.jsx(Ai,{className:"h-10 w-10 text-white"})}),e.jsxs("div",{className:"pb-1.5",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-slate-800 leading-tight",children:(A==null?void 0:A.name)||"Agent"}),(A==null?void 0:A.title)&&e.jsx("p",{className:"text-sm text-slate-500 mt-0.5",children:A.title})]})]})}),e.jsxs("div",{className:"px-6 py-4 flex flex-wrap gap-2",children:[(A==null?void 0:A.phone)&&e.jsxs("a",{href:`tel:${A.phone}`,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-[#406E71]/8 hover:bg-[#406E71]/15 text-[#406E71] text-xs font-medium transition-colors",children:[e.jsx(In,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:A.phone}),e.jsx("span",{className:"sm:hidden",children:"Call"})]}),(A==null?void 0:A.email)&&e.jsxs("a",{href:`mailto:${A.email}`,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-[#2a4c64]/8 hover:bg-[#2a4c64]/15 text-[#2a4c64] text-xs font-medium transition-colors",children:[e.jsx(tr,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:A.email}),e.jsx("span",{className:"sm:hidden",children:"Email"})]})]})]}),e.jsx("div",{className:"bg-white rounded-2xl shadow-lg shadow-slate-200/60 border border-slate-100 overflow-hidden",children:e.jsxs("div",{className:"p-5 sm:p-6",children:[n==="types"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-slate-800",children:"Select a meeting type"}),e.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:"Choose the type of meeting you'd like to schedule"})]}),e.jsx("div",{className:"space-y-2.5",children:I.map(X=>e.jsx("button",{onClick:()=>{l(X),a("date")},className:"w-full text-left group",children:e.jsx("div",{className:"relative rounded-xl border border-slate-150 p-4 transition-all duration-200 hover:shadow-md hover:border-[#406E71]/30 hover:-translate-y-0.5 active:translate-y-0",style:{borderLeftWidth:"3px",borderLeftColor:X.color},children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[e.jsx("span",{className:"text-2xl shrink-0 mt-0.5",children:T0e[X.icon]||"📅"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold text-sm text-slate-800 group-hover:text-[#406E71] transition-colors",children:X.name}),X.description&&e.jsx("p",{className:"text-xs text-slate-500 mt-0.5 line-clamp-2",children:X.description})]})]}),e.jsxs("div",{className:"shrink-0 flex items-center gap-1 px-2.5 py-1 rounded-full bg-slate-100 text-slate-600 text-xs font-medium",children:[e.jsx(nn,{className:"h-3 w-3"}),X.duration_minutes,"m"]})]})})},X.id))})]}),n==="date"&&o&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("button",{onClick:()=>{a("types"),d(null),p(null)},className:"flex items-center gap-1.5 text-xs font-medium text-slate-500 hover:text-slate-800 transition-colors",children:[e.jsx(Oa,{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:T0e[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(nn,{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:vs(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:()=>y(new Date(f.getFullYear(),f.getMonth()-1)),children:e.jsx(Xo,{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:()=>y(new Date(f.getFullYear(),f.getMonth()+1)),children:e.jsx(xa,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-7 gap-0.5 text-center",children:[["Su","Mo","Tu","We","Th","Fr","Sa"].map(X=>e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-slate-400 font-semibold py-2",children:X},X)),te.map((X,ce)=>{if(!X)return e.jsx("div",{},`pad-${ce}`);const ie=B(X),ae=i&&il(X,i),oe=il(X,new Date);return e.jsx("button",{disabled:!ie,onClick:()=>{d(X),p(null)},className:`h-10 w-10 mx-auto rounded-xl text-sm font-medium transition-all duration-150 ${ae?"bg-[#406E71] text-white shadow-md shadow-[#406E71]/30 scale-105":ie?"hover:bg-[#406E71]/10 text-slate-700 hover:text-[#406E71]":"text-slate-200 cursor-not-allowed"} ${oe&&!ae?"ring-1 ring-[#406E71]/40":""}`,children:X.getDate()},X.toISOString())})]})]}),i&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_d,{className:"h-4 w-4 text-[#406E71]"}),e.jsx("h3",{className:"font-semibold text-sm text-slate-800",children:vs(i,"EEEE, MMMM d")})]}),U.length===0?e.jsxs("div",{className:"text-center py-8 space-y-2",children:[e.jsx(nn,{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:U.map(X=>{const ce=u===X;return e.jsx("button",{onClick:()=>p(X),className:`px-3 py-2.5 rounded-xl text-sm font-medium transition-all duration-150 ${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(X)},X)})}),u&&e.jsx(W,{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(Oa,{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:T0e[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(_d,{className:"h-3.5 w-3.5 text-[#406E71]"}),vs(i,"EEE, MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nn,{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(xe,{className:"text-xs font-semibold text-slate-700",children:"Full Name *"}),e.jsx(De,{value:_.name,onChange:X=>b({..._,name:X.target.value}),placeholder:"Jane Smith",className:"h-11 rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs font-semibold text-slate-700",children:"Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(tr,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx(De,{type:"email",value:_.email,onChange:X=>b({..._,email:X.target.value}),placeholder:"jane@email.com",className:"h-11 pl-9 rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs font-semibold text-slate-700",children:"Phone"}),e.jsxs("div",{className:"relative",children:[e.jsx(In,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx(De,{type:"tel",value:_.phone,onChange:X=>b({..._,phone:X.target.value}),placeholder:"(555) 123-4567",className:"h-11 pl-9 rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs font-semibold text-slate-700",children:"Message (optional)"}),e.jsx(_r,{value:_.message,onChange:X=>b({..._,message:X.target.value}),placeholder:"Anything you'd like the agent to know ahead of time?",rows:3,className:"rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20 resize-none"})]})]}),e.jsx(W,{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:!_.name||N,children:N?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($n,{className:"h-10 w-10 text-white"})})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-slate-800",children:"You're booked!"}),e.jsxs("p",{className:"text-slate-500 mt-1.5",children:[o==null?void 0:o.name," with ",(A==null?void 0:A.name)||"your agent"]})]}),e.jsx("div",{className:"inline-flex items-center gap-3 px-5 py-3 rounded-xl bg-slate-50 border border-slate-100",children:e.jsxs("div",{className:"text-left text-sm",children:[e.jsx("p",{className:"font-semibold text-slate-800",children:i&&vs(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."}),((A==null?void 0:A.phone)||(A==null?void 0:A.email))&&e.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[e.jsx("p",{className:"text-xs text-slate-400 uppercase tracking-wider font-semibold",children:"Contact"}),e.jsxs("div",{className:"flex gap-3",children:[(A==null?void 0:A.phone)&&e.jsxs("a",{href:`tel:${A.phone}`,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-full bg-[#406E71]/10 text-[#406E71] text-xs font-medium hover:bg-[#406E71]/20 transition-colors",children:[e.jsx(In,{className:"h-3.5 w-3.5"})," Call"]}),(A==null?void 0:A.email)&&e.jsxs("a",{href:`mailto:${A.email}`,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-full bg-[#2a4c64]/10 text-[#2a4c64] text-xs font-medium hover:bg-[#2a4c64]/20 transition-colors",children:[e.jsx(tr,{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(_d,{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 R5s(){const s=$l().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(Bct,{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 O5s(){const s=$l().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(pXe,{slugOverride:s})}function $ct({slugOverride:t}){const{slug:s}=io(),r=t||s,[n,a]=k.useState(!1),[o,l]=k.useState({}),[i,d]=k.useState(0),[u,p]=k.useState(!1),{data:f,isLoading:y}=gt({queryKey:["public-landing-page",r],queryFn:async()=>{const{data:V,error:q}=await G.from("landing_pages").select("*").eq("slug",r).eq("is_published",!0).single();if(q)throw q;return V},enabled:!!r}),{data:_=[]}=gt({queryKey:["public-landing-page-fields",f==null?void 0:f.id],queryFn:async()=>{const{data:V,error:q}=await G.from("landing_page_fields").select("*").eq("page_id",f.id).order("sort_order");if(q)throw q;return V},enabled:!!(f!=null&&f.id)});k.useEffect(()=>{f!=null&&f.id&&G.from("landing_pages").update({view_count:(f.view_count||0)+1}).eq("id",f.id).then(()=>{})},[f==null?void 0:f.id]);const b=Pt({mutationFn:async()=>{const V=_.find(X=>X.field_type==="text"&&X.label.toLowerCase().includes("name")),q=_.find(X=>X.field_type==="email"),B=_.find(X=>X.field_type==="phone"),U=V?String(o[V.label]||""):null,te=q?String(o[q.label]||""):null,Y=B?String(o[B.label]||""):null,{error:J}=await G.from("landing_page_submissions").insert([{page_id:f.id,answers:JSON.parse(JSON.stringify(o)),contact_name:U,contact_email:te,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;G.functions.invoke("landing-page-lead-notify",{body:{page_id:f.id,contact_name:U,contact_email:te,contact_phone:Y,answers:o}}).catch(X=>console.error("Landing page lead notification error:",X))},onSuccess:()=>a(!0)}),N=V=>{V.preventDefault(),!(_.filter(B=>B.is_required&&!o[B.label]).length>0)&&b.mutate()};if(y)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-gray-400 border-t-transparent"})});if(!f)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-700",children:"Page Not Found"}),e.jsx("p",{className:"text-gray-500 mt-2",children:"This page doesn't exist or is no longer available."})]})});const w=f.primary_color||"#406E71",S=f.accent_color||"#2a4c64",C=f,A=f.page_type==="lead_magnet",I=f.page_type==="just_listed"||f.page_type==="just_sold",L=Array.isArray(C.property_photos)?C.property_photos:[],O=C.lead_magnet_file_url||C.lead_magnet_external_url;if(n)return e.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{background:`linear-gradient(135deg, ${w}, ${S})`},children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl p-8 max-w-md mx-4 text-center",children:[e.jsx($n,{className:"h-16 w-16 mx-auto mb-4",style:{color:w}}),e.jsx("h2",{className:"text-2xl font-bold mb-2",children:A?"Your download is ready!":"Submitted!"}),e.jsx("p",{className:"text-gray-600",children:f.success_message}),A&&O&&e.jsxs("a",{href:O,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 mt-6 px-6 py-3 rounded-lg text-white font-semibold transition-transform hover:scale-105",style:{backgroundColor:w},children:[e.jsx(Qa,{className:"h-5 w-5"}),"Download ",C.lead_magnet_file_name||"Your File"]}),f.agent_name&&e.jsxs("div",{className:"mt-6 pt-4 border-t",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Contact"}),e.jsx("p",{className:"font-semibold",children:f.agent_name}),f.agent_phone&&e.jsxs("a",{href:`tel:${f.agent_phone}`,className:"text-sm flex items-center justify-center gap-1 mt-1",style:{color:w},children:[e.jsx(In,{className:"h-3 w-3"})," ",f.agent_phone]}),f.agent_email&&e.jsxs("a",{href:`mailto:${f.agent_email}`,className:"text-sm flex items-center justify-center gap-1 mt-1",style:{color:w},children:[e.jsx(tr,{className:"h-3 w-3"})," ",f.agent_email]})]})]})});if(I){const V=q=>{const B=parseFloat(q.replace(/[^0-9.]/g,""));return isNaN(B)?q:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(B)};return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[u&&L.length>0&&e.jsxs("div",{className:"fixed inset-0 z-50 bg-black/95 flex items-center justify-center",onClick:()=>p(!1),children:[e.jsx("button",{onClick:()=>p(!1),className:"absolute top-4 right-4 text-white/80 hover:text-white z-10",children:e.jsx(kr,{className:"h-8 w-8"})}),e.jsx("button",{onClick:q=>{q.stopPropagation(),d(B=>B===0?L.length-1:B-1)},className:"absolute left-4 top-1/2 -translate-y-1/2 bg-white/10 hover:bg-white/20 text-white rounded-full p-3 transition-colors z-10",children:e.jsx(Xo,{className:"h-6 w-6"})}),e.jsx("img",{src:L[i],alt:`Property photo ${i+1}`,className:"max-h-[90vh] max-w-[90vw] object-contain rounded-lg",onClick:q=>q.stopPropagation()}),e.jsx("button",{onClick:q=>{q.stopPropagation(),d(B=>B===L.length-1?0:B+1)},className:"absolute right-4 top-1/2 -translate-y-1/2 bg-white/10 hover:bg-white/20 text-white rounded-full p-3 transition-colors z-10",children:e.jsx(xa,{className:"h-6 w-6"})}),e.jsxs("div",{className:"absolute bottom-6 left-1/2 -translate-x-1/2 text-white/70 text-sm",children:[i+1," / ",L.length]})]}),L.length>0&&e.jsxs("div",{className:"relative max-w-6xl mx-auto px-4 pt-6",children:[e.jsx("div",{className:"absolute top-10 left-8 z-10 px-4 py-1.5 rounded-full text-white font-bold text-sm uppercase tracking-wider shadow-lg",style:{backgroundColor:C.property_status==="just_sold"?"#e74c3c":w},children:C.property_status==="just_sold"?"🎉 Just Sold":"🏡 Just Listed"}),L.length===1?e.jsxs("div",{className:"rounded-2xl overflow-hidden cursor-pointer group",onClick:()=>{d(0),p(!0)},children:[e.jsx("img",{src:L[0],alt:"Property",className:"w-full h-[50vh] object-cover group-hover:scale-105 transition-transform duration-500"}),e.jsxs("div",{className:"absolute bottom-4 right-4 bg-black/60 text-white px-3 py-1.5 rounded-lg text-sm flex items-center gap-1.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(Eb,{className:"h-4 w-4"})," View"]})]}):L.length===2?e.jsx("div",{className:"grid grid-cols-2 gap-2 rounded-2xl overflow-hidden",children:L.slice(0,2).map((q,B)=>e.jsx("div",{className:"cursor-pointer group relative",onClick:()=>{d(B),p(!0)},children:e.jsx("img",{src:q,alt:`Property ${B+1}`,className:"w-full h-[45vh] object-cover group-hover:scale-105 transition-transform duration-500"})},B))}):e.jsxs("div",{className:"grid grid-cols-4 gap-2 rounded-2xl overflow-hidden",style:{height:"55vh"},children:[e.jsx("div",{className:"col-span-2 row-span-2 cursor-pointer group relative",onClick:()=>{d(0),p(!0)},children:e.jsx("img",{src:L[0],alt:"Property main",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"})}),L.slice(1,5).map((q,B)=>e.jsxs("div",{className:"cursor-pointer group relative",onClick:()=>{d(B+1),p(!0)},children:[e.jsx("img",{src:q,alt:`Property ${B+2}`,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"}),B===3&&L.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center text-white font-bold text-lg",children:["+",L.length-5," more"]})]},B))]}),L.length>2&&e.jsxs("button",{onClick:()=>{d(0),p(!0)},className:"absolute bottom-4 right-8 bg-white shadow-lg hover:shadow-xl text-gray-800 px-4 py-2 rounded-lg text-sm font-medium flex items-center gap-2 transition-shadow",children:[e.jsx(Eb,{className:"h-4 w-4"})," View all ",L.length," photos"]})]}),L.length===0&&e.jsx("div",{className:"relative py-16 px-4",style:{background:f.hero_image_url?`linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55)), url(${f.hero_image_url}) center/cover`:`linear-gradient(135deg, ${w}, ${S})`},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:[C.property_price&&e.jsx("p",{className:"text-3xl md:text-4xl font-bold mb-2",style:{color:w},children:V(C.property_price)}),C.property_address&&e.jsxs("p",{className:"text-gray-600 flex items-center gap-1.5 mb-5 text-lg",children:[e.jsx(Ia,{className:"h-5 w-5 shrink-0"})," ",C.property_address]}),e.jsxs("div",{className:"flex gap-6 mb-5 py-4 border-y border-gray-100",children:[C.property_beds&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-lg font-semibold",children:[e.jsx(Zy,{className:"h-5 w-5",style:{color:w}})," ",C.property_beds]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Bedrooms"})]}),C.property_baths&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-lg font-semibold",children:[e.jsx(nf,{className:"h-5 w-5",style:{color:w}})," ",C.property_baths]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Bathrooms"})]}),C.property_sqft&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-lg font-semibold",children:[e.jsx(xS,{className:"h-5 w-5",style:{color:w}})," ",Number(C.property_sqft).toLocaleString()]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Sq Ft"})]})]}),C.property_description&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-800 mb-2",children:"About This Property"}),e.jsx("p",{className:"text-gray-600 leading-relaxed whitespace-pre-line",children:C.property_description})]})]})}),e.jsx("div",{className:"md:col-span-2",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 sticky top-6",children:[e.jsx("h2",{className:"text-lg font-bold mb-1",style:{color:w},children:C.property_status==="just_sold"?"Want results like this?":"Interested in this property?"}),e.jsx("p",{className:"text-gray-500 text-sm mb-4",children:"Fill out the form and I'll be in touch!"}),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(In,{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(tr,{className:"h-3 w-3"})," ",f.agent_email]})]})]})]}),e.jsxs("form",{onSubmit:N,className:"space-y-3",children:[_.map(q=>e.jsxs("div",{children:[e.jsxs(xe,{className:"text-xs font-medium",children:[q.label,q.is_required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),H9e(q,o,l)]},q.id)),e.jsx(W,{type:"submit",className:"w-full text-white",style:{backgroundColor:w},disabled:b.isPending,children:b.isPending?"Submitting...":"Submit"}),b.isError&&e.jsx("p",{className:"text-sm text-red-500 text-center",children:"Something went wrong. Please try again."})]})]})})]})}),e.jsx("div",{className:"text-center py-8 text-xs text-gray-400",children:"Powered by LevelUp"})]})}return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx("div",{className:"relative py-16 px-4",style:{background:f.hero_image_url?`linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55)), url(${f.hero_image_url}) center/cover`:`linear-gradient(135deg, ${w}, ${S})`},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}),A&&C.lead_magnet_file_name&&e.jsxs("div",{className:"mt-6 inline-flex items-center gap-2 bg-white/20 backdrop-blur px-4 py-2 rounded-full text-sm",children:[e.jsx(Qa,{className:"h-4 w-4"}),"Free Download: ",C.lead_magnet_file_name]})]})}),e.jsx("div",{className:"max-w-2xl mx-auto px-4 -mt-8",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 md:p-8",children:[A&&e.jsx("p",{className:"text-sm text-gray-500 mb-4 text-center",children:"Fill out the form below to get your free download!"}),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(In,{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(tr,{className:"h-3 w-3"})," ",f.agent_email]})]})]})]}),e.jsxs("form",{onSubmit:N,className:"space-y-4",children:[_.map(V=>e.jsxs("div",{children:[e.jsxs(xe,{className:"text-sm font-medium",children:[V.label,V.is_required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),H9e(V,o,l)]},V.id)),e.jsx(W,{type:"submit",className:"w-full text-white",style:{backgroundColor:w},disabled:b.isPending,children:b.isPending?"Submitting...":A?"Get My Free Download":"Submit"}),b.isError&&e.jsx("p",{className:"text-sm text-red-500 text-center",children:"Something went wrong. Please try again."})]})]})}),e.jsx("div",{className:"text-center py-8 text-xs text-gray-400",children:"Powered by LevelUp"})]})}function H9e(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(De,{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(_r,{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($s,{value:String(a),onValueChange:l=>r(i=>({...i,[t.label]:l})),children:[e.jsx(zs,{className:"mt-1",children:e.jsx(Vs,{placeholder:"Select..."})}),e.jsx(Bs,{children:o.map(l=>e.jsx(vt,{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(Ri,{checked:i.includes(l),onCheckedChange:d=>{const u=d?[...i,l]:i.filter(p=>p!==l);r(p=>({...p,[t.label]:u}))}}),e.jsx("span",{className:"text-sm",children:l})]},l)})});case"toggle":return e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[e.jsx(Ar,{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(De,{value:String(a),onChange:l=>r(i=>({...i,[t.label]:l.target.value})),className:"mt-1"})}}function F5s(){const s=$l().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($ct,{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 z5s=[{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}],MAs={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"},TAs={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"},G9e={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 AAs(t){return G9e[t]||G9e.basic}function B5s(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:z5s,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:[],searchSubdivisions:Array.isArray(s.searchSubdivisions)?s.searchSubdivisions:[]}}function $5s(){const s=window.location.hostname.match(/^([^.]+)\.thelocalmove\.com$/i);return s?s[1]:null}function q5s(){const t=$5s(),{data:s,isLoading:r,error:n}=gt({queryKey:["lead-site",t],queryFn:async()=>{var p;if(!t)return null;const{data:a,error:o}=await G.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 G.from("profiles").select("id, name, avatar_url, email, phone, title, bio, areas_served, years_experience, instagram_url, facebook_url, linkedin_url").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 G.from("team_members").select("team_id, teams(avatar_url, name)").eq("user_id",a.agent_id).limit(1).maybeSingle();f&&((p=f.teams)!=null&&p.avatar_url)&&(i=f.teams.avatar_url)}const d={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,areas_served:l.areas_served||null,years_experience:l.years_experience??null,instagram_url:l.instagram_url||null,facebook_url:l.facebook_url||null,linkedin_url:l.linkedin_url||null}:void 0,testimonials:Array.isArray(a.testimonials)?a.testimonials.filter(f=>f&&typeof f=="object"&&f.text).map(f=>({name:String(f.name||"Client"),text:String(f.text),rating:typeof f.rating=="number"?f.rating:5,location:f.location?String(f.location):void 0})):[],seoMetaTitle:a.seo_meta_title||null,seoMetaDescription:a.seo_meta_description||null},u=B5s(a);return{siteConfig:d,themeConfig:u}},enabled:!!t,staleTime:5*60*1e3,gcTime:30*60*1e3,refetchOnWindowFocus:!1});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 U5s(t,s){try{await G.functions.invoke("lead-site-notify",{body:{lead:s,lead_site_id:t}})}catch(r){console.warn("Lead notification failed:",r)}}const qct=k.createContext(null);function npe(){const t=k.useContext(qct);if(!t)throw new Error("useLeadSiteAuth must be used within LeadSiteAuthProvider");return t}function V5s({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}}=G.auth.onAuthStateChange(async(y,_)=>{const b=(_==null?void 0:_.user)??null;if(n(b),b){const{data:N}=await G.from("lead_site_consumer_profiles").select("id, name, phone").eq("user_id",b.id).eq("lead_site_id",t.id).maybeSingle();N&&o({...N,email:b.email||""})}else o(null);i(!1)});return G.auth.getSession().then(({data:{session:y}})=>{n((y==null?void 0:y.user)??null),y!=null&&y.user?G.from("lead_site_consumer_profiles").select("id, name, phone").eq("user_id",y.user.id).eq("lead_site_id",t.id).maybeSingle().then(({data:_})=>{_&&o({..._,email:y.user.email||""}),i(!1)}):i(!1)}),()=>f.unsubscribe()},[t.id]);const d=k.useCallback(async f=>{const y=f.email.toLowerCase().trim(),_=f.phone.replace(/\D/g,""),{data:b,error:N}=await G.auth.signUp({email:y,password:_,options:{data:{full_name:f.name,consumer_site_id:t.id},emailRedirectTo:window.location.origin}});if(N){if(N.message.includes("already registered")){await u(y,_);return}throw N}if(b.user){const{error:w}=await G.from("lead_site_consumer_profiles").insert({user_id:b.user.id,lead_site_id:t.id,name:f.name.trim(),phone:f.phone.trim()});w&&console.warn("Consumer profile insert error:",w);const{error:S}=await G.from("lead_site_leads").insert({lead_site_id:t.id,name:f.name.trim(),email:y,phone:f.phone.trim(),message:"Created account on website",source_page:window.location.pathname,lead_type:"website_registration",metadata:{registered:!0,has_account:!0}});S&&console.error("Lead insert error (CRM sync may not trigger):",S),U5s(t.id,{name:f.name.trim(),email:y,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,y)=>{const _=y.replace(/\D/g,""),{error:b}=await G.auth.signInWithPassword({email:f.toLowerCase().trim(),password:_});if(b)throw b},[]),p=k.useCallback(async()=>{await G.auth.signOut(),n(null),o(null)},[]);return e.jsx(qct.Provider,{value:{user:r,profile:a,isLoading:l,signUp:d,signIn:u,signOut:p},children:s})}function WCe({open:t,mode:s,siteConfig:r,onComplete:n,onSkip:a,theme:o="default",accentColor:l}){var J;const{signUp:i,signIn:d}=npe(),[u,p]=k.useState(!1),[f,y]=k.useState(""),[_,b]=k.useState(""),[N,w]=k.useState(""),[S,C]=k.useState(!1),[A,I]=k.useState(""),L=s==="required",O=o==="luxury",V=l||(O?"#c9a96e":"#2563eb"),q=((J=r.agent)==null?void 0:J.full_name)||"the agent",B={borderColor:`${V}66`,"--tw-ring-color":`${V}66`},U=async X=>{var ie;if(X.preventDefault(),I(""),!_.trim()||!N.trim()){I("Email and phone number are required.");return}if(!u&&!f.trim()){I("Name is required.");return}if(N.replace(/\D/g,"").length<7){I("Please enter a valid phone number.");return}C(!0);try{u?await d(_,N):await i({name:f,email:_,phone:N}),n()}catch(ae){(ie=ae==null?void 0:ae.message)!=null&&ie.includes("Invalid login")?I("Invalid email or phone number. Please try again."):I((ae==null?void 0:ae.message)||"Something went wrong. Please try again.")}finally{C(!1)}},te=O?"w-full px-3 py-2.5 border rounded-lg text-sm focus:outline-none focus:ring-2":"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",Y=O?B:void 0;return e.jsx(fs,{open:t,onOpenChange:L?void 0:X=>{X||a()},children:e.jsxs(ps,{className:`sm:max-w-md ${O?"border-white/10 bg-[#f7f1e7] text-[#201915]":""}`,onPointerDownOutside:L?X=>X.preventDefault():void 0,onEscapeKeyDown:L?X=>X.preventDefault():void 0,children:[e.jsxs(ks,{children:[e.jsx(_s,{className:"text-xl",style:O?{fontFamily:"'Playfair Display', Georgia, serif"}:void 0,children:u?"Welcome Back":L?"Create a Free Account to Continue":"Save Your Search & Get Updates"}),e.jsx(Ir,{className:O?"text-[#5f5145]":void 0,children:u?"Sign in with your email and phone number.":`Create a free account to save favorites, get alerts, and connect with ${q}.`})]}),e.jsxs("form",{onSubmit:U,className:"space-y-3 mt-2",children:[!u&&e.jsx("input",{type:"text",required:!0,placeholder:"Your name",value:f,onChange:X=>y(X.target.value),className:te,style:Y}),e.jsx("input",{type:"email",required:!0,placeholder:"Email address",value:_,onChange:X=>b(X.target.value),className:te,style:Y}),e.jsxs("div",{children:[e.jsx("input",{type:"tel",required:!0,placeholder:"Phone number",value:N,onChange:X=>w(X.target.value),className:te,style:Y}),e.jsx("p",{className:`text-xs mt-1 ${O?"text-[#8a7869]":"text-gray-400"}`,children:u?"Your phone number is your password":"Your phone number will be used as your password"})]}),A&&e.jsx("p",{className:"text-red-600 text-sm",children:A}),e.jsx("button",{type:"submit",disabled:S,className:`w-full py-2.5 font-medium rounded-lg disabled:opacity-50 transition-colors ${O?"text-black hover:opacity-90 tracking-wider uppercase text-sm":"bg-blue-600 text-white hover:bg-blue-700"}`,style:O?{backgroundColor:V}:void 0,children:S?u?"Signing in...":"Creating account...":u?"Sign In":"Create Account"}),e.jsx("button",{type:"button",onClick:()=>{p(!u),I("")},className:"w-full text-center text-sm hover:opacity-80 transition-opacity",style:{color:V},children:u?"Don't have an account? Sign up":"Already have an account? Sign in"}),!L&&!u&&e.jsx("button",{type:"button",onClick:a,className:`w-full py-2 text-sm transition-colors ${O?"text-[#7a6758] hover:text-[#201915]":"text-gray-500 hover:text-gray-700"}`,children:"Skip for now"})]}),e.jsx("p",{className:`text-xs text-center mt-1 ${O?"text-[#8a7869]":"text-gray-400"}`,children:"By registering you agree to receive property updates. You can unsubscribe anytime."})]})})}function KCe({siteConfig:t,pagePath:s}){const r=t.agent;if(!r)return null;const n=`https://${t.subdomainSlug}.thelocalmove.com`,o=(r.areas_served||"").split(/,|;|\|/).map(A=>A.trim()).filter(Boolean),l=o[0]||"",[i,d]=l.split(/,\s*/),u=(r.bio||"").match(/\b(CRS|GRI|ABR|CNE|SRES|SRS|RENE|MRP|PSA|AHWD|C2EX|CIPS|CRB|e-?PRO)\b/gi)||[],p=[...new Set(u.map(A=>A.toUpperCase()))],f=t.testimonials||[],y=f.length?{"@type":"AggregateRating",ratingValue:(f.reduce((A,I)=>A+(I.rating||5),0)/f.length).toFixed(1),reviewCount:f.length,bestRating:5,worstRating:1}:void 0,_=[r.facebook_url,r.instagram_url,r.linkedin_url].filter(Boolean),b={"@context":"https://schema.org","@type":["RealEstateAgent","LocalBusiness"],"@id":`${n}/#agent`,name:r.full_name,url:n,image:r.avatar_url||t.ogImageUrl||void 0,logo:t.ogImageUrl||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 local real estate professional${l?` serving ${l}`:""}.`,priceRange:"$$",..._.length&&{sameAs:_},...t.brokerageLegalName&&{worksFor:{"@type":"RealEstateAgent",name:t.brokerageLegalName,...t.brokerageLicenseNumber&&{identifier:t.brokerageLicenseNumber}}},...t.agentLicenseNumber&&{identifier:t.agentLicenseNumber},...i&&{address:{"@type":"PostalAddress",addressLocality:i,...d&&{addressRegion:d},addressCountry:"US"}},...o.length&&{areaServed:o.map(A=>{const[I,L]=A.split(/,\s*/);return{"@type":"City",name:I,...L&&{containedInPlace:{"@type":"State",name:L}}}})},...y&&{aggregateRating:y},...f.length&&{review:f.slice(0,10).map(A=>({"@type":"Review",author:{"@type":"Person",name:A.name},reviewBody:A.text,reviewRating:{"@type":"Rating",ratingValue:A.rating||5,bestRating:5,worstRating:1},...A.location&&{locationCreated:{"@type":"Place",name:A.location}}}))}},N={"@context":"https://schema.org","@type":"Person","@id":`${n}/#person`,name:r.full_name,jobTitle:r.title||"Real Estate Agent",description:r.bio||void 0,image:r.avatar_url||void 0,url:n,email:r.email,telephone:r.phone||void 0,..._.length&&{sameAs:_},...r.years_experience&&{knowsAbout:["Residential Real Estate","Home Buying","Home Selling",l?`${l} Real Estate`:"Local Real Estate"].filter(Boolean)},...p.length&&{hasCredential:p.map(A=>({"@type":"EducationalOccupationalCredential",credentialCategory:"designation",name:A}))},...t.brokerageLegalName&&{worksFor:{"@type":"Organization",name:t.brokerageLegalName}}},w={"@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"}},S=[{name:"Search Homes",description:`Browse all current MLS listings${l?` in ${l}`:""}.`,path:"/search"},{name:"Featured Areas",description:"Explore featured neighborhoods, cities, and communities.",path:"/areas"},{name:"Sold Properties",description:"See recently sold homes and local market activity.",path:"/sold"},{name:"Home Valuation",description:"Get a free, no-obligation estimate of what your home is worth.",path:"/sell"},{name:"About",description:`Learn more about ${r.full_name}${t.brokerageLegalName?` and ${t.brokerageLegalName}`:""}.`,path:"/about"},{name:"Contact",description:`Get in touch with ${r.full_name} for buying, selling, or relocation help.`,path:"/contact"}],C={"@context":"https://schema.org","@type":"ItemList","@id":`${n}/#nav`,name:"Main Navigation",itemListElement:S.map((A,I)=>({"@type":"SiteNavigationElement",position:I+1,name:A.name,description:A.description,url:`${n}${A.path}`}))};return e.jsxs(kl,{children:[e.jsx("script",{type:"application/ld+json",children:JSON.stringify(b)}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify(N)}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify(w)}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify(C)})]})}function EAs({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(kl,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})})}function PAs({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(kl,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})})}function H5s({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(kl,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(s)})})}function IAs({title:t,description:s,publishedAt:r,imageUrl:n,slug:a,siteConfig:o}){const l=`https://${o.subdomainSlug}.thelocalmove.com`,i=o.agent,d={"@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(kl,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(d)})})}function ZCe({siteConfig:t}){var _;const s=t.agent;if(!s)return null;const r=s.full_name,n=t.brokerageLegalName||"their brokerage",a=s.areas_served||"the local market",o=((_=a.split(/,|;|\|/)[0])==null?void 0:_.trim())||"the local area",l=s.years_experience,i=s.phone||"",d=s.email,u=t.agentLicenseNumber,p=(s.bio||"").match(/\b(CRS|GRI|ABR|CNE|SRES|SRS|RENE|MRP|PSA|AHWD|C2EX|CIPS|CRB|e-?PRO)\b/gi)||[],f=[...new Set(p.map(b=>b.toUpperCase()))],y=[{question:`Who is ${r}?`,answer:`${r} is a ${s.title||"REALTOR®"} with ${n}${l?`, with ${l}+ years of local real estate experience`:""} serving ${a}. ${s.bio?s.bio.slice(0,280):""}`.trim()},{question:`What areas does ${r} serve?`,answer:`${r} serves ${a} and surrounding communities. Whether you're buying, selling, relocating, or downsizing, ${r.split(" ")[0]} provides expert local guidance.`},{question:`How can I contact ${r}?`,answer:`You can reach ${r} by ${i?`phone at ${i}, `:""}email at ${d}, or by booking a consultation directly through this website.`},...f.length?[{question:`What real estate designations does ${r} hold?`,answer:`${r} holds the following professional designations: ${f.join(", ")}. These designations represent advanced training in specialized areas of real estate.`}]:[],...u?[{question:`Is ${r} a licensed real estate agent?`,answer:`Yes, ${r} is a fully licensed real estate professional (License #${u}) with ${n}.`}]:[],{question:`How do I search for homes for sale in ${o}?`,answer:`Use the property search on this site to view all current MLS listings in ${o}. You can filter by price, bedrooms, neighborhood, school district, and more. Save searches to receive instant email alerts when new homes match your criteria.`},{question:`What is the home buying process like in ${o}?`,answer:`${r} guides buyers through every step: getting pre-approved, searching MLS listings, touring homes, writing competitive offers, navigating inspections and appraisals, and closing on schedule. Contact ${r.split(" ")[0]} for a free buyer consultation.`},{question:`How do I find out what my home is worth in ${o}?`,answer:`Request a free, no-obligation home valuation from ${r}. ${r.split(" ")[0]} provides a comparative market analysis (CMA) using recent sold comps and current market conditions in ${o}.`}];return e.jsx(H5s,{faqs:y})}const W9e="ls_visitor_geo",G5s=1e3*60*60;function W5s(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.startsWith("/homes-in-")?"subdivision":t==="/dashboard"?"dashboard":"other"}function K5s(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"subdivision":return t.replace("/homes-in-","").split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ");case"dashboard":return"My Dashboard";default:return t}}async function Z5s(){try{const t=localStorage.getItem(W9e);if(t){const s=JSON.parse(t);if(Date.now()-s.ts{o.current||(o.current=!0,Z5s().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=W5s(l),d=K5s(l,i),u=localStorage.getItem(`ls_visitor_fp_${t.id}`)||null,p=a.current;G.from("lead_site_page_views").insert({lead_site_id:t.id,page_type:i,page_path:l,page_title:d,visitor_fingerprint:u,auth_user_id:s||null,visitor_city:(p==null?void 0:p.city)||null,visitor_region:(p==null?void 0:p.region)||null,visitor_country:(p==null?void 0:p.country)||null,visitor_lat:(p==null?void 0:p.lat)||null,visitor_lng:(p==null?void 0:p.lng)||null}).then(({error:f})=>{f&&console.error("[PageTracking] insert failed:",f.message)})},[r.pathname,t==null?void 0:t.id,s])}const Y5s=3e4;function XCe(t,s){const r=$l(),n=k.useRef(null),a=k.useRef(null),o=k.useRef(0),l=r.pathname,i=X5s(l),d=Q5s(l,i),u=i==="listing"&&l.split("/listing/")[1]||null;k.useEffect(()=>{if(!(t!=null&&t.id)||!s)return;i==="listing"&&(o.current+=1);const p=localStorage.getItem(`ls_visitor_fp_${t.id}`)||null,f=async()=>{const{data:y,error:_}=await G.from("lead_site_active_visitors").upsert({lead_site_id:t.id,auth_user_id:s,visitor_fingerprint:p,current_page_path:l,current_page_title:d,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&&(n.current=y.id,o.current>=2&&!y.notified_agent&&G.functions.invoke("lead-site-presence-notify",{body:{visitor_id:y.id,lead_site_id:t.id}}).catch(()=>{}))};return f(),a.current&&clearInterval(a.current),a.current=setInterval(f,Y5s),()=>{a.current&&clearInterval(a.current)}},[t==null?void 0:t.id,s,l]),k.useEffect(()=>{if(!(t!=null&&t.id)||!s)return;const p=()=>{n.current&&G.from("lead_site_active_visitors").delete().eq("id",n.current).then(()=>{})};return window.addEventListener("beforeunload",p),()=>window.removeEventListener("beforeunload",p)},[t==null?void 0:t.id,s])}function X5s(t){return t==="/"?"home":t==="/search"?"search":t.startsWith("/listing/")?"listing":t.startsWith("/homes-for-sale-in-")?"city":t.startsWith("/homes-in-")?"subdivision":"other"}function Q5s(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(" ");case"subdivision":return t.replace("/homes-in-","").split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ");default:return t}}function J5s({children:t,siteConfig:s}){var ve,he,ge,je,qe,Me,ke,Re,Ve;const r=$l(),n=wr(),[a,o]=k.useState(!1),[l,i]=k.useState(!1),[d,u]=k.useState(!1),[p,f]=k.useState([]),[y,_]=k.useState([]),[b,N]=k.useState(null),w=k.useRef(null),S=k.useRef(null),{user:C,profile:A,signOut:I}=npe();YCe(s,C==null?void 0:C.id),XCe(s,C==null?void 0:C.id);const L=((ve=s.agent)==null?void 0:ve.full_name)||"Agent",O=s.siteTitle||`${L} Real Estate`,V=r.pathname==="/search",q=r.pathname==="/",B=s.leadRegistrationMode!=="disabled";k.useEffect(()=>{(async()=>{const{data:Ue}=await G.from("lead_site_city_pages").select("city_name, city_slug").eq("site_id",s.id).eq("is_published",!0).order("sort_order",{ascending:!0});f(Ue||[])})()},[s.id]),k.useEffect(()=>{(async()=>{const{data:Ue}=await G.from("lead_site_menu_items").select("*").eq("site_id",s.id).eq("is_visible",!0).order("sort_order",{ascending:!0});_(Ue||[])})()},[s.id]),k.useEffect(()=>{const Ne=Ue=>{w.current&&!w.current.contains(Ue.target)&&u(!1),S.current&&!S.current.contains(Ue.target)&&N(null)};return document.addEventListener("mousedown",Ne),()=>document.removeEventListener("mousedown",Ne)},[]);const U=y.length>0,Y=U?[]:[{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=y.filter(Ne=>!Ne.parent_id),X=Ne=>y.filter(Ue=>Ue.parent_id===Ne),ce=q?"bg-transparent text-white":"bg-white/95 backdrop-blur text-gray-900 border-b border-gray-100 shadow-sm",ie=s.siteTitle||`${L} - Real Estate`,ae=s.siteTagline||`Browse homes and listings with ${L}`,oe=s.ogImageUrl||((he=s.agent)==null?void 0:he.avatar_url)||"",me=`https://${s.subdomainSlug||""}.thelocalmove.com`;return e.jsxs("div",{className:`flex flex-col ${V?"h-screen overflow-hidden":"min-h-screen"} bg-white`,children:[e.jsx(KCe,{siteConfig:s,pagePath:r.pathname}),e.jsx(ZCe,{siteConfig:s}),e.jsxs(kl,{children:[e.jsx("title",{children:ie}),e.jsx("meta",{name:"description",content:ae}),e.jsx("meta",{property:"og:title",content:ie}),e.jsx("meta",{property:"og:description",content:ae}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:url",content:me+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:ie}),e.jsx("meta",{name:"twitter:description",content:ae}),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:`${me}${r.pathname}`}),s.subdomainSlug==="matthogg"&&e.jsx("script",{src:"https://analytics.ahrefs.com/analytics.js","data-key":"kyFjzruyvE0yTdMokzgCBw",async:!0})]}),e.jsxs("header",{className:`${q?"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(da,{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:L,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(Ne=>e.jsx(da,{to:Ne.to,className:`px-4 py-2 rounded-lg text-sm font-medium tracking-wide transition-colors ${r.pathname===Ne.to?q?"bg-white/15 text-white":"bg-gray-100 text-gray-900":q?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:Ne.label},Ne.to)),U&&J.map(Ne=>{if(Ne.item_type==="dropdown"){const Ue=X(Ne.id);return e.jsxs("div",{ref:S,className:"relative",children:[e.jsxs("button",{onClick:()=>N(b===Ne.id?null:Ne.id),className:`flex items-center gap-1 px-4 py-2 rounded-lg text-sm font-medium tracking-wide transition-colors ${q?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:[Ne.label," ",e.jsx(Bi,{className:`h-3.5 w-3.5 transition-transform ${b===Ne.id?"rotate-180":""}`})]}),b===Ne.id&&Ue.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:Ue.map(Ie=>e.jsx(D9,{item:Ie,onClick:()=>N(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"},Ie.id))})]},Ne.id)}return e.jsx(D9,{item:Ne,className:`px-4 py-2 rounded-lg text-sm font-medium tracking-wide transition-colors ${q?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`},Ne.id)}),p.length>0&&e.jsxs("div",{ref:w,className:"relative",children:[e.jsxs("button",{onClick:()=>u(!d),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-")?q?"bg-white/15 text-white":"bg-gray-100 text-gray-900":q?"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(Bi,{className:`h-3.5 w-3.5 transition-transform ${d?"rotate-180":""}`})]}),d&&e.jsx("div",{className:"absolute top-full right-0 mt-2 w-52 bg-white rounded-xl shadow-xl border border-gray-100 py-2 z-50 animate-in fade-in slide-in-from-top-2 duration-150",children:p.map(Ne=>e.jsx("button",{onClick:()=>{n(`/homes-for-sale-in-${Ne.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:Ne.city_name},Ne.city_slug))})]}),C?e.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[e.jsxs(da,{to:"/account",className:`flex items-center gap-1.5 px-3 py-2 rounded-lg text-sm font-medium transition-colors ${q?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:[e.jsx(Xa,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden lg:inline",children:"Saved"})]}),e.jsxs(da,{to:"/account",className:`flex items-center gap-1.5 px-3 py-2 rounded-lg text-sm font-medium transition-colors ${q?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:[e.jsx(Ai,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden lg:inline",children:((je=A==null?void 0:A.name)==null?void 0:je.split(" ")[0])||"Account"})]})]}):B?e.jsx("button",{onClick:()=>i(!0),className:`ml-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors ${q?"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 ${q?"text-white hover:bg-white/10":"text-gray-600 hover:bg-gray-100"}`,children:a?e.jsx(kr,{className:"h-5 w-5"}):e.jsx(dS,{className:"h-5 w-5"})})]})}),a&&e.jsx("div",{className:`md:hidden border-t ${q?"border-white/10 bg-black/95 backdrop-blur":"border-gray-100 bg-white"} max-h-[calc(100vh-5rem)] overflow-y-auto overscroll-contain`,children:e.jsxs("div",{className:"px-4 py-3 space-y-1 pb-8",children:[Y.map(Ne=>e.jsx(da,{to:Ne.to,onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${r.pathname===Ne.to?q?"bg-white/15 text-white":"bg-gray-100 text-gray-900":q?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`,children:Ne.label},Ne.to)),U&&J.map(Ne=>{if(Ne.item_type==="dropdown"){const Ue=X(Ne.id);return e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:`px-3 pt-3 pb-1 text-xs font-semibold uppercase tracking-wider ${q?"text-white/40":"text-gray-400"}`,children:Ne.label}),Ue.map(Ie=>e.jsx(D9,{item:Ie,onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${q?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`},Ie.id))]},Ne.id)}return e.jsx(D9,{item:Ne,onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${q?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`},Ne.id)}),p.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`px-3 pt-3 pb-1 text-xs font-semibold uppercase tracking-wider ${q?"text-white/40":"text-gray-400"}`,children:"Cities"}),p.map(Ne=>e.jsx(da,{to:`/homes-for-sale-in-${Ne.city_slug}`,onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${r.pathname===`/homes-for-sale-in-${Ne.city_slug}`?q?"bg-white/15 text-white":"bg-gray-100 text-gray-900":q?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`,children:Ne.city_name},Ne.city_slug))]}),C?e.jsxs(e.Fragment,{children:[e.jsx(da,{to:"/account",onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${q?"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 ${q?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`,children:"Sign Out"})]}):B?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 ${q?"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}),!V&&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:[((qe=s.agent)==null?void 0:qe.avatar_url)&&e.jsx("img",{src:s.agent.avatar_url,alt:L,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:L}),e.jsx("p",{className:"text-sm text-gray-500",children:((Me=s.agent)==null?void 0:Me.title)||"Real Estate Professional"})]})]}),((ke=s.agent)==null?void 0:ke.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(In,{className:"h-3.5 w-3.5"})," ",s.agent.phone]})}),((Re=s.agent)==null?void 0:Re.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(tr,{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(Ne=>e.jsx("li",{children:e.jsx(da,{to:Ne.to,className:"hover:text-white transition-colors",children:Ne.label})},Ne.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(da,{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:[L," · ",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()," ",L,". Powered by LevelUp."]})]})]})]})}),!V&&((Ve=s.agent)==null?void 0:Ve.avatar_url)&&e.jsx(eMs,{agent:s.agent}),l&&e.jsx(WCe,{open:l,mode:"optional",siteConfig:s,onComplete:()=>i(!1),onSkip:()=>i(!1)})]})}function eMs({agent:t}){var a;const[s,r]=k.useState(!1),n=wr();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(In,{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(tr,{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(kr,{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 D9({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(da,{to:n,className:s,onClick:r,children:t.label})}function tMs({children:t,siteConfig:s}){var me,ve,he,ge,je,qe,Me;const r=$l(),n=wr(),[a,o]=k.useState(!1),[l,i]=k.useState(!1),[d,u]=k.useState(!1),[p,f]=k.useState([]),[y,_]=k.useState(!1),b=k.useRef(null),{user:N,profile:w,signOut:S}=npe();YCe(s,N==null?void 0:N.id),XCe(s,N==null?void 0:N.id);const C=((me=s.agent)==null?void 0:me.full_name)||"Agent",A=s.siteTitle||`${C} Real Estate`,I=s.brokerageLegalName?`${C} | ${s.brokerageLegalName}`:C,L=ke=>{if(!ke)return ke;const Re=C.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Ve=new RegExp(`^\\s*${Re}\\s*[|\\-–—:]\\s*`,"i");return ke.replace(Ve,"").trim()},O=A&&A!==`${C} Real Estate`?A:null,V=O?L(O):null,q=V&&V.toLowerCase()!==C.toLowerCase()?V:null,B=r.pathname==="/search",U=r.pathname==="/",te=s.leadRegistrationMode!=="disabled",Y="#c9a96e";k.useEffect(()=>{const ke=()=>_(window.scrollY>80);return window.addEventListener("scroll",ke,{passive:!0}),()=>window.removeEventListener("scroll",ke)},[]),k.useEffect(()=>{(async()=>{const{data:Re}=await G.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(Re||[])})()},[s.id]),k.useEffect(()=>{const ke=Re=>{b.current&&!b.current.contains(Re.target)&&u(!1)};return document.addEventListener("mousedown",ke),()=>document.removeEventListener("mousedown",ke)},[]);const J=[{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"}],X=s.siteTitle||`${C} - Real Estate`,ce=s.siteTagline||`Browse homes and listings with ${C}`,ie=s.ogImageUrl||((ve=s.agent)==null?void 0:ve.avatar_url)||"",ae=`https://${s.subdomainSlug||""}.thelocalmove.com`,oe=U?y?"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 ${B?"h-screen overflow-hidden":"min-h-screen"} bg-[#0d0b0a]`,children:[e.jsx(KCe,{siteConfig:s,pagePath:r.pathname}),e.jsx(ZCe,{siteConfig:s}),e.jsxs(kl,{children:[e.jsx("title",{children:X}),e.jsx("meta",{name:"description",content:ce}),e.jsx("meta",{property:"og:title",content:X}),e.jsx("meta",{property:"og:description",content:ce}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:url",content:ae+r.pathname}),ie&&e.jsx("meta",{property:"og:image",content:ie}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:X}),e.jsx("meta",{name:"twitter:description",content:ce}),ie&&e.jsx("meta",{name:"twitter:image",content:ie}),s.faviconUrl&&e.jsx("link",{rel:"icon",href:s.faviconUrl,type:"image/png"}),e.jsx("link",{rel:"canonical",href:`${ae}${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:`${U?"fixed":"sticky"} top-0 left-0 right-0 z-50 transition-all duration-500 ${oe}`,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(da,{to:"/",className:"flex items-center gap-3 min-w-0",children:e.jsxs("span",{className:"flex flex-col leading-none max-w-[320px] xl:max-w-[420px]",children:[e.jsx("span",{className:"block whitespace-normal text-white text-xl tracking-tight",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:I}),q&&e.jsx("span",{className:"mt-1 text-[11px] tracking-[0.18em] uppercase text-white/70",children:q})]})}),e.jsxs("nav",{className:"hidden lg:flex items-center gap-1",children:[J.map(ke=>e.jsx(da,{to:ke.to,className:`px-4 py-2 text-xs tracking-[0.15em] uppercase transition-colors duration-300 ${r.pathname===ke.to?"text-white":"text-white/40 hover:text-white"}`,children:ke.label},ke.to)),p.length>0&&e.jsxs("div",{ref:b,className:"relative",children:[e.jsxs("button",{onClick:()=>u(!d),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(Bi,{className:`h-3 w-3 transition-transform ${d?"rotate-180":""}`})]}),d&&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:p.map(ke=>e.jsx("button",{onClick:()=>{n(`/homes-for-sale-in-${ke.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:ke.city_name},ke.city_slug))})]}),N?e.jsxs("div",{className:"flex items-center gap-1 ml-3",children:[e.jsxs(da,{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(Xa,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:"Saved"})]}),e.jsxs(da,{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(Ai,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:((he=w==null?void 0:w.name)==null?void 0:he.split(" ")[0])||"Account"})]})]}):te?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(kr,{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:[J.map(ke=>e.jsx(da,{to:ke.to,onClick:()=>o(!1),className:`block px-3 py-3 text-xs tracking-[0.2em] uppercase transition-colors ${r.pathname===ke.to?"text-white":"text-white/40 hover:text-white"}`,children:ke.label},ke.to)),p.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:Y},children:"Cities"}),p.map(ke=>e.jsx(da,{to:`/homes-for-sale-in-${ke.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:ke.city_name},ke.city_slug))]}),N?e.jsxs(e.Fragment,{children:[e.jsx(da,{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 S(),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"})]}):te?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}),!B&&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:C}),e.jsx("p",{className:"text-white/20 text-xs tracking-[0.15em] uppercase mb-6",children:((ge=s.agent)==null?void 0:ge.title)||"Real Estate Professional"}),((je=s.agent)==null?void 0:je.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(In,{className:"h-3.5 w-3.5"})," ",s.agent.phone]}),((qe=s.agent)==null?void 0:qe.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(tr,{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:Y},children:"Quick Links"}),e.jsx("ul",{className:"space-y-3",children:J.map(ke=>e.jsx("li",{children:e.jsx(da,{to:ke.to,className:"text-xs tracking-wider uppercase text-white/30 hover:text-white transition-colors",children:ke.label})},ke.to))})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs tracking-[0.3em] uppercase mb-6",style:{color:Y},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(da,{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:[C," · ",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()," ",C,". Powered by LevelUp."]})]})]})]})}),!B&&((Me=s.agent)==null?void 0:Me.avatar_url)&&e.jsx(sMs,{agent:s.agent,accentColor:Y}),l&&e.jsx(WCe,{open:l,mode:"optional",siteConfig:s,onComplete:()=>i(!1),onSkip:()=>i(!1),theme:"luxury",accentColor:Y})]})}function sMs({agent:t,accentColor:s}){var o;const[r,n]=k.useState(!1),a=wr();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(In,{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(tr,{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(kr,{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 kI="#2c1810",Ny="#b8860b";function rMs({children:t,siteConfig:s}){var q,B,U;const r=$l();wr();const[n,a]=k.useState(!1),[o,l]=k.useState(!1),[i,d]=k.useState(!1),[u,p]=k.useState([]),[f,y]=k.useState(!1),_=k.useRef(null),{user:b,profile:N,signOut:w}=npe();YCe(s,b==null?void 0:b.id),XCe(s,b==null?void 0:b.id);const S=((q=s.agent)==null?void 0:q.full_name)||"Agent",C=s.siteTitle||`${S} Land & Ranch`,A=r.pathname==="/",I=s.leadRegistrationMode!=="disabled";k.useEffect(()=>{const te=()=>y(window.scrollY>80);return window.addEventListener("scroll",te,{passive:!0}),()=>window.removeEventListener("scroll",te)},[]),k.useEffect(()=>{(async()=>{const{data:Y}=await G.from("lead_site_city_pages").select("city_name, city_slug").eq("site_id",s.id).eq("is_published",!0).order("sort_order");Y&&p(Y)})()},[s.id]),k.useEffect(()=>{const te=Y=>{_.current&&!_.current.contains(Y.target)&&d(!1)};return document.addEventListener("mousedown",te),()=>document.removeEventListener("mousedown",te)},[]);const L=[{label:"Home",path:"/"},{label:"Search Properties",path:"/search"},{label:"About",path:"/about"},{label:"Contact",path:"/contact"}],O=f||!A?"bg-white/95 backdrop-blur-md shadow-sm":"bg-transparent",V=f||!A?kI:"#ffffff";return e.jsxs("div",{className:"min-h-screen",style:{fontFamily:"'Lora', Georgia, serif"},children:[e.jsxs(kl,{children:[e.jsx("title",{children:C}),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(KCe,{siteConfig:s}),e.jsx(ZCe,{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(da,{to:"/",className:"flex items-center gap-2.5",children:[e.jsx(jM,{className:"w-7 h-7",style:{color:Ny}}),e.jsx("span",{className:"text-lg font-bold tracking-wide",style:{color:V,fontFamily:"'Playfair Display', Georgia, serif"},children:C})]}),e.jsxs("nav",{className:"hidden md:flex items-center gap-1",children:[L.map(te=>e.jsx(da,{to:te.path,className:"px-4 py-2 text-sm font-medium tracking-wide uppercase transition-colors hover:opacity-80",style:{color:r.pathname===te.path?Ny:V},children:te.label},te.path)),u.length>0&&e.jsxs("div",{ref:_,className:"relative",children:[e.jsxs("button",{onClick:()=>d(!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:V},children:["Areas ",e.jsx(Bi,{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(te=>e.jsx(da,{to:`/homes-for-sale-in-${te.city_slug}`,className:"block px-4 py-2.5 text-sm hover:bg-gray-50 transition-colors",style:{color:kI},onClick:()=>d(!1),children:te.city_name},te.city_slug))})]}),b?e.jsx("div",{className:"flex items-center gap-2 ml-3",children:e.jsxs(da,{to:"/account",className:"px-4 py-2 text-sm font-medium rounded-full border-2 transition-all hover:scale-105",style:{borderColor:Ny,color:V},children:[e.jsx(Ai,{className:"w-4 h-4 inline mr-1.5"}),(N==null?void 0:N.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:Ny},children:"Sign In"}):null]}),e.jsx("button",{onClick:()=>a(!n),className:"md:hidden p-2",style:{color:V},children:n?e.jsx(kr,{className:"w-6 h-6"}):e.jsx(dS,{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:[L.map(te=>e.jsx(da,{to:te.path,className:"block px-4 py-3 text-base font-medium rounded-lg hover:bg-gray-50 transition-colors",style:{color:r.pathname===te.path?Ny:kI},onClick:()=>a(!1),children:te.label},te.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(te=>e.jsx(da,{to:`/homes-for-sale-in-${te.city_slug}`,className:"block px-4 py-2.5 text-sm rounded-lg hover:bg-gray-50",style:{color:kI},onClick:()=>a(!1),children:te.city_name},te.city_slug))]}),!b&&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:Ny},children:"Sign In"})]})})]}),e.jsx("main",{children:t}),e.jsx("footer",{className:"py-16 px-4",style:{backgroundColor:kI},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(jM,{className:"w-6 h-6",style:{color:Ny}}),e.jsx("span",{className:"text-lg font-bold text-white",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:C})]}),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:L.map(te=>e.jsx(da,{to:te.path,className:"block text-white/60 hover:text-white text-sm transition-colors",children:te.label},te.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:[((B=s.agent)==null?void 0:B.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(In,{className:"w-4 h-4",style:{color:Ny}}),s.agent.phone]}),((U=s.agent)==null?void 0:U.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(tr,{className:"w-4 h-4",style:{color:Ny}}),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()," ",C,". All rights reserved."]}),e.jsx("div",{className:"h-px w-16",style:{backgroundColor:Ny}})]})]})}),o&&e.jsx(WCe,{open:o,mode:s.leadRegistrationMode==="required"?"required":"optional",siteConfig:s,onSkip:()=>l(!1),onComplete:()=>l(!1)})]})}const nMs=k.lazy(()=>Ba(()=>import("./LeadSiteHome-5r1d5obS.js"),__vite__mapDeps([0,1,2,3]))),aMs=k.lazy(()=>Ba(()=>import("./LeadSiteLuxuryHome-Jv-ALhIS.js"),__vite__mapDeps([4,2,3]))),iMs=k.lazy(()=>Ba(()=>import("./LeadSiteLandRanchHome-D3b6t0hr.js"),__vite__mapDeps([5,1,2,3]))),oMs=k.lazy(()=>Ba(()=>import("./LeadSiteSearch-6WIDcv25.js"),__vite__mapDeps([6,1,7,3,8]))),lMs=k.lazy(()=>Ba(()=>import("./LeadSiteLuxurySearch-D8cf-b7B.js"),__vite__mapDeps([9,1,7,3,8]))),cMs=k.lazy(()=>Ba(()=>import("./LeadSiteListingDetail-BLGNzWWU.js"),__vite__mapDeps([10,11,3,12]))),dMs=k.lazy(()=>Ba(()=>import("./LeadSiteLuxuryListingDetail-DXccqCnl.js"),__vite__mapDeps([13,11,3,12]))),uMs=k.lazy(()=>Ba(()=>import("./LeadSiteAbout-CRme8skk.js"),[])),hMs=k.lazy(()=>Ba(()=>import("./LeadSiteLuxuryAbout-xmWgn-F5.js"),[])),mMs=k.lazy(()=>Ba(()=>import("./LeadSiteContact-DDfAI9sr.js"),[])),pMs=k.lazy(()=>Ba(()=>import("./LeadSiteLuxuryContact-CbAhgXda.js"),[])),fMs=k.lazy(()=>Ba(()=>import("./LeadSiteConsumerDashboard-DO-qr-vN.js"),[])),K9e=k.lazy(()=>Ba(()=>import("./LeadSiteBlog-n2AIDF7L.js"),[])),xMs=k.lazy(()=>Ba(()=>import("./LeadSiteCommunity-B4M_YGBi.js"),[])),gMs=k.lazy(()=>Ba(()=>import("./LeadSiteSellers-X6TTY9m_.js"),[])),yMs=k.lazy(()=>Ba(()=>import("./LeadSiteCityPage-Diicdo3c.js"),__vite__mapDeps([14,3,8]))),vMs=k.lazy(()=>Ba(()=>import("./LeadSiteSubdivisionPage-DkLlyCgv.js"),__vite__mapDeps([15,3]))),_Ms=k.lazy(()=>Ba(()=>import("./LeadSiteCustomPage-MXIbJxNK.js"),[]));function bMs(){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"})})}function wMs(){const{siteConfig:t,themeConfig:s,isLoading:r,error:n}=q5s();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?rMs:a?tMs:J5s,i=o?e.jsx(iMs,{siteConfig:t,themeConfig:s??void 0}):a?e.jsx(aMs,{siteConfig:t,themeConfig:s??void 0}):e.jsx(nMs,{siteConfig:t,themeConfig:s??void 0});return e.jsx(V5s,{siteConfig:t,children:e.jsx(l,{siteConfig:t,children:e.jsx(k.Suspense,{fallback:e.jsx(bMs,{}),children:e.jsxs(Hoe,{children:[e.jsx(ys,{path:"/",element:i}),e.jsx(ys,{path:"/search",element:a?e.jsx(lMs,{siteConfig:t}):e.jsx(oMs,{siteConfig:t})}),e.jsx(ys,{path:"/listing/:mlsNumber",element:a?e.jsx(dMs,{siteConfig:t}):e.jsx(cMs,{siteConfig:t})}),e.jsx(ys,{path:"/about",element:a?e.jsx(hMs,{siteConfig:t}):e.jsx(uMs,{siteConfig:t})}),e.jsx(ys,{path:"/contact",element:a?e.jsx(pMs,{siteConfig:t}):e.jsx(mMs,{siteConfig:t})}),e.jsx(ys,{path:"/account",element:e.jsx(fMs,{siteConfig:t})}),e.jsx(ys,{path:"/blog",element:e.jsx(K9e,{siteConfig:t,isLuxury:a})}),e.jsx(ys,{path:"/blog/:slug",element:e.jsx(K9e,{siteConfig:t,isLuxury:a})}),e.jsx(ys,{path:"/sell",element:e.jsx(gMs,{siteConfig:t,themeConfig:s??void 0,isLuxury:a})}),e.jsx(ys,{path:"/community",element:e.jsx(xMs,{siteConfig:t,isLuxury:a})}),e.jsx(ys,{path:"/p/:pageSlug",element:e.jsx(_Ms,{siteConfig:t})}),e.jsx(ys,{path:"/*",element:e.jsx(jMs,{siteConfig:t})})]})})})})}function jMs({siteConfig:t}){const s=$l(),r=s.pathname.match(/^\/homes-in-(.+)$/);if(r)return e.jsx(vMs,{siteConfig:t,subdivisionSlug:r[1]});const n=s.pathname.match(/^\/homes-for-sale-in-(.+)$/);return n?e.jsx(yMs,{siteConfig:t,citySlugOverride:n[1]}):null}const NMs=({team:t,onSelect:s})=>{const{data:r}=gt({queryKey:["team-card-info",t.id],queryFn:async()=>{const{data:n}=await G.from("team_members").select("user_id, role").eq("team_id",t.id),a=(n==null?void 0:n.length)||0,o=n==null?void 0:n.find(i=>i.role==="team_leader");let l=null;if(o){const{data:i}=await G.from("profiles").select("name, avatar_url").eq("id",o.user_id).single();l=i}return{count:a,leaderProfile:l}}});return e.jsxs(Pe,{className:"cursor-pointer hover:shadow-md transition-shadow group",onClick:s,children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(zt,{className:"text-lg truncate",children:t.name}),t.description&&e.jsx(dr,{className:"mt-1 line-clamp-2",children:t.description})]}),e.jsxs(Qe,{variant:"secondary",className:"ml-2 shrink-0",children:[e.jsx(ir,{className:"h-3 w-3 mr-1"}),(r==null?void 0:r.count)??"…"]})]})}),e.jsxs(Oe,{className:"space-y-3",children:[(r==null?void 0:r.leaderProfile)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Nn,{className:"h-6 w-6",children:[e.jsx(Ma,{src:r.leaderProfile.avatar_url||""}),e.jsx(kn,{className:"text-xs",children:(r.leaderProfile.name||"?").charAt(0).toUpperCase()})]}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(Cm,{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(zu,{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(Qe,{variant:"outline",className:"text-xs py-0",children:"Lead Pond"}),t.shared_assets_enabled&&e.jsx(Qe,{variant:"outline",className:"text-xs py-0",children:"Shared Assets"}),t.shared_videos_enabled&&e.jsx(Qe,{variant:"outline",className:"text-xs py-0",children:"Shared Videos"})]})]})]})},kMs=()=>{const{user:t,isAdmin:s,isBrokerageManager:r,brokerageId:n,managedBrokerages:a,selectedBrokerageId:o}=Us(),l=o||(a.length>0?a[0].id:n),i=s?void 0:l||void 0,{teams:d,isLoading:u,createTeam:p,updateTeam:f,deleteTeam:y,addMember:_,removeMember:b,updateMemberRole:N}=TC(i),[w,S]=k.useState(!1),[C,A]=k.useState(null),{data:I}=gt({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:V,error:q}=await G.from("brokerages").select("id, name").order("name");if(q)throw q;return V||[]},enabled:s}),{data:L}=gt({queryKey:["brokerage-agents-for-teams",l],queryFn:async()=>{const{data:V,error:q}=await G.from("profiles").select("id, name, email, avatar_url").eq("brokerage_id",l).order("name");if(q)throw q;return V||[]},enabled:!!l}),O=async V=>{const q=V.brokerage_id||l||null,B=await p.mutateAsync({name:V.name,brokerage_id:q,description:V.description});if(V.leaderId&&V.leaderId!=="none"&&await _.mutateAsync({team_id:B.id,user_id:V.leaderId,role:"team_leader"}),V.memberIds)for(const U of V.memberIds)await _.mutateAsync({team_id:B.id,user_id:U,role:"team_member"});S(!1)};return!r&&!s?e.jsx(Ds,{title:"Teams",description:"Team Management",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(ir,{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(Ds,{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(W,{onClick:()=>S(!0),children:[e.jsx(qs,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(gtt,{open:w,onOpenChange:S,onCreateTeam:O,isCreating:p.isPending,brokerageAgents:L||[],isAdmin:s,allBrokerages:I,activeBrokerageId:l}),u&&e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(V=>e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-6",children:[e.jsx(Ms,{className:"h-5 w-32 mb-3"}),e.jsx(Ms,{className:"h-4 w-48 mb-4"}),e.jsx(Ms,{className:"h-8 w-full"})]})},V))}),!u&&d.length===0&&!C&&e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(ir,{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(W,{onClick:()=>S(!0),children:[e.jsx(qs,{className:"mr-2 h-4 w-4"}),"Create Your First Team"]})]})}),!u&&d.length>0&&!C&&e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:d.map(V=>e.jsx(NMs,{team:V,onSelect:()=>A(V)},V.id))}),C&&e.jsx(xtt,{team:C,brokerageAgents:L||[],onBack:()=>A(null),onUpdate:V=>f.mutateAsync({id:C.id,...V}).then(q=>A(q)),onAddMember:(V,q)=>_.mutateAsync({team_id:C.id,user_id:V,role:q}),onRemoveMember:V=>b.mutateAsync({team_id:C.id,member_id:V}),onUpdateRole:(V,q)=>N.mutateAsync({team_id:C.id,member_id:V,role:q}),onDeleteTeam:()=>y.mutate(C.id),isUpdating:f.isPending,isAddingMember:_.isPending})]})})},SMs=()=>{const{data:t,isLoading:s}=Px(),{useTeamMembers:r}=TC(),{data:n=[],isLoading:a}=r((t==null?void 0:t.teamId)||"");if(s)return e.jsx(Ds,{title:"My Team",description:"Your team",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ms,{className:"h-8 w-48"}),e.jsx(Ms,{className:"h-40 w-full"})]})});if(!t)return e.jsx(Ds,{title:"My Team",description:"Your team",children:e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(ir,{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(Ds,{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(Qe,{variant:t.role==="team_leader"?"default":"secondary",className:"capitalize",children:t.role==="team_leader"?e.jsxs(e.Fragment,{children:[e.jsx(Cm,{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(ta,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(Jn,{className:"flex-wrap",children:[e.jsx(cs,{value:"members",children:"Members"}),o.contact_visibility!=="private"&&e.jsxs(cs,{value:"contacts",children:[e.jsx(Q4,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),o.lead_pond_enabled&&e.jsxs(cs,{value:"lead-pond",children:[e.jsx(Ag,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),o.shared_assets_enabled&&e.jsxs(cs,{value:"shared-assets",children:[e.jsx(Mm,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]})]}),e.jsx(Ss,{value:"members",className:"space-y-2",children:a?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(l=>e.jsx(Ms,{className:"h-16 w-full"},l))}):n.map(l=>{var i,d,u,p;return e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsxs(Nn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:((i=l.profile)==null?void 0:i.avatar_url)||""}),e.jsx(kn,{children:(((d=l.profile)==null?void 0:d.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium",children:((u=l.profile)==null?void 0:u.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(p=l.profile)==null?void 0:p.email})]}),l.role==="team_leader"?e.jsxs(Qe,{className:"ml-auto bg-amber-500/10 text-amber-600 border-amber-500",children:[e.jsx(Cm,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(Qe,{variant:"secondary",className:"ml-auto",children:"Member"})]})},l.id)})}),o.contact_visibility!=="private"&&e.jsx(Ss,{value:"contacts",className:"space-y-4",children:e.jsx(m4e,{})}),o.lead_pond_enabled&&e.jsx(Ss,{value:"lead-pond",className:"space-y-4",children:e.jsx(p4e,{teamId:t.teamId})}),o.shared_assets_enabled&&e.jsx(Ss,{value:"shared-assets",className:"space-y-4",children:e.jsx(ftt,{teamId:t.teamId})})]})]})})};function CMs(){const{user:t}=Us(),s=Qt(),r=gt({queryKey:["booking-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:S}=await G.from("agent_booking_settings").select("*").eq("user_id",t.id).maybeSingle();if(S)throw S;return w},enabled:!!t}),n=gt({queryKey:["booking-types",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:S}=await G.from("agent_booking_types").select("*").eq("user_id",t.id).order("sort_order");if(S)throw S;return w},enabled:!!t}),a=gt({queryKey:["availability-slots",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:S}=await G.from("agent_availability_slots").select("*").eq("user_id",t.id).order("day_of_week").order("start_time");if(S)throw S;return w},enabled:!!t}),o=gt({queryKey:["blocked-dates",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:S}=await G.from("agent_blocked_dates").select("*").eq("user_id",t.id).order("blocked_date");if(S)throw S;return w},enabled:!!t}),l=gt({queryKey:["bookings",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:S}=await G.from("bookings").select("*, booking_type:agent_booking_types(*)").eq("agent_user_id",t.id).order("booking_date",{ascending:!1});if(S)throw S;return w},enabled:!!t}),i=Pt({mutationFn:async()=>{const{data:w,error:S}=await G.from("agent_booking_settings").insert({user_id:t.id,slug:""}).select().single();if(S)throw S;const C=[{name:"Listing Consultation",description:"Get a comprehensive market analysis and listing strategy for your home",duration_minutes:60,color:"#10B981",icon:"Home",sort_order:0},{name:"Buyer Consultation",description:"Discuss your home search criteria, budget, and buying process",duration_minutes:45,color:"#3B82F6",icon:"Search",sort_order:1},{name:"Home Valuation",description:"Find out what your home is worth in today's market",duration_minutes:30,color:"#F59E0B",icon:"DollarSign",sort_order:2},{name:"General Meeting",description:"Coffee chat, check-in, or quick real estate question",duration_minutes:30,color:"#8B5CF6",icon:"Coffee",sort_order:3}],{error:A}=await G.from("agent_booking_types").insert(C.map(O=>({...O,user_id:t.id})));if(A)throw A;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:L}=await G.from("agent_availability_slots").insert(I);if(L)throw L;return w},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),s.invalidateQueries({queryKey:["booking-types"]}),s.invalidateQueries({queryKey:["availability-slots"]}),pe.success("Scheduler set up successfully!")},onError:w=>pe.error(w.message)}),d=Pt({mutationFn:async w=>{const{error:S}=await G.from("agent_booking_settings").update(w).eq("user_id",t.id);if(S)throw S},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),pe.success("Settings updated")},onError:w=>pe.error(w.message)}),u=Pt({mutationFn:async w=>{const S={...w,user_id:t.id};if(w.id){const{error:C}=await G.from("agent_booking_types").update(S).eq("id",w.id);if(C)throw C}else{const{error:C}=await G.from("agent_booking_types").insert(S);if(C)throw C}},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),pe.success("Booking type saved")},onError:w=>pe.error(w.message)}),p=Pt({mutationFn:async w=>{const{error:S}=await G.from("agent_booking_types").delete().eq("id",w);if(S)throw S},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),pe.success("Booking type deleted")},onError:w=>pe.error(w.message)}),f=Pt({mutationFn:async w=>{const S={...w,user_id:t.id};if(w.id){const{error:C}=await G.from("agent_availability_slots").update(S).eq("id",w.id);if(C)throw C}else{const{error:C}=await G.from("agent_availability_slots").insert(S);if(C)throw C}},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:w=>pe.error(w.message)}),y=Pt({mutationFn:async w=>{const{error:S}=await G.from("agent_availability_slots").delete().eq("id",w);if(S)throw S},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:w=>pe.error(w.message)}),_=Pt({mutationFn:async w=>{const{error:S}=await G.from("agent_blocked_dates").insert({...w,user_id:t.id});if(S)throw S},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]}),pe.success("Date blocked")},onError:w=>pe.error(w.message)}),b=Pt({mutationFn:async w=>{const{error:S}=await G.from("agent_blocked_dates").delete().eq("id",w);if(S)throw S},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]})},onError:w=>pe.error(w.message)}),N=Pt({mutationFn:async({id:w,reason:S})=>{const{error:C}=await G.from("bookings").update({status:"cancelled",cancelled_at:new Date().toISOString(),cancel_reason:S}).eq("id",w);if(C)throw C},onSuccess:()=>{s.invalidateQueries({queryKey:["bookings"]}),pe.success("Booking cancelled")},onError:w=>pe.error(w.message)});return{settings:r.data,bookingTypes:n.data??[],availability:a.data??[],blockedDates:o.data??[],bookings:l.data??[],isLoading:r.isLoading,initializeSettings:i,updateSettings:d,upsertBookingType:u,deleteBookingType:p,upsertAvailability:f,deleteAvailability:y,addBlockedDate:_,removeBlockedDate:b,cancelBooking:N}}const Z9e={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function MMs({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)},d=p=>{a({...p}),l(!0)},u=()=>{n!=null&&n.name&&(s(n),l(!1),a(null))};return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Booking Types"}),e.jsx(dr,{children:"The meeting types prospects can book with you"})]}),e.jsxs(W,{onClick:i,size:"sm",children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Add Type"]})]}),e.jsx(Oe,{children:t.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No booking types yet. Add one to get started."}):e.jsx("div",{className:"grid gap-3",children:t.map(p=>e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center text-lg",style:{backgroundColor:p.color+"20"},children:Z9e[p.icon]||"📅"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium",children:p.name}),!p.is_active&&e.jsx(Qe,{variant:"secondary",className:"text-xs",children:"Inactive"}),p.qualification_enabled&&e.jsxs(Qe,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(kL,{className:"h-3 w-3"})," Qualifying"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(nn,{className:"h-3 w-3"}),p.duration_minutes," min",p.description&&e.jsxs("span",{children:["· ",p.description.slice(0,60),p.description.length>60?"...":""]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>d(p),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>r(p.id),className:"text-destructive hover:text-destructive",children:e.jsx(vr,{className:"h-4 w-4"})})]})]},p.id))})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{children:[e.jsx(ks,{children:e.jsxs(_s,{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(xe,{children:"Name"}),e.jsx(De,{value:n.name||"",onChange:p=>a({...n,name:p.target.value}),placeholder:"e.g. Listing Consultation"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Description"}),e.jsx(_r,{value:n.description||"",onChange:p=>a({...n,description:p.target.value}),placeholder:"Brief description for prospects",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Duration (minutes)"}),e.jsx(De,{type:"number",min:15,max:180,step:15,value:n.duration_minutes||30,onChange:p=>a({...n,duration_minutes:parseInt(p.target.value)||30})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Color"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:n.color||"#3B82F6",onChange:p=>a({...n,color:p.target.value}),className:"h-10 w-10 rounded border cursor-pointer"}),e.jsx(De,{value:n.color||"#3B82F6",onChange:p=>a({...n,color:p.target.value}),className:"flex-1"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Icon"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(Z9e).map(([p,f])=>e.jsx("button",{onClick:()=>a({...n,icon:p}),className:`w-10 h-10 rounded-lg text-lg flex items-center justify-center border transition-colors ${n.icon===p?"border-primary bg-primary/10":"hover:bg-muted"}`,children:f},p))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Meeting Link Override (optional)"}),e.jsx(De,{value:n.meeting_link_override||"",onChange:p=>a({...n,meeting_link_override:p.target.value||null}),placeholder:"Use a different link for this type"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Pre-Qualification Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ask qualifying questions before booking"})]}),e.jsx(Ar,{checked:n.qualification_enabled||!1,onCheckedChange:p=>a({...n,qualification_enabled:p})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{children:"Active"}),e.jsx(Ar,{checked:n.is_active??!0,onCheckedChange:p=>a({...n,is_active:p})})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(W,{onClick:u,children:"Save"})]})]})})]})}const Y9e=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function TMs({slots:t,onSave:s,onDelete:r}){const[n,a]=k.useState(null),[o,l]=k.useState("09:00"),[i,d]=k.useState("17:00"),u=Y9e.map((f,y)=>t.filter(_=>_.day_of_week===y)),p=()=>{n!==null&&(s({day_of_week:n,start_time:o,end_time:i,is_active:!0}),a(null),l("09:00"),d("17:00"))};return e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(nn,{className:"h-5 w-5"}),"Weekly Availability"]}),e.jsx(dr,{children:"Set your available hours for each day"})]}),e.jsx(Oe,{className:"space-y-2",children:Y9e.map((f,y)=>{const _=u[y];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:[_.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-1",children:"Unavailable"}):_.map(b=>{var N,w;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{type:"time",className:"w-28 h-8 text-sm",defaultValue:(N=b.start_time)==null?void 0:N.slice(0,5),onBlur:S=>s({id:b.id,start_time:S.target.value})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"to"}),e.jsx(De,{type:"time",className:"w-28 h-8 text-sm",defaultValue:(w=b.end_time)==null?void 0:w.slice(0,5),onBlur:S=>s({id:b.id,end_time:S.target.value})}),e.jsx(Ar,{checked:b.is_active,onCheckedChange:S=>s({id:b.id,is_active:S})}),e.jsx(W,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>r(b.id),children:e.jsx(vr,{className:"h-3.5 w-3.5 text-muted-foreground"})})]},b.id)}),n===y?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{type:"time",className:"w-28 h-8 text-sm",value:o,onChange:b=>l(b.target.value)}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"to"}),e.jsx(De,{type:"time",className:"w-28 h-8 text-sm",value:i,onChange:b=>d(b.target.value)}),e.jsx(W,{size:"sm",className:"h-8",onClick:p,children:"Add"}),e.jsx(W,{variant:"ghost",size:"sm",className:"h-8",onClick:()=>a(null),children:"Cancel"})]}):e.jsxs(W,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground",onClick:()=>a(y),children:[e.jsx(qs,{className:"h-3 w-3 mr-1"})," Add hours"]})]})]},f)})})]})}const AMs={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 EMs({bookings:t,onCancel:s}){const r=t.filter(o=>o.status==="confirmed"&&new Date(o.booking_date)>=new Date(new Date().toDateString())),n=t.filter(o=>o.status!=="confirmed"||new Date(o.booking_date){var i,d;return e.jsxs("div",{className:"flex items-start justify-between p-4 rounded-lg border hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ai,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:o.guest_name}),e.jsx(Qe,{className:`text-xs ${AMs[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(_d,{className:"h-3.5 w-3.5"}),vs(new Date(o.booking_date+"T00:00:00"),"MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nn,{className:"h-3.5 w-3.5"}),(i=o.start_time)==null?void 0:i.slice(0,5)," - ",(d=o.end_time)==null?void 0:d.slice(0,5)]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:[o.guest_email&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(tr,{className:"h-3 w-3"}),o.guest_email]}),o.guest_phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(In,{className:"h-3 w-3"}),o.guest_phone]})]}),o.booking_type&&e.jsx(Qe,{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(W,{variant:"ghost",size:"sm",onClick:()=>s(o.id),className:"text-destructive hover:text-destructive",children:[e.jsx(Jl,{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(Dt,{children:[e.jsx(zt,{children:"Upcoming Bookings"}),e.jsxs(dr,{children:[r.length," upcoming appointment",r.length!==1?"s":""]})]}),e.jsx(Oe,{children:r.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No upcoming bookings"}):e.jsx("div",{className:"space-y-3",children:r.map(o=>a(o,!0))})})]}),n.length>0&&e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Past & Cancelled"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:n.slice(0,20).map(o=>a(o))})})]})]})}function PMs({blockedDates:t,onAdd:s,onRemove:r}){const[n,a]=k.useState(!1),[o,l]=k.useState(""),[i,d]=k.useState(""),u=()=>{o&&(s({blocked_date:o,reason:i||void 0}),a(!1),l(""),d(""))};return e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(dL,{className:"h-5 w-5"}),"Blocked Dates"]}),e.jsx(dr,{children:"Block specific dates (vacations, holidays, etc.)"})]}),e.jsxs(W,{size:"sm",variant:"outline",onClick:()=>a(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Block Date"]})]}),e.jsxs(Oe,{children:[n&&e.jsxs("div",{className:"flex items-center gap-2 mb-3 p-3 rounded-lg border bg-muted/30",children:[e.jsx(De,{type:"date",value:o,onChange:p=>l(p.target.value),className:"w-40"}),e.jsx(De,{placeholder:"Reason (optional)",value:i,onChange:p=>d(p.target.value),className:"flex-1"}),e.jsx(W,{size:"sm",onClick:u,children:"Add"}),e.jsx(W,{size:"sm",variant:"ghost",onClick:()=>a(!1),children:"Cancel"})]}),t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No blocked dates"}):e.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(p=>e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full border bg-muted/50 text-sm",children:[e.jsx("span",{children:vs(new Date(p.blocked_date+"T00:00:00"),"MMM d, yyyy")}),p.reason&&e.jsxs("span",{className:"text-muted-foreground",children:["(",p.reason,")"]}),e.jsx("button",{onClick:()=>r(p.id),className:"ml-1 text-muted-foreground hover:text-destructive",children:e.jsx(kr,{className:"h-3.5 w-3.5"})})]},p.id))})]})]})}function IMs(){const{settings:t,bookingTypes:s,availability:r,blockedDates:n,bookings:a,isLoading:o,initializeSettings:l,updateSettings:i,upsertBookingType:d,deleteBookingType:u,upsertAvailability:p,deleteAvailability:f,addBlockedDate:y,removeBlockedDate:_,cancelBooking:b}=CMs(),[N,w]=k.useState("");k.useState(15),N||t!=null&&t.meeting_link;const S=t!=null&&t.slug?`https://booking.relevelup.com/${t.slug}`:null;return o?e.jsx(Ds,{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(Ds,{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(_d,{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:[S&&e.jsxs(e.Fragment,{children:[e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(S),pe.success("Booking link copied!")},children:[e.jsx(Va,{className:"h-4 w-4 mr-1"})," Copy Link"]}),e.jsx(W,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:S,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Yr,{className:"h-4 w-4 mr-1"})," Preview"]})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{htmlFor:"scheduler-active",className:"text-sm",children:"Active"}),e.jsx(Ar,{id:"scheduler-active",checked:t.is_active,onCheckedChange:C=>i.mutate({is_active:C})})]})]})]}),e.jsxs(ta,{defaultValue:"types",className:"space-y-4",children:[e.jsxs(Jn,{children:[e.jsx(cs,{value:"types",children:"Booking Types"}),e.jsx(cs,{value:"availability",children:"Availability"}),e.jsx(cs,{value:"settings",children:"Settings"}),e.jsxs(cs,{value:"bookings",children:["Bookings",a.filter(C=>C.status==="confirmed").length>0&&e.jsx(Qe,{variant:"secondary",className:"ml-1.5 text-xs",children:a.filter(C=>C.status==="confirmed").length})]})]}),e.jsx(Ss,{value:"types",children:e.jsx(MMs,{types:s,onSave:C=>d.mutate(C),onDelete:C=>u.mutate(C)})}),e.jsx(Ss,{value:"availability",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(TMs,{slots:r,onSave:C=>p.mutate(C),onDelete:C=>f.mutate(C)}),e.jsx(PMs,{blockedDates:n,onAdd:C=>y.mutate(C),onRemove:C=>_.mutate(C)})]})}),e.jsx(Ss,{value:"settings",children:e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(FL,{className:"h-5 w-5"}),"General Settings"]}),e.jsx(dr,{children:"Configure your booking page defaults"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Booking Page URL"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{value:t.slug,readOnly:!0,className:"bg-muted"}),e.jsx(W,{variant:"outline",size:"sm",onClick:()=>{S&&(navigator.clipboard.writeText(S),pe.success("Copied!"))},children:e.jsx(Va,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{htmlFor:"meeting-link",children:[e.jsx(Do,{className:"h-4 w-4 inline mr-1"}),"Default Meeting Link"]}),e.jsx(De,{id:"meeting-link",placeholder:"https://zoom.us/j/your-personal-link",defaultValue:t.meeting_link||"",onBlur:C=>i.mutate({meeting_link:C.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(xe,{children:"Buffer Between Meetings"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{type:"number",min:0,max:60,defaultValue:t.buffer_minutes,onBlur:C=>i.mutate({buffer_minutes:parseInt(C.target.value)||15})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"min"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Minimum Notice"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{type:"number",min:0,max:72,defaultValue:t.min_notice_hours,onBlur:C=>i.mutate({min_notice_hours:parseInt(C.target.value)||2})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"hours"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Max Advance Booking"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{type:"number",min:1,max:90,defaultValue:t.max_advance_days,onBlur:C=>i.mutate({max_advance_days:parseInt(C.target.value)||30})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"days"})]})]})]})]})]})}),e.jsx(Ss,{value:"bookings",children:e.jsx(EMs,{bookings:a,onCancel:C=>b.mutate({id:C})})})]})]})}):e.jsx(Ds,{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(_d,{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(Oe,{className:"pt-6 space-y-4",children:[e.jsx("div",{className:"grid grid-cols-2 gap-4",children:[{icon:"🏠",title:"Listing Consultation",desc:"60 min"},{icon:"🔍",title:"Buyer Consultation",desc:"45 min"},{icon:"💰",title:"Home Valuation",desc:"30 min"},{icon:"☕",title:"General Meeting",desc:"30 min"}].map(C=>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:C.icon}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:C.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C.desc})]})]},C.title))}),e.jsx(ho,{}),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(W,{onClick:()=>l.mutate(),disabled:l.isPending,className:"w-full",size:"lg",children:[e.jsx(Or,{className:"h-4 w-4 mr-2"}),l.isPending?"Setting up...":"Activate Scheduler"]})]})})]})})}const X9e=[{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 LMs(){const{user:t}=Us(),s=ya(),{toast:r}=ja(),n=wr(),a=Qt(),[o,l]=k.useState(!1),[i,d]=k.useState(null),[u,p]=k.useState(null),[f,y]=k.useState({title:"",description:"",page_type:"lead_capture"}),{data:_=[],isLoading:b}=gt({queryKey:["landing-pages",s],queryFn:async()=>{const{data:C,error:A}=await G.from("landing_pages").select("*").eq("user_id",s).order("created_at",{ascending:!1});if(A)throw A;return C},enabled:!!s}),N=Pt({mutationFn:async()=>{const C=f.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,"")+"-"+Date.now().toString(36),{data:A}=await G.from("profiles").select("name, phone, avatar_url, email").eq("id",s).single(),I=f.page_type==="just_listed"||f.page_type==="just_sold",{data:L,error:O}=await G.from("landing_pages").insert({user_id:s,title:f.title,description:f.description||null,page_type:f.page_type,slug:C,hero_headline:I?f.page_type==="just_listed"?"🏡 Just Listed":"🎉 Just Sold":f.page_type==="lead_magnet"?"📥 Free Download":f.title,agent_name:(A==null?void 0:A.name)||null,agent_phone:(A==null?void 0:A.phone)||null,agent_email:(A==null?void 0:A.email)||t.email||null,agent_photo_url:(A==null?void 0:A.avatar_url)||null,property_status:I?f.page_type.replace("just_",""):null}).select().single();if(O)throw O;const V=DMs(f.page_type);if(V.length>0){const{error:q}=await G.from("landing_page_fields").insert(V.map((B,U)=>({...B,page_id:L.id,sort_order:U})));if(q)throw q}return L},onSuccess:C=>{a.invalidateQueries({queryKey:["landing-pages"]}),l(!1),y({title:"",description:"",page_type:"lead_capture"}),r({title:"Landing page created!"}),n(`/mission-control/landing-pages/${C.id}`)},onError:C=>r({title:"Error",description:C.message,variant:"destructive"})}),w=Pt({mutationFn:async C=>{const{error:A}=await G.from("landing_pages").delete().eq("id",C);if(A)throw A},onSuccess:()=>{a.invalidateQueries({queryKey:["landing-pages"]}),d(null),r({title:"Landing page deleted"})}}),S=C=>`https://pages.relevelup.com/${C}`;return e.jsxs(Ds,{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(W,{onClick:()=>l(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"})," New Page"]})]}),b?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):_.length===0?e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(vn,{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(W,{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:_.map(C=>{var A;return e.jsx(Pe,{className:"hover:shadow-md transition-shadow",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0 cursor-pointer",onClick:()=>n(`/mission-control/landing-pages/${C.id}`),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold truncate",children:C.title}),e.jsx(Qe,{variant:C.is_published?"default":"secondary",className:"text-[10px]",children:C.is_published?"Published":"Draft"}),e.jsx(Qe,{variant:"outline",className:"text-[10px]",children:((A=X9e.find(I=>I.id===C.page_type))==null?void 0:A.label)||C.page_type})]}),C.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:C.description}),e.jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(jn,{className:"h-3 w-3"})," ",C.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(vn,{className:"h-3 w-3"})," ",C.submission_count," submissions"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[C.is_published&&e.jsxs(e.Fragment,{children:[e.jsx(W,{size:"sm",variant:"outline",onClick:()=>p(S(C.slug)),children:e.jsx(Jy,{className:"h-3.5 w-3.5"})}),e.jsx(W,{size:"sm",variant:"outline",onClick:()=>{navigator.clipboard.writeText(S(C.slug)),r({title:"Link copied!"})},children:e.jsx(Va,{className:"h-3.5 w-3.5"})}),e.jsx(W,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:S(C.slug),target:"_blank",rel:"noopener noreferrer",children:e.jsx(Yr,{className:"h-3.5 w-3.5"})})})]}),e.jsxs(Hd,{children:[e.jsx(Gd,{asChild:!0,children:e.jsx(W,{size:"sm",variant:"ghost",children:e.jsx(ix,{className:"h-4 w-4"})})}),e.jsxs(Nd,{align:"end",children:[e.jsxs(_a,{onClick:()=>n(`/mission-control/landing-pages/${C.id}`),children:[e.jsx(ga,{className:"h-3.5 w-3.5 mr-2"})," Edit"]}),e.jsxs(_a,{onClick:()=>d(C.id),className:"text-destructive",children:[e.jsx(vr,{className:"h-3.5 w-3.5 mr-2"})," Delete"]})]})]})]})]})})},C.id)})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(ps,{children:[e.jsx(ks,{children:e.jsx(_s,{children:"Create Landing Page"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Page Title"}),e.jsx(De,{value:f.title,onChange:C=>y(A=>({...A,title:C.target.value})),placeholder:"e.g. Veterans Home & Land Expo"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Description (optional)"}),e.jsx(_r,{value:f.description,onChange:C=>y(A=>({...A,description:C.target.value})),placeholder:"Brief internal description...",rows:2})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Page Template"}),e.jsxs($s,{value:f.page_type,onValueChange:C=>y(A=>({...A,page_type:C})),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsx(Bs,{children:X9e.map(C=>e.jsx(vt,{value:C.id,children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:C.label}),e.jsx("div",{className:"text-xs text-muted-foreground",children:C.description})]})},C.id))})]})]})]}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(W,{onClick:()=>N.mutate(),disabled:!f.title.trim()||N.isPending,children:N.isPending?"Creating...":"Create Page"})]})]})}),e.jsx(Rl,{open:!!i,onOpenChange:()=>d(null),children:e.jsxs(gl,{children:[e.jsxs(yl,{children:[e.jsx(_l,{children:"Delete Landing Page?"}),e.jsx(bl,{children:"This will permanently delete this page and all its submissions."})]}),e.jsxs(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:()=>i&&w.mutate(i),children:"Delete"})]})]})}),e.jsx(fs,{open:!!u,onOpenChange:()=>p(null),children:e.jsxs(ps,{className:"max-w-sm",children:[e.jsx(ks,{children:e.jsx(_s,{children:"QR Code"})}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[u&&e.jsx(EO,{value:u,size:240}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:u}),e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>{u&&(navigator.clipboard.writeText(u),r({title:"URL copied!"}))},children:[e.jsx(Va,{className:"h-3.5 w-3.5 mr-1"})," Copy URL"]})]})]})})]})}function DMs(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 RMs=[{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 OMs(){const{pageId:t}=io(),s=wr(),{user:r}=Us(),n=ya(),{toast:a}=ja(),o=Qt(),[l,i]=k.useState(null),[d,u]=k.useState(!1),{data:p,isLoading:f}=gt({queryKey:["landing-page",t],queryFn:async()=>{const{data:ie,error:ae}=await G.from("landing_pages").select("*").eq("id",t).single();if(ae)throw ae;return ie},enabled:!!t}),{data:y=[],isLoading:_}=gt({queryKey:["landing-page-fields",t],queryFn:async()=>{const{data:ie,error:ae}=await G.from("landing_page_fields").select("*").eq("page_id",t).order("sort_order");if(ae)throw ae;return ie},enabled:!!t}),{data:b=[]}=gt({queryKey:["landing-page-submissions",t],queryFn:async()=>{const{data:ie,error:ae}=await G.from("landing_page_submissions").select("*").eq("page_id",t).order("created_at",{ascending:!1});if(ae)throw ae;return ie},enabled:!!t}),{data:N=[]}=gt({queryKey:["my-listings-for-pages",n],queryFn:async()=>{const{data:ie,error:ae}=await G.from("listings").select("id, property_address, city, state, price, bedrooms, bathrooms, square_footage, description, status").eq("agent_id",n).order("created_at",{ascending:!1});if(ae)throw ae;return ie},enabled:!!r&&((p==null?void 0:p.page_type)==="just_listed"||(p==null?void 0:p.page_type)==="just_sold")}),[w,S]=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"}),[C,A]=k.useState([]);k.useEffect(()=>{p&&S({title:p.title,hero_headline:p.hero_headline,hero_subtext:p.hero_subtext||"",hero_image_url:p.hero_image_url,logo_url:p.logo_url,primary_color:p.primary_color,accent_color:p.accent_color,agent_name:p.agent_name||"",agent_phone:p.agent_phone||"",agent_email:p.agent_email||"",agent_photo_url:p.agent_photo_url,success_message:p.success_message||"Thank you! We'll be in touch soon.",is_published:p.is_published,description:p.description||"",lead_magnet_file_url:p.lead_magnet_file_url||null,lead_magnet_file_name:p.lead_magnet_file_name||null,lead_magnet_external_url:p.lead_magnet_external_url||null,listing_id:p.listing_id||null,property_address:p.property_address||"",property_price:p.property_price||"",property_beds:p.property_beds||"",property_baths:p.property_baths||"",property_sqft:p.property_sqft||"",property_description:p.property_description||"",property_photos:Array.isArray(p.property_photos)?p.property_photos:[],property_status:p.property_status||"just_listed"})},[p]),k.useEffect(()=>{y.length>0&&A(y.map(ie=>({id:ie.id,field_type:ie.field_type,label:ie.label,placeholder:ie.placeholder,is_required:ie.is_required,options:typeof ie.options=="string"?ie.options:ie.options?JSON.stringify(ie.options):null,sort_order:ie.sort_order})))},[y]);const I=Pt({mutationFn:async()=>{const{error:ie}=await G.from("landing_pages").update({title:w.title,hero_headline:w.hero_headline,hero_subtext:w.hero_subtext||null,hero_image_url:w.hero_image_url,logo_url:w.logo_url,primary_color:w.primary_color,accent_color:w.accent_color,agent_name:w.agent_name||null,agent_phone:w.agent_phone||null,agent_email:w.agent_email||null,agent_photo_url:w.agent_photo_url,success_message:w.success_message,is_published:w.is_published,description:w.description||null,lead_magnet_file_url:w.lead_magnet_file_url,lead_magnet_file_name:w.lead_magnet_file_name,lead_magnet_external_url:w.lead_magnet_external_url,listing_id:w.listing_id,property_address:w.property_address||null,property_price:w.property_price||null,property_beds:w.property_beds||null,property_baths:w.property_baths||null,property_sqft:w.property_sqft||null,property_description:w.property_description||null,property_photos:w.property_photos,property_status:w.property_status,updated_at:new Date().toISOString()}).eq("id",t);if(ie)throw ie;if(await G.from("landing_page_fields").delete().eq("page_id",t),C.length>0){const{error:ae}=await G.from("landing_page_fields").insert(C.map((oe,me)=>({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:me})));if(ae)throw ae}},onSuccess:()=>{o.invalidateQueries({queryKey:["landing-page",t]}),o.invalidateQueries({queryKey:["landing-page-fields",t]}),a({title:"Page saved!"})},onError:ie=>a({title:"Error",description:ie.message,variant:"destructive"})}),L=async(ie,ae)=>{const oe=ie.name.split(".").pop(),me=`landing-pages/${r.id}/${ae}-${Date.now()}.${oe}`,{error:ve}=await G.storage.from("recruit-landing").upload(me,ie);if(ve)throw ve;const{data:{publicUrl:he}}=G.storage.from("recruit-landing").getPublicUrl(me);return he},O=async(ie,ae)=>{var me;const oe=(me=ie.target.files)==null?void 0:me[0];if(oe){i(ae);try{const ve=await L(oe,ae);S(he=>({...he,[ae]:ve})),a({title:"Image uploaded!"})}catch(ve){a({title:"Upload failed",description:ve.message,variant:"destructive"})}finally{i(null)}}},V=async ie=>{var oe;const ae=(oe=ie.target.files)==null?void 0:oe[0];if(ae){i("lead_magnet");try{const me=await L(ae,"lead-magnet");S(ve=>({...ve,lead_magnet_file_url:me,lead_magnet_file_name:ae.name})),a({title:"File uploaded!"})}catch(me){a({title:"Upload failed",description:me.message,variant:"destructive"})}finally{i(null)}}},q=async ie=>{const ae=ie.target.files;if(!(!ae||ae.length===0)){i("property_photos");try{const oe=[];for(const me of Array.from(ae)){const ve=await L(me,"property-photo");oe.push(ve)}S(me=>({...me,property_photos:[...me.property_photos,...oe]})),a({title:`${oe.length} photo(s) uploaded!`})}catch(oe){a({title:"Upload failed",description:oe.message,variant:"destructive"})}finally{i(null)}}},B=async ie=>{const ae=N.find(me=>me.id===ie);if(!ae)return;const{data:oe}=await G.from("listing_photos").select("photo_url").eq("listing_id",ie).order("sort_order");S(me=>({...me,listing_id:ie,property_address:ae.property_address||`${ae.city}, ${ae.state}`,property_price:ae.price?`$${ae.price.toLocaleString()}`:"",property_beds:ae.bedrooms?String(ae.bedrooms):"",property_baths:ae.bathrooms?String(ae.bathrooms):"",property_sqft:ae.square_footage?ae.square_footage.toLocaleString():"",property_description:ae.description||"",property_photos:(oe==null?void 0:oe.map(ve=>ve.photo_url))||me.property_photos})),a({title:"Listing data imported!"})},U=()=>{A(ie=>[...ie,{field_type:"text",label:"",placeholder:"",is_required:!1,options:null,sort_order:ie.length}])},te=(ie,ae)=>{A(oe=>oe.map((me,ve)=>ve===ie?{...me,...ae}:me))},Y=ie=>{A(ae=>ae.filter((oe,me)=>me!==ie))},J=p?`https://pages.relevelup.com/${p.slug}`:"",X=(p==null?void 0:p.page_type)==="lead_magnet",ce=(p==null?void 0:p.page_type)==="just_listed"||(p==null?void 0:p.page_type)==="just_sold";return f||_?e.jsx(Ds,{title:"Loading...",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):p?e.jsxs(Ds,{title:w.title||"Edit Page",children:[e.jsxs("div",{className:"space-y-6 max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/landing-pages"),children:e.jsx(Oa,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold",children:w.title||"Untitled Page"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx(Qe,{variant:w.is_published?"default":"secondary",className:"text-[10px]",children:w.is_published?"Published":"Draft"}),e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(jn,{className:"h-3 w-3"})," ",p.view_count," views"]}),e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(ir,{className:"h-3 w-3"})," ",b.length," submissions"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[w.is_published&&e.jsxs(e.Fragment,{children:[e.jsx(W,{size:"sm",variant:"outline",onClick:()=>u(!0),children:e.jsx(Jy,{className:"h-3.5 w-3.5"})}),e.jsxs(W,{size:"sm",variant:"outline",onClick:()=>{navigator.clipboard.writeText(J),a({title:"Link copied!"})},children:[e.jsx(Va,{className:"h-3.5 w-3.5 mr-1"})," Copy Link"]}),e.jsx(W,{size:"sm",variant:"outline",asChild:!0,children:e.jsxs("a",{href:J,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Yr,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(W,{onClick:()=>I.mutate(),disabled:I.isPending,children:[e.jsx(bc,{className:"h-4 w-4 mr-2"}),I.isPending?"Saving...":"Save"]})]})]}),e.jsxs(ta,{defaultValue:"design",children:[e.jsxs(Jn,{children:[e.jsx(cs,{value:"design",children:"Design"}),X&&e.jsx(cs,{value:"lead_magnet",children:"Lead Magnet"}),ce&&e.jsx(cs,{value:"property",children:"Property Details"}),e.jsxs(cs,{value:"fields",children:["Form Fields (",C.length,")"]}),e.jsxs(cs,{value:"submissions",children:["Submissions (",b.length,")"]}),e.jsx(cs,{value:"settings",children:"Settings"})]}),e.jsxs(Ss,{value:"design",className:"space-y-4 mt-4",children:[e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Page Details"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Page Title (internal)"}),e.jsx(De,{value:w.title,onChange:ie=>S(ae=>({...ae,title:ie.target.value}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Description (internal)"}),e.jsx(De,{value:w.description,onChange:ie=>S(ae=>({...ae,description:ie.target.value}))})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Hero Section"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Headline"}),e.jsx(De,{value:w.hero_headline,onChange:ie=>S(ae=>({...ae,hero_headline:ie.target.value})),placeholder:"Join us for..."})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Subtext"}),e.jsx(_r,{value:w.hero_subtext,onChange:ie=>S(ae=>({...ae,hero_subtext:ie.target.value})),rows:2,placeholder:"A brief description..."})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Background Image"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[w.hero_image_url&&e.jsx("img",{src:w.hero_image_url,alt:"Hero",className:"h-16 w-28 object-cover rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(W,{variant:"outline",size:"sm",asChild:!0,disabled:l==="hero_image_url",children:e.jsxs("span",{children:[e.jsx(Ra,{className:"h-3.5 w-3.5 mr-1"}),l==="hero_image_url"?"Uploading...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:ie=>O(ie,"hero_image_url")})]}),w.hero_image_url&&e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>S(ie=>({...ie,hero_image_url:null})),children:e.jsx(vr,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Branding"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Logo"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[w.logo_url&&e.jsx("img",{src:w.logo_url,alt:"Logo",className:"h-10 w-auto rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(W,{variant:"outline",size:"sm",asChild:!0,disabled:l==="logo_url",children:e.jsxs("span",{children:[e.jsx(Ra,{className:"h-3.5 w-3.5 mr-1"}),l==="logo_url"?"...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:ie=>O(ie,"logo_url")})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Agent Photo"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[w.agent_photo_url&&e.jsx("img",{src:w.agent_photo_url,alt:"Agent",className:"h-10 w-10 rounded-full object-cover"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(W,{variant:"outline",size:"sm",asChild:!0,disabled:l==="agent_photo_url",children:e.jsxs("span",{children:[e.jsx(Ra,{className:"h-3.5 w-3.5 mr-1"}),l==="agent_photo_url"?"...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:ie=>O(ie,"agent_photo_url")})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Primary Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:w.primary_color,onChange:ie=>S(ae=>({...ae,primary_color:ie.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(De,{value:w.primary_color,onChange:ie=>S(ae=>({...ae,primary_color:ie.target.value})),className:"font-mono text-xs"})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Accent Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:w.accent_color,onChange:ie=>S(ae=>({...ae,accent_color:ie.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(De,{value:w.accent_color,onChange:ie=>S(ae=>({...ae,accent_color:ie.target.value})),className:"font-mono text-xs"})]})]})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Agent Info (shown on page)"})}),e.jsx(Oe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Name"}),e.jsx(De,{value:w.agent_name,onChange:ie=>S(ae=>({...ae,agent_name:ie.target.value}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Phone"}),e.jsx(De,{value:w.agent_phone,onChange:ie=>S(ae=>({...ae,agent_phone:ie.target.value}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Email"}),e.jsx(De,{value:w.agent_email,onChange:ie=>S(ae=>({...ae,agent_email:ie.target.value}))})]})]})})]})]}),X&&e.jsx(Ss,{value:"lead_magnet",className:"space-y-4 mt-4",children:e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Qa,{className:"h-4 w-4"})," Giveaway File"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Upload a file or provide an external URL. Visitors will receive the download link after submitting the form."}),e.jsxs("div",{children:[e.jsx(xe,{children:"Upload File (PDF, guide, checklist, etc.)"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[w.lead_magnet_file_name&&e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(Qa,{className:"h-3 w-3"})," ",w.lead_magnet_file_name]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(W,{variant:"outline",size:"sm",asChild:!0,disabled:l==="lead_magnet",children:e.jsxs("span",{children:[e.jsx(Ra,{className:"h-3.5 w-3.5 mr-1"}),l==="lead_magnet"?"Uploading...":"Upload File"]})}),e.jsx("input",{type:"file",className:"hidden",onChange:V})]}),w.lead_magnet_file_url&&e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>S(ie=>({...ie,lead_magnet_file_url:null,lead_magnet_file_name:null})),children:e.jsx(vr,{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(xe,{className:"flex items-center gap-1",children:[e.jsx(Do,{className:"h-3.5 w-3.5"})," External URL"]}),e.jsx(De,{value:w.lead_magnet_external_url||"",onChange:ie=>S(ae=>({...ae,lead_magnet_external_url:ie.target.value||null})),placeholder:"https://drive.google.com/... or https://dropbox.com/...",className:"mt-1"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Link to a file on Google Drive, Dropbox, or any URL"})]})]})]})}),ce&&e.jsxs(Ss,{value:"property",className:"space-y-4 mt-4",children:[e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Mn,{className:"h-4 w-4"})," Import from Listing Exchange"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pull property details and photos directly from one of your listings, or enter them manually below."}),e.jsxs($s,{value:w.listing_id||"",onValueChange:ie=>B(ie),children:[e.jsx(zs,{children:e.jsx(Vs,{placeholder:"Select a listing to import..."})}),e.jsx(Bs,{children:N.map(ie=>{var ae;return e.jsxs(vt,{value:ie.id,children:[ie.property_address||`${ie.city}, ${ie.state}`," — $",(ae=ie.price)==null?void 0:ae.toLocaleString()]},ie.id)})})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Property Information"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Property Address"}),e.jsx(De,{value:w.property_address,onChange:ie=>S(ae=>({...ae,property_address:ie.target.value})),placeholder:"123 Main St, City, State"})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Price"}),e.jsx(De,{value:w.property_price,onChange:ie=>S(ae=>({...ae,property_price:ie.target.value})),placeholder:"$450,000"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Beds"}),e.jsx(De,{value:w.property_beds,onChange:ie=>S(ae=>({...ae,property_beds:ie.target.value})),placeholder:"4"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Baths"}),e.jsx(De,{value:w.property_baths,onChange:ie=>S(ae=>({...ae,property_baths:ie.target.value})),placeholder:"3"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Sq Ft"}),e.jsx(De,{value:w.property_sqft,onChange:ie=>S(ae=>({...ae,property_sqft:ie.target.value})),placeholder:"2,400"})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Description"}),e.jsx(_r,{value:w.property_description,onChange:ie=>S(ae=>({...ae,property_description:ie.target.value})),rows:3,placeholder:"Beautiful home in a great neighborhood..."})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Property Photos"})}),e.jsxs(Oe,{className:"space-y-4",children:[w.property_photos.length>0&&e.jsx("div",{className:"grid grid-cols-3 md:grid-cols-4 gap-2",children:w.property_photos.map((ie,ae)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:ie,alt:`Property ${ae+1}`,className:"h-24 w-full object-cover rounded"}),e.jsx(W,{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:()=>S(oe=>({...oe,property_photos:oe.property_photos.filter((me,ve)=>ve!==ae)})),children:e.jsx(vr,{className:"h-3 w-3"})})]},ae))}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(W,{variant:"outline",size:"sm",asChild:!0,disabled:l==="property_photos",children:e.jsxs("span",{children:[e.jsx(Ra,{className:"h-3.5 w-3.5 mr-1"}),l==="property_photos"?"Uploading...":"Add Photos"]})}),e.jsx("input",{type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:q})]})]})]})]}),e.jsxs(Ss,{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(W,{size:"sm",onClick:U,children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1"})," Add Field"]})]}),C.length===0?e.jsx(Pe,{children:e.jsx(Oe,{className:"py-8 text-center text-muted-foreground",children:"No fields yet. Add fields to build your form."})}):e.jsx("div",{className:"space-y-3",children:C.map((ie,ae)=>e.jsx(Pe,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(mu,{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(xe,{className:"text-xs",children:"Field Type"}),e.jsxs($s,{value:ie.field_type,onValueChange:oe=>te(ae,{field_type:oe}),children:[e.jsx(zs,{children:e.jsx(Vs,{})}),e.jsx(Bs,{children:RMs.map(oe=>e.jsx(vt,{value:oe.value,children:oe.label},oe.value))})]})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Label"}),e.jsx(De,{value:ie.label,onChange:oe=>te(ae,{label:oe.target.value}),placeholder:"e.g. Full Name"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Placeholder"}),e.jsx(De,{value:ie.placeholder||"",onChange:oe=>te(ae,{placeholder:oe.target.value}),placeholder:"Optional hint text"})]})]}),(ie.field_type==="select"||ie.field_type==="multiselect")&&e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Options (comma-separated)"}),e.jsx(De,{value:ie.options?(typeof ie.options=="string"?JSON.parse(ie.options):ie.options).join(", "):"",onChange:oe=>te(ae,{options:JSON.stringify(oe.target.value.split(",").map(me=>me.trim()).filter(Boolean))}),placeholder:"Option 1, Option 2, Option 3"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ar,{checked:ie.is_required,onCheckedChange:oe=>te(ae,{is_required:oe})}),e.jsx(xe,{className:"text-xs",children:"Required"})]})]}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>Y(ae),children:e.jsx(vr,{className:"h-3.5 w-3.5 text-destructive"})})]})})},ae))})]}),e.jsx(Ss,{value:"submissions",className:"mt-4",children:b.length===0?e.jsx(Pe,{children:e.jsx(Oe,{className:"py-12 text-center text-muted-foreground",children:"No submissions yet. Share your page to start collecting leads!"})}):e.jsx("div",{className:"space-y-3",children:b.map(ie=>e.jsx(Pe,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:ie.contact_name||"Anonymous"}),ie.synced_to_crm&&e.jsx(Qe,{variant:"outline",className:"text-[10px]",children:"Synced"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground mt-0.5",children:[ie.contact_email&&e.jsx("span",{className:"mr-3",children:ie.contact_email}),ie.contact_phone&&e.jsx("span",{children:ie.contact_phone})]}),ie.answers&&typeof ie.answers=="object"&&e.jsx("div",{className:"mt-2 text-sm space-y-1",children:Object.entries(ie.answers).map(([ae,oe])=>e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-muted-foreground",children:[ae,":"]})," ",e.jsx("span",{children:String(oe)})]},ae))})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(ie.created_at).toLocaleDateString()})]})})},ie.id))})}),e.jsxs(Ss,{value:"settings",className:"space-y-4 mt-4",children:[e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Publishing"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Published"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Make this page publicly accessible"})]}),e.jsx(Ar,{checked:w.is_published,onCheckedChange:ie=>S(ae=>({...ae,is_published:ie}))})]}),w.is_published&&e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg border",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Public URL:"}),e.jsx("code",{className:"text-xs ml-2 break-all",children:J})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Thank You Message"})}),e.jsx(Oe,{children:e.jsx(_r,{value:w.success_message,onChange:ie=>S(ae=>({...ae,success_message:ie.target.value})),rows:2,placeholder:"Message shown after form submission"})})]})]})]})]}),e.jsx(fs,{open:d,onOpenChange:u,children:e.jsxs(ps,{className:"max-w-sm",children:[e.jsx(ks,{children:e.jsx(_s,{children:"QR Code"})}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[e.jsx(EO,{value:J,size:240}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:J})]})]})})]}):e.jsx(Ds,{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(W,{variant:"link",onClick:()=>s("/mission-control/landing-pages"),children:"Go back"})]})})}function Q9e({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(aL,{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(nL,{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(Qy,{className:"h-3 w-3"}),"0%"]})}const FMs={Phone:In,MessageSquare:wi,Mail:tr,Gift:hi,PenTool:Mb,Video:yn},J9e=["bg-primary","bg-emerald-500","bg-amber-500","bg-sky-500","bg-purple-500","bg-orange-500","bg-pink-500","bg-teal-500"];function zMs(){const t=wr(),{contactsWithScores:s,stats:r,isLoading:n}=lhe(),{data:a}=KR(365),{data:o}=dke(),{data:l}=WR(),i=oke(),d=k.useMemo(()=>{if(!a)return{touchesThisMonth:0,touchesLastMonth:0,touchTrend:0};const I=new Date,L=gc(I),O=tx(I),V=gc(g4(I,1)),q=tx(g4(I,1)),B=a.filter(Y=>gg(new Date(Y.completed_at),{start:L,end:O})).length,U=a.filter(Y=>gg(new Date(Y.completed_at),{start:V,end:q})).length,te=U>0?Math.round((B-U)/U*100):B>0?100:0;return{touchesThisMonth:B,touchesLastMonth:U,touchTrend:te}},[a]),u=k.useMemo(()=>{if(!a)return 0;const I=new Date,L=gc(I),O=tx(I);return new Set(a.filter(V=>gg(new Date(V.completed_at),{start:L,end:O})).map(V=>V.contact_id)).size},[a]),p=k.useMemo(()=>{if(!o)return{closedThisMonth:0,totalGCI:0};const I=new Date,L=gc(I),O=tx(I),V=o.filter(q=>q.close_date&&gg(ol(q.close_date),{start:L,end:O}));return{closedThisMonth:V.length,totalGCI:V.reduce((q,B)=>q+(Number(B.commission_amount)||0),0)}},[o]),f=k.useMemo(()=>{if(!s.length)return{newThisMonth:0,newLastMonth:0,trend:0};const I=new Date,L=gc(I),O=gc(g4(I,1)),V=tx(g4(I,1)),q=s.filter(te=>new Date(te.created_at)>=L).length,B=s.filter(te=>gg(new Date(te.created_at),{start:O,end:V})).length,U=B>0?Math.round((q-B)/B*100):q>0?100:0;return{newThisMonth:q,newLastMonth:B,trend:U}},[s]),y=k.useMemo(()=>{if(!a||!l)return[];const I=new Date,L=gc(I),O=tx(I),V=a.filter(U=>gg(new Date(U.completed_at),{start:L,end:O})),q={};V.forEach(U=>{const te=U.action_type_id;q[te]=(q[te]||0)+1});const B=V.length||1;return l.filter(U=>q[U.id]).map(U=>({id:U.id,name:U.name,icon:U.icon,count:q[U.id]||0,percent:Math.round((q[U.id]||0)/B*100)})).sort((U,te)=>te.count-U.count)},[a,l]),_=k.useMemo(()=>[...s].filter(I=>I.relationshipScore.status==="at-risk"||I.relationshipScore.status==="cooling").sort((I,L)=>{const O=I.relationshipScore.daysSinceTouch??9999;return(L.relationshipScore.daysSinceTouch??9999)-O}).slice(0,5),[s]),b=k.useMemo(()=>{if(!a)return[];const I=new Date,L=gc(I),O=tx(I),V=new Set(a.filter(q=>gg(new Date(q.completed_at),{start:L,end:O})).map(q=>q.contact_id));return s.filter(q=>q.relationshipScore.status==="warm"&&V.has(q.id)&&q.relationshipScore.touchCountLast12Months>=2).sort((q,B)=>B.relationshipScore.score-q.relationshipScore.score).slice(0,5)},[s,a]),N=k.useMemo(()=>{if(!a)return{currentStreak:0,longestStreak:0};const I=new Set(a.map(te=>{const Y=new Date(te.completed_at);return`${Y.getFullYear()}-${Y.getMonth()}-${Y.getDate()}`})),L=new Date;L.setHours(0,0,0,0);let O=0,V=new Date(L);for(;I.has(`${V.getFullYear()}-${V.getMonth()}-${V.getDate()}`);)O++,V.setDate(V.getDate()-1);let q=0,B=0;if(Array.from(I).sort().length>0){const te=a.map(Y=>{const J=new Date(Y.completed_at);return J.setHours(0,0,0,0),J.getTime()}).filter((Y,J,X)=>X.indexOf(Y)===J).sort((Y,J)=>Y-J);B=1;for(let Y=1;Y[...s].sort((I,L)=>I.relationshipScore.score-L.relationshipScore.score),[s]),S=w.filter(I=>I.relationshipScore.status==="warm"),C=w.filter(I=>I.relationshipScore.status==="cooling"),A=w.filter(I=>I.relationshipScore.status==="at-risk");return e.jsx(Ds,{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:[vs(new Date,"MMMM yyyy")," — Your monthly relationship health report"]})]}),N.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(rd,{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:N.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(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Xa,{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(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(lh,{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:d.touchesThisMonth}),e.jsx(Q9e,{value:d.touchTrend})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["vs ",d.touchesLastMonth," last month"]})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(ir,{className:"h-4 w-4"}),"Reached"]}),e.jsx("div",{className:"text-3xl font-bold",children:u}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["of ",r.total," contacts"]})]})}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Qo,{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:f.newThisMonth}),e.jsx(Q9e,{value:f.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(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Rh,{className:"h-4 w-4 text-primary"}),"Weekly Goal"]})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[i.actionsThisWeek," of ",i.weeklyGoal," touches"]}),e.jsxs("span",{className:"text-sm font-medium",children:[Math.round(i.progress),"%"]})]}),e.jsx(xi,{value:i.progress,className:"h-3"}),i.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(Fi,{className:"h-3 w-3"}),"Goal reached! 🎉"]}),i.progress<100&&i.progress>0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[i.weeklyGoal-i.actionsThisWeek," more to hit your goal"]})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(rd,{className:"h-4 w-4 text-orange-500"}),"Momentum"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Current Streak"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xl font-bold",children:N.currentStreak}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"days"}),N.currentStreak>=7&&e.jsx("span",{className:"ml-1",children:"🔥"}),N.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:N.longestStreak}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"days"})]})]}),N.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(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(lh,{className:"h-4 w-4"}),"How You're Reaching Out"]})}),e.jsx(Oe,{children:y.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:y.slice(0,5).map((I,L)=>{const O=FMs[I.icon||""]||lh;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(O,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{children:I.name})]}),e.jsxs("span",{className:"text-muted-foreground",children:[I.count," (",I.percent,"%)"]})]}),e.jsx(xi,{value:I.percent,className:Ot("h-1.5 bg-muted [&>div]:",J9e[L%J9e.length])})]},I.id)})})})]})]}),_.length>0&&e.jsxs(Pe,{className:"border-l-4 border-l-primary",children:[e.jsxs(Dt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(In,{className:"h-5 w-5 text-primary"}),"Who to Reach Out to Today"]}),e.jsxs(Qe,{variant:"secondary",children:[_.length," contacts"]})]}),e.jsx(dr,{children:"These relationships need attention the most"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-2",children:_.map(I=>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/${I.id}`),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(M8,{score:I.relationshipScore,showScore:!0,size:"sm",showTooltip:!1}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:[I.first_name," ",I.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:I.relationshipScore.daysSinceTouch===null?"Never contacted":`Last touch ${I.relationshipScore.daysSinceTouch}d ago`})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[I.phone&&e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:L=>{L.stopPropagation(),window.open(`tel:${I.phone}`)},children:e.jsx(In,{className:"h-4 w-4"})}),I.email&&e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:L=>{L.stopPropagation(),window.open(`mailto:${I.email}`)},children:e.jsx(tr,{className:"h-4 w-4"})}),e.jsx(xa,{className:"h-4 w-4 text-muted-foreground"})]})]},I.id))})})]}),b.length>0&&e.jsxs(Pe,{className:"border-l-4 border-l-emerald-500",children:[e.jsxs(Dt,{className:"pb-3",children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(nc,{className:"h-5 w-5 text-emerald-500"}),"Biggest Wins This Month"]}),e.jsx(dr,{children:"Relationships you've successfully warmed up"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"flex flex-wrap gap-3",children:b.map(I=>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/${I.id}`),children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-500"}),e.jsxs("span",{className:"text-sm font-medium",children:[I.first_name," ",I.last_name]}),e.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400 font-bold",children:I.relationshipScore.score})]},I.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(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Warm"}),e.jsx("p",{className:"text-3xl font-bold text-emerald-600 dark:text-emerald-400",children:r.warm})]}),e.jsx("div",{className:"h-14 w-14 rounded-full bg-emerald-500/10 flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"🟢"})})]}),e.jsx(xi,{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(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Cooling Off"}),e.jsx("p",{className:"text-3xl font-bold text-amber-600 dark:text-amber-400",children:r.cooling})]}),e.jsx("div",{className:"h-14 w-14 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"🟡"})})]}),e.jsx(xi,{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(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"At Risk"}),e.jsx("p",{className:"text-3xl font-bold text-red-600 dark:text-red-400",children:r.atRisk})]}),e.jsx("div",{className:"h-14 w-14 rounded-full bg-red-500/10 flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"🔴"})})]}),e.jsx(xi,{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(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(gL,{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:p.closedThisMonth})]})]}),p.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:["$",p.totalGCI.toLocaleString()]})]})]})})}),e.jsxs(ta,{defaultValue:"at-risk",children:[e.jsxs(Jn,{children:[e.jsxs(cs,{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(cs,{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(cs,{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:A},{key:"cooling",contacts:C},{key:"warm",contacts:S}].map(({key:I,contacts:L})=>e.jsx(Ss,{value:I,children:e.jsx(Pe,{children:e.jsx(Oe,{className:"p-0",children:L.length===0?e.jsx("p",{className:"p-6 text-center text-muted-foreground",children:"No contacts in this category"}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Contact"}),e.jsx(St,{className:"hidden md:table-cell",children:"Last Touch"}),e.jsx(St,{className:"hidden md:table-cell",children:"Touches (12mo)"}),e.jsx(St,{children:"Score"}),e.jsx(St,{className:"w-10"})]})}),e.jsx(Rn,{children:L.slice(0,20).map(O=>e.jsxs(Ps,{className:"cursor-pointer",onClick:()=>t(`/mission-control/contacts/${O.id}`),children:[e.jsxs(ht,{className:"font-medium",children:[O.first_name," ",O.last_name]}),e.jsx(ht,{className:"hidden md:table-cell text-muted-foreground",children:O.relationshipScore.daysSinceTouch===null?"Never":O.relationshipScore.daysSinceTouch===0?"Today":`${O.relationshipScore.daysSinceTouch}d ago`}),e.jsx(ht,{className:"hidden md:table-cell",children:O.relationshipScore.touchCountLast12Months}),e.jsx(ht,{children:e.jsx(M8,{score:O.relationshipScore,showScore:!0})}),e.jsx(ht,{children:e.jsx(xa,{className:"h-4 w-4 text-muted-foreground"})})]},O.id))})]})})})},I))]})]})})}const Uct=({className:t,...s})=>e.jsx("nav",{role:"navigation","aria-label":"pagination",className:Ot("mx-auto flex w-full justify-center",t),...s});Uct.displayName="Pagination";const Vct=k.forwardRef(({className:t,...s},r)=>e.jsx("ul",{ref:r,className:Ot("flex flex-row items-center gap-1",t),...s}));Vct.displayName="PaginationContent";const VI=k.forwardRef(({className:t,...s},r)=>e.jsx("li",{ref:r,className:Ot("",t),...s}));VI.displayName="PaginationItem";const ape=({className:t,isActive:s,size:r="icon",...n})=>e.jsx("a",{"aria-current":s?"page":void 0,className:Ot(TT({variant:s?"outline":"ghost",size:r}),t),...n});ape.displayName="PaginationLink";const Hct=({className:t,...s})=>e.jsxs(ape,{"aria-label":"Go to previous page",size:"default",className:Ot("gap-1 pl-2.5",t),...s,children:[e.jsx(Xo,{className:"h-4 w-4"}),e.jsx("span",{children:"Previous"})]});Hct.displayName="PaginationPrevious";const Gct=({className:t,...s})=>e.jsxs(ape,{"aria-label":"Go to next page",size:"default",className:Ot("gap-1 pr-2.5",t),...s,children:[e.jsx("span",{children:"Next"}),e.jsx(xa,{className:"h-4 w-4"})]});Gct.displayName="PaginationNext";const Wct=({className:t,...s})=>e.jsxs("span",{"aria-hidden":!0,className:Ot("flex h-9 w-9 items-center justify-center",t),...s,children:[e.jsx(Zp,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More pages"})]});Wct.displayName="PaginationEllipsis";function BMs(){const{user:t}=Us();return gt({queryKey:["bulk-email-sends",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:s,error:r}=await G.from("bulk_email_sends").select("contact_id, sent_at, subject").eq("user_id",t.id).order("sent_at",{ascending:!1});if(r)throw r;return s}})}function $Ms(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 HI=[{key:"email",label:"Missing Email",icon:tr,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:In,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:Ia,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:Fu,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:Mn,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:mh,description:"Untagged — won't appear in filtered lists or plans",check:t=>!t.tags||t.tags.length===0,color:"text-slate-500"}];function B5(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 qMs({contact:t,onClose:s}){const r=ake(),[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=HI.filter(i=>i.fieldKey&&i.check(t));return e.jsx(ZA,{open:!0,onOpenChange:()=>s(),children:e.jsxs(SC,{className:"sm:max-w-md overflow-y-auto",children:[e.jsxs(YA,{children:[e.jsxs(XA,{children:["Quick Edit — ",t.first_name," ",t.last_name]}),e.jsxs(sYe,{children:["Fill in missing fields to improve this contact's completeness (",B5(t),"%)"]})]}),e.jsxs("div",{className:"space-y-5 mt-6",children:[l.length>0&&e.jsxs("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-3",children:[e.jsx("p",{className:"text-sm font-medium text-amber-600 dark:text-amber-400 mb-1",children:"Missing Fields"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:l.map(i=>{const d=i.icon;return e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(d,{className:"h-3 w-3"}),i.label.replace("Missing ","")]},i.key)})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(xe,{className:"flex items-center gap-1.5",children:[e.jsx(tr,{className:"h-3.5 w-3.5"})," Email"]}),e.jsx(De,{type:"email",placeholder:"email@example.com",value:n.email,onChange:i=>a(d=>({...d,email:i.target.value})),className:Ot(!t.email&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(xe,{className:"flex items-center gap-1.5",children:[e.jsx(In,{className:"h-3.5 w-3.5"})," Phone"]}),e.jsx(De,{type:"tel",placeholder:"(555) 123-4567",value:n.phone,onChange:i=>a(d=>({...d,phone:i.target.value})),className:Ot(!t.phone&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(xe,{className:"flex items-center gap-1.5",children:[e.jsx(Ia,{className:"h-3.5 w-3.5"})," Address"]}),e.jsx(De,{placeholder:"123 Main St, City, ST 12345",value:n.address,onChange:i=>a(d=>({...d,address:i.target.value})),className:Ot(!t.address&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(xe,{className:"flex items-center gap-1.5",children:[e.jsx(Fu,{className:"h-3.5 w-3.5"})," Birthday"]}),e.jsx(De,{type:"date",value:n.birthday,onChange:i=>a(d=>({...d,birthday:i.target.value})),className:Ot(!t.birthday&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(xe,{className:"flex items-center gap-1.5",children:[e.jsx(Mn,{className:"h-3.5 w-3.5"})," Home Anniversary"]}),e.jsx(De,{type:"date",value:n.home_anniversary,onChange:i=>a(d=>({...d,home_anniversary:i.target.value})),className:Ot(!t.home_anniversary&&"border-amber-500/50")})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(W,{className:"flex-1",onClick:o,disabled:r.isPending,children:[e.jsx(bc,{className:"h-4 w-4 mr-1.5"}),r.isPending?"Saving...":"Save Changes"]}),e.jsx(W,{variant:"outline",onClick:s,children:"Cancel"})]})]})]})})}const eBe="Quick favor — can you update your info? 🙏",tBe=`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 UMs(){const t=wr(),{data:s,isLoading:r}=qh(),{data:n}=Nf(),{data:a}=_O(),{data:o}=sit(),{intakePage:l}=Cme(),{isGmailConnected:i,gmailEmail:d}=Om(),{isReady:u}=Sme(),{data:p}=BMs(),[f,y]=k.useState("blocked"),[_,b]=k.useState([]),[N,w]=k.useState(null),[S,C]=k.useState(!1),[A,I]=k.useState(1),[L,O]=k.useState(25),[V,q]=k.useState(!1),[B,U]=k.useState([]),[te,Y]=k.useState(new Set);k.useEffect(()=>{I(1)},[f,_,L]);const[J,X]=k.useState(!1),[ce,ie]=k.useState(null),[ae,oe]=k.useState([]),[me,ve]=k.useState(""),[he,ge]=k.useState(""),je=k.useMemo(()=>{const Nt=new Map;return(o||[]).forEach(es=>{Nt.has(es.contact_id)||Nt.set(es.contact_id,new Set),Nt.get(es.contact_id).add(es.tag_id)}),Nt},[o]),qe=k.useMemo(()=>{if(!s)return[];if(_.length===0)return s;const Nt=new Set(_.filter(ds=>ds.startsWith("rel:")).map(ds=>ds.slice(4))),es=new Set(_.filter(ds=>ds.startsWith("custom:")).map(ds=>ds.slice(7)));return s.filter(ds=>{var Es;const js=Nt.size>0&&((Es=ds.tags)==null?void 0:Es.some(fr=>Nt.has(fr.relationship_type_id))),lr=je.get(ds.id),Lt=es.size>0&&lr&&Array.from(es).some(fr=>lr.has(fr));return js||Lt})},[s,_,je]),Me=k.useMemo(()=>qe.filter(Nt=>!Nt.email&&!Nt.phone),[qe]),ke=k.useMemo(()=>{if(!qe.length)return{overallCompleteness:0,fullyComplete:0,contactsByGap:{}};const Nt={};Nt.blocked=Me,HI.forEach(lr=>{Nt[lr.key]=qe.filter(lr.check)});const es=qe.map(B5),ds=qe.length>0?Math.round(es.reduce((lr,Lt)=>lr+Lt,0)/qe.length):0,js=es.filter(lr=>lr===100).length;return{contactsByGap:Nt,overallCompleteness:ds,fullyComplete:js}},[qe,Me]),Re=k.useMemo(()=>{if(!s||s.length===0)return null;const Nt=gc(g4(new Date,1)),es=s.filter(Lt=>new Date(Lt.created_at)Lt+Es,0)/es.length),js=ke.overallCompleteness,lr=js-ds;return{oldCompleteness:ds,currentCompleteness:js,diff:lr,oldCount:es.length}},[s,ke.overallCompleteness]),Ve=qe.length,Ne=k.useCallback(()=>{var Hs;const Nt=ke.contactsByGap[f];if(!(Nt!=null&&Nt.length))return;const es=f==="blocked"?"Outreach Blocked":((Hs=HI.find(mr=>mr.key===f))==null?void 0:Hs.label)||f,ds=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Completeness %"],js=Nt.map(mr=>[mr.first_name,mr.last_name||"",mr.email||"",mr.phone||"",mr.address||"",mr.birthday||"",mr.home_anniversary||"",B5(mr).toString()]),lr=[ds.join(","),...js.map(mr=>mr.map(an=>`"${an.replace(/"/g,'""')}"`).join(","))].join(` `),Lt=new Blob([lr],{type:"text/csv"}),Es=URL.createObjectURL(Lt),fr=document.createElement("a");fr.href=Es,fr.download=`sphere-gaps-${es.toLowerCase().replace(/\s+/g,"-")}-${vs(new Date,"yyyy-MM-dd")}.csv`,fr.click(),URL.revokeObjectURL(Es),fn({title:`Exported ${Nt.length} contacts to CSV`})},[ke.contactsByGap,f]),Ue=k.useCallback(async Nt=>{if(!l)return null;try{const{data:es,error:ds}=await G.from("contact_intake_tokens").insert({contact_id:Nt,intake_page_id:l.id}).select("token").single();if(ds)throw ds;return es.token}catch{return null}},[l]),Ie=k.useCallback(Nt=>l?`https://contacts.relevelup.com/${l.slug}?t=${Nt}`:"",[l]),ye=k.useCallback(async Nt=>{if(!l){pe.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const es=await Ue(Nt);es?(await navigator.clipboard.writeText(Ie(es)),pe.success("Update link copied!")):pe.error("Failed to generate link")},[l,Ue,Ie,t]),ct=k.useCallback(async Nt=>{if(!l){pe.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}if(!Nt.email){pe.error("This contact has no email address");return}const es=await Ue(Nt.id);if(!es){pe.error("Failed to generate link");return}const ds=Ie(es),js=tBe.replace("{{update_link}}",ds).replace(/\{\{first_name\}\}/g,Nt.first_name).replace(/\{\{last_name\}\}/g,Nt.last_name||""),lr=eBe.replace(/\{\{first_name\}\}/g,Nt.first_name).replace(/\{\{last_name\}\}/g,Nt.last_name||"");if(i||u)ie({id:Nt.id,first_name:Nt.first_name,last_name:Nt.last_name,email:Nt.email}),oe([]),ve(lr),ge(js),X(!0);else{const Lt=encodeURIComponent(lr),Es=encodeURIComponent(js);window.location.href=`mailto:${Nt.email}?subject=${Lt}&body=${Es}`}},[l,Ue,Ie,i,u,t]),fe=k.useCallback(async Nt=>{if(!l){pe.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const es=Nt.filter(lr=>lr.email);if(!es.length){pe.error("No contacts with email addresses in this group");return}const ds=new Set((p||[]).map(lr=>lr.contact_id)),js=es.filter(lr=>!ds.has(lr.id));if(js.length===0){pe.info(`All ${es.length} contacts with email have already been sent this update request.`);return}if(js.lengtht("/mission-control/integrations")}});return}C(!0);try{const{data:lr,error:Lt}=await G.functions.invoke("process-intake-submissions",{body:{action:"generate_tokens",contact_ids:js.map(Cr=>Cr.id),intake_page_id:l.id}});if(Lt)throw Lt;const Es=typeof lr=="string"?JSON.parse(lr):lr,fr=Array.isArray(Es)?Es:Array.isArray(Es==null?void 0:Es.tokens)?Es.tokens:[],Hs=new Map(fr.filter(Cr=>(Cr==null?void 0:Cr.contact_id)&&(Cr==null?void 0:Cr.token)).map(Cr=>[Cr.contact_id,Cr.token]));if(Hs.size===0&&(await Promise.all(es.map(async Fr=>({contactId:Fr.id,token:await Ue(Fr.id)})))).forEach(({contactId:Fr,token:$r})=>{$r&&Hs.set(Fr,$r)}),Hs.size===0){pe.error("Failed to generate update links. Please try again.");return}const mr=js.filter(Cr=>Hs.has(Cr.id)).map(Cr=>({id:Cr.id,first_name:Cr.first_name,last_name:Cr.last_name,email:Cr.email,updateLink:Ie(Hs.get(Cr.id))})),an=tBe;ie(null),oe(mr),ve(eBe),ge(an),X(!0),pe.success(`Ready to email ${mr.length} contacts`)}catch{pe.error("Failed to generate links")}finally{C(!1)}},[l,i,u,Ie,Ue,t,p]),$e=k.useCallback(Nt=>{const es=new Set((p||[]).map(js=>js.contact_id)),ds=Nt.filter(js=>js.email&&!es.has(js.id));if(ds.length===0){pe.info("No eligible recipients in this group.");return}U(ds),Y(new Set),q(!0)},[p]),Ye=k.useCallback(()=>{const Nt=B.filter(es=>!te.has(es.id));if(Nt.length===0){pe.error("No recipients selected");return}q(!1),fe(Nt)},[B,te,fe]),Te=[{key:"blocked",label:"Outreach Blocked",icon:Tv,color:"text-destructive",description:"Missing BOTH email AND phone — completely unreachable"},...HI].find(Nt=>Nt.key===f),We=ke.contactsByGap[f]||[],Ke=We.filter(Nt=>Nt.email).length,ot=new Set((p||[]).map(Nt=>Nt.contact_id)),He=We.filter(Nt=>Nt.email&&ot.has(Nt.id)).length,Je=Ke-He,ut=Math.max(1,Math.ceil(We.length/L)),mt=Math.min(A,ut),et=(mt-1)*L,Ze=et+L,kt=We.slice(et,Ze),Ut=k.useMemo(()=>{if(ut<=7)return Array.from({length:ut},(js,lr)=>lr+1);const Nt=[1];mt>3&&Nt.push("ellipsis");const es=Math.max(2,mt-1),ds=Math.min(ut-1,mt+1);for(let js=es;js<=ds;js++)Nt.push(js);return mt0&&e.jsx(W,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>b([]),children:"Clear"})]}),e.jsx(Ja,{className:"max-h-72",children:e.jsxs("div",{className:"p-2 space-y-3",children:[n&&n.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide font-semibold text-muted-foreground px-2 mb-1",children:"Relationship"}),n.map(Nt=>{const es=`rel:${Nt.id}`,ds=_.includes(es);return e.jsxs("label",{className:"flex items-center gap-2 px-2 py-1.5 rounded hover:bg-muted/60 cursor-pointer",children:[e.jsx(Ri,{checked:ds,onCheckedChange:js=>{b(lr=>js?[...lr,es]:lr.filter(Lt=>Lt!==es))}}),e.jsx("span",{className:"text-sm",children:Nt.name})]},es)})]}),a&&a.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide font-semibold text-muted-foreground px-2 mb-1",children:"Custom Tags"}),a.map(Nt=>{const es=`custom:${Nt.id}`,ds=_.includes(es);return e.jsxs("label",{className:"flex items-center gap-2 px-2 py-1.5 rounded hover:bg-muted/60 cursor-pointer",children:[e.jsx(Ri,{checked:ds,onCheckedChange:js=>{b(lr=>js?[...lr,es]:lr.filter(Lt=>Lt!==es))}}),e.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{backgroundColor:Nt.color}}),e.jsx("span",{className:"text-sm",children:Nt.name})]},es)})]}),(!n||n.length===0)&&(!a||a.length===0)&&e.jsx("p",{className:"text-sm text-muted-foreground p-3 text-center",children:"No tags yet — create some on contacts to filter here."})]})})]})]})})]}),e.jsx(Pe,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Database Completeness",_.length>0&&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:[ke.overallCompleteness,"%"]}),Re&&Re.diff!==0&&_.length===0&&e.jsxs("div",{className:Ot("flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",Re.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:[Re.diff>0?"↑":"↓"," ",Math.abs(Re.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:[ke.fullyComplete," ",e.jsxs("span",{className:"text-base font-normal text-muted-foreground",children:["/ ",Ve]})]})]})]}),e.jsx(xi,{value:ke.overallCompleteness,className:"h-3"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:ke.overallCompleteness>=80?"🎉 Great job! Your database is well maintained.":ke.overallCompleteness>=50?"⚡ Good start — fill in the gaps below to unlock more outreach channels.":"🔍 Your database needs attention. Start with emails and phone numbers."})]})}),Me.length>0&&e.jsx(Pe,{className:Ot("border-l-4 border-l-destructive cursor-pointer transition-all hover:shadow-md",f==="blocked"&&"ring-2 ring-primary"),onClick:()=>y("blocked"),children:e.jsx(Oe,{className:"pt-5 pb-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-destructive/10 flex items-center justify-center",children:e.jsx(Tv,{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:Me.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:HI.map(Nt=>{var Lt;const es=((Lt=ke.contactsByGap[Nt.key])==null?void 0:Lt.length)||0,ds=Ve>0?Math.round(es/Ve*100):0,js=Nt.icon,lr=f===Nt.key;return e.jsx(Pe,{className:Ot("cursor-pointer transition-all hover:shadow-md",lr&&"ring-2 ring-primary"),onClick:()=>y(Nt.key),children:e.jsxs(Oe,{className:"pt-5 pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(js,{className:Ot("h-5 w-5",Nt.color)}),e.jsx("span",{className:"text-sm font-medium",children:Nt.label})]}),e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsx("span",{className:"text-2xl font-bold",children:es}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[ds,"% of contacts"]})]}),e.jsx(xi,{value:100-ds,className:"mt-2 h-1.5"})]})},Nt.key)})}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-lg",children:[(Te==null?void 0:Te.label)||"Contacts"," — Contacts to Fix"]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(Qe,{variant:"secondary",children:[We.length," contacts"]}),He>0&&e.jsxs(Qe,{variant:"outline",className:"gap-1 text-muted-foreground",children:[e.jsx($n,{className:"h-3 w-3"}),He," already emailed"]}),We.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(W,{variant:"outline",size:"sm",onClick:Ne,className:"gap-1.5",children:[e.jsx(Qa,{className:"h-3.5 w-3.5"}),"Export"]}),Je>0&&l&&e.jsxs(W,{size:"sm",onClick:()=>$e(We),disabled:S,className:"gap-1.5",children:[S?e.jsx(us,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(jn,{className:"h-3.5 w-3.5"}),"Preview & Email ",Je]})]})]})]}),e.jsx(dr,{children:Te==null?void 0:Te.description})]}),e.jsxs(Oe,{className:"p-0",children:[We.length===0?e.jsxs("div",{className:"p-8 text-center",children:[e.jsx($n,{className:"h-10 w-10 text-emerald-500 mx-auto mb-2"}),e.jsx("p",{className:"text-muted-foreground",children:f==="blocked"?"All contacts have at least an email or phone!":"All contacts have this field filled in!"})]}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ps,{children:[e.jsx(St,{children:"Contact"}),e.jsx(St,{className:"hidden md:table-cell",children:"Email"}),e.jsx(St,{className:"hidden md:table-cell",children:"Phone"}),e.jsx(St,{children:"Completeness"}),e.jsx(St,{className:"w-28",children:"Actions"})]})}),e.jsx(Rn,{children:kt.map(Nt=>{const es=$Ms(p,Nt.id);return e.jsxs(Ps,{children:[e.jsx(ht,{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/${Nt.id}`),children:[Nt.first_name," ",Nt.last_name]}),!Nt.email&&!Nt.phone&&f!=="blocked"&&e.jsx(Qe,{variant:"destructive",className:"text-[10px] px-1 py-0",children:"Blocked"}),es&&e.jsxs(ec,{children:[e.jsx(tc,{asChild:!0,children:e.jsxs(Qe,{variant:"outline",className:"text-[10px] px-1.5 py-0 gap-1 text-muted-foreground border-muted",children:[e.jsx(tr,{className:"h-2.5 w-2.5"}),Nl(new Date(es),{addSuffix:!0})]})}),e.jsxs(Dl,{children:["Last bulk emailed ",vs(new Date(es),"MMM d, yyyy h:mm a")]})]})]})}),e.jsx(ht,{className:"hidden md:table-cell text-muted-foreground",children:Nt.email||e.jsx("span",{className:"text-red-400 italic text-xs",children:"Missing"})}),e.jsx(ht,{className:"hidden md:table-cell text-muted-foreground",children:Nt.phone||e.jsx("span",{className:"text-red-400 italic text-xs",children:"Missing"})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xi,{value:B5(Nt),className:"h-2 w-16"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[B5(Nt),"%"]})]})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsxs(ec,{children:[e.jsx(tc,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>w(Nt),children:e.jsx(Ev,{className:"h-3.5 w-3.5"})})}),e.jsx(Dl,{children:"Quick edit"})]}),(Nt.email||Nt.phone)&&l&&e.jsxs(ec,{children:[e.jsx(tc,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>ye(Nt.id),children:e.jsx(Va,{className:"h-3.5 w-3.5"})})}),e.jsx(Dl,{children:"Copy update link"})]}),Nt.email&&l&&e.jsxs(ec,{children:[e.jsx(tc,{asChild:!0,children:e.jsx(W,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>ct(Nt),children:e.jsx(tr,{className:"h-3.5 w-3.5"})})}),e.jsx(Dl,{children:"Email update link"})]})]})})]},Nt.id)})})]}),We.length>0&&e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-3 px-4 py-3 border-t",children:[e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Showing ",e.jsx("span",{className:"font-medium text-foreground",children:et+1}),"–",e.jsx("span",{className:"font-medium text-foreground",children:Math.min(Ze,We.length)})," of"," ",e.jsx("span",{className:"font-medium text-foreground",children:We.length})]}),e.jsxs($s,{value:String(L),onValueChange:Nt=>O(Number(Nt)),children:[e.jsx(zs,{className:"h-8 w-[110px] text-xs",children:e.jsx(Vs,{})}),e.jsxs(Bs,{children:[e.jsx(vt,{value:"25",children:"25 / page"}),e.jsx(vt,{value:"50",children:"50 / page"}),e.jsx(vt,{value:"100",children:"100 / page"}),e.jsx(vt,{value:"250",children:"250 / page"})]})]})]}),ut>1&&e.jsx(Uct,{className:"md:mx-0 md:justify-end",children:e.jsxs(Vct,{children:[e.jsx(VI,{children:e.jsx(Hct,{href:"#",onClick:Nt=>{Nt.preventDefault(),mt>1&&I(mt-1)},className:Ot(mt===1&&"pointer-events-none opacity-50")})}),Ut.map((Nt,es)=>Nt==="ellipsis"?e.jsx(VI,{children:e.jsx(Wct,{})},`e-${es}`):e.jsx(VI,{children:e.jsx(ape,{href:"#",isActive:Nt===mt,onClick:ds=>{ds.preventDefault(),I(Nt)},children:Nt})},Nt)),e.jsx(VI,{children:e.jsx(Gct,{href:"#",onClick:Nt=>{Nt.preventDefault(),mtw(null)}),e.jsx(E1,{open:J,onOpenChange:X,contact:ce||void 0,bulkContacts:ae.length>0?ae:void 0,defaultSubject:me,defaultBody:he,gmailEmail:d}),e.jsx(fs,{open:V,onOpenChange:q,children:e.jsxs(ps,{className:"max-w-2xl",children:[e.jsxs(ks,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(ir,{className:"h-5 w-5 text-primary"}),"Review Recipients"]}),e.jsx(Ir,{children:"Uncheck anyone you don't want to email. Already-emailed contacts are excluded automatically."})]}),e.jsxs("div",{className:"flex items-center justify-between py-2 border-y",children:[e.jsxs("p",{className:"text-sm font-medium",children:[e.jsx("span",{className:"text-primary",children:B.length-te.size}),e.jsxs("span",{className:"text-muted-foreground",children:[" of ",B.length," will be emailed"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>Y(new Set),children:"Select all"}),e.jsx(W,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>Y(new Set(B.map(Nt=>Nt.id))),children:"Clear all"})]})]}),e.jsx(Ja,{className:"max-h-[400px] -mx-6 px-6",children:e.jsx("div",{className:"space-y-1 py-2",children:B.map(Nt=>{var ds,js,lr,Lt;const es=te.has(Nt.id);return e.jsxs("label",{className:Ot("flex items-center gap-3 p-2 rounded-md cursor-pointer hover:bg-muted/60 transition-colors",es&&"opacity-50"),children:[e.jsx(Ri,{checked:!es,onCheckedChange:Es=>{Y(fr=>{const Hs=new Set(fr);return Es?Hs.delete(Nt.id):Hs.add(Nt.id),Hs})}}),e.jsxs("div",{className:"h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center text-xs font-semibold text-primary shrink-0",children:[((js=(ds=Nt.first_name)==null?void 0:ds[0])==null?void 0:js.toUpperCase())||"?",((Lt=(lr=Nt.last_name)==null?void 0:lr[0])==null?void 0:Lt.toUpperCase())||""]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[Nt.first_name," ",Nt.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Nt.email})]})]},Nt.id)})})}),e.jsxs(gn,{children:[e.jsx(W,{variant:"outline",onClick:()=>q(!1),children:"Cancel"}),e.jsxs(W,{onClick:Ye,disabled:B.length-te.size===0||S,className:"gap-1.5",children:[S?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(_n,{className:"h-4 w-4"}),"Send to ",B.length-te.size]})]})]})})]})}function VMs(){const{user:t}=Us(),{intakePage:s,isLoading:r,createPage:n,updatePage:a,submissions:o,loadingSubmissions:l}=Cme(),[i,d]=k.useState(""),[u,p]=k.useState(""),[f,y]=k.useState(!1);k.useEffect(()=>{s&&p(s.welcome_message||"")},[s]),k.useEffect(()=>{if(t!=null&&t.email&&!s){const A=t.email.split("@")[0];d(A.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/-+$/,""))}},[t,s]);const _=s?`https://contacts.relevelup.com/${s.slug}`:"",b=()=>{navigator.clipboard.writeText(_),pe.success("Link copied!")};if(r)return e.jsx(Pe,{children:e.jsx(Oe,{className:"p-6 flex items-center justify-center",children:e.jsx(us,{className:"h-5 w-5 animate-spin text-muted-foreground"})})});if(!s)return e.jsxs(Pe,{children:[e.jsx(Dt,{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(Do,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{children:"Connect Page"}),e.jsx(dr,{children:"Create a public link to capture contact info from new leads or update existing contacts"})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{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(De,{value:i,onChange:A=>d(A.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"jane-smith",className:"max-w-[200px]"})]})]}),e.jsxs(W,{onClick:()=>n.mutate(i),disabled:!i.trim()||n.isPending,children:[n.isPending?e.jsx(us,{className:"h-4 w-4 animate-spin mr-2"}):null,"Create Connect Page"]})]})})]});const N=o.filter(A=>!A.is_processed),w=o.filter(A=>A.is_processed),S=N.length,C=(A,I)=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-sm",children:[A.first_name," ",A.last_name||""]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground mt-0.5",children:[A.email&&e.jsx("span",{children:A.email}),A.phone&&e.jsx("span",{children:A.phone})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[A.real_estate_interest&&A.real_estate_interest!=="not_now"&&e.jsx(Qe,{variant:"outline",className:"text-xs",children:A.real_estate_interest==="buying"?"🏠 Buying":A.real_estate_interest==="selling"?"📋 Selling":A.real_estate_interest==="both"?"🔄 Both":A.real_estate_interest}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(nn,{className:"h-3 w-3"}),vs(new Date(A.created_at),"MMM d")]}),I&&e.jsx($n,{className:"h-4 w-4 text-emerald-500"})]})]},A.id);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsx(Dt,{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(Do,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{children:"Connect Page"}),e.jsx(dr,{children:"Share this link to capture contact info"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{htmlFor:"active-toggle",className:"text-sm text-muted-foreground",children:"Active"}),e.jsx(Ar,{id:"active-toggle",checked:s.is_active,onCheckedChange:A=>a.mutate({is_active:A})})]})]})}),e.jsxs(Oe,{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted/50 rounded-lg",children:[e.jsx("span",{className:"text-sm font-medium truncate flex-1",children:_}),e.jsxs(W,{size:"sm",variant:"outline",onClick:b,children:[e.jsx(Va,{className:"h-3.5 w-3.5 mr-1.5"})," Copy"]}),e.jsx(W,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:_,target:"_blank",rel:"noopener noreferrer",children:e.jsx(Yr,{className:"h-3.5 w-3.5"})})})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Welcome Message"}),f?e.jsxs("div",{className:"mt-1.5 space-y-2",children:[e.jsx("textarea",{value:u,onChange:A=>p(A.target.value),rows:3,className:"w-full px-3 py-2 text-sm border rounded-md bg-background"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{size:"sm",onClick:()=>{a.mutate({welcome_message:u}),y(!1)},children:"Save"}),e.jsx(W,{size:"sm",variant:"outline",onClick:()=>y(!1),children:"Cancel"})]})]}):e.jsx("p",{className:"mt-1.5 text-sm text-muted-foreground cursor-pointer hover:text-foreground transition-colors",onClick:()=>y(!0),children:s.welcome_message||"Click to set a welcome message..."})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ir,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-base",children:"New Submissions"}),S>0&&e.jsxs(dr,{children:[S," awaiting sync"]})]})]}),S>0&&e.jsxs(W,{size:"sm",onClick:async()=>{try{const{data:A,error:I}=await G.functions.invoke("process-intake-submissions",{body:{action:"process_all"}});if(I)throw I;pe.success(`Synced ${A.processed} contacts to your CRM!`)}catch{pe.error("Failed to sync")}},className:"gap-1.5",children:["Sync ",S," to CRM"]})]})}),e.jsx(Oe,{children:l?e.jsx(us,{className:"h-5 w-5 animate-spin text-muted-foreground"}):N.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:N.map(A=>C(A,!1))})})]}),w.length>0&&e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($n,{className:"h-5 w-5 text-emerald-500"}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-base",children:"Synced to CRM"}),e.jsxs(dr,{children:[w.length," contacts already in your database"]})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[w.slice(0,10).map(A=>C(A,!0)),w.length>10&&e.jsxs("p",{className:"text-xs text-muted-foreground text-center pt-1",children:["+ ",w.length-10," more synced contacts"]})]})})]})]})}function HMs(){return e.jsx(Ds,{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(VMs,{})]})})}const GMs={property_view:{label:"Viewed Listing",icon:jn,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:Jo,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:Xa,badgeClass:"bg-rose-500/10 text-rose-600 dark:text-rose-400 border-rose-200 dark:border-rose-700"}},WMs={home:"🏠",search:"🔍",listing:"🏡",city:"🌆",sell:"💰",blog:"📝",dashboard:"📊",other:"📄"};function KMs({locations:t}){const s=k.useRef(null),r=k.useRef(null),[n,a]=k.useState(null);return k.useEffect(()=>{G.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 Ko.accessToken=n,r.current=new Ko.Map({container:s.current,style:"mapbox://styles/mapbox/light-v11",zoom:3.5,center:[-98.5795,39.8283],interactive:!0}),r.current.addControl(new Ko.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)),d=document.createElement("div");d.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; `,d.textContent=String(l.visitor_count),d.addEventListener("mouseenter",()=>{d.style.transform="scale(1.3)"}),d.addEventListener("mouseleave",()=>{d.style.transform="scale(1)"});const u=document.createElement("div");u.appendChild(d),new Ko.Marker({element:u,anchor:"center"}).setLngLat([l.lng,l.lat]).setPopup(new Ko.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 Ko.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(cS,{className:"h-5 w-5 mr-2"})," Map not configured"]})}function Kct(){var L,O,V,q;const{user:t}=Us(),s=wr(),{isGmailConnected:r,gmailEmail:n}=Om(),[a,o]=k.useState("all"),[l,i]=k.useState("30"),[d,u]=k.useState(""),[p,f]=k.useState(!1),[y,_]=k.useState(null),{data:b,isLoading:N}=gt({queryKey:["lead-site-activity-full",t==null?void 0:t.id,l],queryFn:async()=>{const{data:B,error:U}=await G.rpc("get_lead_site_activity_full",{_user_id:t.id,_days:parseInt(l)});if(U)throw U;const te=B;return{...te,visitor_locations:((te==null?void 0:te.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}),w=k.useMemo(()=>{if(!(b!=null&&b.activities))return[];let B=b.activities;if(a!=="all"&&(B=B.filter(U=>U.activity_type===a)),d){const U=d.toLowerCase();B=B.filter(te=>{var Y,J,X,ce,ie;return((Y=te.visitor_name)==null?void 0:Y.toLowerCase().includes(U))||((J=te.visitor_email)==null?void 0:J.toLowerCase().includes(U))||((X=te.mls_number)==null?void 0:X.includes(U))||((ce=te.property_address)==null?void 0:ce.toLowerCase().includes(U))||((ie=te.lead_type)==null?void 0:ie.toLowerCase().includes(U))})}return B},[b==null?void 0:b.activities,a,d]),S=b==null?void 0:b.subdomain,C=B=>S?`https://${S}.thelocalmove.com/listing/${B}`:null,A=b==null?void 0:b.stats,I=B=>{if(B.visitor_email)if(r){const U=(B.visitor_name||"").split(" ");_({id:B.contact_id||"",first_name:U[0]||"",last_name:U.slice(1).join(" ")||null,email:B.visitor_email}),f(!0)}else window.location.href=`mailto:${B.visitor_email}`};return!(b!=null&&b.has_site)&&!N?e.jsx(Ds,{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(Ds,{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(W,{variant:"ghost",size:"icon",onClick:()=>s("/mission-control"),children:e.jsx(Oa,{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(B=>e.jsxs(W,{variant:l===B?"default":"outline",size:"sm",onClick:()=>i(B),children:[B,"d"]},B))})]}),A&&e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[{label:"Page Views",value:A.total_page_views,sub:A.page_views_7d,icon:vn,color:"text-violet-600 dark:text-violet-400",bg:"bg-violet-500/10"},{label:"Listing Views",value:A.total_views,sub:A.views_7d,icon:jn,color:"text-blue-600 dark:text-blue-400",bg:"bg-blue-500/10"},{label:"New Leads",value:A.total_leads,sub:A.leads_7d,icon:Jo,color:"text-emerald-600 dark:text-emerald-400",bg:"bg-emerald-500/10"},{label:"Saved Listings",value:A.total_saved,sub:A.saved_7d,icon:Xa,color:"text-rose-600 dark:text-rose-400",bg:"bg-rose-500/10"}].map(B=>e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:B.label}),e.jsx("p",{className:`text-2xl font-bold ${B.color}`,children:B.value})]}),e.jsx("div",{className:`p-2.5 rounded-xl ${B.bg}`,children:e.jsx(B.icon,{className:`h-5 w-5 ${B.color}`})})]}),e.jsxs("p",{className:"text-[11px] text-muted-foreground mt-1",children:[e.jsx("span",{className:`font-semibold ${B.color}`,children:B.sub})," in last 7d"]})]})},B.label))}),e.jsxs(ta,{defaultValue:"overview",className:"space-y-4",children:[e.jsxs(Jn,{children:[e.jsxs(cs,{value:"overview",className:"gap-1.5",children:[e.jsx(so,{className:"h-4 w-4"})," Overview"]}),e.jsxs(cs,{value:"leads",className:"gap-1.5",children:[e.jsx(Oh,{className:"h-4 w-4"})," Lead Inbox"]}),e.jsxs(cs,{value:"map",className:"gap-1.5",children:[e.jsx(cS,{className:"h-4 w-4"})," Visitor Map"]})]}),e.jsxs(Ss,{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(Dt,{className:"pb-3",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Qo,{className:"h-4 w-4 text-primary"}),"Most Viewed Listings"]})}),e.jsx(Oe,{className:"pt-0",children:!(b!=null&&b.top_listings)||b.top_listings.length===0?e.jsxs("div",{className:"py-8 text-center text-sm text-muted-foreground",children:[e.jsx(Mn,{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:b.top_listings.map((B,U)=>{const te=C(B.mls_number);return e.jsxs("a",{href:te||"#",target:"_blank",rel:"noopener noreferrer",onClick:Y=>{te||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:U+1}),B.photo_url?e.jsx("div",{className:"h-10 w-10 rounded-lg overflow-hidden bg-muted shrink-0",children:e.jsx("img",{src:B.photo_url,alt:"",className:"w-full h-full object-cover"})}):e.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(Mn,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:B.property_address||`MLS# ${B.mls_number}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Nl(new Date(B.last_viewed),{addSuffix:!0})})]}),e.jsxs(Qe,{variant:"secondary",className:"shrink-0 text-xs",children:[B.view_count," view",B.view_count!==1?"s":""]}),te&&e.jsx(Yr,{className:"h-3.5 w-3.5 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity"})]},B.mls_number)})})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(vn,{className:"h-4 w-4 text-primary"}),"Most Visited Pages"]})}),e.jsx(Oe,{className:"pt-0",children:!(b!=null&&b.top_pages)||b.top_pages.length===0?e.jsxs("div",{className:"py-8 text-center text-sm text-muted-foreground",children:[e.jsx(vn,{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:b.top_pages.map((B,U)=>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:U+1}),e.jsx("span",{className:"text-lg w-8 text-center",children:WMs[B.page_type]||"📄"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:B.page_title||B.page_path}),e.jsx("p",{className:"text-xs text-muted-foreground",children:B.page_path})]}),e.jsx(Qe,{variant:"secondary",className:"shrink-0 text-xs capitalize",children:B.page_type}),e.jsx(Qe,{variant:"outline",className:"shrink-0 text-xs",children:B.view_count})]},`${B.page_type}-${B.page_path}`))})})]})]}),(b==null?void 0:b.visitor_locations)&&b.visitor_locations.length>0&&e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Ia,{className:"h-4 w-4 text-primary"}),"Where Visitors Are Browsing From"]})}),e.jsx(Oe,{className:"pt-0",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2",children:b.visitor_locations.slice(0,9).map(B=>e.jsxs("div",{className:"flex items-center gap-2.5 p-2.5 rounded-lg bg-muted/40",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(Ia,{className:"h-3.5 w-3.5 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[B.city,", ",B.region]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:B.country})]}),e.jsx("span",{className:"text-sm font-bold text-primary",children:B.visitor_count})]},`${B.city}-${B.region}`))})})]})]}),e.jsxs(Ss,{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(ln,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by name, email, address...",value:d,onChange:B=>u(B.target.value),className:"pl-9"})]}),e.jsx("div",{className:"flex gap-2",children:[{key:"all",label:"All",count:((L=b==null?void 0:b.activities)==null?void 0:L.length)||0},{key:"new_lead",label:"Leads",count:((O=b==null?void 0:b.activities)==null?void 0:O.filter(B=>B.activity_type==="new_lead").length)||0},{key:"property_view",label:"Views",count:((V=b==null?void 0:b.activities)==null?void 0:V.filter(B=>B.activity_type==="property_view").length)||0},{key:"saved_listing",label:"Saved",count:((q=b==null?void 0:b.activities)==null?void 0:q.filter(B=>B.activity_type==="saved_listing").length)||0}].map(B=>e.jsxs(W,{variant:a===B.key?"default":"outline",size:"sm",onClick:()=>o(B.key),className:"gap-1.5",children:[B.label,e.jsx(Qe,{variant:"secondary",className:"text-[10px] h-4 px-1 rounded-full",children:B.count})]},B.key))})]}),N?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(B=>e.jsx("div",{className:"h-20 rounded-xl bg-muted animate-pulse"},B))}):w.length===0?e.jsx(Pe,{children:e.jsxs(Oe,{className:"p-8 text-center",children:[e.jsx(lh,{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:d?"Try adjusting your search.":"Website engagement will appear here."})]})}):e.jsx("div",{className:"space-y-2",children:w.map((B,U)=>{const te=GMs[B.activity_type],Y=te.icon,J=Nl(new Date(B.occurred_at),{addSuffix:!0}),X=B.visitor_name&&B.visitor_name!=="Site Visitor";return e.jsx(Pe,{className:`transition-all hover:shadow-md ${B.activity_type==="new_lead"?"border-l-4 border-l-emerald-500":B.activity_type==="saved_listing"?"border-l-4 border-l-rose-500":"border-l-4 border-l-blue-500"}`,children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[B.photo_url?e.jsx("a",{href:B.mls_number&&C(B.mls_number)||"#",target:"_blank",rel:"noopener noreferrer",className:"shrink-0 rounded-lg overflow-hidden w-12 h-12 bg-muted",children:e.jsx("img",{src:B.photo_url,alt:B.property_address||"Property",className:"w-full h-full object-cover"})}):e.jsx("div",{className:`p-2 rounded-lg shrink-0 ${B.activity_type==="new_lead"?"bg-emerald-500/10":B.activity_type==="saved_listing"?"bg-rose-500/10":"bg-blue-500/10"}`,children:e.jsx(Y,{className:`h-4 w-4 ${B.activity_type==="new_lead"?"text-emerald-500":B.activity_type==="saved_listing"?"text-rose-500":"text-blue-500"}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[X?e.jsx("button",{className:"font-semibold text-sm text-primary hover:underline text-left truncate",onClick:()=>{B.contact_id&&s(`/mission-control/contacts/${B.contact_id}`)},children:B.visitor_name}):e.jsx("span",{className:"font-medium text-sm text-muted-foreground",children:B.visitor_name||"Site Visitor"}),e.jsx(Qe,{variant:"outline",className:`text-[10px] shrink-0 ${te.badgeClass}`,children:te.label}),B.lead_type&&e.jsx(Qe,{variant:"secondary",className:"text-[10px] capitalize",children:B.lead_type.replace(/_/g," ")})]}),B.property_address&&B.mls_number&&e.jsxs("a",{href:C(B.mls_number)||"#",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 mt-0.5 text-xs font-medium text-foreground hover:text-primary transition-colors truncate",children:[e.jsx(Ia,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:B.property_address}),e.jsx(Yr,{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(nn,{className:"h-3 w-3"}),J]}),B.mls_number&&!B.property_address&&e.jsxs("a",{href:C(B.mls_number)||"#",target:"_blank",rel:"noopener noreferrer",className:"hover:text-primary transition-colors",children:["MLS# ",B.mls_number]})]}),B.message&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1.5 line-clamp-2 italic",children:['"',B.message,'"']})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[B.visitor_email&&e.jsx(W,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-primary",title:r?"Compose via Gmail":"Send Email",onClick:()=>I(B),children:e.jsx(tr,{className:"h-4 w-4"})}),B.visitor_phone&&e.jsxs(e.Fragment,{children:[e.jsx(W,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-primary",title:"Call",onClick:()=>window.location.href=`tel:${B.visitor_phone}`,children:e.jsx(In,{className:"h-4 w-4"})}),e.jsx(W,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-primary",title:"Text",onClick:()=>window.location.href=`sms:${B.visitor_phone}`,children:e.jsx(wi,{className:"h-4 w-4"})})]}),B.contact_id&&e.jsx(W,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",title:"View Contact",onClick:()=>s(`/mission-control/contacts/${B.contact_id}`),children:e.jsx(xa,{className:"h-4 w-4"})})]})]})})},`${B.activity_type}-${B.occurred_at}-${U}`)})})]}),e.jsxs(Ss,{value:"map",className:"space-y-4",children:[e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(cS,{className:"h-4 w-4 text-primary"}),"Visitor Locations",(b==null?void 0:b.visitor_locations)&&b.visitor_locations.length>0&&e.jsxs(Qe,{variant:"secondary",className:"text-xs ml-2",children:[b.visitor_locations.reduce((B,U)=>B+U.visitor_count,0)," visitors from ",b.visitor_locations.length," cities"]})]})}),e.jsx(Oe,{className:"pt-0",children:e.jsx("div",{className:"h-[450px] rounded-xl overflow-hidden border",children:e.jsx(KMs,{locations:(b==null?void 0:b.visitor_locations)||[]})})})]}),(b==null?void 0:b.visitor_locations)&&b.visitor_locations.length>0&&e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsx(zt,{className:"text-base",children:"Location Breakdown"})}),e.jsx(Oe,{className:"pt-0",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2",children:b.visitor_locations.map(B=>e.jsxs("div",{className:"flex items-center gap-2.5 p-3 rounded-lg bg-muted/40",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(Ia,{className:"h-3.5 w-3.5 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[B.city,", ",B.region]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:B.country})]}),e.jsx("span",{className:"text-sm font-bold text-primary",children:B.visitor_count})]},`${B.city}-${B.region}`))})})]})]})]})]}),r&&y&&e.jsx(E1,{open:p,onOpenChange:f,contact:y,gmailEmail:n})]})}const ZMs=Object.freeze(Object.defineProperty({__proto__:null,default:Kct},Symbol.toStringTag,{value:"Module"})),YMs=k.lazy(()=>Ba(()=>import("./MobileAgentApp-CRVrJoZa.js"),[])),XMs=k.lazy(()=>Ba(()=>import("./PostcardManager-CudIP7LW.js"),__vite__mapDeps([16,17]))),QMs=k.lazy(()=>Ba(()=>import("./HomeReelManager-DssTFjYF.js"),[])),JMs=k.lazy(()=>Ba(()=>import("./AdminCredits-ygSbdJO9.js"),[])),eTs=k.lazy(()=>Ba(()=>import("./AdminCleanup-Dh2eyyvH.js"),[])),tTs=k.lazy(()=>Ba(()=>import("./DirectMail-DbKxtDVx.js"),__vite__mapDeps([18,17,19]))),sTs=k.lazy(()=>Ba(()=>import("./InnerCirclePopbyMap-DvEvreo3.js"),[])),rTs=k.lazy(()=>Ba(()=>import("./LiveVisitorFeed-DTF9SMve.js"),[])),nTs=k.lazy(()=>Ba(()=>import("./LeadSites-DiVbvJjC.js"),[])),sBe=k.lazy(()=>Ba(()=>import("./LeadSiteEditor-DkORUxos.js"),__vite__mapDeps([20,21,22]))),aTs=k.lazy(()=>Ba(()=>import("./AdminLeadSiteThemes-zILf3j1c.js"),__vite__mapDeps([23,21]))),iTs=k.lazy(()=>Ba(()=>import("./AdminMlsFeeds-C2Tmft2a.js"),[])),oTs=k.lazy(()=>Ba(()=>import("./AdminLeadSiteAnalytics-RgYmYspN.js"),[])),lTs=k.lazy(()=>Ba(()=>import("./AdminWebsiteInterests-Ci3FA6Pd.js"),[])),cTs=k.lazy(()=>Ba(()=>import("./AdminMlsFeeTracker-CbKs3x8b.js"),[])),dTs=k.lazy(()=>Ba(()=>import("./MLSListings-Cm-nOZ7X.js"),[])),uTs=k.lazy(()=>Ba(()=>import("./MLSListingDetail-Ut9chNGy.js"),__vite__mapDeps([24,12,19]))),hTs=k.lazy(()=>Ba(()=>import("./MarketReportPage-B7hKBtWK.js"),[]));k.lazy(()=>Ba(()=>Promise.resolve().then(()=>ZMs),void 0));const mTs=k.lazy(()=>Ba(()=>import("./EmailCampaigns-C16lZjc8.js"),[])),pTs=k.lazy(()=>Ba(()=>import("./EmailCampaignComposer-PFi8HVtD.js"),__vite__mapDeps([25,26]))),fTs=k.lazy(()=>Ba(()=>import("./EmailCampaignDetail-YQwMQI0m.js"),[])),xTs=k.lazy(()=>Ba(()=>import("./SharedCampaignTemplates-CzBVbO9k.js"),__vite__mapDeps([27,28,26]))),gTs=k.lazy(()=>Ba(()=>import("./AgentTemplates-CZMJeecN.js"),__vite__mapDeps([29,28,26]))),rBe=k.lazy(()=>Ba(()=>import("./TheLocalMoveHome-ChEmcuti.js"),__vite__mapDeps([30,31]))),nBe=k.lazy(()=>Ba(()=>import("./TheLocalMoveGetStarted-BUestkVb.js"),__vite__mapDeps([32,31]))),aBe=k.lazy(()=>Ba(()=>import("./TheLocalMoveCheckout-Cs51Zk_w.js"),[])),iBe=k.lazy(()=>Ba(()=>import("./TheLocalMoveCheckoutSuccess-D9ubwjbs.js"),[])),yTs=k.lazy(()=>Ba(()=>import("./AdminWebsiteOrders-BZrCfwTq.js"),[])),vTs=new Nvt({defaultOptions:{queries:{refetchOnWindowFocus:!1,staleTime:5*60*1e3}}}),_Ts=()=>{const t=window.location.hostname;return t==="listings.relevelup.com"||t.startsWith("listings.")},bTs=()=>{const t=window.location.hostname;return t==="cards.relevelup.com"||t.startsWith("cards.")},wTs=()=>{const t=window.location.hostname;return t==="presentations.relevelup.com"||t.startsWith("presentations.")},jTs=()=>{const t=window.location.hostname;return t==="guestbook.relevelup.com"||t.startsWith("guestbook.")},NTs=()=>{const t=window.location.hostname;return t==="clients.relevelup.com"||t.startsWith("clients.")},kTs=()=>{const t=window.location.hostname;return t==="cardstudio.relevelup.com"||t.startsWith("cardstudio.")},STs=()=>{const t=window.location.hostname;return t==="booking.relevelup.com"||t.startsWith("booking.")},CTs=()=>{const t=window.location.hostname;return t==="contacts.relevelup.com"||t.startsWith("contacts.")},MTs=()=>{const t=window.location.hostname;return t==="pages.relevelup.com"||t.startsWith("pages.")},Zct=()=>{const t=window.location.hostname;return t==="thelocalmove.com"||t==="www.thelocalmove.com"},TTs=()=>window.location.hostname.endsWith(".thelocalmove.com")&&!Zct();if(typeof window<"u")try{const s=new URLSearchParams(window.location.search).get("ref");s&&/^[a-z0-9]{2,32}$/i.test(s)&&localStorage.setItem("levelup_referral_code",s.toLowerCase())}catch{}const ATs=()=>e.jsx(Tvt,{client:vTs,children:e.jsx(yVe,{children:e.jsxs(S1,{children:[e.jsx(ryt,{}),e.jsx(Dyt,{}),e.jsx(z1t,{children:e.jsx(Ewt,{children:e.jsx(Pwt,{children:e.jsxs(Lwt,{children:[e.jsx(Iwt,{}),e.jsx(mNt,{}),e.jsx(TNt,{}),kTs()?e.jsx(D5s,{}):bTs()?e.jsx(Kkt,{}):_Ts()?e.jsx(xkt,{}):wTs()?e.jsx(Xkt,{}):jTs()?e.jsx(zEt,{}):NTs()?e.jsx(aPt,{}):STs()?e.jsx(R5s,{}):CTs()?e.jsx(O5s,{}):MTs()?e.jsx(F5s,{}):Zct()?e.jsxs(Hoe,{children:[e.jsx(ys,{path:"/get-started",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(nBe,{})})}),e.jsx(ys,{path:"/checkout",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(aBe,{})})}),e.jsx(ys,{path:"/checkout/success",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(iBe,{})})}),e.jsx(ys,{path:"/privacy-policy",element:e.jsx(PIe,{})}),e.jsx(ys,{path:"/terms-of-service",element:e.jsx(IIe,{})}),e.jsx(ys,{path:"*",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(rBe,{})})})]}):TTs()?e.jsx(wMs,{}):e.jsxs(Hoe,{children:[e.jsx(ys,{path:"/",element:e.jsx(pPt,{})}),e.jsx(ys,{path:"/the-local-move",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(rBe,{})})}),e.jsx(ys,{path:"/get-started",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(nBe,{})})}),e.jsx(ys,{path:"/local-move/checkout",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(aBe,{})})}),e.jsx(ys,{path:"/local-move/checkout/success",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(iBe,{})})}),e.jsx(ys,{path:"/privacy-policy",element:e.jsx(PIe,{})}),e.jsx(ys,{path:"/terms-of-service",element:e.jsx(IIe,{})}),e.jsx(ys,{path:"/data-deletion",element:e.jsx(fPt,{})}),e.jsx(ys,{path:"/public/listings",element:e.jsx(xWe,{})}),e.jsx(ys,{path:"/public/listing/:slugOrId",element:e.jsx(aLt,{})}),e.jsx(ys,{path:"/card/:slug",element:e.jsx(iLt,{})}),e.jsx(ys,{path:"/join-brokerage/:slug",element:e.jsx(M3s,{})}),e.jsx(ys,{path:"/recruit-unsubscribe",element:e.jsx(P3s,{})}),e.jsx(ys,{path:"/recruit-video/:shareToken",element:e.jsx(A3s,{})}),e.jsx(ys,{path:"/connect/:slug",element:e.jsx(pXe,{})}),e.jsx(ys,{path:"/auth",element:e.jsx(gPt,{})}),e.jsx(ys,{path:"/subscription-success",element:e.jsx(yPt,{})}),e.jsx(ys,{path:"/subscription",element:e.jsx(rr,{children:e.jsx(uIt,{})})}),e.jsxs(ys,{path:"/share/video",element:e.jsx(QIt,{}),children:[e.jsx(ys,{path:":shareToken",element:e.jsx(rLe,{})}),e.jsx(ys,{path:":shareToken/r/:recipientToken",element:e.jsx(rLe,{})})]}),e.jsx(ys,{path:"/p/:shareToken",element:e.jsx(Q3s,{})}),e.jsx(ys,{path:"/portal/:slug",element:e.jsx(a5s,{})}),e.jsx(ys,{path:"/portal/:slug/refer",element:e.jsx(XZe,{})}),e.jsx(ys,{path:"/og/video/:token",element:e.jsx(JIt,{})}),e.jsx(ys,{path:"/setup-brokerage",element:e.jsx(rr,{children:e.jsx(hIt,{})})}),e.jsx(ys,{path:"/claim-account",element:e.jsx(eLe,{})}),e.jsx(ys,{path:"/claim",element:e.jsx(eLe,{})}),e.jsx(ys,{path:"/join",element:e.jsx(mIt,{})}),e.jsx(ys,{path:"/trial",element:e.jsx(NIt,{})}),e.jsx(ys,{path:"/trial/success",element:e.jsx(kIt,{})}),e.jsx(ys,{path:"/dashboard",element:e.jsx(rr,{children:e.jsx(C8t,{})})}),e.jsx(ys,{path:"/profile",element:e.jsx(rr,{children:e.jsx(y$t,{})})}),e.jsx(ys,{path:"/apps",element:e.jsx(rr,{children:e.jsx(T$t,{})})}),e.jsx(ys,{path:"/admin",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(sDe,{})})}),e.jsx(ys,{path:"/admin/dashboard",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(sDe,{})})}),e.jsx(ys,{path:"/admin/apps",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(xVt,{})})}),e.jsx(ys,{path:"/admin/members",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(NVt,{})})}),e.jsx(ys,{path:"/admin/invite-codes",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(kVt,{})})}),e.jsx(ys,{path:"/admin/events",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(EVt,{})})}),e.jsx(ys,{path:"/events",element:e.jsx(rr,{children:e.jsx(k$t,{})})}),e.jsx(ys,{path:"/events/:eventId",element:e.jsx(rr,{children:e.jsx(C$t,{})})}),e.jsx(ys,{path:"/templates",element:e.jsx(rr,{children:e.jsx(A$t,{})})}),e.jsx(ys,{path:"/templates/:templateId",element:e.jsx(rr,{children:e.jsx(L$t,{})})}),e.jsx(ys,{path:"/admin/templates",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(IVt,{})})}),e.jsx(ys,{path:"/academy",element:e.jsx(rr,{children:e.jsx(D$t,{})})}),e.jsx(ys,{path:"/academy/:videoId",element:e.jsx(rr,{children:e.jsx(O$t,{})})}),e.jsx(ys,{path:"/admin/academy",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(DVt,{})})}),e.jsx(ys,{path:"/toolbox",element:e.jsx(rr,{children:e.jsx(F$t,{})})}),e.jsx(ys,{path:"/toolbox/:kitId",element:e.jsx(rr,{children:e.jsx(z$t,{})})}),e.jsx(ys,{path:"/admin/toolbox",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(RVt,{})})}),e.jsx(ys,{path:"/social-swag",element:e.jsx(rr,{children:e.jsx(B$t,{})})}),e.jsx(ys,{path:"/social-swag-2",element:e.jsx(rr,{children:e.jsx(FUt,{})})}),e.jsx(ys,{path:"/social-swag/:swagId",element:e.jsx(rr,{children:e.jsx(zUt,{})})}),e.jsx(ys,{path:"/social-connections",element:e.jsx(rr,{children:e.jsx(I3s,{})})}),e.jsx(ys,{path:"/social-connections/callback",element:e.jsx(rr,{children:e.jsx(L3s,{})})}),e.jsx(ys,{path:"/social-connections/linkedin-callback",element:e.jsx(rr,{children:e.jsx(R3s,{})})}),e.jsx(ys,{path:"/social-connections/google-callback",element:e.jsx(rr,{children:e.jsx(D3s,{})})}),e.jsx(ys,{path:"/admin/social-swag",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(OVt,{})})}),e.jsx(ys,{path:"/admin/social-swag-2",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(bGt,{})})}),e.jsx(ys,{path:"/community",element:e.jsx(rr,{children:e.jsx(nVt,{})})}),e.jsx(ys,{path:"/support",element:e.jsx(rr,{children:e.jsx(aVt,{})})}),e.jsx(ys,{path:"/admin/community",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(wGt,{})})}),e.jsx(ys,{path:"/admin/support-tickets",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(s1s,{})})}),e.jsx(ys,{path:"/admin/email-templates",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(n1s,{})})}),e.jsx(ys,{path:"/admin/agent-email-templates",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(a1s,{})})}),e.jsx(ys,{path:"/admin/analytics",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(Jvs,{})})}),e.jsx(ys,{path:"/admin/brokerage-resources",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(e1s,{})})}),e.jsx(ys,{path:"/admin/dashboard-management",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(t1s,{})})}),e.jsx(ys,{path:"/brokerage/dashboard",element:e.jsx(rr,{requireBrokerageManager:!0,children:e.jsx(g1s,{})})}),e.jsx(ys,{path:"/brokerage/teams",element:e.jsx(rr,{requireBrokerageManager:!0,children:e.jsx(kMs,{})})}),e.jsx(ys,{path:"/brokerage/recruiting",element:e.jsx(rr,{requireBrokerageManager:!0,children:e.jsx(YSs,{})})}),e.jsx(ys,{path:"/my-team",element:e.jsx(rr,{children:e.jsx(SMs,{})})}),e.jsx(ys,{path:"/my-brokerage",element:e.jsx(rr,{children:e.jsx(j1s,{})})}),e.jsx(ys,{path:"/brokerage-content",element:e.jsx(rr,{children:e.jsx(T1s,{})})}),e.jsx(ys,{path:"/brokerage-content/:contentId",element:e.jsx(rr,{children:e.jsx(L1s,{})})}),e.jsx(ys,{path:"/brokerage-resources",element:e.jsx(rr,{requireBrokerageManager:!0,children:e.jsx(uVt,{})})}),e.jsx(ys,{path:"/brokerage-resources/:resourceId",element:e.jsx(rr,{requireBrokerageManager:!0,children:e.jsx(hVt,{})})}),e.jsx(ys,{path:"/newsletters",element:e.jsx(rr,{children:e.jsx(D1s,{})})}),e.jsx(ys,{path:"/newsletters/:id",element:e.jsx(rr,{children:e.jsx(O1s,{})})}),e.jsx(ys,{path:"/wishlist",element:e.jsx(rr,{children:e.jsx(B1s,{})})}),e.jsx(ys,{path:"/wishlist/:itemId",element:e.jsx(rr,{children:e.jsx($1s,{})})}),e.jsx(ys,{path:"/admin/wishlist",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(q1s,{})})}),e.jsx(ys,{path:"/admin/levelup-brief",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(U1s,{})})}),e.jsx(ys,{path:"/admin/newsletters",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(z1s,{})})}),e.jsx(ys,{path:"/admin/additional-services",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(V1s,{})})}),e.jsx(ys,{path:"/admin/discounts",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(H1s,{})})}),e.jsx(ys,{path:"/admin/subscriptions",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(G1s,{})})}),e.jsx(ys,{path:"/admin/referrals",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(W1s,{})})}),e.jsx(ys,{path:"/admin/prospector",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(ASs,{})})}),e.jsx(ys,{path:"/admin/recruiting",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(ZSs,{})})}),e.jsx(ys,{path:"/admin/beta/social-post-generator",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(XCs,{})})}),e.jsx(ys,{path:"/admin/credits",element:e.jsx(rr,{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(JMs,{})})})}),e.jsx(ys,{path:"/admin/cleanup",element:e.jsx(rr,{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(eTs,{})})})}),e.jsx(ys,{path:"/admin/beta/postcard-manager",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(XMs,{})})})}),e.jsx(ys,{path:"/admin/beta/homereel",element:e.jsx(rr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(QMs,{})})})}),e.jsx(ys,{path:"/admin/lms",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(u3s,{})})}),e.jsx(ys,{path:"/admin/lms/stats",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(x3s,{})})}),e.jsx(ys,{path:"/admin/lms/:courseId",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(h3s,{})})}),e.jsx(ys,{path:"/levelup-u",element:e.jsx(rr,{children:e.jsx(g3s,{})})}),e.jsx(ys,{path:"/levelup-u/:courseId",element:e.jsx(rr,{children:e.jsx(v3s,{})})}),e.jsx(ys,{path:"/admin/brokerage-content-activity",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(XSs,{})})}),e.jsx(ys,{path:"/admin/onboarding-checklist",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(Z1s,{})})}),e.jsx(ys,{path:"/admin/marketplace",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(oSs,{})})}),e.jsx(ys,{path:"/admin/agent-points",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(E4s,{})})}),e.jsx(ys,{path:"/admin/reward-store",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(wSs,{})})}),e.jsx(ys,{path:"/admin/integrations",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(NSs,{})})}),e.jsx(ys,{path:"/admin/integrations/callback",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(TSs,{})})}),e.jsx(ys,{path:"/admin/email-campaigns",element:e.jsx(rr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(mTs,{})})})}),e.jsx(ys,{path:"/admin/email-campaigns/templates",element:e.jsx(rr,{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(xTs,{})})})}),e.jsx(ys,{path:"/email-campaigns/templates",element:e.jsx(rr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(gTs,{})})})}),e.jsx(ys,{path:"/admin/email-campaigns/new",element:e.jsx(rr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(pTs,{})})})}),e.jsx(ys,{path:"/admin/email-campaigns/:id",element:e.jsx(rr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(fTs,{})})})}),e.jsx(ys,{path:"/reward-store",element:e.jsx(rr,{children:e.jsx(V3s,{})})}),e.jsx(ys,{path:"/refer-friends",element:e.jsx(rr,{children:e.jsx(G3s,{})})}),e.jsx(ys,{path:"/additional-services",element:e.jsx(rr,{children:e.jsx(i_s,{})})}),e.jsx(ys,{path:"/additional-services/:serviceId",element:e.jsx(rr,{children:e.jsx(o_s,{})})}),e.jsx(ys,{path:"/ai-toolkit",element:e.jsx(rr,{children:e.jsx(l_s,{})})}),e.jsx(ys,{path:"/mission-control",element:e.jsx(rr,{children:e.jsx(C_s,{})})}),e.jsx(ys,{path:"/mission-control/contacts",element:e.jsx(rr,{children:e.jsx(Abs,{})})}),e.jsx(ys,{path:"/mission-control/contacts/:contactId",element:e.jsx(rr,{children:e.jsx(cws,{})})}),e.jsx(ys,{path:"/mission-control/plans",element:e.jsx(rr,{children:e.jsx(dws,{})})}),e.jsx(ys,{path:"/mission-control/popbys",element:e.jsx(rr,{children:e.jsx(gws,{})})}),e.jsx(ys,{path:"/mission-control/popbys/map",element:e.jsx(rr,{children:e.jsx(sTs,{})})}),e.jsx(ys,{path:"/admin/notification-settings",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(SSs,{})})}),e.jsx(ys,{path:"/admin/agent-os",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(X1s,{})})}),e.jsx(ys,{path:"/mission-control/listings",element:e.jsx(rr,{children:e.jsx($ws,{})})}),e.jsx(ys,{path:"/mission-control/listings/new",element:e.jsx(rr,{children:e.jsx(J7e,{})})}),e.jsx(ys,{path:"/mission-control/listings/:listingId",element:e.jsx(rr,{children:e.jsx(a2s,{})})}),e.jsx(ys,{path:"/mission-control/listings/:listingId/edit",element:e.jsx(rr,{children:e.jsx(J7e,{})})}),e.jsx(ys,{path:"/admin/listing-exchange",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(k4s,{})})}),e.jsx(ys,{path:"/mission-control/pipeline",element:e.jsx(rr,{children:e.jsx(kks,{})})}),e.jsx(ys,{path:"/mission-control/tasks",element:e.jsx(rr,{children:e.jsx(Dks,{})})}),e.jsx(ys,{path:"/mission-control/portal-referrals",element:e.jsx(rr,{children:e.jsx($ks,{})})}),e.jsx(ys,{path:"/mission-control/my-card",element:e.jsx(rr,{children:e.jsx(o4s,{})})}),e.jsx(ys,{path:"/mission-control/integrations",element:e.jsx(rr,{children:e.jsx(y4s,{})})}),e.jsx(ys,{path:"/mission-control/integrations/gmail/callback",element:e.jsx(rr,{children:e.jsx(v4s,{})})}),e.jsx(ys,{path:"/mission-control/integrations/canva/callback",element:e.jsx(_4s,{})}),e.jsx(ys,{path:"/mission-control/integrations/meta/callback",element:e.jsx(rr,{children:e.jsx(b4s,{})})}),e.jsx(ys,{path:"/mission-control/scorecard",element:e.jsx(rr,{children:e.jsx(Ews,{})})}),e.jsx(ys,{path:"/admin/scorecard",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(j4s,{})})}),e.jsx(ys,{path:"/admin/scorecard/:userId",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(h9e,{})})}),e.jsx(ys,{path:"/mission-control/scorecard/:userId",element:e.jsx(rr,{children:e.jsx(h9e,{})})}),e.jsx(ys,{path:"/mission-control/relationship-scorecard",element:e.jsx(rr,{children:e.jsx(zMs,{})})}),e.jsx(ys,{path:"/mission-control/sphere-gaps",element:e.jsx(rr,{children:e.jsx(UMs,{})})}),e.jsx(ys,{path:"/mission-control/website-activity",element:e.jsx(rr,{children:e.jsx(Kct,{})})}),e.jsx(ys,{path:"/mission-control/connect-page",element:e.jsx(rr,{children:e.jsx(HMs,{})})}),e.jsx(ys,{path:"/admin/membership-reviews",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(S4s,{})})}),e.jsx(ys,{path:"/admin/weekly-digest",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(T4s,{})})}),e.jsx(ys,{path:"/mission-control/video/record",element:e.jsx(rr,{children:e.jsx(lNs,{})})}),e.jsx(ys,{path:"/mission-control/video-library",element:e.jsx(rr,{children:e.jsx(jNs,{})})}),e.jsx(ys,{path:"/marketplace",element:e.jsx(rr,{children:e.jsx(O3s,{})})}),e.jsx(ys,{path:"/marketplace/:productId",element:e.jsx(rr,{children:e.jsx(F3s,{})})}),e.jsx(ys,{path:"/marketplace/cart",element:e.jsx(rr,{children:e.jsx(z3s,{})})}),e.jsx(ys,{path:"/marketplace/orders",element:e.jsx(rr,{children:e.jsx(B3s,{})})}),e.jsx(ys,{path:"/marketplace/orders/:orderId",element:e.jsx(rr,{children:e.jsx(q3s,{})})}),e.jsx(ys,{path:"/marketplace/success",element:e.jsx(rr,{children:e.jsx(U3s,{})})}),e.jsx(ys,{path:"/admin/agent-cards",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(P4s,{})})}),e.jsx(ys,{path:"/admin/presentation-analytics",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(CSs,{})})}),e.jsx(ys,{path:"/admin/guest-book-analytics",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(MSs,{})})}),e.jsx(ys,{path:"/mission-control/smart-drips",element:e.jsx(rr,{children:e.jsx(I5s,{})})}),e.jsx(ys,{path:"/mission-control/direct-mail",element:e.jsx(rr,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(tTs,{})})})}),e.jsx(ys,{path:"/mission-control/presentations",element:e.jsx(rr,{children:e.jsx(W3s,{})})}),e.jsx(ys,{path:"/mission-control/presentations/new",element:e.jsx(rr,{children:e.jsx(O9e,{})})}),e.jsx(ys,{path:"/mission-control/presentations/:id",element:e.jsx(rr,{children:e.jsx(O9e,{})})}),e.jsx(ys,{path:"/mission-control/guest-book",element:e.jsx(rr,{children:e.jsx(r5s,{})})}),e.jsx(ys,{path:"/mission-control/guest-book/live/:id",element:e.jsx(rr,{children:e.jsx(rTs,{})})}),e.jsx(ys,{path:"/guestbook/:slug",element:e.jsx(YWe,{})}),e.jsx(ys,{path:"/mission-control/card-studio",element:e.jsx(rr,{children:e.jsx(u5s,{})})}),e.jsx(ys,{path:"/mission-control/scheduler",element:e.jsx(rr,{children:e.jsx(IMs,{})})}),e.jsx(ys,{path:"/c/:shareToken",element:e.jsx(Fct,{})}),e.jsx(ys,{path:"/book/:slug",element:e.jsx(Bct,{})}),e.jsx(ys,{path:"/page/:slug",element:e.jsx($ct,{})}),e.jsx(ys,{path:"/mission-control/landing-pages",element:e.jsx(rr,{children:e.jsx(LMs,{})})}),e.jsx(ys,{path:"/mission-control/landing-pages/:pageId",element:e.jsx(rr,{children:e.jsx(OMs,{})})}),e.jsx(ys,{path:"/my-website/:siteId/edit",element:e.jsx(rr,{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(sBe,{})})})}),e.jsx(ys,{path:"/my-website/mls-listings",element:e.jsx(rr,{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(dTs,{})})})}),e.jsx(ys,{path:"/my-website/mls-listings/:mlsId",element:e.jsx(rr,{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(uTs,{})})})}),e.jsx(ys,{path:"/my-website/market-report",element:e.jsx(rr,{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(hTs,{})})})}),e.jsx(ys,{path:"/admin/lead-sites",element:e.jsx(rr,{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(nTs,{})})})}),e.jsx(ys,{path:"/admin/lead-sites/themes",element:e.jsx(rr,{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(aTs,{})})})}),e.jsx(ys,{path:"/admin/lead-sites/:siteId/edit",element:e.jsx(rr,{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(sBe,{})})})}),e.jsx(ys,{path:"/admin/mls-feeds",element:e.jsx(rr,{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(iTs,{})})})}),e.jsx(ys,{path:"/admin/lead-site-analytics",element:e.jsx(rr,{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(oTs,{})})})}),e.jsx(ys,{path:"/admin/website-interests",element:e.jsx(rr,{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(lTs,{})})})}),e.jsx(ys,{path:"/admin/website-orders",element:e.jsx(rr,{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(yTs,{})})})}),e.jsx(ys,{path:"/admin/mls-fee-tracker",element:e.jsx(rr,{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(cTs,{})})})}),e.jsx(ys,{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(YMs,{})})}),e.jsx(ys,{path:"*",element:e.jsx(zct,{})})]}),")"]})})})})]})})}),Vp=window.location.hostname,ETs=Vp.includes("lovable.app")||Vp.includes("lovableproject.com"),PTs=(()=>{try{return window.self!==window.top}catch{return!0}})(),ITs=Vp.startsWith("cards.")||Vp.startsWith("cardstudio.")||Vp.startsWith("listings.")||Vp.startsWith("presentations.")||Vp.startsWith("guestbook.")||Vp.startsWith("clients.")||Vp.startsWith("booking.")||Vp.startsWith("contacts.")||Vp.startsWith("pages.")||Vp.endsWith(".thelocalmove.com")&&!Vp.startsWith("dashboard.");var gBe;ETs||PTs||ITs?((gBe=navigator.serviceWorker)==null||gBe.getRegistrations().then(t=>{t.forEach(s=>s.unregister())}),"caches"in window&&caches.keys().then(t=>t.forEach(s=>caches.delete(s)))):"serviceWorker"in navigator&&Ba(async()=>{const{registerSW:t}=await import("./virtual_pwa-register-Cn-I4tD-.js");return{registerSW:t}},[]).then(({registerSW:t})=>{let s=!1;const r=()=>{if(!s)return;const a=document.activeElement;a&&(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.tagName==="SELECT"||a.isContentEditable)||window.location.reload()},n=t({onNeedRefresh(){if(s=!0,document.visibilityState==="hidden"){window.location.reload();return}document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&window.location.reload()}),setTimeout(r,5*60*1e3)},onOfflineReady(){}});setInterval(()=>{n==null||n(!0).catch(()=>{})},15*60*1e3)});Aqe(document.getElementById("root")).render(e.jsx(ATs,{}));export{ubs as $,Bi as A,pe as B,so as C,qs as D,jn as E,rd as F,Oa as G,Mn as H,FY as I,dh as J,mh as K,ga as L,wi as M,Jxe as N,A1t as O,In as P,Ia as Q,cn as R,ln as S,Qo as T,ir as U,AEe as V,Xa as W,kr as X,_O as Y,Oh as Z,Ba as _,wr as a,Sae as a$,tit as a0,pbs as a1,zSe as a2,Zn as a3,io as a4,Om as a5,Pt as a6,nd as a7,_n as a8,E1 as a9,Ss as aA,W as aB,Ln as aC,Dn as aD,Ps as aE,St as aF,Rn as aG,ht as aH,Qe as aI,Ar as aJ,fs as aK,ps as aL,ks as aM,_s as aN,xe as aO,De as aP,$s as aQ,zs as aR,Vs as aS,Bs as aT,vt as aU,gn as aV,eAs as aW,vs as aX,hi as aY,_r as aZ,qo as a_,vS as aa,us as ab,Zy as ac,nf as ad,jL as ae,id as af,WU as ag,_L as ah,qy as ai,Ag as aj,Xo as ak,Yr as al,Sm as am,EM as an,Hoe as ao,ys as ap,Pe as aq,Dt as ar,zt as as,_c as at,dr as au,Oe as av,ta as aw,Jn as ax,cs as ay,cl as az,op as b,Ir as b$,H4 as b0,pa as b1,bc as b2,Va as b3,vr as b4,Ds as b5,iS as b6,mi as b7,Ra as b8,Sb as b9,S4e as bA,jAs as bB,qV as bC,C4e as bD,iC as bE,mu as bF,ec as bG,tc as bH,Gv as bI,Dl as bJ,_se as bK,mo as bL,po as bM,no as bN,Ja as bO,hL as bP,$n as bQ,ro as bR,wJ as bS,xJ as bT,oL as bU,Hu as bV,MM as bW,vn as bX,EV as bY,WL as bZ,yx as b_,MJ as ba,hh as bb,Co as bc,eie as bd,Cg as be,Iv as bf,xi as bg,Qa as bh,oS as bi,Zi as bj,Rd as bk,yn as bl,Ig as bm,hS as bn,Qy as bo,aIt as bp,Nn as bq,Ma as br,kn as bs,v4e as bt,yce as bu,w4e as bv,oO as bw,dre as bx,N4e as by,_4e as bz,Ot as c,_a as c$,Vj as c0,S1 as c1,UL as c2,Dc as c3,PL as c4,Ri as c5,fn as c6,wpt as c7,ao as c8,xt as c9,Kre as cA,tS as cB,cS as cC,oJ as cD,Cm as cE,zu as cF,wZ as cG,uu as cH,Ih as cI,k4e as cJ,Av as cK,NAs as cL,MAs as cM,TAs as cN,pp as cO,AAs as cP,yGt as cQ,Gn as cR,uh as cS,Kv as cT,xx as cU,Ab as cV,gd as cW,Hd as cX,Gd as cY,Nd as cZ,ije as c_,D_s as ca,L_s as cb,O_s as cc,Ko as cd,AM as ce,ML as cf,si as cg,sAs as ch,NWe as ci,nAs as cj,aAs as ck,iAs as cl,e1 as cm,DNe as cn,Do as co,hr as cp,n0 as cq,ZA as cr,SC as cs,YA as ct,XA as cu,Wre as cv,zl as cw,gx as cx,EL as cy,rte as cz,So as d,Nb as d$,FL as d0,dS as d1,z5s as d2,Jo as d3,fp as d4,mL as d5,fx as d6,td as d7,Sme as d8,ya as d9,Ev as dA,_ne as dB,Z4 as dC,Oke as dD,zke as dE,Zke as dF,O9t as dG,Yke as dH,Iat as dI,Xke as dJ,K4 as dK,rS as dL,SM as dM,CM as dN,Dh as dO,Xy as dP,V4 as dQ,G4 as dR,vo as dS,wS as dT,fS as dU,Dke as dV,ja as dW,kl as dX,Q4 as dY,Rh as dZ,yj as d_,sit as da,Pie as db,zCe as dc,Jy as dd,ho as de,hu as df,Nae as dg,EO as dh,Wa as di,Mm as dj,Y4 as dk,mS as dl,uf as dm,tT as dn,Eat as dp,M0 as dq,hO as dr,tp as ds,Aat as dt,mC as du,pC as dv,_1 as dw,au as dx,iL as dy,xS as dz,Us as e,aS as e0,lL as e1,MW as e2,dte as e3,ad as e4,eN as e5,t1 as e6,e0 as e7,pS as e8,jM as e9,REt as ea,Bvt as eb,npe as ec,uq as ed,WCe as ee,U5s as ef,PAs as eg,EAs as eh,cW as ei,$ne as ej,uie as ek,_M as el,nc as em,IAs as en,KCe as eo,LM as ep,H5s as eq,da as er,Nc as f,gt as g,CC as h,w_s as i,e as j,xa as k,tr as l,Qt as m,iu as n,Y6t as o,Or as p,Nl as q,k as r,G as s,Ai as t,$l as u,nn as v,nhe as w,Nf as x,JA as y,af as z};