const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/LeadSiteHome-B10NY1B9.js","assets/useLeadSiteSearchSuggestions-Do0sAwZO.js","assets/CityPagesModule-iDsYKutw.js","assets/imageOptimization-rphVJGSj.js","assets/LeadSiteLuxuryHome-bH_WjiPM.js","assets/LeadSiteLandRanchHome-5zCeXn71.js","assets/LeadSiteSearch-Bvi507Sn.js","assets/SaveSearchButton-CwWVNkcb.js","assets/LeadSiteMap-BvGAsQZK.js","assets/LeadSiteLuxurySearch-C9Hm42Qw.js","assets/LeadSiteListingDetail-BpaLg3Qx.js","assets/ListingVideoTour-BpwdVseB.js","assets/useListingVideos-Ow9EF2Xx.js","assets/LeadSiteLuxuryListingDetail-CPBDEdqn.js","assets/LeadSiteCityPage-D8V5su2n.js","assets/LeadSiteSubdivisionPage-z7EjThAS.js","assets/PostcardManager-Cuq0uV3T.js","assets/usePostcardZones-BjFzqolC.js","assets/DirectMail-DJ6SWmEP.js","assets/jspdf.es.min-Dq6hsrli.js","assets/LeadSiteEditor-CV9stTNo.js","assets/VideoUrlField-D7ON7vd-.js","assets/LeadSiteEditor-BzY4kI8E.css","assets/AdminLeadSiteThemes-DuCvqjKm.js","assets/MLSListingDetail-BgMw-_3F.js","assets/EmailCampaignComposer-DADdZqvr.js","assets/EditorModeSelector-C0MAeHxw.js","assets/SharedCampaignTemplates-BdCMln4T.js","assets/TemplateEditorDialog-DvUUFW90.js","assets/AgentTemplates-DcZJqQ0f.js","assets/TheLocalMoveHome-Cgm0ofBf.js","assets/tlm-hero-bg-BbD3acLf.js","assets/TheLocalMoveGetStarted-CyVKJvsI.js"])))=>i.map(i=>d[i]); var Kmt=Object.defineProperty;var uAe=t=>{throw TypeError(t)};var Zmt=(t,s,r)=>s in t?Kmt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r;var En=(t,s,r)=>Zmt(t,typeof s!="symbol"?s+"":s,r),gxe=(t,s,r)=>s.has(t)||uAe("Cannot "+r);var ds=(t,s,r)=>(gxe(t,s,"read from private field"),r?r.call(t):s.get(t)),za=(t,s,r)=>s.has(t)?uAe("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,r),zn=(t,s,r,n)=>(gxe(t,s,"write to private field"),n?n.call(t,r):s.set(t,r),r),Ii=(t,s,r)=>(gxe(t,s,"access private method"),r);var Z7=(t,s,r,n)=>({set _(a){zn(t,s,a,r)},get _(){return ds(t,s,n)}});function Ymt(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 Xmt="modulepreload",Qmt=function(t){return"/"+t},hAe={},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=Qmt(d),d in hAe)return;hAe[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":Xmt,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 fd=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function no(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Jmt(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:{}},Ide={},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"),ept=Symbol.for("react.portal"),tpt=Symbol.for("react.fragment"),spt=Symbol.for("react.strict_mode"),rpt=Symbol.for("react.profiler"),npt=Symbol.for("react.provider"),apt=Symbol.for("react.context"),ipt=Symbol.for("react.forward_ref"),opt=Symbol.for("react.suspense"),lpt=Symbol.for("react.memo"),cpt=Symbol.for("react.lazy"),mAe=Symbol.iterator;function dpt(t){return t===null||typeof t!="object"?null:(t=mAe&&t[mAe]||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 pAe=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(Te,ye))Mea(De,Te)?(oe[he]=De,oe[Me]=ye,he=Me):(oe[he]=Te,oe[Ue]=ye,he=Ue);else if(Mea(De,ye))oe[he]=De,oe[Me]=ye,he=Me;else break e}}return me}function a(oe,me){var ye=oe.sortIndex-me.sortIndex;return ye!==0?ye: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,k=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,ae(L);else{var me=r(u);me!==null&&ie(I,me.startTime-oe)}}function L(oe,me){b=!1,N&&(N=!1,k(q),q=-1),_=!0;var ye=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 Ne=!0;else{var Ue=r(u);Ue!==null&&ie(I,Ue.startTime-me),Ne=!1}return Ne}finally{f=null,y=ye,_=!1}}var O=!1,V=null,q=-1,B=5,U=-1;function te(){return!(t.unstable_now()-Uoe||125he?(oe.sortIndex=ye,s(u,oe),r(d)===null&&oe===r(u)&&(N?(k(q),q=-1):N=!0,ie(I,ye-he))):(oe.sortIndex=ge,s(d,oe),b||_||(b=!0,ae(L))),oe},t.unstable_shouldYield=te,t.unstable_wrapCallback=function(oe){var me=y;return function(){var ye=y;y=me;try{return oe.apply(this,arguments)}finally{y=ye}}}})(EBe);ABe.exports=EBe;var bpt=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 wpt=S,xf=bpt;function Vr(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,jpt=/^[: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]*$/,xAe={},gAe={};function Npt(t){return E0e.call(gAe,t)?!0:E0e.call(xAe,t)?!1:jpt.test(t)?gAe[t]=!0:(xAe[t]=!0,!1)}function kpt(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 Spt(t,s,r,n){if(s===null||typeof s>"u"||kpt(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{_xe=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?SI(t):""}function Cpt(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=bxe(t.type,!1),t;case 11:return t=bxe(t.type.render,!1),t;case 1:return t=bxe(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 Mpt(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 Tpt(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 Q7(t){t._valueTracker||(t._valueTracker=Tpt(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 uoe(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 vAe(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 _Ae(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"||uoe(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=J7.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},Apt=["Webkit","ms","Moz","O"];Object.keys(GI).forEach(function(t){Apt.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 Ept=$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(Ept[t]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(Vr(137,t));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(Vr(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(Vr(61))}if(s.style!=null&&typeof s.style!="object")throw Error(Vr(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 jAe(t){if(t=_R(t)){if(typeof V0e!="function")throw Error(Vr(280));var s=t.stateNode;s&&(s=Fde(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,jAe(t),s)for(t=0;t>>=0,t===0?32:31-(qpt(t)/Upt|0)|0}var ez=64,tz=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 foe(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 Wpt(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),PAe=" ",IAe=!1;function u$e(t,s){switch(t){case"keyup":return bft.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 jft(t,s){switch(t){case"compositionend":return h$e(s);case"keypress":return s.which!==32?null:(IAe=!0,PAe);case"textInput":return t=s.data,t===PAe&&IAe?null:t;default:return null}}function Nft(t,s){if(U5)return t==="compositionend"||!N2e&&u$e(t,s)?(t=c$e(),F9=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=OAe(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=uoe();s instanceof t.HTMLIFrameElement;){try{var r=typeof s.contentWindow.location.href=="string"}catch{r=!1}if(r)t=s.contentWindow;else break;s=uoe(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 Ift(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=FAe(r,o);var l=FAe(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 zAe(t,s,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;X0e||V5==null||V5!==uoe(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=yoe(Y0e,"onSelect"),0W5||(t.current=rve[W5],rve[W5]=null,W5--)}function Il(t,s){W5++,rve[W5]=t.current,t.current=s}var Vb={},Fh=lw(Vb),dp=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 up(t){return t=t.childContextTypes,t!=null}function _oe(){sc(dp),sc(Fh)}function GAe(t,s,r){if(Fh.current!==Vb)throw Error(Vr(168));Il(Fh,s),Il(dp,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(Vr(108,Mpt(t)||"Unknown",a));return $c({},r,n)}function boe(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Vb,FS=Fh.current,Il(Fh,t),Il(dp,dp.current),!0}function WAe(t,s,r){var n=t.stateNode;if(!n)throw Error(Vr(169));r?(t=S$e(t,s,FS),n.__reactInternalMemoizedMergedChildContext=t,sc(dp),sc(Fh),Il(Fh,t)):sc(dp),Il(dp,r)}var Cv=null,zde=!1,Dxe=!1;function C$e(t){Cv===null?Cv=[t]:Cv.push(t)}function Hft(t){zde=!0,C$e(t)}function cw(){if(!Dxe&&Cv!==null){Dxe=!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(k,V,A[q],I);if(U===null){V===null&&(V=B);break}t&&V&&U.alternate===null&&s(k,V),C=o(U,C,q),O===null?L=U:O.sibling=U,O=U,V=B}if(q===A.length)return r(k,V),yc&&V2(k,q),L;if(V===null){for(;qq?(B=V,V=null):B=V.sibling;var te=y(k,V,U.value,I);if(te===null){V===null&&(V=B);break}t&&V&&te.alternate===null&&s(k,V),C=o(te,C,q),O===null?L=te:O.sibling=te,O=te,V=B}if(U.done)return r(k,V),yc&&V2(k,q),L;if(V===null){for(;!U.done;q++,U=A.next())U=f(k,U.value,I),U!==null&&(C=o(U,C,q),O===null?L=U:O.sibling=U,O=U);return yc&&V2(k,q),L}for(V=n(k,V);!U.done;q++,U=A.next())U=_(V,k,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(k,Y)}),yc&&V2(k,q),L}function w(k,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 X7: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(k,O.sibling),C=a(O,A.props.children),C.return=k,k=C;break e}}else if(O.elementType===L||typeof L=="object"&&L!==null&&L.$$typeof===A_&&YAe(L)===O.type){r(k,O.sibling),C=a(O,A.props),C.ref=V6(k,O,A),C.return=k,k=C;break e}r(k,O);break}else s(k,O);O=O.sibling}A.type===q5?(C=U4(A.props.children,k.mode,I,A.key),C.return=k,k=C):(I=G9(A.type,A.key,A.props,null,k.mode,I),I.ref=V6(k,C,A),I.return=k,k=I)}return l(k);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(k,C.sibling),C=a(C,A.children||[]),C.return=k,k=C;break e}else{r(k,C);break}else s(k,C);C=C.sibling}C=Uxe(A,k.mode,I),C.return=k,k=C}return l(k);case A_:return O=A._init,w(k,C,O(A._payload),I)}if(CI(A))return b(k,C,A,I);if(z6(A))return N(k,C,A,I);lz(k,A)}return typeof A=="string"&&A!==""||typeof A=="number"?(A=""+A,C!==null&&C.tag===6?(r(k,C.sibling),C=a(C,A),C.return=k,k=C):(r(k,C),C=qxe(A,k.mode,I),C.return=k,k=C),l(k)):r(k,C)}return w}var wT=E$e(!0),P$e=E$e(!1),Noe=lw(null),koe=null,Y5=null,T2e=null;function A2e(){T2e=Y5=koe=null}function E2e(t){var s=Noe.current;sc(Noe),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){koe=t,T2e=Y5=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&s&&(ap=!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(koe===null)throw Error(Vr(308));Y5=t,koe.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,fo&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 B9(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 XAe(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 Soe(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 QAe(t,s,r){if(t=s.effects,s.effects=null,t!==null)for(s=0;sr?r:4,t(!0);var n=Oxe.transition;Oxe.transition={};try{t(!1),s()}finally{Yo=r,Oxe.transition=n}}function X$e(){return kx().memoizedState}function Zft(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 Yft(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=Moe=!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 Toe={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},Xft={readContext:Nx,useCallback:function(t,s){return Cy().memoizedState=[t,s===void 0?null:s],t},useContext:Nx,useEffect:eEe,useImperativeHandle:function(t,s,r){return r=r!=null?r.concat([t]):null,q9(4194308,4,G$e.bind(null,s,t),r)},useLayoutEffect:function(t,s){return q9(4194308,4,t,s)},useInsertionEffect:function(t,s){return q9(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=Zft.bind(null,zc,t),[n.memoizedState,t]},useRef:function(t){var s=Cy();return t={current:t},s.memoizedState=t},useState:JAe,useDebugValue:$2e,useDeferredValue:function(t){return Cy().memoizedState=t},useTransition:function(){var t=JAe(!1),s=t[0];return t=Kft.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(Vr(407));r=r()}else{if(r=s(),Ou===null)throw Error(Vr(349));BS&30||F$e(n,s,r)}a.memoizedState=r;var o={value:r,getSnapshot:s};return a.queue=o,eEe(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":Wl("cancel",t),Wl("close",t),a=n;break;case"iframe":case"object":case"embed":Wl("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=Coe(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*pd()-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=pd(),s.sibling=null,r=Lc.current,Il(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(Vr(156,s.tag))}function axt(t,s){switch(C2e(s),s.tag){case 1:return up(s.type)&&_oe(),t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 3:return jT(),sc(dp),sc(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(sc(Lc),t=s.memoizedState,t!==null&&t.dehydrated!==null){if(s.alternate===null)throw Error(Vr(340));bT()}return t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 19:return sc(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 dz=!1,Ah=!1,ixt=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 uEe=!1;function oxt(t,s){if(Q0e=xoe,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},xoe=!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,k=s.stateNode,C=k.getSnapshotBeforeUpdate(s.elementType===s.type?N:hg(s.type,N),w);k.__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(Vr(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=uEe,uEe=!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 qde(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[Uft],delete s[Vft])),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 hEe(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=voe));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(Lde,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?Lxe(t.parentNode,r):t.nodeType===1&&Lxe(t,r),O8(t)):Lxe(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 mEe(t){var s=t.updateQueue;if(s!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new ixt),s.forEach(function(n){var a=xxt.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=pd()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*cxt(n/1960))-n,10t?16:t,ob===null)var n=!1;else{if(t=ob,ob=null,Poe=0,fo&6)throw Error(Vr(331));var a=fo;for(fo|=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;dpd()-H2e?q4(t,0):V2e|=r),hp(t,s)}function jqe(t,s){s===0&&(t.mode&1?(s=tz,tz<<=1,!(tz&130023424)&&(tz=4194304)):s=1);var r=km();t=u1(t,s),t!==null&&(yR(t,s,r),hp(t,r))}function fxt(t){var s=t.memoizedState,r=0;s!==null&&(r=s.retryLane),jqe(t,r)}function xxt(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(Vr(314))}n!==null&&n.delete(s),jqe(t,r)}var Nqe;Nqe=function(t,s,r){if(t!==null)if(t.memoizedProps!==s.pendingProps||dp.current)ap=!0;else{if(!(t.lanes&r)&&!(s.flags&128))return ap=!1,rxt(t,s,r);ap=!!(t.flags&131072)}else ap=!1,yc&&s.flags&1048576&&M$e(s,joe,s.index);switch(s.lanes=0,s.tag){case 2:var n=s.type;U9(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,up(n)?(o=!0,boe(s)):o=!1,s.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,I2e(s),a.updater=$de,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(U9(t,s),t=s.pendingProps,a=n._init,n=a(n._payload),s.type=n,a=s.tag=yxt(n),t=hg(n,t),a){case 0:s=dve(null,s,n,t,r);break e;case 1:s=lEe(null,s,n,t,r);break e;case 11:s=iEe(null,s,n,t,r);break e;case 14:s=oEe(null,s,n,hg(n.type,t),r);break e}throw Error(Vr(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),lEe(t,s,n,a,r);case 3:e:{if(oqe(s),t===null)throw Error(Vr(387));n=s.pendingProps,o=s.memoizedState,a=o.element,L$e(t,s),Soe(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(Vr(423)),s),s=cEe(t,s,n,r,a);break e}else if(n!==a){a=NT(Error(Vr(424)),s),s=cEe(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),iEe(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,Il(Noe,n._currentValue),n._currentValue=l,o!==null)if(Fg(o.value,l)){if(o.children===a.children&&!dp.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(Vr(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),oEe(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),U9(t,s),s.tag=1,up(n)?(t=!0,boe(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(Vr(156,s.tag))};function kqe(t,s){return QBe(t,s)}function gxt(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 gxt(t,s,r,n)}function Z2e(t){return t=t.prototype,!(!t||!t.isReactComponent)}function yxt(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 G9(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 Vde(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(Vr(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 Vde(t,s,r,n){return t=dx(22,t,n,s),t.elementType=DBe,t.lanes=r,t.stateNode={isHidden:!1},t}function qxe(t,s,r){return t=dx(6,t,null,s),t.lanes=r,t}function Uxe(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 vxt(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=jxe(0),this.expirationTimes=jxe(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=jxe(0),this.identifierPrefix=n,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function Y2e(t,s,r,n,a,o,l,i,d){return t=new vxt(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 _xt(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 ip=TBe.exports;const eje=no(ip);var Aqe,bEe=ip;Aqe=bEe.createRoot,bEe.hydrateRoot;const kxt=1,Sxt=1e6;let Vxe=0;function Cxt(){return Vxe=(Vxe+1)%Number.MAX_SAFE_INTEGER,Vxe.toString()}const Hxe=new Map,wEe=t=>{if(Hxe.has(t))return;const s=setTimeout(()=>{Hxe.delete(t),tL({type:"REMOVE_TOAST",toastId:t})},Sxt);Hxe.set(t,s)},Mxt=(t,s)=>{switch(s.type){case"ADD_TOAST":return{...t,toasts:[s.toast,...t.toasts].slice(0,kxt)};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?wEe(r):t.toasts.forEach(n=>{wEe(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)}}},W9=[];let K9={toasts:[]};function tL(t){K9=Mxt(K9,t),W9.forEach(s=>{s(K9)})}function pn({...t}){const s=Cxt(),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]=S.useState(K9);return S.useEffect(()=>(W9.push(s),()=>{const r=W9.indexOf(s);r>-1&&W9.splice(r,1)}),[t]),{...t,toast:pn,dismiss:r=>tL({type:"DISMISS_TOAST",toastId:r})}}function Sr(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 jEe(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=jEe(a,s);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a{const{children:l,...i}=o,d=S.useMemo(()=>i,Object.values(i));return e.jsx(r.Provider,{value:d,children:l})};n.displayName=t+"Provider";function a(o){const l=S.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=S.createContext(l),d=r.length;r=[...r,l];const u=f=>{var k;const{scope:y,children:_,...b}=f,N=((k=y==null?void 0:y[t])==null?void 0:k[d])||i,w=S.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=S.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=>S.createContext(l));return function(i){const d=(i==null?void 0:i[t])||o;return S.useMemo(()=>({[`__scope${t}`]:{...i,[t]:d}}),[i,d])}};return a.scopeName=t,[n,Axt(a,...s)]}function Axt(...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 S.useMemo(()=>({[`__scope${s.scopeName}`]:l}),[l])}};return r.scopeName=s.scopeName,r}function Hb(t){const s=Ext(t),r=S.forwardRef((n,a)=>{const{children:o,...l}=n,i=S.Children.toArray(o),d=i.find(Pxt);if(d){const u=d.props.children,p=i.map(f=>f===d?S.Children.count(u)>1?S.Children.only(null):S.isValidElement(u)?u.props.children:null:f);return e.jsx(s,{...l,ref:a,children:S.isValidElement(u)?S.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 Ext(t){const s=S.forwardRef((r,n)=>{const{children:a,...o}=r;if(S.isValidElement(a)){const l=Lxt(a),i=Ixt(o,a.props);return a.type!==S.Fragment&&(i.ref=n?m1(n,l):l),S.cloneElement(a,i)}return S.Children.count(a)>1?S.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 Pxt(t){return S.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Eqe}function Ixt(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 Lxt(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:k}=N,C=xt.useRef(null),A=xt.useRef(new Map).current;return e.jsx(a,{scope:w,itemMap:A,collectionRef:C,children:k})};l.displayName=s;const i=t+"CollectionSlot",d=Hb(i),u=xt.forwardRef((N,w)=>{const{scope:k,children:C}=N,A=o(i,k),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:k,children:C,...A}=N,I=xt.useRef(null),L=Ta(w,I),O=o(p,k);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 Dxt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Jr=Dxt.reduce((t,s)=>{const r=Hb(`Primitive.${s}`),n=S.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&&ip.flushSync(()=>t.dispatchEvent(s))}function ed(t){const s=S.useRef(t);return S.useEffect(()=>{s.current=t}),S.useMemo(()=>(...r)=>{var n;return(n=s.current)==null?void 0:n.call(s,...r)},[])}function Rxt(t,s=globalThis==null?void 0:globalThis.document){const r=ed(t);S.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 Oxt="DismissableLayer",jve="dismissableLayer.update",Fxt="dismissableLayer.pointerDownOutside",zxt="dismissableLayer.focusOutside",NEe,Iqe=S.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),dw=S.forwardRef((t,s)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,onDismiss:i,...d}=t,u=S.useContext(Iqe),[p,f]=S.useState(null),y=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,_]=S.useState({}),b=Ta(s,V=>f(V)),N=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),k=N.indexOf(w),C=p?N.indexOf(p):-1,A=u.layersWithOutsidePointerEventsDisabled.size>0,I=C>=k,L=$xt(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=qxt(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 Rxt(V=>{C===u.layers.size-1&&(n==null||n(V),!V.defaultPrevented&&i&&(V.preventDefault(),i()))},y),S.useEffect(()=>{if(p)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(NEe=y.body.style.pointerEvents,y.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),kEe(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(y.body.style.pointerEvents=NEe)}},[p,y,r,u]),S.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),kEe())},[p,u]),S.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:Sr(t.onFocusCapture,O.onFocusCapture),onBlurCapture:Sr(t.onBlurCapture,O.onBlurCapture),onPointerDownCapture:Sr(t.onPointerDownCapture,L.onPointerDownCapture)})});dw.displayName=Oxt;var Bxt="DismissableLayerBranch",Lqe=S.forwardRef((t,s)=>{const r=S.useContext(Iqe),n=S.useRef(null),a=Ta(s,n);return S.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=Bxt;function $xt(t,s=globalThis==null?void 0:globalThis.document){const r=ed(t),n=S.useRef(!1),a=S.useRef(()=>{});return S.useEffect(()=>{const o=i=>{if(i.target&&!n.current){let d=function(){Dqe(Fxt,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 qxt(t,s=globalThis==null?void 0:globalThis.document){const r=ed(t),n=S.useRef(!1);return S.useEffect(()=>{const a=o=>{o.target&&!n.current&&Dqe(zxt,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 kEe(){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 Uxt=dw,Vxt=Lqe,ad=globalThis!=null&&globalThis.document?S.useLayoutEffect:()=>{},Hxt="Portal",IA=S.forwardRef((t,s)=>{var i;const{container:r,...n}=t,[a,o]=S.useState(!1);ad(()=>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=Hxt;function Gxt(t,s){return S.useReducer((r,n)=>s[r][n]??r,t)}var jd=t=>{const{present:s,children:r}=t,n=Wxt(s),a=typeof r=="function"?r({present:n.isPresent}):S.Children.only(r),o=Ta(n.ref,Kxt(a));return typeof r=="function"||n.isPresent?S.cloneElement(a,{ref:o}):null};jd.displayName="Presence";function Wxt(t){const[s,r]=S.useState(),n=S.useRef(null),a=S.useRef(t),o=S.useRef("none"),l=t?"mounted":"unmounted",[i,d]=Gxt(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return S.useEffect(()=>{const u=mz(n.current);o.current=i==="mounted"?u:"none"},[i]),ad(()=>{const u=n.current,p=a.current;if(p!==t){const y=o.current,_=mz(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]),ad(()=>{if(s){let u;const p=s.ownerDocument.defaultView??window,f=_=>{const N=mz(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=mz(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:S.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function mz(t){return(t==null?void 0:t.animationName)||"none"}function Kxt(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 Zxt=c2e[" useInsertionEffect ".trim().toString()]||ad;function Uu({prop:t,defaultProp:s,onChange:r=()=>{},caller:n}){const[a,o,l]=Yxt({defaultProp:s,onChange:r}),i=t!==void 0,d=i?t:a;{const p=S.useRef(t!==void 0);S.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=S.useCallback(p=>{var f;if(i){const y=Xxt(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 Yxt({defaultProp:t,onChange:s}){const[r,n]=S.useState(t),a=S.useRef(r),o=S.useRef(s);return Zxt(()=>{o.current=s},[s]),S.useEffect(()=>{var l;a.current!==r&&((l=o.current)==null||l.call(o,r),a.current=r)},[r,a]),[r,n,o]}function Xxt(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"}),Qxt="VisuallyHidden",Zde=S.forwardRef((t,s)=>e.jsx(Jr.span,{...t,ref:s,style:{...Rqe,...t.style}}));Zde.displayName=Qxt;var Jxt=Zde,rje="ToastProvider",[nje,egt,tgt]=wR("Toast"),[Oqe,LTs]=qc("Toast",[tgt]),[sgt,Yde]=Oqe(rje),Fqe=t=>{const{__scopeToast:s,label:r="Notification",duration:n=5e3,swipeDirection:a="right",swipeThreshold:o=50,children:l}=t,[i,d]=S.useState(null),[u,p]=S.useState(0),f=S.useRef(!1),y=S.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(sgt,{scope:s,label:r,duration:n,swipeDirection:a,swipeThreshold:o,toastCount:u,viewport:i,onViewportChange:d,onToastAdd:S.useCallback(()=>p(_=>_+1),[]),onToastRemove:S.useCallback(()=>p(_=>_-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:y,children:l})})};Fqe.displayName=rje;var zqe="ToastViewport",rgt=["F8"],Nve="toast.viewportPause",kve="toast.viewportResume",Bqe=S.forwardRef((t,s)=>{const{__scopeToast:r,hotkey:n=rgt,label:a="Notifications ({hotkey})",...o}=t,l=Yde(zqe,r),i=egt(r),d=S.useRef(null),u=S.useRef(null),p=S.useRef(null),f=S.useRef(null),y=Ta(s,f,l.onViewportChange),_=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),b=l.toastCount>0;S.useEffect(()=>{const w=k=>{var A;n.length!==0&&n.every(I=>k[I]||k.code===I)&&((A=f.current)==null||A.focus())};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[n]),S.useEffect(()=>{const w=d.current,k=f.current;if(b&&w&&k){const C=()=>{if(!l.isClosePausedRef.current){const O=new CustomEvent(Nve);k.dispatchEvent(O),l.isClosePausedRef.current=!0}},A=()=>{if(l.isClosePausedRef.current){const O=new CustomEvent(kve);k.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=S.useCallback(({tabbingDirection:w})=>{const C=i().map(A=>{const I=A.ref.current,L=[I,...xgt(I)];return w==="forwards"?L:L.reverse()});return(w==="forwards"?C.reverse():C).flat()},[i]);return S.useEffect(()=>{const w=f.current;if(w){const k=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);Gxe(Y.slice(J+1))?C.preventDefault():B?(O=u.current)==null||O.focus():(V=p.current)==null||V.focus()}};return w.addEventListener("keydown",k),()=>w.removeEventListener("keydown",k)}},[i,N]),e.jsxs(Vxt,{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"});Gxe(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"});Gxe(w)}})]})});Bqe.displayName=zqe;var $qe="ToastFocusProxy",Sve=S.forwardRef((t,s)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...a}=t,o=Yde($qe,r);return e.jsx(Zde,{"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",ngt="toast.swipeStart",agt="toast.swipeMove",igt="toast.swipeCancel",ogt="toast.swipeEnd",qqe=S.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(dgt,{open:i,...l,ref:s,onClose:()=>d(!1),onPause:ed(t.onPause),onResume:ed(t.onResume),onSwipeStart:Sr(t.onSwipeStart,u=>{u.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Sr(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:Sr(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:Sr(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[lgt,cgt]=Oqe(jR,{onClose(){}}),dgt=S.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=Yde(jR,r),[w,k]=S.useState(null),C=Ta(s,X=>k(X)),A=S.useRef(null),I=S.useRef(null),L=a||N.duration,O=S.useRef(0),V=S.useRef(L),q=S.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=S.useCallback(X=>{!X||X===1/0||(window.clearTimeout(q.current),O.current=new Date().getTime(),q.current=window.setTimeout(te,X))},[te]);S.useEffect(()=>{const X=N.viewport;if(X){const ce=()=>{Y(V.current),u==null||u()},ae=()=>{const ie=new Date().getTime()-O.current;V.current=V.current-ie,window.clearTimeout(q.current),d==null||d()};return X.addEventListener(Nve,ae),X.addEventListener(kve,ce),()=>{X.removeEventListener(Nve,ae),X.removeEventListener(kve,ce)}}},[N.viewport,L,d,u,Y]),S.useEffect(()=>{o&&!N.isClosePausedRef.current&&Y(L)},[o,L,N.isClosePausedRef,Y]),S.useEffect(()=>(B(),()=>U()),[B,U]);const J=S.useMemo(()=>w?Zqe(w):null,[w]);return N.viewport?e.jsxs(e.Fragment,{children:[J&&e.jsx(ugt,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:J}),e.jsx(lgt,{scope:r,onClose:te,children:ip.createPortal(e.jsx(nje.ItemSlot,{scope:r,children:e.jsx(Uxt,{asChild:!0,onEscapeKeyDown:Sr(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:Sr(t.onKeyDown,X=>{X.key==="Escape"&&(i==null||i(X.nativeEvent),X.nativeEvent.defaultPrevented||(N.isFocusedToastEscapeKeyDownRef.current=!0,te()))}),onPointerDown:Sr(t.onPointerDown,X=>{X.button===0&&(A.current={x:X.clientX,y:X.clientY})}),onPointerMove:Sr(t.onPointerMove,X=>{if(!A.current)return;const ce=X.clientX-A.current.x,ae=X.clientY-A.current.y,ie=!!I.current,oe=["left","right"].includes(N.swipeDirection),me=["left","up"].includes(N.swipeDirection)?Math.min:Math.max,ye=oe?me(0,ce):0,he=oe?0:me(0,ae),ge=X.pointerType==="touch"?10:2,Ne={x:ye,y:he},Ue={originalEvent:X,delta:Ne};ie?(I.current=Ne,pz(agt,f,Ue,{discrete:!1})):SEe(Ne,N.swipeDirection,ge)?(I.current=Ne,pz(ngt,p,Ue,{discrete:!1}),X.target.setPointerCapture(X.pointerId)):(Math.abs(ce)>ge||Math.abs(ae)>ge)&&(A.current=null)}),onPointerUp:Sr(t.onPointerUp,X=>{const ce=I.current,ae=X.target;if(ae.hasPointerCapture(X.pointerId)&&ae.releasePointerCapture(X.pointerId),I.current=null,A.current=null,ce){const ie=X.currentTarget,oe={originalEvent:X,delta:ce};SEe(ce,N.swipeDirection,N.swipeThreshold)?pz(ogt,_,oe,{discrete:!0}):pz(igt,y,oe,{discrete:!0}),ie.addEventListener("click",me=>me.preventDefault(),{once:!0})}})})})}),N.viewport)})]}):null}),ugt=t=>{const{__scopeToast:s,children:r,...n}=t,a=Yde(jR,s),[o,l]=S.useState(!1),[i,d]=S.useState(!1);return pgt(()=>l(!0)),S.useEffect(()=>{const u=window.setTimeout(()=>d(!0),1e3);return()=>window.clearTimeout(u)},[]),i?null:e.jsx(IA,{asChild:!0,children:e.jsx(Zde,{...n,children:o&&e.jsxs(e.Fragment,{children:[a.label," ",r]})})})},hgt="ToastTitle",Uqe=S.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(Jr.div,{...n,ref:s})});Uqe.displayName=hgt;var mgt="ToastDescription",Vqe=S.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(Jr.div,{...n,ref:s})});Vqe.displayName=mgt;var Hqe="ToastAction",Gqe=S.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=S.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t,a=cgt(Wqe,r);return e.jsx(Kqe,{asChild:!0,children:e.jsx(Jr.button,{type:"button",...n,ref:s,onClick:Sr(t.onClick,a.onClose)})})});aje.displayName=Wqe;var Kqe=S.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),fgt(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 pz(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 SEe=(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 pgt(t=()=>{}){const s=ed(t);ad(()=>{let r=0,n=0;return r=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(s)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(n)}},[s])}function fgt(t){return t.nodeType===t.ELEMENT_NODE}function xgt(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 Gxe(t){const s=document.activeElement;return t.some(r=>r===s?!0:(r.focus(),document.activeElement!==s))}var ggt=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,MEe=bi,bC=(t,s)=>r=>{var n;if((s==null?void 0:s.variants)==null)return MEe(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=CEe(p)||CEe(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 MEe(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 ygt=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 vgt={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=S.forwardRef(({color:t="currentColor",size:s=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:a="",children:o,iconNode:l,...i},d)=>S.createElement("svg",{ref:d,...vgt,width:s,height:s,stroke:t,strokeWidth:n?Number(r)*24/Number(s):r,className:rUe("lucide",a),...i},[...l.map(([u,p])=>S.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=S.forwardRef(({className:n,...a},o)=>S.createElement(nUe,{ref:o,iconNode:s,className:rUe(`lucide-${ygt(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 Z9=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 Y9=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 X9=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 Q9=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 J9=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 eB=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 tB=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 sB=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 rB=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 nB=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 aB=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 iB=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 oB=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 lB=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 cB=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 dB=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 uB=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 hB=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 mB=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 pB=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 fB=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 xB=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 gB=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 yB=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 vB=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 _B=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 bB=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 wB=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 jB=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 NB=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 kB=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 SB=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 CB=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 MB=Z("Ambulance",[["path",{d:"M10 10H6",key:"1bsnug"}],["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.28a1 1 0 0 0-.684-.948l-1.923-.641a1 1 0 0 1-.578-.502l-1.539-3.076A1 1 0 0 0 16.382 8H14",key:"lrkjwd"}],["path",{d:"M8 8v4",key:"1fwk8c"}],["path",{d:"M9 18h6",key:"x1upvd"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TB=Z("Ampersand",[["path",{d:"M17.5 12c0 4.4-3.6 8-8 8A4.5 4.5 0 0 1 5 15.5c0-6 8-4 8-8.5a3 3 0 1 0-6 0c0 3 2.5 8.5 12 13",key:"1o9ehi"}],["path",{d:"M16 12h3",key:"4uvgyw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AB=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 EB=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 PB=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 IB=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 LB=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 DB=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 RB=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 OB=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 FB=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 zB=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 BB=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 $B=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 qB=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 UB=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 VB=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 HB=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 GB=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 WB=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 KB=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 ZB=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 YB=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 XB=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 QB=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 JB=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 e$=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 t$=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 s$=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 r$=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 n$=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 a$=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 i$=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 o$=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 l$=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 Ga=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 c$=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 d$=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 u$=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 h$=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 m$=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 p$=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 f$=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 x$=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 g$=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 y$=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 v$=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 _$=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 b$=Z("AudioWaveform",[["path",{d:"M2 13a2 2 0 0 0 2-2V7a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0V4a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0v-4a2 2 0 0 1 2-2",key:"57tc96"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rc=Z("Award",[["path",{d:"m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526",key:"1yiouv"}],["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const w$=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 j$=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 N$=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 k$=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 S$=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 C$=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 M$=Z("BadgeEuro",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M7 12h5",key:"gblrwe"}],["path",{d:"M15 9.4a4 4 0 1 0 0 5.2",key:"1makmb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const T$=Z("BadgeHelp",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["line",{x1:"12",x2:"12.01",y1:"17",y2:"17",key:"io3f8k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const A$=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 E$=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 P$=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 I$=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 L$=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 D$=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 R$=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 O$=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 F$=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 z$=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 B$=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 $$=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 q$=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 U$=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 V$=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 H$=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 G$=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 W$=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 K$=Z("BatteryFull",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}],["line",{x1:"6",x2:"6",y1:"11",y2:"13",key:"1wd6dw"}],["line",{x1:"10",x2:"10",y1:"11",y2:"13",key:"haxvl5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"13",key:"c6fn6x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z$=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 Y$=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 X$=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 Q$=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 J$=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 eq=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 tq=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 sq=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 rq=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 nq=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 aq=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 iq=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 oq=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 lq=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 cq=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 dq=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 uq=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 hq=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 mq=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 pq=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 fq=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 xq=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 gq=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 yq=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 vq=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 _q=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 bq=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 wq=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 jq=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 Nq=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 kq=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 Sq=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 Cq=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 Mq=Z("Bomb",[["circle",{cx:"11",cy:"13",r:"9",key:"hd149"}],["path",{d:"M14.35 4.65 16.3 2.7a2.41 2.41 0 0 1 3.4 0l1.6 1.6a2.4 2.4 0 0 1 0 3.4l-1.95 1.95",key:"jp4j1b"}],["path",{d:"m22 2-1.5 1.5",key:"ay92ug"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tq=Z("Bone",[["path",{d:"M17 10c.7-.7 1.69 0 2.5 0a2.5 2.5 0 1 0 0-5 .5.5 0 0 1-.5-.5 2.5 2.5 0 1 0-5 0c0 .81.7 1.8 0 2.5l-7 7c-.7.7-1.69 0-2.5 0a2.5 2.5 0 0 0 0 5c.28 0 .5.22.5.5a2.5 2.5 0 1 0 5 0c0-.81-.7-1.8 0-2.5Z",key:"w610uw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aq=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 Eq=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 Pq=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 Iq=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 Lq=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 Dq=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 Rq=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 Oq=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 Fq=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 zq=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 Bq=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 $q=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 qq=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 Uq=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 Vq=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 Hq=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 Gq=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 Wq=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 Kq=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 Zq=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 Yq=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 Xq=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 Qq=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 Jq=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 eU=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 tU=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 sU=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 rU=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 nU=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 aU=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 iU=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 oU=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 lU=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 cU=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 dU=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 uU=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 hU=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 mU=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 pU=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 fU=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 xU=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 gU=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 yU=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 vU=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 _U=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 bU=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 wU=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 jU=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 NU=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 kU=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 SU=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 CU=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 yd=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 MU=Z("CalendarFold",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 17V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h11Z",key:"kg77oy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M15 22v-4a2 2 0 0 1 2-2h4",key:"1gnbqr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TU=Z("CalendarHeart",[["path",{d:"M3 10h18V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7",key:"136lmk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21.29 14.7a2.43 2.43 0 0 0-2.65-.52c-.3.12-.57.3-.8.53l-.34.34-.35-.34a2.43 2.43 0 0 0-2.65-.53c-.3.12-.56.3-.79.53-.95.94-1 2.53.2 3.74L17.5 22l3.6-3.55c1.2-1.21 1.14-2.8.19-3.74Z",key:"1t7hil"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AU=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 EU=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 PU=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 IU=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 LU=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 DU=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 RU=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 OU=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 ln=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 FU=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 zU=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 BU=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 $U=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 qU=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 UU=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 VU=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 HU=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 GU=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 WU=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 KU=Z("Carrot",[["path",{d:"M2.27 21.7s9.87-3.5 12.73-6.36a4.5 4.5 0 0 0-6.36-6.37C5.77 11.84 2.27 21.7 2.27 21.7zM8.64 14l-2.05-2.04M15.34 15l-2.46-2.46",key:"rfqxbe"}],["path",{d:"M22 9s-1.33-2-3.5-2C16.86 7 15 9 15 9s1.33 2 3.5 2S22 9 22 9z",key:"6b25w4"}],["path",{d:"M15 2s-2 1.33-2 3.5S15 9 15 9s2-1.84 2-3.5C17 3.33 15 2 15 2z",key:"fn65lo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZU=Z("CaseLower",[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YU=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 XU=Z("CaseUpper",[["path",{d:"m3 15 4-8 4 8",key:"1vwr6u"}],["path",{d:"M4 13h6",key:"1r9ots"}],["path",{d:"M15 11h4.5a2 2 0 0 1 0 4H15V7h4a2 2 0 0 1 0 4",key:"1sqfas"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QU=Z("CassetteTape",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["circle",{cx:"8",cy:"10",r:"2",key:"1xl4ub"}],["path",{d:"M8 12h8",key:"1wcyev"}],["circle",{cx:"16",cy:"10",r:"2",key:"r14t7q"}],["path",{d:"m6 20 .7-2.9A1.4 1.4 0 0 1 8.1 16h7.8a1.4 1.4 0 0 1 1.4 1l.7 3",key:"l01ucn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JU=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 eV=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 tV=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 sV=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 rV=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 nV=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 aV=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 iV=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 oV=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 lV=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 cV=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 dV=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 uV=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 hV=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 mV=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 pV=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 Fi=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 fV=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 xV=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 gV=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 yV=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 vV=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 _V=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 bV=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 wV=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 jV=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 NV=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 kV=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 SV=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 CV=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 MV=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 ti=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 Hn=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 TV=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 AV=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 EV=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 PV=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 IV=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 LV=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 DV=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 RV=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 OV=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 sp=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 FV=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 Ql=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 zV=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 BV=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 $V=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 qV=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 UV=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 VV=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 HV=Z("ClipboardPlus",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M9 14h6",key:"159ibu"}],["path",{d:"M12 17v-6",key:"1y8rbf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GV=Z("ClipboardType",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M9 12v-1h6v1",key:"iehl6m"}],["path",{d:"M11 17h2",key:"12w5me"}],["path",{d:"M12 11v6",key:"1bwqyc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WV=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 KV=Z("Clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZV=Z("Clock1",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 14.5 8",key:"12zbmj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YV=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 XV=Z("Clock11",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 9.5 8",key:"l5bg6f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QV=Z("Clock12",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12",key:"1fub01"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JV=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 eH=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 tH=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 sH=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 rH=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 nH=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 aH=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 iH=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 oH=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 lH=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 cH=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 on=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 dH=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 uH=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 hH=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 mH=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 pH=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 fH=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 xH=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 gH=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 yH=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 vH=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 _H=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 bH=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 wH=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 jH=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 NH=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 kH=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 SH=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 CH=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 MH=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 TH=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 AH=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 EH=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 PH=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 IH=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 LH=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 DH=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 RH=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 OH=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 FH=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 zH=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 BH=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 $H=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 qH=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 UH=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 VH=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 HH=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 GH=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 Wa=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 WH=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 KH=Z("Copyright",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M14.83 14.83a4 4 0 1 1 0-5.66",key:"1i56pz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZH=Z("CornerDownLeft",[["polyline",{points:"9 10 4 15 9 20",key:"r3jprv"}],["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YH=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 XH=Z("CornerLeftDown",[["polyline",{points:"14 15 9 20 4 15",key:"nkc4i"}],["path",{d:"M20 4h-7a4 4 0 0 0-4 4v12",key:"nbpdq2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QH=Z("CornerLeftUp",[["polyline",{points:"14 9 9 4 4 9",key:"m9oyvo"}],["path",{d:"M20 20h-7a4 4 0 0 1-4-4V4",key:"1blwi3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JH=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 eG=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 tG=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 sG=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 rG=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 nG=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 aG=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 iG=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 oG=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 lG=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 cG=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 dG=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 uG=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 hG=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 mG=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 pG=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 fG=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 xG=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 gG=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 yG=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 vG=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 _G=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 bG=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 wG=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 jG=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 NG=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 kG=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 SG=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 CG=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 MG=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 TG=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 AG=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 EG=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 PG=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 IG=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 LG=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 DG=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 RG=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 OG=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 FG=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 zG=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 BG=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 $G=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 qG=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 UG=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 VG=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 HG=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 GG=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 WG=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 KG=Z("Drumstick",[["path",{d:"M15.4 15.63a7.875 6 135 1 1 6.23-6.23 4.5 3.43 135 0 0-6.23 6.23",key:"1dtqwm"}],["path",{d:"m8.29 12.71-2.6 2.6a2.5 2.5 0 1 0-1.65 4.65A2.5 2.5 0 1 0 8.7 18.3l2.59-2.59",key:"1oq1fw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZG=Z("Dumbbell",[["path",{d:"M14.4 14.4 9.6 9.6",key:"ic80wn"}],["path",{d:"M18.657 21.485a2 2 0 1 1-2.829-2.828l-1.767 1.768a2 2 0 1 1-2.829-2.829l6.364-6.364a2 2 0 1 1 2.829 2.829l-1.768 1.767a2 2 0 1 1 2.828 2.829z",key:"nnl7wr"}],["path",{d:"m21.5 21.5-1.4-1.4",key:"1f1ice"}],["path",{d:"M3.9 3.9 2.5 2.5",key:"1evmna"}],["path",{d:"M6.404 12.768a2 2 0 1 1-2.829-2.829l1.768-1.767a2 2 0 1 1-2.828-2.829l2.828-2.828a2 2 0 1 1 2.829 2.828l1.767-1.768a2 2 0 1 1 2.829 2.829z",key:"yhosts"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YG=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 XG=Z("Ear",[["path",{d:"M6 8.5a6.5 6.5 0 1 1 13 0c0 6-6 6-6 10a3.5 3.5 0 1 1-7 0",key:"1dfaln"}],["path",{d:"M15 8.5a2.5 2.5 0 0 0-5 0v1a2 2 0 1 1 0 4",key:"1qnva7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QG=Z("EarthLock",[["path",{d:"M7 3.34V5a3 3 0 0 0 3 3",key:"w732o8"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2 2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"f02343"}],["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M12 2a10 10 0 1 0 9.54 13",key:"zjsr6q"}],["path",{d:"M20 6V4a2 2 0 1 0-4 0v2",key:"1of5e8"}],["rect",{width:"8",height:"5",x:"14",y:"6",rx:"1",key:"1fmf51"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const 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 JG=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 eW=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 tW=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 sW=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 rW=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 nW=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 aW=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 iW=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 oW=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 lW=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 Zr=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 cW=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 mp=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 Cn=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 dW=Z("Factory",[["path",{d:"M2 20a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8l-7 5V8l-7 5V4a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"159hny"}],["path",{d:"M17 18h1",key:"uldtlt"}],["path",{d:"M12 18h1",key:"s9uhes"}],["path",{d:"M7 18h1",key:"1neino"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uW=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 hW=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 mW=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 pW=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 fW=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 xW=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 gW=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 yW=Z("FileAudio2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2",key:"17k7jt"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"3",cy:"17",r:"1",key:"vo6nti"}],["path",{d:"M2 17v-3a4 4 0 0 1 8 0v3",key:"1ggdre"}],["circle",{cx:"9",cy:"17",r:"1",key:"bc1fq4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vW=Z("FileAudio",[["path",{d:"M17.5 22h.5a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"rslqgf"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 19a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 1 1-4 0v-1a2 2 0 1 1 4 0",key:"9f7x3i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const 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 _W=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 bW=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 wW=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 jW=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 NW=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 kW=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 SW=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 CW=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 MW=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 TW=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 AW=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 EW=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 PW=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 IW=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 LW=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 DW=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 RW=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 OW=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 FW=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 zW=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 BW=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 $W=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 qW=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 UW=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 VW=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 HW=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 GW=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 WW=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 KW=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 ZW=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 YW=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 yn=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 XW=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 QW=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 JW=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 eK=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 tK=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 sK=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 rK=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 nK=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 aK=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 iK=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 oK=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 lK=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 cK=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 dK=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 uK=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 hK=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 mK=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 pK=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 fK=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 xK=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 gK=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 yK=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 vK=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 _K=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 bK=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 wK=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 jK=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 NK=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 kK=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 SK=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 CK=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 MK=Z("FoldHorizontal",[["path",{d:"M2 12h6",key:"1wqiqv"}],["path",{d:"M22 12h-6",key:"1eg9hc"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m19 9-3 3 3 3",key:"12ol22"}],["path",{d:"m5 15 3-3-3-3",key:"1kdhjc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TK=Z("FoldVertical",[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3-3-3 3",key:"e37ymu"}],["path",{d:"m15 5-3 3-3-3",key:"19d6lf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AK=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 EK=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 PK=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 IK=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 LK=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 DK=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 RK=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 OK=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 FK=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 zK=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 BK=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 $K=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 qK=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 UK=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 VK=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 HK=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 GK=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 WK=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 KK=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 ZK=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 YK=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 XK=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 QK=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 JK=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 eZ=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 tZ=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 sZ=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 rZ=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 nZ=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 aZ=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 iZ=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 oZ=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 lZ=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 cZ=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 dZ=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 uZ=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 hZ=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 mZ=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 pZ=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 fZ=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 xZ=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 gZ=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 yZ=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 vZ=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 _Z=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 bZ=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 yi=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 wZ=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 jZ=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 NZ=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 kZ=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 SZ=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 CZ=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 MZ=Z("GitGraph",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TZ=Z("GitMerge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AZ=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 EZ=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 PZ=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 IZ=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 LZ=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 DZ=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 RZ=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 OZ=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 FZ=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 zZ=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 BZ=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 $Z=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 qZ=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 UZ=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 VZ=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 HZ=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 GZ=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 WZ=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 KZ=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 ZZ=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 YZ=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 XZ=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 QZ=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 JZ=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 eY=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 tY=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 sY=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 rY=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 nY=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 aY=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 iY=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 oY=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 lY=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 cY=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 dY=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 uY=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 hY=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 mY=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 pY=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 fY=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 xY=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 gY=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 yY=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 vY=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 _Y=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 bY=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 wY=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 jY=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 NY=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 kY=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 SY=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 CY=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 Sn=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 MY=Z("IdCard",[["path",{d:"M16 10h2",key:"8sgtl7"}],["path",{d:"M16 14h2",key:"epxaof"}],["path",{d:"M6.17 15a3 3 0 0 1 5.66 0",key:"n6f512"}],["circle",{cx:"9",cy:"11",r:"2",key:"yxgjnd"}],["rect",{x:"2",y:"5",width:"20",height:"14",rx:"2",key:"qneu4z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TY=Z("ImageDown",[["path",{d:"M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21",key:"9csbqa"}],["path",{d:"m14 19 3 3v-5.5",key:"9ldu5r"}],["path",{d:"m17 22 3-3",key:"1nkfve"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AY=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 EY=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 PY=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 IY=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 LY=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 DY=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 RY=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 OY=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 FY=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 zY=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 BY=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 $Y=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 qY=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 UY=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 VY=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 HY=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 pp=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 GY=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 WY=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 KY=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 ZY=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 YY=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 XY=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 QY=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 JY=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 eX=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 tX=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 sX=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 rX=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 nX=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 aX=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 iX=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 oX=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 lX=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 cX=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 dX=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 fp=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 uX=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 hX=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 mX=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 pX=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 fX=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 xX=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 gX=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 yX=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 vX=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 _X=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 bX=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 go=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 xp=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 wX=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 jX=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 NX=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 kX=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 SX=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 CX=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 MX=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 TX=Z("ListPlus",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M18 9v6",key:"1twb98"}],["path",{d:"M21 12h-6",key:"bt1uis"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AX=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 EX=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 PX=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 IX=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 LX=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 DX=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 RX=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 OX=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 FX=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 zX=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 BX=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 vd=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 $X=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 qX=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 UX=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 VX=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 HX=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 GX=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 WX=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 KX=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 ZX=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 YX=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 XX=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 QX=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 JX=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 eQ=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 tQ=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 sQ=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 rQ=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 nQ=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 aQ=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 iQ=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 oQ=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 lQ=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 cQ=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 dQ=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 uQ=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 hQ=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 mQ=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 pQ=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 fQ=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 xQ=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 gQ=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 yQ=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 vQ=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 _Q=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 bQ=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 wQ=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 jQ=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 Ol=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 NQ=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 kQ=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 SQ=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 CQ=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 MQ=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 TQ=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 AQ=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 EQ=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 PQ=Z("MessageSquareShare",[["path",{d:"M21 12v3a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h7",key:"tqtdkg"}],["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"m16 8 5-5",key:"15mbrl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IQ=Z("MessageSquareText",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M13 8H7",key:"14i4kc"}],["path",{d:"M17 12H7",key:"16if0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LQ=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 DQ=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 Si=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 RQ=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 OQ=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 FQ=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 zQ=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 BQ=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 $Q=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 qQ=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 UQ=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 VQ=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 HQ=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 GQ=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 WQ=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 KQ=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 ZQ=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 YQ=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 XQ=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 QQ=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 JQ=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 eJ=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 tJ=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 sJ=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 rJ=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 nJ=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 aJ=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 iJ=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 oJ=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 lJ=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 cJ=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 dJ=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 uJ=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 hJ=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 mJ=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 pJ=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 fJ=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 xJ=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 gJ=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 yJ=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 vJ=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 _J=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 bJ=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 wJ=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 jJ=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 NJ=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 kJ=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 SJ=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 CJ=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 MJ=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 TJ=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 AJ=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 EJ=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 PJ=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 IJ=Z("NotebookPen",[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LJ=Z("NotebookTabs",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M15 2v20",key:"dcj49h"}],["path",{d:"M15 7h5",key:"1xj5lc"}],["path",{d:"M15 12h5",key:"w5shd9"}],["path",{d:"M15 17h5",key:"1qaofu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DJ=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 RJ=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 OJ=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 FJ=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 zJ=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 BJ=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 $J=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 qJ=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 UJ=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 VJ=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 HJ=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 GJ=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 WJ=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 KJ=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 ZJ=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 YJ=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 XJ=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 QJ=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 JJ=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 eee=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 tee=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 see=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 Fl=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 ree=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 nee=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 aee=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 iee=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 oee=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 lee=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 cee=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 dee=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 uee=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 hee=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 mee=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 pee=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 fee=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 xee=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 gee=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 yee=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 vee=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 _ee=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 bee=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 wee=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 jee=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 Nee=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 kee=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 See=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 Cee=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 Mee=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 Tee=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 Aee=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 Eee=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 Pee=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 Iee=Z("Pickaxe",[["path",{d:"M14.531 12.469 6.619 20.38a1 1 0 1 1-3-3l7.912-7.912",key:"we99rg"}],["path",{d:"M15.686 4.314A12.5 12.5 0 0 0 5.461 2.958 1 1 0 0 0 5.58 4.71a22 22 0 0 1 6.318 3.393",key:"1w6hck"}],["path",{d:"M17.7 3.7a1 1 0 0 0-1.4 0l-4.6 4.6a1 1 0 0 0 0 1.4l2.6 2.6a1 1 0 0 0 1.4 0l4.6-4.6a1 1 0 0 0 0-1.4z",key:"15hgfx"}],["path",{d:"M19.686 8.314a12.501 12.501 0 0 1 1.356 10.225 1 1 0 0 1-1.751-.119 22 22 0 0 0-3.393-6.319",key:"452b4h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lee=Z("PictureInPicture2",[["path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4",key:"daa4of"}],["rect",{width:"10",height:"7",x:"12",y:"13",rx:"2",key:"1nb8gs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dee=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 Ree=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 Oee=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 Fee=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 zee=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 Bee=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 $ee=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 qee=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 Uee=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 Vee=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 Hee=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 Gee=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 Wee=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 Bs=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 Kee=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 Zee=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 Yee=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 Xee=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 Qee=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 Jee=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 ete=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 tte=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 ste=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 rte=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 nte=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 ate=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 ite=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 ote=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 lte=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 cte=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 dte=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 ute=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 hte=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 mte=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 pte=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 fte=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 xte=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 gte=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 yte=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 vte=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 _te=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 bte=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 wte=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 jte=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 Nte=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 kte=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 Ste=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 Cte=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 Mte=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 Tte=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 Ate=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 Ete=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 Pte=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 Ite=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 Lte=Z("RefreshCwOff",[["path",{d:"M21 8L18.74 5.74A9.75 9.75 0 0 0 12 3C11 3 10.03 3.16 9.13 3.47",key:"1krf6h"}],["path",{d:"M8 16H3v5",key:"1cv678"}],["path",{d:"M3 12C3 9.51 4 7.26 5.64 5.64",key:"ruvoct"}],["path",{d:"m3 16 2.26 2.26A9.75 9.75 0 0 0 12 21c2.49 0 4.74-1 6.36-2.64",key:"19q130"}],["path",{d:"M21 12c0 1-.16 1.97-.47 2.87",key:"4w8emr"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M22 22 2 2",key:"1r8tn9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const 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 Dte=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 Rte=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 Ote=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 Fte=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 zte=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 Bte=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 $te=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 qte=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 Ute=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 Vte=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 Hte=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 Gte=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 Wte=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 Kte=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 Zte=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 Yte=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 Xte=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 Qte=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 Jte=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 ese=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 tse=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 sse=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 rse=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 nse=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 ase=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 ise=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 ose=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 lse=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 cse=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 dse=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 use=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 hse=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 mse=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 pse=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 fse=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 xse=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 gse=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 yse=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 vse=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 _se=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 bse=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 wse=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 jse=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 Nse=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 kse=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 Sse=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 an=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 Cse=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 Mse=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 Mn=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 Tse=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 Ase=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 Ese=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 Pse=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 Ise=Z("ServerOff",[["path",{d:"M7 2h13a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-5",key:"bt2siv"}],["path",{d:"M10 10 2.5 2.5C2 2 2 2.5 2 5v3a2 2 0 0 0 2 2h6z",key:"1hjrv1"}],["path",{d:"M22 17v-1a2 2 0 0 0-2-2h-1",key:"1iynyr"}],["path",{d:"M4 14a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16.5l1-.5.5.5-8-8H4z",key:"161ggg"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lse=Z("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const 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 Dse=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 _d=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 Rse=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 Ose=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 Fse=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 zse=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 Bse=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 $se=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 qse=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 Use=Z("ShieldPlus",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9 12h6",key:"1c52cq"}],["path",{d:"M12 9v6",key:"199k2o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vse=Z("ShieldQuestion",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $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 Hse=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 Gse=Z("Ship",[["path",{d:"M12 10.189V14",key:"1p8cqu"}],["path",{d:"M12 2v3",key:"qbqxhf"}],["path",{d:"M19 13V7a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2v6",key:"qpkstq"}],["path",{d:"M19.38 20A11.6 11.6 0 0 0 21 14l-8.188-3.639a2 2 0 0 0-1.624 0L3 14a11.6 11.6 0 0 0 2.81 7.76",key:"7tigtc"}],["path",{d:"M2 21c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1s1.2 1 2.5 1c2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"1924j5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wse=Z("Shirt",[["path",{d:"M20.38 3.46 16 2a4 4 0 0 1-8 0L3.62 3.46a2 2 0 0 0-1.34 2.23l.58 3.47a1 1 0 0 0 .99.84H6v10c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2V10h2.15a1 1 0 0 0 .99-.84l.58-3.47a2 2 0 0 0-1.34-2.23z",key:"1wgbhj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const 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 Kse=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 op=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 Zse=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 Yse=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 Xse=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 Qse=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 Jse=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 ere=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 tre=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 sre=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 rre=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 nre=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 are=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 ire=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 ore=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 lre=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 cre=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 dre=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 ure=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 hre=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 mre=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 pre=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 fre=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 xre=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 gre=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 yre=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 vre=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 _re=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 bre=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 wre=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 jre=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 Nre=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 kre=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 Sre=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 Cre=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 Mre=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 Tre=Z("Spline",[["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M5 17A12 12 0 0 1 17 5",key:"1okkup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Are=Z("Split",[["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M8 3H3v5",key:"15dfkv"}],["path",{d:"M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3",key:"1qrqzj"}],["path",{d:"m15 9 6-6",key:"ko1vev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ere=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 Pre=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 Ire=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 Lre=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 Dre=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 Rre=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 Ore=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 Fre=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 zre=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 Bre=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 $re=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 qre=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 Ure=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 Vre=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 Hre=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 Gre=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 Wre=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 Kre=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 Zre=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 Yre=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 Xre=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 Qre=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 Jre=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 ene=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 tne=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 sne=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 rne=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 nne=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 ane=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 ine=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 one=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 lne=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 cne=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 dne=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 une=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 hne=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 mne=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 pne=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 fne=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 xne=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 gne=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 yne=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 vne=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 _ne=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 bne=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 wne=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 jne=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 Nne=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 kne=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 Sne=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 Cne=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 Mne=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 Tne=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 Ane=Z("TestTube",[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ene=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 Pne=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 Ine=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 Lne=Z("TextQuote",[["path",{d:"M17 6H3",key:"16j9eg"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 18H8",key:"1wfozv"}],["path",{d:"M3 12v6",key:"fv4c87"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dne=Z("TextSearch",[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M10 12H3",key:"1ulcyk"}],["path",{d:"M10 18H3",key:"13769t"}],["circle",{cx:"17",cy:"15",r:"3",key:"1upz2a"}],["path",{d:"m21 19-1.9-1.9",key:"dwi7p8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $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 Rne=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 One=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 Fne=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 zne=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 Bne=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 $ne=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 qne=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 Une=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 Vne=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 Hne=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 Gne=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 Wne=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 Kne=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 Zne=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 Yne=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 Xne=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 Qne=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 Jne=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 eae=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 tae=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 sae=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 rae=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 nae=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 aae=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 iae=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 oae=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 lae=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 cae=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 dae=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 uae=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 xr=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 hae=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 mae=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 pae=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 fae=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 xae=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 gae=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 yae=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 Vi=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 vae=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 _ae=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 bae=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 wae=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 jae=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 Nae=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 kae=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 Sae=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 Cae=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 Mae=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 Tae=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 Aae=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 Eae=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 Pae=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 Iae=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 Lae=Z("Unplug",[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const 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 Dae=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 Rae=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 Oae=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 Fae=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 zae=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 Bae=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 or=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 $ae=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 qae=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 Uae=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 Vae=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 Hae=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 Gae=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 Wae=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 gn=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 Kae=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 Zae=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 Yae=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 Xae=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 Qae=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 Jae=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 eie=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 tie=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 sie=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 rie=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 nie=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 aie=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 iie=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 oie=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 lie=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 cie=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 die=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 uie=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 hie=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 mie=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 pie=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 fie=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 xie=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 gie=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 yie=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 vie=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 _ie=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 bie=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 wie=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 jie=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 Nie=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 kie=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 Sie=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 Cie=Z("Wine",[["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M12 15v7",key:"t2xh3l"}],["path",{d:"M12 15a5 5 0 0 0 5-5c0-2-.5-4-2-8H9c-1.5 4-2 6-2 8a5 5 0 0 0 5 5Z",key:"10ffi3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mie=Z("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tie=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 Aie=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 jr=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 Eie=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 Pie=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 _gt=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:Z9,AArrowUp:Y9,ALargeSmall:X9,Accessibility:Q9,Activity:lh,AirVent:J9,Airplay:eB,AlarmClock:sB,AlarmClockCheck:G2,AlarmClockMinus:W2,AlarmClockOff:tB,AlarmClockPlus:K2,AlarmSmoke:rB,Album:nB,AlignCenter:V4,AlignCenterHorizontal:aB,AlignCenterVertical:iB,AlignEndHorizontal:oB,AlignEndVertical:lB,AlignHorizontalDistributeCenter:cB,AlignHorizontalDistributeEnd:dB,AlignHorizontalDistributeStart:uB,AlignHorizontalJustifyCenter:hB,AlignHorizontalJustifyEnd:mB,AlignHorizontalJustifyStart:pB,AlignHorizontalSpaceAround:fB,AlignHorizontalSpaceBetween:xB,AlignJustify:gB,AlignLeft:H4,AlignRight:G4,AlignStartHorizontal:yB,AlignStartVertical:vB,AlignVerticalDistributeCenter:_B,AlignVerticalDistributeEnd:bB,AlignVerticalDistributeStart:wB,AlignVerticalJustifyCenter:jB,AlignVerticalJustifyEnd:NB,AlignVerticalJustifyStart:kB,AlignVerticalSpaceAround:SB,AlignVerticalSpaceBetween:CB,Ambulance:MB,Ampersand:TB,Ampersands:AB,Amphora:EB,Anchor:PB,Angry:IB,Annoyed:LB,Antenna:DB,Anvil:RB,Aperture:OB,AppWindow:sL,AppWindowMac:FB,Apple:zB,Archive:yM,ArchiveRestore:rL,ArchiveX:BB,Armchair:$B,ArrowBigDown:UB,ArrowBigDownDash:qB,ArrowBigLeft:HB,ArrowBigLeftDash:VB,ArrowBigRight:WB,ArrowBigRightDash:GB,ArrowBigUp:ZB,ArrowBigUpDash:KB,ArrowDown:Ih,ArrowDown01:YB,ArrowDown10:XB,ArrowDownAZ:Z2,ArrowDownFromLine:QB,ArrowDownLeft:JB,ArrowDownNarrowWide:e$,ArrowDownRight:nL,ArrowDownToDot:t$,ArrowDownToLine:s$,ArrowDownUp:r$,ArrowDownWideNarrow:Y2,ArrowDownZA:X2,ArrowLeft:Oa,ArrowLeftFromLine:n$,ArrowLeftRight:a$,ArrowLeftToLine:i$,ArrowRight:Ga,ArrowRightFromLine:o$,ArrowRightLeft:Gv,ArrowRightToLine:l$,ArrowUp:uu,ArrowUp01:c$,ArrowUp10:d$,ArrowUpAZ:Q2,ArrowUpDown:td,ArrowUpFromDot:u$,ArrowUpFromLine:h$,ArrowUpLeft:m$,ArrowUpNarrowWide:J2,ArrowUpRight:aL,ArrowUpToLine:p$,ArrowUpWideNarrow:f$,ArrowUpZA:ej,ArrowsUpFromLine:x$,Asterisk:g$,AtSign:y$,Atom:v$,AudioLines:_$,AudioWaveform:b$,Award:rc,Axe:w$,Axis3d:tj,Baby:j$,Backpack:N$,Badge:B$,BadgeAlert:k$,BadgeCent:S$,BadgeCheck:sj,BadgeDollarSign:C$,BadgeEuro:M$,BadgeHelp:T$,BadgeIndianRupee:A$,BadgeInfo:E$,BadgeJapaneseYen:P$,BadgeMinus:I$,BadgePercent:L$,BadgePlus:D$,BadgePoundSterling:R$,BadgeRussianRuble:O$,BadgeSwissFranc:F$,BadgeX:z$,BaggageClaim:$$,Ban:iL,Banana:q$,Bandage:U$,Banknote:V$,Barcode:H$,Baseline:G$,Bath:nf,Battery:Q$,BatteryCharging:W$,BatteryFull:K$,BatteryLow:Z$,BatteryMedium:Y$,BatteryWarning:X$,Beaker:J$,Bean:tq,BeanOff:eq,Bed:Zy,BedDouble:W4,BedSingle:sq,Beef:rq,Beer:aq,BeerOff:nq,Bell:Sm,BellDot:iq,BellElectric:oq,BellMinus:lq,BellOff:Wv,BellPlus:cq,BellRing:dq,BetweenHorizontalEnd:rj,BetweenHorizontalStart:nj,BetweenVerticalEnd:uq,BetweenVerticalStart:hq,BicepsFlexed:mq,Bike:pq,Binary:fq,Binoculars:xq,Biohazard:gq,Bird:yq,Bitcoin:vq,Blend:_q,Blinds:bq,Blocks:wq,Bluetooth:Sq,BluetoothConnected:jq,BluetoothOff:Nq,BluetoothSearching:kq,Bold:K4,Bolt:Cq,Bomb:Mq,Bone:Tq,Book:Xq,BookA:Aq,BookAudio:Eq,BookCheck:Pq,BookCopy:Iq,BookDashed:aj,BookDown:Lq,BookHeadphones:Dq,BookHeart:Rq,BookImage:Oq,BookKey:Fq,BookLock:zq,BookMarked:Bq,BookMinus:$q,BookOpen:ch,BookOpenCheck:qq,BookOpenText:Uq,BookPlus:Vq,BookText:Hq,BookType:Gq,BookUp:Kq,BookUp2:Wq,BookUser:Zq,BookX:Yq,Bookmark:fx,BookmarkCheck:Qq,BookmarkMinus:Jq,BookmarkPlus:oL,BookmarkX:eU,BoomBox:tU,Bot:vM,BotMessageSquare:sU,BotOff:rU,Box:nU,Boxes:aU,Braces:ij,Brackets:iU,Brain:lL,BrainCircuit:oU,BrainCog:lU,BrickWall:cU,Briefcase:dh,BriefcaseBusiness:dU,BriefcaseConveyorBelt:uU,BriefcaseMedical:hU,BringToFront:mU,Brush:pU,Bug:gU,BugOff:fU,BugPlay:xU,Building:Z4,Building2:pa,Bus:vU,BusFront:yU,Cable:bU,CableCar:_U,Cake:Fu,CakeSlice:wU,Calculator:_M,Calendar:ln,Calendar1:jU,CalendarArrowDown:NU,CalendarArrowUp:kU,CalendarCheck:cL,CalendarCheck2:SU,CalendarClock:bM,CalendarCog:CU,CalendarDays:yd,CalendarFold:MU,CalendarHeart:TU,CalendarMinus:EU,CalendarMinus2:AU,CalendarOff:dL,CalendarPlus:jb,CalendarPlus2:PU,CalendarRange:IU,CalendarSearch:LU,CalendarSync:DU,CalendarX:OU,CalendarX2:RU,Camera:xx,CameraOff:FU,Candy:$U,CandyCane:zU,CandyOff:BU,Cannabis:qU,Captions:oj,CaptionsOff:UU,Car:GU,CarFront:VU,CarTaxiFront:HU,Caravan:WU,Carrot:KU,CaseLower:ZU,CaseSensitive:YU,CaseUpper:XU,CassetteTape:QU,Cast:JU,Castle:eV,Cat:tV,Cctv:sV,ChartArea:lj,ChartBar:dj,ChartBarBig:cj,ChartBarDecreasing:rV,ChartBarIncreasing:nV,ChartBarStacked:aV,ChartCandlestick:uj,ChartColumn:so,ChartColumnBig:hj,ChartColumnDecreasing:iV,ChartColumnIncreasing:mj,ChartColumnStacked:oV,ChartGantt:lV,ChartLine:pj,ChartNetwork:cV,ChartNoAxesColumn:xj,ChartNoAxesColumnDecreasing:dV,ChartNoAxesColumnIncreasing:fj,ChartNoAxesCombined:uV,ChartNoAxesGantt:gj,ChartPie:yj,ChartScatter:vj,ChartSpline:hV,Check:Zn,CheckCheck:uL,ChefHat:mV,Cherry:pV,ChevronDown:Fi,ChevronFirst:fV,ChevronLast:xV,ChevronLeft:Xo,ChevronRight:xa,ChevronUp:af,ChevronsDown:yV,ChevronsDownUp:gV,ChevronsLeft:bV,ChevronsLeftRight:_V,ChevronsLeftRightEllipsis:vV,ChevronsRight:jV,ChevronsRightLeft:wV,ChevronsUp:NV,ChevronsUpDown:gx,Chrome:kV,Church:SV,Cigarette:MV,CigaretteOff:CV,Circle:sd,CircleAlert:ro,CircleArrowDown:_j,CircleArrowLeft:bj,CircleArrowOutDownLeft:wj,CircleArrowOutDownRight:jj,CircleArrowOutUpLeft:Nj,CircleArrowOutUpRight:kj,CircleArrowRight:Sj,CircleArrowUp:Cj,CircleCheck:Hn,CircleCheckBig:ti,CircleChevronDown:Mj,CircleChevronLeft:Tj,CircleChevronRight:Aj,CircleChevronUp:Ej,CircleDashed:TV,CircleDivide:Pj,CircleDollarSign:AV,CircleDot:PV,CircleDotDashed:EV,CircleEllipsis:IV,CircleEqual:LV,CircleFadingArrowUp:DV,CircleFadingPlus:RV,CircleGauge:Ij,CircleHelp:Mv,CircleMinus:Lj,CircleOff:OV,CircleParking:Rj,CircleParkingOff:Dj,CirclePause:Oj,CirclePercent:Fj,CirclePlay:sp,CirclePlus:zj,CirclePower:Bj,CircleSlash:FV,CircleSlash2:$j,CircleStop:qj,CircleUser:Vj,CircleUserRound:Uj,CircleX:Ql,CircuitBoard:zV,Citrus:BV,Clapperboard:$V,Clipboard:KV,ClipboardCheck:wM,ClipboardCopy:qV,ClipboardList:Nb,ClipboardMinus:UV,ClipboardPaste:VV,ClipboardPen:Gj,ClipboardPenLine:Hj,ClipboardPlus:HV,ClipboardType:GV,ClipboardX:WV,Clock:on,Clock1:ZV,Clock10:YV,Clock11:XV,Clock12:QV,Clock2:JV,Clock3:eH,Clock4:tH,Clock5:sH,Clock6:rH,Clock7:nH,Clock8:aH,Clock9:iH,ClockAlert:oH,ClockArrowDown:lH,ClockArrowUp:cH,Cloud:NH,CloudAlert:dH,CloudCog:uH,CloudDownload:Wj,CloudDrizzle:hH,CloudFog:mH,CloudHail:pH,CloudLightning:fH,CloudMoon:gH,CloudMoonRain:xH,CloudOff:yH,CloudRain:_H,CloudRainWind:vH,CloudSnow:bH,CloudSun:jH,CloudSunRain:wH,CloudUpload:Kj,Cloudy:kH,Clover:Bv,Club:SH,Code:Y4,CodeXml:Zj,Codepen:CH,Codesandbox:MH,Coffee:X4,Cog:TH,Coins:hL,Columns2:Yj,Columns3:Xj,Columns4:AH,Combine:EH,Command:PH,Compass:jM,Component:IH,Computer:LH,ConciergeBell:DH,Cone:RH,Construction:OH,Contact:Q4,ContactRound:Qj,Container:FH,Contrast:zH,Cookie:BH,CookingPot:$H,Copy:Wa,CopyCheck:qH,CopyMinus:UH,CopyPlus:VH,CopySlash:HH,CopyX:GH,Copyleft:WH,Copyright:KH,CornerDownLeft:ZH,CornerDownRight:YH,CornerLeftDown:XH,CornerLeftUp:QH,CornerRightDown:JH,CornerRightUp:eG,CornerUpLeft:tG,CornerUpRight:sG,Cpu:rG,CreativeCommons:nG,CreditCard:yx,Croissant:aG,Crop:iG,Cross:oG,Crosshair:lG,Crown:Cm,Cuboid:cG,CupSoda:dG,Currency:uG,Cylinder:hG,Dam:mG,Database:mL,DatabaseBackup:pG,DatabaseZap:fG,Delete:xG,Dessert:gG,Diameter:yG,Diamond:bG,DiamondMinus:vG,DiamondPercent:Jj,DiamondPlus:_G,Dice1:wG,Dice2:jG,Dice3:NG,Dice4:kG,Dice5:SG,Dice6:CG,Dices:MG,Diff:TG,Disc:IG,Disc2:AG,Disc3:EG,DiscAlbum:PG,Divide:LG,Dna:RG,DnaOff:DG,Dock:OG,Dog:FG,DollarSign:_c,Donut:zG,DoorClosed:BG,DoorOpen:Kv,Dot:$G,Download:Qa,DraftingCompass:qG,Drama:UG,Dribbble:VG,Drill:HG,Droplet:GG,Droplets:Ag,Drum:WG,Drumstick:KG,Dumbbell:ZG,Ear:XG,EarOff:YG,Earth:eN,EarthLock:QG,Eclipse:JG,Egg:NM,EggFried:eW,EggOff:tW,Ellipsis:Zp,EllipsisVertical:ix,Equal:nW,EqualApproximately:sW,EqualNot:rW,Eraser:aW,EthernetPort:iW,Euro:oW,Expand:lW,ExternalLink:Zr,Eye:Cn,EyeClosed:cW,EyeOff:mp,Facebook:hu,Factory:dW,Fan:uW,FastForward:hW,Feather:mW,Fence:pW,FerrisWheel:fW,Figma:xW,File:kM,FileArchive:gW,FileAudio:vW,FileAudio2:yW,FileAxis3d:tN,FileBadge:bW,FileBadge2:_W,FileBox:wW,FileChartColumn:rN,FileChartColumnIncreasing:sN,FileChartLine:nN,FileChartPie:aN,FileCheck:NW,FileCheck2:jW,FileClock:kW,FileCode:CW,FileCode2:SW,FileCog:iN,FileDiff:MW,FileDigit:TW,FileDown:J4,FileHeart:AW,FileImage:kb,FileInput:EW,FileJson:IW,FileJson2:PW,FileKey:DW,FileKey2:LW,FileLock:OW,FileLock2:RW,FileMinus:zW,FileMinus2:FW,FileMusic:BW,FileOutput:$W,FilePen:lN,FilePenLine:oN,FilePlus:UW,FilePlus2:qW,FileQuestion:VW,FileScan:HW,FileSearch:WW,FileSearch2:GW,FileSliders:KW,FileSpreadsheet:Zv,FileStack:pL,FileSymlink:ZW,FileTerminal:YW,FileText:yn,FileType:QW,FileType2:XW,FileUp:JW,FileUser:eK,FileVideo:sK,FileVideo2:tK,FileVolume:nK,FileVolume2:rK,FileWarning:aK,FileX:oK,FileX2:iK,Files:lK,Film:Rd,Filter:Eg,FilterX:cK,Fingerprint:dK,FireExtinguisher:uK,Fish:pK,FishOff:hK,FishSymbol:mK,Flag:Yv,FlagOff:fK,FlagTriangleLeft:xK,FlagTriangleRight:gK,Flame:rd,FlameKindling:yK,Flashlight:_K,FlashlightOff:vK,FlaskConical:Sb,FlaskConicalOff:bK,FlaskRound:wK,FlipHorizontal:fL,FlipHorizontal2:jK,FlipVertical:kK,FlipVertical2:NK,Flower:SK,Flower2:kg,Focus:CK,FoldHorizontal:MK,FoldVertical:TK,Folder:sZ,FolderArchive:AK,FolderCheck:EK,FolderClock:PK,FolderClosed:IK,FolderCode:LK,FolderCog:cN,FolderDot:DK,FolderDown:RK,FolderGit:FK,FolderGit2:OK,FolderHeart:zK,FolderInput:BK,FolderKanban:$K,FolderKey:qK,FolderLock:UK,FolderMinus:VK,FolderOpen:Mm,FolderOpenDot:HK,FolderOutput:GK,FolderPen:dN,FolderPlus:WK,FolderRoot:KK,FolderSearch:YK,FolderSearch2:ZK,FolderSymlink:XK,FolderSync:QK,FolderTree:JK,FolderUp:eZ,FolderX:tZ,Folders:rZ,Footprints:nZ,Forklift:aZ,Forward:iZ,Frame:oZ,Framer:lZ,Frown:cZ,Fuel:dZ,Fullscreen:uZ,GalleryHorizontal:mZ,GalleryHorizontalEnd:hZ,GalleryThumbnails:pZ,GalleryVertical:xZ,GalleryVerticalEnd:fZ,Gamepad:yZ,Gamepad2:gZ,Gauge:vZ,Gavel:_Z,Gem:bZ,Ghost:eS,Gift:yi,GitBranch:jZ,GitBranchPlus:wZ,GitCommitHorizontal:uN,GitCommitVertical:NZ,GitCompare:SZ,GitCompareArrows:kZ,GitFork:CZ,GitGraph:MZ,GitMerge:TZ,GitPullRequest:DZ,GitPullRequestArrow:AZ,GitPullRequestClosed:EZ,GitPullRequestCreate:IZ,GitPullRequestCreateArrow:PZ,GitPullRequestDraft:LZ,Github:RZ,Gitlab:OZ,GlassWater:FZ,Glasses:zZ,Globe:nd,GlobeLock:BZ,Goal:$Z,Grab:qZ,GraduationCap:Lh,Grape:UZ,Grid2x2:mN,Grid2x2Check:VZ,Grid2x2Plus:hN,Grid2x2X:HZ,Grid3x3:Xf,Grip:WZ,GripHorizontal:GZ,GripVertical:mu,Group:KZ,Guitar:ZZ,Ham:YZ,Hammer:XZ,Hand:xL,HandCoins:QZ,HandHeart:JZ,HandHelping:pN,HandMetal:eY,HandPlatter:tY,Handshake:gL,HardDrive:yL,HardDriveDownload:sY,HardDriveUpload:rY,HardHat:nY,Hash:tS,Haze:aY,HdmiPort:iY,Heading:dY,Heading1:SM,Heading2:CM,Heading3:vL,Heading4:oY,Heading5:lY,Heading6:cY,HeadphoneOff:uY,Headphones:hY,Headset:mY,Heart:Xa,HeartCrack:pY,HeartHandshake:fY,HeartOff:xY,HeartPulse:gY,Heater:yY,Hexagon:vY,Highlighter:_Y,History:MM,Hop:wY,HopOff:bY,Hospital:jY,Hotel:NY,Hourglass:kY,House:Sn,HousePlug:SY,HousePlus:CY,IceCreamBowl:fN,IceCreamCone:xN,IdCard:MY,Image:qo,ImageDown:TY,ImageMinus:AY,ImageOff:EY,ImagePlay:PY,ImagePlus:Xv,ImageUp:IY,ImageUpscale:LY,Images:DY,Import:RY,Inbox:OY,IndentDecrease:gN,IndentIncrease:yN,IndianRupee:FY,Infinity:zY,Info:sS,InspectionPanel:BY,Instagram:pu,Italic:rS,IterationCcw:$Y,IterationCw:qY,JapaneseYen:UY,Joystick:VY,Kanban:Yy,Key:pp,KeyRound:nS,KeySquare:HY,Keyboard:KY,KeyboardMusic:GY,KeyboardOff:WY,Lamp:eX,LampCeiling:ZY,LampDesk:YY,LampFloor:XY,LampWallDown:QY,LampWallUp:JY,LandPlot:tX,Landmark:sX,Languages:rX,Laptop:aX,LaptopMinimal:vN,LaptopMinimalCheck:nX,Lasso:oX,LassoSelect:iX,Laugh:lX,Layers:_L,Layers2:cX,Layers3:dX,LayoutDashboard:aS,LayoutGrid:fp,LayoutList:uX,LayoutPanelLeft:hX,LayoutPanelTop:mX,LayoutTemplate:iS,Leaf:pX,LeafyGreen:fX,Lectern:xX,LetterText:gX,Library:oS,LibraryBig:yX,LifeBuoy:TM,Ligature:vX,Lightbulb:Cb,LightbulbOff:_X,Link:go,Link2:Do,Link2Off:bX,Linkedin:xp,List:Dh,ListCheck:wX,ListChecks:jX,ListCollapse:NX,ListEnd:kX,ListFilter:SX,ListMinus:CX,ListMusic:MX,ListOrdered:Xy,ListPlus:TX,ListRestart:AX,ListStart:EX,ListTodo:PX,ListTree:IX,ListVideo:LX,ListX:DX,Loader:OX,LoaderCircle:us,LoaderPinwheel:RX,Locate:AM,LocateFixed:FX,LocateOff:zX,Lock:vd,LockKeyhole:BX,LockKeyholeOpen:_N,LockOpen:bN,LogIn:lS,LogOut:EM,Logs:$X,Lollipop:qX,Luggage:UX,Magnet:VX,Mail:tr,MailCheck:HX,MailMinus:GX,MailOpen:WX,MailPlus:bL,MailQuestion:KX,MailSearch:ZX,MailWarning:YX,MailX:wL,Mailbox:XX,Mails:QX,Map:cS,MapPin:Ia,MapPinCheck:eQ,MapPinCheckInside:JX,MapPinHouse:tQ,MapPinMinus:rQ,MapPinMinusInside:sQ,MapPinOff:nQ,MapPinPlus:iQ,MapPinPlusInside:aQ,MapPinX:lQ,MapPinXInside:oQ,MapPinned:cQ,Martini:dQ,Maximize:jL,Maximize2:uQ,Medal:Qv,Megaphone:uh,MegaphoneOff:hQ,Meh:mQ,MemoryStick:pQ,Menu:dS,Merge:fQ,MessageCircle:Ol,MessageCircleCode:xQ,MessageCircleDashed:gQ,MessageCircleHeart:PM,MessageCircleMore:yQ,MessageCircleOff:vQ,MessageCirclePlus:_Q,MessageCircleQuestion:NL,MessageCircleReply:bQ,MessageCircleWarning:wQ,MessageCircleX:jQ,MessageSquare:Si,MessageSquareCode:NQ,MessageSquareDashed:kQ,MessageSquareDiff:SQ,MessageSquareDot:CQ,MessageSquareHeart:MQ,MessageSquareLock:TQ,MessageSquareMore:kL,MessageSquareOff:AQ,MessageSquarePlus:IM,MessageSquareQuote:SL,MessageSquareReply:EQ,MessageSquareShare:PQ,MessageSquareText:IQ,MessageSquareWarning:LQ,MessageSquareX:DQ,MessagesSquare:RQ,Mic:CL,MicOff:OQ,MicVocal:wN,Microchip:FQ,Microscope:zQ,Microwave:BQ,Milestone:$Q,Milk:UQ,MilkOff:qQ,Minimize:HQ,Minimize2:VQ,Minus:Qy,Monitor:hS,MonitorCheck:GQ,MonitorCog:WQ,MonitorDot:KQ,MonitorDown:ZQ,MonitorOff:YQ,MonitorPause:XQ,MonitorPlay:QQ,MonitorSmartphone:JQ,MonitorSpeaker:eJ,MonitorStop:tJ,MonitorUp:uS,MonitorX:sJ,Moon:nJ,MoonStar:rJ,Mountain:iJ,MountainSnow:aJ,Mouse:dJ,MouseOff:oJ,MousePointer:au,MousePointer2:lJ,MousePointerBan:cJ,MousePointerClick:Tm,Move:jJ,Move3d:jN,MoveDiagonal:hJ,MoveDiagonal2:uJ,MoveDown:fJ,MoveDownLeft:mJ,MoveDownRight:pJ,MoveHorizontal:xJ,MoveLeft:gJ,MoveRight:yJ,MoveUp:bJ,MoveUpLeft:vJ,MoveUpRight:_J,MoveVertical:wJ,Music:CJ,Music2:NJ,Music3:kJ,Music4:SJ,Navigation:ML,Navigation2:TJ,Navigation2Off:MJ,NavigationOff:AJ,Network:EJ,Newspaper:Jv,Nfc:PJ,Notebook:RJ,NotebookPen:IJ,NotebookTabs:LJ,NotebookText:DJ,NotepadText:FJ,NotepadTextDashed:OJ,Nut:BJ,NutOff:zJ,Octagon:qJ,OctagonAlert:Tv,OctagonMinus:$J,OctagonPause:NN,OctagonX:kN,Omega:UJ,Option:VJ,Orbit:HJ,Origami:GJ,Package:cl,Package2:WJ,PackageCheck:KJ,PackageMinus:ZJ,PackageOpen:YJ,PackagePlus:XJ,PackageSearch:QJ,PackageX:JJ,PaintBucket:eee,PaintRoller:tee,Paintbrush:see,PaintbrushVertical:SN,Palette:Fl,PanelBottom:aee,PanelBottomClose:ree,PanelBottomDashed:CN,PanelBottomOpen:nee,PanelLeft:EN,PanelLeftClose:MN,PanelLeftDashed:TN,PanelLeftOpen:AN,PanelRight:lee,PanelRightClose:iee,PanelRightDashed:PN,PanelRightOpen:oee,PanelTop:uee,PanelTopClose:cee,PanelTopDashed:IN,PanelTopOpen:dee,PanelsLeftBottom:hee,PanelsRightBottom:mee,PanelsTopLeft:Av,Paperclip:mS,Parentheses:pee,ParkingMeter:fee,PartyPopper:qd,Pause:hh,PawPrint:xee,PcCase:gee,Pen:Ry,PenLine:Ev,PenOff:yee,PenTool:Mb,Pencil:ga,PencilLine:vee,PencilOff:_ee,PencilRuler:bee,Pentagon:wee,Percent:LM,PersonStanding:jee,PhilippinePeso:Nee,Phone:In,PhoneCall:kee,PhoneForwarded:See,PhoneIncoming:Cee,PhoneMissed:Mee,PhoneOff:Tee,PhoneOutgoing:Aee,Pi:Eee,Piano:Pee,Pickaxe:Iee,PictureInPicture:Dee,PictureInPicture2:Lee,PiggyBank:Ree,Pilcrow:zee,PilcrowLeft:Oee,PilcrowRight:Fee,Pill:$ee,PillBottle:Bee,Pin:Tb,PinOff:TL,Pipette:qee,Pizza:Uee,Plane:Gee,PlaneLanding:Vee,PlaneTakeoff:Hee,Play:Co,Plug:AL,Plug2:Wee,PlugZap:LN,Plus:Bs,Pocket:Zee,PocketKnife:Kee,Podcast:Yee,Pointer:Qee,PointerOff:Xee,Popcorn:Jee,Popsicle:ete,PoundSterling:tte,Power:EL,PowerOff:ste,Presentation:Pg,Printer:PL,PrinterCheck:rte,Projector:nte,Proportions:ate,Puzzle:ite,Pyramid:ote,QrCode:Jy,Quote:pS,Rabbit:lte,Radar:cte,Radiation:dte,Radical:ute,Radio:e1,RadioReceiver:hte,RadioTower:mte,Radius:pte,RailSymbol:fte,Rainbow:xte,Rat:gte,Ratio:yte,Receipt:Cte,ReceiptCent:vte,ReceiptEuro:_te,ReceiptIndianRupee:bte,ReceiptJapaneseYen:wte,ReceiptPoundSterling:jte,ReceiptRussianRuble:Nte,ReceiptSwissFranc:kte,ReceiptText:Ste,RectangleEllipsis:DN,RectangleHorizontal:Mte,RectangleVertical:Tte,Recycle:Ate,Redo:fS,Redo2:Ete,RedoDot:Pte,RefreshCcw:DM,RefreshCcwDot:Ite,RefreshCw:Zi,RefreshCwOff:Lte,Refrigerator:Dte,Regex:Rte,RemoveFormatting:Ote,Repeat:IL,Repeat1:Fte,Repeat2:zte,Replace:$te,ReplaceAll:Bte,Reply:LL,ReplyAll:qte,Rewind:Ute,Ribbon:Vte,Rocket:e0,RockingChair:Hte,RollerCoaster:Gte,Rotate3d:RN,RotateCcw:t0,RotateCcwSquare:Wte,RotateCw:DL,RotateCwSquare:Kte,Route:Yte,RouteOff:Zte,Router:Xte,Rows2:ON,Rows3:FN,Rows4:Qte,Rss:Jte,Ruler:xS,RussianRuble:ese,Sailboat:tse,Salad:sse,Sandwich:rse,Satellite:ase,SatelliteDish:nse,Save:bc,SaveAll:ise,SaveOff:ose,Scale:RL,Scale3d:zN,Scaling:lse,Scan:xse,ScanBarcode:cse,ScanEye:dse,ScanFace:use,ScanLine:hse,ScanQrCode:mse,ScanSearch:pse,ScanText:fse,School:gse,Scissors:vse,ScissorsLineDashed:yse,ScreenShare:bse,ScreenShareOff:_se,Scroll:jse,ScrollText:wse,Search:an,SearchCheck:Nse,SearchCode:kse,SearchSlash:Sse,SearchX:OL,Section:Cse,Send:Mn,SendHorizontal:BN,SendToBack:Mse,SeparatorHorizontal:Tse,SeparatorVertical:Ase,Server:Lse,ServerCog:Ese,ServerCrash:Pse,ServerOff:Ise,Settings:So,Settings2:FL,Shapes:Dse,Share:zL,Share2:_d,Sheet:Rse,Shell:Ose,Shield:zu,ShieldAlert:Fse,ShieldBan:zse,ShieldCheck:t1,ShieldEllipsis:Bse,ShieldHalf:$se,ShieldMinus:qse,ShieldOff:gS,ShieldPlus:Use,ShieldQuestion:Vse,ShieldX:$N,Ship:Gse,ShipWheel:Hse,Shirt:Wse,ShoppingBag:s0,ShoppingBasket:Kse,ShoppingCart:op,Shovel:Zse,ShowerHead:Yse,Shrink:Xse,Shrub:Qse,Shuffle:yS,Sigma:Jse,Signal:nre,SignalHigh:ere,SignalLow:tre,SignalMedium:sre,SignalZero:rre,Signature:are,Signpost:ore,SignpostBig:ire,Siren:lre,SkipBack:cre,SkipForward:dre,Skull:ure,Slack:hre,Slash:mre,Slice:pre,SlidersHorizontal:vS,SlidersVertical:qN,Smartphone:Ig,SmartphoneCharging:fre,SmartphoneNfc:xre,Smile:yre,SmilePlus:gre,Snail:vre,Snowflake:qy,Sofa:_re,Soup:bre,Space:wre,Spade:jre,Sparkle:Nre,Sparkles:Or,Speaker:kre,Speech:Sre,SpellCheck:Mre,SpellCheck2:Cre,Spline:Tre,Split:Are,SprayCan:Ere,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:Ire,SquareDashedBottomCode:Pre,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:Lre,SquareScissors:Ek,SquareSigma:Pk,SquareSlash:Ik,SquareSplitHorizontal:Lk,SquareSplitVertical:Dk,SquareSquare:Dre,SquareStack:Rre,SquareTerminal:Rk,SquareUser:Fk,SquareUserRound:Ok,SquareX:zk,Squircle:Ore,Squirrel:Fre,Stamp:zre,Star:Gn,StarHalf:Bre,StarOff:$re,StepBack:qre,StepForward:Ure,Stethoscope:Vre,Sticker:Hre,StickyNote:Gre,Store:Wre,StretchHorizontal:Kre,StretchVertical:Zre,Strikethrough:BL,Subscript:Yre,Sun:s1,SunDim:Xre,SunMedium:Qre,SunMoon:Jre,SunSnow:ene,Sunrise:tne,Sunset:sne,Superscript:rne,SwatchBook:nne,SwissFranc:ane,SwitchCamera:ine,Sword:one,Swords:lne,Syringe:cne,Table:OM,Table2:RM,TableCellsMerge:dne,TableCellsSplit:une,TableColumnsSplit:hne,TableOfContents:mne,TableProperties:pne,TableRowsSplit:fne,Tablet:gne,TabletSmartphone:xne,Tablets:yne,Tag:mh,Tags:vne,Tally1:_ne,Tally2:bne,Tally3:wne,Tally4:jne,Tally5:Nne,Tangent:kne,Target:Rh,Telescope:Sne,Tent:Mne,TentTree:Cne,Terminal:Tne,TestTube:Ane,TestTubeDiagonal:Bk,TestTubes:Ene,Text:Rne,TextCursor:Ine,TextCursorInput:Pne,TextQuote:Lne,TextSearch:Dne,TextSelect:$k,Theater:One,Thermometer:Bne,ThermometerSnowflake:Fne,ThermometerSun:zne,ThumbsDown:$L,ThumbsUp:Bu,Ticket:qL,TicketCheck:$ne,TicketMinus:qne,TicketPercent:Une,TicketPlus:Vne,TicketSlash:Hne,TicketX:Gne,Tickets:Kne,TicketsPlane:Wne,Timer:Xne,TimerOff:Zne,TimerReset:Yne,ToggleLeft:Qne,ToggleRight:Jne,Toilet:eae,Tornado:tae,Torus:sae,Touchpad:nae,TouchpadOff:rae,TowerControl:aae,ToyBrick:iae,Tractor:oae,TrafficCone:lae,TrainFront:dae,TrainFrontTunnel:cae,TrainTrack:uae,TramFront:qk,Trash:hae,Trash2:xr,TreeDeciduous:mae,TreePalm:Uk,TreePine:Ab,Trees:pae,Trello:fae,TrendingDown:bS,TrendingUp:Qo,TrendingUpDown:xae,Triangle:yae,TriangleAlert:Dc,TriangleRight:gae,Trophy:Vi,Truck:UL,Turtle:vae,Tv:bae,TvMinimal:Vk,TvMinimalPlay:_ae,Twitch:wae,Twitter:jae,Type:kae,TypeOutline:Nae,Umbrella:Cae,UmbrellaOff:Sae,Underline:VL,Undo:wS,Undo2:Mae,UndoDot:Tae,UnfoldHorizontal:Aae,UnfoldVertical:Eae,Ungroup:Pae,University:Hk,Unlink:jS,Unlink2:Iae,Unplug:Lae,Upload:Ra,Usb:Dae,User:Ai,UserCheck:n0,UserCog:HL,UserMinus:GL,UserPen:Rae,UserPlus:Jo,UserRound:Xk,UserRoundCheck:Gk,UserRoundCog:Wk,UserRoundMinus:Kk,UserRoundPen:Oae,UserRoundPlus:Zk,UserRoundSearch:Fae,UserRoundX:Yk,UserSearch:zae,UserX:Bae,Users:or,UsersRound:Qk,Utensils:e4,UtensilsCrossed:Jk,UtilityPole:$ae,Variable:FM,Vault:qae,Vegan:Uae,VenetianMask:Vae,Vibrate:Gae,VibrateOff:Hae,Video:gn,VideoOff:Wae,Videotape:Kae,View:Zae,Voicemail:Yae,Volleyball:Xae,Volume:sie,Volume1:Qae,Volume2:Jae,VolumeOff:eie,VolumeX:tie,Vote:rie,Wallet:WL,WalletCards:nie,WalletMinimal:t4,Wallpaper:aie,Wand:iie,WandSparkles:Iv,Warehouse:oie,WashingMachine:lie,Watch:cie,Waves:die,Waypoints:uie,Webcam:hie,Webhook:pie,WebhookOff:mie,Weight:fie,Wheat:gie,WheatOff:xie,WholeWord:yie,Wifi:jie,WifiHigh:vie,WifiLow:_ie,WifiOff:bie,WifiZero:wie,Wind:kie,WindArrowDown:Nie,Wine:Cie,WineOff:Sie,Workflow:Mie,Worm:Tie,WrapText:Aie,Wrench:Lg,X:jr,Youtube:Eie,Zap:Oh,ZapOff:Pie,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:Z9,AArrowDownIcon:Z9,AArrowUp:Y9,AArrowUpIcon:Y9,ALargeSmall:X9,ALargeSmallIcon:X9,Accessibility:Q9,AccessibilityIcon:Q9,Activity:lh,ActivityIcon:lh,ActivitySquare:UN,ActivitySquareIcon:UN,AirVent:J9,AirVentIcon:J9,Airplay:eB,AirplayIcon:eB,AlarmCheck:G2,AlarmCheckIcon:G2,AlarmClock:sB,AlarmClockCheck:G2,AlarmClockCheckIcon:G2,AlarmClockIcon:sB,AlarmClockMinus:W2,AlarmClockMinusIcon:W2,AlarmClockOff:tB,AlarmClockOffIcon:tB,AlarmClockPlus:K2,AlarmClockPlusIcon:K2,AlarmMinus:W2,AlarmMinusIcon:W2,AlarmPlus:K2,AlarmPlusIcon:K2,AlarmSmoke:rB,AlarmSmokeIcon:rB,Album:nB,AlbumIcon:nB,AlertCircle:ro,AlertCircleIcon:ro,AlertOctagon:Tv,AlertOctagonIcon:Tv,AlertTriangle:Dc,AlertTriangleIcon:Dc,AlignCenter:V4,AlignCenterHorizontal:aB,AlignCenterHorizontalIcon:aB,AlignCenterIcon:V4,AlignCenterVertical:iB,AlignCenterVerticalIcon:iB,AlignEndHorizontal:oB,AlignEndHorizontalIcon:oB,AlignEndVertical:lB,AlignEndVerticalIcon:lB,AlignHorizontalDistributeCenter:cB,AlignHorizontalDistributeCenterIcon:cB,AlignHorizontalDistributeEnd:dB,AlignHorizontalDistributeEndIcon:dB,AlignHorizontalDistributeStart:uB,AlignHorizontalDistributeStartIcon:uB,AlignHorizontalJustifyCenter:hB,AlignHorizontalJustifyCenterIcon:hB,AlignHorizontalJustifyEnd:mB,AlignHorizontalJustifyEndIcon:mB,AlignHorizontalJustifyStart:pB,AlignHorizontalJustifyStartIcon:pB,AlignHorizontalSpaceAround:fB,AlignHorizontalSpaceAroundIcon:fB,AlignHorizontalSpaceBetween:xB,AlignHorizontalSpaceBetweenIcon:xB,AlignJustify:gB,AlignJustifyIcon:gB,AlignLeft:H4,AlignLeftIcon:H4,AlignRight:G4,AlignRightIcon:G4,AlignStartHorizontal:yB,AlignStartHorizontalIcon:yB,AlignStartVertical:vB,AlignStartVerticalIcon:vB,AlignVerticalDistributeCenter:_B,AlignVerticalDistributeCenterIcon:_B,AlignVerticalDistributeEnd:bB,AlignVerticalDistributeEndIcon:bB,AlignVerticalDistributeStart:wB,AlignVerticalDistributeStartIcon:wB,AlignVerticalJustifyCenter:jB,AlignVerticalJustifyCenterIcon:jB,AlignVerticalJustifyEnd:NB,AlignVerticalJustifyEndIcon:NB,AlignVerticalJustifyStart:kB,AlignVerticalJustifyStartIcon:kB,AlignVerticalSpaceAround:SB,AlignVerticalSpaceAroundIcon:SB,AlignVerticalSpaceBetween:CB,AlignVerticalSpaceBetweenIcon:CB,Ambulance:MB,AmbulanceIcon:MB,Ampersand:TB,AmpersandIcon:TB,Ampersands:AB,AmpersandsIcon:AB,Amphora:EB,AmphoraIcon:EB,Anchor:PB,AnchorIcon:PB,Angry:IB,AngryIcon:IB,Annoyed:LB,AnnoyedIcon:LB,Antenna:DB,AntennaIcon:DB,Anvil:RB,AnvilIcon:RB,Aperture:OB,ApertureIcon:OB,AppWindow:sL,AppWindowIcon:sL,AppWindowMac:FB,AppWindowMacIcon:FB,Apple:zB,AppleIcon:zB,Archive:yM,ArchiveIcon:yM,ArchiveRestore:rL,ArchiveRestoreIcon:rL,ArchiveX:BB,ArchiveXIcon:BB,AreaChart:lj,AreaChartIcon:lj,Armchair:$B,ArmchairIcon:$B,ArrowBigDown:UB,ArrowBigDownDash:qB,ArrowBigDownDashIcon:qB,ArrowBigDownIcon:UB,ArrowBigLeft:HB,ArrowBigLeftDash:VB,ArrowBigLeftDashIcon:VB,ArrowBigLeftIcon:HB,ArrowBigRight:WB,ArrowBigRightDash:GB,ArrowBigRightDashIcon:GB,ArrowBigRightIcon:WB,ArrowBigUp:ZB,ArrowBigUpDash:KB,ArrowBigUpDashIcon:KB,ArrowBigUpIcon:ZB,ArrowDown:Ih,ArrowDown01:YB,ArrowDown01Icon:YB,ArrowDown10:XB,ArrowDown10Icon:XB,ArrowDownAZ:Z2,ArrowDownAZIcon:Z2,ArrowDownAz:Z2,ArrowDownAzIcon:Z2,ArrowDownCircle:_j,ArrowDownCircleIcon:_j,ArrowDownFromLine:QB,ArrowDownFromLineIcon:QB,ArrowDownIcon:Ih,ArrowDownLeft:JB,ArrowDownLeftFromCircle:wj,ArrowDownLeftFromCircleIcon:wj,ArrowDownLeftFromSquare:KN,ArrowDownLeftFromSquareIcon:KN,ArrowDownLeftIcon:JB,ArrowDownLeftSquare:VN,ArrowDownLeftSquareIcon:VN,ArrowDownNarrowWide:e$,ArrowDownNarrowWideIcon:e$,ArrowDownRight:nL,ArrowDownRightFromCircle:jj,ArrowDownRightFromCircleIcon:jj,ArrowDownRightFromSquare:ZN,ArrowDownRightFromSquareIcon:ZN,ArrowDownRightIcon:nL,ArrowDownRightSquare:HN,ArrowDownRightSquareIcon:HN,ArrowDownSquare:GN,ArrowDownSquareIcon:GN,ArrowDownToDot:t$,ArrowDownToDotIcon:t$,ArrowDownToLine:s$,ArrowDownToLineIcon:s$,ArrowDownUp:r$,ArrowDownUpIcon:r$,ArrowDownWideNarrow:Y2,ArrowDownWideNarrowIcon:Y2,ArrowDownZA:X2,ArrowDownZAIcon:X2,ArrowDownZa:X2,ArrowDownZaIcon:X2,ArrowLeft:Oa,ArrowLeftCircle:bj,ArrowLeftCircleIcon:bj,ArrowLeftFromLine:n$,ArrowLeftFromLineIcon:n$,ArrowLeftIcon:Oa,ArrowLeftRight:a$,ArrowLeftRightIcon:a$,ArrowLeftSquare:WN,ArrowLeftSquareIcon:WN,ArrowLeftToLine:i$,ArrowLeftToLineIcon:i$,ArrowRight:Ga,ArrowRightCircle:Sj,ArrowRightCircleIcon:Sj,ArrowRightFromLine:o$,ArrowRightFromLineIcon:o$,ArrowRightIcon:Ga,ArrowRightLeft:Gv,ArrowRightLeftIcon:Gv,ArrowRightSquare:QN,ArrowRightSquareIcon:QN,ArrowRightToLine:l$,ArrowRightToLineIcon:l$,ArrowUp:uu,ArrowUp01:c$,ArrowUp01Icon:c$,ArrowUp10:d$,ArrowUp10Icon:d$,ArrowUpAZ:Q2,ArrowUpAZIcon:Q2,ArrowUpAz:Q2,ArrowUpAzIcon:Q2,ArrowUpCircle:Cj,ArrowUpCircleIcon:Cj,ArrowUpDown:td,ArrowUpDownIcon:td,ArrowUpFromDot:u$,ArrowUpFromDotIcon:u$,ArrowUpFromLine:h$,ArrowUpFromLineIcon:h$,ArrowUpIcon:uu,ArrowUpLeft:m$,ArrowUpLeftFromCircle:Nj,ArrowUpLeftFromCircleIcon:Nj,ArrowUpLeftFromSquare:YN,ArrowUpLeftFromSquareIcon:YN,ArrowUpLeftIcon:m$,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:p$,ArrowUpToLineIcon:p$,ArrowUpWideNarrow:f$,ArrowUpWideNarrowIcon:f$,ArrowUpZA:ej,ArrowUpZAIcon:ej,ArrowUpZa:ej,ArrowUpZaIcon:ej,ArrowsUpFromLine:x$,ArrowsUpFromLineIcon:x$,Asterisk:g$,AsteriskIcon:g$,AsteriskSquare:sk,AsteriskSquareIcon:sk,AtSign:y$,AtSignIcon:y$,Atom:v$,AtomIcon:v$,AudioLines:_$,AudioLinesIcon:_$,AudioWaveform:b$,AudioWaveformIcon:b$,Award:rc,AwardIcon:rc,Axe:w$,AxeIcon:w$,Axis3D:tj,Axis3DIcon:tj,Axis3d:tj,Axis3dIcon:tj,Baby:j$,BabyIcon:j$,Backpack:N$,BackpackIcon:N$,Badge:B$,BadgeAlert:k$,BadgeAlertIcon:k$,BadgeCent:S$,BadgeCentIcon:S$,BadgeCheck:sj,BadgeCheckIcon:sj,BadgeDollarSign:C$,BadgeDollarSignIcon:C$,BadgeEuro:M$,BadgeEuroIcon:M$,BadgeHelp:T$,BadgeHelpIcon:T$,BadgeIcon:B$,BadgeIndianRupee:A$,BadgeIndianRupeeIcon:A$,BadgeInfo:E$,BadgeInfoIcon:E$,BadgeJapaneseYen:P$,BadgeJapaneseYenIcon:P$,BadgeMinus:I$,BadgeMinusIcon:I$,BadgePercent:L$,BadgePercentIcon:L$,BadgePlus:D$,BadgePlusIcon:D$,BadgePoundSterling:R$,BadgePoundSterlingIcon:R$,BadgeRussianRuble:O$,BadgeRussianRubleIcon:O$,BadgeSwissFranc:F$,BadgeSwissFrancIcon:F$,BadgeX:z$,BadgeXIcon:z$,BaggageClaim:$$,BaggageClaimIcon:$$,Ban:iL,BanIcon:iL,Banana:q$,BananaIcon:q$,Bandage:U$,BandageIcon:U$,Banknote:V$,BanknoteIcon:V$,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:H$,BarcodeIcon:H$,Baseline:G$,BaselineIcon:G$,Bath:nf,BathIcon:nf,Battery:Q$,BatteryCharging:W$,BatteryChargingIcon:W$,BatteryFull:K$,BatteryFullIcon:K$,BatteryIcon:Q$,BatteryLow:Z$,BatteryLowIcon:Z$,BatteryMedium:Y$,BatteryMediumIcon:Y$,BatteryWarning:X$,BatteryWarningIcon:X$,Beaker:J$,BeakerIcon:J$,Bean:tq,BeanIcon:tq,BeanOff:eq,BeanOffIcon:eq,Bed:Zy,BedDouble:W4,BedDoubleIcon:W4,BedIcon:Zy,BedSingle:sq,BedSingleIcon:sq,Beef:rq,BeefIcon:rq,Beer:aq,BeerIcon:aq,BeerOff:nq,BeerOffIcon:nq,Bell:Sm,BellDot:iq,BellDotIcon:iq,BellElectric:oq,BellElectricIcon:oq,BellIcon:Sm,BellMinus:lq,BellMinusIcon:lq,BellOff:Wv,BellOffIcon:Wv,BellPlus:cq,BellPlusIcon:cq,BellRing:dq,BellRingIcon:dq,BetweenHorizonalEnd:rj,BetweenHorizonalEndIcon:rj,BetweenHorizonalStart:nj,BetweenHorizonalStartIcon:nj,BetweenHorizontalEnd:rj,BetweenHorizontalEndIcon:rj,BetweenHorizontalStart:nj,BetweenHorizontalStartIcon:nj,BetweenVerticalEnd:uq,BetweenVerticalEndIcon:uq,BetweenVerticalStart:hq,BetweenVerticalStartIcon:hq,BicepsFlexed:mq,BicepsFlexedIcon:mq,Bike:pq,BikeIcon:pq,Binary:fq,BinaryIcon:fq,Binoculars:xq,BinocularsIcon:xq,Biohazard:gq,BiohazardIcon:gq,Bird:yq,BirdIcon:yq,Bitcoin:vq,BitcoinIcon:vq,Blend:_q,BlendIcon:_q,Blinds:bq,BlindsIcon:bq,Blocks:wq,BlocksIcon:wq,Bluetooth:Sq,BluetoothConnected:jq,BluetoothConnectedIcon:jq,BluetoothIcon:Sq,BluetoothOff:Nq,BluetoothOffIcon:Nq,BluetoothSearching:kq,BluetoothSearchingIcon:kq,Bold:K4,BoldIcon:K4,Bolt:Cq,BoltIcon:Cq,Bomb:Mq,BombIcon:Mq,Bone:Tq,BoneIcon:Tq,Book:Xq,BookA:Aq,BookAIcon:Aq,BookAudio:Eq,BookAudioIcon:Eq,BookCheck:Pq,BookCheckIcon:Pq,BookCopy:Iq,BookCopyIcon:Iq,BookDashed:aj,BookDashedIcon:aj,BookDown:Lq,BookDownIcon:Lq,BookHeadphones:Dq,BookHeadphonesIcon:Dq,BookHeart:Rq,BookHeartIcon:Rq,BookIcon:Xq,BookImage:Oq,BookImageIcon:Oq,BookKey:Fq,BookKeyIcon:Fq,BookLock:zq,BookLockIcon:zq,BookMarked:Bq,BookMarkedIcon:Bq,BookMinus:$q,BookMinusIcon:$q,BookOpen:ch,BookOpenCheck:qq,BookOpenCheckIcon:qq,BookOpenIcon:ch,BookOpenText:Uq,BookOpenTextIcon:Uq,BookPlus:Vq,BookPlusIcon:Vq,BookTemplate:aj,BookTemplateIcon:aj,BookText:Hq,BookTextIcon:Hq,BookType:Gq,BookTypeIcon:Gq,BookUp:Kq,BookUp2:Wq,BookUp2Icon:Wq,BookUpIcon:Kq,BookUser:Zq,BookUserIcon:Zq,BookX:Yq,BookXIcon:Yq,Bookmark:fx,BookmarkCheck:Qq,BookmarkCheckIcon:Qq,BookmarkIcon:fx,BookmarkMinus:Jq,BookmarkMinusIcon:Jq,BookmarkPlus:oL,BookmarkPlusIcon:oL,BookmarkX:eU,BookmarkXIcon:eU,BoomBox:tU,BoomBoxIcon:tU,Bot:vM,BotIcon:vM,BotMessageSquare:sU,BotMessageSquareIcon:sU,BotOff:rU,BotOffIcon:rU,Box:nU,BoxIcon:nU,BoxSelect:hk,BoxSelectIcon:hk,Boxes:aU,BoxesIcon:aU,Braces:ij,BracesIcon:ij,Brackets:iU,BracketsIcon:iU,Brain:lL,BrainCircuit:oU,BrainCircuitIcon:oU,BrainCog:lU,BrainCogIcon:lU,BrainIcon:lL,BrickWall:cU,BrickWallIcon:cU,Briefcase:dh,BriefcaseBusiness:dU,BriefcaseBusinessIcon:dU,BriefcaseConveyorBelt:uU,BriefcaseConveyorBeltIcon:uU,BriefcaseIcon:dh,BriefcaseMedical:hU,BriefcaseMedicalIcon:hU,BringToFront:mU,BringToFrontIcon:mU,Brush:pU,BrushIcon:pU,Bug:gU,BugIcon:gU,BugOff:fU,BugOffIcon:fU,BugPlay:xU,BugPlayIcon:xU,Building:Z4,Building2:pa,Building2Icon:pa,BuildingIcon:Z4,Bus:vU,BusFront:yU,BusFrontIcon:yU,BusIcon:vU,Cable:bU,CableCar:_U,CableCarIcon:_U,CableIcon:bU,Cake:Fu,CakeIcon:Fu,CakeSlice:wU,CakeSliceIcon:wU,Calculator:_M,CalculatorIcon:_M,Calendar:ln,Calendar1:jU,Calendar1Icon:jU,CalendarArrowDown:NU,CalendarArrowDownIcon:NU,CalendarArrowUp:kU,CalendarArrowUpIcon:kU,CalendarCheck:cL,CalendarCheck2:SU,CalendarCheck2Icon:SU,CalendarCheckIcon:cL,CalendarClock:bM,CalendarClockIcon:bM,CalendarCog:CU,CalendarCogIcon:CU,CalendarDays:yd,CalendarDaysIcon:yd,CalendarFold:MU,CalendarFoldIcon:MU,CalendarHeart:TU,CalendarHeartIcon:TU,CalendarIcon:ln,CalendarMinus:EU,CalendarMinus2:AU,CalendarMinus2Icon:AU,CalendarMinusIcon:EU,CalendarOff:dL,CalendarOffIcon:dL,CalendarPlus:jb,CalendarPlus2:PU,CalendarPlus2Icon:PU,CalendarPlusIcon:jb,CalendarRange:IU,CalendarRangeIcon:IU,CalendarSearch:LU,CalendarSearchIcon:LU,CalendarSync:DU,CalendarSyncIcon:DU,CalendarX:OU,CalendarX2:RU,CalendarX2Icon:RU,CalendarXIcon:OU,Camera:xx,CameraIcon:xx,CameraOff:FU,CameraOffIcon:FU,CandlestickChart:uj,CandlestickChartIcon:uj,Candy:$U,CandyCane:zU,CandyCaneIcon:zU,CandyIcon:$U,CandyOff:BU,CandyOffIcon:BU,Cannabis:qU,CannabisIcon:qU,Captions:oj,CaptionsIcon:oj,CaptionsOff:UU,CaptionsOffIcon:UU,Car:GU,CarFront:VU,CarFrontIcon:VU,CarIcon:GU,CarTaxiFront:HU,CarTaxiFrontIcon:HU,Caravan:WU,CaravanIcon:WU,Carrot:KU,CarrotIcon:KU,CaseLower:ZU,CaseLowerIcon:ZU,CaseSensitive:YU,CaseSensitiveIcon:YU,CaseUpper:XU,CaseUpperIcon:XU,CassetteTape:QU,CassetteTapeIcon:QU,Cast:JU,CastIcon:JU,Castle:eV,CastleIcon:eV,Cat:tV,CatIcon:tV,Cctv:sV,CctvIcon:sV,ChartArea:lj,ChartAreaIcon:lj,ChartBar:dj,ChartBarBig:cj,ChartBarBigIcon:cj,ChartBarDecreasing:rV,ChartBarDecreasingIcon:rV,ChartBarIcon:dj,ChartBarIncreasing:nV,ChartBarIncreasingIcon:nV,ChartBarStacked:aV,ChartBarStackedIcon:aV,ChartCandlestick:uj,ChartCandlestickIcon:uj,ChartColumn:so,ChartColumnBig:hj,ChartColumnBigIcon:hj,ChartColumnDecreasing:iV,ChartColumnDecreasingIcon:iV,ChartColumnIcon:so,ChartColumnIncreasing:mj,ChartColumnIncreasingIcon:mj,ChartColumnStacked:oV,ChartColumnStackedIcon:oV,ChartGantt:lV,ChartGanttIcon:lV,ChartLine:pj,ChartLineIcon:pj,ChartNetwork:cV,ChartNetworkIcon:cV,ChartNoAxesColumn:xj,ChartNoAxesColumnDecreasing:dV,ChartNoAxesColumnDecreasingIcon:dV,ChartNoAxesColumnIcon:xj,ChartNoAxesColumnIncreasing:fj,ChartNoAxesColumnIncreasingIcon:fj,ChartNoAxesCombined:uV,ChartNoAxesCombinedIcon:uV,ChartNoAxesGantt:gj,ChartNoAxesGanttIcon:gj,ChartPie:yj,ChartPieIcon:yj,ChartScatter:vj,ChartScatterIcon:vj,ChartSpline:hV,ChartSplineIcon:hV,Check:Zn,CheckCheck:uL,CheckCheckIcon:uL,CheckCircle:ti,CheckCircle2:Hn,CheckCircle2Icon:Hn,CheckCircleIcon:ti,CheckIcon:Zn,CheckSquare:Pv,CheckSquare2:nk,CheckSquare2Icon:nk,CheckSquareIcon:Pv,ChefHat:mV,ChefHatIcon:mV,Cherry:pV,CherryIcon:pV,ChevronDown:Fi,ChevronDownCircle:Mj,ChevronDownCircleIcon:Mj,ChevronDownIcon:Fi,ChevronDownSquare:ak,ChevronDownSquareIcon:ak,ChevronFirst:fV,ChevronFirstIcon:fV,ChevronLast:xV,ChevronLastIcon:xV,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:yV,ChevronsDownIcon:yV,ChevronsDownUp:gV,ChevronsDownUpIcon:gV,ChevronsLeft:bV,ChevronsLeftIcon:bV,ChevronsLeftRight:_V,ChevronsLeftRightEllipsis:vV,ChevronsLeftRightEllipsisIcon:vV,ChevronsLeftRightIcon:_V,ChevronsRight:jV,ChevronsRightIcon:jV,ChevronsRightLeft:wV,ChevronsRightLeftIcon:wV,ChevronsUp:NV,ChevronsUpDown:gx,ChevronsUpDownIcon:gx,ChevronsUpIcon:NV,Chrome:kV,ChromeIcon:kV,Church:SV,ChurchIcon:SV,Cigarette:MV,CigaretteIcon:MV,CigaretteOff:CV,CigaretteOffIcon:CV,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:Hn,CircleCheckBig:ti,CircleCheckBigIcon:ti,CircleCheckIcon:Hn,CircleChevronDown:Mj,CircleChevronDownIcon:Mj,CircleChevronLeft:Tj,CircleChevronLeftIcon:Tj,CircleChevronRight:Aj,CircleChevronRightIcon:Aj,CircleChevronUp:Ej,CircleChevronUpIcon:Ej,CircleDashed:TV,CircleDashedIcon:TV,CircleDivide:Pj,CircleDivideIcon:Pj,CircleDollarSign:AV,CircleDollarSignIcon:AV,CircleDot:PV,CircleDotDashed:EV,CircleDotDashedIcon:EV,CircleDotIcon:PV,CircleEllipsis:IV,CircleEllipsisIcon:IV,CircleEqual:LV,CircleEqualIcon:LV,CircleFadingArrowUp:DV,CircleFadingArrowUpIcon:DV,CircleFadingPlus:RV,CircleFadingPlusIcon:RV,CircleGauge:Ij,CircleGaugeIcon:Ij,CircleHelp:Mv,CircleHelpIcon:Mv,CircleIcon:sd,CircleMinus:Lj,CircleMinusIcon:Lj,CircleOff:OV,CircleOffIcon:OV,CircleParking:Rj,CircleParkingIcon:Rj,CircleParkingOff:Dj,CircleParkingOffIcon:Dj,CirclePause:Oj,CirclePauseIcon:Oj,CirclePercent:Fj,CirclePercentIcon:Fj,CirclePlay:sp,CirclePlayIcon:sp,CirclePlus:zj,CirclePlusIcon:zj,CirclePower:Bj,CirclePowerIcon:Bj,CircleSlash:FV,CircleSlash2:$j,CircleSlash2Icon:$j,CircleSlashIcon:FV,CircleSlashed:$j,CircleSlashedIcon:$j,CircleStop:qj,CircleStopIcon:qj,CircleUser:Vj,CircleUserIcon:Vj,CircleUserRound:Uj,CircleUserRoundIcon:Uj,CircleX:Ql,CircleXIcon:Ql,CircuitBoard:zV,CircuitBoardIcon:zV,Citrus:BV,CitrusIcon:BV,Clapperboard:$V,ClapperboardIcon:$V,Clipboard:KV,ClipboardCheck:wM,ClipboardCheckIcon:wM,ClipboardCopy:qV,ClipboardCopyIcon:qV,ClipboardEdit:Gj,ClipboardEditIcon:Gj,ClipboardIcon:KV,ClipboardList:Nb,ClipboardListIcon:Nb,ClipboardMinus:UV,ClipboardMinusIcon:UV,ClipboardPaste:VV,ClipboardPasteIcon:VV,ClipboardPen:Gj,ClipboardPenIcon:Gj,ClipboardPenLine:Hj,ClipboardPenLineIcon:Hj,ClipboardPlus:HV,ClipboardPlusIcon:HV,ClipboardSignature:Hj,ClipboardSignatureIcon:Hj,ClipboardType:GV,ClipboardTypeIcon:GV,ClipboardX:WV,ClipboardXIcon:WV,Clock:on,Clock1:ZV,Clock10:YV,Clock10Icon:YV,Clock11:XV,Clock11Icon:XV,Clock12:QV,Clock12Icon:QV,Clock1Icon:ZV,Clock2:JV,Clock2Icon:JV,Clock3:eH,Clock3Icon:eH,Clock4:tH,Clock4Icon:tH,Clock5:sH,Clock5Icon:sH,Clock6:rH,Clock6Icon:rH,Clock7:nH,Clock7Icon:nH,Clock8:aH,Clock8Icon:aH,Clock9:iH,Clock9Icon:iH,ClockAlert:oH,ClockAlertIcon:oH,ClockArrowDown:lH,ClockArrowDownIcon:lH,ClockArrowUp:cH,ClockArrowUpIcon:cH,ClockIcon:on,Cloud:NH,CloudAlert:dH,CloudAlertIcon:dH,CloudCog:uH,CloudCogIcon:uH,CloudDownload:Wj,CloudDownloadIcon:Wj,CloudDrizzle:hH,CloudDrizzleIcon:hH,CloudFog:mH,CloudFogIcon:mH,CloudHail:pH,CloudHailIcon:pH,CloudIcon:NH,CloudLightning:fH,CloudLightningIcon:fH,CloudMoon:gH,CloudMoonIcon:gH,CloudMoonRain:xH,CloudMoonRainIcon:xH,CloudOff:yH,CloudOffIcon:yH,CloudRain:_H,CloudRainIcon:_H,CloudRainWind:vH,CloudRainWindIcon:vH,CloudSnow:bH,CloudSnowIcon:bH,CloudSun:jH,CloudSunIcon:jH,CloudSunRain:wH,CloudSunRainIcon:wH,CloudUpload:Kj,CloudUploadIcon:Kj,Cloudy:kH,CloudyIcon:kH,Clover:Bv,CloverIcon:Bv,Club:SH,ClubIcon:SH,Code:Y4,Code2:Zj,Code2Icon:Zj,CodeIcon:Y4,CodeSquare:ck,CodeSquareIcon:ck,CodeXml:Zj,CodeXmlIcon:Zj,Codepen:CH,CodepenIcon:CH,Codesandbox:MH,CodesandboxIcon:MH,Coffee:X4,CoffeeIcon:X4,Cog:TH,CogIcon:TH,Coins:hL,CoinsIcon:hL,Columns:Yj,Columns2:Yj,Columns2Icon:Yj,Columns3:Xj,Columns3Icon:Xj,Columns4:AH,Columns4Icon:AH,ColumnsIcon:Yj,Combine:EH,CombineIcon:EH,Command:PH,CommandIcon:PH,Compass:jM,CompassIcon:jM,Component:IH,ComponentIcon:IH,Computer:LH,ComputerIcon:LH,ConciergeBell:DH,ConciergeBellIcon:DH,Cone:RH,ConeIcon:RH,Construction:OH,ConstructionIcon:OH,Contact:Q4,Contact2:Qj,Contact2Icon:Qj,ContactIcon:Q4,ContactRound:Qj,ContactRoundIcon:Qj,Container:FH,ContainerIcon:FH,Contrast:zH,ContrastIcon:zH,Cookie:BH,CookieIcon:BH,CookingPot:$H,CookingPotIcon:$H,Copy:Wa,CopyCheck:qH,CopyCheckIcon:qH,CopyIcon:Wa,CopyMinus:UH,CopyMinusIcon:UH,CopyPlus:VH,CopyPlusIcon:VH,CopySlash:HH,CopySlashIcon:HH,CopyX:GH,CopyXIcon:GH,Copyleft:WH,CopyleftIcon:WH,Copyright:KH,CopyrightIcon:KH,CornerDownLeft:ZH,CornerDownLeftIcon:ZH,CornerDownRight:YH,CornerDownRightIcon:YH,CornerLeftDown:XH,CornerLeftDownIcon:XH,CornerLeftUp:QH,CornerLeftUpIcon:QH,CornerRightDown:JH,CornerRightDownIcon:JH,CornerRightUp:eG,CornerRightUpIcon:eG,CornerUpLeft:tG,CornerUpLeftIcon:tG,CornerUpRight:sG,CornerUpRightIcon:sG,Cpu:rG,CpuIcon:rG,CreativeCommons:nG,CreativeCommonsIcon:nG,CreditCard:yx,CreditCardIcon:yx,Croissant:aG,CroissantIcon:aG,Crop:iG,CropIcon:iG,Cross:oG,CrossIcon:oG,Crosshair:lG,CrosshairIcon:lG,Crown:Cm,CrownIcon:Cm,Cuboid:cG,CuboidIcon:cG,CupSoda:dG,CupSodaIcon:dG,CurlyBraces:ij,CurlyBracesIcon:ij,Currency:uG,CurrencyIcon:uG,Cylinder:hG,CylinderIcon:hG,Dam:mG,DamIcon:mG,Database:mL,DatabaseBackup:pG,DatabaseBackupIcon:pG,DatabaseIcon:mL,DatabaseZap:fG,DatabaseZapIcon:fG,Delete:xG,DeleteIcon:xG,Dessert:gG,DessertIcon:gG,Diameter:yG,DiameterIcon:yG,Diamond:bG,DiamondIcon:bG,DiamondMinus:vG,DiamondMinusIcon:vG,DiamondPercent:Jj,DiamondPercentIcon:Jj,DiamondPlus:_G,DiamondPlusIcon:_G,Dice1:wG,Dice1Icon:wG,Dice2:jG,Dice2Icon:jG,Dice3:NG,Dice3Icon:NG,Dice4:kG,Dice4Icon:kG,Dice5:SG,Dice5Icon:SG,Dice6:CG,Dice6Icon:CG,Dices:MG,DicesIcon:MG,Diff:TG,DiffIcon:TG,Disc:IG,Disc2:AG,Disc2Icon:AG,Disc3:EG,Disc3Icon:EG,DiscAlbum:PG,DiscAlbumIcon:PG,DiscIcon:IG,Divide:LG,DivideCircle:Pj,DivideCircleIcon:Pj,DivideIcon:LG,DivideSquare:mk,DivideSquareIcon:mk,Dna:RG,DnaIcon:RG,DnaOff:DG,DnaOffIcon:DG,Dock:OG,DockIcon:OG,Dog:FG,DogIcon:FG,DollarSign:_c,DollarSignIcon:_c,Donut:zG,DonutIcon:zG,DoorClosed:BG,DoorClosedIcon:BG,DoorOpen:Kv,DoorOpenIcon:Kv,Dot:$G,DotIcon:$G,DotSquare:pk,DotSquareIcon:pk,Download:Qa,DownloadCloud:Wj,DownloadCloudIcon:Wj,DownloadIcon:Qa,DraftingCompass:qG,DraftingCompassIcon:qG,Drama:UG,DramaIcon:UG,Dribbble:VG,DribbbleIcon:VG,Drill:HG,DrillIcon:HG,Droplet:GG,DropletIcon:GG,Droplets:Ag,DropletsIcon:Ag,Drum:WG,DrumIcon:WG,Drumstick:KG,DrumstickIcon:KG,Dumbbell:ZG,DumbbellIcon:ZG,Ear:XG,EarIcon:XG,EarOff:YG,EarOffIcon:YG,Earth:eN,EarthIcon:eN,EarthLock:QG,EarthLockIcon:QG,Eclipse:JG,EclipseIcon:JG,Edit:Wc,Edit2:Ry,Edit2Icon:Ry,Edit3:Ev,Edit3Icon:Ev,EditIcon:Wc,Egg:NM,EggFried:eW,EggFriedIcon:eW,EggIcon:NM,EggOff:tW,EggOffIcon:tW,Ellipsis:Zp,EllipsisIcon:Zp,EllipsisVertical:ix,EllipsisVerticalIcon:ix,Equal:nW,EqualApproximately:sW,EqualApproximatelyIcon:sW,EqualIcon:nW,EqualNot:rW,EqualNotIcon:rW,EqualSquare:fk,EqualSquareIcon:fk,Eraser:aW,EraserIcon:aW,EthernetPort:iW,EthernetPortIcon:iW,Euro:oW,EuroIcon:oW,Expand:lW,ExpandIcon:lW,ExternalLink:Zr,ExternalLinkIcon:Zr,Eye:Cn,EyeClosed:cW,EyeClosedIcon:cW,EyeIcon:Cn,EyeOff:mp,EyeOffIcon:mp,Facebook:hu,FacebookIcon:hu,Factory:dW,FactoryIcon:dW,Fan:uW,FanIcon:uW,FastForward:hW,FastForwardIcon:hW,Feather:mW,FeatherIcon:mW,Fence:pW,FenceIcon:pW,FerrisWheel:fW,FerrisWheelIcon:fW,Figma:xW,FigmaIcon:xW,File:kM,FileArchive:gW,FileArchiveIcon:gW,FileAudio:vW,FileAudio2:yW,FileAudio2Icon:yW,FileAudioIcon:vW,FileAxis3D:tN,FileAxis3DIcon:tN,FileAxis3d:tN,FileAxis3dIcon:tN,FileBadge:bW,FileBadge2:_W,FileBadge2Icon:_W,FileBadgeIcon:bW,FileBarChart:sN,FileBarChart2:rN,FileBarChart2Icon:rN,FileBarChartIcon:sN,FileBox:wW,FileBoxIcon:wW,FileChartColumn:rN,FileChartColumnIcon:rN,FileChartColumnIncreasing:sN,FileChartColumnIncreasingIcon:sN,FileChartLine:nN,FileChartLineIcon:nN,FileChartPie:aN,FileChartPieIcon:aN,FileCheck:NW,FileCheck2:jW,FileCheck2Icon:jW,FileCheckIcon:NW,FileClock:kW,FileClockIcon:kW,FileCode:CW,FileCode2:SW,FileCode2Icon:SW,FileCodeIcon:CW,FileCog:iN,FileCog2:iN,FileCog2Icon:iN,FileCogIcon:iN,FileDiff:MW,FileDiffIcon:MW,FileDigit:TW,FileDigitIcon:TW,FileDown:J4,FileDownIcon:J4,FileEdit:lN,FileEditIcon:lN,FileHeart:AW,FileHeartIcon:AW,FileIcon:kM,FileImage:kb,FileImageIcon:kb,FileInput:EW,FileInputIcon:EW,FileJson:IW,FileJson2:PW,FileJson2Icon:PW,FileJsonIcon:IW,FileKey:DW,FileKey2:LW,FileKey2Icon:LW,FileKeyIcon:DW,FileLineChart:nN,FileLineChartIcon:nN,FileLock:OW,FileLock2:RW,FileLock2Icon:RW,FileLockIcon:OW,FileMinus:zW,FileMinus2:FW,FileMinus2Icon:FW,FileMinusIcon:zW,FileMusic:BW,FileMusicIcon:BW,FileOutput:$W,FileOutputIcon:$W,FilePen:lN,FilePenIcon:lN,FilePenLine:oN,FilePenLineIcon:oN,FilePieChart:aN,FilePieChartIcon:aN,FilePlus:UW,FilePlus2:qW,FilePlus2Icon:qW,FilePlusIcon:UW,FileQuestion:VW,FileQuestionIcon:VW,FileScan:HW,FileScanIcon:HW,FileSearch:WW,FileSearch2:GW,FileSearch2Icon:GW,FileSearchIcon:WW,FileSignature:oN,FileSignatureIcon:oN,FileSliders:KW,FileSlidersIcon:KW,FileSpreadsheet:Zv,FileSpreadsheetIcon:Zv,FileStack:pL,FileStackIcon:pL,FileSymlink:ZW,FileSymlinkIcon:ZW,FileTerminal:YW,FileTerminalIcon:YW,FileText:yn,FileTextIcon:yn,FileType:QW,FileType2:XW,FileType2Icon:XW,FileTypeIcon:QW,FileUp:JW,FileUpIcon:JW,FileUser:eK,FileUserIcon:eK,FileVideo:sK,FileVideo2:tK,FileVideo2Icon:tK,FileVideoIcon:sK,FileVolume:nK,FileVolume2:rK,FileVolume2Icon:rK,FileVolumeIcon:nK,FileWarning:aK,FileWarningIcon:aK,FileX:oK,FileX2:iK,FileX2Icon:iK,FileXIcon:oK,Files:lK,FilesIcon:lK,Film:Rd,FilmIcon:Rd,Filter:Eg,FilterIcon:Eg,FilterX:cK,FilterXIcon:cK,Fingerprint:dK,FingerprintIcon:dK,FireExtinguisher:uK,FireExtinguisherIcon:uK,Fish:pK,FishIcon:pK,FishOff:hK,FishOffIcon:hK,FishSymbol:mK,FishSymbolIcon:mK,Flag:Yv,FlagIcon:Yv,FlagOff:fK,FlagOffIcon:fK,FlagTriangleLeft:xK,FlagTriangleLeftIcon:xK,FlagTriangleRight:gK,FlagTriangleRightIcon:gK,Flame:rd,FlameIcon:rd,FlameKindling:yK,FlameKindlingIcon:yK,Flashlight:_K,FlashlightIcon:_K,FlashlightOff:vK,FlashlightOffIcon:vK,FlaskConical:Sb,FlaskConicalIcon:Sb,FlaskConicalOff:bK,FlaskConicalOffIcon:bK,FlaskRound:wK,FlaskRoundIcon:wK,FlipHorizontal:fL,FlipHorizontal2:jK,FlipHorizontal2Icon:jK,FlipHorizontalIcon:fL,FlipVertical:kK,FlipVertical2:NK,FlipVertical2Icon:NK,FlipVerticalIcon:kK,Flower:SK,Flower2:kg,Flower2Icon:kg,FlowerIcon:SK,Focus:CK,FocusIcon:CK,FoldHorizontal:MK,FoldHorizontalIcon:MK,FoldVertical:TK,FoldVerticalIcon:TK,Folder:sZ,FolderArchive:AK,FolderArchiveIcon:AK,FolderCheck:EK,FolderCheckIcon:EK,FolderClock:PK,FolderClockIcon:PK,FolderClosed:IK,FolderClosedIcon:IK,FolderCode:LK,FolderCodeIcon:LK,FolderCog:cN,FolderCog2:cN,FolderCog2Icon:cN,FolderCogIcon:cN,FolderDot:DK,FolderDotIcon:DK,FolderDown:RK,FolderDownIcon:RK,FolderEdit:dN,FolderEditIcon:dN,FolderGit:FK,FolderGit2:OK,FolderGit2Icon:OK,FolderGitIcon:FK,FolderHeart:zK,FolderHeartIcon:zK,FolderIcon:sZ,FolderInput:BK,FolderInputIcon:BK,FolderKanban:$K,FolderKanbanIcon:$K,FolderKey:qK,FolderKeyIcon:qK,FolderLock:UK,FolderLockIcon:UK,FolderMinus:VK,FolderMinusIcon:VK,FolderOpen:Mm,FolderOpenDot:HK,FolderOpenDotIcon:HK,FolderOpenIcon:Mm,FolderOutput:GK,FolderOutputIcon:GK,FolderPen:dN,FolderPenIcon:dN,FolderPlus:WK,FolderPlusIcon:WK,FolderRoot:KK,FolderRootIcon:KK,FolderSearch:YK,FolderSearch2:ZK,FolderSearch2Icon:ZK,FolderSearchIcon:YK,FolderSymlink:XK,FolderSymlinkIcon:XK,FolderSync:QK,FolderSyncIcon:QK,FolderTree:JK,FolderTreeIcon:JK,FolderUp:eZ,FolderUpIcon:eZ,FolderX:tZ,FolderXIcon:tZ,Folders:rZ,FoldersIcon:rZ,Footprints:nZ,FootprintsIcon:nZ,ForkKnife:e4,ForkKnifeCrossed:Jk,ForkKnifeCrossedIcon:Jk,ForkKnifeIcon:e4,Forklift:aZ,ForkliftIcon:aZ,FormInput:DN,FormInputIcon:DN,Forward:iZ,ForwardIcon:iZ,Frame:oZ,FrameIcon:oZ,Framer:lZ,FramerIcon:lZ,Frown:cZ,FrownIcon:cZ,Fuel:dZ,FuelIcon:dZ,Fullscreen:uZ,FullscreenIcon:uZ,FunctionSquare:xk,FunctionSquareIcon:xk,GalleryHorizontal:mZ,GalleryHorizontalEnd:hZ,GalleryHorizontalEndIcon:hZ,GalleryHorizontalIcon:mZ,GalleryThumbnails:pZ,GalleryThumbnailsIcon:pZ,GalleryVertical:xZ,GalleryVerticalEnd:fZ,GalleryVerticalEndIcon:fZ,GalleryVerticalIcon:xZ,Gamepad:yZ,Gamepad2:gZ,Gamepad2Icon:gZ,GamepadIcon:yZ,GanttChart:gj,GanttChartIcon:gj,GanttChartSquare:ky,GanttChartSquareIcon:ky,Gauge:vZ,GaugeCircle:Ij,GaugeCircleIcon:Ij,GaugeIcon:vZ,Gavel:_Z,GavelIcon:_Z,Gem:bZ,GemIcon:bZ,Ghost:eS,GhostIcon:eS,Gift:yi,GiftIcon:yi,GitBranch:jZ,GitBranchIcon:jZ,GitBranchPlus:wZ,GitBranchPlusIcon:wZ,GitCommit:uN,GitCommitHorizontal:uN,GitCommitHorizontalIcon:uN,GitCommitIcon:uN,GitCommitVertical:NZ,GitCommitVerticalIcon:NZ,GitCompare:SZ,GitCompareArrows:kZ,GitCompareArrowsIcon:kZ,GitCompareIcon:SZ,GitFork:CZ,GitForkIcon:CZ,GitGraph:MZ,GitGraphIcon:MZ,GitMerge:TZ,GitMergeIcon:TZ,GitPullRequest:DZ,GitPullRequestArrow:AZ,GitPullRequestArrowIcon:AZ,GitPullRequestClosed:EZ,GitPullRequestClosedIcon:EZ,GitPullRequestCreate:IZ,GitPullRequestCreateArrow:PZ,GitPullRequestCreateArrowIcon:PZ,GitPullRequestCreateIcon:IZ,GitPullRequestDraft:LZ,GitPullRequestDraftIcon:LZ,GitPullRequestIcon:DZ,Github:RZ,GithubIcon:RZ,Gitlab:OZ,GitlabIcon:OZ,GlassWater:FZ,GlassWaterIcon:FZ,Glasses:zZ,GlassesIcon:zZ,Globe:nd,Globe2:eN,Globe2Icon:eN,GlobeIcon:nd,GlobeLock:BZ,GlobeLockIcon:BZ,Goal:$Z,GoalIcon:$Z,Grab:qZ,GrabIcon:qZ,GraduationCap:Lh,GraduationCapIcon:Lh,Grape:UZ,GrapeIcon:UZ,Grid:Xf,Grid2X2:mN,Grid2X2Icon:mN,Grid2X2Plus:hN,Grid2X2PlusIcon:hN,Grid2x2:mN,Grid2x2Check:VZ,Grid2x2CheckIcon:VZ,Grid2x2Icon:mN,Grid2x2Plus:hN,Grid2x2PlusIcon:hN,Grid2x2X:HZ,Grid2x2XIcon:HZ,Grid3X3:Xf,Grid3X3Icon:Xf,Grid3x3:Xf,Grid3x3Icon:Xf,GridIcon:Xf,Grip:WZ,GripHorizontal:GZ,GripHorizontalIcon:GZ,GripIcon:WZ,GripVertical:mu,GripVerticalIcon:mu,Group:KZ,GroupIcon:KZ,Guitar:ZZ,GuitarIcon:ZZ,Ham:YZ,HamIcon:YZ,Hammer:XZ,HammerIcon:XZ,Hand:xL,HandCoins:QZ,HandCoinsIcon:QZ,HandHeart:JZ,HandHeartIcon:JZ,HandHelping:pN,HandHelpingIcon:pN,HandIcon:xL,HandMetal:eY,HandMetalIcon:eY,HandPlatter:tY,HandPlatterIcon:tY,Handshake:gL,HandshakeIcon:gL,HardDrive:yL,HardDriveDownload:sY,HardDriveDownloadIcon:sY,HardDriveIcon:yL,HardDriveUpload:rY,HardDriveUploadIcon:rY,HardHat:nY,HardHatIcon:nY,Hash:tS,HashIcon:tS,Haze:aY,HazeIcon:aY,HdmiPort:iY,HdmiPortIcon:iY,Heading:dY,Heading1:SM,Heading1Icon:SM,Heading2:CM,Heading2Icon:CM,Heading3:vL,Heading3Icon:vL,Heading4:oY,Heading4Icon:oY,Heading5:lY,Heading5Icon:lY,Heading6:cY,Heading6Icon:cY,HeadingIcon:dY,HeadphoneOff:uY,HeadphoneOffIcon:uY,Headphones:hY,HeadphonesIcon:hY,Headset:mY,HeadsetIcon:mY,Heart:Xa,HeartCrack:pY,HeartCrackIcon:pY,HeartHandshake:fY,HeartHandshakeIcon:fY,HeartIcon:Xa,HeartOff:xY,HeartOffIcon:xY,HeartPulse:gY,HeartPulseIcon:gY,Heater:yY,HeaterIcon:yY,HelpCircle:Mv,HelpCircleIcon:Mv,HelpingHand:pN,HelpingHandIcon:pN,Hexagon:vY,HexagonIcon:vY,Highlighter:_Y,HighlighterIcon:_Y,History:MM,HistoryIcon:MM,Home:Sn,HomeIcon:Sn,Hop:wY,HopIcon:wY,HopOff:bY,HopOffIcon:bY,Hospital:jY,HospitalIcon:jY,Hotel:NY,HotelIcon:NY,Hourglass:kY,HourglassIcon:kY,House:Sn,HouseIcon:Sn,HousePlug:SY,HousePlugIcon:SY,HousePlus:CY,HousePlusIcon:CY,IceCream:xN,IceCream2:fN,IceCream2Icon:fN,IceCreamBowl:fN,IceCreamBowlIcon:fN,IceCreamCone:xN,IceCreamConeIcon:xN,IceCreamIcon:xN,Icon:nUe,IdCard:MY,IdCardIcon:MY,Image:qo,ImageDown:TY,ImageDownIcon:TY,ImageIcon:qo,ImageMinus:AY,ImageMinusIcon:AY,ImageOff:EY,ImageOffIcon:EY,ImagePlay:PY,ImagePlayIcon:PY,ImagePlus:Xv,ImagePlusIcon:Xv,ImageUp:IY,ImageUpIcon:IY,ImageUpscale:LY,ImageUpscaleIcon:LY,Images:DY,ImagesIcon:DY,Import:RY,ImportIcon:RY,Inbox:OY,InboxIcon:OY,Indent:yN,IndentDecrease:gN,IndentDecreaseIcon:gN,IndentIcon:yN,IndentIncrease:yN,IndentIncreaseIcon:yN,IndianRupee:FY,IndianRupeeIcon:FY,Infinity:zY,InfinityIcon:zY,Info:sS,InfoIcon:sS,Inspect:wk,InspectIcon:wk,InspectionPanel:BY,InspectionPanelIcon:BY,Instagram:pu,InstagramIcon:pu,Italic:rS,ItalicIcon:rS,IterationCcw:$Y,IterationCcwIcon:$Y,IterationCw:qY,IterationCwIcon:qY,JapaneseYen:UY,JapaneseYenIcon:UY,Joystick:VY,JoystickIcon:VY,Kanban:Yy,KanbanIcon:Yy,KanbanSquare:gk,KanbanSquareDashed:dk,KanbanSquareDashedIcon:dk,KanbanSquareIcon:gk,Key:pp,KeyIcon:pp,KeyRound:nS,KeyRoundIcon:nS,KeySquare:HY,KeySquareIcon:HY,Keyboard:KY,KeyboardIcon:KY,KeyboardMusic:GY,KeyboardMusicIcon:GY,KeyboardOff:WY,KeyboardOffIcon:WY,Lamp:eX,LampCeiling:ZY,LampCeilingIcon:ZY,LampDesk:YY,LampDeskIcon:YY,LampFloor:XY,LampFloorIcon:XY,LampIcon:eX,LampWallDown:QY,LampWallDownIcon:QY,LampWallUp:JY,LampWallUpIcon:JY,LandPlot:tX,LandPlotIcon:tX,Landmark:sX,LandmarkIcon:sX,Languages:rX,LanguagesIcon:rX,Laptop:aX,Laptop2:vN,Laptop2Icon:vN,LaptopIcon:aX,LaptopMinimal:vN,LaptopMinimalCheck:nX,LaptopMinimalCheckIcon:nX,LaptopMinimalIcon:vN,Lasso:oX,LassoIcon:oX,LassoSelect:iX,LassoSelectIcon:iX,Laugh:lX,LaughIcon:lX,Layers:_L,Layers2:cX,Layers2Icon:cX,Layers3:dX,Layers3Icon:dX,LayersIcon:_L,Layout:Av,LayoutDashboard:aS,LayoutDashboardIcon:aS,LayoutGrid:fp,LayoutGridIcon:fp,LayoutIcon:Av,LayoutList:uX,LayoutListIcon:uX,LayoutPanelLeft:hX,LayoutPanelLeftIcon:hX,LayoutPanelTop:mX,LayoutPanelTopIcon:mX,LayoutTemplate:iS,LayoutTemplateIcon:iS,Leaf:pX,LeafIcon:pX,LeafyGreen:fX,LeafyGreenIcon:fX,Lectern:xX,LecternIcon:xX,LetterText:gX,LetterTextIcon:gX,Library:oS,LibraryBig:yX,LibraryBigIcon:yX,LibraryIcon:oS,LibrarySquare:yk,LibrarySquareIcon:yk,LifeBuoy:TM,LifeBuoyIcon:TM,Ligature:vX,LigatureIcon:vX,Lightbulb:Cb,LightbulbIcon:Cb,LightbulbOff:_X,LightbulbOffIcon:_X,LineChart:pj,LineChartIcon:pj,Link:go,Link2:Do,Link2Icon:Do,Link2Off:bX,Link2OffIcon:bX,LinkIcon:go,Linkedin:xp,LinkedinIcon:xp,List:Dh,ListCheck:wX,ListCheckIcon:wX,ListChecks:jX,ListChecksIcon:jX,ListCollapse:NX,ListCollapseIcon:NX,ListEnd:kX,ListEndIcon:kX,ListFilter:SX,ListFilterIcon:SX,ListIcon:Dh,ListMinus:CX,ListMinusIcon:CX,ListMusic:MX,ListMusicIcon:MX,ListOrdered:Xy,ListOrderedIcon:Xy,ListPlus:TX,ListPlusIcon:TX,ListRestart:AX,ListRestartIcon:AX,ListStart:EX,ListStartIcon:EX,ListTodo:PX,ListTodoIcon:PX,ListTree:IX,ListTreeIcon:IX,ListVideo:LX,ListVideoIcon:LX,ListX:DX,ListXIcon:DX,Loader:OX,Loader2:us,Loader2Icon:us,LoaderCircle:us,LoaderCircleIcon:us,LoaderIcon:OX,LoaderPinwheel:RX,LoaderPinwheelIcon:RX,Locate:AM,LocateFixed:FX,LocateFixedIcon:FX,LocateIcon:AM,LocateOff:zX,LocateOffIcon:zX,Lock:vd,LockIcon:vd,LockKeyhole:BX,LockKeyholeIcon:BX,LockKeyholeOpen:_N,LockKeyholeOpenIcon:_N,LockOpen:bN,LockOpenIcon:bN,LogIn:lS,LogInIcon:lS,LogOut:EM,LogOutIcon:EM,Logs:$X,LogsIcon:$X,Lollipop:qX,LollipopIcon:qX,LucideAArrowDown:Z9,LucideAArrowUp:Y9,LucideALargeSmall:X9,LucideAccessibility:Q9,LucideActivity:lh,LucideActivitySquare:UN,LucideAirVent:J9,LucideAirplay:eB,LucideAlarmCheck:G2,LucideAlarmClock:sB,LucideAlarmClockCheck:G2,LucideAlarmClockMinus:W2,LucideAlarmClockOff:tB,LucideAlarmClockPlus:K2,LucideAlarmMinus:W2,LucideAlarmPlus:K2,LucideAlarmSmoke:rB,LucideAlbum:nB,LucideAlertCircle:ro,LucideAlertOctagon:Tv,LucideAlertTriangle:Dc,LucideAlignCenter:V4,LucideAlignCenterHorizontal:aB,LucideAlignCenterVertical:iB,LucideAlignEndHorizontal:oB,LucideAlignEndVertical:lB,LucideAlignHorizontalDistributeCenter:cB,LucideAlignHorizontalDistributeEnd:dB,LucideAlignHorizontalDistributeStart:uB,LucideAlignHorizontalJustifyCenter:hB,LucideAlignHorizontalJustifyEnd:mB,LucideAlignHorizontalJustifyStart:pB,LucideAlignHorizontalSpaceAround:fB,LucideAlignHorizontalSpaceBetween:xB,LucideAlignJustify:gB,LucideAlignLeft:H4,LucideAlignRight:G4,LucideAlignStartHorizontal:yB,LucideAlignStartVertical:vB,LucideAlignVerticalDistributeCenter:_B,LucideAlignVerticalDistributeEnd:bB,LucideAlignVerticalDistributeStart:wB,LucideAlignVerticalJustifyCenter:jB,LucideAlignVerticalJustifyEnd:NB,LucideAlignVerticalJustifyStart:kB,LucideAlignVerticalSpaceAround:SB,LucideAlignVerticalSpaceBetween:CB,LucideAmbulance:MB,LucideAmpersand:TB,LucideAmpersands:AB,LucideAmphora:EB,LucideAnchor:PB,LucideAngry:IB,LucideAnnoyed:LB,LucideAntenna:DB,LucideAnvil:RB,LucideAperture:OB,LucideAppWindow:sL,LucideAppWindowMac:FB,LucideApple:zB,LucideArchive:yM,LucideArchiveRestore:rL,LucideArchiveX:BB,LucideAreaChart:lj,LucideArmchair:$B,LucideArrowBigDown:UB,LucideArrowBigDownDash:qB,LucideArrowBigLeft:HB,LucideArrowBigLeftDash:VB,LucideArrowBigRight:WB,LucideArrowBigRightDash:GB,LucideArrowBigUp:ZB,LucideArrowBigUpDash:KB,LucideArrowDown:Ih,LucideArrowDown01:YB,LucideArrowDown10:XB,LucideArrowDownAZ:Z2,LucideArrowDownAz:Z2,LucideArrowDownCircle:_j,LucideArrowDownFromLine:QB,LucideArrowDownLeft:JB,LucideArrowDownLeftFromCircle:wj,LucideArrowDownLeftFromSquare:KN,LucideArrowDownLeftSquare:VN,LucideArrowDownNarrowWide:e$,LucideArrowDownRight:nL,LucideArrowDownRightFromCircle:jj,LucideArrowDownRightFromSquare:ZN,LucideArrowDownRightSquare:HN,LucideArrowDownSquare:GN,LucideArrowDownToDot:t$,LucideArrowDownToLine:s$,LucideArrowDownUp:r$,LucideArrowDownWideNarrow:Y2,LucideArrowDownZA:X2,LucideArrowDownZa:X2,LucideArrowLeft:Oa,LucideArrowLeftCircle:bj,LucideArrowLeftFromLine:n$,LucideArrowLeftRight:a$,LucideArrowLeftSquare:WN,LucideArrowLeftToLine:i$,LucideArrowRight:Ga,LucideArrowRightCircle:Sj,LucideArrowRightFromLine:o$,LucideArrowRightLeft:Gv,LucideArrowRightSquare:QN,LucideArrowRightToLine:l$,LucideArrowUp:uu,LucideArrowUp01:c$,LucideArrowUp10:d$,LucideArrowUpAZ:Q2,LucideArrowUpAz:Q2,LucideArrowUpCircle:Cj,LucideArrowUpDown:td,LucideArrowUpFromDot:u$,LucideArrowUpFromLine:h$,LucideArrowUpLeft:m$,LucideArrowUpLeftFromCircle:Nj,LucideArrowUpLeftFromSquare:YN,LucideArrowUpLeftSquare:JN,LucideArrowUpNarrowWide:J2,LucideArrowUpRight:aL,LucideArrowUpRightFromCircle:kj,LucideArrowUpRightFromSquare:XN,LucideArrowUpRightSquare:ek,LucideArrowUpSquare:tk,LucideArrowUpToLine:p$,LucideArrowUpWideNarrow:f$,LucideArrowUpZA:ej,LucideArrowUpZa:ej,LucideArrowsUpFromLine:x$,LucideAsterisk:g$,LucideAsteriskSquare:sk,LucideAtSign:y$,LucideAtom:v$,LucideAudioLines:_$,LucideAudioWaveform:b$,LucideAward:rc,LucideAxe:w$,LucideAxis3D:tj,LucideAxis3d:tj,LucideBaby:j$,LucideBackpack:N$,LucideBadge:B$,LucideBadgeAlert:k$,LucideBadgeCent:S$,LucideBadgeCheck:sj,LucideBadgeDollarSign:C$,LucideBadgeEuro:M$,LucideBadgeHelp:T$,LucideBadgeIndianRupee:A$,LucideBadgeInfo:E$,LucideBadgeJapaneseYen:P$,LucideBadgeMinus:I$,LucideBadgePercent:L$,LucideBadgePlus:D$,LucideBadgePoundSterling:R$,LucideBadgeRussianRuble:O$,LucideBadgeSwissFranc:F$,LucideBadgeX:z$,LucideBaggageClaim:$$,LucideBan:iL,LucideBanana:q$,LucideBandage:U$,LucideBanknote:V$,LucideBarChart:fj,LucideBarChart2:xj,LucideBarChart3:so,LucideBarChart4:mj,LucideBarChartBig:hj,LucideBarChartHorizontal:dj,LucideBarChartHorizontalBig:cj,LucideBarcode:H$,LucideBaseline:G$,LucideBath:nf,LucideBattery:Q$,LucideBatteryCharging:W$,LucideBatteryFull:K$,LucideBatteryLow:Z$,LucideBatteryMedium:Y$,LucideBatteryWarning:X$,LucideBeaker:J$,LucideBean:tq,LucideBeanOff:eq,LucideBed:Zy,LucideBedDouble:W4,LucideBedSingle:sq,LucideBeef:rq,LucideBeer:aq,LucideBeerOff:nq,LucideBell:Sm,LucideBellDot:iq,LucideBellElectric:oq,LucideBellMinus:lq,LucideBellOff:Wv,LucideBellPlus:cq,LucideBellRing:dq,LucideBetweenHorizonalEnd:rj,LucideBetweenHorizonalStart:nj,LucideBetweenHorizontalEnd:rj,LucideBetweenHorizontalStart:nj,LucideBetweenVerticalEnd:uq,LucideBetweenVerticalStart:hq,LucideBicepsFlexed:mq,LucideBike:pq,LucideBinary:fq,LucideBinoculars:xq,LucideBiohazard:gq,LucideBird:yq,LucideBitcoin:vq,LucideBlend:_q,LucideBlinds:bq,LucideBlocks:wq,LucideBluetooth:Sq,LucideBluetoothConnected:jq,LucideBluetoothOff:Nq,LucideBluetoothSearching:kq,LucideBold:K4,LucideBolt:Cq,LucideBomb:Mq,LucideBone:Tq,LucideBook:Xq,LucideBookA:Aq,LucideBookAudio:Eq,LucideBookCheck:Pq,LucideBookCopy:Iq,LucideBookDashed:aj,LucideBookDown:Lq,LucideBookHeadphones:Dq,LucideBookHeart:Rq,LucideBookImage:Oq,LucideBookKey:Fq,LucideBookLock:zq,LucideBookMarked:Bq,LucideBookMinus:$q,LucideBookOpen:ch,LucideBookOpenCheck:qq,LucideBookOpenText:Uq,LucideBookPlus:Vq,LucideBookTemplate:aj,LucideBookText:Hq,LucideBookType:Gq,LucideBookUp:Kq,LucideBookUp2:Wq,LucideBookUser:Zq,LucideBookX:Yq,LucideBookmark:fx,LucideBookmarkCheck:Qq,LucideBookmarkMinus:Jq,LucideBookmarkPlus:oL,LucideBookmarkX:eU,LucideBoomBox:tU,LucideBot:vM,LucideBotMessageSquare:sU,LucideBotOff:rU,LucideBox:nU,LucideBoxSelect:hk,LucideBoxes:aU,LucideBraces:ij,LucideBrackets:iU,LucideBrain:lL,LucideBrainCircuit:oU,LucideBrainCog:lU,LucideBrickWall:cU,LucideBriefcase:dh,LucideBriefcaseBusiness:dU,LucideBriefcaseConveyorBelt:uU,LucideBriefcaseMedical:hU,LucideBringToFront:mU,LucideBrush:pU,LucideBug:gU,LucideBugOff:fU,LucideBugPlay:xU,LucideBuilding:Z4,LucideBuilding2:pa,LucideBus:vU,LucideBusFront:yU,LucideCable:bU,LucideCableCar:_U,LucideCake:Fu,LucideCakeSlice:wU,LucideCalculator:_M,LucideCalendar:ln,LucideCalendar1:jU,LucideCalendarArrowDown:NU,LucideCalendarArrowUp:kU,LucideCalendarCheck:cL,LucideCalendarCheck2:SU,LucideCalendarClock:bM,LucideCalendarCog:CU,LucideCalendarDays:yd,LucideCalendarFold:MU,LucideCalendarHeart:TU,LucideCalendarMinus:EU,LucideCalendarMinus2:AU,LucideCalendarOff:dL,LucideCalendarPlus:jb,LucideCalendarPlus2:PU,LucideCalendarRange:IU,LucideCalendarSearch:LU,LucideCalendarSync:DU,LucideCalendarX:OU,LucideCalendarX2:RU,LucideCamera:xx,LucideCameraOff:FU,LucideCandlestickChart:uj,LucideCandy:$U,LucideCandyCane:zU,LucideCandyOff:BU,LucideCannabis:qU,LucideCaptions:oj,LucideCaptionsOff:UU,LucideCar:GU,LucideCarFront:VU,LucideCarTaxiFront:HU,LucideCaravan:WU,LucideCarrot:KU,LucideCaseLower:ZU,LucideCaseSensitive:YU,LucideCaseUpper:XU,LucideCassetteTape:QU,LucideCast:JU,LucideCastle:eV,LucideCat:tV,LucideCctv:sV,LucideChartArea:lj,LucideChartBar:dj,LucideChartBarBig:cj,LucideChartBarDecreasing:rV,LucideChartBarIncreasing:nV,LucideChartBarStacked:aV,LucideChartCandlestick:uj,LucideChartColumn:so,LucideChartColumnBig:hj,LucideChartColumnDecreasing:iV,LucideChartColumnIncreasing:mj,LucideChartColumnStacked:oV,LucideChartGantt:lV,LucideChartLine:pj,LucideChartNetwork:cV,LucideChartNoAxesColumn:xj,LucideChartNoAxesColumnDecreasing:dV,LucideChartNoAxesColumnIncreasing:fj,LucideChartNoAxesCombined:uV,LucideChartNoAxesGantt:gj,LucideChartPie:yj,LucideChartScatter:vj,LucideChartSpline:hV,LucideCheck:Zn,LucideCheckCheck:uL,LucideCheckCircle:ti,LucideCheckCircle2:Hn,LucideCheckSquare:Pv,LucideCheckSquare2:nk,LucideChefHat:mV,LucideCherry:pV,LucideChevronDown:Fi,LucideChevronDownCircle:Mj,LucideChevronDownSquare:ak,LucideChevronFirst:fV,LucideChevronLast:xV,LucideChevronLeft:Xo,LucideChevronLeftCircle:Tj,LucideChevronLeftSquare:ik,LucideChevronRight:xa,LucideChevronRightCircle:Aj,LucideChevronRightSquare:ok,LucideChevronUp:af,LucideChevronUpCircle:Ej,LucideChevronUpSquare:lk,LucideChevronsDown:yV,LucideChevronsDownUp:gV,LucideChevronsLeft:bV,LucideChevronsLeftRight:_V,LucideChevronsLeftRightEllipsis:vV,LucideChevronsRight:jV,LucideChevronsRightLeft:wV,LucideChevronsUp:NV,LucideChevronsUpDown:gx,LucideChrome:kV,LucideChurch:SV,LucideCigarette:MV,LucideCigaretteOff:CV,LucideCircle:sd,LucideCircleAlert:ro,LucideCircleArrowDown:_j,LucideCircleArrowLeft:bj,LucideCircleArrowOutDownLeft:wj,LucideCircleArrowOutDownRight:jj,LucideCircleArrowOutUpLeft:Nj,LucideCircleArrowOutUpRight:kj,LucideCircleArrowRight:Sj,LucideCircleArrowUp:Cj,LucideCircleCheck:Hn,LucideCircleCheckBig:ti,LucideCircleChevronDown:Mj,LucideCircleChevronLeft:Tj,LucideCircleChevronRight:Aj,LucideCircleChevronUp:Ej,LucideCircleDashed:TV,LucideCircleDivide:Pj,LucideCircleDollarSign:AV,LucideCircleDot:PV,LucideCircleDotDashed:EV,LucideCircleEllipsis:IV,LucideCircleEqual:LV,LucideCircleFadingArrowUp:DV,LucideCircleFadingPlus:RV,LucideCircleGauge:Ij,LucideCircleHelp:Mv,LucideCircleMinus:Lj,LucideCircleOff:OV,LucideCircleParking:Rj,LucideCircleParkingOff:Dj,LucideCirclePause:Oj,LucideCirclePercent:Fj,LucideCirclePlay:sp,LucideCirclePlus:zj,LucideCirclePower:Bj,LucideCircleSlash:FV,LucideCircleSlash2:$j,LucideCircleSlashed:$j,LucideCircleStop:qj,LucideCircleUser:Vj,LucideCircleUserRound:Uj,LucideCircleX:Ql,LucideCircuitBoard:zV,LucideCitrus:BV,LucideClapperboard:$V,LucideClipboard:KV,LucideClipboardCheck:wM,LucideClipboardCopy:qV,LucideClipboardEdit:Gj,LucideClipboardList:Nb,LucideClipboardMinus:UV,LucideClipboardPaste:VV,LucideClipboardPen:Gj,LucideClipboardPenLine:Hj,LucideClipboardPlus:HV,LucideClipboardSignature:Hj,LucideClipboardType:GV,LucideClipboardX:WV,LucideClock:on,LucideClock1:ZV,LucideClock10:YV,LucideClock11:XV,LucideClock12:QV,LucideClock2:JV,LucideClock3:eH,LucideClock4:tH,LucideClock5:sH,LucideClock6:rH,LucideClock7:nH,LucideClock8:aH,LucideClock9:iH,LucideClockAlert:oH,LucideClockArrowDown:lH,LucideClockArrowUp:cH,LucideCloud:NH,LucideCloudAlert:dH,LucideCloudCog:uH,LucideCloudDownload:Wj,LucideCloudDrizzle:hH,LucideCloudFog:mH,LucideCloudHail:pH,LucideCloudLightning:fH,LucideCloudMoon:gH,LucideCloudMoonRain:xH,LucideCloudOff:yH,LucideCloudRain:_H,LucideCloudRainWind:vH,LucideCloudSnow:bH,LucideCloudSun:jH,LucideCloudSunRain:wH,LucideCloudUpload:Kj,LucideCloudy:kH,LucideClover:Bv,LucideClub:SH,LucideCode:Y4,LucideCode2:Zj,LucideCodeSquare:ck,LucideCodeXml:Zj,LucideCodepen:CH,LucideCodesandbox:MH,LucideCoffee:X4,LucideCog:TH,LucideCoins:hL,LucideColumns:Yj,LucideColumns2:Yj,LucideColumns3:Xj,LucideColumns4:AH,LucideCombine:EH,LucideCommand:PH,LucideCompass:jM,LucideComponent:IH,LucideComputer:LH,LucideConciergeBell:DH,LucideCone:RH,LucideConstruction:OH,LucideContact:Q4,LucideContact2:Qj,LucideContactRound:Qj,LucideContainer:FH,LucideContrast:zH,LucideCookie:BH,LucideCookingPot:$H,LucideCopy:Wa,LucideCopyCheck:qH,LucideCopyMinus:UH,LucideCopyPlus:VH,LucideCopySlash:HH,LucideCopyX:GH,LucideCopyleft:WH,LucideCopyright:KH,LucideCornerDownLeft:ZH,LucideCornerDownRight:YH,LucideCornerLeftDown:XH,LucideCornerLeftUp:QH,LucideCornerRightDown:JH,LucideCornerRightUp:eG,LucideCornerUpLeft:tG,LucideCornerUpRight:sG,LucideCpu:rG,LucideCreativeCommons:nG,LucideCreditCard:yx,LucideCroissant:aG,LucideCrop:iG,LucideCross:oG,LucideCrosshair:lG,LucideCrown:Cm,LucideCuboid:cG,LucideCupSoda:dG,LucideCurlyBraces:ij,LucideCurrency:uG,LucideCylinder:hG,LucideDam:mG,LucideDatabase:mL,LucideDatabaseBackup:pG,LucideDatabaseZap:fG,LucideDelete:xG,LucideDessert:gG,LucideDiameter:yG,LucideDiamond:bG,LucideDiamondMinus:vG,LucideDiamondPercent:Jj,LucideDiamondPlus:_G,LucideDice1:wG,LucideDice2:jG,LucideDice3:NG,LucideDice4:kG,LucideDice5:SG,LucideDice6:CG,LucideDices:MG,LucideDiff:TG,LucideDisc:IG,LucideDisc2:AG,LucideDisc3:EG,LucideDiscAlbum:PG,LucideDivide:LG,LucideDivideCircle:Pj,LucideDivideSquare:mk,LucideDna:RG,LucideDnaOff:DG,LucideDock:OG,LucideDog:FG,LucideDollarSign:_c,LucideDonut:zG,LucideDoorClosed:BG,LucideDoorOpen:Kv,LucideDot:$G,LucideDotSquare:pk,LucideDownload:Qa,LucideDownloadCloud:Wj,LucideDraftingCompass:qG,LucideDrama:UG,LucideDribbble:VG,LucideDrill:HG,LucideDroplet:GG,LucideDroplets:Ag,LucideDrum:WG,LucideDrumstick:KG,LucideDumbbell:ZG,LucideEar:XG,LucideEarOff:YG,LucideEarth:eN,LucideEarthLock:QG,LucideEclipse:JG,LucideEdit:Wc,LucideEdit2:Ry,LucideEdit3:Ev,LucideEgg:NM,LucideEggFried:eW,LucideEggOff:tW,LucideEllipsis:Zp,LucideEllipsisVertical:ix,LucideEqual:nW,LucideEqualApproximately:sW,LucideEqualNot:rW,LucideEqualSquare:fk,LucideEraser:aW,LucideEthernetPort:iW,LucideEuro:oW,LucideExpand:lW,LucideExternalLink:Zr,LucideEye:Cn,LucideEyeClosed:cW,LucideEyeOff:mp,LucideFacebook:hu,LucideFactory:dW,LucideFan:uW,LucideFastForward:hW,LucideFeather:mW,LucideFence:pW,LucideFerrisWheel:fW,LucideFigma:xW,LucideFile:kM,LucideFileArchive:gW,LucideFileAudio:vW,LucideFileAudio2:yW,LucideFileAxis3D:tN,LucideFileAxis3d:tN,LucideFileBadge:bW,LucideFileBadge2:_W,LucideFileBarChart:sN,LucideFileBarChart2:rN,LucideFileBox:wW,LucideFileChartColumn:rN,LucideFileChartColumnIncreasing:sN,LucideFileChartLine:nN,LucideFileChartPie:aN,LucideFileCheck:NW,LucideFileCheck2:jW,LucideFileClock:kW,LucideFileCode:CW,LucideFileCode2:SW,LucideFileCog:iN,LucideFileCog2:iN,LucideFileDiff:MW,LucideFileDigit:TW,LucideFileDown:J4,LucideFileEdit:lN,LucideFileHeart:AW,LucideFileImage:kb,LucideFileInput:EW,LucideFileJson:IW,LucideFileJson2:PW,LucideFileKey:DW,LucideFileKey2:LW,LucideFileLineChart:nN,LucideFileLock:OW,LucideFileLock2:RW,LucideFileMinus:zW,LucideFileMinus2:FW,LucideFileMusic:BW,LucideFileOutput:$W,LucideFilePen:lN,LucideFilePenLine:oN,LucideFilePieChart:aN,LucideFilePlus:UW,LucideFilePlus2:qW,LucideFileQuestion:VW,LucideFileScan:HW,LucideFileSearch:WW,LucideFileSearch2:GW,LucideFileSignature:oN,LucideFileSliders:KW,LucideFileSpreadsheet:Zv,LucideFileStack:pL,LucideFileSymlink:ZW,LucideFileTerminal:YW,LucideFileText:yn,LucideFileType:QW,LucideFileType2:XW,LucideFileUp:JW,LucideFileUser:eK,LucideFileVideo:sK,LucideFileVideo2:tK,LucideFileVolume:nK,LucideFileVolume2:rK,LucideFileWarning:aK,LucideFileX:oK,LucideFileX2:iK,LucideFiles:lK,LucideFilm:Rd,LucideFilter:Eg,LucideFilterX:cK,LucideFingerprint:dK,LucideFireExtinguisher:uK,LucideFish:pK,LucideFishOff:hK,LucideFishSymbol:mK,LucideFlag:Yv,LucideFlagOff:fK,LucideFlagTriangleLeft:xK,LucideFlagTriangleRight:gK,LucideFlame:rd,LucideFlameKindling:yK,LucideFlashlight:_K,LucideFlashlightOff:vK,LucideFlaskConical:Sb,LucideFlaskConicalOff:bK,LucideFlaskRound:wK,LucideFlipHorizontal:fL,LucideFlipHorizontal2:jK,LucideFlipVertical:kK,LucideFlipVertical2:NK,LucideFlower:SK,LucideFlower2:kg,LucideFocus:CK,LucideFoldHorizontal:MK,LucideFoldVertical:TK,LucideFolder:sZ,LucideFolderArchive:AK,LucideFolderCheck:EK,LucideFolderClock:PK,LucideFolderClosed:IK,LucideFolderCode:LK,LucideFolderCog:cN,LucideFolderCog2:cN,LucideFolderDot:DK,LucideFolderDown:RK,LucideFolderEdit:dN,LucideFolderGit:FK,LucideFolderGit2:OK,LucideFolderHeart:zK,LucideFolderInput:BK,LucideFolderKanban:$K,LucideFolderKey:qK,LucideFolderLock:UK,LucideFolderMinus:VK,LucideFolderOpen:Mm,LucideFolderOpenDot:HK,LucideFolderOutput:GK,LucideFolderPen:dN,LucideFolderPlus:WK,LucideFolderRoot:KK,LucideFolderSearch:YK,LucideFolderSearch2:ZK,LucideFolderSymlink:XK,LucideFolderSync:QK,LucideFolderTree:JK,LucideFolderUp:eZ,LucideFolderX:tZ,LucideFolders:rZ,LucideFootprints:nZ,LucideForkKnife:e4,LucideForkKnifeCrossed:Jk,LucideForklift:aZ,LucideFormInput:DN,LucideForward:iZ,LucideFrame:oZ,LucideFramer:lZ,LucideFrown:cZ,LucideFuel:dZ,LucideFullscreen:uZ,LucideFunctionSquare:xk,LucideGalleryHorizontal:mZ,LucideGalleryHorizontalEnd:hZ,LucideGalleryThumbnails:pZ,LucideGalleryVertical:xZ,LucideGalleryVerticalEnd:fZ,LucideGamepad:yZ,LucideGamepad2:gZ,LucideGanttChart:gj,LucideGanttChartSquare:ky,LucideGauge:vZ,LucideGaugeCircle:Ij,LucideGavel:_Z,LucideGem:bZ,LucideGhost:eS,LucideGift:yi,LucideGitBranch:jZ,LucideGitBranchPlus:wZ,LucideGitCommit:uN,LucideGitCommitHorizontal:uN,LucideGitCommitVertical:NZ,LucideGitCompare:SZ,LucideGitCompareArrows:kZ,LucideGitFork:CZ,LucideGitGraph:MZ,LucideGitMerge:TZ,LucideGitPullRequest:DZ,LucideGitPullRequestArrow:AZ,LucideGitPullRequestClosed:EZ,LucideGitPullRequestCreate:IZ,LucideGitPullRequestCreateArrow:PZ,LucideGitPullRequestDraft:LZ,LucideGithub:RZ,LucideGitlab:OZ,LucideGlassWater:FZ,LucideGlasses:zZ,LucideGlobe:nd,LucideGlobe2:eN,LucideGlobeLock:BZ,LucideGoal:$Z,LucideGrab:qZ,LucideGraduationCap:Lh,LucideGrape:UZ,LucideGrid:Xf,LucideGrid2X2:mN,LucideGrid2X2Plus:hN,LucideGrid2x2:mN,LucideGrid2x2Check:VZ,LucideGrid2x2Plus:hN,LucideGrid2x2X:HZ,LucideGrid3X3:Xf,LucideGrid3x3:Xf,LucideGrip:WZ,LucideGripHorizontal:GZ,LucideGripVertical:mu,LucideGroup:KZ,LucideGuitar:ZZ,LucideHam:YZ,LucideHammer:XZ,LucideHand:xL,LucideHandCoins:QZ,LucideHandHeart:JZ,LucideHandHelping:pN,LucideHandMetal:eY,LucideHandPlatter:tY,LucideHandshake:gL,LucideHardDrive:yL,LucideHardDriveDownload:sY,LucideHardDriveUpload:rY,LucideHardHat:nY,LucideHash:tS,LucideHaze:aY,LucideHdmiPort:iY,LucideHeading:dY,LucideHeading1:SM,LucideHeading2:CM,LucideHeading3:vL,LucideHeading4:oY,LucideHeading5:lY,LucideHeading6:cY,LucideHeadphoneOff:uY,LucideHeadphones:hY,LucideHeadset:mY,LucideHeart:Xa,LucideHeartCrack:pY,LucideHeartHandshake:fY,LucideHeartOff:xY,LucideHeartPulse:gY,LucideHeater:yY,LucideHelpCircle:Mv,LucideHelpingHand:pN,LucideHexagon:vY,LucideHighlighter:_Y,LucideHistory:MM,LucideHome:Sn,LucideHop:wY,LucideHopOff:bY,LucideHospital:jY,LucideHotel:NY,LucideHourglass:kY,LucideHouse:Sn,LucideHousePlug:SY,LucideHousePlus:CY,LucideIceCream:xN,LucideIceCream2:fN,LucideIceCreamBowl:fN,LucideIceCreamCone:xN,LucideIdCard:MY,LucideImage:qo,LucideImageDown:TY,LucideImageMinus:AY,LucideImageOff:EY,LucideImagePlay:PY,LucideImagePlus:Xv,LucideImageUp:IY,LucideImageUpscale:LY,LucideImages:DY,LucideImport:RY,LucideInbox:OY,LucideIndent:yN,LucideIndentDecrease:gN,LucideIndentIncrease:yN,LucideIndianRupee:FY,LucideInfinity:zY,LucideInfo:sS,LucideInspect:wk,LucideInspectionPanel:BY,LucideInstagram:pu,LucideItalic:rS,LucideIterationCcw:$Y,LucideIterationCw:qY,LucideJapaneseYen:UY,LucideJoystick:VY,LucideKanban:Yy,LucideKanbanSquare:gk,LucideKanbanSquareDashed:dk,LucideKey:pp,LucideKeyRound:nS,LucideKeySquare:HY,LucideKeyboard:KY,LucideKeyboardMusic:GY,LucideKeyboardOff:WY,LucideLamp:eX,LucideLampCeiling:ZY,LucideLampDesk:YY,LucideLampFloor:XY,LucideLampWallDown:QY,LucideLampWallUp:JY,LucideLandPlot:tX,LucideLandmark:sX,LucideLanguages:rX,LucideLaptop:aX,LucideLaptop2:vN,LucideLaptopMinimal:vN,LucideLaptopMinimalCheck:nX,LucideLasso:oX,LucideLassoSelect:iX,LucideLaugh:lX,LucideLayers:_L,LucideLayers2:cX,LucideLayers3:dX,LucideLayout:Av,LucideLayoutDashboard:aS,LucideLayoutGrid:fp,LucideLayoutList:uX,LucideLayoutPanelLeft:hX,LucideLayoutPanelTop:mX,LucideLayoutTemplate:iS,LucideLeaf:pX,LucideLeafyGreen:fX,LucideLectern:xX,LucideLetterText:gX,LucideLibrary:oS,LucideLibraryBig:yX,LucideLibrarySquare:yk,LucideLifeBuoy:TM,LucideLigature:vX,LucideLightbulb:Cb,LucideLightbulbOff:_X,LucideLineChart:pj,LucideLink:go,LucideLink2:Do,LucideLink2Off:bX,LucideLinkedin:xp,LucideList:Dh,LucideListCheck:wX,LucideListChecks:jX,LucideListCollapse:NX,LucideListEnd:kX,LucideListFilter:SX,LucideListMinus:CX,LucideListMusic:MX,LucideListOrdered:Xy,LucideListPlus:TX,LucideListRestart:AX,LucideListStart:EX,LucideListTodo:PX,LucideListTree:IX,LucideListVideo:LX,LucideListX:DX,LucideLoader:OX,LucideLoader2:us,LucideLoaderCircle:us,LucideLoaderPinwheel:RX,LucideLocate:AM,LucideLocateFixed:FX,LucideLocateOff:zX,LucideLock:vd,LucideLockKeyhole:BX,LucideLockKeyholeOpen:_N,LucideLockOpen:bN,LucideLogIn:lS,LucideLogOut:EM,LucideLogs:$X,LucideLollipop:qX,LucideLuggage:UX,LucideMSquare:vk,LucideMagnet:VX,LucideMail:tr,LucideMailCheck:HX,LucideMailMinus:GX,LucideMailOpen:WX,LucideMailPlus:bL,LucideMailQuestion:KX,LucideMailSearch:ZX,LucideMailWarning:YX,LucideMailX:wL,LucideMailbox:XX,LucideMails:QX,LucideMap:cS,LucideMapPin:Ia,LucideMapPinCheck:eQ,LucideMapPinCheckInside:JX,LucideMapPinHouse:tQ,LucideMapPinMinus:rQ,LucideMapPinMinusInside:sQ,LucideMapPinOff:nQ,LucideMapPinPlus:iQ,LucideMapPinPlusInside:aQ,LucideMapPinX:lQ,LucideMapPinXInside:oQ,LucideMapPinned:cQ,LucideMartini:dQ,LucideMaximize:jL,LucideMaximize2:uQ,LucideMedal:Qv,LucideMegaphone:uh,LucideMegaphoneOff:hQ,LucideMeh:mQ,LucideMemoryStick:pQ,LucideMenu:dS,LucideMenuSquare:_k,LucideMerge:fQ,LucideMessageCircle:Ol,LucideMessageCircleCode:xQ,LucideMessageCircleDashed:gQ,LucideMessageCircleHeart:PM,LucideMessageCircleMore:yQ,LucideMessageCircleOff:vQ,LucideMessageCirclePlus:_Q,LucideMessageCircleQuestion:NL,LucideMessageCircleReply:bQ,LucideMessageCircleWarning:wQ,LucideMessageCircleX:jQ,LucideMessageSquare:Si,LucideMessageSquareCode:NQ,LucideMessageSquareDashed:kQ,LucideMessageSquareDiff:SQ,LucideMessageSquareDot:CQ,LucideMessageSquareHeart:MQ,LucideMessageSquareLock:TQ,LucideMessageSquareMore:kL,LucideMessageSquareOff:AQ,LucideMessageSquarePlus:IM,LucideMessageSquareQuote:SL,LucideMessageSquareReply:EQ,LucideMessageSquareShare:PQ,LucideMessageSquareText:IQ,LucideMessageSquareWarning:LQ,LucideMessageSquareX:DQ,LucideMessagesSquare:RQ,LucideMic:CL,LucideMic2:wN,LucideMicOff:OQ,LucideMicVocal:wN,LucideMicrochip:FQ,LucideMicroscope:zQ,LucideMicrowave:BQ,LucideMilestone:$Q,LucideMilk:UQ,LucideMilkOff:qQ,LucideMinimize:HQ,LucideMinimize2:VQ,LucideMinus:Qy,LucideMinusCircle:Lj,LucideMinusSquare:bk,LucideMonitor:hS,LucideMonitorCheck:GQ,LucideMonitorCog:WQ,LucideMonitorDot:KQ,LucideMonitorDown:ZQ,LucideMonitorOff:YQ,LucideMonitorPause:XQ,LucideMonitorPlay:QQ,LucideMonitorSmartphone:JQ,LucideMonitorSpeaker:eJ,LucideMonitorStop:tJ,LucideMonitorUp:uS,LucideMonitorX:sJ,LucideMoon:nJ,LucideMoonStar:rJ,LucideMoreHorizontal:Zp,LucideMoreVertical:ix,LucideMountain:iJ,LucideMountainSnow:aJ,LucideMouse:dJ,LucideMouseOff:oJ,LucideMousePointer:au,LucideMousePointer2:lJ,LucideMousePointerBan:cJ,LucideMousePointerClick:Tm,LucideMousePointerSquareDashed:uk,LucideMove:jJ,LucideMove3D:jN,LucideMove3d:jN,LucideMoveDiagonal:hJ,LucideMoveDiagonal2:uJ,LucideMoveDown:fJ,LucideMoveDownLeft:mJ,LucideMoveDownRight:pJ,LucideMoveHorizontal:xJ,LucideMoveLeft:gJ,LucideMoveRight:yJ,LucideMoveUp:bJ,LucideMoveUpLeft:vJ,LucideMoveUpRight:_J,LucideMoveVertical:wJ,LucideMusic:CJ,LucideMusic2:NJ,LucideMusic3:kJ,LucideMusic4:SJ,LucideNavigation:ML,LucideNavigation2:TJ,LucideNavigation2Off:MJ,LucideNavigationOff:AJ,LucideNetwork:EJ,LucideNewspaper:Jv,LucideNfc:PJ,LucideNotebook:RJ,LucideNotebookPen:IJ,LucideNotebookTabs:LJ,LucideNotebookText:DJ,LucideNotepadText:FJ,LucideNotepadTextDashed:OJ,LucideNut:BJ,LucideNutOff:zJ,LucideOctagon:qJ,LucideOctagonAlert:Tv,LucideOctagonMinus:$J,LucideOctagonPause:NN,LucideOctagonX:kN,LucideOmega:UJ,LucideOption:VJ,LucideOrbit:HJ,LucideOrigami:GJ,LucideOutdent:gN,LucidePackage:cl,LucidePackage2:WJ,LucidePackageCheck:KJ,LucidePackageMinus:ZJ,LucidePackageOpen:YJ,LucidePackagePlus:XJ,LucidePackageSearch:QJ,LucidePackageX:JJ,LucidePaintBucket:eee,LucidePaintRoller:tee,LucidePaintbrush:see,LucidePaintbrush2:SN,LucidePaintbrushVertical:SN,LucidePalette:Fl,LucidePalmtree:Uk,LucidePanelBottom:aee,LucidePanelBottomClose:ree,LucidePanelBottomDashed:CN,LucidePanelBottomInactive:CN,LucidePanelBottomOpen:nee,LucidePanelLeft:EN,LucidePanelLeftClose:MN,LucidePanelLeftDashed:TN,LucidePanelLeftInactive:TN,LucidePanelLeftOpen:AN,LucidePanelRight:lee,LucidePanelRightClose:iee,LucidePanelRightDashed:PN,LucidePanelRightInactive:PN,LucidePanelRightOpen:oee,LucidePanelTop:uee,LucidePanelTopClose:cee,LucidePanelTopDashed:IN,LucidePanelTopInactive:IN,LucidePanelTopOpen:dee,LucidePanelsLeftBottom:hee,LucidePanelsLeftRight:Xj,LucidePanelsRightBottom:mee,LucidePanelsTopBottom:FN,LucidePanelsTopLeft:Av,LucidePaperclip:mS,LucideParentheses:pee,LucideParkingCircle:Rj,LucideParkingCircleOff:Dj,LucideParkingMeter:fee,LucideParkingSquare:Nk,LucideParkingSquareOff:jk,LucidePartyPopper:qd,LucidePause:hh,LucidePauseCircle:Oj,LucidePauseOctagon:NN,LucidePawPrint:xee,LucidePcCase:gee,LucidePen:Ry,LucidePenBox:Wc,LucidePenLine:Ev,LucidePenOff:yee,LucidePenSquare:Wc,LucidePenTool:Mb,LucidePencil:ga,LucidePencilLine:vee,LucidePencilOff:_ee,LucidePencilRuler:bee,LucidePentagon:wee,LucidePercent:LM,LucidePercentCircle:Fj,LucidePercentDiamond:Jj,LucidePercentSquare:kk,LucidePersonStanding:jee,LucidePhilippinePeso:Nee,LucidePhone:In,LucidePhoneCall:kee,LucidePhoneForwarded:See,LucidePhoneIncoming:Cee,LucidePhoneMissed:Mee,LucidePhoneOff:Tee,LucidePhoneOutgoing:Aee,LucidePi:Eee,LucidePiSquare:Sk,LucidePiano:Pee,LucidePickaxe:Iee,LucidePictureInPicture:Dee,LucidePictureInPicture2:Lee,LucidePieChart:yj,LucidePiggyBank:Ree,LucidePilcrow:zee,LucidePilcrowLeft:Oee,LucidePilcrowRight:Fee,LucidePilcrowSquare:Ck,LucidePill:$ee,LucidePillBottle:Bee,LucidePin:Tb,LucidePinOff:TL,LucidePipette:qee,LucidePizza:Uee,LucidePlane:Gee,LucidePlaneLanding:Vee,LucidePlaneTakeoff:Hee,LucidePlay:Co,LucidePlayCircle:sp,LucidePlaySquare:Mk,LucidePlug:AL,LucidePlug2:Wee,LucidePlugZap:LN,LucidePlugZap2:LN,LucidePlus:Bs,LucidePlusCircle:zj,LucidePlusSquare:Tk,LucidePocket:Zee,LucidePocketKnife:Kee,LucidePodcast:Yee,LucidePointer:Qee,LucidePointerOff:Xee,LucidePopcorn:Jee,LucidePopsicle:ete,LucidePoundSterling:tte,LucidePower:EL,LucidePowerCircle:Bj,LucidePowerOff:ste,LucidePowerSquare:Ak,LucidePresentation:Pg,LucidePrinter:PL,LucidePrinterCheck:rte,LucideProjector:nte,LucideProportions:ate,LucidePuzzle:ite,LucidePyramid:ote,LucideQrCode:Jy,LucideQuote:pS,LucideRabbit:lte,LucideRadar:cte,LucideRadiation:dte,LucideRadical:ute,LucideRadio:e1,LucideRadioReceiver:hte,LucideRadioTower:mte,LucideRadius:pte,LucideRailSymbol:fte,LucideRainbow:xte,LucideRat:gte,LucideRatio:yte,LucideReceipt:Cte,LucideReceiptCent:vte,LucideReceiptEuro:_te,LucideReceiptIndianRupee:bte,LucideReceiptJapaneseYen:wte,LucideReceiptPoundSterling:jte,LucideReceiptRussianRuble:Nte,LucideReceiptSwissFranc:kte,LucideReceiptText:Ste,LucideRectangleEllipsis:DN,LucideRectangleHorizontal:Mte,LucideRectangleVertical:Tte,LucideRecycle:Ate,LucideRedo:fS,LucideRedo2:Ete,LucideRedoDot:Pte,LucideRefreshCcw:DM,LucideRefreshCcwDot:Ite,LucideRefreshCw:Zi,LucideRefreshCwOff:Lte,LucideRefrigerator:Dte,LucideRegex:Rte,LucideRemoveFormatting:Ote,LucideRepeat:IL,LucideRepeat1:Fte,LucideRepeat2:zte,LucideReplace:$te,LucideReplaceAll:Bte,LucideReply:LL,LucideReplyAll:qte,LucideRewind:Ute,LucideRibbon:Vte,LucideRocket:e0,LucideRockingChair:Hte,LucideRollerCoaster:Gte,LucideRotate3D:RN,LucideRotate3d:RN,LucideRotateCcw:t0,LucideRotateCcwSquare:Wte,LucideRotateCw:DL,LucideRotateCwSquare:Kte,LucideRoute:Yte,LucideRouteOff:Zte,LucideRouter:Xte,LucideRows:ON,LucideRows2:ON,LucideRows3:FN,LucideRows4:Qte,LucideRss:Jte,LucideRuler:xS,LucideRussianRuble:ese,LucideSailboat:tse,LucideSalad:sse,LucideSandwich:rse,LucideSatellite:ase,LucideSatelliteDish:nse,LucideSave:bc,LucideSaveAll:ise,LucideSaveOff:ose,LucideScale:RL,LucideScale3D:zN,LucideScale3d:zN,LucideScaling:lse,LucideScan:xse,LucideScanBarcode:cse,LucideScanEye:dse,LucideScanFace:use,LucideScanLine:hse,LucideScanQrCode:mse,LucideScanSearch:pse,LucideScanText:fse,LucideScatterChart:vj,LucideSchool:gse,LucideSchool2:Hk,LucideScissors:vse,LucideScissorsLineDashed:yse,LucideScissorsSquare:Ek,LucideScissorsSquareDashedBottom:rk,LucideScreenShare:bse,LucideScreenShareOff:_se,LucideScroll:jse,LucideScrollText:wse,LucideSearch:an,LucideSearchCheck:Nse,LucideSearchCode:kse,LucideSearchSlash:Sse,LucideSearchX:OL,LucideSection:Cse,LucideSend:Mn,LucideSendHorizonal:BN,LucideSendHorizontal:BN,LucideSendToBack:Mse,LucideSeparatorHorizontal:Tse,LucideSeparatorVertical:Ase,LucideServer:Lse,LucideServerCog:Ese,LucideServerCrash:Pse,LucideServerOff:Ise,LucideSettings:So,LucideSettings2:FL,LucideShapes:Dse,LucideShare:zL,LucideShare2:_d,LucideSheet:Rse,LucideShell:Ose,LucideShield:zu,LucideShieldAlert:Fse,LucideShieldBan:zse,LucideShieldCheck:t1,LucideShieldClose:$N,LucideShieldEllipsis:Bse,LucideShieldHalf:$se,LucideShieldMinus:qse,LucideShieldOff:gS,LucideShieldPlus:Use,LucideShieldQuestion:Vse,LucideShieldX:$N,LucideShip:Gse,LucideShipWheel:Hse,LucideShirt:Wse,LucideShoppingBag:s0,LucideShoppingBasket:Kse,LucideShoppingCart:op,LucideShovel:Zse,LucideShowerHead:Yse,LucideShrink:Xse,LucideShrub:Qse,LucideShuffle:yS,LucideSidebar:EN,LucideSidebarClose:MN,LucideSidebarOpen:AN,LucideSigma:Jse,LucideSigmaSquare:Pk,LucideSignal:nre,LucideSignalHigh:ere,LucideSignalLow:tre,LucideSignalMedium:sre,LucideSignalZero:rre,LucideSignature:are,LucideSignpost:ore,LucideSignpostBig:ire,LucideSiren:lre,LucideSkipBack:cre,LucideSkipForward:dre,LucideSkull:ure,LucideSlack:hre,LucideSlash:mre,LucideSlashSquare:Ik,LucideSlice:pre,LucideSliders:qN,LucideSlidersHorizontal:vS,LucideSlidersVertical:qN,LucideSmartphone:Ig,LucideSmartphoneCharging:fre,LucideSmartphoneNfc:xre,LucideSmile:yre,LucideSmilePlus:gre,LucideSnail:vre,LucideSnowflake:qy,LucideSofa:_re,LucideSortAsc:J2,LucideSortDesc:Y2,LucideSoup:bre,LucideSpace:wre,LucideSpade:jre,LucideSparkle:Nre,LucideSparkles:Or,LucideSpeaker:kre,LucideSpeech:Sre,LucideSpellCheck:Mre,LucideSpellCheck2:Cre,LucideSpline:Tre,LucideSplit:Are,LucideSplitSquareHorizontal:Lk,LucideSplitSquareVertical:Dk,LucideSprayCan:Ere,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:Ire,LucideSquareDashedBottomCode:Pre,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:Lre,LucideSquareScissors:Ek,LucideSquareSigma:Pk,LucideSquareSlash:Ik,LucideSquareSplitHorizontal:Lk,LucideSquareSplitVertical:Dk,LucideSquareSquare:Dre,LucideSquareStack:Rre,LucideSquareTerminal:Rk,LucideSquareUser:Fk,LucideSquareUserRound:Ok,LucideSquareX:zk,LucideSquircle:Ore,LucideSquirrel:Fre,LucideStamp:zre,LucideStar:Gn,LucideStarHalf:Bre,LucideStarOff:$re,LucideStars:Or,LucideStepBack:qre,LucideStepForward:Ure,LucideStethoscope:Vre,LucideSticker:Hre,LucideStickyNote:Gre,LucideStopCircle:qj,LucideStore:Wre,LucideStretchHorizontal:Kre,LucideStretchVertical:Zre,LucideStrikethrough:BL,LucideSubscript:Yre,LucideSubtitles:oj,LucideSun:s1,LucideSunDim:Xre,LucideSunMedium:Qre,LucideSunMoon:Jre,LucideSunSnow:ene,LucideSunrise:tne,LucideSunset:sne,LucideSuperscript:rne,LucideSwatchBook:nne,LucideSwissFranc:ane,LucideSwitchCamera:ine,LucideSword:one,LucideSwords:lne,LucideSyringe:cne,LucideTable:OM,LucideTable2:RM,LucideTableCellsMerge:dne,LucideTableCellsSplit:une,LucideTableColumnsSplit:hne,LucideTableOfContents:mne,LucideTableProperties:pne,LucideTableRowsSplit:fne,LucideTablet:gne,LucideTabletSmartphone:xne,LucideTablets:yne,LucideTag:mh,LucideTags:vne,LucideTally1:_ne,LucideTally2:bne,LucideTally3:wne,LucideTally4:jne,LucideTally5:Nne,LucideTangent:kne,LucideTarget:Rh,LucideTelescope:Sne,LucideTent:Mne,LucideTentTree:Cne,LucideTerminal:Tne,LucideTerminalSquare:Rk,LucideTestTube:Ane,LucideTestTube2:Bk,LucideTestTubeDiagonal:Bk,LucideTestTubes:Ene,LucideText:Rne,LucideTextCursor:Ine,LucideTextCursorInput:Pne,LucideTextQuote:Lne,LucideTextSearch:Dne,LucideTextSelect:$k,LucideTextSelection:$k,LucideTheater:One,LucideThermometer:Bne,LucideThermometerSnowflake:Fne,LucideThermometerSun:zne,LucideThumbsDown:$L,LucideThumbsUp:Bu,LucideTicket:qL,LucideTicketCheck:$ne,LucideTicketMinus:qne,LucideTicketPercent:Une,LucideTicketPlus:Vne,LucideTicketSlash:Hne,LucideTicketX:Gne,LucideTickets:Kne,LucideTicketsPlane:Wne,LucideTimer:Xne,LucideTimerOff:Zne,LucideTimerReset:Yne,LucideToggleLeft:Qne,LucideToggleRight:Jne,LucideToilet:eae,LucideTornado:tae,LucideTorus:sae,LucideTouchpad:nae,LucideTouchpadOff:rae,LucideTowerControl:aae,LucideToyBrick:iae,LucideTractor:oae,LucideTrafficCone:lae,LucideTrain:qk,LucideTrainFront:dae,LucideTrainFrontTunnel:cae,LucideTrainTrack:uae,LucideTramFront:qk,LucideTrash:hae,LucideTrash2:xr,LucideTreeDeciduous:mae,LucideTreePalm:Uk,LucideTreePine:Ab,LucideTrees:pae,LucideTrello:fae,LucideTrendingDown:bS,LucideTrendingUp:Qo,LucideTrendingUpDown:xae,LucideTriangle:yae,LucideTriangleAlert:Dc,LucideTriangleRight:gae,LucideTrophy:Vi,LucideTruck:UL,LucideTurtle:vae,LucideTv:bae,LucideTv2:Vk,LucideTvMinimal:Vk,LucideTvMinimalPlay:_ae,LucideTwitch:wae,LucideTwitter:jae,LucideType:kae,LucideTypeOutline:Nae,LucideUmbrella:Cae,LucideUmbrellaOff:Sae,LucideUnderline:VL,LucideUndo:wS,LucideUndo2:Mae,LucideUndoDot:Tae,LucideUnfoldHorizontal:Aae,LucideUnfoldVertical:Eae,LucideUngroup:Pae,LucideUniversity:Hk,LucideUnlink:jS,LucideUnlink2:Iae,LucideUnlock:bN,LucideUnlockKeyhole:_N,LucideUnplug:Lae,LucideUpload:Ra,LucideUploadCloud:Kj,LucideUsb:Dae,LucideUser:Ai,LucideUser2:Xk,LucideUserCheck:n0,LucideUserCheck2:Gk,LucideUserCircle:Vj,LucideUserCircle2:Uj,LucideUserCog:HL,LucideUserCog2:Wk,LucideUserMinus:GL,LucideUserMinus2:Kk,LucideUserPen:Rae,LucideUserPlus:Jo,LucideUserPlus2:Zk,LucideUserRound:Xk,LucideUserRoundCheck:Gk,LucideUserRoundCog:Wk,LucideUserRoundMinus:Kk,LucideUserRoundPen:Oae,LucideUserRoundPlus:Zk,LucideUserRoundSearch:Fae,LucideUserRoundX:Yk,LucideUserSearch:zae,LucideUserSquare:Fk,LucideUserSquare2:Ok,LucideUserX:Bae,LucideUserX2:Yk,LucideUsers:or,LucideUsers2:Qk,LucideUsersRound:Qk,LucideUtensils:e4,LucideUtensilsCrossed:Jk,LucideUtilityPole:$ae,LucideVariable:FM,LucideVault:qae,LucideVegan:Uae,LucideVenetianMask:Vae,LucideVerified:sj,LucideVibrate:Gae,LucideVibrateOff:Hae,LucideVideo:gn,LucideVideoOff:Wae,LucideVideotape:Kae,LucideView:Zae,LucideVoicemail:Yae,LucideVolleyball:Xae,LucideVolume:sie,LucideVolume1:Qae,LucideVolume2:Jae,LucideVolumeOff:eie,LucideVolumeX:tie,LucideVote:rie,LucideWallet:WL,LucideWallet2:t4,LucideWalletCards:nie,LucideWalletMinimal:t4,LucideWallpaper:aie,LucideWand:iie,LucideWand2:Iv,LucideWandSparkles:Iv,LucideWarehouse:oie,LucideWashingMachine:lie,LucideWatch:cie,LucideWaves:die,LucideWaypoints:uie,LucideWebcam:hie,LucideWebhook:pie,LucideWebhookOff:mie,LucideWeight:fie,LucideWheat:gie,LucideWheatOff:xie,LucideWholeWord:yie,LucideWifi:jie,LucideWifiHigh:vie,LucideWifiLow:_ie,LucideWifiOff:bie,LucideWifiZero:wie,LucideWind:kie,LucideWindArrowDown:Nie,LucideWine:Cie,LucideWineOff:Sie,LucideWorkflow:Mie,LucideWorm:Tie,LucideWrapText:Aie,LucideWrench:Lg,LucideX:jr,LucideXCircle:Ql,LucideXOctagon:kN,LucideXSquare:zk,LucideYoutube:Eie,LucideZap:Oh,LucideZapOff:Pie,LucideZoomIn:Eb,LucideZoomOut:zM,Luggage:UX,LuggageIcon:UX,MSquare:vk,MSquareIcon:vk,Magnet:VX,MagnetIcon:VX,Mail:tr,MailCheck:HX,MailCheckIcon:HX,MailIcon:tr,MailMinus:GX,MailMinusIcon:GX,MailOpen:WX,MailOpenIcon:WX,MailPlus:bL,MailPlusIcon:bL,MailQuestion:KX,MailQuestionIcon:KX,MailSearch:ZX,MailSearchIcon:ZX,MailWarning:YX,MailWarningIcon:YX,MailX:wL,MailXIcon:wL,Mailbox:XX,MailboxIcon:XX,Mails:QX,MailsIcon:QX,Map:cS,MapIcon:cS,MapPin:Ia,MapPinCheck:eQ,MapPinCheckIcon:eQ,MapPinCheckInside:JX,MapPinCheckInsideIcon:JX,MapPinHouse:tQ,MapPinHouseIcon:tQ,MapPinIcon:Ia,MapPinMinus:rQ,MapPinMinusIcon:rQ,MapPinMinusInside:sQ,MapPinMinusInsideIcon:sQ,MapPinOff:nQ,MapPinOffIcon:nQ,MapPinPlus:iQ,MapPinPlusIcon:iQ,MapPinPlusInside:aQ,MapPinPlusInsideIcon:aQ,MapPinX:lQ,MapPinXIcon:lQ,MapPinXInside:oQ,MapPinXInsideIcon:oQ,MapPinned:cQ,MapPinnedIcon:cQ,Martini:dQ,MartiniIcon:dQ,Maximize:jL,Maximize2:uQ,Maximize2Icon:uQ,MaximizeIcon:jL,Medal:Qv,MedalIcon:Qv,Megaphone:uh,MegaphoneIcon:uh,MegaphoneOff:hQ,MegaphoneOffIcon:hQ,Meh:mQ,MehIcon:mQ,MemoryStick:pQ,MemoryStickIcon:pQ,Menu:dS,MenuIcon:dS,MenuSquare:_k,MenuSquareIcon:_k,Merge:fQ,MergeIcon:fQ,MessageCircle:Ol,MessageCircleCode:xQ,MessageCircleCodeIcon:xQ,MessageCircleDashed:gQ,MessageCircleDashedIcon:gQ,MessageCircleHeart:PM,MessageCircleHeartIcon:PM,MessageCircleIcon:Ol,MessageCircleMore:yQ,MessageCircleMoreIcon:yQ,MessageCircleOff:vQ,MessageCircleOffIcon:vQ,MessageCirclePlus:_Q,MessageCirclePlusIcon:_Q,MessageCircleQuestion:NL,MessageCircleQuestionIcon:NL,MessageCircleReply:bQ,MessageCircleReplyIcon:bQ,MessageCircleWarning:wQ,MessageCircleWarningIcon:wQ,MessageCircleX:jQ,MessageCircleXIcon:jQ,MessageSquare:Si,MessageSquareCode:NQ,MessageSquareCodeIcon:NQ,MessageSquareDashed:kQ,MessageSquareDashedIcon:kQ,MessageSquareDiff:SQ,MessageSquareDiffIcon:SQ,MessageSquareDot:CQ,MessageSquareDotIcon:CQ,MessageSquareHeart:MQ,MessageSquareHeartIcon:MQ,MessageSquareIcon:Si,MessageSquareLock:TQ,MessageSquareLockIcon:TQ,MessageSquareMore:kL,MessageSquareMoreIcon:kL,MessageSquareOff:AQ,MessageSquareOffIcon:AQ,MessageSquarePlus:IM,MessageSquarePlusIcon:IM,MessageSquareQuote:SL,MessageSquareQuoteIcon:SL,MessageSquareReply:EQ,MessageSquareReplyIcon:EQ,MessageSquareShare:PQ,MessageSquareShareIcon:PQ,MessageSquareText:IQ,MessageSquareTextIcon:IQ,MessageSquareWarning:LQ,MessageSquareWarningIcon:LQ,MessageSquareX:DQ,MessageSquareXIcon:DQ,MessagesSquare:RQ,MessagesSquareIcon:RQ,Mic:CL,Mic2:wN,Mic2Icon:wN,MicIcon:CL,MicOff:OQ,MicOffIcon:OQ,MicVocal:wN,MicVocalIcon:wN,Microchip:FQ,MicrochipIcon:FQ,Microscope:zQ,MicroscopeIcon:zQ,Microwave:BQ,MicrowaveIcon:BQ,Milestone:$Q,MilestoneIcon:$Q,Milk:UQ,MilkIcon:UQ,MilkOff:qQ,MilkOffIcon:qQ,Minimize:HQ,Minimize2:VQ,Minimize2Icon:VQ,MinimizeIcon:HQ,Minus:Qy,MinusCircle:Lj,MinusCircleIcon:Lj,MinusIcon:Qy,MinusSquare:bk,MinusSquareIcon:bk,Monitor:hS,MonitorCheck:GQ,MonitorCheckIcon:GQ,MonitorCog:WQ,MonitorCogIcon:WQ,MonitorDot:KQ,MonitorDotIcon:KQ,MonitorDown:ZQ,MonitorDownIcon:ZQ,MonitorIcon:hS,MonitorOff:YQ,MonitorOffIcon:YQ,MonitorPause:XQ,MonitorPauseIcon:XQ,MonitorPlay:QQ,MonitorPlayIcon:QQ,MonitorSmartphone:JQ,MonitorSmartphoneIcon:JQ,MonitorSpeaker:eJ,MonitorSpeakerIcon:eJ,MonitorStop:tJ,MonitorStopIcon:tJ,MonitorUp:uS,MonitorUpIcon:uS,MonitorX:sJ,MonitorXIcon:sJ,Moon:nJ,MoonIcon:nJ,MoonStar:rJ,MoonStarIcon:rJ,MoreHorizontal:Zp,MoreHorizontalIcon:Zp,MoreVertical:ix,MoreVerticalIcon:ix,Mountain:iJ,MountainIcon:iJ,MountainSnow:aJ,MountainSnowIcon:aJ,Mouse:dJ,MouseIcon:dJ,MouseOff:oJ,MouseOffIcon:oJ,MousePointer:au,MousePointer2:lJ,MousePointer2Icon:lJ,MousePointerBan:cJ,MousePointerBanIcon:cJ,MousePointerClick:Tm,MousePointerClickIcon:Tm,MousePointerIcon:au,MousePointerSquareDashed:uk,MousePointerSquareDashedIcon:uk,Move:jJ,Move3D:jN,Move3DIcon:jN,Move3d:jN,Move3dIcon:jN,MoveDiagonal:hJ,MoveDiagonal2:uJ,MoveDiagonal2Icon:uJ,MoveDiagonalIcon:hJ,MoveDown:fJ,MoveDownIcon:fJ,MoveDownLeft:mJ,MoveDownLeftIcon:mJ,MoveDownRight:pJ,MoveDownRightIcon:pJ,MoveHorizontal:xJ,MoveHorizontalIcon:xJ,MoveIcon:jJ,MoveLeft:gJ,MoveLeftIcon:gJ,MoveRight:yJ,MoveRightIcon:yJ,MoveUp:bJ,MoveUpIcon:bJ,MoveUpLeft:vJ,MoveUpLeftIcon:vJ,MoveUpRight:_J,MoveUpRightIcon:_J,MoveVertical:wJ,MoveVerticalIcon:wJ,Music:CJ,Music2:NJ,Music2Icon:NJ,Music3:kJ,Music3Icon:kJ,Music4:SJ,Music4Icon:SJ,MusicIcon:CJ,Navigation:ML,Navigation2:TJ,Navigation2Icon:TJ,Navigation2Off:MJ,Navigation2OffIcon:MJ,NavigationIcon:ML,NavigationOff:AJ,NavigationOffIcon:AJ,Network:EJ,NetworkIcon:EJ,Newspaper:Jv,NewspaperIcon:Jv,Nfc:PJ,NfcIcon:PJ,Notebook:RJ,NotebookIcon:RJ,NotebookPen:IJ,NotebookPenIcon:IJ,NotebookTabs:LJ,NotebookTabsIcon:LJ,NotebookText:DJ,NotebookTextIcon:DJ,NotepadText:FJ,NotepadTextDashed:OJ,NotepadTextDashedIcon:OJ,NotepadTextIcon:FJ,Nut:BJ,NutIcon:BJ,NutOff:zJ,NutOffIcon:zJ,Octagon:qJ,OctagonAlert:Tv,OctagonAlertIcon:Tv,OctagonIcon:qJ,OctagonMinus:$J,OctagonMinusIcon:$J,OctagonPause:NN,OctagonPauseIcon:NN,OctagonX:kN,OctagonXIcon:kN,Omega:UJ,OmegaIcon:UJ,Option:VJ,OptionIcon:VJ,Orbit:HJ,OrbitIcon:HJ,Origami:GJ,OrigamiIcon:GJ,Outdent:gN,OutdentIcon:gN,Package:cl,Package2:WJ,Package2Icon:WJ,PackageCheck:KJ,PackageCheckIcon:KJ,PackageIcon:cl,PackageMinus:ZJ,PackageMinusIcon:ZJ,PackageOpen:YJ,PackageOpenIcon:YJ,PackagePlus:XJ,PackagePlusIcon:XJ,PackageSearch:QJ,PackageSearchIcon:QJ,PackageX:JJ,PackageXIcon:JJ,PaintBucket:eee,PaintBucketIcon:eee,PaintRoller:tee,PaintRollerIcon:tee,Paintbrush:see,Paintbrush2:SN,Paintbrush2Icon:SN,PaintbrushIcon:see,PaintbrushVertical:SN,PaintbrushVerticalIcon:SN,Palette:Fl,PaletteIcon:Fl,Palmtree:Uk,PalmtreeIcon:Uk,PanelBottom:aee,PanelBottomClose:ree,PanelBottomCloseIcon:ree,PanelBottomDashed:CN,PanelBottomDashedIcon:CN,PanelBottomIcon:aee,PanelBottomInactive:CN,PanelBottomInactiveIcon:CN,PanelBottomOpen:nee,PanelBottomOpenIcon:nee,PanelLeft:EN,PanelLeftClose:MN,PanelLeftCloseIcon:MN,PanelLeftDashed:TN,PanelLeftDashedIcon:TN,PanelLeftIcon:EN,PanelLeftInactive:TN,PanelLeftInactiveIcon:TN,PanelLeftOpen:AN,PanelLeftOpenIcon:AN,PanelRight:lee,PanelRightClose:iee,PanelRightCloseIcon:iee,PanelRightDashed:PN,PanelRightDashedIcon:PN,PanelRightIcon:lee,PanelRightInactive:PN,PanelRightInactiveIcon:PN,PanelRightOpen:oee,PanelRightOpenIcon:oee,PanelTop:uee,PanelTopClose:cee,PanelTopCloseIcon:cee,PanelTopDashed:IN,PanelTopDashedIcon:IN,PanelTopIcon:uee,PanelTopInactive:IN,PanelTopInactiveIcon:IN,PanelTopOpen:dee,PanelTopOpenIcon:dee,PanelsLeftBottom:hee,PanelsLeftBottomIcon:hee,PanelsLeftRight:Xj,PanelsLeftRightIcon:Xj,PanelsRightBottom:mee,PanelsRightBottomIcon:mee,PanelsTopBottom:FN,PanelsTopBottomIcon:FN,PanelsTopLeft:Av,PanelsTopLeftIcon:Av,Paperclip:mS,PaperclipIcon:mS,Parentheses:pee,ParenthesesIcon:pee,ParkingCircle:Rj,ParkingCircleIcon:Rj,ParkingCircleOff:Dj,ParkingCircleOffIcon:Dj,ParkingMeter:fee,ParkingMeterIcon:fee,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:xee,PawPrintIcon:xee,PcCase:gee,PcCaseIcon:gee,Pen:Ry,PenBox:Wc,PenBoxIcon:Wc,PenIcon:Ry,PenLine:Ev,PenLineIcon:Ev,PenOff:yee,PenOffIcon:yee,PenSquare:Wc,PenSquareIcon:Wc,PenTool:Mb,PenToolIcon:Mb,Pencil:ga,PencilIcon:ga,PencilLine:vee,PencilLineIcon:vee,PencilOff:_ee,PencilOffIcon:_ee,PencilRuler:bee,PencilRulerIcon:bee,Pentagon:wee,PentagonIcon:wee,Percent:LM,PercentCircle:Fj,PercentCircleIcon:Fj,PercentDiamond:Jj,PercentDiamondIcon:Jj,PercentIcon:LM,PercentSquare:kk,PercentSquareIcon:kk,PersonStanding:jee,PersonStandingIcon:jee,PhilippinePeso:Nee,PhilippinePesoIcon:Nee,Phone:In,PhoneCall:kee,PhoneCallIcon:kee,PhoneForwarded:See,PhoneForwardedIcon:See,PhoneIcon:In,PhoneIncoming:Cee,PhoneIncomingIcon:Cee,PhoneMissed:Mee,PhoneMissedIcon:Mee,PhoneOff:Tee,PhoneOffIcon:Tee,PhoneOutgoing:Aee,PhoneOutgoingIcon:Aee,Pi:Eee,PiIcon:Eee,PiSquare:Sk,PiSquareIcon:Sk,Piano:Pee,PianoIcon:Pee,Pickaxe:Iee,PickaxeIcon:Iee,PictureInPicture:Dee,PictureInPicture2:Lee,PictureInPicture2Icon:Lee,PictureInPictureIcon:Dee,PieChart:yj,PieChartIcon:yj,PiggyBank:Ree,PiggyBankIcon:Ree,Pilcrow:zee,PilcrowIcon:zee,PilcrowLeft:Oee,PilcrowLeftIcon:Oee,PilcrowRight:Fee,PilcrowRightIcon:Fee,PilcrowSquare:Ck,PilcrowSquareIcon:Ck,Pill:$ee,PillBottle:Bee,PillBottleIcon:Bee,PillIcon:$ee,Pin:Tb,PinIcon:Tb,PinOff:TL,PinOffIcon:TL,Pipette:qee,PipetteIcon:qee,Pizza:Uee,PizzaIcon:Uee,Plane:Gee,PlaneIcon:Gee,PlaneLanding:Vee,PlaneLandingIcon:Vee,PlaneTakeoff:Hee,PlaneTakeoffIcon:Hee,Play:Co,PlayCircle:sp,PlayCircleIcon:sp,PlayIcon:Co,PlaySquare:Mk,PlaySquareIcon:Mk,Plug:AL,Plug2:Wee,Plug2Icon:Wee,PlugIcon:AL,PlugZap:LN,PlugZap2:LN,PlugZap2Icon:LN,PlugZapIcon:LN,Plus:Bs,PlusCircle:zj,PlusCircleIcon:zj,PlusIcon:Bs,PlusSquare:Tk,PlusSquareIcon:Tk,Pocket:Zee,PocketIcon:Zee,PocketKnife:Kee,PocketKnifeIcon:Kee,Podcast:Yee,PodcastIcon:Yee,Pointer:Qee,PointerIcon:Qee,PointerOff:Xee,PointerOffIcon:Xee,Popcorn:Jee,PopcornIcon:Jee,Popsicle:ete,PopsicleIcon:ete,PoundSterling:tte,PoundSterlingIcon:tte,Power:EL,PowerCircle:Bj,PowerCircleIcon:Bj,PowerIcon:EL,PowerOff:ste,PowerOffIcon:ste,PowerSquare:Ak,PowerSquareIcon:Ak,Presentation:Pg,PresentationIcon:Pg,Printer:PL,PrinterCheck:rte,PrinterCheckIcon:rte,PrinterIcon:PL,Projector:nte,ProjectorIcon:nte,Proportions:ate,ProportionsIcon:ate,Puzzle:ite,PuzzleIcon:ite,Pyramid:ote,PyramidIcon:ote,QrCode:Jy,QrCodeIcon:Jy,Quote:pS,QuoteIcon:pS,Rabbit:lte,RabbitIcon:lte,Radar:cte,RadarIcon:cte,Radiation:dte,RadiationIcon:dte,Radical:ute,RadicalIcon:ute,Radio:e1,RadioIcon:e1,RadioReceiver:hte,RadioReceiverIcon:hte,RadioTower:mte,RadioTowerIcon:mte,Radius:pte,RadiusIcon:pte,RailSymbol:fte,RailSymbolIcon:fte,Rainbow:xte,RainbowIcon:xte,Rat:gte,RatIcon:gte,Ratio:yte,RatioIcon:yte,Receipt:Cte,ReceiptCent:vte,ReceiptCentIcon:vte,ReceiptEuro:_te,ReceiptEuroIcon:_te,ReceiptIcon:Cte,ReceiptIndianRupee:bte,ReceiptIndianRupeeIcon:bte,ReceiptJapaneseYen:wte,ReceiptJapaneseYenIcon:wte,ReceiptPoundSterling:jte,ReceiptPoundSterlingIcon:jte,ReceiptRussianRuble:Nte,ReceiptRussianRubleIcon:Nte,ReceiptSwissFranc:kte,ReceiptSwissFrancIcon:kte,ReceiptText:Ste,ReceiptTextIcon:Ste,RectangleEllipsis:DN,RectangleEllipsisIcon:DN,RectangleHorizontal:Mte,RectangleHorizontalIcon:Mte,RectangleVertical:Tte,RectangleVerticalIcon:Tte,Recycle:Ate,RecycleIcon:Ate,Redo:fS,Redo2:Ete,Redo2Icon:Ete,RedoDot:Pte,RedoDotIcon:Pte,RedoIcon:fS,RefreshCcw:DM,RefreshCcwDot:Ite,RefreshCcwDotIcon:Ite,RefreshCcwIcon:DM,RefreshCw:Zi,RefreshCwIcon:Zi,RefreshCwOff:Lte,RefreshCwOffIcon:Lte,Refrigerator:Dte,RefrigeratorIcon:Dte,Regex:Rte,RegexIcon:Rte,RemoveFormatting:Ote,RemoveFormattingIcon:Ote,Repeat:IL,Repeat1:Fte,Repeat1Icon:Fte,Repeat2:zte,Repeat2Icon:zte,RepeatIcon:IL,Replace:$te,ReplaceAll:Bte,ReplaceAllIcon:Bte,ReplaceIcon:$te,Reply:LL,ReplyAll:qte,ReplyAllIcon:qte,ReplyIcon:LL,Rewind:Ute,RewindIcon:Ute,Ribbon:Vte,RibbonIcon:Vte,Rocket:e0,RocketIcon:e0,RockingChair:Hte,RockingChairIcon:Hte,RollerCoaster:Gte,RollerCoasterIcon:Gte,Rotate3D:RN,Rotate3DIcon:RN,Rotate3d:RN,Rotate3dIcon:RN,RotateCcw:t0,RotateCcwIcon:t0,RotateCcwSquare:Wte,RotateCcwSquareIcon:Wte,RotateCw:DL,RotateCwIcon:DL,RotateCwSquare:Kte,RotateCwSquareIcon:Kte,Route:Yte,RouteIcon:Yte,RouteOff:Zte,RouteOffIcon:Zte,Router:Xte,RouterIcon:Xte,Rows:ON,Rows2:ON,Rows2Icon:ON,Rows3:FN,Rows3Icon:FN,Rows4:Qte,Rows4Icon:Qte,RowsIcon:ON,Rss:Jte,RssIcon:Jte,Ruler:xS,RulerIcon:xS,RussianRuble:ese,RussianRubleIcon:ese,Sailboat:tse,SailboatIcon:tse,Salad:sse,SaladIcon:sse,Sandwich:rse,SandwichIcon:rse,Satellite:ase,SatelliteDish:nse,SatelliteDishIcon:nse,SatelliteIcon:ase,Save:bc,SaveAll:ise,SaveAllIcon:ise,SaveIcon:bc,SaveOff:ose,SaveOffIcon:ose,Scale:RL,Scale3D:zN,Scale3DIcon:zN,Scale3d:zN,Scale3dIcon:zN,ScaleIcon:RL,Scaling:lse,ScalingIcon:lse,Scan:xse,ScanBarcode:cse,ScanBarcodeIcon:cse,ScanEye:dse,ScanEyeIcon:dse,ScanFace:use,ScanFaceIcon:use,ScanIcon:xse,ScanLine:hse,ScanLineIcon:hse,ScanQrCode:mse,ScanQrCodeIcon:mse,ScanSearch:pse,ScanSearchIcon:pse,ScanText:fse,ScanTextIcon:fse,ScatterChart:vj,ScatterChartIcon:vj,School:gse,School2:Hk,School2Icon:Hk,SchoolIcon:gse,Scissors:vse,ScissorsIcon:vse,ScissorsLineDashed:yse,ScissorsLineDashedIcon:yse,ScissorsSquare:Ek,ScissorsSquareDashedBottom:rk,ScissorsSquareDashedBottomIcon:rk,ScissorsSquareIcon:Ek,ScreenShare:bse,ScreenShareIcon:bse,ScreenShareOff:_se,ScreenShareOffIcon:_se,Scroll:jse,ScrollIcon:jse,ScrollText:wse,ScrollTextIcon:wse,Search:an,SearchCheck:Nse,SearchCheckIcon:Nse,SearchCode:kse,SearchCodeIcon:kse,SearchIcon:an,SearchSlash:Sse,SearchSlashIcon:Sse,SearchX:OL,SearchXIcon:OL,Section:Cse,SectionIcon:Cse,Send:Mn,SendHorizonal:BN,SendHorizonalIcon:BN,SendHorizontal:BN,SendHorizontalIcon:BN,SendIcon:Mn,SendToBack:Mse,SendToBackIcon:Mse,SeparatorHorizontal:Tse,SeparatorHorizontalIcon:Tse,SeparatorVertical:Ase,SeparatorVerticalIcon:Ase,Server:Lse,ServerCog:Ese,ServerCogIcon:Ese,ServerCrash:Pse,ServerCrashIcon:Pse,ServerIcon:Lse,ServerOff:Ise,ServerOffIcon:Ise,Settings:So,Settings2:FL,Settings2Icon:FL,SettingsIcon:So,Shapes:Dse,ShapesIcon:Dse,Share:zL,Share2:_d,Share2Icon:_d,ShareIcon:zL,Sheet:Rse,SheetIcon:Rse,Shell:Ose,ShellIcon:Ose,Shield:zu,ShieldAlert:Fse,ShieldAlertIcon:Fse,ShieldBan:zse,ShieldBanIcon:zse,ShieldCheck:t1,ShieldCheckIcon:t1,ShieldClose:$N,ShieldCloseIcon:$N,ShieldEllipsis:Bse,ShieldEllipsisIcon:Bse,ShieldHalf:$se,ShieldHalfIcon:$se,ShieldIcon:zu,ShieldMinus:qse,ShieldMinusIcon:qse,ShieldOff:gS,ShieldOffIcon:gS,ShieldPlus:Use,ShieldPlusIcon:Use,ShieldQuestion:Vse,ShieldQuestionIcon:Vse,ShieldX:$N,ShieldXIcon:$N,Ship:Gse,ShipIcon:Gse,ShipWheel:Hse,ShipWheelIcon:Hse,Shirt:Wse,ShirtIcon:Wse,ShoppingBag:s0,ShoppingBagIcon:s0,ShoppingBasket:Kse,ShoppingBasketIcon:Kse,ShoppingCart:op,ShoppingCartIcon:op,Shovel:Zse,ShovelIcon:Zse,ShowerHead:Yse,ShowerHeadIcon:Yse,Shrink:Xse,ShrinkIcon:Xse,Shrub:Qse,ShrubIcon:Qse,Shuffle:yS,ShuffleIcon:yS,Sidebar:EN,SidebarClose:MN,SidebarCloseIcon:MN,SidebarIcon:EN,SidebarOpen:AN,SidebarOpenIcon:AN,Sigma:Jse,SigmaIcon:Jse,SigmaSquare:Pk,SigmaSquareIcon:Pk,Signal:nre,SignalHigh:ere,SignalHighIcon:ere,SignalIcon:nre,SignalLow:tre,SignalLowIcon:tre,SignalMedium:sre,SignalMediumIcon:sre,SignalZero:rre,SignalZeroIcon:rre,Signature:are,SignatureIcon:are,Signpost:ore,SignpostBig:ire,SignpostBigIcon:ire,SignpostIcon:ore,Siren:lre,SirenIcon:lre,SkipBack:cre,SkipBackIcon:cre,SkipForward:dre,SkipForwardIcon:dre,Skull:ure,SkullIcon:ure,Slack:hre,SlackIcon:hre,Slash:mre,SlashIcon:mre,SlashSquare:Ik,SlashSquareIcon:Ik,Slice:pre,SliceIcon:pre,Sliders:qN,SlidersHorizontal:vS,SlidersHorizontalIcon:vS,SlidersIcon:qN,SlidersVertical:qN,SlidersVerticalIcon:qN,Smartphone:Ig,SmartphoneCharging:fre,SmartphoneChargingIcon:fre,SmartphoneIcon:Ig,SmartphoneNfc:xre,SmartphoneNfcIcon:xre,Smile:yre,SmileIcon:yre,SmilePlus:gre,SmilePlusIcon:gre,Snail:vre,SnailIcon:vre,Snowflake:qy,SnowflakeIcon:qy,Sofa:_re,SofaIcon:_re,SortAsc:J2,SortAscIcon:J2,SortDesc:Y2,SortDescIcon:Y2,Soup:bre,SoupIcon:bre,Space:wre,SpaceIcon:wre,Spade:jre,SpadeIcon:jre,Sparkle:Nre,SparkleIcon:Nre,Sparkles:Or,SparklesIcon:Or,Speaker:kre,SpeakerIcon:kre,Speech:Sre,SpeechIcon:Sre,SpellCheck:Mre,SpellCheck2:Cre,SpellCheck2Icon:Cre,SpellCheckIcon:Mre,Spline:Tre,SplineIcon:Tre,Split:Are,SplitIcon:Are,SplitSquareHorizontal:Lk,SplitSquareHorizontalIcon:Lk,SplitSquareVertical:Dk,SplitSquareVerticalIcon:Dk,SprayCan:Ere,SprayCanIcon:Ere,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:Ire,SquareDashedBottomCode:Pre,SquareDashedBottomCodeIcon:Pre,SquareDashedBottomIcon:Ire,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:Lre,SquareRadicalIcon:Lre,SquareScissors:Ek,SquareScissorsIcon:Ek,SquareSigma:Pk,SquareSigmaIcon:Pk,SquareSlash:Ik,SquareSlashIcon:Ik,SquareSplitHorizontal:Lk,SquareSplitHorizontalIcon:Lk,SquareSplitVertical:Dk,SquareSplitVerticalIcon:Dk,SquareSquare:Dre,SquareSquareIcon:Dre,SquareStack:Rre,SquareStackIcon:Rre,SquareTerminal:Rk,SquareTerminalIcon:Rk,SquareUser:Fk,SquareUserIcon:Fk,SquareUserRound:Ok,SquareUserRoundIcon:Ok,SquareX:zk,SquareXIcon:zk,Squircle:Ore,SquircleIcon:Ore,Squirrel:Fre,SquirrelIcon:Fre,Stamp:zre,StampIcon:zre,Star:Gn,StarHalf:Bre,StarHalfIcon:Bre,StarIcon:Gn,StarOff:$re,StarOffIcon:$re,Stars:Or,StarsIcon:Or,StepBack:qre,StepBackIcon:qre,StepForward:Ure,StepForwardIcon:Ure,Stethoscope:Vre,StethoscopeIcon:Vre,Sticker:Hre,StickerIcon:Hre,StickyNote:Gre,StickyNoteIcon:Gre,StopCircle:qj,StopCircleIcon:qj,Store:Wre,StoreIcon:Wre,StretchHorizontal:Kre,StretchHorizontalIcon:Kre,StretchVertical:Zre,StretchVerticalIcon:Zre,Strikethrough:BL,StrikethroughIcon:BL,Subscript:Yre,SubscriptIcon:Yre,Subtitles:oj,SubtitlesIcon:oj,Sun:s1,SunDim:Xre,SunDimIcon:Xre,SunIcon:s1,SunMedium:Qre,SunMediumIcon:Qre,SunMoon:Jre,SunMoonIcon:Jre,SunSnow:ene,SunSnowIcon:ene,Sunrise:tne,SunriseIcon:tne,Sunset:sne,SunsetIcon:sne,Superscript:rne,SuperscriptIcon:rne,SwatchBook:nne,SwatchBookIcon:nne,SwissFranc:ane,SwissFrancIcon:ane,SwitchCamera:ine,SwitchCameraIcon:ine,Sword:one,SwordIcon:one,Swords:lne,SwordsIcon:lne,Syringe:cne,SyringeIcon:cne,Table:OM,Table2:RM,Table2Icon:RM,TableCellsMerge:dne,TableCellsMergeIcon:dne,TableCellsSplit:une,TableCellsSplitIcon:une,TableColumnsSplit:hne,TableColumnsSplitIcon:hne,TableIcon:OM,TableOfContents:mne,TableOfContentsIcon:mne,TableProperties:pne,TablePropertiesIcon:pne,TableRowsSplit:fne,TableRowsSplitIcon:fne,Tablet:gne,TabletIcon:gne,TabletSmartphone:xne,TabletSmartphoneIcon:xne,Tablets:yne,TabletsIcon:yne,Tag:mh,TagIcon:mh,Tags:vne,TagsIcon:vne,Tally1:_ne,Tally1Icon:_ne,Tally2:bne,Tally2Icon:bne,Tally3:wne,Tally3Icon:wne,Tally4:jne,Tally4Icon:jne,Tally5:Nne,Tally5Icon:Nne,Tangent:kne,TangentIcon:kne,Target:Rh,TargetIcon:Rh,Telescope:Sne,TelescopeIcon:Sne,Tent:Mne,TentIcon:Mne,TentTree:Cne,TentTreeIcon:Cne,Terminal:Tne,TerminalIcon:Tne,TerminalSquare:Rk,TerminalSquareIcon:Rk,TestTube:Ane,TestTube2:Bk,TestTube2Icon:Bk,TestTubeDiagonal:Bk,TestTubeDiagonalIcon:Bk,TestTubeIcon:Ane,TestTubes:Ene,TestTubesIcon:Ene,Text:Rne,TextCursor:Ine,TextCursorIcon:Ine,TextCursorInput:Pne,TextCursorInputIcon:Pne,TextIcon:Rne,TextQuote:Lne,TextQuoteIcon:Lne,TextSearch:Dne,TextSearchIcon:Dne,TextSelect:$k,TextSelectIcon:$k,TextSelection:$k,TextSelectionIcon:$k,Theater:One,TheaterIcon:One,Thermometer:Bne,ThermometerIcon:Bne,ThermometerSnowflake:Fne,ThermometerSnowflakeIcon:Fne,ThermometerSun:zne,ThermometerSunIcon:zne,ThumbsDown:$L,ThumbsDownIcon:$L,ThumbsUp:Bu,ThumbsUpIcon:Bu,Ticket:qL,TicketCheck:$ne,TicketCheckIcon:$ne,TicketIcon:qL,TicketMinus:qne,TicketMinusIcon:qne,TicketPercent:Une,TicketPercentIcon:Une,TicketPlus:Vne,TicketPlusIcon:Vne,TicketSlash:Hne,TicketSlashIcon:Hne,TicketX:Gne,TicketXIcon:Gne,Tickets:Kne,TicketsIcon:Kne,TicketsPlane:Wne,TicketsPlaneIcon:Wne,Timer:Xne,TimerIcon:Xne,TimerOff:Zne,TimerOffIcon:Zne,TimerReset:Yne,TimerResetIcon:Yne,ToggleLeft:Qne,ToggleLeftIcon:Qne,ToggleRight:Jne,ToggleRightIcon:Jne,Toilet:eae,ToiletIcon:eae,Tornado:tae,TornadoIcon:tae,Torus:sae,TorusIcon:sae,Touchpad:nae,TouchpadIcon:nae,TouchpadOff:rae,TouchpadOffIcon:rae,TowerControl:aae,TowerControlIcon:aae,ToyBrick:iae,ToyBrickIcon:iae,Tractor:oae,TractorIcon:oae,TrafficCone:lae,TrafficConeIcon:lae,Train:qk,TrainFront:dae,TrainFrontIcon:dae,TrainFrontTunnel:cae,TrainFrontTunnelIcon:cae,TrainIcon:qk,TrainTrack:uae,TrainTrackIcon:uae,TramFront:qk,TramFrontIcon:qk,Trash:hae,Trash2:xr,Trash2Icon:xr,TrashIcon:hae,TreeDeciduous:mae,TreeDeciduousIcon:mae,TreePalm:Uk,TreePalmIcon:Uk,TreePine:Ab,TreePineIcon:Ab,Trees:pae,TreesIcon:pae,Trello:fae,TrelloIcon:fae,TrendingDown:bS,TrendingDownIcon:bS,TrendingUp:Qo,TrendingUpDown:xae,TrendingUpDownIcon:xae,TrendingUpIcon:Qo,Triangle:yae,TriangleAlert:Dc,TriangleAlertIcon:Dc,TriangleIcon:yae,TriangleRight:gae,TriangleRightIcon:gae,Trophy:Vi,TrophyIcon:Vi,Truck:UL,TruckIcon:UL,Turtle:vae,TurtleIcon:vae,Tv:bae,Tv2:Vk,Tv2Icon:Vk,TvIcon:bae,TvMinimal:Vk,TvMinimalIcon:Vk,TvMinimalPlay:_ae,TvMinimalPlayIcon:_ae,Twitch:wae,TwitchIcon:wae,Twitter:jae,TwitterIcon:jae,Type:kae,TypeIcon:kae,TypeOutline:Nae,TypeOutlineIcon:Nae,Umbrella:Cae,UmbrellaIcon:Cae,UmbrellaOff:Sae,UmbrellaOffIcon:Sae,Underline:VL,UnderlineIcon:VL,Undo:wS,Undo2:Mae,Undo2Icon:Mae,UndoDot:Tae,UndoDotIcon:Tae,UndoIcon:wS,UnfoldHorizontal:Aae,UnfoldHorizontalIcon:Aae,UnfoldVertical:Eae,UnfoldVerticalIcon:Eae,Ungroup:Pae,UngroupIcon:Pae,University:Hk,UniversityIcon:Hk,Unlink:jS,Unlink2:Iae,Unlink2Icon:Iae,UnlinkIcon:jS,Unlock:bN,UnlockIcon:bN,UnlockKeyhole:_N,UnlockKeyholeIcon:_N,Unplug:Lae,UnplugIcon:Lae,Upload:Ra,UploadCloud:Kj,UploadCloudIcon:Kj,UploadIcon:Ra,Usb:Dae,UsbIcon:Dae,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:Rae,UserPenIcon:Rae,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:Oae,UserRoundPenIcon:Oae,UserRoundPlus:Zk,UserRoundPlusIcon:Zk,UserRoundSearch:Fae,UserRoundSearchIcon:Fae,UserRoundX:Yk,UserRoundXIcon:Yk,UserSearch:zae,UserSearchIcon:zae,UserSquare:Fk,UserSquare2:Ok,UserSquare2Icon:Ok,UserSquareIcon:Fk,UserX:Bae,UserX2:Yk,UserX2Icon:Yk,UserXIcon:Bae,Users:or,Users2:Qk,Users2Icon:Qk,UsersIcon:or,UsersRound:Qk,UsersRoundIcon:Qk,Utensils:e4,UtensilsCrossed:Jk,UtensilsCrossedIcon:Jk,UtensilsIcon:e4,UtilityPole:$ae,UtilityPoleIcon:$ae,Variable:FM,VariableIcon:FM,Vault:qae,VaultIcon:qae,Vegan:Uae,VeganIcon:Uae,VenetianMask:Vae,VenetianMaskIcon:Vae,Verified:sj,VerifiedIcon:sj,Vibrate:Gae,VibrateIcon:Gae,VibrateOff:Hae,VibrateOffIcon:Hae,Video:gn,VideoIcon:gn,VideoOff:Wae,VideoOffIcon:Wae,Videotape:Kae,VideotapeIcon:Kae,View:Zae,ViewIcon:Zae,Voicemail:Yae,VoicemailIcon:Yae,Volleyball:Xae,VolleyballIcon:Xae,Volume:sie,Volume1:Qae,Volume1Icon:Qae,Volume2:Jae,Volume2Icon:Jae,VolumeIcon:sie,VolumeOff:eie,VolumeOffIcon:eie,VolumeX:tie,VolumeXIcon:tie,Vote:rie,VoteIcon:rie,Wallet:WL,Wallet2:t4,Wallet2Icon:t4,WalletCards:nie,WalletCardsIcon:nie,WalletIcon:WL,WalletMinimal:t4,WalletMinimalIcon:t4,Wallpaper:aie,WallpaperIcon:aie,Wand:iie,Wand2:Iv,Wand2Icon:Iv,WandIcon:iie,WandSparkles:Iv,WandSparklesIcon:Iv,Warehouse:oie,WarehouseIcon:oie,WashingMachine:lie,WashingMachineIcon:lie,Watch:cie,WatchIcon:cie,Waves:die,WavesIcon:die,Waypoints:uie,WaypointsIcon:uie,Webcam:hie,WebcamIcon:hie,Webhook:pie,WebhookIcon:pie,WebhookOff:mie,WebhookOffIcon:mie,Weight:fie,WeightIcon:fie,Wheat:gie,WheatIcon:gie,WheatOff:xie,WheatOffIcon:xie,WholeWord:yie,WholeWordIcon:yie,Wifi:jie,WifiHigh:vie,WifiHighIcon:vie,WifiIcon:jie,WifiLow:_ie,WifiLowIcon:_ie,WifiOff:bie,WifiOffIcon:bie,WifiZero:wie,WifiZeroIcon:wie,Wind:kie,WindArrowDown:Nie,WindArrowDownIcon:Nie,WindIcon:kie,Wine:Cie,WineIcon:Cie,WineOff:Sie,WineOffIcon:Sie,Workflow:Mie,WorkflowIcon:Mie,Worm:Tie,WormIcon:Tie,WrapText:Aie,WrapTextIcon:Aie,Wrench:Lg,WrenchIcon:Lg,X:jr,XCircle:Ql,XCircleIcon:Ql,XIcon:jr,XOctagon:kN,XOctagonIcon:kN,XSquare:zk,XSquareIcon:zk,Youtube:Eie,YoutubeIcon:Eie,Zap:Oh,ZapIcon:Oh,ZapOff:Pie,ZapOffIcon:Pie,ZoomIn:Eb,ZoomInIcon:Eb,ZoomOut:zM,ZoomOutIcon:zM,createLucideIcon:Z,icons:_gt},Symbol.toStringTag,{value:"Module"})),oje="-",bgt=t=>{const s=jgt(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)||wgt(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},TEe=/^\[(.+)\]$/,wgt=t=>{if(TEe.test(t)){const s=TEe.exec(t)[1],r=s==null?void 0:s.substring(0,s.indexOf(":"));if(r)return"arbitrary.."+r}},jgt=t=>{const{theme:s,prefix:r}=t,n={nextPart:new Map,validators:[]};return kgt(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:AEe(s,a);o.classGroupId=r;return}if(typeof a=="function"){if(Ngt(a)){Cve(a(n),s,r,n);return}s.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([o,l])=>{Cve(l,AEe(s,o),r,n)})})},AEe=(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},Ngt=t=>t.isThemeGetter,kgt=(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,Sgt=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="!",Cgt=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},Mgt=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},Tgt=t=>({cache:Sgt(t.cacheSize),parseClassName:Cgt(t),...bgt(t)}),Agt=/\s+/,Egt=(t,s)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a}=s,o=[],l=t.trim().split(Agt);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=Mgt(p).join(":"),k=f?w+iUe:w,C=k+N;if(o.includes(C))continue;o.push(C);const A=a(N,b);for(let I=0;I0?" "+i:i)}return i};function Pgt(){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=Tgt(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=Egt(d,r);return a(d,p),p}return function(){return o(Pgt.apply(null,arguments))}}const Hl=t=>{const s=r=>r[t]||[];return s.isThemeGetter=!0,s},lUe=/^\[(?:([a-z-]+):)?(.+)\]$/i,Lgt=/^\d+\/\d+$/,Dgt=new Set(["px","full","screen"]),Rgt=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Ogt=/\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$/,Fgt=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,zgt=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Bgt=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,hv=t=>BM(t)||Dgt.has(t)||Lgt.test(t),p_=t=>LA(t,"length",Kgt),BM=t=>!!t&&!Number.isNaN(Number(t)),Wxe=t=>LA(t,"number",BM),W6=t=>!!t&&Number.isInteger(Number(t)),$gt=t=>t.endsWith("%")&&BM(t.slice(0,-1)),Mi=t=>lUe.test(t),f_=t=>Rgt.test(t),qgt=new Set(["length","size","percentage"]),Ugt=t=>LA(t,qgt,cUe),Vgt=t=>LA(t,"position",cUe),Hgt=new Set(["image","url"]),Ggt=t=>LA(t,Hgt,Ygt),Wgt=t=>LA(t,"",Zgt),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},Kgt=t=>Ogt.test(t)&&!Fgt.test(t),cUe=()=>!1,Zgt=t=>zgt.test(t),Ygt=t=>Bgt.test(t),Xgt=()=>{const t=Hl("colors"),s=Hl("spacing"),r=Hl("blur"),n=Hl("brightness"),a=Hl("borderColor"),o=Hl("borderRadius"),l=Hl("borderSpacing"),i=Hl("borderWidth"),d=Hl("contrast"),u=Hl("grayscale"),p=Hl("hueRotate"),f=Hl("invert"),y=Hl("gap"),_=Hl("gradientColorStops"),b=Hl("gradientColorStopPositions"),N=Hl("inset"),w=Hl("margin"),k=Hl("opacity"),C=Hl("padding"),A=Hl("saturate"),I=Hl("scale"),L=Hl("sepia"),O=Hl("skew"),V=Hl("space"),q=Hl("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"],ae=()=>["solid","dashed","dotted","double","none"],ie=()=>["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],ye=()=>["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:[$gt,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":ye()}],"break-before":[{"break-before":ye()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...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",Wxe]}],"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,Wxe]}],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":[k]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[k]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ae(),"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":[k]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...ce(),Vgt]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Ugt]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Ggt]}],"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":[k]}],"border-style":[{border:[...ae(),"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":[k]}],"divide-style":[{divide:ae()}],"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:["",...ae()]}],"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":[k]}],"ring-offset-w":[{"ring-offset":[hv,p_]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",f_,Wgt]}],"shadow-color":[{shadow:[K6]}],opacity:[{opacity:[k]}],"mix-blend":[{"mix-blend":[...ie(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":ie()}],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":[k]}],"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_,Wxe]}],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"]}}},Qgt=Igt(Xgt);function Dt(...t){return Qgt(bi(t))}function Pl(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 EEe(t){const s=new Date(t);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(s)}function Xde(t){return t?t.replace(/<[^>]*>/g,""):""}const Jgt=ggt,dUe=S.forwardRef(({className:t,...s},r)=>e.jsx(Yqe,{ref:r,className:Dt("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 eyt=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=S.forwardRef(({className:t,variant:s,...r},n)=>e.jsx(Xqe,{ref:n,className:Dt(eyt({variant:s}),t),...r}));uUe.displayName=Xqe.displayName;const tyt=S.forwardRef(({className:t,...s},r)=>e.jsx(eUe,{ref:r,className:Dt("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}));tyt.displayName=eUe.displayName;const hUe=S.forwardRef(({className:t,...s},r)=>e.jsx(tUe,{ref:r,className:Dt("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(jr,{className:"h-4 w-4"})}));hUe.displayName=tUe.displayName;const mUe=S.forwardRef(({className:t,...s},r)=>e.jsx(Qqe,{ref:r,className:Dt("text-sm font-semibold",t),...s}));mUe.displayName=Qqe.displayName;const pUe=S.forwardRef(({className:t,...s},r)=>e.jsx(Jqe,{ref:r,className:Dt("text-sm opacity-90",t),...s}));pUe.displayName=Jqe.displayName;function syt(){const{toasts:t}=ja();return e.jsxs(Jgt,{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 PEe=["light","dark"],ryt="(prefers-color-scheme: dark)",nyt=S.createContext(void 0),ayt={setTheme:t=>{},themes:[]},iyt=()=>{var t;return(t=S.useContext(nyt))!=null?t:ayt};S.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?PEe.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 k=l?l[b]:b,C=N?b+"|| ''":`'${k}'`,A="";return a&&w&&!N&&PEe.includes(b)&&(A+=`d.style.colorScheme = '${b}';`),r==="class"?N||k?A+=`c.add(${C})`:A+="null":k&&(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='${ryt}',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 S.createElement("script",{nonce:d,dangerouslySetInnerHTML:{__html:_}})});var oyt=t=>{switch(t){case"success":return dyt;case"info":return hyt;case"warning":return uyt;case"error":return myt;default:return null}},lyt=Array(12).fill(0),cyt=({visible:t,className:s})=>xt.createElement("div",{className:["sonner-loading-wrapper",s].filter(Boolean).join(" "),"data-visible":t},xt.createElement("div",{className:"sonner-spinner"},lyt.map((r,n)=>xt.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),dyt=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"})),uyt=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"})),hyt=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"})),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-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"})),pyt=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"})),fyt=()=>{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,xyt=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(yyt(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}},Jm=new xyt,gyt=(t,s)=>{let r=(s==null?void 0:s.id)||Mve++;return Jm.addToast({title:t,...s,id:r}),r},yyt=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",vyt=gyt,_yt=()=>Jm.toasts,byt=()=>Jm.getActiveToasts(),pe=Object.assign(vyt,{success:Jm.success,info:Jm.info,warning:Jm.warning,error:Jm.error,custom:Jm.custom,message:Jm.message,promise:Jm.promise,dismiss:Jm.dismiss,loading:Jm.loading},{getHistory:_yt,getToasts:byt});function wyt(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))}wyt(`: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 fz(t){return t.label!==void 0}var jyt=3,Nyt="32px",kyt="16px",IEe=4e3,Syt=356,Cyt=14,Myt=20,Tyt=200;function ig(...t){return t.filter(Boolean).join(" ")}function Ayt(t){let[s,r]=t.split("-"),n=[];return s&&n.push(s),r&&n.push(r),n}var Eyt=t=>{var s,r,n,a,o,l,i,d,u,p,f;let{invert:y,toast:_,unstyled:b,interacting:N,setHeights:w,visibleToasts:k,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:ae,loadingIcon:ie,expandByDefault:oe,classNames:me,icons:ye,closeButtonAriaLabel:he="Close toast",pauseWhenPageIsHidden:ge}=t,[Ne,Ue]=xt.useState(null),[Te,Me]=xt.useState(null),[De,qe]=xt.useState(!1),[ke,$e]=xt.useState(!1),[Be,we]=xt.useState(!1),[ut,fe]=xt.useState(!1),[He,et]=xt.useState(!1),[tt,_e]=xt.useState(0),[Ge,We]=xt.useState(0),it=xt.useRef(_.duration||X||IEe),Ve=xt.useRef(null),Xe=xt.useRef(null),dt=A===0,pt=A+1<=k,Je=_.type,Ze=_.dismissible!==!1,Nt=_.className||"",Ot=_.descriptionClassName||"",Yt=xt.useMemo(()=>C.findIndex(lr=>lr.toastId===_.id)||0,[C,_.id]),Ps=xt.useMemo(()=>{var lr;return(lr=_.closeButton)!=null?lr:q},[_.closeButton,q]),$s=xt.useMemo(()=>_.duration||X||IEe,[_.duration,X]),Zs=xt.useRef(0),Dr=xt.useRef(0),$t=xt.useRef(0),Us=xt.useRef(null),[Nr,Xs]=ce.split("-"),kr=xt.useMemo(()=>C.reduce((lr,Fr,Wr)=>Wr>=Yt?lr:lr+Fr.height,0),[C,Yt]),fn=fyt(),Yr=_.invert||y,$r=Je==="loading";Dr.current=xt.useMemo(()=>Yt*ae+kr,[Yt,kr]),xt.useEffect(()=>{it.current=$s},[$s]),xt.useEffect(()=>{qe(!0)},[]),xt.useEffect(()=>{let lr=Xe.current;if(lr){let Fr=lr.getBoundingClientRect().height;return We(Fr),w(Wr=>[{toastId:_.id,height:Fr,position:_.position},...Wr]),()=>w(Wr=>Wr.filter(Nn=>Nn.toastId!==_.id))}},[w,_.id]),xt.useLayoutEffect(()=>{if(!De)return;let lr=Xe.current,Fr=lr.style.height;lr.style.height="auto";let Wr=lr.getBoundingClientRect().height;lr.style.height=Fr,We(Wr),w(Nn=>Nn.find(ai=>ai.toastId===_.id)?Nn.map(ai=>ai.toastId===_.id?{...ai,height:Wr}:ai):[{toastId:_.id,height:Wr,position:_.position},...Nn])},[De,_.title,_.description,w,_.id]);let Gr=xt.useCallback(()=>{$e(!0),_e(Dr.current),w(lr=>lr.filter(Fr=>Fr.toastId!==_.id)),setTimeout(()=>{O(_)},Tyt)},[_,O,w,Dr]);xt.useEffect(()=>{if(_.promise&&Je==="loading"||_.duration===1/0||_.type==="loading")return;let lr;return L||N||ge&&fn?(()=>{if($t.current{var Fr;(Fr=_.onAutoClose)==null||Fr.call(_,_),Gr()},it.current)),()=>clearTimeout(lr)},[L,N,_,Je,ge,fn,Gr]),xt.useEffect(()=>{_.delete&&Gr()},[Gr,_.delete]);function nr(){var lr,Fr,Wr;return ye!=null&&ye.loading?xt.createElement("div",{className:ig(me==null?void 0:me.loader,(lr=_==null?void 0:_.classNames)==null?void 0:lr.loader,"sonner-loader"),"data-visible":Je==="loading"},ye.loading):ie?xt.createElement("div",{className:ig(me==null?void 0:me.loader,(Fr=_==null?void 0:_.classNames)==null?void 0:Fr.loader,"sonner-loader"),"data-visible":Je==="loading"},ie):xt.createElement(cyt,{className:ig(me==null?void 0:me.loader,(Wr=_==null?void 0:_.classNames)==null?void 0:Wr.loader),visible:Je==="loading"})}return xt.createElement("li",{tabIndex:0,ref:Xe,className:ig(Y,Nt,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[Je],(r=_==null?void 0:_.classNames)==null?void 0:r[Je]),"data-sonner-toast":"","data-rich-colors":(n=_.richColors)!=null?n:V,"data-styled":!(_.jsx||_.unstyled||b),"data-mounted":De,"data-promise":!!_.promise,"data-swiped":He,"data-removed":ke,"data-visible":pt,"data-y-position":Nr,"data-x-position":Xs,"data-index":A,"data-front":dt,"data-swiping":Be,"data-dismissible":Ze,"data-type":Je,"data-invert":Yr,"data-swipe-out":ut,"data-swipe-direction":Te,"data-expanded":!!(L||oe&&De),style:{"--index":A,"--toasts-before":A,"--z-index":I.length-A,"--offset":`${ke?tt:Dr.current}px`,"--initial-height":oe?"auto":`${Ge}px`,...B,..._.style},onDragEnd:()=>{we(!1),Ue(null),Us.current=null},onPointerDown:lr=>{$r||!Ze||(Ve.current=new Date,_e(Dr.current),lr.target.setPointerCapture(lr.pointerId),lr.target.tagName!=="BUTTON"&&(we(!0),Us.current={x:lr.clientX,y:lr.clientY}))},onPointerUp:()=>{var lr,Fr,Wr,Nn;if(ut||!Ze)return;Us.current=null;let ai=Number(((lr=Xe.current)==null?void 0:lr.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),ns=Number(((Fr=Xe.current)==null?void 0:Fr.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),$n=new Date().getTime()-((Wr=Ve.current)==null?void 0:Wr.getTime()),dn=Ne==="x"?ai:ns,zr=Math.abs(dn)/$n;if(Math.abs(dn)>=Myt||zr>.11){_e(Dr.current),(Nn=_.onDismiss)==null||Nn.call(_,_),Me(Ne==="x"?ai>0?"right":"left":ns>0?"down":"up"),Gr(),fe(!0),et(!1);return}we(!1),Ue(null)},onPointerMove:lr=>{var Fr,Wr,Nn,ai;if(!Us.current||!Ze||((Fr=window.getSelection())==null?void 0:Fr.toString().length)>0)return;let ns=lr.clientY-Us.current.y,$n=lr.clientX-Us.current.x,dn=(Wr=t.swipeDirections)!=null?Wr:Ayt(ce);!Ne&&(Math.abs($n)>1||Math.abs(ns)>1)&&Ue(Math.abs($n)>Math.abs(ns)?"x":"y");let zr={x:0,y:0};Ne==="y"?(dn.includes("top")||dn.includes("bottom"))&&(dn.includes("top")&&ns<0||dn.includes("bottom")&&ns>0)&&(zr.y=ns):Ne==="x"&&(dn.includes("left")||dn.includes("right"))&&(dn.includes("left")&&$n<0||dn.includes("right")&&$n>0)&&(zr.x=$n),(Math.abs(zr.x)>0||Math.abs(zr.y)>0)&&et(!0),(Nn=Xe.current)==null||Nn.style.setProperty("--swipe-amount-x",`${zr.x}px`),(ai=Xe.current)==null||ai.style.setProperty("--swipe-amount-y",`${zr.y}px`)}},Ps&&!_.jsx?xt.createElement("button",{"aria-label":he,"data-disabled":$r,"data-close-button":!0,onClick:$r||!Ze?()=>{}:()=>{var lr;Gr(),(lr=_.onDismiss)==null||lr.call(_,_)},className:ig(me==null?void 0:me.closeButton,(a=_==null?void 0:_.classNames)==null?void 0:a.closeButton)},(o=ye==null?void 0:ye.close)!=null?o:pyt):null,_.jsx||S.isValidElement(_.title)?_.jsx?_.jsx:typeof _.title=="function"?_.title():_.title:xt.createElement(xt.Fragment,null,Je||_.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||(ye==null?void 0:ye[Je])||oyt(Je):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,Ot,me==null?void 0:me.description,(u=_==null?void 0:_.classNames)==null?void 0:u.description)},typeof _.description=="function"?_.description():_.description):null),S.isValidElement(_.cancel)?_.cancel:_.cancel&&fz(_.cancel)?xt.createElement("button",{"data-button":!0,"data-cancel":!0,style:_.cancelButtonStyle||U,onClick:lr=>{var Fr,Wr;fz(_.cancel)&&Ze&&((Wr=(Fr=_.cancel).onClick)==null||Wr.call(Fr,lr),Gr())},className:ig(me==null?void 0:me.cancelButton,(p=_==null?void 0:_.classNames)==null?void 0:p.cancelButton)},_.cancel.label):null,S.isValidElement(_.action)?_.action:_.action&&fz(_.action)?xt.createElement("button",{"data-button":!0,"data-action":!0,style:_.actionButtonStyle||te,onClick:lr=>{var Fr,Wr;fz(_.action)&&((Wr=(Fr=_.action).onClick)==null||Wr.call(Fr,lr),!lr.defaultPrevented&&Gr())},className:ig(me==null?void 0:me.actionButton,(f=_==null?void 0:_.classNames)==null?void 0:f.actionButton)},_.action.label):null))};function LEe(){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 Pyt(t,s){let r={};return[t,s].forEach((n,a)=>{let o=a===1,l=o?"--mobile-offset":"--offset",i=o?kyt:Nyt;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 Iyt=S.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=jyt,toastOptions:N,dir:w=LEe(),gap:k=Cyt,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,ae]=xt.useState(p!=="system"?p:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),ie=xt.useRef(null),oe=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),me=xt.useRef(null),ye=xt.useRef(!1),he=xt.useCallback(ge=>{V(Ne=>{var Ue;return(Ue=Ne.find(Te=>Te.id===ge.id))!=null&&Ue.delete||Jm.dismiss(ge.id),Ne.filter(({id:Te})=>Te!==ge.id)})},[]);return xt.useEffect(()=>Jm.subscribe(ge=>{if(ge.dismiss){V(Ne=>Ne.map(Ue=>Ue.id===ge.id?{...Ue,delete:!0}:Ue));return}setTimeout(()=>{eje.flushSync(()=>{V(Ne=>{let Ue=Ne.findIndex(Te=>Te.id===ge.id);return Ue!==-1?[...Ne.slice(0,Ue),{...Ne[Ue],...ge},...Ne.slice(Ue+1)]:[ge,...Ne]})})})}),[]),xt.useEffect(()=>{if(p!=="system"){ae(p);return}if(p==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?ae("dark"):ae("light")),typeof window>"u")return;let ge=window.matchMedia("(prefers-color-scheme: dark)");try{ge.addEventListener("change",({matches:Ne})=>{ae(Ne?"dark":"light")})}catch{ge.addListener(({matches:Ue})=>{try{ae(Ue?"dark":"light")}catch(Te){console.error(Te)}})}},[p]),xt.useEffect(()=>{O.length<=1&&Y(!1)},[O]),xt.useEffect(()=>{let ge=Ne=>{var Ue,Te;a.every(Me=>Ne[Me]||Ne.code===Me)&&(Y(!0),(Ue=ie.current)==null||Ue.focus()),Ne.code==="Escape"&&(document.activeElement===ie.current||(Te=ie.current)!=null&&Te.contains(document.activeElement))&&Y(!1)};return document.addEventListener("keydown",ge),()=>document.removeEventListener("keydown",ge)},[a]),xt.useEffect(()=>{if(ie.current)return()=>{me.current&&(me.current.focus({preventScroll:!0}),me.current=null,ye.current=!1)}},[ie.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,Ne)=>{var Ue;let[Te,Me]=ge.split("-");return O.length?xt.createElement("ol",{key:ge,dir:w==="auto"?LEe():w,tabIndex:-1,ref:ie,className:i,"data-sonner-toaster":!0,"data-theme":ce,"data-y-position":Te,"data-lifted":te&&O.length>1&&!o,"data-x-position":Me,style:{"--front-toast-height":`${((Ue=B[0])==null?void 0:Ue.height)||0}px`,"--width":`${Syt}px`,"--gap":`${k}px`,..._,...Pyt(d,u)},onBlur:De=>{ye.current&&!De.currentTarget.contains(De.relatedTarget)&&(ye.current=!1,me.current&&(me.current.focus({preventScroll:!0}),me.current=null))},onFocus:De=>{De.target instanceof HTMLElement&&De.target.dataset.dismissible==="false"||ye.current||(ye.current=!0,me.current=De.relatedTarget)},onMouseEnter:()=>Y(!0),onMouseMove:()=>Y(!0),onMouseLeave:()=>{J||Y(!1)},onDragEnd:()=>Y(!1),onPointerDown:De=>{De.target instanceof HTMLElement&&De.target.dataset.dismissible==="false"||X(!0)},onPointerUp:()=>X(!1)},O.filter(De=>!De.position&&Ne===0||De.position===ge).map((De,qe)=>{var ke,$e;return xt.createElement(Eyt,{key:De.id,icons:A,index:qe,toast:De,defaultRichColors:f,duration:(ke=N==null?void 0:N.duration)!=null?ke:y,className:N==null?void 0:N.className,descriptionClassName:N==null?void 0:N.descriptionClassName,invert:r,visibleToasts:b,closeButton:($e=N==null?void 0:N.closeButton)!=null?$e: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(Be=>Be.position==De.position),heights:B.filter(Be=>Be.position==De.position),setHeights:U,expandByDefault:o,gap:k,loadingIcon:C,expanded:te,pauseWhenPageIsHidden:L,swipeDirections:t.swipeDirections})})):null}))});const Lyt=({...t})=>{const{theme:s="system"}=iyt();return e.jsx(Iyt,{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 Dyt=c2e[" useId ".trim().toString()]||(()=>{}),Ryt=0;function fu(t){const[s,r]=S.useState(Dyt());return ad(()=>{r(n=>n??String(Ryt++))},[t]),s?`radix-${s}`:""}const Oyt=["top","right","bottom","left"],Gb=Math.min,Yp=Math.max,Doe=Math.round,xz=Math.floor,Wb=t=>({x:t,y:t}),Fyt={left:"right",right:"left",bottom:"top",top:"bottom"},zyt={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 Byt(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=Roe(l)),[l,Roe(l)]}function $yt(t){const s=Roe(t);return[Ave(t),s,Ave(s)]}function Ave(t){return t.replace(/start|end/g,s=>zyt[s])}function qyt(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 Uyt(t,s,r,n){const a=DA(t);let o=qyt(f1(t),r==="start",n);return a&&(o=o.map(l=>l+"-"+a),s&&(o=o.concat(o.map(Ave)))),o}function Roe(t){return t.replace(/left|right|bottom|top/g,s=>Fyt[s])}function Vyt(t){return{top:0,right:0,bottom:0,left:0,...t}}function fUe(t){return typeof t!="number"?Vyt(t):{top:t,right:t,bottom:t,left:t}}function Ooe(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 DEe(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 Hyt=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}=DEe(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",k=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[k],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),ae=!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 ae=(Y=U.filter(ie=>ie.overflows[0]<=0).sort((ie,oe)=>ie.overflows[1]-oe.overflows[1])[0])==null?void 0:Y.placement;if(!ae)switch(_){case"bestFit":{var J;const ie=(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,ye)=>me+ye,0)]).sort((oe,me)=>oe[1]-me[1])[0])==null?void 0:J[0];ie&&(ae=ie);break}case"initialPlacement":ae=i;break}if(a!==ae)return{reset:{placement:ae}}}return{}}}};function REe(t,s){return{top:t.top-s.height,right:t.right-s.width,bottom:t.bottom-s.height,left:t.left-s.width}}function OEe(t){return Oyt.some(s=>t[s]>=0)}const Kyt=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=REe(o,r.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:OEe(l)}}}case"escaped":{const o=await Z8(s,{...a,altBoundary:!0}),l=REe(o,r.floating);return{data:{escapedOffsets:l,escaped:OEe(l)}}}default:return{}}}}};async function Zyt(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 Yyt=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 Zyt(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}}}}},Xyt=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:k,y:C}=w;return{x:k,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",k=y==="y"?"bottom":"right",C=_+p[w],A=_-p[k];_=Tve(C,_,A)}if(l){const w=f==="y"?"top":"left",k=f==="y"?"bottom":"right",C=b+p[w],A=b-p[k];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}}}}}},Qyt=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 k,C;const A=y==="y"?"width":"height",I=["top","left"].includes(f1(a)),L=o.reference[f]-o.floating[A]+(I&&((k=l.offset)==null?void 0:k[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}}}},Jyt=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,k;f==="top"||f==="bottom"?(w=f,k=y===(await(l.isRTL==null?void 0:l.isRTL(i.floating))?"start":"end")?"left":"right"):(k=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[k],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 Qde(){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 Qde()?t instanceof Node||t instanceof of(t).Node:!1}function zg(t){return Qde()?t instanceof Element||t instanceof of(t).Element:!1}function h0(t){return Qde()?t instanceof HTMLElement||t instanceof of(t).HTMLElement:!1}function FEe(t){return!Qde()||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 e0t(t){return["table","td","th"].includes(RA(t))}function Jde(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 t0t(t){let s=Zb(t);for(;h0(s)&&!ST(s);){if(uje(s))return s;if(Jde(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 eue(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||FEe(t)&&t.host||b0(t);return FEe(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=Doe(r)!==o||Doe(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?Doe(r.width):r.width)/n,i=(o?Doe(r.height):r.height)/a;return(!l||!Number.isFinite(l))&&(l=1),(!i||!Number.isFinite(i))&&(i=1),{x:l,y:i}}const s0t=Wb(0);function vUe(t){const s=of(t);return!hje()||!s.visualViewport?s0t:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function r0t(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=r0t(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),k=N.getBoundingClientRect(),C=Bg(N),A=k.left+(N.clientLeft+parseFloat(C.paddingLeft))*w.x,I=k.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 Ooe({width:p,height:f,x:d,y:u})}function n0t(t){let{elements:s,rect:r,offsetParent:n,strategy:a}=t;const o=a==="fixed",l=b0(n),i=s?Jde(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=eue(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 a0t(t){return Array.from(t.getClientRects())}function Pve(t,s){const r=eue(t).scrollLeft;return s?s.left+r:US(b0(t)).left+r}function i0t(t){const s=b0(t),r=eue(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 o0t(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 l0t(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 zEe(t,s,r){let n;if(s==="viewport")n=o0t(t,r);else if(s==="document")n=i0t(b0(t));else if(zg(s))n=l0t(s,r);else{const a=vUe(t);n={...s,x:s.x-a.x,y:s.y-a.y}}return Ooe(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 c0t(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 d0t(t){let{element:s,boundary:r,rootBoundary:n,strategy:a}=t;const l=[...r==="clippingAncestors"?Jde(s)?[]:c0t(s,this._c):[].concat(r),n],i=l[0],d=l.reduce((u,p)=>{const f=zEe(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},zEe(s,i,a));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function u0t(t){const{width:s,height:r}=yUe(t);return{width:s,height:r}}function h0t(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=eue(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 Kxe(t){return Bg(t).position==="static"}function BEe(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(Jde(t))return r;if(!h0(t)){let a=Zb(t);for(;a&&!ST(a);){if(zg(a)&&!Kxe(a))return a;a=Zb(a)}return r}let n=BEe(t,s);for(;n&&e0t(n)&&Kxe(n);)n=BEe(n,s);return n&&ST(n)&&Kxe(n)&&!uje(n)?r:n||t0t(t)||r}const m0t=async function(t){const s=this.getOffsetParent||bUe,r=this.getDimensions,n=await r(t.floating);return{reference:h0t(t.reference,await s(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function p0t(t){return Bg(t).direction==="rtl"}const f0t={convertOffsetParentRelativeRectToViewportRelativeRect:n0t,getDocumentElement:b0,getClippingRect:d0t,getOffsetParent:bUe,getElementRects:m0t,getClientRects:a0t,getDimensions:u0t,getScale:$M,isElement:zg,isRTL:p0t};function x0t(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 _=xz(p),b=xz(a.clientWidth-(u+f)),N=xz(a.clientHeight-(p+y)),w=xz(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 g0t(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(k=>{a&&k.addEventListener("scroll",r,{passive:!0}),o&&k.addEventListener("resize",r)});const f=u&&i?x0t(u,r):null;let y=-1,_=null;l&&(_=new ResizeObserver(k=>{let[C]=k;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 k=US(t);N&&(k.x!==N.x||k.y!==N.y||k.width!==N.width||k.height!==N.height)&&r(),N=k,b=requestAnimationFrame(w)}return r(),()=>{var k;p.forEach(C=>{a&&C.removeEventListener("scroll",r),o&&C.removeEventListener("resize",r)}),f==null||f(),(k=_)==null||k.disconnect(),_=null,d&&cancelAnimationFrame(b)}}const y0t=Yyt,v0t=Xyt,_0t=Wyt,b0t=Jyt,w0t=Kyt,$Ee=Gyt,j0t=Qyt,N0t=(t,s,r)=>{const n=new Map,a={platform:f0t,...r},o={...a.platform,_c:n};return Hyt(t,s,{...a,platform:o})};var Iie=typeof document<"u"?S.useLayoutEffect:S.useEffect;function Foe(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(!Foe(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)&&!Foe(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 qEe(t,s){const r=wUe(t);return Math.round(s*r)/r}function Zxe(t){const s=S.useRef(t);return Iie(()=>{s.current=t}),s}function k0t(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]=S.useState({x:0,y:0,strategy:r,placement:s,middlewareData:{},isPositioned:!1}),[y,_]=S.useState(n);Foe(y,n)||_(n);const[b,N]=S.useState(null),[w,k]=S.useState(null),C=S.useCallback(oe=>{oe!==O.current&&(O.current=oe,N(oe))},[]),A=S.useCallback(oe=>{oe!==V.current&&(V.current=oe,k(oe))},[]),I=o||b,L=l||w,O=S.useRef(null),V=S.useRef(null),q=S.useRef(p),B=d!=null,U=Zxe(d),te=Zxe(a),Y=Zxe(u),J=S.useCallback(()=>{if(!O.current||!V.current)return;const oe={placement:s,strategy:r,middleware:y};te.current&&(oe.platform=te.current),N0t(O.current,V.current,oe).then(me=>{const ye={...me,isPositioned:Y.current!==!1};X.current&&!Foe(q.current,ye)&&(q.current=ye,ip.flushSync(()=>{f(ye)}))})},[y,s,r,te,Y]);Iie(()=>{u===!1&&q.current.isPositioned&&(q.current.isPositioned=!1,f(oe=>({...oe,isPositioned:!1})))},[u]);const X=S.useRef(!1);Iie(()=>(X.current=!0,()=>{X.current=!1}),[]),Iie(()=>{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=S.useMemo(()=>({reference:O,floating:V,setReference:C,setFloating:A}),[C,A]),ae=S.useMemo(()=>({reference:I,floating:L}),[I,L]),ie=S.useMemo(()=>{const oe={position:r,left:0,top:0};if(!ae.floating)return oe;const me=qEe(ae.floating,p.x),ye=qEe(ae.floating,p.y);return i?{...oe,transform:"translate("+me+"px, "+ye+"px)",...wUe(ae.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:me,top:ye}},[r,i,ae.floating,p.x,p.y]);return S.useMemo(()=>({...p,update:J,refs:ce,elements:ae,floatingStyles:ie}),[p,J,ce,ae,ie])}const S0t=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?$Ee({element:n.current,padding:a}).fn(r):{}:n?$Ee({element:n,padding:a}).fn(r):{}}}},C0t=(t,s)=>({...y0t(t),options:[t,s]}),M0t=(t,s)=>({...v0t(t),options:[t,s]}),T0t=(t,s)=>({...j0t(t),options:[t,s]}),A0t=(t,s)=>({..._0t(t),options:[t,s]}),E0t=(t,s)=>({...b0t(t),options:[t,s]}),P0t=(t,s)=>({...w0t(t),options:[t,s]}),I0t=(t,s)=>({...S0t(t),options:[t,s]});var L0t="Arrow",jUe=S.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=L0t;var D0t=jUe;function kR(t){const[s,r]=S.useState(void 0);return ad(()=>{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),[R0t,kUe]=NUe(pje),SUe=t=>{const{__scopePopper:s,children:r}=t,[n,a]=S.useState(null);return e.jsx(R0t,{scope:s,anchor:n,onAnchorChange:a,children:r})};SUe.displayName=pje;var CUe="PopperAnchor",MUe=S.forwardRef((t,s)=>{const{__scopePopper:r,virtualRef:n,...a}=t,o=kUe(CUe,r),l=S.useRef(null),i=Ta(s,l);return S.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",[O0t,F0t]=NUe(fje),TUe=S.forwardRef((t,s)=>{var De,qe,ke,$e,Be,we;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),[k,C]=S.useState(null),A=Ta(s,ut=>C(ut)),[I,L]=S.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(B0t),altBoundary:Y},{refs:X,floatingStyles:ce,placement:ae,isPositioned:ie,middlewareData:oe}=k0t({strategy:"fixed",placement:B,whileElementsMounted:(...ut)=>g0t(...ut,{animationFrame:_==="always"}),elements:{reference:w.anchor},middleware:[C0t({mainAxis:a+q,alignmentAxis:l}),d&&M0t({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?T0t():void 0,...J}),d&&A0t({...J}),E0t({...J,apply:({elements:ut,rects:fe,availableWidth:He,availableHeight:et})=>{const{width:tt,height:_e}=fe.reference,Ge=ut.floating.style;Ge.setProperty("--radix-popper-available-width",`${He}px`),Ge.setProperty("--radix-popper-available-height",`${et}px`),Ge.setProperty("--radix-popper-anchor-width",`${tt}px`),Ge.setProperty("--radix-popper-anchor-height",`${_e}px`)}}),I&&I0t({element:I,padding:i}),$0t({arrowWidth:V,arrowHeight:q}),y&&P0t({strategy:"referenceHidden",...J})]}),[me,ye]=PUe(ae),he=ed(b);ad(()=>{ie&&(he==null||he())},[ie,he]);const ge=(De=oe.arrow)==null?void 0:De.x,Ne=(qe=oe.arrow)==null?void 0:qe.y,Ue=((ke=oe.arrow)==null?void 0:ke.centerOffset)!==0,[Te,Me]=S.useState();return ad(()=>{k&&Me(window.getComputedStyle(k).zIndex)},[k]),e.jsx("div",{ref:X.setFloating,"data-radix-popper-content-wrapper":"",style:{...ce,transform:ie?ce.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Te,"--radix-popper-transform-origin":[($e=oe.transformOrigin)==null?void 0:$e.x,(Be=oe.transformOrigin)==null?void 0:Be.y].join(" "),...((we=oe.hide)==null?void 0:we.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:e.jsx(O0t,{scope:r,placedSide:me,onArrowChange:L,arrowX:ge,arrowY:Ne,shouldHideArrow:Ue,children:e.jsx(Jr.div,{"data-side":me,"data-align":ye,...N,ref:A,style:{...N.style,animation:ie?void 0:"none"}})})})});TUe.displayName=fje;var AUe="PopperArrow",z0t={top:"bottom",right:"left",bottom:"top",left:"right"},EUe=S.forwardRef(function(s,r){const{__scopePopper:n,...a}=s,o=F0t(AUe,n),l=z0t[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(D0t,{...a,ref:r,style:{...a.style,display:"block"}})})});EUe.displayName=AUe;function B0t(t){return t!==null}var $0t=t=>({name:"transformOrigin",options:t,fn(s){var w,k,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=(((k=a.arrow)==null?void 0:k.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,[tue,RTs]=qc("Tooltip",[w0]),sue=w0(),IUe="TooltipProvider",q0t=700,Ive="tooltip.open",[U0t,xje]=tue(IUe),LUe=t=>{const{__scopeTooltip:s,delayDuration:r=q0t,skipDelayDuration:n=300,disableHoverableContent:a=!1,children:o}=t,l=S.useRef(!0),i=S.useRef(!1),d=S.useRef(0);return S.useEffect(()=>{const u=d.current;return()=>window.clearTimeout(u)},[]),e.jsx(U0t,{scope:s,isOpenDelayedRef:l,delayDuration:r,onOpen:S.useCallback(()=>{window.clearTimeout(d.current),l.current=!1},[]),onClose:S.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>l.current=!0,n)},[n]),isPointerInTransitRef:i,onPointerInTransitChange:S.useCallback(u=>{i.current=u},[]),disableHoverableContent:a,children:o})};LUe.displayName=IUe;var X8="Tooltip",[V0t,rue]=tue(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=sue(s),[p,f]=S.useState(null),y=fu(),_=S.useRef(0),b=l??d.disableHoverableContent,N=i??d.delayDuration,w=S.useRef(!1),[k,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=S.useMemo(()=>k?w.current?"delayed-open":"instant-open":"closed",[k]),I=S.useCallback(()=>{window.clearTimeout(_.current),_.current=0,w.current=!1,C(!0)},[C]),L=S.useCallback(()=>{window.clearTimeout(_.current),_.current=0,C(!1)},[C]),O=S.useCallback(()=>{window.clearTimeout(_.current),_.current=window.setTimeout(()=>{w.current=!0,C(!0),_.current=0},N)},[N,C]);return S.useEffect(()=>()=>{_.current&&(window.clearTimeout(_.current),_.current=0)},[]),e.jsx(SR,{...u,children:e.jsx(V0t,{scope:s,contentId:y,open:k,stateAttribute:A,trigger:p,onTriggerChange:f,onTriggerEnter:S.useCallback(()=>{d.isOpenDelayedRef.current?O():I()},[d.isOpenDelayedRef,O,I]),onTriggerLeave:S.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=S.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=rue(Lve,r),o=xje(Lve,r),l=sue(r),i=S.useRef(null),d=Ta(s,i,a.onTriggerChange),u=S.useRef(!1),p=S.useRef(!1),f=S.useCallback(()=>u.current=!1,[]);return S.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:Sr(t.onPointerMove,y=>{y.pointerType!=="touch"&&!p.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),p.current=!0)}),onPointerLeave:Sr(t.onPointerLeave,()=>{a.onTriggerLeave(),p.current=!1}),onPointerDown:Sr(t.onPointerDown,()=>{a.open&&a.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Sr(t.onFocus,()=>{u.current||a.onOpen()}),onBlur:Sr(t.onBlur,a.onClose),onClick:Sr(t.onClick,a.onClose)})})});RUe.displayName=Lve;var H0t="TooltipPortal",[OTs,G0t]=tue(H0t,{forceMount:void 0}),CT="TooltipContent",OUe=S.forwardRef((t,s)=>{const r=G0t(CT,t.__scopeTooltip),{forceMount:n=r.forceMount,side:a="top",...o}=t,l=rue(CT,t.__scopeTooltip);return e.jsx(jd,{present:n||l.open,children:l.disableHoverableContent?e.jsx(FUe,{side:a,...o,ref:s}):e.jsx(W0t,{side:a,...o,ref:s})})}),W0t=S.forwardRef((t,s)=>{const r=rue(CT,t.__scopeTooltip),n=xje(CT,t.__scopeTooltip),a=S.useRef(null),o=Ta(s,a),[l,i]=S.useState(null),{trigger:d,onClose:u}=r,p=a.current,{onPointerInTransitChange:f}=n,y=S.useCallback(()=>{i(null),f(!1)},[f]),_=S.useCallback((b,N)=>{const w=b.currentTarget,k={x:b.clientX,y:b.clientY},C=Q0t(k,w.getBoundingClientRect()),A=J0t(k,C),I=evt(N.getBoundingClientRect()),L=svt([...A,...I]);i(L),f(!0)},[f]);return S.useEffect(()=>()=>y(),[y]),S.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]),S.useEffect(()=>{if(l){const b=N=>{const w=N.target,k={x:N.clientX,y:N.clientY},C=(d==null?void 0:d.contains(w))||(p==null?void 0:p.contains(w)),A=!tvt(k,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})}),[K0t,Z0t]=tue(X8,{isInside:!1}),Y0t=Pqe("TooltipContent"),FUe=S.forwardRef((t,s)=>{const{__scopeTooltip:r,children:n,"aria-label":a,onEscapeKeyDown:o,onPointerDownOutside:l,...i}=t,d=rue(CT,r),u=sue(r),{onClose:p}=d;return S.useEffect(()=>(document.addEventListener(Ive,p),()=>document.removeEventListener(Ive,p)),[p]),S.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(Y0t,{children:n}),e.jsx(K0t,{scope:r,isInside:!0,children:e.jsx(Jxt,{id:d.contentId,role:"tooltip",children:a||n})})]})})});OUe.displayName=CT;var zUe="TooltipArrow",X0t=S.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=sue(r);return Z0t(zUe,r).isInside?null:e.jsx(MR,{...a,...n,ref:s})});X0t.displayName=zUe;function Q0t(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 J0t(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 evt(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 tvt(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 svt(t){const s=t.slice();return s.sort((r,n)=>r.xn.x?1:r.yn.y?1:0),rvt(s)}function rvt(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 nvt=LUe,avt=DUe,ivt=RUe,BUe=OUe;const S1=nvt,Jl=avt,ec=ivt,Ll=S.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(BUe,{ref:n,sideOffset:s,className:Dt("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}));Ll.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 ovt(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 UEe(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 VEe(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=HEe(t)&&HEe(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 cvt(t,s,r=0){const n=[...t,s];return r&&n.length>r?n.slice(1):n}function dvt(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,uvt=(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(){ds(this,Y_)||this.setEventListener(ds(this,oT))}onUnsubscribe(){var s;this.hasListeners()||((s=ds(this,Y_))==null||s.call(this),zn(this,Y_,void 0))}setEventListener(s){var r;zn(this,oT,s),(r=ds(this,Y_))==null||r.call(this),zn(this,Y_,s(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(s){ds(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 ds(this,P4)=="boolean"?ds(this,P4):((s=globalThis.document)==null?void 0:s.visibilityState)!=="hidden"}},P4=new WeakMap,Y_=new WeakMap,oT=new WeakMap,oBe),vje=new uvt,lT,X_,cT,lBe,hvt=(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(){ds(this,X_)||this.setEventListener(ds(this,cT))}onUnsubscribe(){var s;this.hasListeners()||((s=ds(this,X_))==null||s.call(this),zn(this,X_,void 0))}setEventListener(s){var r;zn(this,cT,s),(r=ds(this,X_))==null||r.call(this),zn(this,X_,s(this.setOnline.bind(this)))}setOnline(s){ds(this,lT)!==s&&(zn(this,lT,s),this.listeners.forEach(n=>{n(s)}))}isOnline(){return ds(this,lT)}},lT=new WeakMap,X_=new WeakMap,cT=new WeakMap,lBe),Boe=new hvt;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 mvt(t){return Math.min(1e3*2**t,3e4)}function HUe(t){return(t??"online")==="online"?Boe.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 Yxe(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"||Boe.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=k=>{(n||u())&&N(k)},(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(k){N=Promise.reject(k)}Promise.resolve(N).then(f).catch(k=>{var O;if(n)return;const C=t.retry??(VS?0:3),A=t.retryDelay??mvt,I=typeof A=="function"?A(r,k):A,L=C===!0||typeof C=="number"&&ru()?void 0:_()).then(()=>{s?y(k):b()})})};return{promise:o,cancel:l,continue:()=>(a==null||a(),o),cancelRetry:i,continueRetry:d,canStart:p,start:()=>(p()?b():_().then(b),o)}}var pvt=t=>setTimeout(t,0);function fvt(){let t=[],s=0,r=i=>{i()},n=i=>{i()},a=pvt;const o=i=>{s?t.push(i):a(()=>{r(i)})},l=()=>{const i=t;t=[],i.length&&a(()=>{n(()=>{i.forEach(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=fvt(),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(){ds(this,I4)&&(clearTimeout(ds(this,I4)),zn(this,I4,void 0))}},I4=new WeakMap,cBe),dT,L4,Jf,D4,Sh,mR,R4,mg,_v,dBe,xvt=(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,ds(this,D4).getQueryCache()),this.queryKey=s.queryKey,this.queryHash=s.queryHash,zn(this,dT,gvt(this.options)),this.state=s.state??ds(this,dT),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var s;return(s=ds(this,Sh))==null?void 0:s.promise}setOptions(s){this.options={...ds(this,mR),...s},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&ds(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=ds(this,Sh))==null?void 0:n.promise;return(a=ds(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(ds(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=ds(this,Sh))==null||r.continue()}onOnline(){var r;const s=this.observers.find(n=>n.shouldFetchOnReconnect());s==null||s.refetch({cancelRefetch:!1}),(r=ds(this,Sh))==null||r.continue()}addObserver(s){this.observers.includes(s)||(this.observers.push(s),this.clearGcTimeout(),ds(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||(ds(this,Sh)&&(ds(this,R4)?ds(this,Sh).cancel({revert:!0}):ds(this,Sh).cancelRetry()),this.scheduleGc()),ds(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(ds(this,Sh))return ds(this,Sh).continueRetry(),ds(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:ds(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:ds(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;Yxe(y)&&y.silent||Ii(this,mg,_v).call(this,{type:"error",error:y}),Yxe(y)||((b=(_=ds(this,Jf).config).onError)==null||b.call(_,y,this),(w=(N=ds(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(k){d(k);return}(b=(_=ds(this,Jf).config).onSuccess)==null||b.call(_,y,this),(w=(N=ds(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})),ds(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 Yxe(a)&&a.revert&&ds(this,L4)?{...ds(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()}),ds(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 gvt(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,yvt=(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 xvt({client:s,queryKey:a,queryHash:o,options:s.defaultQueryOptions(r),state:n,defaultOptions:s.getQueryDefaults(a)}),this.add(l)),l}add(s){ds(this,Iy).has(s.queryHash)||(ds(this,Iy).set(s.queryHash,s),this.notify({type:"added",query:s}))}remove(s){const r=ds(this,Iy).get(s.queryHash);r&&(s.destroy(),r===s&&ds(this,Iy).delete(s.queryHash),this.notify({type:"removed",query:s}))}clear(){nu.batch(()=>{this.getAll().forEach(s=>{this.remove(s)})})}get(s){return ds(this,Iy).get(s)}getAll(){return[...ds(this,Iy).values()]}find(s){const r={exact:!0,...s};return this.getAll().find(n=>UEe(r,n))}findAll(s={}){const r=this.getAll();return Object.keys(s).length>0?r.filter(n=>UEe(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,vvt=(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){ds(this,Ly).includes(s)||(ds(this,Ly).push(s),this.clearGcTimeout(),ds(this,um).notify({type:"observerAdded",mutation:this,observer:s}))}removeObserver(s){zn(this,Ly,ds(this,Ly).filter(r=>r!==s)),this.scheduleGc(),ds(this,um).notify({type:"observerRemoved",mutation:this,observer:s})}optionalRemove(){ds(this,Ly).length||(this.state.status==="pending"?this.scheduleGc():ds(this,um).remove(this))}continue(){var s;return((s=ds(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,k,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:()=>ds(this,um).canRun(this)}));const n=this.state.status==="pending",a=!ds(this,O4).canStart();try{if(n)r();else{Ii(this,Dy,w_).call(this,{type:"pending",variables:s,isPaused:a}),await((l=(o=ds(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 ds(this,O4).start();return await((p=(u=ds(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=(_=ds(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=(k=ds(this,um).config).onError)==null?void 0:C.call(k,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=ds(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{ds(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(()=>{ds(this,Ly).forEach(n=>{n.onMutationUpdate(s)}),ds(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,_vt=(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 vvt({mutationCache:this,mutationId:++Z7(this,pR)._,options:s.defaultMutationOptions(r),state:n});return this.add(a),a}add(s){ds(this,Lv).add(s);const r=gz(s);if(typeof r=="string"){const n=ds(this,pg).get(r);n?n.push(s):ds(this,pg).set(r,[s])}this.notify({type:"added",mutation:s})}remove(s){if(ds(this,Lv).delete(s)){const r=gz(s);if(typeof r=="string"){const n=ds(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&&ds(this,pg).delete(r)}}this.notify({type:"removed",mutation:s})}canRun(s){const r=gz(s);if(typeof r=="string"){const n=ds(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=gz(s);if(typeof r=="string"){const a=(n=ds(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(()=>{ds(this,Lv).forEach(s=>{this.notify({type:"removed",mutation:s})}),ds(this,Lv).clear(),ds(this,pg).clear()})}getAll(){return Array.from(ds(this,Lv))}find(s){const r={exact:!0,...s};return this.getAll().find(n=>VEe(r,n))}findAll(s={}){return this.getAll().filter(r=>VEe(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 gz(t){var s;return(s=t.options.scope)==null?void 0:s.id}function $oe(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)})},k=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 k(V),{maxPages:B}=s.options,U=L?dvt:cvt;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 bvt(t,s){return s?zve(t,s)!=null:!1}function wvt(t,s){return!s||!t.getPreviousPageParam?!1:XUe(t,s)!=null}var Gc,Q_,J_,uT,hT,eb,mT,pT,pBe,jvt=(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 yvt),zn(this,Q_,t.mutationCache||new _vt),zn(this,J_,t.defaultOptions||{}),zn(this,uT,new Map),zn(this,hT,new Map),zn(this,eb,0)}mount(){Z7(this,eb)._++,ds(this,eb)===1&&(zn(this,mT,vje.subscribe(async t=>{t&&(await this.resumePausedMutations(),ds(this,Gc).onFocus())})),zn(this,pT,Boe.subscribe(async t=>{t&&(await this.resumePausedMutations(),ds(this,Gc).onOnline())})))}unmount(){var t,s;Z7(this,eb)._--,ds(this,eb)===0&&((t=ds(this,mT))==null||t.call(this),zn(this,mT,void 0),(s=ds(this,pT))==null||s.call(this),zn(this,pT,void 0))}isFetching(t){return ds(this,Gc).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return ds(this,Q_).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=ds(this,Gc).get(s.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const s=this.defaultQueryOptions(t),r=ds(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 ds(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=ds(this,Gc).get(n.queryHash),o=a==null?void 0:a.state.data,l=ovt(s,o);if(l!==void 0)return ds(this,Gc).build(this,n).setData(l,{...r,manual:!0})}setQueriesData(t,s,r){return nu.batch(()=>ds(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=ds(this,Gc).get(s.queryHash))==null?void 0:r.state}removeQueries(t){const s=ds(this,Gc);nu.batch(()=>{s.findAll(t).forEach(r=>{s.remove(r)})})}resetQueries(t,s){const r=ds(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(()=>ds(this,Gc).findAll(t).map(a=>a.cancel(r)));return Promise.all(n).then(pm).catch(pm)}invalidateQueries(t,s={}){return nu.batch(()=>(ds(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(()=>ds(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=ds(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=$oe(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(pm).catch(pm)}ensureInfiniteQueryData(t){return t.behavior=$oe(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return Boe.isOnline()?ds(this,Q_).resumePausedMutations():Promise.resolve()}getQueryCache(){return ds(this,Gc)}getMutationCache(){return ds(this,Q_)}getDefaultOptions(){return ds(this,J_)}setDefaultOptions(t){zn(this,J_,t)}setQueryDefaults(t,s){ds(this,uT).set(HS(t),{queryKey:t,defaultOptions:s})}getQueryDefaults(t){const s=[...ds(this,uT).values()],r={};return s.forEach(n=>{Q8(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,s){ds(this,hT).set(HS(t),{mutationKey:t,defaultOptions:s})}getMutationDefaults(t){const s=[...ds(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={...ds(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:{...ds(this,J_).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){ds(this,Gc).clear(),ds(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),Ym,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,Ym);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,Ym,s),zn(this,sb,null),zn(this,tb,Fve()),this.options.experimental_prefetchInRender||ds(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&&(ds(this,eo).addObserver(this),WEe(ds(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(ds(this,eo),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Wve(ds(this,eo),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ii(this,Uo,Vve).call(this),Ii(this,Uo,Hve).call(this),ds(this,eo).removeObserver(this)}setOptions(s){const r=this.options,n=ds(this,eo);if(this.options=ds(this,Ym).defaultQueryOptions(s),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ex(this.options.enabled,ds(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),ds(this,eo).setOptions(this.options),r._defaulted&&!zoe(this.options,r)&&ds(this,Ym).getQueryCache().notify({type:"observerOptionsUpdated",query:ds(this,eo),observer:this});const a=this.hasListeners();a&&KEe(ds(this,eo),n,this.options,r)&&Ii(this,Uo,AI).call(this),this.updateResult(),a&&(ds(this,eo)!==n||ex(this.options.enabled,ds(this,eo))!==ex(r.enabled,ds(this,eo))||Pb(this.options.staleTime,ds(this,eo))!==Pb(r.staleTime,ds(this,eo)))&&Ii(this,Uo,Bve).call(this);const o=Ii(this,Uo,$ve).call(this);a&&(ds(this,eo)!==n||ex(this.options.enabled,ds(this,eo))!==ex(r.enabled,ds(this,eo))||o!==ds(this,rb))&&Ii(this,Uo,qve).call(this,o)}getOptimisticResult(s){const r=ds(this,Ym).getQueryCache().build(ds(this,Ym),s),n=this.createResult(r,s);return kvt(this,n)&&(zn(this,hm,n),zn(this,fT,this.options),zn(this,F4,ds(this,eo).state)),n}getCurrentResult(){return ds(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){ds(this,yT).add(s)}getCurrentQuery(){return ds(this,eo)}refetch({...s}={}){return this.fetch({...s})}fetchOptimistic(s){const r=ds(this,Ym).defaultQueryOptions(s),n=ds(this,Ym).getQueryCache().build(ds(this,Ym),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(),ds(this,hm)))}createResult(s,r){var B;const n=ds(this,eo),a=this.options,o=ds(this,hm),l=ds(this,F4),i=ds(this,fT),u=s!==n?s.state:ds(this,fR),{state:p}=s;let f={...p},y=!1,_;if(r._optimisticResults){const U=this.hasListeners(),te=!U&&WEe(s,r),Y=U&&KEe(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 k=!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,k=!0):U=typeof r.placeholderData=="function"?r.placeholderData((B=ds(this,gT))==null?void 0:B.state.data,ds(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&&!k)if(o&&_===(l==null?void 0:l.data)&&r.select===ds(this,xR))_=ds(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)}ds(this,sb)&&(b=ds(this,sb),_=ds(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:ds(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=ds(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=ds(this,hm),r=this.createResult(ds(this,eo),this.options);if(zn(this,F4,ds(this,eo).state),zn(this,fT,this.options),ds(this,F4).data!==void 0&&zn(this,gT,ds(this,eo)),zoe(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&&!ds(this,yT).size)return!0;const l=new Set(o??ds(this,yT));return this.options.throwOnError&&l.add("error"),Object.keys(ds(this,hm)).some(i=>{const d=i;return ds(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)}},Ym=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=ds(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,ds(this,eo));if(VS||ds(this,hm).isStale||!Dve(s))return;const n=$Ue(ds(this,hm).dataUpdatedAt,s)+1;zn(this,z4,setTimeout(()=>{ds(this,hm).isStale||this.updateResult()},n))},$ve=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(ds(this,eo)):this.options.refetchInterval)??!1},qve=function(s){Ii(this,Uo,Hve).call(this),zn(this,rb,s),!(VS||ex(this.options.enabled,ds(this,eo))===!1||!Dve(ds(this,rb))||ds(this,rb)===0)&&zn(this,B4,setInterval(()=>{(this.options.refetchIntervalInBackground||vje.isFocused())&&Ii(this,Uo,AI).call(this)},ds(this,rb)))},Uve=function(){Ii(this,Uo,Bve).call(this),Ii(this,Uo,qve).call(this,Ii(this,Uo,$ve).call(this))},Vve=function(){ds(this,z4)&&(clearTimeout(ds(this,z4)),zn(this,z4,void 0))},Hve=function(){ds(this,B4)&&(clearInterval(ds(this,B4)),zn(this,B4,void 0))},Gve=function(){const s=ds(this,Ym).getQueryCache().build(ds(this,Ym),this.options);if(s===ds(this,eo))return;const r=ds(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(ds(this,hm))}),ds(this,Ym).getQueryCache().notify({query:ds(this,eo),type:"observerResultsUpdated"})})},fBe);function Nvt(t,s){return ex(s.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&s.retryOnMount===!1)}function WEe(t,s){return Nvt(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 KEe(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 kvt(t,s){return!zoe(t.getCurrentResult(),s)}var Svt=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:$oe()})}getOptimisticResult(t){return t.behavior=$oe(),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:bvt(s,r.data),hasPreviousPage:wvt(s,r.data),isFetchNextPageError:u,isFetchingNextPage:p,isFetchPreviousPageError:f,isFetchingPreviousPage:y,isRefetchError:i&&!u&&!f,isRefetching:o&&!p&&!y}}},nb,ab,Xm,Dv,l1,Lie,Kve,xBe,Cvt=(xBe=class extends FA{constructor(r,n){super();za(this,l1);za(this,nb);za(this,ab);za(this,Xm);za(this,Dv);zn(this,nb,r),this.setOptions(n),this.bindMethods(),Ii(this,l1,Lie).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=ds(this,nb).defaultMutationOptions(r),zoe(this.options,n)||ds(this,nb).getMutationCache().notify({type:"observerOptionsUpdated",mutation:ds(this,Xm),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&HS(n.mutationKey)!==HS(this.options.mutationKey)?this.reset():((a=ds(this,Xm))==null?void 0:a.state.status)==="pending"&&ds(this,Xm).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=ds(this,Xm))==null||r.removeObserver(this)}onMutationUpdate(r){Ii(this,l1,Lie).call(this),Ii(this,l1,Kve).call(this,r)}getCurrentResult(){return ds(this,ab)}reset(){var r;(r=ds(this,Xm))==null||r.removeObserver(this),zn(this,Xm,void 0),Ii(this,l1,Lie).call(this),Ii(this,l1,Kve).call(this)}mutate(r,n){var a;return zn(this,Dv,n),(a=ds(this,Xm))==null||a.removeObserver(this),zn(this,Xm,ds(this,nb).getMutationCache().build(ds(this,nb),this.options)),ds(this,Xm).addObserver(this),ds(this,Xm).execute(r)}},nb=new WeakMap,ab=new WeakMap,Xm=new WeakMap,Dv=new WeakMap,l1=new WeakSet,Lie=function(){var n;const r=((n=ds(this,Xm))==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(ds(this,Dv)&&this.hasListeners()){const f=ds(this,ab).variables,y=ds(this,ab).context;(r==null?void 0:r.type)==="success"?((a=(n=ds(this,Dv)).onSuccess)==null||a.call(n,r.data,f,y),(l=(o=ds(this,Dv)).onSettled)==null||l.call(o,r.data,null,f,y)):(r==null?void 0:r.type)==="error"&&((d=(i=ds(this,Dv)).onError)==null||d.call(i,r.error,f,y),(p=(u=ds(this,Dv)).onSettled)==null||p.call(u,void 0,r.error,f,y))}this.listeners.forEach(f=>{f(ds(this,ab))})})},xBe),eVe=S.createContext(void 0),Qt=t=>{const s=S.useContext(eVe);if(!s)throw new Error("No QueryClient set, use QueryClientProvider to set one");return s},Mvt=({client:t,children:s})=>(S.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),e.jsx(eVe.Provider,{value:t,children:s})),tVe=S.createContext(!1),Tvt=()=>S.useContext(tVe);tVe.Provider;function Avt(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Evt=S.createContext(Avt()),Pvt=()=>S.useContext(Evt),Ivt=(t,s)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(s.isReset()||(t.retryOnMount=!1))},Lvt=t=>{S.useEffect(()=>{t.clearReset()},[t])},Dvt=({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])),Rvt=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))}},Ovt=(t,s)=>t.isLoading&&t.isFetching&&!s,Fvt=(t,s)=>(t==null?void 0:t.suspense)&&s.isPending,ZEe=(t,s,r)=>s.fetchOptimistic(t).catch(()=>{r.clearReset()});function sVe(t,s,r){var f,y,_,b,N;const n=Tvt(),a=Pvt(),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",Rvt(l),Ivt(l,a),Lvt(a);const i=!o.getQueryCache().get(l.queryHash),[d]=S.useState(()=>new s(o,l)),u=d.getOptimisticResult(l),p=!n&&t.subscribed!==!1;if(S.useSyncExternalStore(S.useCallback(w=>{const k=p?d.subscribe(nu.batchCalls(w)):pm;return d.updateResult(),k},[d,p]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),S.useEffect(()=>{d.setOptions(l)},[l,d]),Fvt(l,u))throw ZEe(l,d,a);if(Dvt({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&&Ovt(u,n)){const w=i?ZEe(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 Et(t,s){const r=Qt(),[n]=S.useState(()=>new Cvt(r,t));S.useEffect(()=>{n.setOptions(t)},[n,t]);const a=S.useSyncExternalStore(S.useCallback(l=>n.subscribe(nu.batchCalls(l)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),o=S.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 zvt(t,s){return sVe(t,Svt)}/** * @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 $vt(){return Math.random().toString(36).substr(2,8)}function XEe(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||$vt()})}function qoe(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 qvt(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(),k=w==null?null:w-u;u=w,d&&d({action:i,location:N.location,delta:k})}function y(w,k){i=lb.Push;let C=Zve(N.location,w,k);u=p()+1;let A=XEe(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,k){i=lb.Replace;let C=Zve(N.location,w,k);u=p();let A=XEe(C,u),I=N.createHref(C);l.replaceState(A,"",I),o&&d&&d({action:i,location:N.location,delta:0})}function b(w){let k=a.location.origin!=="null"?a.location.origin:a.location.href,C=typeof w=="string"?w:qoe(w);return C=C.replace(/ $/,"%20"),bd(k,"No window.location.(origin|href) available to create URL for href: "+C),new URL(C,k)}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(YEe,f),d=w,()=>{a.removeEventListener(YEe,f),d=null}},createHref(w){return s(a,w)},createURL:b,encodeLocation(w){let k=b(w);return{pathname:k.pathname,search:k.search,hash:k.hash}},push:y,replace:_,go(w){return l.go(w)}};return N}var QEe;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(QEe||(QEe={}));function Uvt(t,s,r){return r===void 0&&(r="/"),Vvt(t,s,r,!1)}function Vvt(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);Hvt(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:Qvt(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 Hvt(t){t.sort((s,r)=>s.score!==r.score?r.score-s.score:Jvt(s.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const Gvt=/^:[\w-]+$/,Wvt=3,Kvt=2,Zvt=1,Yvt=10,Xvt=-2,JEe=t=>t==="*";function Qvt(t,s){let r=t.split("/"),n=r.length;return r.some(JEe)&&(n+=Xvt),s&&(n+=Kvt),r.filter(a=>!JEe(a)).reduce((a,o)=>a+(Gvt.test(o)?Wvt:o===""?Zvt:Yvt),n)}function Jvt(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 e1t(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 t1t(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 s1t(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 r1t(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:n1t(r,s):s,search:o1t(n),hash:l1t(a)}}function n1t(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 Xxe(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 a1t(t){return t.filter((s,r)=>r===0||s.route.path&&s.route.path.length>0)}function wje(t,s){let r=a1t(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("?"),Xxe("?","pathname","search",a)),bd(!a.pathname||!a.pathname.includes("#"),Xxe("#","pathname","hash",a)),bd(!a.search||!a.search.includes("#"),Xxe("#","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=r1t(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,"/"),i1t=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),o1t=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,l1t=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function c1t(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const iVe=["post","put","patch","delete"];new Set(iVe);const d1t=["get",...iVe];new Set(d1t);/** * 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}),S.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 p1t=S.createContext(null);function f1t(t){let s=S.useContext(j0).outlet;return s&&S.createElement(p1t.Provider,{value:t},s)}function ao(){let{matches:t}=S.useContext(j0),s=t[t.length-1];return s?s.params:{}}function cVe(t,s){let{relative:r}=s===void 0?{}:s,{future:n}=S.useContext(uw),{matches:a}=S.useContext(j0),{pathname:o}=Bl(),l=JSON.stringify(wje(a,n.v7_relativeSplatPath));return S.useMemo(()=>jje(t,JSON.parse(l),o,r==="path"),[t,l,o,r])}function x1t(t,s){return g1t(t,s)}function g1t(t,s,r,n){BA()||bd(!1);let{navigator:a}=S.useContext(uw),{matches:o}=S.useContext(j0),l=o[o.length-1],i=l?l.params:{};l&&l.pathname;let d=l?l.pathnameBase:"/";l&&l.route;let u=Bl(),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=Uvt(t,{pathname:_}),N=w1t(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?S.createElement(nue.Provider,{value:{location:eD({pathname:"/",search:"",hash:"",state:null,key:"default"},p),navigationType:lb.Pop}},N):N}function y1t(){let t=S1t(),s=c1t(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),r=t instanceof Error?t.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return S.createElement(S.Fragment,null,S.createElement("h2",null,"Unexpected Application Error!"),S.createElement("h3",{style:{fontStyle:"italic"}},s),r?S.createElement("pre",{style:a},r):null,null)}const v1t=S.createElement(y1t,null);class _1t extends S.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?S.createElement(j0.Provider,{value:this.props.routeContext},S.createElement(oVe.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function b1t(t){let{routeContext:s,match:r,children:n}=t,a=S.useContext(Nje);return a&&a.static&&a.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=r.route.id),S.createElement(j0.Provider,{value:s},n)}function w1t(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||v1t,d&&(u<0&&y===0?(b=!0,w=null):u===y&&(b=!0,w=f.route.hydrateFallbackElement||null)));let k=s.concat(l.slice(0,y+1)),C=()=>{let A;return _?A=N:b?A=w:f.route.Component?A=S.createElement(f.route.Component,null):f.route.element?A=f.route.element:A=p,S.createElement(b1t,{match:f,routeContext:{outlet:p,matches:k,isDataRoute:r!=null},children:A})};return r&&(f.route.ErrorBoundary||f.route.errorElement||y===0)?S.createElement(_1t,{location:r.location,revalidation:r.revalidation,component:N,error:_,children:C(),routeContext:{outlet:null,matches:k,isDataRoute:!0}}):C()},null)}var dVe=function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t}(dVe||{}),Uoe=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}(Uoe||{});function j1t(t){let s=S.useContext(Nje);return s||bd(!1),s}function N1t(t){let s=S.useContext(u1t);return s||bd(!1),s}function k1t(t){let s=S.useContext(j0);return s||bd(!1),s}function uVe(t){let s=k1t(),r=s.matches[s.matches.length-1];return r.route.id||bd(!1),r.route.id}function S1t(){var t;let s=S.useContext(oVe),r=N1t(Uoe.UseRouteError),n=uVe(Uoe.UseRouteError);return s!==void 0?s:(t=r.errors)==null?void 0:t[n]}function C1t(){let{router:t}=j1t(dVe.UseNavigateStable),s=uVe(Uoe.UseNavigateStable),r=S.useRef(!1);return lVe(()=>{r.current=!0}),S.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 M1t(t,s){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function Qxe(t){let{to:s,replace:r,state:n,relative:a}=t;BA()||bd(!1);let{future:o,static:l}=S.useContext(uw),{matches:i}=S.useContext(j0),{pathname:d}=Bl(),u=vr(),p=jje(s,wje(i,o.v7_relativeSplatPath),d,a==="path"),f=JSON.stringify(p);return S.useEffect(()=>u(JSON.parse(f),{replace:r,state:n,relative:a}),[u,f,a,r,n]),null}function T1t(t){return f1t(t.context)}function xs(t){bd(!1)}function A1t(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=S.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=S.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:S.createElement(uw.Provider,{value:u},S.createElement(nue.Provider,{children:r,value:N}))}function Voe(t){let{children:s,location:r}=t;return x1t(Yve(s),r)}new Promise(()=>{});function Yve(t,s){s===void 0&&(s=[]);let r=[];return S.Children.forEach(t,(n,a)=>{if(!S.isValidElement(n))return;let o=[...s,a];if(n.type===S.Fragment){r.push.apply(r,Yve(n.props.children,o));return}n.type!==xs&&bd(!1),!n.props.index||!n.props.children||bd(!1);let l={id:n.props.id||o.join("-"),caseSensitive:n.props.caseSensitive,element:n.props.element,Component:n.props.Component,index:n.props.index,path:n.props.path,loader:n.props.loader,action:n.props.action,errorElement:n.props.errorElement,ErrorBoundary:n.props.ErrorBoundary,hasErrorBoundary:n.props.ErrorBoundary!=null||n.props.errorElement!=null,shouldRevalidate:n.props.shouldRevalidate,handle:n.props.handle,lazy:n.props.lazy};n.props.children&&(l.children=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 P1t(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function I1t(t,s){return t.button===0&&(!s||s==="_self")&&!P1t(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 L1t(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 D1t=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],R1t="6";try{window.__reactRouterVersion=R1t}catch{}const O1t="startTransition",tPe=c2e[O1t];function F1t(t){let{basename:s,children:r,future:n,window:a}=t,o=S.useRef();o.current==null&&(o.current=Bvt({window:a,v5Compat:!0}));let l=o.current,[i,d]=S.useState({action:l.action,location:l.location}),{v7_startTransition:u}=n||{},p=S.useCallback(f=>{u&&tPe?tPe(()=>d(f)):d(f)},[d,u]);return S.useLayoutEffect(()=>l.listen(p),[l,p]),S.useEffect(()=>M1t(n),[n]),S.createElement(A1t,{basename:s,children:r,location:i.location,navigationType:i.action,navigator:l,future:n})}const z1t=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",B1t=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,da=S.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=E1t(s,D1t),{basename:_}=S.useContext(uw),b,N=!1;if(typeof u=="string"&&B1t.test(u)&&(b=u,z1t))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=h1t(u,{relative:a}),k=$1t(u,{replace:l,state:i,target:d,preventScrollReset:p,relative:a,viewTransition:f});function C(A){n&&n(A),A.defaultPrevented||k(A)}return S.createElement("a",Xve({},y,{href:b||w,onClick:N||o?n:C,ref:r,target:d}))});var sPe;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(sPe||(sPe={}));var rPe;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(rPe||(rPe={}));function $1t(t,s){let{target:r,replace:n,state:a,preventScrollReset:o,relative:l,viewTransition:i}=s===void 0?{}:s,d=vr(),u=Bl(),p=cVe(t,{relative:l});return S.useCallback(f=>{if(I1t(f,r)){f.preventDefault();let y=n!==void 0?n:qoe(u)===qoe(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=S.useRef(Qve(t)),r=S.useRef(!1),n=Bl(),a=S.useMemo(()=>L1t(n.search,r.current?null:s.current),[n.search]),o=vr(),l=S.useCallback((i,d)=>{const u=Qve(typeof i=="function"?i(a):i);r.current=!0,o("?"+u,d)},[o,a]);return[a,l]}var q1t=typeof Element<"u",U1t=typeof Map=="function",V1t=typeof Set=="function",H1t=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function Die(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(!Die(t[n],s[n]))return!1;return!0}var o;if(U1t&&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(!Die(n.value[1],s.get(n.value[0])))return!1;return!0}if(V1t&&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(H1t&&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(q1t&&t instanceof Element)return!1;for(n=r;n--!==0;)if(!((a[n]==="_owner"||a[n]==="__v"||a[n]==="__o")&&t.$$typeof)&&!Die(t[a[n]],s[a[n]]))return!1;return!0}return t!==t&&s!==s}var G1t=function(s,r){try{return Die(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 W1t=no(G1t);var K1t=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}},Z1t=K1t;const nPe=no(Z1t);var Y1t=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||{}),Jxe={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"]}},aPe=Object.values(hVe),kje={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},Q1t=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},J1t=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},e_t=t=>UM(t,qM.ON_CHANGE_CLIENT_STATE)||(()=>{}),ege=(t,s)=>s.filter(r=>typeof r[t]<"u").map(r=>r[t]).reduce((r,n)=>({...r,...n}),{}),t_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"&&s_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:t_t(["href"],t),bodyAttributes:ege("bodyAttributes",t),defer:UM(t,qM.DEFER),encode:UM(t,qM.ENCODE_SPECIAL_CHARACTERS),htmlAttributes:ege("htmlAttributes",t),linkTags:Z6("link",["rel","href"],t),metaTags:Z6("meta",["name","charset","http-equiv","property","itemprop"],t),noscriptTags:Z6("noscript",["innerHTML"],t),onChangeClientState:e_t(t),scriptTags:Z6("script",["src","innerHTML"],t),styleTags:Z6("style",["cssText"],t),title:J1t(t),titleAttributes:ege("titleAttributes",t),prioritizeSeoTags:r_t(t,qM.PRIORITIZE_SEO_TAGS)}),mVe=t=>Array.isArray(t)?t.join(""):t,a_t=(t,s)=>{const r=Object.keys(t);for(let n=0;nArray.isArray(t)?t.reduce((r,n)=>(a_t(n,s)?r.priority.push(n):r.default.push(n),r),{priority:[],default:[]}):{default:t,priority:[]},iPe=(t,s)=>({...t,[s]:void 0}),i_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},""),o_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)}`},l_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=i_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),c_t=(t,s,r)=>{const n={key:s,[Sg]:!0},a=fVe(r,n);return[xt.createElement("title",a,s)]},Rie=(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:()=>c_t(t,s.title,s.titleAttributes),toString:()=>o_t(t,s.title,s.titleAttributes,r)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>fVe(s),toString:()=>pVe(s)};default:return{toComponent:()=>Rie(t,s),toString:()=>l_t(t,s,r)}}},d_t=({metaTags:t,linkTags:s,scriptTags:r,encode:n})=>{const a=tge(t,Jxe.meta),o=tge(s,Jxe.link),l=tge(r,Jxe.script);return{priorityMethods:{toComponent:()=>[...Rie("meta",a.priority),...Rie("link",o.priority),...Rie("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}},u_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}=d_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=u_t,yz=[],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?yz:this.instances,add:t=>{(this.canUseDOM?yz:this.instances).push(t)},remove:t=>{const s=(this.canUseDOM?yz:this.instances).indexOf(t);(this.canUseDOM?yz: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:{}}))}},h_t={},gVe=xt.createContext(h_t),$4,yVe=($4=class extends S.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(","))},m_t=(t,s)=>{typeof t<"u"&&document.title!==t&&(document.title=mVe(t)),s1e("title",s)},oPe=(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),m_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:k,oldTags:C}=_[w];k.length&&(b[w]=k),C.length&&(N[w]=_[w].oldTags)}),s&&s(),d(t,b,N)},Y6=null,p_t=t=>{Y6&&cancelAnimationFrame(Y6),t.defer?Y6=requestAnimationFrame(()=>{oPe(t,()=>{Y6=null})}):(oPe(t),Y6=null)},f_t=p_t,lPe=class extends S.Component{constructor(){super(...arguments);En(this,"rendered",!1)}shouldComponentUpdate(s){return!X1t(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=n_t(s.get().map(o=>{const l={...o.props};return delete l.context,l}));yVe.canUseDOM?f_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,nc=(A0e=class extends S.Component{shouldComponentUpdate(t){return!W1t(iPe(this.props,"helmetData"),iPe(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 nPe(aPe.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 ${aPe.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`),nPe(!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[Q1t[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(lPe,{...r,context:n.value}):xt.createElement(gVe.Consumer,null,a=>xt.createElement(lPe,{...r,context:a}))}},En(A0e,"defaultProps",{defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1}),A0e);const x_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 g_t extends Sje{constructor(s){super("Failed to send a request to the Edge Function","FunctionsFetchError",s)}}class y_t extends Sje{constructor(s){super("Relay Error invoking the Edge Function","FunctionsRelayError",s)}}class v_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 __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 b_t{constructor(s,{headers:r={},customFetch:n,region:a=r1e.Any}={}){this.url=s,this.headers=r,this.region=a,this.fetch=x_t(n)}setAuth(s){this.headers.Authorization=`Bearer ${s}`}invoke(s,r={}){var n;return __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 g_t(b)}),f=p.headers.get("x-relay-error");if(f&&f==="true")throw new y_t(p);if(!p.ok)throw new v_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 rp={},Cje={},aue={},TR={},iue={},oue={},w_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=w_t();const j_t=MT.fetch,vVe=MT.fetch.bind(MT),_Ve=MT.Headers,N_t=MT.Request,k_t=MT.Response,$A=Object.freeze(Object.defineProperty({__proto__:null,Headers:_Ve,Request:N_t,Response:k_t,default:vVe,fetch:j_t},Symbol.toStringTag,{value:"Module"})),S_t=Jmt($A);var lue={};Object.defineProperty(lue,"__esModule",{value:!0});let C_t=class extends Error{constructor(s){super(s.message),this.name="PostgrestError",this.details=s.details,this.hint=s.hint,this.code=s.code}};lue.default=C_t;var bVe=fd&&fd.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(oue,"__esModule",{value:!0});const M_t=bVe(S_t),T_t=bVe(lue);let A_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=M_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 k=await o.text();k===""||(this.headers.Accept==="text/csv"||this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?p=k:p=JSON.parse(k))}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 T_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}};oue.default=A_t;var E_t=fd&&fd.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(iue,"__esModule",{value:!0});const P_t=E_t(oue);let I_t=class extends P_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}};iue.default=I_t;var L_t=fd&&fd.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(TR,"__esModule",{value:!0});const D_t=L_t(iue);let R_t=class extends D_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=R_t;var O_t=fd&&fd.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(aue,"__esModule",{value:!0});const X6=O_t(TR);let F_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})}};aue.default=F_t;var cue={},due={};Object.defineProperty(due,"__esModule",{value:!0});due.version=void 0;due.version="0.0.0-automated";Object.defineProperty(cue,"__esModule",{value:!0});cue.DEFAULT_HEADERS=void 0;const z_t=due;cue.DEFAULT_HEADERS={"X-Client-Info":`postgrest-js/${z_t.version}`};var wVe=fd&&fd.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Cje,"__esModule",{value:!0});const B_t=wVe(aue),$_t=wVe(TR),q_t=cue;let U_t=class jVe{constructor(s,{headers:r={},schema:n,fetch:a}={}){this.url=s,this.headers=Object.assign(Object.assign({},q_t.DEFAULT_HEADERS),r),this.schemaName=n,this.fetch=a}from(s){const r=new URL(`${this.url}/${s}`);return new B_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 $_t.default({method:l,url:i,headers:u,schema:this.schemaName,body:d,fetch:this.fetch,allowEmpty:!1})}};Cje.default=U_t;var qA=fd&&fd.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(rp,"__esModule",{value:!0});rp.PostgrestError=rp.PostgrestBuilder=rp.PostgrestTransformBuilder=rp.PostgrestFilterBuilder=rp.PostgrestQueryBuilder=rp.PostgrestClient=void 0;const NVe=qA(Cje);rp.PostgrestClient=NVe.default;const kVe=qA(aue);rp.PostgrestQueryBuilder=kVe.default;const SVe=qA(TR);rp.PostgrestFilterBuilder=SVe.default;const CVe=qA(iue);rp.PostgrestTransformBuilder=CVe.default;const MVe=qA(oue);rp.PostgrestBuilder=MVe.default;const TVe=qA(lue);rp.PostgrestError=TVe.default;var V_t=rp.default={PostgrestClient:NVe.default,PostgrestQueryBuilder:kVe.default,PostgrestFilterBuilder:SVe.default,PostgrestTransformBuilder:CVe.default,PostgrestBuilder:MVe.default,PostgrestError:TVe.default};const{PostgrestClient:H_t,PostgrestQueryBuilder:VTs,PostgrestFilterBuilder:HTs,PostgrestTransformBuilder:GTs,PostgrestBuilder:WTs,PostgrestError:KTs}=V_t;let n1e;typeof window>"u"?n1e=require("ws"):n1e=window.WebSocket;const G_t=n1e,W_t="2.11.10",K_t={"X-Client-Info":`realtime-js/${W_t}`},Z_t="1.0.0",AVe=1e4,Y_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 X_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 Tl;(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"})(Tl||(Tl={}));const cPe=(t,s,r={})=>{var n;const a=(n=r.skipTypes)!==null&&n!==void 0?n:[];return Object.keys(s).reduce((o,l)=>(o[l]=Q_t(l,t,s,a),o),{})},Q_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 sbt(s,r)}switch(t){case Tl.bool:return J_t(s);case Tl.float4:case Tl.float8:case Tl.int2:case Tl.int4:case Tl.int8:case Tl.numeric:case Tl.oid:return ebt(s);case Tl.json:case Tl.jsonb:return tbt(s);case Tl.timestamp:return rbt(s);case Tl.abstime:case Tl.date:case Tl.daterange:case Tl.int4range:case Tl.int8range:case Tl.money:case Tl.reltime:case Tl.text:case Tl.time:case Tl.timestamptz:case Tl.timetz:case Tl.tsrange:case Tl.tstzrange:return i1e(s);default:return i1e(s)}},i1e=t=>t,J_t=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},ebt=t=>{if(typeof t=="string"){const s=parseFloat(t);if(!Number.isNaN(s))return s}return t},tbt=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch(s){return console.log(`JSON parse error: ${s}`),t}return t},sbt=(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},rbt=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 sge{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 dPe;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(dPe||(dPe={}));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 uPe;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(uPe||(uPe={}));var hPe;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(hPe||(hPe={}));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 sge(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:k,schema:C,table:A,filter:I}}=w,L=p&&p[N];if(L&&L.event===k&&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 sge(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 sge(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,k,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=(k=_==null?void 0:_.filter)===null||k===void 0?void 0:k.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:k,type:C,errors:A}=b;y=Object.assign(Object.assign({},{schema:N,table:w,commit_timestamp:k,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=cPe(s.columns,s.record)),(s.type==="UPDATE"||s.type==="DELETE")&&(r.old=cPe(s.columns,s.old_record)),r}}const mPe=()=>{},nbt=` addEventListener("message", (e) => { if (e.data.event === "start") { setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); } });`;class abt{constructor(s,r){var n;this.accessTokenValue=null,this.apiKey=null,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers=K_t,this.params={},this.timeout=AVe,this.heartbeatIntervalMs=25e3,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=mPe,this.ref=0,this.logger=mPe,this.conn=null,this.sendBuffer=[],this.serializer=new X_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=G_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 ibt(this.endpointURL(),void 0,{close:()=>{this.conn=null}})}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:Z_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(Y_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([nbt],{type:"application/javascript"});r=URL.createObjectURL(n)}return r}}class ibt{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 obt 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 lbt=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)},cbt=()=>lbt(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 rge=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),dbt=(t,s,r)=>wC(void 0,void 0,void 0,function*(){const n=yield cbt();t instanceof n&&!(r!=null&&r.noResolveJson)?t.json().then(a=>{s(new obt(rge(a),t.status||500))}).catch(a=>{s(new o1e(rge(a),a))}):s(new o1e(rge(t),t))}),ubt=(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,ubt(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=>dbt(d,i,n))})})}function Hoe(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 hbt(t,s,r,n,a){return wC(this,void 0,void 0,function*(){return AR(t,"PUT",s,n,a,r)})}function mbt(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 Km=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 pbt={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},pPe={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class fbt{constructor(s,r={},n,a){this.url=s,this.headers=r,this.bucketId=n,this.fetch=LVe(a)}uploadOrUpdate(s,r,n,a){return Km(this,void 0,void 0,function*(){try{let o;const l=Object.assign(Object.assign({},pPe),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 Km(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",s,r,n)})}uploadToSignedUrl(s,r,n,a){return Km(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:pPe.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 Km(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 Km(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",s,r,n)})}move(s,r,n){return Km(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 Km(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 Km(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 Km(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 Km(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 Hoe(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 Km(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{const n=yield Hoe(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 Km(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{return yield mbt(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 Km(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 Km(this,void 0,void 0,function*(){try{const a=Object.assign(Object.assign(Object.assign({},pbt),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 xbt="2.7.1",gbt={"X-Client-Info":`storage-js/${xbt}`};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 ybt{constructor(s,r={},n){this.url=s,this.headers=Object.assign(Object.assign({},gbt),r),this.fetch=LVe(n)}listBuckets(){return l5(this,void 0,void 0,function*(){try{return{data:yield Hoe(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 Hoe(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 hbt(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 vbt extends ybt{constructor(s,r={},n){super(s,r,n)}from(s){return new fbt(this.url,this.headers,s,this.fetch)}}const _bt="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 bbt={"X-Client-Info":`supabase-js-${EI}/${_bt}`},wbt={headers:bbt},jbt={schema:"public"},Nbt={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},kbt={};var Sbt=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 Cbt=t=>{let s;return t?s=t:typeof fetch>"u"?s=vVe:s=fetch,(...r)=>s(...r)},Mbt=()=>typeof Headers>"u"?_Ve:Headers,Tbt=(t,s,r)=>{const n=Cbt(r),a=Mbt();return(o,l)=>Sbt(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 Abt=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 Ebt(t){return t.endsWith("/")?t:t+"/"}function Pbt(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:()=>Abt(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,nge=c1e*E5,Ibt="http://localhost:9999",Lbt="supabase.auth.token",Dbt={"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"}},Rbt=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,Obt=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 Fbt extends Aje{constructor(s,r,n){super(s,r,n),this.name="AuthApiError",this.status=r,this.code=n}}function zbt(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 Bbt(t){return Ti(t)&&t.name==="AuthSessionMissingError"}class age extends hw{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class vz extends hw{constructor(s){super(s,"AuthInvalidCredentialsError",400,void 0)}}class _z 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 $bt(t){return Ti(t)&&t.name==="AuthImplicitGrantRedirectError"}class fPe 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 ige(t){return Ti(t)&&t.name==="AuthRetryableFetchError"}class xPe 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 gPe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),yPe=` \r=`.split(""),qbt=(()=>{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 vPe(t){const s=[],r=l=>{s.push(String.fromCodePoint(l))},n={utf8seq:0,codepoint:0},a={queue:0,queuedBits:0},o=l=>{Hbt(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 Vbt(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}Ubt(n,s)}}function Hbt(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 Gbt(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};for(let a=0;as.push(r)),new Uint8Array(s)}function Kbt(t){return Math.round(Date.now()/1e3)+t}function Zbt(){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 Ybt(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)},Xbt=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))},bz=async(t,s)=>{const r=await t.getItem(s);if(!r)return null;try{return JSON.parse(r)}catch{return r}},wz=async(t,s)=>{await t.removeItem(s)};class uue{constructor(){this.promise=new uue.promiseConstructor((s,r)=>{this.resolve=s,this.reject=r})}}uue.promiseConstructor=Promise;function oge(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 Jbt(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 ewt(t){return("0"+t.toString(16)).substr(-2)}function twt(){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,ewt).join("")}async function swt(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 rwt(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 swt(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function c5(t,s,r=!1){const n=twt();let a=n;r&&(a+="/PASSWORD_RECOVERY"),await $Ve(t,`${s}-code-verifier`,a);const o=await rwt(n);return[o,n===o?"plain":"s256"]}const nwt=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function awt(t){const s=t.headers.get(d1e);if(!s||!s.match(nwt))return null;try{return new Date(`${s}T00:00:00.0Z`)}catch{return null}}function iwt(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 owt(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 lwt=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),cwt=[502,503,504];async function _Pe(t){var s;if(!Xbt(t))throw new u1e(s4(t),0);if(cwt.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=awt(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 xPe(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 xPe(s4(r),t.status,r.weak_password.reasons);throw new Fbt(s4(r),t.status||500,n)}const dwt=(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 uwt(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 uwt(t,s,r,n,a,o){const l=dwt(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 _Pe(i),n!=null&&n.noResolveJson)return i;try{return await i.json()}catch(d){await _Pe(d)}}function N_(t){var s;let r=null;fwt(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=Kbt(t.expires_in)));const n=(s=t.user)!==null&&s!==void 0?s:t;return{data:{session:r,user:n},error:null}}function bPe(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 hwt(t){return{data:t,error:null}}function mwt(t){const{action_link:s,email_otp:r,hashed_token:n,redirect_to:a,verification_type:o}=t,l=lwt(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 pwt(t){return t}function fwt(t){return t.access_token&&t.refresh_token&&t.expires_in}var xwt=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 ywt={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 wPe(t={}){return{getItem:s=>t[s]||null,setItem:(s,r)=>{t[s]=r},removeItem:s=>{delete t[s]}}}function vwt(){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 _wt extends qVe{}async function bwt(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 _wt(`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()}}))}vwt();const wwt={url:Ibt,storageKey:Lbt,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:Dbt,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function jPe(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({},wwt),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 gwt({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||jPe,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=bwt:this.lock=jPe,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=ywt:(this.memoryStorage={},this.storage=wPe(this.memoryStorage)):(this.memoryStorage={},this.storage=wPe(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=Ybt(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),$bt(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 vz("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:bPe})}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:bPe})}else throw new vz("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 age}:(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 bz(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 wz(this.storage,`${this.storageKey}-code-verifier`),l)throw l;return!o||!o.session||!o.user?{data:{user:null,session:null,redirectType:null},error:new age}:(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 age}:(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 vz("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:hwt})}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 vz("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 bz(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 Bbt(r)&&(await this._removeSession(),await wz(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}=oge(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 _z("No browser detected.");if(s.error||s.error_description||s.error_code)throw new _z(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 fPe("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new _z("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 fPe("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 _z("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 k={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:k,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 bz(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&&!(zbt(i)&&(i.status===404||i.status===401||i.status===403)))return{error:i}}return s!=="others"&&(await this._removeSession(),await wz(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(s){const r=Zbt(),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 Jbt(async a=>(a>0&&await Qbt(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&&ige(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}=oge(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+Obt>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}}=oge(n);if(iwt(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=owt(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,Wbt(`${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 jwt=tD;class Nwt extends jwt{constructor(s){super(s)}}var kwt=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 Swt{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=Ebt(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:jbt,realtime:kbt,auth:Object.assign(Object.assign({},Nbt),{storageKey:u}),global:wbt},f=Pbt(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=Tbt(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 H_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 b_t(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}get storage(){return new vbt(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 kwt(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 Nwt({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 abt(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 Cwt=(t,s,r)=>new Swt(t,s,r),Mwt="https://relzejiswnotikjgvjhz.supabase.co",Twt="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM",G=Cwt(Mwt,Twt,{auth:{storage:localStorage,persistSession:!0,autoRefreshToken:!0}}),UVe=S.createContext(void 0),Awt=({children:t})=>{const[s,r]=S.useState(null),[n,a]=S.useState(null),[o,l]=S.useState(!0),[i,d]=S.useState(!0),[u,p]=S.useState(!1),[f,y]=S.useState(!1),[_,b]=S.useState(null),[N,w]=S.useState([]),[k,C]=S.useState(null),A=S.useRef(null),I=S.useRef(!1),L=S.useRef(!1),O=vr(),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:ae}]=await Promise.all([G.rpc("has_role",{_user_id:Y,_role:"admin"}),G.rpc("has_role",{_user_id:Y,_role:"brokerage_manager"})]);if(X||ae)console.error("Role RPC errors:",{isAdminError:X,isBrokerError:ae}),p(!1),y(!1);else{const me=!!J,ye=!!ce;console.log("RPC roles result:",{adminValue:me,brokerValue:ye}),p(me),y(ye)}const{data:ie,error:oe}=await G.from("profiles").select("brokerage_id").eq("id",Y).single();if(b(!oe&&ie?ie.brokerage_id:null),ce){console.log("Fetching managed brokerages for user:",Y);const{data:me,error:ye}=await G.from("brokerage_manager_assignments").select("brokerage_id").eq("user_id",Y);if(console.log("Managed brokerage assignments result:",{assignments:me,assignmentsError:ye}),ye||!me){console.error("Error fetching managed brokerage assignments:",ye),w([]);return}const he=Array.from(new Set(me.map(Te=>Te.brokerage_id).filter(Boolean)));if(he.length===0){w([]);return}const{data:ge,error:Ne}=await G.from("brokerages").select("id, name").in("id",he);if(console.log("Managed brokerages details result:",{brokeragesData:ge,brokeragesError:Ne}),Ne||!ge){console.error("Error fetching managed brokerages details:",Ne),w([]);return}const Ue=ge.map(Te=>({id:Te.id,name:Te.name})).sort((Te,Me)=>he.indexOf(Te.id)-he.indexOf(Me.id));console.log("Parsed managed brokerages:",Ue),w(Ue),Ue.length>0&&C(Te=>Te??Ue[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)}}};S.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)))}),ae=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(ae),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)=>{const ce=`${window.location.origin}/dashboard`,{error:ae}=await G.auth.signUp({email:Y,password:J,options:{emailRedirectTo:ce,data:{name:X}}});if(ae)throw pe.error(ae.message),ae;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:k,setSelectedBrokerageId:C},children:t})},qs=()=>{const t=S.useContext(UVe);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t},VVe=S.createContext(void 0),O2="levelup_admin_session",x_="levelup_impersonation",lge="levelup_impersonation_return",Ewt=({children:t})=>{const[s,r]=S.useState(!1),[n,a]=S.useState(null),[o,l]=S.useState(!1);S.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(lge,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:k}=await G.auth.verifyOtp({token_hash:b.token_hash,type:w});if(k)throw console.error("Verify OTP error:",k),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(lge)||"/admin/members";sessionStorage.removeItem(lge),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})},hue=()=>{const t=S.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"}}),K=S.forwardRef(({className:t,variant:s,size:r,asChild:n=!1,...a},o)=>{const l=n?tje:"button";return e.jsx(l,{className:Dt(TT({variant:s,size:r,className:t})),ref:o,...a})});K.displayName="Button";const Pwt=()=>{const{isImpersonating:t,impersonatedUser:s,stopImpersonation:r,isLoading:n}=hue();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(K,{size:"sm",variant:"secondary",onClick:r,disabled:n,className:"bg-amber-100 hover:bg-amber-200 text-amber-950 border-0",children:n?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(jr,{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=S.createContext(void 0),u5="levelup_acting_as",jz="levelup_acting_as_self",Iwt=({children:t})=>{const{user:s}=qs(),[r,n]=S.useState(!1),[a,o]=S.useState([]),[l,i]=S.useState(null),[d,u]=S.useState({}),[p,f]=S.useState(!0),[y,_]=S.useState(()=>sessionStorage.getItem(jz)==="true");S.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(jz)==="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(jz),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(jz,"true"),sessionStorage.removeItem(u5)},w=C=>!r||y?!0:d[C]===!0,k=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:k,permissions:d,hasPermission:w,isLoading:p,isActingAsSelf:y,setActingAsSelf:N},children:t})},Eje=()=>{const t=S.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=S;function Lwt(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var Dwt=typeof Object.is=="function"?Object.is:Lwt,Rwt=AT.useState,Owt=AT.useEffect,Fwt=AT.useLayoutEffect,zwt=AT.useDebugValue;function Bwt(t,s){var r=s(),n=Rwt({inst:{value:r,getSnapshot:s}}),a=n[0].inst,o=n[1];return Fwt(function(){a.value=r,a.getSnapshot=s,cge(a)&&o({inst:a})},[t,r,s]),Owt(function(){return cge(a)&&o({inst:a}),t(function(){cge(a)&&o({inst:a})})},[t]),zwt(r),r}function cge(t){var s=t.getSnapshot;t=t.value;try{var r=s();return!Dwt(t,r)}catch{return!0}}function $wt(t,s){return s()}var qwt=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?$wt:Bwt;WVe.useSyncExternalStore=AT.useSyncExternalStore!==void 0?AT.useSyncExternalStore:qwt;GVe.exports=WVe;var Uwt=GVe.exports;function Vwt(){return Uwt.useSyncExternalStore(Hwt,()=>!0,()=>!1)}function Hwt(){return()=>{}}var Pje="Avatar",[Gwt,ZTs]=qc(Pje),[Wwt,KVe]=Gwt(Pje),ZVe=S.forwardRef((t,s)=>{const{__scopeAvatar:r,...n}=t,[a,o]=S.useState("idle");return e.jsx(Wwt,{scope:r,imageLoadingStatus:a,onImageLoadingStatusChange:o,children:e.jsx(Jr.span,{...n,ref:s})})});ZVe.displayName=Pje;var YVe="AvatarImage",XVe=S.forwardRef((t,s)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:a=()=>{},...o}=t,l=KVe(YVe,r),i=Kwt(n,o),d=ed(u=>{a(u),l.onImageLoadingStatusChange(u)});return ad(()=>{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=S.forwardRef((t,s)=>{const{__scopeAvatar:r,delayMs:n,...a}=t,o=KVe(QVe,r),[l,i]=S.useState(n===void 0);return S.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 NPe(t,s){return t?s?(t.src!==s&&(t.src=s),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function Kwt(t,{referrerPolicy:s,crossOrigin:r}){const n=Vwt(),a=S.useRef(null),o=n?(a.current||(a.current=new window.Image),a.current):null,[l,i]=S.useState(()=>NPe(o,t));return ad(()=>{i(NPe(o,t))},[o,t]),ad(()=>{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 wn=S.forwardRef(({className:t,...s},r)=>e.jsx(eHe,{ref:r,className:Dt("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...s}));wn.displayName=eHe.displayName;const Ma=S.forwardRef(({className:t,...s},r)=>e.jsx(tHe,{ref:r,className:Dt("aspect-square h-full w-full",t),...s}));Ma.displayName=tHe.displayName;const jn=S.forwardRef(({className:t,...s},r)=>e.jsx(sHe,{ref:r,className:Dt("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...s}));jn.displayName=sHe.displayName;const Zwt=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:Dt(Zwt({variant:s}),t),...r})}var Ywt=S.createContext(void 0);function mw(t){const s=S.useContext(Ywt);return t||s||"ltr"}var dge=0;function mue(){S.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??kPe()),document.body.insertAdjacentElement("beforeend",t[1]??kPe()),dge++,()=>{dge===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(s=>s.remove()),dge--}},[])}function kPe(){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 uge="focusScope.autoFocusOnMount",hge="focusScope.autoFocusOnUnmount",SPe={bubbles:!1,cancelable:!0},Xwt="FocusScope",ER=S.forwardRef((t,s)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...l}=t,[i,d]=S.useState(null),u=ed(a),p=ed(o),f=S.useRef(null),y=Ta(s,N=>d(N)),_=S.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;S.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}))},k=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(k);return i&&C.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",N),document.removeEventListener("focusout",w),C.disconnect()}}},[n,i,_.paused]),S.useEffect(()=>{if(i){MPe.add(_);const N=document.activeElement;if(!i.contains(N)){const k=new CustomEvent(uge,SPe);i.addEventListener(uge,u),i.dispatchEvent(k),k.defaultPrevented||(Qwt(r2t(rHe(i)),{select:!0}),document.activeElement===N&&k_(i))}return()=>{i.removeEventListener(uge,u),setTimeout(()=>{const k=new CustomEvent(hge,SPe);i.addEventListener(hge,p),i.dispatchEvent(k),k.defaultPrevented||k_(N??document.body,{select:!0}),i.removeEventListener(hge,p),MPe.remove(_)},0)}}},[i,u,p,_]);const b=S.useCallback(N=>{if(!r&&!n||_.paused)return;const w=N.key==="Tab"&&!N.altKey&&!N.ctrlKey&&!N.metaKey,k=document.activeElement;if(w&&k){const C=N.currentTarget,[A,I]=Jwt(C);A&&I?!N.shiftKey&&k===I?(N.preventDefault(),r&&k_(A,{select:!0})):N.shiftKey&&k===A&&(N.preventDefault(),r&&k_(I,{select:!0})):k===C&&N.preventDefault()}},[r,n,_.paused]);return e.jsx(Jr.div,{tabIndex:-1,...l,ref:y,onKeyDown:b})});ER.displayName=Xwt;function Qwt(t,{select:s=!1}={}){const r=document.activeElement;for(const n of t)if(k_(n,{select:s}),document.activeElement!==r)return}function Jwt(t){const s=rHe(t),r=CPe(s,t),n=CPe(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 CPe(t,s){for(const r of t)if(!e2t(r,{upTo:s}))return r}function e2t(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 t2t(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&&t2t(t)&&s&&t.select()}}var MPe=s2t();function s2t(){let t=[];return{add(s){const r=t[0];s!==r&&(r==null||r.pause()),t=TPe(t,s),t.unshift(s)},remove(s){var r;t=TPe(t,s),(r=t[0])==null||r.resume()}}}function TPe(t,s){const r=[...t],n=r.indexOf(s);return n!==-1&&r.splice(n,1),r}function r2t(t){return t.filter(s=>s.tagName!=="A")}var mge="rovingFocusGroup.onEntryFocus",n2t={bubbles:!1,cancelable:!0},PR="RovingFocusGroup",[h1e,nHe,a2t]=wR(PR),[i2t,pw]=qc(PR,[a2t]),[o2t,l2t]=i2t(PR),aHe=S.forwardRef((t,s)=>e.jsx(h1e.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(h1e.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(c2t,{...t,ref:s})})}));aHe.displayName=PR;var c2t=S.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=S.useRef(null),_=Ta(s,y),b=mw(o),[N,w]=Uu({prop:l,defaultProp:i??null,onChange:d,caller:PR}),[k,C]=S.useState(!1),A=ed(u),I=nHe(r),L=S.useRef(!1),[O,V]=S.useState(0);return S.useEffect(()=>{const q=y.current;if(q)return q.addEventListener(mge,A),()=>q.removeEventListener(mge,A)},[A]),e.jsx(o2t,{scope:r,orientation:n,dir:b,loop:a,currentTabStopId:N,onItemFocus:S.useCallback(q=>w(q),[w]),onItemShiftTab:S.useCallback(()=>C(!0),[]),onFocusableItemAdd:S.useCallback(()=>V(q=>q+1),[]),onFocusableItemRemove:S.useCallback(()=>V(q=>q-1),[]),children:e.jsx(Jr.div,{tabIndex:k||O===0?-1:0,"data-orientation":n,...f,ref:_,style:{outline:"none",...t.style},onMouseDown:Sr(t.onMouseDown,()=>{L.current=!0}),onFocus:Sr(t.onFocus,q=>{const B=!L.current;if(q.target===q.currentTarget&&B&&!k){const U=new CustomEvent(mge,n2t);if(q.currentTarget.dispatchEvent(U),!U.defaultPrevented){const te=I().filter(ae=>ae.focusable),Y=te.find(ae=>ae.active),J=te.find(ae=>ae.id===N),ce=[Y,J,...te].filter(Boolean).map(ae=>ae.ref.current);lHe(ce,p)}}L.current=!1}),onBlur:Sr(t.onBlur,()=>C(!1))})})}),iHe="RovingFocusGroupItem",oHe=S.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:a=!1,tabStopId:o,children:l,...i}=t,d=fu(),u=o||d,p=l2t(iHe,r),f=p.currentTabStopId===u,y=nHe(r),{onFocusableItemAdd:_,onFocusableItemRemove:b,currentTabStopId:N}=p;return S.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:Sr(t.onMouseDown,w=>{n?p.onItemFocus(u):w.preventDefault()}),onFocus:Sr(t.onFocus,()=>p.onItemFocus(u)),onKeyDown:Sr(t.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){p.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const k=h2t(w,p.orientation,p.dir);if(k!==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(k==="last")A.reverse();else if(k==="prev"||k==="next"){k==="prev"&&A.reverse();const I=A.indexOf(w.currentTarget);A=p.loop?m2t(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 d2t={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function u2t(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function h2t(t,s,r){const n=u2t(t.key,r);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return d2t[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 m2t(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var pue=aHe,fue=oHe,p2t=function(t){if(typeof document>"u")return null;var s=Array.isArray(t)?t[0]:t;return s.ownerDocument.body},h5=new WeakMap,Nz=new WeakMap,kz={},pge=0,cHe=function(t){return t&&(t.host||cHe(t.parentNode))},f2t=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})},x2t=function(t,s,r,n){var a=f2t(s,Array.isArray(t)?t:[t]);kz[r]||(kz[r]=new WeakMap);var o=kz[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&&Nz.set(y,!0),w===1&&y.setAttribute(r,"true"),b||y.setAttribute(n,"true")}catch(k){console.error("aria-hidden: cannot operate on ",y,k)}})};return p(s),i.clear(),pge++,function(){l.forEach(function(f){var y=h5.get(f)-1,_=o.get(f)-1;h5.set(f,y),o.set(f,_),y||(Nz.has(f)||f.removeAttribute(n),Nz.delete(f)),_||f.removeAttribute(r)}),pge--,pge||(h5=new WeakMap,h5=new WeakMap,Nz=new WeakMap,kz={})}},xue=function(t,s,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(t)?t:[t]),a=p2t(t);return a?(n.push.apply(n,Array.from(a.querySelectorAll("[aria-live]"))),x2t(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 I2t;var s=L2t(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])}},R2t=mHe(),HM="data-scroll-locked",O2t=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(y2t,` { 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(Oie,` { right: `).concat(i,"px ").concat(n,`; } .`).concat(Fie,` { margin-right: `).concat(i,"px ").concat(n,`; } .`).concat(Oie," .").concat(Oie,` { right: 0 `).concat(n,`; } .`).concat(Fie," .").concat(Fie,` { margin-right: 0 `).concat(n,`; } body[`).concat(HM,`] { `).concat(v2t,": ").concat(i,`px; } `)},EPe=function(){var t=parseInt(document.body.getAttribute(HM)||"0",10);return isFinite(t)?t:0},F2t=function(){S.useEffect(function(){return document.body.setAttribute(HM,(EPe()+1).toString()),function(){var t=EPe()-1;t<=0?document.body.removeAttribute(HM):document.body.setAttribute(HM,t.toString())}},[])},z2t=function(t){var s=t.noRelative,r=t.noImportant,n=t.gapMode,a=n===void 0?"margin":n;F2t();var o=S.useMemo(function(){return D2t(a)},[a]);return S.createElement(R2t,{styles:O2t(o,!s,a,r?"":"!important")})},m1e=!1;if(typeof window<"u")try{var Sz=Object.defineProperty({},"passive",{get:function(){return m1e=!0,!0}});window.addEventListener("test",Sz,Sz),window.removeEventListener("test",Sz,Sz)}catch{m1e=!1}var m5=m1e?{passive:!1}:!1,B2t=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&&!B2t(t)&&r[s]==="visible")},$2t=function(t){return pHe(t,"overflowY")},q2t=function(t){return pHe(t,"overflowX")},PPe=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},U2t=function(t){var s=t.scrollTop,r=t.scrollHeight,n=t.clientHeight;return[s,r,n]},V2t=function(t){var s=t.scrollLeft,r=t.scrollWidth,n=t.clientWidth;return[s,r,n]},fHe=function(t,s){return t==="v"?$2t(s):q2t(s)},xHe=function(t,s){return t==="v"?U2t(s):V2t(s)},H2t=function(t,s){return t==="h"&&s==="rtl"?-1:1},G2t=function(t,s,r,n,a){var o=H2t(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],k=N-w-o*b;(b||k)&&fHe(t,i)&&(f+=k,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},Cz=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},IPe=function(t){return[t.deltaX,t.deltaY]},LPe=function(t){return t&&"current"in t?t.current:t},W2t=function(t,s){return t[0]===s[0]&&t[1]===s[1]},K2t=function(t){return` .block-interactivity-`.concat(t,` {pointer-events: none;} .allow-interactivity-`).concat(t,` {pointer-events: all;} `)},Z2t=0,p5=[];function Y2t(t){var s=S.useRef([]),r=S.useRef([0,0]),n=S.useRef(),a=S.useState(Z2t++)[0],o=S.useState(mHe)[0],l=S.useRef(t);S.useEffect(function(){l.current=t},[t]),S.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var N=g2t([t.lockRef.current],(t.shards||[]).map(LPe),!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=S.useCallback(function(N,w){if("touches"in N&&N.touches.length===2||N.type==="wheel"&&N.ctrlKey)return!l.current.allowPinchZoom;var k=Cz(N),C=r.current,A="deltaX"in N?N.deltaX:C[0]-k[0],I="deltaY"in N?N.deltaY:C[1]-k[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=PPe(V,O);if(!q)return!0;if(q?L=V:(L=V==="v"?"h":"v",q=PPe(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 G2t(B,w,N,B==="h"?A:I,!0)},[]),d=S.useCallback(function(N){var w=N;if(!(!p5.length||p5[p5.length-1]!==o)){var k="deltaY"in w?IPe(w):Cz(w),C=s.current.filter(function(L){return L.name===w.type&&(L.target===w.target||w.target===L.shadowParent)&&W2t(L.delta,k)})[0];if(C&&C.should){w.cancelable&&w.preventDefault();return}if(!C){var A=(l.current.shards||[]).map(LPe).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=S.useCallback(function(N,w,k,C){var A={name:N,delta:w,target:k,should:C,shadowParent:X2t(k)};s.current.push(A),setTimeout(function(){s.current=s.current.filter(function(I){return I!==A})},1)},[]),p=S.useCallback(function(N){r.current=Cz(N),n.current=void 0},[]),f=S.useCallback(function(N){u(N.type,IPe(N),N.target,i(N,t.lockRef.current))},[]),y=S.useCallback(function(N){u(N.type,Cz(N),N.target,i(N,t.lockRef.current))},[]);S.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 S.createElement(S.Fragment,null,b?S.createElement(o,{styles:K2t(a)}):null,_?S.createElement(z2t,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function X2t(t){for(var s=null;t!==null;)t instanceof ShadowRoot&&(s=t.host,t=t.host),t=t.parentNode;return s}const Q2t=S2t(hHe,Y2t);var IR=S.forwardRef(function(t,s){return S.createElement(gue,zy({},t,{ref:s,sideCar:Q2t}))});IR.classNames=gue.classNames;var p1e=["Enter"," "],J2t=["ArrowDown","PageUp","Home"],gHe=["ArrowUp","PageDown","End"],ejt=[...J2t,...gHe],tjt={ltr:[...p1e,"ArrowRight"],rtl:[...p1e,"ArrowLeft"]},sjt={ltr:["ArrowLeft"],rtl:["ArrowRight"]},LR="Menu",[sD,rjt,njt]=wR(LR),[jC,yHe]=qc(LR,[njt,w0,pw]),yue=w0(),vHe=pw(),[ajt,NC]=jC(LR),[ijt,DR]=jC(LR),_He=t=>{const{__scopeMenu:s,open:r=!1,children:n,dir:a,onOpenChange:o,modal:l=!0}=t,i=yue(s),[d,u]=S.useState(null),p=S.useRef(!1),f=ed(o),y=mw(a);return S.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(ajt,{scope:s,open:r,onOpenChange:f,content:d,onContentChange:u,children:e.jsx(ijt,{scope:s,onClose:S.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:p,dir:y,modal:l,children:n})})})};_He.displayName=LR;var ojt="MenuAnchor",Ije=S.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=yue(r);return e.jsx(OA,{...a,...n,ref:s})});Ije.displayName=ojt;var Lje="MenuPortal",[ljt,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(ljt,{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",[cjt,Dje]=jC(vx),jHe=S.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(djt,{...a,ref:s}):e.jsx(ujt,{...a,ref:s})})})})}),djt=S.forwardRef((t,s)=>{const r=NC(vx,t.__scopeMenu),n=S.useRef(null),a=Ta(s,n);return S.useEffect(()=>{const o=n.current;if(o)return xue(o)},[]),e.jsx(Rje,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Sr(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),ujt=S.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)})}),hjt=Hb("MenuContent.ScrollLock"),Rje=S.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),k=DR(vx,r),C=yue(r),A=vHe(r),I=rjt(r),[L,O]=S.useState(null),V=S.useRef(null),q=Ta(s,V,w.onContentChange),B=S.useRef(0),U=S.useRef(""),te=S.useRef(0),Y=S.useRef(null),J=S.useRef("right"),X=S.useRef(0),ce=b?IR:S.Fragment,ae=b?{as:hjt,allowPinchZoom:!0}:void 0,ie=me=>{var De,qe;const ye=U.current+me,he=I().filter(ke=>!ke.disabled),ge=document.activeElement,Ne=(De=he.find(ke=>ke.ref.current===ge))==null?void 0:De.textValue,Ue=he.map(ke=>ke.textValue),Te=Njt(Ue,ye,Ne),Me=(qe=he.find(ke=>ke.textValue===Te))==null?void 0:qe.ref.current;(function ke($e){U.current=$e,window.clearTimeout(B.current),$e!==""&&(B.current=window.setTimeout(()=>ke(""),1e3))})(ye),Me&&setTimeout(()=>Me.focus())};S.useEffect(()=>()=>window.clearTimeout(B.current),[]),mue();const oe=S.useCallback(me=>{var he,ge;return J.current===((he=Y.current)==null?void 0:he.side)&&Sjt(me,(ge=Y.current)==null?void 0:ge.area)},[]);return e.jsx(cjt,{scope:r,searchRef:U,onItemEnter:S.useCallback(me=>{oe(me)&&me.preventDefault()},[oe]),onItemLeave:S.useCallback(me=>{var ye;oe(me)||((ye=V.current)==null||ye.focus(),O(null))},[oe]),onTriggerLeave:S.useCallback(me=>{oe(me)&&me.preventDefault()},[oe]),pointerGraceTimerRef:te,onPointerGraceIntentChange:S.useCallback(me=>{Y.current=me},[]),children:e.jsx(ce,{...ae,children:e.jsx(ER,{asChild:!0,trapped:a,onMountAutoFocus:Sr(o,me=>{var ye;me.preventDefault(),(ye=V.current)==null||ye.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(pue,{asChild:!0,...A,dir:k.dir,orientation:"vertical",loop:n,currentTabStopId:L,onCurrentTabStopIdChange:O,onEntryFocus:Sr(d,me=>{k.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:k.dir,...C,...N,ref:q,style:{outline:"none",...N.style},onKeyDown:Sr(N.onKeyDown,me=>{const he=me.target.closest("[data-radix-menu-content]")===me.currentTarget,ge=me.ctrlKey||me.altKey||me.metaKey,Ne=me.key.length===1;he&&(me.key==="Tab"&&me.preventDefault(),!ge&&Ne&&ie(me.key));const Ue=V.current;if(me.target!==Ue||!ejt.includes(me.key))return;me.preventDefault();const Me=I().filter(De=>!De.disabled).map(De=>De.ref.current);gHe.includes(me.key)&&Me.reverse(),wjt(Me)}),onBlur:Sr(t.onBlur,me=>{me.currentTarget.contains(me.target)||(window.clearTimeout(B.current),U.current="")}),onPointerMove:Sr(t.onPointerMove,rD(me=>{const ye=me.target,he=X.current!==me.clientX;if(me.currentTarget.contains(ye)&&he){const ge=me.clientX>X.current?"right":"left";J.current=ge,X.current=me.clientX}}))})})})})})})});jHe.displayName=vx;var mjt="MenuGroup",Oje=S.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Jr.div,{role:"group",...n,ref:s})});Oje.displayName=mjt;var pjt="MenuLabel",NHe=S.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Jr.div,{...n,ref:s})});NHe.displayName=pjt;var Goe="MenuItem",DPe="menu.itemSelect",vue=S.forwardRef((t,s)=>{const{disabled:r=!1,onSelect:n,...a}=t,o=S.useRef(null),l=DR(Goe,t.__scopeMenu),i=Dje(Goe,t.__scopeMenu),d=Ta(s,o),u=S.useRef(!1),p=()=>{const f=o.current;if(!r&&f){const y=new CustomEvent(DPe,{bubbles:!0,cancelable:!0});f.addEventListener(DPe,_=>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:Sr(t.onClick,p),onPointerDown:f=>{var y;(y=t.onPointerDown)==null||y.call(t,f),u.current=!0},onPointerUp:Sr(t.onPointerUp,f=>{var y;u.current||(y=f.currentTarget)==null||y.click()}),onKeyDown:Sr(t.onKeyDown,f=>{const y=i.searchRef.current!=="";r||y&&f.key===" "||p1e.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});vue.displayName=Goe;var kHe=S.forwardRef((t,s)=>{const{__scopeMenu:r,disabled:n=!1,textValue:a,...o}=t,l=Dje(Goe,r),i=vHe(r),d=S.useRef(null),u=Ta(s,d),[p,f]=S.useState(!1),[y,_]=S.useState("");return S.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(fue,{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:Sr(t.onPointerMove,rD(b=>{n?l.onItemLeave(b):(l.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Sr(t.onPointerLeave,rD(b=>l.onItemLeave(b))),onFocus:Sr(t.onFocus,()=>f(!0)),onBlur:Sr(t.onBlur,()=>f(!1))})})})}),fjt="MenuCheckboxItem",SHe=S.forwardRef((t,s)=>{const{checked:r=!1,onCheckedChange:n,...a}=t;return e.jsx(EHe,{scope:t.__scopeMenu,checked:r,children:e.jsx(vue,{role:"menuitemcheckbox","aria-checked":Woe(r)?"mixed":r,...a,ref:s,"data-state":zje(r),onSelect:Sr(a.onSelect,()=>n==null?void 0:n(Woe(r)?!0:!r),{checkForDefaultPrevented:!1})})})});SHe.displayName=fjt;var CHe="MenuRadioGroup",[xjt,gjt]=jC(CHe,{value:void 0,onValueChange:()=>{}}),MHe=S.forwardRef((t,s)=>{const{value:r,onValueChange:n,...a}=t,o=ed(n);return e.jsx(xjt,{scope:t.__scopeMenu,value:r,onValueChange:o,children:e.jsx(Oje,{...a,ref:s})})});MHe.displayName=CHe;var THe="MenuRadioItem",AHe=S.forwardRef((t,s)=>{const{value:r,...n}=t,a=gjt(THe,t.__scopeMenu),o=r===a.value;return e.jsx(EHe,{scope:t.__scopeMenu,checked:o,children:e.jsx(vue,{role:"menuitemradio","aria-checked":o,...n,ref:s,"data-state":zje(o),onSelect:Sr(n.onSelect,()=>{var l;return(l=a.onValueChange)==null?void 0:l.call(a,r)},{checkForDefaultPrevented:!1})})})});AHe.displayName=THe;var Fje="MenuItemIndicator",[EHe,yjt]=jC(Fje,{checked:!1}),PHe=S.forwardRef((t,s)=>{const{__scopeMenu:r,forceMount:n,...a}=t,o=yjt(Fje,r);return e.jsx(jd,{present:n||Woe(o.checked)||o.checked===!0,children:e.jsx(Jr.span,{...a,ref:s,"data-state":zje(o.checked)})})});PHe.displayName=Fje;var vjt="MenuSeparator",IHe=S.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Jr.div,{role:"separator","aria-orientation":"horizontal",...n,ref:s})});IHe.displayName=vjt;var _jt="MenuArrow",LHe=S.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=yue(r);return e.jsx(MR,{...a,...n,ref:s})});LHe.displayName=_jt;var bjt="MenuSub",[YTs,DHe]=jC(bjt),PI="MenuSubTrigger",RHe=S.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=S.useRef(null),{pointerGraceTimerRef:i,onPointerGraceIntentChange:d}=o,u={__scopeMenu:t.__scopeMenu},p=S.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return S.useEffect(()=>p,[p]),S.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:Sr(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:Sr(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",k=w?-5:5,C=y[w?"left":"right"],A=y[w?"right":"left"];o.onPointerGraceIntentChange({area:[{x:f.clientX+k,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:Sr(t.onKeyDown,f=>{var _;const y=o.searchRef.current!=="";t.disabled||y&&f.key===" "||tjt[n.dir].includes(f.key)&&(r.onOpenChange(!0),(_=r.content)==null||_.focus(),f.preventDefault())})})})});RHe.displayName=PI;var OHe="MenuSubContent",FHe=S.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=S.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:Sr(t.onFocusOutside,p=>{p.target!==i.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Sr(t.onEscapeKeyDown,p=>{l.onClose(),p.preventDefault()}),onKeyDown:Sr(t.onKeyDown,p=>{var _;const f=p.currentTarget.contains(p.target),y=sjt[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 Woe(t){return t==="indeterminate"}function zje(t){return Woe(t)?"indeterminate":t?"checked":"unchecked"}function wjt(t){const s=document.activeElement;for(const r of t)if(r===s||(r.focus(),document.activeElement!==s))return}function jjt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}function Njt(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=jjt(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 kjt(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 Sjt(t,s){if(!s)return!1;const r={x:t.clientX,y:t.clientY};return kjt(r,s)}function rD(t){return s=>s.pointerType==="mouse"?t(s):void 0}var Cjt=_He,Mjt=Ije,Tjt=wHe,Ajt=jHe,Ejt=Oje,Pjt=NHe,Ijt=vue,Ljt=SHe,Djt=MHe,Rjt=AHe,Ojt=PHe,Fjt=IHe,zjt=LHe,Bjt=RHe,$jt=FHe,_ue="DropdownMenu",[qjt,XTs]=qc(_ue,[yHe]),Rm=yHe(),[Ujt,BHe]=qjt(_ue),$He=t=>{const{__scopeDropdownMenu:s,children:r,dir:n,open:a,defaultOpen:o,onOpenChange:l,modal:i=!0}=t,d=Rm(s),u=S.useRef(null),[p,f]=Uu({prop:a,defaultProp:o??!1,onChange:l,caller:_ue});return e.jsx(Ujt,{scope:s,triggerId:fu(),triggerRef:u,contentId:fu(),open:p,onOpenChange:f,onOpenToggle:S.useCallback(()=>f(y=>!y),[f]),modal:i,children:e.jsx(Cjt,{...d,open:p,onOpenChange:f,dir:n,modal:i,children:r})})};$He.displayName=_ue;var qHe="DropdownMenuTrigger",UHe=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...a}=t,o=BHe(qHe,r),l=Rm(r);return e.jsx(Mjt,{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:Sr(t.onPointerDown,i=>{!n&&i.button===0&&i.ctrlKey===!1&&(o.onOpenToggle(),o.open||i.preventDefault())}),onKeyDown:Sr(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 Vjt="DropdownMenuPortal",VHe=t=>{const{__scopeDropdownMenu:s,...r}=t,n=Rm(s);return e.jsx(Tjt,{...n,...r})};VHe.displayName=Vjt;var HHe="DropdownMenuContent",GHe=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=BHe(HHe,r),o=Rm(r),l=S.useRef(!1);return e.jsx(Ajt,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...n,ref:s,onCloseAutoFocus:Sr(t.onCloseAutoFocus,i=>{var d;l.current||(d=a.triggerRef.current)==null||d.focus(),l.current=!1,i.preventDefault()}),onInteractOutside:Sr(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 Hjt="DropdownMenuGroup",Gjt=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Ejt,{...a,...n,ref:s})});Gjt.displayName=Hjt;var Wjt="DropdownMenuLabel",WHe=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Pjt,{...a,...n,ref:s})});WHe.displayName=Wjt;var Kjt="DropdownMenuItem",KHe=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Ijt,{...a,...n,ref:s})});KHe.displayName=Kjt;var Zjt="DropdownMenuCheckboxItem",ZHe=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Ljt,{...a,...n,ref:s})});ZHe.displayName=Zjt;var Yjt="DropdownMenuRadioGroup",Xjt=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Djt,{...a,...n,ref:s})});Xjt.displayName=Yjt;var Qjt="DropdownMenuRadioItem",YHe=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Rjt,{...a,...n,ref:s})});YHe.displayName=Qjt;var Jjt="DropdownMenuItemIndicator",XHe=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Ojt,{...a,...n,ref:s})});XHe.displayName=Jjt;var eNt="DropdownMenuSeparator",QHe=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Fjt,{...a,...n,ref:s})});QHe.displayName=eNt;var tNt="DropdownMenuArrow",sNt=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(zjt,{...a,...n,ref:s})});sNt.displayName=tNt;var rNt="DropdownMenuSubTrigger",JHe=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Bjt,{...a,...n,ref:s})});JHe.displayName=rNt;var nNt="DropdownMenuSubContent",eGe=S.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx($jt,{...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=nNt;var aNt=$He,iNt=UHe,oNt=VHe,tGe=GHe,sGe=WHe,rGe=KHe,nGe=ZHe,aGe=YHe,iGe=XHe,oGe=QHe,lGe=JHe,cGe=eGe;const Hd=aNt,Gd=iNt,lNt=S.forwardRef(({className:t,inset:s,children:r,...n},a)=>e.jsxs(lGe,{ref:a,className:Dt("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"})]}));lNt.displayName=lGe.displayName;const cNt=S.forwardRef(({className:t,...s},r)=>e.jsx(cGe,{ref:r,className:Dt("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}));cNt.displayName=cGe.displayName;const Nd=S.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(oNt,{children:e.jsx(tGe,{ref:n,sideOffset:s,className:Dt("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=S.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(rGe,{ref:n,className:Dt("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 dNt=S.forwardRef(({className:t,children:s,checked:r,...n},a)=>e.jsxs(nGe,{ref:a,className:Dt("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]}));dNt.displayName=nGe.displayName;const uNt=S.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(aGe,{ref:n,className:Dt("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]}));uNt.displayName=aGe.displayName;const f1e=S.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(sGe,{ref:n,className:Dt("px-2 py-1.5 text-sm font-semibold",s&&"pl-8",t),...r}));f1e.displayName=sGe.displayName;const Yb=S.forwardRef(({className:t,...s},r)=>e.jsx(oGe,{ref:r,className:Dt("-mx-1 my-1 h-px bg-muted",t),...s}));Yb.displayName=oGe.displayName;const hNt=()=>{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(or,{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(K,{variant:"secondary",size:"sm",className:"gap-2 bg-primary-foreground/20 hover:bg-primary-foreground/30 text-primary-foreground border-0",children:[a?e.jsxs(e.Fragment,{children:[e.jsx(Ai,{className:"h-4 w-4"}),e.jsx("strong",{children:"My Account"})]}):s?e.jsxs(e.Fragment,{children:[e.jsxs(wn,{className:"h-5 w-5",children:[e.jsx(Ma,{src:s.avatar_url||void 0}),e.jsx(jn,{className:"text-[10px] bg-primary-foreground/30",children:l(s.name)})]}),e.jsx("strong",{children:s.name})]}):e.jsx("strong",{children:"Select..."}),e.jsx(Fi,{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(wn,{className:"h-6 w-6",children:[e.jsx(Ma,{src:i.avatar_url||void 0}),e.jsx(jn,{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}=qs(),d=Bl();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(Qxe,{to:"/auth",replace:!0})}return s&&!l?e.jsx(Qxe,{to:"/dashboard",replace:!0}):r&&!i&&!l?e.jsx(Qxe,{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 ye=new OffscreenCanvas(1,1),he=ye.getContext("2d");he.fillRect(0,0,1,1);var ge=ye.transferToImageBitmap();he.createPattern(ge,"no-repeat")}catch{return!1}return!0}();function d(){}function u(ye){var he=r.exports.Promise,ge=he!==void 0?he:s.Promise;return typeof ge=="function"?new ge(ye):(ye(d,d),null)}var p=function(ye,he){return{transform:function(ge){if(ye)return ge;if(he.has(ge))return he.get(ge);var Ne=new OffscreenCanvas(ge.width,ge.height),Ue=Ne.getContext("2d");return Ue.drawImage(ge,0,0),he.set(ge,Ne),Ne},clear:function(){he.clear()}}}(i,new Map),f=function(){var ye=Math.floor(16.666666666666668),he,ge,Ne={},Ue=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(he=function(Te){var Me=Math.random();return Ne[Me]=requestAnimationFrame(function De(qe){Ue===qe||Ue+ye-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 pNt(){const t=Qt();return Et({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 fNt(){const t=Qt(),{user:s}=qs();return Et({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 bue="Dialog",[dGe,uGe]=qc(bue),[xNt,Hg]=dGe(bue),hGe=t=>{const{__scopeDialog:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!0}=t,i=S.useRef(null),d=S.useRef(null),[u,p]=Uu({prop:n,defaultProp:a??!1,onChange:o,caller:bue});return e.jsx(xNt,{scope:s,triggerRef:i,contentRef:d,contentId:fu(),titleId:fu(),descriptionId:fu(),open:u,onOpenChange:p,onOpenToggle:S.useCallback(()=>p(f=>!f),[p]),modal:l,children:r})};hGe.displayName=bue;var mGe="DialogTrigger",pGe=S.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:Sr(t.onClick,a.onOpenToggle)})});pGe.displayName=mGe;var $je="DialogPortal",[gNt,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(gNt,{scope:s,forceMount:r,children:S.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 Koe="DialogOverlay",gGe=S.forwardRef((t,s)=>{const r=fGe(Koe,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=Hg(Koe,t.__scopeDialog);return o.modal?e.jsx(jd,{present:n||o.open,children:e.jsx(vNt,{...a,ref:s})}):null});gGe.displayName=Koe;var yNt=Hb("DialogOverlay.RemoveScroll"),vNt=S.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Hg(Koe,r);return e.jsx(IR,{as:yNt,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=S.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(_Nt,{...a,ref:s}):e.jsx(bNt,{...a,ref:s})})});yGe.displayName=GS;var _Nt=S.forwardRef((t,s)=>{const r=Hg(GS,t.__scopeDialog),n=S.useRef(null),a=Ta(s,r.contentRef,n);return S.useEffect(()=>{const o=n.current;if(o)return xue(o)},[]),e.jsx(vGe,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Sr(t.onCloseAutoFocus,o=>{var l;o.preventDefault(),(l=r.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Sr(t.onPointerDownOutside,o=>{const l=o.detail.originalEvent,i=l.button===0&&l.ctrlKey===!0;(l.button===2||i)&&o.preventDefault()}),onFocusOutside:Sr(t.onFocusOutside,o=>o.preventDefault())})}),bNt=S.forwardRef((t,s)=>{const r=Hg(GS,t.__scopeDialog),n=S.useRef(!1),a=S.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=S.forwardRef((t,s)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,...l}=t,i=Hg(GS,r),d=S.useRef(null),u=Ta(s,d);return mue(),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(jNt,{titleId:i.titleId}),e.jsx(kNt,{contentRef:d,descriptionId:i.descriptionId})]})]})}),qje="DialogTitle",_Ge=S.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=S.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=S.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=Hg(jGe,r);return e.jsx(Jr.button,{type:"button",...n,ref:s,onClick:Sr(t.onClick,()=>a.onOpenChange(!1))})});NGe.displayName=jGe;function Uje(t){return t?"open":"closed"}var kGe="DialogTitleWarning",[wNt,SGe]=Txt(kGe,{contentName:GS,titleName:qje,docsSlug:"dialog"}),jNt=({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 S.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},NNt="DialogDescriptionWarning",kNt=({contentRef:t,descriptionId:s})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${SGe(NNt).contentName}}.`;return S.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},wue=hGe,Vje=pGe,jue=xGe,UA=gGe,VA=yGe,RR=_Ge,OR=wGe,FR=NGe;const fs=wue,hi=Vje,SNt=jue,QTs=FR,CGe=S.forwardRef(({className:t,...s},r)=>e.jsx(UA,{ref:r,className:Dt("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 hs=S.forwardRef(({className:t,children:s,overlayClassName:r,...n},a)=>e.jsxs(SNt,{children:[e.jsx(CGe,{className:r}),e.jsxs(VA,{ref:a,className:Dt("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(jr,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));hs.displayName=VA.displayName;const js=({className:t,...s})=>e.jsx("div",{className:Dt("flex flex-col space-y-1.5 text-center sm:text-left",t),...s});js.displayName="DialogHeader";const _n=({className:t,...s})=>e.jsx("div",{className:Dt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});_n.displayName="DialogFooter";const _s=S.forwardRef(({className:t,...s},r)=>e.jsx(RR,{ref:r,className:Dt("text-lg font-semibold leading-none tracking-tight",t),...s}));_s.displayName=RR.displayName;const Ir=S.forwardRef(({className:t,...s},r)=>e.jsx(OR,{ref:r,className:Dt("text-sm text-muted-foreground",t),...s}));Ir.displayName=OR.displayName;const CNt={points_earned:Vi,listing_created:Sn,deal_closed:_c,custom:Gn},OPe={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"},FPe=()=>{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 MNt(){const{user:t}=qs(),s=Qt(),{data:r}=mNt(),n=pNt(),[a,o]=S.useState(null),[l,i]=S.useState(!1),d=S.useCallback(()=>{const _=Date.now()+3e3,b={startVelocity:30,spread:360,ticks:60,zIndex:9999},N=(k,C)=>Math.random()*(C-k)+k,w=setInterval(()=>{const k=_-Date.now();if(k<=0){clearInterval(w);return}const C=50*(k/3e3);RPe({...b,particleCount:C,origin:{x:N(.1,.3),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]}),RPe({...b,particleCount:C,origin:{x:N(.7,.9),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]})},250)},[]);S.useEffect(()=>{FPe()||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(FPe()||!a)return null;const p=CNt[a.celebration_type]||Gn,f=OPe[a.celebration_type]||OPe.custom;return e.jsx(fs,{open:l,onOpenChange:y=>!y&&u(),children:e.jsxs(hs,{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(K,{onClick:u,className:"w-full",size:"lg",children:"Awesome! 🙌"}),r&&r.length>1&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-3",children:["+",r.length-1," more celebration",r.length>2?"s":""," waiting"]})]})]})})}const MGe="/assets/levelup-logo-horizontal-DEFNc0ms.png",Hje="/assets/levelup-logo-white-C2RAgAoG.png",TNt="/assets/listings-hero-BI9Ki9Dq.jpg",Le=S.forwardRef(({className:t,type:s,...r},n)=>e.jsx("input",{type:s,className:Dt("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...r}));Le.displayName="Input";var TGe={exports:{}};(function(t,s){(function(r,n){t.exports=n()})(fd,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],ve=h[3],Ce=h[4],Ee=h[5],Ke=h[6],ze=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]=ve*g+Ce*P+Ee*H,x[4]=ve*j+Ce*R+Ee*Q,x[5]=ve*T+Ce*F+Ee*se,x[6]=Ke*g+ze*P+nt*H,x[7]=Ke*j+ze*R+nt*Q,x[8]=Ke*T+ze*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 k(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],ve=c[13],Ce=c[14],Ee=c[15],Ke=h*R-g*P,ze=h*F-j*P,nt=h*H-T*P,ot=g*F-j*R,lt=g*H-T*R,It=j*H-T*F,jt=Q*ve-se*ue,Pt=Q*Ce-re*ue,Ct=Q*Ee-le*ue,Mt=se*Ce-re*ve,ss=se*Ee-le*ve,is=re*Ee-le*Ce,ms=Ke*is-ze*ss+nt*Mt+ot*Ct-lt*Pt+It*jt;return ms?(x[0]=(R*is-F*ss+H*Mt)*(ms=1/ms),x[1]=(j*ss-g*is-T*Mt)*ms,x[2]=(ve*It-Ce*lt+Ee*ot)*ms,x[3]=(re*lt-se*It-le*ot)*ms,x[4]=(F*Ct-P*is-H*Pt)*ms,x[5]=(h*is-j*Ct+T*Pt)*ms,x[6]=(Ce*nt-ue*It-Ee*ze)*ms,x[7]=(Q*It-re*nt+le*ze)*ms,x[8]=(P*ss-R*Ct+H*jt)*ms,x[9]=(g*Ct-h*ss-T*jt)*ms,x[10]=(ue*lt-ve*nt+Ee*Ke)*ms,x[11]=(se*nt-Q*lt-le*Ke)*ms,x[12]=(R*Pt-P*Mt-F*jt)*ms,x[13]=(h*Mt-g*Pt+j*jt)*ms,x[14]=(ve*ze-ue*ot-Ce*Ke)*ms,x[15]=(Q*ot-se*ze+re*Ke)*ms,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],ve=c[12],Ce=c[13],Ee=c[14],Ke=c[15],ze=h[0],nt=h[1],ot=h[2],lt=h[3];return x[0]=ze*g+nt*R+ot*se+lt*ve,x[1]=ze*j+nt*F+ot*re+lt*Ce,x[2]=ze*T+nt*H+ot*le+lt*Ee,x[3]=ze*P+nt*Q+ot*ue+lt*Ke,x[4]=(ze=h[4])*g+(nt=h[5])*R+(ot=h[6])*se+(lt=h[7])*ve,x[5]=ze*j+nt*F+ot*re+lt*Ce,x[6]=ze*T+nt*H+ot*le+lt*Ee,x[7]=ze*P+nt*Q+ot*ue+lt*Ke,x[8]=(ze=h[8])*g+(nt=h[9])*R+(ot=h[10])*se+(lt=h[11])*ve,x[9]=ze*j+nt*F+ot*re+lt*Ce,x[10]=ze*T+nt*H+ot*le+lt*Ee,x[11]=ze*P+nt*Q+ot*ue+lt*Ke,x[12]=(ze=h[12])*g+(nt=h[13])*R+(ot=h[14])*se+(lt=h[15])*ve,x[13]=ze*j+nt*F+ot*re+lt*Ce,x[14]=ze*T+nt*H+ot*le+lt*Ee,x[15]=ze*P+nt*Q+ot*ue+lt*Ke,x}function A(x,c,h){var g,j,T,P,R,F,H,Q,se,re,le,ue,ve=h[0],Ce=h[1],Ee=h[2];return c===x?(x[12]=c[0]*ve+c[4]*Ce+c[8]*Ee+c[12],x[13]=c[1]*ve+c[5]*Ce+c[9]*Ee+c[13],x[14]=c[2]*ve+c[6]*Ce+c[10]*Ee+c[14],x[15]=c[3]*ve+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*ve+R*Ce+se*Ee+c[12],x[13]=j*ve+F*Ce+re*Ee+c[13],x[14]=T*ve+H*Ce+le*Ee+c[14],x[15]=P*ve+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 $e(x,c){return x[0]*c[0]+x[1]*c[1]+x[2]*c[2]}function Be(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 we(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 ut(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 He(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 et(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 _e=me,Ge=ye,We=ce;function it(){var x=new u(4);return u!=Float32Array&&(x[0]=0,x[1]=0,x[2]=0,x[3]=0),x}function Ve(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 Xe(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 dt(x,c){return x[0]*c[0]+x[1]*c[1]+x[2]*c[2]+x[3]*c[3]}function pt(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 Je(){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 Nt(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 Ot(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(),it();var Yt,Ps,$s,Zs=Xe,Dr=(Yt=J(),Ps=ae(1,0,0),$s=ae(0,1,0),function(x,c,h){var g=$e(c,h);return g<-.999999?(Be(Yt,Ps,c),We(Yt)<1e-6&&Be(Yt,$s,c),ke(Yt,Yt),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,Yt,Math.PI),x):g>.999999?(x[0]=0,x[1]=0,x[2]=0,x[3]=1,x):(Be(Yt,c,h),x[0]=Yt[0],x[1]=Yt[1],x[2]=Yt[2],x[3]=1+g,Zs(x,x))});function $t(){var x=new u(2);return u!=Float32Array&&(x[0]=0,x[1]=0),x}function Us(x,c){var h=new u(2);return h[0]=x,h[1]=c,h}function Nr(x,c,h){return x[0]=c,x[1]=h,x}function Xs(x,c,h){return x[0]=c[0]+h[0],x[1]=c[1]+h[1],x}function kr(x,c,h){return x[0]=c[0]-h[0],x[1]=c[1]-h[1],x}function fn(x,c,h){return x[0]=c[0]*h,x[1]=c[1]*h,x}function Yr(x){var c=x[0],h=x[1];return Math.sqrt(c*c+h*h)}function $r(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 Gr(x,c){return x[0]*c[0]+x[1]*c[1]}Je(),Je(),f();var nr,lr,Fr=kr;function Wr(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x.default:x}$t();var Nn=function(){if(lr)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 lr=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=Wr(Nn);function ns(x,c){this.x=x,this.y=c}function $n(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 Bt(x,c,h,g){const j=new ai(x,c,h,g);return function(T){return j.solve(T)}}const Se=Bt(.25,.1,.25,1);function Oe(x,c,h){return Math.min(h,Math.max(c,x))}function Ye(x,c,h){return(h=Oe((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 Tt=1;function Ht(){return Tt++}function Ut(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 Ts(x,c,h){const g={};for(const j in x)g[j]=c.call(this,x[j],j,x);return g}function ys(x,c,h){const g={};for(const j in x)c.call(this,x[j],j,x)&&(g[j]=x[j]);return g}function ir(x){return Array.isArray(x)?x.map(ir):typeof x=="object"&&x?Ts(x,ir):x}function Lr(x,c){for(let h=0;h=0)return!0;return!1}const Hr={};function Rr(x){Hr[x]||(typeof console<"u"&&console.warn(x),Hr[x]=!0)}function un(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 zi(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 Bi(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 Om,kd,ju,Fm,Wu,zm;function Sd(){return Om==null&&(Om=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&typeof self.createImageBitmap=="function"),Om}const Cd={now:()=>Fm!==void 0?Fm:performance.now(),setNow(x){Fm=x},restoreNow(){Fm=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(zm!==void 0)return zm;if(!Sd())return zm=!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,ve)=>{if(F)return;if(le&&le.message!=="SecurityError"&&Rr(le.toString()),ue&&ve)return re(ue);const Ce=Date.now();fetch(P).then(Ee=>{if(Ee.ok){const Ke=H?Ee.clone():null;return re(Ee,Ke,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,ve)=>{(g.type==="arrayBuffer"?le.arrayBuffer():g.type==="json"?le.json():le.text()).then(Ce=>{F||(ue&&ve&&function(Ee,Ke,ze){if(zx(),Kh==null)return;const nt=To(Ke.headers.get("cache-control")||"");if(nt["no-store"])return;const ot={status:Ke.status,statusText:Ke.statusText,headers:new Headers};Ke.headers.forEach((Ct,Mt)=>ot.headers.set(Mt,Ct)),nt["max-age"]&&ot.headers.set("Expires",new Date(ze+1e3*nt["max-age"]).toUTCString());const lt=ot.headers.get("expires");if(!lt||new Date(lt).getTime()-ze<42e4)return;let It=Aw(Ee.url,{persistentParams:Ew});if(Ke.status===206){const Ct=Ee.headers.get("Range");if(!Ct)return;ot.status=200,It=L0(It,{range:Ct})}const jt=new Response((Pt=Ke.status)!==200&&Pt!==404&&[101,103,204,205,304].includes(Pt)?null:Ke.body,ot);var Pt;zx(),Kh!=null&&Kh.then(Ct=>Ct.put(It,jt)).catch(Ct=>Rr(Ct.message))}(P,ue,ve),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(ve=>{let Ce=Aw(le.url,{persistentParams:Ew});const Ee=le.headers.get("Range");Ee&&(Ce=L0(Ce,{range:Ee})),ve.match(Ce).then(Ke=>{const ze=function(nt){if(!nt)return!1;const ot=new Date(nt.headers.get("expires")||0),lt=To(nt.headers.get("cache-control")||"");return Number(ot)>Date.now()&&!lt["no-cache"]}(Ke);ve.delete(Ce).catch(ue),ze&&ve.put(Ce,Ke.clone()).catch(ue),ue(null,Ke,ze)}).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:{}},St={exports:{}},Os=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,St.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}),St.exports);return Af.exports=x,Af.exports.murmur3=x,Af.exports.murmur2=c,Af.exports}(),ar=Wr(Os);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 Bm,Zh={},O0=function(){if(Bm)return Zh;Bm=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]),ve=g(se[2]),Ce=ve<=.5?ve*(ue+1):ve+ue-ve*ue,Ee=2*ve-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),ve=h-H,Ce=g-Q,Ee=j-se,Ke=c.image.data,ze=4*(H+Q*F+se*R),nt=4*(H+Q*F+ue*R),ot=4*(H+le*F+se*R),lt=4*(H+le*F+ue*R),It=4*(re+Q*F+se*R),jt=4*(re+Q*F+ue*R),Pt=4*(re+le*F+se*R),Ct=4*(re+le*F+ue*R);this.r=nn(nn(nn(Ke[ze],Ke[nt],Ee),nn(Ke[ot],Ke[lt],Ee),Ce),nn(nn(Ke[It],Ke[jt],Ee),nn(Ke[Pt],Ke[Ct],Ee),Ce),ve)/255*(this.premultiplied?T:1),this.g=nn(nn(nn(Ke[ze+1],Ke[nt+1],Ee),nn(Ke[ot+1],Ke[lt+1],Ee),Ce),nn(nn(Ke[It+1],Ke[jt+1],Ee),nn(Ke[Pt+1],Ke[Ct+1],Ee),Ce),ve)/255*(this.premultiplied?T:1),this.b=nn(nn(nn(Ke[ze+2],Ke[nt+2],Ee),nn(Ke[ot+2],Ke[lt+2],Ee),Ce),nn(nn(Ke[It+2],Ke[jt+2],Ee),nn(Ke[Pt+2],Ke[Ct+2],Ee),Ce),ve)/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+(Pnn(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(nn(x.r,c.r,h),nn(x.g,c.g,h),nn(x.b,c.b,h),nn(x.a,c.a,h))},number:nn});class $m 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"},Pr={kind:"number"},si={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 kl(x){if(x.kind==="array"){const c=kl(x.itemType);return typeof x.N=="number"?`array<${c}, ${x.N}>`:x.itemType.kind==="value"?"array":`array<${c}>`}return x.kind}const ape=[qx,Pr,si,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 ape)if(!Rw(h,c))return null}}return`Expected ${kl(x)} but found ${kl(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 qm{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 qm(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 qm(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new qm(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 PO(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 si;if(typeof x=="boolean")return oi;if(typeof x=="number")return Pr;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 wr{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 wr(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 cn={string:si,number:Pr,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 cn)||H==="object")return h.error('The item type argument of "array" must be one of string, number, boolean',1);R=cn[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=cn[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",Pr),!F))return null;let H=null;if(R["text-font"]&&(H=h.parseObjectValue(R["text-font"],P,"text-font",Kd(si)),!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 ipe={"to-boolean":oi,"to-color":Nu,"to-number":Pr,"to-string":si};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.`:PO(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);IO(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 LO(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 ope(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&&!(!DO(x,c,h,g)||!DO(h,g,x,c));var j,T}function qE(x){const c=new ns(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),h=new ns(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]];Um(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)Um(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 OO(x,c){return c.dist-x.dist}function FO(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(UO(x,c))return 0}else if(UO(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=io(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=hpe(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,upe(x,se,h,re,j)):c||g?c&&!g?P=Math.min(P,$O(h,re,x,se,j)):!c&&g&&(P=Math.min(P,$O(x,se,h,re,j))):P=Math.min(P,qO(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,VO(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=ppe(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=Pr,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 HO(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 GO(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 wr))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 wr))return h.error("Scope of 'config' expression must be a string literal.");T=rn(F.value)}if(h.options){const F=HO(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=HO(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=GO(se,R,F,H):Array.isArray(se)&&(se=se.map(re=>typeof re=="number"?GO(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 wr)&&T.type.kind!=="resolvedImage"&&eP(T)){const P=new $w(this._scope,this.options,this.iconImageUseTheme);try{T=new wr(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 $m(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 wr}),!!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,Pr);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 WO=.95047,KO=1.08883,ZO=4/29,V1=6/29,YO=3*V1*V1,fpe=V1*V1*V1,xpe=Math.PI/180,gpe=180/Math.PI;function tP(x){return x>fpe?Math.pow(x,1/3):x/YO+ZO}function sP(x){return x>V1?x*x*x:YO*(x-ZO)}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)/WO),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)/KO)),alpha:x.a}}function XO(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=WO*sP(h),g=KO*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 ype(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:XO,interpolate:function(x,c,h){return{l:nn(x.l,c.l,h),a:nn(x.a,c.a,h),b:nn(x.b,c.b,h),alpha:nn(x.alpha,c.alpha,h)}}},G1={forward:function(x){const{l:c,a:h,b:g}=rP(x),j=Math.atan2(g,h)*gpe;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*xpe,h=x.c;return XO({l:x.l,a:Math.cos(c)*h,b:Math.sin(c)*h,alpha:x.alpha})},interpolate:function(x,c,h){return{h:ype(x.h,c.h,h),c:nn(x.c,c.c,h),l:nn(x.l,c.l,h),alpha:nn(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,Pr),!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 ${kl(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,Pr),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,si,Pr,qx,li])?new e2(g,j):(h.error(`Expected first argument to be of type boolean, string, number or null, but found ${kl(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 ${kl(Oo(h))} instead.`);if(!D1(g,["string","array"]))throw new dl(`Expected second argument to be of type array or string, but found ${kl(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=Pr,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,si,Pr,qx,li]))return h.error(`Expected first argument to be of type boolean, string, number or null, but found ${kl(g.type)} instead`),null;if(c.length===4){const T=h.parse(c[3],3,Pr);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 ${kl(Oo(h))} instead.`);if(!D1(g,["string","array"]))throw new dl(`Expected second argument to be of type array or string, but found ${kl(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,Pr);if(!g||!j)return null;if(!zE(g.type,[Kd(li),si,li]))return h.error(`Expected first argument to be of type array or string, but found ${kl(g.type)} instead`),null;if(c.length===4){const T=h.parse(c[3],3,Pr);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 ${kl(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(si),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,si),j=h.parse(c[2],2,si);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 QO(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 JO(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(!QO(R,F.type))return P.concat(1).error(`"${R}" comparisons are not supported for type '${kl(F.type)}'.`);let H=P.parse(T[2],2,li);if(!H)return null;if(!QO(R,H.type))return P.concat(2).error(`"${R}" comparisons are not supported for type '${kl(H.type)}'.`);if(F.type.kind!==H.type.kind&&F.type.kind!=="value"&&H.type.kind!=="value")return P.error(`Cannot compare types '${kl(F.type)}' and '${kl(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 eF=G0("==",function(x,c,h){return c===h},JO),t3=G0("!=",function(x,c,h){return c!==h},function(x,c,h,g){return!JO(0,c,h,g)}),vpe=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}),_pe=G0("<=",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});class s3{constructor(c,h,g,j,T,P){this.type=si,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,Pr);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",si),!T))return null;let P=null;if(j.currency&&(P=h.parseObjectValue(j.currency,2,"currency",si),!P))return null;let R=null;if(j.unit&&(R=h.parseObjectValue(j.unit,2,"unit",si),!R))return null;let F=null;if(j["min-fraction-digits"]&&(F=h.parseObjectValue(j["min-fraction-digits"],2,"min-fraction-digits",Pr),!F))return null;let H=null;return j["max-fraction-digits"]&&(H=h.parseObjectValue(j["max-fraction-digits"],2,"max-fraction-digits",Pr),!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=Pr,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 ${kl(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 ${kl(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 sF(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={"==":eF,"!=":t3,">":tF,"<":vpe,">=":bpe,"<=":_pe,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:wr,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 rF(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=PO(c,h,g,T);if(P)throw new dl(P);return new Aa(c/255,h/255,g/255,T)}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=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 aF(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 iF(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 oF(x){return x}function lF(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=cF;else if(T==="interval")P=jpe;else if(T==="categorical"){P=wpe,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=dF}if(g){const H={},Q=[];for(let le=0;lele[0]),evaluate:({zoom:le},ue)=>cF({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 wpe(x,c,h,g,j){return Pf(typeof h===j?g[h]:void 0,x.default,c.default)}function jpe(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 cF(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,ve=Q-re;return ue===0?0:se===1?ve/ue:(Math.pow(se,ve)-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]||oF;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 dF(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"},[si],(x,[c])=>{throw new dl(c.evaluate(x))}],typeof:[si,[li],(x,[c])=>kl(Oo(c.evaluate(x)))],"to-rgba":[Kd(Pr,4),[Nu],(x,[c])=>c.evaluate(x).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[Kd(Pr,4),[Nu],(x,[c])=>c.evaluate(x).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[Nu,[Pr,Pr,Pr],rF],rgba:[Nu,[Pr,Pr,Pr,Pr],rF],hsl:[Nu,[Pr,Pr,Pr],nF],hsla:[Nu,[Pr,Pr,Pr,Pr],nF],has:{type:oi,overloads:[[[si],(x,[c])=>s2(c.evaluate(x),x.properties())],[[si,sy],(x,[c,h])=>s2(c.evaluate(x),h.evaluate(x))]]},get:{type:li,overloads:[[[si],(x,[c])=>n3(c.evaluate(x),x.properties())],[[si,sy],(x,[c,h])=>n3(c.evaluate(x),h.evaluate(x))]]},"feature-state":[li,[si],(x,[c])=>n3(c.evaluate(x),x.featureState||{})],properties:[sy,[],x=>x.properties()],"geometry-type":[si,[],x=>x.geometryType()],worldview:[si,[],x=>x.globals.worldview||""],"is-active-floor":[oi,oy(si),(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:[Pr,[],x=>x.globals.zoom],pitch:[Pr,[],x=>x.globals.pitch||0],"distance-from-center":[Pr,[],x=>x.distanceFromCenter()],"measure-light":[Pr,[si],(x,[c])=>x.measureLight(c.evaluate(x))],"heatmap-density":[Pr,[],x=>x.globals.heatmapDensity||0],"line-progress":[Pr,[],x=>x.globals.lineProgress||0],"raster-value":[Pr,[],x=>x.globals.rasterValue||0],"raster-particle-speed":[Pr,[],x=>x.globals.rasterParticleSpeed||0],"sky-radial-progress":[Pr,[],x=>x.globals.skyRadialProgress||0],accumulated:[li,[],x=>x.globals.accumulated===void 0?null:x.globals.accumulated],"+":[Pr,oy(Pr),(x,c)=>{let h=0;for(const g of c)h+=g.evaluate(x);return h}],"*":[Pr,oy(Pr),(x,c)=>{let h=1;for(const g of c)h*=g.evaluate(x);return h}],"-":{type:Pr,overloads:[[[Pr,Pr],(x,[c,h])=>c.evaluate(x)-h.evaluate(x)],[[Pr],(x,[c])=>-c.evaluate(x)]]},"/":[Pr,[Pr,Pr],(x,[c,h])=>c.evaluate(x)/h.evaluate(x)],"%":[Pr,[Pr,Pr],(x,[c,h])=>c.evaluate(x)%h.evaluate(x)],ln2:[Pr,[],()=>Math.LN2],pi:[Pr,[],()=>Math.PI],e:[Pr,[],()=>Math.E],"^":[Pr,[Pr,Pr],(x,[c,h])=>Math.pow(c.evaluate(x),h.evaluate(x))],sqrt:[Pr,[Pr],(x,[c])=>Math.sqrt(c.evaluate(x))],log10:[Pr,[Pr],(x,[c])=>Math.log(c.evaluate(x))/Math.LN10],ln:[Pr,[Pr],(x,[c])=>Math.log(c.evaluate(x))],log2:[Pr,[Pr],(x,[c])=>Math.log2(c.evaluate(x))],sin:[Pr,[Pr],(x,[c])=>Math.sin(c.evaluate(x))],cos:[Pr,[Pr],(x,[c])=>Math.cos(c.evaluate(x))],tan:[Pr,[Pr],(x,[c])=>Math.tan(c.evaluate(x))],asin:[Pr,[Pr],(x,[c])=>Math.asin(c.evaluate(x))],acos:[Pr,[Pr],(x,[c])=>Math.acos(c.evaluate(x))],atan:[Pr,[Pr],(x,[c])=>Math.atan(c.evaluate(x))],min:[Pr,oy(Pr),(x,c)=>Math.min(...c.map(h=>h.evaluate(x)))],max:[Pr,oy(Pr),(x,c)=>Math.max(...c.map(h=>h.evaluate(x)))],abs:[Pr,[Pr],(x,[c])=>Math.abs(c.evaluate(x))],round:[Pr,[Pr],(x,[c])=>{const h=c.evaluate(x);return h<0?-Math.round(-h):Math.round(h)}],floor:[Pr,[Pr],(x,[c])=>Math.floor(c.evaluate(x))],ceil:[Pr,[Pr],(x,[c])=>Math.ceil(c.evaluate(x))],"filter-==":[oi,[si,li],(x,[c,h])=>x.properties()[c.value]===h.value],"filter-id-==":[oi,[li],(x,[c])=>x.id()===c.value],"filter-type-==":[oi,[si],(x,[c])=>x.geometryType()===c.value],"filter-<":[oi,[si,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,[si,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,[si,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,[si,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(si)],(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,[si,Kd(li)],(x,[c,h])=>h.value.indexOf(x.properties()[c.value])>=0],"filter-in-large":[oi,[si,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,[si],(x,[c])=>{const h=x.globals&&x.globals.isSupportedScript;return!h||h(c.evaluate(x))}],upcase:[si,[si],(x,[c])=>c.evaluate(x).toUpperCase()],downcase:[si,[si],(x,[c])=>c.evaluate(x).toLowerCase()],concat:[si,oy(li),(x,c)=>c.map(h=>rn(h.evaluate(x))).join("")],"resolved-locale":[si,[z0],(x,[c])=>c.evaluate(x).resolvedLocale()],random:[Pr,[Pr,Pr,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:si,number:Pr,enum:si,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?aF(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 $m("","data expressions not supported")]);const R=Ef(T,["zoom","pitch","distance-from-center"]);if(!R&&!oP(c))return ly([new $m("","zoom expressions not supported")]);const F=Ef(T,["measure-light"]);if(!F&&!iF(c))return ly([new $m("","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 $m("","line-progress expression not supported")]);const Q=c.expression&&c.expression.relaxZoomRestriction,se=Pp(T);return se||R||Q?se instanceof $m?ly([se]):se instanceof Ad&&!l3(c)?ly([new $m("",'"interpolate" expressions cannot be used with this property')]):aF(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 $m("",'"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,lF(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 $m||x.eachChild(h=>{const g=Pp(h);g instanceof $m?c=g:c&&g&&c!==g&&(c=new $m("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),c}var dP,uF,a2=function(){if(uF)return dP;uF=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[ve+0]&&T>=re[ve+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 ve=se;ve<=le;ve++){var Ce=this.d*ve+ue;if((!H||H(this._convertFromCellCoord(ue),this._convertFromCellCoord(ve),this._convertFromCellCoord(ue+1),this._convertFromCellCoord(ve+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,mF=x=>x>=12784&&x<=12799,pF=x=>x>=12800&&x<=13055,fF=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,xF=x=>x>=65040&&x<=65055,gP=x=>x>=65072&&x<=65103,gF=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 Npe(x){for(const c of x)if(!kpe(c.charCodeAt(0)))return!1;return!0}function kpe(x){return!(hF(x)||u3(x)||h3(x)||xP(x)||yP(x))}function Spe(x){return!(x<11904||!(p3(x)||hP(x)||gP(x)||x3(x)||fF(x)||m3(x)||If(x)||o2(x)||mP(x)||f3(x)||pF(x)||vP(x)||l2(x)||uP(x)||Gx(x)||mF(x)||Z0(x)||xF(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)||fF(x)||m3(x)||If(x)||!(!o2(x)||x>=12296&&x<=12305||x>=12308&&x<=12319||x===12336)||mP(x)||f3(x)||pF(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)||mF(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)||!(!gF(x)||x>=65112&&x<=65118||x>=65123&&x<=65126)||(c=>c>=5120&&c<=5759)(x)||(c=>c>=6320&&c<=6399)(x)||xF(x)||(c=>c>=19904&&c<=19967)(x)||c2(x)||pP(x))))}function yF(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)||gF(c)||vP(c)||c===8734||c===8756||c===8757||c>=9984&&c<=10087||c>=10102&&c<=10131||c===65532||c===65533)}(x))}function vF(x){return hF(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 Cpe(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 _F=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},bF=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?_F(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},wF=function(){Wx.isLoading()||Wx.isLoaded()||kP()!=="deferred"||bF()};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 ir(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:ir(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 ir(this._values[c].transition)}setTransition(c,h){this._values.hasOwnProperty(c)||(this._values[c]=new y3(this._values[c].property)),this._values[c].transition=ir(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 jF(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 jF(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 kF(se),se=NF(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=Gt[`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,ve)=>Q.value.evaluate(se,re,{},le,void 0,void 0,ue,ve),H=!H0(Q.value.expression)}return{filter:P,dynamicFilter:F||void 0,needGeometry:CF(T),needFeature:!!H}}function NF(x){if(!Array.isArray(x))return x;const c=function(h){if(SF.has(h[0])){for(let g=1;gNF(h))}function kF(x){let c=!1;const h=[];if(x[0]==="case"){for(let g=1;g",">=","<","<=","to-boolean"]);function Mpe(x,c){return xc?1:0}function CF(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(Mpe)]]:["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 MF(x){const c=x.indexOf(u2);return c>=0?x.slice(c+1):""}let TF;const AP=()=>TF||(TF=new Qi({"icon-size":new Vs(Gt.layout_symbol["icon-size"]),"icon-image":new Vs(Gt.layout_symbol["icon-image"]),"icon-rotate":new Vs(Gt.layout_symbol["icon-rotate"]),"icon-offset":new Vs(Gt.layout_symbol["icon-offset"]),"text-size":new Vs(Gt.layout_symbol["text-size"]),"text-rotate":new Vs(Gt.layout_symbol["text-rotate"]),"text-offset":new Vs(Gt.layout_symbol["text-offset"])}));let EP;const PP=()=>EP||(EP=new Qi({"icon-opacity":new Vs(Gt.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new Vs(Gt.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new Vs(Gt.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Vs(Gt.paint_symbol["text-emissive-strength"]),"icon-color":new Vs(Gt.paint_symbol["icon-color"]),"icon-halo-color":new Vs(Gt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Vs(Gt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Vs(Gt.paint_symbol["icon-halo-blur"]),"icon-translate":new Vs(Gt.paint_symbol["icon-translate"]),"text-opacity":new Vs(Gt.paint_symbol["text-opacity"]),"text-occlusion-opacity":new Vs(Gt.paint_symbol["text-occlusion-opacity"]),"text-color":new Vs(Gt.paint_symbol["text-color"],{runtimeType:Nu,getOverride:x=>x.textColor,hasOverride:x=>!!x.textColor}),"text-halo-color":new Vs(Gt.paint_symbol["text-halo-color"]),"text-halo-width":new Vs(Gt.paint_symbol["text-halo-width"]),"text-halo-blur":new Vs(Gt.paint_symbol["text-halo-blur"]),"text-translate":new Vs(Gt.paint_symbol["text-translate"]),"symbol-z-offset":new Vs(Gt.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"})}));class Tpe{constructor(c,h,g,j,T,P){this._conditionSpec=c,this._propertiesSpec=g;const R=cy(c,Gt.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",Ape=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,Gt[`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)&&Ape.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 Tpe(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())),ys(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 Epe=new ArrayBuffer(0);class Ri{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=Epe),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=AF(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:AF(h,Math.max(g,c)),alignment:c}}function AF(x,c){return Math.ceil(x/c)*c}class _h extends Ri{_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,fr(_h,"StructArrayLayout2i4");class Df extends Ri{_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,fr(Df,"StructArrayLayout3i6");class ld extends Ri{_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}}ld.prototype.bytesPerElement=8,fr(ld,"StructArrayLayout2i2ui8");class Jh extends Ri{_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,fr(Jh,"StructArrayLayout1f4");class LP extends Ri{_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,fr(LP,"StructArrayLayout2i1f8");class DP extends Ri{_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,fr(DP,"StructArrayLayout3i8");class RP extends Ri{_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,fr(RP,"StructArrayLayout4i8");class OP extends Ri{_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,fr(OP,"StructArrayLayout5i10");class m2 extends Ri{_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,fr(m2,"StructArrayLayout2i4ub1f12");class Vm extends Ri{_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}}Vm.prototype.bytesPerElement=12,fr(Vm,"StructArrayLayout3f12");class Rf extends Ri{_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,fr(Rf,"StructArrayLayout4ui1f12");class e_ extends Ri{_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,fr(e_,"StructArrayLayout4ui8");class k3 extends Ri{_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,fr(k3,"StructArrayLayout6i12");class FP extends Ri{_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,fr(FP,"StructArrayLayout4i4ui4i24");class zP extends Ri{_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,fr(zP,"StructArrayLayout3i3f20");class Yx extends Ri{_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,fr(Yx,"StructArrayLayout4f16");class p2 extends Ri{_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,fr(p2,"StructArrayLayout1ul4");class Hm extends Ri{_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}}Hm.prototype.bytesPerElement=4,fr(Hm,"StructArrayLayout2ui4");class S3 extends Ri{_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 ve=20*c,Ce=10*c;return this.int16[ve+0]=h,this.int16[ve+1]=g,this.int16[ve+2]=j,this.int16[ve+3]=T,this.int16[ve+4]=P,this.float32[Ce+3]=R,this.float32[Ce+4]=F,this.float32[Ce+5]=H,this.float32[Ce+6]=Q,this.int16[ve+14]=se,this.uint32[Ce+8]=re,this.uint16[ve+18]=le,this.uint16[ve+19]=ue,c}}S3.prototype.bytesPerElement=40,fr(S3,"StructArrayLayout5i4f1i1ul2ui40");class f2 extends Ri{_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,fr(f2,"StructArrayLayout3i2i2i16");class BP extends Ri{_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,fr(BP,"StructArrayLayout2f1f2i16");class x2 extends Ri{_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,fr(x2,"StructArrayLayout2ub4f20");class Ao extends Ri{_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,fr(Ao,"StructArrayLayout3ui6");class C3 extends Ri{_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,ve,Ce,Ee,Ke,ze,nt,ot){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,ve,Ce,Ee,Ke,ze,nt,ot)}emplace(c,h,g,j,T,P,R,F,H,Q,se,re,le,ue,ve,Ce,Ee,Ke,ze,nt,ot,lt){const It=30*c,jt=15*c,Pt=60*c;return this.int16[It+0]=h,this.int16[It+1]=g,this.int16[It+2]=j,this.float32[jt+2]=T,this.float32[jt+3]=P,this.uint16[It+8]=R,this.uint16[It+9]=F,this.uint32[jt+5]=H,this.uint32[jt+6]=Q,this.uint32[jt+7]=se,this.uint16[It+16]=re,this.uint16[It+17]=le,this.uint16[It+18]=ue,this.float32[jt+10]=ve,this.float32[jt+11]=Ce,this.uint8[Pt+48]=Ee,this.uint8[Pt+49]=Ke,this.uint8[Pt+50]=ze,this.uint32[jt+13]=nt,this.int16[It+28]=ot,this.uint8[Pt+58]=lt,c}}C3.prototype.bytesPerElement=60,fr(C3,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class $P extends Ri{_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,ve,Ce,Ee,Ke,ze,nt,ot,lt,It,jt,Pt,Ct,Mt,ss,is,ms,bs,ps,Is){const es=this.length;return this.resize(es+1),this.emplace(es,c,h,g,j,T,P,R,F,H,Q,se,re,le,ue,ve,Ce,Ee,Ke,ze,nt,ot,lt,It,jt,Pt,Ct,Mt,ss,is,ms,bs,ps,Is)}emplace(c,h,g,j,T,P,R,F,H,Q,se,re,le,ue,ve,Ce,Ee,Ke,ze,nt,ot,lt,It,jt,Pt,Ct,Mt,ss,is,ms,bs,ps,Is,es){const vs=20*c,Ss=40*c,Ls=80*c;return this.float32[vs+0]=h,this.float32[vs+1]=g,this.int16[Ss+4]=j,this.int16[Ss+5]=T,this.int16[Ss+6]=P,this.int16[Ss+7]=R,this.int16[Ss+8]=F,this.int16[Ss+9]=H,this.int16[Ss+10]=Q,this.int16[Ss+11]=se,this.int16[Ss+12]=re,this.uint16[Ss+13]=le,this.uint16[Ss+14]=ue,this.uint16[Ss+15]=ve,this.uint16[Ss+16]=Ce,this.uint16[Ss+17]=Ee,this.uint16[Ss+18]=Ke,this.uint16[Ss+19]=ze,this.uint16[Ss+20]=nt,this.uint16[Ss+21]=ot,this.uint16[Ss+22]=lt,this.uint16[Ss+23]=It,this.uint16[Ss+24]=jt,this.uint16[Ss+25]=Pt,this.uint16[Ss+26]=Ct,this.uint16[Ss+27]=Mt,this.uint32[vs+14]=ss,this.float32[vs+15]=is,this.float32[vs+16]=ms,this.float32[vs+17]=bs,this.float32[vs+18]=ps,this.uint8[Ls+76]=Is,this.uint16[Ss+39]=es,c}}$P.prototype.bytesPerElement=80,fr($P,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class M3 extends Ri{_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,fr(M3,"StructArrayLayout6f24");class J0 extends Ri{_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,fr(J0,"StructArrayLayout5f20");class g2 extends Ri{_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,fr(g2,"StructArrayLayout7f28");class qP extends Ri{_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,fr(qP,"StructArrayLayout11f44");class UP extends Ri{_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,fr(UP,"StructArrayLayout9f36");class ev extends Ri{_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,fr(ev,"StructArrayLayout2f8");class VP extends Ri{_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,fr(VP,"StructArrayLayout1ul3ui12");class tv extends Ri{_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,fr(tv,"StructArrayLayout1ui2");class HP extends Ri{_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,ve,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,ve,Ce)}emplace(c,h,g,j,T,P,R,F,H,Q,se,re,le,ue,ve,Ce,Ee){const Ke=16*c;return this.float32[Ke+0]=h,this.float32[Ke+1]=g,this.float32[Ke+2]=j,this.float32[Ke+3]=T,this.float32[Ke+4]=P,this.float32[Ke+5]=R,this.float32[Ke+6]=F,this.float32[Ke+7]=H,this.float32[Ke+8]=Q,this.float32[Ke+9]=se,this.float32[Ke+10]=re,this.float32[Ke+11]=le,this.float32[Ke+12]=ue,this.float32[Ke+13]=ve,this.float32[Ke+14]=Ce,this.float32[Ke+15]=Ee,c}}HP.prototype.bytesPerElement=64,fr(HP,"StructArrayLayout16f64");class T3 extends Ri{_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,fr(T3,"StructArrayLayout4ui3f20");class A3 extends Ri{_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,fr(A3,"StructArrayLayout1i2");class E3 extends Ri{_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,fr(E3,"StructArrayLayout1ub1");class EF 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]}}EF.prototype.size=40;class GP extends S3{get(c){return new EF(this,c)}}fr(GP,"CollisionBoxArray");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.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}}PF.prototype.size=60;class IF extends C3{get(c){return new PF(this,c)}}fr(IF,"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 LF extends $P{get(c){return new y2(this,c)}}fr(LF,"SymbolInstanceArray");class DF extends Jh{getoffsetX(c){return this.float32[1*c+0]}}fr(DF,"GlyphOffsetArray");class v2 extends _h{getx(c){return this.int16[2*c+0]}gety(c){return this.int16[2*c+1]}}fr(v2,"SymbolLineVertexArray");class RF 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]}}RF.prototype.size=12;class WP extends VP{get(c){return new RF(this,c)}}fr(WP,"FeatureIndexArray");class OF extends Hm{geta_centroid_pos0(c){return this.uint16[2*c+0]}geta_centroid_pos1(c){return this.uint16[2*c+1]}}fr(OF,"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)}}fr(ZP,"FillExtrusionWallArray");const FF=la([{name:"a_pos",components:2,type:"Int16"}],4),Ppe=la([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),Ipe=la([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class wi{constructor(c=[]){this.segments=c}_prepareSegment(c,h,g,j,T){let P=this.segments[this.segments.length-1];return c>wi.MAX_VERTEX_ARRAY_LENGTH&&Rr(`Max vertices per segment is ${wi.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${c}`),(!P||P.vertexLength+c>wi.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 wi([{vertexOffset:c,primitiveOffset:h,vertexLength:g,primitiveLength:j,vaos:{},sortKey:0}])}}function P3(x,c){return 256*(x=Oe(Math.floor(x),0,255))+Oe(Math.floor(c),0,255)}wi.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,fr(wi,"SegmentVector");const Lpe=la([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Dpe=la([{name:"a_pattern_b",components:4,type:"Uint16"}]),Rpe=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 Fpe(c):new Sl(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 Ope(c):new Sl(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=Ie(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 ve=ct(P,Q,"source");this.binders[P]=re?new je(H,F,Q,ve,c.id):new ne(H,F,Q,ve),j.push(`/a_${P}`)}else{const ve=ct(P,Q,"composite");this.binders[P]=new de(H,F,Q,se,h,ve),j.push(`/z_${P}`)}else this.binders[P]=re?new ee(H.value,F):new W(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 je)&&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 je?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 ve in this.binders){const Ce=this.binders[ve];if(Ce.context=this.context,(Ce instanceof ne||Ce instanceof de||Ce instanceof je)&&Ce.expression&&Ce.expression.kind&&Ce.expression.kind!=="constant"&&(Ce.expression.isStateDependent===!0||Ce.expression.isLightConstant===!1)){const Ee=T.paint.get(ve);Ce.expression=Ee.value;for(const Ke of ue){const ze=c[Ke.toString()];h.eachPosition(Ke,(nt,ot,lt)=>{const It=j.feature(nt);Ce.updatePaintArray(ot,lt,It,ze,P,R,H,Q)})}if(!le)for(const Ke of g.uniqueIds){const ze=c[Ke.toString()];g.eachPosition(Ke,(nt,ot,lt)=>{const It=j.feature(nt);Ce.updatePaintArray(ot,lt,It,ze,P,R,H,Q)})}se=!0}}return se}defines(){const c=[];for(const h in this.binders){const g=this.binders[h];(g instanceof W||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 W||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 je)&&h.paintVertexBuffer&&this._buffers.push(h.paintVertexBuffer),h instanceof je&&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 je)&&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 je)&&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 Fe={"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 Ie(x,c){return Fe[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 ct(x,c,h){const g=rt[x];return g&&g[h]||st[c][h]}fr(W,"ConstantBinder"),fr(ee,"PatternConstantBinder"),fr(ne,"SourceExpressionBinder"),fr(je,"PatternCompositeBinder"),fr(de,"CompositeExpressionBinder"),fr(be,"ProgramConfiguration",{omit:["_buffers"]}),fr(Ae,"ProgramConfigurationSet");const mt=sr/Math.PI/2,at=64,zt=[at,32,16],wt=-mt,Rt=mt;function ft(x,c,h,g=mt){return h=Kr(h),[x*Math.sin(h)*g,-c*g,x*Math.cos(h)*g]}function _t(x,c,h){return ft(Math.cos(Kr(x)),Math.sin(Kr(x)),c,h)}const At=63710088e-1,Wt=2*Math.PI*At;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 At*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 rs({lng:this.lng-g,lat:this.lat-h},{lng:this.lng+g,lat:this.lat+h})}toEcef(c){return _t(this.lat,this.lng,mt+c*mt/At)}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 rs{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 rs))return Array.isArray(c)?c.length===4||c.every(Array.isArray)?this.extend(rs.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 rs?c:new rs(c)}}function Jt(x){return Wt*Math.cos(x*Math.PI/180)}function Ns(x){return(180+x)/360}function As(x){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+x*Math.PI/360)))/360}function Kt(x,c){return x/Jt(c)}function Vt(x){return 360*x-180}function ts(x){return 360/Math.PI*Math.atan(Math.exp((180-360*x)*Math.PI/180))-90}function as(x,c){return x*Jt(ts(c))}const cs=85.051129;function Qs(x){return Math.cos(Kr(Oe(x,-85.051129,cs)))}function Hs(x,c){const h=Oe(c,0,25.5),g=Math.pow(2,h);return Qs(x)*Wt/(512*g)}function Gs(x){return 1/Math.cos(x*Math.PI/180)}function Cs(x,c=0){const h=Math.exp(Math.PI*(1-(x.y+c/sr)/(1<=F?(Ar(x,c,h,H,Q,T,se,R,F),Ar(x,H,Q,g,j,se,P,R,F)):x.push(P)}function hr(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)&&Rr("Geometry exceeds allowed extent, reduce your vector tile buffer size"),x}function qr(x,c,h){const g=x.loadGeometry(),j=x.extent,T=sr/j;if(c&&h&&h.projection.isReprojectedInTileSpace){const P=1<{const le=Vt((c.x+re.x/j)/P),ue=ts((c.y+re.y/j)/P),ve=Q.project(le,ue);re.x=(ve.x*R-F)*j,re.y=(ve.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)qn(R,T);return g}function Un(x,c){return{type:x.type,id:x.id,properties:x.properties,geometry:c?qr(x):[]}}class mn{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 ns(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 ve=ue.length;if(ve<=1)return[ue];const Ce=[];let Ee,Ke;for(let ze=0;ze=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 mn(this._pbf,h,this.extent,this._keys,this._values)}}function ji(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",Ni="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 kn=new qa((x,c,h)=>x.reset(c).require(Fn,g=>{h.id=g}).optional("fixed_height_relative",g=>{h.constantHeight=g},pi.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},pi.decodeRelativeHeight).geometry(g=>{h.position=g},pi.getPoint).success()),$i=new qa((x,c,h)=>x.reset(c).require(Fn,g=>{h.id=g}).optional("fixed_height",g=>{h.constantHeight=g},pi.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},pi.decodeMetricHeight).geometry(g=>{h.position=g},pi.getPoint).success());class pi{static getPoint(c){return Us(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"?$i:void 0:kn}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 Cl(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=Ja.fromPoints(this.points),this.projections=[],this.frustumEdges=[_e([],this.points[2],this.points[3]),_e([],this.points[0],this.points[3]),_e([],this.points[4],this.points[0]),_e([],this.points[5],this.points[1]),_e([],this.points[6],this.points[2]),_e([],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=pt([],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=ke([],Be([],_e([],P[H[0]],P[H[1]]),_e([],P[H[2]],P[H[1]]))),se=-$e(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($e([h[0],h[1],h[2]],c)+g<0)return!1}return!0}}class Ja{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 Ja(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])]}}fr(Ja,"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 ns(Math.trunc(c.position[0]+g*T),Math.trunc(c.position[1]+j*T)),new ns(Math.trunc(c.position[0]-g*T),Math.trunc(c.position[1]-j*T))]}next(){this.index++}valid(){return this.index{return R.a0?Ne(F,F,1/H):ie(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;Nr(se,c.x,c.y);const re=new Vo(se,null);for(let le=0;le0?Gr(F,R)/nt:0,lt=Oe(ot,0,1),It=Math.abs((ot-lt)*this.edgeProps[le].len);kr(H,se,Ce),Nr(Q,ve[1],-ve[0]);const jt=It+Math.abs(Gr(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],ve=this.vertexProps[R].dir,Ce=this.vertexProps[F].dir;if(ie(h,H[0]/c,H[1]/c,Q),ie(g,re[0]/c,re[1]/c,le),ie(j,ve[1],-ve[0],0),Ne(j,j,se),ie(T,Ce[1],-Ce[0],0),Ne(T,T,ue),this.distSqLines(ae(h[0]+.5*j[0],h[1]+.5*j[1],h[2]+.5*j[2]),ae(g[0]-.5*T[0],g[1]-.5*T[1],g[2]-.5*T[2]),ae(h[0]-.5*j[0],h[1]-.5*j[1],h[2]-.5*j[2]),ae(g[0]+.5*T[0],g[1]+.5*T[1],g[2]+.5*T[2]))<=.0025000000000000005)continue;const Ee=this.vertices.length,Ke=Xs($t(),H,re);this.vertices.push({position:fn(Ke,Ke,.5),height:.5*(Q+le),extent:.5*(se+ue)});const ze=Xs($t(),ve,Ce);this.vertexProps.push({dir:$r(ze,ze)}),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=kr($t(),this.vertices[Ee].position,H),ot=Yr(nt),lt={vec:nt,dir:fn($t(),nt,1/ot),len:ot};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=$e(T,T),H=$e(T,P),Q=$e(T,R),se=$e(P,P),re=$e(P,R),le=F*se-H*H;if(le===0)return Me(we(T,g,j,$e(R,P)/$e(P,P)),c);const ue=(F*re-H*Q)/le;return Me(we(T,c,h,(H*re-Q*se)/le),we(P,g,j,ue))}}class Ci{static parseFrom(c,h){const g=pi.parse(c);if(!g)return[];let{vertices:j,features:T}=g;const P=1/Cs(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*Ye(0,h,c>=0?c:Math.abs(.5*c))}}fr(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 wi,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=Un(H,le);if(!this.layers[0]._featureFilter.filter(new Ka(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),ue,g))continue;const ve=R?R.evaluate(ue,{},g):void 0,Ce={id:Q,properties:H.properties,type:H.type,sourceLayerIndex:re,index:se,geometry:le?ue.geometry:qr(H,g,j),patterns:{},sortKey:ve};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,FF.members),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=c.createVertexBuffer(this.globeExtVertexArray,Ipe.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=c.createVertexBuffer(this.elevatedLayoutVertexArray,Ppe.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),ve=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 ns(re,le)):0;this.hasElevation=this.hasElevation||Ce!==0;for(let Ee=0;Ee<4;Ee++)this.elevatedLayoutVertexArray.emplaceBack(Ce)}this.indexArray.emplaceBack(ve,ve+1,ve+2),this.indexArray.emplaceBack(ve,ve+2,ve+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 ns(c,h),new ns(c,j),new ns(g,j),new ns(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=un(x,c,h[0]);return T!==un(x,c,h[1])||T!==un(x,c,h[2])||T!==un(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 zF(x){return Math.sqrt(x[0]*x[0]+x[1]*x[1])}function JCe(x,c,h,g,j){if(!c[0]&&!c[1])return x;const T=ns.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,Oe(h,0,1))+x.center[c]}function fy(x){if(x.z<=1)return Xct[x.z+2*x.y+x.x];const c=Bpe(qF(x));return Ja.fromPoints(c)}function nv(x,c,h){return Ne(x,x,1-h),Ue(x,x,c,h)}function i3e(x,c){const h=av(c.zoom);if(h===0)return fy(x);const g=qF(x),j=Bpe(g),T=Ns(g.getWest())*c.worldSize,P=Ns(g.getEast())*c.worldSize,R=As(g.getNorth())*c.worldSize,F=As(g.getSouth())*c.worldSize,H=[T,R,0],Q=[P,R,0],se=[T,F,0],re=[P,F,0],le=k([],c.globeMatrix);return ut(H,H,le),ut(Q,Q,le),ut(se,se,le),ut(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),Ja.fromPoints(j)}function o3e(x,c,h){for(const g of x)ut(g,g,c),Ne(g,g,h)}function l3e(x,c,h,g){const j=c/x.worldSize,T=x.globeMatrix;if(h.z<=1){const Pt=fy(h).getCorners();return o3e(Pt,T,j),Ja.fromPoints(Pt)}const P=qF(h,g),R=Bpe(P,mt+$F(x._tileCoverLift));o3e(R,T,j);const F=Number.MAX_VALUE,H=[-F,-F,-F],Q=[F,F,F];if(P.contains(x.center)){for(const Mt of R)he(Q,Q,Mt),ge(H,H,Mt);H[2]=0;const Pt=x.point,Ct=[Pt.x*j,Pt.y*j,0];return he(Q,Q,Ct),ge(H,H,Ct),new Ja(Q,H)}if(x._tileCoverLift>0){for(const Pt of R)he(Q,Q,Pt),ge(H,H,Pt);return new Ja(Q,H)}const se=[T[12]*j,T[13]*j,T[14]*j],re=P.getCenter(),le=Oe(x.center.lat,-85.051129,cs),ue=Oe(re.lat,-85.051129,cs),ve=Ns(x.center.lng),Ce=As(le);let Ee=ve-Ns(re.lng);const Ke=Ce-As(ue);Ee>.5?Ee-=1:Ee<-.5&&(Ee+=1);let ze=0;Math.abs(Ee)>Math.abs(Ke)?ze=Ee>=0?1:3:(ze=Ke>=0?0:2,Ue(se,se,[T[4]*j,T[5]*j,T[6]*j],-Math.sin(Kr(Ke>=0?P.getSouth():P.getNorth()))*mt));const nt=R[ze],ot=R[(ze+1)%4],lt=new Qct(nt,ot,se),It=[zpe(lt,0)||nt[0],zpe(lt,1)||nt[1],zpe(lt,2)||nt[2]],jt=av(x.zoom);if(jt>0){const Pt=function({x:Mt,y:ss,z:is},ms,bs,ps,Is){const es=1/(1<.5?mr=-1:er<-.5&&(mr=1),vs=((vs+mr)*ms-(ps*=ms))*bs+ps,Ss=((Ss+mr)*ms-ps)*bs+ps,Ls=(Ls*ms-(Is*=ms))*bs+Is,Ws=(Ws*ms-Is)*bs+Is,[[vs,Ws,0],[Ss,Ws,0],[Ss,Ls,0],[vs,Ls,0]]}(h,c,x._pixelsPerMercatorPixel,ve,Ce);for(let Mt=0;MtMath.PI/2*1.01}const m3e=Kr(85),Jct=Math.cos(m3e),edt=Math.sin(m3e),tdt=b(),p3e=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 f3e(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,ve=h.projection.projectTilePoint(le.x,le.y,H);if(ue>0){const ze=h.projection.upVector(H,le.x,le.y);ve.x+=ze[0]*Q*ue,ve.y+=ze[1]*Q*ue,ve.z+=ze[2]*Q*ue}const Ce=T?le:sdt(ve.x,ve.y,ve.z,g),Ee=T?x.tilespaceRays.map(ze=>ndt(ze,ue)):x.queryGeometry.screenGeometry,Ke=pt([],[ve.x,ve.y,ve.z,1],g);if(!P&&T?F*=Ke[3]/h.cameraToCenterDistance:P&&!T&&(F*=h.cameraToCenterDistance/Ke[3]),T){const ze=ts((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 k3e(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=T3e(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=Hpe(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,ve=1;do{let Ce,Ee=le;le=null;let Ke=null;for(ue=0;Ee;){ue++;let ze=Ee,nt=0;for(let lt=0;lt0||ot>0&&ze;)nt!==0&&(ot===0||!ze||Ee.z<=ze.z)?(Ce=Ee,Ee=Ee.nextZ,nt--):(Ce=ze,ze=ze.nextZ,ot--),Ke?Ke.nextZ=Ce:le=Ce,Ce.prevZ=Ke,Ke=Ce;Ee=ze}Ke.nextZ=null,ve*=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?ddt(x,g,j,T):cdt(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=udt(k2(x),c),c,h,g,j,T,2):P===2&&hdt(x,c,h,g,j,T):t6(k2(x),c,h,g,j,T,1);break}}}function cdt(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 ddt(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),ve=Math.max(R,F,H),Ce=Math.max(Q,se,re),Ee=Hpe(le,ue,c,h,g),Ke=Hpe(ve,Ce,c,h,g);let ze=x.prevZ,nt=x.nextZ;for(;ze&&ze.z>=Ee&&nt&&nt.z<=Ke;){if(ze.x>=le&&ze.x<=ve&&ze.y>=ue&&ze.y<=Ce&&ze!==j&&ze!==P&&s6(R,Q,F,se,H,re,ze.x,ze.y)&&Cc(ze.prev,ze,ze.next)>=0||(ze=ze.prevZ,nt.x>=le&&nt.x<=ve&&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(;ze&&ze.z>=Ee;){if(ze.x>=le&&ze.x<=ve&&ze.y>=ue&&ze.y<=Ce&&ze!==j&&ze!==P&&s6(R,Q,F,se,H,re,ze.x,ze.y)&&Cc(ze.prev,ze,ze.next)>=0)return!1;ze=ze.prevZ}for(;nt&&nt.z<=Ke;){if(nt.x>=le&&nt.x<=ve&&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 udt(x,c){let h=x;do{const g=h.prev,j=h.next.next;!O3(g,j)&&C3e(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 hdt(x,c,h,g,j,T){let P=x;do{let R=P.next.next;for(;R!==P.prev;){if(P.i!==R.i&&gdt(P,R)){let F=M3e(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 mdt(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 pdt(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 ve=P.x+(F-P.y)*(P.next.x-P.x)/(P.next.y-P.y);if(ve<=R&&ve>Q&&(Q=ve,H=P.x=P.x&&P.x>=re&&R!==P.x&&S3e(FH.x||P.x===H.x&&fdt(H,P)))&&(H=P,ue=ve)}P=P.next}while(P!==se);return H}(x,c);if(!h)return c;const g=M3e(h,x);return k2(g,g.next),k2(h,h.next)}function fdt(x,c){return Cc(x.prev,x,c.prev)<0&&Cc(c.next,x,x.next)<0}function Hpe(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 xdt(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)&&S3e(x,c,h,g,j,T,P,R)}function gdt(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&&C3e(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 C3e(x,c,h,g){const j=HF(Cc(x,c,h)),T=HF(Cc(x,c,g)),P=HF(Cc(h,g,x)),R=HF(Cc(h,g,c));return j!==T&&P!==R||!(j!==0||!VF(x,h,c))||!(T!==0||!VF(x,g,c))||!(P!==0||!VF(h,x,g))||!(R!==0||!VF(h,c,g))}function VF(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 HF(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 M3e(x,c){const h=Gpe(x.i,x.x,x.y),g=Gpe(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 T3e(x,c,h,g){const j=Gpe(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 Gpe(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,ve=this.vertexHashLookup.get(rm.computePosHash(se));ve!=null?ue=ve.next:(ve=this.vertexHashLookup.get(rm.computePosHash(re)),ue=ve!=null?ve.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 vdt(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(c.portals,this.unevalEdges);const T=h(),P=h(),R=h(),F=(re,le)=>{re.sort((ve,Ce)=>ve.type===le&&Ce.type!==le?-1:ve.type!==le&&Ce.type===le?1:0);const ue=re.findIndex(ve=>ve.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=wi.simpleSegment(0,se.primitiveOffset,0,se.primitiveLength),this.depthSegments=wi.simpleSegment(0,P.primitiveOffset,0,P.primitiveLength),this.renderableBridgeSegments=wi.simpleSegment(0,R.primitiveOffset,0,R.primitiveLength),this.renderableTunnelSegments=wi.simpleSegment(0,Q.primitiveOffset,0,Q.primitiveLength),this.shadowCasterSegments=wi.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,odt.members),this.vertexBufferNormal=c.createVertexBuffer(this.vertexNormals,ldt.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;Hie(bs,h[ps].x,h[ps].y,g[ps]*F),se=J(),re=J(),le=J(),ue=J(),ve=J(),Ce=(bs,ps)=>{const Is=R.get(rm.computePosHash(h[ps])),es=Is.from,vs=Is.to;if(!es||!vs)return;Q(se,es),Q(re,ps),Q(le,vs),et(ue),tt(se,re)||(_e(ve,re,se),ke(ue,ve)),tt(le,re)||(_e(ve,le,re),oe(ue,ue,ke(ve,ve)));const Ss=We(ue);return Ss>0?Ne(bs,ue,1/Ss):void 0};let Ee=Number.POSITIVE_INFINITY;this.sortSubarray(j,T.min,T.max,(bs,ps)=>bs.featureInfo.featureIndex-ps.featureInfo.featureIndex);const Ke=J(),ze=J(),nt=J(),ot=J(),lt=J(),It=J(),jt=J(),Pt=J(),Ct=J(),Mt=[J(),J(),J(),J()],ss=[J(),J(),J(),J()],is=[{coord:new ns(0,0),height:0},{coord:new ns(0,0),height:0}],ms=(bs,ps)=>bs>ps;for(let bs=T.min;bsEe.featureInfo.featureIndex-Ke.featureInfo.featureIndex;this.sortSubarray(j,T.min,T.max,F),this.sortSubarray(j,P.min,P.max,F);const H=Ee=>ke(Ee,Ee),Q=[{coord:new ns(0,0),height:0},{coord:new ns(0,0),height:0}],se=(Ee,Ke)=>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 _dt(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&&Xpe(c,h,0,j-1,this._compare),this._root=Ype(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 Zpe(g,T).load(c,h,j)}}function Ype(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=Ype(R,c,h,g,P),R.right=Ype(R,c,h,P+1,j),R}return null}function Xpe(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}Xpe(x,c,h,R,j),Xpe(x,c,R+1,g,j)}const E3e=11102230246251565e-32,jh=134217729,bdt=(3+8*E3e)*E3e;function Qpe(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 Jpe(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,ve,Ce,Ee,Ke,ze,nt){let ot,lt,It,jt,Pt,Ct,Mt,ss,is,ms,bs,ps,Is,es,vs,Ss,Ls,Ws;const mr=ue-Ke,er=Ce-Ke,Js=ve-ze,Ks=Ee-ze;es=mr*Ks,Ct=jh*mr,Mt=Ct-(Ct-mr),ss=mr-Mt,Ct=jh*Ks,is=Ct-(Ct-Ks),ms=Ks-is,vs=ss*ms-(es-Mt*is-ss*is-Mt*ms),Ss=Js*er,Ct=jh*Js,Mt=Ct-(Ct-Js),ss=Js-Mt,Ct=jh*er,is=Ct-(Ct-er),ms=er-is,Ls=ss*ms-(Ss-Mt*is-ss*is-Mt*ms),bs=vs-Ls,Pt=vs-bs,F3[0]=vs-(bs+Pt)+(Pt-Ls),ps=es+bs,Pt=ps-es,Is=es-(ps-Pt)+(bs-Pt),bs=Is-Ss,Pt=Is-bs,F3[1]=Is-(bs+Pt)+(Pt-Ss),Ws=ps+bs,Pt=Ws-ps,F3[2]=ps-(Ws-Pt)+(bs-Pt),F3[3]=Ws;let cr=function(Na,An){let Ca=An[0];for(let Vn=1;Vn<4;Vn++)Ca+=An[Vn];return Ca}(0,F3),br=22204460492503146e-32*nt;if(cr>=br||-cr>=br||(Pt=ue-mr,ot=ue-(mr+Pt)+(Pt-Ke),Pt=Ce-er,It=Ce-(er+Pt)+(Pt-Ke),Pt=ve-Js,lt=ve-(Js+Pt)+(Pt-ze),Pt=Ee-Ks,jt=Ee-(Ks+Pt)+(Pt-ze),ot===0&<===0&&It===0&&jt===0)||(br=11093356479670487e-47*nt+bdt*Math.abs(cr),cr+=mr*jt+Ks*ot-(Js*It+er*lt),cr>=br||-cr>=br))return cr;es=ot*Ks,Ct=jh*ot,Mt=Ct-(Ct-ot),ss=ot-Mt,Ct=jh*Ks,is=Ct-(Ct-Ks),ms=Ks-is,vs=ss*ms-(es-Mt*is-ss*is-Mt*ms),Ss=lt*er,Ct=jh*lt,Mt=Ct-(Ct-lt),ss=lt-Mt,Ct=jh*er,is=Ct-(Ct-er),ms=er-is,Ls=ss*ms-(Ss-Mt*is-ss*is-Mt*ms),bs=vs-Ls,Pt=vs-bs,nm[0]=vs-(bs+Pt)+(Pt-Ls),ps=es+bs,Pt=ps-es,Is=es-(ps-Pt)+(bs-Pt),bs=Is-Ss,Pt=Is-bs,nm[1]=Is-(bs+Pt)+(Pt-Ss),Ws=ps+bs,Pt=Ws-ps,nm[2]=ps-(Ws-Pt)+(bs-Pt),nm[3]=Ws;const Br=Qpe(4,F3,4,nm,P3e);es=mr*jt,Ct=jh*mr,Mt=Ct-(Ct-mr),ss=mr-Mt,Ct=jh*jt,is=Ct-(Ct-jt),ms=jt-is,vs=ss*ms-(es-Mt*is-ss*is-Mt*ms),Ss=Js*It,Ct=jh*Js,Mt=Ct-(Ct-Js),ss=Js-Mt,Ct=jh*It,is=Ct-(Ct-It),ms=It-is,Ls=ss*ms-(Ss-Mt*is-ss*is-Mt*ms),bs=vs-Ls,Pt=vs-bs,nm[0]=vs-(bs+Pt)+(Pt-Ls),ps=es+bs,Pt=ps-es,Is=es-(ps-Pt)+(bs-Pt),bs=Is-Ss,Pt=Is-bs,nm[1]=Is-(bs+Pt)+(Pt-Ss),Ws=ps+bs,Pt=Ws-ps,nm[2]=ps-(Ws-Pt)+(bs-Pt),nm[3]=Ws;const Tr=Qpe(Br,P3e,4,nm,I3e);es=ot*jt,Ct=jh*ot,Mt=Ct-(Ct-ot),ss=ot-Mt,Ct=jh*jt,is=Ct-(Ct-jt),ms=jt-is,vs=ss*ms-(es-Mt*is-ss*is-Mt*ms),Ss=lt*It,Ct=jh*lt,Mt=Ct-(Ct-lt),ss=lt-Mt,Ct=jh*It,is=Ct-(Ct-It),ms=It-is,Ls=ss*ms-(Ss-Mt*is-ss*is-Mt*ms),bs=vs-Ls,Pt=vs-bs,nm[0]=vs-(bs+Pt)+(Pt-Ls),ps=es+bs,Pt=ps-es,Is=es-(ps-Pt)+(bs-Pt),bs=Is-Ss,Pt=Is-bs,nm[1]=Is-(bs+Pt)+(Pt-Ss),Ws=ps+bs,Pt=Ws-ps,nm[2]=ps-(Ws-Pt)+(bs-Pt),nm[3]=Ws;const Tn=Qpe(Tr,I3e,4,nm,L3e);return L3e[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:Jpe(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 GF(x,c){return x[0]*c[1]-x[1]*c[0]}function efe(x,c){return x[0]*c[0]+x[1]*c[1]}function tfe(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(It,jt,Pt){return[It[0]+jt*Pt[0],It[1]+jt*Pt[1]]}const ve=[Q[0]-F[0],Q[1]-F[1]];let Ce=GF(re,le),Ee=Ce*Ce;const Ke=efe(re,re);if(Ee>0){const It=GF(ve,le)/Ce;if(It<0||It>1)return null;const jt=GF(ve,re)/Ce;return jt<0||jt>1?null:It===0||It===1?[ue(F,It,re)]:jt===0||jt===1?[ue(Q,jt,le)]:[ue(F,It,re)]}if(Ce=GF(ve,re),Ee=Ce*Ce,Ee>0)return null;const ze=efe(re,ve)/Ke,nt=ze+efe(re,le)/Ke,ot=Math.min(ze,nt),lt=Math.max(ze,nt);return ot<=1&<>=0?ot===1?[ue(F,ot>0?ot:0,re)]:lt===0?[ue(F,lt<1?lt:1,re)]:[ue(F,ot>0?ot: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 wdt(x,c){if(x===c)return 0;if(Jpe(x.point,x.otherEvent.point,c.point)!==0||Jpe(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 jdt{constructor(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null}isExterior(){return this.holeOf==null}}function Ndt(x,c,h,g){let j,T=x+1,P=c[x].point;const R=c.length;for(Tg;)T--;return T}function kdt(x,c,h){const g=new jdt;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 R3e=Math.max,O3e=Math.min;let WF=0;function F3e(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]=O3e(j[0],re),j[1]=O3e(j[1],le),j[2]=R3e(j[2],re),j[3]=R3e(j[3],le),g.push(Q),g.push(se)}}const KF=[];function z3e(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 ve=null;return re.length*le.length===0&&(ue===0?ve=KF:ue===2?ve=re:(ue===1||ue===3)&&(ve=re.length===0?le:re)),ve}(g,j,h);if(T)return T===KF?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,ve,Ce){const Ee=new Gw(void 0,a_);let Ke,ze,nt,ot,lt,It;for(nt=0,ot=re.length;ntve[2]||ve[0]>ue[2]||ue[1]>ve[3]||ve[1]>ue[3])&&(Ce===0?Ee=KF:Ce===2?Ee=re:(Ce===1||Ce===3)&&(Ee=re.concat(le))),Ee}(g,j,P,R,h),T)return T===KF?null:T;const H=function(re,le,ue,ve,Ce,Ee){const Ke=new Zpe(wdt),ze=[],nt=Math.min(ve[2],Ce[2]);let ot,lt,It;for(;re.length!==0;){let jt=re.pop();if(ze.push(jt),Ee===0&&jt.point[0]>nt||Ee===2&&jt.point[0]>ve[2])break;if(jt.left){lt=ot=Ke.insert(jt),It=Ke.minNode(),ot=ot!==It?Ke.prev(ot):null,lt=Ke.next(lt);const Pt=ot?ot.key:null;let Ct;if(o6(jt,Pt,Ee),lt&&tfe(jt,lt.key,re)===2&&(o6(jt,Pt,Ee),o6(lt.key,jt,Ee)),ot&&tfe(ot.key,jt,re)===2){let Mt=ot;Mt=Mt!==It?Ke.prev(Mt):null,Ct=Mt?Mt.key:null,o6(Pt,Ct,Ee),o6(jt,Pt,Ee)}}else jt=jt.otherEvent,lt=ot=Ke.find(jt),ot&<&&(ot=ot!==It?Ke.prev(ot):null,lt=Ke.next(lt),Ke.remove(jt),lt&&ot&&tfe(ot.key,lt.key,re))}return ze}(F,0,0,P,R,h),Q=function(re){let le,ue;const ve=function(Ke){let ze,nt,ot,lt,It;const jt=[];for(nt=0,ot=Ke.length;nt{Ce[It]=!0,It=ve.length)&&ve[ot];);Ee.push(ze)}return Ee}(H),se=[];for(let re=0;re{P.push(new ns(se,F+(se-R)/(H-R)*(Q-F)))}:(P,R,F,H,Q,se)=>{P.push(new ns(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,ve,Ce,c):Ee>h?Ke=c&&T(H,le,ue,ve,Ce,c),Ke>h&&Ee<=h&&T(H,le,ue,ve,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 Sdt(x,c){const h=z3e(sfe(x),sfe([c]),0);return h==null?[]:B3e(h)}function Cdt(x,c,h=0){let j=sfe(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 ve=Math.trunc(le/ue*3),Ce=-Math.trunc(re/ue*3);T.push([[[F,H],[Q,se],[Q+ve,se+Ce],[F+ve,H+Ce],[F,H]]])}return T.length>0&&(j=z3e(j,T,2)),B3e(j,1/65536,128)}function sfe(x,c=1){return[x.map(h=>h.map(g=>[g.x*c,g.y*c]))]}function B3e(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 ns(F*c,H*c)._round()});return T>0&&P.reverse(),P}))}class rfe{constructor(c,h){this.layoutVertexArray=new _h,this.indexArray=new Ao,this.lineIndexArray=new Hm,this.triangleSegments=new wi,this.lineSegments=new wi,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,adt.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,idt.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 YF{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 rfe(c,!1),this.elevationBufferData=new rfe(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=Wpe("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=Un(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:qr(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=Kpe("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(Ni)&&(re=+c.properties[Ni]),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 ze of F)H+=ze.length;const Q=h.triangleSegments.prepareSegment(H,h.layoutVertexArray,h.indexArray),se=Q.vertexLength,re=[],le=[],ue=[],ve=[],Ce=[],Ee=h.layoutVertexArray.length;for(const ze of F){if(ze.length===0)continue;ze!==F[0]&&le.push(re.length/2);const nt=h.lineSegments.prepareSegment(ze.length,h.layoutVertexArray,h.lineIndexArray),ot=nt.vertexLength;g&&Ce.push(h.layoutVertexArray.length-Ee),R(ze[0],ue,ve),h.layoutVertexArray.emplaceBack(ze[0].x,ze[0].y),h.lineIndexArray.emplaceBack(ot+ze.length-1,ot),re.push(ze[0].x),re.push(ze[0].y);for(let lt=1;lt0&&g&&this.elevationMode==="hd-road-base"){const ze=g.elevation.isTunnel(),nt=g.elevation.safeArea,ot=this.elevatedStructures.addVertices(ue,ve);this.elevatedStructures.addTriangles(Ke,ot,ze);const lt=Ce.length;if(lt>0){for(let It=0;It=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 ns(g,j),new ns(T,j),new ns(T,P),new ns(g,P),new ns(g,j)],se=F;for(const re of H)se.push(...Sdt(re,Q));return se}}let $3e,q3e,U3e,V3e;fr(YF,"FillBucket",{omit:["layers","patternFeatures"]}),fr(rfe,"FillBufferData"),fr(rm,"ElevatedStructures");class XF{constructor(c,h,g,j){if(this.triangleCount=h.length/3,this.min=new ns(0,0),this.max=new ns(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],this.triangleCount===0||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=Un(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:qr(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 ns(1/0,1/0),le=new ns(-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 ns((F.x+T.x*sr)*R-P.x*sr,(F.y+T.y*sr)*R-P.y*sr))}return afe(h,j,x.indices,0,x.indices.length,0,0)}function Y3e(x,c,h,g){const j=Math.pow(2,g.z-h.z);return new ns((x+h.x*sr)*j-g.x*sr,(c+h.y*sr)*j-g.y*sr)}function X3e(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 ofe=mn.types,Fdt=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius","fill-extrusion-line-width","fill-extrusion-emissive-strength"],zdt=["fill-extrusion-flood-light-ground-radius"],Bdt=Math.pow(2,13),$dt=Math.pow(2,15)-1,t7=new ns(0,1),ov=2147483648,s7=1073741824;function c6(x,c,h,g,j,T,P,R){x.emplaceBack((c<<1)+P,(h<<1)+T,(Math.floor(g*Bdt)<<1)+j,Math.round(R))}function d6(x,c,h){x.emplaceBack(c.x*sr,c.y*sr,h?1:0)}function r7(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 J3e{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class lfe{constructor(){this.centroidXY=new ns(0,0),this.vertexArrayOffset=0,this.vertexCount=0,this.groundVertexArrayOffset=0,this.groundVertexCount=0,this.flags=0,this.footprintSegIdx=-1,this.footprintSegLen=0,this.polygonSegIdx=-1,this.polygonSegLen=0,this.min=new ns(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new ns(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0,this.groupCentroidPos=new ns(0,0)}span(){return new ns(this.max.x-this.min.x,this.max.y-this.min.y)}}class cfe{constructor(){this.acc=new ns(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,nn(h.y,c.y,(0-h.x)/(c.x-h.x))),h.x>sr!=c.x>sr&&this.addBorderIntersection(1,nn(h.y,c.y,(sr-h.x)/(c.x-h.x))),h.y<0!=c.y<0&&this.addBorderIntersection(2,nn(h.x,c.x,(0-h.y)/(c.y-h.y))),h.y>sr!=c.y>sr&&this.addBorderIntersection(3,nn(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 ns(0,0):new ns(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce((c,h)=>c+ +(h[0]!==Number.MAX_VALUE),0):0}}function e5e(x,c){const h=x.add(c)._unit(),g=Oe(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*$dt*((j=x).x*(T=c).y-j.y*T.x<0?-1:1)}const qdt=[x=>x.x<0,x=>x.x>sr,x=>x.y<0,x=>x.y>sr];function Udt(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(qdt[F](H)){j.push(F);break}return j}class dfe{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=>zdt.includes(h)),this._segments=new wi,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 wi}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=e5e(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 wi);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,Idt.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 n7{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 OF,this.wallVertexArray=new ZP,this.indexArray=new Ao,this.programConfigurations=new Ae(c.layers,{zoom:c.zoom,lut:c.lut},h=>Fdt.includes(h)),this.segments=new wi,this.stateDependentLayerIds=this.layers.filter(h=>h.isStateDependent()).map(h=>h.id),this.groundEffect=new dfe(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=Wpe("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=Cs(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=Un(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:qr(T,g,j),properties:T.properties,type:T.type,patterns:{}},re=this.layoutVertexArray.length,le=ofe[se.type]==="Polygon";if(this.hasPattern)this.features.push({featureId:T.id,feature:Kpe("fill-extrusion",this.layers,se,this.zoom,this.pixelRatio,h)});else if(this.wallMode)for(const ue of se.geometry)for(const ve of Q3e(ue,le))this.addFeature(T.id,se,[ve],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=ofe[F.type]==="Polygon",{geometry:Q}=F;if(this.wallMode)for(const se of Q)for(const re of Q3e(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,Ddt),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.wallVertexBuffer=c.createVertexBuffer(this.wallVertexArray,Pdt.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=c.createVertexBuffer(this.layoutVertexExtArray,Ldt.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,Edt.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 ns(0,0),new ns(sr,sr)],re=F.projection,le=re.name==="globe",ue=this.wallMode||ofe[h.type]==="Polygon",ve=new cfe;ve.centroidDataIndex=this.centroidData.length;const Ce=new lfe;Ce.buildingId=c,h.properties&&h.properties.hasOwnProperty("building_id")&&(Ce.buildingId=Number(h.properties.building_id)),ve.buildingId=Ce.buildingId;const Ee=this.layers[0].paint.get("fill-extrusion-base").evaluate(h,{},T)<=0,Ke=this.layers[0].paint.get("fill-extrusion-height").evaluate(h,{},T);let ze;if(Ce.height=Ke,Ce.vertexArrayOffset=this.layoutVertexArray.length,Ce.groundVertexArrayOffset=this.groundEffect.vertexArray.length,le&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new k3),this.wallMode){if(le)return void Rr("Non zero fill-extrusion-line-width is not yet supported on globe.");if(g.length!==1)return;ze=function(Ct){const Mt=Ct[0].x===Ct[Ct.length-1].x&&Ct[0].y===Ct[Ct.length-1].y;(function(Js){let Ks=0;const cr=Js.length;for(let br=0;br=0})(Ct)||(Ct=Ct.reverse());const is={geometry:[],joinNormals:[],indices:[]},ms=[],bs=[],ps=[];let Is=Ct.length;for(;Is>=2&&Ct[Is-1].equals(Ct[Is-2]);)Is--;if(Is<(Mt?3:2))return is;let es,vs,Ss,Ls,Ws,mr=0;for(;mr0;let Tr="miter";const Tn=2;Tr==="miter"&&br>Tn&&(Tr="bevel"),Tr==="bevel"&&(br>100&&(Tr="flipbevel"),br{const Za=new ns(An.x,An.y),Da=new ns(An.x,An.y);Za.x+=Ca.x*mo,Za.y+=Ca.y*mo,Da.x-=Ca.x*Math.max(Vn,1),Da.y-=Ca.y*Math.max(Vn,1),ps.push(Ca),ms.push(Za),bs.push(Da)};if(Tr==="miter")Ks._mult(br),Na(es,Ks,0,0);else if(Tr==="flipbevel")Ks=Ws.mult(-1),Na(es,Ks,0,0),Na(es,Ks.mult(-1),0,0);else{const An=-Math.sqrt(br*br-1),Ca=Br?An:0,Vn=Br?0:An;vs&&Na(es,Ls,Ca,Vn),Ss&&Na(es,Ws,Ca,Vn)}}is.geometry=[...ms,...bs.reverse(),ms[0]],is.joinNormals=[...ps,...ps.reverse(),ps[ps.length-1]];const er=is.geometry.length-1;for(let Js=0;JsCt<(Mt.length-1)/2||Ct===Mt.length-1,ot=this.wallMode?[g]:a6(g,500);for(let Ct=ot.length-1;Ct>=0;Ct--){const Mt=ot[Ct];(Mt.length===0||Hdt(Mt[0]))&&ot.splice(Ct,1)}let lt;if(le)lt=o5e(ot,se,T);else{lt=[];for(const Ct of ot)lt.push({polygon:Ct,bounds:se})}const It=ue?this.edgeRadius:0,jt=It>0&&this.zoom<17,Pt=(Ct,Mt)=>{if(Ct.length===0)return!1;const ss=Ct[Ct.length-1];return Mt.x===ss.x&&Mt.y===ss.y};for(const{polygon:Ct,bounds:Mt}of lt){let ss=0,is=0;for(const Is of Ct)ue&&!Is[0].equals(Is[Is.length-1])&&Is.push(Is[0]),is+=ue?Is.length-1:Is.length;const ms=this.segments.prepareSegment((ue?5:4)*is,this.layoutVertexArray,this.indexArray);Ce.footprintSegIdx<0&&(Ce.footprintSegIdx=this.footprintSegments.length),Ce.polygonSegIdx<0&&(Ce.polygonSegIdx=this.polygonSegments.length);const bs={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},ps=new J3e;if(ps.vertexOffset=this.footprintVertices.length,ps.indexOffset=3*this.footprintIndices.length,ps.ringIndices=[],ue){const Is=[],es=[];ss=ms.vertexLength;for(let Ss=0;Ss4&&n5e(es[es.length-2],es[0],es[1]),Ss=It?Vdt(es[es.length-2],es[0],es[1],It):0;const Ls=[];let Ws,mr,er;mr=es[1].sub(es[0])._perp()._unit();let Js=!0;for(let Ks=1,cr=0;Ks0?1:0,Ca=br.dist(Br);if(cr+Ca>32768&&(cr=0),It){er=Tr.sub(Br)._perp()._unit();let Da=s5e(br,Br,Tr,t5e(mr,er),It);isNaN(Da)&&(Da=0);const ki=Br.sub(br)._unit();br=br.add(ki.mult(Ss))._round(),Br=Br.add(ki.mult(-Da))._round(),Ss=Da,mr=er,Ee&&this.zoom>=17&&(Pt(Ls,br)||Ls.push(br),Pt(Ls,Br)||Ls.push(Br))}const Vn=ms.vertexLength,mo=es.length>4&&n5e(br,Br,Tr);let Za=a5e(cr,vs,Js);if(c6(this.layoutVertexArray,br.x,br.y,Na,An,0,0,Za),c6(this.layoutVertexArray,br.x,br.y,Na,An,0,1,Za),this.wallMode){const Da=nt(Ks-1,es),ki=ze.joinNormals[Ks-1];d6(this.wallVertexArray,ki,Da),d6(this.wallVertexArray,ki,Da)}if(cr+=Ca,Za=a5e(cr,mo,!Js),vs=mo,c6(this.layoutVertexArray,Br.x,Br.y,Na,An,0,0,Za),c6(this.layoutVertexArray,Br.x,Br.y,Na,An,0,1,Za),this.wallMode){const Da=nt(Ks,es),ki=ze.joinNormals[Ks];d6(this.wallVertexArray,ki,Da),d6(this.wallVertexArray,ki,Da)}if(ms.vertexLength+=4,this.indexArray.emplaceBack(Vn+0,Vn+1,Vn+2),this.indexArray.emplaceBack(Vn+1,Vn+3,Vn+2),ms.primitiveLength+=2,It){const Da=ss+(Ks===1?es.length-2:Ks-2),ki=Ks===1?ss:Da+1;if(this.indexArray.emplaceBack(Vn+1,Da,Vn+3),this.indexArray.emplaceBack(Da,ki,Vn+3),ms.primitiveLength+=2,Ws===void 0&&(Ws=Vn),!ufe(Tr,es[Ks],Mt)){const oo=Ks===es.length-1?Ws:ms.vertexLength;this.indexArray.emplaceBack(Vn+2,Vn+3,oo),this.indexArray.emplaceBack(Vn+3,oo+1,oo),this.indexArray.emplaceBack(Vn+3,ki,oo+1),ms.primitiveLength+=3}Js=!Js}if(le){const Da=this.layoutVertexExtArray,ki=re.projectTilePoint(br.x,br.y,T),oo=re.projectTilePoint(Br.x,Br.y,T),cc=re.upVector(T,br.x,br.y),lo=re.upVector(T,Br.x,Br.y);u6(Da,ki,cc),u6(Da,ki,cc),u6(Da,oo,lo),u6(Da,oo,lo)}}ue&&(ss+=es.length-1),Ee&&It&&this.zoom>=17&&(Ls.length!==0&&Pt(Ls,Ls[0])&&Ls.pop(),this.groundEffect.addData(Ls,Mt,Q,It>0))}this.footprintSegments.push(ps),bs.triangleCount=this.indexArray.length-bs.triangleArrayOffset,this.polygonSegments.push(bs),++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=ve.borders?t7:this.encodeCentroid(ve,Ce),h.properties&&h.properties.hasOwnProperty("building_id")){const Ct=Ce.buildingId;let Mt=this.buildingGroups.get(Ct);Mt||(Mt={accX:0,accY:0,accCount:0,mergedMin:new ns(Number.MAX_VALUE,Number.MAX_VALUE),mergedMax:new ns(-Number.MAX_VALUE,-Number.MAX_VALUE),partIndices:[]},this.buildingGroups.set(Ct,Mt)),Mt.accX+=ve.acc.x,Mt.accY+=ve.acc.y,Mt.accCount+=ve.accCount,Mt.mergedMin.x=Math.min(Mt.mergedMin.x,Ce.min.x),Mt.mergedMin.y=Math.min(Mt.mergedMin.y,Ce.min.y),Mt.mergedMax.x=Math.max(Mt.mergedMax.x,Ce.max.x),Mt.mergedMax.y=Math.max(Mt.mergedMax.y,Ce.max.y),Mt.partIndices.push(this.centroidData.length)}if(this.centroidData.push(Ce),ve.borders){this.featuresOnBorder.push(ve);const Ct=this.featuresOnBorder.length-1;for(let Mt=0;Mtthis.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[ve[0]*(1-Ee[0])+Ce[0]*Ee[0],ve[1]*(1-Ee[1])+Ce[1]*Ee[1]],le=[],ue=[];for(const ve of this.triangleSubSegments){le[0]=ve.min.x/sr,le[1]=ve.min.y/sr,ue[0]=ve.max.x/sr,ue[1]=ve.max.y/sr;const Ce=re(Q,se,le),Ee=re(Q,se,ue);if(new Ja([Ce[0],Ce[1],T],[Ee[0],Ee[1],P]).intersectsPrecise(g)===0){H&&(j.segments.push(H),H=void 0);continue}const Ke=ve.segment;H&&H.vertexOffset!==Ke.vertexOffset&&(j.segments.push(H),H=void 0),H?(H.vertexLength+=Ke.vertexLength,H.primitiveLength+=Ke.primitiveLength):H={vertexOffset:Ke.vertexOffset,primitiveLength:Ke.primitiveLength,vertexLength:Ke.vertexLength,primitiveOffset:Ke.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 ns(Oe(g.x,1,8191)<<3|T,Oe(g.y,1,8191)<<3|P)}encodeBorderCentroid(c){if(!c.borders)return new ns(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 ns(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 ns((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 ns(Oe(h.groupCentroidPos.x,1,8191)<<3|j,Oe(h.groupCentroidPos.y,1,8191)<<3|T)}else h.centroidXY=new ns(0,0);this.writeCentroidToBuffer(h)}writeCentroidToBuffer(c){this.groundEffect.updateHiddenByLandmark(c);const h=c.vertexArrayOffset,g=c.vertexCount+c.vertexArrayOffset,j=-1073741824&c.flags?t7: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!==e7.None?-1073741824:ov);else for(const F of this.centroidData)if(!(F.flags&ov||F.flags&s7||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 t5e(x,c){const h=x.add(c)._unit();return x.x*h.x+x.y*h.y}function Vdt(x,c,h,g){const j=c.sub(x)._perp()._unit(),T=h.sub(c)._perp()._unit();return s5e(x,c,h,t5e(j,T),g)}function s5e(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 ufe(x,c,h){return x.xh[1].x&&c.x>h[1].x||x.yh[1].y&&c.y>h[1].y}function r5e(x,c){return x.xc[1].x||x.yc[1].y}function Hdt(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 n5e(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 a5e(x,c,h){const g=c?2|x:-3&x;return h?1|g:-2&g}function i5e(){const x=Math.PI/32,c=Math.tan(x),h=At;return h*Math.sqrt(1+2*c*c)-h}function o5e(x,c,h){const g=1<{for(const jt of lt)ue.push({polygon:jt,bounds:It})},Ce=Math.ceil(Math.log2(Q)),Ee=Math.ceil(Math.log2(se)),Ke=Ce-Ee,ze=[];for(let lt=0;lt0?0:1);for(let lt=0;ltIt+1?ot.push({polygons:ms,bounds:ps,depth:It+1}):ve(ms,ps)}if(bs.length){const ps=[new ns(jt===0?is:Pt.x,jt===1?is:Pt.y),Ct];ze.length>It+1?ot.push({polygons:bs,bounds:ps,depth:It+1}):ve(bs,ps)}}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=ts((h.y+H/sr)/g);return(As(.5*(ts((h.y+Q/sr)/g)+se))*g-h.y)*sr}})}function Gdt(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&&u5e(R,F,P,j),R[P]T&&u5e(F,R,P,T)}}function a7(x,c,h,g,j,T){const P=[];for(let R=0;R=g&&ue.x>=g||(le.x>=g?le=new ns(g,le.y+(g-le.x)/(ue.x-le.x)*(ue.y-le.y))._round():ue.x>=g&&(ue=new ns(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 ns(le.x+(j-le.y)/(ue.y-le.y)*(ue.x-le.x),j)._round():ue.y>=j&&(ue=new ns(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+m5e(Ee,Ke,le)*ve,max:1},parentIndex:R,prevPoint:Ee,nextPoint:Ke})),H.push(ue),T&&(T[T.length-1].progress.max=Ce+m5e(Ee,Ke,ue)*ve,T[T.length-1].nextPoint=Ke)))))}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 m5e(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 p5e(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{is[0]=ms,is[1]=bs,is[2]=ps,is[3]=1},ss=i5e();le>0&&(le+=ss),ue+=ss;for(const is of re){const ms=[],bs=[];for(const ps of is){const Is=ps.x+ve.x,es=ps.y+ve.y,vs=se.projection.projectTilePoint(Is,es,ot),Ss=se.projection.upVector(ot,ps.x,ps.y);let Ls=le,Ws=ue;if(Ee){const mr=g5e(Is,es,le,ue,Ee,Ke,ze,nt);Ls+=mr.base,Ws+=mr.top}le!==0?Mt(Pt,vs.x+Ss[0]*jt*Ls,vs.y+Ss[1]*jt*Ls,vs.z+Ss[2]*jt*Ls):Mt(Pt,vs.x,vs.y,vs.z),Mt(Ct,vs.x+Ss[0]*jt*Ws,vs.y+Ss[1]*jt*Ws,vs.z+Ss[2]*jt*Ws),ut(Pt,Pt,Ce),ut(Ct,Ct,Ce),ms.push(new S2(Pt[0],Pt[1],Pt[2])),bs.push(new S2(Ct[0],Ct[1],Ct[2]))}lt.push(ms),It.push(bs)}return[lt,It]}(x,c,h,g,j,T,P,R,F,H,Q):P?function(se,re,le,ue,ve,Ce,Ee,Ke,ze){const nt=[],ot=[],lt=[0,0,0,1];for(const It of se){const jt=[],Pt=[];for(const Ct of It){const Mt=Ct.x+ue.x,ss=Ct.y+ue.y,is=g5e(Mt,ss,re,le,Ce,Ee,Ke,ze);lt[0]=Mt,lt[1]=ss,lt[2]=is.base,lt[3]=1,pt(lt,lt,ve),lt[3]=Math.max(lt[3],1e-5);const ms=new S2(lt[0]/lt[3],lt[1]/lt[3],lt[2]/lt[3]);lt[0]=Mt,lt[1]=ss,lt[2]=is.top,lt[3]=1,pt(lt,lt,ve),lt[3]=Math.max(lt[3],1e-5);const bs=new S2(lt[0]/lt[3],lt[1]/lt[3],lt[2]/lt[3]);jt.push(ms),Pt.push(bs)}nt.push(jt),ot.push(Pt)}return[nt,ot]}(c,h,g,j,T,P,R,F,H):function(se,re,le,ue,ve){const Ce=[],Ee=[],Ke=ve[8]*re,ze=ve[9]*re,nt=ve[10]*re,ot=ve[11]*re,lt=ve[8]*le,It=ve[9]*le,jt=ve[10]*le,Pt=ve[11]*le;for(const Ct of se){const Mt=[],ss=[];for(const is of Ct){const ms=is.x+ue.x,bs=is.y+ue.y,ps=ve[0]*ms+ve[4]*bs+ve[12],Is=ve[1]*ms+ve[5]*bs+ve[13],es=ve[2]*ms+ve[6]*bs+ve[14],vs=ve[3]*ms+ve[7]*bs+ve[15],Ss=ps+Ke,Ls=Is+ze,Ws=es+nt,mr=Math.max(vs+ot,1e-5),er=ps+lt,Js=Is+It,Ks=es+jt,cr=Math.max(vs+Pt,1e-5);Mt.push(new S2(Ss/mr,Ls/mr,Ws/mr)),ss.push(new S2(er/cr,Js/cr,Ks/cr))}Ce.push(Mt),Ee.push(ss)}return[Ce,Ee]}(c,h,g,j,T)}function g5e(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),ve=Math.floor(re[1]/8),Ce=10*(re[0]-8*ue),Ee=10*(re[1]-8*ve),Ke=se.getElevationAt(ue,ve,!0,!0),ze=se.getMeterToDEM(le),nt=Math.floor(.5*(Ce*ze-1)),ot=Math.floor(.5*(Ee*ze-1)),lt=se.tileCoordToPixel(ue,ve),It=2*nt+1,jt=2*ot+1,Pt=function(bs,ps,Is,es,vs){return[bs.getElevationAtPixel(ps,Is,!0),bs.getElevationAtPixel(ps+vs,Is,!0),bs.getElevationAtPixel(ps,Is+vs,!0),bs.getElevationAtPixel(ps+es,Is+vs,!0)]}(se,lt.x-nt,lt.y-ot,It,jt),Ct=Math.abs(Pt[0]-Pt[1]),Mt=Math.abs(Pt[2]-Pt[3]),ss=Math.abs(Pt[0]-Pt[2])+Math.abs(Pt[1]-Pt[3]),is=Math.min(.25,.5*ze*(Ct+Mt)/It),ms=Math.min(.25,.5*ze*ss/jt);return Ke+Math.max(is*Ce,ms*Ee)}(j,T,R):F;return{base:F+(h===0?-1:h),top:H?Math.max(Q+g,F+h+2):F+g}}const hfe=4096;class Kdt{constructor(c){this.module=c,this.memoryStack=this.module.malloc(hfe),this.memoryStackNextFree=this.memoryStack}createIntArray(c){const h=this.memoryStackNextFree;return this.memoryStackNextFree+=c.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>hfe?-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>hfe?-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(C5e.decode(le.subarray(ue,ue+Ce))),ue+=Ce,ue>>0,Math.ceil(1.2*nt)),lt=Math.ceil((ot-nt)/65536);try{return ve.grow(lt),Ce(),!0}catch{return!1}},b:Ee}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(le,Ke):le.then(ze=>ze.arrayBuffer()).then(ze=>WebAssembly.instantiate(ze,Ke))).then(ze=>{const{Rb:nt,Qb:ot,P:lt,T:It,X:jt,Ja:Pt,La:Ct,Qa:Mt,Va:ss,Wa:is,eb:ms,jb:bs,f:ps,e:Is,yb:es,zb:vs,Ab:Ss,Bb:Ls,Db:Ws,Gb:mr}=ze.instance.exports;ve=Is;const er=(()=>{let Js=0,Ks=0,cr=0,br=0;return Br=>{cr&&(nt(br),nt(Js),Ks+=cr,cr=Js=0),Js||(Ks+=128,Js=ot(Ks));const Tr=Br.length+7&-8;let Tn=Js;Tr>=Ks&&(cr=Tr,Tn=br=ot(Tr));for(let Na=0;Na{Qx=le,m6=void 0}))}()),re&&Q.push(function(){if(mfe)return;const le=function(ue){let ve;const Ce=WebAssembly.instantiateStreaming(ue,{}).then(ze=>{ve=ze.instance,ve.exports.__wasm_call_ctors()}),Ee={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},Ke={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:Ce,supported:!0,decodeGltfBuffer(ze,nt,ot,lt,It,jt){(function(Pt,Ct,Mt,ss,is,ms,bs){const ps=Pt.exports.sbrk,Is=ss+3&-4,es=ps(Is*is),vs=ps(ms.length),Ss=new Uint8Array(Pt.exports.memory.buffer);Ss.set(ms,vs);const Ls=Ct(es,ss,is,vs,ms.length);if(Ls===0&&bs&&bs(es,Is,is),Mt.set(Ss.subarray(es,es+ss*is)),ps(es-ps(0)),Ls!==0)throw new Error(`Malformed buffer data: ${Ls}`)})(ve,ve.exports[Ke[It]],ze,nt,ot,lt,ve.exports[Ee[jt]])}}}(fetch(ac()));return le.ready.then(()=>{mfe=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 A5e(h,0,x,c)}function ffe(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 xfe(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,ffe(this.format),xfe(this.format),c):"data"in c&&c.data&&P.texSubImage2D(P.TEXTURE_2D,0,R,F,g,j,ffe(this.format),xfe(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 tut=la([{name:"a_pos_3f",components:3,type:"Float32"}]),sut=la([{name:"a_color_3f",components:3,type:"Float32"}]),rut=la([{name:"a_color_4f",components:4,type:"Float32"}]),nut=la([{name:"a_uv_2f",components:2,type:"Float32"}]),aut=la([{name:"a_normal_3f",components:3,type:"Float32"}]),iut=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"}]),out=la([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function P5e(x,c){const h=c7(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),ve=_r.fromLngLat(R);ve.y=Oe(ve.y,-1+o_,1-o_);const Ce=ve.toLngLat(),Ee=T.project(Ce.lng,Ce.lat),Ke=_r.fromLngLat(Ce);Ke.x+=o_;const ze=Ke.toLngLat(),nt=T.project(ze.lng,ze.lat),ot=L5e(nt.x-Ee.x,nt.y-Ee.y,ue),lt=_r.fromLngLat(Ce);lt.y+=o_;const It=lt.toLngLat(),jt=T.project(It.lng,It.lat),Pt=L5e(jt.x-Ee.x,jt.y-Ee.y,ue),Ct=Math.abs(ot.x)/Math.abs(Pt.y),Mt=w([]);V(Mt,Mt,-ue*(1-(H?0:F)));const ss=w([]);return I(ss,ss,[1,1-(1-Ct)*F,1]),ss[4]=-Pt.x/Pt.y*F,V(ss,ss,ue),C(ss,Mt,ss),ss}(x.projection,0,x.center,h,c),j=I5e(x);return I(g,g,[j,j,1]),g}function I5e(x){const c=x.projection,h=c7(x.projection,x.zoom,x.width,x.height),g=gfe(c,x.center),j=gfe(c,qt.convert(c.center));return Math.pow(2,g*h+(1-h)*j)}function c7(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 Ye(T[0]+R,T[1]+R,c)}const o_=1/4e4;function gfe(x,c){const h=Oe(c.lat,-85.051129,cs),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=_r.fromLngLat(g),F=_r.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 L5e(x,c,h){const g=Math.cos(h),j=Math.sin(h);return{x:x*g-c*j,y:x*j+c*g}}function D5e(x,c,h){w(x),V(x,x,Kr(c[2])),L(x,x,Kr(c[0])),O(x,x,Kr(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 d7(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=Be([],F,H);ke(Q,Q),me(H,g,c),F[2]=(T-j)*R,H[2]=(P-j)*R;const se=F;return Be(se,F,H),ke(se,se),Dr(x,Q,se)}function u7(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=ts(H[1]/F),se=Vt(H[0]/F),re=w([]),le=Kt(1,Q)*F,ue=Kt(1,0)*F*Hs(Q,P.zoom),ve=1/qpe(F);let Ce=ue*ve;if(R){const nt=c7(P.projection,P.zoom,P.width,P.height,1024);Ce=ve*P.projection.pixelSpaceConversion(P.center.lat,F,nt)}const Ee=_t(Q,se);oe(Ee,Ee,Ne([],ke([],Ee),le*Ce*H[2]));const Ke=function(nt){const ot=[nt[0],nt[1],nt[2]];let lt=[0,1,0];const It=Be([],lt,ot);return Be(lt,ot,It),De(lt)===0&&(lt=[0,1,0],Be(It,ot,lt)),ke(It,It),ke(lt,lt),ke(ot,ot),[It[0],It[1],It[2],0,lt[0],lt[1],lt[2],0,ot[0],ot[1],ot[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 ze=C([],P.globeMatrix,Ke);return C(ze,ze,re),C(ze,ze,T),ze}(x,c,h);if(g>0){const T=function(P,R){const F=R.worldSize,H=Kt(1,0)*F*Hs(R.center.lat,R.zoom)/qpe(F),Q=Kt(1,R.center.lat)*F,se=w([]);O(se,se,Kr(R.center.lng)),L(se,se,Kr(R.center.lat)),A(se,se,[0,0,mt]),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,ve,Ce)=>{const Ee=ce(ue),Ke=ce(ve),ze=nv(ue,ve,Ce);return Ne(ze,ze,1/ce(ze)*nn(Ee,Ke,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 yfe(x,c,h,g){const j=Ja.projectAabbCorners(g,h);let T=Number.MAX_VALUE;for(let R=0;R0||Ce===0&&ue[0]*ve[0]+ue[1]*ve[1]>=0&&ue[0]*ue[0]+ue[1]*ue[1]>ve[0]*ve[0]+ve[1]*ve[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 h7(x,c,h,g,j,T,P,R,F,H=!1){const Q=h.zoom,se=h.project(g),re=Hs(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,ve=1;const Ce=h.worldSize;if(H){if(h.projection.name==="mercator"){let nt=0;h.elevation&&(nt=h.elevation.getAtPointOrZero(new _r(se.x/Ce,se.y/Ce),0));const ot=pt([],[se.x,se.y,nt,1],h.projMatrix)[3]/h.cameraToCenterDistance;ue=ot,ve=ot*Hs(h.center.lat,Q)}else if(h.projection.name==="globe"){const nt=u7(x,h),ot=[0,0,0,1];pt(ot,ot,C([],h.projMatrix,nt));const lt=ot[3]/h.cameraToCenterDistance,It=av(Q),jt=h.projection.pixelsPerMeter(g.lat,Ce)*Hs(g.lat,Q),Pt=h.projection.pixelsPerMeter(h.center.lat,Ce)*Hs(h.center.lat,Q);ue=lt/nn(jt,Qs(h.center.lat),It),ve=lt*re/jt,ue*=Pt,ve*=Pt}}else ue=le;I(x,x,[ue,ue,ve]);const Ee=[...x],Ke=c.orientation,ze=[];if(D5e(ze,[Ke[0]+(j?j[0]:0),Ke[1]+(j?j[1]:0),Ke[2]+(j?j[2]:0)],T),C(x,Ee,ze),R&&h.elevation){let nt=0;const ot=[];if(F&&h.elevation){nt=function(It,jt,Pt,Ct,Mt){const ss=jt.elevation;if(!ss)return 0;const is=Ja.projectAabbCorners(Pt,Ct),ms=Kt(1,Mt.lat)*jt.worldSize,bs=function(Ks,cr){const br=[0,0,1],Br=[{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 Tr of Br){const Tn=Ks[Tr.corners[0]],Na=Ks[Tr.corners[1]],An=Ks[Tr.corners[2]],Ca=[Na[0]-Tn[0],Na[1]-Tn[1],cr*(Na[2]-Tn[2])],Vn=Be(Ca,Ca,[An[0]-Tn[0],An[1]-Tn[1],cr*(An[2]-Tn[2])]);ke(Vn,Vn),Tr.dotProductWithUp=$e(Vn,br)}return Br.sort((Tr,Tn)=>Tr.dotProductWithUp-Tn.dotProductWithUp),Br[0].corners}(is,ms),ps=is[bs[0]],Is=is[bs[1]],es=is[bs[2]],vs=is[bs[3]],Ss=ss.getAtPointOrZero(new _r(ps[0]/jt.worldSize,ps[1]/jt.worldSize),0),Ls=ss.getAtPointOrZero(new _r(Is[0]/jt.worldSize,Is[1]/jt.worldSize),0),Ws=ss.getAtPointOrZero(new _r(es[0]/jt.worldSize,es[1]/jt.worldSize),0),mr=ss.getAtPointOrZero(new _r(vs[0]/jt.worldSize,vs[1]/jt.worldSize),0),er=(Ss+mr)/2,Js=(Ls+Ws)/2;return er>Js?Ls=c.gl.NEAREST_MIPMAP_NEAREST}),x.uploaded=!0,x.image=null)}function lut(x,c,h){x.indexBuffer=c.createIndexBuffer(x.indexArray,!1,!0),x.vertexBuffer=c.createVertexBuffer(x.vertexArray,tut.members,!1,!0),x.normalArray&&(x.normalBuffer=c.createVertexBuffer(x.normalArray,aut.members,!1,!0)),x.texcoordArray&&(x.texcoordBuffer=c.createVertexBuffer(x.texcoordArray,nut.members,!1,!0)),x.colorArray&&(x.colorBuffer=c.createVertexBuffer(x.colorArray,(x.colorArray.bytesPerElement===12?sut:rut).members,!1,!0)),x.featureArray&&(x.pbrBuffer=c.createVertexBuffer(x.featureArray,out.members,!0)),x.segments=wi.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 vfe(x,c,h){if(x.meshes)for(const g of x.meshes)lut(g,c,h);if(x.children)for(const g of x.children)vfe(g,c,h)}function m7(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)m7(c)}function cut(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 _fe(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&&cut(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)_fe(c)}function M2(x,c){const h=x.json.bufferViews[c.bufferView],g=o7[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 bfe(x,c,h,g){const j=o7[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;Ce0){T.texcoordArray=new ev;const re=c.json.accessors[j.TEXCOORD_0];T.texcoordArray.resize(re.count);const le=M2(c,re);bfe(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:ve="OPAQUE",alphaCutoff:Ce=.5,normalTexture:Ee,occlusionTexture:Ke,emissiveTexture:ze,doubleSided:nt,name:ot}=re,{baseColorFactor:lt=[1,1,1,1],metallicFactor:It=1,roughnessFactor:jt=1,baseColorTexture:Pt,metallicRoughnessTexture:Ct}=re.pbrMetallicRoughness||{},Mt=Ke?le[Ke.index]:void 0;if(Ke&&Ke.extensions&&Ke.extensions.KHR_texture_transform&&Mt){const ss=Ke.extensions.KHR_texture_transform;Mt.offsetScale=[ss.offset[0],ss.offset[1],ss.scale[0],ss.scale[1]]}return{name:ot,pbrMetallicRoughness:{baseColorFactor:new Aa(...lt),metallicFactor:It,roughnessFactor:jt,baseColorTexture:Pt?le[Pt.index]:void 0,metallicRoughnessTexture:Ct?le[Ct.index]:void 0},doubleSided:nt,emissiveFactor:new Aa(...ue),alphaMode:ve,alphaCutoff:Ce,normalTexture:Ee?le[Ee.index]:void 0,occlusionTexture:Mt,emissionTexture:ze?le[ze.index]:void 0,defined:re.defined===void 0}}(se!==void 0?c.json.materials[se]:{defined:!1},h),T}function O5e(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,ve){var Ce=le[0],Ee=le[1],Ke=le[2],ze=le[3],nt=Ce+Ce,ot=Ee+Ee,lt=Ke+Ke,It=Ce*nt,jt=Ce*ot,Pt=Ce*lt,Ct=Ee*ot,Mt=Ee*lt,ss=Ke*lt,is=ze*nt,ms=ze*ot,bs=ze*lt,ps=ve[0],Is=ve[1],es=ve[2];return re[0]=(1-(Ct+ss))*ps,re[1]=(jt+bs)*ps,re[2]=(Pt-ms)*ps,re[3]=0,re[4]=(jt-bs)*Is,re[5]=(1-(It+ss))*Is,re[6]=(Mt+is)*Is,re[7]=0,re[8]=(Pt+ms)*es,re[9]=(Mt-is)*es,re[10]=(1-(It+Ct))*es,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:ve}=le.aabb;re[0]+=ue[0]+ve[0],re[1]+=ue[1]+ve[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(Ke){const ze=atob(Ke),nt=new Uint8Array(ze.length);for(let ot=0;ot1&&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 mut(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 wfe(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(dut(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(O5e(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,ve)=>ue-ve);for(let ue=le.length-1;ue>=0;ue--)F.splice(le[ue],1)}}(R,P,x.json.nodes),R}function put(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 F5e(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=Ue([],P.pos,F,Q/2),re=Ue([],P.pos,F,-Q/2),le=[se[0],se[1],se[2]+P.height],ue=[re[0],re[1],re[2]+P.height],ve=Ue([],P.normal,F,H);Ne(ve,ve,R);const Ce=Ue([],P.normal,F,-H);Ne(Ce,Ce,R),oe(ve,se,ve),oe(Ce,re,Ce),se[2]+=.1,re[2]+=.1,g.emplaceBack(ve[0],ve[1],ve[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(ve[0],ve[1],ve[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 fut(x,c){const h={};h.indexArray=new Ao,h.vertexArray=new Vm,h.colorArray=new Yx,F5e(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 Ja([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),h}const z5e=la([{name:"a_pos_3f",components:3,type:"Float32"}]),xut=la([{name:"a_normal_3",components:3,type:"Int16"}]),gut=la([{name:"a_centroid_3",components:3,type:"Int16"}]),B5e=la([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),yut=la([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),vut=la([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),_ut=la([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),but=la([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),wut=la([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Int16"}]),$5e=mn.types,p7=32767;function jut(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 Nut(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 jfe{constructor(){this.layoutVertexArray=new Vm,this.layoutAttenuationArray=new Yx,this.layoutColorArray=new Hm,this.indexArray=new Ao,this.indexArrayForConflation=new Ao,this.segmentsBucket=new wi}}class Nfe{constructor(c){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new wi,this.entranceBloom=new jfe;const h=66560;this.layoutVertexArray=new Vm,this.layoutVertexArray.reserve(h),this.layoutNormalArray=new Df,this.layoutNormalArray.reserve(h),this.layoutCentroidArray=new Df,this.layoutCentroidArray.reserve(h),this.layoutColorArray=new Hm,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 wi,this.entranceBloom=new jfe,c&&(this.layoutFacadePaintArray=new Hm,this.layoutFacadeDataArray=new e_,this.layoutFacadeVerticalRangeArray=new Hm)}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 q5e{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 ns(1/0,1/0),this.footprintsMax=new ns(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new Nfe(!1),this.buildingWithFacade=new Nfe(!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 dfe(c),this.groundEffect.groundRadiusArray=new Jh,this.hasAppearances=null}updateFootprints(c,h){const g=new XF([],[],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(i7!=null||y5e!=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)),ve=Math.ceil((ue-le)/65536);try{return R.grow(ve),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 Kdt({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,i7=h,i7)).catch(h=>{Rr("Could not load building-gen"),B3=null,y5e=h instanceof Error?h:new Error("Unknown error")}),B3}()}populate(c,h,g,j){const T=Zdt();if(!T)return;const P=Cs(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($5e[Ee.type]!=="LineString"){R.set(Ee.id,Ee.properties.source_id);continue}const Ke=this.layers[0]._featureFilter.needGeometry;if(Ke&&!this.layers[0]._featureFilter.filter(new Ka(this.zoom),Ee,g))continue;const ze=Un(Ee,Ke);if(!Ke&&!this.layers[0]._featureFilter.filter(new Ka(this.zoom),ze,g))continue;const nt=Ke?ze.geometry:qr(Ee,g,j),ot=[];for(const Pt of nt)for(const Ct of Pt)ot.push(Ct.x),ot.push(Ct.y);const lt={coordinates:ot,crossPerc:Ee.properties.cross_perc,distanceToRoad:Ee.properties.distance_to_road,entrances:Ee.properties.entrances,sourceId:0},It=Ee.properties.source_id;let jt=F.get(It);jt||(jt=[],F.set(It,jt)),jt.push(lt),++H}this.maxHeight=0;const Q=new Array,se=new Set,re=Ee=>{Ee!=null&&se.add(Ee)},le=(Ee,Ke)=>{Ee!=null&&Q.push({buildingId:Ee,footprintIndex:Ke})},ue=64*(c.length-H),ve=ue/2;this.buildingWithFacade.reserve(ue,ve,!0),this.buildingWithoutFacade.reserve(2*ue,2*ve,!1),this.footprintsIndices.reserve(16*(c.length-H)),this.footprintsVertices.reserve(8*(c.length-H));for(const{feature:Ee,id:Ke,index:ze,sourceLayerIndex:nt}of c){if($5e[Ee.type]==="LineString")continue;const ot=this.layers[0]._featureFilter.needGeometry;if(ot&&!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 It=Un(Ee,ot);if(!ot&&!this.layers[0]._featureFilter.filter(new Ka(this.zoom),It,g))continue;const jt=ot?It.geometry:qr(Ee,g,j),Pt=a6(jt,500);let Ct=!1;for(const ea of Pt)if(ea.length!==1){Ct=!0;break}if(Ct){re(lt);continue}if(!jut(jt,163)){re(lt);continue}const Mt=this.layers[0],ss=Nut(Mt.layout.get("building-roof-shape").evaluate(Ee,{},g)),is=Mt.layout.get("building-base").evaluate(Ee,{},g),ms=Mt.layout.get("building-height").evaluate(Ee,{},g),bs=Mt.layout.get("building-flood-light-ground-radius").evaluate(Ee,{},g),ps=Mt.paint.get("building-ambient-occlusion-intensity"),Is=bs/this.tileToMeter;Ee.properties["building-part"]="roof";const es=Mt.paint.get("building-color").evaluate(Ee,{},this.canonical).toPremultipliedRenderColor(this.lut),vs=Mt.paint.get("building-emissive-strength").evaluate(Ee,{},this.canonical);Ee.properties["building-part"]="wall";const Ss=Mt.paint.get("building-color").evaluate(Ee,{},this.canonical).toPremultipliedRenderColor(this.lut),Ls=Mt.paint.get("building-emissive-strength").evaluate(Ee,{},this.canonical);Ee.properties["building-part"]="window";const Ws=Mt.paint.get("building-color").evaluate(Ee,{},this.canonical).toPremultipliedRenderColor(this.lut),mr=Mt.paint.get("building-emissive-strength").evaluate(Ee,{},this.canonical);Ee.properties["building-part"]="door";const er=Mt.paint.get("building-color").evaluate(Ee,{},this.canonical).toPremultipliedRenderColor(this.lut),Js=Mt.paint.get("building-emissive-strength").evaluate(Ee,{},this.canonical);let Ks=Mt.layout.get("building-flood-light-wall-radius").evaluate(Ee,{},g);Ks=Oe(Ks,0,2048);const cr=Ks/2048*p7,br=R.get(Ke),Br=F.get(br)||[],Tr=Br.length!==0&&Mt.layout.get("building-facade").evaluate(Ee,{},g);T.setFacadeOptions(4,!0),T.setFauxFacadeOptions(Tr,!1,1);let Tn=0,Na=0,An=0,Ca=0,Vn=0,mo=0,Za=0,Da=0,ki=0,oo=0,cc=0;if(Tr){let ea=Math.round(Mt.layout.get("building-facade-floors").evaluate(Ee,{},g));if(is===0){ea=Math.max(1,ea-(Br.length>0?1:0));let Io=4;if(ms>100){const Ul=[10,13,15];Io=Ul[Ee.id?Ee.id%Ul.length:0]}else ms<=10&&(Io=3);T.setFacadeOptions(Io,!0),Vn=(ms<15?1.3:1.61803)*Io/P}else Vn=is/P;mo=ms/P,Vn=Math.min(Vn,mo),An=Mt.layout.get("building-facade-unit-width").evaluate(Ee,{},g)/P,Ca=(mo-Vn)/ea,T.setFauxFacadeOptions(!0,!0,An);const Ac=Mt.layout.get("building-facade-window").evaluate(Ee,{},g);Tn=Ac[0],Na=Ac[1],Za=Math.floor(65535*Math.min(1,Vn/sr)),Da=Math.floor(65535*Math.min(1,mo/sr)),ki=Math.floor(255*Tn)<<8|Math.floor(255*Na),oo=Math.floor(65535*Math.min(1,An/sr)),cc=Math.floor(65535*Math.min(1,Ca/sr))}const lo=Array(Pt.length),Eo={x:1/0,y:1/0},rl={x:-1/0,y:-1/0},Po={x:0,y:0};let dd=0;for(let ea=0;ea0){const Io=[],Ul=Array(Ac.length+1);Ul[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:U7,indicesLength:pxe,bloomIndicesOffset:ud,bloomIndicesLength:po,groundEffectVertexOffset:D2,groundEffectVertexLength:t5,hasFauxFacade:Tr,height:J3,promoteId:Ke,feature:It,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,ze,{},h.availableImages,g,h.brightness),this.groundEffect.addPaintPropertiesData(Ee,ze,{},h.availableImages,g,h.brightness),h.featureIndex.insert(Ee,jt,ze,nt,this.index,Xd)}Q.forEach(({buildingId:Ee,footprintIndex:Ke})=>{se.has(Ee)&&(this.footprints[Ke].hiddenFlags|=4)});const Ce=new Set;this.buildingIds.forEach((Ee,Ke,ze)=>{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,z5e.members),g.layoutNormalBuffer=c.createVertexBuffer(g.layoutNormalArray,xut.members),g.layoutCentroidBuffer=c.createVertexBuffer(g.layoutCentroidArray,gut.members),g.layoutFloodLightDataBuffer=c.createVertexBuffer(g.layoutFloodLightDataArray,wut.members),g.layoutFacadeDataArray&&g.layoutFacadeDataArray.length&&(g.layoutFacadeDataBuffer=c.createVertexBuffer(g.layoutFacadeDataArray,vut.members)),g.layoutFacadeVerticalRangeArray&&g.layoutFacadeVerticalRangeArray.length&&(g.layoutFacadeVerticalRangeBuffer=c.createVertexBuffer(g.layoutFacadeVerticalRangeArray,_ut.members)),g.entranceBloom.layoutVertexArray.length&&(g.entranceBloom.layoutVertexBuffer=c.createVertexBuffer(g.entranceBloom.layoutVertexArray,z5e.members),g.entranceBloom.layoutAttenuationBuffer=c.createVertexBuffer(g.entranceBloom.layoutAttenuationArray,but.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,B5e.members,!0),g.layoutFacadePaintArray&&(g.layoutFacadePaintBuffer?g.layoutFacadePaintBuffer.updateData(g.layoutFacadePaintArray):g.layoutFacadePaintBuffer=c.createVertexBuffer(g.layoutFacadePaintArray,yut.members,!0)),g.entranceBloom.layoutColorBuffer?g.entranceBloom.layoutColorBuffer.updateData(g.entranceBloom.layoutColorArray):g.entranceBloom.layoutColorBuffer=c.createVertexBuffer(g.entranceBloom.layoutColorArray,B5e.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),ve=j.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const Ee of j.parts){let Ke,ze=R;Ee.part===1?(ze=R,Ke=F):Ee.part===0?(ze=H,Ke=Q):Ee.part===2?(ze=se,Ke=re):Ee.part===3&&(ze=le,Ke=ue),Ke=Oe(Ke,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||kut(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 kut(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 ve=j-Math.abs(ue);le=Math.sqrt(re*re+ve*ve)}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 Rr("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 Vm,this.patternVertexArray=new Vm,this.indexArray=new Ao,this.programConfigurations=new Ae(c.layers,{zoom:c.zoom,lut:c.lut}),this.segments=new wi,this.maxLineLength=0,this.zOffsetVertexArray=new Vm,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=Wpe("line",this.layers,this.pixelRatio,h);const T=this.layers[0].layout.get("line-sort-key");this.tileToMeter=Cs(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"&&Rr(`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:ve}of c){const Ce=this.layers[0]._featureFilter.needGeometry,Ee=Un(re,Ce);if(!this.layers[0]._featureFilter.filter(new Ka(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),Ee,g))continue;const Ke=T?T.evaluate(Ee,{},g):void 0,ze={id:le,properties:re.properties,type:re.type,sourceLayerIndex:ve,index:ue,geometry:Ce?Ee.geometry:qr(re,g,j),patterns:{},sortKey:Ke};F.push(ze)}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:ve}=re;if(se&&this.addFeatureDashes(re,H),this.hasPattern){const Ce=Kpe("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,ve,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,Put)),this.patternVertexArray.length!==0&&(this.patternVertexBuffer=c.createVertexBuffer(this.patternVertexArray,Lut)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=c.createVertexBuffer(this.zOffsetVertexArray,Mut.members,!0)),!this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexArray.length>0&&(this.elevationGroundScaleVertexBuffer=c.createVertexBuffer(this.elevationGroundScaleVertexArray,Tut.members,!0)),this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,Aut),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 ve=this.layers[0].paint.get("line-width").value;if(ve.kind!=="constant"&&ve.isLineProgressConstant===!1&&(this.variableWidthValue=ve),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,Ke]=this.clipRuntimeLinesToTile(h,1);for(let ze=0;ze0?ot.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 a7(c,-h,-h,sr+h,sr+h)}clipRuntimeLinesToTile(c,h){const g=[];return[a7(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(ve,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/Cs(g);for(const P of c)Wdt(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 Pt={min:this.lineClips.start,max:this.lineClips.end},Ct=1;if(F){const is=this.lineClips.end-this.lineClips.start;Pt=function(ms,bs,ps){return{min:Xi(ms.min,bs,ps),max:Xi(ms.max,bs,ps)}}(F.progress,{min:0,max:1},Pt),is>0&&(Ct=(Pt.max-Pt.min)/is)}const Mt=+h.properties.mapbox_clip_feature_len,ss=+h.properties.mapbox_clip_seg_len;if(Number.isNaN(Mt)||Number.isNaN(ss)){for(let ms=0;ms=2&&c[ue-1].equals(c[ue-2]);)ue--;let ve=0;for(;ve0,vs=this.overscaling<=16?122880/(512*this.overscaling):0;if(Ct&&Mt==="round"){if(bsP&&(Mt="bevel"),Mt==="bevel"&&(bs>2&&(Mt="flipbevel"),bs2*vs){const Ws=Ee.sub(Ee.sub(Ke)._mult(vs/Ss)._round());this.updateDistance(Ke,Ws),this.addCurrentVertex(Ws,nt,0,0,Ce,jt),Ke=Ws}this.updateDistance(Ke,Ee),is._mult(bs),this.addCurrentVertex(Ee,is,0,0,Ce,jt);const Ls=Ee.dist(ze);if(Ls>2*vs){const Ws=Ee.add(ze.sub(Ee)._mult(vs/Ls)._round());this.updateDistance(Ee,Ws),this.addCurrentVertex(Ws,ot,0,0,Ce,jt),Ee=Ws}}else is._mult(bs),this.addCurrentVertex(Ee,is,0,0,Ce,jt);else if(Mt==="flipbevel"){if(bs>100)is=ot.mult(-1);else{const Ss=bs*nt.add(ot).mag()/nt.sub(ot).mag();is._perp()._mult(Ss*(es?-1:1))}this.addCurrentVertex(Ee,is,0,0,Ce,jt),this.addCurrentVertex(Ee,is.mult(-1),0,0,Ce,jt)}else if(Mt==="bevel"||Mt==="fakeround"){const Ss=Ee.dist(Ke);let Ls=1;if(this.elevationType==="offset"&&Mt==="bevel"&&this.currentLineJoinType!=="round"&&!this.patternJoinNone&&jt!=null&&Ke&&ze){const cr=4*vs;Ss1){this.lineSoFar=c.w;const ve=(h.x-c.x)/se,Ce=(h.y-c.y)/se,Ee=(h.z-c.z)/se,Ke=(h.w-c.w)/se,ze=h.x-c.x,nt=h.y-c.y,ot=Math.sqrt(ze*ze+nt*nt);if(ot===0)return;const lt=-nt/ot,It=ze/ot,jt=lt,Pt=It,Ct=-lt,Mt=-It;for(let ss=1;ss=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 kfe(x,c,h){return x.xh||x.yh}let G5e,W5e;function K5e(x,c,h){return c*(sr/(x.tileSize*Math.pow(2,h-x.tileID.overscaledZ)))}fr(f7,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const Z5e=(x,c,h)=>(1-h)*x+h*c;function Y5e(x,c){return 1/K5e(x,1,c.tileZoom)}function X5e(x,c,h,g){return x.translatePosMatrix(g||c.tileID.projMatrix,c,h.paint.get("line-translate"),h.paint.get("line-translate-anchor"))}const Q5e=x=>{const c=[];J5e(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 J5e(x){const c=x.paint.get("line-dasharray").value;return c.kind!=="constant"||c.value}let Sfe;const eMe=()=>Sfe||(Sfe={layout:G5e||(G5e=new Qi({"line-cap":new Vs(Gt.layout_line["line-cap"]),"line-join":new Vs(Gt.layout_line["line-join"]),"line-miter-limit":new Ys(Gt.layout_line["line-miter-limit"]),"line-round-limit":new Ys(Gt.layout_line["line-round-limit"]),"line-sort-key":new Vs(Gt.layout_line["line-sort-key"]),"line-z-offset":new Vs(Gt.layout_line["line-z-offset"]),"line-elevation-reference":new Ys(Gt.layout_line["line-elevation-reference"]),"line-cross-slope":new Ys(Gt.layout_line["line-cross-slope"]),visibility:new Ys(Gt.layout_line.visibility),"line-width-unit":new Ys(Gt.layout_line["line-width-unit"]),"line-elevation-ground-scale":new Vs(Gt.layout_line["line-elevation-ground-scale"])})),paint:W5e||(W5e=new Qi({"line-opacity":new Vs(Gt.paint_line["line-opacity"]),"line-color":new Vs(Gt.paint_line["line-color"]),"line-translate":new Ys(Gt.paint_line["line-translate"]),"line-translate-anchor":new Ys(Gt.paint_line["line-translate-anchor"]),"line-width":new Vs(Gt.paint_line["line-width"]),"line-gap-width":new Vs(Gt.paint_line["line-gap-width"]),"line-offset":new Vs(Gt.paint_line["line-offset"]),"line-blur":new Vs(Gt.paint_line["line-blur"]),"line-dasharray":new Vs(Gt.paint_line["line-dasharray"]),"line-pattern":new Vs(Gt.paint_line["line-pattern"]),"line-pattern-cross-fade":new Ys(Gt.paint_line["line-pattern-cross-fade"]),"line-gradient":new Q1(Gt.paint_line["line-gradient"]),"line-trim-offset":new Ys(Gt.paint_line["line-trim-offset"]),"line-trim-fade-range":new Ys(Gt.paint_line["line-trim-fade-range"]),"line-trim-color":new Ys(Gt.paint_line["line-trim-color"]),"line-emissive-strength":new Vs(Gt.paint_line["line-emissive-strength"]),"line-border-width":new Vs(Gt.paint_line["line-border-width"]),"line-border-color":new Vs(Gt.paint_line["line-border-color"]),"line-occlusion-opacity":new Ys(Gt.paint_line["line-occlusion-opacity"]),"line-blend-mode":new Ys(Gt.paint_line["line-blend-mode"]),"line-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"})}))},Sfe);class Fut extends Vs{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 tMe(x,c){return c>0?c+2*x:x}const zut=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),But=la([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),$ut=la([{name:"a_projected_pos",components:4,type:"Float32"}],4);la([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const qut=la([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Uut=la([{name:"a_feature_index",components:1,type:"Float32"}],4),Vut=la([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),Hut=la([{name:"a_texb",components:2,type:"Uint16"}]),Gut=la([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),Wut=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 sMe=la([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Kut=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 Cfe=class zie{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(zie.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,zie.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)}}};Cfe.HEADER_DWORDS=12,Cfe.HEADER_BYTES=48;let Mfe=Cfe;function Tfe(x,c,h,g){return[P3(255*x,255*c),P3(255*h,255*g)]}function rMe(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")}fr(Mfe,"SymbolPropertiesUBO",{omit:["headerBuffer","propertiesBuffer","blockIndicesBuffer"]});class Afe{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),ve=le||ue,Ce=!(!re||!re.value||re.value.kind!=="composite"),Ee=this.layer._transitionablePaint._values[H],Ke=!ve&&(Ee&&Ee.value&&Ee.value.expression&&Ee.value.expression.kind)==="camera";ve?(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){Rr(`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 Mfe(R,re,this.uboSizeDwords),this.ubos[re].writeHeader(H)),this.ubos[re].writeDataDrivenBlock(Q,le,H);const ve={batchIndex:re,localFeatureIndex:le,vtFeatureIndex:h,featureId:F};return this.allFeatures.push(ve),F!=null&&(this.featureVertexRangesFromId.has(F)||this.featureVertexRangesFromId.set(F,[]),this.featureVertexRangesFromId.get(F).push(ve)),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:[]},ve=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(re.vtFeatureIndex):void 0,Ce=this.evaluateAllProperties(ue,se,j,T,R,void 0,ve);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 ve=le.useThemeName?T.get(le.useThemeName):void 0,Ce=rMe(ve&&typeof ve!="string"?ve.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 Yut(x){return x==="︶"||x==="﹈"||x==="︸"||x==="﹄"||x==="﹂"||x==="︾"||x==="︼"||x==="︺"||x==="︘"||x==="﹀"||x==="︐"||x==="︓"||x==="︔"||x==="`"||x===" ̄"||x==="︑"||x==="︒"}function Xut(x){return x==="︵"||x==="﹇"||x==="︷"||x==="﹃"||x==="﹁"||x==="︽"||x==="︻"||x==="︹"||x==="︗"||x==="︿"}const Efe=4294967296,nMe=1/Efe,aMe=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");let x7=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)*Efe;return this.pos+=8,x}readSFixed64(){const x=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Efe;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&&aMe?aMe.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&&iMe(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&&iMe(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,Qut,c)}writePackedSVarint(x,c){c.length&&this.writeMessage(x,Jut,c)}writePackedBoolean(x,c){c.length&&this.writeMessage(x,sht,c)}writePackedFloat(x,c){c.length&&this.writeMessage(x,eht,c)}writePackedDouble(x,c){c.length&&this.writeMessage(x,tht,c)}writePackedFixed32(x,c){c.length&&this.writeMessage(x,rht,c)}writePackedSFixed32(x,c){c.length&&this.writeMessage(x,nht,c)}writePackedFixed64(x,c){c.length&&this.writeMessage(x,aht,c)}writePackedSFixed64(x,c){c.length&&this.writeMessage(x,iht,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 iMe(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 Qut(x,c){for(let h=0;h=0&&g>=c&&g7[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 Pfe(x,c,h,g,j,T,P,R,F,H,Q,se,re,le,ue,ve=1,Ce=1){const Ee=U3.fromFeature(x,j,ve,Ce);se===am.vertical&&Ee.verticalizePunctuation(re);let Ke=[];const ze=function(jt,Pt,Ct,Mt,ss,is,ms=1){if(!jt)return[];const bs=[],ps=function(vs,Ss,Ls,Ws,mr,er,Js=1){let Ks=0;for(let cr=0;cr=0;let es=0;for(let vs=0;vs0&&Xd>Vn&&(Vn=Xd)}else{const Mc=Ct[oo.fontStack];if(!Mc)continue;Mc[lo]&&(Po=Mc[lo]);const Cu=Pt[oo.fontStack];if(!Cu)continue;const ud=Cu.glyphs[lo];if(!ud)continue;if(rl=ud.metrics,dc=lo!==8203?lc:0,Js){const po=Cu.ascender!==void 0?Math.abs(Cu.ascender):0,Xd=Cu.descender!==void 0?Math.abs(Cu.descender):0,Tc=(po+Xd)*Eo;mo-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 xMe(x){let c=0;for(let h=0;hH){const ue=(H-F)/le,ve=nn(se.x,re.x,ue),Ce=nn(se.y,re.y,ue),Ee=new cv(ve,Ce,0,re.angleTo(se),Q);return!P||fMe(x,Ee,R,P,c)?Ee:void 0}F+=le}}function mht(x,c,h,g,j,T,P,R,F){const H=gMe(g,T,P),Q=yMe(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&&ot=0&&re+H<=Q){const lt=new cv(nt,ot,0,Ke,ue);g&&!fMe(x,lt,T,g,j)||le.push(lt)}}se+=Ee}return R||le.length||P||(le=vMe(x,se/2,h,g,j,T,P,!0,F)),le}function _Me(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 Ofe(x){let c=0;for(let h=0;h0,bMe(c,g,this.iconDescriptors,T),bMe(h,g,this.patternDescriptors,T),this.iconDescriptors.sort(v7),this.patternDescriptors.sort(v7);let P=0;const R=j?j.data:"";R&&(P=Jx(P,Ofe(R))),P=Jx(P,1);for(const F of this.iconDescriptors)P=Jx(P,Ofe(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,Ofe(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,v7)&&this.isSubsetArray(this.patternDescriptors,c.patternDescriptors,v7)}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 wMe{constructor(c){this.sourceAtlasHash=c}}class jMe{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?Bfe(c,H):c,se=F?Bfe(h,H):h;this.addImages(Q,T,1,R),this.addImages(se,P,2,R);const{w:re,h:le}=_Me(R),ue=new Pd({width:re||1,height:le||1});for(const[ve,Ce]of Q.entries()){const Ee=T.get(ve).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[ve,Ce]of se.entries()){const Ee=P.get(ve),Ke=Ee.paddedRect;let ze=Ee.padding;const nt=Ke.x+ze,ot=Ke.y+ze,lt=Ce.data.width,It=Ce.data.height;ze=ze>1?ze-1:ze,Pd.copy(Ce.data,ue,{x:0,y:0},{x:nt,y:ot},Ce.data,g),Pd.copy(Ce.data,ue,{x:0,y:It-ze},{x:nt,y:ot-ze},{width:lt,height:ze},g),Pd.copy(Ce.data,ue,{x:0,y:0},{x:nt,y:ot+It},{width:lt,height:ze},g),Pd.copy(Ce.data,ue,{x:lt-ze,y:0},{x:nt-ze,y:ot},{width:ze,height:It},g),Pd.copy(Ce.data,ue,{x:0,y:0},{x:nt+lt,y:ot},{width:ze,height:It},g),Pd.copy(Ce.data,ue,{x:lt-ze,y:It-ze},{x:nt-ze,y:ot-ze},{width:ze,height:ze},g),Pd.copy(Ce.data,ue,{x:0,y:It-ze},{x:nt+lt,y:ot-ze},{width:ze,height:ze},g),Pd.copy(Ce.data,ue,{x:0,y:0},{x:nt+lt,y:ot+It},{width:ze,height:ze},g),Pd.copy(Ce.data,ue,{x:lt-ze,y:0},{x:nt-ze,y:ot+It},{width:ze,height:ze},g)}this.lut=g,this.image=ue,this.iconPositions=T,this.patternPositions=P,F&&(this.contentDescriptor=new Ffe(Q,se,j,g,H))}addImages(c,h,g,j){for(const[T,P]of c.entries()){const{bin:R,imagePosition:F,imageVariant:H}=zfe(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=qm.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=qm.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})}}fr(_6,"ImagePosition"),fr(jMe,"ImageAtlas",{omit:["lut"]}),fr(wMe,"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 x7(re).readFields(oht,{})}(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 NMe(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 Rr("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!==$fe.none&&(this.localGlyphMode===$fe.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 _7.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:ve}=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:ve/2,localGlyph:!0}}}}function SMe(x,c){return x+c[1]-c[0]}function qfe(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(SMe,0),ve=le.reduce(SMe,0),Ce=F-ue,Ee=H-ve;let Ke=0,ze=ue,nt=0,ot=ve,lt=0,It=Ce,jt=0,Pt=Ee;if(P.content&&g){const Mt=P.content;Ke=b7(re,0,Mt[0]),nt=b7(le,0,Mt[1]),ze=b7(re,Mt[0],Mt[2]),ot=b7(le,Mt[1],Mt[3]),lt=Mt[0]-Ke,jt=Mt[1]-nt,It=Mt[2]-Mt[0]-ze,Pt=Mt[3]-Mt[1]-ot}const Ct=(Mt,ss,is,ms)=>{const bs=w7(Mt.stretch-Ke,ze,Q,x.left*j),ps=j7(Mt.fixed-lt,It,Mt.stretch,ue),Is=w7(ss.stretch-nt,ot,se,x.top*j),es=j7(ss.fixed-jt,Pt,ss.stretch,ve),vs=w7(is.stretch-Ke,ze,Q,x.left*j),Ss=j7(is.fixed-lt,It,is.stretch,ue),Ls=w7(ms.stretch-nt,ot,se,x.top*j),Ws=j7(ms.fixed-jt,Pt,ms.stretch,ve),mr=new ns(bs,Is),er=new ns(vs,Is),Js=new ns(vs,Ls),Ks=new ns(bs,Ls),cr=new ns(ps/R,es/R),br=new ns(Ss/R,Ws/R),Br=c*Math.PI/180;if(Br){const Vn=Math.sin(Br),mo=Math.cos(Br),Za=[mo,-Vn,Vn,mo];mr._matMult(Za),er._matMult(Za),Ks._matMult(Za),Js._matMult(Za)}const Tr=Mt.stretch+Mt.fixed,Tn=is.stretch+is.fixed,Na=ss.stretch+ss.fixed,An=ms.stretch+ms.fixed,Ca=x.imageSecondary;return{tl:mr,tr:er,bl:Ks,br:Js,texPrimary:{x:P.paddedRect.x+1+Tr,y:P.paddedRect.y+1+Na,w:Tn-Tr,h:An-Na},texSecondary:Ca?{x:Ca.paddedRect.x+1+Tr,y:Ca.paddedRect.y+1+Na,w:Tn-Tr,h:An-Na}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:cr,pixelOffsetBR:br,minFontScaleX:It/R/Q,minFontScaleY:Pt/R/se,isSDF:h}};if(P.stretchX||P.stretchY){const Mt=CMe(re,Ce,ue),ss=CMe(le,Ee,ve);for(let is=0;is0?[Ke,-ze]:nt<0?[-Ke,ze]:Ke===0?[ze,Ke]:[ze,-Ke]}(h);let le=Math.abs(c.top-c.bottom);for(const Ee of c.positionedLines)le-=Ee.lineOffset;const ue=c.positionedLines.length,ve=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([],ght);if(F===0)return new ns(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 ght(x,c){return c.max-x.max}_7.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:ve,gridInner:Ce,gridOuter:Ee}=this;this.lang&&(ue.lang=this.lang),ue.clearRect(ve,ve,R,F),ue.fillText(x,ve,ve+P);const Ke=ue.getImageData(ve,ve,R,F);Ee.fill(w6,0,se),Ce.fill(0,0,se);for(let ze=0;ze0?It*It:0,Ce[lt]=It<0?It*It:0}}NMe(Ee,0,0,H,Q,H,this.f,this.v,this.z),NMe(Ce,ve,ve,R,F,H,this.f,this.v,this.z);for(let ze=0;zeT.y!=ve.y>T.y&&T.x<(ve.x-ue.x)*(T.y-ue.y)/(ve.y-ue.y)+ue.x&&(R=!R),F=Math.min(F,Of(T,ue,ve))}}return(R?1:-1)*Math.sqrt(F)}(this.p,j),this.max=this.d+this.h*Math.SQRT2}}const yht=Object.keys,Ufe=Number.POSITIVE_INFINITY,vht=Math.sqrt(2);function l_(x,c,h,g,j,T){const P=Lfe(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=Kr(H),re=new ns(Q?Q[0]:0,Q?Q[1]:0),le=new ns(F.left,F.top),ue=new ns(F.right,F.top),ve=new ns(F.left,F.bottom),Ce=new ns(F.right,F.bottom);le._rotateAround(se,re),ue._rotateAround(se,re),ve._rotateAround(se,re),Ce._rotateAround(se,re),F.left=Math.min(le.x,ue.x,ve.x,Ce.x),F.right=Math.max(le.x,ue.x,ve.x,Ce.x),F.top=Math.min(le.y,ue.y,ve.y,Ce.y),F.bottom=Math.max(le.y,ue.y,ve.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 AMe(x,[c,h]){let g=0,j=0;if(h===Ufe){c<0&&(c=0);const T=c/vht;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 _ht(x,c,h,g,j,T,P,R,F,H,Q,se,re,le,ue){const ve=x.layers[0],Ce=ve.appearances;if(Ce.length===0)return{iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const Ee={iconBBox:null,iconVerticalBBox:null},Ke={textBBox:null,textVerticalBBox:null},{baseIconRotate:ze,baseTextRotate:nt,iconScaleFactor:ot}=function(It,jt,Pt){const Ct=It.get("icon-rotate").evaluate(jt,{},Pt),Mt=It.get("text-rotate").evaluate(jt,{},Pt),[ss,is]=It.get("icon-size-scale-range");return{baseIconRotate:Ct,baseTextRotate:Mt,iconScaleFactor:Oe(1,ss,is)}}(g,j,T);c&&(Ee.iconBBox=l_(c,Ee.iconBBox,ze),h)&&(Ee.iconVerticalBBox=l_(h,Ee.iconVerticalBBox,ze+90));const lt=k7(se.horizontal);lt&&(Ke.textBBox=l_(lt,Ke.textBBox,nt,1,le)),se.vertical&&(Ke.textVerticalBBox=l_(se.vertical,Ke.textVerticalBBox,nt+90,1,le));for(const It of Ce)It.hasIconLayoutProperties()&&bht(Ee,x,ve,It,j,T,R,ze,P,F,c,H,ot,Q,ue),It.hasTextLayoutProperties()&&wht(Ke,ve,It,j,T,le,nt,re,lt,se.vertical);return{iconBBox:Ee.iconBBox,iconVerticalBBox:Ee.iconVerticalBBox,textBBox:Ke.textBBox,textVerticalBBox:Ke.textVerticalBBox}}function bht(x,c,h,g,j,T,P,R,F,H,Q,se,re,le,ue){const{appearanceIconOffset:ve,appearanceIconRotate:Ce,appearanceIconSize:Ee}=EMe(g,h,j,T,P,R,F,H.iconScaleFactor);let Ke=null,ze=null,nt=null;g.hasLayoutProperty("icon-image")?nt=function(lt,It,jt,Pt,Ct,Mt,ss,is){let ms=null;const bs=It.getAppearanceValueAndResolveTokens(jt,"icon-image",Pt,Ct,is);if(bs){const ps=lt.getResolvedImageFromTokens(bs),Is=jt.hasLayoutProperty("icon-size")?jt.getUnevaluatedLayoutProperty("icon-size"):It._unevaluatedLayout._values["icon-size"],es=j6(ps,T2(lt.zoom,Is,lt.worldview,is),Is,Ct,lt.zoom,Pt,lt.pixelRatio,ss,lt.worldview,is);ms=Mt.get(es.iconPrimary.toString())}return ms}(c,h,g,j,T,se,re,ue):Q&&(nt=Q.imagePrimary),nt&&(Ke=y7(nt,null,ve,le),c.allowVerticalPlacement&&(ze=y7(nt,null,ve,le)));const ot=F>0?Ee/F:1;Ke&&(x.iconBBox=l_(Ke,x.iconBBox,Ce,ot!==1?ot:void 0)),ze&&(x.iconVerticalBBox=l_(ze,x.iconVerticalBBox,Ce+90,ot!==1?ot:void 0))}function EMe(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 wht(x,c,h,g,j,T,P,R,F,H){const{appearanceTextOffset:Q,appearanceTextRotate:se,appearanceTextSize:re}=PMe(h,c,g,j,T,P,R),le=re/R,ue=[(Q[0]-T[0])*le,(Q[1]-T[1])*le],ve=ue[0]!==0||ue[1]!==0;F&&(x.textBBox=l_(F,x.textBBox,se,le,Q,ve?ue:void 0)),H&&(x.textVerticalBBox=l_(H,x.textVerticalBBox,se+90,le,Q,ve?ue:void 0))}function PMe(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 N7(x,c,h,g,j,T,P,R,F){if(!c||!c.usvg)return;const H=pMe(g),Q=pMe(j),se=T!=="both"&&T!=="width"||!hMe(g)?1:Q.width/H.width,re=T!=="both"&&T!=="height"||!mMe(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}=zfe(le,c,1);F.set(le,ue)}function IMe(x,c,h,g,j,T,P,R,F,H){if(!x)return;const Q=function(se,re,le,ue,ve,Ce,Ee){if(se.kind==="camera")return se.maxSize;if(se.kind==="composite"){const Ke=re.possiblyEvaluate(new Ka(se.maxZoom,{worldview:Ce}),le,Ee).evaluate(ve,{},le,Ee),ze=re.possiblyEvaluate(new Ka(se.minZoom,{worldview:Ce}),le,Ee).evaluate(ve,{},le,Ee);return Math.max(Ke,ze)}return re.possiblyEvaluate(new Ka(ue,{worldview:Ce}),le,Ee).evaluate(ve,{},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:IMe(x.getPrimary(),c,h,g,j,T,P,R,F,H),iconSecondary:IMe(x.getSecondary(),c,h,g,j,T,P,R,F,H)}}function jht(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||Rr(`Mismatch in icon variant sizes: ${x.toString()} and ${c.toString()}`),g.usvg!==j.usvg&&Rr(`Mismatch in icon variant image types: ${x.id} and ${c.id}`))}function LMe(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 Nht(x,c){for(const h in x.horizontal)DMe(x.horizontal[h],c);DMe(x.vertical,c)}function DMe(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 Vfe(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 kht(x,c,h,g,j,T,P,R,F){const H=k7(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=Dfe(c,T.vertical,F,Q,R,P)),H&&(re=Dfe(c,H,F,Q,R,P))),{defaultShapedIcon:re,verticallyShapedIcon:se}}function RMe(x,c){return x*c/24}function Sht(x,c,h,g,j,T,P,R,F,H,Q,se,re,le,ue,ve,Ce,Ee,Ke,ze,nt,ot,lt,It){let jt=P.textMaxSize.evaluate(c,{},re);jt===void 0?jt=R*P.textScaleFactor:jt*=P.textScaleFactor;const Pt=x.layers[0].layout,Ct=RMe(R,P.textScaleFactor),Mt=k7(h.horizontal)||h.vertical,ss=x.hasAnyAppearanceLayoutProperty(["text-size","text-offset","text-rotate"]),is=x.getAppearanceFeatureData(c.index);(Ce!=="none"||ss)&&is&&(is.textShaping=Mt,is.iconTextFitPadding=Pt.get("icon-text-fit-padding").evaluate(c,{},re),is.fontScale=Ct,is.textScaleFactor=P.textScaleFactor);const ms=le.name==="globe",bs=x.tilePixelRatio*jt/24,ps=(Ws=x.overscaling,x.zoom>18&&Ws>2&&(Ws>>=1),Math.max(sr/(512*Ws),1)*Pt.get("symbol-spacing")),Is=Pt.get("text-padding")*x.tilePixelRatio,es=Pt.get("icon-padding")*x.tilePixelRatio,vs=Kr(Pt.get("text-max-angle")),Ss=Pt.get("icon-rotation-alignment")==="map"&&ze!=="point",Ls=ps/2;var Ws;x.hasAnyIconTextFit===!1&&Ce!=="none"&&(x.hasAnyIconTextFit=!0);const mr=c.properties?+c.properties[Fn]:null,er=mr&&x.elevationFeatureIdToIndex?x.elevationFeatureIdToIndex.get(mr):65535,Js=(Ks,cr,br)=>{if(cr.x<0||cr.x>=sr||cr.y<0||cr.y>=sr)return;let Br=null;if(ms){const{x:Tr,y:Tn,z:Na}=le.projectTilePoint(cr.x,cr.y,br);Br={anchor:new cv(Tr,Tn,Na,0,void 0),up:le.upVector(br,cr.x,cr.y)}}(function(Tr,Tn,Na,An,Ca,Vn,mo,Za,Da,ki,oo,cc,lo,Eo,rl,Po,dd,dc,Kn,Su,zo,Mc,Cu,ud,po,Xd,Tc,U7,J3,Yu,pxe,e5){const dv=Tr.addToLineVertexArray(Tn,An);let uv,Lp,Dp,D2,t5,ea,Ac,Io=0,Ul=0,Rp=0,im=0,om=-1,lm=-1;const Bf={};let V7=ar("");const rg=Na?Na.anchor:Tn,s5=U7!=="none";let r5=0,Ml=0;if(Da._unevaluatedLayout.getValue("text-radial-offset")===void 0){const Bo=Da.layout.get("text-offset").evaluate(zo,{},po);r5=Bo[0]*lc,Ml=Bo[1]*lc}else r5=Da.layout.get("text-radial-offset").evaluate(zo,{},po)*lc,Ml=Ufe;if(Tr.allowVerticalPlacement&&Ca.vertical){const Bo=Ca.vertical;if(rl)ea=Wfe(Bo),Za&&(Ac=Wfe(Za));else{const Mu=Da.layout.get("text-rotate").evaluate(zo,{},po)+90;Dp=S7(ki,rg,Tn,oo,cc,lo,Bo,Eo,Mu,Po,e5),Za&&(D2=S7(ki,rg,Tn,oo,cc,lo,Za,dc,Mu,null,pxe))}}if(Vn){const Bo=Da.layout.get("icon-rotate").evaluate(zo,{},po),Mu=qfe(Vn,Bo,Cu,s5,Mc.iconScaleFactor),Xu=Za?qfe(Za,Bo,Cu,s5,Mc.iconScaleFactor):void 0;Lp=S7(ki,rg,Tn,oo,cc,lo,Vn,dc,Bo,null,Yu);const qf=function(ng,F6,n5,$mt,qmt,rAe,nAe,Umt,PTs,xxe){const aAe=ng.layers[0],iAe=aAe.appearances;let a5=F6.length;if(n5&&(a5=Math.max(a5,n5.length)),iAe.length===0)return a5;const[Vmt,Hmt]=$mt.get("icon-size-scale-range"),Gmt=Oe(1,Vmt,Hmt);for(const K7 of iAe)if(K7.hasLayoutProperty("icon-image")){const oAe=aAe.getAppearanceValueAndResolveTokens(K7,"icon-image",rAe,nAe,xxe);if(oAe){const lAe=ng.getResolvedImageFromTokens(oAe);if(lAe){const cAe=K7.hasLayoutProperty("icon-size")?K7.getUnevaluatedLayoutProperty("icon-size"):qmt._values["icon-size"],Wmt=j6(lAe,T2(ng.zoom,cAe,ng.worldview,xxe),cAe,nAe,ng.zoom,rAe,ng.pixelRatio,Gmt,ng.worldview,xxe),dAe=Umt.get(Wmt.iconPrimary.toString());dAe&&(a5=Math.max(a5,pht(dAe)))}}}return a5}(Tr,Mu,Xu,Da.layout,Da._unevaluatedLayout,zo,po,Tr.iconAtlasPositions,0,ud);Io=4*qf;const H7=Da.layout.get("icon-size").evaluate(zo,{},po,ud),G7=Mc.compositeIconSizes?Mc.compositeIconSizes[0].evaluate(zo,{},po,ud):0,fxe=Mc.compositeIconSizes?Mc.compositeIconSizes[1].evaluate(zo,{},po,ud):0,W7=Gfe(Tr.layerIds[0],Tr.iconSizeData,H7,Mc.iconScaleFactor,G7,fxe);Tr.addSymbols(Tr.icon,Mu,W7,Su,Kn,zo,void 0,Na,Tn,dv.lineStartIndex,dv.lineLength,-1,ud,po,Xd,Tc,Tr.symbolInstances.length,qf),om=Tr.icon.placedSymbolArray.length-1,Xu&&(Ul=4*qf,Tr.addSymbols(Tr.icon,Xu,W7,Su,Kn,zo,am.vertical,Na,Tn,dv.lineStartIndex,dv.lineLength,-1,ud,po,Xd,Tc,Tr.symbolInstances.length,qf),lm=Tr.icon.placedSymbolArray.length-1)}for(const Bo in Ca.horizontal){const Mu=Bo,Xu=Ca.horizontal[Mu];uv||(V7=ar(Xu.text),rl?t5=Wfe(Xu):uv=S7(ki,rg,Tn,oo,cc,lo,Xu,Eo,Da.layout.get("text-rotate").evaluate(zo,{},po),Po,e5));const qf=Xu.positionedLines.length===1;if(Rp+=OMe(Tr,Na,Tn,Xu,mo,Da,rl,zo,Po,dv,Ca.vertical?am.horizontal:am.horizontalOnly,qf?yht(Ca.horizontal):[Mu],Bf,om,Mc,ud,po,Tr.symbolInstances.length,Xd),qf)break}Ca.vertical&&(im+=OMe(Tr,Na,Tn,Ca.vertical,mo,Da,rl,zo,Po,dv,am.vertical,["vertical"],Bf,lm,Mc,ud,po,Tr.symbolInstances.length,Xd));let hl=-1;const Vl=(Bo,Mu)=>Bo?Math.max(Bo,Mu):Mu;hl=Vl(t5,hl),hl=Vl(ea,hl),hl=Vl(Ac,hl);const $f=hl>-1?1:0;Tr.glyphOffsetArray.length>=65535&&Rr("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),zo.sortKey!==void 0&&Tr.addToSortKeyRanges(Tr.symbolInstances.length,zo.sortKey),Tr.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,V7,uv!==void 0?uv:Tr.collisionBoxArray.length,uv!==void 0?uv+1:Tr.collisionBoxArray.length,Dp!==void 0?Dp:Tr.collisionBoxArray.length,Dp!==void 0?Dp+1:Tr.collisionBoxArray.length,Lp!==void 0?Lp:Tr.collisionBoxArray.length,Lp!==void 0?Lp+1:Tr.collisionBoxArray.length,D2||Tr.collisionBoxArray.length,D2?D2+1:Tr.collisionBoxArray.length,oo,Rp,im,Io,Ul,$f,0,r5,Ml,hl,0,s5?1:0,J3)})(x,cr,Br,Ks,h,g,T,j,x.layers[0],x.collisionBoxArray,c.index,c.sourceLayerIndex,x.index,Is,Ke,H,0,es,Ss,Ee,c,P,Q,se,re,ue,ve,Ce,er,nt,ot,lt)};if(ze==="line")for(const Ks of a7(c.geometry,0,0,sr,sr)){const cr=mht(Ks,ps,vs,h.vertical||Mt,g,24,bs,x.overscaling,sr);for(const br of cr)Mt&&Cht(x,Mt.text,Ls,br)||Js(Ks,br,re)}else if(ze==="line-center"){for(const Ks of c.geometry)if(Ks.length>1){const cr=hht(Ks,vs,h.vertical||Mt,g,24,bs);cr&&Js(Ks,cr,re)}}else if(c.type==="Polygon")for(const Ks of a6(c.geometry,0)){const cr=xht(Ks,16);Js(Ks[0],new cv(cr.x,cr.y,0,0,void 0),re)}else if(c.type==="LineString")for(const Ks of c.geometry)Js(Ks,new cv(Ks[0].x,Ks[0].y,0,0,void 0),re);else if(c.type==="Point")for(const Ks of c.geometry)for(const cr of Ks)Js([cr],new cv(cr.x,cr.y,0,0,void 0),re)}const Hfe=255,A2=Hfe*lv;function OMe(x,c,h,g,j,T,P,R,F,H,Q,se,re,le,ue,ve,Ce,Ee,Ke){const ze=TMe(0,g,F,T,P,R,j,x.allowVerticalPlacement,void 0,ue.textScaleFactor),nt=T.layout.get("text-size").evaluate(R,{},Ce),ot=ue.compositeTextSizes?ue.compositeTextSizes[0].evaluate(R,{},Ce):0,lt=ue.compositeTextSizes?ue.compositeTextSizes[1].evaluate(R,{},Ce):0,It=Gfe(x.layerIds[0],x.textSizeData,nt,ue.textScaleFactor,ot,lt);x.addSymbols(x.text,ze,It,F,P,R,Q,c,h,H.lineStartIndex,H.lineLength,le,ve,Ce,Ke,!1,Ee,ze.length);for(const jt of se)re[jt]=x.text.placedSymbolArray.length-1;return 4*ze.length}function Gfe(x,c,h,g,j,T){const P=c;let R=null;return P.kind==="source"?(R=[lv*h*g],R[0]>A2&&Rr(`${x}: Value for "text-size" is >= ${Hfe}. Reduce your "text-size".`)):P.kind==="composite"&&(R=[lv*j*g,lv*T*g],(R[0]>A2||R[1]>A2)&&Rr(`${x}: Value for "text-size" is >= ${Hfe}. Reduce your "text-size".`)),R}function k7(x){for(const c in x)return x[c];return null}function S7(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,Lfe(P)&&P.collisionPadding){const ve=P.collisionPadding;le-=ve[0],se-=ve[1],ue+=ve[2],re+=ve[3]}if(F){const ve=new ns(le,se),Ce=new ns(ue,se),Ee=new ns(le,re),Ke=new ns(ue,re),ze=Kr(F);let nt=new ns(0,0);H&&(nt=new ns(H[0],H[1])),ve._rotateAround(ze,nt),Ce._rotateAround(ze,nt),Ee._rotateAround(ze,nt),Ke._rotateAround(ze,nt),le=Math.min(ve.x,Ce.x,Ee.x,Ke.x),ue=Math.max(ve.x,Ce.x,Ee.x,Ke.x),se=Math.min(ve.y,Ce.y,Ee.y,Ke.y),re=Math.max(ve.y,Ce.y,Ee.y,Ke.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 Wfe(x){Lfe(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 Cht(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])ze&&(nt(lt,ms,jt,Pt,ss,is),nt(ms,It,ss,is,Ct,Mt))}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),ve-=ze,Ce-=ze,Ee+=ze,Ke+=ze;const ot=1/Math.max(Ee-ve,Ke-Ce);return{scale:ot,x:ve*ot,y:Ce*ot,x2:Ee*ot,y2:Ke*ot,projection:c}}function zMe(x,{x:c,y:h},g=0){return new ns(((c-g)*x.scale-x.x)*sr,(h*x.scale-x.y)*sr)}const Mht=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 Kt(1,c)*h}pixelSpaceConversion(c,h,g){return 1}farthestPixelDistance(c){return FMe(c,c.pixelsPerMeter)}pointCoordinate(c,h,g,j){const T=c.horizonLineFromTop(!1),P=new ns(h,Math.max(T,g));return c.rayIntersectionCoordinate(c.pointRayIntersection(P,j))}pointCoordinate3D(c,h,g){const j=new ns(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(M7(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=Oe(La(F/g)+this.center[0],-180,180),Q=Oe(La(2*Math.atan(Math.pow(j/R,1/g))-G3),-85.051129,cs);return new qt(H,this.southernCenter?-Q:Q)}}class BMe 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:Ns(c),y:As(h),z:0}}unproject(c,h){const g=Vt(c),j=ts(h);return new qt(g,j)}}const $Me=Kr(cs);class Iht extends c_{project(c,h){const g=(h=Kr(h))*h,j=g*g;return{x:.5*((c=Kr(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=Oe(g-T,-$Me,$Me)}while(Math.abs(T)>1e-6&&--j>0);P=g*g;const R=Oe(La(c/(.8707+P*(P*(P*P*P*(.003971-.001529*P)-.013791)-.131979))),-180,180),F=La(g);return new qt(R,F)}}const qMe=Kr(cs);class Lht extends c_{project(c,h){h=Kr(h),c=Kr(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),ve=Math.sin(g/2),Ce=2*ue*ve,Ee=ve*ve,Ke=1-le*ue*ue,ze=Ke?1/Ke:0,nt=Ke?Math.acos(H*ue)*Math.sqrt(1/Ke):0,ot=.5*(2*nt*H*ve+2*g/Math.PI)-c,lt=.5*(nt*Q+j)-h,It=.5*ze*(le*Ee+nt*H*ue*re)+1/Math.PI,jt=ze*(Ce*se/4-nt*Q*ve),Pt=.125*ze*(se*ve-nt*Q*le*Ce),Ct=.5*ze*(re*ue+nt*Ee*H)+.5,Mt=jt*Pt-Ct*It;R=(lt*jt-ot*Ct)/Mt,F=(ot*Pt-lt*It)/Mt,g=Oe(g-R,-Math.PI,Math.PI),j=Oe(j-F,-qMe,qMe)}while((Math.abs(R)>P||Math.abs(F)>P)&&--T>0);return new qt(La(g),La(j))}}class UMe 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(Kr(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:Kr(c)*j*g+.5,y:-Math.sin(Kr(h))/j*g+.5,z:0}}unproject(c,h){const{scale:g,cosPhi:j}=this,T=-(h-.5)/g,P=Oe(La((c-.5)/g)/j,-180,180),R=Math.asin(Oe(T*j,-1,1)),F=Oe(La(R),-85.051129,cs);return new qt(P,F)}}class Dht extends BMe{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 ut(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=ke([],j),P=g?c._centerAltitude+g:c.elevation?c.elevation.getAtPointOrZero(c.locationCoordinate(h),c._centerAltitude):c._centerAltitude;Ue(j,j,T,Kt(1,0)*sr*P);const R=w(new Float64Array(16));return C(R,c.pixelMatrix,c.globeMatrix),ut(j,j,R),new ns(j[0],j[1])}pixelsPerMeter(c,h){return Kt(1,0)*h}pixelSpaceConversion(c,h,g){const j=Kt(1,c)*h,T=nn(Kt(1,45)*h,j,g);return this.pixelsPerMeter(c,h)/T}createTileMatrix(c,h,g){const j=$pe(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,Kr(g.lng)),L(j,j,Kr(g.lat)),I(j,j,[c._pixelsPerMercatorPixel,c._pixelsPerMercatorPixel,1]),Float32Array.from(j)}pointCoordinate(c,h,g,j){return a3e(c,h,g,!0)||new _r(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!a3e(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([],Ne([],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),ve=Ne([],F.up(),ue),Ce=Ne([],F.right(),ue*le),Ee=ke([],oe([],oe([],H,ve),Ce)),Ke=[];let ze;if(new ra(Q,Ee).closestPointOnSphere(re,se,Ke)){const nt=oe([],Ke,re),ot=_e([],nt,Q);ze=Math.cos(j.fovAboveCenter)*ce(ot)}else{const nt=_e([],Q,re),ot=_e([],re,Q);ke(ot,ot);const lt=ce(nt)-se;ze=Math.sqrt(lt*(lt+2*se));const It=Math.acos(ze/(se+lt))-Math.acos($e(H,ot));ze*=Math.cos(It)}return 1.01*ze}(c,this.pixelsPerMeter(c.center.lat,c.worldSize)),g=av(c.zoom);if(g>0){const j=FMe(c,Kt(1,c.center.lat)*c.worldSize),T=c.worldSize/(2*Math.PI),P=Math.max(c.width,c.height)/c.worldSize*Math.PI;return nn(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:$F(UF(fy(c)))}}}function VMe(x){const c=x.parallels,h=!!c&&Math.abs(c[0]+c[1])<.01;switch(x.name){case"mercator":return new BMe(x);case"equirectangular":return new Eht(x);case"naturalEarth":return new Iht(x);case"equalEarth":return new Aht(x);case"winkelTripel":return new Lht(x);case"albers":return h?new UMe(x):new Tht(x);case"lambertConformalConic":return h?new UMe(x):new Pht(x);case"globe":return new Dht(x)}throw new Error(`Invalid projection name: ${x.name}`)}class Rht{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 wi(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,ve=c*K3;ue[ve]=h,ue[ve+1]=g,ue[ve+2]=j,ue[ve+3]=T,ue[ve+4]=P,ue[ve+5]=R,ue[ve+6]=F,ue[ve+7]=H,ue[ve+8]=Q,ue[ve+9]=se,ue[ve+10]=re,ue[ve+11]=le}upload(c,h,g,j,T,P){this.isEmpty()||(g&&(this.cachedBatchIndices=null,this.cachedBatchSegments=null,this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,zut.members,!!P),this.indexBuffer=c.createIndexBuffer(this.indexArray,h),this.dynamicLayoutVertexBuffer=c.createVertexBuffer(this.dynamicLayoutVertexArray,$ut.members,!0),this.opacityVertexBuffer=c.createVertexBuffer(this.opacityVertexArray,Fht,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=c.createVertexBuffer(this.iconTransitioningVertexArray,Hut.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=c.createVertexBuffer(this.globeExtVertexArray,But.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||T)&&(this.zOffsetVertexBuffer=c.createVertexBuffer(this.zOffsetVertexArray,qut.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=c.createVertexBuffer(this.orientationVertexArray,Vut.members,!0)),this.opacityVertexBuffer.itemSize=1,this.featureIdArray&&this.featureIdArray.length>0&&(this.featureIdBuffer=c.createVertexBuffer(this.featureIdArray,Uut.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())}}fr(Kfe,"SymbolBuffers",{omit:["cachedBatchIndices","cachedBatchSegments"]});class Zfe{constructor(c,h,g){this.layoutVertexArray=new c,this.layoutAttributes=h,this.indexArray=new g,this.segments=new wi,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,Gut.members,!0),this.collisionVertexBufferExt=c.createVertexBuffer(this.collisionVertexArrayExt,Wut.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}fr(Zfe,"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 Kfe(new Ae(this.layers,{zoom:this.zoom,lut:this.lut},c=>c.startsWith("text")||c.startsWith("symbol"))),this.icon=new Kfe(new Ae(this.layers,{zoom:this.zoom,lut:this.lut},c=>c.startsWith("icon")||c.startsWith("symbol"))),this.disableSymbolUBO||(this.text.uboBinder=new Afe(this.layers[0],this.zoom,this.lut,!0,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords),this.icon.uboBinder=new Afe(this.layers[0],this.zoom,this.lut,!1,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords)),this.glyphOffsetArray=new DF,this.lineVertexArray=new v2,this.symbolInstances=new LF}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),ve=H.possiblyEvaluate(new Ka(le,{worldview:this.worldview}),j),Ce=ue.evaluate(g,{},j,T);F=Ce+(ve.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!JF(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=Oe(h.scaleFactor||1,se,re),[ue,ve]=P.get("text-size-scale-range"),Ce=Oe(h.scaleFactor||1,ue,ve),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),Ke=Q.value.kind!=="constant"||!!Q.value.value||Object.keys(Q.parameters).length>0,ze=this.hasAnyAppearanceLayoutProperty("icon-image"),nt=P.get("symbol-sort-key");if(this.features=[],this.featureAppearanceData=new Map,!Ee&&!Ke&&!ze)return;const ot=h.iconDependencies,lt=h.glyphDependencies,It=h.availableImages,jt=new Ka(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),Pt=Ct=>{const Mt=Ct.id.toString();ot.has(Mt)?ot.get(Mt).push(Ct):ot.set(Mt,[Ct])};for(const Ct of c){const{feature:Mt,id:ss,index:is,sourceLayerIndex:ms}=Ct,bs=T._featureFilter.needGeometry,ps=Un(Mt,bs);if(!T._featureFilter.filter(jt,ps,g))continue;if(bs||(ps.geometry=qr(Mt,g,j)),R&&Mt.type!==1&&g.z<=5){const er=ps.geometry,Js=.98078528056,Ks=(cr,br)=>$e(QP(cr.x,cr.y,g,1),QP(br.x,br.y,g,1)){if(!er.getLayoutProperty("icon-image"))return;const Js=this.getCombinedIconPrimary(er,vs,ps,g,It,Ws,le);Js&&Pt(Js)}),Is){const er=F.evaluate(ps,{},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 Ks of Is.sections)if(Ks.image){const cr=Ks.image.getPrimary().scaleSelf(this.pixelRatio*Ce),br=cr.id.toString(),Br=ot.get(br)||[];Br.push(cr),ot.set(br,Br)}else{const cr=_P(Is.toString()),br=Ks.fontStack||er,Br=lt[br]=lt[br]||{};this.calculateGlyphDependencies(Ks.text,Br,Js,this.allowVerticalPlacement,cr)}}}if(P.get("symbol-placement")==="line"&&(this.features=function(Ct){const Mt={},ss={},is=[];let ms=0;function bs(vs){is.push(Ct[vs]),ms++}function ps(vs,Ss,Ls){const Ws=ss[vs];return delete ss[vs],ss[Ss]=Ws,is[Ws].geometry[0].pop(),is[Ws].geometry[0]=is[Ws].geometry[0].concat(Ls[0]),Ws}function Is(vs,Ss,Ls){const Ws=Mt[Ss];return delete Mt[Ss],Mt[vs]=Ws,is[Ws].geometry[0].shift(),is[Ws].geometry[0]=Ls[0].concat(is[Ws].geometry[0]),Ws}function es(vs,Ss,Ls){const Ws=Ls?Ss[0][Ss[0].length-1]:Ss[0][0];return`${vs}:${Ws.x}:${Ws.y}`}for(let vs=0;vsvs.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 Ct of h.elevationFeatures)this.elevationFeatureIdToIndex.set(Ct.id,this.elevationFeatures.length),this.elevationFeatures.push(Ct)}}else P.get("symbol-z-elevate")&&(this.elevationType="offset");this.elevationType!=="none"&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((Ct,Mt)=>Ct.sortKey-Mt.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:ve}=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 Ke=Ee.toString(),ze=this.iconAtlasPositions&&this.iconAtlasPositions.get(Ke);if(ze){const{appearanceIconOffset:nt,appearanceIconRotate:ot}=EMe(Ce,Q,j,R,le,ve,ue,se);let lt=y7(ze,void 0,nt,Q.layout.get("icon-anchor").evaluate(j,re,R));const It=ze.sdf,jt=Q.layout.get("icon-text-fit").constantOr("none");jt!=="none"&&h.textShaping&&h.iconTextFitPadding&&h.fontScale&&(lt=Dfe(lt,h.textShaping,jt,h.iconTextFitPadding,nt,h.fontScale));const Pt=this.calculateEffectiveAppearanceIconSize(Ce,H.zoom,j,R,F,se,ue),Ct=0,Mt=1+(Math.min(A2,Math.round(Pt*lv))<<1),ss=qfe(lt,ot,It,jt!=="none",se);h.isUsingAppearanceIconVertexData||(h.isUsingAppearanceIconVertexData=!0,h.layoutBasedIconVertexData=this.icon.snapshotSymbolVertexData(T,c.numIconVertices));const is=Math.floor(c.numIconVertices/4),ms=Math.min(ss.length,is);let bs=T;for(let Is=0;Is0||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 ot=g>=0?F.appearances[g]:null;if(ot&&h.textShaping){const{appearanceTextOffset:lt,appearanceTextRotate:It,appearanceTextSize:jt}=PMe(ot,F,j,R,re,ue,le);h.fontScale=RMe(jt,h.textScaleFactor);const Pt=ot.getUnevaluatedLayoutProperty("text-size");let Ct=this.textSizeData,Mt=Ee,ss=Ke;ot.hasLayoutProperty("text-size")&&(Ct=T2(this.zoom,Pt,this.worldview,ze),Mt=this.textSizeData.kind==="composite"?this.textSizeData.minZoom:0,ss=this.textSizeData.kind==="composite"?this.textSizeData.maxZoom:0);const is=h.textShaping.bottom-re[1],ms=h.textShaping.left-re[0],bs=h.textShaping.right-re[0];h.textShaping.top=lt[1]+(h.textShaping.top-re[1]),h.textShaping.bottom=lt[1]+is,h.textShaping.left=lt[0]+ms,h.textShaping.right=lt[0]+bs;const ps=TMe(0,h.textShaping,lt,F,!1,j,Q,this.allowVerticalPlacement,It),Is=jt&&Ct.kind==="composite"?Pt.possiblyEvaluate(new Ka(Mt,{}),R).evaluate(j,se,R):ve,es=jt&&Ct.kind==="composite"?Pt.possiblyEvaluate(new Ka(ss,{}),R).evaluate(j,se,R):Ce,vs=Gfe(ot.name,Ct,jt,H,Is,es),Ss=Array.isArray(vs)?vs[1]:jt,Ls=0,Ws=1+(Math.min(A2,Math.round(Ss*lv))<<1);h.isUsingAppearanceTextVertexData||(h.isUsingAppearanceTextVertexData=!0,h.layoutBasedTextVertexData=this.text.snapshotSymbolVertexData(T,c.numHorizontalGlyphVertices+c.numVerticalGlyphVertices));for(let mr=0;mr0){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=Cs(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 Ke=new ns(F.tileAnchorX,F.tileAnchorY),ze=.075+Ee.pointElevation(Ke);F.zOffset!==ze&&(h=!0,F.zOffset=ze),ze!==0&&(this.hasAnyZOffset=!0);const nt=Ee.computeSlopeNormal(Ke,j),ot=Dr(Je(),ae(0,0,1),nt);He(H,H,ot),He(Q,Q,ot),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||ve,P=P||Ce)}if(ve&&(T7(this.text.orientationVertexArray,se,H,Q),T7(this.text.orientationVertexArray,re,H,Q)),Ce){const{placedIconSymbolIndex:Ke,verticalPlacedIconSymbolIndex:ze}=F;Ke>=0&&T7(this.icon.orientationVertexArray,le,H,Q),ze>=0&&T7(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 Rht(se.appearances,se.appearancesVersion));const le=this.featureAppearances.update(j,P);if(le.kind==="no-changes")return R;let ue=1,ve=0,Ce=!1,Ee=!1;if(H){const[lt,It]=re.get("icon-size-scale-range");ue=Oe(1,lt,It)}let Ke=1,ze=0,nt=!1;if(Q){const[lt,It]=re.get("text-size-scale-range");Ke=Oe(1,lt,It)}const ot=new Map;if(T&&g)for(const lt of g){const It=T.getImage(lt,se.scope);if(It){const jt=new qm(lt.toString());ot.set(jt.toString(),It)}}for(let lt=0;ltbs.isActive({globals:j,feature:Mt,canonical:c,featureState:Ct})):-1;ss=ms>=0?ms:-1}const is=jt.activeAppearanceIndex!==ss;if(Q){const ms=re.get("text-size"),bs=this.textSizeData.kind==="composite"?this.textSizeData.minZoom:0,ps=this.textSizeData.kind==="composite"?this.textSizeData.maxZoom:0,Is={canonical:c,layer:se,featureState:Ct,availableImages:g,textScaleFactor:Ke,imageMap:ot,layoutTextOffset:re.get("text-offset").evaluate(Mt,Ct,c).map(vs=>vs*lc),layoutTextSize:ms.evaluate(Mt,Ct,c),layoutTextRotate:re.get("text-rotate").evaluate(Mt,Ct,c),layoutMinZoomSize:ms.evaluate(Mt,{zoom:bs},c),layoutMaxZoomSize:ms.evaluate(Mt,{zoom:ps},c),layoutTextSizeMinZoom:bs,layoutTextSizeMaxZoom:ps},es=this.updateSymbolInstanceTextVertices(It,jt,ss,Mt,ze,Is);ze+=es.vertexOffsetDelta,nt=nt||es.hasChanges}if(H){const ms={canonical:c,layer:se,featureState:Ct,availableImages:g,globalProperties:j,iconScaleFactor:ue,layoutIconOffset:re.get("icon-offset").evaluate(Mt,Ct,c),layoutIconSize:re.get("icon-size").evaluate(Mt,Ct,c,g),layoutIconRotate:re.get("icon-rotate").evaluate(Mt,Ct,c)},bs=this.updateSymbolInstanceIconVertices(It,jt,ss,Mt,ve,ms);ve+=bs.vertexOffsetDelta,Ce=Ce||bs.hasChanges}if(is){const ms=It.featureIndex,bs=j?j.brightness:null,ps=Ct||{},Is=ss>=0?se.appearances[ss]:null;this.text.uboBinder&&(this.text.uboBinder.layer=se,Ee=this.text.uboBinder.updateFeaturePaintForAppearance(ms,Mt,ps,c,g,bs,Is)||Ee),this.icon.uboBinder&&(this.icon.uboBinder.layer=se,Ee=this.icon.uboBinder.updateFeaturePaintForAppearance(ms,Mt,ps,c,g,bs,Is)||Ee)}jt.activeAppearanceIndex=ss}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=VMe(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,ve,Ce,Ee,Ke){const ze=c.indexArray,nt=c.layoutVertexArray,ot=c.globeExtVertexArray,lt=Ke,It=c.uboBinder?c.uboBinder.getCurrentBatchIndex():void 0,jt=c.segments.prepareSegment(4*lt,nt,ze,this.canOverlap?P.sortKey:void 0,It),Pt=this.glyphOffsetArray.length,Ct=jt.vertexLength,Mt=this.allowVerticalPlacement&&R===am.vertical?Math.PI/2:0,ss=P.text&&P.text.sections;let is=nt.length,ms=-1;for(let Is=0;Is=0)){const Is=4*bs;for(let es=0;es=0?h.rightJustifiedTextSymbolIndex:h.centerJustifiedTextSymbolIndex>=0?h.centerJustifiedTextSymbolIndex:h.leftJustifiedTextSymbolIndex>=0?h.leftJustifiedTextSymbolIndex:h.verticalPlacedTextSymbolIndex>=0?h.verticalPlacedTextSymbolIndex:j),P=Rfe(this.textSizeData,c,T)/lc;return this.tilePixelRatio*P}getSymbolInstanceIconSize(c,h,g){const j=this.icon.placedSymbolArray.get(g),T=Rfe(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 GMe,WMe,Yfe;fr(eg,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),eg.addDynamicAttributes=W3;class KMe{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}}fr(KMe,"FormatSectionOverride",{omit:["defaultValue"]});const Xfe=()=>Yfe||(Yfe={layout:GMe||(GMe=new Qi({"symbol-placement":new Ys(Gt.layout_symbol["symbol-placement"]),"symbol-spacing":new Ys(Gt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ys(Gt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Vs(Gt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ys(Gt.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Ys(Gt.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new Ys(Gt.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new Ys(Gt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Ys(Gt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ys(Gt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ys(Gt.layout_symbol["icon-rotation-alignment"]),"icon-size":new Vs(Gt.layout_symbol["icon-size"]),"icon-size-scale-range":new Ys(Gt.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new Vs(Gt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Vs(Gt.layout_symbol["icon-text-fit-padding"]),"icon-image":new Vs(Gt.layout_symbol["icon-image"]),"icon-image-use-theme":new Ys({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new Vs(Gt.layout_symbol["icon-rotate"]),"icon-padding":new Ys(Gt.layout_symbol["icon-padding"]),"icon-keep-upright":new Ys(Gt.layout_symbol["icon-keep-upright"]),"icon-offset":new Vs(Gt.layout_symbol["icon-offset"]),"icon-anchor":new Vs(Gt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ys(Gt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ys(Gt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ys(Gt.layout_symbol["text-rotation-alignment"]),"text-field":new Vs(Gt.layout_symbol["text-field"]),"text-font":new Vs(Gt.layout_symbol["text-font"]),"text-size":new Vs(Gt.layout_symbol["text-size"]),"text-size-scale-range":new Ys(Gt.layout_symbol["text-size-scale-range"]),"text-max-width":new Vs(Gt.layout_symbol["text-max-width"]),"text-line-height":new Vs(Gt.layout_symbol["text-line-height"]),"text-letter-spacing":new Vs(Gt.layout_symbol["text-letter-spacing"]),"text-justify":new Vs(Gt.layout_symbol["text-justify"]),"text-radial-offset":new Vs(Gt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ys(Gt.layout_symbol["text-variable-anchor"]),"text-anchor":new Vs(Gt.layout_symbol["text-anchor"]),"text-max-angle":new Ys(Gt.layout_symbol["text-max-angle"]),"text-writing-mode":new Ys(Gt.layout_symbol["text-writing-mode"]),"text-rotate":new Vs(Gt.layout_symbol["text-rotate"]),"text-padding":new Ys(Gt.layout_symbol["text-padding"]),"text-keep-upright":new Ys(Gt.layout_symbol["text-keep-upright"]),"text-transform":new Vs(Gt.layout_symbol["text-transform"]),"text-offset":new Vs(Gt.layout_symbol["text-offset"]),"text-allow-overlap":new Ys(Gt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Ys(Gt.layout_symbol["text-ignore-placement"]),"text-optional":new Ys(Gt.layout_symbol["text-optional"]),visibility:new Ys(Gt.layout_symbol.visibility)})),paint:WMe||(WMe=new Qi({"icon-opacity":new Vs(Gt.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new Vs(Gt.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new Vs(Gt.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Vs(Gt.paint_symbol["text-emissive-strength"]),"icon-color":new Vs(Gt.paint_symbol["icon-color"]),"icon-halo-color":new Vs(Gt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Vs(Gt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Vs(Gt.paint_symbol["icon-halo-blur"]),"icon-translate":new Ys(Gt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ys(Gt.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Ys(Gt.paint_symbol["icon-image-cross-fade"]),"text-opacity":new Vs(Gt.paint_symbol["text-opacity"]),"text-occlusion-opacity":new Vs(Gt.paint_symbol["text-occlusion-opacity"]),"text-color":new Vs(Gt.paint_symbol["text-color"],{runtimeType:Nu,getOverride:x=>x.textColor,hasOverride:x=>!!x.textColor}),"text-halo-color":new Vs(Gt.paint_symbol["text-halo-color"]),"text-halo-width":new Vs(Gt.paint_symbol["text-halo-width"]),"text-halo-blur":new Vs(Gt.paint_symbol["text-halo-blur"]),"text-translate":new Ys(Gt.paint_symbol["text-translate"]),"text-translate-anchor":new Ys(Gt.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Ys(Gt.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Ys(Gt.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Ys(Gt.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Ys(Gt.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new Vs(Gt.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"})}))},Yfe);class A7 extends Yd{constructor(c,h,g,j){super(c,Xfe(),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=Bi(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:HMe(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:HMe(g.properties,R)}createBucket(c){return new eg(c)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const c of Xfe().paint.overridableProperties){if(!A7.hasPaintOverride(this.layout,c))continue;const h=this.paint.get(c),g=new KMe(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())&&A7.hasPaintOverride(this.layout,c)}static hasPaintOverride(c,h){const g=c.get("text-field"),j=Xfe().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 wr&&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 ZMe,YMe,XMe,QMe;var E7=la([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Uint16",components:2}]);function P7(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 JMe(x,c,h,g,j,T,P,R){const F=function(H,Q,se,re,le,ue,ve,Ce){const Ee=P7(0,0,1,0,1,1,0,1),Ke=P7(H,Q,se,re,le,ue,ve,Ce);return _(Ke,Ke,y([],Ee))}(x,c,h,g,j,T,P,R);return[F[2]/F[8]/sr,F[5]/F[8]/sr]}function I7(x){return[x[0],Math.min(Math.max(x[1],-85.051129),cs)]}class eTe 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]cs?this.onNorthPole=!0:j<-85.051129&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const T=c.map(_r.fromLngLat);this.tileID=function(P){let R=1/0,F=1/0,H=-1/0,Q=-1/0;for(const ve of P)R=Math.min(R,ve.x),F=Math.min(F,ve.y),H=Math.max(H,ve.x),Q=Math.max(Q,ve.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,Ke=Ce[1].y-Ce[0].y,ze=Ce[2].x-Ce[1].x,nt=Ce[2].y-Ce[1].y,ot=Ce[3].x-Ce[2].x,lt=Ce[3].y-Ce[2].y,It=Ce[0].x-Ce[3].x,jt=Ce[0].y-Ce[3].y,Pt=Ee*nt-ze*Ke,Ct=ze*lt-ot*nt,Mt=ot*jt-It*lt,ss=It*Ke-Ee*jt;return Pt>0&&Ct>0&&Mt>0&&ss>0||Pt<0&&Ct<0&&Mt<0&&ss<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 zMe(j,Ee)._round()});this.perspectiveTransform=JMe(T.x,T.y,P.x,P.y,R.x,R.y,F.x,F.y);const H=this._boundsArray=new ld;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,E7.members),this.boundsSegments=wi.simpleSegment(0,0,4,2);const Q=[],se=function(Ce){return[I7(Ce[0]),I7(Ce[1]),I7(Ce[2]),I7(Ce[3])]}(this.coordinates),[re,le,ue,ve]=function(Ce){let Ee=Ce[0][0],Ke=Ee,ze=Ce[0][1],nt=ze;for(let ot=1;otKe&&(Ke=Ce[ot][0]),Ce[ot][1]nt&&(nt=Ce[ot][1]);return[Ee,ze,Ke-Ee,nt-ze]}(se);{const Ce=new ld,[Ee,Ke,ze,nt]=function(ps){let Is=ps[0].x,es=Is,vs=ps[0].y,Ss=vs;for(let Ls=1;Lses&&(es=ps[Ls].x),ps[Ls].ySs&&(Ss=ps[Ls].y);return[Is,vs,es-Is,Ss-vs]}(g),ot=ps=>[(ps.x-Ee)/ze,(ps.y-Ke)/nt],[lt,It,jt,Pt]=g.map(ot),Ct=function(ps,Is,es,vs,Ss,Ls,Ws,mr){const er=P7(0,0,1,0,1,1,0,1);return _(er,er,y([],P7(ps,Is,es,vs,Ss,Ls,Ws,mr)))}(lt[0],lt[1],It[0],It[1],jt[0],jt[1],Pt[0],Pt[1]);this.elevatedGlobePerspectiveTransform=JMe(lt[0],lt[1],It[0],It[1],jt[0],jt[1],Pt[0],Pt[1]);const Mt=(ps,Is)=>{Q.push(ps.lng);const es=Math.round((ps.lng-re)/ue*sr),vs=Math.round((ps.lat-le)/ve*sr),Ss=ot(Is),Ls=fe([],[Ss[0],Ss[1],1],Ct),Ws=Math.round(Ls[0]/Ls[2]*sr),mr=Math.round(Ls[1]/Ls[2]*sr);Ce.emplaceBack(es,vs,Ws,mr)},ss=g[3].x-g[0].x,is=g[3].y-g[0].y,ms=g[2].x-g[1].x,bs=g[2].y-g[1].y;for(let ps=0;ps<65;ps++){const Is=ps/64,es=[g[0].x+Is*ss,g[0].y+Is*is],vs=[g[1].x+Is*ms,g[1].y+Is*bs],Ss=vs[0]-es[0],Ls=vs[1]-es[1];for(let Ws=0;Ws<65;Ws++){const mr=Ws/64,er={x:es[0]+Ss*mr,y:es[1]+Ls*mr};Mt(h.projection.unproject(er.x,er.y),er)}}this.elevatedGlobeVertexBuffer=c.createVertexBuffer(Ce,E7.members)}{this.maxLongitudeTriangleSize=0;let Ce=[],Ee=new Ao;const Ke=(ze,nt,ot)=>{Ee.emplaceBack(ze,nt,ot);const lt=Q[ze],It=Q[nt],jt=Q[ot],Pt=Math.min(Math.min(lt,It),jt),Ct=Math.max(Math.max(lt,It),jt)-Pt;Ct>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=Ct),Ce.push(Pt+Ct/2)};for(let ze=0;ze<64;ze++)for(let nt=0;nt<64;nt++){const ot=65*ze+nt,lt=ot+1,It=ot+65,jt=It+1;Ke(ot,It,lt),Ke(lt,It,jt)}[Ce,Ee]=function(ze,nt){const ot=Array.from({length:ze.length},(jt,Pt)=>Pt);ot.sort((jt,Pt)=>ze[jt]-ze[Pt]);const lt=[],It=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,zi(g,se+1,g.length,j+360-F)-se),P}j0}}let sTe,rTe,nTe,aTe,iTe,oTe,lTe;class cTe extends Yd{constructor(c,h,g,j){super(c,{layout:sTe||(sTe=new Qi({visibility:new Ys(Gt["layout_raster-particle"].visibility)})),paint:rTe||(rTe=new Qi({"raster-particle-array-band":new Ys(Gt["paint_raster-particle"]["raster-particle-array-band"]),"raster-particle-count":new Ys(Gt["paint_raster-particle"]["raster-particle-count"]),"raster-particle-color":new Q1(Gt["paint_raster-particle"]["raster-particle-color"]),"raster-particle-max-speed":new Ys(Gt["paint_raster-particle"]["raster-particle-max-speed"]),"raster-particle-speed-factor":new Ys(Gt["paint_raster-particle"]["raster-particle-speed-factor"]),"raster-particle-fade-opacity-factor":new Ys(Gt["paint_raster-particle"]["raster-particle-fade-opacity-factor"]),"raster-particle-reset-rate-factor":new Ys(Gt["paint_raster-particle"]["raster-particle-reset-rate-factor"]),"raster-particle-elevation":new Ys(Gt["paint_raster-particle"]["raster-particle-elevation"]),"raster-particle-color-use-theme":new Vs({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 $ht 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 Jfe(x,c,h){const g=[0,0,1],j=Ze([]);return Ot(j,j,h?-Kr(x)+Math.PI:Kr(x)),Nt(j,j,-Kr(c)),He(g,g,j),ke(g,g)}class L7{constructor(c,h,g,j){this.message=(c?`${c}: `:"")+g,j&&(this.identifier=j),h!=null&&h.__line__&&(this.line=h.__line__)}}function exe(x,c){const h=x.indexOf("://")===-1;try{return new URL(x,h&&c?"http://example.com":void 0),!0}catch{return!1}}class dTe{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 uTe{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 ns(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 txe{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=Cs(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=Un(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:qr(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*Te(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(JF(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;ve=Ce?ve-sr:ve;const Ee=Math.floor(ve),Ke=Math.floor(H.float32[ue+1]);let ze=!1;for(const nt of this.activeReplacements)if(!G3e(nt,g,e7.Model,j)&&!(nt.min.x>Ee||Ee>nt.max.x||nt.min.y>Ke||Ke>nt.max.y)&&(ze=X3e(Y3e(Ee,Ke,c.canonical,nt.footprintTileId.canonical),nt.footprint),ze))break;H.float32[ue]=ze?ve+sr:ve,P=P||ze!==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,iut.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 Rr(`modelId is not evaluated for layer ${P.id} and it is not going to get rendered.`),H;(exe(H,!1)||this.styleDefinedModelURLs[H]!==void 0)&&(this.modelUris.includes(H)||this.modelUris.push(H)),this.instancesPerModel[H]||(this.instancesPerModel[H]=new uTe);const Q=this.instancesPerModel[H],se=Q.instancedDataArray,re=new dTe(g,se.length);let le;j&&(le=Ci.getElevationFeature(c,j));for(const ue of h)for(const ve of ue){if(ve.x<0||ve.x>=sr||ve.y<0||ve.y>=sr)continue;if(this.lookupDim!==0&&F){const Ee=(this.lookupDim-1)/sr,Ke=this.lookupDim*(ve.y*Ee|0)+ve.x*Ee|0;if(this.lookup){if(this.lookup[Ke]!==0)continue;this.lookup[Ke]=1}}this.instanceCount++;const Ce=se.length;if(se.resize(Ce+1),j){Q.instancesRoadElevation||(Q.instancesRoadElevation=[]);const Ee=le?le.pointElevation(new ns(ve.x,ve.y)):0;Q.instancesRoadElevation.push(Ee)}Q.instancesEvaluatedElevation.push(0),se.float32[16*Ce]=ve.x,se.float32[16*Ce+1]=ve.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])),D5e(re,F,H);const ve=Math.round(100*se.a)+se.b/1.05;for(let Ce=0;Ce10?this.tileToMeter:Cs(R,ot)),ze[Ke+4]=Q[0],ze[Ke+5]=Q[1],ze[Ke+6]=Q[2]+(g.instancesRoadElevation?g.instancesRoadElevation[Ee]:0)+nt,ze[Ke+7]=re[0],ze[Ke+8]=re[1],ze[Ke+9]=re[2],ze[Ke+10]=re[4],ze[Ke+11]=re[5],ze[Ke+12]=re[6],ze[Ke+13]=re[8],ze[Ke+14]=re[9],ze[Ke+15]=re[10],g.instancesEvaluatedElevation[Ee]=Q[2]}}}fr(txe,"ModelBucket",{omit:["layers"]}),fr(uTe,"PerModelAttributes"),fr(dTe,"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 fTe(H)),mTe(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(!$n(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):vfe(j,c,!0)}for(const g of h)m7(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($n(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 Is=sxe[ps],es=Math.abs(Is);es>Mt&&(Ct=Is,Mt=es,ss=bs,is=ms)}if(Mt>.1){const ms=1-(lt+.5*Math.abs(ss*is))/ue;let bs=h._dem.get(jt,It)+Ct*ms;const ps=h._dem.get(jt+ss,It+is),Is=h._dem.get(jt-ss,It-is,!0);(bs-ps)*(bs-Is)>0&&(bs=(ps+Is)/2),sxe[Pt]=h._dem.set(jt,It,bs),P2[Pt]=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)m7(h.node),_fe(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]};k(T,P.node.globalMatrix),j[0]=c,j[1]=h,ut(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 ns(c,h),new ns(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 qht(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=nn(F,255*h[0],h[3]),H=nn(H,255*h[1],h[3]),Q=nn(Q,255*h[2],h[3]));const se=F<<8|H,re=Q<<8|Math.floor(255*g[3]),le=function(lt){const It=Oe(lt,0,2);return Math.min(Math.round(.5*It*255),255)}(g[2])<<8|15*g[0]<<4|15*g[1],ue=Oe(j[0],0,1),ve=Oe(j[1],0,1),Ce=Oe(j[2],0,1),Ee=Oe(j[3],0,1);let Ke,ze,nt,ot;if(ue!==ve&&P!==T&&ve!==ue){const lt=P-T;ze=1/(lt*(ve-ue)),nt=-(T+lt*ue)/(lt*(ve-ue));const It=Oe(j[4],-1,1);ot=Math.pow(10,It),Ke=255*Ce<<8|255*Ee}else Ke=65535,ze=0,nt=1,ot=1;if(x.emplaceBack(se,re,le,Ke,ze,nt,ot),R){const lt=R.length;R.clear();for(let It=0;It>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 ve;if(R&&se===2&&g.lights&&(ve=new T3,ve.resize(10*g.lights.length)),qht(P.featureArray,H,le,re,ue,P.aabb.min[2],P.aabb.max[2],ve),ve&&R){R=!1;const Ce=g.meshes[g.lightMeshIndex];Ce.featureArray=ve,Ce.featureArray._trim()}}P.featureArray._trim(),j++}}fr(D7,"Tiled3dModelBucket",{omit:["layers"]}),fr(fTe,"Tiled3dModelFeature");const Vht=["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 Vht)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 E5e(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=wfe(j),R=T.modelSpec,F=new R5e(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 rxe(x,c,h,g){const j=1<F>=ot.vertexArrayOffset&&Fnt.polygon).flat());const Ce=le?R:null,[Ee,Ke]=x5e(T,g,se,Q,H,P,Ce,re,ue,T.center.lat,x.tileID.canonical),ze=x.queryGeometry;return f5e(Ee,Ke,ze.isPointQuery()?ze.screenBounds:ze.screenGeometry)}},building:class extends Yd{constructor(x,c,h,g){super(x,{layout:U5e||(U5e=new Qi({visibility:new Ys(Gt.layout_building.visibility),"building-facade":new Vs(Gt.layout_building["building-facade"]),"building-facade-floors":new Vs(Gt.layout_building["building-facade-floors"]),"building-facade-unit-width":new Vs(Gt.layout_building["building-facade-unit-width"]),"building-facade-window":new Vs(Gt.layout_building["building-facade-window"]),"building-roof-shape":new Vs(Gt.layout_building["building-roof-shape"]),"building-height":new Vs(Gt.layout_building["building-height"]),"building-base":new Vs(Gt.layout_building["building-base"]),"building-flood-light-wall-radius":new Vs(Gt.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new Vs(Gt.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new Vs(Gt.layout_building["building-flip-roof-orientation"])})),paint:V5e||(V5e=new Qi({"building-opacity":new Ys(Gt.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new Ys(Gt.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new Ys(Gt.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new Ys(Gt.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new Ys(Gt.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new Ys(Gt.paint_building["building-vertical-scale"]),"building-cast-shadows":new Ys(Gt.paint_building["building-cast-shadows"]),"building-color":new Vs(Gt.paint_building["building-color"]),"building-emissive-strength":new Vs(Gt.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new Ys(Gt.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new Ys(Gt.paint_building["building-cutoff-fade-range"]),"building-front-cutoff":new Ys(Gt.paint_building["building-front-cutoff"]),"building-flood-light-color":new Ys(Gt.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new Ys(Gt.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new Ys(Gt.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new Vs({type:"string",default:"default","property-type":"data-driven"})}))},c,h,g),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(x){return new q5e(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]=x5e(T,g,se,Q,new ns(0,0),P,null,[0,0],1,T.center.lat,x.tileID.canonical),ve=x.queryGeometry;return f5e(le,ue,ve.isPointQuery()?ve.screenBounds:ve.screenGeometry)}},line:class extends Yd{constructor(x,c,h,g){const j=eMe();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=eMe();return g6=new Fut(h.paint.properties["line-width"].specification),g6.useIntegerZoom=!0,g6})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,x)}createBucket(x){return new f7(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=Q5e(this);return{config:new be(this,{zoom:c,lut:h}),defines:g,overrideFog:!1}}queryRadius(x){const c=x,h=tMe(r_("line-width",this,c),r_("line-gap-width",this,c)),g=r_("line-offset",this,c);return h/2+Math.abs(g)+zF(this.paint.get("line-translate"))}queryIntersectsFeature(x,c,h,g,j,T){if(x.queryGeometry.isAboveHorizon)return!1;const P=JCe(x.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),T.angle,x.pixelToTileUnitsFactor),R=x.pixelToTileUnitsFactor/2*tMe(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 ns(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 xTe{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 x7(this.rawTileData)).layers,this.sourceLayerCoder=new xTe(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,(ve,Ce,Ee,Ke)=>hy(g.bufferedTilespaceGeometry,ve-H,Ce-H,Ee+H,Ke+H));se.sort(Kht);let re=null;j.elevation&&se.length>0&&(re=Z3.create(j.elevation,this.tileID));const le={};let ue;for(let ve=0;ve(Ke||(Ke=qr(ze,this.tileID.canonical,T)),nt.queryIntersectsFeature(g,ze,ot,Ke,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&&!Lr(le,se))return;const ue=g.sourceCache,ve=this.sourceLayerCoder.decode(H),Ce=this.vtLayers[ve].feature(R),Ee=this.getId(Ce,ve);for(let Ke=0;Ke`${R.key}: ${R.message}`).join(", ");return void Rr(`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 yTe(x,c,h,g,j){return Ts(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 Kht(x,c){return c-x}function vTe(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}fr(gTe,"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),R7=new Uint16Array(1089);function _Te(x){return x===0?-.03125:x===32?.03125:0}const bTe={Other:0,Symbol:1,FillExtrusion:2},wTe={type:2,extent:sr,loadGeometry:()=>[[new ns(0,0),new ns(8193,0),new ns(8193,8193),new ns(0,8193),new ns(0,0)]]};class Zht{constructor(){this.tasks={},this.taskQueue=[],Xt(["process"],this),this.invoker=new Wht(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===bTe.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 omt(x,c,h){x===1?(c.rgb_color=z7(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 lmt(x,c,h){x===1?c.transform=F7(h,h.readVarint()+h.pos):x===2?c.spread_method=h.readVarint():x===3?c.stops.push(kTe(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 kTe(x,c){return x.readFields(cmt,{offset:0,opacity:255,rgb_color:nxe},c)}function cmt(x,c,h){x===1?c.offset=h.readFloat():x===2?c.opacity=h.readVarint():x===3&&(c.rgb_color=z7(h.readVarint()))}function dmt(x,c,h){x===1?c.transform=F7(h,h.readVarint()+h.pos):x===2?c.spread_method=h.readVarint():x===3?c.stops.push(kTe(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 umt(x,c,h){x===1?c.transform=F7(h,h.readVarint()+h.pos):x===2?c.clip_path_idx=h.readVarint():x===3&&c.children.push(O7(h,h.readVarint()+h.pos))}function hmt(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(O7(h,h.readVarint()+h.pos))}class mmt{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 axe,I6=null;function ixe(x,c,h,g,j){for(const T of g.children)STe(x,c,h,T,j)}function STe(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,ve,Ce){return ue.opacity!==255||ve||Ce}(F,se!=null,Q!=null))return void ixe(T,P,R,F,H);const re=P6(T.canvas.width,T.canvas.height),le=re.getContext("2d");ixe(le,P,R,F,H),se&&ITe(le,P,R,se),Q&<e(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?(CTe(T,R,F,H),TTe(T,R,F,H)):(TTe(T,R,F,H),CTe(T,R,F,H))}(x,c,h,g.path,j),x.restore())}function CTe(x,c,h,g){const j=h.fill;if(!j)return;const T=j.opacity/255;switch(x.save(),x.beginPath(),DTe(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=ATe(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=ETe(x,P,T,g)}}x.fill(MTe(h)),x.restore()}function MTe(x){return x.rule===1?"nonzero":x.rule===2?"evenodd":void 0}function TTe(x,c,h,g){const j=h.stroke;if(!j)return;const T=RTe(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=ATe(x,c.linear_gradients[j.linear_gradient_idx],P,g,!0);break;case"radial_gradient_idx":x.strokeStyle=ETe(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 ATe(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 ETe(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,ve=se;if(j){re=T.transformPoint(re),le=T.transformPoint(le);const Ee=(T.a+T.d)/2;ue=F*Ee,ve=c.r*Ee}const Ce=x.createRadialGradient(re.x,re.y,ue,le.x,le.y,ve);for(const Ee of c.stops)Ce.addColorStop(Ee.offset,Y3(Ee.rgb_color,Ee.opacity*h,g));return Ce}function PTe(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)PTe(P,j,h,F.group);else if(F.path){const H=F.path,Q=new Path2D;Q.addPath(RTe(H),j),P.fill(Q,MTe(H))}const R=g.clip_path_idx!=null?h.clip_paths[g.clip_path_idx]:null;R&&ITe(P,j,h,R),x.globalCompositeOperation="source-over",x.drawImage(T,0,0)}function ITe(x,c,h,g){const j=P6(x.canvas.width,x.canvas.height);PTe(j.getContext("2d"),c,h,g),x.globalCompositeOperation="destination-in",x.drawImage(j,0,0)}function LTe(x,c,h,g,j){if(g.children.length===0)return;const T=g.mask_idx!=null?h.masks[g.mask_idx]:null;T&<e(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,ve=new Path2D;ve.rect(re,le,Q,se),ue.addPath(ve,c),H.clip(ue);for(const Ke of g.children)STe(H,c,h,Ke,j);const Ce=H.getImageData(0,0,P,R),Ee=Ce.data;if(g.mask_type===1)for(let Ke=0;Kec[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 zTe(x,c,h,g,j,T,P,R,F,H,Q){const se=g-x,re=j-c,le=T-h,ue=P-x,ve=R-c,Ce=F-h,Ee=Q[1]*Ce-Q[2]*ve,Ke=Q[2]*ue-Q[0]*Ce,ze=Q[0]*ve-Q[1]*ue,nt=se*Ee+re*Ke+le*ze;if(Math.abs(nt)<1e-15)return null;const ot=1/nt,lt=H[0]-x,It=H[1]-c,jt=H[2]-h,Pt=(lt*Ee+It*Ke+jt*ze)*ot;if(Pt<0||Pt>1)return null;const Ct=It*le-jt*re,Mt=jt*se-lt*le,ss=lt*re-It*se,is=(Q[0]*Ct+Q[1]*Mt+Q[2]*ss)*ot;return is<0||Pt+is>1?null:(ue*Ct+ve*Mt+Ce*ss)*ot}function BTe(x,c,h){return(x-c)/(h-c)}function $Te(x,c,h,g,j,T,P,R,F){const H=1<{const Ke=Ce?1:0,ze=(le+1)*ve-Ke,nt=ue*ve,ot=(ue+1)*ve-Ke;Ee[0]=le*ve,Ee[1]=nt,Ee[2]=ze,Ee[3]=ot};let se=new OTe(F);const re=[];for(let le=0;le=1;F/=2){const le=R[R.length-1];se=new OTe(F);for(let ue=0;ue0;){const{idx:ue,t:ve,nodex:Ce,nodey:Ee,depth:Ke}=le.pop();if(this.leaves[ue]){$Te(Ce,Ee,Ke,c,h,g,j,se,re);const nt=1<=ps[2])return ve}continue}let ze=0;for(let nt=0;nt=H[Q[jt]]&&(Q.splice(jt,0,nt),It=!0);It||(Q[ze]=nt),ze++}}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=$7.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 N3e({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 Cmt(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}"`)}}fr($7,"DEMData"),fr(qTe,"DemMinMaxQuadTree",{omit:["dem"]});var Ip=Uint8Array,L6=Uint16Array,Mmt=Int32Array,VTe=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]),HTe=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]),Tmt=new Ip([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),GTe=function(x,c){for(var h=new L6(31),g=0;g<31;++g)h[g]=c+=1<>1|(21845&ql)<<1;ZTe[ql]=((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(ql=0;ql<144;++ql)R6[ql]=8;for(ql=144;ql<256;++ql)R6[ql]=9;for(ql=256;ql<280;++ql)R6[ql]=7;for(ql=280;ql<288;++ql)R6[ql]=8;var YTe=new Ip(32);for(ql=0;ql<32;++ql)YTe[ql]=5;var Pmt=D6(R6,9),Imt=D6(YTe,5),lxe=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},cxe=function(x,c){var h=c/8|0;return(x[h]|x[h+1]<<8|x[h+2]<<16)>>(7&c)},Lmt=function(x){return(x+7)/8|0},Dmt=["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||Dmt[x]);if(g.code=x,Error.captureStackTrace&&Error.captureStackTrace(g,sg),!h)throw g;return g},Rmt=new Ip(0),Omt=typeof TextDecoder<"u"&&new TextDecoder;try{Omt.decode(Rmt,{stream:!0})}catch{}const Fmt={gzip_data:"gzip"};class zf extends Error{constructor(c){super(c),this.name="MRTError"}}const zmt={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},XTe={uint32:1,uint16:2,uint8:4},Bmt={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let dxe;class q7{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 dxe(h.subarray(0,g)).readFields(gmt,{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 QTe(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 JTe(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 QTe{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=zmt[T],this.dataIndex=R,this.bandShape=[j+2*P,j+2*P,XTe[this.pixelFormat]],this._decodedBlocks=new B7(F?F.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return XTe[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}}}q7.setPbf=function(x){dxe=x};class JTe{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)}}q7.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(ve,Ce){if(!globalThis.DecompressionStream&&Ce==="gzip_data")return Promise.resolve((ot=function(jt){jt[0]==31&&jt[1]==139&&jt[2]==8||sg(6,"invalid gzip data");var Pt=jt[3],Ct=10;4&Pt&&(Ct+=2+(jt[10]|jt[11]<<8));for(var Mt=(Pt>>3&1)+(Pt>>4&1);Mt>0;Mt-=!jt[Ct++]);return Ct+(2&Pt)}(Ee=ve),ot+8>Ee.length&&sg(6,"invalid gzip data"),function(jt,Pt,Ct,Mt){var ss=jt.length;if(!ss||Pt.f&&!Pt.l)return Ct||new Ip(0);var is=!Ct,ms=is||Pt.i!=2,bs=Pt.i;is&&(Ct=new Ip(3*ss));var ps=function(po){var Xd=Ct.length;if(po>Xd){var Tc=new Ip(Math.max(2*Xd,po));Tc.set(Ct),Ct=Tc}},Is=Pt.f||0,es=Pt.p||0,vs=Pt.b||0,Ss=Pt.l,Ls=Pt.d,Ws=Pt.m,mr=Pt.n,er=8*ss;do{if(!Ss){Is=tg(jt,es,1);var Js=tg(jt,es+1,3);if(es+=3,!Js){var Ks=jt[(Za=Lmt(es)+4)-4]|jt[Za-3]<<8,cr=Za+Ks;if(cr>ss){bs&&sg(0);break}ms&&ps(vs+Ks),Ct.set(jt.subarray(Za,cr),vs),Pt.b=vs+=Ks,Pt.p=es=8*cr,Pt.f=Is;continue}if(Js==1)Ss=Pmt,Ls=Imt,Ws=9,mr=5;else if(Js==2){var br=tg(jt,es,31)+257,Br=tg(jt,es+10,15)+4,Tr=br+tg(jt,es+5,31)+1;es+=14;for(var Tn=new Ip(Tr),Na=new Ip(19),An=0;An>4)<16)Tn[An++]=Za;else{var ki=0,oo=0;for(Za==16?(oo=3+tg(jt,es,3),es+=2,ki=Tn[An-1]):Za==17?(oo=3+tg(jt,es,7),es+=3):Za==18&&(oo=11+tg(jt,es,127),es+=7);oo--;)Tn[An++]=ki}}var cc=Tn.subarray(0,br),lo=Tn.subarray(br);Ws=lxe(cc),mr=lxe(lo),Ss=D6(cc,Ws),Ls=D6(lo,mr)}else sg(1);if(es>er){bs&&sg(0);break}}ms&&ps(vs+131072);for(var Eo=(1<>4;if((es+=15&ki)>er){bs&&sg(0);break}if(ki||sg(2),dd<256)Ct[vs++]=dd;else{if(dd==256){Po=es,Ss=null;break}var dc=dd-254;dd>264&&(dc=tg(jt,es,(1<<(zo=VTe[An=dd-257]))-1)+KTe[An],es+=zo);var Kn=Ls[cxe(jt,es)&rl],Su=Kn>>4;if(Kn||sg(3),es+=15&Kn,lo=Emt[Su],Su>3){var zo=HTe[Su];lo+=cxe(jt,es)&(1<er){bs&&sg(0);break}ms&&ps(vs+131072);var Mc=vs+dc;if(vspo.length)&&(Tc=po.length),new Ip(po.subarray(0,Tc))}(Ct,0,vs):Ct.subarray(0,vs)}(Ee.subarray(ot,-8),{i:2},new Ip(((ze=Ee)[(nt=ze.length)-4]|ze[nt-3]<<8|ze[nt-2]<<16|ze[nt-1]<<24)>>>0),Ke)));var Ee,Ke,ze,nt,ot;const lt=Fmt[Ce];if(!lt)throw new Error(`Unhandled codec: ${Ce}`);const It=new globalThis.DecompressionStream(lt);return new Response(new Blob([ve]).stream().pipeThrough(It)).arrayBuffer().then(jt=>new Uint8Array(jt))}(re,se).then(ve=>(function(Ce,Ee){Ce.readFields(jmt,Ee)}(new dxe(ve),le),new Bmt[R](le.buffer))),ue.then(ve=>{for(let Ce=Q.length-1;Ce>=0;Ce--)switch(Q[Ce]){case"delta_filter":kmt(ve,F);break;case"zigzag_filter":Smt(ve);break;case"bitshuffle_filter":Cmt(ve,R);break;default:throw new zf(`Unhandled filter "${Q[Ce]}"`)}return{layerName:j,blockIndex:H,data:ve}}).catch(ve=>{throw ve})}))},fr(JTe,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),fr(q7,"MapboxRasterTile"),fr(QTe,"MapboxRasterLayer",{omit:["_blocksInProgress"]});const eAe=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class uxe{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=eAe[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 uxe(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=eAe.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 hxe(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],Ke=P[2*Ce+1];Ee>=c&&Ee<=g&&Ke>=h&&Ke<=j&&H.push(T[Ce])}continue}const le=re+se>>1,ue=P[2*le],ve=P[2*le+1];ue>=c&&ue<=g&&ve>=h&&ve<=j&&H.push(T[le]),(Q===0?c<=ue:h<=ve)&&(F.push(re),F.push(le-1),F.push(1-Q)),(Q===0?g>=ue:j>=ve)&&(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++)sAe(T[2*Ce],T[2*Ce+1],c,h)<=H&&F.push(j[Ce]);continue}const le=re+se>>1,ue=T[2*le],ve=T[2*le+1];sAe(ue,ve,c,h)<=H&&F.push(j[le]),(Q===0?c-g<=ue:h-g<=ve)&&(R.push(re),R.push(le-1),R.push(1-Q)),(Q===0?c+g>=ue:h+g>=ve)&&(R.push(le+1),R.push(se),R.push(1-Q))}return F}}function hxe(x,c,h,g,j,T){if(j-g<=h)return;const P=g+j>>1;tAe(x,c,P,g,j,T),hxe(x,c,h,g,P-1,1-T),hxe(x,c,h,P+1,j,1-T)}function tAe(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);tAe(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){mxe(x,h,g),mxe(c,2*h,2*g),mxe(c,2*h+1,2*g+1)}function mxe(x,c,h){const g=x[c];x[c]=x[h],x[h]=g}function sAe(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 Zht}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=qm,i.E=Ei,i.F=Q0,i.G=2,i.H=_6,i.I=kc,i.J=_Me,i.K=BC,i.L=jF,i.M=Fw,i.N=zw,i.O=l3,i.P=ns,i.Q=o3,i.R=D0,i.S=oP,i.T=yy,i.U=n2,i.V=L7,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$=x7,i.a0=oc,i.a1=Bw,i.a2=$C,i.a3=O0,i.a4=MP,i.a5=class extends L7{},i.a6=lP,i.a7=iF,i.a8=Gt,i.a9=function(x){const c=x.value;return c?$C(c)?exe(c,!0)?[]:[new L7(x.key,c,`invalid url "${c}"`)]:[new L7(x.key,c,`string expected, "${Fw(c)}" found`)]:[]},i.aA=K5e,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 ns(c,h),max:new ns(g,j)}},i.aC=Oe,i.aD=C,i.aE=pt,i.aF=mt,i.aG=Zu,i.aH=Ns,i.aI=hr,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 x7(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=tTe,i.aT=cTe,i.aU=qt,i.aV=eTe,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_=q7,i.aa=v3,i.ab=Qi,i.ac=Ys,i.ad=class{constructor(x){this.specification=x}possiblyEvaluate(x,c){return sa(x.expression.evaluate(c))}interpolate(x,c,h){return{x:nn(x.x,c.x,h),y:nn(x.y,c.y,h),z:nn(x.z,c.z,h),azimuthal:nn(x.azimuthal,c.azimuthal,h),polar:nn(x.polar,c.polar,h)}}},i.ae=Ka,i.af=W0,i.ag=_r,i.ah=ut,i.ai=ce,i.aj=Ye,i.ak=Kx,i.al=av,i.am=nn,i.an=sr,i.ao=Mp,i.ap=Kr,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:nn(x.x,c.x,h),y:nn(x.y,c.y,h),z:nn(x.z,c.z,h)}}},i.as=function(x,c,h=0,g=!0){const j=new ns(h,h),T=x.sub(j),P=c.add(j),R=[T,new ns(P.x,T.y),P,new ns(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(ot=>F.has(ot.fqid)),ve=(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):{},Ke=Object.keys(Ce).length>0&&!c;Q.hasAppearances=Q.layers.some(ot=>ot.appearances&&ot.appearances.length>0);const ze=Ke?Q.stateDependentLayers:Q.layers;if(Ke&&Q.stateDependentLayers.length!==0||c||ue||g){const ot=this.latestFeatureIndex.loadVTLayers()[re];if(Q.update(Ce,ot,P,Ee,ze,c,R,this.tileID.canonical),(g||ue)&&!c&&Q instanceof eg&&ve&&ve.type==="symbol"){const lt=Q;lt.text&<.text.uboBinder&<.text.uboBinder.updateDynamicExpressions(ve,ot,this.tileID.canonical,P,Ce,R),lt.icon&<.icon.uboBinder&<.icon.uboBinder.updateDynamicExpressions(ve,ot,this.tileID.canonical,P,Ce,R)}if(Q instanceof eg){const lt=Q,It=x.context;lt.text&<.text.uboBinder&<.text.uboBinder.upload(It),lt.icon&<.icon.uboBinder&<.icon.uboBinder.upload(It)}}if(Ke&&Q.stateDependentLayers.length!==0||c||Q.hasAppearances){const ot={zoom:x.transform.zoom,pitch:x.transform.pitch,brightness:x.style.getBrightness()||0,worldview:x.worldview},lt=Q.updateAppearances(this.tileID.canonical,Ce,P,ot,x.imageManager,Ke&&Q.stateDependentLayers.length!==0);if(lt&<.hasUboChanges){const It=x.context;Q instanceof eg&&Q.text&&Q.text.uboBinder&&Q.text.uboBinder.upload(It),Q instanceof eg&&Q.icon&&Q.icon.uboBinder&&Q.icon.uboBinder.upload(It)}}(Q instanceof f7||Q instanceof YF)&&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;ve--){const Ce=4*ve,Ee=d_[Ce+0],Ke=d_[Ce+1],ze=d_[Ce+2],nt=d_[Ce+3],ot=Ee+ze>>1,lt=Ke+nt>>1,It=ot+lt-Ke,jt=lt+Ee-ot,Pt=Ke*vy+Ee,Ct=nt*vy+ze,Mt=lt*vy+ot,ss=Math.hypot((_y[2*Pt+0]+_y[2*Ct+0])/2-_y[2*Mt+0],(_y[2*Pt+1]+_y[2*Ct+1])/2-_y[2*Mt+1])>=16;u_[Mt]=u_[Mt]||(ss?1:0),ve<1022&&(u_[Mt]=u_[Mt]||u_[(Ke+jt>>1)*vy+(Ee+It>>1)]||u_[(nt+jt>>1)*vy+(ze+It>>1)])}const Q=new ld,se=new Ao;let re=0;function le(ve,Ce){const Ee=Ce*vy+ve;return R7[Ee]===0&&(Q.emplaceBack(_y[2*Ee+0],_y[2*Ee+1],ve*sr/Ff,Ce*sr/Ff),R7[Ee]=++re),R7[Ee]-1}function ue(ve,Ce,Ee,Ke,ze,nt){const ot=ve+Ee>>1,lt=Ce+Ke>>1;if(Math.abs(ve-ze)+Math.abs(Ce-nt)>1&&u_[lt*vy+ot])ue(ze,nt,ve,Ce,ot,lt),ue(Ee,Ke,ze,nt,ot,lt);else{const It=le(ve,Ce),jt=le(Ee,Ke),Pt=le(ze,nt);se.emplaceBack(It,jt,Pt)}}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 ld,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=k(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 ve=[le*g.worldSize,ue*g.worldSize,0];ut(ve,ve,T),R=nv(R,ve,P)}return ut(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,ve)=>{const Ce=(le-se)/(ve-1),Ee=(ue-re)/(ve-1),Ke=P.length;for(let ze=0;zeH*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 Ne(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)*zr:0;let T=x!==0||c!==0?Math.atan2(-c,-x)*zr+90:0;return T<0&&(T+=360),[g,T,j]},i.cQ=ae,i.cR=sa,i.cS=Cs,i.cT=oe,i.cU=Ja,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=E5e,i.cY=wfe,i.cZ=R5e,i.c_=exe,i.ca=2,i.cb=7,i.cc=6,i.cd=we,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=I5e,i.cn=N2,i.co=l3e,i.cp=function(x,c,h,g,j,T,P,R,F){if(F.name==="globe")return l3e(x,c,new N2(h,g,j),!1);const H=E2({z:h,x:g,y:j},F);return new Ja([(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 Zt[c]},i.ct=cs,i.cu=Ve,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,Rt,0];return ut(h,h,c),ut(g,g,c),[h[0]>0&&h[0]<=x.width&&h[1]>0&&h[1]<=x.height&&!Upe(x,new qt(x.center.lat,90)),g[0]>0&&g[0]<=x.width&&g[1]>0&&g[1]<=x.height&&!Upe(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=c7,i.cz=Y,i.d=function(x){return ha.API_TILEJSON_REGEX.test(x)},i.d$=Zct,i.d0=ho,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=_7,i.d3=$fe,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=_F,i.d7=Aw,i.d8=ar,i.d9=ir,i.dA=$F,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=d3e,i.dI=ui,i.dJ=Bi,i.dK=Qfe,i.dL=function(x,c){const h=[0,0,0];return ut(h,h,JP(fy(c.canonical))),ut(h,h,x),h},i.dM=x=>({u_matrix:new m(x),u_texsize:new Wm(x),u_pixels_to_tile_units:new D(x),u_device_pixel_ratio:new Sl(x),u_width_scale:new Sl(x),u_floor_width_scale:new Sl(x),u_image:new w2(x),u_units_to_pixels:new Wm(x),u_tile_units_to_pixels:new Sl(x),u_alpha_discard_threshold:new Sl(x),u_trim_offset:new Wm(x),u_trim_fade_range:new Wm(x),u_trim_gradient_mix_range:new Wm(x),u_trim_color:new I3(x),u_zbias_factor:new Sl(x),u_tile_to_meter:new Sl(x),u_ground_shadow_factor:new j2(x),u_pattern_transition:new Sl(x)}),i.dN=x=>({u_matrix:new m(x),u_pixels_to_tile_units:new D(x),u_device_pixel_ratio:new Sl(x),u_width_scale:new Sl(x),u_floor_width_scale:new Sl(x),u_units_to_pixels:new Wm(x),u_dash_image:new w2(x),u_gradient_image:new w2(x),u_image_height:new Sl(x),u_texsize:new Wm(x),u_tile_units_to_pixels:new Sl(x),u_alpha_discard_threshold:new Sl(x),u_trim_offset:new Wm(x),u_trim_fade_range:new Wm(x),u_trim_gradient_mix_range:new Wm(x),u_trim_color:new I3(x),u_zbias_factor:new Sl(x),u_tile_to_meter:new Sl(x),u_ground_shadow_factor:new j2(x)}),i.dO=x=>({u_camera_to_center_distance:new Sl(x),u_extrude_scale:new D(x),u_device_pixel_ratio:new Sl(x),u_matrix:new m(x),u_inv_rot_matrix:new m(x),u_merc_center:new Wm(x),u_tile_id:new j2(x),u_zoom_transition:new Sl(x),u_up_dir:new j2(x),u_emissive_strength:new Sl(x)}),i.dP=BP,i.dQ=Kut,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,ffe(this.format),xfe(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=p3e,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=d3e(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:tdt,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?Z5e(.07,.7,Oe((14-Q.zoom)/5,0,1)):.07,re=h.paint.get("line-trim-color-use-theme").constantOr("default")==="none";return{u_matrix:X5e(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:Y5e(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:Cs(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?Z5e(.07,.7,Oe((14-Q.zoom)/5,0,1)):.07;return{u_matrix:X5e(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:J5e(h)&&c.lineAtlasTexture?c.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Y5e(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:Cs(c.tileID.canonical,0),u_ground_shadow_factor:H}},i.dY=Ut,i.dZ=e6,i.d_=as,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 $ht(x,c):new Ght[x.type](x,c,h,g)},i.df=ys,i.dg=b3,i.dh=MF,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=Fpe,i.dm=class extends Gm{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=Er,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/Kt(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=qF,i.ds=function(x){const c=80.051129;x=Oe(x,-80.051129,c)/c*90;const h=Math.pow(Math.abs(Math.sin(Kr(x))),3);return Math.round(h*(zt.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=K3e(new ns(0,0),new ns(sr,sr),x),g=[];if(c&&!nfe(h,this._globalClipBounds))return g;for(const j of this._activeRegions){if(j.hiddenByOverlap||!nfe(h,j))continue;const T=Odt(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=K3e(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||QF(c.min,h.min)||QF(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||!W3e(h,g)||h.order!==g.order||h.clipMask!==g.clipMask||!$n(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=ld,i.eI=E7,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=i3e,i.ed=$pe,i.ee=Vm,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 Oe((x-c)/(h-c)*(j-g)+g,g,j)},i.ek=Ot,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=sF,i.en=2,i.eo=qe,i.ep=Je,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,ve=P+Q+ue,Ce=0;return ve>0?(Ce=2*Math.sqrt(ve+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=rxe,i.eu=h7,i.ev=u7,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=h3e,i.f1=function(x){const c=[0,0,0],h=w(new Float64Array(16));return C(h,x.pixelMatrix,x.globeMatrix),ut(c,c,h),new ns(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||bF()},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=fr,i.f9=n_,i.fA=mn,i.fB=function(x){let c=0;if(new Uint32Array(x,0,1)[0]!==S5e){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)&&Rr("Invalid b3dm header information.")}return A5e(x,c)},i.fC=function(x,c){const h=wfe(x);for(const g of h){for(const j of g.meshes)put(j);g.lights&&(g.lightMeshIndex=g.meshes.length,g.meshes.push(fut(g.lights,c)))}return h},i.fD=D7,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;gRr(j.message))}).catch(h=>Rr(h.message))}).catch(c=>Rr(c.message))},i.fa=2,i.fb=Vx,i.fc=E2,i.fd=GP,i.fe=xTe,i.ff=gTe,i.fg=H5e,i.fh=Fn,i.fi="hd_road_elevation",i.fj=Ci,i.fk=Ts,i.fl=YF,i.fm=iv,i.fn=zfe,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[ve,Ce]=ue.textSizeScaleRange,[Ee,Ke]=ue.iconSizeScaleRange;ue.textScaleFactor=Oe(ue.scaleFactor,ve,Ce),ue.iconScaleFactor=Oe(ue.scaleFactor,Ee,Ke);const ze=le["text-size"],nt=le["icon-size"];if(x.textSizeData.kind==="composite"){const{minZoom:Ct,maxZoom:Mt}=x.textSizeData;ue.compositeTextSizes=[ze.possiblyEvaluate(new Ka(Ct,{worldview:Q}),T),ze.possiblyEvaluate(new Ka(Mt,{worldview:Q}),T)]}if(x.iconSizeData.kind==="composite"){const{minZoom:Ct,maxZoom:Mt}=x.iconSizeData;ue.compositeIconSizes=[nt.possiblyEvaluate(new Ka(Ct,{worldview:Q}),T,se),nt.possiblyEvaluate(new Ka(Mt,{worldview:Q}),T,se)]}ue.layoutTextSize=ze.possiblyEvaluate(new Ka(P+1,{worldview:Q}),T),ue.layoutIconSize=nt.possiblyEvaluate(new Ka(P+1,{worldview:Q}),T,se),ue.textMaxSize=ze.possiblyEvaluate(new Ka(18,{worldview:Q}),T);const ot=re.get("symbol-placement"),lt=re.get("text-rotation-alignment")==="map"&&ot!=="point",It=re.get("text-size");let jt=!1;const Pt=[];for(const Ct of x.features){const Mt=re.get("text-font").evaluate(Ct,{},T).join(","),ss=It.evaluate(Ct,{},T)*ue.textScaleFactor,is=ue.layoutTextSize.evaluate(Ct,{},T)*ue.textScaleFactor,ms=ue.layoutIconSize.evaluate(Ct,{},T,se)*ue.iconScaleFactor,bs={horizontal:{},vertical:void 0},ps=Ct.text;let Is,es=[0,0];if(ps){const Vn=ps.toString(),mo=re.get("text-letter-spacing").evaluate(Ct,{},T)*lc,Za=re.get("text-line-height").evaluate(Ct,{},T)*lc,Da=Npe(Vn)?mo:0,ki=re.get("text-anchor").evaluate(Ct,{},T),oo=re.get("text-variable-anchor");if(!oo){const Po=re.get("text-radial-offset").evaluate(Ct,{},T);if(Po)es=AMe(ki,[Po*lc,Ufe]);else{const dd=re.get("text-offset").evaluate(Ct,{},T);es=[dd[0]*lc,dd[1]*lc]}}let cc=lt?"center":re.get("text-justify").evaluate(Ct,{},T);const lo=ot==="point",Eo=lo?re.get("text-max-width").evaluate(Ct,{},T)*lc:1/0,rl=Po=>{x.allowVerticalPlacement&&_P(Vn)&&(bs.vertical=Pfe(ps,c,h,j,Mt,Eo,Za,ki,Po,Da,es,am.vertical,!0,is,ss,F,ue.textScaleFactor))};if(!lt&&oo){const Po=cc==="auto"?oo.map(dc=>Vfe(dc)):[cc];let dd=!1;for(let dc=0;dc=0||!_P(Vn)){const Po=Pfe(ps,c,h,j,Mt,Eo,Za,ki,cc,Da,es,am.horizontal,!1,is,ss,F,ue.textScaleFactor);Po&&(bs.horizontal[cc]=Po)}rl(lo?"left":cc)}}let vs,Ss,Ls,Ws,mr,er,Js=!1;const Ks=re.get("icon-text-fit").evaluate(Ct,{},T);if(Ct.icon&&Ct.icon.hasPrimary()){const Vn=j6(Ct.icon,x.iconSizeData,le["icon-size"],T,x.zoom,Ct,F,ue.iconScaleFactor,Q,se);vs=Vn.iconPrimary,Ls=Vn.iconSecondary;const mo=vs.toString();if(Ss=g.get(mo),Ss&&(mr=re.get("icon-offset").evaluate(Ct,{},T),er=re.get("icon-anchor").evaluate(Ct,{},T),Is=y7(j.get(mo),Ls?j.get(Ls.toString()):void 0,mr,er),Js=Ss.sdf,x.sdfIcons===void 0?x.sdfIcons=Ss.sdf:x.sdfIcons!==Ss.sdf&&Rr("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(Ss.pixelRatio!==x.pixelRatio||re.get("icon-rotate").constantOr(1)!==0)&&(x.iconsNeedLinear=!0)),Ls){const Za=Ls.toString();Ws=g.get(Za)}}jt=jt||!(!Ct.icon||!Ct.icon.hasSecondary());const cr=k7(bs.horizontal)||bs.vertical;x.iconsInText||(x.iconsInText=!!cr&&cr.iconsInText);const br=is*ue.textScaleFactor/lc,{defaultShapedIcon:Br,verticallyShapedIcon:Tr}=kht(x,Is,re,Ct,T,bs,br,mr,Ks);Ks!=="none"&&Is&&(hMe(Is)||mMe(Is))&&(N7(0,Ss,vs,Is,Br,Ks,H,g,j),N7(0,Ws,Ls,Is,Br,Ks,H,g,j),Tr&&(N7(0,Ss,vs,Is,Tr,Ks,H,g,j),N7(0,Ws,Ls,Is,Tr,Ks,H,g,j))),Is=Br;const{iconBBox:Tn,iconVerticalBBox:Na,textBBox:An,textVerticalBBox:Ca}=_ht(x,Is,Tr,re,Ct,T,ms,mr,ue,j,er,bs,is,es,se);Pt.push({feature:Ct,shapedTextOrientations:bs,shapedText:cr,shapedIcon:Is,iconPrimary:vs,iconSecondary:Ls,iconOffset:mr,iconAnchor:er,verticallyShapedIcon:Tr,layoutTextSize:is,layoutIconSize:ms,textOffset:es,isSDFIcon:Js,iconTextFit:Ks,iconCollisionBounds:Tn,iconVerticalCollisionBounds:Na,textCollisionBounds:An,textVerticalCollisionBounds:Ca})}return{featureData:Pt,sizes:ue,hasAnySecondaryIcon:jt,textAlongLine:lt,symbolPlacement:ot}},i.fr=Bfe,i.fs=Ffe,i.ft=wMe,i.fu=jMe,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 ve of Q){const{shapedIcon:Ce,verticallyShapedIcon:Ee,feature:Ke,shapedTextOrientations:ze,shapedText:nt,layoutTextSize:ot,textOffset:lt,isSDFIcon:It,iconPrimary:jt,iconSecondary:Pt,iconTextFit:Ct,iconOffset:Mt,iconCollisionBounds:ss,iconVerticalCollisionBounds:is,textCollisionBounds:ms}=ve;LMe(Ce,H.iconPositions,jt,Pt),LMe(Ee,H.iconPositions,jt,Pt),Nht(ze,H.iconPositions),jht(jt,Pt,H.iconPositions),(nt||Ce)&&Sht(x,Ke,ze,Ce,Ee,F,re,ot,0,lt,It,g,j,P,R,se,Ct,Mt,le,ue,ss,is,ms)}h&&x.generateCollisionDebugBuffers(T,x.collisionBoxArray,re.textScaleFactor)},i.fw=f7,i.fx=$a,i.fy=function(x){return x<=1?1:Math.pow(2,Math.floor(Math.log2(x)))},i.fz=$7,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=Ht,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=Rr,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[ir.id]),Ht=Tt[0];if(Ht.visibility==="none")continue;const Ut=Ht.source||"";let Xt=this.familiesBySource[Ut];Xt||(Xt=this.familiesBySource[Ut]=Object.create(null));const Ts=Ht.sourceLayer||"_geojsonTileLayer";let ys=Xt[Ts];ys||(ys=Xt[Ts]=[]),ys.push(Tt)}}}const b=1*d.fa;class N{constructor(Se){const Oe={},Ye=[];for(const Ht in Se){const Ut=Se[Ht],Xt=Oe[Ht]={};for(const Ts in Ut.glyphs){const ys=Ut.glyphs[+Ts];if(!ys||ys.bitmap.width===0||ys.bitmap.height===0)continue;const ir=ys.metrics.localGlyph?b:1,Lr={x:0,y:0,w:ys.bitmap.width+2*ir,h:ys.bitmap.height+2*ir};Ye.push(Lr),Xt[Ts]=Lr}}const{w:yt,h:bt}=d.J(Ye),Tt=new d.f9({width:yt||1,height:bt||1});for(const Ht in Se){const Ut=Se[Ht];for(const Xt in Ut.glyphs){const Ts=Ut.glyphs[+Xt];if(!Ts||Ts.bitmap.width===0||Ts.bitmap.height===0)continue;const ys=Oe[Ht][Xt],ir=Ts.metrics.localGlyph?b:1;d.f9.copy(Ts.bitmap,Tt,{x:0,y:0},{x:ys.x+ir,y:ys.y+ir},Ts.bitmap)}}this.image=Tt,this.positions=Oe}}function w(Bt,Se,Oe){Bt[Se]?Oe&&(Bt[Se].center=Oe):Bt[Se]={floorIds:new Set,center:Oe||[0,0],floors:{}}}function k(Bt,Se,Oe,Ye){for(const yt of Se)w(Bt,yt),Bt[yt].floors[Oe]=Ye,Bt[yt].floorIds.add(Oe)}function C(Bt){return{id:Bt.properties.id.toString(),center:[Bt.properties.center_lon||0,Bt.properties.center_lat||0]}}function A(Bt,Se){const Oe=Bt.properties.id.toString(),Ye=!!Bt.properties.is_default&&Bt.properties.is_default,yt=Bt.properties.connected_floor_ids?new Set(Bt.properties.connected_floor_ids.toString().split(";")):new Set,bt=Bt.properties.conflicted_floor_ids?new Set(Bt.properties.conflicted_floor_ids.toString().split(";")):new Set,Tt=Bt.properties.structure_ids?new Set(Bt.properties.structure_ids.toString().split(";")):new Set,Ht=Bt.properties.name.toString(),Ut=Bt.properties.z_index,Xt=function(Ts,ys){const ir=Ts.loadGeometry();if(!ir||ir.length===0)return;const Lr=ir.map(Hr=>Hr.map(Rr=>d.fb(Rr,ys,Ts.extent)));return Lr.length===0?void 0:{type:"Polygon",coordinates:[Lr[0]]}}(Bt,Se);return{id:Oe,isDefault:Ye,connections:yt,conflicts:bt,buildings:Tt,name:Ht,zIndex:Ut,geometry:Xt}}function I(Bt,Se){return Se.every(Oe=>Bt.properties&&Bt.properties[Oe]!=null)}function L(Bt){return I(Bt,["type","id","name"])&&Bt.properties.type==="structure"}function O(Bt){return I(Bt,["type","id","name","z_index"])&&Bt.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,Oe,Ye,yt,bt,Tt){this.status="parsing",this.data=Se,this.collisionBoxArray=new d.fd;const Ht=new d.fe(Object.keys(Se.layers).sort()),Ut=new d.ff(this.tileID,this.promoteId);Ut.bucketLayerIDs=[];const Xt={},Ts=new d.fg(256,256),ys={featureIndex:Ut,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:Ts,availableImages:Ye,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};this.indoor&&(ys.activeFloors=function(Rr,un,Wn,sa){const ua=un.indoorState.activeFloorsVisible;if(!un.sourceLayers)return ua?un.indoorState.activeFloors:void 0;const To=function(ii,zi){if(!ii)return d.w("No source layers defined in indoor specification"),zi;if(ii.size===0)return zi;const tl=ii.difference(zi);for(const ui of tl)d.w(`Missing source layer required in indoor specification: ${ui}`);return zi.intersection(zi)}(un.sourceLayers,new Set(Object.keys(Rr.layers))),wo=un.indoorState,Yi=function(ii,zi,tl,ui,Bi){const Xi={};for(const ha of zi){const sl=ii.layers[ha];if(sl)for(let ac=0;ac=ui.maxzoom||ui.visibility==="none")continue;q(tl,this.zoom,ys.brightness,Ye,this.worldview,ys.activeFloors);const Bi=Xt[ui.id]=ui.createBucket({index:Ut.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:Ye,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords,disableSymbolUBO:this.disableSymbolUBO});Ut.bucketLayerIDs.push(tl.map(ha=>d.F(ha.id,ha.scope)));let Xi=Bi.prepare?Bi.prepare():null;Xi!=null?(Xi=Xi.then(()=>Bi.populate(Yi,ys,this.tileID.canonical,this.tileTransform)),ir.push(Xi)):Bi.populate(Yi,ys,this.tileID.canonical,this.tileTransform)}}const Hr=()=>{Ts.trim();const Rr=!(!ys.elevationFeatures||!ys.elevationFeatures.some(ui=>ui.heightRange.min<0));let un,Wn,sa,ua,To,wo,Yi;const ii={type:"maybePrepare",renderSourceType:this.renderSourceType,zoom:this.zoom},zi=()=>{if(un)return this.status="done",Tt(un);if(this.extraShadowCaster)this.status="done",Tt(null,{buckets:Object.values(Xt).filter(ui=>!ui.isEmpty()),featureIndex:Ut,collisionBoxArray:null,hasTunnelGeometry:Rr,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:ys.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(Wn&&sa&&ua&&Yi){const Bi=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,ys.brightness,Ye,this.worldview,ys.activeFloors),ha[ac]=d.fq(ic,Wn,Bi.positions,sa,Xi,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,To,this.worldview,Ye))}const sl={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(bt,sa,To,()=>{sl.iconsPending=!1,tl(ha,Bi,sl,void 0,Yi)}),this.rasterizeIfNeeded(bt,ua,wo,()=>{sl.patternsPending=!1,tl(ha,Bi,sl,void 0,Yi)})}},tl=(ui,Bi,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 Tt(null,{buckets:Object.values(Xt).filter(wu=>!wu.isEmpty()),featureIndex:Ut,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:Rr,glyphAtlasImage:Bi.image,lineAtlas:Ts,imageAtlas:null,brightness:ys.brightness});const bu=(wu,Om)=>{for(const kd in Xt){const ju=Xt[kd];if(kd in ui)d.fv(ju,ui[kd],this.showCollisionBoxes,Ye,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,sa,Om);else if(ju.hasPattern&&(ju instanceof d.fw||ju instanceof d.fl||ju instanceof d.e0)){q(ju.layers,this.zoom,ys.brightness,Ye,this.worldview,ys.activeFloors);const Fm=Object.fromEntries(Om.patternPositions);ju.addFeatures(ys,this.tileID.canonical,Fm,Ye,this.tileTransform,this.brightness)}}this.status="done",Tt(null,{buckets:Object.values(Xt).filter(kd=>!kd.isEmpty()),featureIndex:Ut,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:Rr,glyphAtlasImage:Bi.image,lineAtlas:Ts,imageAtlas:wu,brightness:ys.brightness})};if(ac){const wu=new Map,Om=d.fr(sa,wu),kd=d.fr(ua,wu),ju=new d.fs(Om,kd,sl,this.lut,wu);bt.send("checkAtlasCache",{descriptor:ju,scope:this.scope},(Fm,Wu)=>{let zm,Sd;if(Fm&&d.w(`[Worker] Error checking atlas cache: ${Fm.message}`),Wu)zm=new d.ft(Wu.sourceHash),Sd=Wu;else{const Cd=new d.fu(sa,ua,this.lut,sl);zm=Cd,Sd=Cd}bu(zm,Sd)})}else bu(null,{iconPositions:new Map,patternPositions:new Map})};if(!this.extraShadowCaster){const ui=d.fk(ys.glyphDependencies,ha=>Object.keys(ha).map(Number));Object.keys(ui).length?bt.send("getGlyphs",{uid:this.uid,stacks:ui},(ha,sl)=>{un||(un=ha,Wn=sl,zi())},void 0,!1,ii):Wn={},Yi=new Map;const Bi=Array.from(ys.iconDependencies.keys()).map(ha=>d.I.parse(ha));Bi.length?bt.send("getImages",{images:Bi,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(ha,sl)=>{if(!un){un=ha,sa=new Map,To=this.updateImageMapAndGetImageTaskQueue(sa,sl.images,ys.iconDependencies);for(const[ac,ic]of sl.versions.entries())Yi.set(ac,ic);zi()}},void 0,!1,ii):(sa=new Map,To=new Map);const Xi=Array.from(ys.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(!un){un=ha,ua=new Map,wo=this.updateImageMapAndGetImageTaskQueue(ua,sl.images,ys.patternDependencies);for(const[ac,ic]of sl.versions.entries())Yi.set(ac,ic);zi()}},void 0,!1,ii):(ua=new Map,wo=new Map)}if(ys.elevationFeatures&&ys.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 Bi=d.fm.evaluate(ui);for(const Xi of Object.values(Xt))if(Xi instanceof d.fl){const ha=Se.layers[Ht.decode(Xi.sourceLayerIndex)];Xi.setEvaluatedPortalGraph(Bi,ha,this.tileID.canonical,ys.availableImages,ys.brightness)}}zi()};ir.length>0?Promise.allSettled(ir).then(Hr).catch(Tt):Hr()}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,Oe,Ye,yt){Array.from(Oe.values()).some(bt=>bt.usvg)?this.rasterize(Se,Oe,Ye,yt):yt()}updateImageMapAndGetImageTaskQueue(Se,Oe,Ye){const yt=new Map;for(const bt of Oe.keys()){const Tt=Ye.get(bt)||[];for(const Ht of Tt){const Ut=Ht.toString(),Xt=Oe.get(Ht.id.toString());Xt.usvg?yt.has(Ut)||(yt.set(Ut,Ht),Se.set(Ut,Object.assign({},Xt))):Se.set(Ut,Xt)}}return yt}rasterize(Se,Oe,Ye,yt){this.rasterizeTask=Se.send("rasterizeImages",{scope:this.scope,tasks:Ye},(bt,Tt)=>{if(!bt)for(const[Ht,Ut]of Tt.entries()){const Xt=Object.assign(Oe.get(Ht),{data:Ut});Oe.set(Ht,Xt)}yt()})}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function q(Bt,Se,Oe,Ye,yt,bt){const Tt=new d.ae(Se,{brightness:Oe,worldview:yt,activeFloors:bt});for(const Ht of Bt)Ht.recalculate(Tt,Ye)}class B extends d.E{constructor({actor:Se,layerIndex:Oe,availableImages:Ye,availableModels:yt,isSpriteLoaded:bt,tileProvider:Tt,brightness:Ht,maxUniformBufferBindings:Ut,maxUniformBlockSizeDwords:Xt,disableSymbolUBO:Ts}){super(),this.actor=Se,this.layerIndex=Oe,this.availableImages=Ye,this.availableModels=yt,this.loadVectorData=d.aO,this.tileProvider=Tt,this.loading={},this.loaded={},this.deduped=new d.aN(Se.scheduler),this.isSpriteLoaded=bt,this.scheduler=Se.scheduler,this.brightness=Ht,this.maxUniformBufferBindings=Ut,this.maxUniformBlockSizeDwords=Xt,this.disableSymbolUBO=Ts}loadTileData(Se,Oe){if(!this.tileProvider)return this.loadVectorData(Se,Oe);const Ye=new AbortController,{z:yt,x:bt,y:Tt}=Se.tileID.canonical;return this.tileProvider.loadTile({z:yt,x:bt,y:Tt},{request:Se.request,signal:Ye.signal}).then(Ht=>{if(Ye.signal.aborted)return;if(Ht==null){const Xt=new Error("Tile not found");return Xt.status=404,Oe(Xt)}if(Ht.data===null)return Oe(null,null);const Ut=new Map;Ht.expires&&Ut.set("expires",Ht.expires),Ht.cacheControl&&Ut.set("cache-control",Ht.cacheControl),Oe(null,{rawData:Ht.data,responseHeaders:Ut})}).catch(Ht=>{Ye.signal.aborted||Oe(Ht instanceof Error?Ht:new Error(String(Ht)))}),()=>Ye.abort()}loadTile(Se,Oe){const Ye=Se.uid,yt=Se&&Se.request,bt=yt&&yt.collectResourceTiming,Tt=this.loading[Ye]=new V(Se);Tt.maxUniformBufferBindings=this.maxUniformBufferBindings,Tt.maxUniformBlockSizeDwords=this.maxUniformBlockSizeDwords,Tt.disableSymbolUBO=this.disableSymbolUBO,Tt.abort=this.loadTileData(Se,(Ht,Ut)=>{const Xt=!this.loading[Ye];if(delete this.loading[Ye],Tt.cancelRasterize(),Xt||Ht||!Ut)return Tt.status="done",Xt||(this.loaded[Ye]=Tt),Oe(Ht);const Ts=Ut.rawData,ys={},ir=d.aP(Ut.responseHeaders);ir&&ir.expires&&(ys.expires=ir.expires),ir&&ir.cacheControl&&(ys.cacheControl=ir.cacheControl),Tt.vectorTile=Ut.vectorTile||new d.fx(new d.a$(Ts));const Lr=()=>{Tt.parse(Tt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(Hr,Rr)=>{if(Hr||!Rr)return Oe(Hr);const un={};if(bt){const Wn=u(yt);Wn.length>0&&(un.resourceTiming=JSON.parse(JSON.stringify(Wn)))}Oe(null,Object.assign({rawTileData:Ts.slice(0),responseHeaders:Ut.responseHeaders},Rr,ys,un))})};this.isSpriteLoaded?Lr():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(Lr,{type:"parseTile",renderSourceType:Se.renderSourceType,zoom:Se.tileZoom}):Lr()}),this.loaded=this.loaded||{},this.loaded[Ye]=Tt})}reloadTile(Se,Oe){const Ye=this.loaded,yt=Se.uid;if(Ye&&Ye[yt]){const bt=Ye[yt];bt.updateParameters(Se);const Tt=(Ht,Ut)=>{const Xt=bt.reloadCallback;Xt&&(delete bt.reloadCallback,bt.parse(bt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Xt)),Oe(Ht,Ut)};bt.status==="parsing"?bt.reloadCallback=Tt:bt.status==="done"&&(bt.vectorTile?bt.parse(bt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Tt):Tt())}else Oe(null,void 0)}abortTile(Se,Oe){const Ye=Se.uid,yt=this.loading[Ye];yt&&(yt.abort&&yt.abort(),delete this.loading[Ye]),Oe()}removeTile(Se,Oe){const Ye=this.loaded,yt=Se.uid;Ye&&Ye[yt]&&delete Ye[yt],Oe()}}class U{constructor(Se){this.loading={}}loadTile(Se,Oe){const Ye=Se.uid,{cancel:yt}=d.b1(Se.request,(bt,Tt,Ht)=>{const Ut=!this.loading[Ye];if(delete this.loading[Ye],Ut||bt||!Tt)return Oe(bt);this.decodeTile(Ye,Tt,Se.encoding).then(Xt=>{const{expires:Ts,cacheControl:ys}=d.aP(Ht);Oe(null,Object.assign(Xt,{expires:Ts,cacheControl:ys}))}).catch(Xt=>Oe(Xt))});this.loading[Ye]={cancel:yt}}async decodeTile(Se,Oe,Ye){const yt=await createImageBitmap(new Blob([new Uint8Array(Oe)],{type:"image/png"})),bt=1-(yt.width-d.fy(yt.width))/2,Tt=bt<1,Ht=this.getImageData(yt,bt);return yt.close(),{dem:new d.fz(Se,Ht,Ye,Tt),borderReady:Tt}}reloadTile(Se,Oe){Oe(null,null)}abortTile(Se,Oe){const Ye=Se.uid,yt=this.loading[Ye];yt&&(yt.cancel(),delete this.loading[Ye]),Oe()}removeTile(Se,Oe){Oe()}getImageData(Se,Oe){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 Ye=this.offscreenCanvasContext.getImageData(-Oe,-Oe,Se.width+2*Oe,Se.height+2*Oe);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),Ye}}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,Oe){const Ye=this._mrt;this.status="parsing",this._entireBuffer=Se;try{Ye.parseHeader(Se),this._isHeaderLoaded=!0;const yt=[];for(const bt in Ye.layers){const Tt=Ye.getLayer(bt),Ht=Tt.getDataRange(Tt.getBandList()),Ut=Ye.createDecodingTask(Ht),Xt=Se.slice(Ht.firstByte,Ht.lastByte+1),Ts=d.a_.performDecoding(Xt,Ut).then(ys=>Ut.complete(null,ys)).catch(ys=>Ut.complete(ys,null));yt.push(Ts)}Promise.allSettled(yt).then(()=>Oe(null,Ye)).catch(bt=>Oe(bt))}catch(yt){Oe(yt)}}}class Y{constructor({actor:Se}){this.actor=Se,this.loading={},this.loaded={}}loadTile(Se,Oe){const Ye=Se.uid,yt=Se.request,bt=this.loading[Ye]=new te(Se),{cancel:Tt}=d.b1(yt,(Ht,Ut,Xt)=>{const Ts=!this.loading[Ye];if(delete this.loading[Ye],Ts||Ht||!Ut)return bt.status="done",Ts||(this.loaded[Ye]=bt),Oe(Ht);bt.parse(Ut,(ys,ir)=>{if(ys||!ir)return Oe(ys);Oe(null,ir,Xt)}),this.loaded[Ye]=bt});bt.abort=Tt}reloadTile(Se,Oe){Oe(null,void 0)}abortTile(Se,Oe){const Ye=Se.uid,yt=this.loading[Ye];yt&&(yt.abort&&yt.abort(),delete this.loading[Ye]),Oe()}removeTile(Se,Oe){const Ye=Se.uid;this.loaded[Ye]&&delete this.loaded[Ye],Oe()}decodeRasterArray(Se,Oe){d.a_.performDecoding(Se.buffer,Se.task).then(Ye=>Oe(null,Ye)).catch(Ye=>Oe(Ye))}}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 Oe of this._feature.geometry)Se.push([new d.P(Oe[0],Oe[1])]);return Se}{const Se=[];for(const Oe of this._feature.geometry){const Ye=[];for(const yt of Oe)Ye.push(new d.P(yt[0],yt[1]));Se.push(Ye)}return Se}}toGeoJSON(Se,Oe,Ye){return J.call(this,Se,Oe,Ye)}}class ce{constructor(Se,Oe){this.name=Se,this.extent=d.an,this.length=Oe.length,this._jsonFeatures=Oe}feature(Se){return new X(this._jsonFeatures[Se])}}class ae{constructor(Se){this.layers={},this.extent=d.an;for(const Oe of Object.keys(Se))this.layers[Oe]=new ce(Oe,Se[Oe])}}const ie=64/4096;class oe{constructor(){this.features=new Map}clear(){this.features.clear()}load(Se=[],Oe){for(const Ye of Se){const yt=Ye.id;if(yt==null)continue;let bt=this.features.get(yt);bt&&this.updateCache(bt,Oe),Ye.geometry?(bt=ye(Ye),this.updateCache(bt,Oe),this.features.set(yt,bt)):this.features.delete(yt),this.updateCache(bt,Oe)}}updateCache(Se,Oe){for(const{canonical:Ye,uid:yt}of Object.values(Oe)){const{z:bt,x:Tt,y:Ht}=Ye;me(Se,Math.pow(2,bt),Tt,Ht)&&delete Oe[yt]}}getTile(Se,Oe,Ye){const yt=Math.pow(2,Se),bt=[];for(const Tt of this.features.values())me(Tt,yt,Oe,Ye)&&bt.push(Ue(Tt,yt,Oe,Ye));return{features:bt}}getFeatures(){return[...this.features.values()]}}function me({minX:Bt,minY:Se,maxX:Oe,maxY:Ye},yt,bt,Tt){return Bt<(bt+1+ie)/yt&&Se<(Tt+1+ie)/yt&&Oe>(bt-ie)/yt&&Ye>(Tt-ie)/yt}function ye(Bt){const{id:Se,geometry:Oe,properties:Ye}=Bt;if(!Oe)return;if(Oe.type==="GeometryCollection")throw new Error("GeometryCollection not supported in dynamic mode.");const{type:yt,coordinates:bt}=Oe,Tt={id:Se,type:1,geometry:[],tags:Ye,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},Ht=Tt.geometry;if(yt==="Point")he(bt,Ht,Tt);else if(yt==="MultiPoint")for(const Ut of bt)he(Ut,Ht,Tt);else if(yt==="LineString")Tt.type=2,ge(bt,Ht,Tt);else if(yt==="MultiLineString")Tt.type=2,Ne(bt,Ht,Tt);else if(yt==="Polygon")Tt.type=3,Ne(bt,Ht,Tt,!0);else{if(yt!=="MultiPolygon")throw new Error("Input data is not a valid GeoJSON object.");Tt.type=3;for(const Ut of bt)Ne(Ut,Ht,Tt,!0)}return Tt}function he([Bt,Se],Oe,Ye){const yt=d.aH(Bt);let bt=d.aL(Se);bt=bt<0?0:bt>1?1:bt,Oe.push(yt,bt),Ye.minX=Math.min(Ye.minX,yt),Ye.minY=Math.min(Ye.minY,bt),Ye.maxX=Math.max(Ye.maxX,yt),Ye.maxY=Math.max(Ye.maxY,bt)}function ge(Bt,Se,Oe,Ye=!1,yt=!1){const bt=[];for(const Tt of Bt)he(Tt,bt,Oe);Se.push(bt),Ye&&function(Tt,Ht){let Ut=0;for(let Xt=0,Ts=Tt.length,ys=Ts-2;Xt0===Ht)for(let Xt=0,Ts=Tt.length;Xt=Tt&&ys>=Tt||(Xt>=Tt?(Ts+=Math.round(Hr*((Tt-Xt)/Lr)),Xt=Tt):ys>=Tt&&(ir=Ts+Math.round(Hr*((Tt-Xt)/Lr)),ys=Tt),Ts>=Tt&&ir>=Tt||(Ts>=Tt?(Xt+=Math.round(Lr*((Tt-Ts)/Hr)),Ts=Tt):ir>=Tt&&(ys=Xt+Math.round(Lr*((Tt-Ts)/Hr)),ir=Tt),Ht&&Xt===Ht[Ht.length-1][0]&&Ts===Ht[Ht.length-1][1]||(Ht=[[Xt,Ts]],yt.push(Ht)),Ht.push([ys,ir])))))}}function Me(Bt,Se,Oe,Ye,yt){const bt=(Oe-ie)/Se,Tt=(Ye-ie)/Se,Ht=(Oe+1+ie)/Se,Ut=(Ye+1+ie)/Se;function Xt(ir,Lr){let Hr=0;return irHt&&(Hr|=2),LrUt&&(Hr|=8),Hr}let Ts=[];for(let ir=1;ir<=8;ir*=2){let Lr=Bt[Bt.length-2],Hr=Bt[Bt.length-1],Rr=!(Xt(Lr,Hr)&ir);for(let un=0;un>31}function we(Bt,Se){const{geometry:Oe,type:Ye}=Bt;let yt=0,bt=0;if(Ye===1){Se.writeVarint($e(1,Oe.length));for(const Tt of Oe){const Ht=Tt[0]-yt,Ut=Tt[1]-bt;Se.writeVarint(Be(Ht)),Se.writeVarint(Be(Ut)),yt+=Ht,bt+=Ut}}else for(const Tt of Oe){if(Tt.length===0)continue;Se.writeVarint($e(1,1));const Ht=Tt.length-(Ye===3?1:0);for(let Ut=0;UtBt},He=Math.fround||(et=new Float32Array(1),Bt=>(et[0]=+Bt,et[0]));var et;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:Oe,minZoom:Ye,maxZoom:yt}=this.options;Oe&&console.time("total time");const bt=`prepare ${Se.length} points`;Oe&&console.time(bt),this.points=Se;const Tt=[];for(let Ut=0;Ut=Ye;Ut--){const Xt=+Date.now();Ht=this.trees[Ut]=this._createTree(this._cluster(Ht,Ut)),Oe&&console.log("z%d: %d clusters in %dms",Ut,Ht.numItems,+Date.now()-Xt)}return Oe&&console.timeEnd("total time"),this}getClusters(Se,Oe){let Ye=((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 Tt=Math.max(-90,Math.min(90,Se[3]));if(Se[2]-Se[0]>=360)Ye=-180,bt=180;else if(Ye>bt){const ys=this.getClusters([Ye,yt,180,Tt],Oe),ir=this.getClusters([-180,yt,bt,Tt],Oe);return ys.concat(ir)}const Ht=this.trees[this._limitZoom(Oe)],Ut=Ht.range(We(Ye),it(Tt),We(bt),it(yt)),Xt=Ht.data,Ts=[];for(const ys of Ut){const ir=this.stride*ys;Ts.push(Xt[ir+5]>1?_e(Xt,ir,this.clusterProps):this.points[Xt[ir+3]])}return Ts}getChildren(Se){const Oe=this._getOriginId(Se),Ye=this._getOriginZoom(Se),yt="No cluster with the specified id.",bt=this.trees[Ye];if(!bt)throw new Error(yt);const Tt=bt.data;if(Oe*this.stride>=Tt.length)throw new Error(yt);const Ht=this.options.radius/(this.options.extent*Math.pow(2,Ye-1)),Ut=bt.within(Tt[Oe*this.stride],Tt[Oe*this.stride+1],Ht),Xt=[];for(const Ts of Ut){const ys=Ts*this.stride;Tt[ys+4]===Se&&Xt.push(Tt[ys+5]>1?_e(Tt,ys,this.clusterProps):this.points[Tt[ys+3]])}if(Xt.length===0)throw new Error(yt);return Xt}getLeaves(Se,Oe,Ye){const yt=[];return this._appendLeaves(yt,Se,Oe=Oe||10,Ye=Ye||0,0),yt}getTile(Se,Oe,Ye){const yt=this.trees[this._limitZoom(Se)],bt=Math.pow(2,Se),{extent:Tt,radius:Ht}=this.options,Ut=Ht/Tt,Xt=(Ye-Ut)/bt,Ts=(Ye+1+Ut)/bt,ys={features:[]};return this._addTileFeatures(yt.range((Oe-Ut)/bt,Xt,(Oe+1+Ut)/bt,Ts),yt.data,Oe,Ye,bt,ys),Oe===0&&this._addTileFeatures(yt.range(1-Ut/bt,Xt,1,Ts),yt.data,bt,Ye,bt,ys),Oe===bt-1&&this._addTileFeatures(yt.range(0,Xt,Ut/bt,Ts),yt.data,-1,Ye,bt,ys),ys.features.length?ys:null}getClusterExpansionZoom(Se){let Oe=this._getOriginZoom(Se)-1;for(;Oe<=this.options.maxZoom;){const Ye=this.getChildren(Se);if(Oe++,Ye.length!==1)break;Se=Ye[0].properties.cluster_id}return Oe}_appendLeaves(Se,Oe,Ye,yt,bt){const Tt=this.getChildren(Oe);for(const Ht of Tt){const Ut=Ht.properties;if(Ut&&Ut.cluster?bt+Ut.point_count<=yt?bt+=Ut.point_count:bt=this._appendLeaves(Se,Ut.cluster_id,Ye,yt,bt):bt1;let Ts,ys,ir;if(Xt)Ts=Ge(Oe,Ut,this.clusterProps),ys=Oe[Ut],ir=Oe[Ut+1];else{const Rr=this.points[Oe[Ut+3]];Ts=Rr.properties;const[un,Wn]=Rr.geometry.coordinates;ys=We(un),ir=it(Wn)}const Lr={type:1,geometry:[[Math.round(this.options.extent*(ys*bt-Ye)),Math.round(this.options.extent*(ir*bt-yt))]],tags:Ts};let Hr;Hr=Xt||this.options.generateId?Oe[Ut+3]:this.points[Oe[Ut+3]].id,Hr!==void 0&&(Lr.id=Hr),Tt.features.push(Lr)}}_limitZoom(Se){return Math.max(this.options.minZoom,Math.min(Math.floor(+Se),this.options.maxZoom+1))}_cluster(Se,Oe){const{radius:Ye,extent:yt,reduce:bt,minPoints:Tt}=this.options,Ht=Ye/(yt*Math.pow(2,Oe)),Ut=Se.data,Xt=[],Ts=this.stride;for(let ys=0;ysOe&&(un+=Ut[sa+5])}if(un>Rr&&un>=Tt){let Wn,sa=ir*Rr,ua=Lr*Rr,To=-1;const wo=(ys/Ts<<5)+(Oe+1)+this.points.length;for(const Yi of Hr){const ii=Yi*Ts;if(Ut[ii+2]<=Oe)continue;Ut[ii+2]=Oe;const zi=Ut[ii+5];sa+=Ut[ii]*zi,ua+=Ut[ii+1]*zi,Ut[ii+4]=wo,bt&&(Wn||(Wn=this._map(Ut,ys,!0),To=this.clusterProps.length,this.clusterProps.push(Wn)),bt(Wn,this._map(Ut,ii)))}Ut[ys+4]=wo,Xt.push(sa/un,ua/un,1/0,wo,-1,un),bt&&Xt.push(To)}else{for(let Wn=0;Wn1)for(const Wn of Hr){const sa=Wn*Ts;if(!(Ut[sa+2]<=Oe)){Ut[sa+2]=Oe;for(let ua=0;ua>5}_getOriginZoom(Se){return(Se-this.points.length)%32}_map(Se,Oe,Ye){if(Se[Oe+5]>1){const Tt=this.clusterProps[Se[Oe+6]];return Ye?Object.assign({},Tt):Tt}const yt=this.points[Se[Oe+3]].properties,bt=this.options.map(yt);return Ye&&bt===yt?Object.assign({},bt):bt}}function _e(Bt,Se,Oe){return{type:"Feature",id:Bt[Se+3],properties:Ge(Bt,Se,Oe),geometry:{type:"Point",coordinates:[(Ye=Bt[Se],360*(Ye-.5)),Ve(Bt[Se+1])]}};var Ye}function Ge(Bt,Se,Oe){const Ye=Bt[Se+5],yt=Ye>=1e4?`${Math.round(Ye/1e3)}k`:Ye>=1e3?Math.round(Ye/100)/10+"k":Ye,bt=Bt[Se+6],Tt=bt===-1?{}:Object.assign({},Oe[bt]);return Object.assign(Tt,{cluster:!0,cluster_id:Bt[Se+3],point_count:Ye,point_count_abbreviated:yt})}function We(Bt){return Bt/360+.5}function it(Bt){const Se=Math.sin(Bt*Math.PI/180),Oe=.5-.25*Math.log((1+Se)/(1-Se))/Math.PI;return Oe<0?0:Oe>1?1:Oe}function Ve(Bt){const Se=(180-360*Bt)*Math.PI/180;return 360*Math.atan(Math.exp(Se))/Math.PI-90}function Xe(Bt,Se,Oe,Ye){let yt=Ye;const bt=Se+(Oe-Se>>1);let Tt,Ht=Oe-Se;const Ut=Bt[Se],Xt=Bt[Se+1],Ts=Bt[Oe],ys=Bt[Oe+1];for(let ir=Se+3;iryt)Tt=ir,yt=Lr;else if(Lr===yt){const Hr=Math.abs(ir-bt);HrYe&&(Tt-Se>3&&Xe(Bt,Se,Tt,Ye),Bt[Tt+2]=yt,Oe-Tt>3&&Xe(Bt,Tt,Oe,Ye))}function dt(Bt,Se,Oe,Ye,yt,bt){let Tt=yt-Oe,Ht=bt-Ye;if(Tt!==0||Ht!==0){const Ut=((Bt-Oe)*Tt+(Se-Ye)*Ht)/(Tt*Tt+Ht*Ht);Ut>1?(Oe=yt,Ye=bt):Ut>0&&(Oe+=Tt*Ut,Ye+=Ht*Ut)}return Tt=Bt-Oe,Ht=Se-Ye,Tt*Tt+Ht*Ht}function pt(Bt,Se,Oe,Ye){const yt={id:Bt??null,type:Se,geometry:Oe,tags:Ye,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(Se==="Point"||Se==="MultiPoint"||Se==="LineString")Je(yt,Oe);else if(Se==="Polygon")Je(yt,Oe[0]);else if(Se==="MultiLineString")for(const bt of Oe)Je(yt,bt);else if(Se==="MultiPolygon")for(const bt of Oe)Je(yt,bt[0]);return yt}function Je(Bt,Se){for(let Oe=0;Oe0&&(Tt+=Ye?(yt*Ts-Xt*bt)/2:Math.sqrt(Math.pow(Xt-yt,2)+Math.pow(Ts-bt,2))),yt=Xt,bt=Ts}const Ht=Se.length-3;Se[2]=1,Xe(Se,0,Ht,Oe),Se[Ht+2]=1,Se.size=Math.abs(Tt),Se.start=0,Se.end=Se.size}function Yt(Bt,Se,Oe,Ye){for(let yt=0;yt1?1:Oe}function Zs(Bt,Se,Oe,Ye,yt,bt,Tt,Ht){if(Ye/=Se,bt>=(Oe/=Se)&&Tt=Ye)return null;const Ut=[];for(const Xt of Bt){const Ts=Xt.geometry;let ys=Xt.type;const ir=yt===0?Xt.minX:Xt.minY,Lr=yt===0?Xt.maxX:Xt.maxY;if(ir>=Oe&&Lr=Ye)continue;let Hr=[];if(ys==="Point"||ys==="MultiPoint")Dr(Ts,Hr,Oe,Ye,yt);else if(ys==="LineString")$t(Ts,Hr,Oe,Ye,yt,!1,Ht.lineMetrics);else if(ys==="MultiLineString")Nr(Ts,Hr,Oe,Ye,yt,!1);else if(ys==="Polygon")Nr(Ts,Hr,Oe,Ye,yt,!0);else if(ys==="MultiPolygon")for(const Rr of Ts){const un=[];Nr(Rr,un,Oe,Ye,yt,!0),un.length&&Hr.push(un)}if(Hr.length){if(Ht.lineMetrics&&ys==="LineString"){for(const Rr of Hr)Ut.push(pt(Xt.id,ys,Rr,Xt.tags));continue}ys!=="LineString"&&ys!=="MultiLineString"||(Hr.length===1?(ys="LineString",Hr=Hr[0]):ys="MultiLineString"),ys!=="Point"&&ys!=="MultiPoint"||(ys=Hr.length===3?"Point":"MultiPoint"),Ut.push(pt(Xt.id,ys,Hr,Xt.tags))}}return Ut.length?Ut:null}function Dr(Bt,Se,Oe,Ye,yt){for(let bt=0;bt=Oe&&Tt<=Ye&&Xs(Se,Bt[bt],Bt[bt+1],Bt[bt+2])}}function $t(Bt,Se,Oe,Ye,yt,bt,Tt){let Ht=Us(Bt);const Ut=yt===0?kr:fn;let Xt,Ts,ys=Bt.start;for(let un=0;unOe&&(Ts=Ut(Ht,Wn,sa,To,wo,Oe),Tt&&(Ht.start=ys+Xt*Ts)):Yi>Ye?ii=Oe&&(Ts=Ut(Ht,Wn,sa,To,wo,Oe),zi=!0),ii>Ye&&Yi<=Ye&&(Ts=Ut(Ht,Wn,sa,To,wo,Ye),zi=!0),!bt&&zi&&(Tt&&(Ht.end=ys+Xt*Ts),Se.push(Ht),Ht=Us(Bt)),Tt&&(ys+=Xt)}let ir=Bt.length-3;const Lr=Bt[ir],Hr=Bt[ir+1],Rr=yt===0?Lr:Hr;Rr>=Oe&&Rr<=Ye&&Xs(Ht,Lr,Hr,Bt[ir+2]),ir=Ht.length-3,bt&&ir>=3&&(Ht[ir]!==Ht[0]||Ht[ir+1]!==Ht[1])&&Xs(Ht,Ht[0],Ht[1],Ht[2]),Ht.length&&Se.push(Ht)}function Us(Bt){const Se=[];return Se.size=Bt.size,Se.start=Bt.start,Se.end=Bt.end,Se}function Nr(Bt,Se,Oe,Ye,yt,bt){for(const Tt of Bt)$t(Tt,Se,Oe,Ye,yt,bt,!1)}function Xs(Bt,Se,Oe,Ye){Bt.push(Se,Oe,Ye)}function kr(Bt,Se,Oe,Ye,yt,bt){const Tt=(bt-Se)/(Ye-Se);return Xs(Bt,bt,Oe+(yt-Oe)*Tt,1),Tt}function fn(Bt,Se,Oe,Ye,yt,bt){const Tt=(bt-Oe)/(yt-Oe);return Xs(Bt,Se+(Ye-Se)*Tt,bt,1),Tt}function Yr(Bt,Se){const Oe=[];for(let Ye=0;Ye0&&Se.size<(yt?Tt:Ye))return void(Oe.numPoints+=Se.length/3);const Ht=[];for(let Ut=0;UtTt)&&(Oe.numSimplified++,Ht.push(Se[Ut],Se[Ut+1])),Oe.numPoints++;yt&&function(Ut,Xt){let Ts=0;for(let ys=0,ir=Ut.length,Lr=ir-2;ys0===Xt)for(let ys=0,ir=Ut.length;ys24)throw new Error("maxZoom should be in the 0-24 range");if(Oe.promoteId&&Oe.generateId)throw new Error("promoteId and generateId cannot be used together.");let yt=function(bt,Tt){const Ht=[];if(bt.type==="FeatureCollection")for(let Ut=0;Ut1&&console.time("creation"),Lr=this.tiles[ir]=lr(Se,Oe,Ye,yt,Xt),this.tileCoords.push({z:Oe,x:Ye,y:yt}),Ts)){Ts>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",Oe,Ye,yt,Lr.numFeatures,Lr.numPoints,Lr.numSimplified),console.timeEnd("creation"));const zi=`z${Oe}`;this.stats[zi]=(this.stats[zi]||0)+1,this.total++}if(Lr.source=Se,bt==null){if(Oe===Xt.indexMaxZoom||Lr.numPoints<=Xt.indexMaxPoints)continue}else{if(Oe===Xt.maxZoom||Oe===bt)continue;if(bt!=null){const zi=bt-Oe;if(Ye!==Tt>>zi||yt!==Ht>>zi)continue}}if(Lr.source=null,Se.length===0)continue;Ts>1&&console.time("clipping");const Hr=.5*Xt.buffer/Xt.extent,Rr=.5-Hr,un=.5+Hr,Wn=1+Hr;let sa=null,ua=null,To=null,wo=null,Yi=Zs(Se,ys,Ye-Hr,Ye+un,0,Lr.minX,Lr.maxX,Xt),ii=Zs(Se,ys,Ye+Rr,Ye+Wn,0,Lr.minX,Lr.maxX,Xt);Se=null,Yi&&(sa=Zs(Yi,ys,yt-Hr,yt+un,1,Lr.minY,Lr.maxY,Xt),ua=Zs(Yi,ys,yt+Rr,yt+Wn,1,Lr.minY,Lr.maxY,Xt),Yi=null),ii&&(To=Zs(ii,ys,yt-Hr,yt+un,1,Lr.minY,Lr.maxY,Xt),wo=Zs(ii,ys,yt+Rr,yt+Wn,1,Lr.minY,Lr.maxY,Xt),ii=null),Ts>1&&console.timeEnd("clipping"),Ut.push(sa||[],Oe+1,2*Ye,2*yt),Ut.push(ua||[],Oe+1,2*Ye,2*yt+1),Ut.push(To||[],Oe+1,2*Ye+1,2*yt),Ut.push(wo||[],Oe+1,2*Ye+1,2*yt+1)}}getTile(Se,Oe,Ye){Se=+Se,Oe=+Oe,Ye=+Ye;const yt=this.options,{extent:bt,debug:Tt}=yt;if(Se<0||Se>24)return null;const Ht=1<1&&console.log("drilling down to z%d-%d-%d",Se,Oe,Ye);let Xt,Ts=Se,ys=Oe,ir=Ye;for(;!Xt&&Ts>0;)Ts--,ys>>=1,ir>>=1,Xt=this.tiles[ns(Ts,ys,ir)];return Xt&&Xt.source?(Tt>1&&(console.log("found parent tile z%d-%d-%d",Ts,ys,ir),console.time("drilling down")),this.splitTile(Xt.source,Ts,ys,ir,Se,Oe,Ye),Tt>1&&console.timeEnd("drilling down"),this.tiles[Ut]?Gr(this.tiles[Ut],bt):null):null}}function ns(Bt,Se,Oe){return 32*((1<Xt.tags&&"3d_elevation_id"in Xt.tags&&"source"in Xt.tags&&Xt.tags.source==="elevation",bt=Ye.features.filter(Xt=>yt(Xt));let Tt={_geojsonTileLayer:Ye.features};bt.length>0&&(Tt={_geojsonTileLayer:Ye.features.filter(Xt=>!yt(Xt)),hd_road_elevation:bt});const Ht=new ae(Tt),Ut=function(Xt){const Ts=new d.a$;for(const ys of Object.keys(Xt))Ts.writeMessage(3,De,{name:ys,features:Xt[ys]});return Ts.finish()}(Tt).buffer;Se(null,{vectorTile:Ht,rawData:Ut})}class dn extends B{constructor(Se){super(Se),this.loadVectorData=$n,this._dynamicIndex=new oe}loadData(Se,Oe){const Ye=Se&&Se.request,yt=Ye&&Ye.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(Se,(bt,Tt)=>{if(bt||!Tt)return Oe(bt);if(typeof Tt!="object")return Oe(new Error(`Input data given to '${Se.source}' is not a valid GeoJSON object.`));{try{if(Se.filter){const Ut=d.X(Se.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(Ut.result==="error")throw new Error(Ut.value.map(Xt=>`${Xt.key}: ${Xt.message}`).join(", "));Tt.features=Tt.features.filter(Xt=>Ut.value.evaluate({zoom:0},Xt))}Se.dynamic?(Tt.type==="Feature"&&(Tt={type:"FeatureCollection",features:[Tt]}),Se.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(Tt.features,this.loaded),Se.cluster&&(Tt.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=Se.cluster?new tt(function({superclusterOptions:Ut,clusterProperties:Xt}){if(!Xt||!Ut)return Ut;const Ts={},ys={},ir={accumulated:null,zoom:0},Lr={properties:null},Hr=Object.keys(Xt);for(const Rr of Hr){const[un,Wn]=Xt[Rr],sa=d.X(Wn),ua=d.X(typeof un=="string"?[un,["accumulated"],["get",Rr]]:un);Ts[Rr]=sa.value,ys[Rr]=ua.value}return Ut.map=Rr=>{Lr.properties=Rr;const un={};for(const Wn of Hr)un[Wn]=Ts[Wn].evaluate(ir,Lr);return un},Ut.reduce=(Rr,un)=>{Lr.properties=un;for(const Wn of Hr)ir.accumulated=Rr[Wn],Rr[Wn]=ys[Wn].evaluate(ir,Lr)},Ut}(Se)).load(Tt.features):Se.dynamic?this._dynamicIndex:function(Ut,Xt){return new ai(Ut,Xt)}(Tt,Se.geojsonVtOptions)}catch(Ut){return Oe(Ut)}const Ht={};if(yt){const Ut=u(Ye);Ut&&(Ht.resourceTiming={},Ht.resourceTiming[Se.source]=JSON.parse(JSON.stringify(Ut)))}Oe(null,Ht)}})}reloadTile(Se,Oe){const Ye=this.loaded;return Ye&&Ye[Se.uid]?Se.partial?Oe(null,void 0):super.reloadTile(Se,Oe):this.loadTile(Se,Oe)}loadGeoJSON(Se,Oe){if(Se.request)d.m(Se.request,Oe);else{if(typeof Se.data!="string")return Oe(new Error(`Input data given to '${Se.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return Oe(null,JSON.parse(Se.data))}catch{return Oe(new Error(`Input data given to '${Se.source}' is not a valid GeoJSON object.`))}},0)}}getClusterExpansionZoom(Se,Oe){try{Oe(null,this._geoJSONIndex.getClusterExpansionZoom(Se.clusterId))}catch(Ye){Oe(Ye)}}getClusterChildren(Se,Oe){try{Oe(null,this._geoJSONIndex.getChildren(Se.clusterId))}catch(Ye){Oe(Ye)}}getClusterLeaves(Se,Oe){try{Oe(null,this._geoJSONIndex.getLeaves(Se.clusterId,Se.limit,Se.offset))}catch(Ye){Oe(Ye)}}}class zr{constructor(Se,Oe,Ye){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=Oe,this.worldview=Ye}parse(Se,Oe,Ye,yt){this.status="parsing";const bt=new d.aR(Ye.tileID.overscaledZ,Ye.tileID.wrap,Ye.tileID.canonical.z,Ye.tileID.canonical.x,Ye.tileID.canonical.y),Tt=[],Ht=Oe.familiesBySource[Ye.source],Ut=new d.ff(bt,Ye.promoteId);Ut.bucketLayerIDs=[],Ut.is3DTile=!0,d.fB(Se).then(Xt=>{const Ts=Xt.json.extensionsUsed&&Xt.json.extensionsUsed.includes("MAPBOX_mesh_features")||Xt.json.asset.extras&&Xt.json.asset.extras.MAPBOX_mesh_features,ys=Xt.json.extensionsUsed&&Xt.json.extensionsUsed.includes("EXT_meshopt_compression"),ir=new d.ae(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const Lr in Ht)for(const Hr of Ht[Lr]){const Rr=Hr[0];Ut.bucketLayerIDs.push(Hr.map(sa=>d.F(sa.id,sa.scope))),Rr.recalculate(ir,[]);const un=d.fC(Xt,1/d.cS(Ye.tileID.canonical)),Wn=new d.fD(Hr,un,bt,Ts,ys,this.brightness,Ut,this.worldview);Ts||(Wn.needsUpload=!0),Tt.push(Wn),Wn.evaluate(Rr)}this.status="done",yt(null,{buckets:Tt,featureIndex:Ut,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(Xt=>yt(new Error(Xt.message)))}}class Kr{constructor({actor:Se,layerIndex:Oe,availableImages:Ye,availableModels:yt,brightness:bt,worldview:Tt}){this.actor=Se,this.layerIndex=Oe,this.availableImages=Ye,this.availableModels=yt,this.brightness=bt,this.loading={},this.loaded={},this.worldview=Tt}loadTile(Se,Oe){const Ye=Se.uid,yt=this.loading[Ye]=new zr(Se,this.brightness,this.worldview);d.b1(Se.request,(bt,Tt)=>{const Ht=!this.loading[Ye];return delete this.loading[Ye],Ht||bt?(yt.status="done",Ht||(this.loaded[Ye]=yt),Oe(bt)):Tt&&Tt.byteLength!==0?void yt.parse(Tt,this.layerIndex,Se,(Ut,Xt)=>{yt.status="done",this.loaded=this.loaded||{},this.loaded[Ye]=yt,Ut||!Xt?Oe(Ut):Oe(null,Xt)}):(yt.status="done",this.loaded[Ye]=yt,Oe())})}reloadTile(Se,Oe){const Ye=this.loaded,yt=Se.uid;if(Ye&&Ye[yt]){const bt=Ye[yt];bt.projection=Se.projection,bt.brightness=Se.brightness;const Tt=(Ht,Ut)=>{bt.reloadCallback&&(delete bt.reloadCallback,this.loadTile(Se,Oe)),Oe(Ht,Ut)};bt.status==="parsing"?bt.reloadCallback=Tt:bt.status==="done"&&this.loadTile(Se,Oe)}}abortTile(Se,Oe){const Ye=Se.uid;this.loading[Ye]&&delete this.loading[Ye],Oe()}removeTile(Se,Oe){const Ye=this.loaded,yt=Se.uid;Ye&&Ye[yt]&&delete Ye[yt],Oe()}}const La=new Map,Zt=new Map;class Er{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:dn,"raster-dem":U,"raster-array":Y,"batched-model":Kr},this.workerSources={},this.self.registerWorkerSource=(Oe,Ye)=>{if(this.workerSourceTypes[Oe])throw new Error(`Worker source with name "${Oe}" already registered.`);this.workerSourceTypes[Oe]=Ye},this.self.registerRTLTextPlugin=Oe=>{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=Oe.applyArabicShaping,d.fF.processBidirectionalText=Oe.processBidirectionalText,d.fF.processStyledBidirectionalText=Oe.processStyledBidirectionalText;for(const Ye of this.rtlPluginParsingListeners)Ye(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(Se,Oe,Ye){delete this.layerIndexes[Se],delete this.availableImages[Se],delete this.availableModels[Se],delete this.workerSources[Se],Ye()}checkIfReady(Se,Oe,Ye){Ye()}setReferrer(Se,Oe){this.referrer=Oe}spriteLoaded(Se,Oe){this.isSpriteLoaded[Se]||(this.isSpriteLoaded[Se]={});const{scope:Ye,isLoaded:yt}=Oe;if(this.isSpriteLoaded[Se][Ye]=yt,this.workerSources[Se]&&this.workerSources[Se][Ye])for(const bt in this.workerSources[Se][Ye]){const Tt=this.workerSources[Se][Ye][bt];for(const Ht in Tt){const Ut=Tt[Ht];Ut instanceof B&&(Ut.isSpriteLoaded=yt,Ut.fire(new d.C("isSpriteLoaded")))}}}setImages(Se,Oe,Ye){this.availableImages[Se]||(this.availableImages[Se]={});const{scope:yt,images:bt}=Oe;if(this.availableImages[Se][yt]=bt,this.workerSources[Se]&&this.workerSources[Se][yt]){for(const Tt in this.workerSources[Se][yt]){const Ht=this.workerSources[Se][yt][Tt];for(const Ut in Ht)Ht[Ut].availableImages=bt}Ye()}else Ye()}setModels(Se,{scope:Oe,models:Ye},yt){if(this.availableModels[Se]||(this.availableModels[Se]={}),this.availableModels[Se][Oe]=Ye,this.workerSources[Se]&&this.workerSources[Se][Oe]){for(const bt in this.workerSources[Se][Oe]){const Tt=this.workerSources[Se][Oe][bt];for(const Ht in Tt)Tt[Ht].availableModels=Ye}yt()}else yt()}setProjection(Se,Oe){this.projections[Se]=d.c0(Oe)}setBrightness(Se,Oe,Ye){this.brightness=Oe,Ye()}setContextParams(Se,Oe,Ye){this.maxUniformBufferBindings=Oe.maxBindingPoints,this.maxUniformBlockSizeDwords=Oe.maxUniformBlockSizeDwords,this.disableSymbolUBO=Oe.disableSymbolUBO,Ye()}setWorldview(Se,Oe,Ye){this.worldview=Oe,Ye()}setLayers(Se,Oe,Ye){this.getLayerIndex(Se,Oe.scope).replace(Oe.layers,Oe.options),Ye()}updateLayers(Se,Oe,Ye){this.getLayerIndex(Se,Oe.scope).update(Oe.layers,Oe.removedIds,Oe.options),Ye()}loadTile(Se,Oe,Ye){Oe.projection=this.projections[Se]||this.defaultProjection,this.getWorkerSource(Se,Oe).loadTile(Oe,Ye)}decodeRasterArray(Se,Oe,Ye){this.getWorkerSource(Se,Oe).decodeRasterArray(Oe,Ye)}reloadTile(Se,Oe,Ye){Oe.projection=this.projections[Se]||this.defaultProjection,this.getWorkerSource(Se,Oe).reloadTile(Oe,Ye)}abortTile(Se,Oe,Ye){this.getWorkerSource(Se,Oe).abortTile(Oe,Ye)}removeTile(Se,Oe,Ye){this.getWorkerSource(Se,Oe).removeTile(Oe,Ye)}removeSource(Se,Oe,Ye){if(!(this.workerSources[Se]&&this.workerSources[Se][Oe.scope]&&this.workerSources[Se][Oe.scope][Oe.type]&&this.workerSources[Se][Oe.scope][Oe.type][Oe.source]))return;const yt=this.workerSources[Se][Oe.scope][Oe.type][Oe.source];delete this.workerSources[Se][Oe.scope][Oe.type][Oe.source],yt.removeSource!==void 0?yt.removeSource(Oe,Ye):Ye()}loadTileProvider(Se,Oe,Ye){(async function(yt,bt){const Tt=Zt.get(yt);if(Tt)return Tt;const Ht=La.get(yt);if(Ht!==void 0)return Ht;const Ut=import(bt).then(Xt=>{const Ts=Xt.default;if(typeof Ts!="function")throw new Error(`TileProvider "${yt}" module must default-export a class`);if(typeof Ts.prototype.loadTile!="function")throw new Error(`TileProvider "${yt}" class must have a loadTile method`);return Zt.set(yt,Ts),Ts}).finally(()=>{La.delete(yt)});return La.set(yt,Ut),Ut})(Oe.name,Oe.url).then(yt=>{const bt=new yt(Oe.options);return this.getWorkerSource(Se,{type:Oe.type,source:Oe.source,scope:Oe.scope},bt),bt.load&&Oe.request?bt.load({request:Oe.request}):null}).then(yt=>Ye(null,yt)).catch(yt=>Ye(yt instanceof Error?yt:new Error(typeof yt=="string"?yt:"Unknown error")))}loadWorkerSource(Se,Oe,Ye){try{this.self.importScripts(Oe.url),Ye()}catch(yt){Ye(yt)}}syncRTLPluginState(Se,Oe,Ye){if(d.fF.isParsed())Ye(null,!0);else if(d.fF.isParsing())this.rtlPluginParsingListeners.push(Ye);else try{d.fF.setState(Oe);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()?Ye(null,!0):this.rtlPluginParsingListeners.push(Ye))}catch(yt){Ye(yt)}}setConfig(Se,Oe){Object.assign(d.g,Oe)}getAvailableImages(Se,Oe){this.availableImages[Se]||(this.availableImages[Se]={});let Ye=this.availableImages[Se][Oe];return Ye||(Ye=[]),Ye}getAvailableModels(Se,Oe){this.availableModels[Se]||(this.availableModels[Se]={});let Ye=this.availableModels[Se][Oe];return Ye||(Ye={}),Ye}getLayerIndex(Se,Oe){this.layerIndexes[Se]||(this.layerIndexes[Se]={});let Ye=this.layerIndexes[Se][Oe];return Ye||(Ye=this.layerIndexes[Se][Oe]=new _,Ye.scope=Oe),Ye}getWorkerSource(Se,Oe,Ye){const{type:yt,source:bt,scope:Tt}=Oe,Ht=this.workerSources;if(Ht[Se]||(Ht[Se]={}),Ht[Se][Tt]||(Ht[Se][Tt]={}),Ht[Se][Tt][yt]||(Ht[Se][Tt][yt]={}),this.isSpriteLoaded[Se]||(this.isSpriteLoaded[Se]={}),!Ht[Se][Tt][yt][bt]){const Ut={send:(Ts,ys,ir,Lr,Hr,Rr)=>this.actor.send(Ts,ys,ir,Se,Hr,Rr),scheduler:this.actor.scheduler},Xt=this.workerSourceTypes[yt];if(!Xt)throw new Error(`Unknown worker source type "${yt}".`);Ht[Se][Tt][yt][bt]=new Xt({actor:Ut,layerIndex:this.getLayerIndex(Se,Tt),availableImages:this.getAvailableImages(Se,Tt),availableModels:this.getAvailableModels(Se,Tt),isSpriteLoaded:this.isSpriteLoaded[Se][Tt],tileProvider:Ye,brightness:this.brightness,worldview:this.worldview,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords,disableSymbolUBO:this.disableSymbolUBO})}return Ht[Se][Tt][yt][bt]}rasterizeImagesWorker(Se,Oe,Ye){const yt=new Map;for(const[bt,{image:Tt,imageVariant:Ht}]of Oe.tasks.entries()){const Ut=this.imageRasterizer.rasterize(Ht,Tt,Oe.scope,Se);yt.set(bt,Ut)}Ye(void 0,yt)}removeRasterizedImages(Se,Oe,Ye){this.imageRasterizer.removeImagesFromCacheByIds(Oe.imageIds,Oe.scope,Se),Ye()}enforceCacheSizeLimit(Se,Oe){d.fH(Oe)}getWorkerPerformanceMetrics(Se,Oe,Ye){Ye(void 0,void 0)}}return d.fE(self)&&(self.worker=new Er(self)),Er}),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,$,W=new Blob([""],{type:"text/javascript"}),ee=URL.createObjectURL(W);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 W=$.getImageData(0,0,1,1);return W&&W.width===z.width}()?(v[D=E&&E.failIfMajorPerformanceCaveat]===void 0&&(v[D]=function(z){var $,W=function(ee){var ne=document.createElement("canvas"),de=Object.create(M.webGLContextAttributes);return de.failIfMajorPerformanceCaveat=ee,ne.getContext("webgl2",de)}(z);if(!W)return!1;try{$=W.createShader(W.VERTEX_SHADER)}catch{return!1}return!(!$||W.isContextLost())&&(W.shaderSource($,"void main() {}"),W.compileShader($),W.getShaderParameter($,W.COMPILE_STATUS)===!0)}(D)),v[D]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var D}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 k=typeof document<"u"?document.documentElement&&document.documentElement.style:null,C=k&&k.userSelect!==void 0?"userSelect":"WebkitUserSelect";let A;function I(){k&&C&&(A=k[C],k[C]="none")}function L(){k&&C&&(k[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=ae(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=ae(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=ae(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=ae(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=ae(m);return i.e(m)?(E.path=`/styles/v1${E.path}/iconset.pbf`,this._makeAPIURL(E,this._customAccessToken||v)):ie(E)}normalizeSpriteURL(m,v,E,D){const z=ae(m);return i.e(m)?(z.path=`/styles/v1${z.path}/sprite${v}${E}`,this._makeAPIURL(z,this._customAccessToken||D)):(z.path+=`${v}${E}`,ie(z))}normalizeTileURL(m,v,E){if(this._isSkuTokenExpired()&&this._createSkuToken(),m&&!i.e(m))return m;const D=ae(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 W of $){const ee=W.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=ae(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=ae(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 ie(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||""}`),ie(m)}}const ce=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function ae(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 ie(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 ye(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 W=localStorage.getItem(D);W&&(this.anonIdTimestamp=Number(W));const ee=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp=1&&localStorage.setItem(v,JSON.stringify(this.eventData)),$&&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=ae(i.g.EVENTS_URL);z.params.push(`access_token=${D||i.g.ACCESS_TOKEN||""}`);const $={event:this.type,created:new Date(m).toISOString()},W=v?Object.assign($,v):$,ee={url:ie(z),headers:{"Content-Type":"text/plain"},body:JSON.stringify([W])};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(!ye(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 Ne=new class extends he{constructor(M){super("appUserTurnstile"),this._customAccessToken=M}postTurnstileEvent(M,m){ye(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),W=(D-this.eventData.lastSuccess)/864e5;E=E||W>=1||W<-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()}},Ue=Ne.postTurnstileEvent.bind(Ne),Te=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}},Me=Te.postMapLoadEvent.bind(Te),De=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(!ye(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)}},qe=De.postStyleLoadEvent.bind(De),ke=new ge({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),$e=ke.postMetricsEvent.bind(ke),Be=new ge({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),we=Be.postMetricsEvent.bind(Be),ut=new class extends he{constructor(){super("gljs.performance")}postPerformanceEvent(M,m){ye(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"),W=function(Ae){const Fe={};if(Ae){for(const Ie in Ae)if(Ie!=="other")for(const rt of Ae[Ie]){const st=`${Ie}ResolveRangeMin`,ct=`${Ie}ResolveRangeMax`,mt=`${Ie}RequestCount`,at=`${Ie}RequestCachedCount`;Fe[st]=Math.min(Fe[st]||1/0,rt.startTime),Fe[ct]=Math.max(Fe[ct]||-1/0,rt.responseEnd);const zt=wt=>{Fe[wt]===void 0&&(Fe[wt]=0),++Fe[wt]};rt.transferSize!==void 0&&rt.transferSize===0&&zt(at),zt(mt)}}return Fe}(function(Ae,Fe){const Ie={};if(Ae)for(const rt of Ae){const st=Fe(rt);Ie[st]===void 0&&(Ie[st]=[]),Ie[st].push(rt)}return Ie}(z,f)),ee=window.devicePixelRatio,ne=navigator.connection||navigator.mozConnection||navigator.webkitConnection,de=ne?ne.effectiveType:void 0,je={counters:[],metadata:[],attributes:[]},be=(Ae,Fe,Ie)=>{Ie!=null&&Ae.push({name:Fe,value:Ie.toString()})};for(const Ae in W)be(je.counters,Ae,W[Ae]);if(D.interactionRange[0]!==1/0&&D.interactionRange[1]!==-1/0&&(be(je.counters,"interactionRangeMin",D.interactionRange[0]),be(je.counters,"interactionRangeMax",D.interactionRange[1])),$)for(const Ae of Object.values(u)){const Fe=$.find(Ie=>Ie.name===Ae);Fe&&be(je.counters,Ae,Fe.startTime)}return be(je.counters,"visibilityHidden",D.visibilityHidden),be(je.attributes,"style",function(Ae){if(Ae)for(const Fe of Ae){const Ie=Fe.name.split("?")[0];if(i.i(Ie)){const rt=Ie.split("/").slice(-2);if(rt.length===2)return`mapbox://styles/${rt[0]}/${rt[1]}`}}}(z)),be(je.attributes,"terrainEnabled",D.terrainEnabled?"true":"false"),be(je.attributes,"fogEnabled",D.fogEnabled?"true":"false"),be(je.attributes,"projection",D.projection),be(je.attributes,"zoom",D.zoom),be(je.metadata,"devicePixelRatio",ee),be(je.metadata,"connectionEffectiveType",de),be(je.metadata,"navigatorUserAgent",navigator.userAgent),be(je.metadata,"screenWidth",window.screen.width),be(je.metadata,"screenHeight",window.screen.height),be(je.metadata,"windowWidth",window.innerWidth),be(je.metadata,"windowHeight",window.innerHeight),be(je.metadata,"mapWidth",D.width/ee),be(je.metadata,"mapHeight",D.height/ee),be(je.metadata,"webglRenderer",D.renderer),be(je.metadata,"webglVendor",D.vendor),be(je.metadata,"sdkVersion",d),be(je.metadata,"sdkIdentifier","mapbox-gl-js"),je}(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=ut.postPerformanceEvent.bind(ut),He=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=ae(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:ie(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}},et=He.getSessionAPI.bind(He),tt=new Set;function _e(M,m){m?tt.add(M):tt.delete(M)}class Ge{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 We(M){const{userImage:m}=M;return!!(m&&m.render&&m.render())&&(M.data.replace(new Uint8Array(m.data.buffer)),!0)}const it={workerUrl:"",workerClass:null,workerParams:void 0};function Ve(M){return it.workerClass!=null?new it.workerClass:new self.Worker(it.workerUrl,Object.assign({name:M},it.workerParams))}const Xe="mapboxgl_preloaded_worker_pool";class dt{constructor(m){this.active={},this.name=m}acquire(m,v=dt.workerCount){if(!this.workers)for(this.workers=[];this.workers.length{v.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[Xe]}numActive(){return Object.keys(this.active).length}}dt.workerCount=2;class pt{constructor(m,v,E="Worker",D=dt.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 Je,Ze;function Nt(){return Je||(Je=new dt),Je}pt.Actor=i.A;class Ot 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 pt((Ze||(Ze=new dt("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 je=$.get(de.iconsetId);je&&(this.getImage(de,v)?z.push(de):je.addPendingRequest(de))}if(D.length===0)return void this._notify(z,v,E);let W=!0;const ee=!!this.loaded.get(v),ne=this.images.get(v);if(!ee)for(const de of D)ne.has(de.toString())||(W=!1);ee||W?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[$,W]of D.entries()){const ee=this.getImage(W.id,z);ee&&E.set($,{image:ee,imageVariant:W})}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:W}]of v.entries())D.set(z,this.imageRasterizer.rasterize(W,$,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 W=D.get($.toString());if(!W){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:W.usvg?null:W.data.clone(),pixelRatio:W.pixelRatio,sdf:W.sdf,usvg:W.usvg,stretchX:W.stretchX,stretchY:W.stretchY,content:W.content,hasRenderCallback:!!(W.userImage&&W.userImage.render)};W.usvg&&Object.assign(ee,{width:W.icon.usvg_tree.width,height:W.icon.usvg_tree.height}),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),W=this.getImage(m,v);if(!W)return null;if($){if($.position.version===W.version)return $.position;$.position.version=W.version}else{if(W.usvg&&!W.data){const ee=this.getPatternInFlightId(D,v);if(this.patternsInFlight.has(ee))return null;this.patternsInFlight.add(ee);const ne=new i.D(m).scaleSelf(i.o.devicePixelRatio),de=new Map([[ne.toString(),{image:W,imageVariant:ne}]]);return this._rasterizeImages(v,de,(je,be)=>this.storePatternImage(ne,v,W,E,be)),null}this.storePattern(m,v,W)}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(),W=z?z.get($):void 0;W&&(E.data=W,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),W=this.atlasImage.get(m);W.resize({width:z||1,height:$||1});const ee=this.images.get(m);for(const[ne,{bin:de,position:je}]of E.entries()){let be=je.padding;const Ae=de.x+be,Fe=de.y+be,Ie=ee.get(ne).data,rt=Ie.width,st=Ie.height;be=be>1?be-1:be,i.q.copy(Ie,W,{x:0,y:0},{x:Ae,y:Fe},{width:rt,height:st},v),i.q.copy(Ie,W,{x:0,y:st-be},{x:Ae,y:Fe-be},{width:rt,height:be},v),i.q.copy(Ie,W,{x:0,y:0},{x:Ae,y:Fe+st},{width:rt,height:be},v),i.q.copy(Ie,W,{x:rt-be,y:0},{x:Ae-be,y:Fe},{width:be,height:st},v),i.q.copy(Ie,W,{x:0,y:0},{x:Ae+rt,y:Fe},{width:be,height:st},v),i.q.copy(Ie,W,{x:rt-be,y:st-be},{x:Ae-be,y:Fe-be},{width:be,height:be},v),i.q.copy(Ie,W,{x:0,y:st-be},{x:Ae+rt,y:Fe-be},{width:be,height:be},v),i.q.copy(Ie,W,{x:0,y:0},{x:Ae+rt,y:Fe+st},{width:be,height:be},v),i.q.copy(Ie,W,{x:rt-be,y:0},{x:Ae-be,y:Fe+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());We(z)&&this.updateImage(D,v,z)}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove()}}function Yt(M){const m=M.value,v=M.valueSpec,E=M.style,D=M.styleSpec,z=M.key,$=M.arrayElementValidator||dn;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 $s(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,$,W,ee={};const ne=D!=="categorical"&&v.property===void 0,de=!ne,je=function(Ie){const rt=Ie.stops;return Array.isArray(rt)&&Array.isArray(rt[0])&&i.K(rt[0][0])}(v),be=zr({key:M.key,value:M.value,valueSpec:M.styleSpec.function,style:M.style,styleSpec:M.styleSpec,objectElementValidators:{stops:function(Ie){if(D==="identity")return[new i.V(Ie.key,Ie.value,'identity function may not have a "stops" property')];let rt=[];const st=Ie.value;return rt=rt.concat(Yt({key:Ie.key,value:st,valueSpec:Ie.valueSpec,style:Ie.style,styleSpec:Ie.styleSpec,arrayElementValidator:Ae})),Array.isArray(st)&&st.length===0&&rt.push(new i.V(Ie.key,st,"array must have at least one stop")),rt},default:function(Ie){return dn({key:Ie.key,value:Ie.value,valueSpec:E,style:Ie.style,styleSpec:Ie.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"&&!je||v.property!==void 0||be.push(new i.V(M.key,M.value,'"property" property is required')),be;function Ae(Ie){let rt=[];const st=Ie.value,ct=Ie.key;if(!Array.isArray(st))return[new i.V(ct,st,`array expected, ${i.M(st)} found`)];if(st.length!==2)return[new i.V(ct,st,`array length 2 expected, length ${st.length} found`)];if(je){if(!i.K(st[0]))return[new i.V(ct,st,`object expected, ${i.M(st[0])} found`)];const mt=st[0];if(mt.zoom===void 0)return[new i.V(ct,st,"object stop key must have zoom")];if(mt.value===void 0)return[new i.V(ct,st,"object stop key must have value")];const at=i.L(mt.zoom);if(typeof at!="number")return[new i.V(ct,mt.zoom,"stop zoom values must be numbers")];if(W&&W>at)return[new i.V(ct,mt.zoom,"stop zoom values must appear in ascending order")];at!==W&&(W=at,$=void 0,ee={}),rt=rt.concat(zr({key:`${ct}[0]`,value:st[0],valueSpec:{zoom:{}},style:Ie.style,styleSpec:Ie.styleSpec,objectElementValidators:{zoom:Ps,value:Fe}}))}else rt=rt.concat(Fe({key:`${ct}[0]`,value:st[0],style:Ie.style,styleSpec:Ie.styleSpec},st));return i.U(i.W(st[1]))?rt.concat([new i.V(`${ct}[1]`,st[1],"expressions are not allowed in function stops.")]):rt.concat(dn({key:`${ct}[1]`,value:st[1],valueSpec:E,style:Ie.style,styleSpec:Ie.styleSpec}))}function Fe(Ie,rt){const st=i.M(Ie.value),ct=i.L(Ie.value),mt=Ie.value!==null?Ie.value:rt;if(z){if(st!==z)return[new i.V(Ie.key,mt,`${st} stop domain type must match previous stop domain type ${z}`)]}else z=st;if(st!=="number"&&st!=="string"&&st!=="boolean"&&typeof ct!="number"&&typeof ct!="string"&&typeof ct!="boolean")return[new i.V(Ie.key,mt,"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(Ie.key,mt,at)]}return D!=="categorical"||st!=="number"||typeof ct=="number"&&isFinite(ct)&&Math.floor(ct)===ct?D!=="categorical"&&st==="number"&&typeof ct=="number"&&typeof $=="number"&&$!==void 0&&ct<$?[new i.V(Ie.key,mt,"stop domain values must appear in ascending order")]:($=ct,D==="categorical"&&ct in ee?[new i.V(Ie.key,mt,"stop domain values must be unique")]:(ee[ct]=!0,[])):[new i.V(Ie.key,mt,`integer expected, found ${String(ct)}`)]}}function Zs(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 Dr(v,M);if(M.expressionContext==="appearance")return $t(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 Dr(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(...Dr(D,m))}),E)}function $t(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(...$t(D,m))}),E)}function Us(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 Nr(M){return i.a4(i.W(M.value))?Zs(Object.assign({},M,{expressionContext:"filter",valueSpec:M.styleSpec[`filter_${M.layerType||"fill"}`]})):Xs(M)}function Xs(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=Us({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)===W&&(ee=ne)}),ee?ee.ref?m.push(new i.V(E,v.ref,"ref cannot reference another ref layer")):$=i.L(ee.type):typeof W=="string"&&m.push(new i.V(E,v.ref,`ref layer "${W}" 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(zr({key:E,value:v,valueSpec:z.layer,style:M.style,styleSpec:M.styleSpec,objectElementValidators:{"*":()=>[],type:()=>dn({key:`${E}.type`,value:v.type,valueSpec:z.layer.type,style:M.style,styleSpec:M.styleSpec,object:v,objectKey:"type"}),filter:ee=>Nr(Object.assign({layerType:$},ee)),layout:ee=>zr({layer:v,key:ee.key,value:ee.value,valueSpec:{},style:ee.style,styleSpec:ee.styleSpec,objectElementValidators:{"*":ne=>Yr(Object.assign({layerType:$},ne))}}),paint:ee=>zr({layer:v,key:ee.key,value:ee.value,valueSpec:{},style:ee.style,styleSpec:ee.styleSpec,objectElementValidators:{"*":ne=>fn(Object.assign({layerType:$,layer:v},ne))}}),appearances(ee){const ne=Yt({key:ee.key,value:ee.value,valueSpec:ee.valueSpec,style:ee.style,styleSpec:ee.styleSpec,arrayElementValidator:be=>function(Ae){const{key:Fe,layer:Ie,layerType:rt}=Ae,st=i.L(Ae.value),ct=i.L(st.name),mt=i.L(st.condition),at=zr({key:Fe,value:st,valueSpec:Ae.styleSpec.appearance,style:Ae.style,styleSpec:Ae.styleSpec,objectElementValidators:{condition:zt=>function(wt){const Rt=[];return Rt.push(...Zs({key:wt.key,value:wt.object.condition,valueSpec:i.a8.appearance.condition,expressionContext:"appearance"})),Rt}(Object.assign({layer:Ie,layerType:rt},zt)),properties:zt=>function(wt){const Rt=[],{styleSpec:ft,layer:_t,layerType:At}=wt,Wt=ft[`paint_${At}`],qt=ft[`layout_${At}`],rs=wt.object[wt.objectKey];for(const Jt in rs){const Ns=Jt in Wt?"paint":Jt in qt?"layout":void 0;if(!Ns){Rt.push(new i.V(wt.key,Jt,`unknown property "${Jt}" for layer type "${At}"`));continue}const As=Object.assign({},wt,{key:`${wt.key}.${Jt}`,object:rs,objectKey:Jt,layer:_t,layerType:At,value:rs[Jt],valueSpec:Ns==="paint"?Wt[Jt]:qt[Jt]});Rt.push(...kr(As,Ns))}return Rt}(Object.assign({layer:Ie,layerType:rt},zt))}});return ct!=="hidden"&&mt===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:[],je=new Set;return de.forEach((be,Ae)=>{const Fe=i.L(be.name);if(Fe)if(je.has(Fe)){const Ie=i.L(v.id);ne.push(new i.V(ee.key,Fe,`Duplicated appearance name "${Fe}" for layer "${Ie}"`))}else je.add(Fe)}),ne}}})),m}function Gr({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 Gr({key:m,value:v});if(Array.isArray(v)){const D=[],z=i.W(v),$=i.X(z);return $.result==="error"?($.value.forEach(W=>{D.push(new i.V(`${m}${W.key}`,null,`${W.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 lr(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(zr({key:v,value:m,valueSpec:E[`source_${z.replace("-","_")}`],style:M.style,styleSpec:E,objectElementValidators:nr})),$;case"geojson":if($=zr({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 W in m.clusterProperties){const ee=m.clusterProperties[W];if(!Array.isArray(ee))return[new i.V(`${v}.clusterProperties.${W}`,ee,"array expected")];const[ne,de]=ee,je=typeof ne=="string"?[ne,["accumulated"],["get",W]]:ne;$.push(...Zs({key:`${v}.${W}.map`,value:de,expressionContext:"cluster-map"})),$.push(...Zs({key:`${v}.${W}.reduce`,value:je,expressionContext:"cluster-reduce"}))}}return $;case"video":return zr({key:v,value:m,valueSpec:E.source_video,style:D,styleSpec:E});case"image":return zr({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 Us({key:`${v}.type`,value:m.type,valueSpec:{values:Fr(E)}})}}function Fr(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 Wr(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 W=$.match(/^(.*)-transition$/),ee=$.match(/^(.*)-use-theme$/);z=z.concat(ee&&E[ee[1]]?dn({key:$,value:m[$],valueSpec:{type:"string"},style:D,styleSpec:v}):W&&E[W[1]]&&E[W[1]].transition?dn({key:$,value:m[$],valueSpec:v.transition,style:D,styleSpec:v}):E[$]?dn({key:$,value:m[$],valueSpec:E[$],style:D,styleSpec:v}):[new i.V($,m[$],`unknown property "${$}"`)])}return z}function Nn(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,W=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(W)for(let de=0;de[],array:Yt,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:Ps,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:Us,filter:Nr,function:$s,layer:$r,object:zr,source:lr,model:i.a9,light:Wr,"light-3d":Nn,terrain:ai,fog:ns,string:Gr,formatted:function(M){return Gr(M).length===0?[]:Zs(M)},resolvedImage:function(M){return Gr(M).length===0?[]:Zs(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(dn({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 $=zr(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(zr({key:v,value:m,valueSpec:E[`iconset_${z}`],style:D,styleSpec:E})),function(W,ee){return!(W!=="source"||!ee.source)}(z,m)){const W=D.sources&&D.sources[m.source],ee=W&&i.L(W.type);W?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 dn(M,m=!1){const v=M.value,E=M.valueSpec,D=M.styleSpec;if(E.expression){if(i.a6(i.L(v)))return $s(M);if(i.U(i.W(v)))return Zs(M)}if(E.type&&$n[E.type]){const z=$n[E.type](M);return m===!0&&z.length>0&&Array.isArray(M.value)?Zs(M):z}return zr(Object.assign({},M,{valueSpec:E.type?D[E.type]:E}))}function zr(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 W=[];for(const ee in v){const ne=ee.split(".")[0];let de;D[ne]?de=D[ne]:E[ne]?de=dn:D["*"]?de=D["*"]:E["*"]&&(de=dn),de?W=W.concat(de({key:(m&&`${m}.`)+ee,value:v[ee],valueSpec:E[ne]||E["*"],style:z,styleSpec:$,object:v,objectKey:ee},v)):W.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&&W.push(new i.V(m,v,`missing required property "${ee}"`))}return W}function Kr({key:M,value:m}){const v=Gr({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 zr({key:v.key||"",value:M,valueSpec:Object.assign(m.$root,{"*":{type:"*"}}),styleSpec:m,style:M,objectElementValidators:{glyphs:Kr}})}function Zt(M,m=i.a8){return ys(La(M,m))}const Er=M=>ys(lr(M)),Bt=M=>ys(Wr(M)),Se=M=>ys(Nn(M)),Oe=M=>ys(ai(M)),Ye=M=>ys(ns(M)),yt=M=>ys(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 W in v){const ee=W.match(/^(.*)-transition$/);$=$.concat(ee&&z[ee[1]]&&z[ee[1]].transition?dn({key:W,value:v[W],valueSpec:D.transition,style:E,styleSpec:D}):z[W]?dn({key:W,value:v[W],valueSpec:z[W],style:E,styleSpec:D}):[new i.a5(W,v[W],`unknown property "${W}"`)])}return $}(M)),bt=M=>ys(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 W in v){const ee=W.match(/^(.*)-transition$/);$=$.concat(ee&&z[ee[1]]&&z[ee[1]].transition?dn({key:W,value:v[W],valueSpec:D.transition,style:E,styleSpec:D}):z[W]?dn({key:W,value:v[W],valueSpec:z[W],style:E,styleSpec:D}):[new i.a5(W,v[W],`unknown property "${W}"`)])}return $}(M)),Tt=M=>ys($r(M)),Ht=M=>ys(Nr(M)),Ut=M=>ys(fn(M)),Xt=M=>ys(Yr(M)),Ts=M=>ys(i.a9(M));function ys(M){return M.slice().sort((m,v)=>m.line&&v.line?m.line-v.line:0)}function ir(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 Lr=i.a8.light;let Hr;class Rr extends i.E{constructor(m,v="flat"){super(),this._transitionable=new i.aa(Hr||(Hr=new i.ab({anchor:new i.ac(Lr.anchor),position:new i.ad(Lr.position),color:new i.ac(Lr.color),intensity:new i.ac(Lr.intensity)}))),this.setLight(m,v),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(m,v,E={}){this._validate(Bt,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)&&ir(this,m.call(Zt,Object.assign({value:v,style:{glyphs:!0,sprite:!0},styleSpec:i.a8})))}}const un=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(un.source),exaggeration:new i.ac(un.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 W=1-Math.min(1,Math.exp((m-z)/($-z)*-6));return W*=W*W,W=Math.min(1,1.00747*W),W*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 W=[[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 W){const je=i.ah([],de,m),be=i.ai(je);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 zi 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(Ye,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),W=z.elevation?z.elevation.getAtPointOrZero($):0;return wo(E,$.x,$.y,W,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)&&ir(this,m.call(Zt,Object.assign({value:v,style:{glyphs:!0,sprite:!0},styleSpec:i.a8})))}}let tl,ui,Bi,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"),W=this.properties.get("vignette-color");return W.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:W}}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)&&ir(this,M.call(Zt,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)&&ir(this,M.call(Zt,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=()=>Bi||(Bi=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]),W=z.add($)._div(2);E=[z,$],D=i.as(z,$).every(ee=>v.isPointAboveHorizon(ee))&&v.isPointAboveHorizon(W)}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 W=m.tileID.wrap+($.unwrapped?D:0);const ee=$.polygon.map(rt=>i.au(m.tileTransform,rt,W));if(!i.av(ee,0,0,i.an,i.an))return;W=m.tileID.wrap+(this.screenGeometryMercator.unwrapped?D:0);const ne=this.screenGeometryMercator.polygon.map(rt=>i.aw(m.tileTransform,rt,W)),de=ne.map(rt=>new i.P(rt[0],rt[1])),je=v.getFreeCameraOptions().position||new i.ag(0,0,0),be=i.aw(m.tileTransform,je,W),Ae=ne.map(rt=>{const st=i.ax(rt,rt,be);return i.ay(st,st),new i.az(be,st)}),Fe=i.aA(m,1,v.zoom)*v._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:de,tilespaceRays:Ae,bufferedTilespaceGeometry:ee,bufferedTilespaceBounds:(Ie=i.aB(ee),Ie.min.x=i.aC(Ie.min.x,0,i.an),Ie.min.y=i.aC(Ie.min.y,0,i.an),Ie.max.x=i.aC(Ie.max.x,0,i.an),Ie.max.y=i.aC(Ie.max.y,0,i.an),Ie),tile:m,tileID:m.tileID,pixelToTileUnitsFactor:Fe};var Ie}_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 W=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,W),i.aE(ne,ne,W),i.aE(de,de,W);const je=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,je)&&ee[3]1?Om(z.slice(0,rt),$):[],mt=rtnew i.P(kd(Rt.x),Rt.y)),mt=mt.map(Rt=>new i.P(kd(Rt.x),Rt.y));const at=[...ct];at.length===0&&at.push(mt[mt.length-1]);const zt=i.am(at[at.length-1].y,(mt.length===0?ct[0]:mt[0]).y,st);let wt;return wt=Ae?[new i.P(0,zt),new i.P(0,0),new i.P(1,0),new i.P(1,zt)]:[new i.P(1,zt),new i.P(1,1),new i.P(0,1),new i.P(0,zt)],at.push(...wt),mt.length===0?at.push(ct[0]):at.push(...mt),{polygon:at.map(Rt=>new i.ag(Rt.x,Rt.y)),unwrapped:!1}}(m,v);if(E)return E;const D=function(z,$){let W=!1,ee=-1/0,ne=0;for(let je=0;jeee&&(ee=z[je].x,ne=je);for(let je=0;je.5&&(Ae.x{je.x-=1}),{polygon:z,unwrapped:W}}(Om(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 Om(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 Fm(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(W,ee){if(W)return D(W);if(ee){M.url&&ee.tiles&&M.tiles&&delete M.tiles;const ne=Fm(M,ee,m);if(ne instanceof Error)return D(ne);D(null,ne)}},$=function(W,ee,ne){if(!W)return null;if(!ee&&!ne)return W;ne=ne||W.worldview_default;const de=Object.values(W.language||{});if(de.length===0)return null;const je=Object.values(W.worldview||{});if(je.length===0)return null;const be=de.every(Fe=>Fe===ee),Ae=je.every(Fe=>Fe===ne);return be&&Ae?W:ee in(W.language_options||{})||ne in(W.worldview_options||{})?null:W.language_options&&W.worldview_options?W: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:W,...ee}=M;z(null,ee)})}function zm(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($))):W&&(this._setTileJSON(W),Ue(W.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 W=$.provider;if(!W&&"url"in $&&$.url&&(W=i.aM($.url)),!W)return null;const ee=i.g.TILE_PROVIDER_URLS[W];if(!ee)return null;let ne;try{ne=new URL(ee,i.g.API_URL).href}catch{return i.w(`TileProvider "${W}" has an invalid URL: "${ee}"`),null}return{name:W,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},($,W)=>{if(E.signal.aborted)return;if($)return void v($);const ee=W?W.find(ne=>ne!=null):null;if(ee){const ne=Fm(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,W=$?{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:W,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,(je,be)=>{if(je||!be)ne.call(this,je);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,je){return delete m.request,m.aborted?v(null):de?v(de):(je&&je.resourceTiming&&(m.resourceTiming=je.resourceTiming),this.map._refreshExpiredTiles&&je&&m.setExpiryData(je),m.loadVectorData(je,this.map.painter),i.aQ(this.dispatcher),v(null,je),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),Ue(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,$,W)=>{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(W);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:W,y:ee,z:ne}=v;if(!isFinite(W)||!isFinite(ee)||!isFinite(ne))throw new Error("Invalid MRT header");const de=2**ne,je=de*i.aH(M),be=de*i.aL(m);return function([Ae,Fe],Ie,{scaled:rt=!0}={}){if(!Ie)throw new Error("bandView is undefined");const{data:st,tileSize:ct,buffer:mt,offset:at,scale:zt,dimension:wt}=Ie;if(Ae<-mt||Ae>ct+mt||Fe<-mt||Fe>ct+mt)throw new Error(`Point (${Ae}, ${Fe}) out of bounds for tileSize=${ct}, buffer=${mt}`);const Rt=(Fe+mt)*(ct+2*mt)+(Ae+mt);if(new Uint32Array(st.buffer)[Rt]===4294967295)return null;let ft=[];ft=rt?[]:new Ie.data.constructor(wt);for(let _t=0;_t{if(delete m.request,m.aborted)return m.state="unloaded",v(null);if(W)return W.name==="AbortError"?void 0:(m.state="errored",v(W));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 W=m.textureDescriptorPerLayer.get(v.id);return Object.assign({},W,{texture:m.texturePerLayer.get(v.id)})}getImages(m,v){const E=new Map;for(const D of m)for(const z of v){const[$,W]=z.split("/"),ee=D.getLayer($);if(!ee||!ee.hasBand(W)||!ee.hasDataForBand(W))continue;const{bytes:ne,tileSize:de,buffer:je}=ee.getBandView(W),be=de+2*je,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 $={},W=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:je}of ne.dataIndex)for(const be of je)E.bands&&!E.bands.includes(be)||(W.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)),W.delete(i.F(ee,be)),W.size===0&&z($)})},!1))}W.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,$,W)=>{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(W);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,($,W)=>{$?z($):D(W?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&&(W[new i.aR(M.overscaledZ,D,m.z,E,m.y-1).key]={backfilled:!1},W[new i.aR(M.overscaledZ,M.wrap,m.z,m.x,m.y-1).key]={backfilled:!1},W[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,$,(W,ee)=>z&&!ee?(M.state="loaded",m(null)):(delete M.request,M.destroy(!1),M.aborted?m(null):W?m(W):(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)),Ue(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(W){return delete M.request,M.aborted?(M.state="unloaded",m(null)):W===void 0?(M.state="errored",m(null)):W===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}(W)?(this.loadTileData(M,W),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(W=>{W.name!=="AbortError"&&(M.state="errored",m(W))});$.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,W=m.sourceCache.tilesIn(M,m.has3DLayers,D);W.sort(Bx);const ee=[];for(const ne of W){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 je=de.styleLayer.queryRenderedFeatures(M,m.sourceCache,E);Object.keys(je).length&&ee.push({wrappedTileID:0,queryResults:je})}}return ee.length===0?{}:function(ne){const de={},je={};for(const be of ne){const Ae=be.queryResults,Fe=be.wrappedTileID,Ie=je[Fe]=je[Fe]||{};for(const rt in Ae){const st=Ae[rt],ct=Ie[rt]=Ie[rt]||{},mt=de[rt]=de[rt]||[];for(const at of st)ct[at.featureIndex]||(ct[at.featureIndex]=!0,mt.push(at))}}return de}(ee)}function zx(M,m,v,E,D,z){const $={},W=E.queryRenderedSymbols(M),ee=[];for(const ne of Object.keys(W).map(Number))ee.push(D[ne]);ee.sort(Bx);for(const ne of ee){const de=ne.featureIndex.lookupSymbolFeatures(W[ne.bucketInstanceId],ne.bucketIndex,ne.sourceLayerIndex,m,v,z);for(const je in de){const be=$[je]=$[je]||[],Ae=de[je];Ae.sort((Fe,Ie)=>{const rt=ne.featureSortOrder;if(rt){const st=rt.indexOf(Fe.featureIndex);return rt.indexOf(Ie.featureIndex)-st}return Ie.featureIndex-Fe.featureIndex});for(const Fe of Ae)be.push(Fe)}}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||$,W)}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 W=this.actor;if(!W)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 je=(Ie,rt)=>{ee.complete(Ie,rt),Ie?D(Ie):(de.forEach(st=>st(null,rt)),this._taskQueue.delete(ne))},be=(Ie,rt)=>{if(Ie)return D(Ie);const st=W.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:rt,task:ee},je,void 0,!0);if(v!==null){const ct=this._workQueuePerLayer.get(v)||[];ct.push(()=>{st&&st.cancel(),ee.cancel()}),this._workQueuePerLayer.has(v)||this._workQueuePerLayer.set(v,ct)}};let Ae;try{Ae=$.getLayer(m)}catch(Ie){if(this.state==="reloading")return;throw Ie}if(!Ae)return void D(new Error(`Unknown sourceLayer "${m}"`));if(Ae.hasDataForBand(E))return de.forEach(Ie=>Ie(null,null)),void this._taskQueue.delete(ne);const Fe=Ae.getDataRange([E]);if(ee=$.createDecodingTask(Fe),!ee||ee.tasks.length)if(v!==null&&this.flushQueues(v),this.entireBuffer)be(null,this.entireBuffer.slice(Fe.firstByte,Fe.lastByte+1));else{const Ie=Object.assign({},this.requestParams,{headers:{Range:`bytes=${Fe.firstByte}-${Fe.lastByte}`}}),rt=i.b1(Ie,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:W,offset:ee,scale:ne}=D.getBandView(E),de=$+2*W,je=new i.q({width:de,height:de},z),be=this.texturePerLayer.get(v);be&&be instanceof i.T&&be.update(je,{premultiply:!1}),this.textureDescriptorPerLayer.set(v,{layer:m,band:E,img:je,buffer:W,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 W=String(v),ee=Object.assign({},E[W],D[W]);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 W in z)delete $[W];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 W of Object.keys(this.deletedStates[D][$]))delete this.state[D][$][W];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,W=z.tileID,ee=new i.P($.canonical.x,$.canonical.y)._rotate(this.transform.angle),ne=new i.P(W.canonical.x,W.canonical.y)._rotate(this.transform.angle);return $.overscaledZ-W.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 W=this.map.painter.terrain;this.update(this.transform,W.getScaledDemTileSize(),!0),W.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,$,W),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 W=$.tileID;for(;$&&$.tileID.overscaledZ>v+1;){const ne=$.tileID.scaledTo($.tileID.overscaledZ-1);$=this._tiles[ne.key],$&&$.hasData()&&(W=ne)}let ee=W;for(;ee.overscaledZ>v;)if(ee=ee.scaledTo(ee.overscaledZ-1),m[ee.key]){D[W.key]=W;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,W=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,$):$;this._cache.setMaxSize(W)}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 W,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],Fe=Math.floor(Ae)-Math.log2(ne.getDemUpscale());ee>Fe&&(ee=Fe)}const de=this._maxzoomOverride===null&&this._source.reparseOverscaled;if(this.used||this.usedForTerrain){if(this._source.tileID)W=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,W=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"&&(W.push(new i.aR(1,0,1,0,0)),W.push(new i.aR(1,0,1,1,0)),W.push(new i.aR(1,0,1,0,1)),W.push(new i.aR(1,0,1,1,1)))}else if(W=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);W=W.filter(Fe=>Ae(Fe))}}else W=[];if(W.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}),Fe=Math.min(Ae,ee);if($){const Ie=m.extendTileCover(W,Fe);for(const rt of Ie)W.push(rt)}else if(z){const Ie=this.transform.getFrustum(Fe),rt=m.extendTileCoverToNearPlane(W,Ie,Fe);for(const st of rt)W.push(st);if(Fe>=18&&this._hasTunnelGeometry()){const st=m.extendTileCoverForTunnels(W,Ie,Fe,20);for(const ct of st)W.push(ct)}}else if(this.castsShadows&&D){const Ie=m.extendTileCover(W,Fe,D,16);for(const rt of Ie)this._shadowCasterTiles[rt.key]=!0,W.push(rt)}}const je=this._updateRetainedTiles(W);if(this._supportsFading&&W.length!==0){const Ae={},Fe={},Ie=i.o.now(),rt=Object.keys(je);for(const ct of rt){const mt=je[ct],at=this._tiles[ct];if(!at||at.fadeEndTime!==void 0&&at.fadeEndTime<=Ie)continue;const zt=this.findLoadedParent(mt,Math.max(mt.overscaledZ-yh.maxOverzooming,this._source.minzoom));zt&&(this._addTile(zt.tileID),Ae[zt.tileID.key]=zt.tileID),Fe[ct]=mt}const st=W[W.length-1].overscaledZ;for(const ct in this._tiles){const mt=this._tiles[ct];if(je[ct]||!mt.hasData())continue;let at=mt.tileID;for(;at.overscaledZ>st;){at=at.scaledTo(at.overscaledZ-1);const zt=this._tiles[at.key];if(zt&&zt.hasData()&&Fe[at.key]){je[ct]=mt.tileID;break}}}for(const ct in Ae)je[ct]||(this._coveredTiles[ct]=!0,je[ct]=Ae[ct])}for(const Ae in je)this._tiles[Ae].clearFadeHold();const be=i.b3(this._tiles,je);for(const Ae of be){const Fe=this._tiles[Ae];Fe.hasSymbolBuckets&&!Fe.holdingForFade()?Fe.setHoldDuration(this.map._fadeDuration):Fe.hasSymbolBuckets&&!Fe.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),W=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 je=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&&je&&(de=this._addTile(Ae)),de&&(v[Ae.key]=Ae,je=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",W=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 je=ne.tileID.canonical;if(je.z===0){const be=[Math.abs(i.aC(W,...Mf(je,-1))-W),Math.abs(i.aC(W,...Mf(je,1))-W)];de=[0,2*be.indexOf(Math.min(...be))-1]}else{const be=[Math.abs(i.aC(W,...Mf(je,-1))-W),Math.abs(i.aC(W,...Mf(je,0))-W),Math.abs(i.aC(W,...Mf(je,1))-W)];de=[be.indexOf(Math.min(...be))-1]}}else de=[0];for(const je of de){const be=m.containsTile(ne,z,v,je);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 W=1/(1<<$.canonical.z);z[$.key]=(($.canonical.x+.5)*W+$.wrap-E[0])*D[0]+(($.canonical.y+.5)*W-E[1])*D[1]-E[2]*D[2]}return v.sort(($,W)=>z[$.key]-z[W.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 W=Array.from(E.values());i.t(W,(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,je=>{this._source.type==="raster-dem"&&de.dem&&this._backfillDEM(de),ne(je,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 W=1;z.type==="fill-extrusion"?W=D.visible?z.paint.get("fill-extrusion-vertical-scale"):0:z.type==="building"&&(W=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:W})}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-$)/W:0;return this.points[z].mult(1-ee).add(this.points[v].mult(ee))}}class St{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 W=[];if(m<=0&&v<=0&&this.width<=E&&this.height<=D){if(z)return!0;for(let ee=0;ee0:W}_queryCircle(m,v,E,D,z){const $=m-E,W=m+E,ee=v-E,ne=v+E;if(W<0||$>this.width||ne<0||ee>this.height)return!D&&[];const de=[];return this._forEachCell($,ee,W,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,$,W,ee){const ne=W.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 Fe=4*Ae;if(m<=be[Fe+2]&&v<=be[Fe+3]&&E>=be[Fe+0]&&D>=be[Fe+1]&&(!ee||ee(this.boxKeys[Ae]))){if(W.hitTest)return $.push(!0),!0;$.push({key:this.boxKeys[Ae],x1:be[Fe],y1:be[Fe+1],x2:be[Fe+2],y2:be[Fe+3]})}}}const je=this.circleCells[z];if(je!==null){const be=this.circles;for(const Ae of je)if(!ne.circle[Ae]){ne.circle[Ae]=!0;const Fe=3*Ae;if(this._circleAndRectCollide(be[Fe],be[Fe+1],be[Fe+2],m,v,E,D)&&(!ee||ee(this.circleKeys[Ae]))){if(W.hitTest)return $.push(!0),!0;{const Ie=be[Fe],rt=be[Fe+1],st=be[Fe+2];$.push({key:this.circleKeys[Ae],x1:Ie-st,y1:rt-st,x2:Ie+st,y2:rt+st})}}}}}_queryCellCircle(m,v,E,D,z,$,W,ee){const ne=W.circle,de=W.seenUids,je=this.boxCells[z];if(je!==null){const Ae=this.bboxes;for(const Fe of je)if(!de.box[Fe]){de.box[Fe]=!0;const Ie=4*Fe;if(this._circleAndRectCollide(ne.x,ne.y,ne.radius,Ae[Ie+0],Ae[Ie+1],Ae[Ie+2],Ae[Ie+3])&&(!ee||ee(this.boxKeys[Fe])))return $.push(!0),!0}}const be=this.circleCells[z];if(be!==null){const Ae=this.circles;for(const Fe of be)if(!de.circle[Fe]){de.circle[Fe]=!0;const Ie=3*Fe;if(this._circlesCollide(Ae[Ie],Ae[Ie+1],Ae[Ie+2],ne.x,ne.y,ne.radius)&&(!ee||ee(this.circleKeys[Fe])))return $.push(!0),!0}}}_forEachCell(m,v,E,D,z,$,W,ee){const ne=this._convertToXCellCoord(m),de=this._convertToYCellCoord(v),je=this._convertToXCellCoord(E),be=this._convertToYCellCoord(D);for(let Ae=ne;Ae<=je;Ae++)for(let Fe=de;Fe<=be;Fe++)if(z.call(this,m,v,E,D,this.xCellCount*Fe+Ae,$,W,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 W=D-m,ee=z-v,ne=E+$;return ne*ne>W*W+ee*ee}_circleAndRectCollide(m,v,E,D,z,$,W){const ee=($-D)/2,ne=Math.abs(m-(D+ee));if(ne>ee+E)return!1;const de=(W-z)/2,je=Math.abs(v-(z+de));if(je>de+E)return!1;if(ne<=ee||je<=de)return!0;const be=ne-ee,Ae=je-de;return be*be+Ae*Ae<=E*E}}const Os=Math.tan(85*Math.PI/180);function ar(M,m,v,E,D,z,$){const W=i.bb();if(v)if(z.name==="globe"){const ee=i.bc(D,m);i.aD(W,W,ee)}else{const ee=i.bd([],$);W[0]=ee[0],W[1]=ee[1],W[4]=ee[2],W[5]=ee[3],E||i.ba(W,W,D.angle)}else i.aD(W,D.labelPlaneMatrix,M);return W}function tn(M,m,v,E,D,z,$){const W=ar(M,m,v,E,D,z,$);return z.name==="globe"&&v||(W[2]=W[6]=W[10]=W[14]=0),W}function xn(M,m,v,E,D,z,$){if(v){if(z.name==="globe"){const W=ar(M,m,v,E,D,z,$);return i.b7(W,W),i.aD(W,M,W),W}{const W=i.b8(M),ee=i.b9([]);return ee[0]=$[0],ee[1]=$[1],ee[4]=$[2],ee[5]=$[3],i.aD(W,W,ee),E||i.ba(W,W,-D.angle),W}}return D.glCoordMatrix}function oa(M,m,v,E){const D=[M,m,v,1];v?i.aE(D,D,E):nn(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,$,W,ee,ne,de=1){const je=v.transform,be=E?M.textSizeData:M.iconSizeData,Ae=i.bj(be,v.transform.zoom,de),Fe=je.projection.name==="globe",Ie=[256/v.width*2+1,256/v.height*2+1],rt=E?M.text.dynamicLayoutVertexArray:M.icon.dynamicLayoutVertexArray;rt.clear();let st=null;Fe&&(st=E?M.text.globeExtVertexArray:M.icon.globeExtVertexArray);const ct=M.lineVertexArray,mt=E?M.text.placedSymbolArray:M.icon.placedSymbolArray,at=v.transform.width/v.transform.height;let zt,wt=!1;for(let Rt=0;RtMath.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)>Os}(v,E)?m===1?{needsFlipping:!0}:null:v<0?{needsFlipping:!0}:null}function O0(M,m,v,E,D,z,$,W,ee,ne,de,je,be,Ae,Fe,Ie,rt,st,ct,mt){const at=m/24,zt=M.lineOffsetX*at,wt=M.lineOffsetY*at,{lineStartIndex:Rt,glyphStartIndex:ft,numGlyphs:_t,segment:At,writingMode:Wt,flipState:qt}=M,rs=Rt+M.lineLength,Jt=Ns=>{if(de){const[ts,as,cs]=Ns.up,Qs=ne.length;i.bm(de,Qs+0,ts,as,cs),i.bm(de,Qs+1,ts,as,cs),i.bm(de,Qs+2,ts,as,cs),i.bm(de,Qs+3,ts,as,cs)}const[As,Kt,Vt]=Ns.point;i.bn(ne,As,Kt,Vt,Ns.angle)};if(_t>1){const Ns=Bm(at,W,zt,wt,v,je,be,M,ee,z,Ae,Ie,!1,rt,st,ct,mt);if(!Ns)return{notEnoughRoom:!0};if(E&&!v){let[As,Kt,Vt]=Ns.first.point,[ts,as,cs]=Ns.last.point;[As,Kt]=oa(As,Kt,Vt,$),[ts,as]=oa(ts,as,cs,$);const Qs=Zh(Wt,qt,(ts-As)*Fe,as-Kt);if(M.flipState=Qs&&Qs.needsFlipping?1:2,Qs)return Qs}Jt(Ns.first);for(let As=ft+1;As0?ts:FE(be,Vt,As,1,D,void 0,rt,st.canonical),cs=Zh(Wt,qt,(as[0]-As[0])*Fe,as[1]-As[1]);if(M.flipState=cs&&cs.needsFlipping?1:2,cs)return cs}const Ns=FC(at*W.getoffsetX(ft),zt,wt,v,je,be,At,Rt,rs,ee,z,Ae,Ie,!1,!1,rt,st,ct,mt);if(!Ns)return{notEnoughRoom:!0};Jt(Ns)}return{}}function Aa(M,m,v,E,D){const{x:z,y:$,z:W}=E.projectTilePoint(M.x,M.y,m);if(!D)return oa(z,$,W,v);const[ee,ne,de]=D.getElevation(M,D.elevation,D.elevationFeature);return oa(z+ee,$+ne,W+de,v)}function FE(M,m,v,E,D,z,$,W){const ee=Aa(M.sub(m)._unit()._add(M),W,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,$,W,ee,ne,de,je,be,Ae,Fe,Ie,rt,st,ct){const mt=E?M-m:M+m;let at=mt>0?1:-1,zt=0;E&&(at*=-1,zt=Math.PI),at<0&&(zt+=Math.PI);let wt=W+$+(at>0?0:1)|0,Rt=D,ft=D,_t=0,At=0;const Wt=Math.abs(mt),qt=[],rs=[];let Jt=z,Ns=Jt,As=i.be([]);const Kt=()=>FE(Ns,Jt,ft,Wt-_t+1,de,be,Ie,rt.canonical);for(;_t+At<=Wt;){if(wt+=at,wt=ee)return null;if(ft=Rt,Ns=Jt,qt.push(ft),Ae&&rs.push(Ns),Jt=new i.P(ne.getx(wt),ne.gety(wt)),Rt=je[wt],!Rt){const Ar=Aa(Jt,rt.canonical,de,Ie,be);Rt=Ar[3]>0?je[wt]=Ar:Kt()}_t+=At;const Cs=i.ax([],Rt,ft),_r=i.bf(ft,Rt);if(v&&_r>0&&At>0&&i.bi(As,Cs)/(At*_r)0,mt),Rt=ne*wt.perspectiveRatio,ft=(E.x1*v+W.x-E.padding)*Rt+wt.point.x,_t=(E.y1*v+W.y-E.padding)*Rt+wt.point.y,At=(E.x2*v+W.x+E.padding)*Rt+wt.point.x,Wt=(E.y2*v+W.y+E.padding)*Rt+wt.point.y,qt=wt.perspectiveRatio<=.55||wt.occluded;return!this.isInsideGrid(ft,_t,At,Wt)||!ee&&this.grid.hitTest(ft,_t,At,Wt,je)||qt?{box:[],offscreen:!1,occluded:wt.occluded}:{box:[ft,_t,At,Wt],offscreen:this.isOffscreen(ft,_t,At,Wt),occluded:!1}}placeCollisionCircles(m,v,E,D,z,$,W,ee,ne,de,je,be,Ae,Fe,Ie,rt){const st=[],ct=this.transform.elevation,mt=m.getProjection(),at=m.elevationType==="road",zt=!!ct||at,wt=i.bu.getAtTileOffsetFunc(rt,this.transform.center.lat,this.transform.worldSize,mt),Rt=new i.P(E.tileAnchorX,E.tileAnchorY),ft=new i.P(E.tileAnchorX,E.tileAnchorY);let{x:_t,y:At,z:Wt}=mt.projectTilePoint(ft.x,ft.y,rt.canonical),qt=null;if(zt){const _r=at?m.getElevationFeatureForText(D):null;qt={getElevation:wt,elevation:ct,elevationFeature:_r};const[Ar,hr,yr]=wt(Rt,ct,_r);_t+=Ar,At+=hr,Wt+=yr}const rs=mt.name==="globe",Jt=this.projectAndGetPerspectiveRatio(ee,_t,At,Wt,rt,rs||!!ct||this.transform.pitch>0,mt),{perspectiveRatio:Ns}=Jt,As=(be?W/Ns:W*Ns)/i.by,Kt=oa(_t,At,Wt,ne),Vt=E.lineOffsetX*As,ts=E.lineOffsetY*As,as=i.ap(m.layers[0].layout.get("text-max-angle")),cs=Math.cos(as),Qs=Jt.signedDistanceFromCamera>0?Bm(As,$,Vt,ts,at&&E.flipState===1,Kt,ft,E,z,ne,{},zt&&!be?qt:null,be&&zt,mt,rt,be,cs):null;let Hs=!1,Gs=!1,Cs=!0;if(Qs&&!Jt.occluded){const _r=.5*Fe*Ns+Ie,Ar=new i.P(-100,-100),hr=new i.P(this.screenRightBoundary,this.screenBottomBoundary),yr=new OC,{first:Qr,last:vn}=Qs,hn=Qr.path.length;let qn=[];for(let mn=hn-1;mn>=1;mn--)qn.push(Qr.path[mn]);for(let mn=1;mn(zt&&!rs&&(mi=wt(Wimn[3]<=0)&&(qn=[]));let Un=[];if(qn.length>0){let mn=1/0,Ea=-1/0,mi=1/0,Wi=-1/0;for(const ji of qn)mn=Math.min(mn,ji[0]),mi=Math.min(mi,ji[1]),Ea=Math.max(Ea,ji[0]),Wi=Math.max(Wi,ji[1]);Ea>=Ar.x&&mn<=hr.x&&Wi>=Ar.y&&mi<=hr.y&&(Un=[qn.map(ji=>new i.P(ji[0],ji[1]))],(mnhr.x||mihr.y)&&(Un=i.bv(Un,Ar.x,Ar.y,hr.x,hr.y)))}for(const mn of Un){yr.reset(mn,.25*_r);let Ea=0;Ea=yr.length<=.5*_r?1:Math.ceil(yr.paddedLength/qr)+1;for(let mi=0;mi0?(i.aE(ee,ee,m),this.fogState&&z&&W.name!=="globe"&&(ne=function(be,Ae,Fe,Ie,rt,st){const ct=st.calculateFogTileMatrix(rt),mt=[Ae,Fe,Ie];return i.ah(mt,mt,ct),ua(be,i.ai(mt),st.pitch,st._fov)}(this.fogState,v,E,D,z.toUnwrapped(),this.transform)>.9)):nn(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(W)/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),W=-(z-.5)*m,ee=-($-.5)*v,ne=i.bG(M,E);return new i.P(W+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),W=E.latestFeatureIndex;if(!$||!W||v.fqid!==$.layerIds[0])return;const ee=$.layers[0].layout,ne=$.layers[0].paint,de=E.collisionBoxArray,je=Math.pow(2,this.transform.zoom-E.tileID.overscaledZ),be=E.tileSize/i.an,Ae=E.tileID.toUnwrapped();this.transform.setProjection($.projection);const Fe=(Ie=E.tileID,rt=$.getProjection(),st=this.transform,rt.name===this.projection?st.calculateProjMatrix(Ie.toUnwrapped()):I1(st,rt,Ie));var Ie,rt,st;const ct=ee.get("text-pitch-alignment")==="map",mt=ee.get("text-rotation-alignment")==="map";v.compileFilter(v.options);const at=v.dynamicFilter(),zt=v.dynamicFilterNeedsFeature(),wt=v.dynamicFilterNeedsGeometry(),Rt=this.transform.calculatePixelsToTileUnitsMatrix(E),ft=tn(Fe,E.tileID.canonical,ct,mt,this.transform,$.getProjection(),Rt);let _t=null;const At=$.getProjection().createInversionMatrix(this.transform,E.tileID.canonical);if(ct){const ts=xn(Fe,E.tileID.canonical,ct,mt,this.transform,$.getProjection(),Rt);_t=i.aD([],this.transform.labelPlaneMatrix,ts)}let Wt=null;at&&E.latestFeatureIndex&&(Wt={unwrappedTileID:Ae,dynamicFilter:at,dynamicFilterNeedsFeature:zt,needGeometry:wt}),this.retainedQueryData[$.bucketInstanceId]=new si($.bucketInstanceId,W,$.sourceLayerIndex,$.index,E.tileID);const[qt,rs]=$.layers[0].layout.get("text-size-scale-range"),Jt=i.aC(z,qt,rs),[Ns,As]=ee.get("icon-size-scale-range"),Kt=i.aC(z,Ns,As),Vt={bucket:$,layout:ee,paint:ne,posMatrix:Fe,invMatrix:At,mercatorCenter:[i.aH(this.transform.center.lng),i.aL(this.transform.center.lat)],textLabelPlaneMatrix:ft,labelToScreenMatrix:_t,clippingData:Wt,scale:je,textPixelRatio:be,holdingForFade:E.holdingForFade(),collisionBoxArray:de,partiallyEvaluatedTextSize:i.bj($.textSizeData,this.transform.zoom,Jt),partiallyEvaluatedIconSize:i.bj($.iconSizeData,this.transform.zoom,Kt),collisionGroup:this.collisionGroups.get($.sourceID),latestFeatureIndex:E.latestFeatureIndex};if(D)for(const ts of $.sortKeyRanges){const{sortKey:as,symbolInstanceStart:cs,symbolInstanceEnd:Qs}=ts;m.push({sortKey:as,symbolInstanceStart:cs,symbolInstanceEnd:Qs,parameters:Vt})}else m.push({symbolInstanceStart:0,symbolInstanceEnd:$.symbolInstances.length,parameters:Vt})}attemptAnchorPlacement(m,v,E,D,z,$,W,ee,ne,de,je,be,Ae,Fe,Ie,rt,st,ct,mt,at,zt){const{textOffset0:wt,textOffset1:Rt,crossTileID:ft}=Ie,_t=[wt,Rt],At=Nu(m,$,W,_t,ee),Wt=this.collisionIndex.placeCollisionBox(st,ee,v,E,D,z,sy(At.x,At.y,ne,de,this.transform.angle),Fe,je,be,Ae.predicate);if(mt){const qt=st.getSymbolInstanceIconSize(zt,this.transform.zoom,Ie.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(st,qt,mt,E,D,z,sy(At.x,At.y,ne,de,this.transform.angle),Fe,je,be,Ae.predicate).box.length===0)return}if(Wt.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:W,anchor:m,textScale:ee,prevAnchor:qt},this.markUsedJustification(st,m,Ie,ct),st.allowVerticalPlacement&&(this.markUsedOrientation(st,ct,Ie),this.placedOrientations[ft]=ct),{shift:At,placedGlyphBoxes:Wt}}}placeLayerBucketPart(m,v,E,D,z=1){const{bucket:$,layout:W,paint:ee,posMatrix:ne,textLabelPlaneMatrix:de,labelToScreenMatrix:je,clippingData:be,textPixelRatio:Ae,mercatorCenter:Fe,invMatrix:Ie,holdingForFade:rt,collisionBoxArray:st,partiallyEvaluatedTextSize:ct,partiallyEvaluatedIconSize:mt,collisionGroup:at,latestFeatureIndex:zt}=m.parameters,wt=W.get("text-optional"),Rt=W.get("icon-optional"),ft=W.get("text-allow-overlap"),_t=W.get("icon-allow-overlap"),At=W.get("text-rotation-alignment")==="map",Wt=W.get("icon-rotation-alignment")==="map",qt=W.get("text-pitch-alignment")==="map",rs=ee.get("symbol-z-offset"),Jt=W.get("symbol-elevation-reference")==="sea",Ns=W.get("symbol-placement"),[As,Kt]=W.get("text-size-scale-range"),[Vt,ts]=W.get("icon-size-scale-range"),as=i.aC(z,As,Kt),cs=i.aC(z,Vt,ts),Qs=W.get("text-variable-anchor"),Hs=At&&Ns!=="point",Gs=Wt&&Ns!=="point",Cs=Qs&&$.hasTextData(),_r=$.hasIconTextFit()&&Cs&&$.hasIconData();this.transform.setProjection($.projection);const Ar=Cs||Hs,hr=Gs||_r;let yr=ft&&(_t||!$.hasIconData()||Rt),Qr=_t&&(ft||!$.hasTextData()||wt);const vn=!rs.isConstant();!$.collisionArrays&&st&&$.deserializeCollisionBoxes(st),E&&D&&$.updateCollisionDebugBuffers(this.transform.zoom,st,as,cs);const hn=(qr,Un,mn)=>{const{crossTileID:Ea,numVerticalGlyphVertices:mi}=qr;let Wi=null;if(be&&be.dynamicFilterNeedsFeature||vn){const Ci=this.retainedQueryData[$.bucketInstanceId],Pi=zt.loadFeature({featureIndex:qr.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(qr.tileAnchorX,qr.tileAnchorY),this.transform.calculateDistanceTileData(be.unwrappedTileID)))return this.placements[Ea]=new qx(!1,!1,!1,!0),void v.add(Ea);const ji=rs.evaluate(Wi,{});if((qr.zOffset||0)+(ji||0)>0&&this.frontCutoffStart>0){const Ci=2*this.frontCutoffStart-1,Pi=[qr.tileAnchorX,qr.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?ji:ji+i.bu.getAtTileOffset(Ci.tileID,new i.P(Ci.tileAnchorX,Ci.tileAnchorY),Pi,Cl),Ci.elevation+=qr.zOffset},bh=mn.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,qr))}return Fo},Pi=(ci,Fo)=>{if($.allowVerticalPlacement&&mi>0&&mn.verticalTextBox){for(const Ed of $.writingModes)if(Ed===i.bk.vertical?(kn=Fo(),$i=kn):kn=ci(),kn&&kn.box&&kn.box.length)break}else kn=ci()};if(Qs){let ci=Qs;if(this.prevPlacement&&this.prevPlacement.variableOffsets[Ea]){const ho=this.prevPlacement.variableOffsets[Ea];ci.indexOf(ho.anchor)>0&&(ci=ci.filter(wh=>wh!==ho.anchor),ci.unshift(ho.anchor))}const Fo=(ho,wh,uy)=>{const sv=$.getSymbolInstanceTextSize(ct,qr,this.transform.zoom,Un),rv=(ho.x2-ho.x1)*sv+2*ho.padding,t_=(ho.y2-ho.y1)*sv+2*ho.padding,Xx=qr.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,qr,Un,$,uy,Xx,ct,mt);if(hy&&(Of=hy.placedGlyphBoxes,Of&&Of.box&&Of.box.length)){$a=!0,qa=hy.shift;break}}return Of};Pi(()=>Fo(bh,mn.iconBox,i.bk.horizontal),()=>{const ho=mn.verticalTextBox;return ho&&Sc(ho),$.allowVerticalPlacement&&!(kn&&kn.box&&kn.box.length)&&mi>0&&ho?Fo(ho,mn.verticalIconBox,i.bk.vertical):{box:null,offscreen:null,occluded:null}}),kn&&($a=kn.box,Fn=kn.offscreen,Ni=kn.occluded);const Ed=Ci(!(!kn||!kn.box));if(!$a&&this.prevPlacement){const ho=this.prevPlacement.variableOffsets[Ea];ho&&(this.variableOffsets[Ea]=ho,this.markUsedJustification($,ho.anchor,qr,Ed))}}else{const ci=(Fo,Ed)=>{const ho=$.getSymbolInstanceTextSize(ct,qr,this.transform.zoom,Un),wh=this.collisionIndex.placeCollisionBox($,ho,Fo,Fe,Ie,Ar,new i.P(0,0),ft,Ae,ne,at.predicate);return wh&&wh.box&&wh.box.length&&(this.markUsedOrientation($,Ed,qr),this.placedOrientations[Ea]=Ed),wh};Pi(()=>ci(bh,i.bk.horizontal),()=>{const Fo=mn.verticalTextBox;return $.allowVerticalPlacement&&mi>0&&Fo?(Sc(Fo),ci(Fo,i.bk.vertical)):{box:null,offscreen:null,occluded:null}}),Ci(!!(kn&&kn.box&&kn.box.length))}}if(pi=kn,$a=pi&&pi.box&&pi.box.length>0,Fn=pi&&pi.offscreen,Ni=pi&&pi.occluded,qr.useRuntimeCollisionCircles){const Ci=qr.centerJustifiedTextSymbolIndex>=0?qr.centerJustifiedTextSymbolIndex:qr.verticalPlacedTextSymbolIndex,Pi=$.text.placedSymbolArray.get(Ci),ci=i.bl($.textSizeData,ct,Pi),Fo=W.get("text-padding");Vo=this.collisionIndex.placeCollisionCircles($,ft,Pi,Ci,$.lineVertexArray,$.glyphOffsetArray,ci,ne,de,je,E,qt,at.predicate,qr.collisionCircleDiameter*ci/i.by,Fo,this.retainedQueryData[$.bucketInstanceId].tileID),$a=ft||Vo.circles.length>0&&!Vo.collisionDetected,Fn=Fn&&Vo.offscreen,Ni=Vo.occluded}if(mn.iconFeatureIndex&&(cd=mn.iconFeatureIndex),mn.iconBox){const Ci=Pi=>{Sc(Pi);const ci=qr.hasIconTextFit&&qa?sy(qa.x,qa.y,At,qt,this.transform.angle):new i.P(0,0),Fo=$.getSymbolInstanceIconSize(mt,this.transform.zoom,qr.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox($,Fo,Pi,Fe,Ie,hr,ci,_t,Ae,ne,at.predicate)};$i&&$i.box&&$i.box.length&&mn.verticalIconBox?(ra=Ci(mn.verticalIconBox),On=ra.box.length>0):(ra=Ci(mn.iconBox),On=ra.box.length>0),Fn=Fn&&ra.offscreen,Ji=ra.occluded}const Ja=wt||qr.numHorizontalGlyphVertices===0&&mi===0,tm=Rt||qr.numIconVertices===0;if(Ja||tm?tm?Ja||(On=On&&$a):$a=On&&$a:On=$a=On&&$a,$a&&pi&&pi.box&&this.collisionIndex.insertCollisionBox(pi.box,W.get("text-ignore-placement"),$.bucketInstanceId,$i&&$i.box&&ul?ul:_i,at.ID),On&&ra&&this.collisionIndex.insertCollisionBox(ra.box,W.get("icon-ignore-placement"),$.bucketInstanceId,cd,at.ID),Vo&&($a&&this.collisionIndex.insertCollisionCircles(Vo.circles,W.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 Pr);for(let ci=0;ci=0;--Un){const mn=qr[Un];hn($.symbolInstances.get(mn),mn,$.collisionArrays[mn])}$.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 qr=$.getSortedIndexesByZOffset();for(let Un=0;Un=0&&(m.text.placedSymbolArray.get(z).crossTileID=je>=0&&z!==je?0:ne),$>=0&&(m.text.placedSymbolArray.get($).crossTileID=je>=0&&$!==je?0:ne),W>=0&&(m.text.placedSymbolArray.get(W).crossTileID=je>=0&&W!==je?0:ne),ee>=0&&(m.text.placedSymbolArray.get(ee).crossTileID=je>=0&&ee!==je?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:W,rightJustifiedTextSymbolIndex:ee,verticalPlacedTextSymbolIndex:ne}=E,de=m.text.placedSymbolArray;$>=0&&(de.get($).placedOrientation=D),W>=0&&(de.get(W).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:{},W=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 W)this.placedOrientations[ee]||!this.opacities[ee]||this.opacities[ee].isHidden()||(this.placedOrientations[ee]=W[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 W=$.getBucket(m);W&&$.latestFeatureIndex&&m.fqid===W.layerIds[0]&&(this.updateBucketOpacities(W,z,$,$.collisionBoxArray,E,D,$.tileID,m.scope),W.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(W,$.tileID),W.elevationType==="road"&&W.updateRoadElevation($.tileID.canonical),W.updateZOffset())}}updateBucketOpacities(m,v,E,D,z,$,W,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,je=!!m.layers[0].dynamicFilter(),be=new F0(null,0,!1,!1,!0),Ae=ne.get("text-allow-overlap"),Fe=ne.get("icon-allow-overlap"),Ie=ne.get("text-variable-anchor"),rt=ne.get("text-rotation-alignment")==="map",st=ne.get("text-pitch-alignment")==="map",ct=de.get("symbol-z-offset"),mt=ne.get("symbol-elevation-reference")==="sea",at=!ct.isConstant(),zt=new F0(null,0,Ae&&(Fe||!m.hasIconData()||ne.get("icon-optional")),Fe&&(Ae||!m.hasTextData()||ne.get("text-optional")),!0);!m.collisionArrays&&D&&(m.hasIconCollisionBoxData()||m.hasTextCollisionBoxData())&&m.deserializeCollisionBoxes(D);const wt=(ft,_t,At)=>{for(let Wt=0;Wt<_t/4;Wt++)ft.opacityVertexArray.emplaceBack(At)};let Rt=0;$&&m.updateReplacement(W,$),this.collisionIndex.clearClippedSymbolsForBucket(m.bucketInstanceId);for(let ft=0;ft0||Wt>0,Qs=rs>0,Hs=this.placedOrientations[qt],Gs=Hs===i.bk.vertical,Cs=Hs===i.bk.horizontal||Hs===i.bk.horizontalOnly;!cs&&!Qs||as.isHidden()||Rt++;let _r=!1;if((cs||Qs)&&$)for(const Ar of m.activeReplacements){if(i.bz(Ar,z,i.bA.Symbol,ee)||Ar.min.x>Jt||Jt>Ar.max.x||Ar.min.y>Ns||Ns>Ar.max.y)continue;const hr=i.bB(Jt,Ns,W.canonical,Ar.footprintTileId.canonical);if(_r=i.bC(hr,Ar.footprint),_r)break}if(_r&&this.collisionIndex.markSymbolAsClipped(m.bucketInstanceId,_t.featureIndex),cs){const Ar=_r?Ux:D1(as.text);wt(m.text,At,Gs?Ux:Ar),wt(m.text,Wt,Cs?Ux:Ar);const hr=as.text.isHidden(),{leftJustifiedTextSymbolIndex:yr,centerJustifiedTextSymbolIndex:Qr,rightJustifiedTextSymbolIndex:vn,verticalPlacedTextSymbolIndex:hn}=_t,qn=m.text.placedSymbolArray,qr=hr||Gs?1:0;yr>=0&&(qn.get(yr).hidden=qr),Qr>=0&&(qn.get(Qr).hidden=qr),vn>=0&&(qn.get(vn).hidden=qr),hn>=0&&(qn.get(hn).hidden=hr||Cs?1:0);const Un=this.variableOffsets[qt];Un&&this.markUsedJustification(m,Un.anchor,_t,Hs);const mn=this.placedOrientations[qt];mn&&(this.markUsedJustification(m,"left",_t,mn),this.markUsedOrientation(m,mn,_t))}if(Qs){const Ar=_r?Ux:D1(as.icon),{placedIconSymbolIndex:hr,verticalPlacedIconSymbolIndex:yr}=_t,Qr=m.icon.placedSymbolArray,vn=as.icon.isHidden()?1:0;hr>=0&&(wt(m.icon,rs,Gs?Ux:Ar),Qr.get(hr).hidden=vn),yr>=0&&(wt(m.icon,_t.numVerticalIconVertices,Cs?Ux:Ar),Qr.get(yr).hidden=vn)}if(m.hasIconCollisionBoxData()||m.hasTextCollisionBoxData()){const Ar=m.collisionArrays[ft];if(Ar){let hr=new i.P(0,0),yr=!0;if(Ar.textBox||Ar.verticalTextBox){if(Ie){const vn=this.variableOffsets[qt];vn?(hr=Nu(vn.anchor,vn.width,vn.height,vn.textOffset,vn.textScale),rt&&hr._rotate(st?this.transform.angle:-this.transform.angle)):yr=!1}je&&(yr=!as.clipped),Ar.textBox&&z0(m.textCollisionBox.collisionVertexArray,as.text.placed,!yr||Gs,Vt,mt,hr.x,hr.y),Ar.verticalTextBox&&z0(m.textCollisionBox.collisionVertexArray,as.text.placed,!yr||Cs,Vt,mt,hr.x,hr.y)}const Qr=yr&&!!(!Cs&&Ar.verticalIconBox);Ar.iconBox&&z0(m.iconCollisionBox.collisionVertexArray,as.icon.placed,Qr,Vt,mt,_t.hasIconTextFit?hr.x:0,_t.hasIconTextFit?hr.y:0),Ar.verticalIconBox&&z0(m.iconCollisionBox.collisionVertexArray,as.icon.placed,!Qr,Vt,mt,_t.hasIconTextFit?hr.x:0,_t.hasIconTextFit?hr.y:0)}}}if(m.fullyClipped=Rt===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),kl=Math.pow(2,16),ape=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*kl+v*ape+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 W=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,je=de.layout.get("symbol-z-elevate"),be=de.layout.get("symbol-sort-key").constantOr(1)!==void 0,Ae=de.layout.get("symbol-z-order"),Fe=Ae==="viewport-y"||Ae==="auto"&&!(Ae!=="viewport-y"&&be),Ie=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=Fe&&Ie,st=this._inProgressLayer=this._inProgressLayer||new BE(de),ct=i.F(ee.source,ee.scope);if(st.continuePlacement(je||rt?D[ct]:E[ct],this.placement,this._showCollisionBoxes,ee,W,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 qm{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 Ie){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 PO{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 W=D[$];W.tileID=W.tileID.unwrapTo(W.tileID.wrap+v),z[W.tileID.key]=W}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 W in $){const ee=$[W];ee.tileID.isChildOf(m)&&ee.findMatches(v.symbolInstances,m,D)}else{const W=$[m.scaledTo(Number(z)).key];W&&W.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 wr{constructor(m,v,E){this.func=m,this.mask=v,this.range=E}}wr.ReadOnly=!1,wr.ReadWrite=!0,wr.disabled=new wr(519,wr.ReadOnly,[0,1]);const dl=7680;class cn{constructor(m,v,E,D,z,$){this.test=m,this.ref=v,this.mask=E,this.fail=D,this.depthFail=z,this.pass=$}}cn.disabled=new cn({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),W=[$.x-D.x,$.y-D.y,$.z-D.z];v||(v=[0,0,1]),v[2]=Math.abs(v[2]),this.orientation=$C(W,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 W=new Float64Array(16);return i.bT(W,m,v,E,D,z,$),W}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 ipe=(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,$,W){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(W),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,je,Ae,Fe,Ie);ee.has(rt)||(z.push(new i.aR(je,be,Ae,Fe,Ie)),ee.add(rt))};for(let je=0;jebe.canonical.z)continue;const Ae=be.canonical,Fe=be.overscaledZ,Ie=be.wrap,rt=1<0,mt=Ae.y+10,zt=be.wrap-(ct?0:1),wt=be.wrap+(st?0:1),Rt=ct?Ae.x-1:rt-1,ft=st?Ae.x+1:0;if($)E[0]<0?(ne(Fe,wt,Ae.z,ft,Ae.y),E[1]<0&&mt&&(ne(Fe,Ie,Ae.z,Ae.x,Ae.y+1),ne(Fe,wt,Ae.z,ft,Ae.y+1)),E[1]>0&&at&&(ne(Fe,Ie,Ae.z,Ae.x,Ae.y-1),ne(Fe,wt,Ae.z,ft,Ae.y-1))):E[0]>0?(ne(Fe,zt,Ae.z,Rt,Ae.y),E[1]<0&&mt&&(ne(Fe,Ie,Ae.z,Ae.x,Ae.y+1),ne(Fe,zt,Ae.z,Rt,Ae.y+1)),E[1]>0&&at&&(ne(Fe,Ie,Ae.z,Ae.x,Ae.y-1),ne(Fe,zt,Ae.z,Rt,Ae.y-1))):E[1]<0&&mt?ne(Fe,Ie,Ae.z,Ae.x,Ae.y+1):at&&ne(Fe,Ie,Ae.z,Ae.x,Ae.y-1);else{const _t=be.visibleQuadrants;1&_t&&(ne(Fe,zt,Ae.z,Rt,Ae.y),at&&(ne(Fe,Ie,Ae.z,Ae.x,Ae.y-1),ne(Fe,zt,Ae.z,Rt,Ae.y-1))),2&_t&&(ne(Fe,wt,Ae.z,ft,Ae.y),at&&(ne(Fe,Ie,Ae.z,Ae.x,Ae.y-1),ne(Fe,wt,Ae.z,ft,Ae.y-1))),4&_t&&(ne(Fe,zt,Ae.z,Rt,Ae.y),mt&&(ne(Fe,Ie,Ae.z,Ae.x,Ae.y+1),ne(Fe,zt,Ae.z,Rt,Ae.y+1))),8&_t&&(ne(Fe,wt,Ae.z,ft,Ae.y),mt&&(ne(Fe,Ie,Ae.z,Ae.x,Ae.y+1),ne(Fe,wt,Ae.z,ft,Ae.y+1)))}}const de=[];for(const je of z)z.some(be=>je.isChildOf(be))||de.push(je);if(z=de.filter(je=>!m.some(be=>!!(je.overscaledZ{const st=rt.canonical.x+.5-Ae[0],ct=rt.canonical.y+.5-Ae[1];return st*st+ct*ct{const Rt=i.ck(mt,ct,at,zt,wt);z.has(Rt)||(D.push(new i.aR(ct,mt,at,zt,wt)),z.add(Rt))},W=m.reduce((ct,mt)=>Math.max(ct,mt.overscaledZ),E),ee=1<{const at=Math.floor(ct[0]),zt=Math.floor(ct[1]),wt=(ct[0]-at)*i.an,Rt=(ct[1]-zt)*i.an,ft=Math.floor(mt[0]),_t=Math.floor(mt[1]),At=(mt[0]-ft)*i.an,Wt=(mt[1]-_t)*i.an;for(let qt=-1;qt<=1;qt++){const rs=at+qt;if(!(rs<0||rs>=ee)){de.x=wt-qt*i.an,je.x=At-(rs-ft)*i.an;for(let Jt=-1;Jt<=1;Jt++){const Ns=zt+Jt;de.y=Rt-Jt*i.an,je.y=Wt-(Ns-_t)*i.an,i.cI(de,je,ne)&&$(W,0,E,rs,Ns)}}}},Ae=v.points,Fe=Ae[i.c9],Ie=Ae[i.ca],rt=this._projectToGround(Fe,Ae[i.cb]),st=this._projectToGround(Ie,Ae[i.cc]);return be(Fe,rt),be(Ie,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],W=z[i.ch],ee=z[i.ci],ne=z[i.cj];if(ee[2]>=0&&ne[2]>=0||$[2]<=0||W[2]<=0)return[];const de=ee[2]<0?this._projectToZ($,ee,0):ee,je=ne[2]<0?this._projectToZ(W,ne,0):ne,be=-D,Ae=ee[2]3&&(Ie.length=3),Ie}_findExtensionTilesInQuad(m,v,E,D){const z=[],$=new Set;for(const ft of m)$.add(ft.key);const W=m.reduce((ft,_t)=>Math.max(ft,_t.overscaledZ),v),ee=1<{const At=ft.canonical.x+.5-wt,Wt=ft.canonical.y+.5-Rt,qt=_t.canonical.x+.5-wt,rs=_t.canonical.y+.5-Rt;return At*At+Wt*Wt-(qt*qt+rs*rs)||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 W=this.locationCoordinate(this.center),ee=this.center.lat,ne=1<{const as=new i.ag(Vt.x+25e-6,Vt.y,Vt.z),cs=new i.ag(Vt.x,Vt.y+25e-6,Vt.z),Qs=Vt.toLngLat(),Hs=as.toLngLat(),Gs=cs.toLngLat(),Cs=this.locationCoordinate(Qs),_r=this.locationCoordinate(Hs),Ar=this.locationCoordinate(Gs),hr=Math.hypot(_r.x-Cs.x,_r.y-Cs.y),yr=Math.hypot(Ar.x-Cs.x,Ar.y-Cs.y);return Math.sqrt(hr*yr)*Rt/25e-6},_t=Vt=>{const ts=zt,as=wt;return{aabb:i.cp(this,ne,0,0,0,Vt,as,ts,this.projection),zoom:0,x:0,y:0,minZ:as,maxZ:ts,wrap:Vt,fullyVisible:!1}},At=[];let Wt=[];const qt=v,rs=m.reparseOverscaled?E:v,Jt=(rt-this._centerAltitude)*Ie,Ns=Vt=>{if(!this._elevation||!Vt.tileID||!$)return;const ts=this._elevation.getMinMaxForTile(Vt.tileID),as=Vt.aabb;ts?(as.min[2]=ts.min,as.max[2]=ts.max,as.center[2]=(as.min[2]+as.max[2])/2):(Vt.shouldSplit=Kt(Vt),Vt.shouldSplit||(as.min[2]=as.max[2]=as.center[2]=this._centerAltitude))},As=(Vt,ts)=>{if(.707*ts{if(Vt.zoom=.9)return!0}else if(z&&(cs=Vt.aabb.distanceZ(st)*Ie),this.projection.isReprojectedInTileSpace&&E<=5){const yr=Math.pow(2,Vt.zoom),Qr=ft(new i.ag((Vt.x+.5)/yr,(Vt.y+.5)/yr));Qs=Qr>.85?1:Qr}if(!$&&!je){const yr=Math.sqrt(ts*ts+as*as+cs*cs);let Qr=(1<0;){const Vt=At.pop(),ts=Vt.x,as=Vt.y;let cs=Vt.fullyVisible;const Qs=()=>this.projection.name==="globe"&&(Vt.y===0||Vt.y===(1<Hs)continue;let Gs=0;if(!cs){let hr=ct?Vt.aabb.intersectsPrecise(Ae):Vt.aabb.intersectsPreciseFlat(Ae);if(hr===0&&Qs()){const yr=new i.cn(Vt.zoom,ts,as);hr=i.co(this,ne,yr,!0).intersectsPrecise(Ae)}if(hr===0)continue;if(m.calculateQuadrantVisibility)if(Ae.containsPoint(Vt.aabb.center))Gs=15;else for(let yr=0;yr<4;yr++)Vt.aabb.quadrant(yr).intersects(Ae)!==0&&(Gs|=1<>1),_r={aabb:$?Vt.aabb.quadrant(Hs):i.cp(this,ne,Vt.zoom+1,Gs,Cs,Vt.wrap,Vt.minZ,Vt.maxZ,this.projection),zoom:Vt.zoom+1,x:Gs,y:Cs,wrap:Vt.wrap,fullyVisible:cs,tileID:void 0,shouldSplit:void 0,minZ:Vt.minZ,maxZ:Vt.maxZ};z&&!je&&(_r.tileID=new i.aR(Vt.zoom+1===qt?rs:Vt.zoom+1,Vt.wrap,Vt.zoom+1,Gs,Cs),Ns(_r)),At.push(_r)}}if(this.fogCullDistSq){const Vt=this.fogCullDistSq,ts=this.horizonLineFromTop();Wt=Wt.filter(as=>{const cs=[0,0,0,1],Qs=[i.an,i.an,0,1],Hs=this.calculateFogTileMatrix(as.tileID.toUnwrapped());i.aE(cs,cs,Hs),i.aE(Qs,Qs,Hs);const Gs=i.cq([],cs,Qs),Cs=i.cr([],cs,Qs),_r=i.cK(Gs,Cs);if(_r===0)return!0;let Ar=!1;const hr=this._elevation;if(hr&&_r>Vt&&ts!==0){const yr=this.calculateProjMatrix(as.tileID.toUnwrapped());let Qr;m.isTerrainDEM||(Qr=hr.getMinMaxForTile(as.tileID)),Qr||(Qr={min:wt,max:zt});const vn=i.cs(this.rotation),hn=[vn[0]*i.an,vn[1]*i.an,Qr.max];i.ah(hn,hn,yr),Ar=(1-hn[1])*this.height*.5Vt.distanceSq-ts.distanceSq).map(Vt=>Vt.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 W=this.worldSize;E=(v.x-z.x)/W,D=(v.y-z.y)/W}else{const W=this.pointCoordinate(v),ee=this.pointCoordinate(z);E=W.x-ee.x,D=W.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 W=D[2],ee=z[2];return{p0:D,p1:z,t:W===ee?0:(E-W)/(ee-W)}}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,W=m.clone();for(let ee=0;ee<10&&z-D>$;ee++){W.y=i.am(D,z,.66);const ne=this.projection.pointCoordinate3D(this,W.x,W.y);ne?(z=W.y,E=ne):D=W.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)),W=this.pointLocation3D(new i.P(D,E)),ee=this.pointLocation3D(new i.P(v,E));let ne=Math.min(z.lng,$.lng,W.lng,ee.lng),de=Math.max(z.lng,$.lng,W.lng,ee.lng),je=Math.min(z.lat,$.lat,W.lat,ee.lat),be=Math.max(z.lat,$.lat,W.lat,ee.lat);const Ae=Math.pow(2,-this.zoom)/16*270,Fe=this.projection.name==="globe"?1:4,Ie=(rt,st,ct,mt,at)=>{const zt=(rt+ct)/2,wt=(st+mt)/2,Rt=new i.P(zt,wt),{lng:ft,lat:_t}=this.pointLocation3D(Rt),At=Math.max(0,ne-ft,je-_t,ft-de,_t-be);ne=Math.min(ne,ft),de=Math.max(de,ft),je=Math.min(je,_t),be=Math.max(be,_t),(atAe)&&(Ie(rt,st,zt,wt,at+1),Ie(zt,wt,ct,mt,at+1))};if(Ie(v,m,D,m,1),Ie(D,m,D,E,1),Ie(D,E,v,E,1),Ie(v,E,v,m,1),this.projection.name==="globe"){const[rt,st]=i.cw(this);rt?(be=90,de=180,ne=-180):st&&(je=-90,de=180,ne=-180)}return new i.aK(new i.aU(ne,je),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,W=new i.P(D,E),ee=new i.P($,E),ne=new i.P($,z),de=new i.P(D,z);let je=this.pointCoordinate(W,m),be=this.pointCoordinate(ee,m);const Ae=this.pointCoordinate(ne,v),Fe=this.pointCoordinate(de,v),Ie=(rt,st)=>(st.y-rt.y)/(st.x-rt.x);return je.y>1&&be.y>=0?je=new i.ag((1-Fe.y)/Ie(Fe,je)+Fe.x,1):je.y<0&&be.y<=1&&(je=new i.ag(-Fe.y/Ie(Fe,je)+Fe.x,0)),be.y>1&&je.y>=0?be=new i.ag((1-Ae.y)/Ie(Ae,be)+Ae.x,1):be.y<0&&je.y<=1&&(be=new i.ag(-Ae.y/Ie(Ae,be)+Ae.x,0)),new i.aK().extend(this.coordinateLocation(je)).extend(this.coordinateLocation(be)).extend(this.coordinateLocation(Fe)).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.maxLngje&&(W=je-ne),je-deAe&&($=Ae-ee),Ae-be{for(let Kt=0;Kt<16;Kt++)rs[Kt]=i.am(Jt[Kt],Ns[Kt],As)})(W,W,ee,i.cL(this.pitch>=$0?1:this.pitch/$0))}else W=ee;const ne=i.cz([],ee,$);let de=i.cz([],W,$);if(this.projection.isReprojectedInTileSpace){const _t=this.locationCoordinate(this.center),At=i.b9([]);i.bx(At,At,[_t.x*this.worldSize,_t.y*this.worldSize,0]),i.aD(At,At,i.cA(this)),i.bx(At,At,[-_t.x*this.worldSize,-_t.y*this.worldSize,0]),i.aD(de,de,At),i.aD(ne,ne,At),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 je=i.b7([],W);this.frustumCorners=i.cD.fromInvProjectionMatrix(je,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 Fe=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;Ae[8]=2*-m.x/this.width,Ae[9]=2*(m.y+Fe)/this.height,this.skyboxMatrix=i.aD(be,Ae,be);const Ie=this.point,rt=Ie.x,st=Ie.y,ct=this.width%2/2,mt=this.height%2/2,at=Math.cos(this.angle),zt=Math.sin(this.angle),wt=rt-Math.round(rt)+at*ct+zt*mt,Rt=st-Math.round(st)+at*mt+zt*ct,ft=new Float64Array(de);if(i.bx(ft,ft,[wt>.5?wt-1:wt,Rt>.5?Rt-1:Rt,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)),W=Math.max((m[2]-z)/Math.cos(E),$),ee=this._zoomFromMercatorZ(W);i.bg(m,m,v,W),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),W=this.tileSize*Math.pow(2,$),ee=this.getCameraToCenterDistance(this.projection,$,W),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 W=$[3]=Math.max($[3],1e-6);return $[0]/=W,$[1]/=W,$[2]/=W,$}([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 IO{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 W=this.receivers[$];if(!W||!D.intersectsAabb(W.aabb))continue;W.aabb.min=D.closestPoint(W.aabb.min),W.aabb.max=D.closestPoint(W.aabb.max);const ee=W.aabb.getCorners();for(let ne=0;ne1||be[1]<-1||be[1]>1){de=!1;break}}if(W.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 IO,this._depthMode=new wr(m.context.gl.LEQUAL,wr.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,W=0;for(const st of E.style.order){const ct=E.style._mergedLayers[st];ct.hasShadowPass()&&!ct.isHidden(m.zoom)&&($=W),!z||z!==st&&z!==ct.slot||(this._drawShadowAfterLayer=W>0?W-1:0),W+=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 ct=ee.gl,mt=ee.createFramebuffer(ne,de,0,"texture"),at=new i.T(ee,{width:ne,height:de,data:null},ct.DEPTH_COMPONENT16);mt.depthAttachment.set(at.texture),this._cascades.push({framebuffer:mt,texture:at,matrix:[],far:0,boundingSphereRadius:0,frustum:new i.cl,scale:0})}}this.shadowDirection=LO(v);let je=0;if(m.elevation){const st=m.elevation,ct=[1e4,-1e4];st.visibleDemTiles.filter(mt=>mt.dem).forEach(mt=>{const at=mt.dem.tree;ct[0]=Math.min(ct[0],at.minimums[0]),ct[1]=Math.max(ct[1],at.maximums[0])}),ct[0]!==1e4&&(je=(ct[1]-ct[0])*st.exaggeration())}const be=1.5*m.cameraToCenterDistance,Ae=3*be,Fe=new Float64Array(16);for(let st=0;st=0)return{};const z=function(ee,ne,de){const je=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 W={};return W.vertices=z,W.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])],W}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 LO(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"),W=[$.x,$.y,$.z],ee=v.properties.get("color-use-theme")==="none",ne=v.properties.get("color"),de=v.properties.get("intensity"),je=Math.max(i.bi([0,0,1],W),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),je*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,W=M.scale,ee=M.worldSize,ne=1/ee,de=M.aspect,je=Math.sqrt(1+de*de)*Math.tan(.5*M.fovX),be=je*je,Ae=E-v,Fe=E+v;let Ie,rt;be>Ae/Fe?(Ie=E,rt=E*je):(Ie=.5*Fe*(1+be),rt=.5*Math.sqrt(Ae*Ae+2*(E*E+v*v)*be+Fe*Fe*be*be));const st=M.projection.pixelsPerMeter(M.center.lat,ee),ct=M._camera.getCameraToWorldMercator(),mt=[0,0,-Ie*ne];i.ah(mt,mt,ct);let at=rt*ne;const zt=function(cs){return cs[0]/=W,cs[1]/=W,cs[2]=i.bU(cs[2],M._center.lat),cs},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 cs=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 Hs=new Float64Array(16);i.cz(Hs,Qs,cs);const Gs=new Float64Array(16);i.b7(Gs,Hs);const Cs=i.cl.fromInvProjectionMatrix(Gs,ee,$,!0);for(const _r of Cs.points){const Ar=zt(_r);at=Math.max(at,i.bK(i.cV([],mt,Ar)))}}at*=D/(D-1);const Rt=Math.acos(m[2]),ft=Math.atan2(-m[0],-m[1]),_t=new Bw;_t.position=mt,_t.setPitchBearing(Rt,ft);const At=_t.getWorldToCamera(ee,st),Wt=at*ee,qt=Math.min(M._mercatorZfromZoom(17)*ee*-2,-2*Wt),rs=_t.getCameraToClipOrthographic(-Wt,Wt,-Wt,Wt,qt,(Wt+z*st)/m[2]),Jt=new Float64Array(16);i.aD(Jt,rs,At);const Ns=i.cQ(Math.floor(1e6*mt[0])/1e6*ee,Math.floor(1e6*mt[1])/1e6*ee,0),As=.5*D,Kt=[0,0,0];i.ah(Kt,Ns,Jt),i.bJ(Kt,Kt,As);const Vt=[Math.floor(Kt[0]),Math.floor(Kt[1]),Math.floor(Kt[2])],ts=[0,0,0];i.ax(ts,Kt,Vt),i.bJ(ts,ts,-1/As);const as=new Float64Array(16);return i.b9(as),i.bx(as,as,ts),i.aD(Jt,as,Jt),[Jt,Wt]}class ope 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 W of D){const ee=m[W];this.hasURLBeenRequested(ee)&&!E.forceReload||(this.modelByURL[ee]={modelId:W,scope:v},z.push(this.loadModel(W,ee)),$.push(W)),this.models[v][W]||(this.models[v][W]={model:null,numReferences:1})}this.numModelsLoading[v]=(this.numModelsLoading[v]||0)+$.length,Promise.allSettled(z).then(W=>{for(let ee=0;ee{this.fire(new i.B(new Error(`Could not load models: ${W.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 DO(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,W=E*m;return[$,W,$+D*m,W+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[$,W]of z)m.set(i.I.from({name:$,iconsetId:this.id}),W),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 W=this._convertRingToPoints($.coordinates[0]);if(i.bw(W,E))return!0}else if($.type==="MultiPolygon"){const W=this._convertMultiPolygonToPoints($.coordinates);if(i.d0(E,W))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 lpe 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(($,W)=>W.zIndex-$.zIndex).filter(($,W,ee)=>W===0||$.zIndex!==ee[W-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)=>ir(M,m&&m.filter(v=>v.identifier!=="source.canvas")),cpe=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"]),RO=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 Um 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 Ge,this._hasDataDrivenEmissive=!1,this.indoorManager=new lpe(this),this.dispatcher=v.dispatcher?v.dispatcher:new pt(Nt(),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 Ot(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 ope(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=Um.registerForPluginStateChange(D=>{E.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:D.pluginStatus,pluginURL:D.pluginURL},(z,$)=>{if(i.d6(z),$&&$.every(W=>W))for(const W in E._sourceCaches){const ee=E._sourceCaches[W],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 W=this._layers[$];W.source===z.id&&this._validateLayer(W)}})}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(W){$(W,!1)}};if(typeof m=="string"){const z=this.map._requestManager.normalizeStyleURL(m),$=this.map._requestManager.transformRequest(z,i.R.Style);i.m($,(W,ee)=>{W?this.fire(new i.B(W)):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,($,W)=>{if(this._request=null,$)this.fire(new i.B($));else if(W)return this.importsCache.set(m,W),this._load(W,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),W=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(W),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:je})=>je===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 Um(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,Zt(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 Rr(ee.properties,ee.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new Rr(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),je=!!this.directionalLight&&this.directionalLight.shadowsEnabled();de&&ne.canCastShadows()&&je&&(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 je=de.layout.get("text-font");je&&je.value&&je.value.kind==="constant"&&ee.add(je.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 W=this.isRootStyle();m.imports?this._loadImports(m.imports,v).then(()=>{this._reloadImports(),this.fire(new i.C(W?"style.load":"style.import.load"))}).catch(ee=>{this.fire(new i.B(new Error("Failed to load imports",ee))),this.fire(new i.C(W?"style.load":"style.import.load"))}):(this._reloadImports(),this.fire(new i.C(W?"style.load":"style.import.load")))};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];const D=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(D){const 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,$,W,ee,ne,de;const je={};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&&(W=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),je[be.scope]=be._styleColorTheme}}),this.light=m,this.ambientLight=v,this.directionalLight=E,this.fog=z,this.snow=$,this.rain=W,this._styleColorThemeForScope=je,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 W=i.F($,z.scope);m[W]=z._sourceCaches[$]}for(const $ in z._otherSourceCaches){const W=i.F($,z.scope);v[W]=z._otherSourceCaches[$]}for(const $ in z._symbolSourceCaches){const W=i.F($,z.scope);E[W]=z._symbolSourceCaches[$]}for(const $ in z._fillExtrusionSourceCaches){const W=i.F($,z.scope);D[W]=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 W of $._order){const ee=$._layers[W];if(ee.type==="slot"){const ne=i.da(W);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 W of $)if(W.type==="slot"){const ee=i.da(W.id);m[ee]&&z(m[ee]),this._mergedSlots.push(ee)}else{const ee=i.F(W.id,W.scope);this._mergedOrder.push(ee),E[ee]=W,W.is3D(!!this.terrain)&&(this._has3DLayers=!0,D=this._mergedOrder.length-1),W.type==="circle"&&(this._hasCircleLayers=!0),W.type==="symbol"&&(this._hasSymbolLayers=!0),W.type==="clip"&&(this._clipLayerPresent=!0)}};if(z(v),this._has3DLayers){const $={};for(let W=0;W$[W]-$[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 W of Object.keys($E))z[W]===void 0&&(z[W]=$E[W].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 W=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:je}=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(W)&&this.removeImage(W),this.addImage(W,{data:new i.q({width:ne,height:de},je),pixelRatio:1,sdf:!1,usvg:!1,version:0});const be=this.imageManager.getImage(W,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,$,W;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,W||(W=be,z=Ae,je())}),de=i.n(E.transformRequest(E.normalizeSpriteURL(v,ee,".png"),i.R.SpriteImage),(be,Ae)=>{de=null,W||(W=be,$=Ae,je())});function je(){if(W)D(W);else if(z&&$){const be=i.o.getImageData($),Ae={};for(const Fe in z){const{width:Ie,height:rt,x:st,y:ct,sdf:mt,pixelRatio:at,stretchX:zt,stretchY:wt,content:Rt}=z[Fe],ft=new i.q({width:Ie,height:rt});i.q.copy(be,ft,{x:st,y:ct},{x:0,y:0},{width:Ie,height:rt},null),Ae[Fe]={data:ft,pixelRatio:at!==void 0?at:1,sdf:mt!==void 0&&mt,stretchX:zt,stretchY:wt,content:Rt,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 W=new Map;for(const ee in $)W.set(i.I.from(ee),$[ee]);this.addImages(W)}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 W={},ee=i.c$(new i.a$($));for(const ne of ee.icons){const de={version:1,pixelRatio:i.o.devicePixelRatio,content:DO(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};W[ne.name]=de}D(null,W)}))}_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 W=m.getDefaultProgramParams($,v.zoom,this._styleColorTheme.lut);W&&(E.style=this,this.fog&&(E._fogVisible=!0,W.overrideFog=!0,E.getOrCreateProgram($,W)),E._fogVisible=!1,W.overrideFog=!1,E.getOrCreateProgram($,W),(this.stylesheet.terrain||this.stylesheet.projection&&this.stylesheet.projection.name==="globe")&&(W.overrideRtt=!0,E.getOrCreateProgram($,W)))}}}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:je}=ee[ne];(de||je)&&(this._updateWorkerLayers(ne,de,je),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 je=ne.layout&&ne.layout.get("source-max-zoom");if(je!=null){const be=$[de];$[de]=be==null?je:Math.min(be,je)}}}!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 W=this.imageManager.getPendingImageProviders();for(const ee of W)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,Zt(m)))return!1;(m=i.d9(m)).layers=P1(m.layers);const E=function($,W){if(!$)return[{command:Sa.setStyle,args:[W]}];let ee=[];try{if(!i.b6($.version,W.version))return[{command:Sa.setStyle,args:[W]}];if(i.b6($.center,W.center)||ee.push({command:Sa.setCenter,args:[W.center]}),i.b6($.zoom,W.zoom)||ee.push({command:Sa.setZoom,args:[W.zoom]}),i.b6($.bearing,W.bearing)||ee.push({command:Sa.setBearing,args:[W.bearing]}),i.b6($.pitch,W.pitch)||ee.push({command:Sa.setPitch,args:[W.pitch]}),i.b6($.sprite,W.sprite)||ee.push({command:Sa.setSprite,args:[W.sprite]}),i.b6($.glyphs,W.glyphs)||ee.push({command:Sa.setGlyphs,args:[W.glyphs]}),i.b6($.imports,W.imports)||function(Ae=[],Fe=[],Ie){Fe=Fe||[];const rt=(Ae=Ae||[]).map(ty),st=Fe.map(ty),ct=Ae.reduce(R0,{}),mt=Fe.reduce(R0,{}),at=rt.slice();let zt,wt,Rt,ft;for(zt=0,wt=0;zt{Ae.source&&ne[Ae.source]?ee.push({command:Sa.removeLayer,args:[Ae.id]}):je.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,W.terrain)||ee.push({command:Sa.setTerrain,args:[W.terrain]}),function(Ae,Fe,Ie){Fe=Fe||[];const rt=(Ae=Ae||[]).map(ty),st=Fe.map(ty),ct=Ae.reduce(R0,{}),mt=Fe.reduce(R0,{}),at=rt.slice(),zt=Object.create(null);let wt,Rt,ft,_t,At,Wt,qt;for(wt=0,Rt=0;wt!($.command in RO));if(E.length===0)return!1;const D=E.filter($=>!($.command in cpe));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(Ts,`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(Er,`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 W=($===i.b4.Symbol?"symbol:":$===i.b4.FillExtrusion?"fill-extrusion:":"other:")+D.id,ee=i.F(W,this.scope),ne=this._sourceCaches[W]=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"),W=1-i.cP($.x,$.y,$.z)[2]/90,ee=E(D)*z*W,ne=v.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),de=v.properties.get("intensity"),je=E(ne)*de;return Number(((ee+je)/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 W;if($.properties)for(const ee in $.properties){const ne=i.X($.properties[ee]);ne.result==="success"&&(W=W||{},W[ee]=ne.value)}z.push({layerId:$.layer,namespace:$.featureNamespace,properties:W,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 W=E.getOwnLayer($.layer);W&&z.push(W)}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 W=$.value.expression,ee=i.F(v,D.scope),ne=D.options.get(ee);if(!ne)return;let de;const{minValue:je,maxValue:be,stepValue:Ae,type:Fe,values:Ie}=z[v],rt=i.X(z[v].default);rt.result==="success"&&(de=rt.value.expression),de?(this.options.set(ee,Object.assign({},ne,{value:W,default:de,minValue:je,maxValue:be,stepValue:Ae,type:Fe,values:Ie})),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),W=v.options.get($),ee=W?W.value||W.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:W,maxValue:ee,stepValue:ne,type:de,values:je}=v[E];if(D){const be=i.F(E,this.scope);this.options.set(be,{default:D,value:z,minValue:W,maxValue:ee,stepValue:ne,type:de,values:je})}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(Tt,`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 W=this._order.length;if(v){const je=this._order.indexOf(v);if(je===-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.`):W=je}this._order.splice(W,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 je=i.F(z.source,z.scope);de.type!==z.type?this._changes.updateSourceCache(je,"clear"):(this._changes.updateSourceCache(je,"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(Ht,`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(Zt,{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,Ut.call(Zt,{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),je=de.getFeaturesetLayers(ee);for(const{source:be,sourceLayer:Ae}of je)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 W=this.getOwnSourceCaches(E);for(const ee of W)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),je=de.getFeaturesetLayers(ee);for(const{source:be,sourceLayer:Ae}of je)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 W=this.getOwnSourceCaches(E);for(const ee of W)ee.removeFeatureState($,m.id,v)}getFeatureState(m){if(this._checkLoaded(),"target"in m){let z;if("featuresetId"in m.target){const{featuresetId:$,importId:W}=m.target,ee=this.getFragmentStyle(W),ne=ee.getFeaturesetLayers($);for(const{source:de,sourceLayer:je}of ne){const be=ee.getFeatureState({id:m.id,source:de,sourceLayer:je});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,W=this.getLayer($);z=this.getFeatureState({id:m.id,source:W.source,sourceLayer:W.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=W=>this._mergedLayers[W].is3D(!!this.terrain),E=this.order,D={},z=[];for(let W=E.length-1;W>=0;W--){const ee=E[W];if(v(ee)){D[ee]=W;for(const ne of m){const de=ne[ee];if(de)for(const je of de)z.push(je)}}}z.sort((W,ee)=>ee.intersectionZ-W.intersectionZ);const $=[];for(let W=E.length-1;W>=0;W--){const ee=E[W];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 je=this.getOwnLayerSourceCache(de),be=z[je.id]=z[je.id]||{sourceCache:je,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 je=this._layers[de];if(!je)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.`))),[];$(je)}}else for(const de in this._layers)$(this._layers[de]);const W=this._queryRenderedFeatures(m,z,E),ee=this._flattenAndSortRenderedFeatures(W),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(Ht,"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 je of de)$.push({targetId:z,filter:D,target:je});for(const{style:je}of this.fragments){const be=je.getFeaturesetDescriptors();for(const Ae of be)$.push({targetId:z,filter:D,target:Ae})}}const W=this.queryRenderedTargets(m,$,E),ee=[],ne=new Set;for(const de of W)for(const je of de.variants[z])Kh(je,de,ne)||ee.push(new i.di(de,je));return ee}queryRenderedTargets(m,v,E){const D={},z=(W,ee,ne,de)=>{const je=D[ee.id]=D[ee.id]||{sourceCache:ee,layers:{},has3DLayers:!1};if(je.layers[W.fqid]=je.layers[W.fqid]||{styleLayer:W,targets:[]},W.is3D(!!this.terrain)&&(je.has3DLayers=!0),!de)return ne.uniqueFeatureID=!1,void je.layers[W.fqid].targets.push(ne);je.layers[W.fqid].targets.push(Object.assign({},ne,{namespace:de.namespace,properties:de.properties,uniqueFeatureID:de.uniqueFeatureID}))};for(const W of v)if("featuresetId"in W.target){const{featuresetId:ee,importId:ne}=W.target,de=this.getFragmentStyle(ne);if(!de||!de._featuresetSelectors)continue;const je=de._featuresetSelectors[ee];if(!je){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 je){const Ae=de.getOwnLayer(be.layerId);Ae&&!UE.has(Ae.type)&&z(Ae,de.getOwnLayerSourceCache(Ae),W,be)}}else if("layerId"in W.target){const{layerId:ee}=W.target,ne=this.getLayer(ee);if(!ne||UE.has(ne.type))continue;z(ne,this.getLayerSourceCache(ne),W)}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 W in v){const ee=Cf($,v[W],this._availableImages,E,z,this.getActualScope());Object.keys(ee).length&&D.push(ee)}if(this.placement)for(const W in v){if(v[W].sourceCache._renderSourceType!==i.b4.Symbol)continue;const ee=zx($.screenGeometry,v[W],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(Ht,"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 Um.getSourceType(m)?E(new Error(`A source type called "${m}" already exists.`)):(Um.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 W in m)if(!i.b6(m[W],D[W])){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 W="terrain-dem-src";this.addSource(W,E.source),E=i.d9(E),E=Object.assign(E,{source:W})}const z=Object.assign({},E),$={};if(this.terrain&&D){z.source=this.terrain.get().source;const W=this.terrain?this.getFragmentStyle(this.terrain.scope):null;W&&($.style=W.serialize())}if(this._validate(Oe,"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 W of Object.keys(i.a8.terrain))!E.hasOwnProperty(W)&&i.a8.terrain[W].default&&(E[W]=i.a8.terrain[W].default);for(const W in m)if(!i.b6(m[W],$[W])){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 zi(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(Zt,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=LO(this.directionalLight));const E=new Set,D=new Set,z=new Set;for(const $ in this._mergedLayers){const W=this._mergedLayers[$];W.type==="building"?E.add(W.source):W.type==="raster"&&W.paint&&W.paint.get("raster-elevation-reference")==="ground"&&z.add(W.source),W.hasElevation()&&!D.has(W.source)&&D.add(W.source)}for(const $ in this._mergedSourceCaches){const W=this._mergedSourceCaches[$],ee=D.has(W._source.id);W._isRasterElevatedOverTerrain=z.has(W._source.id),E.has(W._source.id)&&(W._source.reparseOverscaled=!1),W.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,W=!1;const ee={},ne={};for(const Ie of this._mergedOrder){const rt=this._mergedLayers[Ie];if(rt.type!=="symbol")continue;const st=i.F(rt.source,rt.scope);let ct=ee[st];if(!ct){const at=this.getLayerSourceCache(rt);if(!at)continue;const zt=at.getRenderableIds(!0).map(wt=>at.getTileByID(wt));ne[st]=zt.slice(),ct=ee[st]=zt.sort((wt,Rt)=>Rt.tileID.overscaledZ-wt.tileID.overscaledZ||(wt.tileID.isLessThan(Rt.tileID)?-1:1))}const mt=this.crossTileSymbolIndex.addLayer(rt,ct,m.center.lng,m.projection);$=$||mt}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder);const de=!!(this.placement&&!m.equals(this.placement.transform)),je=!!(this.placement&&(this.placement.lastReplacementSourceUpdateTime!==0&&!z||this.placement.lastReplacementSourceUpdateTime!==z.updateTime)),be=de||je||$,Ae=(be||this.pauseablePlacement.isStale())&&E===0,Fe=this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.o.now(),m.zoom)&&E!==0;if((this.pauseablePlacement.isFullPlacementRequested()||!this.pauseablePlacement.placement||Ae||Fe)&&(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 Ie=this.map.painter.maxFrontCutoffRawStart;if(Ie>0){const rt=180*m.pitch/Math.PI;if(rt>=15){const st=Math.min(1,Math.max(0,(rt-15)/5)),ct=st*st*(3-2*st);this.pauseablePlacement.placement.frontCutoffStart=-.5*(1-ct)+Ie*ct}}}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()),W=!0),$&&this.pauseablePlacement.setStale()),W||$){this._buildingIndex.onNewFrame(m.zoom);for(let Ie=0;Iez===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],W=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(W).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 W=$.style.stylesheet&&$.style.stylesheet.schema;return $.config=v,$.style.updateConfig(v,W),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 W=v.images.map(ee=>i.I.toString(ee));$.setDependencies(v.tileID.key,v.type,W)}},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)}}Um.getSourceType=function(M){return kp[M]},Um.setSourceType=function(M,m){kp[M]=m},Um.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,OO=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,FO=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(` `),dpe=["precision highp float;",Ww,iy.vertexSource].join(` `);var zO={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(OO);if(D)for(const z of D)FO.has(z)||m.add(z)}}function BO(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,($,W)=>(D.push(W),"")),m=m.replace(Gw,($,W)=>(E.push(W),""));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,($,W,ee,ne,de)=>(v.add(de),W==="define"?` #ifndef HAS_UNIFORM_u_${de} ${BO(ne)?"flat ":""}in ${ee} ${ne} ${de}; #else uniform ${ee} ${ne} u_${de}; #endif `:W==="initialize"?` #ifdef HAS_UNIFORM_u_${de} ${ee} ${ne} ${de} = u_${de}; #endif `:W==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${de} in ${ee} ${ne} ${de}; #endif `:W==="initialize-attribute"?"":void 0)),vertexSource:m=m.replace(sr,($,W,ee,ne,de)=>{const je=`MATERIAL_ATTRIBUTE_OFFSET_${de}`,be=ne==="float"?"vec2":ne,Ae=`GET_ATTRIBUTE_${be}(a_${de}, materialInfo, ${je})`,Fe=de.match(/color/)?"color":be;return W==="define-attribute-vertex-shader-only"?` #ifdef HAS_ATTRIBUTE_a_${de} in ${ee} ${ne} a_${de}; #endif `:v.has(de)?W==="define"?` #ifndef HAS_UNIFORM_u_${de} uniform lowp float u_${de}_t; #if !defined(${je}) in ${ee} ${be} a_${de}; #endif ${BO(ne)?"flat ":""}out ${ee} ${ne} ${de}; #else uniform ${ee} ${ne} u_${de}; #endif `:W==="initialize"?Fe==="vec4"||Fe==="uvec4"?` #ifndef HAS_UNIFORM_u_${de} ${de} = a_${de}; #else ${ee} ${ne} ${de} = u_${de}; #endif `:` #if !defined(HAS_UNIFORM_u_${de}) #ifdef ${je} ${de} = unpack_mix_${Fe}(${Ae}, u_${de}_t); #else ${de} = unpack_mix_${Fe}(a_${de}, u_${de}_t); #endif #else ${ee} ${ne} ${de} = u_${de}; #endif `:W==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${de} in ${ee} ${ne} a_${de}; out ${ee} ${ne} ${de}; #endif `:W==="initialize-attribute"?` #ifdef HAS_ATTRIBUTE_a_${de} ${de} = a_${de}; #endif `:void 0:W==="define"?` #ifndef HAS_UNIFORM_u_${de} uniform lowp float u_${de}_t; #if !defined(${je}) in ${ee} ${be} a_${de}; #endif #else uniform ${ee} ${ne} u_${de}; #endif `:W==="define-instanced"?Fe==="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 `:W==="initialize-attribute-custom"?` #ifdef HAS_ATTRIBUTE_a_${de} ${ee} ${ne} ${de} = a_${de}; #endif `:Fe==="vec4"||Fe==="uvec4"?` #ifndef HAS_UNIFORM_u_${de} #ifdef ${je} ${ee} ${ne} ${de} = ${Ae}; #else ${ee} ${ne} ${de} = a_${de}; #endif #else ${ee} ${ne} ${de} = u_${de}; #endif `:` #ifndef HAS_UNIFORM_u_${de} #ifdef ${je} ${ee} ${ne} ${de} = unpack_mix_${Fe}(${Ae}, u_${de}_t); #else ${ee} ${ne} ${de} = unpack_mix_${Fe}(a_${de}, u_${de}_t); #endif #else ${ee} ${ne} ${de} = u_${de}; #endif `}),usedDefines:z,vertexIncludes:E,fragmentIncludes:D}}class $O{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,$,W,ee){this.context=m;let ne=this.boundPaintVertexBuffers.length!==D.length;for(let je=0;!ne&&je{const zt=mt.paint.get("hillshade-shadow-color"),wt=mt.paint.get("hillshade-shadow-color-use-theme").constantOr("default")==="none",Rt=mt.paint.get("hillshade-highlight-color"),ft=mt.paint.get("hillshade-highlight-color-use-theme").constantOr("default")==="none",_t=mt.paint.get("hillshade-accent-color"),At=mt.paint.get("hillshade-accent-color-use-theme").constantOr("default")==="none",Wt=mt.paint.get("hillshade-emissive-strength");let qt=i.ap(mt.paint.get("hillshade-illumination-direction"));if(mt.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"),Ns=i.cP(Jt.x,Jt.y,Jt.z);qt=i.ap(Ns[1])}const rs=!st.options.moving;return{u_matrix:at||st.transform.calculateProjMatrix(ct.tileID.toUnwrapped(),rs),u_image:0,u_latrange:YE(0,ct.tileID),u_light:[mt.paint.get("hillshade-exaggeration"),qt],u_shadow:zt.toPremultipliedRenderColor(wt?null:mt.lut),u_highlight:Rt.toPremultipliedRenderColor(ft?null:mt.lut),u_emissive_strength:Wt,u_accent:_t.toPremultipliedRenderColor(At?null:mt.lut)}})(M,v,E,M.terrain?m.projMatrix:null);M.uploadCommonUniforms(W,be,m.toUnwrapped());const{tileBoundsBuffer:Fe,tileBoundsIndexBuffer:Ie,tileBoundsSegments:rt}=M.getTileBoundsBuffers(v);be.draw(M,ee.TRIANGLES,D,z,$,Xr.disabled,Ae,E.id,Fe,Ie,rt)}function qO(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 hpe(M,m,v){const E=M.context,D=E.gl;if(!m.dem)return;const z=m.dem;if(E.activeTexture.set(D.TEXTURE1),qO(M,m,z),!m.demTexture)return;m.demTexture.bind(D.NEAREST,D.CLAMP_TO_EDGE);const $=z.dim;E.activeTexture.set(D.TEXTURE0);let W=m.hillshadeFBO;if(!W){const be=new i.T(E,{width:$,height:$,data:null},D.RGBA8);be.bind(D.LINEAR,D.CLAMP_TO_EDGE),W=m.hillshadeFBO=E.createFramebuffer($,$,1,"renderbuffer"),W.colorAttachment0.set(be.texture)}E.bindFramebuffer.set(W.framebuffer),E.viewport.set([0,0,$,$]);const{tileBoundsBuffer:ee,tileBoundsIndexBuffer:ne,tileBoundsSegments:de}=M.getMercatorTileBoundsBuffers(),je=[];M.linearFloatFilteringSupported()&&je.push("TERRAIN_DEM_FLOAT_FORMAT"),M.terrain&&M.terrain.renderingToTexture&&M.emissiveMode==="mrt-fallback"&&je.push("USE_MRT1"),M.getOrCreateProgram("hillshadePrepare",{defines:je}).draw(M,D.TRIANGLES,wr.disabled,cn.disabled,rn.unblended,Xr.disabled,((be,Ae)=>{const Fe=Ae.stride,Ie=i.bb();return i.bT(Ie,0,i.an,-i.an,0,0,1),i.bx(Ie,Ie,[0,-i.an,0]),{u_matrix:Ie,u_image:1,u_dimension:[Fe,Fe],u_zoom:be.overscaledZ}})(m.tileID,z),v.id,ee,ne,de),m.needsHillshadePrepare=!1}class io{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 UO extends io{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 mpe extends io{getDefault(){return 1}set(m){(m!==this.current||this.dirty)&&(this.gl.clearDepth(m),this.current=m,this.dirty=!1)}}class GC extends io{getDefault(){return 0}set(m){(m!==this.current||this.dirty)&&(this.gl.clearStencil(m),this.current=m,this.dirty=!1)}}class ppe extends io{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 VO extends io{getDefault(){return!0}set(m){(m!==this.current||this.dirty)&&(this.gl.depthMask(m),this.current=m,this.dirty=!1)}}class XE extends io{getDefault(){return 255}set(m){(m!==this.current||this.dirty)&&(this.gl.stencilMask(m),this.current=m,this.dirty=!1)}}class WC extends io{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 io{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 io{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 io{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 io{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 io{getDefault(){return this.gl.LESS}set(m){(m!==this.current||this.dirty)&&(this.gl.depthFunc(m),this.current=m,this.dirty=!1)}}class HO extends io{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 io{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 GO extends io{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 io{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 io{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 io{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 io{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 io{getDefault(){return null}set(M){(M!==this.current||this.dirty)&&(this.gl.useProgram(M),this.current=M,this.dirty=!1)}};class Kw extends io{getDefault(){return this.gl.TEXTURE0}set(m){(m!==this.current||this.dirty)&&(this.gl.activeTexture(m),this.current=m,this.dirty=!1)}}class WO extends io{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 KO extends io{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 ZO extends io{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 io{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 YO extends io{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 fpe extends io{getDefault(){return null}set(m){const v=this.gl;v.bindBuffer(v.ELEMENT_ARRAY_BUFFER,m),this.current=m,this.dirty=!1}}class xpe extends io{getDefault(){return null}set(m){this.gl&&(m!==this.current||this.dirty)&&(this.gl.bindVertexArray(m),this.current=m,this.dirty=!1)}}class gpe extends io{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 io{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 io{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 io{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 XO 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 ype 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,$,W,ee,ne,de,je,be,Ae,Fe,Ie,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:W,u_frustum_br:ee,u_frustum_bl:ne,u_globe_pos:de,u_globe_radius:je,u_viewport:be,u_grid_matrix:rt?Float32Array.from(rt):new Float32Array(9),u_skirt_height:Ae,u_far_z_cutoff:Fe,u_emissive_texture_available:Ie});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,W=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),je=de&&M.refreshedUponExpiration?1:i.aC(de?$:1-W,0,1);return m?{opacity:1,mix:1-je,isFading:$<1}:{opacity:je,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 W=new i.b0($,this._source.tileSize*$.overscaleFactor(),m.tileZoom,void 0,void 0,this._source.worldview);W.state="loaded",this._tiles[$.key]=W}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 je=i.an/128,be=i.an+je/2,Ae=be+je;for(let Ie=-je;Iebe||Ie<0||Ie>be?24575:0,ct=i.aC(Math.round(rt),0,i.an),mt=i.aC(Math.round(Ie),0,i.an);ee.emplaceBack(ct+st,mt)}const Fe=(Ie,rt)=>{const st=rt*de+Ie;ne.emplaceBack(st+1,st,st+de),ne.emplaceBack(st+de,st+de+1,st+1)};for(let Ie=1;Ie<129;Ie++)for(let rt=1;rt<129;rt++)Fe(rt,Ie);return[0,129].forEach(Ie=>{for(let rt=0;rt<130;rt++)Fe(rt,Ie),Fe(Ie,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 W=$.gl;this._overlapStencilMode=new cn({func:W.GEQUAL,mask:255},0,255,W.KEEP,W.KEEP,W.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 W=m.terrain&&m.terrain.scope,ee=D.get("source"),ne=z?this._mockSourceCache:m.getSourceCache(ee,W);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 je=this.getScaledDemTileSize();this.sourceCache.update(v,je,!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 W=z-this._previousZoom;const ee=this._previousUpdateTimestamp;let ne=z;this._evaluationZoom!=null&&(ne=this._evaluationZoom,Math.abs(z-ne)>.5&&(W=.5*(z-ne+W)),W*D<0&&(ne+=W)),this._evaluationZoom=ne;const de=$.getExaggeration(ne),je=de===$.getExaggeration(Math.max(0,ne-.1));if(je&&Math.abs(de-this._exaggeration)<.01)return de;let be=Math.min(.1,.00375*(this._updateTimestamp-ee));return(je||de<.1||Math.abs(W)<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()),je=new i.P(de.x,de.y);ee.sort((be,Ae)=>{if(Ae.overscaledZ-be.overscaledZ)return Ae.overscaledZ-be.overscaledZ;const Fe=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 W={};this._visibleDemTiles=[];for(const ee of this.proxyCoords){const ne=this.terrainTileForTile[ee.key];if(!ne)continue;const de=ne.tileID.key;de in W||(this._visibleDemTiles.push(ne),W[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),qO(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),W=D||"";return E[`u_dem_tl${W}`]=[z.x*$%1,z.y*$%1],E[`u_dem_scale${W}`]=$,!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 W=null,ee=null,ne=1;if(E&&E.morphing&&this._useVertexMorphing){const Ae=E.morphing.srcDemTile,Fe=E.morphing.dstDemTile;ne=E.morphing.phase,Ae&&Fe&&(this._prepareDemTileUniforms(m,Ae,$,"_prev")&&(ee=Ae),this._prepareDemTileUniforms(m,Fe,$)&&(W=Fe))}const de=Ae=>Ae&&Ae.demTexture&&this.painter.linearFloatFilteringSupported()?z.LINEAR:z.NEAREST;let je=null;var be;if(this.enabled?ee&&W?(je=W.demTexture,D.activeTexture.set(z.TEXTURE4),ee.demTexture.bind(de(ee),z.CLAMP_TO_EDGE),$.u_dem_lerp=ne):(W=this.terrainTileForTile[m.tileID.key],je=this._prepareDemTileUniforms(m,W,$)?W.demTexture:this.emptyDEMTexture):je=this.emptyDEMTexture,D.activeTexture.set(z.TEXTURE2),je&&($.u_dem_size=(be=je).size[0]===1?1:be.size[0]-2,je.bind(de(W),z.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(E&&E.useDepthForOcclusion,v,$),E&&E.useMeterToDem&&W){const Ae=(1<{if(st===Jt)return;const Ns=[XC[Jt],"PROJECTION_GLOBE_VIEW"];mt&&Ns.push("CUSTOM_ANTIALIASING");const As=ne.isTileAffectedByFog(rs);rt=ne.getOrCreateProgram("globeRaster",{defines:Ns,overrideFog:As}),st=Jt},zt=ne.colorModeForRenderPass(),wt=new wr(Ie.LEQUAL,wr.ReadWrite,ne.depthRangeFor3D);Ad.update(Ae);const Rt=i.dq(ct),ft=[i.aH(ct.center.lng),i.aL(ct.center.lat)],_t=ne.globeSharedBuffers,At=[ct.width*i.o.devicePixelRatio,ct.height*i.o.devicePixelRatio],Wt=Float32Array.from(ct.globeMatrix),qt={useDenormalizedUpVectorScale:!0};{const rs=ne.transform,Jt=Xw(rs.zoom,de.exaggeration(),de.sourceCache._source.tileSize);st=-1;const Ns=Ie.TRIANGLES;for(const As of be){const Kt=je.getTile(As),Vt=cn.disabled,ts=de.prevTerrainTileForTile[As.key],as=de.terrainTileForTile[As.key];nP(ts,as)&&Ad.newMorphing(As.key,ts,as,Ae,250),Qw(ne,Kt.emissiveTexture),Fe.activeTexture.set(Ie.TEXTURE0),Kt.texture&&Kt.texture.bind(Ie.LINEAR,Ie.CLAMP_TO_EDGE);const cs=Ad.getMorphValuesForProxy(As.key),Qs=cs?1:0;cs&&Object.assign(qt,{morphing:{srcDemTile:cs.from,dstDemTile:cs.to,phase:i.dn(cs.phase)}});const Hs=i.dr(As.canonical),Gs=i.ds(Hs.getCenter().lat),Cs=i.dt(As.canonical,Hs,Gs,rs.worldSize/rs._pixelsPerMercatorPixel),_r=i.du(i.dv(As.canonical)),Ar=ne.emissiveMode==="mrt-fallback"?1:0,hr=G1(rs.expandedFarZProjMatrix,Wt,Rt,_r,i.al(rs.zoom),ft,rs.frustumCorners.TL,rs.frustumCorners.TR,rs.frustumCorners.BR,rs.frustumCorners.BL,rs.globeCenterInViewSpace,rs.globeRadius,At,Jt,rs._farZ,Ar,Cs);if(at(As,Qs),rt&&(de.setupElevationDraw(Kt,rt,qt),ne.uploadCommonUniforms(Fe,rt,As.toUnwrapped()),_t)){const[yr,Qr,vn]=_t.getGridBuffers(Gs,Jt!==0);rt.draw(ne,Ns,wt,Vt,zt,Xr.backCCW,hr,"globe_raster",yr,Qr,vn)}}}if(_t&&(ne.renderDefaultNorthPole||ne.renderDefaultSouthPole)){const rs=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];mt&&rs.push("CUSTOM_ANTIALIASING"),rt=ne.getOrCreateProgram("globeRaster",{defines:rs});for(const Jt of be){const{x:Ns,y:As,z:Kt}=Jt.canonical,Vt=As===0,ts=As===(1<yr.draw(ne,Ie.TRIANGLES,wt,cn.disabled,zt,Xr.disabled,G1(ct.expandedFarZProjMatrix,Cs,Cs,_r,0,ft,ct.frustumCorners.TL,ct.frustumCorners.TR,ct.frustumCorners.BR,ct.frustumCorners.BL,ct.globeCenterInViewSpace,ct.globeRadius,At,0,ct._farZ,Ar),"globe_pole_raster",Qr,Qs,Hs);de.setupElevationDraw(Gs,rt,qt),ne.uploadCommonUniforms(Fe,rt,Jt.toUnwrapped()),Vt&&ne.renderDefaultNorthPole&&hr(rt,as),ts&&ne.renderDefaultSouthPole&&(Cs=i.cC(i.bb(),Cs,[1,-1,1]),hr(rt,cs))}}}})(D,z,$,W,ee);else{const ne=D.context,de=ne.gl;let je,be;const Ae=D.shadowRenderer,Fe=oc(D,D.longestCutoffRange),Ie=zt=>{if(be===zt)return;const wt=[];wt.push(XC[zt]),Fe.shouldRenderCutoff&&wt.push("RENDER_CUTOFF"),Ae&&(wt.push("RENDER_SHADOWS"),Ae.useNormalOffset&&wt.push("NORMAL_OFFSET")),je=D.getOrCreateProgram("terrainRaster",{defines:wt}),be=zt},rt=D.colorModeForRenderPass(),st=new wr(de.LEQUAL,wr.ReadWrite,D.depthRangeFor3D);Ad.update(ee);const ct=D.transform,mt=Xw(ct.zoom,z.exaggeration(),z.sourceCache._source.tileSize);let at=[0,0,0];if(Ae){const zt=D.style.directionalLight,wt=D.style.ambientLight;zt&&wt&&(at=Ap(D.style,zt,wt))}{be=-1;const zt=de.TRIANGLES,[wt,Rt]=[z.gridIndexBuffer,z.gridSegments];for(const ft of W){const _t=$.getTile(ft),At=cn.disabled,Wt=z.prevTerrainTileForTile[ft.key],qt=z.terrainTileForTile[ft.key];nP(Wt,qt)&&Ad.newMorphing(ft.key,Wt,qt,ee,250),Qw(D,_t.emissiveTexture),ne.activeTexture.set(de.TEXTURE0),_t.texture&&_t.texture.bind(de.LINEAR,de.CLAMP_TO_EDGE);const rs=Ad.getMorphValuesForProxy(ft.key),Jt=rs?1:0;let Ns;rs&&(Ns={morphing:{srcDemTile:rs.from,dstDemTile:rs.to,phase:i.dn(rs.phase)}});const As=D.emissiveMode==="mrt-fallback"?1:0,Kt=Yw(ft.projMatrix,QC(ft.canonical,ct.renderWorldCopies)?mt/10:mt,at,As);if(Ie(Jt),!je)continue;z.setupElevationDraw(_t,je,Ns);const Vt=ft.toUnwrapped();Ae&&Ae.setupShadows(Vt,je),D.uploadCommonUniforms(ne,je,Vt,null,Fe),je.draw(D,zt,st,At,rt,Xr.backCCW,Kt,"terrain_raster",z.gridBuffer,wt,Rt)}}}}(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(),W=v.style.order,ee=[];this._updateFBOs(v.emissiveMode==="mrt-fallback");let ne=0;for(const de of z){const je=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++],Fe=be!==void 0;if(je.texture=Ae.tex,je.emissiveTexture=Ae.emissiveTex,Fe&&!Ae.dirty){ee.push(je.tileID);continue}E.bindFramebuffer.set(Ae.fb.framebuffer);const Ie=E.gl;let rt;Ie.drawBuffers(v.emissiveMode==="mrt-fallback"?[Ie.COLOR_ATTACHMENT0,Ie.COLOR_ATTACHMENT1]:[Ie.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 ct=v.style._mergedLayers[W[st]];if(ct.isHidden(v.transform.zoom))continue;const mt=v.style.getLayerSourceCache(ct),at=mt?this.proxyToSource[de.key][mt.id]:[de];if(!at)continue;const zt=at;E.viewport.set([0,0,Ae.fb.width,Ae.fb.height]),rt!==(mt?mt.id:null)&&(this._setupStencil(Ae,at,ct,mt),rt=mt?mt.id:null),v.renderLayer(v,mt,ct,zt)}if(Ie.drawBuffers([Ie.COLOR_ATTACHMENT0]),this._drapedRenderBatches.length===0)for(const st of this._pendingGroundEffectLayers){const ct=v.style._mergedLayers[W[st]];if(ct.isHidden(v.transform.zoom))continue;const mt=v.style.getLayerSourceCache(ct),at=mt?this.proxyToSource[de.key][mt.id]:[de];if(!at)continue;const zt=at;E.viewport.set([0,0,Ae.fb.width,Ae.fb.height]),rt!==(mt?mt.id:null)&&(this._setupStencil(Ae,at,ct,mt),rt=mt?mt.id:null),v.renderLayer(v,mt,ct,zt)}this.renderedToTile?(Ae.dirty=!0,ee.push(je.tileID)):Fe||--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,W=1<<$.overscaledZ,{x:ee,y:ne}=$.canonical,de=ee/W,je=(ee+1)/W,be=ne/W,Ae=(ne+1)/W;return{minx:de,miny:be,maxx:je,maxy:Ae,t:z.dem.tree.raycastRoot(de,be,je,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 ype(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 W=new i.T(D,{width:$[0],height:$[1],data:null},z.R8);W.bind(z.LINEAR,z.CLAMP_TO_EDGE),m.emissiveTex=W,E.createColorAttachment(D,1),E.colorAttachment1.set(W.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>W.end)||i.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=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 W=0;W<$.length;++W){const ee=Object.values($[W]);v.renderCachePool.push(...ee)}}return}this._clearRasterLayersFromRenderCache();const E=this.proxyCoords,D=this._tilesDirty;for(let $=E.length-1;$>=0;$--){const W=E[$];if(v.getTileByID(W.key),v.proxyCachedFBO[W.key]!==void 0){const ee=m[W.key],ne=this.proxyToSource[W.key];let de=0;for(const je in ne){const be=ne[je],Ae=ee[je];if(!Ae||Ae.length!==be.length||be.some((Fe,Ie)=>Fe!==Ae[Ie]||D[je]&&D[je].hasOwnProperty(Fe.key))){de=-1;break}++de}for(const je in v.proxyCachedFBO[W.key])v.renderCache[v.proxyCachedFBO[W.key][je]].dirty=de<0||de!==Object.values(ee).length}}const z=[...this._drapedRenderBatches];z.sort(($,W)=>W.end-W.start-($.end-$.start));for(const $ of z)for(const W of E){if(v.proxyCachedFBO[W.key])continue;let ee=v.renderCachePool.pop();ee===void 0&&v.renderCache.length<50&&(ee=v.renderCache.length,v.renderCache.push(this._createFBO())),ee!==void 0&&(v.proxyCachedFBO[W.key]={},v.proxyCachedFBO[W.key][$.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 W;if(E.isTileClipped())W=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);W=1,this._overlapStencilMode.test={func:$.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+W>255&&(z.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=W,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):cn.disabled}_renderTileClippingMasks(m,v){const E=this.painter,D=this.painter.context,z=D.gl;E._tileClippingMaskIDs={},D.setColorMode(rn.disabled),D.setDepthMode(wr.disabled);const $=E.getOrCreateProgram("clippingMask");for(const W of m){const ee=E._tileClippingMaskIDs[W.key]=--v;$.draw(E,z.TRIANGLES,wr.disabled,new cn({func:z.ALWAYS,mask:0},ee,255,z.KEEP,z.KEEP,z.REPLACE),rn.disabled,Xr.disabled,Jw(W.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],W=i.cV([],E.slice(0,3),$);i.ay(W,W);const ee=this.raycast($,W,this._exaggeration);return ee!==null&&ee?(i.bg($,$,W,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(),W=$.tileID;if(!W)return;const ee=new i.P(W.x,W.y)._div(1<(je.min.x=Math.min(je.min.x,be.x-ee.x),je.min.y=Math.min(je.min.y,be.y-ee.y),je.max.x=Math.max(je.max.x,be.x-ee.x),je.max.y=Math.max(je.max.y,be.y-ee.y),je),{min:new i.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new i.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),de=(je,be)=>{const Ae=je.wrap+je.canonical.x/(1<rt+ne.max.x||Fe+Iest+ne.max.y};for(let je=0;je$.key===v.tileID.key);if(z)return z}if(v.tileID.key!==m.key){const z=m.canonical.z-v.tileID.canonical.z;let $,W,ee;D=i.bb();const ne=v.tileID.wrap-m.wrap<0?($=i.an>>z,W=$*((v.tileID.canonical.x<=je){const be=m.canonical.z-je;v.getSource().reparseOverscaled?(W=Math.max(m.canonical.z+2,v.transform.tileZoom),$=new i.aR(W,m.wrap,je,m.canonical.x>>be,m.canonical.y>>be)):be!==0&&(W=je,$=new i.aR(W,m.wrap,je,m.canonical.x>>be,m.canonical.y>>be))}$.key!==m.key&&(ne.push($.key),E=v.getTile($))}const de=je=>{ne.forEach(be=>{D[be]=je}),ne.length=0};for(W-=1;W>=ee&&(!E||!E.hasData());W--){E&&de(E.tileID.key);const je=$.calculateScaledKey(W);if(E=v.getTileByID(je),E&&E.hasData())break;const be=D[je];if(be===null)break;be===void 0?ne.push(je):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(W,ee,ne){const de=i.bi(ee,W),je=i.bi(ne,[.2126,.7152,.0722]),be=(Fe,Ie,rt)=>(1-rt)*Fe+rt*Ie,Ae=be(1-.3*Math.min(je,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 QO=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],JO=["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 W=m.gl;this.program=W.createProgram(),this.configuration=D,this.name=v,this.fixedDefines=[...$];const ee=`#version 300 es ${(D?D.defines():[]).concat($.map(Ie=>`#define ${Ie}`)).join(` `)}`,ne=[ee,$1];for(const Ie of E.fragmentIncludes)ne.push(Ep[Ie]);ne.push(E.fragmentSource);const de=ne.join(` `),je=[ee,dpe];for(const Ie of E.vertexIncludes)je.push(Ep[Ie]);this.forceManualRenderingForInstanceIDShaders=m.forceManualRenderingForInstanceIDShaders&&E.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&je.push("uniform int u_instanceID;"),je.push(E.vertexSource);let be=je.join(` `);this.forceManualRenderingForInstanceIDShaders&&(be=be.replaceAll("gl_InstanceID","u_instanceID"));const Ae=W.createShader(W.FRAGMENT_SHADER);if(W.isContextLost())return void(this.failedToCreate=!0);W.shaderSource(Ae,de),W.compileShader(Ae),W.attachShader(this.program,Ae);const Fe=W.createShader(W.VERTEX_SHADER);W.isContextLost()?this.failedToCreate=!0:(W.shaderSource(Fe,be),W.compileShader(Fe),W.attachShader(this.program,Fe),this.attributes={},W.linkProgram(this.program),W.deleteShader(Fe),W.deleteShader(Ae),this.fixedUniforms=z(m),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=D?D.getUniforms(m):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(Ie=>({u_instanceID:new i.bX(Ie)}))(m)),($.includes("TERRAIN")||$.includes("ELEVATED")||v.includes("symbol")||v.includes("circle"))&&(this.terrainUniforms=(Ie=>({u_dem:new i.bX(Ie),u_dem_prev:new i.bX(Ie),u_dem_tl:new i.b_(Ie),u_dem_scale:new i.bZ(Ie),u_dem_tl_prev:new i.b_(Ie),u_dem_scale_prev:new i.bZ(Ie),u_dem_size:new i.bZ(Ie),u_dem_lerp:new i.bZ(Ie),u_exaggeration:new i.bZ(Ie),u_depth:new i.bX(Ie),u_depth_size_inv:new i.b_(Ie),u_depth_range_unpack:new i.b_(Ie),u_occluder_half_size:new i.bZ(Ie),u_occlusion_depth_offset:new i.bZ(Ie),u_meter_to_dem:new i.bZ(Ie),u_label_plane_matrix_inv:new i.b$(Ie)}))(m)),$.includes("GLOBE")&&(this.globeUniforms=(Ie=>({u_tile_tl_up:new i.bY(Ie),u_tile_tr_up:new i.bY(Ie),u_tile_br_up:new i.bY(Ie),u_tile_bl_up:new i.bY(Ie),u_tile_up_scale:new i.bZ(Ie)}))(m)),$.includes("FOG")&&(this.fogUniforms=(Ie=>({u_fog_matrix:new i.b$(Ie),u_fog_range:new i.b_(Ie),u_fog_color:new i.cO(Ie),u_fog_horizon_blend:new i.bZ(Ie),u_fog_vertical_limit:new i.b_(Ie),u_fog_temporal_offset:new i.bZ(Ie),u_frustum_tl:new i.bY(Ie),u_frustum_tr:new i.bY(Ie),u_frustum_br:new i.bY(Ie),u_frustum_bl:new i.bY(Ie),u_globe_pos:new i.bY(Ie),u_globe_radius:new i.bZ(Ie),u_globe_transition:new i.bZ(Ie),u_is_globe:new i.bX(Ie),u_viewport:new i.b_(Ie)}))(m)),$.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(Ie=>({u_cutoff_params:new i.cO(Ie)}))(m)),$.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(Ie=>({u_lighting_ambient_color:new i.bY(Ie),u_lighting_directional_dir:new i.bY(Ie),u_lighting_directional_color:new i.bY(Ie),u_ground_radiance:new i.bY(Ie)}))(m)),$.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(Ie=>({u_light_matrix_0:new i.b$(Ie),u_light_matrix_1:new i.b$(Ie),u_fade_range:new i.b_(Ie),u_shadow_normal_offset:new i.bY(Ie),u_shadow_intensity:new i.bZ(Ie),u_shadow_texel_size:new i.bZ(Ie),u_shadow_map_resolution:new i.bZ(Ie),u_shadow_direction:new i.bY(Ie),u_shadow_bias:new i.bY(Ie),u_shadowmap_0:new i.bX(Ie),u_shadowmap_1:new i.bX(Ie)}))(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,$,W,ee,ne,de){const je=m.options.wireframe;if(je.terrain===!1&&je.layers2D===!1&&je.layers3D===!1)return;const be=m.context;if(!(!(!je.terrain||this.name!=="terrainRaster"&&this.name!=="globeRaster")||!(!je.layers2D||m._terrain&&m._terrain.renderingToTexture||!QO.includes(this.name))||!(!je.layers3D||!JO.includes(this.name))))return;const Ae=be.gl,Fe=m.wireframeDebugCache.getLinesFromTrianglesBuffer(m.frameCounter,z,be);if(!Fe)return;const Ie=[...this.fixedDefines,"DEBUG_WIREFRAME"],rt=m.getOrCreateProgram(this.name,{config:this.configuration,defines:Ie});be.program.set(rt.program);const st=(at,zt,wt)=>{if(zt[at]&&wt[at])for(const Rt in zt[at])wt[at][Rt]&&wt[at][Rt].set(wt.program,Rt,zt[at][Rt].current)};ne&&ne.setUniforms(rt.program,be,rt.binderUniforms,W,{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),Fe.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 wr(v.func===Ae.LESS?Ae.LEQUAL:v.func,wr.ReadOnly,v.range)),be.setStencilMode(cn.disabled);const ct=3*$.primitiveLength*2,mt=3*$.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const at=de||1;for(let zt=0;zt1?Ae.drawElementsInstanced(Ae.LINES,ct,Ae.UNSIGNED_SHORT,mt,de):Ae.drawElements(Ae.LINES,ct,Ae.UNSIGNED_SHORT,mt);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,$,W,ee,ne,de,je,be,Ae,Fe,Ie,rt){const st=m.context,ct=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,W[ft]);Fe&&Fe.setUniforms(this.program,st,this.binderUniforms,be,{zoom:Ae});const mt={[ct.POINTS]:1,[ct.LINES]:2,[ct.TRIANGLES]:3,[ct.LINE_STRIP]:1}[v];this.checkUniforms(ee,"RENDER_SHADOWS",this.shadowUniforms);const at=Ie||[],zt=Fe?Fe.getPaintVertexBuffers():[],wt=v===ct.TRIANGLES&&de,Rt=rt&&rt>0?1:void 0;for(const ft of je.get()){const _t=ft.vaos||(ft.vaos={});if((_t[ee]||(_t[ee]=new $O)).bind(st,this,ne,zt,de,ft.vertexOffset,at,Rt),this.forceManualRenderingForInstanceIDShaders){const At=rt||1;for(let Wt=0;Wt1?ct.drawElementsInstanced(v,ft.primitiveLength*mt,ct.UNSIGNED_SHORT,ft.primitiveOffset*mt*2,rt):de?ct.drawElements(v,ft.primitiveLength*mt,ct.UNSIGNED_SHORT,ft.primitiveOffset*mt*2):ct.drawArrays(v,ft.vertexOffset,ft.vertexLength);wt&&this._drawDebugWireframe(m,E,D,z,de,ft,be,Ae,Fe,rt)}}}function eF(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},vpe=i.bb(),tF=(M,m,v,E,D,z,$,W,ee,ne,de,je,be,Ae,Fe,Ie,rt,st,ct=[0,0,1])=>{const mt=m.style.light,at=mt.properties.get("position"),zt=[at.x,at.y,at.z],wt=i.dE();mt.properties.get("anchor")==="viewport"&&(i.dF(wt,-m.transform.angle),i.dG(zt,zt,wt));const Rt=mt.properties.get("color").toPremultipliedRenderColor(null),ft=m.transform,_t={u_matrix:M,u_lightpos:zt,u_lightintensity:mt.properties.get("intensity"),u_lightcolor:[Rt.r,Rt.g,Rt.b],u_vertical_gradient:+v,u_opacity:E,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:vpe,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:Fe,u_vertical_scale:Ie,u_flood_light_intensity:rt,u_ground_shadow_factor:st,u_front_cutoff_params:ct};return ft.projection.name==="globe"&&(_t.u_tile_id=[W.canonical.x,W.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]}),bpe=(M,m,v,E,D,z,$,W,ee,ne,de,je,be,Ae,Fe,Ie,rt,st)=>{const ct=tF(M,m,v,E,D,z,$,W,ne,de,je,be,Ae,Fe,Ie,rt,1,[0,0,0]),mt={u_height_factor:-Math.pow(2,W.overscaledZ)/ee.tileSize/8};return Object.assign(ct,eF(m,ee,st),mt)},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),eF(v,E,z)),sF=(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}),rF=(M,m)=>({u_matrix:M,u_depth_bias:m}),nF=(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,$,W,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:W,u_flood_light_intensity:ee,u_front_cutoff_params:ne}),a3=M=>({u_matrix:M}),i3=M=>({u_matrix:M}),aF=(M,m,v,E,D,z,$,W)=>{const ee=i.an/z.tileSize;return{u_matrix:M,u_inv_rot_matrix:m,u_camera_to_center_distance:v.getCameraToCenterDistance(W),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(),iF=(M,m,v,E,D,z,$)=>{const W=M.transform,ee=W.projection.name==="globe",ne=ee?i.dH(W.zoom,m.canonical)*W._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:je.mix,u_opacity:je.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:lF(be.paint.get("raster-hue-rotate")),u_perspective_transform:Ae,u_raster_elevation:Fe,u_zoom_transition:W,u_merc_center:ee,u_cutoff_params:ne,u_colorization_mix:oP(i.dK,rt,ct),u_colorization_offset:l3(i.dK,st,ct),u_color_ramp:Ie,u_texture_offset:[at/(mt+2*at),mt/(mt+2*at)],u_texture_res:[mt+2*at,mt+2*at],u_emissive_strength:zt,u_zbias_factor:lP(M)});function lF(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,wpe=(M,m,v,E,D,z,$,W,ee,ne,de,je)=>({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:je,u_zoom_transition:$,u_merc_center:W,u_cutoff_params:ee}),jpe=(M,m,v,E,D,z,$,W,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:W,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]}),cF=(M,m,v,E,D,z,$,W,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:W,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=i.bb(),c3=(M,m,v,E,D,z,$,W,ee,ne,de,je,be,Ae,Fe,Ie,rt,st,ct,mt,at,zt,wt,Rt)=>{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(ct),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:W,u_is_text:+ne,u_elevation_from_sea:ee?1:0,u_pitch_with_map:+E,u_texsize:de,u_texsize_icon:je,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:dF,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:dF,u_up_vector:[0,-1,0],u_color_adj_mat:zt,u_icon_transition:wt||0,u_gamma_scale:E?D.transform.getCameraToCenterDistance(ct)*Math.cos(D.terrain?0:D.transform._pitch):1,u_device_pixel_ratio:i.o.devicePixelRatio,u_is_halo:1,u_scale_factor:Rt||1,u_ground_shadow_factor:mt,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 ct.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,$,W,ee)=>Object.assign(function(ne,de,je,be,Ae,Fe){const{width:Ie,height:rt}=be.imageManager.getPixelSize(de),st=Math.pow(2,Fe.tileID.overscaledZ),ct=Fe.tileSize*Math.pow(2,be.transform.tileZoom)/st,mt=ct*(Fe.tileID.canonical.x+Fe.tileID.wrap*st),at=ct*Fe.tileID.canonical.y;return{u_image:0,u_pattern_tl:je.tl,u_pattern_br:je.br,u_texsize:[Ie,rt],u_pattern_size:je.displaySize,u_pattern_units_to_pixels:Ae?[be.transform.width,-1*be.transform.height]:[1/i.aA(Fe,1,be.transform.tileZoom),1/i.aA(Fe,1,be.transform.tileZoom)],u_pixel_coord_upper:[mt>>16,at>>16],u_pixel_coord_lower:[65535&mt,65535&at]}}(0,z,$,E,W,ee),{u_matrix:M,u_emissive_strength:m,u_opacity:v}),K1=new Float32Array(i.b9([])),W0=(M,m,v,E,D,z,$,W,ee,ne,de,je,be,Ae=[0,0,0],Fe,Ie,rt)=>{const st=D.style.light,ct=st.properties.get("position"),mt=[-ct.x,-ct.y,ct.z],at=i.dE();st.properties.get("anchor")==="viewport"&&(i.dF(at,-D.transform.angle),i.dG(mt,mt,at));const zt=de.alphaMode==="MASK",wt=st.properties.get("color").toNonPremultipliedRenderColor(null),Rt=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]),Ie&&(ft.r=Ie.color.r,ft.g=Ie.color.g,ft.b=Ie.color.b,ft.a=Ie.colorMix,je=Ie.emissionStrength,z*=Ie.opacity),{u_matrix:M,u_lighting_matrix:m,u_normal_matrix:v,u_node_matrix:E||K1,u_lightpos:mt,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:+zt,u_alphaCutoff:de.alphaCutoff,u_baseColorFactor:$.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:W.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:Rt,u_emissive_strength:je,u_occlusionTextureTransform:Fe||[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 uF{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 W=m.gl;this.buffer=W.createBuffer(),m.bindVertexBuffer.set(this.buffer),W.bufferData(W.ARRAY_BUFFER,v.arrayBuffer,this.dynamicDraw?W.DYNAMIC_DRAW:W.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 XO(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 W=new i.T(m,{width:E,height:D,data:null},m.extRenderToTextureHalfFloat?m.gl.RGBA16F:m.gl.RGBA8);W.bind($.LINEAR,$.CLAMP_TO_EDGE);const ee=m.createFramebuffer(E,D,1,null);if(ee.colorAttachment0.set(W.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 UO(this),this.clearDepth=new mpe(this),this.clearStencil=new GC(this),this.colorMask=new ppe(this),this.depthMask=new VO(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 HO(this),this.blendFunc=new JE(this),this.blendColor=new GO(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 WO(this),this.bindFramebuffer=new KO(this),this.bindRenderbuffer=new ZO(this),this.bindTexture=new V1(this),this.bindVertexBuffer=new YO(this),this.bindElementBuffer=new fpe(this),this.bindVertexArrayOES=new xpe(this),this.pixelStoreUnpack=new gpe(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 uF(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 fr(M,m,v,E,D,z,$){const W=M.context,ee=W.gl,ne=M.transform,de=[i.aH(ne.center.lng),i.aL(ne.center.lat)],je=v.layout.get("symbol-placement"),be=v.layout.get("text-variable-anchor"),Ae=v.layout.get("icon-rotation-alignment")==="map",Fe=v.layout.get("text-rotation-alignment")==="map",Ie=je!=="point",rt=[];let st=0,ct=0;for(let ft=0;ft0){const Ar=i.bb(),hr=Hs;i.cz(Ar,Wt.placementInvProjMatrix,ne.glCoordMatrix),i.cz(Ar,Ar,Wt.placementViewportMatrix),rt.push({circleArray:Cs,circleOffset:ct,transform:hr,invTransform:Ar,projection:Wt.getProjection()}),st+=Cs.length/4,ct=st}if(!Gs)continue;M.terrain&&M.terrain.setupElevationDraw(At,Qs);const _r=as?[_t.canonical.x,_t.canonical.y,1<<_t.canonical.z]:[0,0,0];Qs.draw(M,ee.LINES,wr.disabled,cn.disabled,M.colorModeForRenderPass(),Xr.disabled,aF(Hs,qt,ne,cs,de,At,_r,Wt.getProjection()),v.id,Gs.layoutVertexBuffer,Gs.indexBuffer,Gs.segments,null,ne.zoom,null,[Gs.collisionVertexBuffer,Gs.collisionVertexBufferExt])}if(!$||!rt.length)return;const mt=M.getOrCreateProgram("collisionCircle"),at=new i.dP;at.resize(4*st),at._trim();let zt=0;for(const ft of rt)for(let _t=0;_t=0&&(Ae[mt.associatedIconIndex]={x:qt,y:rs,z:Jt,angle:ts})}else L1(wt,je)}if(ne){be.clear();const ct=M.icon.placedSymbolArray;for(let mt=0;mt{let kn=[0,0,0];if(qa){const $i=M.style.directionalLight,pi=M.style.ambientLight;$i&&pi&&(kn=Ap(M.style,$i,pi))}return kn},Un=qa=>{if(M.context.disableSymbolUBO)return;qa.push("USE_PAINT_PROPERTIES_UBO");const kn=Math.floor(M.context.maxUniformBlockSize/4),$i=Math.floor(kn/4);qa.push(`MAX_UBO_SIZE_VEC4 ${$i}u`)},mn=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],Rt.gl.RGBA8)),Rt.activeTexture.set(Rt.gl.TEXTURE0+10),v.lut.texture&&v.lut.texture.bind(Rt.gl.LINEAR,Rt.gl.CLAMP_TO_EDGE),qa.push("APPLY_LUT_ON_GPU"))},mi=()=>{const qa=At&&v.layout.get("symbol-placement")!=="point",kn=[];mn(kn),Ea(kn);const $i=qa||vn,pi=Cs.elevationType==="road",Vo=M.shadowRenderer,ra=pi&&qt&&!!Vo&&Vo.enabled,_i=qr(ra),ul=pi&&qt&&!M.terrain?Kt:As,cd=v.paint.get("icon-image-cross-fade");M.terrainRenderModeElevated()&&qt&&kn.push("PITCH_WITH_MAP_TERRAIN"),_r&&(kn.push("PROJECTION_GLOBE_VIEW"),$i&&kn.push("PROJECTED_POS_ON_VIEWPORT")),cd>0&&Cs.hasAnySecondaryIcon&&kn.push("ICON_TRANSITION"),!Cs.icon.zOffsetVertexBuffer||pi&&M.terrain||kn.push("Z_OFFSET"),st===0&&ct===0&&mt===0&&at===1||kn.push("COLOR_ADJUSTMENT"),Cs.sdfIcons&&kn.push("RENDER_SDF"),ra&&kn.push("RENDER_SHADOWS","NORMAL_OFFSET"),pi&&qt&&!M.terrain&&Cs.icon.orientationVertexBuffer&&kn.push("ELEVATED_ROADS"),Un(kn);const Cl=Rt.disableSymbolUBO?Cs.icon.programConfigurations.get(v.id):null,Sc=M.getOrCreateProgram("symbol",{config:Cl,defines:kn}),bh=Gs.imageAtlasTexture?Gs.imageAtlasTexture.size:[0,0],Ja=Cs.iconSizeData,tm=i.bj(Ja,_t.zoom),sm=qt||!_t.isOrthographic,Ci=ar(hr,Gs.tileID.canonical,qt,At,_t,Cs.getProjection(),yr),Pi=xn(hr,Gs.tileID.canonical,qt,At,_t,Cs.getProjection(),yr),ci=Cs.icon.uboBinder&&Cs.icon.uboBinder.cachedHeader&&256&Cs.icon.uboBinder.cachedHeader.dataDrivenMask?[0,0]:W,Fo=M.translatePosMatrix(Pi,Gs,ci,ne,!0),Ed=M.translatePosMatrix(hr,Gs,ci,ne),ho=$i?i2:Ci,wh=At&&!qt&&!qa;let uy=Qs;!as&&!_t.mercatorFromTransition||At||(uy=Hx(_t));const sv=_r?uy:Qs,rv=v.getColorAdjustmentMatrix(st,ct,mt,at),t_=c3(Ja.kind,tm,wh,qt,M,Ed,ho,Fo,zt,!1,bh,[0,0],0,Hs,Ar,Vt,hn,sv,Cs.getProjection(),_i,qn,rv,cd,null),Xx=Gs.imageAtlasTexture?Gs.imageAtlasTexture:null,Of=v.layout.get("icon-size").constantOr(0)!==1||Cs.iconsNeedLinear,s_=Cs.sdfIcons||M.options.rotating||M.options.zooming||Of||sm?ft.LINEAR:ft.NEAREST,Zu=Cs.sdfIcons&&v.paint.get("icon-halo-width").constantOr(1)!==0,hy=M.terrain&&qt&&qa?i.b7(i.bb(),Ci):i2;if(qa&&Cs.icon){const my=i.bu.getAtTileOffsetFunc(Hs,_t.center.lat,_t.worldSize,Cs.getProjection()),py=tn(hr,Gs.tileID.canonical,qt,At,_t,Cs.getProjection(),yr),L3=v.layout.get("icon-size-scale-range"),r_=i.aC(M.scaleFactor,L3[0],L3[1]);kc(Cs,hr,M,!1,py,Pi,qt,Ie,my,Hs,r_)}return{program:Sc,buffers:Cs.icon,uniformValues:t_,atlasTexture:Xx,atlasTextureIcon:null,atlasInterpolation:s_,atlasInterpolationIcon:null,isSDF:Cs.sdfIcons,hasHalo:Zu,depthMode:ul,tile:Gs,renderWithShadows:ra,labelPlaneMatrixInv:hy}},Wi=()=>{const qa=Wt&&v.layout.get("symbol-placement")!=="point",kn=[],$i=qa||ts||vn,pi=Cs.elevationType==="road",Vo=M.shadowRenderer,ra=pi&&rs&&!!Vo&&Vo.enabled,_i=qr(ra),ul=pi&&rs&&!M.terrain?Kt:As;M.terrainRenderModeElevated()&&rs&&kn.push("PITCH_WITH_MAP_TERRAIN"),_r&&(kn.push("PROJECTION_GLOBE_VIEW"),$i&&kn.push("PROJECTED_POS_ON_VIEWPORT")),!Cs.text.zOffsetVertexBuffer||pi&&M.terrain||kn.push("Z_OFFSET"),Cs.iconsInText&&kn.push("RENDER_TEXT_AND_SYMBOL"),kn.push("RENDER_SDF"),ra&&kn.push("RENDER_SHADOWS","NORMAL_OFFSET"),pi&&rs&&!M.terrain&&Cs.text.orientationVertexBuffer&&kn.push("ELEVATED_ROADS"),mn(kn),Un(kn);const cd=Rt.disableSymbolUBO?Cs.text.programConfigurations.get(v.id):null,Cl=M.getOrCreateProgram("symbol",{config:cd,defines:kn});let Sc,bh=[0,0],Ja=null;const tm=Cs.textSizeData;Cs.iconsInText&&(bh=Gs.imageAtlasTexture?Gs.imageAtlasTexture.size:[0,0],Ja=Gs.imageAtlasTexture?Gs.imageAtlasTexture:null,Sc=rs||!_t.isOrthographic||M.options.rotating||M.options.zooming||tm.kind==="composite"||tm.kind==="camera"?ft.LINEAR:ft.NEAREST);const sm=Gs.glyphAtlasTexture?Gs.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(hr,Gs.tileID.canonical,rs,Wt,_t,Cs.getProjection(),yr),Ed=xn(hr,Gs.tileID.canonical,rs,Wt,_t,Cs.getProjection(),yr),ho=Cs.text.uboBinder&&Cs.text.uboBinder.cachedHeader&&256&Cs.text.uboBinder.cachedHeader.dataDrivenMask?[0,0]:ee,wh=M.translatePosMatrix(Ed,Gs,ho,de,!0),uy=M.translatePosMatrix(hr,Gs,ho,de),sv=$i?i2:Fo,rv=Wt&&!rs&&!qa;let t_=Qs;!as&&!_t.mercatorFromTransition||Wt||(t_=Hx(_t));const Xx=c3(tm.kind,ci,rv,rs,M,uy,sv,wh,zt,!0,sm,bh,0,Hs,Ar,Vt,hn,_r?t_:Qs,Cs.getProjection(),_i,qn,null,null,Pi),Of=Gs.glyphAtlasTexture?Gs.glyphAtlasTexture:null,s_=ft.LINEAR,Zu=v.paint.get("text-halo-width").constantOr(1)!==0,hy=M.terrain&&rs&&qa?i.b7(i.bb(),Fo):i2;if(qa&&Cs.text){const my=i.bu.getAtTileOffsetFunc(Hs,_t.center.lat,_t.worldSize,Cs.getProjection()),py=tn(hr,Gs.tileID.canonical,rs,Wt,_t,Cs.getProjection(),yr);kc(Cs,hr,M,!0,py,Ed,rs,rt,my,Hs,Pi)}return{program:Cl,buffers:Cs.text,uniformValues:Xx,atlasTexture:Of,atlasTextureIcon:Ja,atlasInterpolation:s_,atlasInterpolationIcon:Sc,isSDF:!0,hasHalo:Zu,depthMode:ul,tile:Gs,renderWithShadows:ra,labelPlaneMatrixInv:hy}},ji=Cs.icon.segments.get().length,$a=Cs.text.segments.get().length,On=ji&&!$.onlyText?mi():null,Fn=$a&&!$.onlyIcons?Wi():null,Ni=v.paint.get("icon-opacity").constantOr(1),Ji=v.paint.get("text-opacity").constantOr(1);if(Jt&&Cs.canOverlap){Ns=!0;const qa=Ni&&!$.onlyText?Cs.icon.segments.get():[],kn=Ji&&!$.onlyIcons?Cs.text.segments.get():[];for(const $i of qa)cs.push({segments:new i.dy([$i]),sortKey:$i.sortKey,state:On});for(const $i of kn)cs.push({segments:new i.dy([$i]),sortKey:$i.sortKey,state:Fn})}else $.onlyText||cs.push({segments:Ni?Cs.icon.segments:new i.dy([]),sortKey:0,state:On}),$.onlyIcons||cs.push({segments:Ji?Cs.text.segments:new i.dy([]),sortKey:0,state:Fn})}Ns&&cs.sort((Hs,Gs)=>Hs.sortKey-Gs.sortKey);for(const Hs of cs){const Gs=Hs.state;if(Gs)if(M.terrain?M.terrain.setupElevationDraw(Gs.tile,Gs.program,{useDepthForOcclusion:_t.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:Gs.labelPlaneMatrixInv}):M.setupDepthForOcclusion(_t.depthOcclusionForSymbolsAndCircles,Gs.program),Rt.activeTexture.set(ft.TEXTURE0),Gs.atlasTexture&&Gs.atlasTexture.bind(Gs.atlasInterpolation,ft.CLAMP_TO_EDGE,!0),Gs.atlasTextureIcon&&(Rt.activeTexture.set(ft.TEXTURE1),Gs.atlasTextureIcon&&Gs.atlasTextureIcon.bind(Gs.atlasInterpolationIcon,ft.CLAMP_TO_EDGE,!0)),Gs.renderWithShadows&&M.shadowRenderer.setupShadows(Gs.tile.tileID.toUnwrapped(),Gs.program,"vector-tile"),M.uploadCommonLightUniforms(M.context,Gs.program),Gs.hasHalo){const Cs=Gs.uniformValues;Cs.u_is_halo=1,h3(Gs.buffers,Hs.segments,v,M,Gs.program,Gs.depthMode,D,z,Cs,2),Cs.u_is_halo=0}else{if(Gs.isSDF){const Cs=Gs.uniformValues;Gs.hasHalo&&(Cs.u_is_halo=1,h3(Gs.buffers,Hs.segments,v,M,Gs.program,Gs.depthMode,D,z,Cs,1)),Cs.u_is_halo=0}h3(Gs.buffers,Hs.segments,v,M,Gs.program,Gs.depthMode,D,z,Gs.uniformValues,1)}}}function h3(M,m,v,E,D,z,$,W,ee,ne){const de=E.context,je=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,ct=M.uboBinder.getConstantUniformValues(rt,st);ee.u_spp_fill_np_color=ct.fill_np_color,ee.u_spp_halo_np_color=ct.halo_np_color,ee.u_spp_opacity=ct.opacity,ee.u_spp_halo_width=ct.halo_width,ee.u_spp_halo_blur=ct.halo_blur,ee.u_spp_emissive_strength=ct.emissive_strength,ee.u_spp_occlusion_opacity=ct.occlusion_opacity,ee.u_spp_z_offset=ct.z_offset;const mt=v.paint.get(M.uboBinder.isText?"text-translate-anchor":"icon-translate-anchor"),at=M.uboBinder.cachedHeader&&256&M.uboBinder.cachedHeader.dataDrivenMask&&mt==="map"?E.transform.angle:0;ee.u_spp_translate_rotation=[Math.cos(at),Math.sin(at)]}const{batchIndices:Fe,batchSegments:Ie}=M.getBatchGrouping(m);for(const rt of Fe){const st=Ie.get(rt);M.uboBinder&&M.uboBinder.bind(de,D.program,rt),D.draw(E,je.TRIANGLES,z,$,W,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"),W=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"),je=v.layout.get("line-width-unit")==="meters",be=de==="sea",Ae=!(!M.terrain||!M.terrain.enabled),Fe=M.context,Ie=Fe.gl;if(v.hasElevatedBuckets&&M.transform.projection.name==="globe")return;const rt=v.layout.get("line-cross-slope"),st=rt!==void 0,ct=rt<1,mt=D||M.colorModeForDrapableLayerRenderPass(W?ee:null),at=M.terrain&&M.terrain.renderingToTexture||z,zt=at?1:i.o.devicePixelRatio,wt=v.paint.get("line-dasharray"),Rt=wt.constantOr(1),ft=v.layout.get("line-cap"),_t=wt.constantOr(null),At=ft.constantOr(null),Wt=v.paint.get("line-pattern"),qt=Wt.constantOr(1),rs=v.paint.get("line-pattern-cross-fade"),Jt=Wt.constantOr(null),Ns=v.paint.get("line-opacity").constantOr(1);let As=!qt&&Ns!==1||M.depthOcclusion&&ne>0&&ne<1;const Kt=v.paint.get("line-gradient"),Vt=qt?"linePattern":"line",ts=i.dU(v);let as;if(at&&M.terrain&&M.terrain.clipOrMaskOverlapStencilType()&&(As=!1),ne!==0&&M.depthOcclusion){const Cs=v.paint._values["line-opacity"];Cs&&Cs.value&&Cs.value.kind==="constant"?as=Cs.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&&ts.push("VARIABLE_LINE_WIDTH"),at&&(M.emissiveMode!=="dual-source-blending"||W?M.emissiveMode==="mrt-fallback"&&ts.push("USE_MRT1"):ts.push("DUAL_SOURCE_BLENDING"));const cs={},Qs=(Cs,_r,Ar,hr,yr,Qr)=>{for(const vn of Cs){const hn=m.getTile(vn);if(qt&&!hn.patternsLoaded())continue;const qn=hn.getBucket(v);if(!qn||qn.elevationType!=="none"&&!yr||qn.elevationType==="none"&&yr)continue;M.prepareDrawTile();const qr=[..._r],Un=M.shadowRenderer,mn=qn.elevationType==="road"&&!!Un&&Un.enabled;let Ea=[0,0,0];if(mn){const ra=M.style.directionalLight,_i=M.style.ambientLight;ra&&_i&&(Ea=Ap(M.style,ra,_i)),qr.push("RENDER_SHADOWS","NORMAL_OFFSET")}const mi=qn.programConfigurations.get(v.id);let Wi=!1;if(Jt&&hn.imageAtlas){const ra=i.dV.from(Jt),_i=ra.getPrimary().scaleSelf(zt).toString(),ul=hn.imageAtlas.patternPositions.get(_i),cd=ra.getSecondary(),Cl=cd?hn.imageAtlas.patternPositions.get(cd.scaleSelf(zt).toString()):null;Wi=!!ul&&!!Cl,ul&&mi.setConstantPatternPositions(ul,Cl)}rs>0&&(Wi||mi.getPatternTransitionVertexBuffer("line-pattern"))&&qr.push("LINE_PATTERN_TRANSITION"),qn.elevationGroundScaleVertexBuffer&&qr.push("ELEVATION_GROUND_SCALE");const ji=M.isTileAffectedByFog(vn),$a=M.getOrCreateProgram(Vt,{config:mi,defines:qr,overrideFog:ji});if(!qt&&_t&&At&&hn.lineAtlas){const ra=hn.lineAtlas.getDash(_t,At);ra&&mi.setConstantPatternPositions(ra)}mn&&Un.setupShadows(hn.tileID.toUnwrapped(),$a,"vector-tile");let[On,Fn]=v.paint.get("line-trim-offset");(At==="round"||At==="square")&&On!==Fn&&(On===0&&(On-=1),Fn===1&&(Fn+=1));const Ni=at?vn.projMatrix:null,Ji=je?1/qn.tileToMeter/i.aA(hn,1,M.transform.zoom):1,qa=je?1/qn.tileToMeter/i.aA(hn,1,Math.floor(M.transform.zoom)):1,kn=Rt?v.paint._values["line-floorwidth"]:null;let $i;if(kn&&kn.value.kind==="constant"){const ra=qn.zoom;ra in cs||(cs[ra]=Math.max(.01,v.widthExpression().evaluate({zoom:ra}))),$i=kn.value.value;const _i=Math.floor(M.transform.zoom);kn.value.value=cs[ra]*Math.pow(2,_i-hn.tileID.overscaledZ)}const pi=qt?i.dW(M,hn,v,Ni,zt,Ji,qa,[On,Fn],Ea,rs):i.dX(M,hn,v,Ni,qn.lineClipsArray.length,zt,Ji,qa,[On,Fn],Ea);if(Kt){const ra=qn.gradients[v.id];let _i=ra.texture;if(v.gradientVersion!==ra.version){let ul=256;if(v.stepInterpolant){const cd=m.getSource().maxzoom,Cl=vn.canonical.z===cd?Math.ceil(1<{as!=null&&(as.value=Ns*ne),$a.draw(M,Ie.TRIANGLES,Ar,ra,mt,Xr.disabled,pi,v.id,qn.layoutVertexBuffer,qn.indexBuffer,qn.segments,v.paint,M.transform.zoom,mi,[qn.layoutVertexBuffer2,qn.patternVertexBuffer,qn.zOffsetVertexBuffer,qn.elevationGroundScaleVertexBuffer]),as!=null&&(as.value=Ns)};if(As&&!yr){const ra=M.stencilModeForClipping(vn).ref;ra===0&&at&&Fe.clear({stencil:0});const _i={func:Ie.EQUAL,mask:255};pi.u_alpha_discard_threshold=.8,Vo(new cn(_i,ra,255,Ie.KEEP,Ie.KEEP,Ie.INVERT)),pi.u_alpha_discard_threshold=0,Vo(new cn(_i,ra,255,Ie.KEEP,Ie.KEEP,Ie.KEEP))}else pi.u_alpha_discard_threshold=As&&yr&&Qr?.8:0,Vo(yr?hr:M.stencilModeForClipping(vn));$i!==void 0&&(kn.value.value=$i)}};let Hs=M.depthModeForSublayer(0,wr.ReadOnly);const Gs=new wr(M.depthOcclusion?Ie.GREATER:Ie.LEQUAL,wr.ReadOnly,M.depthRangeFor3D);if(v.hasNonElevatedBuckets){const Cs=!at&&M.terrain;ne!==0&&Cs?i.w(`Occlusion opacity for layer ${v.id} is supported on terrain only if the layer has line-z-offset enabled.`):Cs?i.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${v.id}.`):Qs(E,ts,Hs,cn.disabled,!1,!0)}if(v.hasElevatedBuckets){de==="hd-road-markup"?Ae||(Hs=Gs,ts.push("ELEVATED_ROADS")):(ts.push("ELEVATED"),Hs=Gs,st&&ts.push(ct?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),be&&ts.push("ELEVATION_REFERENCE_SEA"));const Cs=As?M.stencilModeFor3D():cn.disabled;M.forceTerrainMode=!0,Qs(E,ts,Hs,Cs,!0,!0),As&&Qs(E,ts,Hs,Cs,!0,!1),M.forceTerrainMode=!1}As&&(M.resetStencilClippingMasks(),at&&Fe.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*Fe}(M.transform),ne=M.transform.getFreeCameraOptions().position,de="elevatedStructuresDepthReconstruct",je=M.getOrCreateProgram(de,{defines:["DEPTH_RECONSTRUCTION"]}),be=M.getOrCreateProgram(de);for(const Ae of E){const Fe=m.getTile(Ae),Ie=Fe.getBucket(v);if(!Ie)continue;const rt=Ie.elevatedStructures;if(!rt)continue;const st=Ie.elevationBufferData.heightRange,ct=uP(Ae.toUnwrapped(),ne),mt=M.translatePosMatrix(Ae.projMatrix,Fe,v.paint.get("fill-translate"),v.paint.get("fill-translate-anchor"));let at,zt,wt,Rt;if(D==="initialize"){if(!st||st.min>=1||rt.depthSegments.segments[0].primitiveLength===0)continue;at=s2(mt,ct,ee,1,0),zt=$,wt=rt.depthSegments,Rt=je}else if(D==="reset"){if(!st||st.min>=0||rt.maskSegments.segments[0].primitiveLength===0)continue;at=s2(mt,ct,0,0,1),zt=W,wt=rt.maskSegments,Rt=je}else if(D==="geometry"){if(rt.depthSegments.segments[0].primitiveLength===0)continue;at=s2(mt,ct,ee,1,0),zt=$,wt=rt.depthSegments,Rt=be}Rt.draw(M,z.TRIANGLES,zt,cn.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:W,colorMode:ee,elevationType:ne,terrainEnabled:de,pass:je}=M,be=D.context.gl,Ae=$.paint.get("fill-pattern"),Fe=$.paint.get("fill-pattern-cross-fade"),Ie=Ae.constantOr(null);let rt=ne;ne!=="road"||m&&!de||(rt="none");const st=rt==="road",ct=M.painter.shadowRenderer,mt=st&&!!ct&&ct.enabled,at=new wr(D.context.gl.LEQUAL,wr.ReadOnly,D.depthRangeFor3D);let zt=[0,0,0];if(mt){const _t=D.style.directionalLight,At=D.style.ambientLight;_t&&At&&(zt=Ap(D.style,_t,At))}const wt=Ae&&Ae.constantOr(1),Rt=D.terrain&&D.terrain.renderingToTexture,ft=(_t,At)=>{let Wt,qt,rs,Jt,Ns;At?(Wt=wt&&!$.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",rs=be.LINES):(Wt=wt?"fillPattern":"fill",rs=be.TRIANGLES);for(const As of W){const Kt=z.getTile(As);if(wt&&!Kt.patternsLoaded())continue;const Vt=Kt.getBucket($);if(!Vt)continue;const ts=m?Vt.elevationBufferData:Vt.bufferData;if(ts.isEmpty())continue;D.prepareDrawTile();const as=ts.programConfigurations.get($.id),cs=D.isTileAffectedByFog(As),Qs=[],Hs=[];st&&(Qs.push("ELEVATED_ROADS"),Hs.push(ts.elevatedLayoutVertexBuffer)),mt&&Qs.push("RENDER_SHADOWS","NORMAL_OFFSET"),Rt&&v&&Qs.push("USE_MRT1"),wt&&(D.context.activeTexture.set(be.TEXTURE0),Kt.imageAtlasTexture&&Kt.imageAtlasTexture.bind(be.LINEAR,be.CLAMP_TO_EDGE),as.updatePaintBuffers());let Gs=!1;if(Ie&&Kt.imageAtlas){const yr=Kt.imageAtlas,Qr=i.dV.from(Ie),vn=Qr.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),hn=Qr.getSecondary(),qn=yr.patternPositions.get(vn),qr=hn?yr.patternPositions.get(hn.scaleSelf(i.o.devicePixelRatio).toString()):null;Gs=!!qn&&!!qr,qn&&as.setConstantPatternPositions(qn,qr)}Fe>0&&(Gs||as.getPatternTransitionVertexBuffer("fill-pattern"))&&Qs.push("FILL_PATTERN_TRANSITION");const Cs=D.getOrCreateProgram(Wt,{config:as,overrideFog:cs,defines:Qs}),_r=D.translatePosMatrix(As.projMatrix,Kt,$.paint.get("fill-translate"),$.paint.get("fill-translate-anchor"));mt&&ct.setupShadows(Kt.tileID.toUnwrapped(),Cs,"vector-tile");const Ar=$.paint.get("fill-emissive-strength");if(At){Jt=ts.lineIndexBuffer,Ns=ts.lineSegments;const yr=D.terrain&&D.terrain.renderingToTexture?D.terrain.drapeBufferSize:[be.drawingBufferWidth,be.drawingBufferHeight];qt=Wt==="fillOutlinePattern"&&wt?W1(_r,Ar,D,Kt,yr,zt,Fe):sF(_r,Ar,yr,zt)}else Jt=ts.indexBuffer,Ns=ts.triangleSegments,qt=wt?r3(_r,Ar,D,Kt,zt,Fe):s3(_r,Ar,zt);D.uploadCommonUniforms(D.context,Cs,As.toUnwrapped());let hr=_t;(ne==="road"&&!de||ne==="offset")&&(hr=at),Cs.draw(D,rs,hr,E||D.stencilModeForClipping(As),ee,Xr.disabled,qt,$.id,ts.layoutVertexBuffer,Jt,Ns,$.paint,D.transform.zoom,as,Hs)}};D.renderPass===je&&ft(D.depthModeForSublayer(1,D.renderPass==="opaque"?wr.ReadWrite:wr.ReadOnly),!1),rt==="none"&&D.renderPass==="translucent"&&$.paint.get("fill-antialias")&&ft(D.depthModeForSublayer($.getPaintProperty("fill-outline-color")?2:0,wr.ReadOnly),!0)}function Z0(M,m,v,E,D,z,$,W){v.resetLayerRenderingStats(M);const ee=M.context,ne=ee.gl,de=M.transform,je=v.paint.get("fill-extrusion-pattern"),be=v.paint.get("fill-extrusion-pattern-cross-fade"),Ae=je.constantOr(null),Fe=je.constantOr(1),Ie=v.paint.get("fill-extrusion-opacity"),rt=M.style.enable3dLights(),st=v.paint.get(rt&&!Fe?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),ct=[v.paint.get("fill-extrusion-ambient-occlusion-intensity"),st],mt=v.layout.get("fill-extrusion-edge-radius"),at=mt>0&&!v.paint.get("fill-extrusion-rounded-roof"),zt=at?0:mt,wt=de.projection.name==="globe"?i.e1():0,Rt=de.projection.name==="globe",ft=Rt?i.al(de.zoom):0,_t=[i.aH(de.center.lng),i.aL(de.center.lat)],At=v.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",Wt=v.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(At?null:v.lut).toArray01().slice(0,3),qt=v.paint.get("fill-extrusion-flood-light-intensity"),rs=v.paint.get("fill-extrusion-vertical-scale"),Jt=v.paint.get("fill-extrusion-line-width").constantOr(1)!==0,Ns=v.paint.get("fill-extrusion-height-alignment"),As=v.paint.get("fill-extrusion-base-alignment"),Kt=oc(M,v.paint.get("fill-extrusion-cutoff-fade-range")),Vt=v.paint.get("fill-extrusion-front-cutoff"),ts=p3(de.pitch,Vt,!!M.terrain),as=ts[2]<1;as&&(M.maxFrontCutoffRawStart=Math.max(M.maxFrontCutoffRawStart,Vt[0]));const cs=[];let Qs;Rt&&cs.push("PROJECTION_GLOBE_VIEW"),ct[0]>0&&cs.push("FAUX_AO"),at&&cs.push("ZERO_ROOF_RADIUS"),W&&cs.push("HAS_CENTROID"),qt>0&&cs.push("FLOOD_LIGHT"),Kt.shouldRenderCutoff&&cs.push("RENDER_CUTOFF"),as&&cs.push("RENDER_FRONT_CUTOFF"),Jt&&cs.push("RENDER_WALL_MODE");const Hs=M.renderPass==="shadow",Gs=M.shadowRenderer,Cs=Hs&&!!Gs,_r=Hs?Xr.disabled:Xr.backCCW;M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!0);let Ar=[0,0,0];if(Gs){const Qr=M.style.directionalLight,vn=M.style.ambientLight;Qr&&vn&&(Ar=Ap(M.style,Qr,vn)),Hs||(cs.push("RENDER_SHADOWS"),Gs.useNormalOffset&&cs.push("NORMAL_OFFSET")),Qs=cs.concat(["SHADOWS_SINGLE_CASCADE"])}const hr=Cs?"fillExtrusionDepth":Fe?"fillExtrusionPattern":"fillExtrusion",yr=v.getLayerRenderingStats();for(const Qr of E){const vn=m.getTile(Qr),hn=vn.getBucket(v);if(!hn||hn.projection.name!==de.projection.name)continue;let qn=!1;Gs&&(qn=Gs.getMaxCascadeForTile(Qr.toUnwrapped())===0);const qr=M.isTileAffectedByFog(Qr),Un=hn.programConfigurations.get(v.id);let mn=!1;if(Ae&&vn.imageAtlas){const Fn=vn.imageAtlas,Ni=i.dV.from(Ae),Ji=Ni.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),qa=Ni.getSecondary(),kn=Fn.patternPositions.get(Ji),$i=qa?Fn.patternPositions.get(qa.scaleSelf(i.o.devicePixelRatio).toString()):null;mn=!!kn&&!!$i,kn&&Un.setConstantPatternPositions(kn,$i)}be>0&&(mn||Un.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&cs.push("FILL_EXTRUSION_PATTERN_TRANSITION");const Ea=M.getOrCreateProgram(hr,{config:Un,defines:qn?Qs:cs,overrideFog:qr});if(M.terrain&&M.terrain.setupElevationDraw(vn,Ea,{useMeterToDem:!0}),!hn.centroidVertexBuffer){const Fn=Ea.getAttributeLocation(ne,"a_centroid_pos");Fn!==-1&&ne.vertexAttribI4ui(Fn,0,0,0,0)}!Hs&&Gs&&Gs.setupShadows(vn.tileID.toUnwrapped(),Ea,"vector-tile"),Fe&&(M.context.activeTexture.set(ne.TEXTURE0),vn.imageAtlasTexture&&vn.imageAtlasTexture.bind(ne.LINEAR,ne.CLAMP_TO_EDGE),Un.updatePaintBuffers());const mi=v.paint.get("fill-extrusion-vertical-gradient"),Wi=1/hn.tileToMeter;let ji;if(Hs&&Gs){if(f3(vn.tileID,hn.maxHeight,M))continue;const Fn=Gs.calculateShadowPassMatrixFromTile(vn.tileID.toUnwrapped());ji=_pe(Fn,zt,Wi,rs,Ns,As)}else{const Fn=M.translatePosMatrix(Qr.expandedProjMatrix,vn,v.paint.get("fill-extrusion-translate"),v.paint.get("fill-extrusion-translate-anchor")),Ni=de.projection.createInversionMatrix(de,Qr.canonical);ji=Fe?bpe(Fn,M,mi,Ie,ct,zt,Wi,Qr,vn,wt,Ns,As,ft,_t,Ni,Wt,rs,be):tF(Fn,M,mi,Ie,ct,zt,Wi,Qr,wt,Ns,As,ft,_t,Ni,Wt,rs,qt,Ar,ts)}M.uploadCommonUniforms(ee,Ea,Qr.toUnwrapped(),null,Kt);let $a=hn.segments;if(de.projection.name==="mercator"&&!Hs&&($a=hn.getVisibleSegments(vn.tileID,M.terrain,M.transform.getFrustum(0)),!$a.get().length))continue;if(yr)if(Hs)for(const Fn of $a.get())yr.numRenderedVerticesInShadowPass+=Fn.primitiveLength;else for(const Fn of $a.get())yr.numRenderedVerticesInTransparentPass+=Fn.primitiveLength;const On=[];(M.terrain||W)&&On.push(hn.centroidVertexBuffer),Rt&&On.push(hn.layoutVertexExtBuffer),Jt&&On.push(hn.wallVertexBuffer),Ea.draw(M,ee.gl.TRIANGLES,D,z,$,_r,ji,v.id,hn.layoutVertexBuffer,hn.indexBuffer,$a,v.paint,M.transform.zoom,Un,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,$,W,ee,ne,de,je,be,Ae,Fe,Ie,rt,st,ct,mt,at){const zt=m.context,wt=zt.gl,Rt=m.transform,ft=m.transform.zoom,_t=[],At=M.translate,Wt=M.translateAnchor,qt=M.edgeRadius,rs=oc(m,M.cutoffFadeRange);de==="clear"?(_t.push("CLEAR_SUBPASS"),mt&&(_t.push("CLEAR_FROM_TEXTURE"),zt.activeTexture.set(wt.TEXTURE0),mt.bind(wt.LINEAR,wt.CLAMP_TO_EDGE))):de==="sdf"?_t.push("SDF_SUBPASS"):de==="emissive"&&(_t.push("USE_MRT1"),zt.activeTexture.set(wt.TEXTURE0),mt.bind(wt.LINEAR,wt.CLAMP_TO_EDGE)),st&&_t.push("HAS_CENTROID"),rs.shouldRenderCutoff&&_t.push("RENDER_CUTOFF");const Jt=(Ns,As,Kt,Vt,ts)=>{let as=_t;As.groundRadiusBuffer!=null&&(as=_t.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const cs=As.programConfigurations.get(E.id),Qs=m.isTileAffectedByFog(Ns),Hs=m.getOrCreateProgram("fillExtrusionGroundEffect",{config:cs,defines:as,overrideFog:Qs}),Gs=((_r,Ar,hr,yr,Qr,vn,hn,qn,qr,Un,mn)=>({u_matrix:Ar,u_opacity:hr,u_ao_pass:yr?1:0,u_meter_to_tile:Qr,u_ao:vn,u_flood_light_intensity:hn,u_flood_light_color:qn,u_attenuation:qr,u_edge_radius:Un,u_fb:0,u_fb_size:mn,u_dynamic_offset:1}))(0,Vt,je,ne,ts,[be,Ae*ts],Fe,Ie,rt,ft>=17?0:qt*ts,mt?mt.size[0]:0),Cs=[];st&&Cs.push(As.hiddenByLandmarkVertexBuffer),As.groundRadiusBuffer!=null&&Cs.push(As.groundRadiusBuffer),m.uploadCommonUniforms(zt,Hs,Ns.toUnwrapped(),null,rs),Hs.draw(m,zt.gl.TRIANGLES,z,$,W,ee,Gs,E.id,As.vertexBuffer,As.indexBuffer,Kt,E.paint,ft,cs,Cs)};for(const Ns of D){const As=v.getTile(Ns),Kt=As.getBucket(E);if(!Kt||Kt.projection.name!==Rt.projection.name||!Kt.groundEffect||Kt.groundEffect&&!Kt.groundEffect.hasData())continue;const Vt=Kt.groundEffect,ts=1/Kt.tileToMeter;{const as=m.translatePosMatrix(Ns.projMatrix,As,At,Wt),cs=Vt.getDefaultSegment();Jt(Ns,Vt,cs,as,ts)}if(ct)for(let as=0;as<4;as++){const cs=i.d$[as](Ns),Qs=v.getTile(cs);if(!Qs)continue;const Hs=Qs.getBucket(E);if(!Hs||Hs.projection.name!==Rt.projection.name||!Hs.groundEffect||Hs.groundEffect&&!Hs.groundEffect.hasData())continue;const Gs=Hs.groundEffect;let Cs,_r;as===0?(Cs=[-i.an,0,0],_r=1):as===1?(Cs=[i.an,0,0],_r=0):as===2?(Cs=[0,-i.an,0],_r=3):(Cs=[0,i.an,0],_r=2);const Ar=Gs.regionSegments[_r];if(!Ar)continue;const hr=new Float32Array(16);i.bx(hr,Ns.projMatrix,Cs),Jt(Ns,Gs,Ar,m.translatePosMatrix(hr,As,At,Wt),ts)}}}function mF(M,m,v,E,D,z,$){E.centroidVertexArray.length===0&&E.createCentroidsBuffer();const W=z?z.findDEMTileFor(v):null;if(!(W&&W.dem||$))return;z&&W&&W.dem&&E.selfDEMTileTimestamp!==W.dem._timestamp&&(E.borderDoneWithNeighborZ=[-1,-1,-1,-1],E.selfDEMTileTimestamp=W.dem._timestamp);const ee=(st,ct)=>{(st.flags|ct.flags)&i.e3?(st.flags|=i.e3,ct.flags|=i.e3):(st.flags&=~i.e3,ct.flags&=~i.e3)},ne=st=>new i.P(Math.ceil((st+i.e4)*i.e5),0),de=(st,ct,mt)=>{const at=Math.ceil((st+i.e4)*i.e5),zt=Math.floor(Math.max(0,Math.min(i.an-1,mt))/4);return new i.P(at,zt<<5|(3&ct)<<3|7)},je=st=>{const ct=m.getSource().minzoom,mt=zt=>{const wt=m.getTileByID(zt);if(wt&&wt.hasData())return wt.getBucket(D)},at=[0,-1,1];for(const zt of at){if(st.overscaledZ+zt(be[0]=Math.min(st.min.y,ct.min.y),be[1]=Math.max(st.max.y,ct.max.y),be[2]=i.an-ct.min.x>st.max.x?ct.min.x-i.an:st.max.x,be),Fe=(st,ct)=>(be[0]=Math.min(st.min.x,ct.min.x),be[1]=Math.max(st.max.x,ct.max.x),be[2]=i.an-ct.min.y>st.max.y?ct.min.y-i.an:st.max.y,be),Ie=[(st,ct)=>Ae(st,ct),(st,ct)=>Ae(ct,st),(st,ct)=>Fe(st,ct),(st,ct)=>Fe(ct,st)],rt=(st,ct,mt,at,zt,wt,Rt)=>{if(!z)return 0;const ft=[[wt?mt:st,wt?st:mt,0],[wt?mt:ct,wt?ct:mt,0]],_t=Rt<0?i.an+Rt:Rt,At=[wt?_t:(st+ct)/2,wt?(st+ct)/2:_t,0];return mt===0&&Rt<0||mt!==0&&Rt>0?z.getForTilePoints(zt,[At],!0,at):ft.push(At),z.getForTilePoints(v,ft,!0,W),Math.max(ft[0][2],ft[1][2],At[2])/z.exaggeration()};for(let st=0;st<4;st++){const ct=E.borderFeatureIndices[st];if(ct.length===0)continue;const mt=i.d$[st](v),at=je(mt);if(!(at&&at instanceof i.e0))continue;const zt=z?z.findDEMTileFor(mt):null;if(!(zt&&zt.dem||$)||(z&&zt&&zt.dem&&E.borderDEMTileTimestamp[st]!==zt.dem._timestamp&&(E.borderDoneWithNeighborZ[st]=-1,E.borderDEMTileTimestamp[st]=zt.dem._timestamp),E.borderDoneWithNeighborZ[st]===at.canonical.z))continue;at.centroidVertexArray.length===0&&at.createCentroidsBuffer();const wt=(st<2?1:5)-st,Rt=at.borderDoneWithNeighborZ[wt]!==E.canonical.z,ft=at.borderFeatureIndices[wt];let _t=0;if(E.canonical.z!==at.canonical.z){for(const rs of ct)E.showCentroid(E.featuresOnBorder[rs]);if(Rt)for(const rs of ft)at.showCentroid(at.featuresOnBorder[rs]);E.borderDoneWithNeighborZ[st]=at.canonical.z,at.borderDoneWithNeighborZ[wt]=E.canonical.z;continue}const At=new Map,Wt=new Set,qt=new Set;for(let rs=0;rs1||Kt.intersectsCount()>1;{let Hs=0;if(zt&&zt.dem&&!Qs){const Gs=Ie[st](Ns,Vt),Cs=st%2?i.an-1:0;Hs=rt(Gs[0],Math.min(i.an-1,Gs[1]),Cs,zt,mt,st<2,Gs[2])}Ns.centroidXY=de(Hs,st,cs),Vt.centroidXY=de(Hs,wt,cs)}if(E.writeCentroidToBuffer(Ns),at.writeCentroidToBuffer(Vt),Jt.buildingId!==void 0){for(const Hs of E.centroidData)Hs.buildingId===Jt.buildingId&&Hs!==Ns&&(Hs.centroidXY=Ns.centroidXY,E.writeCentroidToBuffer(Hs));for(const Hs of at.centroidData)Hs.buildingId===Jt.buildingId&&Hs!==Vt&&(Hs.centroidXY=Vt.centroidXY,at.writeCentroidToBuffer(Hs))}}for(const rs of ct){if(Wt.has(rs))continue;const Jt=E.featuresOnBorder[rs],Ns=E.centroidData[Jt.centroidDataIndex],As=Jt.borders[st];let Kt;for(;_tAs[0]+3||Vt[0]>As[0]-3)break;at.showCentroid(Kt),_t++}if(Kt&&_tAs[1]-3||(ts++,++_t===ft.length))break;Kt=at.featuresOnBorder[ft[_t]]}for(;Vt=ft.length){E.showCentroid(Jt);continue}Kt=at.featuresOnBorder[ft[Vt]];let as=!1;if(ts>=1){const Hs=Kt.borders[wt];Math.abs(As[0]-Hs[0])<3&&Math.abs(As[1]-Hs[1])<3&&(ts=1,as=!0,_t=Vt+1)}else if(ts===0){E.showCentroid(Jt);continue}const cs=at.centroidData[Kt.centroidDataIndex];$&&as&&ee(Ns,cs);const Qs=Jt.intersectsCount()>1||Kt.intersectsCount()>1;if(ts>1)_t=Vt,Ns.centroidXY=cs.centroidXY=new i.P(0,0);else if(zt&&zt.dem&&!Qs){const Hs=Ie[st](Ns,cs),Gs=st%2?i.an-1:0,Cs=rt(Hs[0],Math.min(i.an-1,Hs[1]),Gs,zt,mt,st<2,Hs[2]);Ns.centroidXY=cs.centroidXY=ne(Cs)}else Qs?Ns.centroidXY=cs.centroidXY=new i.P(0,0):(Ns.centroidXY=E.encodeBorderCentroid(Jt),cs.centroidXY=at.encodeBorderCentroid(Kt));E.writeCentroidToBuffer(Ns),at.writeCentroidToBuffer(cs)}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 pF=[1,0,0],fF=[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 W=m;if(E.elevation){const Fe=E.elevation.getMinMaxForTile(M);Fe&&(W+=Fe.max)}const ee=E.scaleZoom($);W/=i.e2(E.center.lat,ee);const ne=[...D.shadowDirection];ne[2]=-ne[2];const de=D.computeSimplifiedTileShadowVolume(z,W,$,ne);if(!de)return!1;const je=[pF,fF,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,je)===0||Ae.intersectsPrecise(de.vertices,de.planes,je)===0}function c2(M){const{painter:m,source:v,layer:E,coords:D}=M;let z=M.defines;const $=m.context,W=m.renderPass==="shadow",ee=m.renderPass==="light-beam",ne=m.shadowRenderer,de=i.e2(m.transform.center.lat,m.transform.zoom),je=oc(m,E.paint.get("building-cutoff-fade-range"));je.shouldRenderCutoff&&(z=z.concat("RENDER_CUTOFF"));const be=E.paint.get("building-front-cutoff"),Ae=be[2]<1&&!m.terrain,Fe=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 Ie of D){const rt=v.getTile(Ie),st=rt.getBucket(E);if(!st)continue;ne&&ne.getMaxCascadeForTile(Ie.toUnwrapped())===0&&(z=z.concat("SHADOWS_SINGLE_CASCADE"));const ct=st.programConfigurations.get(E.id);let mt,at,zt,wt=m.translatePosMatrix(Ie.expandedProjMatrix,rt,[0,0],"map");if(wt=i.cC(i.bb(),wt,[1,1,M.verticalScale]),W&&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]),zt=i3(ft),mt=at=m.getOrCreateProgram("buildingDepth",{config:ct,defines:z,overrideFog:!1})}else if(ee)mt=at=m.getOrCreateProgram("buildingBloom",{config:ct,defines:z,overrideFog:!1}),zt=a3(wt);else{const ft=m.transform.calculatePosMatrix(Ie.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 At=m.transform.getFreeCameraOptions().position,Wt=1<{if(ee){const At=ft.entranceBloom;_t.draw(m,$.gl.TRIANGLES,M.depthMode,cn.disabled,M.blendMode,Xr.disabled,zt,E.id,At.layoutVertexBuffer,At.indexBuffer,At.segmentsBucket,E.paint,m.transform.zoom,ct,[At.layoutAttenuationBuffer,At.layoutColorBuffer])}else{const At=ft.segmentsBucket;let Wt=[ft.layoutNormalBuffer,ft.layoutCentroidBuffer,ft.layoutColorBuffer,ft.layoutFloodLightDataBuffer];ft.layoutFacadePaintBuffer&&(Wt=Wt.concat([ft.layoutFacadeDataBuffer,ft.layoutFacadeVerticalRangeBuffer,ft.layoutFacadePaintBuffer])),_t.draw(m,$.gl.TRIANGLES,M.depthMode,cn.disabled,M.blendMode,W?Xr.disabled:Xr.backCW,zt,E.id,ft.layoutVertexBuffer,ft.indexBuffer,At,E.paint,m.transform.zoom,ct,Wt)}};m.uploadCommonUniforms($,at,Ie.toUnwrapped(),null,je),st.buildingWithoutFacade&&Rt(st.buildingWithoutFacade,at),st.buildingWithFacade&&(mt!==at&&m.uploadCommonUniforms($,mt,Ie.toUnwrapped(),null,je),Rt(st.buildingWithFacade,mt))}}function pP(M,m,v,E,D,z,$,W,ee,ne,de,je,be,Ae){const Fe=M.context.gl,Ie=M.depthModeForSublayer(1,wr.ReadOnly,Fe.LEQUAL,!0),rt=.1*(1-(st=de))+3*st;var st;const ct=M._showOverdrawInspector,mt=je,at=new hP;ct||If(at,M,m,v,E,Ie,new cn({func:Fe.ALWAYS,mask:255},255,255,Fe.KEEP,Fe.KEEP,Fe.REPLACE),new rn([Fe.ONE,Fe.ONE,Fe.ONE,Fe.ONE],i.aq.transparent,[!1,!1,!1,!0],Fe.MIN),Xr.disabled,D,"sdf",z,$,W,ee,ne,rt,mt,!1,void 0);{const zt=ct?cn.disabled:new cn({func:Fe.EQUAL,mask:255},255,255,Fe.KEEP,Fe.DECR,Fe.DECR),wt=ct?M.colorModeForRenderPass():new rn([Fe.ONE_MINUS_DST_ALPHA,Fe.DST_ALPHA,Fe.ONE,Fe.ONE],i.aq.transparent,[!0,!0,!0,!0]);If(at,M,m,v,E,Ie,zt,wt,Xr.disabled,D,"color",z,$,W,ee,ne,rt,mt,!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,$,W,ee){const ne=E.getSource(),de=v.globeSharedBuffers;if(!de)return;let je,be,Ae;if(m&&(je=E.getTile(m)),ne instanceof i.aV?(be=ne.texture,Ae=i.dw(0,0,v.transform)):je&&m&&(be=je.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 Fe=v.context,Ie=Fe.gl,rt=D.paint.get("raster-resampling")==="nearest"?Ie.NEAREST:Ie.LINEAR,st=v.colorModeForDrapableLayerRenderPass(z),ct=$.defines;ct.push("GLOBE_POLES");const mt=new wr(Ie.LEQUAL,wr.ReadWrite,v.depthRangeFor3D),at=Float32Array.from(v.transform.expandedFarZProjMatrix),zt=Float32Array.from(i.du(i.dv(new i.cn(0,0,0))));v.terrain&&v.terrain.prepareDrawTile(),Fe.activeTexture.set(Ie.TEXTURE0),be.bind(rt,Ie.CLAMP_TO_EDGE),Fe.activeTexture.set(Ie.TEXTURE1),be.bind(rt,Ie.CLAMP_TO_EDGE),"useMipmap"in be&&Fe.extTextureFilterAnisotropic&&v.transform.pitch>20&&Ie.texParameterf(Ie.TEXTURE_2D,Fe.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,Fe.extTextureFilterAnisotropicMax);const[wt,Rt,ft,_t]=m?de.getPoleBuffers(m.canonical.z,!1):de.getPoleBuffers(0,!0),At=D.paint.get("raster-elevation");let Wt;M?(Wt=wt,v.renderDefaultNorthPole=At!==0):(Wt=Rt,v.renderDefaultSouthPole=At!==0);const qt=fP($.mix),rs=((Ns,As,Kt,Vt,ts,as,cs,Qs,Hs,Gs,Cs,_r,Ar,hr)=>oF(Ns,As,Kt,Vt,new Float32Array(16),new Float32Array(9),[0,0],ts,[0,0],[0,0,0,0],1,{opacity:1,mix:0},cs,[0,0],Hs,2,Cs,_r,Ar,1,0,hr))(v,at,zt,Ae,i.al(v.transform.zoom),0,D,0,At,0,qt,$.offset,$.range,z),Jt=v.getOrCreateProgram("raster",{defines:ct});v.uploadCommonUniforms(Fe,Jt,null),Jt.draw(v,Ie.TRIANGLES,mt,ee,st,W,rs,D.id,Wt,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 xF(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 gF{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),rs=i.ed(qt);be=i.aD(new Float32Array(16),ee.globeMatrix,rs),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 Fe=M.getOrCreateProgram("debug",{defines:je}),Ie=m.getTileByID(v.key);M.terrain&&M.terrain.setupElevationDraw(Ie,Fe);const rt=wr.disabled,st=cn.disabled,ct=M.colorModeForRenderPass(),mt="$debug";W.activeTexture.set(ne.TEXTURE0),M.emptyTexture.bind(ne.LINEAR,ne.CLAMP_TO_EDGE),de?Ie._makeGlobeTileDebugBuffers(M.context,ee):Ie._makeDebugTileBoundsBuffers(M.context,ee.projection);const at=Ie._tileDebugBuffer||M.debugBuffer,zt=Ie._tileDebugIndexBuffer||M.debugIndexBuffer,wt=Ie._tileDebugSegments||M.debugSegments;if(Fe.draw(M,ne.LINE_STRIP,rt,st,ct,Xr.disabled,r2(be,E.toPremultipliedRenderColor(null)),mt,at,zt,wt,null,null,null,[Ie._globeTileDebugBorderBuffer]),$){const qt=Ie.latestRawTileData,rs=Math.floor((qt&&qt.byteLength||0)/1024);let Jt=v.canonical.toString();v.overscaledZ!==v.canonical.z&&(Jt+=` => ${v.overscaledZ}`),Jt+=` ${Ie.state}`,Jt+=` ${rs}kb`,function(Ns,As){Ns.initDebugOverlayCanvas();const Kt=Ns.debugOverlayCanvas,Vt=Ns.context.gl,ts=Ns.debugOverlayCanvas.getContext("2d");ts.clearRect(0,0,Kt.width,Kt.height),ts.shadowColor="white",ts.shadowBlur=2,ts.lineWidth=1.5,ts.strokeStyle="white",ts.textBaseline="top",ts.font="bold 36px Open Sans, sans-serif",ts.fillText(As,5,5),ts.strokeText(As,5,5),Ns.debugOverlayTexture.update(Kt),Ns.debugOverlayTexture.bind(Vt.LINEAR,Vt.CLAMP_TO_EDGE)}(M,Jt)}const Rt=m.getTile(v).tileSize,ft=512/Math.min(Rt,512)*(v.overscaledZ/ee.zoom)*.5,_t=Ie._tileDebugTextBuffer||M.debugBuffer,At=Ie._tileDebugTextIndexBuffer||M.quadTriangleIndexBuffer,Wt=Ie._tileDebugTextSegments||M.debugSegments;Fe.draw(M,ne.TRIANGLES,rt,st,rn.alphaBlended,Xr.disabled,r2(be,i.aq.transparent.toPremultipliedRenderColor(null),ft),mt,_t,At,Wt,null,null,null,[Ie._globeTileDebugTextBuffer])}function vF(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,W=$.gl;W.enable(W.SCISSOR_TEST),W.scissor(m*i.o.devicePixelRatio,v*i.o.devicePixelRatio,E*i.o.devicePixelRatio,D*i.o.devicePixelRatio),$.clear({color:z}),W.disable(W.SCISSOR_TEST)}const Cpe=i.e8([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:vh}=Cpe;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,W=m.paint.get("sky-atmosphere-color"),ee=m.paint.get("sky-atmosphere-halo-color"),ne=m.paint.get("sky-atmosphere-sun-intensity"),de=((je,be,Ae,Fe,Ie)=>({u_matrix_3f:je,u_sun_direction:be,u_sun_intensity:Ae,u_color_tint_r:[Fe.r,Fe.g,Fe.b,Fe.a],u_color_tint_m:[Ie.r,Ie.g,Ie.b,Ie.a],u_luminance:5e-5}))(i.eg(i.dE(),E),D,ne,W.toPremultipliedRenderColor(null),ee.toPremultipliedRenderColor(null));$.framebufferTexture2D($.FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_CUBE_MAP_POSITIVE_X+z,m.skyboxTexture,0),v.draw(M,$.TRIANGLES,wr.disabled,cn.disabled,rn.unblended,Xr.frontCW,de,"skyboxCapture",m.skyboxGeometry.vertexBuffer,m.skyboxGeometry.indexBuffer,m.skyboxGeometry.segment)}const _F=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,_F.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 bF{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 je=i.em(30),be=[];for(let Ae=0;Ae{const ft=z.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];Rt&&ft.push("ALPHA_PASS");const _t=m.getOrCreateProgram("globeAtmosphere",{defines:ft}),At=((qt,rs,Jt,Ns,As,Kt,Vt,ts,as,cs,Qs,Hs)=>({u_frustum_tl:qt,u_frustum_tr:rs,u_frustum_br:Jt,u_frustum_bl:Ns,u_horizon:As,u_transition:Kt,u_fadeout_range:Vt,u_atmosphere_fog_color:ts.toArray01(),u_high_color:as.toArray01(),u_space_color:cs.toArray01(),u_temporal_offset:Qs,u_horizon_angle:Hs}))(z.frustumCorners.TL,z.frustumCorners.TR,z.frustumCorners.BR,z.frustumCorners.BL,z.frustumCorners.horizon,W,rt,de,be,Fe,ct,zt);m.uploadCommonUniforms(E,_t);const Wt=this.atmosphereBuffer;Wt&&_t.draw(m,D.TRIANGLES,$,cn.disabled,Rt?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Xr.backCW,At,Rt?"atmosphere_glow_alpha":"atmosphere_glow",Wt.vertexBuffer,Wt.indexBuffer,Wt.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,W=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),je=i.eg([],ne),be=i.el([],je),Ae=[0,1,0];i.dG(Ae,Ae,be),i.bJ(Ae,Ae,this.params.sizeMultiplier);const Fe=[1,0,0];i.dG(Fe,Fe,be),i.bJ(Fe,Fe,this.params.sizeMultiplier);const Ie=(rt=Ae,st=Fe,ct=E,{u_matrix:Float32Array.from(de),u_up:rt,u_right:st,u_intensity_multiplier:ct});var rt,st,ct;m.uploadCommonUniforms(D,W),this.starsVx&&this.starsIdx&&W.draw(m,z.TRIANGLES,wr.disabled,cn.disabled,this.colorModeAlphaBlendedWriteRGB,Xr.disabled,Ie,"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,je=ee.bucket;for(const be of je.featuresOnBorder)W.has(be.featureId)?de.push(be.footprintIndex):(W.add(be.featureId),ne.push(be.footprintIndex));je.updateFootprintHiddenFlags(ne,i.en,!1),je.updateFootprintHiddenFlags(de,i.en,!0)}}}function wF(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:W,metallicRoughnessTexture:ee}=z.pbrMetallicRoughness,{normalTexture:ne,occlusionTexture:de,emissionTexture:je}=z;function be(Fe,Ie,rt){if(Fe&&(M.push(Ie),$.activeTexture.set($.gl.TEXTURE0+rt),Fe.gfxTexture)){const{minFilter:st,magFilter:ct,wrapS:mt,wrapT:at}=Fe.sampler;Fe.gfxTexture.bindExtraParam(st,ct,mt,at)}}be(W,"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(je,"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,W=m.context,ee=new wr(m.context.gl.LEQUAL,M.isLightMesh?wr.ReadOnly:wr.ReadWrite,m.depthRangeFor3D),ne=m.transform,de=M.mesh,je=de.material,be=je.pbrMetallicRoughness,Ae=m.style.fog;let Fe;Fe=m.transform.projection.zAxisUnit==="pixels"?[...M.nodeModelMatrix]:i.aD([],E.zScaleMatrix,M.nodeModelMatrix),i.aD(Fe,E.negCameraPosMatrix,Fe);const Ie=i.b7([],Fe);i.e6(Ie,Ie);const rt=v.paint.get("model-color-use-theme").constantOr("default")==="none",st=v.paint.get("model-emissive-strength").constantOr(0),ct=W0(new Float32Array(M.worldViewProjection),new Float32Array(Fe),new Float32Array(Ie),null,m,$,be.baseColorFactor,je.emissiveFactor,be.metallicFactor,be.roughnessFactor,je,st,v,void 0,void 0,M.materialOverride,M.modelColor),mt={defines:[]},at=[],zt=m.shadowRenderer;zt&&(zt.useNormalOffset=!1),Ka(mt.defines,at,de,m,rt?null:v.lut);let wt=null;if(Ae){const _t=wF(M.nodeModelMatrix,m.transform);if(wt=new Float32Array(_t),ne.projection.name!=="globe"){const At=de.aabb.min,Wt=de.aabb.max,[qt,rs]=Ae.getOpacityForBounds(_t,At[0],At[1],Wt[0],Wt[1]);mt.overrideFog=qt>=sa||rs>=sa}}const Rt=oc(m,v.paint.get("model-cutoff-fade-range"));Rt.shouldRenderCutoff&&mt.defines.push("RENDER_CUTOFF");const ft=m.getOrCreateProgram("model",mt);m.uploadCommonUniforms(W,ft,null,wt,Rt),m.renderPass!=="shadow"&&zt&&zt.setupShadowsFromMatrix(M.nodeModelMatrix,ft),ft.draw(m,W.gl.TRIANGLES,ee,D,z,de.material.doubleSided?Xr.disabled:Xr.backCCW,ct,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,$,W,ee,ne){const de=M.transform,je=!!m.isGeometryBloom&&m.isGeometryBloom;if(je&&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 Fe of m.meshes){const Ie=W.get(Fe.material.name);if(Ie&&Ie.opacity<=0)continue;if(Fe.material.alphaMode!=="BLEND"){$.push({mesh:Fe,depth:0,modelIndex:D,worldViewProjection:Ae,nodeModelMatrix:be,isLightMesh:je,materialOverride:Ie,modelOpacity:ee,modelColor:ne,node:m,modelMatrix:v});continue}const rt=i.ah([],Fe.centroid,Ae);!de.isOrthographic&&rt[2]<=0||z.push({mesh:Fe,depth:rt[2],modelIndex:D,worldViewProjection:Ae,nodeModelMatrix:be,isLightMesh:je,materialOverride:Ie,modelOpacity:ee,modelColor:ne,node:m,modelMatrix:v})}if(m.children)for(const Fe of m.children)v3(M,Fe,v,E,D,z,$,W,ee,ne)}function X1(M,m,v,E){const D=v.shadowRenderer;if(!D)return;const z=D.getShadowPassDepthMode(),$=D.calculateShadowPassMatrixFromMatrix(m),W=cP($);v.getOrCreateProgram("modelDepth").draw(v,v.context.gl.TRIANGLES,z,cn.disabled,rn.disabled,Xr.disabled,W,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,je){if(je.footprintDebugMesh)return je.footprintDebugMesh;if(!je.footprint)return null;const be=de.context,Ae=je.footprint.vertices,Fe=je.footprint.indices,Ie=new i.dB;Ie.reserve(Ae.length);for(const At of Ae)Ie.emplaceBack(At.x,At.y);const rt=new i.dC;rt.reserve(Fe.length);for(let At=0;At0){const be=z.terrain,Ae=be.findDEMTileFor(W);Ae&&Ae.dem?ee=i.ex.create(be,W,Ae):je=0}if(je===0&&($.terrainElevationMin=0,$.terrainElevationMax=0),je===$.validForExaggeration&&(je===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 Fe=0;Fene&&(ne=Ae.max)}const de=i.aC(E.x,z,$)-E.x,je=i.aC(E.y,W,ee)-E.y,be=i.bU(ne,m.center.lat)-E.z;return m._zoomFromMercatorZ(Math.sqrt(de*de+je*je+be*be))}function Qi(M,m,v,E,D,z,$){const W=M.context,ee=M.renderPass==="shadow",ne=M.shadowRenderer,de=ee&&ne?ne.getShadowPassDepthMode():new wr(W.gl.LEQUAL,wr.ReadWrite,M.depthRangeFor3D),je=M.isTileAffectedByFog(z),be=M.transform.projection.name==="globe";if(v.meshes)for(const Ae of v.meshes){const Fe=be?[]:["MODEL_POSITION_ON_GPU"],Ie=[];let rt,st,ct;const mt=!be&&E.instancedDataArray.length>20;mt&&Fe.push("INSTANCED_ARRAYS");const at=oc(M,m.paint.get("model-cutoff-fade-range"));if(at.shouldRenderCutoff&&Fe.push("RENDER_CUTOFF"),ee&&ne)rt=M.getOrCreateProgram("modelDepth",{defines:Fe}),st=cP($.shadowTileMatrix,$.shadowTileMatrix,Float32Array.from(v.globalMatrix)),ct=rn.disabled;else{Ka(Fe,Ie,Ae,M,m.paint.get("model-color-use-theme").constantOr("default")==="none"?null:m.lut),rt=M.getOrCreateProgram("model",{defines:Fe,overrideFog:je});const wt=Ae.material,Rt=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,Rt.baseColorFactor,wt.emissiveFactor,Rt.metallicFactor,Rt.roughnessFactor,wt,_t,m,D),ne&&($.shadowUniformsInitialized?rt.setShadowUniformValues(W,ne.getShadowUniformValues()):(ne.setupShadows(z.toUnwrapped(),rt,"model-tile"),$.shadowUniformsInitialized=!0)),ct=at.shouldRenderCutoff||ft<1||wt.alphaMode!=="OPAQUE"?rn.alphaBlended:rn.unblended}M.uploadCommonUniforms(W,rt,z.toUnwrapped(),null,at);const zt=Ae.material.doubleSided?Xr.disabled:Xr.backCCW;if(mt)Ie.push(E.instancedDataBuffer),rt.draw(M,W.gl.TRIANGLES,de,cn.disabled,ct,zt,st,m.id,Ae.vertexBuffer,Ae.indexBuffer,Ae.segments,m.paint,M.transform.zoom,void 0,Ie,E.instancedDataArray.length);else{const wt=ee?"u_instance":"u_normal_matrix";for(let Rt=0;Rtee[1]?$:ee,z[0]=v.max[0],$=i.aE(i.bE(),z,D),W=$[1]ee[1]?$:ee,z[1]=v.min[1],$=i.aE(i.bE(),z,D),W=$[1]ee[1]?$:ee;const ne=i.aC(E[0],0,1),de=100*m.pixelsPerMeter*i.aC(E[1],0,1),je=i.aC(E[2],0,1),be=i.ey(i.bE(),W,ee,ne),Ae=Math.tan(.5*m.fovX),Fe=-be[2]*Ae;if(de===0)return be[1]<-Math.abs(Fe)?je:1;const Ie=(-Math.abs(Fe)-be[1])/de,rt=(ct,mt,at)=>(1-at)*ct+at*mt,st=i.aC(rt(1,je,Ie),je,1);return rt(1,st,i.aC((m.pitch-20)/20,0,1))}class b3{}class NF{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(m,v,E){{const je=this._storage.get(v.id);if(je)return je.lastUsedFrameIdx=m,je.buf}const D=E.gl,z=D.getBufferParameter(D.ELEMENT_ARRAY_BUFFER,D.BUFFER_SIZE),$=new ArrayBuffer(z),W=new Int16Array($);D.getBufferSubData(D.ELEMENT_ARRAY_BUFFER,0,new Int16Array($));const ee=new i.eA;for(let je=0;je30&&(E.buf.destroy(),this._storage.delete(v))}destroy(){for(const[m,v]of this._storage)v.buf.destroy(),this._storage.delete(m)}}class kF{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 SF{constructor(m){this.revealStart=11,this.revealRange=2}}const Mpe=i.e8([{type:"Float32",name:"a_pos_2f",components:2}]);class CF{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,W=new i.dC;$.emplaceBack(-1,-1),$.emplaceBack(1,-1),$.emplaceBack(1,1),$.emplaceBack(-1,1),W.emplaceBack(0,1,2),W.emplaceBack(0,2,3),this.vignetteVx=m.context.createVertexBuffer($,Mpe.members),this.vignetteIdx=m.context.createIndexBuffer(W)}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,wr.disabled,cn.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),W=i.ap(z.lat),ee=m.pixelsPerMeter/v,ne=$*i.eD,de=i.eD*Math.log(Math.tan(Math.PI/4+W/2));if(this._offsetXPrev===void 0)this._offsetXPrev=0,this._offsetYPrev=0,this._elevationPrev=0,this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;else{const je=-this._offsetYPrev+de,be=-this._elevationPrev+D;this._accumulatedOffsetX+=(-this._offsetXPrev+ne)*ee,this._accumulatedOffsetY+=je*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 W=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 W=structuredClone(this._vignetteParams);W.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,W.strength=1,W.color=structuredClone(m.style.rain.state.vignetteColor));const ee=this.updateOnRender(m,z.timeFactor),ne=m.context,de=ne.gl,je=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],Fe=(Ie,rt)=>{const st=j3(this._movement.getPosition(),Ie),ct=z.dropletSizeX,mt=z.dropletSizeX*z.dropletSizeYScale,at=m.width/2,zt=m.height/2,wt=Zx(0,z.screenThinning.start,0,1,z.screenThinning.intensity),Rt=Zx(.001,z.screenThinning.range,0,1,z.screenThinning.intensity),ft=Zx(0,z.screenThinning.particleOffset,0,1,z.screenThinning.intensity),_t=(At={modelview:ee.modelviewMatrix,projection:ee.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:st,velocityConeAperture:z.velocityConeAperture,velocity:z.velocity,boxSize:Ie,rainDropletSize:[ct,mt],distortionStrength:z.distortionStrength,rainDirection:$,color:Ae,screenSize:[je.width,je.height],thinningCenterPos:[at,zt],thinningShape:[wt,Rt,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(At.modelview),u_projection:Float32Array.from(At.projection),u_time:At.time,u_cam_pos:At.camPos,u_texScreen:0,u_velocityConeAperture:At.velocityConeAperture,u_velocity:At.velocity,u_boxSize:At.boxSize,u_rainDropletSize:At.rainDropletSize,u_distortionStrength:At.distortionStrength,u_rainDirection:At.rainDirection,u_color:At.color,u_screenSize:At.screenSize,u_thinningCenterPos:At.thinningCenterPos,u_thinningShape:At.thinningShape,u_thinningAffectedRatio:At.thinningAffectedRatio,u_thinningParticleOffset:At.thinningParticleOffset,u_shapeDirectionalPower:At.shapeDirectionalPower,u_shapeNormalPower:At.shapeNormalPower,u_mode:At.mode});var At;const Wt=Math.round(z.intensity*this.particlesCount),qt=i.dy.simpleSegment(0,0,4*Wt,2*Wt);be.draw(m,de.TRIANGLES,wr.disabled,cn.disabled,rn.alphaBlended,Xr.disabled,_t,"rain_particles",this.particlesVx,this.particlesIdx,qt)};z.distortionStrength>0&&Fe(z.boxSize,!0),Fe(z.boxSize,!1),this._vignette.draw(m,W)}}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 MF 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 SF("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 W=i.em(1323123451230);for(let ee=0;ee$)return;const W=Zx(0,1,z.revealStart,z.revealStart+z.revealRange,$);D.strength*=W,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,je=m.transform,be=m.getOrCreateProgram("snowParticle");m.uploadCommonUniforms(ne,be),((Ae,Fe,Ie)=>{const rt=j3(this._movement.getPosition(),Ae),st=je.width/2,ct=je.height/2,mt=Zx(0,Ie.screenThinning.start,0,1,Ie.screenThinning.intensity),at=Zx(.001,Ie.screenThinning.range,0,1,Ie.screenThinning.intensity),zt=Zx(0,Ie.screenThinning.particleOffset,0,1,Ie.screenThinning.intensity),wt=(Rt={modelview:ee.modelviewMatrix,projection:ee.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:rt,velocityConeAperture:Ie.velocityConeAperture,velocity:Ie.velocity,horizontalOscillationRadius:Ie.horizontalOscillationRadius,horizontalOscillationRate:Ie.horizontalOscillationRate,boxSize:Ae,billboardSize:1*Ie.billboardSize,simpleShapeParameters:[Ie.shapeFadeStart,Ie.shapeFadePower],screenSize:[je.width,je.height],thinningCenterPos:[st,ct],thinningShape:[mt,at,Math.pow(10,Ie.screenThinning.fadePower)],thinningAffectedRatio:Ie.screenThinning.affectedRatio,thinningParticleOffset:zt,color:[Ie.color.r,Ie.color.g,Ie.color.b,Ie.color.a],direction:E},{u_modelview:Float32Array.from(Rt.modelview),u_projection:Float32Array.from(Rt.projection),u_time:Rt.time,u_cam_pos:Rt.camPos,u_velocityConeAperture:Rt.velocityConeAperture,u_velocity:Rt.velocity,u_horizontalOscillationRadius:Rt.horizontalOscillationRadius,u_horizontalOscillationRate:Rt.horizontalOscillationRate,u_boxSize:Rt.boxSize,u_billboardSize:Rt.billboardSize,u_simpleShapeParameters:Rt.simpleShapeParameters,u_screenSize:Rt.screenSize,u_thinningCenterPos:Rt.thinningCenterPos,u_thinningShape:Rt.thinningShape,u_thinningAffectedRatio:Rt.thinningAffectedRatio,u_thinningParticleOffset:Rt.thinningParticleOffset,u_particleColor:Rt.color,u_direction:Rt.direction});var Rt;const ft=Math.round(Ie.intensity*this.particlesCount),_t=i.dy.simpleSegment(0,0,4*ft,2*ft);this.particlesVx&&this.particlesIdx&&be.draw(m,de.TRIANGLES,wr.disabled,cn.disabled,rn.alphaBlended,Xr.disabled,wt,"snow_particles",this.particlesVx,this.particlesIdx,_t)})(v.boxSize,0,v),this._vignette.draw(m,D)}}const TF={symbol:function(M,m,v,E,D){if(M.renderPass!=="translucent")return;const z=cn.disabled,$=M.colorModeForRenderPass(),W=v.layout.get("text-variable-anchor"),ee=v.layout.get("text-size-scale-range"),ne=i.aC(M.scaleFactor,ee[0],ee[1]);W&&function(be,Ae,Fe,Ie,rt,st,ct,mt){const at=Ae.transform,zt=rt==="map",wt=st==="map";for(const Rt of be){const ft=Ie.getTile(Rt),_t=ft.getBucket(Fe);if(!_t||!_t.text||!_t.text.segments.get().length)continue;const At=i.bj(_t.textSizeData,at.zoom,mt),Wt=Af(Rt,_t.getProjection(),at),qt=at.calculatePixelsToTileUnitsMatrix(ft),rs=ar(Wt,ft.tileID.canonical,wt,zt,at,_t.getProjection(),qt),Jt=_t.hasIconTextFit()&&_t.hasIconData();At&&hF(_t,zt,wt,ct,at,rs,Rt,Math.pow(2,at.zoom-ft.tileID.overscaledZ),At,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,je=v.paint.get("text-opacity").constantOr(1)!==0;v.layout.get("symbol-sort-key").constantOr(1)!==void 0&&(de||je)?u3(M,m,v,E,z,$):(de&&u3(M,m,v,E,z,$,{onlyIcons:!0}),je&&u3(M,m,v,E,z,$,{onlyText:!0})),m.map.showCollisionBoxes&&(fr(M,m,v,E,v.paint.get("text-translate"),v.paint.get("text-translate-anchor"),!0),fr(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"),W=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,je=M.transform,be=!(!M.terrain||!M.terrain.enabled),Ae=v.layout.get("circle-elevation-reference"),Fe=M.depthModeForSublayer(0,wr.ReadOnly),Ie=new wr(M.context.gl.LEQUAL,wr.ReadOnly,M.depthRangeFor3D),rt=Ae==="none"||be?Fe:Ie,st=cn.disabled,ct=M.colorModeForDrapableLayerRenderPass(ee),mt=je.projection.name==="globe",at=[i.aH(je.center.lng),i.aL(je.center.lat)],zt=[];for(let Rt=0;RtRt.sortKey-ft.sortKey);const wt={useDepthForOcclusion:je.depthOcclusionForSymbolsAndCircles};for(const Rt of zt){const{programConfiguration:ft,program:_t,layoutVertexBuffer:At,dynamicBuffers:Wt,indexBuffer:qt,uniformValues:rs,tile:Jt}=Rt.state,Ns=Rt.segments;M.terrain&&M.terrain.setupElevationDraw(Jt,_t,wt),M.uploadCommonUniforms(ne,_t,Jt.tileID.toUnwrapped()),_t.draw(M,de.TRIANGLES,rt,st,ct,Xr.disabled,rs,v.id,At,qt,Ns,v.paint,je.zoom,ft,Wt)}},heatmap:function(M,m,v,E){if(v.paint.get("heatmap-opacity")!==0)if(M.renderPass==="offscreen"){const D=M.context,z=D.gl,$=cn.disabled,W=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",je=de?["PROJECTION_GLOBE_VIEW"]:[],be=de?Xr.frontCCW:Xr.disabled,Ae=[i.aH(ne.center.lng),i.aL(ne.center.lat)];for(let Fe=0;Fe({u_image:0,u_color_ramp:1,u_opacity:je.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(W,ee,ne,de,je){if(W.renderPass!=="translucent")return;const be=W.context,Ae=be.gl,Fe=W.terrain;if(!Fe)return;const Ie=be.bindFramebuffer.current,rt=W.emissiveMode==="mrt-fallback";ne.lineBlendDrapeFbo=a2.createWithTexture(be,ne.lineBlendDrapeFbo,Fe.drapeBufferSize[0],Fe.drapeBufferSize[1],!0),ne.lineBlendDrapeStencil=ne.lineBlendDrapeFbo._stencilRbo,rt&&Ae.drawBuffers([Ae.COLOR_ATTACHMENT0]),be.clear({color:Gx[je].clearColor,depth:1,stencil:0});const st=W.currentStencilSource,ct=W._tileClippingMaskIDs,mt=W.nextStencilID;W.currentStencilSource=void 0,W._tileClippingMaskIDs={},W.nextStencilID=1;const at=W._terrain;W._terrain=null,W._renderTileClippingMasks(ne,ee,de),m3(W,ee,ne,de,Gx[je].colorMode,!0),W._terrain=at,W.currentStencilSource=st,W._tileClippingMaskIDs=ct,W.nextStencilID=mt,be.bindFramebuffer.set(Ie),rt&&Ae.drawBuffers([Ae.COLOR_ATTACHMENT0,Ae.COLOR_ATTACHMENT1]);const zt=Fe.drapeBufferSize;be.viewport.set([0,0,zt[0],zt[1]]);const wt=ne.lineBlendDrapeFbo;if(!wt)return;be.activeTexture.set(Ae.TEXTURE0),Ae.bindTexture(Ae.TEXTURE_2D,wt.colorAttachment0.get());const Rt=je==="additive"?1:ne.paint.get("line-opacity").constantOr(1),ft=ne.paint.get("line-emissive-strength").constantOr(0),_t=je==="additive"?W.colorModeForDrapableLayerRenderPass(ft):Gx[je].colorMode;W.getOrCreateProgram("lineBlendComposite").draw(W,Ae.TRIANGLES,wr.disabled,cn.disabled,_t,Xr.disabled,n3(0,Rt,Gx[je].compositeUniformValue),ne.id,W.viewportBuffer,W.quadTriangleIndexBuffer,W.viewportSegments,ne.paint,W.transform.zoom)}(M,m,v,E,$):M.renderPass==="offscreen"?void function(W,ee,ne,de,je){const be=W.context,Ae=Math.ceil(W.width),Fe=Math.ceil(W.height);ne.lineBlendFbo=a2.createWithTexture(be,ne.lineBlendFbo,Ae,Fe,!0),ne.lineBlendStencil=ne.lineBlendFbo._stencilRbo,be.clear({color:Gx[je].clearColor,depth:1,stencil:0});const Ie=W.currentStencilSource,rt=W._tileClippingMaskIDs,st=W.nextStencilID;W.currentStencilSource=void 0,W._tileClippingMaskIDs={},W.nextStencilID=1,W._renderTileClippingMasks(ne,ee,de);const ct=W.renderPass;W.renderPass="translucent",m3(W,ee,ne,de,Gx[je].colorMode),W.renderPass=ct,W.currentStencilSource=Ie,W._tileClippingMaskIDs=rt,W.nextStencilID=st,be.viewport.set([0,0,W.width,W.height])}(M,m,v,E,$):M.renderPass==="translucent"?void function(W,ee,ne){const de=W.context,je=de.gl,be=ee.lineBlendFbo;if(!be)return;de.activeTexture.set(je.TEXTURE0),je.bindTexture(je.TEXTURE_2D,be.colorAttachment0.get());const Ae=ne==="additive"?1:ee.paint.get("line-opacity").constantOr(1),Fe=ne==="additive"?W.colorModeForDrapableLayerRenderPass(ee.paint.get("line-emissive-strength").constantOr(0)):Gx[ne].colorMode;W.getOrCreateProgram("lineBlendComposite").draw(W,je.TRIANGLES,wr.disabled,cn.disabled,Fe,Xr.disabled,n3(0,Ae,Gx[ne].compositeUniformValue),ee.id,W.viewportBuffer,W.quadTriangleIndexBuffer,W.viewportSegments,ee.paint,W.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"),W=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 je=!(!M.terrain||!M.terrain.enabled),be={painter:M,sourceCache:m,layer:v,coords:E,colorMode:W,elevationType:de,terrainEnabled:je,pass:ne};if(M.renderPass==="shadow")return void(M.shadowRenderer&&de==="road"&&!je&&function(Fe){const{painter:Ie,sourceCache:rt,layer:st,coords:ct}=Fe,mt=Ie.context.gl,at=Fe.painter.shadowRenderer;for(const zt of ct){const wt=rt.getTile(zt),Rt=wt.getBucket(st);if(!Rt)continue;const ft=Rt.elevatedStructures;if(!ft||!ft.shadowCasterSegments||ft.shadowCasterSegments.segments[0].primitiveLength===0)continue;Ie.prepareDrawTile();const _t=Rt.bufferData.programConfigurations.get(st.id),At=Ie.isTileAffectedByFog(zt),Wt=Ie.getOrCreateProgram("elevatedStructuresDepth",{config:_t,overrideFog:At}),qt=at.calculateShadowPassMatrixFromTile(wt.tileID.toUnwrapped());Ie.uploadCommonUniforms(Ie.context,Wt,zt.toUnwrapped());const rs=rF(qt,0);Wt.draw(Ie,mt.TRIANGLES,at.getShadowPassDepthMode(),cn.disabled,rn.disabled,Xr.disabled,rs,st.id,ft.vertexBuffer,ft.indexBuffer,ft.shadowCasterSegments,st.paint,Ie.transform.zoom,_t)}}(be));const Ae=M.emissiveMode==="mrt-fallback";if(de!=="offset"){if(l2(be,!1,Ae),de==="road"){const Fe=!je&&M.renderPass==="translucent";Fe&&o2(M,m,v,E,"geometry"),l2(be,!0,Ae,cn.disabled),Fe&&function(Ie){const{painter:rt,sourceCache:st,layer:ct,coords:mt,colorMode:at}=Ie,zt=rt.context.gl,wt=Ie.painter.shadowRenderer,Rt=!!wt&&wt.enabled,ft=new wr(rt.context.gl.LEQUAL,wr.ReadOnly,rt.depthRangeFor3D);let _t=[0,0,0];if(Rt){const Wt=rt.style.directionalLight,qt=rt.style.ambientLight;Wt&&qt&&(_t=Ap(rt.style,Wt,qt))}const At=Wt=>{for(const qt of mt){const rs=st.getTile(qt),Jt=rs.getBucket(ct);if(!Jt)continue;const Ns=Jt.elevatedStructures;if(!Ns)continue;let As,Kt;if(Wt?(As=Ns.renderableBridgeSegments,Kt=Ns.bridgeProgramConfigurations.get(ct.id)):(As=Ns.renderableTunnelSegments,Kt=Ns.tunnelProgramConfigurations.get(ct.id)),!As||As.segments[0].primitiveLength===0)continue;Kt.updatePaintBuffers(),rt.prepareDrawTile();const Vt=rt.isTileAffectedByFog(qt),ts=[];Rt&&ts.push("RENDER_SHADOWS","NORMAL_OFFSET");const as=rt.getOrCreateProgram("elevatedStructures",{config:Kt,overrideFog:Vt,defines:ts}),cs=rt.translatePosMatrix(qt.projMatrix,rs,ct.paint.get("fill-translate"),ct.paint.get("fill-translate-anchor"));Rt&&wt.setupShadows(rs.tileID.toUnwrapped(),as,"vector-tile");const Qs=nF(cs,_t);rt.uploadCommonUniforms(rt.context,as,qt.toUnwrapped()),as.draw(rt,zt.TRIANGLES,ft,cn.disabled,at,Xr.backCCW,Qs,ct.id,Ns.vertexBuffer,Ns.indexBuffer,As,ct.paint,rt.transform.zoom,Kt,[Ns.vertexBufferNormal])}};At(!0),At(!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,W=M.terrain,ee=W&&W.renderingToTexture;if(D===0)return;const ne=M.emissiveMode==="mrt-fallback",de=M.conflationActive&&M.style.isLayerClipped(v,m.getSource()),je=M.style.order.indexOf(v.fqid);if(de&&function(be,Ae,Fe,Ie,rt){for(const st of Ie){const ct=Ae.getTile(st).getBucket(Fe);ct&&(ct.updateReplacement(st,be.replacementSource,rt),ct.uploadCentroid(be.context))}}(M,m,v,E,je),W||de)for(const be of E){const Ae=m.getTile(be).getBucket(v);Ae&&mF(M.context,m,be,Ae,v,W,de)}if(M.renderPass==="shadow"&&M.shadowRenderer){if(W&&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,cn.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 Fe=new wr(M.context.gl.LEQUAL,wr.ReadWrite,M.depthRangeFor3D);D===1&&be?Z0(M,m,v,E,Fe,cn.disabled,rn.unblended,de):(Z0(M,m,v,E,Fe,cn.disabled,rn.disabled,de),Z0(M,m,v,E,Fe,M.stencilModeFor3D(),M.colorModeForRenderPass(),de),M.resetStencilClippingMasks())}if(M.style.enable3dLights()&&be&&(!W&&M.transform.projection.name!=="globe"||ee)){const Fe=v.paint.get("fill-extrusion-opacity"),Ie=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"),ct=v.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",mt=v.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(ct?null:v.lut).toArray01().slice(0,3),at=Ie>0&&rt>0,zt=st>0,wt=(_t,At,Wt)=>(1-Wt)*_t+Wt*At,Rt=new hP;Rt.translate=v.paint.get("fill-extrusion-translate"),Rt.translateAnchor=v.paint.get("fill-extrusion-translate-anchor"),Rt.edgeRadius=v.layout.get("fill-extrusion-edge-radius"),Rt.cutoffFadeRange=v.paint.get("fill-extrusion-cutoff-fade-range");const ft=_t=>{const At=M.depthModeForSublayer(1,wr.ReadOnly,$.LEQUAL,!0),Wt=v.paint.get(_t?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),qt=wt(.1,3,Wt),rs=M._showOverdrawInspector;if(!rs){const Jt=new cn({func:$.ALWAYS,mask:255},255,255,$.KEEP,$.KEEP,$.REPLACE),Ns=new rn([$.ONE,$.ONE,$.ONE,$.ONE],i.aq.transparent,[!1,!1,!1,!0],$.MIN);If(Rt,M,m,v,E,At,Jt,Ns,Xr.disabled,_t,"sdf",Fe,Ie,rt,st,mt,qt,de,!1)}{const Jt=rs?cn.disabled:new cn({func:$.EQUAL,mask:255},255,255,$.KEEP,$.DECR,$.DECR),Ns=rs?M.colorModeForRenderPass():new rn([$.ONE_MINUS_DST_ALPHA,$.DST_ALPHA,$.ONE,$.ONE],i.aq.transparent,[!0,!0,!0,!0]);If(Rt,M,m,v,E,At,Jt,Ns,Xr.disabled,_t,"color",Fe,Ie,rt,st,mt,qt,de,!1)}};if(ee){const _t=()=>{const Wt=W.drapeBufferSize[0],qt=W.drapeBufferSize[1];let rs=W.framebufferCopyTexture;return rs&&(!rs||rs.size[0]===Wt&&rs.size[1]===qt)||(rs&&rs.destroy(),rs=W.framebufferCopyTexture=new i.T(z,new i.q({width:Wt,height:qt}),$.RGBA8)),rs.bind($.LINEAR,$.CLAMP_TO_EDGE),$.copyTexSubImage2D($.TEXTURE_2D,0,0,0,0,0,Wt,qt),rs},At=(Wt,qt,rs)=>{const Jt=M.depthModeForSublayer(1,wr.ReadOnly,$.LEQUAL,!1),Ns=v.paint.get(Wt?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),As=wt(.1,3,Ns);{const Kt=new rn([$.ONE,$.ONE,$.ONE,$.ONE],i.aq.transparent,[!1,!1,!1,!0]);If(Rt,M,m,v,E,Jt,cn.disabled,Kt,Xr.disabled,Wt,"clear",Fe,Ie,rt,st,mt,As,de,qt)}{const Kt=new cn({func:$.ALWAYS,mask:255},255,255,$.KEEP,$.KEEP,$.REPLACE),Vt=new rn([$.ONE,$.ONE,$.ONE,$.ONE],i.aq.transparent,[!1,!1,!1,!0],$.MIN);If(Rt,M,m,v,E,Jt,Kt,Vt,Xr.disabled,Wt,"sdf",Fe,Ie,rt,st,mt,As,de,qt)}ne&&!Wt&&(rs=_t());{const Kt=Wt?$.ZERO:$.ONE_MINUS_DST_ALPHA,Vt=new cn({func:$.EQUAL,mask:255},255,255,$.KEEP,$.DECR,$.DECR),ts=new rn([Kt,$.DST_ALPHA,$.ONE_MINUS_DST_ALPHA,$.ZERO],i.aq.transparent,[!0,!0,!0,!0]);If(Rt,M,m,v,E,Jt,Vt,ts,Xr.disabled,Wt,"color",Fe,Ie,rt,st,mt,As,de,qt)}if(!ne||Wt){const Kt=new rn([$.ONE,$.ONE,$.ONE,Wt?$.ZERO:$.ONE],i.aq.transparent,[!1,!1,!1,!0],Wt?$.FUNC_ADD:$.MAX);If(Rt,M,m,v,E,Jt,cn.disabled,Kt,Xr.disabled,Wt,"clear",Fe,Ie,rt,st,mt,As,de,qt,rs)}else{$.drawBuffers([$.NONE,$.COLOR_ATTACHMENT1]);const Kt=new cn({func:$.EQUAL,mask:255},254,255,$.KEEP,$.DECR,$.DECR),Vt=new rn([$.ONE,$.ONE,$.ONE,$.ONE],i.aq.transparent,[!0,!1,!1,!1],$.MAX);If(Rt,M,m,v,E,Jt,Kt,Vt,Xr.disabled,Wt,"emissive",Fe,Ie,rt,st,mt,As,de,qt,rs),$.drawBuffers([$.COLOR_ATTACHMENT0])}};if(at||zt){let Wt;M.prepareDrawTile(),ne&&!at||(Wt=_t()),at&&At(!0,!1,Wt),zt&&At(!1,!0,Wt)}}else at&&ft(!0),zt&&ft(!1),(at||zt)&&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 je=M.conflationActive&&M.style.isLayerClipped(v,m.getSource()),be=M.style.order.indexOf(v.fqid);if(function(Ae,Fe,Ie,rt,st,ct){for(const mt of ct){const at=Fe.getTile(mt).getBucket(Ie);at&&(st&&at.updateReplacement(mt,Ae.replacementSource,rt),at.uploadUpdatedIndexBuffer(Ae.context))}}(M,m,v,be,je,E),function(Ae,Fe,Ie,rt){for(const st of rt){const ct=Fe.getTile(st).getBucket(Ie);ct&&ct.needsEvaluation()&&ct.uploadUpdatedColorBuffer(Ae.context)}}(M,m,v,E),v.resetLayerRenderingStats(M),M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!0),M.renderPass==="shadow"&&M.shadowRenderer){const Ae=[],Fe=M.shadowRenderer.getShadowPassDepthMode();c2({painter:M,source:m,layer:v,coords:E,defines:Ae,blendMode:rn.disabled,depthMode:Fe,opacity:W,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 Fe=v.paint.get("building-facade-emissive-chance"),Ie=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",ct=v.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(st?null:v.lut).toArray01().slice(0,3),mt=v.paint.get("building-flood-light-ground-attenuation"),at=rt>0,zt=new wr(M.context.gl.LEQUAL,wr.ReadWrite,M.depthRangeFor3D);W<1&&c2({painter:M,source:m,layer:v,coords:E,defines:Ae,blendMode:rn.disabled,depthMode:zt,opacity:W,verticalScale:de,facadeEmissiveChance:Fe,facadeAOIntensity:Ie,floodLightIntensity:rt,floodLightColor:ct,depthOnly:!0});const wt=M.colorModeForRenderPass();c2({painter:M,source:m,layer:v,coords:E,defines:Ae,blendMode:wt,depthMode:zt,opacity:W,verticalScale:de,facadeEmissiveChance:Fe,facadeAOIntensity:Ie,floodLightIntensity:rt,floodLightColor:ct});const Rt=v.paint.get("building-front-cutoff");p3(M.transform.pitch,Rt,!!M.terrain),ee&&pP(M,m,v,E,!0,W,D,z,rt,ct,$,je),at&&pP(M,m,v,E,!1,W,D,z,rt,ct,mt,je)}else if(M.renderPass==="light-beam"){const Ae=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],Fe=new wr(M.context.gl.LEQUAL,wr.ReadOnly,M.depthRangeFor3D);c2({painter:M,source:m,layer:v,coords:E,defines:Ae,blendMode:rn.alphaBlended,depthMode:Fe,opacity:W,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,[$,W]=M.renderPass!=="translucent"||z?[{},E]:M.stencilConfigForOverlap(E);for(const ee of W){const ne=m.getTile(ee);if(ne.needsHillshadePrepare&&M.renderPass==="offscreen")hpe(M,ne,v);else if(M.renderPass==="translucent"){const de=M.depthModeForSublayer(0,wr.ReadOnly),je=v.paint.get("hillshade-emissive-strength"),be=M.colorModeForDrapableLayerRenderPass(je),Ae=z&&M.terrain?M.terrain.stencilModeForRTTOverlap(ee):$[ee.overscaledZ];upe(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 W=M.transform.projection.name==="globe",ee=v.paint.get("raster-elevation")!==0,ne=ee&&W,de=M.terrain&&M.terrain.exaggeration()>0&&ee&&v.paint.get("raster-elevation-reference")==="ground",je=!W&&de;if(M.renderElevatedRasterBackface&&!ne)return;const be=M.context,Ae=be.gl,Fe=m.getSource(),Ie=function(_t,At,Wt,qt,rs){const Jt=At.paint.get("raster-color"),Ns=_t.type==="raster-array",As=[],Kt=At.paint.get("raster-resampling"),Vt=At.paint.get("raster-color-mix");let ts=At.paint.get("raster-color-range");const as=[Vt[0],Vt[1],Vt[2],0],cs=Vt[3];let Qs=Kt==="nearest"?qt.NEAREST:qt.LINEAR;if(Ns&&(As.push("RASTER_ARRAY"),Jt||As.push("RASTER_COLOR"),Kt==="linear"&&As.push("RASTER_ARRAY_LINEAR"),Qs=qt.NEAREST,!ts&&_t.rasterLayers)){const Hs=_t.rasterLayers.find(({id:Gs})=>Gs===At.sourceLayer);Hs&&Hs.fields&&Hs.fields.range&&(ts=Hs.fields.range)}if(ts=ts||[0,1],Jt){As.push("RASTER_COLOR"),Wt.activeTexture.set(qt.TEXTURE2),At.updateColorRamp(ts);let Hs=At.colorRampTexture;Hs||(Hs=At.colorRampTexture=new i.T(Wt,At.colorRamp,qt.RGBA8)),Hs.bind(Qs,qt.CLAMP_TO_EDGE)}return rs&&As.push("USE_MRT1"),{mix:as,range:ts,offset:cs,defines:As,resampling:Qs}}(Fe,v,be,Ae,M.terrain&&M.terrain.renderingToTexture&&M.emissiveMode==="mrt-fallback");if(Fe instanceof i.aV&&!E.length&&!W)return;const rt=v.paint.get("raster-emissive-strength"),st=M.colorModeForDrapableLayerRenderPass(rt),ct=M.terrain&&M.terrain.renderingToTexture,mt=!M.options.moving,at=v.paint.get("raster-resampling")==="nearest"?Ae.NEAREST:Ae.LINEAR;if(Fe instanceof i.aV&&!E.length&&(Fe.onNorthPole||Fe.onSouthPole)){const _t=ee?M.stencilModeFor3D():cn.disabled;return void x3(!!Fe.onNorthPole,null,M,m,v,rt,Ie,Xr.disabled,_t)}if(!E.length)return;const[zt,wt]=Fe instanceof i.aV||ct?[{},E]:M.stencilConfigForOverlap(E),Rt=wt[wt.length-1].overscaledZ;ne&&Ie.defines.push("PROJECTION_GLOBE_VIEW"),ee&&Ie.defines.push("RENDER_CUTOFF","ELEVATED"),de&&Ie.defines.push("ELEVATION_REFERENCE_GROUND");const ft=(_t,At,Wt)=>{for(const qt of _t){const rs=qt.toUnwrapped(),Jt=m.getTile(qt);if(ct&&(!Jt||!Jt.hasData()))continue;be.activeTexture.set(Ae.TEXTURE0);const Ns=xF(Jt,Fe,v,Ie);if(!Ns||!Ns.texture)continue;const{texture:As,mix:Kt,offset:Vt,tileSize:ts,buffer:as}=Ns;let cs,Qs;ct?(cs=wr.disabled,Qs=qt.projMatrix):ee?(cs=new wr(Ae.LEQUAL,wr.ReadWrite,M.depthRangeFor3D),Qs=W?Float32Array.from(M.transform.expandedFarZProjMatrix):M.transform.calculateProjMatrix(rs,mt)):(cs=M.depthModeForSublayer(qt.overscaledZ-Rt,$===1?wr.ReadWrite:wr.ReadOnly,Ae.LESS),Qs=M.transform.calculateProjMatrix(rs,mt));const Hs=M.terrain&&ct?M.terrain.stencilModeForRTTOverlap(qt):zt[qt.overscaledZ],Gs=z?0:v.paint.get("raster-fade-duration");Jt.registerFadeDuration(Gs);const Cs=m.findLoadedParent(qt,0),_r=e2(Jt,Cs,m,M.transform,Gs);let Ar,hr;!_r.isFading&&Jt.refreshedUponExpiration&&(Jt.refreshedUponExpiration=!1),M.terrain&&M.terrain.prepareDrawTile(),be.activeTexture.set(Ae.TEXTURE0),As.bind(at,Ae.CLAMP_TO_EDGE),be.activeTexture.set(Ae.TEXTURE1),Cs?(Cs.texture&&Cs.texture.bind(at,Ae.CLAMP_TO_EDGE),Ar=Math.pow(2,Cs.tileID.overscaledZ-Jt.tileID.overscaledZ),hr=[Jt.tileID.canonical.x*Ar%1,Jt.tileID.canonical.y*Ar%1]):As.bind(at,Ae.CLAMP_TO_EDGE),"useMipmap"in As&&be.extTextureFilterAnisotropic&&M.transform.pitch>20&&Ae.texParameterf(Ae.TEXTURE_2D,be.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,be.extTextureFilterAnisotropicMax);const yr=M.transform;let Qr;const vn=ee?xP(yr):[0,0,0,0];let hn,qn,qr,Un,mn,Ea=0;if(ne&&Fe instanceof i.aV&&Fe.coordinates.length>3)hn=Float32Array.from(i.du(i.dv(new i.cn(0,0,0)))),qn=Float32Array.from(yr.globeMatrix),qr=Float32Array.from(i.dq(yr)),Un=[i.aH(yr.center.lng),i.aL(yr.center.lat)],Qr=Fe.elevatedGlobePerspectiveTransform,mn=Fe.elevatedGlobeGridMatrix||new Float32Array(9);else if(ne){const $a=i.dr(qt.canonical);Ea=i.ds($a.getCenter().lat),hn=Float32Array.from(i.du(i.dv(qt.canonical))),qn=Float32Array.from(yr.globeMatrix),qr=Float32Array.from(i.dq(yr)),Un=[i.aH(yr.center.lng),i.aL(yr.center.lat)],Qr=[0,0],mn=Float32Array.from(i.dt(qt.canonical,$a,Ea,yr.worldSize/yr._pixelsPerMercatorPixel))}else Qr=Fe instanceof i.aV?Fe.perspectiveTransform:[0,0],hn=new Float32Array(16),qn=new Float32Array(9),qr=new Float32Array(16),Un=[0,0],mn=new Float32Array(9);const mi=oF(M,Qs,hn,qn,qr,mn,hr||[0,0],i.al(M.transform.zoom),Un,vn,Ar||1,_r,v,Qr,ee?v.paint.get("raster-elevation"):0,2,Kt,Vt,Ie.range,ts,as,rt),Wi=M.isTileAffectedByFog(qt),ji=M.getOrCreateProgram("raster",{defines:Ie.defines,overrideFog:Wi});if(M.uploadCommonUniforms(be,ji,rs),Fe instanceof i.aV){const $a=Fe.elevatedGlobeVertexBuffer,On=Fe.elevatedGlobeIndexBuffer;if(ct||!W)Fe.boundsBuffer&&Fe.boundsSegments&&ji.draw(M,Ae.TRIANGLES,cs,cn.disabled,st,Xr.disabled,mi,v.id,Fe.boundsBuffer,M.quadTriangleIndexBuffer,Fe.boundsSegments);else if($a&&On){const Fn=yr.zoom<=i.cJ?Fe.elevatedGlobeSegments:Fe.getSegmentsForLongitude(yr.center.lng);Fn&&ji.draw(M,Ae.TRIANGLES,cs,cn.disabled,st,At,mi,v.id,$a,On,Fn)}}else if(ne){cs=new wr(Ae.LEQUAL,wr.ReadOnly,M.depthRangeFor3D);const $a=M.globeSharedBuffers;if($a){de&&(M.terrain.setupElevationDraw(Jt,ji),M.uploadCommonUniforms(be,ji,Jt.tileID.toUnwrapped()));const[On,Fn,Ni]=$a.getGridBuffers(Ea,!1),Ji=ji.getAttributeLocation(Ae,"a_texture_pos");Ji!==-1&&Ae.vertexAttribI4ui(Ji,0,0,0,0),ji.draw(M,Ae.TRIANGLES,cs,Wt||Hs,M.colorModeForRenderPass(),At,mi,v.id,On,Fn,Ni)}}else if(je)cs=new wr(Ae.LEQUAL,wr.ReadWrite,M.depthRangeFor3D),M.terrain.setupElevationDraw(Jt,ji),M.uploadCommonUniforms(be,ji,Jt.tileID.toUnwrapped()),yr.pitch>20&&ji.draw(M,Ae.TRIANGLES,cs,cn.disabled,rn.disabled,Xr.frontCCW,mi,v.id,M.terrain.gridBuffer,M.terrain.gridIndexBuffer,M.terrain.gridSegments),ji.draw(M,Ae.TRIANGLES,cs,Hs,st,Xr.backCCW,mi,v.id,M.terrain.gridBuffer,M.terrain.gridIndexBuffer,M.terrain.gridSegments);else{const{tileBoundsBuffer:$a,tileBoundsIndexBuffer:On,tileBoundsSegments:Fn}=M.getTileBoundsBuffers(Jt);ji.draw(M,Ae.TRIANGLES,cs,Hs,st,Xr.disabled,mi,v.id,$a,On,Fn)}}if(!(Fe instanceof i.aV)&&ne)for(const qt of _t){const rs=qt.canonical.y===(1<i.d$[as](rs));Kt.push(rs);const Vt=rs.canonical.x,ts=rs.canonical.y;for(const as of Kt){const cs=at.getTile(At?as.wrapped():as);if(!cs)continue;const Qs=cs.rasterParticleState;if(!Qs)continue;const Hs=as.canonical.x+(1<Rt.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 Rt=M.getOrCreateProgram(mt,{overrideFog:!1,overrideRtt:!0,defines:wt}),ft=new Float32Array(i.b9([])),_t=new i.aR(0,0,0,0,0),At=Ae?cy(ft,W,$,M,0,v.scope,Fe,ee,{tileID:_t,tileSize:be}):n2(ft,W,$,D.toPremultipliedRenderColor(z?null:v.lut));return void Rt.draw(M,de.TRIANGLES,st,rt,ct,Xr.disabled,At,v.id,M.viewportBuffer,M.quadTriangleIndexBuffer,M.viewportSegments)}for(const Rt of zt){const ft=M.isTileAffectedByFog(Rt),_t=M.getOrCreateProgram(mt,{overrideFog:ft,defines:wt}),At=Rt.toUnwrapped(),Wt=E?Rt.projMatrix:M.transform.calculateProjMatrix(At);M.prepareDrawTile();const qt=m?m.getTile(Rt):at?at[Rt.key]:new i.b0(Rt,be,je.zoom,M),rs=Ae?cy(Wt,W,$,M,0,v.scope,Fe,ee,{tileID:Rt,tileSize:be}):n2(Wt,W,$,D.toPremultipliedRenderColor(z?null:v.lut));M.uploadCommonUniforms(ne,_t,At);const{tileBoundsBuffer:Jt,tileBoundsIndexBuffer:Ns,tileBoundsSegments:As}=M.getTileBoundsBuffers(qt);_t.draw(M,de.TRIANGLES,st,rt,ct,Xr.disabled,rs,v.id,Jt,Ns,As)}},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"),W=new wr(z.gl.LEQUAL,wr.ReadOnly,[0,1]),ee=M.frameCounter/1e3%1;$==="atmosphere"?M.renderPass==="offscreen"?v.needsSkyboxCapture(M)&&(function(ne,de){const je=ne.context,be=je.gl;let Ae=de.skyboxFbo;if(!Ae){Ae=de.skyboxFbo=je.createFramebuffer(32,32,1,null),de.skyboxGeometry=new Zd(je),de.skyboxTexture=je.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)}je.bindFramebuffer.set(Ae.framebuffer),je.viewport.set([0,0,32,32]);const Fe=de.getCenter(ne,!0),Ie=ne.getOrCreateProgram("skyboxCapture"),rt=new Float64Array(16);i.b9(rt),i.ef(rt,rt,.5*-Math.PI),Qh(ne,de,Ie,rt,Fe,0),i.b9(rt),i.ef(rt,rt,.5*Math.PI),Qh(ne,de,Ie,rt,Fe,1),i.b9(rt),i.cE(rt,rt,.5*-Math.PI),Qh(ne,de,Ie,rt,Fe,2),i.b9(rt),i.cE(rt,rt,.5*Math.PI),Qh(ne,de,Ie,rt,Fe,3),i.b9(rt),Qh(ne,de,Ie,rt,Fe,4),i.b9(rt),i.ef(rt,rt,Math.PI),Qh(ne,de,Ie,rt,Fe,5),je.viewport.set([0,0,ne.width,ne.height])}(M,v),v.markSkyboxValid(M)):M.renderPass==="sky"&&function(ne,de,je,be,Ae){const Fe=ne.context,Ie=Fe.gl,rt=ne.transform,st=ne.getOrCreateProgram("skybox");Fe.activeTexture.set(Ie.TEXTURE0),Ie.bindTexture(Ie.TEXTURE_CUBE_MAP,de.skyboxTexture);const ct=((mt,at,zt,wt,Rt)=>({u_matrix:mt,u_sun_direction:at,u_cubemap:0,u_opacity:wt,u_temporal_offset:Rt}))(rt.skyboxMatrix,de.getCenter(ne,!1),0,be,Ae);ne.uploadCommonUniforms(Fe,st),st.draw(ne,Ie.TRIANGLES,je,cn.disabled,ne.colorModeForRenderPass(),Xr.backCW,ct,"skybox",de.skyboxGeometry.vertexBuffer,de.skyboxGeometry.indexBuffer,de.skyboxGeometry.segment)}(M,v,W,D,ee):$==="gradient"&&M.renderPass==="sky"&&function(ne,de,je,be,Ae){const Fe=ne.context,Ie=Fe.gl,rt=ne.transform,st=ne.getOrCreateProgram("skyboxGradient");de.skyboxGeometry||(de.skyboxGeometry=new Zd(Fe)),Fe.activeTexture.set(Ie.TEXTURE0);let ct=de.colorRampTexture;ct||(ct=de.colorRampTexture=new i.T(Fe,de.colorRamp,Ie.RGBA8)),ct.bind(Ie.LINEAR,Ie.CLAMP_TO_EDGE);const mt=((at,zt,wt,Rt,ft)=>({u_matrix:at,u_color_ramp:0,u_center_direction:zt,u_radius:i.ap(wt),u_opacity:Rt,u_temporal_offset:ft}))(rt.skyboxMatrix,de.getCenter(ne,!1),de.paint.get("sky-gradient-radius"),be,Ae);ne.uploadCommonUniforms(Fe,st),st.draw(ne,Ie.TRIANGLES,je,cn.disabled,ne.colorModeForRenderPass(),Xr.backCW,mt,"skyboxGradient",de.skyboxGeometry.vertexBuffer,de.skyboxGeometry.indexBuffer,de.skyboxGeometry.segment)}(M,v,W,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 W=M.transform.pointMerc;$.call(z,D.gl,M.transform.customLayerMatrix(),M.transform.getProjection(),M.transform.globeToMercatorMatrix(),i.al(M.transform.zoom),[W.x,W.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 W=z.renderToTile;if(W){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,zt,wt,Rt,ft){const _t=at.transform,At=_t.projection.name==="globe",Wt=_t.getFreeCameraOptions().position;if(!at.modelManager)return;const qt=at.modelManager;wt.modelManager=qt;const rs=at.shadowRenderer;if(!wt._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const Jt=wt._unevaluatedLayout._values["model-id"],Ns=Object.assign({},wt.layout.get("model-id").parameters),As=at.style.order.indexOf(wt.fqid),Kt=wt.paint.get("model-opacity").constantOr(1);for(const Vt of Rt){const ts=zt.getTile(Vt).getBucket(wt);if(!ts||ts.projection.name!==_t.projection.name)continue;const as=ts.getModelUris();if(as&&!ts.modelsRequested&&(qt.addModelsFromBucket(as,ft),ts.modelsRequested=!0),At)Ns.zoom=Vt.overscaledZ;else{const hr=Q1(Vt,_t);Ns.zoom=hr}const cs=Jt.possiblyEvaluate(Ns);if(Ys(at,ts,Vt),Vs.shadowUniformsInitialized=!1,Vs.useSingleShadowCascade=!!rs&&rs.getMaxCascadeForTile(Vt.toUnwrapped())===0,at.renderPass==="shadow"&&rs){if(at.currentShadowCascade===1&&ts.isInsideFirstShadowMapFrustum)continue;const hr=_t.calculatePosMatrix(Vt.toUnwrapped(),_t.worldSize);if(Vs.tileMatrix.set(hr),Vs.shadowTileMatrix=Float32Array.from(rs.calculateShadowPassMatrixFromMatrix(hr)),Vs.aabb.min=[0,0,0],Vs.aabb.max[0]=Vs.aabb.max[1]=i.an,Vs.aabb.max[2]=0,jF(ts,Vs,at,wt.scope))continue}const Qs=1<0&&at.style.isLayerClipped(wt,zt.getSource())&&ts.updateReplacement(Vt,at.replacementSource,As,wt.scope)&&(ts.uploaded=!1,ts.upload(at.context));let Gs=0;const Cs=new Array,_r=new Array,Ar=new Array;for(let hr in ts.instancesPerModel){const yr=ts.instancesPerModel[hr];yr.features.length>0&&!At&&(hr=cs.evaluate(yr.features[0].feature,{}));const Qr=qt.getModel(hr,ft);if(Qr||qt.hasURLBeenRequested(hr)||ts.modelUris.includes(hr)||(ts.modelUris.push(hr),ts.modelsRequested=!1),Qr&&Qr.uploaded)if(At){const vn=i.bJ([],[Wt.x,Wt.y,Wt.z],at.transform.worldSize);i.eo(vn,vn);for(let hn=0;hn0&&Un.elevationUpdate(hr.terrain,hn,qr,Qr.source),Un.needsReEvaluation(hr,qn,Qr)&&Un.evaluate(Qr))}})(at,zt,wt,Rt),function(){const hr=new Map;let yr,Qr,vn;Cs?(yr=Rt.length-1,Qr=-1,vn=-1):(yr=0,Qr=Rt.length,vn=1);const hn=new Float64Array(16),qn=i.ce(),qr=new i.P(0,0);for(let Un=yr;Un!==Qr;Un+=vn){const mn=Rt[Un],Ea=zt.getTile(mn).getBucket(wt);if(!Ea||!Ea.uploaded)continue;let mi=!1;Wt&&(mi=Wt.getMaxCascadeForTile(mn.toUnwrapped())===0);const Wi=_t.calculatePosMatrix(mn.toUnwrapped(),_t.worldSize),ji=Ea.modelTraits;!Qs&&Cs&&(i.b7(hn,Wi),i.ah(qn,rs,hn),qr.x=qn[0],qr.y=qn[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 Ni=0;at.terrain&&Fn.elevation&&(Ni=Fn.elevation*at.terrain.exaggeration());const Ji=(()=>{const Sc=On.aabb;return cs.min=[...Sc.min],cs.max=[...Sc.max],cs.min[2]+=Ni,cs.max[2]+=Ni,i.ah(cs.min,cs.min,Wi),i.ah(cs.max,cs.max,Wi),cs})(),qa=On.evaluatedScale;if(qa[0]<=1&&qa[1]<=1&&qa[2]<=1&&Ji.intersects(Hs)===0)continue;if(!Qs&&Cs){const Sc=.16666666666666666;On.cameraCollisionOpacity=rs[0]>Ji.min[0]&&rs[0]Ji.min[1]&&rs[1]!Cs||On.opacity===1&&Fn.opacity===1?On.depthFn.depth?-1:1);for(const On of $a){const Fn=On.nodeInfo,Ni=Fn.node;if(at._debugParams.show3DModelFootprints&&Ni.footprint){const ra=Ni.id||Ni.name||"footprint";hr.has(ra)||hr.set(ra,{node:Ni,mvp:On.wvpForTile})}let Ji=i.aD([],Kt,On.tileModelMatrix);i.aD(Ji,Ns,Ji);const qa=i.b7([],Ji);i.e6(qa,qa),i.cC(qa,qa,Gt),Ji=i.aD(Ji,Ji,Ni.globalMatrix);const kn=at.renderPass==="light-beam",$i=wt.paint.get("model-color-use-theme").constantOr("default")==="none",pi=ji&i.ez.HasMapboxMeshFeatures,Vo=pi?0:Fn.evaluatedRMEA[0][2];for(let ra=0;ra=sa||wh>=sa}}const Ja=_i.material;let tm;Ja.occlusionTexture&&Ja.occlusionTexture.offsetScale&&(tm=Ja.occlusionTexture.offsetScale,Cl.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const sm=at.getOrCreateProgram("model",Cl);!Qs&&Wt&&Wt.setupShadowsFromMatrix(On.tileModelMatrix,sm,Wt.useNormalOffset),at.uploadCommonUniforms(ft,sm,null,bh);const Ci=Ja.pbrMetallicRoughness;Ci.metallicFactor=.9,Ci.roughnessFactor=.5;const Pi=W0(new Float32Array(cd),new Float32Array(Ji),new Float32Array(qa),new Float32Array(Ni.globalMatrix),at,On.opacity,Ci.baseColorFactor,Ja.emissiveFactor,Ci.metallicFactor,Ci.roughnessFactor,Ja,Vo,wt,[0,0,0],tm);!ul&&(Fn.hasTranslucentParts||On.opacity<1)&&sm.draw(at,ft.gl.TRIANGLES,ts,cn.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?as:ts,cn.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&&hr.size>0){const Un=Array.from(hr.keys()).sort();for(const mn of Un){const{node:Ea,mvp:mi}=hr.get(mn);SP(at,0,Ea,mi)}}}()}(M,m,v,E),void je();if(be.type!=="model")return;const Ae=be.getModels(),Fe=[],Ie=M.transform.getFreeCameraOptions().position,rt=i.bJ([],[Ie.x,Ie.y,Ie.z],M.transform.worldSize);i.eo(rt,rt);const st=[],ct=[];let mt=0;for(const at of Ae){const zt=m.getFeatureState("",at.id),wt={type:"Unknown",id:at.id,properties:at.featureProperties},Rt=v.paint.get("model-rotation").evaluate(wt,zt),ft=v.paint.get("model-scale").evaluate(wt,zt),_t=v.paint.get("model-translation").evaluate(wt,zt),At=v.paint.get("model-opacity").evaluate(wt,zt);CP(v,at.id,zt,at.featureProperties,at.nodeOverrideNames,at.nodeOverrides),X0(v,at.id,zt,at.featureProperties,at.materialOverrideNames,at.materialOverrides),at.nodeOverrides.size>0&&at.computeBoundsAndApplyParent(),at.computeModelMatrix(M,Rt,ft,_t,W,$,!1);const Wt=i.b9([]),qt=i.e2(at.position.lat,M.transform.zoom),rs=i.bP([],[1,1,1/qt]);i.bx(Wt,Wt,rt),Fe.push({zScaleMatrix:rs,negCameraPosMatrix:Wt});for(const Jt of at.nodes)v3(M,Jt,at.matrix,M.transform.expandedFarZProjMatrix,mt,st,ct,at.materialOverrides,At);mt++}if(st.sort((at,zt)=>zt.depth-at.depth),M.renderPass!=="shadow"){if(M._debugParams.show3DModelFootprints){const at=M.transform.projMatrix,zt=new Map,wt=(ft,_t)=>{if(ft.footprint){const At=ft.id||ft.name||"footprint";if(!zt.has(At)){const Wt=i.aD([],at,_t);zt.set(At,{node:ft,mvp:Wt})}}};for(const ft of ct)wt(ft.node,ft.modelMatrix);for(const ft of st)wt(ft.node,ft.modelMatrix);const Rt=Array.from(zt.keys()).sort();for(const ft of Rt){const{node:_t,mvp:At}=zt.get(ft);SP(M,0,_t,At)}}Kx(M,v,st,ct,Fe),je()}else{for(const at of ct)X1(at.mesh,at.nodeModelMatrix,M,v);for(const at of st)X1(at.mesh,at.nodeModelMatrix,M,v);je()}}},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(W=>m.getTileByID(W));for(const W of $)W.updateNeeded(M.id,z)&&E.prepareTile(W,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(W=>m.getTileByID(W));for(const W of $)W.updateNeeded(M.id,z)&&E.prepareTile(W,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 wr(D.LEQUAL,wr.ReadOnly,M.depthRangeFor3D),$=new cn({func:D.ALWAYS,mask:255},255,255,D.KEEP,D.KEEP,D.REPLACE),W=M.transform.getFreeCameraOptions().position,ee=M.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const ne of E){const de=m.getTile(ne),je=de.getBucket(v);if(!je)continue;const be=je.elevatedStructures;if(!be||be.depthSegments.segments[0].primitiveLength===0)continue;const Ae=uP(ne.toUnwrapped(),W),Fe=M.translatePosMatrix(ne.projMatrix,de,v.paint.get("fill-translate"),v.paint.get("fill-translate-anchor")),Ie=s2(Fe,Ae,0,1,0);ee.draw(M,D.TRIANGLES,z,$,rn.disabled,Xr.disabled,Ie,v.id,be.vertexBuffer,be.indexBuffer,be.depthSegments,v.paint,M.transform.zoom)}}};class Tpe{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 kF,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 NF,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const W=new i.q({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new i.T(this.context,W,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 W=new i.eJ;for(const ne of[0,1,3,2,0])W.emplaceBack(ne);this.debugIndexBuffer=m.createIndexBuffer(W),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 cn({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,wr.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 W=!1;for(const ee of E)if(this._tileClippingMaskIDs[ee.key]===void 0){W=!0;break}if(!W)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(wr.disabled);const $=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const W of E){const ee=v.getTile(W),ne=this._tileClippingMaskIDs[W.key]=this.nextStencilID++,{tileBoundsBuffer:de,tileBoundsIndexBuffer:je,tileBoundsSegments:be}=this.getTileBoundsBuffers(ee);$.draw(this,z.TRIANGLES,wr.disabled,new cn({func:z.ALWAYS,mask:0},ne,255,z.KEEP,z.KEEP,z.REPLACE),rn.disabled,Xr.disabled,Jw(W.projMatrix),"$clipping",de,je,be)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const m=this.nextStencilID++,v=this.context.gl;return new cn({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 cn({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(($,W)=>W.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 W=0;Wthis._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(Kt=>{const Vt=D[Kt];return!(Vt.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[Vt.type]});let W=$(),ee=!1,ne=!1,de=null,je=0,be=!1;for(const Kt of W){const Vt=D[Kt];Vt.visibility!=="none"&&(Vt.type==="circle"?ee=!0:Vt.type==="building"?(de=Vt,++je):Vt.type==="symbol"&&(Vt.hasOcclusionOpacityProperties?ne=!0:ee=!0))}this.updateEmissiveMode();let Ae=W.map(Kt=>D[Kt]);const Fe=this.style._mergedSourceCaches;this.imageManager=m.imageManager,this.modelManager=m.modelManager,this.symbolFadeChange=m.placement.symbolFadeChange(i.o.now()),this.imageManager.beginFrame();for(const Kt in Fe){const Vt=Fe[Kt];Vt.used&&(Vt.prepare(this.context),Vt.getSource().usedInConflation&&++je)}let Ie=!1;for(const Kt of Ae)Kt.isHidden(this.transform.zoom)||(Kt.type==="clip"&&(Ie=!0),this.prepareLayer(Kt));const rt={},st={},ct={},mt={},at={};for(const Kt in Fe){const Vt=Fe[Kt];rt[Kt]=Vt.getVisibleCoordinates(),st[Kt]=rt[Kt].slice().reverse(),ct[Kt]=Vt.getVisibleCoordinates(!0).reverse(),mt[Kt]=Vt.getShadowCasterCoordinates(),at[Kt]=Vt.sortCoordinatesByDistance(rt[Kt])}const zt=Kt=>{const Vt=this.style.getLayerSourceCache(Kt);return Vt&&Vt.used?Vt.getSource():null};if(je||Ie||this._clippingActiveLastFrame){const Kt=[],Vt=[];let ts=0;for(const as of Ae)this.isSourceForClippingOrConflation(as,zt(as))&&(Kt.push(as),Vt.push(ts)),ts++;if(Kt&&(Ie||Kt.length>1)||this._clippingActiveLastFrame){Ie=!1;const as=[];for(let cs=0;cs0){const as=zt(Vt);as&&(this.minCutoffZoom=Math.max(as.minzoom,this.minCutoffZoom)),Vt.minzoom&&(this.minCutoffZoom=Math.max(Vt.minzoom,this.minCutoffZoom))}Vt.is3D(z)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=Kt),this._lastOcclusionLayer=Kt)}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(ct),this.opaquePassCutoff=0,W=$(),Ae=W.map(Kt=>D[Kt]));const Rt=this._shadowRenderer;if(Rt){Rt.updateShadowParameters(this.transform,this.style.directionalLight);for(const Kt in Fe)for(const Vt of rt[Kt]){let ts={min:0,max:0};this.terrain&&(ts=this.terrain.getMinMaxForTile(Vt)||ts),Rt.addShadowReceiver(Vt.toUnwrapped(),ts.min,ts.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 bF(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 MF(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 Kt=this.style.getLayerSourceCache(de);this.buildingTileBorderManager.updateBorders(Kt,de)}if(!tt.has(this.context.gl))return;this.renderPass="offscreen";for(const Kt of Ae){const Vt=m.getLayerSourceCache(Kt);if(!Kt.hasOffscreenPass()||Kt.isHidden(this.transform.zoom))continue;const ts=Vt?st[Vt.id]:void 0;(Kt.type==="custom"||Kt.type==="raster"||Kt.type==="raster-particle"||Kt.isSky()||ts&&ts.length)&&this.renderLayer(this,Vt,Kt,ts)}this.depthRangeFor3D=[0,1-(Ae.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,mt)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const At=this.transform.projection.name==="globe"||this.transform.isHorizonVisible(),Wt=(()=>{if(v.showOverdrawInspector)return i.aq.black;const Kt=this.style.fog;if(Kt&&this.transform.projection.supportsFog){const Vt=this.style.getLut(Kt.scope);if(!At){const ts=Kt.properties.get("color-use-theme")==="none",as=Kt.properties.get("color").toNonPremultipliedRenderColor(ts?null:Vt).toArray01();return new i.aq(...as)}if(At){const ts=Kt.properties.get("space-color-use-theme")==="none",as=Kt.properties.get("space-color").toNonPremultipliedRenderColor(ts?null:Vt).toArray01();return new i.aq(...as)}}return i.aq.transparent})();if(this.context.clear({color:Wt,depth:1}),this.clearStencil(),this._showOverdrawInspector=v.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&At&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=W.length-1;this.currentLayer>=0;this.currentLayer--){const Kt=Ae[this.currentLayer],Vt=m.getLayerSourceCache(Kt);if(Kt.isSky())continue;const ts=Vt?(Kt.is3D(z)?at:st)[Vt.id]:void 0;this._renderTileClippingMasks(Kt,Vt,ts),this.renderLayer(this,Vt,Kt,ts)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&At&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||i.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 ts=this.currentLayer;this.depthOcclusion=!0;for(const as of this.layersWithOcclusionOpacity){this.currentLayer=as;const cs=Ae[this.currentLayer],Qs=m.getLayerSourceCache(cs),Hs=Qs?st[Qs.id]:void 0;this.terrain||this._renderTileClippingMasks(cs,Qs,Qs?rt[Qs.id]:void 0),this.renderLayer(this,Qs,cs,Hs)}this.depthOcclusion=!1,this.currentLayer=ts,this.renderPass="translucent",this.layersWithOcclusionOpacity=[]}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this._snow&&this._snow.draw(this),this._rain&&this._rain.draw(this),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let Kt=null;Ae.forEach(Vt=>{const ts=m.getLayerSourceCache(Vt);ts&&!Vt.isHidden(this.transform.zoom)&&ts.getVisibleCoordinates().length&&(!Kt||Kt.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(zO[m],m,z,D);return this.cache[$]||(this.cache[$]=new G0(this.context,m,zO[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=(($,W,ee)=>{const ne=$.properties.get("direction"),de=$.properties.get("color-use-theme")==="none",je=$.properties.get("color").toNonPremultipliedRenderColor(de?null:ee.getLut($.scope)).toArray01(),be=$.properties.get("intensity"),Ae=W.properties.get("color-use-theme")==="none",Fe=W.properties.get("color").toNonPremultipliedRenderColor(Ae?null:ee.getLut(W.scope)).toArray01(),Ie=W.properties.get("intensity"),rt=[ne.x,ne.y,ne.z],st=i.dD(Fe,Ie),ct=i.dD(je,be);return{u_lighting_ambient_color:st,u_lighting_directional_dir:rt,u_lighting_directional_color:ct,u_ground_radiance:iP(rt,ct,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 W=$.getOpacity(this.transform.pitch),ee=((ne,de,je,be,Ae,Fe,Ie,rt,st,ct,mt,at)=>{const zt=ne.transform,wt=de.properties.get("color-use-theme")==="none",Rt=de.properties.get("color").toNonPremultipliedRenderColor(wt?null:ne.style.getLut(de.scope)).toArray01();Rt[3]=be;const ft=ne.frameCounter/1e3%1,[_t,At]=de.properties.get("vertical-range");return{u_fog_matrix:je?zt.calculateFogTileMatrix(je):at||ne.identityMat,u_fog_range:de.getFovAdjustedRange(zt._fov),u_fog_color:Rt,u_fog_horizon_blend:de.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(_t,At),At],u_fog_temporal_offset:ft,u_frustum_tl:Ae,u_frustum_tr:Fe,u_frustum_br:Ie,u_frustum_bl:rt,u_globe_pos:st,u_globe_radius:ct,u_viewport:mt,u_globe_transition:i.al(zt.zoom),u_is_globe:+(zt.projection.name==="globe")}})(this,$,E,W,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*i.o.devicePixelRatio,this.transform.height*i.o.devicePixelRatio],D);v.setFogUniformValues(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 W;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/((W=this.depthRangeFor3D)[1]-W[0]),-1-2*W[0]/(W[1]-W[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 Ape{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 W=$.split("=")[0];return W===E?(D=!0,`${W}=${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,W=Math.round(v.lat*z)/z,ee=M.getBearing(),ne=M.getPitch();let de=m?`/${$}/${W}/${E}`:`${E}/${W}/${$}`;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),Epe=Object.assign({deceleration:20,maxSpeed:1400},N3),Ri=Object.assign({deceleration:1e3,maxSpeed:360},N3),la=Object.assign({deceleration:1e3,maxSpeed:90},N3);class AF{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,Epe);D.zoom=this._map.transform.zoom+z.amount,_h(D,z)}if(v.bearing){const z=Df(v.bearing,E,Ri);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)),W=z.reduce((ee,ne,de,je)=>ee.add(ne.div(je.length)),new i.P(0,0));super(m,{points:z,point:W,lngLats:$,lngLat:v.unproject(W),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 ld(m.type,this._map,m))}mouseup(m){this._map.fire(new ld(m.type,this._map,m))}preclick(m){const v=new MouseEvent("preclick",m);this._map.fire(new ld(v.type,this._map,v))}click(m,v){this._mousedownPos&&this._mousedownPos.dist(v)>=this._clickTolerance||(this.preclick(m),this._map.fire(new ld(m.type,this._map,m)))}dblclick(m){return this._firePreventable(new ld(m.type,this._map,m))}mouseover(m){this._map.fire(new ld(m.type,this._map,m))}mouseout(m){this._map.fire(new ld(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 ld(m.type,this._map,m))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ld("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(m){this._delayContextMenu?this._contextMenuEvent=m:this._map.fire(new ld(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=W-$+"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 Vm(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 W=0;for(const ne in D){const de=D[ne],je=this._touches[ne];je&&(z._add(de),$._add(de.sub(je)),W++,D[ne]=de)}if(this._touches=D,W{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,W=Ao(E,v,z),ee=Ao(E,v,$);if(!W||!ee)return;const ne=this._aroundCenter?null:W.add(ee).div(2);return this._move([W,ee],ne,m)}touchend(m,v,E){if(!this._firstTwoTouches)return;const[D,z]=this._firstTwoTouches,$=Ao(E,v,D),W=Ao(E,v,z);$&&W||(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:W=>{const ee=W.getZoom();W.easeTo({duration:300,easeId:"keyboardHandler",easing:VP,zoom:v?Math.round(ee)+v*(m.shiftKey?2:1):ee,bearing:W.getBearing()+E*this._bearingStep,pitch:W.getPitch()+D*this._pitchStep,offset:[-z*this._panStep,-$*this._panStep],center:W.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 je=v(),be=Math.pow(2,je),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=je,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 $,W=!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):W=!0}else $=E,W=!0;this._active=!0,W&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let ee=$-v();return ee*this._lastDelta<0&&(ee=0),{noInertia:!0,needsRenderFrame:!W,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,W=Math.sqrt(.0729-$*$);v=i.eN($,W,.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 EF{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 PF{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 IF{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 LF extends i.C{}class DF{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 RF{constructor(m,v){this._map=m,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new AF(m),this._bearingSnap=v.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new DF,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 W=D===document?this.handleWindowEvent:this.handleEvent;D.addEventListener(z,W,$)}}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 W=new EF;this._add("tapDragZoom",W);const ee=v.touchPitch=new qP(v);this._add("touchPitch",ee);const ne=new S3(m),de=new f2(m);v.dragRotate=new PF(m,ne,de),this._add("mouseRotate",ne,["mousePitch"]),this._add("mousePitch",de,["mouseRotate"]);const je=new Hm(m),be=new BP(v,m);v.dragPan=new GP(E,je,be),this._add("mousePan",je),this._add("touchPan",be,["touchZoom","touchRotate"]);const Ae=new J0,Fe=new $P;v.touchZoomRotate=new IF(E,Fe,Ae,W),this._add("touchRotate",Ae,["touchPan","touchZoom"]),this._add("touchZoom",Fe,["touchPan","touchRotate"]),this._add("blockableMapEvent",new RP(v));const Ie=v.scrollZoom=new T3(v,this);this._add("scrollZoom",Ie,["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},$={},W={},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:Fe}of this._handlers){if(!Ae.isEnabled())continue;let Ie;this._blockedByActive(W,Fe,be)?Ae.reset():Ae[v||m.type]&&(Ie=Ae[v||m.type](m,ne,ee),this.mergeHandlerResult(z,$,Ie,be,D),Ie&&Ie.needsRenderFrame&&this._triggerRenderFrame()),(Ie||Ae.isActive())&&(W[be]=Ae)}const de={};for(const be in this._previousActiveHandlers)W[be]||(de[be]=D);this._previousActiveHandlers=W,(Object.keys(de).length||v2(z))&&(this._changes.push([z,$,de]),this._triggerRenderFrame()),(Object.keys(W).length||v2(z))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:je}=z;je&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],je(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,$=ct=>[ct.x,ct.y,ct.z];if((()=>{const ct=this._eventsInProgress.drag;return ct&&!this._handlersById[ct.handlerName].isActive()})()&&!v2(m)){const ct=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"),ct!==z.zoom&&this._map._update(!0)}if(z._isCameraConstrained&&D._stop(!0),!v2(m))return void this._fireEvents(v,E,!0);let{panDelta:W,zoomDelta:ee,bearingDelta:ne,pitchDelta:de,around:je,aroundCoord:be,pinchAround:Ae}=m;z._isCameraConstrained&&(ee>0&&(ee=0),z._isCameraConstrained=!1),Ae!==void 0&&(je=Ae),(ee||(ct=>v[ct]&&!this._eventsInProgress[ct])("drag"))&&je&&(this._dragOrigin=$(z.pointCoordinate3D(je)),this._originalZoom=z.zoom,this._trackingEllipsoid.setup(z._camera.position,this._dragOrigin)),z.cameraElevationReference="sea",D._stop(!0),je=je||D.transform.centerPoint,ne&&(z.bearing+=ne),de&&(z.pitch+=de),z._updateCameraState();const Fe=[0,0,0];if(W)if(z.projection.name==="mercator"){const ct=this._trackingEllipsoid.projectRay(z.screenPointToMercatorRay(je).dir),mt=this._trackingEllipsoid.projectRay(z.screenPointToMercatorRay(je.sub(W)).dir);Fe[0]=mt[0]-ct[0],Fe[1]=mt[1]-ct[1]}else{const ct=z.pointCoordinate(je);if(z.projection.name==="globe"){W=W.rotate(-z.angle);const mt=z._pixelsPerMercatorPixel/z.worldSize;Fe[0]=-W.x*i.eQ(i.bV(ct.y))*mt,Fe[1]=-W.y*i.eQ(z.center.lat)*mt}else{const mt=z.pointCoordinate(je.sub(W));ct&&mt&&(Fe[0]=mt.x-ct.x,Fe[1]=mt.y-ct.y)}}const Ie=z.zoom,rt=[0,0,0];if(ee){const ct=$(be||z.pointCoordinate3D(je)),mt={dir:i.ay([],i.ax([],ct,z._camera.position))};if(mt.dir[2]<0){const at=z.zoomDeltaToMovement(ct,ee);i.bJ(rt,mt.dir,at)}}const st=i.cT(Fe,Fe,rt);z._translateCameraConstrained(st),ee&&Math.abs(z.zoom-Ie)>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:je}=m[de];this._eventsInProgress[de]||($[`${de}start`]=je),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:je}=m[de];this._fireEvent(de,je)}const W={};let ee;for(const de in this._eventsInProgress){const{handlerName:je,originalEvent:be}=this._eventsInProgress[de];this._handlersById[je].isActive()||(delete this._eventsInProgress[de],ee=v[je]||be,W[`${de}end`]=ee)}for(const de in W)this._fireEvent(de,W[de]);const ne=y2(this._eventsInProgress);if(E&&(D||z)&&!ne){this._updatingCamera=!0;const de=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),je=be=>be!==0&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new LF("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 OF 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 W=m.clone(),ee=this._extendCameraOptions($);W.bearing=D,W.pitch=z;const ne=i.aU.convert(v),de=i.aU.convert(E),je=.5*(ne.lat+de.lat),be=.5*(ne.lng+de.lng),Ae=i.eT(je,be),Fe=i.ay([],Ae),Ie=i.ay([],i.bh([],Fe,[0,1,0])),rt=i.bh([],Ie,Fe),st=[Ie[0],Ie[1],Ie[2],0,rt[0],rt[1],rt[2],0,Fe[0],Fe[1],Fe[2],0,0,0,0,1],ct=[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(je,ne.lng),i.eT(je,de.lng),i.eT(ne.lat,be),i.eT(de.lat,be)];let mt=i.cU.fromPoints(ct.map(as=>[i.bi(Ie,as),i.bi(rt,as),i.bi(Fe,as)]));const at=i.ah([],mt.center,st);i.eU(at)===0&&i.eV(at,0,0,1),i.ay(at,at),i.bJ(at,at,i.aF),W.center=i.eW(at);const zt=W.getWorldToCameraMatrix(),wt=i.b7(new Float64Array(16),zt);mt=i.cU.applyTransform(mt,i.aD([],zt,st));const Rt=this._extendAABB(mt,W,ee,D);if(!Rt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");mt=Rt,i.ah(at,at,zt);const ft=.5*(mt.max[2]-mt.min[2]),_t=this._minimumAABBFrustumDistance(W,mt),At=i.bJ([],[0,0,1],ft),Wt=i.cT(At,at,At),qt=_t+(W.pitch===0?0:i.bf(at,Wt)),rs=W.globeCenterInViewSpace,Jt=i.ax([],at,[rs[0],rs[1],rs[2]]);i.ay(Jt,Jt),i.bJ(Jt,Jt,qt);const Ns=i.cT([],at,Jt);i.ah(Ns,Ns,wt);const As=i.eD/i.aF,Kt=i.ai(Ns),Vt=i.bU(Math.max(Kt*As-i.eD,Number.EPSILON),0),ts=Math.min(W.zoomFromMercatorZAdjusted(Vt),ee.maxZoom);return ts>.5*(i.cJ+i.cv)?(W.setProjection({name:"mercator"}),W.zoom=ts,this._cameraForBounds(W,v,E,D,z,$)):{center:W.center,zoom:ts,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)),W=$,ee=z,ne=z,de=$,je=v.width-(ee+ne),be=v.height-(W+de),Ae=i.ax([],m.max,m.min),Fe=Math.min(je/Ae[0],be/Ae[1]),Ie=Math.min(v.scaleZoom(v.scale*Fe),E.maxZoom);if(isNaN(Ie))return null;const rt=v.scale/v.zoomScale(Ie),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]+W*rt,m.max[2]]),ct=(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]-=ct.x*rt,st.center[1]+=ct.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 W=m.clone(),ee=this._extendCameraOptions($);W.bearing=D,W.pitch=z;const ne=i.aU.convert(v),de=i.aU.convert(E),je=new i.aU(ne.lng,de.lat),be=new i.aU(de.lng,ne.lat),Ae=W.project(ne),Fe=W.project(de),Ie=this.queryTerrainElevation(ne),rt=this.queryTerrainElevation(de),st=this.queryTerrainElevation(je),ct=this.queryTerrainElevation(be),mt=[[Ae.x,Ae.y,Math.min(Ie||0,rt||0,st||0,ct||0)],[Fe.x,Fe.y,Math.max(Ie||0,rt||0,st||0,ct||0)]];let at=i.cU.fromPoints(mt);const zt=W.getWorldToCameraMatrix(),wt=i.b7(new Float64Array(16),zt);at=i.cU.applyTransform(at,zt);const Rt=this._extendAABB(at,W,ee,D);if(!Rt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");at=Rt;const ft=.5*i.ax([],at.max,at.min)[2],_t=this._minimumAABBFrustumDistance(W,at),At=[0,0,1,0];i.aE(At,At,zt),i.eX(At,At);const Wt=i.bJ([],At,_t+ft),qt=i.cT([],at.center,Wt);i.ah(at.center,at.center,wt),i.ah(qt,qt,wt);const rs=W.unproject(new i.P(at.center[0],at.center[1])),Jt=i.eY(W.projection,rs),Ns=Math.pow(2,Jt),As=Math.min(W._zoomFromMercatorZ(qt[2]*W.pixelsPerMeter*Ns/W.worldSize),ee.maxZoom);return W.mercatorFromTransition&&As<.5*(i.cJ+i.cv)?(W.setProjection({name:"globe"}),W.zoom=As,this._cameraForBounds(W,v,E,D,z,$)):{center:rs,zoom:As,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),W=i.P.convert(v),ee=new i.P(Math.min($.x,W.x),Math.min($.y,W.y)),ne=new i.P(Math.max($.x,W.x),Math.max($.y,W.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge($,W))return this;const de=this.transform.pointLocation3D(ee),je=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)),Fe=[Math.min(de.lng,je.lng,be.lng,Ae.lng),Math.min(de.lat,je.lat,be.lat,Ae.lat)],Ie=[Math.max(de.lng,je.lng,be.lng,Ae.lng),Math.max(de.lat,je.lat,be.lat,Ae.lat)],rt=D&&D.pitch?D.pitch:this.getPitch(),st=this._cameraForBounds(this.transform,Fe,Ie,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 W=typeof m.padding=="number"?this._extendPadding(m.padding):m.padding;if(m.padding!=null&&!E.isPaddingEqual(W))if(m.retainPadding===!1){const ee=E.clone();ee.padding=W,E.setLocationAtPoint(E.center,ee.centerPoint)}else E.padding=W;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 W=D!==E.zoom,ee=z!==E.pitch,ne=$!==E.bearing;return this.fire(new i.C("movestart",v)).fire(new i.C("move",v)),W&&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(),W=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:$,je=this._extendPadding(m.padding),be=i.P.convert(m.offset);let Ae,Fe,Ie;if(E.projection.name==="globe"){const At=i.ag.fromLngLat(E.center),Wt=be.rotate(-E.angle);At.x+=Wt.x/E.worldSize,At.y+=Wt.y/E.worldSize;const qt=At.toLngLat(),rs=i.aU.convert(m.center||qt);this._normalizeCenter(rs),Ae=E.centerPoint.add(Wt),Fe=new i.P(At.x,At.y).mult(E.worldSize),Ie=new i.P(i.aH(rs.lng),i.aL(rs.lat)).mult(E.worldSize).sub(Fe)}else{Ae=E.centerPoint.add(be);const At=E.pointLocation(Ae),Wt=i.aU.convert(m.center||At);this._normalizeCenter(Wt),Fe=E.project(At),Ie=E.project(Wt).sub(Fe)}const rt=E.zoomScale(ee-D);let st,ct;m.around&&(st=i.aU.convert(m.around),ct=E.locationPoint(st));const mt=this._zooming||ee!==D,at=this._rotating||z!==ne,zt=this._pitching||de!==$,wt=!E.isPaddingEqual(je),Rt=m.retainPadding===!1?E.clone():E,ft=At=>Wt=>{if(mt&&(At.zoom=i.am(D,ee,Wt)),at&&(At.bearing=i.am(z,ne,Wt)),zt&&(At.pitch=i.am($,de,Wt)),wt&&(Rt.interpolatePadding(W,je,Wt),Ae=Rt.centerPoint.add(be)),st)At.setLocationAtPoint(st,ct);else{const qt=At.zoomScale(At.zoom-D),rs=ee>D?Math.min(2,rt):Math.max(.5,rt),Jt=Math.pow(rs,1-Wt),Ns=At.unproject(Fe.add(Ie.mult(Wt*Jt)).mult(qt));At.setLocationAtPoint(At.renderWorldCopies?Ns.wrap():Ns,Ae)}return m.preloadOnly||this._fireMoveEvents(v),At};if(m.preloadOnly){const At=this._emulate(ft,m.duration,E);return this._preloadTiles(At),this}const _t={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=mt,this._rotating=at,this._pitching=zt,this._padding=wt,this._easeId=m.easeId,this._prepareEase(v,m.noMoveStart,_t),this._ease(ft(E),At=>{E.cameraElevationReference==="sea"&&E.recenterOnTerrain(),this._afterEase(v,At)},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 as=i.aJ(m,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(as,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(),W=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:$,je=this._extendPadding(m.padding),be=E.zoomScale(ee-D),Ae=i.P.convert(m.offset);let Fe=E.centerPoint.add(Ae);const Ie=E.pointLocation(Fe),rt=i.aU.convert(m.center||Ie);this._normalizeCenter(rt);const st=E.project(Ie),ct=E.project(rt).sub(st);let mt=m.curve;const at=Math.max(E.width,E.height),zt=at/be,wt=ct.mag();if("minZoom"in m){const as=i.aC(Math.min(m.minZoom,D,ee),E.minZoom,E.maxZoom),cs=at/E.zoomScale(as-D);mt=Math.sqrt(cs/wt*2)}const Rt=mt*mt;function ft(as){const cs=(zt*zt-at*at+(as?-1:1)*Rt*Rt*wt*wt)/(2*(as?zt:at)*Rt*wt);return Math.log(Math.sqrt(cs*cs+1)-cs)}function _t(as){return(Math.exp(as)-Math.exp(-as))/2}function At(as){return(Math.exp(as)+Math.exp(-as))/2}const Wt=ft(0);let qt=function(as){return At(Wt)/At(Wt+mt*as)},rs=function(as){return at*((At(Wt)*(_t(cs=Wt+mt*as)/At(cs))-_t(Wt))/Rt)/wt;var cs},Jt=(ft(1)-Wt)/mt;if(Math.abs(wt)<1e-6||!isFinite(Jt)){if(Math.abs(at-zt)<1e-6)return this.easeTo(m,v);const as=ztm.maxDuration&&(m.duration=0);const Ns=z!==ne,As=de!==$,Kt=!E.isPaddingEqual(je),Vt=m.retainPadding===!1?E.clone():E,ts=as=>cs=>{const Qs=cs*Jt,Hs=1/qt(Qs);as.zoom=cs===1?ee:D+as.scaleZoom(Hs),Ns&&(as.bearing=i.am(z,ne,cs)),As&&(as.pitch=i.am($,de,cs)),Kt&&(Vt.interpolatePadding(W,je,cs),Fe=Vt.centerPoint.add(Ae));const Gs=cs===1?rt:as.unproject(st.add(ct.mult(rs(Qs))).mult(Hs));return as.setLocationAtPoint(as.renderWorldCopies?Gs.wrap():Gs,Fe),as._updateCameraOnTerrain(),m.preloadOnly||this._fireMoveEvents(v),as};if(m.preloadOnly){const as=this._emulate(ts,m.duration,E);return this._preloadTiles(as),this}return this._zooming=!0,this._rotating=Ns,this._pitching=As,this._padding=Kt,this._prepareEase(v,!1),this._ease(ts(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 W=0;W<=D;W++){const ee=$(W/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(W=>{const ee=W.textContent||"";if(W.tagName!=="A")return void W.replaceWith(...W.childNodes);const ne=W.getAttribute("href");if(!ne||!/^(https?:|mailto:)/i.test(ne))return void W.replaceWith($.createTextNode(ee));const de=$.createElement("a");de.href=ne,de.textContent=ee,de.rel="noopener nofollow";const je=W.getAttribute("class");je&&(de.className=je),W.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 FF{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 Ppe{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 Ipe={"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 wi extends i.C{constructor(m,v,E,D){const{point:z,lngLat:$,originalEvent:W,target:ee}=m;super(m.type,{point:z,lngLat:$,originalEvent:W,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 W=new Set;for(const ee of v){for(const[ne,de]of D){if(!de.target)continue;const je=ee.variants?ee.variants[ne]:null;if(je){for(const be of je){if(Kh(be,ee,W,ne))continue;const Ae=new i.di(ee,be),Fe=Ew(be,ee,ne);z&&Ae.id!==void 0&&(Ae.state=this.map.getFeatureState(Ae));const Ie=E?this.prevHoveredFeatures.get(Fe):null,rt=new wi(m,ne,de,Ae),st=Ie?Ie.stop:de.handler(rt);if(E&&this.hoveredFeatures.set(Fe,{feature:ee,stop:st}),st!==!1){$=!0;break}}if($)break}}if($)break}if(!$)for(const[ee,ne]of D){const{handler:de,target:je}=ne;if(!je&&de(new wi(m,ee,ne,null))!==!1)break}}}function Lpe(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 Dpe={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},Rpe={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),W=$&&$.pitchDelta;W&&E.setPitch(E.getPitch()+W)}}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)<$&&(W||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 Gm 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:W=0,rotation:ee=em.rotation,rotationAlignment:ne=em.rotationAlignment,pitchAlignment:de=em.pitchAlignment,occludedOpacity:je=em.occludedOpacity,altitude:be=em.altitude}=m||{};this._anchor=E,this._color=D,this._scale=z,this._draggable=$,this._clickTolerance=W,this._rotation=ee,this._rotationAlignment=ne,this._pitchAlignment=de,this._occludedOpacity=je,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",Ie=>{Ie.preventDefault()}),this._element.addEventListener("mousedown",Ie=>{Ie.preventDefault()});const Ae=this._element.classList;for(const Ie in b2)Ae.remove(`mapboxgl-marker-anchor-${Ie}`);Ae.add(`mapboxgl-marker-anchor-${this._anchor}`);const Fe=m&&m.className?m.className.trim().split(/\s+/):[];Ae.add(...Fe),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 W=D/$;return`rotateX(${-z.y*W}deg) rotateY(${z.x*W}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 W=m.sub($),ee=i.cH(Math.atan2(W.y,W.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 FF,this._domRenderTaskQueue=new FF,this._controls=[],this._markers=[],this._popups=[],this._mapId=i.r(),this._locale=Object.assign({},Ipe,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 Ppe(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 RF(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 Ape(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(W=>this.getLayer(W));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 W=E($.point);W.length?D||(D=!0,v.call(this,new ld(M,this,$.originalEvent,{features:W}))):D=!1},mouseout:()=>{D=!1}}}}if(M==="mouseleave"||M==="mouseout"){let D=!1;return{listener:v,targets:m,delegates:{mousemove:W=>{E(W.point).length?D=!0:D&&(D=!1,v.call(this,new ld(M,this,W.originalEvent)))},mouseout:W=>{D&&(D=!1,v.call(this,new ld(M,this,W.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 Um(this,v).load(M),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Um(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 W=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(W,{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(W,{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:W}=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(W)),E.usvg=!1,E.icon=void 0,ne=!0):E.data.replace(W,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?(_e(m,!0),this.painter=new Tpe(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(),je=new i.ae(ee,{now:de,fadeDuration:z,pitch:ne,transition:this.style.transition,worldview:this._worldview});this.style.update(je)}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 W=this._sourcesDirty||this._styleDirty||this._placementDirty||$;if(W||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||W||(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;_e(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(){et(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,M=>{M&&(M.message!==J&&M.status!==401||this._revokeAuth())}),this._isTokenExpired()&&this._revokeAuth(),Me(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&qe(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&$e(this._requestManager._customAccessToken)}_postAddingAppearancesToStyleEvent(){we(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({},Rpe,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 Gm({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=N("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Gm({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({},Sl,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 W=3.2808*$;W>5280?this._setScale(M,W/5280,"mile"):this._setScale(M,W,"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 W=z/$;return W=W>=10?10:W>=5?5:W>=3?3:W>=2?2:W>=1?1:function(ee){const ne=Math.pow(10,Math.ceil(-Math.log(ee)/Math.LN10));return Math.round(ee*ne)/ne}(W),$*W}(m),D=E/m;this._container.innerHTML=v!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:v}).format(E):`${E} ${Wm[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(W)return"bottom-right"}return $?"left":W?"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),W=I3(this.options.offset,$),ee=D.add(W).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(Ope);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:Gm,Style:Um,LngLat:i.aU,LngLatBounds:i.aK,Point:i.P,MercatorCoordinate:i.ag,FreeCameraOptions:zw,Evented:i.E,config:i.g,prewarm:function(){Nt().acquire(Xe)},clearPrewarmedResources:function(){const M=Je;M&&(M.isPreloaded()&&M.numActive()===1?(M.release(Xe),Je=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 dt.workerCount},set workerCount(M){dt.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 it.workerUrl},set workerUrl(M){it.workerUrl=M},get workerClass(){return it.workerClass},set workerClass(M){it.workerClass=M},get workerParams(){return it.workerParams},set workerParams(M){it.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 ANt=TGe.exports;const Ko=no(ANt);function ks({className:t,...s}){return e.jsx("div",{className:Dt("animate-pulse rounded-md bg-muted",t),...s})}const zPe={coming_soon:"#3B82F6",active:"#10B981",price_improvement:"#F97316",under_contract:"#8B5CF6",sold:"#6B7280"},BPe={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function ENt(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function PNt({listings:t,isLoading:s}){const r=vr(),n=S.useRef(null),a=S.useRef(null),o=S.useRef([]),[l,i]=S.useState(""),[d,u]=S.useState(!0);return S.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)})()},[]),S.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,k)=>w+k.longitude,0)/f.length,N=f.reduce((w,k)=>w+k.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]),S.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 _=zPe[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}`,k=document.createElement("div");k.className="cursor-pointer",k.innerHTML=`
`;const C=new Ko.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${b!=null&&b.photo_url?``:""}
${ENt(y.price)}
${y.property_address||""}
${y.city}, ${y.state}
${BPe[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(k).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]),S.useEffect(()=>(window.__navigateToPublicListing__=f=>{r(f)},()=>{delete window.__navigateToPublicListing__}),[r]),d||s?e.jsx(ks,{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(zPe).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:BPe[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=S.useRef({value:t,previous:t});return S.useMemo(()=>(s.current.value!==t&&(s.current.previous=s.current.value,s.current.value=t),s.current.previous),[t])}var INt=[" ","Enter","ArrowUp","ArrowDown"],LNt=[" ","Enter"],WS="Select",[Nue,kue,DNt]=wR(WS),[HA,JTs]=qc(WS,[DNt,w0]),Sue=w0(),[RNt,fw]=HA(WS),[ONt,FNt]=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=Sue(s),[w,k]=S.useState(null),[C,A]=S.useState(null),[I,L]=S.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=S.useRef(null),Y=w?b||!!w.closest("form"):!0,[J,X]=S.useState(new Set),ce=Array.from(J).map(ae=>ae.props.value).join(";");return e.jsx(SR,{...N,children:e.jsxs(RNt,{required:_,scope:s,trigger:w,onTriggerChange:k,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(Nue.Provider,{scope:s,children:e.jsx(ONt,{scope:t.__scopeSelect,onNativeOptionAdd:S.useCallback(ae=>{X(ie=>new Set(ie).add(ae))},[]),onNativeOptionRemove:S.useCallback(ae=>{X(ie=>{const oe=new Set(ie);return oe.delete(ae),oe})},[]),children:r})}),Y?e.jsxs(tWe,{"aria-hidden":!0,required:_,tabIndex:-1,name:p,autoComplete:f,value:B,onChange:ae=>U(ae.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=S.forwardRef((t,s)=>{const{__scopeSelect:r,disabled:n=!1,...a}=t,o=Sue(r),l=fw(PGe,r),i=l.disabled||n,d=Ta(s,l.onTriggerChange),u=kue(r),p=S.useRef("touch"),[f,y,_]=rWe(N=>{const w=u().filter(A=>!A.disabled),k=w.find(A=>A.value===l.value),C=nWe(w,N,k);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:Sr(a.onClick,N=>{N.currentTarget.focus(),p.current!=="mouse"&&b(N)}),onPointerDown:Sr(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:Sr(a.onKeyDown,N=>{const w=f.current!=="";!(N.ctrlKey||N.altKey||N.metaKey)&&N.key.length===1&&y(N.key),!(w&&N.key===" ")&&INt.includes(N.key)&&(b(),N.preventDefault())})})})});IGe.displayName=PGe;var LGe="SelectValue",DGe=S.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 ad(()=>{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 zNt="SelectIcon",RGe=S.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=zNt;var BNt="SelectPortal",OGe=t=>e.jsx(IA,{asChild:!0,...t});OGe.displayName=BNt;var KS="SelectContent",FGe=S.forwardRef((t,s)=>{const r=fw(KS,t.__scopeSelect),[n,a]=S.useState();if(ad(()=>{a(new DocumentFragment)},[]),!r.open){const o=n;return o?ip.createPortal(e.jsx(zGe,{scope:t.__scopeSelect,children:e.jsx(Nue.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),$Nt="SelectContentImpl",qNt=Hb("SelectContent.RemoveScroll"),BGe=S.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,...k}=t,C=fw(KS,r),[A,I]=S.useState(null),[L,O]=S.useState(null),V=Ta(s,De=>I(De)),[q,B]=S.useState(null),[U,te]=S.useState(null),Y=kue(r),[J,X]=S.useState(!1),ce=S.useRef(!1);S.useEffect(()=>{if(A)return xue(A)},[A]),mue();const ae=S.useCallback(De=>{const[qe,...ke]=Y().map(we=>we.ref.current),[$e]=ke.slice(-1),Be=document.activeElement;for(const we of De)if(we===Be||(we==null||we.scrollIntoView({block:"nearest"}),we===qe&&L&&(L.scrollTop=0),we===$e&&L&&(L.scrollTop=L.scrollHeight),we==null||we.focus(),document.activeElement!==Be))return},[Y,L]),ie=S.useCallback(()=>ae([q,A]),[ae,q,A]);S.useEffect(()=>{J&&ie()},[J,ie]);const{onOpenChange:oe,triggerPointerDownPosRef:me}=C;S.useEffect(()=>{if(A){let De={x:0,y:0};const qe=$e=>{var Be,we;De={x:Math.abs(Math.round($e.pageX)-(((Be=me.current)==null?void 0:Be.x)??0)),y:Math.abs(Math.round($e.pageY)-(((we=me.current)==null?void 0:we.y)??0))}},ke=$e=>{De.x<=10&&De.y<=10?$e.preventDefault():A.contains($e.target)||oe(!1),document.removeEventListener("pointermove",qe),me.current=null};return me.current!==null&&(document.addEventListener("pointermove",qe),document.addEventListener("pointerup",ke,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",qe),document.removeEventListener("pointerup",ke,{capture:!0})}}},[A,oe,me]),S.useEffect(()=>{const De=()=>oe(!1);return window.addEventListener("blur",De),window.addEventListener("resize",De),()=>{window.removeEventListener("blur",De),window.removeEventListener("resize",De)}},[oe]);const[ye,he]=rWe(De=>{const qe=Y().filter(Be=>!Be.disabled),ke=qe.find(Be=>Be.ref.current===document.activeElement),$e=nWe(qe,De,ke);$e&&setTimeout(()=>$e.ref.current.focus())}),ge=S.useCallback((De,qe,ke)=>{const $e=!ce.current&&!ke;(C.value!==void 0&&C.value===qe||$e)&&(B(De),$e&&(ce.current=!0))},[C.value]),Ne=S.useCallback(()=>A==null?void 0:A.focus(),[A]),Ue=S.useCallback((De,qe,ke)=>{const $e=!ce.current&&!ke;(C.value!==void 0&&C.value===qe||$e)&&te(De)},[C.value]),Te=n==="popper"?x1e:$Ge,Me=Te===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:Ne,itemTextRefCallback:Ue,focusSelectedItem:ie,selectedItemText:U,position:n,isPositioned:J,searchRef:ye,children:e.jsx(IR,{as:qNt,allowPinchZoom:!0,children:e.jsx(ER,{asChild:!0,trapped:C.open,onMountAutoFocus:De=>{De.preventDefault()},onUnmountAutoFocus:Sr(a,De=>{var qe;(qe=C.trigger)==null||qe.focus({preventScroll:!0}),De.preventDefault()}),children:e.jsx(dw,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:De=>De.preventDefault(),onDismiss:()=>C.onOpenChange(!1),children:e.jsx(Te,{role:"listbox",id:C.contentId,"data-state":C.open?"open":"closed",dir:C.dir,onContextMenu:De=>De.preventDefault(),...k,...Me,onPlaced:()=>X(!0),ref:V,style:{display:"flex",flexDirection:"column",outline:"none",...k.style},onKeyDown:Sr(k.onKeyDown,De=>{const qe=De.ctrlKey||De.altKey||De.metaKey;if(De.key==="Tab"&&De.preventDefault(),!qe&&De.key.length===1&&he(De.key),["ArrowUp","ArrowDown","Home","End"].includes(De.key)){let $e=Y().filter(Be=>!Be.disabled).map(Be=>Be.ref.current);if(["ArrowUp","End"].includes(De.key)&&($e=$e.slice().reverse()),["ArrowUp","ArrowDown"].includes(De.key)){const Be=De.target,we=$e.indexOf(Be);$e=$e.slice(we+1)}setTimeout(()=>ae($e)),De.preventDefault()}})})})})})})});BGe.displayName=$Nt;var UNt="SelectItemAlignedPosition",$Ge=S.forwardRef((t,s)=>{const{__scopeSelect:r,onPlaced:n,...a}=t,o=fw(KS,r),l=xw(KS,r),[i,d]=S.useState(null),[u,p]=S.useState(null),f=Ta(s,V=>p(V)),y=kue(r),_=S.useRef(!1),b=S.useRef(!0),{viewport:N,selectedItem:w,selectedItemText:k,focusSelectedItem:C}=l,A=S.useCallback(()=>{if(o.trigger&&o.valueNode&&i&&u&&N&&w&&k){const V=o.trigger.getBoundingClientRect(),q=u.getBoundingClientRect(),B=o.valueNode.getBoundingClientRect(),U=k.getBoundingClientRect();if(o.dir!=="rtl"){const Be=U.left-q.left,we=B.left-Be,ut=V.left-we,fe=V.width+ut,He=Math.max(fe,q.width),et=window.innerWidth-dg,tt=nD(we,[dg,Math.max(dg,et-He)]);i.style.minWidth=fe+"px",i.style.left=tt+"px"}else{const Be=q.right-U.right,we=window.innerWidth-B.right-Be,ut=window.innerWidth-V.right-we,fe=V.width+ut,He=Math.max(fe,q.width),et=window.innerWidth-dg,tt=nD(we,[dg,Math.max(dg,et-He)]);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),ae=parseInt(X.paddingTop,10),ie=parseInt(X.borderBottomWidth,10),oe=parseInt(X.paddingBottom,10),me=ce+ae+J+oe+ie,ye=Math.min(w.offsetHeight*5,me),he=window.getComputedStyle(N),ge=parseInt(he.paddingTop,10),Ne=parseInt(he.paddingBottom,10),Ue=V.top+V.height/2-dg,Te=Y-Ue,Me=w.offsetHeight/2,De=w.offsetTop+Me,qe=ce+ae+De,ke=me-qe;if(qe<=Ue){const Be=te.length>0&&w===te[te.length-1].ref.current;i.style.bottom="0px";const we=u.clientHeight-N.offsetTop-N.offsetHeight,ut=Math.max(Te,Me+(Be?Ne:0)+we+ie),fe=qe+ut;i.style.height=fe+"px"}else{const Be=te.length>0&&w===te[0].ref.current;i.style.top="0px";const ut=Math.max(Ue,ce+N.offsetTop+(Be?ge:0)+Me)+ke;i.style.height=ut+"px",N.scrollTop=qe-Ue+N.offsetTop}i.style.margin=`${dg}px 0`,i.style.minHeight=ye+"px",i.style.maxHeight=Y+"px",n==null||n(),requestAnimationFrame(()=>_.current=!0)}},[y,o.trigger,o.valueNode,i,u,N,w,k,o.dir,n]);ad(()=>A(),[A]);const[I,L]=S.useState();ad(()=>{u&&L(window.getComputedStyle(u).zIndex)},[u]);const O=S.useCallback(V=>{V&&b.current===!0&&(A(),C==null||C(),b.current=!1)},[A,C]);return e.jsx(HNt,{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=UNt;var VNt="SelectPopperPosition",x1e=S.forwardRef((t,s)=>{const{__scopeSelect:r,align:n="start",collisionPadding:a=dg,...o}=t,l=Sue(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=VNt;var[HNt,Gje]=HA(KS,{}),g1e="SelectViewport",qGe=S.forwardRef((t,s)=>{const{__scopeSelect:r,nonce:n,...a}=t,o=xw(g1e,r),l=Gje(g1e,r),i=Ta(s,o.onViewportChange),d=S.useRef(0);return e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),e.jsx(Nue.Slot,{scope:r,children:e.jsx(Jr.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:i,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Sr(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),k=Math.max(N,w);if(k0?I:0,f.style.justifyContent="flex-end")}}}d.current=p.scrollTop})})})]})});qGe.displayName=g1e;var UGe="SelectGroup",[GNt,WNt]=HA(UGe),KNt=S.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=fu();return e.jsx(GNt,{scope:r,id:a,children:e.jsx(Jr.div,{role:"group","aria-labelledby":a,...n,ref:s})})});KNt.displayName=UGe;var VGe="SelectLabel",HGe=S.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=WNt(VGe,r);return e.jsx(Jr.div,{id:a.id,...n,ref:s})});HGe.displayName=VGe;var Zoe="SelectItem",[ZNt,GGe]=HA(Zoe),WGe=S.forwardRef((t,s)=>{const{__scopeSelect:r,value:n,disabled:a=!1,textValue:o,...l}=t,i=fw(Zoe,r),d=xw(Zoe,r),u=i.value===n,[p,f]=S.useState(o??""),[y,_]=S.useState(!1),b=Ta(s,C=>{var A;return(A=d.itemRefCallback)==null?void 0:A.call(d,C,n,a)}),N=fu(),w=S.useRef("touch"),k=()=>{a||(i.onValueChange(n),i.onOpenChange(!1))};if(n==="")throw new Error("A must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return e.jsx(ZNt,{scope:r,value:n,disabled:a,textId:N,isSelected:u,onItemTextChange:S.useCallback(C=>{f(A=>A||((C==null?void 0:C.textContent)??"").trim())},[]),children:e.jsx(Nue.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:Sr(l.onFocus,()=>_(!0)),onBlur:Sr(l.onBlur,()=>_(!1)),onClick:Sr(l.onClick,()=>{w.current!=="mouse"&&k()}),onPointerUp:Sr(l.onPointerUp,()=>{w.current==="mouse"&&k()}),onPointerDown:Sr(l.onPointerDown,C=>{w.current=C.pointerType}),onPointerMove:Sr(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:Sr(l.onPointerLeave,C=>{var A;C.currentTarget===document.activeElement&&((A=d.onItemLeave)==null||A.call(d))}),onKeyDown:Sr(l.onKeyDown,C=>{var I;((I=d.searchRef)==null?void 0:I.current)!==""&&C.key===" "||(LNt.includes(C.key)&&k(),C.key===" "&&C.preventDefault())})})})})});WGe.displayName=Zoe;var II="SelectItemText",KGe=S.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=FNt(II,r),[p,f]=S.useState(null),y=Ta(s,k=>f(k),d.onItemTextChange,k=>{var C;return(C=i.itemTextRefCallback)==null?void 0:C.call(i,k,d.value,d.disabled)}),_=p==null?void 0:p.textContent,b=S.useMemo(()=>e.jsx("option",{value:d.value,disabled:d.disabled,children:_},d.value),[d.disabled,d.value,_]),{onNativeOptionAdd:N,onNativeOptionRemove:w}=u;return ad(()=>(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?ip.createPortal(o.children,l.valueNode):null]})});KGe.displayName=II;var ZGe="SelectItemIndicator",YGe=S.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=S.forwardRef((t,s)=>{const r=xw(y1e,t.__scopeSelect),n=Gje(y1e,t.__scopeSelect),[a,o]=S.useState(!1),l=Ta(s,n.onScrollButtonChange);return ad(()=>{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=S.forwardRef((t,s)=>{const r=xw(v1e,t.__scopeSelect),n=Gje(v1e,t.__scopeSelect),[a,o]=S.useState(!1),l=Ta(s,n.onScrollButtonChange);return ad(()=>{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=S.forwardRef((t,s)=>{const{__scopeSelect:r,onAutoScroll:n,...a}=t,o=xw("SelectScrollButton",r),l=S.useRef(null),i=kue(r),d=S.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return S.useEffect(()=>()=>d(),[d]),ad(()=>{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:Sr(a.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(n,50))}),onPointerMove:Sr(a.onPointerMove,()=>{var u;(u=o.onItemLeave)==null||u.call(o),l.current===null&&(l.current=window.setInterval(n,50))}),onPointerLeave:Sr(a.onPointerLeave,()=>{d()})})}),YNt="SelectSeparator",eWe=S.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return e.jsx(Jr.div,{"aria-hidden":!0,...n,ref:s})});eWe.displayName=YNt;var _1e="SelectArrow",XNt=S.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=Sue(r),o=fw(_1e,r),l=xw(_1e,r);return o.open&&l.position==="popper"?e.jsx(MR,{...a,...n,ref:s}):null});XNt.displayName=_1e;var QNt="SelectBubbleInput",tWe=S.forwardRef(({__scopeSelect:t,value:s,...r},n)=>{const a=S.useRef(null),o=Ta(n,a),l=zR(s);return S.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=QNt;function sWe(t){return t===""||t===void 0}function rWe(t){const s=ed(t),r=S.useRef(""),n=S.useRef(0),a=S.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=S.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return S.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=JNt(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 JNt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var ekt=EGe,aWe=IGe,tkt=DGe,skt=RGe,rkt=OGe,iWe=FGe,nkt=qGe,oWe=HGe,lWe=WGe,akt=KGe,ikt=YGe,cWe=XGe,dWe=QGe,uWe=eWe;const Fs=ekt,zs=tkt,Ds=S.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(aWe,{ref:n,className:Dt("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(skt,{asChild:!0,children:e.jsx(Fi,{className:"h-4 w-4 opacity-50"})})]}));Ds.displayName=aWe.displayName;const hWe=S.forwardRef(({className:t,...s},r)=>e.jsx(cWe,{ref:r,className:Dt("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=S.forwardRef(({className:t,...s},r)=>e.jsx(dWe,{ref:r,className:Dt("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(Fi,{className:"h-4 w-4"})}));mWe.displayName=dWe.displayName;const Rs=S.forwardRef(({className:t,children:s,position:r="popper",...n},a)=>e.jsx(rkt,{children:e.jsxs(iWe,{ref:a,className:Dt("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(nkt,{className:Dt("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(mWe,{})]})}));Rs.displayName=iWe.displayName;const okt=S.forwardRef(({className:t,...s},r)=>e.jsx(oWe,{ref:r,className:Dt("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));okt.displayName=oWe.displayName;const vt=S.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(lWe,{ref:n,className:Dt("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(ikt,{children:e.jsx(Zn,{className:"h-4 w-4"})})}),e.jsx(akt,{children:s})]}));vt.displayName=lWe.displayName;const lkt=S.forwardRef(({className:t,...s},r)=>e.jsx(uWe,{ref:r,className:Dt("-mx-1 my-1 h-px bg-muted",t),...s}));lkt.displayName=uWe.displayName;const ckt=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=()=>Et({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:k}=await G.from("listing_shares").select("id, sharing_agent_id").eq("share_token",l).eq("listing_id",t).maybeSingle();k&&(y=k.id,_=k.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}}),dkt=()=>Et({mutationFn:async t=>{const{error:s}=await G.rpc("increment_listing_share_click",{p_share_token:t});if(s)throw s}}),ukt={active:"bg-emerald-500",coming_soon:"bg-blue-600",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},$Pe={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},hkt={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]=S.useState(""),[r,n]=S.useState(!1),[a,o]=S.useState({status:"",propertyType:"",minPrice:"",maxPrice:""}),{data:l,isLoading:i}=ckt({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(nc,{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(${TNt})`},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(an,{className:"absolute left-4 top-1/2 -translate-y-1/2 h-5 w-5 text-gray-400"}),e.jsx(Le,{placeholder:"Enter an address, neighborhood, city, or ZIP code",value:t,onChange:f=>s(f.target.value),className:"pl-12 h-14 md:h-16 text-base md:text-lg border-0 focus-visible:ring-0 rounded-none bg-white"})]}),e.jsx(K,{className:"h-14 md:h-16 px-6 md:px-8 rounded-none bg-blue-600 hover:bg-blue-700",children:e.jsx(an,{className:"h-5 w-5 md:h-6 md:w-6"})})]}),e.jsx("div",{className:"flex justify-center mt-6",children:e.jsxs(K,{variant:"secondary",size:"sm",onClick:()=>n(!r),className:"gap-2 bg-white/90 hover:bg-white text-gray-700 shadow-lg",children:[e.jsx(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(Fs,{value:a.status||"all",onValueChange:f=>o({...a,status:f==="all"?"":f}),children:[e.jsx(Ds,{className:"bg-white",children:e.jsx(zs,{placeholder:"Any status"})}),e.jsxs(Rs,{children:[e.jsx(vt,{value:"all",children:"Any status"}),Object.entries($Pe).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(Fs,{value:a.propertyType||"all",onValueChange:f=>o({...a,propertyType:f==="all"?"":f}),children:[e.jsx(Ds,{className:"bg-white",children:e.jsx(zs,{placeholder:"Any type"})}),e.jsxs(Rs,{children:[e.jsx(vt,{value:"all",children:"Any type"}),Object.entries(hkt).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(Le,{type:"number",placeholder:"No min",value:a.minPrice,onChange:f=>o({...a,minPrice:f.target.value}),className:"bg-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Max Price"}),e.jsx(Le,{type:"number",placeholder:"No max",value:a.maxPrice,onChange:f=>o({...a,maxPrice:f.target.value}),className:"bg-white"})]})]}),p&&e.jsx("div",{className:"flex justify-end mt-4",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:u,className:"gap-1 text-gray-500",children:[e.jsx(jr,{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(PNt,{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(ks,{className:"aspect-[4/3]"}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx(ks,{className:"h-7 w-28"}),e.jsx(ks,{className:"h-4 w-full"}),e.jsx(ks,{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,k;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(Sn,{className:"h-12 w-12 text-gray-300"})}),e.jsx(Qe,{className:`absolute top-2 left-2 ${ukt[f.status]} text-white border-0 text-xs font-medium px-2 py-0.5`,children:$Pe[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}),((k=f.agent.brokerage)==null?void 0:k.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(Sn,{className:"h-10 w-10 text-gray-400"})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"No listings found"}),e.jsx("p",{className:"text-gray-500 mb-6",children:p?"Try adjusting your search or filters":"Check back soon for new listings"}),p&&e.jsx(K,{variant:"outline",onClick:u,children:"Clear filters"})]})})}),e.jsx("footer",{className:"bg-gray-900 text-white py-10 mt-auto",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-between gap-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("img",{src: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=S.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Dt("rounded-lg border bg-card text-card-foreground shadow-sm",t),...s}));Pe.displayName="Card";const Lt=S.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Dt("flex flex-col space-y-1.5 p-6",t),...s}));Lt.displayName="CardHeader";const Ft=S.forwardRef(({className:t,...s},r)=>e.jsx("h3",{ref:r,className:Dt("text-2xl font-semibold leading-none tracking-tight",t),...s}));Ft.displayName="CardTitle";const ur=S.forwardRef(({className:t,...s},r)=>e.jsx("p",{ref:r,className:Dt("text-sm text-muted-foreground",t),...s}));ur.displayName="CardDescription";const Re=S.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Dt("p-6 pt-0",t),...s}));Re.displayName="CardContent";const XL=S.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Dt("flex items-center p-6 pt-0",t),...s}));XL.displayName="CardFooter";var mkt="Label",gWe=S.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=mkt;var yWe=gWe;const pkt=bC("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),xe=S.forwardRef(({className:t,...s},r)=>e.jsx(yWe,{ref:r,className:Dt(pkt(),t),...s}));xe.displayName=yWe.displayName;const Yoe="/assets/levelup-logo-color-D3mY9gCJ.png";function fkt(){const t=Bl(),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(xkt,{slug:n})}function xkt({slug:t}){return e.jsx(vkt,{slug:t})}const gkt={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},ykt={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},qPe={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function vkt({slug:t}){var B,U;const{data:s,isLoading:r}=pWe(t),n=fWe(),[a,o]=S.useState(""),[l,i]=S.useState(""),[d,u]=S.useState(""),[p,f]=S.useState(""),[y,_]=S.useState(!1),[b,N]=S.useState(!1),[w,k]=S.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&&k(w===0?I.length-1:w-1)},V=()=>{w!==null&&k(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(ks,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(ks,{className:"h-10 w-48 mb-6"}),e.jsx(ks,{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(ks,{className:"h-12 w-48"}),e.jsx(ks,{className:"h-6 w-full"}),e.jsx(ks,{className:"h-6 w-3/4"})]}),e.jsx(ks,{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:Yoe,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(Sn,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Listing Not Found"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing may no longer be available."}),e.jsx(K,{asChild:!0,children:e.jsx("a",{href:"/",children:"Browse All Listings"})})]})]});const 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(nc,{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":""} ${qPe[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:Yoe,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:()=>k(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:()=>k(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:`${gkt[s.status]} text-white border-0`,children:ykt[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(ln,{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"}),qPe[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(K,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:s.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Zr,{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(Lt,{children:e.jsxs(Ft,{className:"text-lg flex items-center gap-2",children:[e.jsx(Ai,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(Re,{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(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"Interested in this property?"})}),e.jsx(Re,{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(Le,{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(Le,{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(Le,{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(Le,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:p,onChange:te=>f(te.target.value)})]}),e.jsx(K,{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:()=>k(null),children:e.jsxs(hs,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(js,{className:"sr-only",children:e.jsx(_s,{children:"Photo Gallery"})}),e.jsx("button",{onClick:()=>k(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(jr,{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 Cue({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}),_kt=()=>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}}),bkt=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 Et({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 Et({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)})},Ui=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:{}})},wkt=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 Mue({open:t,onOpenChange:s,cardId:r,type:n,agentName:a}){const[o,l]=S.useState(""),[i,d]=S.useState(""),[u,p]=S.useState(""),[f,y]=S.useState(""),[_,b]=S.useState(""),[N,w]=S.useState(!1),k=async C=>{if(C.preventDefault(),!o.trim()){pe.error("Please enter your name");return}w(!0);try{await wkt(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}),Ui(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(hs,{className:"sm:max-w-md rounded-2xl",children:[e.jsxs(js,{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:k,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"lead-name",children:"Name *"}),e.jsx(Le,{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(Le,{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(Le,{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(Fs,{value:f,onValueChange:y,children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select one"})}),e.jsxs(Rs,{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(Le,{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(K,{type:"submit",className:"w-full rounded-2xl",disabled:N,children:N?"Sending...":"Submit"})]})]})})}const jkt=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}),Nkt=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}),kkt=()=>{const t=Qt();return Et({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)})},Skt=()=>{const t=Qt();return Et({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)})},Ckt=()=>{const t=Qt();return Et({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 Mkt(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 Tkt(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 Akt={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 Ekt({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=Tkt(r.video_url),o=n||!!a,l=n?Mkt(r.video_url):a||r.video_url;return e.jsx("div",{className:Akt[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 Pkt={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 Ikt({block:t,variant:s}){const n=t.config.testimonials||[],[a,o]=S.useState(0);if(n.length===0)return null;const l=Pkt[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 Lkt={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 Dkt({block:t,variant:s}){const n=t.config.tags||[];if(n.length===0)return null;const a=Lkt[s];return e.jsx("div",{className:a.container,children:n.map((o,l)=>e.jsx("span",{className:a.tag,children:o},l))})}const Rkt={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 Okt({block:t,cardId:s,variant:r}){const a=t.config.links||[];if(a.length===0)return null;const o=Rkt[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:()=>Ui(s,"button_click",`custom_link_${l.label}`),className:o.link,children:[e.jsx("span",{children:l.label}),e.jsx(Zr,{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 Fkt({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 zkt={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 Bkt({block:t,cardId:s,variant:r}){const a=t.config.platforms||[],o=zkt[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:()=>Ui(s,"button_click",`social_${l.platform}`),className:o.linkClass,title:d.label,children:e.jsx(Fkt,{path:d.icon,color:d.color})},i)})})]})}function Tue({cardId:t,variant:s}){const{data:r}=jkt(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(Ekt,{block:l,variant:s},l.id);case"testimonials":return e.jsx(Ikt,{block:l,variant:s},l.id);case"specialties":return e.jsx(Dkt,{block:l,variant:s},l.id);case"custom_links":return e.jsx(Okt,{block:l,cardId:t,variant:s},l.id);default:return null}}),o&&e.jsx(Bkt,{block:o,cardId:t,variant:s})]})}async function $kt(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 qkt(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 Aue(t){const{first:s,last:r}=qkt(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 $kt(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 Ukt({card:t}){var k;const[s,r]=S.useState(!1),[n,a]=S.useState("booking"),o=((k=t.profile)==null?void 0:k.name)||"Agent",l=o.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),i=(C,A)=>{Ui(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),Ui(t.id,"button_click","book"))},y=()=>{var C,A;Ui(t.id,"contact_saved"),Aue({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()=>{Ui(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),Ui(t.id,"button_click","refer")},N=()=>{a("connect"),r(!0),Ui(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(wn,{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(jn,{className:"text-2xl font-semibold bg-primary text-primary-foreground",children:l})]}),e.jsx("h1",{className:"text-2xl font-bold text-slate-900 mb-0.5",children:o}),t.title&&e.jsx("p",{className:"text-sm font-medium text-primary mb-1",children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&e.jsx("p",{className:"text-sm font-medium text-slate-500 mb-1",children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:"text-xs font-medium text-slate-400 mb-3",children:t.team_name}),t.positioning_statement&&e.jsxs("p",{className:"text-base text-slate-600 italic leading-relaxed max-w-xs mx-auto",children:['"',t.positioning_statement,'"']})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[e.jsxs(K,{onClick: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(K,{onClick:u,className:"flex flex-col items-center gap-1.5 h-auto py-4 bg-primary hover:bg-primary/90 text-primary-foreground rounded-2xl shadow-sm",children:[e.jsx(Si,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Text"})]}),e.jsxs(K,{onClick:p,className:"flex flex-col items-center gap-1.5 h-auto py-4 bg-primary hover:bg-primary/90 text-primary-foreground rounded-2xl shadow-sm",children:[e.jsx(tr,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Email"})]})]}),e.jsxs(K,{onClick:f,className:"w-full h-12 text-base font-semibold rounded-2xl shadow-sm mb-6",variant:"outline",children:[e.jsx(ln,{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(Cue,{card:t,variant:"standard"}),e.jsx(Tue,{cardId:t.id,variant:"standard"}),e.jsxs("div",{className:"space-y-2 mb-6",children:[t.show_save_contact&&e.jsxs(K,{variant:"ghost",onClick: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(K,{variant:"ghost",onClick:()=>{Ui(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(K,{variant:"ghost",onClick:b,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(or,{className:"h-4 w-4 mr-3 text-primary"}),"Refer a Friend"]}),e.jsxs(K,{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(K,{variant:"ghost",onClick:_,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(_d,{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:()=>Ui(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(Mue,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Vkt({card:t}){var k;const[s,r]=S.useState(!1),[n,a]=S.useState("booking"),o=((k=t.profile)==null?void 0:k.name)||"Agent",l=o.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),i=(C,A)=>{Ui(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),Ui(t.id,"button_click","book"))},y=()=>{var C,A;Ui(t.id,"contact_saved"),Aue({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()=>{Ui(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),Ui(t.id,"button_click","refer")},N=()=>{a("connect"),r(!0),Ui(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(wn,{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(jn,{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:Si,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(ln,{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(Cue,{card:t,variant:"luxury"}),e.jsx(Tue,{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:()=>{Ui(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(or,{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(_d,{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:()=>Ui(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(Mue,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Hkt({card:t}){var A,I,L,O;const[s,r]=S.useState(!1),[n,a]=S.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)=>{Ui(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),Ui(t.id,"button_click","book"))},b=()=>{var V,q;Ui(t.id,"contact_saved"),Aue({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()=>{Ui(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),Ui(t.id,"button_click","refer")},k=()=>{a("connect"),r(!0),Ui(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(wn,{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(jn,{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:Si,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(ln,{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(Cue,{card:t,variant:"bold"}),e.jsx(Tue,{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:()=>{Ui(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(or,{className:"h-4 w-4",style:{color:i.accent}})," Refer a Friend"]}),e.jsxs("button",{onClick:k,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(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(_d,{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:()=>Ui(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(Mue,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Gkt({card:t}){var k;const[s,r]=S.useState(!1),[n,a]=S.useState("booking"),o=((k=t.profile)==null?void 0:k.name)||"Agent",l=o.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),i=(C,A)=>{Ui(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),Ui(t.id,"button_click","book"))},y=()=>{var C,A;Ui(t.id,"contact_saved"),Aue({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()=>{Ui(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),Ui(t.id,"button_click","refer")},N=()=>{a("connect"),r(!0),Ui(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(wn,{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(jn,{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:Si,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(ln,{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(Cue,{card:t,variant:"classic"}),e.jsx(Tue,{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:()=>{Ui(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(or,{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(_d,{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:()=>Ui(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(Mue,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Wje({card:t}){switch(t.theme){case"luxury":return e.jsx(Vkt,{card:t});case"bold":return e.jsx(Hkt,{card:t});case"classic":return e.jsx(Gkt,{card:t});case"standard":default:return e.jsx(Ukt,{card:t})}}function Wkt(){const t=Bl();S.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(Kkt,{slug:s})}function Kkt({slug:t}){return e.jsx(Zkt,{slug:t})}function Zkt({slug:t}){var o;const{data:s,isLoading:r,error:n}=vWe(t);if(S.useEffect(()=>{s!=null&&s.id&&Ui(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(ks,{className:"h-28 w-28 rounded-full"}),e.jsx(ks,{className:"h-6 w-48"}),e.jsx(ks,{className:"h-4 w-36"})]}),e.jsx(ks,{className:"h-12 w-full"}),e.jsx(ks,{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(nc,{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]=S.useState(n||""),[d,u]=S.useState(a||""),[p,f]=S.useState(o||""),[y,_]=S.useState(""),[b,N]=S.useState(""),[w,k]=S.useState(!1),[C,A]=S.useState(!1),I=async L=>{if(L.preventDefault(),!l.trim()){pe.error("Please enter your name");return}k(!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{k(!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(Le,{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(Le,{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(Le,{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(Fs,{value:y,onValueChange:_,children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select one"})}),e.jsxs(Rs,{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(Le,{id:"pres-lead-message",value:b,onChange:L=>N(L.target.value),placeholder:"Anything you'd like us to know"})]}),e.jsx(K,{type:"submit",className:"w-full text-lg py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",disabled:w,children:w?"Sending...":s})]})}function Ykt(){const t=Bl();S.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(Xkt,{shareToken:s})}function Xkt({shareToken:t}){var b;const[s,r]=S.useState(null),[n,a]=S.useState(!0),[o,l]=S.useState(0),[i,d]=S.useState(!1);S.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:k}=await G.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",N.owner_user_id).single();let C;if(k!=null&&k.brokerage_id){const{data:I}=await G.from("brokerages").select("name").eq("id",k.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:k==null?void 0:k.name,owner_email:k==null?void 0:k.email,owner_phone:k==null?void 0:k.phone,owner_avatar:k==null?void 0:k.avatar_url,owner_title:(k==null?void 0:k.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 k=N.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(k)return`https://www.loom.com/embed/${k[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(ks,{className:"h-12 w-3/4 mx-auto"}),e.jsx(ks,{className:"h-64 w-full"}),e.jsx(ks,{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:Dt("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(K,{size:"lg",onClick:p,className:"text-lg px-8 py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",children:[s.cta_label,e.jsx(Zr,{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 Qkt(){const{user:t}=qs(),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 eAs(t){const{user:s}=qs();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}=qs(),r=Qt();return S.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 Jkt(){const t=Qt(),s=ya();return Et({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"]}),pn({title:"Open house created!"})},onError:r=>{pn({title:"Error",description:r.message,variant:"destructive"})}})}function kWe(){const t=Qt();return Et({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 e4t(){const t=Qt();return Et({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"]}),pn({title:"Open house deleted"})}})}function t4t(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 s4t(t){const{user:s}=qs();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 r4t(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 n4t(){return Et({mutationFn:async t=>{const{error:s}=await G.from("open_house_survey_responses").insert(t);if(s)throw s}})}function a4t(t){const{user:s}=qs();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 i4t(){const t=Qt();return Et({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 o4t(){const t=Qt();return Et({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 l4t(){const t=Qt();return Et({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 c4t(){const t=Qt();return Et({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 d4t(){return Et({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 u4t(){return Et({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 h4t(){return Et({mutationFn:async t=>{await G.rpc("increment_open_house_scan",{_slug:t})}})}var Eue="Switch",[m4t,tAs]=qc(Eue),[p4t,f4t]=m4t(Eue),SWe=S.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,_]=S.useState(null),b=Ta(s,A=>_(A)),N=S.useRef(!1),w=y?p||!!y.closest("form"):!0,[k,C]=Uu({prop:a,defaultProp:o??!1,onChange:u,caller:Eue});return e.jsxs(p4t,{scope:r,checked:k,disabled:i,children:[e.jsx(Jr.button,{type:"button",role:"switch","aria-checked":k,"aria-required":l,"data-state":AWe(k),"data-disabled":i?"":void 0,disabled:i,value:d,...f,ref:b,onClick:Sr(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:k,required:l,disabled:i,form:p,style:{transform:"translateX(-100%)"}})]})});SWe.displayName=Eue;var CWe="SwitchThumb",MWe=S.forwardRef((t,s)=>{const{__scopeSwitch:r,...n}=t,a=f4t(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 x4t="SwitchBubbleInput",TWe=S.forwardRef(({__scopeSwitch:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=S.useRef(null),i=Ta(l,o),d=zR(r),u=kR(s);return S.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=x4t;function AWe(t){return t?"checked":"unchecked"}var EWe=SWe,g4t=MWe;const Mr=S.forwardRef(({className:t,...s},r)=>e.jsx(EWe,{className:Dt("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",t),...s,ref:r,children:e.jsx(g4t,{className:Dt("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")})}));Mr.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,y4t=864e5,Pue=6e4,BR=36e5,v4t=1e3,Mz=43200,UPe=1440;function VPe(t,s){return PWe(t,s*BR)}let _4t={};function gw(){return _4t}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)/y4t)}function b4t(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*Pue)}function x4(t,s){const r=s*7;return ml(t,r)}function w4t(t,s){return Am(t,s*12)}function j4t(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 Bie(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 k4t(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=HPe(r,n),o=Math.abs(sf(r,n));r.setDate(r.getDate()-a*o);const l=+(HPe(r,n)===-a),i=a*(o-l);return i===0?0:i}function HPe(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 S4t(t,s,r){const n=DWe(t,s)/BR;return LWe(r==null?void 0:r.roundingMethod)(n)}function C4t(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 M4t(t){const s=Yn(t);return+C4t(s)==+tx(s)}function T4t(t,s){const r=Yn(t),n=Yn(s),a=Bie(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=Bie(r,n)===-a;M4t(Yn(t))&&o===1&&Bie(t,n)===1&&(i=!1),l=a*(o-Number(i))}return l===0?0:l}function A4t(t,s,r){const n=DWe(t,s)/1e3;return LWe(r==null?void 0:r.roundingMethod)(n)}function E4t(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 Iue(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=P4t[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 yge(t){return(s={})=>{const r=s.width?String(s.width):t.defaultWidth;return t.formats[r]||t.formats[t.defaultWidth]}}const L4t={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},D4t={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},R4t={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},O4t={date:yge({formats:L4t,defaultWidth:"full"}),time:yge({formats:D4t,defaultWidth:"full"}),dateTime:yge({formats:R4t,defaultWidth:"full"})},F4t={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},z4t=(t,s,r,n)=>F4t[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 B4t={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},$4t={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},q4t={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"]},U4t={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"]},V4t={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"}},H4t={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"}},G4t=(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"},W4t={ordinalNumber:G4t,era:Q6({values:B4t,defaultWidth:"wide"}),quarter:Q6({values:$4t,defaultWidth:"wide",argumentCallback:t=>t-1}),month:Q6({values:q4t,defaultWidth:"wide"}),day:Q6({values:U4t,defaultWidth:"wide"}),dayPeriod:Q6({values:V4t,defaultWidth:"wide",formattingValues:H4t,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)?Z4t(i,f=>f.test(l)):K4t(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 K4t(t,s){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&s(t[r]))return r}function Z4t(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 X4t=/^(\d+)(th|st|nd|rd)?/i,Q4t=/\d+/i,J4t={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},eSt={any:[/^b/i,/^(a|c)/i]},tSt={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},sSt={any:[/1/i,/2/i,/3/i,/4/i]},rSt={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},nSt={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]},aSt={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},iSt={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},oSt={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},lSt={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}},cSt={ordinalNumber:Y4t({matchPattern:X4t,parsePattern:Q4t,valueCallback:t=>parseInt(t,10)}),era:J6({matchPatterns:J4t,defaultMatchWidth:"wide",parsePatterns:eSt,defaultParseWidth:"any"}),quarter:J6({matchPatterns:tSt,defaultMatchWidth:"wide",parsePatterns:sSt,defaultParseWidth:"any",valueCallback:t=>t+1}),month:J6({matchPatterns:rSt,defaultMatchWidth:"wide",parsePatterns:nSt,defaultParseWidth:"any"}),day:J6({matchPatterns:aSt,defaultMatchWidth:"wide",parsePatterns:iSt,defaultParseWidth:"any"}),dayPeriod:J6({matchPatterns:oSt,defaultMatchWidth:"any",parsePatterns:lSt,defaultParseWidth:"any"})},Lue={code:"en-US",formatDistance:I4t,formatLong:O4t,formatRelative:z4t,localize:W4t,match:cSt,options:{weekStartsOn:0,firstWeekContainsDate:1}};function dSt(t){const s=Yn(t);return sf(s,RWe(s))+1}function Xje(t){const s=Yn(t),r=+x1(s)-+b4t(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 uSt(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)-+uSt(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"},GPe={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=dSt(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 KPe(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 KPe(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"+WPe(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"+WPe(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 WPe(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 KPe(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 ZPe=(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"})}},hSt=(t,s)=>{const r=t.match(/(P+)(p+)?/)||[],n=r[1],a=r[2];if(!a)return ZPe(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}}",ZPe(n,s)).replace("{{time}}",FWe(a,s))},j1e={p:FWe,P:hSt},mSt=/^D+$/,pSt=/^Y+$/,fSt=["D","DD","YY","YYYY"];function zWe(t){return mSt.test(t)}function BWe(t){return pSt.test(t)}function N1e(t,s,r){const n=xSt(t,s,r);if(console.warn(n),fSt.includes(t))throw new RangeError(n)}function xSt(t,s,r){const n=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${s}\`) for formatting ${n} to the input \`${r}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const gSt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,ySt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,vSt=/^'([^]*?)'?$/,_St=/''/g,bSt=/[a-zA-Z]/;function gs(t,s,r){var p,f,y,_,b,N,w,k;const n=gw(),a=(r==null?void 0:r.locale)??n.locale??Lue,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??((k=(w=n.locale)==null?void 0:w.options)==null?void 0:k.weekStartsOn)??0,i=Yn(t);if(!w1e(i))throw new RangeError("Invalid time value");let d=s.match(ySt).map(C=>{const A=C[0];if(A==="p"||A==="P"){const I=j1e[A];return I(C,a.formatLong)}return C}).join("").match(gSt).map(C=>{if(C==="''")return{isToken:!1,value:"'"};const A=C[0];if(A==="'")return{isToken:!1,value:wSt(C)};if(GPe[A])return{isToken:!0,value:C};if(A.match(bSt))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=GPe[A[0]];return I(i,A,a.localize,u)}).join("")}function wSt(t){const s=t.match(vSt);return s?s[1].replace(_St,"'"):t}function jSt(t,s,r){const n=gw(),a=(r==null?void 0:r.locale)??n.locale??Lue,o=2520,l=Bie(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=A4t(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 ASt(t){return+Yn(t)>Date.now()}function ESt(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 PSt=10;class $We{constructor(){En(this,"subPriority",0)}validate(s,r){return!0}}class ISt 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 LSt extends $We{constructor(){super(...arguments);En(this,"priority",PSt);En(this,"subPriority",-1)}set(r,n){return n.timestampIsSet?r:Wo(r,ESt(r,Date))}}class Ro{run(s,r,n,a){const o=this.parse(s,r,n,a);return o?{setter:new ISt(o.value,this.validate,this.set,this.priority,this.subPriority),rest:o.rest}:null}validate(s,r,n){return!0}}class DSt 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 xd={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 gd(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*Pue+l*v4t),rest:s.slice(r[0].length)}}function qWe(t){return Rc(xd.anyDigitsSigned,t)}function id(t,s){switch(t){case 1:return Rc(xd.singleDigit,s);case 2:return Rc(xd.twoDigits,s);case 3:return Rc(xd.threeDigits,s);case 4:return Rc(xd.fourDigits,s);default:return Rc(new RegExp("^\\d{1,"+t+"}"),s)}}function Xoe(t,s){switch(t){case 1:return Rc(xd.singleDigitSigned,s);case 2:return Rc(xd.twoDigitsSigned,s);case 3:return Rc(xd.threeDigitsSigned,s);case 4:return Rc(xd.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 RSt 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 gd(id(4,r),o);case"yo":return gd(a.ordinalNumber(r,{unit:"year"}),o);default:return gd(id(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 OSt 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 gd(id(4,r),o);case"Yo":return gd(a.ordinalNumber(r,{unit:"year"}),o);default:return gd(id(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 FSt 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 Xoe(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 zSt 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 Xoe(n==="u"?4:n.length,r)}set(r,n,a){return r.setFullYear(a,0,1),r.setHours(0,0,0,0),r}}class BSt 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 id(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 $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 id(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 qSt 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 gd(Rc(xd.month,r),o);case"MM":return gd(id(2,r),o);case"Mo":return gd(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 USt 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 gd(Rc(xd.month,r),o);case"LL":return gd(id(2,r),o);case"Lo":return gd(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 VSt(t,s,r){const n=Yn(t),a=Jje(n,r)-s;return n.setDate(n.getDate()-a*7),n}class HSt 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(xd.week,r);case"wo":return a.ordinalNumber(r,{unit:"week"});default:return id(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a,o){return zh(VSt(r,a,o),o)}}function GSt(t,s){const r=Yn(t),n=Xje(r)-s;return r.setDate(r.getDate()-n*7),r}class WSt 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(xd.week,r);case"Io":return a.ordinalNumber(r,{unit:"week"});default:return id(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a){return x1(GSt(r,a))}}const KSt=[31,28,31,30,31,30,31,31,30,31,30,31],ZSt=[31,29,31,30,31,30,31,31,30,31,30,31];class YSt 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(xd.date,r);case"do":return a.ordinalNumber(r,{unit:"date"});default:return id(n.length,r)}}validate(r,n){const a=r.getFullYear(),o=VWe(a),l=r.getMonth();return o?n>=1&&n<=ZSt[l]:n>=1&&n<=KSt[l]}set(r,n,a){return r.setDate(a),r.setHours(0,0,0,0),r}}class XSt 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(xd.dayOfYear,r);case"Do":return a.ordinalNumber(r,{unit:"date"});default:return id(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 QSt 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 JSt 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 gd(id(n.length,r),l);case"eo":return gd(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 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","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 gd(id(n.length,r),l);case"co":return gd(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 tCt(t,s){const r=Yn(t),n=SSt(r),a=s-n;return ml(r,a)}class sCt 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 id(n.length,r);case"io":return a.ordinalNumber(r,{unit:"day"});case"iii":return gd(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 gd(a.day(r,{width:"narrow",context:"formatting"}),o);case"iiiiii":return gd(a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),o);case"iiii":default:return gd(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=tCt(r,a),r.setHours(0,0,0,0),r}}class rCt 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 nCt 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 aCt 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 iCt 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(xd.hour12h,r);case"ho":return a.ordinalNumber(r,{unit:"hour"});default:return id(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 oCt 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(xd.hour23h,r);case"Ho":return a.ordinalNumber(r,{unit:"hour"});default:return id(n.length,r)}}validate(r,n){return n>=0&&n<=23}set(r,n,a){return r.setHours(a,0,0,0),r}}class lCt 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(xd.hour11h,r);case"Ko":return a.ordinalNumber(r,{unit:"hour"});default:return id(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 cCt 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(xd.hour24h,r);case"ko":return a.ordinalNumber(r,{unit:"hour"});default:return id(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 dCt extends Ro{constructor(){super(...arguments);En(this,"priority",60);En(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"m":return Rc(xd.minute,r);case"mo":return a.ordinalNumber(r,{unit:"minute"});default:return id(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setMinutes(a,0,0),r}}class uCt extends Ro{constructor(){super(...arguments);En(this,"priority",50);En(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"s":return Rc(xd.second,r);case"so":return a.ordinalNumber(r,{unit:"second"});default:return id(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setSeconds(a,0),r}}class hCt 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 gd(id(n.length,r),a)}set(r,n,a){return r.setMilliseconds(a),r}}class mCt 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 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",40);En(this,"incompatibleTokens","*")}parse(r){return qWe(r)}set(r,n,a){return[Wo(r,a*1e3),{timestampIsSet:!0}]}}class xCt 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 gCt={G:new DSt,y:new RSt,Y:new OSt,R:new FSt,u:new zSt,Q:new BSt,q:new $St,M:new qSt,L:new USt,w:new HSt,I:new WSt,d:new YSt,D:new XSt,E:new QSt,e:new JSt,c:new eCt,i:new sCt,a:new rCt,b:new nCt,B:new aCt,h:new iCt,H:new oCt,K:new lCt,k:new cCt,m:new dCt,s:new uCt,S:new hCt,X:new mCt,x:new pCt,t:new fCt,T:new xCt},yCt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,vCt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,_Ct=/^'([^]*?)'?$/,bCt=/''/g,wCt=/\S/,jCt=/[a-zA-Z]/;function sNe(t,s,r,n){var N,w,k,C;const a=kSt(),o=a.locale??Lue,l=a.firstWeekContainsDate??((w=(N=a.locale)==null?void 0:N.options)==null?void 0:w.firstWeekContainsDate)??1,i=a.weekStartsOn??((C=(k=a.locale)==null?void 0:k.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 LSt],p=s.match(vCt).map(A=>{const I=A[0];if(I in j1e){const L=j1e[I];return L(A,o.formatLong)}return A}).join("").match(yCt),f=[];for(let A of p){BWe(A)&&N1e(A,s,t),zWe(A)&&N1e(A,s,t);const I=A[0],L=gCt[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(jCt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+I+"`");if(A==="''"?A="'":I==="'"&&(A=NCt(A)),t.indexOf(A)===0)t=t.slice(A.length);else return Wo(r,NaN)}}if(t.length>0&&wCt.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 NCt(t){return t.match(_Ct)[1].replace(bCt,"'")}function a0(t){return+Yn(t)o-l);return r>=n&&r<=a}function $ie(t,s){return ml(t,-s)}function xm(t,s){const n=ECt(t);let a;if(n.date){const d=PCt(n.date,2);a=ICt(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=LCt(n.time),isNaN(l)))return new Date(NaN);if(n.timezone){if(i=DCt(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 Tz={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},MCt=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,TCt=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,ACt=/^([+-])(\d{2})(?::?(\d{2}))?$/;function ECt(t){const s={},r=t.split(Tz.dateTimeDelimiter);let n;if(r.length>2)return s;if(/:/.test(r[0])?n=r[0]:(s.date=r[0],n=r[1],Tz.timeZoneDelimiter.test(s.date)&&(s.date=t.split(Tz.timeZoneDelimiter)[0],n=t.substr(s.date.length,t.length))),n){const a=Tz.timezone.exec(n);a?(s.time=n.replace(a[1],""),s.timezone=a[1]):s.time=n}return s}function PCt(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 ICt(t,s){if(s===null)return new Date(NaN);const r=t.match(MCt);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 BCt(s,i,d)?RCt(s,i,d):new Date(NaN);{const u=new Date(0);return!FCt(s,o,l)||!zCt(s,a)?new Date(NaN):(u.setUTCFullYear(s,o,Math.max(a,l)),u)}}function eI(t){return t?parseInt(t):1}function LCt(t){const s=t.match(TCt);if(!s)return NaN;const r=vge(s[1]),n=vge(s[2]),a=vge(s[3]);return $Ct(r,n,a)?r*BR+n*Pue+a*1e3:NaN}function vge(t){return t&&parseFloat(t.replace(",","."))||0}function DCt(t){if(t==="Z")return 0;const s=t.match(ACt);if(!s)return 0;const r=s[1]==="+"?-1:1,n=parseInt(s[2]),a=s[3]&&parseInt(s[3])||0;return qCt(n,a)?r*(n*BR+a*Pue):NaN}function RCt(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 OCt=[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 FCt(t,s,r){return s>=0&&s<=11&&r>=1&&r<=(OCt[s]||(HWe(t)?29:28))}function zCt(t,s){return s>=1&&s<=(HWe(t)?366:365)}function BCt(t,s,r){return s>=1&&s<=53&&r>=0&&r<=6}function $Ct(t,s,r){return t===24?s===0&&r===0:r>=0&&r<60&&s>=0&&s<60&&t>=0&&t<25}function qCt(t,s){return s>=0&&s<=59}function _ge(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=NSt(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 XPe(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 QPe;(function(t){t.mergeShapes=(s,r)=>({...s,...r})})(QPe||(QPe={}));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 UCt=k1e;function VCt(){return UCt}const HCt=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=VCt(),n=HCt({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 xi;a.status==="dirty"&&s.dirty(),n.push(a.value)}return{status:s.value,value:n}}static async mergeObjectAsync(s,r){const n=[];for(const a of r){const o=await a.key,l=await a.value;n.push({key:o,value:l})}return 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 xi;o.status==="dirty"&&s.dirty(),l.status==="dirty"&&s.dirty(),o.value!=="__proto__"&&(typeof l.value<"u"||a.alwaysSet)&&(n[o.value]=l.value)}return{status:s.value,value:n}}}const xi=Object.freeze({status:"aborted"}),LI=t=>({status:"dirty",value:t}),Ix=t=>({status:"valid",value:t}),JPe=t=>t.status==="aborted",e6e=t=>t.status==="dirty",PT=t=>t.status==="valid",Qoe=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 t6e=(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 Oi(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(Qoe(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 t6e(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(Qoe(a)?a:Promise.resolve(a));return t6e(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:gi.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 sle.create(this,this._def)}or(s){return ele.create([this,s],this._def)}and(s){return tle.create(this,s,this._def)}transform(s){return new DT({...Oi(this._def),schema:this,typeName:gi.ZodEffects,effect:{type:"transform",transform:s}})}default(s){const r=typeof s=="function"?s:()=>s;return new T1e({...Oi(this._def),innerType:this,defaultValue:r,typeName:gi.ZodDefault})}brand(){return new p3t({typeName:gi.ZodBranded,type:this,...Oi(this._def)})}catch(s){const r=typeof s=="function"?s:()=>s;return new A1e({...Oi(this._def),innerType:this,catchValue:r,typeName:gi.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 GCt=/^c[^\s-]{8,}$/i,WCt=/^[0-9a-z]+$/,KCt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ZCt=/^[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,YCt=/^[a-z0-9_-]{21}$/i,XCt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,QCt=/^[-+]?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)?)??$/,JCt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,e3t="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let bge;const t3t=/^(?:(?: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])$/,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])\/(3[0-2]|[12]?[0-9])$/,r3t=/^(([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]))$/,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]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,a3t=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,i3t=/^([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])))",o3t=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 l3t(t){return new RegExp(`^${WWe(t)}$`)}function c3t(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 d3t(t,s){return!!((s==="v4"||!s)&&t3t.test(t)||(s==="v6"||!s)&&r3t.test(t))}function u3t(t,s){if(!XCt.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 h3t(t,s){return!!((s==="v4"||!s)&&s3t.test(t)||(s==="v6"||!s)&&n3t.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}),xi}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:gi.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...Oi(t)});function m3t(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}),xi}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"?m3t(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:gi.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...Oi(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}),xi}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:gi.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...Oi(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}),xi}return Ix(s.data)}}S1e.create=t=>new S1e({typeName:gi.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...Oi(t)});class Joe 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}),xi}if(Number.isNaN(s.data.getTime())){const o=this._getOrReturnCtx(s);return Bn(o,{code:en.invalid_date}),xi}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 Joe({...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 Joe({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:gi.ZodDate,...Oi(t)});class s6e 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}),xi}return Ix(s.data)}}s6e.create=t=>new s6e({typeName:gi.ZodSymbol,...Oi(t)});class r6e 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}),xi}return Ix(s.data)}}r6e.create=t=>new r6e({typeName:gi.ZodUndefined,...Oi(t)});class n6e 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}),xi}return Ix(s.data)}}n6e.create=t=>new n6e({typeName:gi.ZodNull,...Oi(t)});class a6e extends bo{constructor(){super(...arguments),this._any=!0}_parse(s){return Ix(s.data)}}a6e.create=t=>new a6e({typeName:gi.ZodAny,...Oi(t)});class i6e extends bo{constructor(){super(...arguments),this._unknown=!0}_parse(s){return Ix(s.data)}}i6e.create=t=>new i6e({typeName:gi.ZodUnknown,...Oi(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}),xi}}Jb.create=t=>new Jb({typeName:gi.ZodNever,...Oi(t)});class o6e 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}),xi}return Ix(s.data)}}o6e.create=t=>new o6e({typeName:gi.ZodVoid,...Oi(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}),xi;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:gi.ZodArray,...Oi(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}),xi}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:gi.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:gi.ZodObject,...Oi(s)});Kc.strictCreate=(t,s)=>new Kc({shape:()=>t,unknownKeys:"strict",catchall:Jb.create(),typeName:gi.ZodObject,...Oi(s)});Kc.lazycreate=(t,s)=>new Kc({shape:t,unknownKeys:"strip",catchall:Jb.create(),typeName:gi.ZodObject,...Oi(s)});class ele 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}),xi}if(r.common.async)return Promise.all(n.map(async o=>{const l={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:l}),ctx:l}})).then(a);{let o;const l=[];for(const d of n){const 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}),xi}}get options(){return this._def.options}}ele.create=(t,s)=>new ele({options:t,typeName:gi.ZodUnion,...Oi(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(JPe(o)||JPe(l))return xi;const i=C1e(o.value,l.value);return i.valid?((e6e(o)||e6e(l))&&r.dirty(),{status:r.value,value:i.data}):(Bn(n,{code:en.invalid_intersection_types}),xi)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([o,l])=>a(o,l)):a(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}tle.create=(t,s,r)=>new tle({left:t,right:s,typeName:gi.ZodIntersection,...Oi(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}),xi;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:gi.ZodTuple,rest:null,...Oi(s)})};class l6e 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}),xi;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 xi;(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 xi;(u.status==="dirty"||p.status==="dirty")&&r.dirty(),i.set(u.value,p.value)}return{status:r.value,value:i}}}}l6e.create=(t,s,r)=>new l6e({valueType:s,keyType:t,typeName:gi.ZodMap,...Oi(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}),xi;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 xi;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:gi.ZodSet,...Oi(s)});class c6e 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})}}c6e.create=(t,s)=>new c6e({getter:t,typeName:gi.ZodLazy,...Oi(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}),xi}return{status:"valid",value:s.data}}get value(){return this._def.value}}M1e.create=(t,s)=>new M1e({value:t,typeName:gi.ZodLiteral,...Oi(s)});function KWe(t,s){return new LT({values:t,typeName:gi.ZodEnum,...Oi(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}),xi}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(s.data)){const r=this._getOrReturnCtx(s),n=this._def.values;return Bn(r,{received:r.data,code:en.invalid_enum_value,options:n}),xi}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 d6e 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}),xi}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}),xi}return Ix(s.data)}get enum(){return this._def.values}}d6e.create=(t,s)=>new d6e({values:t,typeName:gi.ZodNativeEnum,...Oi(s)});class sle 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}),xi;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})))}}sle.create=(t,s)=>new sle({type:t,typeName:gi.ZodPromise,...Oi(s)});class DT extends bo{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===gi.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 xi;const d=await this._def.schema._parseAsync({data:i,path:n.path,parent:n});return d.status==="aborted"?xi:d.status==="dirty"||r.value==="dirty"?LI(d.value):d});{if(r.value==="aborted")return xi;const i=this._def.schema._parseSync({data:l,path:n.path,parent:n});return i.status==="aborted"?xi:i.status==="dirty"||r.value==="dirty"?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"?xi:(i.status==="dirty"&&r.dirty(),l(i.value),{status:r.value,value:i.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>i.status==="aborted"?xi:(i.status==="dirty"&&r.dirty(),l(i.value).then(()=>({status:r.value,value:i.value}))))}if(a.type==="transform")if(n.common.async===!1){const l=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!PT(l))return xi;const i=a.transform(l.value,o);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:i}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(l=>PT(l)?Promise.resolve(a.transform(l.value,o)).then(i=>({status:r.value,value:i})):xi);jo.assertNever(a)}}DT.create=(t,s,r)=>new DT({schema:t,typeName:gi.ZodEffects,effect:s,...Oi(r)});DT.createWithPreprocess=(t,s,r)=>new DT({schema:s,effect:{type:"preprocess",transform:t},typeName:gi.ZodEffects,...Oi(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:gi.ZodOptional,...Oi(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:gi.ZodNullable,...Oi(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:gi.ZodDefault,defaultValue:typeof s.default=="function"?s.default:()=>s.default,...Oi(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 Qoe(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:gi.ZodCatch,catchValue:typeof s.catch=="function"?s.catch:()=>s.catch,...Oi(s)});class u6e 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}),xi}return{status:"valid",value:s.data}}}u6e.create=t=>new u6e({typeName:gi.ZodNaN,...Oi(t)});class p3t 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"?xi: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"?xi:a.status==="dirty"?(r.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:n.path,parent:n})}}static create(s,r){return new rNe({in:s,out:r,typeName:gi.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 Qoe(r)?r.then(a=>n(a)):n(r)}unwrap(){return this._def.innerType}}E1e.create=(t,s)=>new E1e({innerType:t,typeName:gi.ZodReadonly,...Oi(s)});Kc.lazycreate;var gi;(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"})(gi||(gi={}));const Yl=cb.create,e8=IT.create,f3t=S1e.create;Jb.create;i0.create;const kC=Kc.create;Kc.strictCreate;ele.create;tle.create;XS.create;const rle=M1e.create,ZWe=LT.create;sle.create;Lb.create;RT.create;const gr=S.forwardRef(({className:t,...s},r)=>e.jsx("textarea",{className:Dt("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}));gr.displayName="Textarea";const x3t=["Excellent","Good","Neutral","Bad","Very Bad"],g3t=[5,4,3,2,1];function y3t({questions:t,visitorId:s,onComplete:r,onSkip:n}){const a=n4t(),[o,l]=S.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"}),x3t.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}),g3t.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(gr,{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(K,{onClick:f,disabled:a.isPending,className:"w-full h-12 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:a.isPending?e.jsx(us,{className:"h-5 w-5 animate-spin"}):"Submit Feedback"})]})}const v3t=kC({first_name:Yl().trim().min(1,"First name is required").max(50),last_name:Yl().trim().max(50).optional(),email:Yl().trim().email("Please enter a valid email").max(255).optional().or(rle("")),phone:Yl().trim().max(20).optional().or(rle(""))}),_3t=[{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 ye;const s=ao(),r=t||s.slug,{data:n,isLoading:a,error:o}=t4t(r),l=d4t(),i=u4t(),d=h4t(),u=S.useRef(!1),[p,f]=S.useState("welcome"),[y,_]=S.useState(null),[b,N]=S.useState({first_name:"",last_name:"",email:"",phone:""}),[w,k]=S.useState(""),[C,A]=S.useState(!1),[I,L]=S.useState(!1),[O,V]=S.useState(""),[q,B]=S.useState(""),{data:U,isLoading:te}=r4t(n==null?void 0:n.id),Y=!!(n!=null&&n.enable_survey),J=(n==null?void 0:n.ask_visitor_intent)!==!1;S.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]),S.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,Ne]=he.split(":"),Ue=parseInt(ge),Te=Ue>=12?"PM":"AM";return`${Ue>12?Ue-12:Ue||12}:${Ne} ${Te}`},ce=async()=>{B("");const he=v3t.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")},ae=async he=>{k(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(Sn,{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 ie=n.profiles,oe=((ye=ie==null?void 0:ie.name)==null?void 0:ye.split(" ").map(he=>he[0]).join("").slice(0,2))||"?",me=n.event_type==="community";return e.jsxs(e.Fragment,{children:[e.jsxs(nc,{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(wn,{className:"h-16 w-16 mx-auto mb-3 ring-2 ring-white/20",children:[e.jsx(Ma,{src:(ie==null?void 0:ie.avatar_url)||"",alt:(ie==null?void 0:ie.name)||""}),e.jsx(jn,{className:"bg-white/10 text-white text-lg",children:oe})]}),e.jsx("p",{className:"text-white/60 text-sm",children:ie==null?void 0:ie.name}),(ie==null?void 0:ie.title)&&e.jsx("p",{className:"text-white/40 text-xs",children:ie.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(ln,{className:"h-3 w-3"}),gs(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(on,{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(Sn,{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(ln,{className:"h-3 w-3"}),gs(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(on,{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(K,{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(Ga,{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(Le,{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(Le,{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(Le,{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(Le,{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(Mr,{checked:I,onCheckedChange:L})]})]}),I&&e.jsx(Le,{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(K,{onClick:ce,className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Continue ",e.jsx(Ga,{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:_3t.map(he=>e.jsxs("button",{onClick:()=>ae(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(y3t,{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(Hn,{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(yn,{className:"h-4 w-4"}),"View Seller's Disclosures"]}),(ie==null?void 0:ie.name)&&e.jsxs("p",{className:"text-sm text-slate-400",children:["Your host today: ",e.jsx("strong",{className:"text-slate-600",children:ie.name})]})]})]})]}),e.jsx("p",{className:"text-center text-white/30 text-xs mt-6",children:"Powered by LevelUp Guest Book"})]})})]})}function sAs(t){const{user:s}=qs();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 rAs(){const t=Qt(),{user:s}=qs();return Et({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 nAs(){const t=Qt();return Et({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 b3t(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,aAs]=qc(nNe),[j3t,Lx]=XWe(nNe),QWe=S.forwardRef((t,s)=>{const{__scopeScrollArea:r,type:n="hover",dir:a,scrollHideDelay:o=600,...l}=t,[i,d]=S.useState(null),[u,p]=S.useState(null),[f,y]=S.useState(null),[_,b]=S.useState(null),[N,w]=S.useState(null),[k,C]=S.useState(0),[A,I]=S.useState(0),[L,O]=S.useState(!1),[V,q]=S.useState(!1),B=Ta(s,te=>d(te)),U=mw(a);return e.jsx(j3t,{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":k+"px","--radix-scroll-area-corner-height":A+"px",...t.style}})})});QWe.displayName=nNe;var JWe="ScrollAreaViewport",eKe=S.forwardRef((t,s)=>{const{__scopeScrollArea:r,children:n,nonce:a,...o}=t,l=Lx(JWe,r),i=S.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=S.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Lx(N0,t.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:l}=a,i=t.orientation==="horizontal";return S.useEffect(()=>(i?o(!0):l(!0),()=>{i?o(!1):l(!1)}),[i,o,l]),a.type==="hover"?e.jsx(N3t,{...n,ref:s,forceMount:r}):a.type==="scroll"?e.jsx(k3t,{...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 N3t=S.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Lx(N0,t.__scopeScrollArea),[o,l]=S.useState(!1);return S.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})})}),k3t=S.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Lx(N0,t.__scopeScrollArea),o=t.orientation==="horizontal",l=Oue(()=>d("SCROLL_END"),100),[i,d]=w3t("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 S.useEffect(()=>{if(i==="idle"){const u=window.setTimeout(()=>d("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(u)}},[i,a.scrollHideDelay,d]),S.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:Sr(t.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:Sr(t.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),tKe=S.forwardRef((t,s)=>{const r=Lx(N0,t.__scopeScrollArea),{forceMount:n,...a}=t,[o,l]=S.useState(!1),i=t.orientation==="horizontal",d=Oue(()=>{if(r.viewport){const u=r.viewport.offsetWidth{const{orientation:r="vertical",...n}=t,a=Lx(N0,t.__scopeScrollArea),o=S.useRef(null),l=S.useRef(0),[i,d]=S.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 E3t(y,l.current,i,_)}return r==="horizontal"?e.jsx(S3t,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const y=a.viewport.scrollLeft,_=h6e(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(C3t,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const y=a.viewport.scrollTop,_=h6e(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}),S3t=S.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=Lx(N0,t.__scopeScrollArea),[l,i]=S.useState(),d=S.useRef(null),u=Ta(s,d,o.onScrollbarXChange);return S.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":Rue(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:ale(l.paddingLeft),paddingEnd:ale(l.paddingRight)}})}})}),C3t=S.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=Lx(N0,t.__scopeScrollArea),[l,i]=S.useState(),d=S.useRef(null),u=Ta(s,d,o.onScrollbarYChange);return S.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":Rue(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:ale(l.paddingTop),paddingEnd:ale(l.paddingBottom)}})}})}),[M3t,sKe]=XWe(N0),rKe=S.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]=S.useState(null),w=Ta(s,B=>N(B)),k=S.useRef(null),C=S.useRef(""),A=_.viewport,I=n.content-n.viewport,L=ed(p),O=ed(d),V=Oue(f,10);function q(B){if(k.current){const U=B.clientX-k.current.left,te=B.clientY-k.current.top;u({x:U,y:te})}}return S.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]),S.useEffect(O,[n,O]),OT(b,V),OT(_.content,V),e.jsx(M3t,{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:Sr(t.onPointerDown,B=>{B.button===0&&(B.target.setPointerCapture(B.pointerId),k.current=b.getBoundingClientRect(),C.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",_.viewport&&(_.viewport.style.scrollBehavior="auto"),q(B))}),onPointerMove:Sr(t.onPointerMove,q),onPointerUp:Sr(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=""),k.current=null})})})}),nle="ScrollAreaThumb",nKe=S.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=sKe(nle,t.__scopeScrollArea);return e.jsx(jd,{present:r||a.hasThumb,children:e.jsx(T3t,{ref:s,...n})})}),T3t=S.forwardRef((t,s)=>{const{__scopeScrollArea:r,style:n,...a}=t,o=Lx(nle,r),l=sKe(nle,r),{onThumbPositionChange:i}=l,d=Ta(s,f=>l.onThumbChange(f)),u=S.useRef(void 0),p=Oue(()=>{u.current&&(u.current(),u.current=void 0)},100);return S.useEffect(()=>{const f=o.viewport;if(f){const y=()=>{if(p(),!u.current){const _=P3t(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:Sr(t.onPointerDownCapture,f=>{const _=f.target.getBoundingClientRect(),b=f.clientX-_.left,N=f.clientY-_.top;l.onThumbPointerDown({x:b,y:N})}),onPointerUp:Sr(t.onPointerUp,l.onThumbPointerUp)})});nKe.displayName=nle;var oNe="ScrollAreaCorner",aKe=S.forwardRef((t,s)=>{const r=Lx(oNe,t.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?e.jsx(A3t,{...t,ref:s}):null});aKe.displayName=oNe;var A3t=S.forwardRef((t,s)=>{const{__scopeScrollArea:r,...n}=t,a=Lx(oNe,r),[o,l]=S.useState(0),[i,d]=S.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 ale(t){return t?parseInt(t,10):0}function iKe(t,s){const r=t/s;return isNaN(r)?0:r}function Rue(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 E3t(t,s,r,n="ltr"){const a=Rue(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 h6e(t,s,r="ltr"){const n=Rue(s),a=s.scrollbar.paddingStart+s.scrollbar.paddingEnd,o=s.scrollbar.size-a,l=s.content-s.viewport,i=o-n,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 Oue(t,s){const r=ed(t),n=S.useRef(0);return S.useEffect(()=>()=>window.clearTimeout(n.current),[]),S.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,s)},[r,s])}function OT(t,s){const r=ed(s);ad(()=>{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,I3t=eKe,L3t=aKe;const ni=S.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(cKe,{ref:n,className:Dt("relative overflow-hidden",t),...r,children:[e.jsx(I3t,{className:"h-full w-full rounded-[inherit]",children:s}),e.jsx(Fue,{}),e.jsx(L3t,{})]}));ni.displayName=cKe.displayName;const Fue=S.forwardRef(({className:t,orientation:s="vertical",...r},n)=>e.jsx(aNe,{ref:n,orientation:s,className:Dt("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"})}));Fue.displayName=aNe.displayName;const lNe=S.createContext({});function cNe(t){const s=S.useRef(null);return s.current===null&&(s.current=t()),s.current}const D3t=typeof window<"u",dKe=D3t?S.useLayoutEffect:S.useEffect,zue=S.createContext(null);function dNe(t,s){t.indexOf(s)===-1&&t.push(s)}function ile(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,R3t=(t,s)=>r=>s(t(r)),$R=(...t)=>t.reduce(R3t),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),()=>ile(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,O3t=1e-7,F3t=12;function z3t(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)>O3t&&++iz3t(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),B3t=qR(.42,0,1,1),$3t=qR(0,0,.58,1),NKe=qR(.42,0,.58,1),q3t=t=>Array.isArray(t)&&typeof t[0]!="number",kKe=t=>Array.isArray(t)&&typeof t[0]=="number",m6e={linear:_x,easeIn:B3t,easeInOut:NKe,easeOut:$3t,circIn:mNe,circInOut:jKe,circOut:wKe,backIn:hNe,backInOut:_Ke,backOut:vKe,anticipate:bKe},U3t=t=>typeof t=="string",p6e=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(U3t(t))return FT(m6e[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),m6e[t];return t},Az=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"],f6e={value:null,addProjectionMetrics:null};function V3t(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&&f6e.value&&f6e.value.frameloop[s].push(d),d=0,r.clear(),a=!1,o&&(o=!1,p.process(f))}};return p}const H3t=40;function SKe(t,s){let r=!1,n=!0;const a={delta:0,timestamp:0,isProcessing:!1},o=()=>r=!0,l=Az.reduce((A,I)=>(A[I]=V3t(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,H3t),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:Az.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(qie===void 0&&gm.set(sh.isProcessing||ew.useManualTiming?sh.timestamp:performance.now()),qie),set:t=>{qie=t,queueMicrotask(G3t)}},CKe=t=>s=>typeof s=="string"&&s.startsWith(t),MKe=CKe("--"),W3t=CKe("var(--"),pNe=t=>W3t(t)?K3t.test(t.split("/*")[0].trim()):!1,K3t=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function x6e(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)},Ez={...GA,default:1},t8=t=>Math.round(t*1e5)/1e5,fNe=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Z3t(t){return t==null}const Y3t=/^(?:#[\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"&&Y3t.test(r)&&r.startsWith(t)||s&&!Z3t(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}},X3t=t=>p0(0,255,t),jge={...GA,transform:t=>Math.round(X3t(t))},y4={test:xNe("rgb","red"),parse:TKe("red","green","blue"),transform:({red:t,green:s,blue:r,alpha:n=1})=>"rgba("+jge.transform(t)+", "+jge.transform(s)+", "+jge.transform(r)+", "+t8(lD.transform(n))+")"};function Q3t(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:Q3t,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"),J3t=UR("vh"),e5t=UR("vw"),g6e={...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)}},t5t=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function s5t(t){var s,r;return isNaN(t)&&typeof t=="string"&&(((s=t.match(fNe))==null?void 0:s.length)||0)+(((r=t.match(t5t))==null?void 0:r.length)||0)>0}const AKe="number",EKe="color",r5t="var",n5t="var(",y6e="${}",a5t=/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(a5t,d=>(Dd.test(d)?(n.color.push(o),a.push(EKe),r.push(Dd.parse(d))):d.startsWith(n5t)?(n.var.push(o),a.push(r5t),r.push(d)):(n.number.push(o),a.push(AKe),r.push(parseFloat(d))),++o,y6e)).split(y6e);return{values:r,split:i,indexes:n,types:a}}function i5t(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,c5t=(t,s)=>typeof t=="number"?s!=null&&s.trim().endsWith("/")?t:0:l5t(t);function d5t(t){const s=zT(t);return PKe(s)(s.values.map((n,a)=>c5t(n,s.split[a])))}const Dg={test:s5t,parse:i5t,createTransformer:o5t,getAnimatableNone:d5t};function Nge(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 u5t({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=Nge(d,i,t+1/3),o=Nge(d,i,t),l=Nge(d,i,t-1/3)}return{red:Math.round(a*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:n}}function ole(t,s){return r=>r>0?s:t}const tc=(t,s,r)=>t+(s-t)*r,kge=(t,s,r)=>{const n=t*t,a=r*(s*s-n)+n;return a<0?0:Math.sqrt(a)},h5t=[P1e,y4,eM],m5t=t=>h5t.find(s=>s.test(t));function v6e(t){const s=m5t(t);if(Bue(!!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=u5t(r)),r}const _6e=(t,s)=>{const r=v6e(t),n=v6e(s);if(!r||!n)return ole(t,s);const a={...r};return o=>(a.red=kge(r.red,n.red,o),a.green=kge(r.green,n.green,o),a.blue=kge(r.blue,n.blue,o),a.alpha=tc(r.alpha,n.alpha,o),y4.transform(a))},I1e=new Set(["none","hidden"]);function p5t(t,s){return I1e.has(t)?r=>r<=0?t:s:r=>r>=1?s:t}function f5t(t,s){return r=>tc(t,s,r)}function gNe(t){return typeof t=="number"?f5t:typeof t=="string"?pNe(t)?ole:Dd.test(t)?_6e:y5t:Array.isArray(t)?IKe:typeof t=="object"?Dd.test(t)?_6e:x5t:ole}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 g5t(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?p5t(t,s):$R(IKe(g5t(n,a),a.values),r):(Bue(!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"),ole(t,s))};function LKe(t,s,r){return typeof t=="number"&&typeof s=="number"&&typeof r=="number"?tc(t,s,r):gNe(t)(t,s)}const v5t=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=lle?1/0:s}function _5t(t,s=100,r){const n=r({...t,keyframes:[0,s]}),a=Math.min(yNe(n),lle);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 b5t=12;function w5t(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 Sge-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)+Sge>0?-1:1)*((y-_)*b)/N}):(a=u=>{const p=Math.exp(-u*t),f=(u-r)*t+1;return-Sge+p*f},o=u=>{const p=Math.exp(-u*t),f=(r-u)*(t*t);return p*f});const i=5/t,d=w5t(a,o,i);if(t=gp(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 N5t=["duration","bounce"],k5t=["stiffness","damping","mass"];function b6e(t,s){return s.some(r=>t[r]!==void 0)}function S5t(t){let s={velocity:Pc.velocity,stiffness:Pc.stiffness,damping:Pc.damping,mass:Pc.mass,isResolvedFromDuration:!1,...t};if(!b6e(t,k5t)&&b6e(t,N5t))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=j5t({...t,velocity:0});s={...s,...r,mass:Pc.mass},s.isResolvedFromDuration=!0}return s}function cle(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:_}=S5t({...r,velocity:-ux(r.velocity||0)}),b=y||0,N=u/(2*Math.sqrt(d*p)),w=l-o,k=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(k,N),O=(b+N*k*w)/L,A=U=>{const te=Math.exp(-N*k*U);return l-te*(O*Math.sin(L*U)+w*Math.cos(L*U))},V=N*k*O+w*L,q=N*k*w-O*L,I=U=>Math.exp(-N*k*U)*(V*Math.sin(L*U)+q*Math.cos(L*U));else if(N===1){A=te=>l-Math.exp(-k*te)*(w+(b+k*w)*te);const U=b+k*w;I=te=>Math.exp(-k*te)*(k*U*te-b)}else{const U=k*Math.sqrt(N*N-1);A=X=>{const ce=Math.exp(-N*k*X),ae=Math.min(U*X,300);return l-ce*((b+N*k*w)*Math.sinh(ae)+U*w*Math.cosh(ae))/U};const te=(b+N*k*w)/U,Y=N*k*te-w*U,J=N*k*w-te*U;I=X=>{const ce=Math.exp(-N*k*X),ae=Math.min(U*X,300);return ce*(Y*Math.sinh(ae)+J*Math.cosh(ae))}}const B={calculatedDuration:_&&f||null,velocity:U=>gp(I(U)),next:U=>{if(!_&&N<1){const Y=Math.exp(-N*k*U),J=Math.sin(L*U),X=Math.cos(L*U),ce=l-Y*(O*J+w*X),ae=gp(Y*(V*J+q*X));return i.done=Math.abs(ae)<=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=gp(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),lle),te=DKe(Y=>B.next(U*Y).value,U,30);return U+"ms "+te},toTransition:()=>{}};return B}cle.applyToOptions=t=>{const s=_5t(t,100,cle);return t.ease=s.ease,t.duration=gp(s.duration),t.type="keyframes",t};const C5t=5;function RKe(t,s,r){const n=Math.max(s-C5t,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=>k+C(q),I=q=>{const B=C(q),U=A(q);y.done=Math.abs(B)<=u,y.value=y.done?k:U};let L,O;const V=q=>{_(y.value)&&(L=q,O=cle({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 M5t(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=M5t(s,n,a),d=i.length,u=p=>{if(l&&p1)for(;fu(p0(t[0],t[o-1],p)):u}function A5t(t,s){const r=t[t.length-1];for(let n=1;n<=s;n++){const a=oD(0,s,n);t.push(tc(r,1,a))}}function E5t(t){const s=[0];return A5t(s,t.length-1),s}function P5t(t,s){return t.map(r=>r*s)}function I5t(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=q3t(n)?n.map(p6e):p6e(n),o={done:!1,value:s[0]},l=P5t(r&&r.length===s.length?r:E5t(s),t),i=T5t(l,s,{ease:Array.isArray(a)?a:I5t(s,a)});return{calculatedDuration:t,next:d=>(o.value=i(d),o.done=d>=t,o)}}const L5t=t=>t!==null;function $ue(t,{repeat:s,repeatType:r="loop"},n,a=1){const o=t.filter(L5t),i=a<0||s&&r!=="loop"&&s%2===1?0:o.length-1;return!i||n===void 0?o[i]:n}const D5t={decay:D1e,inertia:D1e,tween:s8,keyframes:s8,spring:cle};function OKe(t){typeof t.type=="string"&&(t.type=D5t[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 R5t=t=>t/100;class dle 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(R5t,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 k=this.currentTime-u*(this.playbackSpeed>=0?1:-1),C=this.playbackSpeed>=0?k<0:k>a;this.currentTime=Math.max(k,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=$ue(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=gp(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=v5t,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 O5t(t){for(let s=1;st*180/Math.PI,R1e=t=>{const s=v4(Math.atan2(t[1],t[0]));return O1e(s)},F5t={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),w6e=R1e,j6e=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),N6e=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),z5t={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:j6e,scaleY:N6e,scale:t=>(j6e(t)+N6e(t))/2,rotateX:t=>O1e(v4(Math.atan2(t[6],t[5]))),rotateY:t=>O1e(v4(Math.atan2(-t[2],t[0]))),rotateZ:w6e,rotate:w6e,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=z5t,a=r;else{const i=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=F5t,a=i}if(!a)return F1e(s);const o=n[s],l=a[1].split(",").map($5t);return typeof o=="function"?o(l):l[o]}const B5t=(t,s)=>{const{transform:r="none"}=getComputedStyle(t);return z1e(r,s)};function $5t(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),k6e=t=>t===GA||t===na,q5t=new Set(["x","y","z"]),U5t=WA.filter(t=>!q5t.has(t));function V5t(t){const s=[];return U5t.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=V5t(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 H5t(){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])}O5t(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 G5t=t=>t.startsWith("--");function BKe(t,s,r){G5t(s)?t.style.setProperty(s,r):t.style[s]=r}const W5t={};function $Ke(t,s){const r=pKe(t);return()=>W5t[s]??r()}const K5t=$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})`,S6e={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)||S6e.easeOut):S6e[t]}function Z5t(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 Y5t({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=Y5t(s);this.animation=Z5t(r,n,a,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const p=$ue(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=gp(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&&K5t()?(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 X5t(t){return t in GKe}function Q5t(t){typeof t.ease=="string"&&X5t(t.ease)&&(t.ease=GKe[t.ease])}const Cge=10;class J5t extends HKe{constructor(s){Q5t(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 dle({...l,autoplay:!1}),d=Math.max(Cge,gm.now()-this.startTime),u=p0(0,Cge,d-Cge),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 C6e=(t,s)=>s==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Dg.test(t)||t==="0")&&!t.startsWith("url("));function eMt(t){const s=t[0];if(t.length===1)return!0;for(let r=0;rObject.hasOwnProperty.call(Element.prototype,"animate"));function iMt(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 aMt()&&r&&(WKe.has(r)||nMt.has(r)&&rMt(i))&&(r!=="transform"||!p)&&!u&&!n&&a!=="mirror"&&o!==0&&l!=="inertia"}const oMt=40;class lMt 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,k)=>this.onKeyframesResolved(N,w,y,!k),d,u,p),(b=this.keyframeResolver)==null||b.scheduleResolve()}onKeyframesResolved(s,r,n,a){var k,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;tMt(s,o,l,i)||(f=!1,(ew.instantAnimations||!d)&&(p==null||p($ue(s,n,r))),s[0]=s[s.length-1],U1e(n),n.repeat=0);const _={startTime:a?this.resolvedAt?this.resolvedAt-this.createdAt>oMt?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:r,...n,keyframes:s},b=f&&!u&&iMt(_),N=(C=(k=_.motionValue)==null?void 0:k.owner)==null?void 0:C.current;let w;if(b)try{w=new J5t({..._,element:N})}catch{w=new dle(_)}else w=new dle(_);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(),H5t()),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 cMt=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function dMt(t){const s=cMt.exec(t);if(!s)return[,];const[,r,n,a]=s;return[`--${r??n}`,a]}const uMt=4;function ZKe(t,s,r=1){FT(r<=uMt,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[n,a]=dMt(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 hMt={type:"spring",stiffness:500,damping:25,restSpeed:10},mMt=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),pMt={type:"keyframes",duration:.8},fMt={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},xMt=(t,{keyframes:s})=>s.length>2?pMt:KA.has(t)?t.startsWith("scale")?mMt(s[1]):hMt:fMt;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 gMt=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function yMt(t){for(const s in t)if(!gMt.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-gp(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};yMt(i)||Object.assign(p,xMt(t,p)),p.duration&&(p.duration=gp(p.duration)),p.repeatDelay&&(p.repeatDelay=gp(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=$ue(p.keyframes,i);if(y!==void 0){xl.update(()=>{p.onUpdate(y),p.onComplete()});return}}return i.isSync?new dle(p):new lMt(p)};function M6e(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]=M6e(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]=M6e(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]),T6e=30,vMt=t=>!isNaN(parseFloat(t));class _Mt{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=vMt(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>T6e)return 0;const r=Math.min(this.updatedAt-this.prevUpdatedAt,T6e);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 _Mt(t,s)}const V1e=t=>Array.isArray(t);function bMt(t,s,r){t.hasValue(s)?t.getValue(s).set(r):t.addValue(s,BT(r))}function wMt(t){return V1e(t)?t[t.length-1]||0:t}function jMt(t,s){const r=kS(t,s);let{transitionEnd:n={},transition:a={},...o}=r||{};o={...o,...n};for(const l in o){const i=wMt(o[l]);bMt(t,l,i)}}const ah=t=>!!(t&&t.getVelocity);function NMt(t){return!!(ah(t)&&t.add)}function H1e(t,s){const r=t.getValue("willChange");if(NMt(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 kMt="framerAppearId",QKe="data-"+NNe(kMt);function JKe(t){return t.props[QKe]}function SMt({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&&SMt(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 k=!1;if(window.MotionHandoffAnimation){const I=JKe(t);if(I){const L=window.MotionHandoffAnimation(I,y,xl);L!==null&&(N.startTime=L,k=!0)}}H1e(t,y);const C=u??t.shouldReduceMotion;_.start(wNe(y,_,b,C&&XKe.has(y)?{type:!1}:N,t,k));const A=_.animation;A&&p.push(A)}if(l){const y=()=>xl.update(()=>{l&&jMt(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 CMt(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 CMt(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 MMt(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 TMt={test:t=>t==="auto",parse:t=>t},tZe=t=>s=>s.test(t),sZe=[GA,na,o0,S_,e5t,J3t,TMt],A6e=t=>sZe.find(tZe(t));function AMt(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||mKe(t):!0}const EMt=new Set(["brightness","contrast","saturate","opacity"]);function PMt(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=EMt.has(s)?1:0;return n!==r&&(o*=100),s+"("+o+a+")"}const IMt=/\b([a-z-]*)\(.*?\)/gu,W1e={...Dg,getAnimatableNone:t=>{const s=t.match(IMt);return s?s.map(PMt).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))}},E6e={...GA,transform:Math.round},LMt={rotate:S_,rotateX:S_,rotateY:S_,rotateZ:S_,scale:Ez,scaleX:Ez,scaleY:Ez,scaleZ:Ez,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:g6e,originY:g6e,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,...LMt,zIndex:E6e,fillOpacity:lD,strokeOpacity:lD,numOctaves:E6e},DMt={...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=>DMt[t],RMt=new Set([W1e,K1e]);function nZe(t,s){let r=rZe(t);return RMt.has(r)||(r=Dg),r.getAnimatableNone?r.getAnimatableNone(s):void 0}const OMt=new Set(["auto","none","0"]);function FMt(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 Uie(t){return hKe(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const{schedule:CNe,cancel:iAs}=SKe(queueMicrotask,!1),ug={x:!1,y:!1};function iZe(){return ug.x||ug.y}function BMt(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 $Mt(t){return!(t.pointerType==="touch"||iZe())}function qMt(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(!$Mt(w))return;d=!1;const k=s(l,w);typeof k=="function"&&(u=k,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,UMt=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function VMt(t){return UMt.has(t.tagName)||t.isContentEditable===!0}const HMt=new Set(["INPUT","SELECT","TEXTAREA"]);function GMt(t){return HMt.has(t.tagName)||t.isContentEditable===!0}const Vie=new WeakSet;function P6e(t){return s=>{s.key==="Enter"&&t(s)}}function Mge(t,s){t.dispatchEvent(new PointerEvent("pointer"+s,{isPrimary:!0,bubbles:!0}))}const WMt=(t,s)=>{const r=t.currentTarget;if(!r)return;const n=P6e(()=>{if(Vie.has(r))return;Mge(r,"down");const a=P6e(()=>{Mge(r,"up")}),o=()=>Mge(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 I6e(t){return MNe(t)&&!iZe()}const L6e=new WeakSet;function KMt(t,s,r={}){const[n,a,o]=oZe(t,r),l=i=>{const d=i.currentTarget;if(!I6e(i)||L6e.has(i))return;Vie.add(d),r.stopPropagation&&L6e.add(i);const u=s(d,i),p=(_,b)=>{window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",y),Vie.has(d)&&Vie.delete(d),I6e(_)&&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),Uie(i)&&(i.addEventListener("focus",u=>WMt(u,a)),!VMt(i)&&!i.hasAttribute("tabindex")&&(i.tabIndex=0))}),o}function TNe(t){return hKe(t)&&"ownerSVGElement"in t}const Hie=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],ZMt=cZe("inline","width","offsetWidth"),YMt=cZe("block","height","offsetHeight");function XMt({target:t,borderBoxSize:s}){var r;(r=Hie.get(t))==null||r.forEach(n=>{n(t,{get width(){return ZMt(t,s)},get height(){return YMt(t,s)}})})}function QMt(t){t.forEach(XMt)}function JMt(){typeof ResizeObserver>"u"||(C_=new ResizeObserver(QMt))}function eTt(t,s){C_||JMt();const r=SNe(t);return r.forEach(n=>{let a=Hie.get(n);a||(a=new Set,Hie.set(n,a)),a.add(s),C_==null||C_.observe(n)}),()=>{r.forEach(n=>{const a=Hie.get(n);a==null||a.delete(s),a!=null&&a.size||C_==null||C_.unobserve(n)})}}const Gie=new Set;let tM;function tTt(){tM=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};Gie.forEach(s=>s(t))},window.addEventListener("resize",tM)}function sTt(t){return Gie.add(t),tM||tTt(),()=>{Gie.delete(t),!Gie.size&&typeof tM=="function"&&(window.removeEventListener("resize",tM),tM=void 0)}}function D6e(t,s){return typeof t=="function"?sTt(t):eTt(t,s)}function rTt(t){return TNe(t)&&t.tagName==="svg"}const nTt=[...sZe,Dd,Dg],aTt=t=>nTt.find(tZe(t)),R6e=()=>({translate:0,scale:1,origin:0,originPoint:0}),sM=()=>({x:R6e(),y:R6e()}),O6e=()=>({min:0,max:0}),tu=()=>({x:O6e(),y:O6e()}),iTt=new WeakMap;function que(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 Uue(t){return que(t.animate)||ENe.some(s=>cD(t[s]))}function dZe(t){return!!(Uue(t)||t.variants)}function oTt(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},lTt=typeof window<"u";function cTt(){if(uZe.current=!0,!!lTt)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 F6e=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let ule={};function hZe(t){ule=t}function dTt(){return ule}class uTt{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=Uue(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,iTt.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||cTt(),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:gp(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 ule){const r=ule[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):!aTt(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 uTt{constructor(){super(...arguments),this.KeyframeResolver=zMt}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 hTt({x:t,y:s}){return{top:s.min,right:t.max,bottom:s.max,left:t.min}}function mTt(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 Tge(t){return t===void 0||t===1}function Y1e({scale:t,scaleX:s,scaleY:r}){return!Tge(t)||!Tge(s)||!Tge(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 z6e(t.x)||z6e(t.y)}function z6e(t){return t&&t!=="0%"}function hle(t,s,r){const n=t-r,a=s*n;return r+a}function B6e(t,s,r,n,a){return a!==void 0&&(t=hle(t,a,n)),hle(t,r,n)+s}function X1e(t,s=0,r=1,n,a){t.min=B6e(t.min,s,r,n,a),t.max=B6e(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 $6e=.999999999999,q6e=1.0000000000001;function pTt(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;d$6e&&(s.x=1),s.y$6e&&(s.y=1)}function Oy(t,s){t.min+=s,t.max+=s}function U6e(t,s,r,n,a=.5){const o=tc(t.min,t.max,a);X1e(t,s,r,o,n)}function V6e(t,s){return typeof t=="string"?parseFloat(t)/100*(s.max-s.min):t}function Wie(t,s,r){const n=r??t;U6e(t.x,V6e(s.x,n.x),s.scaleX,s.scale,s.originX),U6e(t.y,V6e(s.y,n.y),s.scaleY,s.scale,s.originY)}function gZe(t,s){return pZe(mTt(t.getBoundingClientRect(),s))}function fTt(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 xTt={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},gTt=WA.length;function yTt(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=H6e(t,s.target.x),n=H6e(t,s.target.y);return`${r}% ${n}%`}},vTt={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=tc(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:vTt};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 _Tt(t){return window.getComputedStyle(t)}class bTt 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):B5t(s,r);{const a=_Tt(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 wTt={offset:"stroke-dashoffset",array:"stroke-dasharray"},jTt={offset:"strokeDashoffset",array:"strokeDasharray"};function NTt(t,s,r=1,n=0,a=!0){t.pathLength=1;const o=a?wTt:jTt;t[o.offset]=`${-n}`,t[o.array]=`${s} ${r}`}const kTt=["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 kTt)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&&NTt(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 STt(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 CTt 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){STt(s,r,n,a)}mount(s){this.isSVGTag=wZe(s.tagName),super.mount(s)}}const MTt=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})=>MMt(t,r,n)))}function PTt(t){let s=ETt(t),r=G6e(),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 k=0;kN&&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],ye=J[oe];if(b.hasOwnProperty(oe))continue;let he=!1;V1e(me)&&V1e(ye)?he=!kZe(me,ye):he=me!==ye,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 ae=V&&q;B&&(!ae||U)&&y.push(...te.map(oe=>{const me={type:C};if(typeof oe=="string"&&(n||a)&&!ae&&t.manuallyAnimateOnMount&&t.parent){const{parent:ye}=t,he=kS(ye,oe);if(ye.enteringChildren&&he){const{delayChildren:ge}=he.transition||{};me.delay=KKe(ye.enteringChildren,t,ge)}}return{animation:oe,options:me}}))}if(_.size){const k={};if(typeof p.initial!="boolean"){const C=kS(t,Array.isArray(p.initial)?p.initial[0]:p.initial);C&&C.transition&&(k.transition=C.transition)}_.forEach(C=>{const A=t.getBaseTarget(C),I=t.getValue(C);I&&(I.liveStyle=!0),k[C]=A??null}),y.push({animation:k})}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=G6e(),a=!0}}}function ITt(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 G6e(){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 W6e(t,s){t.translate=s.translate,t.scale=s.scale,t.originPoint=s.originPoint,t.origin=s.origin}const SZe=1e-4,LTt=1-SZe,DTt=1+SZe,CZe=.01,RTt=0-CZe,OTt=0+CZe;function ym(t){return t.max-t.min}function FTt(t,s,r){return Math.abs(t-s)<=r}function K6e(t,s,r,n=.5){t.origin=n,t.originPoint=tc(s.min,s.max,t.origin),t.scale=ym(r)/ym(s),t.translate=tc(r.min,r.max,t.origin)-t.originPoint,(t.scale>=LTt&&t.scale<=DTt||isNaN(t.scale))&&(t.scale=1),(t.translate>=RTt&&t.translate<=OTt||isNaN(t.translate))&&(t.translate=0)}function r8(t,s,r,n){K6e(t.x,s.x,r.x,n?n.originX:void 0),K6e(t.y,s.y,r.y,n?n.originY:void 0)}function Z6e(t,s,r,n=0){const a=n?tc(r.min,r.max,n):r.min;t.min=a+s.min,t.max=t.min+ym(s)}function zTt(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=0){const a=n?tc(r.min,r.max,n):r.min;t.min=s.min-a,t.max=t.min+ym(s)}function mle(t,s,r,n){Y6e(t.x,s.x,r.x,n==null?void 0:n.x),Y6e(t.y,s.y,r.y,n==null?void 0:n.y)}function X6e(t,s,r,n,a){return t-=s,t=hle(t,1/r,n),a!==void 0&&(t=hle(t,1/a,n)),t}function BTt(t,s=0,r=1,n=.5,a,o=t,l=t){if(o0.test(s)&&(s=parseFloat(s),s=tc(l.min,l.max,s/100)-l.min),typeof s!="number")return;let i=tc(o.min,o.max,n);t===o&&(i-=s),t.min=X6e(t.min,s,r,i,a),t.max=X6e(t.max,s,r,i,a)}function Q6e(t,s,[r,n,a],o,l){BTt(t,s[r],s[n],s[a],s.scale,o,l)}const $Tt=["x","scaleX","originX"],qTt=["y","scaleY","originY"];function J6e(t,s,r,n){Q6e(t.x,s,$Tt,r?r.x:void 0,n?n.x:void 0),Q6e(t.y,s,qTt,r?r.y:void 0,n?n.y:void 0)}function eIe(t){return t.translate===0&&t.scale===1}function MZe(t){return eIe(t.x)&&eIe(t.y)}function tIe(t,s){return t.min===s.min&&t.max===s.max}function UTt(t,s){return tIe(t.x,s.x)&&tIe(t.y,s.y)}function sIe(t,s){return Math.round(t.min)===Math.round(s.min)&&Math.round(t.max)===Math.round(s.max)}function TZe(t,s){return sIe(t.x,s.x)&&sIe(t.y,s.y)}function rIe(t){return ym(t.x)/ym(t.y)}function nIe(t,s){return t.translate===s.translate&&t.scale===s.scale&&t.originPoint===s.originPoint}function My(t){return[t("x"),t("y")]}function VTt(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"],HTt=AZe.length,aIe=t=>typeof t=="string"?parseFloat(t):t,iIe=t=>typeof t=="number"||na.test(t);function GTt(t,s,r,n,a,o){a?(t.opacity=tc(0,r.opacity??1,WTt(n)),t.opacityExit=tc(s.opacity??1,0,KTt(n))):o&&(t.opacity=tc(s.opacity??1,r.opacity??1,n));for(let l=0;lns?1:r(oD(t,s,n))}function ZTt(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 YTt=(t,s)=>t.depth-s.depth;class XTt{constructor(){this.children=[],this.isDirty=!1}add(s){dNe(this.children,s),this.isDirty=!0}remove(s){ile(this.children,s),this.isDirty=!0}forEach(s){this.isDirty&&this.children.sort(YTt),this.isDirty=!1,this.children.forEach(s)}}function QTt(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 Kie(t){return ah(t)?t.get():t}class JTt{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&&(ile(this.members,n),n.unmount())}s.scheduleRender()}remove(s){if(ile(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 Zie={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Age=["","X","Y","Z"],eAt=1e3;let tAt=0;function Ege(t,s,r,n){const{latestValues:a}=s;a[t]&&(r[t]=a[t],s.setStaticValue(t,0),n&&(n[t]=0))}function 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=tAt++,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(nAt),this.nodes.forEach(dAt),this.nodes.forEach(uAt),this.nodes.forEach(aAt)},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=QTt(y,250),Zie.hasAnimatedSinceResize&&(Zie.hasAnimatedSinceResize=!1,this.nodes.forEach(dIe)))})}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()||xAt,{onLayoutAnimationStart:N,onLayoutAnimationComplete:w}=u.getProps(),k=!this.targetLayout||!TZe(this.targetLayout,_),C=!f&&y;if(this.options.layoutRoot||this.resumeFrom||C||f&&(k||!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||dIe(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(hAt),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;uIe(f.x,l.x,L),uIe(f.y,l.y,L),this.setTargetDelta(f),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(mle(y,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),pAt(this.relativeTarget,this.relativeTargetOrigin,y,L),A&&UTt(this.relativeTarget,A)&&(this.isProjectionDirty=!1),A||(A=tu()),og(A,this.relativeTarget)),N&&(this.animationValues=p,GTt(p,u,this.latestValues,L,C,k)),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(()=>{Zie.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=BT(0)),this.motionValue.jump(0,!1),this.currentAnimation=ZTt(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(eAt),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),Wie(i,p),r8(this.projectionDeltaWithTransform,this.layoutCorrected,i,p)}}registerSharedNode(l,i){this.sharedNodes.has(l)||this.sharedNodes.set(l,new JTt),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&&Ege("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(lIe),this.root.sharedNodes.clear()}}}function sAt(t){t.updateLayout()}function rAt(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();mle(N,s.layoutBox,y.layoutBox,b);const w=tu();mle(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 nAt(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 aAt(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function iAt(t){t.clearSnapshot()}function lIe(t){t.clearMeasurements()}function oAt(t){t.isLayoutDirty=!0,t.updateLayout()}function cIe(t){t.isLayoutDirty=!1}function lAt(t){t.isAnimationBlocked&&t.layout&&!t.isLayoutDirty&&(t.snapshot=t.layout,t.isLayoutDirty=!0)}function cAt(t){const{visualElement:s}=t.options;s&&s.getProps().onBeforeLayoutMeasure&&s.notify("BeforeLayoutMeasure"),t.resetTransform()}function dIe(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function dAt(t){t.resolveTargetDelta()}function uAt(t){t.calcProjection()}function hAt(t){t.resetSkewAndRotation()}function mAt(t){t.removeLeadSnapshot()}function uIe(t,s,r){t.translate=tc(s.translate,0,r),t.scale=tc(s.scale,1,r),t.origin=s.origin,t.originPoint=s.originPoint}function hIe(t,s,r,n){t.min=tc(s.min,r.min,n),t.max=tc(s.max,r.max,n)}function pAt(t,s,r,n){hIe(t.x,s.x,r.x,n),hIe(t.y,s.y,r.y,n)}function fAt(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const xAt={duration:.45,ease:[.4,0,.1,1]},mIe=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),pIe=mIe("applewebkit/")&&!mIe("chrome/")?Math.round:_x;function fIe(t){t.min=pIe(t.min),t.max=pIe(t.max)}function gAt(t){fIe(t.x),fIe(t.y)}function LZe(t,s,r){return t==="position"||t==="preserve-aspect"&&!FTt(rIe(s),rIe(r),.2)}function yAt(t){var s;return t!==t.root&&((s=t.scroll)==null?void 0:s.wasRoot)}const vAt=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}),Pge={current:void 0},DZe=IZe({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Pge.current){const t=new vAt({});t.mount(window),t.setOptions({layoutScroll:!0}),Pge.current=t}return Pge.current},resetTransform:(t,s)=>{t.style.transform=s!==void 0?s:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),LNe=S.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function xIe(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function _At(...t){return s=>{let r=!1;const n=t.map(a=>{const o=xIe(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:k,bottom:C}=d.current;if(s||o===!1||!i.current||!_||!b)return;const A=r==="left"?`left: ${w}`:`right: ${k}`,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(wAt,{isPresent:s,childRef:i,sizeRef:d,pop:o,children:o===!1?t:S.cloneElement(t,{ref:f})})}const NAt=({children:t,initial:s,isPresent:r,onExitComplete:n,custom:a,presenceAffectsLayout:o,mode:l,anchorX:i,anchorY:d,root:u})=>{const p=cNe(kAt),f=S.useId();let y=!0,_=S.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&&(_={..._}),S.useMemo(()=>{p.forEach((b,N)=>p.set(N,!1))},[r]),S.useEffect(()=>{!r&&!p.size&&n&&n()},[r]),t=e.jsx(jAt,{pop:l==="popLayout",isPresent:r,anchorX:i,anchorY:d,root:u,children:t}),e.jsx(zue.Provider,{value:_,children:t})};function kAt(){return new Map}function RZe(t=!0){const s=S.useContext(zue);if(s===null)return[!0,null];const{isPresent:r,onExitComplete:n,register:a}=s,o=S.useId();S.useEffect(()=>{if(t)return a(o)},[t]);const l=S.useCallback(()=>t&&n&&n(o),[o,n,t]);return!r&&n?[!1,l]:[!0]}const Pz=t=>t.key||"";function gIe(t){const s=[];return S.Children.forEach(t,r=>{S.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=S.useMemo(()=>gIe(t),[t]),_=l&&!p?[]:y.map(Pz),b=S.useRef(!0),N=S.useRef(y),w=cNe(()=>new Map),k=S.useRef(new Set),[C,A]=S.useState(y),[I,L]=S.useState(y);dKe(()=>{b.current=!1,N.current=y;for(let q=0;q{const B=Pz(q),U=l&&!p?!1:y===I||_.includes(B),te=()=>{if(k.current.has(B))return;if(w.has(B))k.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(NAt,{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=S.createContext({strict:!1}),yIe={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 vIe=!1;function SAt(){if(vIe)return;const t={};for(const s in yIe)t[s]={isEnabled:r=>yIe[s].some(n=>!!r[n])};hZe(t),vIe=!0}function FZe(){return SAt(),dTt()}function CAt(t){const s=FZe();for(const r in t)s[r]={...s[r],...t[r]};hZe(s)}const MAt=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 ple(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||MAt.has(t)}let zZe=t=>!ple(t);function TAt(t){typeof t=="function"&&(zZe=s=>s.startsWith("on")?!ple(s):t(s))}try{TAt(require("@emotion/is-prop-valid").default)}catch{}function AAt(t,s,r){const n={};for(const a in t)a==="values"&&typeof t.values=="object"||ah(t[a])||(zZe(a)||r===!0&&ple(a)||!s&&!ple(a)||t.draggable&&a.startsWith("onDrag"))&&(n[a]=t[a]);return n}const Vue=S.createContext({});function EAt(t,s){if(Uue(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 PAt(t){const{initial:s,animate:r}=EAt(t,S.useContext(Vue));return S.useMemo(()=>({initial:s,animate:r}),[_Ie(s),_Ie(r)])}function _Ie(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 IAt({transformTemplate:t},s){return S.useMemo(()=>{const r=RNe();return PNe(r,s,t),Object.assign({},r.vars,r.style)},[s])}function LAt(t,s){const r=t.style||{},n={};return BZe(n,r,t),Object.assign(n,IAt(t,s)),n}function DAt(t,s){const r={},n=LAt(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 RAt(t,s,r,n){const a=S.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 OAt=["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:!!(OAt.indexOf(t)>-1||/[A-Z]/u.test(t))}function FAt(t,s,r,{latestValues:n},a,o=!1,l){const d=(l??ONe(t)?RAt:DAt)(s,n,a,t),u=AAt(s,typeof t=="string",o),p=t!==S.Fragment?{...u,...d,ref:r}:{},{children:f}=s,y=S.useMemo(()=>ah(f)?f.get():f,[f]);return S.createElement(t,{...p,children:y})}function zAt({scrapeMotionValuesFromProps:t,createRenderState:s},r,n,a){return{latestValues:BAt(r,n,a,t),renderState:s()}}function BAt(t,s,r,n){const a={},o=n(t,{});for(const y in o)a[y]=Kie(o[y]);let{initial:l,animate:i}=t;const d=Uue(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"&&!que(f)){const y=Array.isArray(f)?f:[f];for(let _=0;_(s,r)=>{const n=S.useContext(Vue),a=S.useContext(zue),o=()=>zAt(t,s,n,a);return r?o():cNe(o)},$At=qZe({scrapeMotionValuesFromProps:INe,createRenderState:RNe}),qAt=qZe({scrapeMotionValuesFromProps:jZe,createRenderState:$Ze}),UAt=Symbol.for("motionComponentSymbol");function VAt(t,s,r){const n=S.useRef(r);S.useInsertionEffect(()=>{n.current=r});const a=S.useRef(null);return S.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=S.createContext({});function I5(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function HAt(t,s,r,n,a,o){var A,I;const{visualElement:l}=S.useContext(Vue),i=S.useContext(OZe),d=S.useContext(zue),u=S.useContext(LNe),p=u.reducedMotion,f=u.skipAnimations,y=S.useRef(null),_=S.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=S.useContext(UZe);b&&!b.projection&&a&&(b.type==="html"||b.type==="svg")&&GAt(y.current,r,a,N);const w=S.useRef(!1);S.useInsertionEffect(()=>{b&&w.current&&b.update(r,d)});const k=r[QKe],C=S.useRef(!!k&&typeof window<"u"&&!((A=window.MotionHandoffIsComplete)!=null&&A.call(window,k))&&((I=window.MotionHasOptimisedAnimation)==null?void 0:I.call(window,k)));return dKe(()=>{_.current=!0,b&&(w.current=!0,window.MotionIsMounted=!0,b.updateFeatures(),b.scheduleRenderMicrotask(),C.current&&b.animationState&&b.animationState.animateChanges())}),S.useEffect(()=>{b&&(!C.current&&b.animationState&&b.animationState.animateChanges(),C.current&&(queueMicrotask(()=>{var L;(L=window.MotionHandoffMarkAsComplete)==null||L.call(window,k)}),C.current=!1),b.enteringChildren=void 0)}),b}function GAt(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 Ige(t,{forwardMotionProps:s=!1,type:r}={},n,a){n&&CAt(n);const o=r?r==="svg":ONe(t),l=o?qAt:$At;function i(u,p){let f;const y={...S.useContext(LNe),...u,layoutId:WAt(u)},{isStatic:_}=y,b=PAt(u),N=l(u,_);if(!_&&typeof window<"u"){KAt();const w=ZAt(y);f=w.MeasureLayout,b.visualElement=HAt(t,N,y,a,w.ProjectionNode,o)}return e.jsxs(Vue.Provider,{value:b,children:[f&&b.visualElement?e.jsx(f,{visualElement:b.visualElement,...y}):null,FAt(t,u,VAt(N,b.visualElement,p),N,_,s,o)]})}i.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const d=S.forwardRef(i);return d[UAt]=t,d}function WAt({layoutId:t}){const s=S.useContext(lNe).id;return s&&t!==void 0?s+"-"+t:t}function KAt(t,s){S.useContext(OZe).strict}function ZAt(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 YAt(t,s){if(typeof Proxy>"u")return Ige;const r=new Map,n=(o,l)=>Ige(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,Ige(l,void 0,t,s)),r.get(l))})}const XAt=(t,s)=>s.isSVG??ONe(t)?new CTt(s):new bTt(s,{allowProjection:t!==S.Fragment});class QAt extends yw{constructor(s){super(s),s.animationState||(s.animationState=PTt(s))}updateAnimationControlsSubscription(){const{animate:s}=this.node.getProps();que(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 JAt=0;class eEt extends yw{constructor(){super(...arguments),this.id=JAt++,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 tEt={animation:{Feature:QAt},exit:{Feature:eEt}};function VR(t){return{point:{x:t.pageX,y:t.pageY}}}const sEt=t=>s=>MNe(s)&&t(s,VR(s));function n8(t,s,r,n){return dD(t,s,sEt(r),n)}const HZe=({current:t})=>t?t.ownerDocument.defaultView:null,bIe=(t,s)=>Math.abs(t-s);function rEt(t,s){const r=bIe(t.x,s.x),n=bIe(t.y,s.y);return Math.sqrt(r**2+n**2)}const wIe=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=Iz(this.lastRawMoveEventInfo,this.transformPagePoint));const _=Lge(this.lastMoveEventInfo,this.history),b=this.startEvent!==null,N=rEt(_.offset,{x:0,y:0})>=this.distanceThreshold;if(!b&&!N)return;const{point:w}=_,{timestamp:k}=sh;this.history.push({...w,timestamp:k});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=Iz(b,this.transformPagePoint),xl.update(this.updatePoint,!0)},this.handlePointerUp=(_,b)=>{this.end();const{onEnd:N,onSessionEnd:w,resumeAnimation:k}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&k&&k(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const C=Lge(_.type==="pointercancel"?this.lastMoveEventInfo:Iz(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=Iz(d,this.transformPagePoint),{point:p}=u,{timestamp:f}=sh;this.history=[{...p,timestamp:f}];const{onSessionStart:y}=r;y&&y(s,Lge(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);(wIe.has(n.overflowX)||wIe.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 Iz(t,s){return s?{point:s(t.point)}:t}function jIe(t,s){return{x:t.x-s.x,y:t.y-s.y}}function Lge({point:t},s){return{point:t,delta:jIe(t,WZe(s)),offset:jIe(t,nEt(s)),velocity:aEt(s,.1)}}function nEt(t){return t[0]}function WZe(t){return t[t.length-1]}function aEt(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>gp(s)));)r--;if(!n)return{x:0,y:0};n===t[0]&&t.length>2&&a.timestamp-n.timestamp>gp(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 iEt(t,{min:s,max:r},n){return s!==void 0&&tr&&(t=n?tc(r,t,n.max):Math.min(t,r)),t}function NIe(t,s,r){return{min:s!==void 0?t.min+s:void 0,max:r!==void 0?t.max+r-(t.max-t.min):void 0}}function oEt(t,{top:s,left:r,bottom:n,right:a}){return{x:NIe(t.x,r,a),y:NIe(t.y,s,n)}}function kIe(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 dEt(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 uEt(t=e_e){return t===!1?t=0:t===!0&&(t=e_e),{x:SIe(t,"left","right"),y:SIe(t,"top","bottom")}}function SIe(t,s,r){return{min:CIe(t,s),max:CIe(t,r)}}function CIe(t,s){return typeof t=="number"?t:t[s]||0}const hEt=new WeakMap;class mEt{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=BMt(_),!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(k=>{let C=this.getAxisMotionValue(k).get()||0;if(o0.test(C)){const{projection:A}=this.visualElement;if(A&&A.layout){const I=A.layout.layoutBox[k];I&&(C=ym(I)*(parseFloat(C)/100))}}this.originPoint[k]=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:k}=y;if(b&&this.currentDirection===null){this.currentDirection=fEt(k),this.currentDirection!==null&&N&&N(this.currentDirection);return}this.updateAxis("x",y.point,k),this.updateAxis("y",y.point,k),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||!Lz(s,a,this.currentDirection))return;const o=this.getAxisMotionValue(s);let l=this.originPoint[s]+n[s];this.constraints&&this.constraints[s]&&(l=iEt(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=oEt(n.layoutBox,s):this.constraints=!1,this.elastic=uEt(r),a!==this.constraints&&!I5(s)&&n&&this.constraints&&!this.hasMutatedConstraints&&My(l=>{this.constraints!==!1&&this.getAxisMotionValue(l)&&(this.constraints[l]=dEt(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=fTt(n,a.root,this.visualElement.getTransformPagePoint());let l=lEt(a.layout.layoutBox,o);if(r){const i=r(hTt(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(!Lz(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(!Lz(r,n,this.currentDirection))return;const{projection:a}=this.visualElement,o=this.getAxisMotionValue(r);if(a&&a.layout){const{min:l,max:i}=a.layout.layoutBox[r],d=o.get()||0;o.set(s[r]-tc(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]=cEt({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(!Lz(l,s,null))return;const i=this.getAxisMotionValue(l),{min:d,max:u}=this.constraints[l];i.set(tc(d,u,a[l]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;hEt.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&&GMt(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=pEt(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 MIe(t){let s=!0;return()=>{if(s){s=!1;return}t()}}function pEt(t,s,r){const n=D6e(t,MIe(r)),a=D6e(s,MIe(r));return()=>{n(),a()}}function Lz(t,s,r){return(s===!0||s===t)&&(r===null||r===t)}function fEt(t,s=10){let r=null;return Math.abs(t.y)>s?r="y":Math.abs(t.x)>s&&(r="x"),r}class xEt extends yw{constructor(s){super(s),this.removeGroupControls=_x,this.removeListeners=_x,this.controls=new mEt(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 Dge=t=>(s,r)=>{t&&xl.update(()=>t(s,r),!1,!0)};class gEt 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:Dge(s),onStart:Dge(r),onMove:Dge(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 Rge=!1;class yEt extends S.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),Rge&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Zie.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}),Rge=!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;Rge=!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=S.useContext(lNe);return e.jsx(yEt,{...t,layoutGroup:n,switchLayoutGroup:S.useContext(UZe),isPresent:s,safeToRemove:r})}const vEt={pan:{Feature:gEt},drag:{Feature:xEt,ProjectionNode:DZe,MeasureLayout:KZe}};function TIe(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 _Et extends yw{mount(){const{current:s}=this.node;s&&(this.unmount=qMt(s,(r,n)=>(TIe(this.node,n,"Start"),a=>TIe(this.node,a,"End"))))}unmount(){}}class bEt 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 AIe(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 wEt extends yw{mount(){const{current:s}=this.node;if(!s)return;const{globalTapTarget:r,propagate:n}=this.node.props;this.unmount=KMt(s,(a,o)=>(AIe(this.node,o,"Start"),(l,{success:i})=>AIe(this.node,l,i?"End":"Cancel")),{useGlobalTarget:r,stopPropagation:(n==null?void 0:n.tap)===!1})}unmount(){}}const t_e=new WeakMap,Oge=new WeakMap,jEt=t=>{const s=t_e.get(t.target);s&&s(t)},NEt=t=>{t.forEach(jEt)};function kEt({root:t,...s}){const r=t||document;Oge.has(r)||Oge.set(r,{});const n=Oge.get(r),a=JSON.stringify(s);return n[a]||(n[a]=new IntersectionObserver(NEt,{root:t,...s})),n[a]}function SEt(t,s,r){const n=kEt(s);return t_e.set(t,r),n.observe(t),()=>{t_e.delete(t),n.unobserve(t)}}const CEt={some:0,all:1};class MEt 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:CEt[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=SEt(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(TEt(s,r))&&this.startObserver()}unmount(){var s;(s=this.stopObserver)==null||s.call(this),this.hasEnteredView=!1,this.isInView=!1}}function TEt({viewport:t={}},{viewport:s={}}={}){return r=>t[r]!==s[r]}const AEt={inView:{Feature:MEt},tap:{Feature:wEt},focus:{Feature:bEt},hover:{Feature:_Et}},EEt={layout:{ProjectionNode:DZe,MeasureLayout:KZe}},PEt={...tEt,...AEt,...vEt,...EEt},dr=YAt(PEt,XAt),IEt={some:0,all:1};function LEt(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:IEt[a]});return o.forEach(u=>d.observe(u)),()=>d.disconnect()}function DEt(t,{root:s,margin:r,amount:n,once:a=!1,initial:o=!1}={}){const[l,i]=S.useState(o);return S.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 LEt(t.current,d,u)},[s,t,r,a,n]),l}function REt(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 EIe(t){return t.visitor_intent==="buying"&&!t.has_agent}function OEt({token:t}={}){var b;const s=ao(),r=t||s.token,{data:n,isLoading:a,isError:o}=b3t(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(S.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(EIe).length)||0,_=N=>{if(!N)return"";const[w,k]=N.split(":"),C=parseInt(w);return`${C>12?C-12:C||12}:${k} ${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(or,{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(Sn,{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:gs(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(ni,{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 k=REt(N.visitor_intent),C=EIe(N);return e.jsxs(dr.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 ${k.color}`,children:[k.emoji," ",k.label]}),e.jsx("span",{className:"text-white/30 text-xs",children:gs(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 FEt(){const s=Bl().pathname.slice(1);if(S.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(OEt,{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 zEt({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(Sn,{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(Ol,{className:"w-4 h-4 text-[#406E71]"}),e.jsx("span",{className:"text-sm font-medium text-[#406E71]",children:"Text"})]})]})})})]})}function BEt({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(Ga,{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 UEt(t,s){const r=gs(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 VEt(t,s){const r=gs(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 HEt({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:an,color:"text-amber-600 bg-amber-50"},{label:"Appraisal",date:n,icon:Sn,color:"text-purple-600 bg-purple-50"},{label:a?"Closed":"Target Close",date:a||t,icon:ln,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(UEt(i,p),"_blank");else{const f=VEt(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:[gs(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 GEt({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(yn,{className:"w-4 h-4 text-slate-500 group-hover:text-blue-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-slate-700 truncate",children:n.file_name}),e.jsx("p",{className:"text-xs text-slate-400",children:s(n.file_size)})]}),e.jsx(Qa,{className:"w-4 h-4 text-slate-300 group-hover:text-blue-500 transition-colors"})]},n.id))})]})}function WEt({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:gs(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 KEt({portal:t,dealData:s,agentProfile:r,customQuestions:n,deviceFingerprint:a,onComplete:o}){var b,N;const[l,i]=S.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]=S.useState({}),[p,f]=S.useState(!1),y=Et({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(Le,{required:!0,value:l.first_name,onChange:w=>i(k=>({...k,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(Le,{value:l.last_name,onChange:w=>i(k=>({...k,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(Le,{type:"email",value:l.email,onChange:w=>i(k=>({...k,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(Le,{type:"tel",value:l.phone,onChange:w=>i(k=>({...k,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(k=>({...k,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(k=>({...k,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(Le,{required:w.is_required,value:d[w.id]||"",onChange:k=>u(C=>({...C,[w.id]:k.target.value})),className:"mt-1 rounded-xl"}),w.field_type==="textarea"&&e.jsx("textarea",{required:w.is_required,value:d[w.id]||"",onChange:k=>u(C=>({...C,[w.id]:k.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:k=>u(C=>({...C,[w.id]:k.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(k=>e.jsx("option",{value:k,children:k},k))]}),w.field_type==="toggle"&&e.jsx("div",{className:"mt-1.5 flex gap-2",children:["Yes","No"].map(k=>e.jsx("button",{type:"button",onClick:()=>u(C=>({...C,[w.id]:k})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${d[w.id]===k?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200"}`,children:k},k))})]},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(k=>({...k,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(Le,{value:l.spouse_first_name,onChange:w=>i(k=>({...k,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(Le,{value:l.spouse_last_name,onChange:w=>i(k=>({...k,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(Le,{type:"email",value:l.spouse_email,onChange:w=>i(k=>({...k,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(Le,{type:"tel",value:l.spouse_phone,onChange:w=>i(k=>({...k,spouse_phone:w.target.value})),className:"mt-1 rounded-xl"})]})]})]}),e.jsx(K,{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 ZEt(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 YEt(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 XEt({portalId:t,portalSlug:s,ownerUserId:r,rewardText:n,ctaHeadline:a,agentName:o,clientName:l,reviewUrl:i,hubVideoUrl:d}){const[u,p]=S.useState(!1),f=S.useRef(!1),y=ZEt(s);S.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}`},k=()=>{_("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?YEt(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(yi,{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(Ga,{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(Ol,{className:"w-3.5 h-3.5"}),"Text"]}),e.jsxs("button",{onClick:k,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(Wa,{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(Ga,{className:"w-4 h-4 text-slate-400"})]})})]})}function QEt(t){return t==="buy-side"?"Home Search in Progress":t==="listing"?"Your Home Is On The Market":"Active Phase"}function JEt(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 ePt={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:QEt(t),description:JEt(t)};const r=ePt[s];return{key:s,label:r.label,description:r.description}})}function PIe(t){if(!t)return 0;const s=ZZe.indexOf(t);return s>=0?s:0}function tPt(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 sPt(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,ae,ie;const[s,r]=S.useState(!1),[n,a]=S.useState("primary"),[o]=S.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});S.useEffect(()=>(document.body.classList.add("client-portal-page"),()=>document.body.classList.remove("client-portal-page")),[]);const{data:l,isLoading:i,error:d}=tPt(t,!0),u=l==null?void 0:l.linked_portal_id,{data:p}=sPt(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:k}=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(ks,{className:"h-48 w-full rounded-2xl"}),e.jsx(ks,{className:"h-10 w-48 mx-auto"}),e.jsx(ks,{className:"h-32 w-full rounded-2xl"}),e.jsx(ks,{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(KEt,{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(Sn,{className:"w-3.5 h-3.5"}):e.jsx(pp,{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(zEt,{dealData:_==null?void 0:_.deal_pipeline,agentProfile:y,welcomeMessage:_==null?void 0:_.welcome_message,isWon:(ie=(ae=_==null?void 0:_.deal_pipeline)==null?void 0:ae.deal_pipeline_stages)==null?void 0:ie.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(rPt,{portal:_,updates:N,documents:k,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 rPt({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 k,C;return{key:`custom-${w}`,label:N.label||((k=p[w])==null?void 0:k.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(PIe(l==null?void 0:l.name),p.length-1):PIe(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(XEt,{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($Et,{targetCloseDate:o==null?void 0:o.target_close_date,actualCloseDate:o==null?void 0:o.actual_close_date,clientName:t.client_name}),e.jsx(BEt,{journeyStages:p,currentIndex:f}),y&&e.jsx(qEt,{currentStage:y,nextStepText:t.next_step_text,nextStepVideoUrl:_||t.next_step_video_url}),e.jsx(HEt,{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(GEt,{documents:r}),s&&s.length>0&&e.jsx(WEt,{updates:s})]})}function XZe({slug:t}){const s=ao(),r=t||s.slug,[n,a]=S.useState(!1),[o,l]=S.useState(!1),[i,d]=S.useState(""),[u,p]=S.useState(""),[f,y]=S.useState(""),[_,b]=S.useState(""),[N,w]=S.useState(""),[k,C]=S.useState("buying"),[A,I]=S.useState("");S.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:k,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(ks,{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(yi,{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(yi,{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(Le,{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(Le,{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(Le,{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 ${k===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(Le,{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(Le,{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(yi,{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 nPt(){const s=Bl().pathname.slice(1).replace(/\/$/,"");if(S.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",aPt=30,iPt=()=>{const[t]=Nc();S.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])},oPt=()=>{try{const t=localStorage.getItem(s_e);if(!t)return null;const s=JSON.parse(t),r=aPt*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}},fle="/assets/levelup-logo-header-_ZX7DvlA.png",lPt="/assets/scale-your-team-ku4MPatU.png";function cPt({open:t,onOpenChange:s}){return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(hs,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(js,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-[#4a6b6d]/10 rounded-lg",children:e.jsx(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}},dPt=[{icon:sp,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:Fl,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:ln,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:Ol,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:yn,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:yi,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],uPt=[{icon:or,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."}],hPt=[{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."}],mPt=()=>{const{user:t,loading:s}=qs(),r=vr(),[n]=Nc();S.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]=S.useState(null),[l,i]=S.useState(null),[d,u]=S.useState(!1),[p,f]=S.useState(""),[y,_]=S.useState(""),[b,N]=S.useState(""),[w,k]=S.useState(!1),[C,A]=S.useState(!1),I=(V,q=!1)=>{i({tier:V,skipTrial:q}),u(!0)};iPt(),S.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]),S.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}k(!0),o(V+(q?"_direct":""));const B=oPt();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{k(!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:fle,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[e.jsx(K,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var V;return(V=document.getElementById("features"))==null?void 0:V.scrollIntoView({behavior:"smooth"})},children:"Features"}),e.jsx(K,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var V;return(V=document.getElementById("pricing"))==null?void 0:V.scrollIntoView({behavior:"smooth"})},children:"Pricing"}),e.jsx(K,{onClick:()=>r("/auth"),className:"bg-white text-[#4a6b6d] hover:bg-gray-100 font-medium shadow-md",children:"Sign In"})]})]})}),e.jsxs("section",{className:"relative pt-24 pb-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-8",children:[e.jsx("div",{className:"flex justify-center mb-8",children:e.jsx("img",{alt:"LevelUp Consulting Group",className:"h-[136px] md:h-[164px] drop-shadow-lg",src:"/lovable-uploads/3a0c7ef9-9e79-411f-a9af-6f2a99e8bd7b.webp"})}),e.jsxs("p",{className:"text-lg text-white/80 max-w-3xl mx-auto leading-relaxed font-sans font-bold md:text-4xl",children:["The tools you need to get it done.",e.jsx("br",{}),e.jsx("em",{children:"The platform you need to keep it going."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center items-center pt-4",children:[e.jsxs(K,{size:"lg",onClick:()=>{var 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(Ga,{className:"ml-2 w-5 h-5 group-hover:translate-x-1 transition-transform"})]}),e.jsx(K,{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(K,{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(K,{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:dPt.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(Lt,{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(Ft,{className:"text-xl font-sans",children:V.title})]}),e.jsx(Re,{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:uPt.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(Lt,{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(Ft,{className:"text-lg font-semibold text-white",children:V.title})]}),e.jsx(Re,{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(K,{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(Ga,{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(K,{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(K,{size:"lg",variant:"outline",onClick:()=>A(!0),className:"border-[#4a6b6d] text-[#4a6b6d] hover:bg-[#4a6b6d]/10",children:[e.jsx(ln,{className:"mr-2 w-5 h-5"}),"Schedule Info Session"]})]})]}),e.jsx("div",{className:"relative hidden md:block",children:e.jsx("img",{src:lPt,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:hPt.map((V,q)=>e.jsx(Pe,{className:"bg-muted/30 border-0",children:e.jsxs(Re,{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(K,{size:"lg",className:"px-12 py-7 text-lg font-semibold bg-white text-[#4a6b6d] hover:bg-white/90 shadow-2xl transition-all hover:scale-105 group rounded-full",onClick:()=>I("individual_agent"),children:["Start Free Trial",e.jsx(Ga,{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(Lt,{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(Ft,{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(ur,{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(on,{className:"w-4 h-4"}),Tu.individual_agent.trial]})]}),e.jsx(Re,{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(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>I("individual_agent"),children:"Start Free Trial"}),e.jsx(K,{variant:"outline",className:"w-full rounded-full border-2 border-[#4a6b6d] text-[#4a6b6d] bg-white hover:bg-[#4a6b6d]/5 uppercase text-sm font-medium tracking-wide",onClick:()=>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(Lt,{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(Ft,{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(ur,{className:"text-base mt-2",children:Tu.brokerage_under_25.description})]}),e.jsx(Re,{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(K,{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(Lt,{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(Ft,{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(ur,{className:"text-base mt-2",children:Tu.brokerage_over_25.description})]}),e.jsx(Re,{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(K,{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(K,{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(Ga,{className:"ml-2 w-5 h-5"})]}),e.jsx(K,{size:"lg",onClick:()=>r("/auth"),className:"px-10 py-7 text-lg font-semibold border-2 border-white text-white bg-transparent hover:bg-white hover:text-[#4a6b6d]",children:"Sign In"})]})]})})]}),e.jsx("footer",{className:"py-12 bg-[#3d5a5c] text-white/80",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-between gap-4",children:[e.jsx("img",{src:fle,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(cPt,{open:C,onOpenChange:A}),e.jsx(fs,{open:d,onOpenChange:u,children:e.jsxs(hs,{className:"sm:max-w-md",children:[e.jsxs(js,{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(Le,{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(Le,{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(Le,{id:"dialog-coupon",type:"text",placeholder:"Enter discount code",value:b,onChange:V=>N(V.target.value),className:"mt-1"})]})]}),e.jsx(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:O,disabled:w,children:w?"Loading...":"Continue to Checkout"})]})})]})},IIe=()=>e.jsxs(e.Fragment,{children:[e.jsxs(nc,{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"})]})]})]})]})})]}),LIe=()=>e.jsxs(e.Fragment,{children:[e.jsxs(nc,{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"})]})]})]})]})})]}),pPt=()=>e.jsxs(e.Fragment,{children:[e.jsxs(nc,{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"})]})]})]})]})})]}),fPt=kC({email:Yl().email("Invalid email address"),password:Yl().min(6,"Password must be at least 6 characters")}),xPt=()=>{const{signIn:t,user:s}=qs(),r=vr(),[n,a]=S.useState(!1),[o,l]=S.useState({}),[i,d]=S.useState(""),[u,p]=S.useState(!1),[f,y]=S.useState(!1);S.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),k=w.get("email"),C=w.get("password");try{fPt.parse({email:k,password:C}),await t(k,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(Lt,{className:"space-y-1 text-center pb-4",children:[e.jsx(Ft,{className:"text-3xl font-bold text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Welcome Back"}),e.jsx(ur,{className:"text-gray-600",children:"Sign in to access your dashboard"})]}),e.jsx(Re,{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(Le,{id:"signin-email",name:"email",type:"email",placeholder:"your@email.com",required:!0,className:"border-gray-300 focus:border-[#4a6b6d] focus:ring-[#4a6b6d]"}),o.email&&e.jsx("p",{className:"text-sm text-red-600",children:o.email})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"signin-password",className:"text-gray-700",children:"Password"}),e.jsx(Le,{id:"signin-password",name:"password",type:"password",required:!0,className:"border-gray-300 focus:border-[#4a6b6d] focus:ring-[#4a6b6d]"}),o.password&&e.jsx("p",{className:"text-sm text-red-600",children:o.password})]}),e.jsx(K,{type:"submit",className:"w-full bg-[#4a6b6d] hover:bg-[#3d5a5c] text-white font-semibold py-6 text-lg transition-all duration-200 shadow-lg hover:shadow-xl",disabled:n,children:n?"Signing in...":"Sign In"}),e.jsxs(fs,{open:f,onOpenChange:y,children:[e.jsx(hi,{asChild:!0,children:e.jsx(K,{variant:"link",className:"w-full text-sm text-[#4a6b6d] hover:text-[#3d5a5c]",children:"Forgot password?"})}),e.jsxs(hs,{className:"bg-white",children:[e.jsxs(js,{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(Le,{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(K,{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"})]})]})})]})]})},gPt=()=>{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(Lt,{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(ti,{className:"w-10 h-10 text-green-500"})}),e.jsx(Ft,{className:"text-2xl",children:"Welcome to LevelUp!"}),e.jsx(ur,{className:"text-lg",children:"Your subscription has been activated successfully."})]}),e.jsxs(Re,{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]=S.useState(null),[n,a]=S.useState(!0);return S.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},yPt=t=>{const[s,r]=S.useState({isTrial:!1,isExpired:!1,expiresAt:null,daysLeft:null,loading:!0});return S.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")}},DIe="community_last_seen_post_at";function vPt(){const{user:t}=qs(),s=Bl(),[r,n]=S.useState(0),[a,o]=S.useState(null);S.useEffect(()=>{if(!t)return;const i=localStorage.getItem(`${DIe}_${t.id}`);o(i)},[t]),S.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]),S.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=S.useCallback(()=>{if(!t)return;const i=new Date().toISOString();localStorage.setItem(`${DIe}_${t.id}`,i),o(i),n(0)},[t]);return S.useEffect(()=>{s.pathname==="/community"&&r>0&&l()},[s.pathname,r,l]),{unreadCount:r,markAsRead:l}}function _Pt(){const{isAdmin:t}=qs(),{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=wue,zNe=Vje,bPt=jue,tYe=S.forwardRef(({className:t,...s},r)=>e.jsx(UA,{className:Dt("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 wPt=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=S.forwardRef(({side:t="right",className:s,children:r,...n},a)=>e.jsxs(bPt,{children:[e.jsx(tYe,{}),e.jsxs(VA,{ref:a,className:Dt(wPt({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(jr,{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:Dt("flex flex-col space-y-2 text-center sm:text-left",t),...s});YA.displayName="SheetHeader";const XA=S.forwardRef(({className:t,...s},r)=>e.jsx(RR,{ref:r,className:Dt("text-lg font-semibold text-foreground",t),...s}));XA.displayName=RR.displayName;const sYe=S.forwardRef(({className:t,...s},r)=>e.jsx(OR,{ref:r,className:Dt("text-sm text-muted-foreground",t),...s}));sYe.displayName=OR.displayName;var Hue="Collapsible",[jPt,lAs]=qc(Hue),[NPt,BNe]=jPt(Hue),rYe=S.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:Hue});return e.jsx(NPt,{scope:r,disabled:o,contentId:fu(),open:d,onOpenToggle:S.useCallback(()=>u(p=>!p),[u]),children:e.jsx(Jr.div,{"data-state":qNe(d),"data-disabled":o?"":void 0,...i,ref:s})})});rYe.displayName=Hue;var nYe="CollapsibleTrigger",aYe=S.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:Sr(t.onClick,a.onOpenToggle)})});aYe.displayName=nYe;var $Ne="CollapsibleContent",iYe=S.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(kPt,{...n,ref:s,present:o})})});iYe.displayName=$Ne;var kPt=S.forwardRef((t,s)=>{const{__scopeCollapsible:r,present:n,children:a,...o}=t,l=BNe($Ne,r),[i,d]=S.useState(n),u=S.useRef(null),p=Ta(s,u),f=S.useRef(0),y=f.current,_=S.useRef(0),b=_.current,N=l.open||i,w=S.useRef(N),k=S.useRef(void 0);return S.useEffect(()=>{const C=requestAnimationFrame(()=>w.current=!1);return()=>cancelAnimationFrame(C)},[]),ad(()=>{const C=u.current;if(C){k.current=k.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=k.current.transitionDuration,C.style.animationName=k.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 SPt=rYe;const lf=SPt,cf=aYe,df=iYe,CPt="/assets/levelup-logo-Eif24dqY.png",MPt="/assets/levelup-logo-icon-C-7iromj.png",TPt="/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,APt=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,cYe=(t,s)=>t.has(APt(s)),EPt=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&&!EPt(t))s=t;else for(const a in t)t.hasOwnProperty(a)&&(s[a]=eu(t[a]));else return t;return s}var Gue=t=>/^\w*$/.test(t),hd=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=(Gue(s)?[s]:HNe(s)).reduce((a,o)=>fm(a)?a:a[o],t);return hd(n)||n===t?hd(t[s])?r:t[s]:n},Kp=t=>typeof t=="boolean",Ho=(t,s,r)=>{let n=-1;const a=Gue(s)?[s]:HNe(s),o=a.length,l=o-1;for(;++nxt.useContext(GNe),PPt=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 IPt(t){const s=Wue(),{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 LPt(t){const s=Wue(),{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 DPt(t){const s=Wue(),{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=LPt({control:a,name:r,defaultValue:d,exact:!0}),p=IPt({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:xle.CHANGE}),[r]),N=xt.useCallback(()=>y.current.onBlur({target:{value:Pn(a._formValues,r),name:r},type:xle.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]),k=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),hd(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:k,formState:p,fieldState:_}),[k,p,_])}const RPt=t=>t.render(DPt(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],RIe=()=>{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=[]}}},Qm=t=>wd(t)&&!Object.keys(t).length,KNe=t=>t.type==="file",wg=t=>typeof t=="function",gle=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",OPt=t=>ZNe(t)||HR(t),Fge=t=>gle(t)&&t.isConnected;function FPt(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 yle(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])?[]:{},yle(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])?hd(s)||r_e(r[a])?r[a]=Array.isArray(t[a])?yle(t[a],[]):{...yle(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,yle(s));const OIe={value:!1,isValid:!1},FIe={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&&!hd(t[0].attributes.value)?hd(t[0].value)||t[0].value===""?FIe:{value:t[0].value,isValid:!0}:FIe:OIe}return OIe},gYe=(t,{valueAsNumber:s,valueAsDate:r,setValueAs:n})=>hd(t)?t:s?t===""?NaN:t&&+t:r&&Uy(t)?new Date(t):n?n(t):t;const zIe={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,zIe):zIe;function BIe(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(hd(s.value)?t.ref.value:s.value,t)}var BPt=(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}},vle=t=>t instanceof RegExp,rI=t=>hd(t)?t:vle(t)?t.source:wd(t)?vle(t.value)?t.value.source:t.value:t,$Ie=t=>({isOnSubmit:!t||t===bg.onSubmit,isOnBlur:t===bg.onBlur,isOnChange:t===bg.onChange,isOnAll:t===bg.all,isOnTouch:t===bg.onTouched});const qIe="AsyncFunction";var $Pt=t=>!!t&&!!t.validate&&!!(wg(t.validate)&&t.validate.constructor.name===qIe||wd(t.validate)&&Object.values(t.validate).find(s=>s.constructor.name===qIe)),qPt=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),UIe=(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 VIe(t,s,r){const n=Pn(t,r);if(n||Gue(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 UPt=(t,s,r,n)=>{r(t);const{name:a,...o}=t;return Qm(o)||Object.keys(o).length>=Object.keys(s).length||Object.keys(o).find(l=>s[l]===(!n||bg.all))},VPt=(t,s,r)=>!t||!s||t===s||a8(t).some(n=>n&&(r?n===s:n.startsWith(s)||s.startsWith(n))),HPt=(t,s,r,n,a)=>a.isOnAll?!1:!r&&a.isOnTouch?!(s||t):(r?n.isOnBlur:a.isOnBlur)?!t:(r?n.isOnChange:a.isOnChange)?t:!0,GPt=(t,s)=>!VNe(Pn(t,s)).length&&Id(t,s),WPt=(t,s,r)=>{const n=a8(Pn(t,r));return Ho(n,"root",s[r]),Ho(t,r,n),t},Yie=t=>Uy(t);function HIe(t,s,r="validate"){if(Yie(t)||Array.isArray(t)&&t.every(Yie)||Kp(t)&&!t)return{type:r,message:Yie(t)?t:"",ref:s}}var x5=t=>wd(t)&&!vle(t)?t:{value:t,message:""},GIe=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:k}=t._f,C=Pn(r,N);if(!k||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))&&hd(l.value)&&hd(C)||gle(l)&&l.value===""||C===""||Array.isArray(C)&&!C.length,U=hYe.bind(null,N,n,L),te=(Y,J,X,ce=mv.maxLength,ae=mv.minLength)=>{const ie=Y?J:X;L[N]={type:Y?ce:ae,message:ie,ref:l,...U(Y?ce:ae,ie)}};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}=Yie(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 ae=l.valueAsNumber||C&&+C;fm(X.value)||(Y=ae>X.value),fm(ce.value)||(J=aenew Date(new Date().toDateString()+" "+ye),oe=l.type=="time",me=l.type=="week";Uy(X.value)&&C&&(Y=oe?ie(C)>ie(X.value):me?C>X.value:ae>new Date(X.value)),Uy(ce.value)&&C&&(J=oe?ie(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(vle(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=HIe(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(!Qm(Y)&&!n)break;const X=HIe(await b[J](C,r),A,J);X&&(Y={...X,...U(J,X.message)},I(X.message),n&&(L[N]=Y))}if(!Qm(Y)&&(L[N]={ref:A,...Y},!n))return L}}return I(!0),L};const KPt={mode:bg.onSubmit,reValidateMode:bg.onChange,shouldFocusError:!0};function ZPt(t={}){let s={...KPt,...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:RIe(),state:RIe()},_=s.criteriaMode===bg.all,b=We=>it=>{clearTimeout(u),u=setTimeout(We,it)},N=async We=>{if(!s.disabled&&(p.isValid||f.isValid||We)){const it=s.resolver?Qm((await V()).errors):await B(n,!0);it!==r.isValid&&y.state.next({isValid:it})}},w=(We,it)=>{!s.disabled&&(p.isValidating||p.validatingFields||f.isValidating||f.validatingFields)&&((We||Array.from(i.mount)).forEach(Ve=>{Ve&&(it?Ho(r.validatingFields,Ve,it):Id(r.validatingFields,Ve))}),y.state.next({validatingFields:r.validatingFields,isValidating:!Qm(r.validatingFields)}))},k=(We,it=[],Ve,Xe,dt=!0,pt=!0)=>{if(Xe&&Ve&&!s.disabled){if(l.action=!0,pt&&Array.isArray(Pn(n,We))){const Je=Ve(Pn(n,We),Xe.argA,Xe.argB);dt&&Ho(n,We,Je)}if(pt&&Array.isArray(Pn(r.errors,We))){const Je=Ve(Pn(r.errors,We),Xe.argA,Xe.argB);dt&&Ho(r.errors,We,Je),GPt(r.errors,We)}if((p.touchedFields||f.touchedFields)&&pt&&Array.isArray(Pn(r.touchedFields,We))){const Je=Ve(Pn(r.touchedFields,We),Xe.argA,Xe.argB);dt&&Ho(r.touchedFields,We,Je)}(p.dirtyFields||f.dirtyFields)&&(r.dirtyFields=sI(a,o)),y.state.next({name:We,isDirty:te(We,it),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else Ho(o,We,it)},C=(We,it)=>{Ho(r.errors,We,it),y.state.next({errors:r.errors})},A=We=>{r.errors=We,y.state.next({errors:r.errors,isValid:!1})},I=(We,it,Ve,Xe)=>{const dt=Pn(n,We);if(dt){const pt=Pn(o,We,hd(Ve)?Pn(a,We):Ve);hd(pt)||Xe&&Xe.defaultChecked||it?Ho(o,We,it?pt:BIe(dt._f)):X(We,pt),l.mount&&N()}},L=(We,it,Ve,Xe,dt)=>{let pt=!1,Je=!1;const Ze={name:We};if(!s.disabled){if(!Ve||Xe){(p.isDirty||f.isDirty)&&(Je=r.isDirty,r.isDirty=Ze.isDirty=te(),pt=Je!==Ze.isDirty);const Nt=Rv(Pn(a,We),it);Je=!!Pn(r.dirtyFields,We),Nt?Id(r.dirtyFields,We):Ho(r.dirtyFields,We,!0),Ze.dirtyFields=r.dirtyFields,pt=pt||(p.dirtyFields||f.dirtyFields)&&Je!==!Nt}if(Ve){const Nt=Pn(r.touchedFields,We);Nt||(Ho(r.touchedFields,We,Ve),Ze.touchedFields=r.touchedFields,pt=pt||(p.touchedFields||f.touchedFields)&&Nt!==Ve)}pt&&dt&&y.state.next(Ze)}return pt?Ze:{}},O=(We,it,Ve,Xe)=>{const dt=Pn(r.errors,We),pt=(p.isValid||f.isValid)&&Kp(it)&&r.isValid!==it;if(s.delayError&&Ve?(d=b(()=>C(We,Ve)),d(s.delayError)):(clearTimeout(u),d=null,Ve?Ho(r.errors,We,Ve):Id(r.errors,We)),(Ve?!Rv(dt,Ve):dt)||!Qm(Xe)||pt){const Je={...Xe,...pt&&Kp(it)?{isValid:it}:{},errors:r.errors,name:We};r={...r,...Je},y.state.next(Je)}},V=async We=>{w(We,!0);const it=await s.resolver(o,s.context,BPt(We||i.mount,n,s.criteriaMode,s.shouldUseNativeValidation));return w(We),it},q=async We=>{const{errors:it}=await V(We);if(We)for(const Ve of We){const Xe=Pn(it,Ve);Xe?Ho(r.errors,Ve,Xe):Id(r.errors,Ve)}else r.errors=it;return it},B=async(We,it,Ve={valid:!0})=>{for(const Xe in We){const dt=We[Xe];if(dt){const{_f:pt,...Je}=dt;if(pt){const Ze=i.array.has(pt.name),Nt=dt._f&&$Pt(dt._f);Nt&&p.validatingFields&&w([Xe],!0);const Ot=await GIe(dt,i.disabled,o,_,s.shouldUseNativeValidation&&!it,Ze);if(Nt&&p.validatingFields&&w([Xe]),Ot[pt.name]&&(Ve.valid=!1,it))break;!it&&(Pn(Ot,pt.name)?Ze?WPt(r.errors,Ot,pt.name):Ho(r.errors,pt.name,Ot[pt.name]):Id(r.errors,pt.name))}!Qm(Je)&&await B(Je,it,Ve)}}return Ve.valid},U=()=>{for(const We of i.unMount){const it=Pn(n,We);it&&(it._f.refs?it._f.refs.every(Ve=>!Fge(Ve)):!Fge(it._f.ref))&&De(We)}i.unMount=new Set},te=(We,it)=>!s.disabled&&(We&&it&&Ho(o,We,it),!Rv(ye(),a)),Y=(We,it,Ve)=>uYe(We,i,{...l.mount?o:hd(it)?a:Uy(We)?{[We]:it}:it},Ve,it),J=We=>VNe(Pn(l.mount?o:a,We,s.shouldUnregister?Pn(a,We,[]):[])),X=(We,it,Ve={})=>{const Xe=Pn(n,We);let dt=it;if(Xe){const pt=Xe._f;pt&&(!pt.disabled&&Ho(o,We,gYe(it,pt)),dt=gle(pt.ref)&&fm(it)?"":it,mYe(pt.ref)?[...pt.ref.options].forEach(Je=>Je.selected=dt.includes(Je.value)):pt.refs?HR(pt.ref)?pt.refs.forEach(Je=>{(!Je.defaultChecked||!Je.disabled)&&(Array.isArray(dt)?Je.checked=!!dt.find(Ze=>Ze===Je.value):Je.checked=dt===Je.value||!!dt)}):pt.refs.forEach(Je=>Je.checked=Je.value===dt):KNe(pt.ref)?pt.ref.value="":(pt.ref.value=dt,pt.ref.type||y.state.next({name:We,values:eu(o)})))}(Ve.shouldDirty||Ve.shouldTouch)&&L(We,dt,Ve.shouldTouch,Ve.shouldDirty,!0),Ve.shouldValidate&&me(We)},ce=(We,it,Ve)=>{for(const Xe in it){if(!it.hasOwnProperty(Xe))return;const dt=it[Xe],pt=We+"."+Xe,Je=Pn(n,pt);(i.array.has(We)||wd(dt)||Je&&!Je._f)&&!_4(dt)?ce(pt,dt,Ve):X(pt,dt,Ve)}},ae=(We,it,Ve={})=>{const Xe=Pn(n,We),dt=i.array.has(We),pt=eu(it);Ho(o,We,pt),dt?(y.array.next({name:We,values:eu(o)}),(p.isDirty||p.dirtyFields||f.isDirty||f.dirtyFields)&&Ve.shouldDirty&&y.state.next({name:We,dirtyFields:sI(a,o),isDirty:te(We,pt)})):Xe&&!Xe._f&&!fm(pt)?ce(We,pt,Ve):X(We,pt,Ve),UIe(We,i)&&y.state.next({...r,name:We}),y.state.next({name:l.mount?We:void 0,values:eu(o)})},ie=async We=>{l.mount=!0;const it=We.target;let Ve=it.name,Xe=!0;const dt=Pn(n,Ve),pt=Nt=>{Xe=Number.isNaN(Nt)||_4(Nt)&&isNaN(Nt.getTime())||Rv(Nt,Pn(o,Ve,Nt))},Je=$Ie(s.mode),Ze=$Ie(s.reValidateMode);if(dt){let Nt,Ot;const Yt=it.type?BIe(dt._f):lYe(We),Ps=We.type===xle.BLUR||We.type===xle.FOCUS_OUT,$s=!qPt(dt._f)&&!s.resolver&&!Pn(r.errors,Ve)&&!dt._f.deps||HPt(Ps,Pn(r.touchedFields,Ve),r.isSubmitted,Ze,Je),Zs=UIe(Ve,i,Ps);Ho(o,Ve,Yt),Ps?(dt._f.onBlur&&dt._f.onBlur(We),d&&d(0)):dt._f.onChange&&dt._f.onChange(We);const Dr=L(Ve,Yt,Ps),$t=!Qm(Dr)||Zs;if(!Ps&&y.state.next({name:Ve,type:We.type,values:eu(o)}),$s)return(p.isValid||f.isValid)&&(s.mode==="onBlur"?Ps&&N():Ps||N()),$t&&y.state.next({name:Ve,...Zs?{}:Dr});if(!Ps&&Zs&&y.state.next({...r}),s.resolver){const{errors:Us}=await V([Ve]);if(pt(Yt),Xe){const Nr=VIe(r.errors,n,Ve),Xs=VIe(Us,n,Nr.name||Ve);Nt=Xs.error,Ve=Xs.name,Ot=Qm(Us)}}else w([Ve],!0),Nt=(await GIe(dt,i.disabled,o,_,s.shouldUseNativeValidation))[Ve],w([Ve]),pt(Yt),Xe&&(Nt?Ot=!1:(p.isValid||f.isValid)&&(Ot=await B(n,!0)));Xe&&(dt._f.deps&&me(dt._f.deps),O(Ve,Ot,Nt,Dr))}},oe=(We,it)=>{if(Pn(r.errors,it)&&We.focus)return We.focus(),1},me=async(We,it={})=>{let Ve,Xe;const dt=a8(We);if(s.resolver){const pt=await q(hd(We)?We:dt);Ve=Qm(pt),Xe=We?!dt.some(Je=>Pn(pt,Je)):Ve}else We?(Xe=(await Promise.all(dt.map(async pt=>{const Je=Pn(n,pt);return await B(Je&&Je._f?{[pt]:Je}:Je)}))).every(Boolean),!(!Xe&&!r.isValid)&&N()):Xe=Ve=await B(n);return y.state.next({...!Uy(We)||(p.isValid||f.isValid)&&Ve!==r.isValid?{}:{name:We},...s.resolver||!We?{isValid:Ve}:{},errors:r.errors}),it.shouldFocus&&!Xe&&i8(n,oe,We?dt:i.mount),Xe},ye=We=>{const it={...l.mount?o:a};return hd(We)?it:Uy(We)?Pn(it,We):We.map(Ve=>Pn(it,Ve))},he=(We,it)=>({invalid:!!Pn((it||r).errors,We),isDirty:!!Pn((it||r).dirtyFields,We),error:Pn((it||r).errors,We),isValidating:!!Pn(r.validatingFields,We),isTouched:!!Pn((it||r).touchedFields,We)}),ge=We=>{We&&a8(We).forEach(it=>Id(r.errors,it)),y.state.next({errors:We?r.errors:{}})},Ne=(We,it,Ve)=>{const Xe=(Pn(n,We,{_f:{}})._f||{}).ref,dt=Pn(r.errors,We)||{},{ref:pt,message:Je,type:Ze,...Nt}=dt;Ho(r.errors,We,{...Nt,...it,ref:Xe}),y.state.next({name:We,errors:r.errors,isValid:!1}),Ve&&Ve.shouldFocus&&Xe&&Xe.focus&&Xe.focus()},Ue=(We,it)=>wg(We)?y.state.subscribe({next:Ve=>"values"in Ve&&We(Y(void 0,it),Ve)}):Y(We,it,!0),Te=We=>y.state.subscribe({next:it=>{VPt(We.name,it.name,We.exact)&&UPt(it,We.formState||p,tt,We.reRenderRoot)&&We.callback({values:{...o},...r,...it,defaultValues:a})}}).unsubscribe,Me=We=>(l.mount=!0,f={...f,...We.formState},Te({...We,formState:f})),De=(We,it={})=>{for(const Ve of We?a8(We):i.mount)i.mount.delete(Ve),i.array.delete(Ve),it.keepValue||(Id(n,Ve),Id(o,Ve)),!it.keepError&&Id(r.errors,Ve),!it.keepDirty&&Id(r.dirtyFields,Ve),!it.keepTouched&&Id(r.touchedFields,Ve),!it.keepIsValidating&&Id(r.validatingFields,Ve),!s.shouldUnregister&&!it.keepDefaultValue&&Id(a,Ve);y.state.next({values:eu(o)}),y.state.next({...r,...it.keepDirty?{isDirty:te()}:{}}),!it.keepIsValid&&N()},qe=({disabled:We,name:it})=>{(Kp(We)&&l.mount||We||i.disabled.has(it))&&(We?i.disabled.add(it):i.disabled.delete(it))},ke=(We,it={})=>{let Ve=Pn(n,We);const Xe=Kp(it.disabled)||Kp(s.disabled);return Ho(n,We,{...Ve||{},_f:{...Ve&&Ve._f?Ve._f:{ref:{name:We}},name:We,mount:!0,...it}}),i.mount.add(We),Ve?qe({disabled:Kp(it.disabled)?it.disabled:s.disabled,name:We}):I(We,!0,it.value),{...Xe?{disabled:it.disabled||s.disabled}:{},...s.progressive?{required:!!it.required,min:rI(it.min),max:rI(it.max),minLength:rI(it.minLength),maxLength:rI(it.maxLength),pattern:rI(it.pattern)}:{},name:We,onChange:ie,onBlur:ie,ref:dt=>{if(dt){ke(We,it),Ve=Pn(n,We);const pt=hd(dt.value)&&dt.querySelectorAll&&dt.querySelectorAll("input,select,textarea")[0]||dt,Je=OPt(pt),Ze=Ve._f.refs||[];if(Je?Ze.find(Nt=>Nt===pt):pt===Ve._f.ref)return;Ho(n,We,{_f:{...Ve._f,...Je?{refs:[...Ze.filter(Fge),pt,...Array.isArray(Pn(a,We))?[{}]:[]],ref:{type:pt.type,name:We}}:{ref:pt}}}),I(We,!1,void 0,pt)}else Ve=Pn(n,We,{}),Ve._f&&(Ve._f.mount=!1),(s.shouldUnregister||it.shouldUnregister)&&!(cYe(i.array,We)&&l.action)&&i.unMount.add(We)}}},$e=()=>s.shouldFocusError&&i8(n,oe,i.mount),Be=We=>{Kp(We)&&(y.state.next({disabled:We}),i8(n,(it,Ve)=>{const Xe=Pn(n,Ve);Xe&&(it.disabled=Xe._f.disabled||We,Array.isArray(Xe._f.refs)&&Xe._f.refs.forEach(dt=>{dt.disabled=Xe._f.disabled||We}))},0,!1))},we=(We,it)=>async Ve=>{let Xe;Ve&&(Ve.preventDefault&&Ve.preventDefault(),Ve.persist&&Ve.persist());let dt=eu(o);if(y.state.next({isSubmitting:!0}),s.resolver){const{errors:pt,values:Je}=await V();r.errors=pt,dt=eu(Je)}else await B(n);if(i.disabled.size)for(const pt of i.disabled)Id(dt,pt);if(Id(r.errors,"root"),Qm(r.errors)){y.state.next({errors:{}});try{await We(dt,Ve)}catch(pt){Xe=pt}}else it&&await it({...r.errors},Ve),$e(),setTimeout($e);if(y.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Qm(r.errors)&&!Xe,submitCount:r.submitCount+1,errors:r.errors}),Xe)throw Xe},ut=(We,it={})=>{Pn(n,We)&&(hd(it.defaultValue)?ae(We,eu(Pn(a,We))):(ae(We,it.defaultValue),Ho(a,We,eu(it.defaultValue))),it.keepTouched||Id(r.touchedFields,We),it.keepDirty||(Id(r.dirtyFields,We),r.isDirty=it.defaultValue?te(We,eu(Pn(a,We))):te()),it.keepError||(Id(r.errors,We),p.isValid&&N()),y.state.next({...r}))},fe=(We,it={})=>{const Ve=We?eu(We):a,Xe=eu(Ve),dt=Qm(We),pt=dt?a:Xe;if(it.keepDefaultValues||(a=Ve),!it.keepValues){if(it.keepDirtyValues){const Je=new Set([...i.mount,...Object.keys(sI(a,o))]);for(const Ze of Array.from(Je))Pn(r.dirtyFields,Ze)?Ho(pt,Ze,Pn(o,Ze)):ae(Ze,Pn(pt,Ze))}else{if(UNe&&hd(We))for(const Je of i.mount){const Ze=Pn(n,Je);if(Ze&&Ze._f){const Nt=Array.isArray(Ze._f.refs)?Ze._f.refs[0]:Ze._f.ref;if(gle(Nt)){const Ot=Nt.closest("form");if(Ot){Ot.reset();break}}}}if(it.keepFieldsRef)for(const Je of i.mount)ae(Je,Pn(pt,Je));else n={}}o=s.shouldUnregister?it.keepDefaultValues?eu(a):{}:eu(pt),y.array.next({values:{...pt}}),y.state.next({values:{...pt}})}i={mount:it.keepDirtyValues?i.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!p.isValid||!!it.keepIsValid||!!it.keepDirtyValues,l.watch=!!s.shouldUnregister,y.state.next({submitCount:it.keepSubmitCount?r.submitCount:0,isDirty:dt?!1:it.keepDirty?r.isDirty:!!(it.keepDefaultValues&&!Rv(We,a)),isSubmitted:it.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:dt?{}:it.keepDirtyValues?it.keepDefaultValues&&o?sI(a,o):r.dirtyFields:it.keepDefaultValues&&We?sI(a,We):it.keepDirty?r.dirtyFields:{},touchedFields:it.keepTouched?r.touchedFields:{},errors:it.keepErrors?r.errors:{},isSubmitSuccessful:it.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},He=(We,it)=>fe(wg(We)?We(o):We,it),et=(We,it={})=>{const Ve=Pn(n,We),Xe=Ve&&Ve._f;if(Xe){const dt=Xe.refs?Xe.refs[0]:Xe.ref;dt.focus&&(dt.focus(),it.shouldSelect&&wg(dt.select)&&dt.select())}},tt=We=>{r={...r,...We}},Ge={control:{register:ke,unregister:De,getFieldState:he,handleSubmit:we,setError:Ne,_subscribe:Te,_runSchema:V,_focusError:$e,_getWatch:Y,_getDirty:te,_setValid:N,_setFieldArray:k,_setDisabledField:qe,_setErrors:A,_getFieldArray:J,_reset:fe,_resetDefaultValues:()=>wg(s.defaultValues)&&s.defaultValues().then(We=>{He(We,s.resetOptions),y.state.next({isLoading:!1})}),_removeUnmounted:U,_disableForm:Be,_subjects:y,_proxyFormState:p,get _fields(){return n},get _formValues(){return o},get _state(){return l},set _state(We){l=We},get _defaultValues(){return a},get _names(){return i},set _names(We){i=We},get _formState(){return r},get _options(){return s},set _options(We){s={...s,...We}}},subscribe:Me,trigger:me,register:ke,handleSubmit:we,watch:Ue,setValue:ae,getValues:ye,reset:He,resetField:ut,clearErrors:ge,unregister:De,setError:Ne,setFocus:et,getFieldState:he};return{...Ge,formControl:Ge}}function Kue(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}=ZPt(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 WIe=(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?WIe(n.ref,r,t):n.refs&&n.refs.forEach(a=>WIe(a,r,t))}},YPt=(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(XPt(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},XPt=(t,s)=>t.some(r=>r.startsWith(s+"."));var QPt=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},Zue=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:YPt(QPt(l.errors,!o.shouldUseNativeValidation&&o.criteriaMode==="all"),o)};throw l}))}catch(l){return Promise.reject(l)}}};const Yue=PPt,_Ye=S.createContext({}),Ec=({...t})=>e.jsx(_Ye.Provider,{value:{name:t.name},children:e.jsx(RPt,{...t})}),Xue=()=>{const t=S.useContext(_Ye),s=S.useContext(bYe),{getFieldState:r,formState:n}=Wue(),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=S.createContext({}),mc=S.forwardRef(({className:t,...s},r)=>{const n=S.useId();return e.jsx(bYe.Provider,{value:{id:n},children:e.jsx("div",{ref:r,className:Dt("space-y-2",t),...s})})});mc.displayName="FormItem";const pc=S.forwardRef(({className:t,...s},r)=>{const{error:n,formItemId:a}=Xue();return e.jsx(xe,{ref:r,className:Dt(n&&"text-destructive",t),htmlFor:a,...s})});pc.displayName="FormLabel";const fc=S.forwardRef(({...t},s)=>{const{error:r,formItemId:n,formDescriptionId:a,formMessageId:o}=Xue();return e.jsx(tje,{ref:s,id:n,"aria-describedby":r?`${a} ${o}`:`${a}`,"aria-invalid":!!r,...t})});fc.displayName="FormControl";const Xie=S.forwardRef(({className:t,...s},r)=>{const{formDescriptionId:n}=Xue();return e.jsx("p",{ref:r,id:n,className:Dt("text-sm text-muted-foreground",t),...s})});Xie.displayName="FormDescription";const vm=S.forwardRef(({className:t,children:s,...r},n)=>{const{error:a,formMessageId:o}=Xue(),l=a?String(a==null?void 0:a.message):s;return l?e.jsx("p",{ref:n,id:o,className:Dt("text-sm font-medium text-destructive",t),...r,children:l}):null});vm.displayName="FormMessage";const JPt=kC({category:ZWe(["general","technology","crm","marketing"]),subject:Yl().min(5,"Subject must be at least 5 characters").max(200),description:Yl().min(20,"Please provide more details (at least 20 characters)").max(2e3)}),e6t={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function n_e({trigger:t}){const[s,r]=S.useState(!1),[n,a]=S.useState(!1),{user:o}=qs(),l=Kue({resolver:Zue(JPt),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:e6t[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(hi,{asChild:!0,children:t||e.jsxs(K,{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(hs,{className:"sm:max-w-[500px]",children:[e.jsxs(js,{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(Yue,{...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(Fs,{onValueChange:d.onChange,defaultValue:d.value,children:[e.jsx(fc,{children:e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select a category"})})}),e.jsxs(Rs,{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(Le,{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(gr,{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(K,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:n,children:n?"Submitting...":"Submit Ticket"})]})]})})]})]})}const t6t=()=>{const{user:t}=qs(),s=vr(),[r,n]=S.useState([]),[a,o]=S.useState(0),[l,i]=S.useState(!1),[d,u]=S.useState(null);S.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 k=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(k)}},[t,d]);const p=b=>{const N=b.toLowerCase();return N.includes("community")||N.includes("post")?Si:N.includes("academy")||N.includes("video")?gn:N.includes("template")?Fl:N.includes("event")?ln:N.includes("newsletter")?Jv:N.includes("brokerage")?dh:N.includes("swag")||N.includes("social")?yi:N.includes("toolbox")||N.includes("tool")?Lg:N.includes("brief")?Or:Si},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(K,{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(K,{variant:"ghost",size:"sm",className:"text-xs h-6",onClick:y,children:"Mark all read"})]}),e.jsx(ni,{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 KIe=1,s6t=.9,r6t=.8,n6t=.17,zge=.1,Bge=.999,a6t=.9999,i6t=.99,o6t=/[\\\/_+.#"@\[\(\{&]/,l6t=/[\\\/_+.#"@\[\(\{&]/g,c6t=/[\s-]/,wYe=/[\s-]/g;function a_e(t,s,r,n,a,o,l){if(o===s.length)return a===t.length?KIe:i6t;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*=KIe:o6t.test(t.charAt(u-1))?(f*=r6t,_=t.slice(a,u-1).match(l6t),_&&a>0&&(f*=Math.pow(Bge,_.length))):c6t.test(t.charAt(u-1))?(f*=s6t,b=t.slice(a,u-1).match(wYe),b&&a>0&&(f*=Math.pow(Bge,b.length))):(f*=n6t,a>0&&(f*=Math.pow(Bge,u-a))),t.charAt(u)!==s.charAt(o)&&(f*=a6t)),(ff&&(f=y*zge)),f>p&&(p=f),u=r.indexOf(d,u+1);return l[i]=p,p}function ZIe(t){return t.toLowerCase().replace(wYe," ")}function d6t(t,s,r){return t=r&&r.length>0?`${t+" "+r.join(" ")}`:t,a_e(t,s,ZIe(t),ZIe(s),0,0,{})}var nI='[cmdk-group=""]',$ge='[cmdk-group-items=""]',u6t='[cmdk-group-heading=""]',jYe='[cmdk-item=""]',YIe=`${jYe}:not([aria-disabled="true"])`,i_e="cmdk-item-select",L5="data-value",h6t=(t,s,r)=>d6t(t,s,r),NYe=S.createContext(void 0),GR=()=>S.useContext(NYe),kYe=S.createContext(void 0),YNe=()=>S.useContext(kYe),SYe=S.createContext(void 0),CYe=S.forwardRef((t,s)=>{let r=D5(()=>{var ge,Ne;return{search:"",value:(Ne=(ge=t.value)!=null?ge:t.defaultValue)!=null?Ne:"",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,...k}=t,C=fu(),A=fu(),I=fu(),L=S.useRef(null),O=j6t();QS(()=>{if(p!==void 0){let ge=p.trim();r.current.value=ge,V.emit()}},[p]),QS(()=>{O(6,J)},[]);let V=S.useMemo(()=>({subscribe:ge=>(l.current.add(ge),()=>l.current.delete(ge)),snapshot:()=>r.current,setState:(ge,Ne,Ue)=>{var Te,Me,De,qe;if(!Object.is(r.current[ge],Ne)){if(r.current[ge]=Ne,ge==="search")Y(),U(),O(1,te);else if(ge==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ke=document.getElementById(I);ke?ke.focus():(Te=document.getElementById(C))==null||Te.focus()}if(O(7,()=>{var ke;r.current.selectedItemId=(ke=X())==null?void 0:ke.id,V.emit()}),Ue||O(5,J),((Me=i.current)==null?void 0:Me.value)!==void 0){let ke=Ne??"";(qe=(De=i.current).onValueChange)==null||qe.call(De,ke);return}}V.emit()}},emit:()=>{l.current.forEach(ge=>ge())}}),[]),q=S.useMemo(()=>({value:(ge,Ne,Ue)=>{var Te;Ne!==((Te=o.current.get(ge))==null?void 0:Te.value)&&(o.current.set(ge,{value:Ne,keywords:Ue}),r.current.filtered.items.set(ge,B(Ne,Ue)),O(2,()=>{U(),V.emit()}))},item:(ge,Ne)=>(n.current.add(ge),Ne&&(a.current.has(Ne)?a.current.get(Ne).add(ge):a.current.set(Ne,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 Ue=X();O(4,()=>{Y(),(Ue==null?void 0:Ue.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,Ne){var Ue,Te;let Me=(Te=(Ue=i.current)==null?void 0:Ue.filter)!=null?Te:h6t;return ge?Me(ge,r.current.search,Ne):0}function U(){if(!r.current.search||i.current.shouldFilter===!1)return;let ge=r.current.filtered.items,Ne=[];r.current.filtered.groups.forEach(Te=>{let Me=a.current.get(Te),De=0;Me.forEach(qe=>{let ke=ge.get(qe);De=Math.max(ke,De)}),Ne.push([Te,De])});let Ue=L.current;ce().sort((Te,Me)=>{var De,qe;let ke=Te.getAttribute("id"),$e=Me.getAttribute("id");return((De=ge.get($e))!=null?De:0)-((qe=ge.get(ke))!=null?qe:0)}).forEach(Te=>{let Me=Te.closest($ge);Me?Me.appendChild(Te.parentElement===Me?Te:Te.closest(`${$ge} > *`)):Ue.appendChild(Te.parentElement===Ue?Te:Te.closest(`${$ge} > *`))}),Ne.sort((Te,Me)=>Me[1]-Te[1]).forEach(Te=>{var Me;let De=(Me=L.current)==null?void 0:Me.querySelector(`${nI}[${L5}="${encodeURIComponent(Te[0])}"]`);De==null||De.parentElement.appendChild(De)})}function te(){let ge=ce().find(Ue=>Ue.getAttribute("aria-disabled")!=="true"),Ne=ge==null?void 0:ge.getAttribute(L5);V.setState("value",Ne||void 0)}function Y(){var ge,Ne,Ue,Te;if(!r.current.search||i.current.shouldFilter===!1){r.current.filtered.count=n.current.size;return}r.current.filtered.groups=new Set;let Me=0;for(let De of n.current){let qe=(Ne=(ge=o.current.get(De))==null?void 0:ge.value)!=null?Ne:"",ke=(Te=(Ue=o.current.get(De))==null?void 0:Ue.keywords)!=null?Te:[],$e=B(qe,ke);r.current.filtered.items.set(De,$e),$e>0&&Me++}for(let[De,qe]of a.current)for(let ke of qe)if(r.current.filtered.items.get(ke)>0){r.current.filtered.groups.add(De);break}r.current.filtered.count=Me}function J(){var ge,Ne,Ue;let Te=X();Te&&(((ge=Te.parentElement)==null?void 0:ge.firstChild)===Te&&((Ue=(Ne=Te.closest(nI))==null?void 0:Ne.querySelector(u6t))==null||Ue.scrollIntoView({block:"nearest"})),Te.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(YIe))||[])}function ae(ge){let Ne=ce()[ge];Ne&&V.setState("value",Ne.getAttribute(L5))}function ie(ge){var Ne;let Ue=X(),Te=ce(),Me=Te.findIndex(qe=>qe===Ue),De=Te[Me+ge];(Ne=i.current)!=null&&Ne.loop&&(De=Me+ge<0?Te[Te.length-1]:Me+ge===Te.length?Te[0]:Te[Me+ge]),De&&V.setState("value",De.getAttribute(L5))}function oe(ge){let Ne=X(),Ue=Ne==null?void 0:Ne.closest(nI),Te;for(;Ue&&!Te;)Ue=ge>0?b6t(Ue,nI):w6t(Ue,nI),Te=Ue==null?void 0:Ue.querySelector(YIe);Te?V.setState("value",Te.getAttribute(L5)):ie(ge)}let me=()=>ae(ce().length-1),ye=ge=>{ge.preventDefault(),ge.metaKey?me():ge.altKey?oe(1):ie(1)},he=ge=>{ge.preventDefault(),ge.metaKey?ae(0):ge.altKey?oe(-1):ie(-1)};return S.createElement(Jr.div,{ref:s,tabIndex:-1,...k,"cmdk-root":"",onKeyDown:ge=>{var Ne;(Ne=k.onKeyDown)==null||Ne.call(k,ge);let Ue=ge.nativeEvent.isComposing||ge.keyCode===229;if(!(ge.defaultPrevented||Ue))switch(ge.key){case"n":case"j":{w&&ge.ctrlKey&&ye(ge);break}case"ArrowDown":{ye(ge);break}case"p":case"k":{w&&ge.ctrlKey&&he(ge);break}case"ArrowUp":{he(ge);break}case"Home":{ge.preventDefault(),ae(0);break}case"End":{ge.preventDefault(),me();break}case"Enter":{ge.preventDefault();let Te=X();if(Te){let Me=new Event(i_e);Te.dispatchEvent(Me)}}}}},S.createElement("label",{"cmdk-label":"",htmlFor:q.inputId,id:q.labelId,style:k6t},d),Que(t,ge=>S.createElement(kYe.Provider,{value:V},S.createElement(NYe.Provider,{value:q},ge))))}),m6t=S.forwardRef((t,s)=>{var r,n;let a=fu(),o=S.useRef(null),l=S.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);S.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:k,onSelect:C,forceMount:A,keywords:I,...L}=t;return S.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)}),p6t=S.forwardRef((t,s)=>{let{heading:r,children:n,forceMount:a,...o}=t,l=fu(),i=S.useRef(null),d=S.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=S.useMemo(()=>({id:l,forceMount:a}),[a]);return S.createElement(Jr.div,{ref:m1(i,s),...o,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},r&&S.createElement("div",{ref:d,"cmdk-group-heading":"","aria-hidden":!0,id:u},r),Que(t,_=>S.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?u:void 0},S.createElement(SYe.Provider,{value:y},_))))}),f6t=S.forwardRef((t,s)=>{let{alwaysRender:r,...n}=t,a=S.useRef(null),o=sw(l=>!l.search);return!r&&!o?null:S.createElement(Jr.div,{ref:m1(a,s),...n,"cmdk-separator":"",role:"separator"})}),x6t=S.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 S.useEffect(()=>{t.value!=null&&o.setState("search",t.value)},[t.value]),S.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)}})}),g6t=S.forwardRef((t,s)=>{let{children:r,label:n="Suggestions",...a}=t,o=S.useRef(null),l=S.useRef(null),i=sw(u=>u.selectedItemId),d=GR();return S.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)}}},[]),S.createElement(Jr.div,{ref:m1(o,s),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":n,id:d.listId},Que(t,u=>S.createElement("div",{ref:m1(l,d.listInnerRef),"cmdk-list-sizer":""},u)))}),y6t=S.forwardRef((t,s)=>{let{open:r,onOpenChange:n,overlayClassName:a,contentClassName:o,container:l,...i}=t;return S.createElement(wue,{open:r,onOpenChange:n},S.createElement(jue,{container:l},S.createElement(UA,{"cmdk-overlay":"",className:a}),S.createElement(VA,{"aria-label":t.label,"cmdk-dialog":"",className:o},S.createElement(CYe,{ref:s,...i}))))}),v6t=S.forwardRef((t,s)=>sw(r=>r.filtered.count===0)?S.createElement(Jr.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),_6t=S.forwardRef((t,s)=>{let{progress:r,children:n,label:a="Loading...",...o}=t;return S.createElement(Jr.div,{ref:s,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},Que(t,l=>S.createElement("div",{"aria-hidden":!0},l)))}),_p=Object.assign(CYe,{List:g6t,Item:m6t,Input:x6t,Group:p6t,Separator:f6t,Dialog:y6t,Empty:v6t,Loading:_6t});function b6t(t,s){let r=t.nextElementSibling;for(;r;){if(r.matches(s))return r;r=r.nextElementSibling}}function w6t(t,s){let r=t.previousElementSibling;for(;r;){if(r.matches(s))return r;r=r.previousElementSibling}}function MYe(t){let s=S.useRef(t);return QS(()=>{s.current=t}),s}var QS=typeof window>"u"?S.useEffect:S.useLayoutEffect;function D5(t){let s=S.useRef();return s.current===void 0&&(s.current=t()),s}function sw(t){let s=YNe(),r=()=>t(s.snapshot());return S.useSyncExternalStore(s.subscribe,r,r)}function TYe(t,s,r,n=[]){let a=S.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 j6t=()=>{let[t,s]=S.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 N6t(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function Que({asChild:t,children:s},r){return t&&S.isValidElement(s)?S.cloneElement(N6t(s),{ref:s.ref},r(s.props.children)):r(s)}var k6t={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Sx=S.forwardRef(({className:t,...s},r)=>e.jsx(_p,{ref:r,className:Dt("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...s}));Sx.displayName=_p.displayName;const S6t=({children:t,...s})=>e.jsx(fs,{...s,children:e.jsx(hs,{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=S.forwardRef(({className:t,...s},r)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(an,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(_p.Input,{ref:r,className:Dt("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=_p.Input.displayName;const Mx=S.forwardRef(({className:t,...s},r)=>e.jsx(_p.List,{ref:r,className:Dt("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));Mx.displayName=_p.List.displayName;const Tx=S.forwardRef((t,s)=>e.jsx(_p.Empty,{ref:s,className:"py-6 text-center text-sm",...t}));Tx.displayName=_p.Empty.displayName;const Ax=S.forwardRef(({className:t,...s},r)=>e.jsx(_p.Group,{ref:r,className:Dt("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=_p.Group.displayName;const C6t=S.forwardRef(({className:t,...s},r)=>e.jsx(_p.Separator,{ref:r,className:Dt("-mx-1 h-px bg-border",t),...s}));C6t.displayName=_p.Separator.displayName;const lp=S.forwardRef(({className:t,...s},r)=>e.jsx(_p.Item,{ref:r,className:Dt("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}));lp.displayName=_p.Item.displayName;const M6t={event:{label:"Events",icon:yd,color:"bg-blue-500/10 text-blue-600"},template:{label:"Templates",icon:Fl,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"}},XIe=()=>{const[t,s]=S.useState(!1),[r,n]=S.useState(""),[a,o]=S.useState([]),[l,i]=S.useState(!1),d=vr();S.useEffect(()=>{const y=_=>{_.key==="k"&&(_.metaKey||_.ctrlKey)&&(_.preventDefault(),s(b=>!b))};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[]);const u=S.useCallback(async y=>{if(!y.trim()){o([]);return}i(!0);const _=`%${y}%`;try{const[b,N,w,k,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}`})}),k.data&&k.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)}},[]);S.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(K,{variant:"outline",className:"relative h-9 w-9 p-0 xl:h-9 xl:w-60 xl:justify-start xl:px-3 xl:py-2",onClick:()=>s(!0),children:[e.jsx(an,{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(S6t,{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=M6t[y],N=b.icon;return e.jsx(Ax,{heading:b.label,children:_.map(w=>e.jsxs(lp,{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)})]})]})]})},T6t=({expiresAt:t,className:s,showUpgradeButton:r=!0})=>{const[n,a]=S.useState(null),o=vr();if(S.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:Dt("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(K,{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:Dt("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(on,{className:Dt("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:Dt("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:Dt("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.days,"d"]}),e.jsxs("span",{className:Dt("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.hours,"h"]}),e.jsxs("span",{className:Dt("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.minutes,"m"]}),e.jsx("span",{className:Dt("text-xs",i?"text-destructive/70":d?"text-amber-600/70":"text-primary/70"),children:"remaining"})]})]})]}),r&&e.jsxs(K,{size:"sm",onClick:()=>o("/subscription"),variant:i?"destructive":d?"default":"outline",className:Dt("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"]})]})},A6t=()=>{const t=vr();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(Lt,{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(Ft,{className:"text-2xl",children:"Your Free Trial Has Ended"}),e.jsx(ur,{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(Re,{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(Re,{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(or,{className:"h-6 w-6 text-primary"})}),e.jsx("h3",{className:"font-semibold text-lg mb-1",children:"Individual Agent"}),e.jsxs("p",{className:"text-2xl font-bold text-primary mb-2",children:["$39",e.jsx("span",{className:"text-sm font-normal text-muted-foreground",children:"/mo"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Perfect for solo agents ready to level up"}),e.jsxs(K,{className:"w-full",onClick:s=>{s.stopPropagation(),t("/subscription")},children:[e.jsx(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(Re,{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(K,{variant:"outline",className:"w-full border-amber-500 text-amber-600 hover:bg-amber-50",onClick:s=>{s.stopPropagation(),t("/subscription")},children:[e.jsx(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"})]})]})]})]})]})})},E6t=({hasUnseenBrief:t,onClick:s,className:r})=>e.jsxs(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"icon",onClick:s,className:Dt("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(Ll,{children:e.jsx("p",{children:"The LevelUp Brief"})})]});var Jue="Checkbox",[P6t,cAs]=qc(Jue),[I6t,XNe]=P6t(Jue);function L6t(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:Jue}),[b,N]=S.useState(null),[w,k]=S.useState(null),C=S.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:k};return e.jsx(I6t,{scope:s,...I,children:D6t(f)?f(I):n})}var AYe="CheckboxTrigger",EYe=S.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=S.useRef(d);return S.useEffect(()=>{const k=o==null?void 0:o.form;if(k){const C=()=>f(w.current);return k.addEventListener("reset",C),()=>k.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:Sr(s,k=>{k.key==="Enter"&&k.preventDefault()}),onClick:Sr(r,k=>{f(C=>Db(C)?!0:!C),b&&_&&(y.current=k.isPropagationStopped(),y.current||k.stopPropagation())})})});EYe.displayName=AYe;var QNe=S.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(L6t,{__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=Jue;var PYe="CheckboxIndicator",IYe=S.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=S.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);S.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 k=S.useRef(Db(o)?!1:o);return e.jsx(Jr.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??k.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 D6t(t){return typeof t=="function"}function Db(t){return t==="indeterminate"}function RYe(t){return Db(t)?"indeterminate":t?"checked":"unchecked"}const Hi=S.forwardRef(({className:t,...s},r)=>e.jsx(QNe,{ref:r,className:Dt("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:Dt("flex items-center justify-center text-current"),children:e.jsx(Zn,{className:"h-4 w-4"})})}));Hi.displayName=QNe.displayName;var JNe="Radio",[R6t,OYe]=qc(JNe),[O6t,F6t]=R6t(JNe),FYe=S.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]=S.useState(null),_=Ta(s,w=>y(w)),b=S.useRef(!1),N=f?u||!!f.closest("form"):!0;return e.jsxs(O6t,{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:Sr(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=S.forwardRef((t,s)=>{const{__scopeRadio:r,forceMount:n,...a}=t,o=F6t(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 z6t="RadioBubbleInput",$Ye=S.forwardRef(({__scopeRadio:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=S.useRef(null),i=Ta(l,o),d=zR(r),u=kR(s);return S.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=z6t;function qYe(t){return t?"checked":"unchecked"}var B6t=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],ehe="RadioGroup",[$6t,dAs]=qc(ehe,[pw,OYe]),UYe=pw(),VYe=OYe(),[q6t,U6t]=$6t(ehe),HYe=S.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:ehe});return e.jsx(q6t,{scope:r,name:n,required:l,disabled:i,value:N,onValueChange:w,children:e.jsx(pue,{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=ehe;var GYe="RadioGroupItem",WYe=S.forwardRef((t,s)=>{const{__scopeRadioGroup:r,disabled:n,...a}=t,o=U6t(GYe,r),l=o.disabled||n,i=UYe(r),d=VYe(r),u=S.useRef(null),p=Ta(s,u),f=o.value===a.value,y=S.useRef(!1);return S.useEffect(()=>{const _=N=>{B6t.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(fue,{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:Sr(_=>{_.key==="Enter"&&_.preventDefault()}),onFocus:Sr(a.onFocus,()=>{var _;y.current&&((_=u.current)==null||_.click())})})})});WYe.displayName=GYe;var V6t="RadioGroupIndicator",KYe=S.forwardRef((t,s)=>{const{__scopeRadioGroup:r,...n}=t,a=VYe(r);return e.jsx(BYe,{...a,...n,ref:s})});KYe.displayName=V6t;var ZYe=HYe,YYe=WYe,H6t=KYe;const eke=S.forwardRef(({className:t,...s},r)=>e.jsx(ZYe,{className:Dt("grid gap-2",t),...s,ref:r}));eke.displayName=ZYe.displayName;const _le=S.forwardRef(({className:t,...s},r)=>e.jsx(YYe,{ref:r,className:Dt("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(H6t,{className:"flex items-center justify-center",children:e.jsx(sd,{className:"h-2.5 w-2.5 fill-current text-current"})})}));_le.displayName=YYe.displayName;const G6t=({brief:t,open:s,onClose:r,onDismiss:n})=>{const{user:a}=qs(),[o,l]=S.useState({}),[i,d]=S.useState({}),[u,p]=S.useState([]);S.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:k}=await G.from("levelup_brief_poll_responses").select("poll_id, option_id").eq("user_id",a.id).in("poll_id",w);if(k){const C={};k.forEach(A=>{C[A.poll_id]||(C[A.poll_id]=[]),C[A.poll_id].push(A.option_id)}),d(C)}},y=(w,k)=>{l(C=>({...C,[w]:k}))},_=(w,k,C)=>{l(A=>{const I=A[w]||[];return C?{...A,[w]:[...I,k]}:{...A,[w]:I.filter(L=>L!==k)}})},b=async w=>{if(!a)return;const k=o[w];if(!k||Array.isArray(k)&&k.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(k)?k:[k],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(hs,{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(jr,{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(ni,{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(K,{variant:"outline",size:"sm",onClick:()=>window.open(w.url,"_blank"),className:"gap-2",children:[e.jsx(Zr,{className:"h-4 w-4"}),w.title]},w.id))})]}),t.polls.map(w=>{var A,I;const k=((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}),k&&e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[e.jsx(Hn,{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(_le,{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(Hi,{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(K,{size:"sm",onClick:()=>b(w.id),disabled:C,children:C?"Submitting...":k?"Update Response":"Submit"})]},w.id)})]})}),e.jsxs("div",{className:"p-4 pb-[calc(1rem+env(safe-area-inset-bottom))] border-t bg-muted/30 flex flex-col items-center gap-2 sticky bottom-0 z-10",children:[e.jsx(K,{onClick:r,className:"w-full max-w-xs",children:"Got it!"}),e.jsx(K,{variant:"ghost",size:"sm",onClick:n,children:"Don't show again"})]})]})})},W6t=()=>{const{user:t}=qs(),[s,r]=S.useState(null),[n,a]=S.useState(!1),[o,l]=S.useState(!0),[i,d]=S.useState(!1),u=S.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(),[k,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:k.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]);S.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 K6t(){const[t,s]=S.useState(!1),[r,n]=S.useState(!1),[a,o]=S.useState(null);S.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(K,{size:"sm",variant:"secondary",onClick:i,className:"text-xs",children:"Install"}),e.jsx("button",{onClick:l,className:"p-1.5 hover:bg-primary-foreground/10 rounded-full transition-colors","aria-label":"Dismiss",children:e.jsx(jr,{className:"h-4 w-4"})})]})]})}):null}const Z6t=({children:t,onRefresh:s})=>{const[r,n]=S.useState(!1),[a,o]=S.useState(0),[l,i]=S.useState(!1),d=S.useRef(null),u=S.useRef(0),p=Qt(),f=80,y=120,_=S.useCallback(C=>{const A=d.current;A&&A.scrollTop<=0&&(u.current=C.touches[0].clientY,n(!0))},[]),b=S.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=S.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),k=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(${k}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}=qs(),[s,r]=S.useState(!1),[n,a]=S.useState(!1),[o,l]=S.useState(0),[i,d]=S.useState(!0);S.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=S.useCallback(()=>{sessionStorage.setItem("review-prompt-dismissed","true"),r(!1)},[]),p=S.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=S.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}},Y6t="https://search.google.com/local/writereview?placeid=ChIJM73ERQD1QogRPxupMFObuck&source=g.page.m.ia._&laa=nmx-review-solicitation-ia2",X6t=()=>{const{shouldShowPrompt:t,isLoading:s,dismissPrompt:r,submitReview:n,markPostedToGoogle:a}=XYe(),[o,l]=S.useState(!1),[i,d]=S.useState("review"),[u,p]=S.useState(0),[f,y]=S.useState(0),[_,b]=S.useState(""),[N,w]=S.useState(!1),[k,C]=S.useState(!1);if(s||!t&&!k)return null;const A=async()=>{if(u===0){pn({title:"Please select a rating",variant:"destructive"});return}w(!0);const O=await n(u,_);w(!1),O.success?(C(!0),pn({title:"Thank you for your feedback!",description:"Your review helps us improve."}),d("google")):pn({title:"Error submitting review",description:O.error,variant:"destructive"})},I=async O=>{O&&(await navigator.clipboard.writeText(_||`${u} star rating for LevelUp!`),pn({title:"Review copied!",description:"Paste it on Google Reviews."}),await a(),window.open(Y6t,"_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(hs,{className:"sm:max-w-md",children:i==="review"?e.jsxs(e.Fragment,{children:[e.jsxs(js,{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:Dt("h-8 w-8 transition-colors",(f||u)>=O?"fill-yellow-400 text-yellow-400":"text-muted-foreground")})},O))}),e.jsx(gr,{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(K,{variant:"outline",onClick:L,className:"flex-1",children:"Maybe Later"}),e.jsx(K,{onClick:A,disabled:N||u===0,className:"flex-1",children:N?"Submitting...":"Submit Review"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(js,{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(K,{variant:"outline",onClick:()=>I(!1),className:"flex-1",children:"No Thanks"}),e.jsx(K,{onClick:()=>I(!0),className:"flex-1",children:"Yes, Open Google"})]})]})]})})})]})};function Q6t(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 k=await navigator.serviceWorker.register("/push-sw.js",{scope:"/push-notifications/"});d(k),r(Notification.permission);const C=await k.pushManager.getSubscription();a(!!C)}catch(N){console.error("Error initializing push notifications:",N)}finally{l(!1)}})()},[f]);const y=S.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=Q6t(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 k=w.toJSON(),{error:C}=await G.from("push_subscriptions").upsert({user_id:t.id,endpoint:k.endpoint,p256dh_key:k.keys.p256dh,auth_key:k.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]),_=S.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 qge="push_notification_prompt_dismissed",J6t=["/dashboard","/admin"],eIt=()=>{const{user:t}=qs(),{isSupported:s,isSubscribed:r,isLoading:n,subscribe:a}=QYe(),o=Bl(),[l,i]=S.useState(!1),[d,u]=S.useState(!1),p=J6t.some(_=>o.pathname===_||o.pathname.startsWith(`${_}/`));S.useEffect(()=>{if(p){i(!1);return}if(!t||!s||r||n||localStorage.getItem(`${qge}_${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(`${qge}_${t.id}`,"true"),i(!1))},y=()=>{t&&localStorage.setItem(`${qge}_${t.id}`,"true"),i(!1)};return!s||r||p?null:e.jsx(fs,{open:l,onOpenChange:_=>!_&&y(),children:e.jsxs(hs,{className:"sm:max-w-md",children:[e.jsxs(js,{children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-primary/10",children:e.jsx(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(K,{onClick:f,disabled:d,className:"w-full",children:d?"Enabling...":"Enable Notifications"}),e.jsx(K,{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."})]})})},QIe=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},tIt=t=>t?QIe(t):QIe,sIt=t=>t;function rIt(t,s=sIt){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 JIe=t=>{const s=tIt(t),r=n=>rIt(s,n);return Object.assign(r,s),r},nIt=t=>t?JIe(t):JIe;function aIt(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)}}}},iIt=(t,s)=>(r,n,a)=>{let o={storage:aIt(()=>window.localStorage),partialize:w=>w,version:0,merge:(w,k)=>({...k,...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,k)=>(y(w,k),f());const _=t((...w)=>(r(...w),f()),n,a);a.getInitialState=()=>_;let b;const N=()=>{var w,k;if(!p)return;const C=++i;l=!1,d.forEach(I=>{var L;return I((L=n())!=null?L:_)});const A=((k=o.onRehydrateStorage)==null?void 0:k.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||_},oIt=iIt,the=nIt()(oIt((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}=qs(),{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=S.createContext({onlineUsers:[],totalOnline:0}),lIt=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{}},cIt=({children:t})=>{const{user:s,brokerageId:r,isAdmin:n}=qs(),[a,o]=S.useState([]),[l,i]=S.useState(null);S.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 lIt(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=()=>S.useContext(JYe),eLe="dashboard-sidebar-collapsed",Es=({children:t,title:s})=>{var fe;const{user:r,signOut:n,isAdmin:a,isBrokerageManager:o,brokerageId:l}=qs(),{isAssistant:i,actingAsAgent:d,hasPermission:u}=Eje(),{isImpersonating:p}=hue(),y=(i&&!!d?40:0)+(p?40:0),{avatarUrl:_}=QZe(r==null?void 0:r.id),{isTrial:b,isExpired:N,expiresAt:w}=yPt(r==null?void 0:r.id),{isInnerCircleEnabled:k,isMarketplaceEnabled:C}=eYe(),{currentBrief:A,shouldShowPopup:I,hasUnseenBrief:L,openBrief:O,closeBrief:V,dismissBrief:q}=W6t(),{unreadCount:B}=vPt(),{openCount:U}=_Pt(),{data:te}=Px(),Y=!!te,X=the(He=>He.cartItems).reduce((He,et)=>He+et.quantity,0),{leadSite:ce,hasLeadSite:ae,siteUrl:ie}=CC(),oe=vr(),me=Bl(),[ye,he]=S.useState(null);S.useEffect(()=>{r!=null&&r.id&&G.from("profiles").select("name").eq("id",r.id).single().then(({data:He})=>{He!=null&&He.name&&he(He.name)})},[r==null?void 0:r.id]);const ge=ye||((fe=r==null?void 0:r.user_metadata)==null?void 0:fe.name)||(r==null?void 0:r.email)||"User",[Ne,Ue]=S.useState(()=>typeof window<"u"?localStorage.getItem(eLe)==="true":!1);S.useEffect(()=>{localStorage.setItem(eLe,String(Ne))},[Ne]);const[Te,Me]=S.useState({agentos:!0,tools:!0,marketing:!0,learning:!0,community:!0,contacts:!0,website:!0,help:!1}),De=He=>{Me(et=>({...et,[He]:!et[He]}))},qe=He=>He.split(" ").map(et=>et[0]).join("").toUpperCase().slice(0,2),ke=He=>me.pathname===He,$e=He=>He.some(et=>me.pathname===et),Be=({path:He,icon:et,label:tt,badgeCount:_e})=>{const Ge=e.jsxs(K,{variant:"ghost",size:"sm",className:Dt("text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",ke(He)&&"bg-sidebar-accent text-sidebar-accent-foreground",Ne?"w-10 h-10 p-0 justify-center":"w-full justify-start gap-2"),onClick:()=>oe(He),children:[e.jsxs("div",{className:"relative",children:[e.jsx(et,{className:"h-4 w-4 shrink-0"}),Ne&&_e!=null&&_e>0&&e.jsx("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-muted-foreground/40 border border-background"})]}),!Ne&&tt,!Ne&&_e!=null&&_e>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:_e>9?"9+":_e})]});return Ne?e.jsxs(Jl,{delayDuration:0,children:[e.jsx(ec,{asChild:!0,children:Ge}),e.jsxs(Ll,{side:"right",className:"flex items-center gap-2",children:[tt,_e!=null&&_e>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:_e>9?"9+":_e})]})]}):Ge},we=({id:He,label:et,icon:tt,children:_e,activePaths:Ge,showBetaBadge:We,defaultPath:it,badgeCount:Ve})=>{if(Ne){const Xe=it||Ge[0];return e.jsxs(Jl,{delayDuration:0,children:[e.jsx(ec,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:Dt("w-10 h-10 p-0 justify-center text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",$e(Ge)&&"text-primary"),onClick:()=>oe(Xe),children:e.jsxs("div",{className:"relative",children:[e.jsx(tt,{className:"h-4 w-4"}),Ve!=null&&Ve>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(Ll,{side:"right",className:"flex items-center gap-2",children:[et,We&&e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 rounded border border-amber-500 text-amber-600",children:"Beta"}),Ve!=null&&Ve>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:Ve>9?"9+":Ve})]})]})}return e.jsxs(lf,{open:Te[He],onOpenChange:()=>De(He),children:[e.jsx(cf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:Dt("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",$e(Ge)&&"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"}),et,We&&e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsxs("span",{className:"flex items-center gap-1",children:[Ve!=null&&Ve>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:Ve>9?"9+":Ve}),e.jsx(Fi,{className:Dt("h-4 w-4 transition-transform duration-200",Te[He]&&"rotate-180")})]})]})}),e.jsx(df,{className:"pl-4 space-y-1 mt-1",children:_e})]})},ut=({isMobile:He=!1})=>{const et=He?!1:Ne;return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:Dt("p-3 border-b border-sidebar-border",et?"flex flex-col items-center gap-2":"flex items-center justify-between"),children:[et?e.jsx("img",{src:MPt,alt:"LevelUp",className:"h-8 w-auto"}):e.jsx("img",{src:CPt,alt:"LevelUp",className:"h-8 w-auto"}),!He&&e.jsxs(Jl,{delayDuration:0,children:[e.jsx(ec,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>Ue(!et),children:e.jsx(Xo,{className:Dt("h-4 w-4 transition-transform duration-300",et&&"rotate-180")})})}),e.jsx(Ll,{side:"right",children:et?"Expand sidebar":"Collapse sidebar"})]})]}),e.jsx(ni,{className:"flex-1 [&_[data-radix-scroll-area-scrollbar]]:w-1.5",children:e.jsxs("nav",{className:Dt("p-3 space-y-1",et&&"flex flex-col items-center"),children:[e.jsx(Be,{path:"/dashboard",icon:aS,label:"Dashboard"}),e.jsx(Be,{path:"/apps",icon:Xf,label:"Apps & Tools"}),Ne?e.jsxs(Jl,{delayDuration:0,children:[e.jsx(ec,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:Dt("w-10 h-10 p-0 justify-center relative text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ke("/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(Ll,{side:"right",className:"flex items-center gap-2",children:["LevelUp U",e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-primary-foreground bg-primary rounded px-1 py-0.5",children:"New"})]})]}):e.jsxs(K,{variant:"ghost",size:"sm",className:Dt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ke("/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(Be,{path:"/events",icon:yd,label:"Events"}),e.jsxs(we,{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(Be,{path:"/mission-control",icon:Xa,label:"Mission Control"}),u("contacts")&&!et&&e.jsxs(lf,{open:Te.contacts,onOpenChange:()=>De("contacts"),children:[e.jsx(cf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:Dt("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",$e(["/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(or,{className:"h-4 w-4"}),"Contacts"]}),e.jsx(Fi,{className:Dt("h-3.5 w-3.5 transition-transform duration-200",Te.contacts&&"rotate-180")})]})}),e.jsxs(df,{className:"pl-4 pr-1 space-y-0.5 mt-0.5",children:[e.jsx(Be,{path:"/mission-control/contacts",icon:or,label:"All Contacts"}),e.jsx(Be,{path:"/mission-control/relationship-scorecard",icon:lh,label:"Relationship Report"}),e.jsx(Be,{path:"/mission-control/sphere-gaps",icon:OL,label:"Sphere Gaps"}),e.jsx(Be,{path:"/mission-control/connect-page",icon:Do,label:"Connect Page"})]})]}),u("contacts")&&et&&e.jsx(Be,{path:"/mission-control/contacts",icon:or,label:"Contacts"}),u("contacts")&&e.jsx(Be,{path:"/mission-control/plans",icon:yd,label:"TouchPlans"}),u("pipeline")&&e.jsx(Be,{path:"/mission-control/pipeline",icon:Yy,label:"Deal Pipeline"}),u("pipeline")&&e.jsx(Be,{path:"/mission-control/tasks",icon:Pv,label:"Tasks"}),u("popbys")&&e.jsx(Be,{path:"/mission-control/popbys",icon:yi,label:"Popbys"}),u("videos")&&e.jsx(Be,{path:"/mission-control/video-library",icon:gn,label:"Video Library"}),u("scorecard")&&e.jsx(Be,{path:"/mission-control/scorecard",icon:so,label:"Scorecard"}),u("listings")&&e.jsx(Be,{path:"/mission-control/listings",icon:pa,label:"Listing Exchange"}),!et&&e.jsxs(K,{variant:"ghost",size:"sm",className:Dt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ke("/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"})]}),et&&e.jsx(Be,{path:"/mission-control/smart-drips",icon:Oh,label:"Smart Drips"})]}),ae&&ce&&e.jsxs(we,{id:"website",label:"My Website",icon:nd,activePaths:[`/admin/lead-sites/${ce.id}/edit`],defaultPath:`/admin/lead-sites/${ce.id}/edit`,children:[et?e.jsxs(Jl,{delayDuration:0,children:[e.jsx(ec,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:"w-10 h-10 p-0 justify-center text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>window.open(ie||"#","_blank"),children:e.jsx(Cn,{className:"h-4 w-4"})})}),e.jsx(Ll,{side:"right",children:"View Site"})]}):e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>window.open(ie||"#","_blank"),children:[e.jsx(Cn,{className:"h-4 w-4"}),"View Site",e.jsx(Zr,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsx(Be,{path:`/my-website/${ce.id}/edit`,icon:ga,label:"Edit Website"}),e.jsx(Be,{path:"/my-website/mls-listings",icon:Sn,label:"MLS Listings"}),e.jsx(Be,{path:"/my-website/market-report",icon:so,label:"Market Reports"}),e.jsx(Be,{path:"/mission-control/website-activity",icon:lh,label:"Website Activity"}),e.jsx(Be,{path:"/m",icon:Ig,label:"Mobile Command"})]}),e.jsxs(we,{id:"marketing",label:"Marketing",icon:uh,activePaths:["/templates","/social-swag-2","/newsletters"],defaultPath:"/templates",children:[e.jsx(Be,{path:"/templates",icon:Fl,label:"Templates"}),e.jsx(Be,{path:"/social-swag-2",icon:Ig,label:"Social Swag"}),e.jsx(Be,{path:"/newsletters",icon:Jv,label:"Newsletters"})]}),e.jsxs(we,{id:"learning",label:"Learning",icon:ch,activePaths:["/academy","/toolbox"],defaultPath:"/academy",children:[e.jsx(Be,{path:"/academy",icon:Lh,label:"Academy"}),e.jsx(Be,{path:"/toolbox",icon:Lg,label:"Toolbox"})]}),e.jsxs(we,{id:"community",label:"Community",icon:Si,activePaths:["/community","/wishlist"],defaultPath:"/community",badgeCount:B,children:[e.jsx(Be,{path:"/community",icon:or,label:"Community",badgeCount:B}),e.jsx(Be,{path:"/wishlist",icon:Cb,label:"Wishlist",badgeCount:U}),!et&&e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>window.open("https://www.facebook.com/share/g/1CC6thti2V/","_blank"),children:[e.jsx(Zr,{className:"h-4 w-4"}),"Facebook Group"]})]}),e.jsxs(we,{id:"goods",label:"The Goods",icon:op,activePaths:["/marketplace","/reward-store"],defaultPath:"/reward-store",children:[C&&!et&&e.jsxs(K,{variant:"ghost",size:"sm",className:Dt("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(op,{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&&et&&e.jsx(Be,{path:"/marketplace",icon:op,label:"Marketplace"}),e.jsx(Be,{path:"/reward-store",icon:Vi,label:"Reward Store"})]}),e.jsxs(we,{id:"help",label:"Help & Services",icon:Mv,activePaths:["/support","/additional-services"],defaultPath:"/support",children:[e.jsx(Be,{path:"/support",icon:TM,label:"Support"}),e.jsx(Be,{path:"/additional-services",icon:Or,label:"Additional Services"})]}),a&&e.jsxs(e.Fragment,{children:[!et&&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"})}),et?e.jsx("div",{className:"pt-3 border-t border-sidebar-border mt-3 space-y-1",children:e.jsx(Be,{path:"/admin",icon:vd,label:"Admin Dashboard"})}):e.jsxs(K,{variant:"ghost",size:"sm",className:Dt("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(vd,{className:"h-4 w-4"}),"Admin Dashboard"]})]}),(l||o)&&!a&&e.jsxs(e.Fragment,{children:[!et&&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"})}),et?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(Be,{path:"/my-brokerage",icon:pa,label:"My Brokerage"}),e.jsx(Be,{path:"/brokerage-content",icon:ch,label:"Brokerage Content"})]}),Y&&!o&&e.jsx(Be,{path:"/my-team",icon:or,label:"My Team"}),o&&e.jsxs(e.Fragment,{children:[e.jsx(Be,{path:"/brokerage/dashboard",icon:So,label:"Manage Brokerages"}),e.jsx(Be,{path:"/brokerage/teams",icon:or,label:"Teams"}),e.jsx(Be,{path:"/brokerage/recruiting",icon:uh,label:"Recruiting"}),e.jsx(Be,{path:"/brokerage-resources",icon:dh,label:"Brokerage Resources"})]})]}):e.jsxs(e.Fragment,{children:[l&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"ghost",size:"sm",className:Dt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ke("/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(K,{variant:"ghost",size:"sm",className:Dt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ke("/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(K,{variant:"ghost",size:"sm",className:Dt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ke("/my-team")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/my-team"),children:[e.jsx(or,{className:"h-4 w-4"}),"My Team"]}),o&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"ghost",size:"sm",className:Dt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ke("/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(K,{variant:"ghost",size:"sm",className:Dt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ke("/brokerage/teams")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/brokerage/teams"),children:[e.jsx(or,{className:"h-4 w-4"}),"Teams",e.jsx("span",{className:"ml-auto text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"New"})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:Dt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ke("/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(K,{variant:"ghost",size:"sm",className:Dt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ke("/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(K,{variant:"ghost",size:"sm",className:Dt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ke("/profile")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>oe("/profile"),children:[e.jsx(Ai,{className:"h-4 w-4"}),"Profile"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:n,children:[e.jsx(EM,{className:"h-4 w-4"}),"Sign Out"]})]})]})};return e.jsx(cIt,{children:e.jsx(S1,{children:e.jsxs("div",{className:"min-h-screen bg-background flex",children:[b&&N&&e.jsx(A6t,{}),typeof document<"u"&&ip.createPortal(e.jsx("aside",{className:Dt("hidden md:flex flex-col bg-card border-r border-border fixed left-0 z-30 !pointer-events-auto transition-[width] duration-300",Ne?"w-16":"w-56"),style:{top:`${y}px`,height:`calc(100vh - ${y}px)`},children:e.jsx(ut,{})}),document.body),e.jsxs("div",{className:Dt("flex-1 flex flex-col overflow-hidden transition-all duration-300",Ne?"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(K,{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(ut,{isMobile:!0})})]}),e.jsx("div",{className:"flex-1 md:hidden",children:e.jsx("img",{src:TPt,alt:"LevelUp",className:"h-8 w-auto"})}),e.jsx("div",{className:"hidden md:flex flex-1 justify-center",children:e.jsx(XIe,{})}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[b&&!N&&w&&e.jsx(T6t,{expiresAt:w,className:"hidden lg:flex"}),e.jsx("div",{className:"md:hidden",children:e.jsx(XIe,{})}),A&&e.jsx(E6t,{hasUnseenBrief:L,onClick:O}),C&&e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",onClick:()=>oe("/marketplace/cart"),children:[e.jsx(op,{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(t6t,{}),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(wn,{className:"h-9 w-9 cursor-pointer hover:opacity-80 transition-opacity",children:[e.jsx(Ma,{src:_||void 0}),e.jsx(jn,{className:"bg-primary text-primary-foreground font-medium text-sm",children:qe(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(Z6t,{children:e.jsx("main",{className:"p-4 sm:p-6 lg:p-8 overflow-x-hidden",children:t})}),A&&e.jsx(G6t,{brief:A,open:I,onClose:V,onDismiss:q}),e.jsx(K6t,{}),e.jsx(X6t,{}),e.jsx(eIt,{})]})]})})})},dIt=()=>{const{user:t}=qs(),[s,r]=S.useState(!1),[n,a]=S.useState(null),[o,l]=S.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(Es,{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(Le,{id:"coupon",placeholder:"Enter discount code",value:o,onChange:f=>l(f.target.value),className:"mt-1"})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6 mb-8",children:[e.jsxs(Pe,{className:"border-2 border-primary/20 hover:border-primary/50 transition-colors relative overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 right-0 bg-primary text-primary-foreground text-xs px-3 py-1 rounded-bl-lg font-medium",children:"Popular"}),e.jsxs(Lt,{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(or,{className:"h-7 w-7 text-primary"})}),e.jsx(Ft,{className:"text-xl",children:"Individual Agent"}),e.jsx(ur,{children:"Perfect for solo agents ready to level up"})]}),e.jsxs(Re,{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(K,{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(Lt,{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(Ft,{className:"text-xl",children:"Brokerage"}),e.jsx(ur,{children:"For teams and brokerages up to 25 agents"})]}),e.jsxs(Re,{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(K,{variant:"outline",className:"w-full border-amber-500 text-amber-600 hover:bg-amber-50",size:"lg",onClick:()=>i("brokerage_under_25"),disabled:s,children:[s&&n==="brokerage_under_25"?e.jsx(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(Lt,{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(Ft,{className:"text-xl",children:"Brokerage 25+"}),e.jsx(ur,{children:"For larger brokerages with 25+ agents"})]}),e.jsxs(Re,{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(K,{variant:"outline",className:"w-full border-purple-500 text-purple-600 hover:bg-purple-50",size:"lg",onClick:()=>i("brokerage_over_25"),disabled:s,children:[s&&n==="brokerage_over_25"?e.jsx(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(Re,{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"})]})]})]})})]})})},uIt=()=>{const{user:t,loading:s,isBrokerageManager:r,brokerageId:n}=qs(),a=vr(),[o,l]=S.useState(""),[i,d]=S.useState(!1),[u,p]=S.useState(!1);S.useEffect(()=>{!s&&!t&&a("/auth")},[t,s,a]),S.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(Lt,{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(Ft,{className:"text-2xl",children:"Setting Up Your Brokerage"}),e.jsx(ur,{className:"text-lg",children:"We're assigning you as the brokerage manager and preparing your dashboard..."})]}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground",children:[e.jsx(ti,{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(Lt,{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(Ft,{className:"text-2xl",children:"Set Up Your Brokerage"}),e.jsx(ur,{className:"text-lg",children:"Create your brokerage to start managing your team"})]}),e.jsxs(Re,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"brokerage-name",children:"Brokerage Name"}),e.jsx(Le,{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(or,{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(ti,{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(ti,{className:"w-4 h-4 text-green-500"}),"Access exclusive brokerage resources"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(ti,{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(ti,{className:"w-4 h-4 text-green-500"}),"Share resources with your agents"]})]})]}),e.jsxs(K,{onClick:f,className:"w-full",disabled:i||!o.trim(),children:[i?"Creating...":"Create Brokerage",e.jsx(Ga,{className:"w-4 h-4 ml-2"})]})]})]})})},tLe=()=>{const t=vr(),[s,r]=S.useState("verifying"),[n,a]=S.useState("");S.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(Lt,{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(Ft,{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(ur,{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(Re,{children:e.jsx(K,{onClick:o,className:"w-full",children:"Go to Login"})})]})})},hIt=()=>{const t=vr(),[s]=Nc(),[r,n]=S.useState(s.get("code")||""),[a,o]=S.useState(""),[l,i]=S.useState(""),[d,u]=S.useState(""),[p,f]=S.useState(!1),[y,_]=S.useState(!1),[b,N]=S.useState(!1),[w,k]=S.useState(!1),[C,A]=S.useState(null),[I,L]=S.useState(null),[O,V]=S.useState(null),[q,B]=S.useState(null);S.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:ae,error:ie}=await G.auth.signUp({email:a.trim(),password:l,options:{emailRedirectTo:ce,data:{name:d.trim()}}});if(ie){ie.message.includes("already registered")?pe.error("This email is already registered. Please sign in instead."):pe.error(ie.message);return}ae.user&&(await G.rpc("add_default_signup_tag",{user_id:ae.user.id}),I?await G.functions.invoke("assign-brokerage",{body:{userId:ae.user.id,brokerageId:I}}):q?await G.functions.invoke("assign-brokerage",{body:{userId:ae.user.id,trialDays:q}}):await G.functions.invoke("assign-brokerage",{body:{userId:ae.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(Lt,{className:"text-center",children:[e.jsx(Ft,{className:"text-2xl font-bold text-primary",children:O?`Join ${O}`:"Join LevelUp"}),e.jsx(ur,{children:w?O?`Create your account to join ${O}`:"Create your account to get started":"Enter your invite code to continue"})]}),e.jsx(Re,{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(Le,{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(Le,{id:"email",type:"email",placeholder:"you@example.com",value:a,onChange:J=>o(J.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"password",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(Le,{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(mp,{className:"h-4 w-4"}):e.jsx(Cn,{className:"h-4 w-4"})})]})]}),e.jsx(K,{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(Le,{id:"inviteCode",type:"text",placeholder:"Enter your invite code",value:r,onChange:J=>n(J.target.value),required:!0,autoFocus:!0})]}),e.jsx(K,{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"})]})})]})})},mIt="/assets/testimonial-avatar-1-BsCQFauB.jpg",pIt="/assets/testimonial-avatar-2-B6VPVc2t.jpg",fIt="/assets/testimonial-avatar-3-GuEFwYUE.jpg",xIt="/assets/testimonial-avatar-4-98iKMtkB.jpg",gIt="/assets/testimonial-avatar-5-ZsZfyxMX.jpg",yIt=[mIt,pIt,fIt,xIt,gIt],vIt=kC({name:Yl().trim().min(2,"Name must be at least 2 characters").max(100),email:Yl().trim().email("Please enter a valid email address").max(255),phone:Yl().trim().min(10,"Please enter a valid phone number").max(20).optional().or(rle("")),brokerage:Yl().trim().max(200).optional().or(rle(""))}),_It=[{icon:sp,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:Fl,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:ln,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:Ol,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:yn,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:yi,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],bIt=[{icon:or,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."}],wIt=[{name:"Sarah M.",role:"Top Producer, RE/MAX",quote:"LevelUp completely transformed how I run my business. The templates alone save me hours every week."},{name:"Mike T.",role:"Brokerage Owner",quote:"Onboarding new agents used to take weeks. Now they're productive from day one with all the training resources."},{name:"Jessica L.",role:"Team Lead",quote:"The community is incredible. I've learned more from other agents here than any conference I've attended."}],jIt=()=>{const t=vr(),[s,r]=S.useState(!1),[n,a]=S.useState({name:"",email:"",phone:"",brokerage:""}),[o,l]=S.useState({}),i=async d=>{var p,f;d.preventDefault(),l({});const u=vIt.safeParse(n);if(!u.success){const y={};u.error.errors.forEach(_=>{_.path[0]&&(y[_.path[0]]=_.message)}),l(y);return}r(!0);try{const{data:y,error:_}=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}});if(_){console.error("Trial signup error:",_),pe.error(_.message||"Something went wrong. Please try again.");return}if(y!=null&&y.error){pe.error(y.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(nc,{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:fle,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[e.jsx(K,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var d;return(d=document.getElementById("features"))==null?void 0:d.scrollIntoView({behavior:"smooth"})},children:"Features"}),e.jsx(K,{onClick:()=>t("/auth"),className:"bg-white text-[#4a6b6d] hover:bg-gray-100 font-medium shadow-md",children:"Sign In"})]})]})}),e.jsxs("section",{className:"relative pt-24 pb-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"grid lg:grid-cols-2 gap-12 items-center",children:[e.jsxs("div",{className:"space-y-8 text-center lg:text-left",children:[e.jsx("div",{className:"flex justify-center lg:justify-start",children:e.jsx("img",{alt:"LevelUp Consulting Group",className:"h-24 md:h-32 drop-shadow-lg",src:"/lovable-uploads/3a0c7ef9-9e79-411f-a9af-6f2a99e8bd7b.webp"})}),e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white/10 text-white text-sm font-medium",children:[e.jsx(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(Hn,{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(Hn,{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:yIt.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(Re,{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(Le,{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(Le,{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(Le,{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(Le,{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(K,{type:"submit",className:"w-full h-12 text-lg font-semibold bg-[#4a6b6d] hover:bg-[#3d5a5c]",disabled:s,children:s?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"mr-2 h-5 w-5 animate-spin"}),"Creating Your Account..."]}):e.jsxs(e.Fragment,{children:["Start My Free Trial",e.jsx(Ga,{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:_It.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(Lt,{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(Ft,{className:"text-xl font-sans",children:d.title})]}),e.jsx(Re,{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:bIt.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(Lt,{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(Ft,{className:"text-lg font-semibold text-white",children:d.title})]}),e.jsx(Re,{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:wIt.map((d,u)=>e.jsx(Pe,{className:"border hover:shadow-lg transition-shadow",children:e.jsxs(Re,{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(or,{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(Re,{className:"p-12 text-center relative",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-white mb-4 font-sans",children:"Ready to Level Up Your Business?"}),e.jsx("p",{className:"text-xl text-white/80 mb-8 max-w-2xl mx-auto",children:"Join thousands of successful agents. Start your free 7-day trial today."}),e.jsxs(K,{onClick:()=>window.scrollTo({top:0,behavior:"smooth"}),size:"lg",className:"h-14 px-8 text-lg font-semibold bg-white text-[#1e3a4c] hover:bg-white/90 shadow-2xl transition-all hover:scale-105 rounded-full",children:["Start Your Free Trial Now",e.jsx(Ga,{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."})]})})})]})]})},NIt=()=>{const t=vr();return e.jsxs(e.Fragment,{children:[e.jsx(nc,{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:fle,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsx(K,{onClick:()=>t("/auth"),className:"bg-white text-[#4a6b6d] hover:bg-gray-100 font-medium shadow-md",children:"Sign In"})]})}),e.jsxs("section",{className:"relative pt-24 pb-12 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] overflow-hidden flex-1 flex items-center",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsx("div",{className:"flex justify-center",children:e.jsx(Pe,{className:"max-w-lg w-full bg-white shadow-2xl border-0",children:e.jsxs(Re,{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(Hn,{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(K,{onClick:()=>t("/auth"),className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:["Go to Sign In",e.jsx(Ga,{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."]})]})})})]})]})},kIt=kC({viewerName:Yl().min(1,"Name is required").max(100,"Name must be less than 100 characters"),viewerEmail:Yl().email("Please enter a valid email").max(255,"Email must be less than 255 characters"),viewerPhone:Yl().max(20,"Phone must be less than 20 characters").optional(),message:Yl().min(1,"Message is required").max(1e3,"Message must be less than 1000 characters")});function SIt({shareToken:t,agentName:s,hasContact:r}){const[n,a]=S.useState(!1),[o,l]=S.useState(!1),[i,d]=S.useState(null),u=Kue({resolver:Zue(kIt),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(Re,{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(Hn,{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(Lt,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Ol,{className:"h-5 w-5 text-primary"}),e.jsx(Ft,{className:"text-lg",children:"Reply to this video"})]}),e.jsx(ur,{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(Re,{children:e.jsx(Yue,{...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(Le,{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(Le,{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(Le,{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(gr,{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(K,{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(Mn,{className:"h-4 w-4"}),"Send Message"]})})]})})})]})}const CIt=()=>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"})]}),MIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-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"})]}),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-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"})]}),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-blue-900/5 via-slate-800/3 to-indigo-900/5"}),e.jsx("div",{className:"absolute top-[5%] right-[10%] opacity-15",children:e.jsxs("div",{className:"w-12 h-24 relative",children:[e.jsx("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-10 h-3 bg-blue-600 rounded-full"}),e.jsx("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 w-0 h-0 border-l-[20px] border-r-[20px] border-t-[60px] border-l-transparent border-r-transparent border-t-blue-500"})]})}),e.jsx(rc,{className:"absolute top-[8%] left-[12%] w-12 h-12 text-blue-600/15"}),e.jsx(Gn,{className:"absolute top-[15%] left-[22%] w-5 h-5 text-amber-500/25 fill-amber-500/15"}),e.jsx(rc,{className:"absolute bottom-[20%] right-[8%] w-14 h-14 text-indigo-500/12"}),e.jsx("div",{className:"absolute top-[3%] left-[40%] opacity-12",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"w-10 h-5 bg-slate-700 rounded-full rounded-tr-none rotate-6"}),e.jsx("div",{className:"w-10 h-5 bg-slate-700 rounded-full rounded-tl-none -rotate-6"})]})}),e.jsx(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"}})]}),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-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"})]}),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-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"}})]}),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-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"})]}),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-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"})]}),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-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"})]}),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-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"})]}),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-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"})]})]})]}),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-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(rc,{className:"absolute bottom-[20%] right-[12%] w-12 h-12 text-blue-500/18"}),e.jsx(rc,{className:"absolute top-[18%] left-[28%] w-8 h-8 text-indigo-400/15"}),e.jsx(Yv,{className:"absolute top-[8%] left-[60%] w-10 h-10 text-indigo-400/18"})]}),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-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(yi,{className:"absolute bottom-[18%] right-[15%] w-12 h-12 text-rose-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-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"})]}),$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-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"})]}),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-teal-900/10 via-cyan-900/6 to-emerald-900/10"}),e.jsx(Sn,{className:"absolute top-[8%] left-[10%] w-14 h-14 text-teal-500/22"}),e.jsx(Sn,{className:"absolute bottom-[15%] right-[8%] w-16 h-16 text-emerald-500/18"}),e.jsx(pp,{className:"absolute top-[12%] right-[18%] w-10 h-10 text-amber-400/25"}),e.jsx(pp,{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"})]}),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-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(pp,{className:"absolute bottom-[18%] left-[18%] w-12 h-12 text-amber-400/25"}),e.jsx(Sn,{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"})]}),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-amber-900/10 via-yellow-900/6 to-orange-900/10"}),e.jsx(pp,{className:"absolute bottom-[12%] left-[50%] -translate-x-1/2 w-24 h-24 text-amber-400/25 rotate-45"}),e.jsx(pp,{className:"absolute top-[10%] left-[12%] w-10 h-10 text-yellow-400/30"}),e.jsx(pp,{className:"absolute top-[12%] right-[15%] w-9 h-9 text-amber-300/25"}),e.jsx(Sn,{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"})]}),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-teal-900/10 via-emerald-900/6 to-green-900/10"}),e.jsx(Sn,{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(pp,{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"})]}),sLe=()=>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"})]}),GIt=()=>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"})]}),WIt=()=>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(Sn,{className:"absolute top-8 left-[38%] w-3 h-3 text-teal-300/40 animate-pulse delay-200"})]}),KIt=()=>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"})]}),rLe=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Sn,{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(Sn,{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(GIt,{})},{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(KIt,{})},{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(or,{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(rc,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Congratulations, ${t}!`:"Congratulations!",subText:"So proud of your accomplishment",gradientClasses:"from-amber-50/70 via-yellow-50/50 to-orange-50/40 dark:from-amber-950/30 dark:via-yellow-950/20 dark:to-orange-950/20",accentColor:"amber",decorativeElement:e.jsx(sLe,{})},{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(rLe,{})},{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(zIt,{})},{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(BIt,{})},{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($It,{})},{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(DIt,{})},{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(EIt,{})},{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(TIt,{})},{id:"fathers_day",name:"Father's Day",description:"Celebrate the amazing dads",icon:e.jsx(rc,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Father's Day, ${t}!`:"Happy Father's Day!",subText:"Celebrating the wonderful fathers in our lives",gradientClasses:"from-blue-50/70 via-sky-50/50 to-indigo-50/40 dark:from-blue-950/30 dark:via-sky-950/20 dark:to-indigo-950/20",accentColor:"blue",decorativeElement:e.jsx(AIt,{})},{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(CIt,{})},{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(MIt,{})},{id:"labor_day",name:"Labor Day",description:"Celebrate the workers",icon:e.jsx(rc,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Labor Day, ${t}!`:"Happy Labor Day!",subText:"Celebrating the hard work that builds our communities",gradientClasses:"from-blue-50/70 via-indigo-50/50 to-sky-50/40 dark:from-blue-950/30 dark:via-indigo-950/20 dark:to-sky-950/20",accentColor:"blue",decorativeElement:e.jsx(FIt,{})},{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(PIt,{})},{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(LIt,{})},{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(IIt,{})},{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(RIt,{})},{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(OIt,{})},{id:"home_anniversary",name:"Home Anniversary",description:"Celebrate their home ownership milestone",icon:e.jsx(Sn,{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(qIt,{})},{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(UIt,{})},{id:"just_listed",name:"Just Listed",description:"Announce a new listing",icon:e.jsx(ln,{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(rLe,{})},{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(WIt,{})},{id:"closing_day",name:"Closing Day",description:"Celebrate their closing day",icon:e.jsx(pp,{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(VIt,{})},{id:"move_in_day",name:"Move-in Day",description:"Welcome them to their new home",icon:e.jsx(Sn,{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(HIt,{})},{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(rc,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Congratulations, ${t}!`:"Congratulations!",subText:"You're pre-approved and ready to find your dream home",gradientClasses:"from-violet-50/70 via-purple-50/50 to-indigo-50/40 dark:from-violet-950/30 dark:via-purple-950/20 dark:to-indigo-950/20",accentColor:"violet",decorativeElement:e.jsx(sLe,{})}],ZIt=[{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 YIt(t){return l_e.filter(s=>s.category===t)}function GM(t){return l_e.find(s=>s.id===t)||l_e[0]}function nLe(){const{shareToken:t,recipientToken:s}=ao(),[r,n]=S.useState(null),[a,o]=S.useState(null),[l,i]=S.useState(null),[d,u]=S.useState(!0),[p,f]=S.useState(null),[y,_]=S.useState(!0),b=S.useRef(null),N=S.useRef(0),w=S.useRef(0),k=(()=>{const Y=new URLSearchParams(window.location.search);return s||Y.get("rt")||null})(),C=S.useCallback((Y,J=!1)=>{if(!k||Y<=0)return;const X=Math.max(1,Math.round(Y));if(X<=w.current)return;const ae=`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${encodeURIComponent(k)}&e=watch&ws=${X}`;J&&navigator.sendBeacon?navigator.sendBeacon(ae):fetch(ae,{method:"GET",keepalive:J}).catch(()=>{}),w.current=Math.max(w.current,X)},[k]);S.useEffect(()=>{var oe;if(!y||!(r!=null&&r.playback_url)||!k)return;let Y=!1;const J=()=>{N.current>0&&C(N.current,!0)},X=()=>{document.visibilityState==="hidden"&&J()},ce=()=>{J()},ae=()=>{var ye;if(Y||!b.current||!((ye=window.playerjs)!=null&&ye.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)})},ie=document.querySelector('script[data-bunny-playerjs="true"]');if((oe=window.playerjs)!=null&&oe.Player)ae();else if(ie)ie.addEventListener("load",ae,{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=ae,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,k,C]),S.useEffect(()=>{N.current=0,w.current=0},[k,t]),S.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(ae=>{document.querySelectorAll(ae).forEach(ie=>{ie.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()}},[]),S.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:ae}=await G.storage.from("avatars").list(`${J.owner_user_id}`);if(ae&&ae.length>0){const{data:ie}=G.storage.from("avatars").getPublicUrl(`${J.owner_user_id}/${ae[0].name}`);i(ie.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(Re,{className:"py-12 text-center",children:[e.jsx(gn,{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(nc,{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:Dt("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:Dt("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(wn,{className:"h-14 w-14 border-2 border-primary/20",children:[e.jsx(Ma,{src:l||void 0,alt:a.name||"Agent"}),e.jsx(jn,{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(K,{variant:"outline",size:"icon",asChild:!0,className:"h-10 w-10",children:e.jsx("a",{href:`tel:${a.phone}`,"aria-label":"Call agent",children:e.jsx(In,{className:"h-4 w-4"})})}),a.email&&e.jsx(K,{variant:"outline",size:"icon",asChild:!0,className:"h-10 w-10",children:e.jsx("a",{href:`mailto:${a.email}`,"aria-label":"Email agent",children:e.jsx(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(gn,{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(K,{size:"lg",onClick:()=>_(!0),className:"gap-2",children:[e.jsx(Co,{className:"h-5 w-5"}),"Watch Video"]})}),e.jsx(SIt,{shareToken:t,agentName:(a==null?void 0:a.name)||null,hasContact:!!r.contact_id})]})]})]})}function XIt(){return S.useEffect(()=>(document.body.classList.add("video-landing-page"),()=>{document.body.classList.remove("video-landing-page")}),[]),e.jsx(T1t,{})}function QIt(){const{token:t}=ao();return S.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 she="Tabs",[JIt,uAs]=qc(she,[pw]),tXe=pw(),[eLt,tke]=JIt(she),sXe=S.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:she});return e.jsx(eLt,{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=she;var rXe="TabsList",nXe=S.forwardRef((t,s)=>{const{__scopeTabs:r,loop:n=!0,...a}=t,o=tke(rXe,r),l=tXe(r);return e.jsx(pue,{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=S.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(fue,{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:Sr(t.onMouseDown,f=>{!a&&f.button===0&&f.ctrlKey===!1?l.onValueChange(n):f.preventDefault()}),onKeyDown:Sr(t.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&l.onValueChange(n)}),onFocus:Sr(t.onFocus,()=>{const f=l.activationMode!=="manual";!p&&!a&&f&&l.onValueChange(n)})})})});iXe.displayName=aXe;var oXe="TabsContent",lXe=S.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=S.useRef(p);return S.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 tLt=sXe,uXe=nXe,hXe=iXe,mXe=lXe;const ta=tLt,Jn=S.forwardRef(({className:t,...s},r)=>e.jsx(uXe,{ref:r,className:Dt("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...s}));Jn.displayName=uXe.displayName;const ls=S.forwardRef(({className:t,...s},r)=>e.jsx(hXe,{ref:r,className:Dt("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}));ls.displayName=hXe.displayName;const ws=S.forwardRef(({className:t,...s},r)=>e.jsx(mXe,{ref:r,className:Dt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...s}));ws.displayName=mXe.displayName;const sLt={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},rLt={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 nLt(){var Ue,Te,Me,De;const{slugOrId:t}=ao(),[s]=Nc(),{data:r,isLoading:n}=pWe(t||""),a=fWe(),o=dkt(),l=s.get("ref"),[i,d]=S.useState(""),[u,p]=S.useState(""),[f,y]=S.useState(""),[_,b]=S.useState(""),[N,w]=S.useState(""),[k,C]=S.useState(""),[A,I]=S.useState(""),[L,O]=S.useState("in_person"),[V,q]=S.useState("info"),[B,U]=S.useState(!1),[te,Y]=S.useState(!1),[J,X]=S.useState(null),[ce,ae]=S.useState(!1);S.useEffect(()=>{l&&o.mutate(l)},[l]);const ie=qe=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(qe),oe=async qe=>{if(qe.preventDefault(),!i.trim()||!f.trim()||!r)return;const ke=V==="showing";if(ke&&!k){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:ke?"showing_request":"info_request",preferredDate:ke?k:null,preferredTime:ke&&A||null,showingMode:ke?L:null,message:N.trim()||null}),Y(!0),pe.success(ke?"Showing request sent! The agent will confirm details shortly.":"Thanks! The agent will be in touch soon.")}catch($e){console.error("Lead submission error:",$e),pe.error(`Failed to submit: ${$e.message||"Please try again"}`)}finally{U(!1)}},me=(r==null?void 0:r.photos)||[],ye=me.find(qe=>qe.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(ks,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(ks,{className:"h-10 w-48 mb-6"}),e.jsx(ks,{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(ks,{className:"h-12 w-48"}),e.jsx(ks,{className:"h-6 w-full"}),e.jsx(ks,{className:"h-6 w-3/4"})]}),e.jsx(ks,{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:Yoe,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(Sn,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Listing Not Found"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing may no longer be available."}),e.jsx(K,{asChild:!0,children:e.jsx(da,{to:"/public/listings",children:"Browse All Listings"})})]})]});const Ne=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(nc,{children:[e.jsxs("title",{children:[Ne," | LevelUp Listings"]}),e.jsx("meta",{name:"description",content:`${ie(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}. ${((Ue=r.description)==null?void 0:Ue.slice(0,150))||""}`}),e.jsx("link",{rel:"canonical",href:`https://listings.relevelup.com/${r.slug||r.id}`}),e.jsx("meta",{property:"og:title",content:Ne}),e.jsx("meta",{property:"og:description",content:`${ie(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}`}),ye&&e.jsx("meta",{property:"og:image",content:ye.photo_url}),ye&&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:Ne}),e.jsx("meta",{name:"twitter:description",content:`${ie(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA in ${r.city}, ${r.state}`}),ye&&e.jsx("meta",{name:"twitter:image",content:ye.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(qe=>qe.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:(Te=r.agent.brokerage)!=null&&Te.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:Yoe,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:ye==null?void 0:ye.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((qe,ke)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>X(ke+1),children:[e.jsx("img",{src:qe.photo_url,alt:`${r.property_address||r.city} - Photo ${ke+2} of ${me.length}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),ke===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"]})]},qe.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:`${sLt[r.status]} text-white border-0`,children:rLt[r.status]})}),e.jsx("h1",{className:"text-4xl font-bold text-primary mb-2",children:ie(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(ln,{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(K,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:r.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Zr,{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(Re,{className:"p-0",children:[e.jsxs("div",{className:"relative aspect-video bg-muted cursor-pointer group",onClick:()=>ae(!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(gn,{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(K,{onClick:()=>ae(!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(Lt,{children:e.jsxs(Ft,{className:"text-lg flex items-center gap-2",children:[e.jsx(Ai,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(Re,{children:[e.jsx("p",{className:"font-semibold text-lg",children:r.agent.name}),((Me=r.agent.brokerage)==null?void 0:Me.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:r.agent.brokerage.name})]})]}),e.jsxs(Pe,{className:"border-primary",children:[e.jsx(Lt,{className:"pb-3",children:e.jsx(Ft,{className:"text-lg",children:"Interested in this property?"})}),e.jsx(Re,{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:qe=>q(qe),children:[e.jsxs(Jn,{className:"grid w-full grid-cols-2 mb-4",children:[e.jsxs(ls,{value:"info",className:"gap-1.5",children:[e.jsx(tr,{className:"h-3.5 w-3.5"}),"Get Info"]}),e.jsxs(ls,{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(ws,{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(Le,{id:"preferredDate",type:"date",value:k,onChange:qe=>C(qe.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(Fs,{value:A,onValueChange:I,children:[e.jsx(Ds,{id:"preferredTime",children:e.jsx(zs,{placeholder:"Any time"})}),e.jsxs(Rs,{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(Fs,{value:L,onValueChange:qe=>O(qe),children:[e.jsx(Ds,{id:"showingMode",children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Le,{id:"firstName",type:"text",placeholder:"John",value:i,onChange:qe=>d(qe.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"lastName",children:"Last Name"}),e.jsx(Le,{id:"lastName",type:"text",placeholder:"Doe",value:u,onChange:qe=>p(qe.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"email",children:"Email *"}),e.jsx(Le,{id:"email",type:"email",placeholder:"you@example.com",value:f,onChange:qe=>y(qe.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsxs(xe,{htmlFor:"phone",children:["Phone ",V==="showing"&&"*"]}),e.jsx(Le,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:_,onChange:qe=>b(qe.target.value),required:V==="showing"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"message",children:V==="showing"?"Anything else?":"Message (optional)"}),e.jsx(gr,{id:"message",placeholder:V==="showing"?"e.g. I have flexibility on weekends":"Any specific questions about the property?",value:N,onChange:qe=>w(qe.target.value),rows:2})]}),e.jsx(K,{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(hs,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(js,{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(jr,{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:ae,children:e.jsxs(hs,{className:"max-w-4xl p-0 bg-black overflow-hidden",children:[e.jsx(js,{className:"sr-only",children:e.jsx(_s,{children:"Video Tour"})}),e.jsx("button",{onClick:()=>ae(!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(jr,{className:"h-5 w-5"})}),((De=r==null?void 0:r.video)==null?void 0:De.playback_url)&&e.jsx("div",{className:"aspect-video w-full",children:e.jsx("iframe",{src:r.video.playback_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})]})}),e.jsx("footer",{className:"border-t py-8 mt-16",children:e.jsxs("div",{className:"container mx-auto px-4 text-center text-sm text-muted-foreground",children:[e.jsxs("p",{children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),e.jsx("p",{className:"mt-2",children:e.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"hover:text-foreground",children:"relevelup.com"})})]})})]})]})}function aLt(){var o;const{slug:t}=ao(),{data:s,isLoading:r,error:n}=vWe(t);if(S.useEffect(()=>(document.body.classList.add("agent-card-page"),()=>{document.body.classList.remove("agent-card-page")}),[]),S.useEffect(()=>{s!=null&&s.id&&Ui(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(ks,{className:"h-28 w-28 rounded-full"}),e.jsx(ks,{className:"h-6 w-48"}),e.jsx(ks,{className:"h-4 w-36"})]}),e.jsx(ks,{className:"h-12 w-full"}),e.jsx(ks,{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(nc,{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 _e;const{slug:s}=ao(),r=t||s,[n]=Nc(),a=n.get("t"),[o,l]=S.useState(!0),[i,d]=S.useState(null),[u,p]=S.useState(null),f=S.useRef(null),y=S.useRef(null),[_,b]=S.useState(null),[N,w]=S.useState(null),[k,C]=S.useState(!1),[A,I]=S.useState(!1),[L,O]=S.useState(0),[V,q]=S.useState(!1),[B,U]=S.useState(""),[te,Y]=S.useState(""),[J,X]=S.useState(""),[ce,ae]=S.useState(""),[ie,oe]=S.useState(""),[me,ye]=S.useState(""),[he,ge]=S.useState(""),[Ne,Ue]=S.useState(""),[Te,Me]=S.useState(""),[De,qe]=S.useState(""),[ke,$e]=S.useState(""),[Be,we]=S.useState("");S.useEffect(()=>{ut()},[r,a]);const ut=async()=>{if(!r)return;l(!0);const{data:Ge,error:We}=await G.from("contact_intake_pages").select("*").eq("slug",r).eq("is_active",!0).maybeSingle();if(We||!Ge){q(!0),l(!1);return}p(Ge),y.current=Ge;const{data:it}=await G.from("profiles").select("name, avatar_url, title, phone, email, brokerage_id").eq("id",Ge.user_id).single();if(it){let Ve;if(it.brokerage_id){const{data:pt}=await G.from("brokerages").select("name").eq("id",it.brokerage_id).single();Ve=(pt==null?void 0:pt.name)||void 0}let Xe=it.avatar_url||null;if(!Xe){const{data:pt}=G.storage.from("avatars").getPublicUrl(`${Ge.user_id}/avatar.jpg`);pt!=null&&pt.publicUrl&&(Xe=`${pt.publicUrl}?t=${Date.now()}`)}const dt={...it,avatar_url:Xe,brokerage_name:Ve};d(dt),f.current=dt}if(a)try{console.log("[ConnectPage] Resolving token:",a,"for page:",Ge.id);const{data:Ve,error:Xe}=await G.functions.invoke("process-intake-submissions",{body:{action:"resolve_token",token:a,page_id:Ge.id}});if(console.log("[ConnectPage] Resolve result:",{resolved:Ve,resolveErr:Xe}),!Xe&&(Ve!=null&&Ve.contact_id)){w(Ve.contact_id);const dt=Ve.contact;dt&&(b(dt),U(dt.first_name||""),Y(dt.last_name||""),X(dt.email||""),ae(dt.phone||""),oe(dt.address||""),ye(dt.city||""),ge(dt.state||""),Ue(dt.zip||""),Me(dt.birthday||""),qe(dt.home_anniversary||""))}}catch(Ve){console.error("Failed to resolve token:",Ve)}l(!1)},fe=async()=>{var Ge,We;if(!B.trim()){pe.error("Please enter your first name");return}if(!r){pe.error("Invalid page. Please refresh.");return}I(!0);try{let it=(Ge=y.current)==null?void 0:Ge.id,Ve=(We=y.current)==null?void 0:We.user_id;if(!it||!Ve){const{data:dt}=await G.from("contact_intake_pages").select("id, user_id").eq("slug",r).eq("is_active",!0).maybeSingle();if(!dt){pe.error("This page is no longer active. Please contact the agent directly."),I(!1);return}it=dt.id,Ve=dt.user_id}const{error:Xe}=await G.from("contact_intake_submissions").insert({intake_page_id:it,agent_user_id:Ve,existing_contact_id:N,first_name:B.trim(),last_name:te.trim()||null,email:J.trim()||null,phone:ce.trim()||null,address:ie.trim()||null,city:me.trim()||null,state:he.trim()||null,zip:Ne.trim()||null,birthday:Te||null,home_anniversary:De||null,real_estate_interest:ke||null,message:Be.trim()||null});if(console.log("[ConnectPage] Insert result:",{error:Xe}),Xe)throw Xe;a&&await G.from("contact_intake_tokens").update({used_at:new Date().toISOString()}).eq("token",a);try{const dt=[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:Ve,contactName:dt,contactEmail:J.trim()||null,contactPhone:ce.trim()||null,slug:r})})}catch(dt){console.warn("Connect page notification failed (non-blocking):",dt)}C(!0)}catch(it){console.error(it),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(k)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(nc,{children:e.jsxs("title",{children:["Thank You | ",i==null?void 0:i.name]})}),e.jsxs(dr.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(dr.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(Hn,{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 He=!!a&&!!_,et=3,tt=[{title:He?"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:Ge=>U(Ge.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:Ge=>Y(Ge.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:Ge=>X(Ge.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:Ge=>ae(Ge.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:ie,onChange:Ge=>oe(Ge.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:Ge=>ye(Ge.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:Ge=>ge(Ge.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:Ne,onChange:Ge=>Ue(Ge.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:Te,onChange:Ge=>Me(Ge.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:De,onChange:Ge=>qe(Ge.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(Ge=>e.jsxs("button",{type:"button",onClick:()=>$e(ke===Ge.value?"":Ge.value),className:`p-3.5 rounded-xl border-2 text-left transition-all ${ke===Ge.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:Ge.label}),e.jsx("span",{className:"block text-xs text-slate-500 mt-0.5",children:Ge.desc})]},Ge.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:Be,onChange:Ge=>we(Ge.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(nc,{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(dr.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:((_e=i==null?void 0:i.name)==null?void 0:_e.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(dr.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:et}).map((Ge,We)=>e.jsx("div",{className:`h-1.5 flex-1 rounded-full transition-all duration-500 ${We<=L?"bg-blue-500":"bg-slate-200"}`},We))}),e.jsxs(dr.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(dr.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(Ge=>Ge-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(Ge=>Ge+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(Ge=>Ge+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:S.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]=S.useState(0),[o,l]=S.useState(!1),{trackEngagement:i}=QA(),d=S.useCallback(_=>{i("newsletter",_.id,_.title,"click_link")},[i]),u=S.useCallback(()=>{a(_=>(_+1)%t.length)},[t.length]),p=S.useCallback(()=>{a(_=>(_-1+t.length)%t.length)},[t.length]),f=S.useCallback(_=>{a(_)},[]);if(S.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:Dt("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(K,{variant:"ghost",size:"icon",className:Dt("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(K,{variant:"ghost",size:"icon",className:Dt("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:Dt("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(K,{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 iLt(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=iLt();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 aLe=ske,oLt=({events:t,registrations:s,onNavigateToEvents:r})=>{const[n,a]=S.useState(new Date);S.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(on,{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(K,{onClick:()=>window.open(u,"_blank"),className:`${y.button} text-white gap-2`,children:[e.jsx(Zr,{className:"h-4 w-4"}),f?"Join Now":"Join When Live"]}):e.jsxs(K,{variant:"outline",onClick:r,className:`${y.outlineButton} gap-2`,children:[e.jsx(or,{className:"h-4 w-4"}),"Register & Join"]})})]})})]})};var rke="Progress",nke=100,[lLt,hAs]=qc(rke),[cLt,dLt]=lLt(rke),fXe=S.forwardRef((t,s)=>{const{__scopeProgress:r,value:n=null,max:a,getValueLabel:o=uLt,...l}=t;(a||a===0)&&!iLe(a)&&console.error(hLt(`${a}`,"Progress"));const i=iLe(a)?a:nke;n!==null&&!oLe(n,i)&&console.error(mLt(`${n}`,"Progress"));const d=oLe(n,i)?n:null,u=ble(d)?o(d,i):void 0;return e.jsx(cLt,{scope:r,value:d,max:i,children:e.jsx(Jr.div,{"aria-valuemax":i,"aria-valuemin":0,"aria-valuenow":ble(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=S.forwardRef((t,s)=>{const{__scopeProgress:r,...n}=t,a=dLt(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 uLt(t,s){return`${Math.round(t/s*100)}%`}function yXe(t,s){return t==null?"indeterminate":t===s?"complete":"loading"}function ble(t){return typeof t=="number"}function iLe(t){return ble(t)&&!isNaN(t)&&t>0}function oLe(t,s){return ble(t)&&!isNaN(t)&&t<=s&&t>=0}function hLt(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 mLt(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,pLt=gXe;const fi=S.forwardRef(({className:t,value:s,...r},n)=>e.jsx(vXe,{ref:n,className:Dt("relative h-4 w-full overflow-hidden rounded-full bg-secondary",t),...r,children:e.jsx(pLt,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(s||0)}%)`}})}));fi.displayName=vXe.displayName;function fLt(){const{user:t,isBrokerageManager:s}=qs(),[r,n]=S.useState([]),[a,o]=S.useState([]),[l,i]=S.useState(!1),[d,u]=S.useState(!0),p=s?"brokerage_manager":"agent";S.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 qe,ke;if(!(t!=null&&t.id))return;const O=L.map($e=>$e.item_id),V=I.filter($e=>!O.includes($e.id));if(V.length===0)return;const[q,B,U,te,Y,J,X,ce,ae,ie,oe,me,ye,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)]),Ne={},Ue=(qe=q.data)==null?void 0:qe.brokerage_id;Ne.share_resource=(B.count||0)>0,Ne.post_community=(U.count||0)>0,Ne.register_event=(te.count||0)>0,Ne.view_template=(Y.count||0)>0,Ne.watch_academy=(J.count||0)>0,Ne.use_toolbox=(X.count||0)>0,Ne.launch_app=(ce.count||0)>0,Ne.add_contact=(ae.count||0)>0,Ne.create_video=(ie.count||0)>0,Ne.complete_touch=(oe.count||0)>0,Ne.add_transaction=(me.count||0)>0,Ne.add_listing=(ye.count||0)>0,Ne.add_deal=(ge.count||0)>0;const Te=((ke=he.data)==null?void 0:ke.map($e=>$e.id))||[],Me=[];Ue?Me.push(G.from("profiles").select("id").eq("brokerage_id",Ue).neq("id",t.id).then($e=>{var Be;Ne.add_agent=(((Be=$e.data)==null?void 0:Be.length)||0)>0})):Ne.add_agent=!1,Te.length>0?(Me.push(G.from("contact_plan_cycles").select("id",{count:"exact",head:!0}).in("contact_id",Te).then($e=>{Ne.add_plan=($e.count||0)>0})),Me.push(G.from("contact_popby_settings").select("id",{count:"exact",head:!0}).in("contact_id",Te).then($e=>{Ne.schedule_popby=($e.count||0)>0}))):(Ne.add_plan=!1,Ne.schedule_popby=!1),await Promise.all(Me);const De=V.filter($e=>Ne[$e.action_type]);if(De.length>0){const $e=De.map(we=>({user_id:t.id,item_id:we.id})),{error:Be}=await G.from("onboarding_checklist_progress").upsert($e,{onConflict:"user_id,item_id",ignoreDuplicates:!0});if(!Be){const we=De.map(ut=>({item_id:ut.id,completed_at:new Date().toISOString()}));o(ut=>[...ut,...we])}}},_=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,k=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:k,progressPercentage:C,isItemComplete:I=>a.some(L=>L.item_id===I),markComplete:_,dismiss:b,refetch:f}}const xLt={add_agent:e.jsx(or,{className:"h-4 w-4"}),share_resource:e.jsx(_d,{className:"h-4 w-4"}),post_community:e.jsx(Si,{className:"h-4 w-4"}),register_event:e.jsx(ln,{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(Sn,{className:"h-4 w-4"})},gLt={add_deal:"/mission-control/pipeline",add_listing:"/mission-control/listings/new",post_community:"/community",add_contact:"/mission-control/contacts"};function yLt(){const{items:t,isDismissed:s,loading:r,completedCount:n,totalCount:a,isComplete:o,progressPercentage:l,isItemComplete:i,markComplete:d,dismiss:u}=fLt(),p=vr(),[f,y]=S.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(Lt,{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(Ft,{className:"text-lg",children:"Get Started with LevelUp"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:"Complete these steps to make the most of your membership"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>y(!f),className:"h-8 w-8 p-0",children:f?e.jsx(af,{className:"h-4 w-4"}):e.jsx(Fi,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0 text-muted-foreground hover:text-foreground",children:e.jsx(jr,{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(fi,{value:l,className:"h-2"})]})]}),f&&e.jsx(Re,{className:"pt-0",children:e.jsx("div",{className:"space-y-3",children:t.map(_=>{const b=i(_.id);return e.jsxs("div",{className:Dt("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=gLt[_.action_type];N?p(N):d(_.id)},children:[e.jsx("div",{className:"mt-0.5",children:b?e.jsx(Hn,{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:xLt[_.action_type]||e.jsx(sd,{className:"h-4 w-4"})}),e.jsx("span",{className:Dt("font-medium",b&&"line-through text-muted-foreground"),children:_.title})]}),_.description&&e.jsx("p",{className:Dt("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})},vLt=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})},rhe=()=>{const t=Qt(),s=ya();return Et({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"]}),pn({title:"Contact created successfully"})},onError:r=>{pn({title:"Error creating contact",description:r.message,variant:"destructive"})}})},ake=()=>{const t=Qt();return Et({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"]}),pn({title:"Contact updated successfully"})},onError:s=>{pn({title:"Error updating contact",description:s.message,variant:"destructive"})}})},bXe=()=>{const t=Qt();return Et({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"]}),pn({title:"Spouse link updated"})},onError:s=>{pn({title:"Error linking spouse",description:s.message,variant:"destructive"})}})},ike=()=>{const t=Qt();return Et({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"]}),pn({title:"Contact deleted successfully"})},onError:s=>{pn({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}}),_Lt=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}}),bLt=()=>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}}),wLt=()=>{const t=Qt(),s=ya();return Et({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"]}),pn({title:"Plan created successfully"})},onError:r=>{pn({title:"Error creating plan",description:r.message,variant:"destructive"})}})},jLt=()=>{const t=Qt(),s=ya();return Et({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"]}),pn({title:"Plan duplicated successfully",description:"You can now edit your copy of this plan."})},onError:r=>{pn({title:"Error duplicating plan",description:r.message,variant:"destructive"})}})},NLt=()=>{const t=Qt();return Et({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"]}),pn({title:"Plan updated successfully"})}})},kLt=()=>{const t=Qt();return Et({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"]}),pn({title:"Plan deleted successfully"})}})},SLt=()=>{const t=Qt();return Et({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"]}),pn({title:"Plan schedule updated"})}})},CLt=()=>{const t=Qt();return Et({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"]}),pn({title:"Script created successfully"})},onError:s=>{pn({title:"Error creating script",description:s.message,variant:"destructive"})}})},MLt=()=>{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})},TLt=()=>{const t=Qt(),s=ya();return Et({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"]}),pn({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})},ALt=(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 Et({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"]}),pn({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",lLe=20,wle=()=>{if(typeof window>"u")return lLe;const t=localStorage.getItem(jXe);if(t){const s=parseInt(t,10);if(!isNaN(s)&&s>0)return s}return lLe},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=wle();return{actionsThisWeek:n,weeklyGoal:o,streak:a,progress:Math.min(n/o*100,100)}},ELt=()=>{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})},PLt=()=>{const t=Qt();return ya(),Et({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&&pn({title:`${s} contact(s) enrolled in plans`})}})},kXe=()=>{const t=ya(),{data:s}=ELt(),{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 ILt(){const t=vr(),{data:s,isLoading:r}=kXe(),{data:n}=qh(),a=oke(),[o,l]=S.useState(wle()),[i,d]=S.useState(""),[u,p]=S.useState(!1);S.useEffect(()=>{l(wle())},[]);const f=()=>{const O=parseInt(i,10);if(isNaN(O)||O<1){pn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}l(O),NXe(O),p(!1),pn({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))||[],k=(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=k+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(Re,{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(Lt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ft,{className:"text-lg flex items-center gap-2",children:[e.jsx(or,{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(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5",onClick:O=>{O.stopPropagation(),t("/mission-control/contacts?new=true")},children:[e.jsx(Jo,{className:"h-3.5 w-3.5"}),"Add Contact"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5",onClick:O=>{O.stopPropagation(),t("/mission-control")},children:[e.jsx(In,{className:"h-3.5 w-3.5"}),"Log Touch"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5 border-emerald-200 text-emerald-700 hover:bg-emerald-50 hover:text-emerald-800",onClick:O=>{O.stopPropagation(),t("/mission-control/video/record")},children:[e.jsx(gn,{className:"h-3.5 w-3.5"}),"Quick Video"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5",onClick:O=>{O.stopPropagation(),t("/mission-control/popbys")},children:[e.jsx(Ia,{className:"h-3.5 w-3.5"}),"Pop-by Map"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5 border-purple-200 text-purple-700 hover:bg-purple-50 hover:text-purple-800",onClick:O=>{O.stopPropagation(),t("/mission-control/pipeline")},children:[e.jsx(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(hi,{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(hs,{className:"sm:max-w-[360px]",children:[e.jsxs(js,{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(Le,{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(K,{onClick:f,className:"w-full",children:"Save Goal"})]})]})]})]}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium text-primary",children:I}),e.jsxs("span",{className:"text-muted-foreground",children:[" / ",o," touches"]})]})]}),e.jsx(fi,{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(Sn,{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"?"🎂":"🏠":gs(O.date,"EEE, MMM d")}),e.jsx(xa,{className:"h-3 w-3"})]})]},`${O.contact.id}-${O.type}-${V}`))})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full gap-1 text-muted-foreground hover:text-primary",onClick:()=>t("/mission-control"),children:["Open Agent OS",e.jsx(Ga,{className:"h-4 w-4"})]})]})]})}function LLt(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 DLt(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 RLt(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 OLt(t){const s=Qt();return Et({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 FLt(){const t=Qt();return Et({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 zLt(t){const s=Qt();return Et({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 BLt(){const t=Qt();return Et({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 $Lt(t){const s=Qt();return Et({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 qLt={video:Co,pdf:yn,link:Do,event:ln,graphic:Fl},ULt={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 VLt(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 HLt(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 GLt({item:t}){const s=vr(),r=qLt[t.content_type]||Do,n=ULt[t.content_type]||"",[a,o]=S.useState(null),l=t.thumbnail_url||(t.content_type==="graphic"&&t.file_url?t.file_url:null)||(t.content_type==="video"?VLt(t.url):null);S.useEffect(()=>{l||!t.url||t.content_type!=="video"||!HLt(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(Re,{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:gs(new Date(t.event_date),"MMM d · h:mm a")})]})]})}function WLt(){const{brokerageId:t}=qs(),s=vr(),{data:r=[],isLoading:n}=RLt(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(K,{variant:"ghost",size:"sm",onClick:()=>s("/brokerage-content"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Ga,{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(GLt,{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}=qs();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}=qs();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}=qs();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})},KLt=()=>{const t=Qt(),{user:s}=qs();return Et({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"]})}})},ZLt=()=>{const t=Qt();return Et({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"]})}})},YLt=()=>{const t=Qt();return Et({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 Et({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"]})}})},XLt=()=>{const t=Qt();return Et({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"]})}})},QLt=()=>{const t=Qt();return Et({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"]})}})},JLt=()=>{const t=Qt();return Et({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"]})}})},e8t=()=>{const t=Qt();return Et({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"]})}})},t8t=()=>{const{user:t}=qs();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}=qs();return Et({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}=qs();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})},s8t=()=>{const t=Qt(),{user:s}=qs();return Et({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"]})}})},r8t=t=>{const{user:s}=qs();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})},n8t=()=>{const{user:t}=qs();return Et({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}})},a8t=()=>{const{user:t}=qs();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})},i8t=()=>{const t=Qt(),{user:s}=qs();return Et({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"]})}})},o8t=()=>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}}}),l8t=()=>{const{user:t,brokerageId:s}=qs();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:Dt("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"}),c8t={coming_soon:"bg-amber-500/10 text-amber-600 border-amber-200",active:"bg-emerald-500/10 text-emerald-600 border-emerald-200",under_contract:"bg-blue-500/10 text-blue-600 border-blue-200",sold:"bg-purple-500/10 text-purple-600 border-purple-200",withdrawn:"bg-muted text-muted-foreground border-border"},d8t={coming_soon:"Coming Soon",active:"Active",under_contract:"Under Contract",sold:"Sold",withdrawn:"Withdrawn"};function u8t(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function h8t(){const t=vr(),{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(Re,{className:"p-4",children:e.jsxs("div",{className:"animate-pulse flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 bg-emerald-500/20 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-4 bg-emerald-500/20 rounded w-1/3"}),e.jsx("div",{className:"h-3 bg-emerald-500/10 rounded w-1/2"})]})]})})}):e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Listing Exchange"}),e.jsx(IXe,{})]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control/listings"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Ga,{className:"h-4 w-4"})]})]}),d.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Re,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Sn,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No listings available yet"}),e.jsx(K,{variant:"link",size:"sm",onClick:()=>t("/mission-control/listings/new"),className:"mt-2",children:"Add the first listing"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children: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(Sn,{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 ${c8t[p.status]}`,children:d8t[p.status]})})]}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"font-bold text-sm text-foreground",children:u8t(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 m8t(){const{user:t,brokerageId:s,isAdmin:r}=qs();vr();const n=!!s,[a,o]=S.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(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(Vi,{className:"h-4 w-4 text-yellow-500"}),_()]})}),e.jsx(Re,{children:e.jsx("div",{className:"space-y-2",children:[...Array(y?5:3)].map((N,w)=>e.jsx(ks,{className:"h-10 w-full"},w))})})]});const b=N=>N===0?e.jsx(Vi,{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(Lt,{className:"pb-2",children:[e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(Vi,{className:"h-4 w-4 text-yellow-500"}),_()]}),!r&&n&&e.jsxs("div",{className:"flex gap-1 mt-2",children:[e.jsx(K,{variant:a==="brokerage"?"default":"outline",size:"sm",className:"text-xs h-7 flex-1",onClick:()=>o("brokerage"),children:"My Brokerage"}),e.jsx(K,{variant:a==="global"?"default":"outline",size:"sm",className:"text-xs h-7 flex-1",onClick:()=>o("global"),children:"All LevelUp"})]})]}),e.jsxs(Re,{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,k)=>{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":k===0?"bg-yellow-500/10":""}`,children:[e.jsx("div",{className:"w-5 text-center",children:b(k)}),e.jsx(wn,{className:"h-6 w-6",children:e.jsx(jn,{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(yi,{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(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(Vi,{className:"h-4 w-4 text-yellow-500"}),"My Points"]})}),e.jsx(Re,{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(rc,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Badges"})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[f.slice(0,4).map(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(yi,{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(yi,{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}=qs();return Et({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)}})},p8t=()=>{const t=Qt();return Et({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")}})},f8t=()=>{const t=Qt();return Et({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}=qs(),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}=qs(),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})},ahe=()=>{const t=Qt(),{user:s}=qs();return Et({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)}})},x8t=()=>{const t=Qt();return Et({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)}})},g8t=()=>{const t=Qt();return Et({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}=qs(),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})},y8t=()=>{const t=Qt(),{user:s}=qs();return Et({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)}})},ihe=()=>{const{user:t}=qs();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)})},v8t=()=>{const t=Qt(),{user:s}=qs();return Et({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}=ihe(),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),k=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:k,transactionsByMonth:I,leadSourceBreakdown:w}};return{yearStats:d(r),lifetimeStats:d(a),isLoading:n||o,showCommission:i}},_8t=()=>{const{isAdmin:t}=qs();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},cLe={warm:70,cooling:40};function b8t(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 w8t(t){const s=Math.min(t/12,1);return Math.round(L_.touchpoints*s)}function j8t(t){return t?L_.transactions:0}function N8t(){return 0}function k8t(t){return t>=cLe.warm?"warm":t>=cLe.cooling?"cooling":"at-risk"}function ohe(){const{data:t,isLoading:s}=qh(),{data:r}=wXe(),{data:n}=KR(365),{data:a}=dke(),o=S.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=b8t(_),k=w8t(b),C=j8t(N),A=N8t(),I=Math.round(w+k+C+A),L={score:I,status:k8t(I),breakdown:{recency:Math.round(w),touchpoints:Math.round(k),transactions:Math.round(C),referrals:Math.round(A)},lastTouchDate:y,daysSinceTouch:_,touchCountLast12Months:b,hasTransaction:N};return{...f,relationshipScore:L}})},[t,r,n,a]),l=S.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=vr(),{stats:s,contactsWithScores:r,isLoading:n}=ohe();if(n)return e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(ks,{className:"h-5 w-40"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsx(ks,{className:"h-20 w-full"}),e.jsx(ks,{className:"h-16 w-full"})]})]});if(s.total===0)return e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"text-lg flex items-center gap-2",children:[e.jsx(or,{className:"h-5 w-5"}),"Relationship Health"]})}),e.jsxs(Re,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add contacts to see your relationship health scores."}),e.jsx(K,{variant:"outline",size:"sm",className:"mt-3",onClick:()=>t("/mission-control/contacts?new=true"),children:"Add Your First Contact"})]})]});const a=Math.round(s.warm/s.total*100),o=Math.round(s.cooling/s.total*100),l=Math.round(s.atRisk/s.total*100),i=r.filter(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(Lt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ft,{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(Re,{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(fi,{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(fi,{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(fi,{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(K,{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 S8t=()=>{var ae;const{user:t,isAdmin:s}=qs(),r=vr(),[n,a]=S.useState([]),[o,l]=S.useState([]),[i,d]=S.useState([]),[u,p]=S.useState([]),[f,y]=S.useState([]),[_,b]=S.useState([]),[N,w]=S.useState(new Set),[k,C]=S.useState([]),[A,I]=S.useState([]),[L,O]=S.useState([]),[V,q]=S.useState(null),[B,U]=S.useState(!0);S.useEffect(()=>{te()},[t]);const te=async()=>{var ie,oe,me,ye,he;try{const[ge,Ne,Ue,Te,Me,De,qe,ke,$e,Be,we]=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()]);(ie=we.data)!=null&&ie.name&&q(we.data.name);const ut=((oe=ge.data)==null?void 0:oe.map(Ge=>Ge.tag))||[],fe=new Set(((me=Ue.data)==null?void 0:me.map(Ge=>Ge.app_id))||[]);w(fe);const et=(((ye=Ne.data)==null?void 0:ye.filter(Ge=>!Ge.required_tags||Ge.required_tags.length===0?!0:Ge.required_tags.some(We=>ut.includes(We))))||[]).sort((Ge,We)=>Ge.name==="LevelUp Members Portal"?-1:We.name==="LevelUp Members Portal"?1:0);a(et.slice(0,6));const tt=((he=Te.data)==null?void 0:he.filter(Ge=>WM(Ge.event_date)!=="ended"))||[];l(tt.slice(0,4)),C(Me.data||[]),d(De.data||[]),p(qe.data||[]),y(ke.data||[]),b($e.data||[]);const _e=Be.data||[];I(_e.filter(Ge=>Ge.placement==="top")),O(_e.filter(Ge=>Ge.placement==="between"))}catch(ge){console.error("Error loading dashboard:",ge),pe.error("Failed to load dashboard data")}finally{U(!1)}},Y=async ie=>{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:ie.app_id,app_name:ie.name,user_agent:navigator.userAgent});const{data:ye,error:he}=await G.functions.invoke("sso-launch",{body:{app_id:ie.app_id}});if(he)throw he;ye!=null&&ye.redirect_url?oe&&!oe.closed?(oe.location.href=ye.redirect_url,(me=oe.focus)==null||me.call(oe)):window.location.assign(ye.redirect_url):(oe==null||oe.close(),pe.error("Launch link unavailable"))}catch(ye){oe==null||oe.close(),console.error("Error launching app:",ye),pe.error("Failed to launch app")}},J=ie=>k==null?void 0:k.some(oe=>oe.event_id===ie),X=ie=>{const oe=k==null?void 0:k.find(me=>me.event_id===ie);return oe==null?void 0:oe.zoom_join_url};if(B)return e.jsx(Es,{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=ie=>L.filter(oe=>oe.section_after===ie);return e.jsxs(Es,{title:"Dashboard",children:[e.jsx(oLt,{events:o,registrations:k,onNavigateToEvents:()=>r("/events")}),A.length>0&&e.jsx("div",{className:"mb-8",children:e.jsx(iI,{banners:A})}),e.jsx(yLt,{}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("h2",{className:"text-2xl font-bold text-foreground",children:["Welcome back, ",(V||((ae=t==null?void 0:t.user_metadata)==null?void 0:ae.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(ILt,{}),e.jsx(BXe,{}),e.jsx(m8t,{})]}),e.jsx(WLt,{}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Upcoming Events"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/events"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Ga,{className:"h-4 w-4"})]})]}),o.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Re,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(ln,{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(ie=>{const oe=J(ie.id),me=X(ie.id)||ie.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 ${aLe(ie.event_date)?"bg-red-500/5 border-l-2 border-l-red-500":""}`,onClick:()=>r("/events"),children:[aLe(ie.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(ie.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(ie.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:ie.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(ie.event_date))," at ",uD(new Date(ie.event_date))]})]}),e.jsx("div",{className:"hidden sm:flex flex-shrink-0",children:oe?e.jsxs(K,{size:"sm",variant:"default",className:"gap-1",onClick:ye=>{ye.stopPropagation(),window.open(me,"_blank")},children:[e.jsx(Zr,{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"})]})})]},ie.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(K,{variant:"ghost",size:"sm",onClick:()=>r("/academy"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Ga,{className:"h-4 w-4"})]})]}),f.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Re,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(sp,{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(ie=>e.jsxs("div",{onClick:()=>r(`/academy/${ie.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:[ie.thumbnail_url?e.jsx("img",{src:ie.thumbnail_url,alt:ie.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(sp,{className:"h-8 w-8 text-muted-foreground/50"})}),ie.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:ie.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:ie.title})})]},ie.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(K,{variant:"ghost",size:"sm",onClick:()=>r("/toolbox"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Ga,{className:"h-4 w-4"})]})]}),u.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Re,{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(ie=>e.jsxs("div",{onClick:()=>r(`/toolbox/${ie.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:ie.featured_image_url?e.jsx("img",{src:ie.featured_image_url,alt:ie.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",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:ie.name})})]},ie.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(K,{variant:"ghost",size:"sm",onClick:()=>r("/templates"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Ga,{className:"h-4 w-4"})]})]}),i.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Re,{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(ie=>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:ie.preview_image_url?e.jsx("img",{src:ie.preview_image_url,alt:ie.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:ie.name})})]},ie.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(h8t,{})}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Your Apps"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/apps"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Ga,{className:"h-4 w-4"})]})]}),n.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Re,{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(ie=>{const oe=N.has(ie.id);return e.jsxs("div",{onClick:()=>Y(ie),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:ie.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:ie.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:ie.description})]}),oe&&e.jsx(fx,{className:"h-5 w-5 text-primary fill-current flex-shrink-0"})]},ie.id)})})]}),e.jsxs("section",{className:"mt-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Additional Services"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/additional-services"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Ga,{className:"h-4 w-4"})]})]}),_.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Re,{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(ie=>e.jsxs("div",{onClick:()=>window.open(ie.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:ie.preview_image_url?e.jsx("img",{src:ie.preview_image_url,alt:ie.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",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:ie.name}),ie.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:ie.description})]})]},ie.id))})]})]})};var $Xe="AlertDialog",[C8t,mAs]=qc($Xe,[uGe]),C1=uGe(),qXe=t=>{const{__scopeAlertDialog:s,...r}=t,n=C1(s);return e.jsx(wue,{...n,...r,modal:!0})};qXe.displayName=$Xe;var M8t="AlertDialogTrigger",UXe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=C1(r);return e.jsx(Vje,{...a,...n,ref:s})});UXe.displayName=M8t;var T8t="AlertDialogPortal",VXe=t=>{const{__scopeAlertDialog:s,...r}=t,n=C1(s);return e.jsx(jue,{...n,...r})};VXe.displayName=T8t;var A8t="AlertDialogOverlay",HXe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=C1(r);return e.jsx(UA,{...a,...n,ref:s})});HXe.displayName=A8t;var KM="AlertDialogContent",[E8t,P8t]=C8t(KM),I8t=Pqe("AlertDialogContent"),GXe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,children:n,...a}=t,o=C1(r),l=S.useRef(null),i=Ta(s,l),d=S.useRef(null);return e.jsx(wNt,{contentName:KM,titleName:WXe,docsSlug:"alert-dialog",children:e.jsx(E8t,{scope:r,cancelRef:d,children:e.jsxs(VA,{role:"alertdialog",...o,...a,ref:i,onOpenAutoFocus:Sr(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(I8t,{children:n}),e.jsx(D8t,{contentRef:l})]})})})});GXe.displayName=KM;var WXe="AlertDialogTitle",KXe=S.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=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=C1(r);return e.jsx(OR,{...a,...n,ref:s})});YXe.displayName=ZXe;var L8t="AlertDialogAction",XXe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=C1(r);return e.jsx(FR,{...a,...n,ref:s})});XXe.displayName=L8t;var QXe="AlertDialogCancel",JXe=S.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,{cancelRef:a}=P8t(QXe,r),o=C1(r),l=Ta(s,a);return e.jsx(FR,{...o,...n,ref:l})});JXe.displayName=QXe;var D8t=({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 S.useEffect(()=>{var n;document.getElementById((n=t.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(s)},[s,t]),null},R8t=qXe,O8t=UXe,F8t=VXe,eQe=HXe,tQe=GXe,sQe=XXe,rQe=JXe,nQe=KXe,aQe=YXe;const Dl=R8t,_m=O8t,z8t=F8t,iQe=S.forwardRef(({className:t,...s},r)=>e.jsx(eQe,{className:Dt("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=S.forwardRef(({className:t,...s},r)=>e.jsxs(z8t,{children:[e.jsx(iQe,{}),e.jsx(tQe,{ref:r,className:Dt("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:Dt("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:Dt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});vl.displayName="AlertDialogFooter";const _l=S.forwardRef(({className:t,...s},r)=>e.jsx(nQe,{ref:r,className:Dt("text-lg font-semibold",t),...s}));_l.displayName=nQe.displayName;const bl=S.forwardRef(({className:t,...s},r)=>e.jsx(aQe,{ref:r,className:Dt("text-sm text-muted-foreground",t),...s}));bl.displayName=aQe.displayName;const ll=S.forwardRef(({className:t,...s},r)=>e.jsx(sQe,{ref:r,className:Dt(TT(),t),...s}));ll.displayName=sQe.displayName;const wl=S.forwardRef(({className:t,...s},r)=>e.jsx(rQe,{ref:r,className:Dt(TT({variant:"outline"}),"mt-2 sm:mt-0",t),...s}));wl.displayName=rQe.displayName;const B8t=[{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:gn,description:"View and upload videos"},{key:"listings",label:"Listings",icon:Sn,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 $8t(){var V;const{user:t}=qs(),[s,r]=S.useState([]),[n,a]=S.useState(!0),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState(null),[f,y]=S.useState({email:"",name:"",password:""}),[_,b]=S.useState("create"),[N,w]=S.useState(!1),[k,C]=S.useState(null);S.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(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(or,{className:"h-5 w-5"}),"My Assistants"]})}),e.jsx(Re,{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(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(or,{className:"h-5 w-5"}),"My Assistants"]}),e.jsx(ur,{children:"Add assistants to help manage your Agent OS"})]}),e.jsxs(K,{size:"sm",onClick:()=>{b("create"),l(!0)},children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Add Assistant"]})]})}),e.jsx(Re,{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(wn,{className:"h-10 w-10",children:e.jsx(jn,{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(K,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>{p(q),d(!0)},children:e.jsx(xr,{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:B8t.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(Mr,{checked:q.permissions[J.key]||!1,onCheckedChange:ce=>O(q.id,J.key,ce),disabled:k===q.id})]},J.key)})})]})]},q.id)})})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(hs,{children:[e.jsxs(js,{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(K,{variant:_==="create"?"default":"outline",size:"sm",onClick:()=>b("create"),children:[e.jsx(Bs,{className:"h-3 w-3 mr-1"}),"Create New"]}),e.jsxs(K,{variant:_==="link"?"default":"outline",size:"sm",onClick:()=>b("link"),children:[e.jsx(go,{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(Le,{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(Le,{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(Le,{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(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(K,{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(Dl,{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 Cr(n,a)}cutByIndex(s,r){return s==r?Cr.empty:s==0&&r==this.content.length?this:new Cr(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 Cr(a,o)}addToStart(s){return new Cr([s].concat(this.content),this.size+s.nodeSize)}addToEnd(s){return new Cr(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?Dz(r+1,o):Dz(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 Cr.empty;if(!Array.isArray(r))throw new RangeError("Invalid input for Fragment.fromJSON");return new Cr(r.map(s.nodeFromJSON))}static fromArray(s){if(!s.length)return Cr.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 Nle extends Error{}class bn{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 bn(n,this.openStart,this.openEnd)}removeBetween(s,r){return new bn(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 bn.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 bn(Cr.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 bn(s,n,a)}}bn.empty=new bn(Cr.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 q8t(t,s,r){if(r.openStart>t.depth)throw new Nle("Inserted content deeper than insertion position");if(t.depth-r.openStart!=s.depth-r.openEnd)throw new Nle("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,kle(t,s,a+1)),i),o8(s,r,a,i),l&&SS(CS(l,kle(r,n,a+1)),i)),o8(n,null,a,i),new Cr(i)}function kle(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,kle(t,s,r+1)),n)}return o8(s,null,r,n),new Cr(n)}function U8t(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(Cr.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 Sle(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=dLe.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=Cr.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=Cr.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 Cle 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 Cle(this.type,this.attrs,this.text,s)}withText(s){return s==this.text?this:new Cle(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 W8t(s,r);if(n.next==null)return JS.empty;let a=fQe(n);n.next&&n.err("Unexpected trailing text");let o=eDt(J8t(a));return tDt(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 W8t{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(K8t(t));while(t.eat("|"));return s.length==1?s[0]:{type:"choice",exprs:s}}function K8t(t){let s=[];do s.push(Z8t(t));while(t.next&&t.next!=")"&&t.next!="|");return s.length==1?s[0]:{type:"seq",exprs:s}}function Z8t(t){let s=Q8t(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=Y8t(t,s);else break;return s}function uLe(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let s=Number(t.next);return t.pos++,s}function Y8t(t,s){let r=uLe(t),n=r;return t.eat(",")&&(t.next!="}"?n=uLe(t):n=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:n,expr:s}}function X8t(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 Q8t(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=X8t(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 J8t(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),Cr.from(r),fl.setFrom(n))}createChecked(s=null,r,n){return r=Cr.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=Cr.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(Cr.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 sDt(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 rDt{constructor(s,r,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?sDt(s,r,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class lhe{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 lhe(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=mLe.compile(this.spec.nodes,this),this.marks=lhe.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?pLe(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==""?[]:pLe(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 mLe){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 Cle(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 pLe(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 nDt(t){return t.tag!=null}function aDt(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(nDt(a))this.tags.push(a);else if(aDt(a)){let o=/[^=]*/.exec(a.style)[0];n.indexOf(o)<0&&n.push(o),this.styles.push(a)}}),this.normalizeLists=!this.tags.some(a=>{if(!/^(ul|ol)\b/.test(a.tag)||!a.node)return!1;let o=s.nodes[a.node];return o.contentMatch.matchType(o)})}parse(s,r={}){let n=new xLe(this,r,!1);return n.addAll(s,fl.none,r.from,r.to),n.finish()}parseSlice(s,r={}){let n=new xLe(this,r,!0);return n.addAll(s,fl.none,r.from,r.to),bn.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=gLe(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=gLe(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},iDt={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 fLe(t,s,r){return s!=null?(s?mD:0)|(s==="full"?m_e:0):t&&t.whitespace=="pre"?mD|m_e:r&~c8}class Rz{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(Cr.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=Cr.from(this.content);return!s&&this.match&&(r=r.append(this.match.fillBefore(Cr.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 xLe{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=fLe(null,r.preserveWhitespace,0)|(n?c8:0);a?o=new Rz(a.type,a.attrs,fl.none,!0,r.topMatch||a.type.contentMatch,l):n?o=new Rz(null,null,fl.none,!0,null,l):o=new Rz(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):yLe(u.type,s))?(d=u.addToSet(d),!1):!0),this.nodes.push(new Rz(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 oDt(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 lDt(t,s){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,s)}function gLe(t){let s={};for(let r in t)s[r]=t[r];return s}function yLe(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&&Qie(Vge(n),a(s,r),null,s.attrs)}static renderSpec(s,r,n=null,a){return Qie(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=vLe(s.nodes);return r.text||(r.text=n=>n.text),r}static marksFromSchema(s){return vLe(s.marks)}}function vLe(t){let s={};for(let r in t){let n=t[r].spec.toDOM;n&&(s[r]=n)}return s}function Vge(t){return t.document||window.document}const _Le=new WeakMap;function cDt(t){let s=_Le.get(t);return s===void 0&&_Le.set(t,s=dDt(t)),s}function dDt(t){let s=null;function r(n){if(n&&typeof n=="object")if(Array.isArray(n))if(typeof n[0]=="string")s||(s=[]),s.push(n);else for(let a=0;a-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let l=a.indexOf(" ");l>0&&(r=a.slice(0,l),a=a.slice(l+1));let i,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}=Qie(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 uDt(t,s){return t+s*SQe}function bLe(t){return t&kQe}function hDt(t){return(t-(t&kQe))/SQe}const CQe=1,MQe=2,Jie=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|Jie))>0}get deletedAfter(){return(this.delInfo&(MQe|Jie))>0}get deletedAcross(){return(this.delInfo&Jie)>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=bLe(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:uDt(i/3,s-d),N=s==d?MQe:s==f?CQe:Jie;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=bLe(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 bn(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 bn(Cr.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,bn.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 mDt(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 pDt(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 lhe){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 fDt(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=Cr.from(n.node(b).copy(p)),f++):d--;let y=Cr.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=Cr.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 bn(n,0,0),r.length,!0))}function _Dt(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)&&bDt(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 bn(Cr.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 bDt(t,s,r){let n=t.resolve(s),a=n.index();return n.parent.canReplaceWith(a,a+1,r)}function wDt(t,s,r,n,a){let o=t.doc.nodeAt(s);if(!o)throw new RangeError("No node at given position");r||(r=o.type);let l=r.create(n,null,a||o.marks);if(o.isLeaf)return t.replaceWith(s,s+o.nodeSize,l);if(!r.validContent(o.content))throw new RangeError("Invalid content for node type "+r.name);t.step(new $u(s,s+o.nodeSize,s+1,s+o.nodeSize-1,new bn(Cr.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 jDt(t,s,r=1,n){let a=t.doc.resolve(s),o=Cr.empty,l=Cr.empty;for(let i=a.depth,d=a.depth-r,u=r-1;i>d;i--,u--){o=Cr.from(a.node(i).copy(o));let p=n&&n[u];l=Cr.from(p?p.type.create(p.attrs,l):a.node(i).copy(l))}t.step(new Od(s,s,new bn(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 NDt(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 kDt(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),bn.empty,!0)),n===!0){let p=t.doc.resolve(u);AQe(t,p.node(),p.before(),t.steps.length)}return t}function SDt(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 dhe(t,s,r=s,n=bn.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 CDt(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 CDt{constructor(s,r,n){this.$from=s,this.$to=r,this.unplaced=n,this.frontier=[],this.placed=Cr.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=Cr.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 bn(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=Gge(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(Cr.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=Gge(s,r);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new bn(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=Gge(s,r);if(a.childCount<=1&&r>0){let o=s.size-r<=r+a.size;this.unplaced=new bn(RI(s,r-1,1),r-1,o?r-1:n)}else this.unplaced=new bn(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,Cr.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 k=w.lastChild;this.frontier.push({type:k.type,match:k.contentMatchAt(k.childCount)}),w=k.content}this.unplaced=b?s==0?bn.empty:new bn(RI(l.content,s-1,1),s-1,_<0?l.openEnd:s-1):new bn(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||!Wge(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=Wge(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,Cr.from(s.create(r,n))),this.frontier.push({type:s,match:s.contentMatch})}closeFrontierNode(){let r=this.frontier.pop().match.fillBefore(Cr.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 Gge(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(Cr.empty,!0)))),t.copy(n)}function Wge(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&&!MDt(r,o.content,l)?i:null}function MDt(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=TDt(_.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(Cr.empty,!0))}return t}function EDt(t,s,r,n){if(!n.isInline&&s==r&&t.doc.resolve(s).parent.content.size){let a=SDt(t.doc,s,n.type);a!=null&&(s=r=a)}t.replaceRange(s,r,new bn(Cr.from(n),0,0))}function PDt(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 bn(Cr.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=bn.empty){let a=dhe(this.doc,s,r,n);return a&&this.step(a),this}replaceWith(s,r,n){return this.replace(s,r,new bn(Cr.from(n),0,0))}delete(s,r){return this.replace(s,r,bn.empty)}insert(s,r){return this.replaceWith(s,s,r)}replaceRange(s,r,n){return ADt(this,s,r,n),this}replaceRangeWith(s,r,n){return EDt(this,s,r,n),this}deleteRange(s,r){return PDt(this,s,r),this}lift(s,r){return xDt(this,s,r),this}join(s,r=1){return kDt(this,s,r),this}wrap(s,r){return vDt(this,s,r),this}setBlockType(s,r=s,n,a=null){return _Dt(this,s,r,n,a),this}setNodeMarkup(s,r,n=null,a){return wDt(this,s,r,n,a),this}setNodeAttribute(s,r,n){return this.step(new 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 jDt(this,s,r,n),this}addMark(s,r,n){return mDt(this,s,r,n),this}removeMark(s,r,n){return pDt(this,s,r,n),this}clearIncompatible(s,r,n){return hke(this,s,r,n),this}}const Kge=Object.create(null);class ei{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=Kge[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 Kge)throw new RangeError("Duplicate use of selection JSON ID "+s);return Kge[s]=r,r.prototype.jsonID=s,r}getBookmark(){return Va.between(this.$anchor,this.$head).getBookmark()}}ei.prototype.visible=!0;class FQe{constructor(s,r){this.$from=s,this.$to=r}}let jLe=!1;function NLe(t){!jLe&&!t.parent.inlineContent&&(jLe=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Va extends ei{constructor(s,r=s){NLe(s),NLe(r),super(s,r)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(s,r){let n=s.resolve(r.map(this.head));if(!n.parent.inlineContent)return ei.near(n);let a=s.resolve(r.map(this.anchor));return new Va(a.parent.inlineContent?a:n,n)}replace(s,r=bn.empty){if(super.replace(s,r),r==bn.empty){let n=this.$from.marksAcross(this.$to);n&&s.ensureMarks(n)}}eq(s){return s instanceof Va&&s.anchor==this.anchor&&s.head==this.head}getBookmark(){return new uhe(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 Va(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=ei.findFrom(r,n,!0)||ei.findFrom(r,-n,!0);if(o)r=o.$head;else return ei.near(r,n)}return s.parent.inlineContent||(a==0?s=r:(s=(ei.findFrom(s,-n,!0)||ei.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 kLe(t,s,r){let n=t.steps.length-1;if(n{l==null&&(l=p)}),t.setSelection(ei.near(t.doc.resolve(l),r))}const SLe=1,Oz=2,CLe=4;class LDt 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|=Oz,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&Oz)>0}addStep(s,r){super.addStep(s,r),this.updated=this.updated&~Oz,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(ei.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|=CLe,this}get scrolledIntoView(){return(this.updated&CLe)>0}}function MLe(t,s){return!s||!t?t:t.bind(s)}class FI{constructor(s,r,n){this.name=s,this.init=MLe(r.init,n),this.apply=MLe(r.apply,n)}}const DDt=[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||ei.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 Zge{constructor(s,r){this.schema=s,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=DDt.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 Zge(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=ei.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 Yge=Object.create(null);function BQe(t){return t in Yge?t+"$"+ ++Yge[t]:(Yge[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},RDt=function(){x_e=null},tC=function(t,s,r,n){return r&&(TLe(t,s,r,n,-1)||TLe(t,s,r,n,1))},ODt=/^(img|br|input|textarea|hr)$/i;function TLe(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)||ODt.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 FDt(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 zDt(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=!!ALe&&"webkitFontSmoothing"in ALe.documentElement.style,UDt=YR?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function VDt(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 HDt(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 ELe(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?VDt(o):HDt(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 GDt(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 WDt({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?ZDt(r,a):!r||n&&r.nodeType==1?{node:t,offset:o}:GQe(r,a)}function ZDt(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 YDt(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 QDt(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=QDt(t,n,a,s))}i==null&&(i=XDt(t,l,s));let d=t.docView.nearestDesc(l,!0);return{pos:i,inside:d?d.posAtStart-d.border:-1}}function PLe(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 Xge(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 Xge(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 tRt(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 sRt=/[\u0590-\u08ac]/;function rRt(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?!sRt.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 ILe=null,LLe=null,DLe=!1;function nRt(t,s,r){return ILe==s&&LLe==r?DLe:(ILe=s,LLe=r,DLe=r=="up"||r=="down"?tRt(t,s,r):rRt(t,s,r))}const jx=0,RLe=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:RLe,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:RLe;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 aRt 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 iRt(s,r,n,a,p,f||null,y,u,o,l+1):r.isText?new mhe(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=()=>Cr.empty)}return s}matchesNode(s,r,n){return this.dirty==jx&&s.eq(this.node)&&Mle(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 lRt(this,l&&l.node,s);uRt(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&&hRt(this.dom))}localCompositionInfo(s,r){let{from:n,to:a}=s.state.selection;if(!(s.state.selection instanceof Va)||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=mRt(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 aRt(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(Mle(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 OLe(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 mhe 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 mhe(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 iRt 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 dRt(t,s){return t.type.side-s.type.side}function uRt(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 hRt(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 mRt(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(hhe(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&&BDt(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 fRt(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&&yp&&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&&(qLe(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else qLe(t)}function qLe(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))||Va.between(s,r,n)}function ULe(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 xRt(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&&ei.findFrom(o,s)}function D_(t,s){return t.dispatch(t.state.tr.setSelection(s).scrollIntoView()),!0}function VLe(t,s,r){let n=t.state.selection;if(n instanceof Va)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 Va(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 Va(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 Va(s>0?n.$to:n.$from));{let a=w_e(t.state,s);return a?D_(t,a):!1}}}function Tle(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?gRt(t):yRt(t)}function gRt(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=Tle(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 yRt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a=Tle(r),o,l;for(;;)if(n{t.state==a&&r1(t)},50)}function HLe(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 GLe(t,s,r){let n=t.state.selection;if(n instanceof Va&&!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?ei.near(l,s):ei.findFrom(l,s);return i?D_(t,i):!1}return!1}function WLe(t,s){if(!(t.state.selection instanceof Va))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 KLe(t,s,r){t.domObserver.stop(),s.contentEditable=r,t.domObserver.start()}function bRt(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;KLe(t,n,"true"),setTimeout(()=>KLe(t,n,"false"),20)}return!1}function wRt(t){let s="";return t.ctrlKey&&(s+="c"),t.metaKey&&(s+="m"),t.altKey&&(s+="a"),t.shiftKey&&(s+="s"),s}function jRt(t,s){let r=s.keyCode,n=wRt(s);if(r==8||sx&&r==72&&n=="c")return WLe(t,-1)||v5(t,-1);if(r==46&&!s.shiftKey||sx&&r==68&&n=="c")return WLe(t,1)||v5(t,1);if(r==13||r==27)return!0;if(r==37||sx&&r==66&&n=="c"){let a=r==37?HLe(t,t.state.selection.from)=="ltr"?-1:1:-1;return VLe(t,a,n)||v5(t,a)}else if(r==39||sx&&r==70&&n=="c"){let a=r==39?HLe(t,t.state.selection.from)=="ltr"?1:-1:1;return VLe(t,a,n)||v5(t,a)}else{if(r==38||sx&&r==80&&n=="c")return GLe(t,-1,n)||v5(t,-1);if(r==40||sx&&r==78&&n=="c")return bRt(t)||GLe(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 bn(Cr.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=CRt(r),YR&&MRt(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&&!NRt.test(y.parentNode.nodeName)?{ignore:!0}:null}})),p)i=TRt(ZLe(i,+p[1],+p[2]),p[4]);else if(i=bn.maxOpen(kRt(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 NRt=/^(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 kRt(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 Cr.from(l)}return t}function iJe(t,s,r=0){for(let n=s.length-1;n>=r;n--)t=s[n].create(null,Cr.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(Cr.empty,!0))),t.replaceChild(s<0?0:t.childCount-1,l.copy(i))}function ZLe(t,s,r){return sr})),Jge.createHTML(t)):t}function CRt(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=SRt(t),a)for(let o=0;o=0;i-=2){let d=r.nodes[n[i]];if(!d||d.hasRequiredAttrs())break;a=Cr.from(d.create(n[i+1],a)),o++,l++}return new bn(a,o,l)}const Pm={},Im={},ARt={touchstart:!0,touchmove:!0};class ERt{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 PRt(t){for(let s in Pm){let r=Pm[s];t.dom.addEventListener(s,t.input.eventHandlers[s]=n=>{LRt(t,n)&&!_ke(t,n)&&(t.editable||!(n.type in Im))&&r(t,n)},ARt[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 IRt(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 LRt(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 DRt(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))||jRt(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 Va)||!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 phe(t){return{left:t.clientX,top:t.clientY}}function RRt(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 ORt(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 FRt(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 zRt(t,s,r,n,a){return bke(t,"handleClickOn",s,r,n)||t.someProp("handleClick",o=>o(t,s,n))||(a?FRt(t,r):ORt(t,r))}function BRt(t,s,r,n){return bke(t,"handleDoubleClickOn",s,r,n)||t.someProp("handleDoubleClick",a=>a(t,s,n))}function $Rt(t,s,r,n){return bke(t,"handleTripleClickOn",s,r,n)||t.someProp("handleTripleClick",a=>a(t,s,n))||qRt(t,r,n)}function qRt(t,s,r){if(r.button!=0)return!1;let n=t.state.doc;if(s==-1)return n.inlineContent?(XM(t,Va.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,Va.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 Ale(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&&RRt(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(phe(r));l&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new URt(t,l,r,!!n)):(o=="doubleClick"?BRt:$Rt)(t,l.pos,l.inside,r)?r.preventDefault():mb(t,"pointer"))};class URt{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(phe(s))),this.updateAllowDefault(s),this.allowDefault||!r?mb(this.view,"pointer"):zRt(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,ei.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 VRt=$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 Va&&(s.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||ih&&UQe&&HRt(t)))t.markCursor=t.state.storedMarks||r.marks(),Ale(t,!0),t.markCursor=null;else if(Ale(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,VRt)};function HRt(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(()=>Ale(t),s))}function pJe(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=WRt());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function GRt(t){let s=t.domSelectionRange();if(!s.focusNode)return null;let r=FDt(s.focusNode,s.focusOffset),n=zDt(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 WRt(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Ale(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 KRt(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=yp&&Ob<15||UT&&UDt<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)):KRt(t,i),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function ZRt(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function YRt(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||bn.empty)))return!0;if(!o)return!1;let l=ZRt(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():YRt(t,r)};class xJe{constructor(s,r,n){this.slice=s,this.move=r,this.node=n}}const XRt=sx?"altKey":"ctrlKey";function gJe(t,s){let r;return t.someProp("dragCopies",n=>{r=r||n(s)}),r!=null?!r:!s[XRt]}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(phe(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{QRt(t,s,t.dragging)}finally{t.dragging=null}};function QRt(t,s,r){if(!s.dataTransfer)return;let n=t.posAtCoords(phe(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||bn.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,k)=>_=k),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 Ele{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 Ele&&(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 k=0;kC+p-f)continue;let A=i[k]+p-f;_>=A?i[k+1]=y<=A?-2:-1:y>=p&&w&&(i[k]+=w,i[k+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 k=i[u+2].mapInner(r,w,p+1,t[u]+o+1,l);k!=Ch?(i[u]=f,i[u+1]=_,i[u+2]=k):(i[u+1]=-2,d=!0)}else d=!0}if(d){let u=eOt(i,t,s,r,a,o,l),p=Ple(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=Ple(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 eye(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 tOt={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},sOt=yp&&Ob<=11;class rOt{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 nOt{constructor(s,r){this.view=s,this.handleDOMChange=r,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new rOt,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()}),sOt&&(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,tOt)),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(ULe(this.view)){if(this.suppressingSelectionUpdates)return r1(this.view);if(yp&&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)&&ULe(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||oOt(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),aOt(s)),s.input.badSafariComposition&&(s.input.badSafariComposition=!1,lOt(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 k=n.childNodes[w-1],C=k.pmViewDesc;if(k.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:dOt,context:_});if(u&&u[0].pos!=null){let w=u[0].pos,k=u[1]&&u[1].pos;k==null&&(k=w),b={anchor:w+l,head:k+l}}return{doc:N,sel:b,from:l,to:i}}function dOt(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 uOt=/^(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 hOt(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=cOt(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&&!uOt.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 Va&&!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=t8e(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)),yp&&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),k=p.resolve(b.start),C=N.sameParent(w)&&N.parent.inlineContent&&k.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&&pOt(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=t8e(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=mOt(N.parent.content.cut(N.parentOffset,w.parentOffset),k.parent.content.cut(k.parentOffset,b.endA-k.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 t8e(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 mOt(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||tye(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 fOt(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 ERt,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=r,this.state=r.state,this.directPlugins=r.plugins||[],this.directPlugins.forEach(o8e),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=a8e(this),n8e(this),this.nodeViews=i8e(this),this.docView=OLe(this.state.doc,r8e(this),eye(this),this.dom,this),this.domObserver=new nOt(this,(n,a,o,l)=>hOt(this,n,a,o,l)),this.domObserver.start(),PRt(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(o8e),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 _=i8e(this);gOt(_,this.nodeViews)&&(this.nodeViews=_,o=!0)}(i||r.handleDOMEvents!=this._props.handleDOMEvents)&&k_e(this),this.editable=a8e(this),n8e(this);let d=eye(this),u=r8e(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&&GDt(this);if(l){this.domObserver.stop();let _=f&&(yp||ih)&&!this.composing&&!a.selection.empty&&!s.selection.empty&&xOt(a.selection,s.selection);if(f){let b=ih?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=GRt(this)),(o||!this.docView.update(s.doc,u,d,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=OLe(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())&&xRt(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&&WDt(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&&ELe(this,r.getBoundingClientRect(),s)}else ELe(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 JDt(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 nRt(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&&(IRt(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],eye(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,RDt())}get isDestroyed(){return this.docView==null}dispatchEvent(s){return DRt(this,s)}domSelectionRange(){let s=this.domSelection();return s?Bh&&this.root.nodeType===11&&$Dt(this.dom.ownerDocument)==this.dom&&iOt(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 r8e(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 n8e(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 a8e(t){return!t.someProp("editable",s=>s(t.state)===!1)}function xOt(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 i8e(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 gOt(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 o8e(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:"'"},Ile={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},yOt=typeof navigator<"u"&&/Mac/.test(navigator.platform),vOt=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),Ile[nh]=String.fromCharCode(nh);for(var sye in rw)Ile.hasOwnProperty(sye)||(Ile[sye]=rw[sye]);function _Ot(t){var s=yOt&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||vOt&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",r=!s&&t.key||(t.shiftKey?Ile: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 bOt=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),wOt=typeof navigator<"u"&&/Win/.test(navigator.platform);function jOt(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 COt=(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=dhe(t.doc,n.before(l),n.after(l),bn.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},MOt=(t,s,r)=>{let n=wJe(t,r);if(!n)return!1;let a=Ske(n);return a?jJe(t,a,s):!1},TOt=(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=dhe(t.doc,o,d,bn.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(Va.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 AOt=(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=dhe(t.doc,n.before(),n.after(),bn.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=che(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},LOt=(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=che(t.doc,r.to,1),n==null)return!1;return s&&s(t.tr.join(n).scrollIntoView()),!0},DOt=(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)},ROt=(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(ei.near(d.doc.resolve(i),1)),s(d.scrollIntoView())}return!0},FOt=(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)},BOt=(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 $Ot(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&&$Ot(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=Cr.empty;for(let k=l.length-1;k>=0;k--)b=Cr.from(l[k].create(null,b));b=Cr.from(a.copy(b));let N=t.tr.step(new $u(s.pos-1,_,s.pos,_,new bn(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:ei.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 k=Cr.empty;for(let A=b.length-1;A>=0;A--)k=Cr.from(b[A].copy(k));let C=t.tr.step(new $u(s.pos-b.length,s.pos+o.nodeSize,s.pos+w,s.pos+o.nodeSize-w,new bn(k,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(Va.create(s.doc,t<0?a.start(o):a.end(o)))),!0):!1}}const qOt=CJe(-1),UOt=CJe(1);function VOt(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 l8e(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 Sle(d,d,s.depth),s.endIndex=0;p--)o=Cr.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 bn(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?ZOt(s,r,t,o):YOt(s,r,o):!0:!1}}function ZOt(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?Cr.empty:Cr.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 bn((i?Cr.empty:Cr.from(a.copy(Cr.empty))).append(d?Cr.empty:Cr.from(a.copy(Cr.empty))),i?0:1,d?0:1),i?0:1)),s(n.scrollIntoView()),!0}function XOt(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=Cr.from(u?t.create():null),f=new bn(Cr.from(t.create(null,Cr.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 fhe(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 xhe{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),k=_(...N)(w);return i.push(k),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:fhe({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 QOt=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 ghe(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}=ghe(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 JOt(t={}){return Object.keys(t).length===0&&t.constructor===Object}function eFt(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function c8e(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):eFt(r.getAttribute(l.name));return i==null?o:{...o,[l.name]:i}},{});return{...n,...a}}}}function d8e(t){return Object.fromEntries(Object.entries(t).filter(([s,r])=>s==="attrs"&&JOt(r)?!1:r!=null))}function tFt(t,s){var r;const n=MJe(t),{nodeExtensions:a,markExtensions:o}=ghe(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(k=>k.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:s},y=t.reduce((k,C)=>{const A=aa(C,"extendNodeSchema",f);return{...k,...A?A(u):{}}},{}),_=d8e({...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(k=>{var C;return[k.name,{default:(C=k==null?void 0:k.attribute)===null||C===void 0?void 0:C.default}]}))}),b=Di(aa(u,"parseHTML",f));b&&(_.parseDOM=b.map(k=>c8e(k,p)));const N=aa(u,"renderHTML",f);N&&(_.toDOM=k=>N({node:k,HTMLAttributes:S_e(k,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,k)=>{const C=aa(k,"extendMarkSchema",f);return{...w,...C?C(u):{}}},{}),_=d8e({...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 k;return[w.name,{default:(k=w==null?void 0:w.attribute)===null||k===void 0?void 0:k.default}]}))}),b=Di(aa(u,"parseHTML",f));b&&(_.parseDOM=b.map(w=>c8e(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 nye(t,s){return s.nodes[t]||s.marks[t]||null}function u8e(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 sFt=(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 yhe{constructor(s){this.find=s.find,this.handler=s.handler}}const rFt=(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 Fz(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=sFt(u)+o;return l.forEach(y=>{if(p)return;const _=rFt(f,y.find);if(!_)return;const b=d.state.tr,N=fhe({state:d.state,transaction:b}),w={from:n-(_[0].length-o.length),to:a},{commands:k,chain:C,can:A}=new xhe({editor:r,state:N});y.handler({state:N,range:w,match:_,commands:k,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 nFt(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(Cr.from(p),l.schema);const{from:f}=d,y=f+p.length;Fz({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 Fz({editor:s,from:o,to:l,text:i,rules:r,plugin:n})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:o}=a.state.selection;o&&Fz({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?Fz({editor:s,from:l.pos,to:l.pos,text:` `,rules:r,plugin:n}):!1}},isInputRules:!0});return n}function aFt(t){return Object.prototype.toString.call(t).slice(8,-1)}function zz(t){return aFt(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function vhe(t,s){const r={...t};return zz(t)&&zz(s)&&Object.keys(s).forEach(n=>{zz(s[n])&&zz(t[n])?r[n]=vhe(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:()=>vhe(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 iFt(t){return typeof t=="number"}class oFt{constructor(s){this.find=s.find,this.handler=s.handler}}const lFt=(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 cFt(t){const{editor:s,state:r,from:n,to:a,rule:o,pasteEvent:l,dropEvent:i}=t,{commands:d,chain:u,can:p}=new xhe({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),k=_.textBetween(N-b,w-b,void 0,"");lFt(k,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 Bz=null;const dFt=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 uFt(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=fhe({state:p,transaction:N});if(!(!cFt({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&&(Bz=s)},_=()=>{Bz&&(Bz=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 _=Bz;_!=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,k=b.getMeta("applyPasteRules"),C=!!k;if(!N&&!w&&!C)return;if(C){let{text:L}=k;typeof L=="string"?L=L:L=Mke(Cr.from(L),_.schema);const{from:O}=k,V=O+L.length,q=dFt(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(!(!iFt(A)||!I||A===I.b))return d({rule:p,state:_,from:A,to:I,pasteEvt:l})}}))}function hFt(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=tFt(this.extensions,r),this.setupExtensions()}static resolve(s){const r=nM.sort(nM.flatten(s)),n=hFt(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:nye(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:nye(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,k])=>[w,()=>k({editor:s})]));p={...p,...N}}const f=kOt(p);d.push(f);const y=aa(l,"addInputRules",i);u8e(l,s.options.enableInputRules)&&y&&n.push(...y());const _=aa(l,"addPasteRules",i);u8e(l,s.options.enablePasteRules)&&_&&a.push(..._());const b=aa(l,"addProseMirrorPlugins",i);if(b){const N=b();d.push(...N)}return d}).flat();return[nFt({editor:s,rules:n}),...uFt({editor:s,rules:a}),...o]}get attributes(){return MJe(this.extensions)}get nodeViews(){const{editor:s}=this,{nodeExtensions:r}=ghe(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:nye(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:()=>vhe(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 mFt=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})}}})]}}),pFt=()=>({editor:t,view:s})=>(requestAnimationFrame(()=>{var r;t.isDestroyed||(s.dom.blur(),(r=window==null?void 0:window.getSelection())===null||r===void 0||r.removeAllRanges())}),!0),fFt=(t=!1)=>({commands:s})=>s.setContent("",t),xFt=()=>({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},gFt=t=>s=>t(s),yFt=()=>({state:t,dispatch:s})=>FOt(t,s),vFt=(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 Va(n.doc.resolve(Math.max(l-1,0)))),!0},_Ft=()=>({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},bFt=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},wFt=t=>({tr:s,dispatch:r})=>{const{from:n,to:a}=t;return r&&s.delete(n,a),!0},jFt=()=>({state:t,dispatch:s})=>SOt(t,s),NFt=()=>({commands:t})=>t.keyboardShortcut("Enter"),kFt=()=>({state:t,dispatch:s})=>OOt(t,s);function Lle(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&&Lle(Object.fromEntries(Object.keys(r).map(a=>[a,n.attrs[a]])),r))}function h8e(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&&h8e([...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=Va.create(l,f.from,f.to);r.setSelection(y)}}return!0},CFt=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=()=>{(Dle()||m8e())&&n.dom.focus(),requestAnimationFrame(()=>{r.isDestroyed||(n.focus(),MFt()&&!Dle()&&!m8e()&&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},AFt=(t,s)=>r=>t.every((n,a)=>s(n,{...r,index:a})),EFt=(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 $z(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 Cr)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 Cr.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($z(t),r.parseOptions):l8.fromSchema(d).parse($z(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($z(t),r.parseOptions).content:o.parse($z(t),r.parseOptions)}return vD("",s,r)}function PFt(t,s,r){const n=t.steps.length-1;if(n{l===0&&(l=p)}),t.setSelection(ei.near(t.doc.resolve(l),r))}const IFt=t=>!("type"in t),LFt=(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((IFt(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 Cr){let w="";s.forEach(k=>{k.text&&(w+=k.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&&PFt(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},DFt=()=>({state:t,dispatch:s})=>IOt(t,s),RFt=()=>({state:t,dispatch:s})=>LOt(t,s),OFt=()=>({state:t,dispatch:s})=>COt(t,s),FFt=()=>({state:t,dispatch:s})=>EOt(t,s),zFt=()=>({state:t,dispatch:s,tr:r})=>{try{const n=che(t.doc,t.selection.$from.pos,-1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},BFt=()=>({state:t,dispatch:s,tr:r})=>{try{const n=che(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})=>MOt(t,s),qFt=()=>({state:t,dispatch:s})=>TOt(t,s);function RJe(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function UFt(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=UFt(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=>Lle(f.node.attrs,r,{strict:!1}));return o?!!u.length:u.reduce((f,y)=>f+y.to-y.from,0)>=d}const HFt=(t,s={})=>({state:r,dispatch:n})=>{const a=Vu(t,r.schema);return _D(r,a,s)?DOt(r,n):!1},GFt=()=>({state:t,dispatch:s})=>zOt(t,s),WFt=t=>({state:s,dispatch:r})=>{const n=Vu(t,s.schema);return KOt(n)(s,r)},KFt=()=>({state:t,dispatch:s})=>ROt(t,s);function _he(t,s){return s.nodes[t]?"node":s.marks[t]?"mark":null}function p8e(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 ZFt=(t,s)=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=_he(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,p8e(u.attrs,s)),l&&u.marks.length&&u.marks.forEach(f=>{l===f.type&&r.addMark(p,p+u.nodeSize,l.create(p8e(f.attrs,s)))})})}),!0):!1},YFt=()=>({tr:t,dispatch:s})=>(s&&t.scrollIntoView(),!0),XFt=()=>({tr:t,dispatch:s})=>{if(s){const r=new bx(t.doc);t.setSelection(r)}return!0},QFt=()=>({state:t,dispatch:s})=>AOt(t,s),JFt=()=>({state:t,dispatch:s})=>POt(t,s),e7t=()=>({state:t,dispatch:s})=>BOt(t,s),t7t=()=>({state:t,dispatch:s})=>UOt(t,s),s7t=()=>({state:t,dispatch:s})=>qOt(t,s);function C_e(t,s,r={},n={}){return vD(t,s,{slice:!1,parseOptions:r,errorOnInvalidContent:n.errorOnInvalidContent})}const r7t=(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 n7t(t,s){const r=new pke(t);return s.forEach(n=>{n.steps.forEach(a=>{r.step(a)})}),r}function a7t(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 o7t(t,s){const r={from:0,to:t.content.size};return AJe(t,r,s)}function l7t(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=_he(typeof s=="string"?s:s.name,t.schema);return r==="node"?l7t(t,s):r==="mark"?OJe(t,s):{}}function c7t(t,s=JSON.stringify){const r={};return t.filter(n=>{const a=s(n);return Object.prototype.hasOwnProperty.call(r,a)?!1:r[a]=!0})}function d7t(t){const s=c7t(t);return s.length===1?s:s.filter((r,n)=>!s.filter((o,l)=>l!==n).some(o=>r.oldRange.from>=o.oldRange.from&&r.oldRange.to<=o.oldRange.to&&r.newRange.from>=o.newRange.from&&r.newRange.to<=o.newRange.to))}function u7t(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}})})}),d7t(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 eoe(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=>Lle(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 k=Math.max(_,w),C=Math.min(b,w+N.nodeSize),A=C-k;l+=A,i.push(...N.marks.map(I=>({mark:I,from:k,to:C})))})}),l===0)return!1;const d=i.filter(f=>o?o.name===f.mark.type.name:!0).filter(f=>Lle(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 h7t(t,s,r={}){if(!s)return _D(t,null,r)||M_e(t,null,r);const n=_he(s,t.schema);return n==="node"?_D(t,s,r):n==="mark"?M_e(t,s,r):!1}function f8e(t,s){const{nodeExtensions:r}=ghe(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 m7t(t){return t instanceof Fa}function p7t(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 f7t=(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(k=>k.type===d)?y.marks.forEach(k=>{d===k.type&&r.addMark(b,N,d.create({...k.attrs,...s}))}):r.addMark(b,N,d.create(s))})});return p7t(n,r,d)},x7t=(t,s)=>({tr:r})=>(r.setMeta(t,s),!0),g7t=(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})=>l8e(o,{...l,...s})(r)?!0:i.clearNodes()).command(({state:i})=>l8e(o,{...l,...s})(i,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},y7t=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},v7t=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,{from:a,to:o}=typeof t=="number"?{from:t,to:t}:t,l=Va.atStart(n).from,i=Va.atEnd(n).to,d=j4(a,l,i),u=j4(o,l,i),p=Va.create(n,d,u);s.setSelection(p)}return!0},_7t=t=>({state:s,dispatch:r})=>{const n=Vu(t,s.schema);return XOt(n)(s,r)};function x8e(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 b7t=({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=eoe(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&&x8e(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:a7t(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 Va&&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&&x8e(r,a.extensionManager.splittableMarks),s.scrollIntoView()}return b},w7t=(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 k=Cr.empty;const C=d.index(-1)?1:d.index(-2)?2:3;for(let q=d.depth-C;q>=d.depth-3;q-=1)k=Cr.from(d.node(q).copy(k));const A=d.indexAfter(-1){if(V>-1)return!1;q.isTextblock&&q.content.size===0&&(V=B+1)}),V>-1&&r.setSelection(Va.near(r.doc.resolve(V))),r.scrollIntoView()}return!0}const _=u.pos===d.end()?f.contentMatchAt(0).defaultType:null,b={...eoe(y,f.type.name,f.attrs),...s},N={...eoe(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:k,storedMarks:C}=n,{splittableMarks:A}=o.extensionManager,I=C||k.$to.parentOffset&&k.$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},aye=(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},iye=(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},j7t=(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:k,$to:C}=N,A=k.blockRange(C),I=w||N.$to.parentOffset&&N.$from.marks();if(!A)return!1;const L=Eke(O=>f8e(O.type.name,f))(N);if(A.depth>=1&&L&&A.depth-L.depth<=1){if(L.node.type===_)return u.liftListItem(b);if(f8e(L.node.type.name,f)&&_.validContent(L.node.content)&&i)return d().command(()=>(o.setNodeMarkup(L.pos,_),!0)).command(()=>aye(o,_)).command(()=>iye(o,_)).run()}return!r||!I||!i?d().command(()=>p().wrapInList(_,n)?!0:u.clearNodes()).wrapInList(_,n).command(()=>aye(o,_)).command(()=>iye(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(()=>aye(o,_)).command(()=>iye(o,_)).run()},N7t=(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)},k7t=(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})},S7t=(t,s={})=>({state:r,commands:n})=>{const a=Vu(t,r.schema);return _D(r,a,s)?n.lift(a):n.wrapIn(a,s)},C7t=()=>({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},M7t=()=>({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},T7t=(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},A7t=(t,s={})=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=_he(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(k=>{if(l===k.type){const C=Math.max(w,u),A=Math.min(w+N.nodeSize,p);r.addMark(C,A,l.create({...k.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},E7t=(t,s={})=>({state:r,dispatch:n})=>{const a=Vu(t,r.schema);return VOt(a,s)(r,n)},P7t=(t,s={})=>({state:r,dispatch:n})=>{const a=Vu(t,r.schema);return HOt(a,s)(r,n)};var I7t=Object.freeze({__proto__:null,blur:pFt,clearContent:fFt,clearNodes:xFt,command:gFt,createParagraphNear:yFt,cut:vFt,deleteCurrentNode:_Ft,deleteNode:bFt,deleteRange:wFt,deleteSelection:jFt,enter:NFt,exitCode:kFt,extendMarkRange:SFt,first:CFt,focus:TFt,forEach:AFt,insertContent:EFt,insertContentAt:LFt,joinBackward:OFt,joinDown:RFt,joinForward:FFt,joinItemBackward:zFt,joinItemForward:BFt,joinTextblockBackward:$Ft,joinTextblockForward:qFt,joinUp:DFt,keyboardShortcut:VFt,lift:HFt,liftEmptyBlock:GFt,liftListItem:WFt,newlineInCode:KFt,resetAttributes:ZFt,scrollIntoView:YFt,selectAll:XFt,selectNodeBackward:QFt,selectNodeForward:JFt,selectParentNode:e7t,selectTextblockEnd:t7t,selectTextblockStart:s7t,setContent:r7t,setMark:f7t,setMeta:x7t,setNode:g7t,setNodeSelection:y7t,setTextSelection:v7t,sinkListItem:_7t,splitBlock:b7t,splitListItem:w7t,toggleList:j7t,toggleMark:N7t,toggleNode:k7t,toggleWrap:S7t,undoInputRule:C7t,unsetAllMarks:M7t,unsetMark:T7t,updateAttributes:A7t,wrapIn:E7t,wrapInList:P7t});const L7t=xh.create({name:"commands",addCommands(){return{...I7t}}}),D7t=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})}}})]}}),R7t=xh.create({name:"editable",addProseMirrorPlugins(){return[new vu({key:new Vh("editable"),props:{editable:()=>this.editor.options.editable}})]}}),O7t=new Vh("focusEvents"),F7t=xh.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new vu({key:O7t,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}}}})]}}),z7t=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,k=N&&b.parent.childCount===1?w===f.pos:ei.atStart(u).from===y;return!p||!_.type.isTextblock||_.textContent.length||!k||k&&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 Dle()||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=ei.atStart(s.doc).from,u=ei.atEnd(s.doc).to;if(o||!(l===d&&i===u)||!Ike(r.doc))return;const y=r.tr,_=fhe({state:r,transaction:y}),{commands:b}=new xhe({editor:this.editor,state:_});if(b.clearNodes(),!!y.steps.length)return y}})]}}),B7t=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})}}})]}}),$7t=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 q7t=`.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 U7t(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 V7t extends QOt{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=U7t(q7t,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?[R7t,mFt.configure({blockSeparator:(r=(s=this.options.coreExtensionOptions)===null||s===void 0?void 0:s.clipboardTextSerializer)===null||r===void 0?void 0:r.blockSeparator}),L7t,F7t,z7t,$7t,D7t,B7t].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 xhe({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 h7t(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 o7t(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 yhe({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 yhe({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 yhe({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 yhe({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:()=>vhe(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 oFt({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 H7t(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 G7t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var $Je={exports:{}},oye={};/** * @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 g8e;function W7t(){if(g8e)return oye;g8e=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 oye.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:p,oye}$Je.exports=W7t();var Lke=$Je.exports;const K7t=(...t)=>s=>{t.forEach(r=>{typeof r=="function"?r(s):r&&(r.current=s)})},Z7t=({contentComponent:t})=>{const s=Lke.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return xt.createElement(xt.Fragment,null,Object.values(s))};function Y7t(){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 X7t 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=Y7t(),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:K7t(r,this.editorContentRef),...n}),(s==null?void 0:s.contentComponent)&&xt.createElement(Z7t,{contentComponent:s.contentComponent}))}}const Q7t=S.forwardRef((t,s)=>{const r=xt.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return xt.createElement(X7t,{key:r,innerRef:s,...t})}),Dke=xt.memo(Q7t);var J7t=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},ezt=G7t(J7t),qJe={exports:{}},lye={};/** * @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 y8e;function tzt(){if(y8e)return lye;y8e=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 lye.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 k(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 k(p())},L===null?void 0:function(){return k(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},lye}qJe.exports=tzt();var szt=qJe.exports;const rzt=typeof window<"u"?S.useLayoutEffect:S.useEffect;class nzt{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 azt(t){var s;const[r]=S.useState(()=>new nzt(t.editor)),n=szt.useSyncExternalStoreWithSelector(r.subscribe,r.getSnapshot,r.getServerSnapshot,t.selector,(s=t.equalityFn)!==null&&s!==void 0?s:ezt);return rzt(()=>r.watch(t.editor),[t.editor,r]),S.useDebugValue(n),n}const izt=!1,E_e=typeof window>"u",ozt=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||ozt?null:this.createEditor();if(this.options.current.immediatelyRender&&E_e&&izt)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 V7t(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=S.useRef(t);r.current=t;const[n]=S.useState(()=>new Rke(r)),a=Lke.useSyncExternalStore(n.subscribe,n.getEditor,n.getServerSnapshot);return S.useDebugValue(a),S.useEffect(n.onRender(s)),azt({editor:a,selector:({transactionNumber:o})=>t.shouldRerenderOnTransaction===!1?null:t.immediatelyRender&&o===0?0:o+1}),a}const lzt=S.createContext({editor:null});lzt.Consumer;const czt=S.createContext({onDragStart:void 0}),dzt=()=>S.useContext(czt);xt.forwardRef((t,s)=>{const{onDragStart:r}=dzt(),n=t.as||"div";return xt.createElement(n,{...t,ref:s,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...t.style}})});const uzt=/^\s*>\s$/,hzt=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:uzt,type:this.type})]}}),mzt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,pzt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,fzt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,xzt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,gzt=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:mzt,type:this.type}),HT({find:fzt,type:this.type})]},addPasteRules(){return[rC({find:pzt,type:this.type}),rC({find:xzt,type:this.type})]}}),yzt="listItem",v8e="textStyle",_8e=/^\s*([-+*])\s$/,vzt=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(yzt,this.editor.getAttributes(v8e)).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:_8e,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=bD({find:_8e,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(v8e),editor:this.editor})),[t]}}),_zt=/(^|[^`])`([^`]+)`(?!`)/,bzt=/(^|[^`])`([^`]+)`(?!`)/g,wzt=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:_zt,type:this.type})]},addPasteRules(){return[rC({find:bzt,type:this.type})]}}),jzt=/^```([a-z]+)?[\s\n]$/,Nzt=/^~~~([a-z]+)?[\s\n]$/,kzt=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(ei.near(n.resolve(i))),!0)):t.commands.exitCode()}}},addInputRules(){return[T_e({find:jzt,type:this.type,getAttributes:t=>({language:t[1]})}),T_e({find:Nzt,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(Va.near(l.doc.resolve(Math.max(0,l.selection.from-2)))),l.setMeta("paste",!0),t.dispatch(l),!0}}})]}}),Szt=Hh.create({name:"doc",topNode:!0,content:"block+"});function Czt(t={}){return new vu({view(s){return new Mzt(s,t)}})}class Mzt{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 Tzt=xh.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Czt(this.options)]}});class Qc extends ei{constructor(s){super(s,s)}map(s,r){let n=s.resolve(r.map(this.head));return Qc.valid(n)?new Qc(n):ei.near(n)}content(){return bn.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||!Azt(s)||!Ezt(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;ei.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):ei.near(r)}}function UJe(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function Azt(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 Ezt(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 Pzt(){return new vu({props:{decorations:Rzt,createSelectionBetween(t,s,r){return s.pos==r.pos&&Qc.valid(r)?new Qc(r):null},handleClick:Lzt,handleKeyDown:Izt,handleDOMEvents:{beforeinput:Dzt}}})}const Izt=kke({ArrowLeft:qz("horiz",-1),ArrowRight:qz("horiz",1),ArrowUp:qz("vert",-1),ArrowDown:qz("vert",1)});function qz(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 Va){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 Lzt(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 Dzt(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=Cr.empty;for(let l=n.length-1;l>=0;l--)a=Cr.from(n[l].createAndFill(null,a));let o=t.state.tr.replace(r.pos,r.pos,new bn(a,0,0));return o.setSelection(Va.near(o.doc.resolve(r.pos+1))),t.dispatch(o),!1}function Rzt(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 Ozt=xh.create({name:"gapCursor",addProseMirrorPlugins(){return[Pzt()]},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}}}),Fzt=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()}}}),zzt=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 Rle=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<=Rle)return new s(this.values.concat(a.flatten()))},s.prototype.leafPrepend=function(a){if(this.length+a.length<=Rle)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 Bzt=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 $zt=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;pUzt&&(i=qzt(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;y$zt&&(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 qzt(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 Uzt=20;function Vzt(t,s,r,n){let a=r.getMeta(AS),o;if(a)return a.historyState;r.getMeta(Wzt)&&(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,toe(s)),t.undone,b8e(r.mapping.maps),t.prevTime,t.prevComposition):new R_(t.done,t.undone.addTransform(r,void 0,n,toe(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||!Hzt(r,t.prevRanges)),u=l?cye(t.prevRanges,r.mapping):b8e(r.mapping.maps);return new R_(t.done.addTransform(r,d?s.selection.getBookmark():void 0,n,toe(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),cye(t.prevRanges,r.mapping),t.prevTime,t.prevComposition):new R_(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),cye(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}function Hzt(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 b8e(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 cye(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=Gzt(a,r,t);o&&n(s?o.scrollIntoView():o)}return!0}}const GJe=HJe(!1,!0),WJe=HJe(!0,!0),Zzt=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[Kzt(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()}}}),Yzt=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(!H7t(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}):m7t(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(Va.create(l.doc,u.pos+1)):u.nodeAfter.isBlock?l.setSelection(Fa.create(l.doc,u.pos)):l.setSelection(Va.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(Va.create(l.doc,p+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[BJe({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Xzt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Qzt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Jzt=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,e9t=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,t9t=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:Xzt,type:this.type}),HT({find:Jzt,type:this.type})]},addPasteRules(){return[rC({find:Qzt,type:this.type}),rC({find:e9t,type:this.type})]}}),s9t=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)}}}),r9t="listItem",j8e="textStyle",N8e=/^(\d+)\.\s$/,n9t=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(r9t,this.editor.getAttributes(j8e)).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:N8e,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:N8e,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:s=>({start:+s[1],...this.editor.getAttributes(j8e)}),joinPredicate:(s,r)=>r.childCount+r.attrs.start===+s[1],editor:this.editor})),[t]}}),a9t=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()}}}),i9t=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,o9t=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,l9t=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:i9t,type:this.type})]},addPasteRules(){return[rC({find:o9t,type:this.type})]}}),c9t=Hh.create({name:"text",group:"inline"}),zke=xh.create({name:"starterKit",addExtensions(){const t=[];return this.options.bold!==!1&&t.push(gzt.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(hzt.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(vzt.configure(this.options.bulletList)),this.options.code!==!1&&t.push(wzt.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(kzt.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(Szt.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(Tzt.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(Ozt.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(Fzt.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(zzt.configure(this.options.heading)),this.options.history!==!1&&t.push(Zzt.configure(this.options.history)),this.options.horizontalRule!==!1&&t.push(Yzt.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(t9t.configure(this.options.italic)),this.options.listItem!==!1&&t.push(s9t.configure(this.options.listItem)),this.options.orderedList!==!1&&t.push(n9t.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(a9t.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(l9t.configure(this.options.strike)),this.options.text!==!1&&t.push(c9t.configure(this.options.text)),t}}),d9t="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",u9t="ελ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",h9t="scheme",m9t="slashscheme",uye="whitespace";function p9t(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=p9t(n,r);a.indexOf(t)<0&&a.push(t)}}function f9t(t,s){const r={};for(const n in s)s[n].indexOf(t)>=0&&(r[n]=!0);return r}function np(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}np.groups={};np.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),k8e=(t,s,r,n,a)=>t.ts(s,r,n,a),Ur=(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",soe="SCHEME",F5="SLASH_SCHEME",Bke="NUM",z_e="WS",$ke="NL",m8="OPENBRACE",p8="CLOSEBRACE",Ole="OPENBRACKET",Fle="CLOSEBRACKET",zle="OPENPAREN",Ble="CLOSEPAREN",$le="OPENANGLEBRACKET",qle="CLOSEANGLEBRACKET",Ule="FULLWIDTHLEFTPAREN",Vle="FULLWIDTHRIGHTPAREN",Hle="LEFTCORNERBRACKET",Gle="RIGHTCORNERBRACKET",Wle="LEFTWHITECORNERBRACKET",Kle="RIGHTWHITECORNERBRACKET",Zle="FULLWIDTHLESSTHAN",Yle="FULLWIDTHGREATERTHAN",Xle="AMPERSAND",Qle="APOSTROPHE",Jle="ASTERISK",O_="AT",ece="BACKSLASH",tce="BACKTICK",sce="CARET",G_="COLON",qke="COMMA",rce="DOLLAR",Ay="DOT",nce="EQUALS",Uke="EXCLAMATION",Yf="HYPHEN",f8="PERCENT",ace="PIPE",ice="PLUS",oce="POUND",x8="QUERY",Vke="QUOTE",XJe="FULLWIDTHMIDDLEDOT",Hke="SEMI",Ey="SLASH",g8="TILDE",lce="UNDERSCORE",QJe="EMOJI",cce="SYM";var JJe=Object.freeze({__proto__:null,ALPHANUMERICAL:YJe,AMPERSAND:Xle,APOSTROPHE:Qle,ASCIINUMERICAL:ZJe,ASTERISK:Jle,AT:O_,BACKSLASH:ece,BACKTICK:tce,CARET:sce,CLOSEANGLEBRACKET:qle,CLOSEBRACE:p8,CLOSEBRACKET:Fle,CLOSEPAREN:Ble,COLON:G_,COMMA:qke,DOLLAR:rce,DOT:Ay,EMOJI:QJe,EQUALS:nce,EXCLAMATION:Uke,FULLWIDTHGREATERTHAN:Yle,FULLWIDTHLEFTPAREN:Ule,FULLWIDTHLESSTHAN:Zle,FULLWIDTHMIDDLEDOT:XJe,FULLWIDTHRIGHTPAREN:Vle,HYPHEN:Yf,LEFTCORNERBRACKET:Hle,LEFTWHITECORNERBRACKET:Wle,LOCALHOST:wD,NL:$ke,NUM:Bke,OPENANGLEBRACKET:$le,OPENBRACE:m8,OPENBRACKET:Ole,OPENPAREN:zle,PERCENT:f8,PIPE:ace,PLUS:ice,POUND:oce,QUERY:x8,QUOTE:Vke,RIGHTCORNERBRACKET:Gle,RIGHTWHITECORNERBRACKET:Kle,SCHEME:soe,SEMI:Hke,SLASH:Ey,SLASH_SCHEME:F5,SYM:cce,TILDE:g8,TLD:O_e,UNDERSCORE:lce,UTLD:F_e,UWORD:R_e,WORD:bv,WS:z_e});const fv=/[a-z]/,lI=new RegExp("\\p{L}","u"),hye=new RegExp("\\p{Emoji}","u"),xv=/\d/,mye=/\s/,S8e="\r",pye=` `,x9t="️",g9t="‍",fye="";let Uz=null,Vz=null;function y9t(t=[]){const s={};np.groups=s;const r=new np;Uz==null&&(Uz=C8e(d9t)),Vz==null&&(Vz=C8e(u9t)),Ur(r,"'",Qle),Ur(r,"{",m8),Ur(r,"}",p8),Ur(r,"[",Ole),Ur(r,"]",Fle),Ur(r,"(",zle),Ur(r,")",Ble),Ur(r,"<",$le),Ur(r,">",qle),Ur(r,"(",Ule),Ur(r,")",Vle),Ur(r,"「",Hle),Ur(r,"」",Gle),Ur(r,"『",Wle),Ur(r,"』",Kle),Ur(r,"<",Zle),Ur(r,">",Yle),Ur(r,"&",Xle),Ur(r,"*",Jle),Ur(r,"@",O_),Ur(r,"`",tce),Ur(r,"^",sce),Ur(r,":",G_),Ur(r,",",qke),Ur(r,"$",rce),Ur(r,".",Ay),Ur(r,"=",nce),Ur(r,"!",Uke),Ur(r,"-",Yf),Ur(r,"%",f8),Ur(r,"|",ace),Ur(r,"+",ice),Ur(r,"#",oce),Ur(r,"?",x8),Ur(r,'"',Vke),Ur(r,"/",Ey),Ur(r,";",Hke),Ur(r,"~",g8),Ur(r,"_",lce),Ur(r,"\\",ece),Ur(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=Ur(r,pye,$ke,{[uye]:!0}),u=Ur(r,S8e,z_e,{[uye]:!0}),p=Uc(r,mye,z_e,{[uye]:!0});Ur(r,fye,p),Ur(u,pye,d),Ur(u,fye,p),Uc(u,mye,p),Ur(p,S8e),Ur(p,pye),Uc(p,mye,p),Ur(p,fye,p);const f=Uc(r,hye,QJe,{[KJe]:!0});Ur(f,"#"),Uc(f,hye,f),Ur(f,x9t,f);const y=Ur(f,g9t);Ur(y,"#"),Uc(y,hye,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,k8e(r,w,w,C)}return k8e(r,"localhost",wD,{ascii:!0}),r.jd=new np(cce),{start:r,tokens:Object.assign({groups:s},JJe)}}function eet(t,s){const r=v9t(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 v9t(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:M8e,formatHref:M8e,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 bhe(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 T8e=bhe("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),A8e=bhe("text"),_9t=bhe("nl"),Hz=bhe("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 np(t);function b9t({groups:t}){const s=t.domain.concat([Xle,Jle,O_,ece,tce,sce,rce,nce,Yf,Bke,f8,ace,ice,oce,Ey,cce,g8,lce]),r=[Qle,G_,qke,Ay,Uke,f8,x8,Vke,Hke,$le,qle,m8,p8,Fle,Ole,zle,Ble,Ule,Vle,Hle,Gle,Wle,Kle,Zle,Yle],n=[Xle,Qle,Jle,ece,tce,sce,rce,nce,Yf,m8,p8,f8,ace,ice,oce,x8,Ey,cce,g8,lce],a=Uf(),o=Ur(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=Ur(l,O_);Ur(o,O_,u),Ur(i,O_,u),Ur(d,O_,u);const p=Ur(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=Ur(f,Ay);Li(y,t.domain,f);const _=Uf(T8e);Li(y,t.tld,_),Li(y,t.utld,_),Ur(u,wD,_);const b=Ur(f,Yf);Ur(b,Yf,b),Li(b,t.domain,f),Li(_,t.domain,f),Ur(_,Ay,y),Ur(_,Yf,b);const N=Ur(_,G_);Li(N,t.numeric,T8e);const w=Ur(l,Yf),k=Ur(l,Ay);Ur(w,Yf,w),Li(w,t.domain,l),Li(k,n,o),Li(k,t.domain,l);const C=Uf(Hz);Li(k,t.tld,C),Li(k,t.utld,C),Li(C,t.domain,l),Li(C,n,o),Ur(C,Ay,k),Ur(C,Yf,w),Ur(C,O_,u);const A=Ur(C,G_),I=Uf(Hz);Li(A,t.numeric,I);const L=Uf(Hz),O=Uf();Li(L,s,L),Li(L,r,O),Li(O,s,L),Li(O,r,O),Ur(C,Ey,L),Ur(I,Ey,L);const V=Ur(i,G_),q=Ur(d,G_),B=Ur(q,Ey),U=Ur(B,Ey);Li(i,t.domain,l),Ur(i,Ay,k),Ur(i,Yf,w),Li(d,t.domain,l),Ur(d,Ay,k),Ur(d,Yf,w),Li(V,t.domain,L),Ur(V,Ey,L),Ur(V,x8,L),Li(U,t.domain,L),Li(U,s,L),Ur(U,Ey,L);const te=[[m8,p8],[Ole,Fle],[zle,Ble],[$le,qle],[Ule,Vle],[Hle,Gle],[Wle,Kle],[Zle,Yle]];for(let Y=0;Y=0&&y++,a++,p++;if(y<0)a-=p,a0&&(o.push(xye(A8e,s,l)),l=[]),a-=y,p-=y;const _=f.t,b=r.slice(a-p,a);o.push(xye(_,s,b))}}return l.length>0&&o.push(xye(A8e,s,l)),o}function xye(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 j9t=typeof console<"u"&&console&&console.warn||(()=>{}),N9t="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Zl={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function k9t(){return np.groups={},Zl.scanner=null,Zl.parser=null,Zl.tokenQueue=[],Zl.pluginQueue=[],Zl.customSchemes=[],Zl.initialized=!1,Zl}function E8e(t,s=!1){if(Zl.initialized&&j9t(`linkifyjs: already initialized - will not register custom scheme "${t}" ${N9t}`),!/^[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`);Zl.customSchemes.push([t,s])}function S9t(){Zl.scanner=y9t(Zl.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=n7t(r.doc,[...s]);if(u7t(i).forEach(({newRange:u})=>{const p=i7t(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(!M9t.test(_))return;f=p[0],y=n.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&y){const _=y.split(C9t).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(k=>k.toObject(t.defaultProtocol));if(!A9t(w))return!1;w.filter(k=>k.isLink).map(k=>({...k,from:N+k.start+1,to:N+k.end+1})).filter(k=>n.schema.marks.code?!n.doc.rangeHasMark(k.from,k.to,n.schema.marks.code):!0).filter(k=>t.validate(k.value)).filter(k=>t.shouldAutoLink(k.value)).forEach(k=>{Pke(k.from,k.to,n.doc).some(C=>C.mark.type===t.type)||l.addMark(k.from,k.to,t.type.create({href:k.href}))})}}),!!l.steps.length)return l}})}function P9t(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 I9t(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(T9t,"").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"){E8e(t);return}E8e(t.scheme,t.optionalSlashes)})},onDestroy(){k9t()},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(E9t({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(P9t({type:this.type})),this.options.linkOnPaste&&t.push(I9t({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")}}}),L9t=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&&L9t(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}}}}),D9t=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,R9t=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:D9t,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:k-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 z9t(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 $9t(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 whe(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)||q9t(s.$head);if(r)return r;throw new RangeError(`No cell found around position ${s.head}`)}function q9t(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 U9t(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 Va.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 k=b.attrs;if(N>0&&(k=aC(k,0,N)),w>0&&(k=aC(k,k.colspan-w,w)),_.lefta.bottom){const k={...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 W9t({$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 K9t({$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 Z9t(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=zl.create(a,n.from);else if(l=="row"){const i=a.resolve(n.from+1);o=zl.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=zl.create(a,d+1,u)}}else n instanceof Va&&W9t(n)?o=Va.create(a,n.from):n instanceof Va&&K9t(n)&&(o=Va.create(a,n.$from.start(),n.$from.end()));return o&&(s||(s=t.tr)).setSelection(o),s}const Y9t=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=X9t(t,a,o,r))};return s?s.doc!=t.doc&&iet(s.doc,t.doc,0,n):t.doc.descendants(n),r}function X9t(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;V9t(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;sBt(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=P8e(u)?d+1:p;o.replaceWith(f+n.tableStart,p+n.tableStart,i)}o.setSelection(new zl(o.doc.resolve(d+n.tableStart))),s(o)}return!0}function L8e(t,s){const r=$h(t.schema);return lBt(({node:n})=>r[n.type.spec.tableRole])(t,s)}function lBt(t){return(s,r)=>{const n=s.selection;let a,o;if(n instanceof zl){if(n.$anchorCell.pos!=n.$headCell.pos)return!1;a=n.$anchorCell.nodeAfter,o=n.$anchorCell.pos}else{var l;if(a=$9t(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 dBt(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 uBt=ND("cell",{useDeprecatedLogic:!0});function hBt(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 Gz(t,s){const r=t.selection;if(!(r instanceof zl))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 bn(a,0,0))}),n.docChanged&&s(n)}return!0}function pBt(t){if(t.size===0)return null;let{content:s,openStart:r,openEnd:n}=t;for(;s.childCount==1&&(r>0&&n>0||s.child(0).type.spec.tableRole=="table");)r--,n--,s=s.child(0).content;const a=s.child(0),o=a.type.spec.tableRole,l=a.type.schema,i=[];if(o=="row")for(let d=0;d=0;l--){const{rowspan:i,colspan:d}=o.child(l).attrs;for(let u=a;u=s.length&&s.push(Cr.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(Cr.from(d))}r=o,s=a}return{width:t,height:s,rows:r}}function gBt(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,Cr.from(f)),_=[];for(let b=s.height;b{if(!a)return!1;const o=r.selection;if(o instanceof zl)return roe(r,n,ei.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 roe(r,n,ei.near(r.doc.resolve(o.head+s),s));{const i=r.doc.resolve(l),d=ret(i,t,s);let u;return d?u=ei.near(d,1):s<0?u=ei.near(r.doc.resolve(i.before(-1)),-1):u=ei.near(r.doc.resolve(i.after(-1)),1),roe(r,n,u)}}}function Kz(t,s){return(r,n,a)=>{if(!a)return!1;const o=r.selection;let l;if(o instanceof zl)l=o;else{const d=uet(a,t,s);if(d==null)return!1;l=new zl(r.doc.resolve(d))}const i=ret(l.$headCell,t,s);return i?roe(r,n,new zl(l.$anchorCell,i)):!1}}function vBt(t,s){const r=t.state.doc,n=nC(r.resolve(s));return n?(t.dispatch(t.state.tr.setSelection(new zl(n))),!0):!1}function _Bt(t,s,r){if(!Gg(t.state))return!1;let n=pBt(r);const a=t.state.selection;if(a instanceof zl){n||(n={width:1,height:1,rows:[Cr.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=xBt(n,i.right-i.left,i.bottom-i.top),z8e(t.state,t.dispatch,l,i,n),!0}else if(n){const o=whe(t.state),l=o.start(-1);return z8e(t.state,t.dispatch,l,Jc.get(o.node(-1)).findCell(o.pos-l),n),!0}else return!1}function bBt(t,s){var r;if(s.button!=0||s.ctrlKey||s.metaKey)return;const n=B8e(t,s.target);let a;if(s.shiftKey&&t.state.selection instanceof zl)o(t.state.selection.$anchorCell,s),s.preventDefault();else if(s.shiftKey&&n&&(a=nC(t.state.selection.$anchor))!=null&&((r=gye(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=gye(t,u);const f=W_.getState(t.state)==null;if(!p||!Qke(d,p))if(f)p=d;else return;const y=new zl(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(B8e(t,u.target)!=n&&(f=gye(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 Va))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 B8e(t,s){for(;s&&s!=t.dom;s=s.parentNode)if(s.nodeName=="TD"||s.nodeName=="TH")return s;return null}function gye(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 wBt=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 NBt(-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)=>{kBt(l,i,t,a)},mouseleave:l=>{SBt(l)},mousedown:(l,i)=>{CBt(l,i,s,r)}},decorations:l=>{const i=Jp.getState(l);if(i&&i.activeHandle>-1)return PBt(l,i.activeHandle)},nodeViews:{}}});return o}var NBt=class noe{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 noe(n.setHandle,!1);if(n&&n.setDragging!==void 0)return new noe(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 noe(a,r.dragging)}return r}};function kBt(t,s,r,n){if(!t.editable)return;const a=Jp.getState(t.state);if(a&&!a.dragging){const o=TBt(s.target);let l=-1;if(o){const{left:i,right:d}=o.getBoundingClientRect();s.clientX-i<=r?l=$8e(t,s,"left",r):d-s.clientX<=r&&(l=$8e(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 SBt(t){if(!t.editable)return;const s=Jp.getState(t.state);s&&s.activeHandle>-1&&!s.dragging&&het(t,-1)}function CBt(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=MBt(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&&(ABt(t,y.activeHandle,q8e(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 _=q8e(y.dragging,f,r);U8e(t,y.activeHandle,_,n)}}return U8e(t,l.activeHandle,d,n),o.addEventListener("mouseup",u),o.addEventListener("mousemove",p),s.preventDefault(),!0}function MBt(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 OBt(t,s,r,n,a){const o=RBt(t),l=[],i=[];for(let u=0;u{const{selection:s}=t.state;if(!FBt(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},zBt=Hh.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:LBt,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}=DBt(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=OBt(o.schema,t,s,r);if(a){const i=n.selection.from+1;n.replaceSelectionWith(l).scrollIntoView().setSelection(Va.near(n.doc.resolve(i)))}return!0},addColumnBefore:()=>({state:t,dispatch:s})=>Q9t(t,s),addColumnAfter:()=>({state:t,dispatch:s})=>J9t(t,s),deleteColumn:()=>({state:t,dispatch:s})=>tBt(t,s),addRowBefore:()=>({state:t,dispatch:s})=>rBt(t,s),addRowAfter:()=>({state:t,dispatch:s})=>nBt(t,s),deleteRow:()=>({state:t,dispatch:s})=>iBt(t,s),deleteTable:()=>({state:t,dispatch:s})=>mBt(t,s),mergeCells:()=>({state:t,dispatch:s})=>I8e(t,s),splitCell:()=>({state:t,dispatch:s})=>L8e(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})=>uBt(t,s),mergeOrSplit:()=>({state:t,dispatch:s})=>I8e(t,s)?!0:L8e(t,s),setCellAttribute:(t,s)=>({state:r,dispatch:n})=>cBt(t,s)(r,n),goToNextCell:()=>({state:t,dispatch:s})=>R8e(1)(t,s),goToPreviousCell:()=>({state:t,dispatch:s})=>R8e(-1)(t,s),fixTables:()=>({state:t,dispatch:s})=>(s&&oet(t),!0),setCellSelection:t=>({tr:s,dispatch:r})=>{if(r){const n=zl.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:Zz,"Mod-Backspace":Zz,Delete:Zz,"Mod-Delete":Zz}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[jBt({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],IBt({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const s={name:t.name,options:t.options,storage:t.storage};return{tableRole:Di(aa(t,"tableRole",s))}}}),BBt=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]}}),$Bt=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]}}),qBt=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]=S.useState(!1),[i,d]=S.useState(""),[u,p]=S.useState(!0),f=Oke({extensions:[zke,Zke.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),Yke.configure({types:["heading","paragraph"]}),Xke,R9t.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}),zBt.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}),BBt.extend({addAttributes(){var N;return{...(N=this.parent)==null?void 0:N.call(this),style:{default:null}}}}),$Bt.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}}}}),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}}}})],content:t,onUpdate:({editor:N})=>{s(N.getHTML())},editorProps:{attributes:{class:"outline-none","data-placeholder":r},handlePaste:(N,w)=>{var C;const k=(C=w.clipboardData)==null?void 0:C.items;if(!k)return!1;for(const A of Array.from(k))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}}});S.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(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleHeading({level:1}).run(),className:f.isActive("heading",{level:1})?"bg-muted":"",title:"Heading 1",children:e.jsx(SM,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleHeading({level:2}).run(),className:f.isActive("heading",{level:2})?"bg-muted":"",title:"Heading 2",children:e.jsx(CM,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleBold().run(),className:f.isActive("bold")?"bg-muted":"",title:"Bold",children:e.jsx(K4,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleItalic().run(),className:f.isActive("italic")?"bg-muted":"",title:"Italic",children:e.jsx(rS,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleBulletList().run(),className:f.isActive("bulletList")?"bg-muted":"",title:"Bullet List",children:e.jsx(Dh,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleOrderedList().run(),className:f.isActive("orderedList")?"bg-muted":"",title:"Numbered List",children:e.jsx(Xy,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().setTextAlign("left").run(),className:f.isActive({textAlign:"left"})?"bg-muted":"",title:"Align Left",children:e.jsx(H4,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().setTextAlign("center").run(),className:f.isActive({textAlign:"center"})?"bg-muted":"",title:"Align Center",children:e.jsx(V4,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().setTextAlign("right").run(),className:f.isActive({textAlign:"right"})?"bg-muted":"",title:"Align Right",children:e.jsx(G4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:y,className:f.isActive("link")?"bg-muted":"",title:"Add Link",children:e.jsx(go,{className:"h-4 w-4"})}),f.isActive("link")&&e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:b,title:"Remove Link",children:e.jsx(go,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().undo().run(),disabled:!f.can().undo(),title:"Undo",children:e.jsx(wS,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().redo().run(),disabled:!f.can().redo(),title:"Redo",children:e.jsx(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(hs,{className:"sm:max-w-md",children:[e.jsx(js,{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(Le,{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(Mr,{id:"link-new-tab",checked:u,onCheckedChange:p}),e.jsx(xe,{htmlFor:"link-new-tab",children:"Open in new tab"})]})]}),e.jsxs(_n,{children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{type:"button",onClick:_,children:i?"Apply Link":"Remove Link"})]})]})})]}):null}var UBt=Object.defineProperty,VBt=(t,s,r)=>s in t?UBt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,hc=(t,s,r)=>VBt(t,typeof s!="symbol"?s+"":s,r);const dce={x:0,y:0,width:0,height:0,unit:"px"},_5=(t,s,r)=>Math.min(Math.max(t,s),r),HBt=(...t)=>t.filter(s=>s&&typeof s=="string").join(" "),G8e=(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 GBt(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 WBt(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==="%"?{...dce,...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"?{...dce,...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}:{...dce,...t,unit:"px"}}function W8e(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 k=Math.max(u.height*s,p);(r==="sw"||r=="nw")&&(u.x-=k-u.width),u.width=k}}return u}function KBt(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 ZBt=0;const T_=class cg extends S.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",S.createRef()),hc(this,"mediaRef",S.createRef()),hc(this,"resizeObserver"),hc(this,"initChangeCalled",!1),hc(this,"instanceId",`rc-${ZBt++}`),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(),G8e(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=KBt(b,s.key,_,r),w=W8e(N,n,r,y.width,y.height,l,i,d,u);if(!G8e(a,w)){const k=F_(w,y.width,y.height);p(w,k),f&&f(w,k)}}),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=W8e(_,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={...dce,...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,_=HBt("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 YBt=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,XBt,QBt]=wR(tE),[xet,gAs]=qc(tE,[QBt]),[JBt,jhe]=xet(tE),get=S.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=S.useRef(new Set),k=S.useRef(0),A=l==="horizontal"?e$t:t$t,[I=[],L]=Uu({prop:p,defaultProp:u,onChange:te=>{var J;(J=[...w.current][k.current])==null||J.focus(),f(te)}}),O=S.useRef(I);function V(te){const Y=i$t(I,te);U(te,Y)}function q(te){U(te,k.current)}function B(){const te=O.current[k.current];I[k.current]!==te&&y(I)}function U(te,Y,{commit:J}={commit:!1}){const X=d$t(o),ce=u$t(Math.round((te-n)/o)*o+n,X),ae=nD(ce,[n,a]);L((ie=[])=>{const oe=n$t(ie,ae,Y);if(c$t(oe,d*o)){k.current=oe.indexOf(ae);const me=String(oe)!==String(ie);return me&&J&&y(oe),me?oe:ie}else return ie})}return e.jsx(JBt,{scope:t.__scopeSlider,name:r,disabled:i,min:n,max:a,valueIndexToChangeRef:k,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:Sr(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,ae=k.current,ie=I[ae],oe=o*ce*Y;U(ie+oe,ae,{commit:!0})}}})})})})});get.displayName=tE;var[yet,vet]=xet(tE,{startEdge:"left",endEdge:"right",size:"width",direction:1}),e$t=S.forwardRef((t,s)=>{const{min:r,max:n,dir:a,inverted:o,onSlideStart:l,onSlideMove:i,onSlideEnd:d,onStepKeyDown:u,...p}=t,[f,y]=S.useState(null),_=Ta(s,A=>y(A)),b=S.useRef(void 0),N=mw(a),w=N==="ltr",k=w&&!o||!w&&o;function C(A){const I=b.current||f.getBoundingClientRect(),L=[0,I.width],V=Jke(L,k?[r,n]:[n,r]);return b.current=I,V(A-I.left)}return e.jsx(yet,{scope:t.__scopeSlider,startEdge:k?"left":"right",endEdge:k?"right":"left",direction:k?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[k?"from-left":"from-right"].includes(A.key);u==null||u({event:A,direction:L?-1:1})}})})}),t$t=S.forwardRef((t,s)=>{const{min:r,max:n,inverted:a,onSlideStart:o,onSlideMove:l,onSlideEnd:i,onStepKeyDown:d,...u}=t,p=S.useRef(null),f=Ta(s,p),y=S.useRef(void 0),_=!a;function b(N){const w=y.current||p.current.getBoundingClientRect(),k=[0,w.height],A=Jke(k,_?[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 k=fet[_?"from-bottom":"from-top"].includes(N.key);d==null||d({event:N,direction:k?-1:1})}})})}),_et=S.forwardRef((t,s)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:a,onSlideEnd:o,onHomeKeyDown:l,onEndKeyDown:i,onStepKeyDown:d,...u}=t,p=jhe(tE,r);return e.jsx(Jr.span,{...u,ref:s,onKeyDown:Sr(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:Sr(t.onPointerDown,f=>{const y=f.target;y.setPointerCapture(f.pointerId),f.preventDefault(),p.thumbs.has(y)?y.focus():n(f)}),onPointerMove:Sr(t.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&a(f)}),onPointerUp:Sr(t.onPointerUp,f=>{const y=f.target;y.hasPointerCapture(f.pointerId)&&(y.releasePointerCapture(f.pointerId),o(f))})})}),bet="SliderTrack",wet=S.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=jhe(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=S.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=jhe(W_e,r),o=vet(W_e,r),l=S.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=S.forwardRef((t,s)=>{const r=XBt(t.__scopeSlider),[n,a]=S.useState(null),o=Ta(s,i=>a(i)),l=S.useMemo(()=>n?r().findIndex(i=>i.ref.current===n):-1,[r,n]);return e.jsx(s$t,{...t,ref:o,index:l})}),s$t=S.forwardRef((t,s)=>{const{__scopeSlider:r,index:n,name:a,...o}=t,l=jhe(K_e,r),i=vet(K_e,r),[d,u]=S.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=a$t(n,l.values.length),w=y==null?void 0:y[i.size],k=w?o$t(w,b,i.direction):0;return S.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}% + ${k}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:Sr(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 r$t="RadioBubbleInput",ket=S.forwardRef(({__scopeSlider:t,value:s,...r},n)=>{const a=S.useRef(null),o=Ta(a,n),l=zR(s);return S.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=r$t;function n$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 a$t(t,s){return s>2?`Value ${t+1} of ${s}`:s===2?["Minimum","Maximum"][t]:void 0}function i$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 o$t(t,s,r){const n=t/2,o=Jke([0,50],[0,n]);return(n-o(s)*r)*r}function l$t(t){return t.slice(0,-1).map((s,r)=>t[r+1]-s)}function c$t(t,s){if(s>0){const r=l$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 d$t(t){return(String(t).split(".")[1]||"").length}function u$t(t,s){const r=Math.pow(10,s);return Math.round(t*r)/r}var Met=get,h$t=wet,m$t=jet,p$t=Net;const Cg=S.forwardRef(({className:t,...s},r)=>e.jsxs(Met,{ref:r,className:Dt("relative flex w-full touch-none select-none items-center",t),...s,children:[e.jsx(h$t,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(m$t,{className:"absolute h-full bg-primary"})}),e.jsx(p$t,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));Cg.displayName=Met.displayName;function f$t(t,s,r){return WBt(GBt({unit:"%",width:90},r,t,s),t,s)}const e4e=({open:t,onClose:s,imageSrc:r,onCropComplete:n,aspectRatio:a=1})=>{const o=S.useRef(null),[l,i]=S.useState(),[d,u]=S.useState(),[p,f]=S.useState(1),[y,_]=S.useState(0),b=S.useCallback(k=>{const{width:C,height:A}=k.currentTarget;i(f$t(C,A,a))},[a]),N=S.useCallback(async()=>{const k=o.current;if(!k||!d)return;const C=document.createElement("canvas"),A=C.getContext("2d");if(!A)return;const I=k.naturalWidth/k.width,L=k.naturalHeight/k.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(k,V,q,B,U,0,0,O,O),A.restore(),new Promise((X,ce)=>{C.toBlob(ae=>{ae?X(ae):ce(new Error("Canvas is empty"))},"image/jpeg",.95)})},[d,p,y]),w=async()=>{try{const k=await N();k&&(n(k),s())}catch(k){console.error("Error cropping image:",k)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(hs,{className:"max-w-lg",children:[e.jsx(js,{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(YBt,{crop:l,onChange:(k,C)=>i(C),onComplete:k=>u(k),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:([k])=>f(k),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:([k])=>_(k),className:"flex-1"}),e.jsxs("span",{className:"text-sm text-muted-foreground w-12",children:[y,"°"]})]})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:s,children:"Cancel"}),e.jsx(K,{onClick:w,children:"Save Photo"})]})]})})},x$t=()=>{const{user:t}=qs(),{toast:s}=ja(),[r,n]=S.useState(!1),[a,o]=S.useState(!1),[l,i]=S.useState(null);S.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(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(yx,{className:"h-5 w-5"}),"Subscription"]})}),e.jsx(Re,{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(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(yx,{className:"h-5 w-5"}),"Subscription"]}),e.jsx(ur,{children:"Manage your subscription and billing"})]}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Status"}),e.jsx("div",{className:"mt-1",children:p()})]}),(l==null?void 0:l.endDate)&&l.status==="active"&&e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Next billing date"}),e.jsx("p",{className:"font-medium",children:new Date(l.endDate).toLocaleDateString()})]})]}),l!=null&&l.isGrandfathered?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your account was upgraded from LevelUp 1.0. To update/manage your subscription please reach out to support."}):(l==null?void 0:l.status)==="active"||(l==null?void 0:l.status)==="trialing"?e.jsxs(e.Fragment,{children:[(l==null?void 0:l.status)==="trialing"&&(l==null?void 0:l.endDate)&&e.jsxs("p",{className:"text-sm text-muted-foreground mb-3",children:["Your trial ends on ",new Date(l.endDate).toLocaleDateString(),". After the trial, you'll be charged automatically."]}),e.jsxs(K,{onClick:u,variant:"outline",disabled:a,children:[a?e.jsx(us,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Zr,{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."})]})]})},g$t=()=>{const{user:t}=qs(),s=vr(),{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]=S.useState(!1),[_,b]=S.useState(""),[N,w]=S.useState(!1),[k,C]=S.useState(!1),[A,I]=S.useState(""),[L,O]=S.useState({name:"",email:"",phone:"",title:"",bio:"",areas_served:"",years_experience:"",instagram_url:"",facebook_url:"",linkedin_url:"",email_signature:"",use_email_signature:!1}),[V,q]=S.useState(!1),[B,U]=S.useState(!1),[te,Y]=S.useState({newPassword:"",confirmPassword:""});S.useEffect(()=>{t&&J()},[t]),S.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,ye;if(!(t!=null&&t.id)){console.log("No user ID available yet");return}try{console.log("Loading profile for user:",t.id);const{data: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)||((ye=t.email)==null?void 0:ye.split("@")[0])||"",email:t.email||"",phone:"",title:"",bio:"",areas_served:"",years_experience:"",instagram_url:"",facebook_url:"",linkedin_url:"",email_signature:"",use_email_signature:!1}));const{data:Ne}=await G.storage.from("avatars").list(`${t.id}`);if(Ne&&Ne.length>0){const{data:Ue}=G.storage.from("avatars").getPublicUrl(`${t.id}/${Ne[0].name}`);b(Ue.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 ye=new FileReader;ye.onloadend=()=>{I(ye.result),C(!0)},ye.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(Te=>`${t.id}/${Te.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:Ne}=G.storage.from("avatars").getPublicUrl(he),Ue=Ne.publicUrl;b(`${Ue}?t=${Date.now()}`),await G.from("profiles").update({avatar_url:Ue}).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)}}},ae=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)}},ie=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(Es,{title:a?"Complete Your Profile":o?"Reset Your Password":"Profile Settings",description:a?"Welcome! Please complete your profile setup":o?"Please set a new password for your account":"Manage your account information and password",children:e.jsxs("div",{className:"mx-auto max-w-4xl",children:[!a&&!o&&e.jsx("div",{className:"mb-6",children:e.jsxs(K,{variant:"outline",onClick:()=>{var 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(Lt,{children:[e.jsx(Ft,{children:"Profile Photo"}),e.jsx(ur,{children:"Upload a professional photo for your profile"})]}),e.jsxs(Re,{className:"flex items-center gap-6",children:[e.jsxs(wn,{className:"h-24 w-24",children:[e.jsx(Ma,{src:_}),e.jsx(jn,{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(K,{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(Lt,{children:[e.jsx(Ft,{children:"Personal Information"}),e.jsx(ur,{children:"Update your profile details"})]}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"name",children:"Name"}),e.jsx(Le,{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(Le,{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(Le,{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(Le,{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(gr,{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(Le,{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(Le,{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(Le,{value:L.linkedin_url,onChange:oe=>O({...L,linkedin_url:oe.target.value}),placeholder:"LinkedIn URL"}),e.jsx(Le,{value:L.instagram_url,onChange:oe=>O({...L,instagram_url:oe.target.value}),placeholder:"Instagram URL"}),e.jsx(Le,{value:L.facebook_url,onChange:oe=>O({...L,facebook_url:oe.target.value}),placeholder:"Facebook URL"})]})]}),e.jsxs(K,{onClick:ae,disabled:f,children:[e.jsx(bc,{className:"mr-2 h-4 w-4"}),"Save Changes"]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Ev,{className:"h-5 w-5"}),"Email Signature"]}),e.jsx(ur,{children:"Add a signature that will be appended to emails sent via Gmail"})]}),e.jsxs(Re,{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(Mr,{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(K,{onClick:ae,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(Lt,{children:[e.jsx(Ft,{children:a?"Set Your Password":"Change Password"}),e.jsx(ur,{children:a?"Create a secure password for your account":"Update your password to keep your account secure"})]}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"newPassword",children:"New Password"}),e.jsx(Le,{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(Le,{id:"confirmPassword",type:"password",value:te.confirmPassword,onChange:oe=>Y({...te,confirmPassword:oe.target.value}),placeholder:"Re-enter your new password"})]}),e.jsxs(K,{onClick:ie,disabled:f,children:[e.jsx(bc,{className:"mr-2 h-4 w-4"}),a?"Complete Setup":"Update Password"]}),a&&e.jsx(K,{variant:"outline",onClick:()=>s("/dashboard"),className:"ml-2",children:"Skip for Now"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{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(ur,{children:"Receive browser notifications when new content is added"})]}),e.jsx(Re,{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(Mr,{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(Lt,{children:[e.jsxs(Ft,{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(ur,{children:"Manage your email subscription settings"})]}),e.jsx(Re,{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(Mr,{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($8t,{}),e.jsx(x$t,{})]}),e.jsx(e4e,{open:k,onClose:()=>C(!1),imageSrc:A,onCropComplete:ce,aspectRatio:1})]})})};var y$t="AspectRatio",Tet=S.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=y$t;var v$t=Tet;const _$t=v$t;function b$t(){const{user:t}=qs(),s=Qt(),[r,n]=S.useState(!1),[a,o]=S.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=Et({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(hi,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"gap-2",children:[e.jsx(ln,{className:"h-4 w-4"}),"Subscribe to Calendar"]})}),e.jsxs(hs,{className:"sm:max-w-md",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(ln,{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(Le,{value:u,readOnly:!0,className:"text-xs font-mono"}),e.jsx(K,{variant:"outline",size:"icon",onClick:p,children:r?e.jsx(Zn,{className:"h-4 w-4 text-green-500"}):e.jsx(Wa,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Quick Add"}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-2",onClick:f,children:[e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M18.71 19.5c-.83 1.24-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.81-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M13 3.5c.73-.83 1.94-1.46 2.94-1.5.13 1.17-.34 2.35-1.04 3.19-.69.85-1.83 1.51-2.95 1.42-.15-1.15.41-2.35 1.05-3.11z"})}),"Add to Apple Calendar",e.jsx(Zr,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsxs(K,{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(Zr,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsxs(K,{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(Zr,{className:"h-3 w-3 ml-auto opacity-50"})]})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center pt-2",children:"Events sync automatically. If your membership expires, the calendar will show as empty."})]}):e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generate your personal calendar subscription URL to get started."}),e.jsx(K,{onClick:()=>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(ln,{className:"h-4 w-4 mr-2"}),"Generate Calendar URL"]})})]})})]})]})}const w$t={first_timer:Gn,regular:Qv,dedicated:rc,veteran:Vi,streak_master:rd,century:Vi},j$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 K8e(t){return t===1?e.jsx(Vi,{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(rc,{className:"h-5 w-5 text-amber-600"}):e.jsx("span",{className:"w-5 text-center text-sm font-medium text-muted-foreground",children:t})}function Aet({showUserStats:t=!0,compact:s=!1,brokerageId:r,title:n="Event Leaderboard"}){const{user:a}=qs(),{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(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Vi,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsx(Re,{children:e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((p,f)=>e.jsx(ks,{className:"h-12 w-full"},f))})})]}):e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Vi,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsxs(Re,{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=w$t[p.badge_type]||Gn;return e.jsxs(Qe,{variant:"outline",className:`text-xs ${j$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(ls,{value:"points",className:"flex-1",children:"By Points"}),e.jsx(ls,{value:"events",className:"flex-1",children:"By Events"})]}),e.jsx(ws,{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:K8e(f+1)}),e.jsx(wn,{className:"h-8 w-8",children:e.jsx(jn,{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(ws,{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:K8e(f+1)}),e.jsx(wn,{className:"h-8 w-8",children:e.jsx(jn,{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 N$t(){const t=vr(),{user:s,isAdmin:r}=qs(),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 k=1e3;for(;;){const{data:A,error:I}=await G.from("event_registrations").select("event_id").range(w,w+k-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=Et({mutationFn:async N=>{await G.auth.refreshSession();const{data:w,error:k}=await G.functions.invoke("zoom-register",{body:{event_id:N}});if(k)throw k;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=Et({mutationFn:async N=>{const{data:w,error:k}=await G.functions.invoke("zoom-unregister",{body:{event_id:N}});if(k)throw k;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(k=>k.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(Es,{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(b$t,{}),r&&e.jsx(K,{variant:"outline",onClick:()=>t("/admin/events"),children:"Manage Events"})]})]}),e.jsxs("div",{className:`grid grid-cols-1 ${r?"lg:grid-cols-3":""} gap-6`,children:[e.jsxs("div",{className:r?"lg:col-span-2":"",children:[o?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading events..."}):_.length===0?e.jsx(Pe,{className:"text-center py-12",children:e.jsx(Re,{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),k=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:[k&&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(on,{className:"h-3.5 w-3.5"}),"STARTING SOON"]})]}),N.image_url&&e.jsx(_$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(Lt,{children:[e.jsx(Ft,{className:"line-clamp-2",children:N.title}),N.description&&e.jsx(ur,{className:"line-clamp-2",children:N.description.replace(/<[^>]*>/g,"")})]}),e.jsxs(Re,{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ln,{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(on,{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(or,{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(K,{variant:"outline",className:"flex-1",onClick:()=>u.mutate(N.id),disabled:u.isPending,children:[e.jsx(jr,{className:"h-4 w-4 mr-2"}),"Cancel"]}),e.jsxs(K,{className:"flex-1",onClick:()=>window.open(f(N.id)||N.zoom_link,"_blank"),children:[e.jsx(Zr,{className:"h-4 w-4 mr-2"}),"Join Zoom"]})]}):e.jsx(K,{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(Lt,{children:[e.jsx(Ft,{className:"text-base line-clamp-1",children:N.title}),e.jsx(ur,{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 yye=[{value:"all",label:"All Roles",icon:or},{value:"newest",label:"Newest Members",icon:on},{value:"brokerage_manager",label:"Brokerage Managers",icon:HL},{value:"admin",label:"Admins",icon:zu}];function k$t({open:t,onOpenChange:s,resourceType:r,resourceId:n,resourceTitle:a}){var $e,Be;const{user:o,isAdmin:l,isBrokerageManager:i}=qs(),[d,u]=S.useState([]),[p,f]=S.useState([]),[y,_]=S.useState([]),[b,N]=S.useState([]),[w,k]=S.useState(""),[C,A]=S.useState(""),[I,L]=S.useState(""),[O,V]=S.useState(!1),[q,B]=S.useState(!1),[U,te]=S.useState("agents"),[Y,J]=S.useState("all"),[X,ce]=S.useState({}),ae=l||i;S.useEffect(()=>{t&&o&&(l?ie():oe())},[t,o,l]),S.useEffect(()=>{t||(_([]),N([]),k(""),A(""),L(""),te("agents"),J("all"))},[t]);const ie=async()=>{if(o){V(!0);try{const{data:we,error:ut}=await G.from("brokerages").select("id, name").order("name");if(ut)throw ut;const fe=1e3,He={};let et=0,tt=!0;for(;tt;){const{data:We,error:it}=await G.from("profiles").select("brokerage_id").range(et*fe,(et+1)*fe-1);if(it)throw it;We==null||We.forEach(Ve=>{Ve.brokerage_id&&(He[Ve.brokerage_id]=(He[Ve.brokerage_id]||0)+1)}),tt=(We==null?void 0:We.length)===fe,et++}f((we==null?void 0:we.map(We=>({...We,agent_count:He[We.id]||0})))||[]);const _e=[];for(et=0,tt=!0;tt;){const{data:We,error:it}=await G.from("profiles").select("id, name, email, brokerage_id, created_at, brokerages(name)").neq("id",o.id).order("name").range(et*fe,(et+1)*fe-1);if(it)throw it;We&&_e.push(...We),tt=(We==null?void 0:We.length)===fe,et++}const Ge={};for(et=0,tt=!0;tt;){const{data:We,error:it}=await G.from("user_roles").select("user_id, role").range(et*fe,(et+1)*fe-1);if(it)throw it;We==null||We.forEach(Ve=>{Ge[Ve.user_id]||(Ge[Ve.user_id]=[]),Ge[Ve.user_id].push(Ve.role)}),tt=(We==null?void 0:We.length)===fe,et++}ce(Ge),u(_e.map(We=>{var it;return{id:We.id,name:We.name,email:We.email,brokerage_name:((it=We.brokerages)==null?void 0:it.name)||"No Brokerage",roles:Ge[We.id]||[],created_at:We.created_at}}))}catch(we){console.error("Error loading data:",we),pe.error("Failed to load agents and brokerages")}finally{V(!1)}}},oe=async()=>{if(o){V(!0);try{const{data:we}=await G.from("profiles").select("brokerage_id").eq("id",o.id).single();if(!(we!=null&&we.brokerage_id)){pe.error("You must be part of a brokerage to share resources"),s(!1);return}const{data:ut,error:fe}=await G.from("profiles").select("id, name, email").eq("brokerage_id",we.brokerage_id).neq("id",o.id).order("name");if(fe)throw fe;u(ut||[])}catch(we){console.error("Error loading agents:",we),pe.error("Failed to load agents")}finally{V(!1)}}},me=d.filter(we=>{var fe;const ut=we.name.toLowerCase().includes(w.toLowerCase())||we.email.toLowerCase().includes(w.toLowerCase())||((fe=we.brokerage_name)==null?void 0:fe.toLowerCase().includes(w.toLowerCase()));if(l&&Y!=="all"&&Y!=="newest"){const He=X[we.id]||[];return ut&&He.includes(Y)}return ut}).sort((we,ut)=>Y==="newest"?(ut.created_at||"").localeCompare(we.created_at||""):0),ye=p.filter(we=>we.name.toLowerCase().includes(C.toLowerCase())),he=()=>{y.length===me.length?_([]):_(me.map(we=>we.id))},ge=()=>{b.length===ye.length?N([]):N(ye.map(we=>we.id))},Ne=we=>{if(!ae){_([we]);return}_(ut=>ut.includes(we)?ut.filter(fe=>fe!==we):[...ut,we])},Ue=we=>{N(ut=>ut.includes(we)?ut.filter(fe=>fe!==we):[...ut,we])},Te=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:ut,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 He=(ut==null?void 0:ut.sharesCreated)||y.length;pe.success(`Shared with ${He} agent${He!==1?"s":""}`),s(!1)}catch(ut){console.error("Error sharing resource:",ut),pe.error("Failed to share resource")}finally{B(!1)}},Me=we=>we.split(" ").map(ut=>ut[0]).join("").toUpperCase().slice(0,2),De=we=>{const ut=X[we]||[];return ut.includes("admin")?e.jsx(Qe,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"Admin"}):ut.includes("brokerage_manager")?e.jsx(Qe,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"Manager"}):null},qe=y.length+b.length,ke=Y!=="all"&&Y!=="newest"?me.length:null;return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(hs,{className:"sm:max-w-lg max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsxs(js,{className:"flex-shrink-0",children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(Mn,{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(ls,{value:"agents",className:"flex items-center gap-2",children:[e.jsx(or,{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(ls,{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(ws,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name, email, or brokerage...",value:w,onChange:we=>k(we.target.value),className:"pl-9"})]}),e.jsxs(Fs,{value:Y,onValueChange:J,children:[e.jsxs(Ds,{className:"w-[180px]",children:[e.jsx(Eg,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(zs,{placeholder:"Filter by role"})]}),e.jsx(Rs,{children:yye.map(we=>e.jsx(vt,{value:we.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we.icon,{className:"h-4 w-4"}),e.jsx("span",{children:we.label})]})},we.value))})]})]}),e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:he,className:"text-xs h-8",disabled:me.length===0,children:[e.jsx(or,{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:[ke!==null&&e.jsxs("span",{className:"text-primary font-medium",children:[ke," ",($e=yye.find(we=>we.value===Y))==null?void 0:$e.label]}),e.jsxs("span",{className:"font-medium",children:[y.length," selected"]})]})]}),e.jsx(ni,{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(or,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:Y!=="all"?`No ${(Be=yye.find(we=>we.value===Y))==null?void 0:Be.label.toLowerCase()} found`:"No agents found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:me.map(we=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${y.includes(we.id)?"bg-accent":""}`,onClick:()=>Ne(we.id),children:[e.jsx(Hi,{checked:y.includes(we.id),onCheckedChange:()=>Ne(we.id),className:"flex-shrink-0"}),e.jsx(wn,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(jn,{className:"text-xs bg-primary/10 text-primary",children:Me(we.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:we.name}),De(we.id)]}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[we.email,we.brokerage_name&&e.jsxs("span",{className:"ml-1 opacity-75",children:["• ",we.brokerage_name]})]})]})]},we.id))})})]}),e.jsxs(ws,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search brokerages...",value:C,onChange:we=>A(we.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:ge,className:"text-xs h-8",disabled:ye.length===0,children:[e.jsx(pa,{className:"h-3.5 w-3.5 mr-1.5"}),b.length===ye.length&&ye.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(ni,{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"})}):ye.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:ye.map(we=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${b.includes(we.id)?"bg-accent":""}`,onClick:()=>Ue(we.id),children:[e.jsx(Hi,{checked:b.includes(we.id),onCheckedChange:()=>Ue(we.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:we.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[we.agent_count," agent",we.agent_count!==1?"s":""]})]})]},we.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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search agents...",value:w,onChange:we=>k(we.target.value),className:"pl-9"})]}),ae&&e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:he,className:"text-xs h-8",disabled:me.length===0,children:[e.jsx(or,{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(ni,{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(or,{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(we=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${y.includes(we.id)?"bg-accent":""}`,onClick:()=>Ne(we.id),children:[e.jsx(Hi,{checked:y.includes(we.id),onCheckedChange:()=>Ne(we.id),className:"flex-shrink-0"}),e.jsx(wn,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(jn,{className:"text-xs bg-primary/10 text-primary",children:Me(we.name)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:we.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:we.email})]})]},we.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(gr,{id:"message",placeholder:"I thought you might find this useful...",value:I,onChange:we=>L(we.target.value),rows:2,className:"resize-none"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2 flex-shrink-0",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:Te,disabled:qe===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(Mn,{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]=S.useState(!1),{user:d}=qs();return d?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:n,size:a,onClick:()=>i(!0),className:o,children:[e.jsx(_d,{className:"h-4 w-4 mr-2"}),"Share"]}),e.jsx(k$t,{open:l,onOpenChange:i,resourceType:t,resourceId:s,resourceTitle:r})]}):null}function S$t(){const{eventId:t}=ao(),s=vr(),{user:r}=qs(),[n,a]=S.useState(null),[o,l]=S.useState(null),[i,d]=S.useState(0),[u,p]=S.useState(!0),[f,y]=S.useState(!1);S.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(Es,{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(Es,{title:"Event Not Found",children:e.jsxs("div",{className:"text-center py-16",children:[e.jsx("p",{className:"text-muted-foreground",children:"Event not found"}),e.jsx(K,{onClick:()=>s("/events"),className:"mt-4",children:"Back to Events"})]})});const w=a0(new Date(n.event_date)),k=n.capacity&&i>=n.capacity,C=(o==null?void 0:o.zoom_join_url)||n.zoom_link;return e.jsx(Es,{title:n.title,children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs(K,{variant:"ghost",className:"mb-6 gap-2",onClick:()=>s("/events"),children:[e.jsx(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(sp,{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(Re,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ln,{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(or,{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(ti,{className:"h-5 w-5 text-green-600"}),e.jsx("span",{className:"text-sm font-medium text-green-700",children:"You're registered!"})]}),e.jsxs("div",{className:"space-y-2 pt-2",children:[!w&&e.jsx(e.Fragment,{children:o?e.jsxs(e.Fragment,{children:[e.jsxs(K,{className:"w-full gap-2",onClick:()=>window.open(C,"_blank"),children:[e.jsx(Zr,{className:"h-4 w-4"}),"Join Event"]}),e.jsxs(K,{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(K,{className:"w-full gap-2",onClick:b,disabled:f||(k??!1),children:f?e.jsx(us,{className:"h-4 w-4 animate-spin"}):k?"Event Full":"Register Now"})}),w&&o&&e.jsxs(K,{variant:"outline",className:"w-full gap-2",onClick:()=>window.open(n.zoom_link,"_blank"),children:[e.jsx(Zr,{className:"h-4 w-4"}),"View Recording"]})]})]})})})]})]})})}const C$t=[{id:"quickvid",name:"QuickVid",description:"Record, manage, and share personalized video messages",icon:e.jsx(gn,{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(yn,{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(Mn,{className:"h-6 w-6"}),path:"/admin/email-campaigns",category:"Marketing",beta:!0,color:"bg-teal-500/15 text-teal-600"}],M$t=()=>{const{user:t,isAdmin:s}=qs(),r=vr(),[n,a]=S.useState([]),[o,l]=S.useState(!0),[i,d]=S.useState(""),[u,p]=S.useState("all"),[f,y]=S.useState(new Set),[_,b]=S.useState(new Set);S.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 ae=new Set((X||[]).map(me=>me.tool_id));b(ae);const oe=((te==null?void 0:te.filter(me=>!me.required_tags||me.required_tags.length===0?!0:me.required_tags.some(ye=>U.includes(ye))))||[]).sort((me,ye)=>me.name==="LevelUp Members Portal"?-1:ye.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:ae}=await G.functions.invoke("sso-launch",{body:{app_id:B.app_id},headers:{Authorization:`Bearer ${X}`}});if(ae)throw ae;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.")}},k=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=C$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(Es,{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(Es,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search apps & tools...",className:"pl-10 bg-muted/50 border-0 focus-visible:ring-1",value:i,onChange: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:Dt("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:Dt("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:Dt("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:Dt("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:Dt("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(Zr,{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(vd,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-lg font-medium mb-2 text-foreground",children:"No apps available"}),e.jsx("p",{className:"text-sm text-muted-foreground text-center max-w-md",children:s?"Get started by adding apps in the admin panel":"Contact your administrator to get access to apps"}),s&&e.jsx(K,{className:"mt-4",onClick:()=>r("/admin/apps"),children:"Add Apps"})]})}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children: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:Dt("flex-shrink-0 p-1 transition-colors",U?"text-primary":"text-muted-foreground/50 hover:text-primary"),onClick:Y=>k(Y,B.id),children:e.jsx(fx,{className:Dt("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(an,{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"})]})]})},T$t=()=>{const t=vr(),[s,r]=S.useState(""),[n,a]=S.useState("all"),[o,l]=S.useState("all"),[i,d]=S.useState("grid"),{data:u=[]}=gt({queryKey:["template-categories"],queryFn:async()=>{const{data:k,error:C}=await G.from("template_categories").select("*").order("name");if(C)throw C;return k}}),{data:p=[]}=gt({queryKey:["template-types"],queryFn:async()=>{const{data:k,error:C}=await G.from("template_types").select("*").order("name");if(C)throw C;return k}}),{data:f=[],isLoading:y}=gt({queryKey:["canva-templates"],queryFn:async()=>{const{data:k,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)}),(k||[]).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(k=>{var L;const C=k.name.toLowerCase().includes(s.toLowerCase())||((L=k.description)==null?void 0:L.toLowerCase().includes(s.toLowerCase())),A=n==="all"||k.category_id===n,I=o==="all"||k.type_id===o;return C&&A&&I}),b=()=>{r(""),a("all"),l("all")},N=s||n!=="all"||o!=="all",w=k=>{t(`/templates/${k}`)};return e.jsx(Es,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search templates...",value:s,onChange:k=>r(k.target.value),className:"pl-9"})]}),e.jsxs(Fs,{value:n,onValueChange:a,children:[e.jsx(Ds,{className:"w-full sm:w-48",children:e.jsx(zs,{placeholder:"All Categories"})}),e.jsxs(Rs,{children:[e.jsx(vt,{value:"all",children:"All Categories"}),u.map(k=>e.jsx(vt,{value:k.id,children:k.name},k.id))]})]}),e.jsxs(Fs,{value:o,onValueChange:l,children:[e.jsx(Ds,{className:"w-full sm:w-48",children:e.jsx(zs,{placeholder:"All Types"})}),e.jsxs(Rs,{children:[e.jsx(vt,{value:"all",children:"All Types"}),p.map(k=>e.jsx(vt,{value:k.id,children:k.name},k.id))]})]}),e.jsxs("div",{className:"flex gap-2",children:[N&&e.jsx(K,{variant:"outline",size:"sm",onClick:b,children:"Clear Filters"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:i==="grid"?"secondary":"outline",size:"icon",onClick:()=>d("grid"),className:"rounded-full",children:e.jsx(fp,{className:"h-4 w-4"})}),e.jsx(K,{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((k,C)=>e.jsx(Pe,{children:e.jsxs(Re,{className:"p-4",children:[e.jsx(ks,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(ks,{className:"h-5 w-3/4 mb-2"}),e.jsx(ks,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ks,{className:"h-5 w-16"}),e.jsx(ks,{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(K,{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(k=>e.jsxs(Pe,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${i==="list"?"flex flex-row":""}`,onClick:()=>w(k.id),children:[e.jsxs("div",{className:`relative overflow-hidden bg-muted ${i==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:[k.preview_image_url?e.jsx("img",{src:k.preview_image_url,alt:k.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"}),k.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(go,{className:"h-3 w-3"}),k.links.length]})})]}),e.jsxs(Re,{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:k.name}),k.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:Xde(k.description)}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[k.category&&e.jsx(Qe,{variant:"secondary",className:"text-xs",children:k.category.name}),k.type&&e.jsx(Qe,{variant:"outline",className:"text-xs",children:k.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"}),k.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ol,{className:"h-3.5 w-3.5"}),k.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:C=>{C.stopPropagation(),w(k.id)},children:[e.jsx(Zr,{className:"h-4 w-4"}),"View Template"]})]})]},k.id))})]})})};var A$t="Separator",Z8e="horizontal",E$t=["horizontal","vertical"],Eet=S.forwardRef((t,s)=>{const{decorative:r,orientation:n=Z8e,...a}=t,o=P$t(n)?n:Z8e,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=A$t;function P$t(t){return E$t.includes(t)}var Pet=Eet;const xo=S.forwardRef(({className:t,orientation:s="horizontal",decorative:r=!0,...n},a)=>e.jsx(Pet,{ref:a,decorative:r,orientation:s,className:Dt("shrink-0 bg-border",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...n}));xo.displayName=Pet.displayName;const I$t=()=>{const{templateId:t}=ao(),s=vr(),{user:r,isAdmin:n}=qs(),{toast:a}=ja(),o=Qt(),{trackEngagement:l}=QA(),[i,d]=S.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});S.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=Et({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=Et({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=Et({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]})}}),k=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(Es,{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(Es,{title:u.name,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(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(K,{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(K,{variant:k?"default":"outline",className:"gap-2 rounded-full",onClick:()=>w.mutate(),disabled:!r||w.isPending,children:[e.jsx(Bu,{className:`h-4 w-4 ${k?"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(Re,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(go,{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(K,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{l("template",u.id,u.name,"click_canva"),window.open(I.canva_share_link,"_blank")},children:[e.jsx("span",{className:"font-medium",children:I.title}),e.jsx(Zr,{className:"h-4 w-4 text-muted-foreground"})]},I.id))})]})}),u.video_url&&e.jsx(Pe,{children:e.jsx(Re,{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(Re,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(yn,{className:"h-4 w-4"}),"Guide Files"]}),e.jsx("div",{className:"grid gap-2",children:u.guides.map(I=>e.jsxs(K,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{l("template",u.id,u.name,"click_pdf"),window.open(I.file_url,"_blank")},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children: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(Re,{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(K,{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(xo,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(Ol,{className:"h-5 w-5"}),"Comments (",_.length,")"]}),r?e.jsxs("form",{onSubmit:A,className:"flex gap-2",children:[e.jsx(gr,{placeholder:"Add a comment...",value:i,onChange:I=>d(I.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!i.trim()||b.isPending,children:e.jsx(Mn,{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(Re,{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(Re,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(wn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(jn,{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(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>N.mutate(I.id),children:e.jsx(xr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:I.content})]})]})})},I.id))})]})]})}):e.jsx(Es,{title:"Templates",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(go,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Template not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This template may have been removed or is not available."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(da,{to:"/templates",children:"Back to Templates"})})]})})},L$t=()=>{const{user:t}=qs(),[s,r]=S.useState(""),[n,a]=S.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(k=>({...k,resources:(b==null?void 0:b.filter(C=>C.video_id===k.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(Es,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search videos...",value:s,onChange: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(ls,{value:"all",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:"All Videos"}),o.map(y=>e.jsx(ls,{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(Re,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(gn,{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(gn,{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(on,{className:"h-3 w-3"}),y.duration]})]}),e.jsxs(Lt,{className:"pb-2",children:[e.jsx("div",{className:"flex items-start justify-between gap-2",children:e.jsx(Ft,{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(Re,{className:"pt-0",children:[y.description&&e.jsx(ur,{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(yn,{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(Fl,{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(Fl,{className:"h-3 w-3"}),n.name]})},n.id))})]})}const D$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},R$t=()=>{const{videoId:t}=ao();vr();const{user:s,isAdmin:r}=qs(),{toast:n}=ja(),a=Qt(),{trackEngagement:o}=QA(),[l,i]=S.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});S.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=Et({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"})}}),_=Et({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=Et({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"📁"}},k=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(Es,{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(Es,{title:d.title,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(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:D$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(gn,{className:"h-16 w-16 opacity-50"}),e.jsx(K,{variant:"secondary",asChild:!0,children:e.jsxs("a",{href:d.video_url,target:"_blank",rel:"noopener noreferrer",className:"gap-2",children:[e.jsx(Zr,{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(K,{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(K,{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(Re,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(yn,{className:"h-4 w-4"}),"Resources"]}),e.jsx("div",{className:"grid gap-2",children:d.resources.map(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(xo,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(Ol,{className:"h-5 w-5"}),"Comments (",f.length,")"]}),s?e.jsxs("form",{onSubmit:C,className:"flex gap-2",children:[e.jsx(gr,{placeholder:"Add a comment...",value:l,onChange:A=>i(A.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||y.isPending,children:e.jsx(Mn,{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(Re,{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(Re,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(wn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(jn,{className:"text-sm",children:k(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(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>_.mutate(A.id),children:e.jsx(xr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:A.content})]})]})})},A.id))})]})]})}):e.jsx(Es,{title:"Academy",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(gn,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Video not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This video may have been removed or is not available."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(da,{to:"/academy",children:"Back to Academy"})})]})})};function O$t(){const t=vr(),[s,r]=S.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(Es,{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(an,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search resource kits...",value:s,onChange:_=>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(Re,{className:"p-4",children:[e.jsx(ks,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(ks,{className:"h-5 w-3/4 mb-2"}),e.jsx(ks,{className:"h-4 w-full mb-4"}),e.jsx(ks,{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(Re,{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:Xde(_.description)}),e.jsxs("div",{className:"flex items-center justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(yn,{className:"h-4 w-4"}),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(Ol,{className:"h-3.5 w-3.5"}),w]})]})]})]})]},_.id)})})]})})}const F$t=()=>{const{kitId:t}=ao(),{user:s,isAdmin:r}=qs(),{toast:n}=ja(),a=Qt(),{trackEngagement:o}=QA(),[l,i]=S.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});S.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=Et({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"})}}),_=Et({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=Et({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),k=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(Es,{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(Es,{title:d.name,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(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(K,{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(K,{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(Re,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(yn,{className:"h-4 w-4"}),"Included Resources (",d.files.length,")"]}),e.jsx("div",{className:"grid gap-2",children:d.files.map(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(yn,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:A.name}),A.file_size&&e.jsx("div",{className:"text-xs text-muted-foreground",children:k(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(Re,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Zr,{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(Zr,{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(xo,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(Ol,{className:"h-5 w-5"}),"Comments (",f.length,")"]}),s?e.jsxs("form",{onSubmit:C,className:"flex gap-2",children:[e.jsx(gr,{placeholder:"Add a comment...",value:l,onChange:A=>i(A.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||y.isPending,children:e.jsx(Mn,{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(Re,{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(Re,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(wn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(jn,{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(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>_.mutate(A.id),children:e.jsx(xr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:A.content})]})]})})},A.id))})]})]})}):e.jsx(Es,{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(K,{asChild:!0,className:"mt-4",children:e.jsx(da,{to:"/toolbox",children:"Back to Toolbox"})})]})})},z$t=()=>{const t=vr(),[s,r]=S.useState(""),[n,a]=S.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(Es,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search social swag...",value:s,onChange:u=>r(u.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex gap-2",children:[s&&e.jsx(K,{variant:"outline",size:"sm",onClick:()=>r(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:n==="grid"?"secondary":"outline",size:"icon",onClick:()=>a("grid"),className:"rounded-full",children:e.jsx(fp,{className:"h-4 w-4"})}),e.jsx(K,{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(Re,{className:"p-4",children:[e.jsx(ks,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(ks,{className:"h-5 w-3/4 mb-2"}),e.jsx(ks,{className:"h-4 w-full mb-4"})]})},p))}),!l&&i.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:s?"No items match your search":"No social swag available yet"}),s&&e.jsx(K,{variant:"outline",onClick:()=>r(""),children:"Clear Search"})]}),!l&&i.length>0&&e.jsx("div",{className:n==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:i.map(u=>e.jsxs(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(go,{className:"h-3 w-3"}),u.links.length]})})]}),e.jsxs(Re,{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(Ol,{className:"h-3.5 w-3.5"}),u.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:p=>{p.stopPropagation(),d(u.id)},children:[e.jsx(Zr,{className:"h-4 w-4"}),"View Details"]})]})]},u.id))})]})})};var ri=function(){return ri=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(yqt,{displayMonth:t.displayMonth,hideNext:p,hidePrevious:f,nextMonth:a,previousMonth:n,onPreviousClick:y,onNextClick:_})}function vqt(t){var s,r=$l(),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(Y8e,{displayMonth:t.displayMonth,id:t.id}):l==="dropdown-buttons"?u=e.jsxs(e.Fragment,{children:[e.jsx(Y8e,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id}),e.jsx(X8e,{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(X8e,{displayMonth:t.displayMonth,id:t.id})]}),e.jsx("div",{className:n.caption,style:o.caption,children:u})}function _qt(t){var s=$l(),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 bqt(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 wqt(){var t=$l(),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=bqt(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 jqt(){var t,s=$l(),r=s.classNames,n=s.styles,a=s.components,o=(t=a==null?void 0:a.HeadRow)!==null&&t!==void 0?t:wqt;return e.jsx("thead",{style:n.head,className:r.head,children:e.jsx(o,{})})}function Nqt(t){var s=$l(),r=s.locale,n=s.formatters.formatDay;return e.jsx(e.Fragment,{children:n(t.date,{locale:r})})}var t4e=S.createContext(void 0);function kqt(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(Sqt,{initialProps:t.initialProps,children:t.children})}function Sqt(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 k=w.findIndex(function(C){return il(u,C)});w.splice(k,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=S.useContext(t4e);if(!t)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return t}function Cqt(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=S.createContext(void 0);function Mqt(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(Tqt,{initialProps:t.initialProps,children:t.children})}function Tqt(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,k;(w=s.onDayClick)===null||w===void 0||w.call(s,_,b,N);var C=Cqt(_,n);(k=s.onSelect)===null||k===void 0||k.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:$ie(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:$ie(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:$ie(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=S.useContext(r4e);if(!t)throw new Error("useSelectRange must be used within a SelectRangeProvider");return t}function aoe(t){return Array.isArray(t)?Let([],t):t!==void 0?[t]:[]}function Aqt(t){var s={};return Object.entries(t).forEach(function(r){var n=r[0],a=r[1];s[n]=aoe(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 Eqt=Ug.Selected,gv=Ug.Disabled,Pqt=Ug.Hidden,Iqt=Ug.Today,vye=Ug.RangeEnd,_ye=Ug.RangeMiddle,bye=Ug.RangeStart,Lqt=Ug.Outside;function Dqt(t,s,r){var n,a=(n={},n[Eqt]=aoe(t.selected),n[gv]=aoe(t.disabled),n[Pqt]=aoe(t.hidden),n[Iqt]=[t.today],n[vye]=[],n[_ye]=[],n[bye]=[],n[Lqt]=[],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[bye]=r.modifiers[bye],a[_ye]=r.modifiers[_ye],a[vye]=r.modifiers[vye]),a}var zet=S.createContext(void 0);function Rqt(t){var s=$l(),r=s4e(),n=n4e(),a=Dqt(s,r,n),o=Aqt(s.modifiers),l=ri(ri({},a),o);return e.jsx(zet.Provider,{value:l,children:t.children})}function Bet(){var t=S.useContext(zet);if(!t)throw new Error("useModifiers must be used within a ModifiersProvider");return t}function Oqt(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function Fqt(t){return!!(t&&typeof t=="object"&&"from"in t)}function zqt(t){return!!(t&&typeof t=="object"&&"after"in t)}function Bqt(t){return!!(t&&typeof t=="object"&&"before"in t)}function $qt(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function qqt(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 Uqt(t){return Yje(t)}function Vqt(t){return Array.isArray(t)&&t.every(Yje)}function Hqt(t,s){return s.some(function(r){if(typeof r=="boolean")return r;if(Uqt(r))return il(t,r);if(Vqt(r))return r.includes(t);if(Fqt(r))return qqt(t,r);if($qt(r))return r.dayOfWeek.includes(t.getDay());if(Oqt(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 zqt(r)?sf(t,r.after)>0:Bqt(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 Hqt(t,i)&&o.push(l),o},[]),a={};return n.forEach(function(o){return a[o]=!0}),r&&!Due(t,r)&&(a.outside=!0),a}function Gqt(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 Wqt=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:w4t,startOfWeek:function(w){return a.ISOWeek?x1(w):zh(w,{locale:f,weekStartsOn:d})},endOfWeek:function(w){return a.ISOWeek?OWe(w):Iue(w,{locale:f,weekStartsOn:d})}},_=y[r](t,n==="after"?1:-1);n==="before"&&u?_=j4t([u,_]):n==="after"&&p&&(_=N4t([p,_]));var b=!0;if(o){var N=a4e(_,o);b=!N.disabled&&!N.hidden}return b?_:i.count>Wqt?i.lastFocused:$et(_,{moveBy:r,direction:n,context:a,modifiers:o,retry:ri(ri({},i),{count:i.count+1})})}var qet=S.createContext(void 0);function Kqt(t){var s=eO(),r=Bet(),n=S.useState(),a=n[0],o=n[1],l=S.useState(),i=l[0],d=l[1],u=Gqt(s.displayMonths,r),p=a??(i&&s.isDateDisplayed(i))?i:u,f=function(){d(a),o(void 0)},y=function(w){o(w)},_=$l(),b=function(w,k){if(a){var C=$et(a,{moveBy:w,direction:k,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=S.useContext(qet);if(!t)throw new Error("useFocusContext must be used within a FocusProvider");return t}function Zqt(t,s){var r=Bet(),n=a4e(t,r,s);return n}var o4e=S.createContext(void 0);function Yqt(t){if(!Nhe(t.initialProps)){var s={selected:void 0};return e.jsx(o4e.Provider,{value:s,children:t.children})}return e.jsx(Xqt,{initialProps:t.initialProps,children:t.children})}function Xqt(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=S.useContext(o4e);if(!t)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return t}function Qqt(t,s){var r=$l(),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,k=l.focusStartOfWeek,C=l.focusEndOfWeek,A=function(ie){var oe,me,ye,he;Nhe(r)?(oe=n.onDayClick)===null||oe===void 0||oe.call(n,t,s,ie):QR(r)?(me=a.onDayClick)===null||me===void 0||me.call(a,t,s,ie):JR(r)?(ye=o.onDayClick)===null||ye===void 0||ye.call(o,t,s,ie):(he=r.onDayClick)===null||he===void 0||he.call(r,t,s,ie)},I=function(ie){var oe;y(t),(oe=r.onDayFocus)===null||oe===void 0||oe.call(r,t,s,ie)},L=function(ie){var oe;f(),(oe=r.onDayBlur)===null||oe===void 0||oe.call(r,t,s,ie)},O=function(ie){var oe;(oe=r.onDayMouseEnter)===null||oe===void 0||oe.call(r,t,s,ie)},V=function(ie){var oe;(oe=r.onDayMouseLeave)===null||oe===void 0||oe.call(r,t,s,ie)},q=function(ie){var oe;(oe=r.onDayPointerEnter)===null||oe===void 0||oe.call(r,t,s,ie)},B=function(ie){var oe;(oe=r.onDayPointerLeave)===null||oe===void 0||oe.call(r,t,s,ie)},U=function(ie){var oe;(oe=r.onDayTouchCancel)===null||oe===void 0||oe.call(r,t,s,ie)},te=function(ie){var oe;(oe=r.onDayTouchEnd)===null||oe===void 0||oe.call(r,t,s,ie)},Y=function(ie){var oe;(oe=r.onDayTouchMove)===null||oe===void 0||oe.call(r,t,s,ie)},J=function(ie){var oe;(oe=r.onDayTouchStart)===null||oe===void 0||oe.call(r,t,s,ie)},X=function(ie){var oe;(oe=r.onDayKeyUp)===null||oe===void 0||oe.call(r,t,s,ie)},ce=function(ie){var oe;switch(ie.key){case"ArrowLeft":ie.preventDefault(),ie.stopPropagation(),r.dir==="rtl"?i():d();break;case"ArrowRight":ie.preventDefault(),ie.stopPropagation(),r.dir==="rtl"?d():i();break;case"ArrowDown":ie.preventDefault(),ie.stopPropagation(),u();break;case"ArrowUp":ie.preventDefault(),ie.stopPropagation(),p();break;case"PageUp":ie.preventDefault(),ie.stopPropagation(),ie.shiftKey?N():_();break;case"PageDown":ie.preventDefault(),ie.stopPropagation(),ie.shiftKey?w():b();break;case"Home":ie.preventDefault(),ie.stopPropagation(),k();break;case"End":ie.preventDefault(),ie.stopPropagation(),C();break}(oe=r.onDayKeyDown)===null||oe===void 0||oe.call(r,t,s,ie)},ae={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 ae}function Jqt(){var t=$l(),s=Uet(),r=s4e(),n=n4e(),a=Nhe(t)?s.selected:QR(t)?r.selected:JR(t)?n.selected:void 0;return a}function eUt(t){return Object.values(Ug).includes(t)}function tUt(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(eUt(n)){var o=t.classNames["day_".concat(n)];o&&r.push(o)}}),r}function sUt(t,s){var r=ri({},t.styles.day);return Object.keys(s).forEach(function(n){var a;r=ri(ri({},r),(a=t.modifiersStyles)===null||a===void 0?void 0:a[n])}),r}function rUt(t,s,r){var n,a,o,l=$l(),i=i4e(),d=Zqt(t,s),u=Qqt(t,d),p=Jqt(),f=!!(l.onDayClick||l.mode!=="default");S.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=tUt(l,d).join(" "),_=sUt(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:Nqt,w=e.jsx(N,{date:t,displayMonth:s,activeModifiers:d}),k={style:_,className:y,children:w,role:"gridcell"},C=i.focusTarget&&il(i.focusTarget,t)&&!d.outside,A=i.focusedDay&&il(i.focusedDay,t),I=ri(ri(ri({},k),(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:k};return L}function nUt(t){var s=S.useRef(null),r=rUt(t.date,t.displayMonth,s);return r.isHidden?e.jsx("div",{role:"gridcell"}):r.isButton?e.jsx(uce,ri({name:"day",ref:s},r.buttonProps)):e.jsx("div",ri({},r.divProps))}function aUt(t){var s=t.number,r=t.dates,n=$l(),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(uce,{name:"week-number","aria-label":f,className:l.weeknumber,style:o.weeknumber,onClick:y,children:p})}function iUt(t){var s,r,n=$l(),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:nUt,u=(r=i==null?void 0:i.WeekNumber)!==null&&r!==void 0?r:aUt,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})},CSt(f))})]})}function Q8e(t,s,r){for(var n=r!=null&&r.ISOWeek?OWe(s):Iue(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 oUt(t,s){var r=Q8e(gc(t),tx(t),s);if(s!=null&&s.useFixedWeeks){var n=TSt(t,s);if(n<6){var a=r[r.length-1],o=a.dates[a.dates.length-1],l=x4(o,6-n),i=Q8e(x4(o,1),l,s);r.push.apply(r,i)}}return r}function lUt(t){var s,r,n,a=$l(),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=oUt(t.displayMonth,{useFixedWeeks:!!u,ISOWeek:_,locale:o,weekStartsOn:f,firstWeekContainsDate:y}),N=(s=p==null?void 0:p.Head)!==null&&s!==void 0?s:jqt,w=(r=p==null?void 0:p.Row)!==null&&r!==void 0?r:iUt,k=(n=p==null?void 0:p.Footer)!==null&&n!==void 0?n:_qt;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(k,{displayMonth:t.displayMonth})]})}function cUt(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var dUt=cUt()?S.useLayoutEffect:S.useEffect,wye=!1,uUt=0;function J8e(){return"react-day-picker-".concat(++uUt)}function hUt(t){var s,r=t??(wye?J8e():null),n=S.useState(r),a=n[0],o=n[1];return dUt(function(){a===null&&o(J8e())},[]),S.useEffect(function(){wye===!1&&(wye=!0)},[]),(s=t??a)!==null&&s!==void 0?s:void 0}function mUt(t){var s,r,n=$l(),a=n.dir,o=n.classNames,l=n.styles,i=n.components,d=eO().displayMonths,u=hUt(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=ri(ri({},y),l.caption_start)),b&&(f.push(o.caption_end),y=ri(ri({},y),l.caption_end)),N&&(f.push(o.caption_between),y=ri(ri({},y),l.caption_between));var w=(r=i==null?void 0:i.Caption)!==null&&r!==void 0?r:vqt;return e.jsxs("div",{className:f.join(" "),style:y,children:[e.jsx(w,{id:u,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(lUt,{id:p,"aria-labelledby":u,displayMonth:t.displayMonth})]},t.displayIndex)}function pUt(t){var s=$l(),r=s.classNames,n=s.styles;return e.jsx("div",{className:r.months,style:n.months,children:t.children})}function fUt(t){var s,r,n=t.initialProps,a=$l(),o=i4e(),l=eO(),i=S.useState(!1),d=i[0],u=i[1];S.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=ri(ri({},a.styles.root),a.style),y=Object.keys(n).filter(function(b){return b.startsWith("data-")}).reduce(function(b,N){var w;return ri(ri({},b),(w={},w[N]=n[N],w))},{}),_=(r=(s=n.components)===null||s===void 0?void 0:s.Months)!==null&&r!==void 0?r:pUt;return e.jsx("div",ri({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(mUt,{displayIndex:N,displayMonth:b},N)})})}))}function xUt(t){var s=t.children,r=B$t(t,["children"]);return e.jsx(aqt,{initialProps:r,children:e.jsx(fqt,{children:e.jsx(Yqt,{initialProps:r,children:e.jsx(kqt,{initialProps:r,children:e.jsx(Mqt,{initialProps:r,children:e.jsx(Rqt,{children:e.jsx(Kqt,{children:s})})})})})})})}function gUt(t){return e.jsx(xUt,ri({},t,{children:e.jsx(fUt,{initialProps:t})}))}function uf({className:t,classNames:s,showOutsideDays:r=!0,...n}){return e.jsx(gUt,{showOutsideDays:r,className:Dt("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:Dt(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:Dt(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 khe="Popover",[Vet,yAs]=qc(khe,[w0]),tO=w0(),[yUt,ww]=Vet(khe),Het=t=>{const{__scopePopover:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!1}=t,i=tO(s),d=S.useRef(null),[u,p]=S.useState(!1),[f,y]=Uu({prop:n,defaultProp:a??!1,onChange:o,caller:khe});return e.jsx(SR,{...i,children:e.jsx(yUt,{scope:s,contentId:fu(),triggerRef:d,open:f,onOpenChange:y,onOpenToggle:S.useCallback(()=>y(_=>!_),[y]),hasCustomAnchor:u,onCustomAnchorAdd:S.useCallback(()=>p(!0),[]),onCustomAnchorRemove:S.useCallback(()=>p(!1),[]),modal:l,children:r})})};Het.displayName=khe;var Get="PopoverAnchor",vUt=S.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=ww(Get,r),o=tO(r),{onCustomAnchorAdd:l,onCustomAnchorRemove:i}=a;return S.useEffect(()=>(l(),()=>i()),[l,i]),e.jsx(OA,{...o,...n,ref:s})});vUt.displayName=Get;var Wet="PopoverTrigger",Ket=S.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:Sr(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?i:e.jsx(OA,{asChild:!0,...o,children:i})});Ket.displayName=Wet;var l4e="PopoverPortal",[_Ut,bUt]=Vet(l4e,{forceMount:void 0}),Zet=t=>{const{__scopePopover:s,forceMount:r,children:n,container:a}=t,o=ww(l4e,s);return e.jsx(_Ut,{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=S.forwardRef((t,s)=>{const r=bUt(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(jUt,{...a,ref:s}):e.jsx(NUt,{...a,ref:s})})});Yet.displayName=GT;var wUt=Hb("PopoverContent.RemoveScroll"),jUt=S.forwardRef((t,s)=>{const r=ww(GT,t.__scopePopover),n=S.useRef(null),a=Ta(s,n),o=S.useRef(!1);return S.useEffect(()=>{const l=n.current;if(l)return xue(l)},[]),e.jsx(IR,{as:wUt,allowPinchZoom:!0,children:e.jsx(Xet,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Sr(t.onCloseAutoFocus,l=>{var i;l.preventDefault(),o.current||(i=r.triggerRef.current)==null||i.focus()}),onPointerDownOutside:Sr(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:Sr(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})}),NUt=S.forwardRef((t,s)=>{const r=ww(GT,t.__scopePopover),n=S.useRef(!1),a=S.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=S.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 mue(),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",kUt=S.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=ww(Qet,r);return e.jsx(Jr.button,{type:"button",...n,ref:s,onClick:Sr(t.onClick,()=>a.onOpenChange(!1))})});kUt.displayName=Qet;var SUt="PopoverArrow",CUt=S.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=tO(r);return e.jsx(MR,{...a,...n,ref:s})});CUt.displayName=SUt;function Jet(t){return t?"open":"closed"}var MUt=Het,TUt=Ket,AUt=Zet,ett=Yet;const yo=MUt,vo=TUt,uo=S.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(AUt,{children:e.jsx(ett,{ref:a,align:s,sideOffset:r,className:Dt("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})}));uo.displayName=ett.displayName;const EUt=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=S.forwardRef(({className:t,variant:s,...r},n)=>e.jsx("div",{ref:n,role:"alert",className:Dt(EUt({variant:s}),t),...r}));c4e.displayName="Alert";const PUt=S.forwardRef(({className:t,...s},r)=>e.jsx("h5",{ref:r,className:Dt("mb-1 font-medium leading-none tracking-tight",t),...s}));PUt.displayName="AlertTitle";const d4e=S.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Dt("text-sm [&_p]:leading-relaxed",t),...s}));d4e.displayName="AlertDescription";function IUt({open:t,onOpenChange:s,imageUrl:r,imageId:n,defaultCaption:a="",swagItemId:o,reelId:l}){const i=Qt(),[d,u]=S.useState(a),[p,f]=S.useState([]),[y,_]=S.useState(null),[b,N]=S.useState("now"),[w,k]=S.useState(VPe(YPe(new Date),1)),[C,A]=S.useState("12"),[I,L]=S.useState("00"),[O,V]=S.useState("PM");S.useEffect(()=>{if(t){u(a),N("now"),f([]);const Ne=VPe(YPe(new Date),1);k(Ne);const Ue=Ne.getHours();A(String(Ue>12?Ue-12:Ue===0?12:Ue)),L("00"),V(Ue>=12?"PM":"AM")}},[t,a]);const q=()=>{if(!w)return null;let Ne=parseInt(C);const Ue=parseInt(I);return O==="PM"&&Ne!==12&&(Ne+=12),O==="AM"&&Ne===12&&(Ne=0),JL(QL(w,Ne),Ue)},{data:B,isLoading:U}=gt({queryKey:["social-accounts-for-post"],queryFn:async()=>{const{data:{user:Ne}}=await G.auth.getUser();if(!Ne)return[];const{data:Ue,error:Te}=await G.from("social_accounts").select("*").eq("user_id",Ne.id).eq("is_active",!0).order("platform",{ascending:!0});if(Te)throw Te;return console.log("Fetched social accounts for posting:",Ue),Ue},enabled:t,staleTime:0}),te=Et({mutationFn:async({accountId:Ne,platform:Ue})=>{_(Ne);const{data:Te,error:Me}=await G.functions.invoke("social-post",{body:{platform:Ue,accountId:Ne,imageUrl:r,caption:d}});if(Me)throw Me;if(Te!=null&&Te.error)throw new Error(Te.error);return Te},onSuccess:Ne=>{const Ue=Ne.platform==="facebook"?"Facebook":Ne.platform==="instagram"?"Instagram":Ne.platform==="linkedin"?"LinkedIn":"Google Business";pe.success(`Posted to ${Ue}!`)},onError:Ne=>{pe.error(`Failed to post: ${Ne.message}`)},onSettled:()=>{_(null)}}),Y=Et({mutationFn:async({accountId:Ne,platform:Ue,scheduledFor:Te})=>{const{data:{user:Me}}=await G.auth.getUser();if(!Me)throw new Error("Not authenticated");const{error:De}=await G.from("scheduled_posts").insert({user_id:Me.id,social_account_id:Ne,platform:Ue,image_url:r,caption:d,swag_item_id:o||null,reel_id:l||null,scheduled_for:Te.toISOString(),status:"scheduled"});if(De)throw De;return{platform:Ue}},onSuccess:Ne=>{const Ue=Ne.platform==="facebook"?"Facebook":Ne.platform==="instagram"?"Instagram":"LinkedIn";pe.success(`Post scheduled for ${Ue}!`)},onError:Ne=>{pe.error(`Failed to schedule: ${Ne.message}`)}}),J=async()=>{if(p.length===0){pe.error("Please select at least one account");return}if(b==="schedule"){const Ne=q();if(!Ne||Ne<=new Date){pe.error("Please select a future date and time");return}for(const Ue of p){const Te=B==null?void 0:B.find(Me=>Me.id===Ue);Te&&await Y.mutateAsync({accountId:Ue,platform:Te.platform,scheduledFor:Ne})}i.invalidateQueries({queryKey:["scheduled-posts"]}),pe.success(`${p.length} post(s) scheduled for ${gs(Ne,"PPp")}`)}else for(const Ne of p){const Ue=B==null?void 0:B.find(Te=>Te.id===Ne);Ue&&await te.mutateAsync({accountId:Ne,platform:Ue.platform})}i.invalidateQueries({queryKey:["scheduled-posts"]}),u(""),f([]),s(!1)},X=Ne=>{f(Ue=>Ue.includes(Ne)?Ue.filter(Te=>Te!==Ne):[...Ue,Ne])},ce=(B==null?void 0:B.filter(Ne=>Ne.platform==="facebook"))||[],ae=(B==null?void 0:B.filter(Ne=>Ne.platform==="instagram"))||[],ie=(B==null?void 0:B.filter(Ne=>Ne.platform==="linkedin"))||[],oe=(B==null?void 0:B.filter(Ne=>Ne.platform==="google_business"))||[],me=((B==null?void 0:B.length)||0)>0,ye=te.isPending||Y.isPending,he=Array.from({length:12},(Ne,Ue)=>String(Ue+1)),ge=["00","15","30","45"];return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(hs,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(js,{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(gr,{id:"caption",placeholder:"Write a caption for your post...",value:d,onChange:Ne=>u(Ne.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:Dt("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:Dt("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(on,{className:"h-4 w-4"}),"Schedule for"]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Dt("justify-start text-left font-normal flex-1",!w&&"text-muted-foreground"),children:[e.jsx(ln,{className:"mr-2 h-4 w-4"}),w?gs(w,"PPP"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(uo,{className:"w-auto p-0",align:"start",children:e.jsx(uf,{mode:"single",selected:w,onSelect:k,disabled:Ne=>Nee.jsx(vt,{value:Ne,children:Ne},Ne))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs(Fs,{value:I,onValueChange:L,children:[e.jsx(Ds,{className:"w-[70px]",children:e.jsx(zs,{})}),e.jsx(Rs,{children:ge.map(Ne=>e.jsx(vt,{value:Ne,children:Ne},Ne))})]}),e.jsxs(Fs,{value:O,onValueChange:Ne=>V(Ne),children:[e.jsx(Ds,{className:"w-[70px]",children:e.jsx(zs,{})}),e.jsxs(Rs,{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 ",gs(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(Ne=>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(Hi,{checked:p.includes(Ne.id),onCheckedChange:()=>X(Ne.id),disabled:y===Ne.id}),e.jsxs(wn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:Ne.profile_picture_url||""}),e.jsx(jn,{children:e.jsx(hu,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:Ne.page_name||Ne.platform_username}),y===Ne.id&&e.jsx(us,{className:"h-4 w-4 animate-spin"})]},Ne.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(pu,{className:"h-4 w-4 text-pink-600"})," Instagram"]}),ae.map(Ne=>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(Hi,{checked:p.includes(Ne.id),onCheckedChange:()=>X(Ne.id),disabled:y===Ne.id}),e.jsxs(wn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:Ne.profile_picture_url||""}),e.jsx(jn,{children:e.jsx(pu,{className:"h-4 w-4"})})]}),e.jsxs("span",{className:"flex-1 text-sm font-medium",children:["@",Ne.platform_username]}),y===Ne.id&&e.jsx(us,{className:"h-4 w-4 animate-spin"})]},Ne.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(xp,{className:"h-4 w-4 text-blue-700"})," LinkedIn"]}),ie.map(Ne=>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(Hi,{checked:p.includes(Ne.id),onCheckedChange:()=>X(Ne.id),disabled:y===Ne.id}),e.jsxs(wn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:Ne.profile_picture_url||""}),e.jsx(jn,{children:e.jsx(xp,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:Ne.platform_username}),y===Ne.id&&e.jsx(us,{className:"h-4 w-4 animate-spin"})]},Ne.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(Ne=>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(Hi,{checked:p.includes(Ne.id),onCheckedChange:()=>X(Ne.id),disabled:y===Ne.id}),e.jsxs(wn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:Ne.profile_picture_url||""}),e.jsx(jn,{children:e.jsx(Ia,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:Ne.page_name||Ne.platform_username}),y===Ne.id&&e.jsx(us,{className:"h-4 w-4 animate-spin"})]},Ne.id))]})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:J,disabled:p.length===0||ye,className:"gap-2",children:[ye?e.jsx(us,{className:"h-4 w-4 animate-spin"}):b==="schedule"?e.jsx(ln,{className:"h-4 w-4"}):e.jsx(Mn,{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 LUt(){const t=Qt(),[s,r]=S.useState(void 0),[n,a]=S.useState("all"),[o,l]=S.useState(null),[i,d]=S.useState(""),[u,p]=S.useState(void 0),[f,y]=S.useState("12"),[_,b]=S.useState("00"),[N,w]=S.useState("PM"),{data:k=[],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=k.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=k.filter(oe=>oe.scheduled_for).map(oe=>Em(new Date(oe.scheduled_for))),L=Et({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=Et({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=Et({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=Et({mutationFn:async oe=>{const{data:me,error:ye}=await G.functions.invoke("social-post",{body:{platform:oe.platform,accountId:oe.social_account_id,imageUrl:oe.image_url,caption:oe.caption}});if(ye)throw ye;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 ye=me.getHours();y(String(ye>12?ye-12:ye===0?12:ye)),b(String(me.getMinutes()).padStart(2,"0")),w(ye>=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 ye=JL(QL(u,oe),me);L.mutate({id:o.id,caption:i,scheduled_for:ye.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(xp,{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(on,{className:"h-3 w-3"}),"Scheduled"]});case"posted":return e.jsxs(Qe,{variant:"default",className:"gap-1 bg-green-600",children:[e.jsx(ti,{className:"h-3 w-3"}),"Posted"]});case"failed":return e.jsxs(Qe,{variant:"destructive",className:"gap-1",children:[e.jsx(Ql,{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=k.filter(oe=>oe.status==="scheduled").length,ae=k.filter(oe=>oe.status==="posted").length,ie=k.filter(oe=>oe.status==="scheduled"&&oe.scheduled_for&&ASt(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:ie}),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:ae}),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:k.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(yd,{className:"h-5 w-5"}),e.jsx("h3",{className:"font-semibold",children:"Calendar"})]}),e.jsx(uf,{mode:"single",selected:s,onSelect:r,className:Dt("pointer-events-auto"),modifiers:{hasPost:I},modifiersStyles:{hasPost:{fontWeight:"bold",backgroundColor:"hsl(var(--primary) / 0.1)",borderRadius:"50%"}}}),s&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>r(void 0),className:"w-full mt-2",children:"Clear date filter"})]}),e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(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(K,{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(ln,{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 ${gs(s,"PPP")}`:"Schedule a post from Social Swag to get started!"})]}),e.jsx("div",{className:"space-y-4",children:A.map(oe=>{var me,ye;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(Re,{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)||((ye=oe.social_accounts)==null?void 0:ye.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(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>B(oe),children:e.jsx(ga,{className:"h-4 w-4"})})}),e.jsx(Ll,{children:"Edit post"})]}),e.jsxs(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsx(K,{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(Mn,{className:"h-4 w-4"})})}),e.jsx(Ll,{children:"Post now"})]}),e.jsxs(Dl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(xr,{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(Dl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(xr,{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(on,{className:"h-3 w-3"}),oe.status==="posted"&&oe.posted_at?`Posted ${gs(new Date(oe.posted_at),"PPp")}`:oe.scheduled_for?`Scheduled for ${gs(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(hs,{className:"max-w-lg",children:[e.jsxs(js,{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(gr,{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(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Dt("justify-start text-left font-normal flex-1",!u&&"text-muted-foreground"),children:[e.jsx(ln,{className:"mr-2 h-4 w-4"}),u?gs(u,"PPP"):"Pick a date"]})}),e.jsx(uo,{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(Fs,{value:_,onValueChange:b,children:[e.jsx(Ds,{className:"w-[70px]",children:e.jsx(zs,{})}),e.jsx(Rs,{children:X.map(oe=>e.jsx(vt,{value:oe,children:oe},oe))})]}),e.jsxs(Fs,{value:N,onValueChange:oe=>w(oe),children:[e.jsx(Ds,{className:"w-[70px]",children:e.jsx(zs,{})}),e.jsxs(Rs,{children:[e.jsx(vt,{value:"AM",children:"AM"}),e.jsx(vt,{value:"PM",children:"PM"})]})]})]})]})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(null),children:"Cancel"}),e.jsxs(K,{onClick:U,disabled:L.isPending,children:[L.isPending?e.jsx(us,{className:"h-4 w-4 animate-spin mr-2"}):null,"Save Changes"]})]})]})})]})}function Yz(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 Yz=="function"&&Yz;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 Yz=="function"&&Yz,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,k,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="",ae="",ie="",oe=L.dir,me=L.date,ye={crc32:0,compressedSize:0,uncompressedSize:0};b&&!N||(ye.crc32=_.crc32,ye.compressedSize=_.compressedSize,ye.uncompressedSize=_.uncompressedSize);var he=0;b&&(he|=8),V||!J&&!X||(he|=2048);var ge=0,Ne=0;oe&&(ge|=16),k==="UNIX"?(Ne=798,ge|=function(Te,Me){var De=Te;return Te||(De=Me?16893:33204),(65535&De)<<16}(L.unixPermissions,oe)):(Ne=20,ge|=function(Te){return 63&(Te||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&&(ae=o(1,1)+o(p(q),4)+B,ce+="up"+o(ae.length,2)+ae),X&&(ie=o(1,1)+o(p(te),4)+Y,ce+="uc"+o(ie.length,2)+ie);var Ue="";return Ue+=` \0`,Ue+=o(he,2),Ue+=O.magic,Ue+=o(A,2),Ue+=o(I,2),Ue+=o(ye.crc32,4),Ue+=o(ye.compressedSize,4),Ue+=o(ye.uncompressedSize,4),Ue+=o(q.length,2),Ue+=o(ce.length,2),{fileRecord:f.LOCAL_FILE_HEADER+Ue+q+ce,dirRecord:f.CENTRAL_FILE_HEADER+o(Ne,2)+Ue+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,k){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=[],k(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,k,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,k,C,A=b.length,I=new Array(2*A);for(N=w=0;N>10&1023,I[w++]=56320|1023&k)}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),k=b;w!==b.length&&(l.uint8array?(k=b.subarray(0,w),this.leftOver=b.subarray(w,b.length)):(k=b.slice(0,w),this.leftOver=b.slice(w,b.length))),this.push({data:a.utf8decode(k),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 k=0;k>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,k=_.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,k=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,ae=3,ie=4;function oe(fe,He){return fe.msg=p[He],He}function me(fe){return(fe<<1)-(4fe.avail_out&&(et=fe.avail_out),et!==0&&(l.arraySet(fe.output,He.pending_buf,He.pending_out,et,fe.next_out),fe.next_out+=et,He.pending_out+=et,fe.total_out+=et,fe.avail_out-=et,He.pending-=et,He.pending===0&&(He.pending_out=0))}function ge(fe,He){i._tr_flush_block(fe,0<=fe.block_start?fe.block_start:-1,fe.strstart-fe.block_start,He),fe.block_start=fe.strstart,he(fe.strm)}function Ne(fe,He){fe.pending_buf[fe.pending++]=He}function Ue(fe,He){fe.pending_buf[fe.pending++]=He>>>8&255,fe.pending_buf[fe.pending++]=255&He}function Te(fe,He){var et,tt,_e=fe.max_chain_length,Ge=fe.strstart,We=fe.prev_length,it=fe.nice_match,Ve=fe.strstart>fe.w_size-te?fe.strstart-(fe.w_size-te):0,Xe=fe.window,dt=fe.w_mask,pt=fe.prev,Je=fe.strstart+U,Ze=Xe[Ge+We-1],Nt=Xe[Ge+We];fe.prev_length>=fe.good_match&&(_e>>=2),it>fe.lookahead&&(it=fe.lookahead);do if(Xe[(et=He)+We]===Nt&&Xe[et+We-1]===Ze&&Xe[et]===Xe[Ge]&&Xe[++et]===Xe[Ge+1]){Ge+=2,et++;do;while(Xe[++Ge]===Xe[++et]&&Xe[++Ge]===Xe[++et]&&Xe[++Ge]===Xe[++et]&&Xe[++Ge]===Xe[++et]&&Xe[++Ge]===Xe[++et]&&Xe[++Ge]===Xe[++et]&&Xe[++Ge]===Xe[++et]&&Xe[++Ge]===Xe[++et]&&GeVe&&--_e!=0);return We<=fe.lookahead?We:fe.lookahead}function Me(fe){var He,et,tt,_e,Ge,We,it,Ve,Xe,dt,pt=fe.w_size;do{if(_e=fe.window_size-fe.lookahead-fe.strstart,fe.strstart>=pt+(pt-te)){for(l.arraySet(fe.window,fe.window,pt,pt,0),fe.match_start-=pt,fe.strstart-=pt,fe.block_start-=pt,He=et=fe.hash_size;tt=fe.head[--He],fe.head[He]=pt<=tt?tt-pt:0,--et;);for(He=et=pt;tt=fe.prev[--He],fe.prev[He]=pt<=tt?tt-pt:0,--et;);_e+=pt}if(fe.strm.avail_in===0)break;if(We=fe.strm,it=fe.window,Ve=fe.strstart+fe.lookahead,Xe=_e,dt=void 0,dt=We.avail_in,Xe=B)for(Ge=fe.strstart-fe.insert,fe.ins_h=fe.window[Ge],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(_e=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<=_e&&(fe.ins_h=(fe.ins_h<fe.pending_buf_size-5&&(et=fe.pending_buf_size-5);;){if(fe.lookahead<=1){if(Me(fe),fe.lookahead===0&&He===f)return X;if(fe.lookahead===0)break}fe.strstart+=fe.lookahead,fe.lookahead=0;var tt=fe.block_start+et;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,He===y?(ge(fe,!0),fe.strm.avail_out===0?ae:ie):(fe.strstart>fe.block_start&&(ge(fe,!1),fe.strm.avail_out),X)}),new ke(4,4,8,4,De),new ke(4,5,16,8,De),new ke(4,6,32,32,De),new ke(4,4,16,16,qe),new ke(8,16,32,32,qe),new ke(8,16,128,128,qe),new ke(8,32,128,256,qe),new ke(32,128,258,1024,qe),new ke(32,258,258,4096,qe)],a.deflateInit=function(fe,He){return ut(fe,He,C,15,8,0)},a.deflateInit2=ut,a.deflateReset=we,a.deflateResetKeep=Be,a.deflateSetHeader=function(fe,He){return fe&&fe.state?fe.state.wrap!==2?b:(fe.state.gzhead=He,_):b},a.deflate=function(fe,He){var et,tt,_e,Ge;if(!fe||!fe.state||5>8&255),Ne(tt,tt.gzhead.time>>16&255),Ne(tt,tt.gzhead.time>>24&255),Ne(tt,tt.level===9?2:2<=tt.strategy||tt.level<2?4:0),Ne(tt,255&tt.gzhead.os),tt.gzhead.extra&&tt.gzhead.extra.length&&(Ne(tt,255&tt.gzhead.extra.length),Ne(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):(Ne(tt,0),Ne(tt,0),Ne(tt,0),Ne(tt,0),Ne(tt,0),Ne(tt,tt.level===9?2:2<=tt.strategy||tt.level<2?4:0),Ne(tt,3),tt.status=J);else{var We=C+(tt.w_bits-8<<4)<<8;We|=(2<=tt.strategy||tt.level<2?0:tt.level<6?1:tt.level===6?2:3)<<6,tt.strstart!==0&&(We|=32),We+=31-We%31,tt.status=J,Ue(tt,We),tt.strstart!==0&&(Ue(tt,fe.adler>>>16),Ue(tt,65535&fe.adler)),fe.adler=1}if(tt.status===69)if(tt.gzhead.extra){for(_e=tt.pending;tt.gzindex<(65535&tt.gzhead.extra.length)&&(tt.pending!==tt.pending_buf_size||(tt.gzhead.hcrc&&tt.pending>_e&&(fe.adler=u(fe.adler,tt.pending_buf,tt.pending-_e,_e)),he(fe),_e=tt.pending,tt.pending!==tt.pending_buf_size));)Ne(tt,255&tt.gzhead.extra[tt.gzindex]),tt.gzindex++;tt.gzhead.hcrc&&tt.pending>_e&&(fe.adler=u(fe.adler,tt.pending_buf,tt.pending-_e,_e)),tt.gzindex===tt.gzhead.extra.length&&(tt.gzindex=0,tt.status=73)}else tt.status=73;if(tt.status===73)if(tt.gzhead.name){_e=tt.pending;do{if(tt.pending===tt.pending_buf_size&&(tt.gzhead.hcrc&&tt.pending>_e&&(fe.adler=u(fe.adler,tt.pending_buf,tt.pending-_e,_e)),he(fe),_e=tt.pending,tt.pending===tt.pending_buf_size)){Ge=1;break}Ge=tt.gzindex_e&&(fe.adler=u(fe.adler,tt.pending_buf,tt.pending-_e,_e)),Ge===0&&(tt.gzindex=0,tt.status=91)}else tt.status=91;if(tt.status===91)if(tt.gzhead.comment){_e=tt.pending;do{if(tt.pending===tt.pending_buf_size&&(tt.gzhead.hcrc&&tt.pending>_e&&(fe.adler=u(fe.adler,tt.pending_buf,tt.pending-_e,_e)),he(fe),_e=tt.pending,tt.pending===tt.pending_buf_size)){Ge=1;break}Ge=tt.gzindex_e&&(fe.adler=u(fe.adler,tt.pending_buf,tt.pending-_e,_e)),Ge===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&&(Ne(tt,255&fe.adler),Ne(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(He)<=me(et)&&He!==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||He!==f&&tt.status!==666){var it=tt.strategy===2?function(Ve,Xe){for(var dt;;){if(Ve.lookahead===0&&(Me(Ve),Ve.lookahead===0)){if(Xe===f)return X;break}if(Ve.match_length=0,dt=i._tr_tally(Ve,0,Ve.window[Ve.strstart]),Ve.lookahead--,Ve.strstart++,dt&&(ge(Ve,!1),Ve.strm.avail_out===0))return X}return Ve.insert=0,Xe===y?(ge(Ve,!0),Ve.strm.avail_out===0?ae:ie):Ve.last_lit&&(ge(Ve,!1),Ve.strm.avail_out===0)?X:ce}(tt,He):tt.strategy===3?function(Ve,Xe){for(var dt,pt,Je,Ze,Nt=Ve.window;;){if(Ve.lookahead<=U){if(Me(Ve),Ve.lookahead<=U&&Xe===f)return X;if(Ve.lookahead===0)break}if(Ve.match_length=0,Ve.lookahead>=B&&0Ve.lookahead&&(Ve.match_length=Ve.lookahead)}if(Ve.match_length>=B?(dt=i._tr_tally(Ve,1,Ve.match_length-B),Ve.lookahead-=Ve.match_length,Ve.strstart+=Ve.match_length,Ve.match_length=0):(dt=i._tr_tally(Ve,0,Ve.window[Ve.strstart]),Ve.lookahead--,Ve.strstart++),dt&&(ge(Ve,!1),Ve.strm.avail_out===0))return X}return Ve.insert=0,Xe===y?(ge(Ve,!0),Ve.strm.avail_out===0?ae:ie):Ve.last_lit&&(ge(Ve,!1),Ve.strm.avail_out===0)?X:ce}(tt,He):o[tt.level].func(tt,He);if(it!==ae&&it!==ie||(tt.status=666),it===X||it===ae)return fe.avail_out===0&&(tt.last_flush=-1),_;if(it===ce&&(He===1?i._tr_align(tt):He!==5&&(i._tr_stored_block(tt,0,0,!1),He===3&&(ye(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 He!==y?_:tt.wrap<=0?1:(tt.wrap===2?(Ne(tt,255&fe.adler),Ne(tt,fe.adler>>8&255),Ne(tt,fe.adler>>16&255),Ne(tt,fe.adler>>24&255),Ne(tt,255&fe.total_in),Ne(tt,fe.total_in>>8&255),Ne(tt,fe.total_in>>16&255),Ne(tt,fe.total_in>>24&255)):(Ue(tt,fe.adler>>>16),Ue(tt,65535&fe.adler)),he(fe),0=et.w_size&&(Ge===0&&(ye(et.head),et.strstart=0,et.block_start=0,et.insert=0),Xe=new l.Buf8(et.w_size),l.arraySet(Xe,He,dt-et.w_size,et.w_size,0),He=Xe,dt=et.w_size),We=fe.avail_in,it=fe.next_in,Ve=fe.input,fe.avail_in=dt,fe.next_in=0,fe.input=He,Me(et);et.lookahead>=B;){for(tt=et.strstart,_e=et.lookahead-(B-1);et.ins_h=(et.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=ie.wsize?(o.arraySet(ie.window,J,X-ie.wsize,ie.wsize,0),ie.wnext=0,ie.whave=ie.wsize):(ce<(ae=ie.wsize-ie.wnext)&&(ae=ce),o.arraySet(ie.window,J,X-ce,ae,ie.wnext),(ce-=ae)?(o.arraySet(ie.window,J,X-ce,ce,0),ie.wnext=ce,ie.whave=ie.wsize):(ie.wnext+=ae,ie.wnext===ie.wsize&&(ie.wnext=0),ie.whave>>8&255,X.check=i(X.check,Ge,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&&(Ge[0]=255&he,Ge[1]=he>>>8&255,X.check=i(X.check,Ge,2,0)),ge=he=0,X.mode=3;case 3:for(;ge<32;){if(me===0)break e;me--,he+=ce[ie++]<>>8&255,Ge[2]=he>>>16&255,Ge[3]=he>>>24&255,X.check=i(X.check,Ge,4,0)),ge=he=0,X.mode=4;case 4:for(;ge<16;){if(me===0)break e;me--,he+=ce[ie++]<>8),512&X.flags&&(Ge[0]=255&he,Ge[1]=he>>>8&255,X.check=i(X.check,Ge,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[ie++]<>>8&255,X.check=i(X.check,Ge,2,0)),ge=he=0}else X.head&&(X.head.extra=null);X.mode=6;case 6:if(1024&X.flags&&(me<(Te=X.length)&&(Te=me),Te&&(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,ie,Te,fe)),512&X.flags&&(X.check=i(X.check,ce,Te,ie)),me-=Te,ie+=Te,X.length-=Te),X.length))break e;X.length=0,X.mode=7;case 7:if(2048&X.flags){if(me===0)break e;for(Te=0;fe=ce[ie+Te++],X.head&&fe&&X.length<65536&&(X.head.name+=String.fromCharCode(fe)),fe&&Te>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[ie++]<>>=7&ge,ge-=7&ge,X.mode=27;break}for(;ge<3;){if(me===0)break e;me--,he+=ce[ie++]<>>=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[ie++]<>>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(Te=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[We[X.have++]]=0;if(X.lencode=X.lendyn,X.lenbits=7,et={bits:X.lenbits},He=u(0,X.lens,0,19,X.lencode,0,X.work,et),X.lenbits=et.bits,He){Y.msg="invalid code lengths set",X.mode=30;break}X.have=0,X.mode=19;case 19:for(;X.have>>16&255,$e=65535&_e,!((qe=_e>>>24)<=ge);){if(me===0)break e;me--,he+=ce[ie++]<>>=qe,ge-=qe,X.lens[X.have++]=$e;else{if($e===16){for(tt=qe+2;ge>>=qe,ge-=qe,X.have===0){Y.msg="invalid bit length repeat",X.mode=30;break}fe=X.lens[X.have-1],Te=3+(3&he),he>>>=2,ge-=2}else if($e===17){for(tt=qe+3;ge>>=qe)),he>>>=3,ge-=3}else{for(tt=qe+7;ge>>=qe)),he>>>=7,ge-=7}if(X.have+Te>X.nlen+X.ndist){Y.msg="invalid bit length repeat",X.mode=30;break}for(;Te--;)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,et={bits:X.lenbits},He=u(p,X.lens,0,X.nlen,X.lencode,0,X.work,et),X.lenbits=et.bits,He){Y.msg="invalid literal/lengths set",X.mode=30;break}if(X.distbits=6,X.distcode=X.distdyn,et={bits:X.distbits},He=u(f,X.lens,X.nlen,X.ndist,X.distcode,0,X.work,et),X.distbits=et.bits,He){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<=ye){Y.next_out=oe,Y.avail_out=ye,Y.next_in=ie,Y.avail_in=me,X.hold=he,X.bits=ge,d(Y,Ue),oe=Y.next_out,ae=Y.output,ye=Y.avail_out,ie=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;ke=(_e=X.lencode[he&(1<>>16&255,$e=65535&_e,!((qe=_e>>>24)<=ge);){if(me===0)break e;me--,he+=ce[ie++]<>Be)])>>>16&255,$e=65535&_e,!(Be+(qe=_e>>>24)<=ge);){if(me===0)break e;me--,he+=ce[ie++]<>>=Be,ge-=Be,X.back+=Be}if(he>>>=qe,ge-=qe,X.back+=qe,X.length=$e,ke===0){X.mode=26;break}if(32&ke){X.back=-1,X.mode=12;break}if(64&ke){Y.msg="invalid literal/length code",X.mode=30;break}X.extra=15&ke,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(;ke=(_e=X.distcode[he&(1<>>16&255,$e=65535&_e,!((qe=_e>>>24)<=ge);){if(me===0)break e;me--,he+=ce[ie++]<>Be)])>>>16&255,$e=65535&_e,!(Be+(qe=_e>>>24)<=ge);){if(me===0)break e;me--,he+=ce[ie++]<>>=Be,ge-=Be,X.back+=Be}if(he>>>=qe,ge-=qe,X.back+=qe,64&ke){Y.msg="invalid distance code",X.mode=30;break}X.offset=$e,X.extra=15&ke,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(ye===0)break e;if(Te=Ue-ye,X.offset>Te){if((Te=X.offset-Te)>X.whave&&X.sane){Y.msg="invalid distance too far back",X.mode=30;break}Me=Te>X.wnext?(Te-=X.wnext,X.wsize-Te):X.wnext-Te,Te>X.length&&(Te=X.length),De=X.window}else De=ae,Me=oe-X.offset,Te=X.length;for(yeV?(B=Me[De+w[J]],ge[Ne+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++,--Ue[Y]==0){if(Y===ce)break;Y=f[y+w[J]]}if(ae>>7)]}function Ne(_e,Ge){_e.pending_buf[_e.pending++]=255&Ge,_e.pending_buf[_e.pending++]=Ge>>>8&255}function Ue(_e,Ge,We){_e.bi_valid>k-We?(_e.bi_buf|=Ge<<_e.bi_valid&65535,Ne(_e,_e.bi_buf),_e.bi_buf=Ge>>k-_e.bi_valid,_e.bi_valid+=We-k):(_e.bi_buf|=Ge<<_e.bi_valid&65535,_e.bi_valid+=We)}function Te(_e,Ge,We){Ue(_e,We[2*Ge],We[2*Ge+1])}function Me(_e,Ge){for(var We=0;We|=1&_e,_e>>>=1,We<<=1,0<--Ge;);return We>>>1}function De(_e,Ge,We){var it,Ve,Xe=new Array(w+1),dt=0;for(it=1;it<=w;it++)Xe[it]=dt=dt+We[it-1]<<1;for(Ve=0;Ve<=Ge;Ve++){var pt=_e[2*Ve+1];pt!==0&&(_e[2*Ve]=Me(Xe[pt]++,pt))}}function qe(_e){var Ge;for(Ge=0;Ge>1;1<=We;We--)Be(_e,Xe,We);for(Ve=Je;We=_e.heap[1],_e.heap[1]=_e.heap[_e.heap_len--],Be(_e,Xe,1),it=_e.heap[1],_e.heap[--_e.heap_max]=We,_e.heap[--_e.heap_max]=it,Xe[2*Ve]=Xe[2*We]+Xe[2*it],_e.depth[Ve]=(_e.depth[We]>=_e.depth[it]?_e.depth[We]:_e.depth[it])+1,Xe[2*We+1]=Xe[2*it+1]=Ve,_e.heap[1]=Ve++,Be(_e,Xe,1),2<=_e.heap_len;);_e.heap[--_e.heap_max]=_e.heap[1],function(Nt,Ot){var Yt,Ps,$s,Zs,Dr,$t,Us=Ot.dyn_tree,Nr=Ot.max_code,Xs=Ot.stat_desc.static_tree,kr=Ot.stat_desc.has_stree,fn=Ot.stat_desc.extra_bits,Yr=Ot.stat_desc.extra_base,$r=Ot.stat_desc.max_length,Gr=0;for(Zs=0;Zs<=w;Zs++)Nt.bl_count[Zs]=0;for(Us[2*Nt.heap[Nt.heap_max]+1]=0,Yt=Nt.heap_max+1;Yt>=7;Ve<_;Ve++)for(me[Ve]=Xe<<7,Ge=0;Ge<1<>>=1)if(1&Ze&&pt.dyn_ltree[2*Je]!==0)return l;if(pt.dyn_ltree[18]!==0||pt.dyn_ltree[20]!==0||pt.dyn_ltree[26]!==0)return i;for(Je=32;Je>>3,(Xe=_e.static_len+3+7>>>3)<=Ve&&(Ve=Xe)):Ve=Xe=We+5,We+4<=Ve&&Ge!==-1?tt(_e,Ge,We,it):_e.strategy===4||Xe===Ve?(Ue(_e,2+(it?1:0),3),we(_e,te,Y)):(Ue(_e,4+(it?1:0),3),function(pt,Je,Ze,Nt){var Ot;for(Ue(pt,Je-257,5),Ue(pt,Ze-1,5),Ue(pt,Nt-4,4),Ot=0;Ot>>8&255,_e.pending_buf[_e.d_buf+2*_e.last_lit+1]=255&Ge,_e.pending_buf[_e.l_buf+_e.last_lit]=255&We,_e.last_lit++,Ge===0?_e.dyn_ltree[2*We]++:(_e.matches++,Ge--,_e.dyn_ltree[2*(X[We]+f+1)]++,_e.dyn_dtree[2*ge(Ge)]++),_e.last_lit===_e.lit_bufsize-1},a._tr_align=function(_e){Ue(_e,2,3),Te(_e,A,te),function(Ge){Ge.bi_valid===16?(Ne(Ge,Ge.bi_buf),Ge.bi_buf=0,Ge.bi_valid=0):8<=Ge.bi_valid&&(Ge.pending_buf[Ge.pending++]=255&Ge.bi_buf,Ge.bi_buf>>=8,Ge.bi_valid-=8)}(_e)}},{"../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 fd<"u"?fd:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(ttt);var DUt=ttt.exports;const RUt=no(DUt);function jye(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 OUt=()=>{const{isAdmin:t}=qs(),[s,r]=S.useState(null),[n,a]=S.useState(null),[o,l]=S.useState("all"),[i,d]=S.useState(new Set),[u,p]=S.useState(!1),[f,y]=S.useState(!1),[_,b]=S.useState("images"),[N,w]=S.useState(null),{data:k=[],isLoading:C}=gt({queryKey:["social-swag-2"],queryFn:async()=>{const{data:me,error:ye}=await G.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(ye)throw ye;return me}}),{data:A=[]}=gt({queryKey:["social-swag-2-months"],queryFn:async()=>{const{data:me,error:ye}=await G.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(ye)throw ye;return me}}),{data:I=[]}=gt({queryKey:["social-swag-2-reels"],queryFn:async()=>{const{data:me,error:ye}=await G.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(ye)throw ye;return me}}),{data:L=[]}=gt({queryKey:["my-social-accounts-count"],queryFn:async()=>{const{data:me,error:ye}=await G.from("social_accounts").select("id, platform").eq("is_active",!0);if(ye)throw ye;return me||[]}}),O=L.length>0,V=S.useMemo(()=>o==="all"?null:I.find(me=>me.month===o)||null,[o,I]),q=S.useMemo(()=>[...new Set(k.map(ye=>ye.month))].sort((ye,he)=>he.localeCompare(ye)),[k]);S.useEffect(()=>{q.length>0&&o==="all"&&l(q[0])},[q,o]);const B=me=>{try{const ye=sNe(me,"yyyy-MM",new Date);return gs(ye,"MMMM yyyy")}catch{return me}},U=S.useMemo(()=>o==="all"?k:k.filter(me=>me.month===o),[o,k]),te=S.useMemo(()=>{var me;return o==="all"?null:((me=A.find(ye=>ye.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,ye)=>{try{const ge=await(await fetch(me)).blob(),Ne=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),Ue=navigator.canShare&&navigator.canShare({files:[new File([ge],"test.jpg",{type:"image/jpeg"})]});if(Ne&&Ue){const Te=new File([ge],`social-swag-${ye}.jpg`,{type:"image/jpeg"});await navigator.share({files:[Te],title:"Social Swag Image"}),pe.success("Image ready to save!")}else{const Te=window.URL.createObjectURL(ge),Me=document.createElement("a");Me.href=Te,Me.download=`social-swag-${ye}.jpg`,document.body.appendChild(Me),Me.click(),document.body.removeChild(Me),window.URL.revokeObjectURL(Te),pe.success("Image downloaded!")}}catch(he){he.name!=="AbortError"&&pe.error("Failed to download image")}},X=me=>{d(ye=>{const he=new Set(ye);return he.has(me)?he.delete(me):he.add(me),he})},ce=()=>{d(new Set(U.map(me=>me.id)))},ae=()=>{d(new Set),p(!1)},ie=async()=>{const me=U.filter(ye=>i.has(ye.id));if(me.length===0){pe.error("No images selected");return}y(!0),pe.info(`Preparing ${me.length} images for download...`);try{const ye=new RUt,he=[...me].sort((Me,De)=>Me.sort_order-De.sort_order);for(let Me=0;Me{u?X(me.id):r(me)};return e.jsx(Es,{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"}),k.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(ls,{value:"gallery",className:"gap-2",children:[e.jsx(qo,{className:"h-4 w-4"}),"Gallery"]}),e.jsxs(ls,{value:"scheduled",className:"gap-2",children:[e.jsx(yd,{className:"h-4 w-4"}),"Scheduled"]})]}),e.jsxs(ws,{value:"gallery",className:"space-y-6",children:[t?O?e.jsx(Pe,{className:"border rounded-xl",children:e.jsx(Re,{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-muted text-2xl",children:"📸"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-foreground mb-1",children:"Ready to post!"}),e.jsx("p",{className:"text-muted-foreground",children:'Click any image and use "Create Post" to share directly to your connected accounts.'})]}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsx(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(Re,{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(K,{asChild:!0,className:"gap-2 bg-gradient-to-r from-pink-500 via-purple-500 to-blue-500 hover:from-pink-600 hover:via-purple-600 hover:to-blue-600",children:e.jsxs(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(Re,{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(on,{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:Dt("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"),ae()},className:Dt("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"),ae()},className:Dt("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(K,{variant:"outline",size:"sm",onClick:ce,className:"gap-2",children:["Select All (",U.length,")"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ae,className:"gap-2",children:[e.jsx(jr,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(K,{size:"sm",onClick:ie,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(K,{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 ye=i.has(me.id);return e.jsx(Pe,{className:Dt("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",u&&ye&&"ring-2 ring-primary ring-offset-2"),onClick:()=>oe(me),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:jye(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:gs(new Date(me.post_date+"T00:00:00"),"MMM d")})}),u&&e.jsx("div",{className:Dt("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",ye?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:ye&&e.jsx(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:jye(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(hs,{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:jye(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(ln,{className:"h-4 w-4"}),gs(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(ln,{className:"h-3.5 w-3.5"}),"Post on ",gs(new Date(s.post_date+"T00:00:00"),"MMMM d, yyyy")]})]}),e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:s.caption})})]}),e.jsxs("div",{className:"flex flex-col gap-3 mt-6",children:[t&&e.jsxs(K,{onClick:()=>{w({imageUrl:s.image_url,imageId:s.id,caption:s.caption})},className:"w-full gap-2 bg-gradient-to-r from-pink-500 via-purple-500 to-blue-500 hover:from-pink-600 hover:via-purple-600 hover:to-blue-600 text-white",children:[e.jsx(Mn,{className:"h-4 w-4"}),"Create Post"]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(K,{variant:"outline",onClick:()=>Y(s.caption),className:"flex-1 gap-2",children:[e.jsx(Wa,{className:"h-4 w-4"}),"Copy Caption"]}),e.jsxs(K,{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(hs,{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(K,{onClick:()=>Y(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(Wa,{className:"h-4 w-4"}),"Copy Caption"]}),n.canva_link&&e.jsxs(K,{variant:"outline",onClick:()=>window.open(n.canva_link,"_blank"),className:"flex-1 gap-2",children:[e.jsx(Zr,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})}),e.jsx(IUt,{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(ws,{value:"scheduled",children:e.jsx(LUt,{})})]}):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(Re,{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(on,{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:Dt("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"),ae()},className:Dt("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"),ae()},className:Dt("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(K,{variant:"outline",size:"sm",onClick:ce,className:"gap-2",children:["Select All (",U.length,")"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ae,className:"gap-2",children:[e.jsx(jr,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&e.jsxs(K,{size:"sm",onClick:ie,disabled:f,className:"gap-2",children:[e.jsx(Qa,{className:"h-4 w-4"}),f?"Downloading...":`Download ${i.size} Selected`]})]}):e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>p(!0),className:"gap-2",children:[e.jsx(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 ye=i.has(me.id);return e.jsx(Pe,{className:Dt("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",u&&ye&&"ring-2 ring-primary ring-offset-2"),onClick:()=>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:Dt("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",ye?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:ye&&e.jsx(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(hs,{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(ln,{className:"h-4 w-4"}),gs(new Date(s.created_at),"MMMM d, yyyy")]}),e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:s.caption})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-6",children:[e.jsxs(K,{variant:"outline",onClick:()=>Y(s.caption),className:"flex-1 gap-2",children:[e.jsx(Wa,{className:"h-4 w-4"}),"Copy Caption"]}),e.jsxs(K,{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(hs,{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(K,{onClick:()=>Y(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(Wa,{className:"h-4 w-4"}),"Copy Caption"]}),n.canva_link&&e.jsxs(K,{variant:"outline",onClick:()=>window.open(n.canva_link,"_blank"),className:"flex-1 gap-2",children:[e.jsx(Zr,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})})]})]})})},FUt=()=>{const{swagId:t}=ao(),{user:s}=qs(),{toast:r}=ja(),n=Qt(),{trackEngagement:a}=QA(),[o,l]=S.useState(""),{data:i,isLoading:d}=gt({queryKey:["social-swag-detail",t],queryFn:async()=>{const{data:k,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{...k,links:A||[]}},enabled:!!t});S.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:k,error:C}=await G.from("social_swag_likes").select("*").eq("swag_id",t);if(C)throw C;return k},enabled:!!t}),{data:p=[]}=gt({queryKey:["social-swag-comments",t],queryFn:async()=>{const{data:k,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(k.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 k.map(O=>({...O,user_name:L.get(O.user_id)||"Unknown User"}))},enabled:!!t}),f=Et({mutationFn:async k=>{const{error:C}=await G.from("social_swag_comments").insert({swag_id:t,user_id:s.id,content:k});if(C)throw C},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),l(""),r({title:"Comment added!"})},onError:k=>{r({title:"Error adding comment",description:k.message,variant:"destructive"})}}),y=Et({mutationFn:async k=>{const{error:C}=await G.from("social_swag_comments").delete().eq("id",k);if(C)throw C},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),r({title:"Comment deleted"})}}),_=Et({mutationFn:async()=>{const k=u.find(C=>C.user_id===(s==null?void 0:s.id));if(k){const{error:C}=await G.from("social_swag_likes").delete().eq("id",k.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(k=>k.user_id===(s==null?void 0:s.id)),N=k=>k.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),w=k=>{k.preventDefault(),!(!o.trim()||!s)&&f.mutate(o.trim())};return d?e.jsx(Es,{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(Es,{title:i.title,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(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(K,{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(Re,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(go,{className:"h-4 w-4"}),i.links.length===1?"Canva Link":"Canva Links"]}),e.jsx("div",{className:"grid gap-2",children:i.links.map(k=>e.jsxs(K,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{a("social_swag",i.id,i.title,"click_canva"),window.open(k.canva_share_link,"_blank")},children:[e.jsx("span",{className:"font-medium",children:k.title}),e.jsx(Zr,{className:"h-4 w-4 text-muted-foreground"})]},k.id))})]})}),e.jsx(xo,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(Ol,{className:"h-5 w-5"}),"Comments (",p.length,")"]}),s?e.jsxs("form",{onSubmit:w,className:"flex gap-2",children:[e.jsx(gr,{placeholder:"Add a comment...",value:o,onChange:k=>l(k.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!o.trim()||f.isPending,children:e.jsx(Mn,{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(Re,{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(k=>e.jsx(Pe,{children:e.jsx(Re,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(wn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(jn,{className:"text-sm",children:N(k.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:k.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Nl(new Date(k.created_at),{addSuffix:!0})}),k.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>y.mutate(k.id),children:e.jsx(xr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:k.content})]})]})})},k.id))})]})]})}):e.jsx(Es,{title:"Social Swag",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(go,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Item not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This item may have been removed or is not available."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(da,{to:"/social-swag",children:"Back to Social Swag"})})]})})},zUt=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=S.useState(!0),[i,d]=S.useState(!0),[u,p]=S.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(K,{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(K,{variant:"ghost",className:"w-full justify-between text-muted-foreground hover:text-foreground",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider",children:"Categories"}),o?e.jsx(Fi,{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(K,{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(K,{variant:"ghost",className:"w-full justify-between text-muted-foreground hover:text-foreground",children:[e.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wider flex items-center gap-1",children:[e.jsx(vd,{className:"h-3 w-3"}),"Your Groups"]}),i?e.jsx(Fi,{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(K,{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(K,{variant:"ghost",className:"w-full justify-between text-muted-foreground hover:text-foreground",children:[e.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wider flex items-center gap-1",children:[e.jsx(or,{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(Fi,{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(wn,{className:"h-7 w-7",children:[e.jsx(Ma,{src:y.avatarUrl}),e.jsx(jn,{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))})]})]})})})},BUt=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=S.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(K,{variant:"outline",className:"flex-1 justify-between",children:[e.jsx("span",{className:"truncate",children:d()}),e.jsx(Fi,{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(vd,{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(K,{variant:"outline",size:"icon",className:"relative",children:[e.jsx(or,{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(or,{className:"h-5 w-5"}),"Online Now (",a.length,")"]})}),e.jsx(ni,{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(wn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:u.avatarUrl}),e.jsx(jn,{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 Nye,She="HoverCard",[stt,vAs]=qc(She,[w0]),Che=w0(),[$Ut,u4e]=stt(She),rtt=t=>{const{__scopeHoverCard:s,children:r,open:n,defaultOpen:a,onOpenChange:o,openDelay:l=700,closeDelay:i=300}=t,d=Che(s),u=S.useRef(0),p=S.useRef(0),f=S.useRef(!1),y=S.useRef(!1),[_,b]=Uu({prop:n,defaultProp:a??!1,onChange:o,caller:She}),N=S.useCallback(()=>{clearTimeout(p.current),u.current=window.setTimeout(()=>b(!0),l)},[l,b]),w=S.useCallback(()=>{clearTimeout(u.current),!f.current&&!y.current&&(p.current=window.setTimeout(()=>b(!1),i))},[i,b]),k=S.useCallback(()=>b(!1),[b]);return S.useEffect(()=>()=>{clearTimeout(u.current),clearTimeout(p.current)},[]),e.jsx($Ut,{scope:s,open:_,onOpenChange:b,onOpen:N,onClose:w,onDismiss:k,hasSelectionRef:f,isPointerDownOnContentRef:y,children:e.jsx(SR,{...d,children:r})})};rtt.displayName=She;var ntt="HoverCardTrigger",att=S.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=u4e(ntt,r),o=Che(r);return e.jsx(OA,{asChild:!0,...o,children:e.jsx(Jr.a,{"data-state":a.open?"open":"closed",...n,ref:s,onPointerEnter:Sr(t.onPointerEnter,mce(a.onOpen)),onPointerLeave:Sr(t.onPointerLeave,mce(a.onClose)),onFocus:Sr(t.onFocus,a.onOpen),onBlur:Sr(t.onBlur,a.onClose),onTouchStart:Sr(t.onTouchStart,l=>l.preventDefault())})})});att.displayName=ntt;var qUt="HoverCardPortal",[_As,UUt]=stt(qUt,{forceMount:void 0}),hce="HoverCardContent",itt=S.forwardRef((t,s)=>{const r=UUt(hce,t.__scopeHoverCard),{forceMount:n=r.forceMount,...a}=t,o=u4e(hce,t.__scopeHoverCard);return e.jsx(jd,{present:n||o.open,children:e.jsx(VUt,{"data-state":o.open?"open":"closed",...a,onPointerEnter:Sr(t.onPointerEnter,mce(o.onOpen)),onPointerLeave:Sr(t.onPointerLeave,mce(o.onClose)),ref:s})})});itt.displayName=hce;var VUt=S.forwardRef((t,s)=>{const{__scopeHoverCard:r,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,...i}=t,d=u4e(hce,r),u=Che(r),p=S.useRef(null),f=Ta(s,p),[y,_]=S.useState(!1);return S.useEffect(()=>{if(y){const b=document.body;return Nye=b.style.userSelect||b.style.webkitUserSelect,b.style.userSelect="none",b.style.webkitUserSelect="none",()=>{b.style.userSelect=Nye,b.style.webkitUserSelect=Nye}}},[y]),S.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]),S.useEffect(()=>{p.current&&WUt(p.current).forEach(N=>N.setAttribute("tabindex","-1"))}),e.jsx(dw,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:l,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:Sr(o,b=>{b.preventDefault()}),onDismiss:d.onDismiss,children:e.jsx(CR,{...u,...i,onPointerDown:Sr(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)"}})})}),HUt="HoverCardArrow",GUt=S.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=Che(r);return e.jsx(MR,{...a,...n,ref:s})});GUt.displayName=HUt;function mce(t){return s=>s.pointerType==="touch"?void 0:t()}function WUt(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 KUt=rtt,ZUt=att,ott=itt;const YUt=KUt,XUt=ZUt,ltt=S.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(ott,{ref:a,align:s,sideOffset:r,className:Dt("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 QUt=[{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"}],JUt=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(YUt,{openDelay:200,closeDelay:100,children:[e.jsx(XUt,{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=QUt.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(wn,{className:"h-6 w-6",children:[e.jsx(Ma,{src:l.user_avatar||void 0}),e.jsx(jn,{className:"text-[10px]",children:JUt(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 eVt({images:t,initialIndex:s=0,open:r,onOpenChange:n}){const[a,o]=S.useState(s),[l,i]=S.useState(!1);S.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]);S.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(hs,{className:"max-w-[95vw] max-h-[95vh] w-auto h-auto p-0 border-none bg-black/95 overflow-hidden",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"absolute top-2 right-2 z-50 text-white hover:bg-white/20 h-10 w-10",onClick:()=>n(!1),children:e.jsx(jr,{className:"h-6 w-6"})}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",className:"absolute left-2 top-1/2 -translate-y-1/2 z-50 text-white hover:bg-white/20 h-12 w-12",onClick:d,children:e.jsx(Xo,{className:"h-8 w-8"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 z-50 text-white hover:bg-white/20 h-12 w-12",onClick:u,children:e.jsx(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(K,{variant:"ghost",size:"icon",className:"absolute top-2 left-2 z-50 text-white hover:bg-white/20 h-10 w-10",onClick:()=>i(!l),children:l?e.jsx(zM,{className:"h-5 w-5"}):e.jsx(Eb,{className:"h-5 w-5"})}),e.jsx("div",{className:Dt("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:Dt("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:Dt("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 Xz=[{type:"like",emoji:"👍",label:"Like"},{type:"love",emoji:"❤️",label:"Love"}],tVt=({commentId:t,reactions:s,currentUserId:r})=>{var u,p;const n=Qt(),[a,o]=S.useState(!1),l=s.find(f=>f.user_id===r),i=Et({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=Xz.find(_=>_.type===f))==null?void 0:y.emoji},f)})}),e.jsx("span",{children:s.length})]})}),r&&e.jsxs(yo,{open:a,onOpenChange:o,children:[e.jsx(vo,{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=Xz.find(f=>f.type===l.reaction_type))==null?void 0:u.emoji," ",(p=Xz.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(uo,{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:Xz.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:Dt("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(S.Fragment,{children:i},d))})}function pce({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=S.useRef(null),f=S.useRef(null),[y,_]=S.useState(!1),[b,N]=S.useState("user"),[w,k]=S.useState(""),[C,A]=S.useState(null),[I,L]=S.useState(0),[O,V]=S.useState({top:0,left:0,width:0}),q=S.useRef(new Map),B=S.useRef(new Map),U=ge=>{if(d==="plain"){const Me=[];return q.current.forEach((qe,ke)=>{ge.includes(`@${ke}`)&&Me.push(qe)}),[...new Set(Me)]}const Ne=/@\[([^\]]+)\]\(([^)]+)\)/g,Ue=[];let Te;for(;(Te=Ne.exec(ge))!==null;)Ue.push(Te[2]);return[...new Set(Ue)]},te=ge=>{if(d==="plain"){const Me=[];return B.current.forEach((qe,ke)=>{ge.includes(`#${ke}`)&&Me.push(qe)}),[...new Set(Me)]}const Ne=/#\[([^\]]+)\]\(([^)]+)\)/g,Ue=[];let Te;for(;(Te=Ne.exec(ge))!==null;)Ue.push(Te[2]);return[...new Set(Ue)]};S.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),Ne=w.length>=1?ge.ilike("name",`%${w}%`):ge.order("name"),{data:Ue,error:Te}=await Ne;if(Te)throw Te;const Me=Ue.map(qe=>qe.id),De=await JZe(Me);return Ue.map(qe=>({id:qe.id,name:qe.name||"Unknown",avatar_url:De.get(qe.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:Ne,error:Ue}=await ge;if(Ue)throw Ue;return Ne||[]},enabled:y&&b==="template"&&u,staleTime:3e4}),ae=b==="user"?J:ce,ie=b==="user"?Y:X,oe=ge=>ge.split(" ").map(Ne=>Ne[0]).join("").toUpperCase().slice(0,2),me=ge=>{const Ne=ge.target.value,Ue=ge.target.selectionStart;s(Ne);const Te=Ne.substring(0,Ue),Me=Te.lastIndexOf("@"),De=u?Te.lastIndexOf("#"):-1;let qe=-1,ke="user";if(Me>De?(qe=Me,ke="user"):De>Me&&u&&(qe=De,ke="template"),qe!==-1){const $e=Te.substring(qe+1),Be=$e.includes(" "),we=$e.includes(` `);if(!Be&&!we&&$e.length<=30){A(qe),k($e),N(ke),_(!0),L(0);return}}_(!1),A(null)},ye=ge=>{if(C===null)return;const Ne=t.substring(0,C),Ue=t.substring(C+w.length+1),Te=b==="user"?"@":"#",Me=d==="plain"?`${Te}${ge.name} `:`${Te}[${ge.name}](${ge.id}) `;d==="plain"&&(b==="user"?q.current.set(ge.name,ge.id):B.current.set(ge.name,ge.id));const De=Ne+Me+Ue;s(De),_(!1),A(null),k(""),setTimeout(()=>{if(p.current){const qe=Ne.length+Me.length;p.current.focus(),p.current.setSelectionRange(qe,qe)}},0)},he=ge=>{if(!(!y||ie.length===0))switch(ge.key){case"ArrowDown":ge.preventDefault(),L(Ne=>(Ne+1)%ie.length);break;case"ArrowUp":ge.preventDefault(),L(Ne=>(Ne-1+ie.length)%ie.length);break;case"Enter":ie[I]&&(ge.preventDefault(),ye(ie[I]));break;case"Escape":ge.preventDefault(),_(!1);break;case"Tab":ie[I]&&(ge.preventDefault(),ye(ie[I]));break}};return S.useEffect(()=>{const ge=Ne=>{f.current&&!f.current.contains(Ne.target)&&p.current&&!p.current.contains(Ne.target)&&_(!1)};return document.addEventListener("mousedown",ge),()=>document.removeEventListener("mousedown",ge)},[]),S.useEffect(()=>{if(!y)return;const ge=()=>{const Ne=p.current;if(!Ne)return;const Ue=Ne.getBoundingClientRect();V({top:Ue.bottom+4,left:Ue.left,width:Ue.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(gr,{ref:p,value:t,onChange:me,onKeyDown:ge=>{he(ge),ge.defaultPrevented||i==null||i(ge)},placeholder:r,className:Dt("resize-none",n),style:{minHeight:a}}),y&&ip.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"}),ae?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Searching..."}):ie.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:ie.map((ge,Ne)=>e.jsx("li",{className:Dt("flex items-center gap-2 px-3 py-2 cursor-pointer transition-colors",Ne===I?"bg-accent":"hover:bg-accent/50"),onClick:()=>ye(ge),onMouseEnter:()=>L(Ne),children:b==="user"?e.jsxs(e.Fragment,{children:[e.jsxs(wn,{className:"h-6 w-6",children:[e.jsx(Ma,{src:ge.avatar_url}),e.jsx(jn,{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(Fl,{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 sVt(t){const s=/#\[([^\]]+)\]\(([^)]+)\)/g,r=[];let n;for(;(n=s.exec(t))!==null;)r.push(n[2]);return[...new Set(r)]}const eDe=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]=S.useState(!1),[p,f]=S.useState(""),[y,_]=S.useState([]),b=Et({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=Et({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(wn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Ma,{src:t.user_avatar||void 0}),e.jsx(jn,{className:"text-xs",children:eDe(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(tVt,{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(wn,{className:"h-6 w-6 shrink-0 mt-1",children:[e.jsx(Ma,{src:n||void 0}),e.jsx(jn,{className:"text-xs",children:eDe((a==null?void 0:a.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2 items-start",children:[e.jsx(pce,{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(K,{size:"sm",variant:"ghost",onClick:w,disabled:!p.trim()||b.isPending,className:"h-8 px-2 mt-0.5",children:e.jsx(Mn,{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 Qz=[{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"}],rVt=()=>{const{user:t,isBrokerageManager:s,managedBrokerages:r,isAdmin:n}=qs(),{avatarUrl:a}=QZe(t==null?void 0:t.id),{onlineUsers:o}=eXe(),{toast:l}=ja(),i=Qt(),d=S.useRef(null),[u,p]=S.useState("all"),[f,y]=S.useState(""),[_,b]=S.useState(""),[N,w]=S.useState(""),[k,C]=S.useState([]),[A,I]=S.useState([]),[L,O]=S.useState(""),[V,q]=S.useState(!1),[B,U]=S.useState(null),[te,Y]=S.useState(""),[J,X]=S.useState(new Set),[ce,ae]=S.useState({}),[ie,oe]=S.useState({}),[me,ye]=S.useState([]),[he,ge]=S.useState([]),[Ne,Ue]=S.useState({open:!1,images:[],index:0});S.useEffect(()=>{if(u.startsWith("group:")){const Ze=u.replace("group:","");w(Ze),b("")}else u!=="all"?(b(u),w("")):(b(""),w(""))},[u]);const{data:Te=[]}=gt({queryKey:["community-categories"],queryFn:async()=>{const{data:Ze,error:Nt}=await G.from("community_categories").select("*").order("sort_order");if(Nt)throw Nt;return Ze}}),{data:Me=[]}=gt({queryKey:["community-private-groups"],queryFn:async()=>{const{data:Ze,error:Nt}=await G.from("community_private_groups").select("id, name, description, icon, brokerage_id, sort_order").order("sort_order");if(Nt)throw Nt;return Ze}}),De=20,{data:qe,isLoading:ke,hasNextPage:$e,fetchNextPage:Be,isFetchingNextPage:we}=zvt({queryKey:["community-posts",u],initialPageParam:0,queryFn:async({pageParam:Ze})=>{var Oe;const Nt=Ze*De,Ot=Nt+De;let Yt=G.from("community_posts").select("*").order("is_pinned",{ascending:!1}).order("pinned_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1}).range(Nt,Ot);if(u.startsWith("group:")){const Ye=u.replace("group:","");Yt=Yt.eq("private_group_id",Ye)}else u==="all"||(Yt=Yt.eq("category_id",u).is("private_group_id",null));const{data:Ps,error:$s}=await Yt;if($s)throw $s;const Zs=((Ps==null?void 0:Ps.length)||0)>De,Dr=(Ps||[]).slice(0,De);if(Dr.length===0)return{posts:[],hasMore:!1,nextPage:Ze+1};const $t=Dr.map(Ye=>Ye.id),Us=[...new Set(Dr.filter(Ye=>Ye.category_id).map(Ye=>Ye.category_id))].filter(Boolean),[Nr,Xs,kr,fn,Yr]=await Promise.all([Us.length?G.from("community_categories").select("*").in("id",Us):Promise.resolve({data:[]}),G.from("community_post_media").select("*").in("post_id",$t).order("sort_order"),G.from("community_reactions").select("*").in("post_id",$t),G.from("community_comments").select("*").in("post_id",$t).order("created_at",{ascending:!0}),G.from("community_post_resources").select("*").in("post_id",$t)]),$r=Nr==null?void 0:Nr.data,Gr=Xs==null?void 0:Xs.data,nr=kr==null?void 0:kr.data,lr=fn==null?void 0:fn.data,Fr=Yr==null?void 0:Yr.data,Wr=(lr||[]).map(Ye=>Ye.id),[Nn,ai]=await Promise.all([Wr.length?G.from("community_comment_reactions").select("*").in("comment_id",Wr):Promise.resolve({data:[]}),(()=>{const Ye=(Fr||[]).filter(yt=>yt.resource_type==="template").map(yt=>yt.resource_id);return Ye.length===0?Promise.resolve({data:[]}):G.from("canva_templates").select("id, name, preview_image_url").in("id",Ye)})()]),ns=(Nn==null?void 0:Nn.data)||[],$n=(ai==null?void 0:ai.data)||[],dn=new Map($n.map(Ye=>[Ye.id,{name:Ye.name,preview_image_url:Ye.preview_image_url}])),zr=Array.from(new Set([...Dr.map(Ye=>Ye.user_id),...(nr||[]).map(Ye=>Ye.user_id),...(lr||[]).map(Ye=>Ye.user_id),...ns.map(Ye=>Ye.user_id)])),[Kr,La]=await Promise.all([zr.length?G.from("profiles").select("id, name").in("id",zr):Promise.resolve({data:[]}),JZe(zr)]),Zt=new Map(((Oe=Kr==null?void 0:Kr.data)==null?void 0:Oe.map(Ye=>[Ye.id,Ye.name]))||[]),Er=new Map(($r||[]).map(Ye=>[Ye.id,Ye])),Bt=Ye=>{const yt=new Map,bt=[];return Ye.forEach(Tt=>{yt.set(Tt.id,{...Tt,user_name:Zt.get(Tt.user_id)||"Unknown User",user_avatar:La.get(Tt.user_id),reactions:ns.filter(Ht=>Ht.comment_id===Tt.id).map(Ht=>({...Ht,user_name:Zt.get(Ht.user_id)||"Unknown User",user_avatar:La.get(Ht.user_id)})),replies:[]})}),Ye.forEach(Tt=>{const Ht=yt.get(Tt.id);if(Tt.parent_comment_id&&yt.has(Tt.parent_comment_id)){const Ut=yt.get(Tt.parent_comment_id);Ut.replies=Ut.replies||[],Ut.replies.push(Ht)}else bt.push(Ht)}),bt};return{posts:Dr.map(Ye=>{const yt=(Fr||[]).filter(bt=>bt.post_id===Ye.id).map(bt=>{let Tt="",Ht=null;if(bt.resource_type==="template"){const Ut=dn.get(bt.resource_id);Tt=(Ut==null?void 0:Ut.name)||"Unknown Template",Ht=(Ut==null?void 0:Ut.preview_image_url)||null}return{id:bt.id,resource_type:bt.resource_type,resource_id:bt.resource_id,resource_name:Tt,resource_preview_url:Ht}});return{...Ye,user_name:Zt.get(Ye.user_id)||"Unknown User",user_avatar:La.get(Ye.user_id),category:Ye.category_id?Er.get(Ye.category_id):null,media:(Gr||[]).filter(bt=>bt.post_id===Ye.id),reactions:((nr||[]).filter(bt=>bt.post_id===Ye.id)||[]).map(bt=>({...bt,user_name:Zt.get(bt.user_id)||"Unknown User",user_avatar:La.get(bt.user_id)})),comments:Bt((lr||[]).filter(bt=>bt.post_id===Ye.id)),resources:yt}}),hasMore:Zs,nextPage:Ze+1}},getNextPageParam:Ze=>Ze.hasMore?Ze.nextPage:void 0}),ut=S.useMemo(()=>(qe==null?void 0:qe.pages.flatMap(Ze=>Ze.posts))??[],[qe]),fe=Et({mutationFn:async()=>{q(!0);const{data:Ze,error:Nt}=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(Nt)throw Nt;for(let Yt=0;Yt0){const Yt=me.filter(Ps=>Ps!==t.id).map(Ps=>({post_id:Ze.id,mentioned_user_id:Ps,mentioned_by_user_id:t.id}));Yt.length>0&&await G.from("community_post_mentions").insert(Yt)}const Ot=sVt(f);if(Ot.length>0){const Yt=Ot.map(Ps=>({post_id:Ze.id,resource_type:"template",resource_id:Ps}));await G.from("community_post_resources").insert(Yt)}return Ze},onSuccess:async Ze=>{var Nt;i.invalidateQueries({queryKey:["community-posts"]}),y(""),ye([]),ge([]),b(""),w(""),C([]),I([]),O(""),l({title:"Post created!"});try{const Ot=((Nt=t==null?void 0:t.user_metadata)==null?void 0:Nt.name)||"Someone",Yt=f.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),Ps=Yt.length>50?Yt.substring(0,50)+"...":Yt;await G.functions.invoke("send-push-notification",{body:{title:"New Community Post",body:`${Ot}: ${Ps}`,url:"/community"}})}catch(Ot){console.error("Failed to send push notification:",Ot)}},onError:Ze=>{l({title:"Error creating post",description:Ze.message,variant:"destructive"})},onSettled:()=>q(!1)}),He=Et({mutationFn:async({postId:Ze,content:Nt})=>{const{error:Ot}=await G.from("community_posts").update({content:Nt}).eq("id",Ze);if(Ot)throw Ot},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),U(null),Y(""),l({title:"Post updated!"})}}),et=Et({mutationFn:async Ze=>{const{error:Nt}=await G.from("community_posts").delete().eq("id",Ze);if(Nt)throw Nt},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:"Post deleted"})}}),tt=Et({mutationFn:async({postId:Ze,isPinned:Nt})=>{const{error:Ot}=await G.from("community_posts").update({is_pinned:!Nt,pinned_at:Nt?null:new Date().toISOString(),pinned_by:Nt?null:t==null?void 0:t.id}).eq("id",Ze);if(Ot)throw Ot},onSuccess:(Ze,{isPinned:Nt})=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:Nt?"Post unpinned":"Post pinned to top"})}}),_e=Et({mutationFn:async({postId:Ze,reactionType:Nt})=>{var Yt;const Ot=(Yt=ut.find(Ps=>Ps.id===Ze))==null?void 0:Yt.reactions.find(Ps=>Ps.user_id===(t==null?void 0:t.id));Ot?Ot.reaction_type===Nt?await G.from("community_reactions").delete().eq("id",Ot.id):await G.from("community_reactions").update({reaction_type:Nt}).eq("id",Ot.id):await G.from("community_reactions").insert({post_id:Ze,user_id:t.id,reaction_type:Nt})},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),Ge=Et({mutationFn:async({postId:Ze,content:Nt})=>{const{data:Ot,error:Yt}=await G.from("community_comments").insert({post_id:Ze,user_id:t.id,content:Nt}).select("id").single();if(Yt)throw Yt;const Ps=ie[Ze]||[];if(Ps.length>0&&Ot){const $s=Ps.filter(Zs=>Zs!==t.id).map(Zs=>({comment_id:Ot.id,mentioned_user_id:Zs,mentioned_by_user_id:t.id}));$s.length>0&&await G.from("community_comment_mentions").insert($s)}},onSuccess:(Ze,{postId:Nt})=>{i.invalidateQueries({queryKey:["community-posts"]}),ae(Ot=>({...Ot,[Nt]:""})),oe(Ot=>({...Ot,[Nt]:[]}))}});Et({mutationFn:async Ze=>{const{error:Nt}=await G.from("community_comments").delete().eq("id",Ze);if(Nt)throw Nt},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})});const We=Ze=>{const Nt=Array.from(Ze.target.files||[]);if(Nt.length+k.length>10){l({title:"Maximum 10 files allowed",variant:"destructive"});return}C(Ot=>[...Ot,...Nt]),Nt.forEach(Ot=>{const Yt=new FileReader;Yt.onloadend=()=>{I(Ps=>[...Ps,Yt.result])},Yt.readAsDataURL(Ot)})},it=Ze=>{C(Nt=>Nt.filter((Ot,Yt)=>Yt!==Ze)),I(Nt=>Nt.filter((Ot,Yt)=>Yt!==Ze))},Ve=Ze=>Ze.split(" ").map(Nt=>Nt[0]).join("").toUpperCase().slice(0,2),Xe=Ze=>{const Nt={};return Ze.forEach(Ot=>{Nt[Ot.reaction_type]=(Nt[Ot.reaction_type]||0)+1}),Nt},dt=Ze=>{var Nt;return(Nt=Ze.find(Ot=>Ot.user_id===(t==null?void 0:t.id)))==null?void 0:Nt.reaction_type},pt=Ze=>Ze.reduce((Nt,Ot)=>Nt+1+(Ot.replies?pt(Ot.replies):0),0),Je=Ze=>{if(n)return!0;if(!s||!Ze.private_group_id)return!1;const Nt=Me.find(Ot=>Ot.id===Ze.private_group_id);return Nt!=null&&Nt.brokerage_id?r.some(Ot=>Ot.id===Nt.brokerage_id):!1};return e.jsx(Es,{title:"Community",children:e.jsxs("div",{className:"flex gap-6 w-full isolate z-0",children:[e.jsx(zUt,{categories:Te,privateGroups:Me,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(BUt,{categories:Te,privateGroups:Me,selectedFilter:u,onFilterChange:p,onlineUsers:o}),e.jsx(Pe,{children:e.jsx(Re,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(wn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:a||void 0}),e.jsx(jn,{children:t!=null&&t.email?Ve(t.email.split("@")[0]):"U"})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(pce,{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:ye,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,Nt)=>{var Ot;return e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden bg-muted",children:[(Ot=k[Nt])!=null&&Ot.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(K,{variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>it(Nt),children:e.jsx(jr,{className:"h-3 w-3"})})]},Nt)})}),L&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(go,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Le,{value:L,onChange:Ze=>O(Ze.target.value),placeholder:"https://...",className:"flex-1"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>O(""),children:e.jsx(jr,{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:We,accept:"image/*,video/*",multiple:!0,className:"hidden"}),e.jsxs(K,{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(K,{variant:"ghost",size:"sm",onClick:()=>{var Ze;return(Ze=d.current)==null?void 0:Ze.click()},children:[e.jsx(gn,{className:"h-4 w-4 mr-1"}),"Video"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>O("https://"),children:[e.jsx(go,{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:[Me.length>0?e.jsxs(Fs,{value:N||_||"none",onValueChange:Ze=>{Ze==="none"?(b(""),w("")):Ze.startsWith("group:")?(w(Ze.replace("group:","")),b("")):(b(Ze),w(""))},children:[e.jsx(Ds,{className:"w-[130px] sm:w-[160px] h-8 text-xs sm:text-sm",children:e.jsx(zs,{placeholder:"Select..."})}),e.jsxs(Rs,{children:[e.jsx(vt,{value:"none",children:"No category"}),Te.map(Ze=>e.jsxs(vt,{value:Ze.id,children:[Ze.icon," ",Ze.name]},Ze.id)),Me.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"}),Me.map(Ze=>e.jsxs(vt,{value:`group:${Ze.id}`,children:[Ze.icon||"🔒"," ",Ze.name]},Ze.id))]})]})]}):e.jsxs(Fs,{value:_,onValueChange:b,children:[e.jsx(Ds,{className:"w-[110px] sm:w-[140px] h-8 text-xs sm:text-sm",children:e.jsx(zs,{placeholder:"Category"})}),e.jsx(Rs,{children:Te.map(Ze=>e.jsxs(vt,{value:Ze.id,children:[Ze.icon," ",Ze.name]},Ze.id))})]}),e.jsxs(K,{size:"sm",onClick:()=>fe.mutate(),disabled:!f.trim()||V,children:[e.jsx(Mn,{className:"h-4 w-4 mr-1"}),"Post"]})]})]})]})]})})}),ke?e.jsx("div",{className:"space-y-4",children:[...Array(3)].map((Ze,Nt)=>e.jsx(Pe,{children:e.jsx(Re,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(ks,{className:"h-10 w-10 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(ks,{className:"h-4 w-32"}),e.jsx(ks,{className:"h-4 w-full"}),e.jsx(ks,{className:"h-4 w-3/4"})]})]})})},Nt))}):ut.length===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center",children:[e.jsx(Ol,{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:[ut.map(Ze=>{var Nt,Ot,Yt,Ps;return e.jsx(Pe,{children:e.jsxs(Re,{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(wn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:Ze.user_avatar||void 0}),e.jsx(jn,{children:Ve(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)||Je(Ze))&&e.jsxs(Hd,{children:[e.jsx(Gd,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(Zp,{className:"h-4 w-4"})})}),e.jsxs(Nd,{align:"end",children:[Je(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:()=>et.mutate(Ze.id),children:[e.jsx(xr,{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(($s,Zs)=>{const Dr=Zs===3&&Ze.media.length>4,$t=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:()=>Ue({open:!0,images:Ze.media.map(Us=>({url:Us.media_url,type:Us.media_type==="video"?"video":"image"})),index:Zs}),children:[$s.media_type==="video"?e.jsx("video",{src:$s.media_url,className:"w-full h-full object-cover transition-transform group-hover:scale-105"}):e.jsx("img",{src:$s.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"})})})}),Dr&&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:["+",$t]})})]},$s.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:$s=>{$s.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(go,{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(Xe(Ze.reactions)).slice(0,3).map(([$s])=>{var Zs;return e.jsx("span",{className:"text-base",children:(Zs=Qz.find(Dr=>Dr.type===$s))==null?void 0:Zs.emoji},$s)})}),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(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"flex-1",children:[dt(Ze.reactions)?e.jsx("span",{className:"mr-1",children:(Nt=Qz.find($s=>$s.type===dt(Ze.reactions)))==null?void 0:Nt.emoji}):e.jsx(Bu,{className:"h-4 w-4 mr-1"}),dt(Ze.reactions)?(Ot=Qz.find($s=>$s.type===dt(Ze.reactions)))==null?void 0:Ot.label:"Like"]})}),e.jsx(uo,{className:"w-auto p-2",side:"top",children:e.jsx("div",{className:"flex gap-1",children:Qz.map($s=>e.jsx("button",{onClick:()=>_e.mutate({postId:Ze.id,reactionType:$s.type}),className:"text-2xl hover:scale-125 transition-transform p-1",title:$s.label,children:$s.emoji},$s.type))})})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"flex-1",onClick:()=>X($s=>{const Zs=new Set($s);return Zs.has(Ze.id)?Zs.delete(Ze.id):Zs.add(Ze.id),Zs}),children:[e.jsx(Ol,{className:"h-4 w-4 mr-1"}),(()=>{const $s=pt(Ze.comments);return $s>0?`Comment (${$s})`:"Comment"})()]})]}),J.has(Ze.id)&&e.jsxs("div",{className:"space-y-3 mt-3",children:[Ze.comments.map($s=>e.jsx(dtt,{comment:$s,postId:Ze.id,currentUserId:t==null?void 0:t.id,currentUserAvatar:a,currentUserEmail:t==null?void 0:t.email,canModerate:Je(Ze)},$s.id)),t&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(wn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:a||void 0}),e.jsx(jn,{className:"text-xs",children:Ve(((Yt=t.email)==null?void 0:Yt.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2",children:[e.jsx(pce,{placeholder:"Write a comment... (use @ to mention)",value:ce[Ze.id]||"",onChange:$s=>ae(Zs=>({...Zs,[Ze.id]:$s})),onMentionsChange:$s=>oe(Zs=>({...Zs,[Ze.id]:$s})),mentionFormat:"plain",onKeyDown:$s=>{var Zs;$s.defaultPrevented||$s.key==="Enter"&&!$s.shiftKey&&((Zs=ce[Ze.id])!=null&&Zs.trim())&&($s.preventDefault(),Ge.mutate({postId:Ze.id,content:ce[Ze.id]}))},className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{var $s;($s=ce[Ze.id])!=null&&$s.trim()&&Ge.mutate({postId:Ze.id,content:ce[Ze.id]})},disabled:!((Ps=ce[Ze.id])!=null&&Ps.trim()),className:"h-8 px-2 mt-0.5",children:e.jsx(Mn,{className:"h-4 w-4"})})]})]})]})]})},Ze.id)}),$e&&e.jsx("div",{className:"flex justify-center pt-2",children:e.jsx(K,{variant:"outline",onClick:()=>Be(),disabled:we,children:we?"Loading…":"Load more posts"})})]}),e.jsx(fs,{open:!!B,onOpenChange:()=>U(null),children:e.jsxs(hs,{children:[e.jsx(js,{children:e.jsx(_s,{children:"Edit Post"})}),e.jsx(gr,{value:te,onChange:Ze=>Y(Ze.target.value),className:"min-h-[120px]"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>U(null),children:"Cancel"}),e.jsx(K,{onClick:()=>{B&&He.mutate({postId:B.id,content:te})},disabled:!te.trim(),children:"Save Changes"})]})]})}),e.jsx(eVt,{images:Ne.images,initialIndex:Ne.index,open:Ne.open,onOpenChange:Ze=>Ue(Nt=>({...Nt,open:Ze}))})]})]})})},w5={open:{label:"Open",icon:on,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:Ol,color:"bg-blue-500"},resolved:{label:"Resolved",icon:ti,color:"bg-green-500"},closed:{label:"Closed",icon:Ql,color:"bg-muted-foreground"}},tDe={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function nVt(){const{user:t}=qs(),s=Qt(),[r,n]=S.useState(null),[a,o]=S.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=Et({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(Es,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>n(null),children:e.jsx(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:tDe[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(Lt,{children:e.jsxs(ur,{children:["Created on ",gs(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(Re,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"Conversation"})}),e.jsxs(Re,{children:[e.jsx(ni,{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:gs(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(xo,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(gr,{placeholder:"Type your reply...",value:a,onChange:y=>o(y.target.value),className:"min-h-[80px]"}),e.jsx(K,{onClick:p,disabled:!a.trim()||u.isPending,className:"self-end",children:e.jsx(Mn,{className:"h-4 w-4"})})]})]})]})]})]})})}return e.jsx(Es,{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(Re,{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(K,{size:"lg",className:"gap-2",children:[e.jsx(Bs,{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(K,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(Bs,{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(Re,{className:"text-center py-12",children:[e.jsx(Ol,{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(Re,{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:tDe[f.category]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:gs(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 aVt({open:t,onOpenChange:s}){return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(hs,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(js,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(ln,{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 iVt({open:t,onOpenChange:s}){const{brokerageId:r}=qs(),[n,a]=S.useState(""),[o,l]=S.useState([]),[i,d]=S.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(k=>k!==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(hs,{className:"max-w-md",children:[e.jsx(js,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(Mn,{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(an,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search agents...",value:n,onChange: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(or,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No agents found"})]}):e.jsx(ni,{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(Hi,{checked:o.includes(N.id),onCheckedChange:()=>y(N.id)}),e.jsx(wn,{className:"h-8 w-8",children:e.jsx(jn,{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(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>b(!1),children:"Cancel"}),e.jsx(K,{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(Mn,{className:"h-4 w-4 mr-2"}),"Send Link"]})})]})]})})}function oVt(){const[t,s]=S.useState(!1),[r,n]=S.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{className:"mb-8",children:[e.jsx(Lt,{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(or,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ft,{children:"Agent Onboarding"}),e.jsx(ur,{children:"Schedule onboarding sessions for yourself or your agents"})]})]})}),e.jsx(Re,{children:e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsxs(K,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx(ln,{className:"h-4 w-4"}),"Schedule Agent Onboarding"]}),e.jsxs(K,{variant:"outline",onClick:()=>n(!0),className:"flex items-center gap-2",children:[e.jsx(Mn,{className:"h-4 w-4"}),"Send New Agent Onboarding Link"]})]})})]}),e.jsx(aVt,{open:t,onOpenChange:s}),e.jsx(iVt,{open:r,onOpenChange:n})]})}function lVt({open:t,onOpenChange:s}){return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(hs,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(js,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(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 cVt(){const[t,s]=S.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{className:"mb-8",children:[e.jsx(Lt,{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(Ft,{children:"Launch or ReLaunch Meeting"}),e.jsx(ur,{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(Re,{children:e.jsxs(K,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx(e0,{className:"h-4 w-4"}),"Schedule Launch Meeting"]})})]}),e.jsx(lVt,{open:t,onOpenChange:s})]})}function dVt(){const t=vr(),[s,r]=S.useState(""),[n,a]=S.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())),k=!n||N.category_id===n;return w&&k}),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,k=(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:k,linkCount:C}},b=N=>{t(`/brokerage-resources/${N}`)};return e.jsx(Es,{title:"Brokerage Resources",description:"Access exclusive resources for brokerage managers",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oVt,{}),e.jsx(cVt,{}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(an,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search resources...",value:s,onChange: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(ks,{className:"h-40 w-full"}),e.jsx(Lt,{children:e.jsx(ks,{className:"h-5 w-3/4"})}),e.jsxs(Re,{children:[e.jsx(ks,{className:"h-4 w-full mb-2"}),e.jsx(ks,{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:k,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(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(Ft,{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(Re,{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(yn,{className:"h-4 w-4"}),w]}),k>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(gn,{className:"h-4 w-4"}),k]}),C>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(go,{className:"h-4 w-4"}),C]})]})]})]},N.id)})})]})})}const uVt=()=>{const{resourceId:t}=ao(),{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(Es,{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(Es,{title:s.title,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(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(Re,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(gn,{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(Re,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(yn,{className:"h-4 w-4"}),"Documents (",s.pdfs.length,")"]}),e.jsx("div",{className:"grid gap-2",children:s.pdfs.map(a=>e.jsxs("a",{href:a.file_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(yn,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:a.name}),a.file_size&&e.jsx("div",{className:"text-xs text-muted-foreground",children:n(a.file_size)})]})]}),e.jsx(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(Re,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Zr,{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(Zr,{className:"h-4 w-4 text-primary"})}),e.jsx("div",{className:"font-medium text-sm",children:a.title})]}),e.jsx(Zr,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},a.id))})]})})]})}):e.jsx(Es,{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(K,{asChild:!0,className:"mt-4",children:e.jsx(da,{to:"/brokerage-resources",children:"Back to Resources"})})]})})};function hVt(){const{onlineUsers:t,totalOnline:s}=eXe();return e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(or,{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(Re,{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(ni,{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(wn,{className:"h-9 w-9",children:[e.jsx(Ma,{src:r.avatarUrl,alt:r.name}),e.jsx(jn,{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 sDe={users:{label:"Users & Access",sections:[{title:"Members",description:"Manage users, roles, and brokerage assignments",icon:or,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:_d,path:"/admin/referrals",color:"bg-teal-500/10 text-teal-600"},{title:"Teams",description:"Manage agent teams across all brokerages",icon:or,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:Fl,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:yd,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:yi,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:Vi,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:or,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:Si,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:Sn,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:yn,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:yn,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 rDe(){const t=vr();return console.log("[AdminDashboard] render"),e.jsx(Es,{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(hVt,{})})]}),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(sDe).map(([s,r])=>e.jsx(ls,{value:s,className:"data-[state=active]:bg-background",children:r.label},s))}),Object.entries(sDe).map(([s,r])=>e.jsx(ws,{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(Lt,{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(Ft,{className:"text-base",children:n.title})]}),e.jsx(Re,{className:"pt-0",children:e.jsx(ur,{className:"text-sm",children:n.description})})]},n.path))})},s))]})]})})}const Ln=S.forwardRef(({className:t,...s},r)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:r,className:Dt("w-full caption-bottom text-sm",t),...s})}));Ln.displayName="Table";const Dn=S.forwardRef(({className:t,...s},r)=>e.jsx("thead",{ref:r,className:Dt("[&_tr]:border-b",t),...s}));Dn.displayName="TableHeader";const Rn=S.forwardRef(({className:t,...s},r)=>e.jsx("tbody",{ref:r,className:Dt("[&_tr:last-child]:border-0",t),...s}));Rn.displayName="TableBody";const mVt=S.forwardRef(({className:t,...s},r)=>e.jsx("tfoot",{ref:r,className:Dt("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...s}));mVt.displayName="TableFooter";const Ms=S.forwardRef(({className:t,...s},r)=>e.jsx("tr",{ref:r,className:Dt("border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50",t),...s}));Ms.displayName="TableRow";const kt=S.forwardRef(({className:t,...s},r)=>e.jsx("th",{ref:r,className:Dt("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...s}));kt.displayName="TableHead";const ht=S.forwardRef(({className:t,...s},r)=>e.jsx("td",{ref:r,className:Dt("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...s}));ht.displayName="TableCell";const pVt=S.forwardRef(({className:t,...s},r)=>e.jsx("caption",{ref:r,className:Dt("mt-4 text-sm text-muted-foreground",t),...s}));pVt.displayName="TableCaption";const fVt=()=>{const{isAdmin:t}=qs(),s=vr(),[r,n]=S.useState([]),[a,o]=S.useState(!0),[l,i]=S.useState(!1),[d,u]=S.useState(null);S.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),k={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(k).eq("id",d.id);if(C)throw C;pe.success("App updated successfully")}else{const{error:C}=await G.from("app_tiles").insert([k]);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(K,{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(hi,{asChild:!0,children:e.jsxs(K,{onClick:b,children:[e.jsx(Bs,{className:"mr-2 h-4 w-4"}),"Add App"]})}),e.jsxs(hs,{className:"max-w-2xl",children:[e.jsxs(js,{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(Le,{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(Le,{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(gr,{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(Le,{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(Le,{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(Le,{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(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{type:"submit",children:d?"Update":"Create"})]})]})]})]})]})})}),e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsx(Ft,{children:"Application Tiles"}),e.jsx(ur,{children:"Manage the apps that appear on the member dashboard"})]}),e.jsx(Re,{children:r.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No apps configured yet"}),e.jsxs(K,{onClick:b,children:[e.jsx(Bs,{className:"mr-2 h-4 w-4"}),"Create First App"]})]}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ms,{children:[e.jsx(kt,{children:"Icon"}),e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"App ID"}),e.jsx(kt,{children:"Target URL"}),e.jsx(kt,{children:"Tags"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:r.map(N=>e.jsxs(Ms,{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(K,{size:"sm",variant:"ghost",onClick:()=>_(N),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>y(N.id),children:e.jsx(xr,{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(K,{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 nDe=({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:Dt("gap-1",s),children:[e.jsx(Dc,{className:"h-3 w-3"}),"Trial Expired"]}):a<=1?e.jsxs(Qe,{variant:"destructive",className:Dt("gap-1",s),children:[e.jsx(on,{className:"h-3 w-3"}),"Trial: <1 day left"]}):a<=3?e.jsxs(Qe,{className:Dt("gap-1 bg-amber-500 hover:bg-amber-600",s),children:[e.jsx(on,{className:"h-3 w-3"}),"Trial: ",a," days left"]}):e.jsxs(Qe,{variant:"secondary",className:Dt("gap-1",s),children:[e.jsx(on,{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=S.useRef(null),[i,d]=S.useState([]),[u,p]=S.useState(""),[f,y]=S.useState(!1),[_,b]=S.useState("upload"),[N,w]=S.useState(null),k=()=>{d([]),p(""),b("upload"),w(null),l.current&&(l.current.value="")},C=()=>{k(),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 ae=(X.includes(" ")?X.split(" "):X.split(",")).map(ie=>ie.trim().replace(/^["']|["']$/g,""));if(ae.length>=2){let ie="",oe="",me="",ye="",he;if(ae.length===2){const Ue=ae[0].split(" ");ie=Ue[0]||"",oe=Ue.slice(1).join(" ")||"",me=ae[1]}else if(ae.length===3)ie=ae[0],oe=ae[1],me=ae[2];else if(ae.length===4)ie=ae[0],oe=ae[1],me=ae[2],ye=ae[3];else if(ae.length>=5){ie=ae[0],oe=ae[1],me=ae[2],ye=ae[3];const Ue=ae[4].toLowerCase();he=Ue==="true"||Ue==="yes"||Ue==="1"||Ue==="y"}const Ne=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(me);J.push({firstName:ie.trim(),lastName:oe.trim(),email:me.trim().toLowerCase(),phone:ye.trim()||void 0,smsConsent:he,isValid:Ne&&ie.trim().length>0,error:Ne?ie.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(hs,{className:"max-w-2xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(js,{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(K,{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(Fs,{value:u||"none",onValueChange:q=>p(q==="none"?"":q),children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select a brokerage..."})}),e.jsxs(Rs,{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(Hn,{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(Ms,{className:"bg-muted/30",children:[e.jsx(kt,{children:"First Name"}),e.jsx(kt,{children:"Last Name"}),e.jsx(kt,{children:"Email"}),e.jsx(kt,{children:"Phone"}),e.jsx(kt,{children:"SMS"}),e.jsx(kt,{children:"Status"})]})}),e.jsx(Rn,{children:i.slice(0,100).map((q,B)=>e.jsxs(Ms,{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(Hn,{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(_n,{children:[_==="upload"&&e.jsx(K,{variant:"outline",onClick:C,children:"Cancel"}),_==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:k,children:"Back"}),e.jsx(K,{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(K,{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(kt,{className:Dt("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]=S.useState(t),[a,o]=S.useState(s),l=S.useCallback(d=>{r===d?a==="asc"?o("desc"):a==="desc"?(n(null),o(null)):o("asc"):(n(d),o("asc"))},[r,a]),i=S.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 xVt=[{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:Vi},{type:"custom",title:"Congratulations!",message:"You earned this celebration!",icon:qd}];function htt({open:t,onOpenChange:s,userId:r,userName:n}){const[a,o]=S.useState("custom"),[l,i]=S.useState(""),[d,u]=S.useState(""),p=fNt(),f=_=>{o(_.type),i(_.title),u(_.message)},y=async _=>{if(_.preventDefault(),!l.trim()){pn({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}),pn({title:"Celebration sent! 🎉",description:`${n} will see confetti on their next visit!`}),s(!1),i(""),u(""),o("custom")}catch{pn({title:"Error",description:"Failed to send celebration",variant:"destructive"})}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(hs,{className:"sm:max-w-md",children:[e.jsxs(js,{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:xVt.map((_,b)=>e.jsxs(K,{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(Fs,{value:a,onValueChange:_=>o(_),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Vi,{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(Sn,{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(Le,{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(gr,{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(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:p.isPending,children:[e.jsx(qd,{className:"h-4 w-4 mr-2"}),p.isPending?"Sending...":"Send Celebration"]})]})]})]})})}const kye={points_earned:{label:"Points Earned",icon:Vi,color:"bg-yellow-500"},listing_created:{label:"Listing Created",icon:Sn,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 gVt(){const[t,s]=S.useState(""),[r,n]=S.useState("all"),[a,o]=S.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,k,C;return{...N,user_name:((w=b.get(N.user_id))==null?void 0:w.name)||"Unknown",user_email:((k=b.get(N.user_id))==null?void 0:k.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(kye).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(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium",children:"Total Celebrations"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:u.total})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-green-600",children:"Seen"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold text-green-600",children:u.seen})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-orange-600",children:"Pending"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold text-orange-600",children:u.unseen})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-purple-600",children:"Custom Sent"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold text-purple-600",children:u.byType.custom||0})})]})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(qd,{className:"h-5 w-5"}),"Celebration History"]}),e.jsx(ur,{children:"View all celebrations awarded to agents"})]}),e.jsxs(Re,{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(an,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by agent name, email, or title...",value:t,onChange:p=>s(p.target.value),className:"pl-9"})]}),e.jsxs(Fs,{value:r,onValueChange:n,children:[e.jsx(Ds,{className:"w-[180px]",children:e.jsx(zs,{placeholder:"Filter by type"})}),e.jsxs(Rs,{children:[e.jsx(vt,{value:"all",children:"All Types"}),Object.entries(kye).map(([p,f])=>e.jsx(vt,{value:p,children:f.label},p))]})]}),e.jsxs(Fs,{value:a,onValueChange:o,children:[e.jsx(Ds,{className:"w-[140px]",children:e.jsx(zs,{placeholder:"Status"})}),e.jsxs(Rs,{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(Ms,{children:[e.jsx(kt,{children:"Type"}),e.jsx(kt,{children:"Agent"}),e.jsx(kt,{children:"Title"}),e.jsx(kt,{children:"Points"}),e.jsx(kt,{children:"Created By"}),e.jsx(kt,{children:"Created"}),e.jsx(kt,{children:"Status"})]})}),e.jsx(Rn,{children:d.length===0?e.jsx(Ms,{children:e.jsx(ht,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No celebrations found"})}):d.map(p=>{const f=kye[p.celebration_type],y=f.icon;return e.jsxs(Ms,{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:gs(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 yVt=()=>{const{user:t}=qs(),{toast:s}=ja(),[r,n]=S.useState([]),[a,o]=S.useState(!0),[l,i]=S.useState(!1),[d,u]=S.useState("all"),[p,f]=S.useState("all"),[y,_]=S.useState("new"),[b,N]=S.useState(new Set),w=S.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:ae}=await G.from("trial_email_exports").select("user_id");if(ae)throw ae;const ie=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:ie.has(me.id)}));oe.sort((me,ye)=>new Date(ye.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]);S.useEffect(()=>{w()},[w]);const k=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"&&k(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(" "),Ne=ge[0]||"",Ue=ge.slice(1).join(" ")||"",Te=k(he)==="stripe"?"Credit Card Trial":"Free Trial (No CC)",Me=A(he)?"Converted":I(he)?"Expired":"Active",De=he.created_at?new Date(he.created_at).toLocaleDateString():"",qe=C(he)?new Date(C(he)).toLocaleDateString():"";return`"${Ne}","${Ue}","${he.email}","${he.phone||""}","${Te}","${Me}","${De}","${qe}"`}),ae=[X,...ce].join(` `),ie=new Blob([ae],{type:"text/csv"}),oe=URL.createObjectURL(ie),me=document.createElement("a");me.href=oe,me.download=`trial-users-${new Date().toISOString().split("T")[0]}.csv`,me.click(),URL.revokeObjectURL(oe);const ye=J.filter(he=>!he.already_exported).map(he=>({user_id:he.id,exported_by:t.id}));if(ye.length>0){const{error:he}=await G.from("trial_email_exports").upsert(ye,{onConflict:"user_id"});he&&console.error("Error marking exports:",he)}s({title:"Export complete",description:`Downloaded ${J.length} trial user(s). ${ye.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(Lt,{className:"pb-2",children:[e.jsx(ur,{children:"Total"}),e.jsx(Ft,{className:"text-2xl",children:r.length})]})}),e.jsx(Pe,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(ur,{children:"New (Not Exported)"}),e.jsx(Ft,{className:"text-2xl text-green-600",children:B})]})}),e.jsx(Pe,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(ur,{children:"Active Trials"}),e.jsx(Ft,{className:"text-2xl",children:Y})]})}),e.jsx(Pe,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(ur,{children:"Converted 🎉"}),e.jsx(Ft,{className:"text-2xl text-primary",children:te})]})}),e.jsx(Pe,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(ur,{children:"Already Exported"}),e.jsx(Ft,{className:"text-2xl text-muted-foreground",children:U})]})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(Fs,{value:y,onValueChange:J=>_(J),children:[e.jsx(Ds,{className:"w-[160px]",children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Fs,{value:d,onValueChange:J=>u(J),children:[e.jsx(Ds,{className:"w-[180px]",children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Fs,{value:p,onValueChange:J=>f(J),children:[e.jsx(Ds,{className:"w-[160px]",children:e.jsx(zs,{})}),e.jsxs(Rs,{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(K,{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(Ms,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(kt,{className:"w-[40px]",children:e.jsx(Hi,{checked:L.length>0&&b.size===L.length,onCheckedChange:O})}),e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Email"}),e.jsx(kt,{children:"Trial Type"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{children:"Signup Date"}),e.jsx(kt,{children:"Expires / Renews"}),e.jsx(kt,{children:"Exported"})]})}),e.jsx(Rn,{children:L.length===0?e.jsx(Ms,{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=k(J),ce=A(J),ae=I(J),ie=C(J);return e.jsxs(Ms,{className:`hover:bg-muted/30 ${ce?"bg-primary/5":""}`,children:[e.jsx(ht,{children:e.jsx(Hi,{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"]}):ae?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&&ie?e.jsxs("span",{className:"text-muted-foreground",children:["Renews ",new Date(ie).toLocaleDateString()]}):ie?new Date(ie).toLocaleDateString():"—"}),e.jsx(ht,{children:J.already_exported?e.jsx(Hn,{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"]})]})},vVt=()=>{const[t,s]=S.useState([]),[r,n]=S.useState(!0);return S.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(Re,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(xr,{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(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"User Deletion History"})}),e.jsx(Re,{children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ms,{children:[e.jsx(kt,{children:"Date"}),e.jsx(kt,{children:"User"}),e.jsx(kt,{children:"Email"}),e.jsx(kt,{children:"Brokerage"}),e.jsx(kt,{children:"Type"}),e.jsx(kt,{children:"Deleted By"})]})}),e.jsx(Rn,{children:t.map(a=>e.jsxs(Ms,{children:[e.jsx(ht,{className:"whitespace-nowrap text-sm",children:gs(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}=qs(),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(k=>k.user_id),{data:N}=await G.from("profiles").select("id, name, email, avatar_url").in("id",b),w=new Map((N||[]).map(k=>[k.id,k]));return(y||[]).map(k=>({...k,profile:w.get(k.user_id)||null}))},enabled:!!f}),o=Et({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=Et({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=Et({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=Et({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=Et({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=Et({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}},_Vt=()=>{const{user:t}=qs();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}=qs(),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(k=>k.contact_id),p=[...new Set(i.map(k=>k.added_by))],f=i.filter(k=>k.claimed_by).map(k=>k.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(k=>[k.id,k])),w=new Map((b.data||[]).map(k=>[k.id,k]));return i.map(k=>({...k,status:k.claimed_by?"claimed":"available",contact:N.get(k.contact_id)||null,contributor:w.get(k.added_by)||null,claimer:k.claimed_by&&w.get(k.claimed_by)||null}))},enabled:!!t&&!!s}),a=Et({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=Et({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=Et({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}},bVt=()=>{const t=Qt();return Et({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}=qs(),{data:l}=Px(),{useTeamMembers:i}=TC(),{data:d=[]}=i((l==null?void 0:l.teamId)||""),u=bVt(),[p,f]=S.useState(null),[y,_]=S.useState(""),[b,N]=S.useState(!1),w=d.filter(O=>O.user_id!==(o==null?void 0:o.id)),k=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(hs,{className:"sm:max-w-md",children:[e.jsxs(js,{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(wn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:((V=O.profile)==null?void 0:V.avatar_url)||""}),e.jsx(jn,{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(gr,{id:"transfer-notes",value:y,onChange:O=>_(O.target.value),placeholder:"Reason for transfer...",className:"mt-1",rows:2})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:k,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=vr(),{data:s,isLoading:r}=_Vt(),{data:n}=Px(),[a,o]=S.useState(""),[l,i]=S.useState("all"),[d,u]=S.useState(null),[p,f]=S.useState(""),y=(n==null?void 0:n.role)==="team_leader",_=S.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=S.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(k=>{var C,A,I;return(k.first_name+" "+(k.last_name||"")).toLowerCase().includes(w)||((C=k.email)==null?void 0:C.toLowerCase().includes(w))||((A=k.phone)==null?void 0:A.includes(w))||((I=k.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(ks,{className:"h-10 w-full"}),e.jsx(ks,{className:"h-64 w-full"})]}):!s||s.length===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(or,{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(Re,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name, email, phone, or agent...",value:a,onChange:N=>o(N.target.value),className:"pl-9"})]}),e.jsxs(Fs,{value:l,onValueChange:i,children:[e.jsx(Ds,{className:"w-[200px]",children:e.jsx(zs,{placeholder:"Filter by agent"})}),e.jsxs(Rs,{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(Re,{className:"p-0 overflow-x-auto",children:e.jsxs(Ln,{className:"min-w-[800px]",children:[e.jsx(Dn,{children:e.jsxs(Ms,{children:[e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Agent"}),e.jsx(kt,{children:"Contact Info"}),e.jsx(kt,{children:"Address"}),e.jsx(kt,{children:"Lead Source"}),e.jsx(kt,{children:"Date Added"}),y&&e.jsx(kt,{className:"w-[80px]",children:"Actions"})]})}),e.jsx(Rn,{children:b.length===0?e.jsx(Ms,{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(Ms,{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(wn,{className:"h-6 w-6",children:[e.jsx(Ma,{src:N.owner_avatar_url||""}),e.jsx(jn,{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:gs(new Date(N.created_at),"MMM d, yyyy")})}),y&&e.jsx(ht,{children:e.jsx(K,{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}=qs(),{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(ks,{className:"h-20 w-full"},d))});if(r.length===0)return e.jsx(Pe,{children:e.jsxs(Re,{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(Re,{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(wn,{className:"h-4 w-4",children:[e.jsx(Ma,{src:((_=d.contributor)==null?void 0:_.avatar_url)||""}),e.jsx(jn,{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(K,{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(Re,{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(K,{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(ks,{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(Re,{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(Re,{className:"flex items-center gap-3 p-4",children:[e.jsx(Sn,{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(Re,{className:"flex items-center gap-3 p-4",children:[e.jsx(gn,{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(ls,{value:"presentations",children:["Presentations (",o.length,")"]}),e.jsxs(ls,{value:"guest-books",children:["Guest Books (",i.length,")"]}),e.jsxs(ls,{value:"videos",children:["Videos (",u.length,")"]})]}),e.jsx(ws,{value:"presentations",className:"space-y-2",children:o.length===0?e.jsx(Sye,{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(Re,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(wn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Ma,{src:b.avatar}),e.jsx(jn,{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," · ",gs(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(Cn,{className:"h-3 w-3"}),_.view_count||0]})]})]})},_.id)})}),e.jsx(ws,{value:"guest-books",className:"space-y-2",children:i.length===0?e.jsx(Sye,{icon:e.jsx(Sn,{className:"h-10 w-10"}),label:"No guest books yet"}):i.map(_=>{const b=y(_.agent_id);return e.jsx(Pe,{children:e.jsxs(Re,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(wn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Ma,{src:b.avatar}),e.jsx(jn,{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," · ",gs(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(or,{className:"h-3 w-3"}),_.visitor_count||0]})]})]})},_.id)})}),e.jsx(ws,{value:"videos",className:"space-y-2",children:u.length===0?e.jsx(Sye,{icon:e.jsx(gn,{className:"h-10 w-10"}),label:"No videos yet"}):u.map(_=>{const b=y(_.owner_user_id);return e.jsx(Pe,{children:e.jsxs(Re,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(wn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Ma,{src:b.avatar}),e.jsx(jn,{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," · ",gs(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(Cn,{className:"h-3 w-3"}),_.view_count||0]})]})]})},_.id)})})]})]})},Sye=({icon:t,label:s})=>e.jsx(Pe,{children:e.jsxs(Re,{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]=S.useState(!1),[N,w]=S.useState(""),[k,C]=S.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,k),w(""),C("team_member"),b(!1))};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(K,{variant:"ghost",onClick:r,className:"mb-2",children:"← Back to Teams"}),e.jsxs(ta,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(Jn,{children:[e.jsx(ls,{value:"members",children:"Members"}),e.jsxs(ls,{value:"contacts",children:[e.jsx(Q4,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),t.lead_pond_enabled&&e.jsxs(ls,{value:"lead-pond",children:[e.jsx(Ag,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),t.shared_assets_enabled&&e.jsxs(ls,{value:"shared-assets",children:[e.jsx(Mm,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]}),e.jsx(ls,{value:"settings",children:"Settings"})]}),e.jsxs(ws,{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(hi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Jo,{className:"mr-2 h-4 w-4"}),"Add Member"]})}),e.jsxs(hs,{children:[e.jsxs(js,{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(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{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(uo,{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(lp,{value:B.name||B.email||B.id,disabled:!!U,onSelect:()=>w(B.id),children:[e.jsx(Zn,{className:Dt("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(Fs,{value:k,onValueChange:C,children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsxs(Rs,{children:[e.jsx(vt,{value:"team_leader",children:"Team Leader"}),e.jsx(vt,{value:"team_member",children:"Team Member"})]})]})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>b(!1),children:"Cancel"}),e.jsx(K,{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(ks,{className:"h-16 w-full"},B))}):f.length===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(or,{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(Re,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(wn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:((U=B.profile)==null?void 0:U.avatar_url)||""}),e.jsx(jn,{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(Fs,{value:B.role,onValueChange:ce=>l(B.id,ce),children:[e.jsx(Ds,{className:"w-[140px]",children:e.jsx(zs,{})}),e.jsxs(Rs,{children:[e.jsx(vt,{value:"team_leader",children:"Team Leader"}),e.jsx(vt,{value:"team_member",children:"Team Member"})]})]}),e.jsxs(Dl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{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(ws,{value:"contacts",className:"space-y-4",children:e.jsx(m4e,{})}),t.lead_pond_enabled&&e.jsx(ws,{value:"lead-pond",className:"space-y-4",children:e.jsx(p4e,{teamId:t.id})}),t.shared_assets_enabled&&e.jsx(ws,{value:"shared-assets",className:"space-y-4",children:e.jsx(ftt,{teamId:t.id})}),e.jsxs(ws,{value:"settings",className:"space-y-4",children:[e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsx(Ft,{className:"text-lg",children:"Team Settings"}),e.jsx(ur,{children:"Configure how this team operates."})]}),e.jsxs(Re,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Team Name"}),e.jsx(Le,{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(gr,{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(Fs,{defaultValue:t.contact_visibility,onValueChange:B=>n({contact_visibility:B}),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Mr,{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(Mr,{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(Mr,{checked:t.shared_videos_enabled??!1,onCheckedChange:B=>n({shared_videos_enabled:B})})]})]})]}),e.jsxs(Dl,{children:[e.jsx(_m,{asChild:!0,children:e.jsxs(K,{variant:"destructive",size:"sm",children:[e.jsx(xr,{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]=S.useState(1),[p,f]=S.useState(""),[y,_]=S.useState(""),[b,N]=S.useState(""),[w,k]=S.useState(""),[C,A]=S.useState([]),I=()=>{u(1),f(""),_(""),N(""),k(""),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(hs,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[e.jsxs(js,{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:Dt("h-1.5 flex-1 rounded-full transition-colors","bg-primary")}),e.jsx("div",{className:Dt("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(Le,{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(gr,{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(Fs,{value:b,onValueChange:N,children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"No brokerage (independent team)"})}),e.jsxs(Rs,{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(Fs,{value:w,onValueChange:B=>{k(B),A(U=>U.filter(te=>te!==B))},children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select a team leader (optional)"})}),e.jsxs(Rs,{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(or,{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:Dt("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(wn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:B.avatar_url||""}),e.jsx(jn,{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:Dt("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(_n,{className:"gap-2 sm:gap-0",children:d===1?e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>u(2),disabled:!p.trim(),children:["Next",e.jsx(Ga,{className:"ml-2 h-4 w-4"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",onClick:()=>u(1),children:[e.jsx(Oa,{className:"mr-2 h-4 w-4"}),"Back"]}),e.jsx(K,{onClick:O,disabled:n,children:n?"Creating…":"Create Team"})]})})]})})},wVt=()=>{const{teams:t,isLoading:s,createTeam:r,updateTeam:n,deleteTeam:a,addMember:o,removeMember:l,updateMemberRole:i}=TC(),[d,u]=S.useState(!1),[p,f]=S.useState(null),[y,_]=S.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:k}=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:k||[],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(an,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search teams...",value: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(K,{size:"sm",onClick:()=>u(!0),children:[e.jsx(Bs,{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(Ms,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(kt,{className:"font-semibold",children:"Team Name"}),e.jsx(kt,{className:"font-semibold",children:"Brokerage"}),e.jsx(kt,{className:"font-semibold",children:"Leader"}),e.jsx(kt,{className:"font-semibold",children:"Members"}),e.jsx(kt,{className:"font-semibold",children:"Visibility"}),e.jsx(kt,{className:"w-[100px]"})]})}),e.jsx(Rn,{children:s?e.jsx(e.Fragment,{children:[1,2,3].map(L=>e.jsxs(Ms,{children:[e.jsx(ht,{children:e.jsx(ks,{className:"h-4 w-32"})}),e.jsx(ht,{children:e.jsx(ks,{className:"h-4 w-24"})}),e.jsx(ht,{children:e.jsx(ks,{className:"h-4 w-28"})}),e.jsx(ht,{children:e.jsx(ks,{className:"h-4 w-12"})}),e.jsx(ht,{children:e.jsx(ks,{className:"h-4 w-20"})}),e.jsx(ht,{children:e.jsx(ks,{className:"h-4 w-16"})})]},L))}):I.length===0?e.jsx(Ms,{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(Ms,{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(or,{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(K,{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(K,{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(xr,{className:"h-3.5 w-3.5"})})]})})]},L.id)})})]})})]})},jVt=()=>{const t=vr(),{user:s,isAdmin:r}=qs(),{startImpersonation:n,isLoading:a}=hue(),{toast:o}=ja(),[l,i]=S.useState([]),[d,u]=S.useState([]),[p,f]=S.useState([]),[y,_]=S.useState({}),[b,N]=S.useState(!0);S.useState({});const[w,k]=S.useState(!1),[C,A]=S.useState({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),[I,L]=S.useState(!1),[O,V]=S.useState(""),[q,B]=S.useState(1),[U,te]=S.useState(50),[Y,J]=S.useState("all"),[X,ce]=S.useState("all"),[ae,ie]=S.useState("all"),[oe,me]=S.useState("all"),[ye,he]=S.useState(!1),[ge,Ne]=S.useState(!1),[Ue,Te]=S.useState(null),[Me,De]=S.useState(null),[qe,ke]=S.useState(!1),[$e,Be]=S.useState({name:"",email:"",brokerage_id:"",phone:""}),[we,ut]=S.useState(null),[fe,He]=S.useState(!1),[et,tt]=S.useState(""),[_e,Ge]=S.useState(!1),[We,it]=S.useState(!1),[Ve,Xe]=S.useState(null),[dt,pt]=S.useState(""),[Je,Ze]=S.useState(!1),[Nt,Ot]=S.useState(!1),[Yt,Ps]=S.useState(null),[$s,Zs]=S.useState(!1),[Dr,$t]=S.useState(!1),[Us,Nr]=S.useState(null),[Xs,kr]=S.useState(""),[fn,Yr]=S.useState(!1),[$r,Gr]=S.useState({email:"",name:"",password:"",phone:""}),[nr,lr]=S.useState(!1),[Fr,Wr]=S.useState(!1),[Nn,ai]=S.useState(""),[ns,$n]=S.useState(!1),[dn,zr]=S.useState(!1),[Kr,La]=S.useState(""),[Zt,Er]=S.useState(new Set),[Bt,Se]=S.useState(!1),[Oe,Ye]=S.useState(!1),[yt,bt]=S.useState(null),[Tt,Ht]=S.useState(!1),[Ut,Xt]=S.useState(null),[Ts,ys]=S.useState([]),[ir,Lr]=S.useState([]),[Hr,Rr]=S.useState(!1),[un,Wn]=S.useState({});S.useEffect(()=>{!s||!r||(ua(),To())},[s,r]);const sa=async()=>{try{const{data:St,error:Os}=await G.from("brokerage_manager_assignments").select("user_id, brokerage_id");if(Os)throw Os;const ar={};for(const tn of St??[])ar[tn.brokerage_id]||(ar[tn.brokerage_id]=[]),ar[tn.brokerage_id].push(tn.user_id);_(ar)}catch(St){console.error("Error loading brokerage manager assignments:",St)}},ua=async()=>{try{N(!0);const{data:St,error:Os}=await G.functions.invoke("get-user-details");if(Os)throw Os;const ar=St.users||[];i(ar),f(St.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(Bm=>Bm.agent_id))],{data:Ei}=await G.from("profiles").select("id, name, email").in("id",fa),kc={};for(const Bm of oa){const Zh=Ei==null?void 0:Ei.find(O0=>O0.id===Bm.agent_id);Zh&&(kc[Bm.assistant_id]={agent_name:Zh.name||"",agent_email:Zh.email||""})}Wn(kc)}}}catch(St){console.error("Error loading members:",St),o({title:"Error",description:"Failed to load members",variant:"destructive"})}finally{N(!1)}},To=async()=>{try{const{data:St,error:Os}=await G.from("app_tiles").select("id, name, icon, app_id, required_tags").order("name");if(Os)throw Os;u(St||[])}catch(St){console.error("Error loading apps:",St),o({title:"Error",description:"Failed to load apps",variant:"destructive"})}},wo=async St=>{if(!$e.name.trim()||!$e.email.trim()){o({title:"Error",description:"Name and email are required",variant:"destructive"});return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test($e.email)){o({title:"Error",description:"Please enter a valid email address",variant:"destructive"});return}try{const{error:ar}=await G.from("profiles").update({name:$e.name.trim(),email:$e.email.trim(),brokerage_id:$e.brokerage_id||null,phone:$e.phone.trim()||null}).eq("id",St);if(ar)throw ar;o({title:"Success",description:"Member details updated successfully"}),Te(null),ua()}catch(ar){console.error("Error updating member:",ar),o({title:"Error",description:ar.message||"Failed to update member",variant:"destructive"})}},Yi=async St=>{try{const{data:{session:Os}}=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 ${Os==null?void 0:Os.access_token}`},body:JSON.stringify({userId:St})}),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(Os){console.error("Error resending welcome email:",Os),o({title:"Error",description:Os.message||"Failed to resend welcome email",variant:"destructive"})}},ii=async(St,Os)=>{try{const{error:ar}=await G.functions.invoke("send-password-reset",{body:{email:St,redirectTo:window.location.origin}});if(ar)throw ar;o({title:"Password Reset Sent",description:`Password reset email sent to ${Os}`})}catch(ar){console.error("Error sending password reset:",ar),o({title:"Error",description:ar.message||"Failed to send password reset email",variant:"destructive"})}},zi=async(St,Os)=>{if(confirm(`Are you sure you want to delete ${Os}? 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:St})}),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}k(!0);try{const{data:{session:St}}=await G.auth.getSession(),Os=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${St==null?void 0:St.access_token}`},body:JSON.stringify(C)}),ar=await Os.json();if(!Os.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(St){console.error("Error creating user:",St),o({title:"Error",description:St.message||"Failed to create user",variant:"destructive"})}finally{k(!1)}},ui=async(St,Os,ar,tn)=>{try{const{data:{session:xn}}=await G.auth.getSession(),oa={userId:St,role:Os,action:ar};if(Os==="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"})}},Bi=(St,Os)=>Os.length===0?!0:Os.some(ar=>St.includes(ar)),Xi=async(St,Os,ar)=>{const tn=`${St}-${Os.id}`;ut(tn);try{if(ar){const xn=l.find(fa=>fa.id===St),oa=Os.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",St).eq("tag",fa);if(Ei)throw Ei}o({title:"Access Removed",description:`Removed access to ${Os.name}`})}else if(Os.required_tags.length>0){const{error:xn}=await G.from("user_tags").insert({user_id:St,tag:Os.required_tags[0]});if(xn)throw xn;o({title:"Access Granted",description:`Granted access to ${Os.name}`})}await ua()}catch(xn){console.error("Error toggling access:",xn),o({title:"Error",description:xn.message||"Failed to update access",variant:"destructive"})}finally{ut(null)}},ha=async()=>{const St=et.trim();if(!St){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(St.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}if(p.find(ar=>ar.name.toLowerCase()===St.toLowerCase())){o({title:"Error",description:"A brokerage with this name already exists",variant:"destructive"});return}Ge(!0);try{const{error:ar}=await G.from("brokerages").insert({name:St});if(ar)throw ar;o({title:"Success",description:`Brokerage "${St}" created successfully`}),tt(""),He(!1),ua()}catch(ar){console.error("Error creating brokerage:",ar),o({title:"Error",description:ar.message||"Failed to create brokerage",variant:"destructive"})}finally{Ge(!1)}},sl=St=>{Xe(St),pt(St.name),it(!0)},ac=()=>{Xe(null),pt(""),it(!1)},ic=async()=>{if(!Ve)return;const St=dt.trim();if(!St){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(St.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}Ze(!0);try{const{error:Os}=await G.from("brokerages").update({name:St}).eq("id",Ve.id);if(Os)throw Os;o({title:"Success",description:"Brokerage updated successfully"}),ac(),ua()}catch(Os){console.error("Error updating brokerage:",Os),o({title:"Error",description:Os.message||"Failed to update brokerage",variant:"destructive"})}finally{Ze(!1)}},bu=async(St,Os)=>{var ar;if(!Os||typeof Os!="string"){o({title:"Error",description:"Please select a brokerage first",variant:"destructive"});return}try{const tn={userId:St,role:"brokerage_manager",action:"add",brokerageId:Os};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=St=>{Ps(St),Ot(!0)},Om=async()=>{if(Yt){Zs(!0);try{const St=l.filter(tn=>tn.brokerage_id===Yt.id),{data:{session:Os}}=await G.auth.getSession();for(const tn of St){const xn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Os==null?void 0:Os.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",Yt.id);if(ar)throw ar;o({title:"Success",description:`Brokerage "${Yt.name}" and ${St.length} member(s) deleted`}),Ot(!1),Ps(null),ua()}catch(St){console.error("Error deleting brokerage:",St),o({title:"Error",description:St.message||"Failed to delete brokerage",variant:"destructive"})}finally{Zs(!1)}}},kd=St=>{Nr(St),kr(""),$t(!0)},ju=()=>{Nr(null),kr(""),$t(!1)},Fm=async St=>{try{const{error:Os}=await G.from("profiles").update({brokerage_id:null}).eq("id",St);if(Os)throw Os;o({title:"Success",description:"User removed from brokerage"}),ua()}catch(Os){console.error("Error removing user from brokerage:",Os),o({title:"Error",description:Os.message||"Failed to remove user",variant:"destructive"})}},Wu=async(St,Os)=>{try{const{error:ar}=await G.from("profiles").update({brokerage_id:Os}).eq("id",St);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"})}},zm=async()=>{if(!Us||!$r.email||!$r.name||!$r.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}lr(!0);try{const{data:{session:St}}=await G.auth.getSession(),Os=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${St==null?void 0:St.access_token}`},body:JSON.stringify({...$r,brokerage_id:Us.id,role:"user"})}),ar=await Os.json();if(!Os.ok)throw new Error(ar.error||"Failed to create agent");o({title:"Success",description:`Agent ${$r.email} created successfully`}),Gr({email:"",name:"",password:"",phone:""}),Yr(!1),ua()}catch(St){console.error("Error creating agent:",St),o({title:"Error",description:St.message||"Failed to create agent",variant:"destructive"})}finally{lr(!1)}},Sd=St=>l.filter(Os=>Os.brokerage_id===St),Cd=St=>{const Os=Sd(St);if(!Xs)return Os;const ar=Xs.toLowerCase();return Os.filter(tn=>tn.name.toLowerCase().includes(ar)||tn.email.toLowerCase().includes(ar))},L0=St=>l.filter(Os=>Os.brokerage_id!==St),Aw=l.filter(St=>{var ar;if(O){const tn=O.toLowerCase();if(!(St.name.toLowerCase().includes(tn)||St.email.toLowerCase().includes(tn)||((ar=St.brokerage_name)==null?void 0:ar.toLowerCase().includes(tn))))return!1}if(Y==="claimed"&&!St.claimed||Y==="unclaimed"&&St.claimed||X!=="all"&&!St.roles.includes(X))return!1;const Os=St.is_trial||St.subscription_status==="trialing";return!(ae==="trial"&&!Os||ae==="non-trial"&&Os||oe==="none"&&St.brokerage_id||oe!=="all"&&oe!=="none"&&St.brokerage_id!==oe)}),{sortKey:gh,sortDirection:kp,handleSort:Sp,sortData:Ew}=sO("created_at","desc"),Kh=Ew(Aw,{name:St=>{var Os;return((Os=St.name)==null?void 0:Os.toLowerCase())||""},brokerage:St=>{var Os;return((Os=St.brokerage_name)==null?void 0:Os.toLowerCase())||""},status:St=>St.claimed?"active":"pending",role:St=>St.roles[0]||"",last_login:St=>St.last_sign_in_at?new Date(St.last_sign_in_at).getTime():null,created_at:St=>St.created_at?new Date(St.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=St=>{V(St),B(1)},yh=St=>{te(St),B(1)},Qg=(St,Os)=>{St(Os),B(1)},Mf=async(St,Os)=>{he(!0);try{const ar=l.find(fa=>fa.id===St);if(!ar)return;const tn=ar.trial_expires_at?new Date(ar.trial_expires_at):new Date,xn=new Date(tn.getTime()+Os*24*60*60*1e3),{error:oa}=await G.from("profiles").update({trial_expires_at:xn.toISOString()}).eq("id",St);if(oa)throw oa;o({title:"Trial Extended",description:`Trial extended by ${Os} 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 St=>{Ne(!0);try{const{error:Os}=await G.from("profiles").update({is_trial:!1,trial_expires_at:null,trial_started_at:null,trial_claimed_at:null}).eq("id",St);if(Os)throw Os;o({title:"Account Converted",description:"User has been converted to a full account"}),ua(),Sa()}catch(Os){console.error("Error converting trial:",Os),o({title:"Error",description:Os.message||"Failed to convert account",variant:"destructive"})}finally{Ne(!1)}},Iw=async St=>{Rr(!0);try{const{data:Os}=await G.from("agent_assistant_assignments").select("id, assistant_id, permissions").eq("agent_id",St);if(Os&&Os.length>0){const tn=Os.map(oa=>oa.assistant_id),{data:xn}=await G.from("profiles").select("id, name, email").in("id",tn);ys(Os.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 ys([]);const{data:ar}=await G.from("agent_assistant_assignments").select("id, agent_id, permissions").eq("assistant_id",St);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);Lr(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 Lr([])}catch(Os){console.error("Error loading assistant data:",Os)}finally{Rr(!1)}},P1=St=>{De(St),Be({name:St.name,email:St.email,brokerage_id:St.brokerage_id||"",phone:St.phone||""}),ke(!0),Iw(St.id)},Sa=()=>{De(null),ke(!1),Be({name:"",email:"",brokerage_id:"",phone:""})},Jg=async()=>{Me&&(await wo(Me.id),Sa())},ey=St=>{Er(Os=>{const ar=new Set(Os);return ar.has(St)?ar.delete(St):ar.add(St),ar})},OE=()=>{if(Zt.size===Wd.length&&Wd.every(St=>Zt.has(St.id))){const St=new Set(Zt);Wd.forEach(Os=>St.delete(Os.id)),Er(St)}else{const St=new Set(Zt);Wd.forEach(Os=>St.add(Os.id)),Er(St)}},$x=()=>{Er(new Set)},Tf=async()=>{if(Zt.size===0)return;Se(!0);let St=0,Os=0;try{const{data:{session:ar}}=await G.auth.getSession();for(const tn of Zt)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?St++:Os++}catch{Os++}o({title:"Bulk Email Complete",description:`Sent ${St} emails${Os>0?`, ${Os} failed`:""}`}),$x()}catch(ar){o({title:"Error",description:ar.message||"Failed to send emails",variant:"destructive"})}finally{Se(!1)}},ty=async()=>{if(Zt.size===0)return;Se(!0);let St=0,Os=0;try{const{data:{session:ar}}=await G.auth.getSession();for(const tn of Zt)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?St++:Os++}catch{Os++}o({title:"Bulk Password Reset Complete",description:`Sent ${St} reset emails${Os>0?`, ${Os} failed`:""}`}),$x()}catch(ar){o({title:"Error",description:ar.message||"Failed to send password reset emails",variant:"destructive"})}finally{Se(!1)}},R0=async()=>{if(Zt.size===0)return;const St=l.filter(xn=>Zt.has(xn.id)).map(xn=>xn.name).slice(0,5).join(", "),Os=Zt.size>5?` and ${Zt.size-5} more`:"";if(!confirm(`Are you sure you want to delete ${Zt.size} users (${St}${Os})? 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 Zt)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()=>{Ye(!0);try{const{data:{session:St}}=await G.auth.getSession(),Os=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-phone-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${St==null?void 0:St.access_token}`}});if(!Os.ok){const tn=await Os.json();throw new Error(tn.error||"Failed to sync phones")}const ar=await Os.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(St){o({title:"Error",description:St.message||"Failed to sync phones with GHL",variant:"destructive"})}finally{Ye(!1)}},RC=async(St,Os)=>{bt(St);try{const{data:{session:ar}}=await G.auth.getSession(),{data:tn}=await G.from("profiles").select("phone").eq("id",St).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:Os,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(Os)}`,{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 St=>{await n(St)},OC=()=>{if(Zt.size===0){o({title:"No members selected",description:"Please select members to export",variant:"destructive"});return}const St=l.filter(Ei=>Zt.has(Ei.id)),Os=["Name","Email","Phone","Brokerage","Roles","Status","Created At"],ar=St.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=[Os.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 ${St.length} member(s)`})};return b?e.jsx(Es,{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(Es,{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(K,{size:"sm",variant:"outline",onClick:I1,disabled:Oe,children:[Oe?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:Oe?"Syncing...":"Sync Phones with GHL"}),e.jsx("span",{className:"sm:hidden",children:Oe?"Syncing...":"Sync GHL"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>Wr(!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(hi,{asChild:!0,children:e.jsxs(K,{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(hs,{children:[e.jsxs(js,{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(Le,{id:"name",placeholder:"John Doe",value:C.name,onChange:St=>A({...C,name:St.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"email",children:"Email"}),e.jsx(Le,{id:"email",type:"email",placeholder:"john@example.com",value:C.email,onChange:St=>A({...C,email:St.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"password",children:"Password"}),e.jsx(Le,{id:"password",type:"password",placeholder:"Min 6 characters",value:C.password,onChange:St=>A({...C,password:St.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(Le,{id:"phone",type:"tel",placeholder:"555-123-4567",value:C.phone,onChange:St=>A({...C,phone:St.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(xe,{htmlFor:"brokerage",children:["Brokerage",C.role==="brokerage_manager"?" (required)":""]}),e.jsxs(Fs,{value:C.brokerage_id||"none",onValueChange:St=>A({...C,brokerage_id:St==="none"?"":St}),children:[e.jsx(Ds,{id:"brokerage",children:e.jsx(zs,{placeholder:C.role==="brokerage_manager"?"Select brokerage":"Select brokerage (optional)"})}),e.jsxs(Rs,{children:[e.jsx(vt,{value:"none",children:"None"}),p.map(St=>e.jsx(vt,{value:St.id,children:St.name},St.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"role",children:"Role"}),e.jsxs(Fs,{value:C.role,onValueChange:St=>A({...C,role:St}),children:[e.jsx(Ds,{id:"role",children:e.jsx(zs,{placeholder:"Select role"})}),e.jsxs(Rs,{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(Fs,{value:C.trial_days||"none",onValueChange:St=>A({...C,trial_days:St==="none"?"":St}),children:[e.jsx(Ds,{id:"trial_days",children:e.jsx(zs,{placeholder:"No trial (full access)"})}),e.jsxs(Rs,{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(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),e.jsx(K,{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(ls,{value:"members",children:"Members"}),e.jsx(ls,{value:"brokerages",children:"Brokerages"}),e.jsx(ls,{value:"teams",children:"Teams"}),e.jsx(ls,{value:"trials",children:"Trial Users"}),e.jsx(ls,{value:"access",children:"Access Matrix"}),e.jsx(ls,{value:"celebrations",children:"Celebrations"}),e.jsx(ls,{value:"deletions",children:"Deletion Log"})]}),e.jsxs(ws,{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(an,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search members...",value:O,onChange:St=>Pw(St.target.value),className:"pl-10 h-9"})]}),e.jsxs(Fs,{value:Y,onValueChange:St=>Qg(J,St),children:[e.jsx(Ds,{className:"w-[130px] h-9",children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Fs,{value:X,onValueChange:St=>Qg(ce,St),children:[e.jsx(Ds,{className:"w-[130px] h-9",children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Fs,{value:ae,onValueChange:St=>Qg(ie,St),children:[e.jsx(Ds,{className:"w-[130px] h-9",children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Fs,{value:oe,onValueChange:St=>Qg(me,St),children:[e.jsx(Ds,{className:"w-[150px] h-9",children:e.jsx(zs,{})}),e.jsxs(Rs,{children:[e.jsx(vt,{value:"all",children:"All Brokerages"}),e.jsx(vt,{value:"none",children:"No Brokerage"}),p.map(St=>e.jsx(vt,{value:St.id,children:St.name},St.id))]})]}),(O||Y!=="all"||X!=="all"||ae!=="all"||oe!=="all")&&e.jsxs(K,{variant:"ghost",size:"sm",className:"h-9",onClick:()=>{V(""),J("all"),ce("all"),ie("all"),me("all"),B(1)},children:[e.jsx(jr,{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(Fs,{value:U.toString(),onValueChange:St=>yh(Number(St)),children:[e.jsx(Ds,{className:"h-9 w-[110px]",children:e.jsx(zs,{})}),e.jsxs(Rs,{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"})]})]})]})]}),Zt.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:[Zt.size," selected"]})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:Tf,disabled:Bt,children:[Bt?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(K,{size:"sm",variant:"outline",onClick:ty,disabled:Bt,children:[Bt?e.jsx(us,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(pp,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Password Reset"}),e.jsx("span",{className:"sm:hidden",children:"Reset"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick: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(K,{size:"sm",variant:"destructive",onClick:R0,disabled:Bt,children:[Bt?e.jsx(us,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(xr,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Delete"}),e.jsx("span",{className:"sm:hidden",children:"Del"})]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:$x,disabled:Bt,children:e.jsx(jr,{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(Ms,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(kt,{className:"w-[50px]",children:e.jsx(Hi,{checked:Wd.length>0&&Wd.every(St=>Zt.has(St.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(kt,{className:"w-[100px]"})]})}),e.jsx(Rn,{children:Wd.length===0?e.jsx(Ms,{children:e.jsx(ht,{colSpan:8,className:"text-center py-12 text-muted-foreground",children:"No members found"})}):Wd.map(St=>e.jsxs(Ms,{className:`hover:bg-muted/30 ${Zt.has(St.id)?"bg-primary/5":""}`,children:[e.jsx(ht,{children:e.jsx(Hi,{checked:Zt.has(St.id),onCheckedChange:()=>ey(St.id),"aria-label":`Select ${St.name}`})}),e.jsx(ht,{children:e.jsxs("div",{children:[e.jsx("button",{onClick:()=>P1(St),className:"text-primary hover:underline font-medium text-left",children:St.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:St.email})]})}),e.jsx(ht,{className:"text-muted-foreground",children:St.brokerage_name||"—"}),e.jsx(ht,{children:e.jsx("div",{className:"flex flex-col",children:(()=>{const Os=St.is_trial&&St.trial_expires_at||!St.is_trial&&St.subscription_status==="trialing"&&St.subscription_end_date,ar=St.trial_expires_at||St.subscription_end_date;if(Os&&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:Dt("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:St.claimed?"default":"secondary",className:St.claimed?"bg-primary text-primary-foreground w-fit":"w-fit",children:St.claimed?"Active":"Pending"})})()})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex flex-col",children:[St.roles.length>0?e.jsx("span",{className:"text-sm capitalize",children:St.roles[0]}):e.jsx("span",{className:"text-muted-foreground",children:"—"}),St.roles.includes("assistant")&&un[St.id]&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["→ ",un[St.id].agent_name||un[St.id].agent_email]})]})}),e.jsx(ht,{className:"text-muted-foreground",children:St.last_sign_in_at?new Date(St.last_sign_in_at).toLocaleDateString():"—"}),e.jsx(ht,{className:"text-muted-foreground",children:St.created_at?new Date(St.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(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",onClick:()=>{Xt(St),Ht(!0)},title:"Send celebration",children:e.jsx(qd,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>P1(St),title:"Edit member",children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>RC(St.id,St.email),disabled:yt===St.id,title:"Sync phone with GHL",children:yt===St.id?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(In,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Yi(St.id),title:"Resend welcome email",children:e.jsx(tr,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>ii(St.email,St.name),title:"Send password reset",children:e.jsx(nS,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:()=>Af(St.id),disabled:a||St.id===(s==null?void 0:s.id),title:St.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${St.name}`,children:a?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(lS,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>zi(St.id,St.name),title:"Delete user",children:e.jsx(xr,{className:"h-4 w-4"})})]})})]},St.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(K,{variant:"outline",size:"sm",onClick:()=>B(1),disabled:q===1,children:"First"}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>B(St=>Math.max(1,St-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)},(St,Os)=>{let ar;return Md<=5||q<=3?ar=Os+1:q>=Md-2?ar=Md-4+Os:ar=q-2+Os,e.jsx(K,{variant:q===ar?"default":"outline",size:"sm",className:"h-8 w-8 p-0",onClick:()=>B(ar),children:ar},ar)})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>B(St=>Math.min(Md,St+1)),disabled:q===Md,children:e.jsx(xa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>B(Md),disabled:q===Md,children:"Last"})]})]})]}),e.jsx(fs,{open:qe,onOpenChange:ke,children:e.jsxs(hs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Edit Member"}),e.jsx(Ir,{children:"Update member details, roles, and app access"})]}),Me&&e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Basic Information"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"edit-name",children:"Name"}),e.jsx(Le,{id:"edit-name",value:$e.name,onChange:St=>Be({...$e,name:St.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"edit-email",children:"Email"}),e.jsx(Le,{id:"edit-email",type:"email",value:$e.email,onChange:St=>Be({...$e,email:St.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(Le,{id:"edit-phone",type:"tel",value:$e.phone,onChange:St=>Be({...$e,phone:St.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"edit-brokerage",children:"Brokerage"}),e.jsxs(Fs,{value:$e.brokerage_id||"none",onValueChange:St=>Be({...$e,brokerage_id:St==="none"?"":St}),children:[e.jsx(Ds,{id:"edit-brokerage",children:e.jsx(zs,{placeholder:"Select brokerage"})}),e.jsxs(Rs,{children:[e.jsx(vt,{value:"none",children:"None"}),p.map(St=>e.jsx(vt,{value:St.id,children:St.name},St.id))]})]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Roles"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Me.roles.map(St=>e.jsxs(Qe,{variant:"default",className:"gap-1",children:[e.jsx(zu,{className:"h-3 w-3"}),St,St==="brokerage_manager"?e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(manage in Brokerages tab)"}):e.jsx("button",{onClick:()=>ui(Me.id,St,"remove"),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove role",children:e.jsx(jr,{className:"h-3 w-3"})})]},St)),Me.roles.length===0&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"No roles assigned"})]}),e.jsxs(Fs,{onValueChange:St=>ui(Me.id,St,"add"),children:[e.jsx(Ds,{className:"w-[200px]",children:e.jsx(zs,{placeholder:"Add role..."})}),e.jsxs(Rs,{children:[!Me.roles.includes("admin")&&e.jsx(vt,{value:"admin",children:"Admin"}),!Me.roles.includes("user")&&e.jsx(vt,{value:"user",children:"User"})]})]}),!Me.roles.includes("brokerage_manager")&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"To add as brokerage manager, use Brokerages tab → Manage"})]}),(Ts.length>0||ir.length>0||Me.roles.includes("assistant"))&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(or,{className:"h-4 w-4"}),"Assistant Relationships"]}),Hr?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:[Ts.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:"}),Ts.map(St=>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:St.assistant_name}),e.jsx(Qe,{variant:"outline",className:"text-xs",children:"Assistant"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:St.assistant_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(St.permissions).filter(([,Os])=>Os).map(([Os])=>e.jsx(Qe,{variant:"secondary",className:"text-[10px] capitalize",children:Os},Os))})]},St.id))]}),ir.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:"}),ir.map(St=>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:St.agent_name}),e.jsx(Qe,{variant:"outline",className:"text-xs",children:"Agent"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:St.agent_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(St.permissions).filter(([,Os])=>Os).map(([Os])=>e.jsx(Qe,{variant:"secondary",className:"text-[10px] capitalize",children:Os},Os))})]},St.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(St=>{const Os=Bi(Me.tags,St.required_tags),ar=`${Me.id}-${St.id}`,tn=we===ar,xn=St.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:St.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:St.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(Mr,{checked:Os,onCheckedChange:()=>Xi(Me.id,St,Os)})})]},St.id)})})]}),(Me.is_trial||Me.subscription_status==="trialing")&&e.jsxs("div",{className:"space-y-3 pt-4 border-t",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),"Trial Status"]}),e.jsxs("div",{className:"p-4 rounded-lg border bg-amber-50 dark:bg-amber-950/20 border-amber-200 dark:border-amber-800",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[Me.trial_expires_at&&e.jsx(nDe,{expiresAt:Me.trial_expires_at}),!Me.trial_expires_at&&Me.subscription_status==="trialing"&&Me.subscription_end_date&&e.jsx(nDe,{expiresAt:Me.subscription_end_date})]}),(Me.trial_expires_at||Me.subscription_end_date)&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Expires: ",new Date(Me.trial_expires_at||Me.subscription_end_date).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>Mf(Me.id,7),disabled:ye,children:[e.jsx(jb,{className:"h-4 w-4 mr-1"}),"+7 Days"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>Mf(Me.id,14),disabled:ye,children:[e.jsx(jb,{className:"h-4 w-4 mr-1"}),"+14 Days"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>Mf(Me.id,30),disabled:ye,children:[e.jsx(jb,{className:"h-4 w-4 mr-1"}),"+30 Days"]}),e.jsxs(K,{size:"sm",variant:"default",onClick:()=>D0(Me.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"]})]}),Me.trial_started_at&&e.jsxs("div",{className:"mt-3 text-xs text-muted-foreground",children:["Trial started: ",new Date(Me.trial_started_at).toLocaleDateString(),Me.trial_claimed_at&&e.jsxs("span",{children:[" • Claimed: ",new Date(Me.trial_claimed_at).toLocaleDateString()]})]})]})]}),e.jsxs("div",{className:"space-y-2 pt-4 border-t",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Account Information"}),e.jsxs("div",{className:"text-sm space-y-1 text-muted-foreground",children:[Me.email_confirmed_at&&e.jsxs("div",{children:["Claimed: ",new Date(Me.email_confirmed_at).toLocaleString()]}),Me.last_sign_in_at&&e.jsxs("div",{children:["Last login: ",new Date(Me.last_sign_in_at).toLocaleString()]}),e.jsxs("div",{children:["Created: ",new Date(Me.created_at).toLocaleString()]})]})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:Sa,children:"Cancel"}),e.jsx(K,{onClick:Jg,children:"Save Changes"})]})]})}),e.jsxs(ws,{value:"access",children:[d.length===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No apps configured yet"}),e.jsx(K,{onClick:()=>t("/admin/apps"),children:"Configure Apps"})]})}):e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 space-y-0",children:[e.jsxs("div",{children:[e.jsx(Ft,{children:"Member Access Matrix"}),e.jsx(ur,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search agents by name or email...",value:O,onChange:St=>{V(St.target.value),B(1)},className:"pl-9"})]})]}),e.jsxs(Re,{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(St=>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:St.icon}),e.jsx("span",{className:"text-sm",children:St.name})]})},St.id))]})}),e.jsxs("tbody",{children:[Wd.map(St=>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:St.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:St.email})]})}),d.map(Os=>{const ar=Bi(St.tags,Os.required_tags),tn=`${St.id}-${Os.id}`,xn=we===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(Mr,{checked:ar,onCheckedChange:()=>Xi(St.id,Os,ar),disabled:Os.required_tags.length===0})})},Os.id)})]},St.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(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>B(St=>Math.max(1,St-1)),disabled:q===1,children:e.jsx(Xo,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>B(St=>Math.min(Md,St+1)),disabled:q===Md,children:e.jsx(xa,{className:"h-4 w-4"})})]})]})]})]}),e.jsx("div",{className:"mt-6",children:e.jsx(K,{variant:"outline",onClick:()=>t("/admin/apps"),children:"Manage Apps"})})]}),e.jsxs(ws,{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(an,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search brokerages...",value:Nn,onChange:St=>ai(St.target.value),className:"pl-10"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[p.filter(St=>St.name.toLowerCase().includes(Nn.toLowerCase())).length," of ",p.length," brokerages"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{const St=[];for(const fa of p){const Ei=y[fa.id]??[];for(const kc of Ei){const Bm=l.find(Zh=>Zh.id===kc);if(Bm){const Zh=(Bm.name||"").trim().split(/\s+/),O0=Zh[0]||"",Aa=Zh.slice(1).join(" ")||"";St.push({firstName:O0,lastName:Aa,email:Bm.email,brokerageName:fa.name})}}}if(St.length===0){o({title:"No managers found to export"});return}const ar=[["First Name","Last Name","Email","Brokerage Name"].join(","),...St.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 ${St.length} managers`})},children:[e.jsx(Qa,{className:"mr-2 h-4 w-4"}),"Export Managers"]}),e.jsxs(fs,{open:fe,onOpenChange:He,children:[e.jsx(hi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(pa,{className:"mr-2 h-4 w-4"}),"Add Brokerage"]})}),e.jsxs(hs,{children:[e.jsxs(js,{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(Le,{id:"brokerage-name",placeholder:"Enter brokerage name",value:et,onChange:St=>tt(St.target.value),maxLength:100})]})}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>He(!1),children:"Cancel"}),e.jsx(K,{onClick:ha,disabled:_e,children:_e?"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(Ms,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(kt,{className:"font-semibold",children:"Brokerage Name"}),e.jsx(kt,{className:"font-semibold",children:"Manager(s)"}),e.jsx(kt,{className:"font-semibold",children:"Agents"}),e.jsx(kt,{className:"w-[150px]"})]})}),e.jsx(Rn,{children:(()=>{const St=p.filter(Os=>Os.name.toLowerCase().includes(Nn.toLowerCase()));return St.length===0?e.jsx(Ms,{children:e.jsx(ht,{colSpan:4,className:"text-center py-12 text-muted-foreground",children:Nn?"No brokerages match your search":"No brokerages found"})}):St.map(Os=>{const ar=l.filter(fa=>fa.brokerage_id===Os.id),xn=(y[Os.id]??[]).map(fa=>l.find(Ei=>Ei.id===fa)).filter(Boolean),oa=ar.length;return e.jsxs(Ms,{className:"hover:bg-muted/30",children:[e.jsx(ht,{children:e.jsx("button",{onClick:()=>sl(Os),className:"text-primary hover:underline font-medium",children:Os.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(K,{size:"sm",variant:"outline",className:"h-8",onClick:()=>kd(Os),children:[e.jsx(or,{className:"h-4 w-4 mr-1"}),"Manage"]}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>sl(Os),title:"Edit brokerage",children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>wu(Os),title:"Delete brokerage",children:e.jsx(xr,{className:"h-4 w-4"})})]})})]},Os.id)})})()})]})}),e.jsx(fs,{open:We,onOpenChange:it,children:e.jsxs(hs,{className:"max-w-lg",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Edit Brokerage"}),e.jsx(Ir,{children:"Update brokerage details and manage managers"})]}),Ve&&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(Le,{id:"edit-brokerage-name",value:dt,onChange:St=>pt(St.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 Os=(y[Ve.id]??[]).map(ar=>l.find(tn=>tn.id===ar)).filter(Boolean);return Os.length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No managers assigned"}):Os.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",Ve.id),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove manager from this brokerage",children:e.jsx(jr,{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(yo,{open:ns,onOpenChange:$n,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":ns,className:"w-full justify-between",children:["Search for a member...",e.jsx(an,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(uo,{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 St=new Set(y[Ve.id]??[]);return l.filter(Os=>!St.has(Os.id)&&(r||Os.brokerage_id===Ve.id)).map(Os=>e.jsxs(lp,{value:`${Os.name} ${Os.email}`,onSelect:()=>{bu(Os.id,Ve.id),$n(!1)},children:[Os.name," (",Os.email,")"]},Os.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(St=>St.brokerage_id===Ve.id).length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No members"}):l.filter(St=>St.brokerage_id===Ve.id).map(St=>e.jsxs("div",{className:"text-sm py-1 flex items-center justify-between",children:[e.jsx("span",{children:St.name}),St.roles.includes("brokerage_manager")&&e.jsx(Qe,{variant:"outline",className:"text-xs",children:"Manager"})]},St.id))})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:ac,children:"Cancel"}),e.jsx(K,{onClick:ic,disabled:Je,children:Je?"Saving...":"Save Changes"})]})]})}),e.jsx(fs,{open:Nt,onOpenChange:Ot,children:e.jsxs(hs,{children:[e.jsxs(js,{children:[e.jsx(_s,{className:"text-destructive",children:"Delete Brokerage"}),e.jsxs(Ir,{children:['Are you sure you want to delete "',Yt==null?void 0:Yt.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 "',Yt==null?void 0:Yt.name,'"']}),e.jsxs("li",{children:["All ",l.filter(St=>St.brokerage_id===(Yt==null?void 0:Yt.id)).length," member(s) assigned to this brokerage"]}),e.jsx("li",{children:"All their data, roles, and access"})]})]})}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>Ot(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:Om,disabled:$s,children:$s?"Deleting...":"Yes, Delete Brokerage"})]})]})}),e.jsx(fs,{open:Dr,onOpenChange:$t,children:e.jsxs(hs,{className:"max-w-4xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(pa,{className:"h-5 w-5"}),"Manage ",Us==null?void 0:Us.name]}),e.jsx(Ir,{children:"Add, remove, or manage users in this brokerage"})]}),Us&&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(an,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search members...",value:Xs,onChange:St=>kr(St.target.value),className:"pl-10 h-9"})]}),e.jsxs(fs,{open:fn,onOpenChange:Yr,children:[e.jsx(hi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Jo,{className:"h-4 w-4 mr-1"}),"Add New Agent"]})}),e.jsxs(hs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Add New Agent"}),e.jsxs(Ir,{children:["Create a new agent for ",Us.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(Le,{id:"agent-name",placeholder:"John Doe",value:$r.name,onChange:St=>Gr({...$r,name:St.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"agent-email",children:"Email"}),e.jsx(Le,{id:"agent-email",type:"email",placeholder:"john@example.com",value:$r.email,onChange:St=>Gr({...$r,email:St.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"agent-password",children:"Password"}),e.jsx(Le,{id:"agent-password",type:"password",placeholder:"Min 6 characters",value:$r.password,onChange:St=>Gr({...$r,password:St.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"agent-phone",children:"Phone (optional)"}),e.jsx(Le,{id:"agent-phone",type:"tel",placeholder:"555-123-4567",value:$r.phone,onChange:St=>Gr({...$r,phone:St.target.value})})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>Yr(!1),children:"Cancel"}),e.jsx(K,{onClick:zm,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(yo,{open:dn,onOpenChange:zr,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":dn,className:"w-[300px] justify-between",children:["Select a user to add...",e.jsx(an,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(uo,{className:"w-[300px] p-0",align:"start",children:e.jsxs(Sx,{children:[e.jsx(Cx,{placeholder:"Search users...",value:Kr,onValueChange:La}),e.jsxs(Mx,{children:[e.jsx(Tx,{children:"No users found."}),e.jsx(Ax,{children:L0(Us.id).filter(St=>Kr===""||St.name.toLowerCase().includes(Kr.toLowerCase())||St.email.toLowerCase().includes(Kr.toLowerCase())).map(St=>e.jsxs(lp,{value:`${St.name} ${St.email}`,onSelect:()=>{Wu(St.id,Us.id),zr(!1),La("")},children:[St.name," (",St.email,")"]},St.id))})]})]})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto border rounded-lg",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ms,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(kt,{className:"font-semibold",children:"Name"}),e.jsx(kt,{className:"font-semibold",children:"Email"}),e.jsx(kt,{className:"font-semibold",children:"Status"}),e.jsx(kt,{className:"font-semibold",children:"Role"}),e.jsx(kt,{className:"w-[120px]"})]})}),e.jsx(Rn,{children:Cd(Us.id).length===0?e.jsx(Ms,{children:e.jsx(ht,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:Xs?"No matching members found":"No members in this brokerage"})}):Cd(Us.id).map(St=>e.jsxs(Ms,{className:"hover:bg-muted/30",children:[e.jsx(ht,{className:"font-medium",children:St.name}),e.jsx(ht,{className:"text-muted-foreground",children:St.email}),e.jsx(ht,{children:St.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:St.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:[!St.claimed&&e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Yi(St.id),title:"Resend welcome email",children:e.jsx(tr,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Fm(St.id),title:"Remove from brokerage",children:e.jsx(jr,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:()=>Af(St.id),disabled:a||St.id===(s==null?void 0:s.id),title:St.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${St.name}`,children:a?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(lS,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>zi(St.id,St.name),title:"Delete user",children:e.jsx(xr,{className:"h-4 w-4"})})]})})]},St.id))})]})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Sd(Us.id).length," total member",Sd(Us.id).length!==1?"s":""," •",Sd(Us.id).filter(St=>St.roles.includes("brokerage_manager")).length," manager",Sd(Us.id).filter(St=>St.roles.includes("brokerage_manager")).length!==1?"s":""]})]}),e.jsx(_n,{children:e.jsx(K,{variant:"outline",onClick:ju,children:"Close"})})]})})]}),e.jsx(ws,{value:"teams",children:e.jsx(wVt,{})}),e.jsx(ws,{value:"trials",children:e.jsx(yVt,{})}),e.jsx(ws,{value:"celebrations",children:e.jsx(gVt,{})}),e.jsx(ws,{value:"deletions",children:e.jsx(vVt,{})})]})]}),e.jsx(utt,{open:Fr,onOpenChange:Wr,brokerages:p,onSuccess:ua}),Ut&&e.jsx(htt,{open:Tt,onOpenChange:St=>{Ht(St),St||Xt(null)},userId:Ut.id,userName:Ut.name})]})},NVt=()=>{const[t,s]=S.useState([]),[r,n]=S.useState(!0),[a,o]=S.useState(!1),[l,i]=S.useState(""),[d,u]=S.useState(""),[p,f]=S.useState(""),[y,_]=S.useState("");S.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))},k=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(Es,{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(Lt,{children:[e.jsx(Ft,{children:"Create New Code"}),e.jsxs(ur,{children:["Share link: ",e.jsx("code",{className:"bg-muted px-2 py-1 rounded text-sm",children:I})]})]}),e.jsx(Re,{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(Le,{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(Le,{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(Le,{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(Le,{id:"trialDays",type:"number",placeholder:"None",value:y,onChange:L=>_(L.target.value),className:"w-28"})]}),e.jsxs(K,{type:"submit",disabled:a,children:[a?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Create"]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"Active Codes"})}),e.jsx(Re,{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(Ms,{children:[e.jsx(kt,{children:"Code"}),e.jsx(kt,{children:"Description"}),e.jsx(kt,{children:"Uses"}),e.jsx(kt,{children:"Trial"}),e.jsx(kt,{children:"Created"}),e.jsx(kt,{children:"Active"}),e.jsx(kt,{className:"w-24",children:"Actions"})]})}),e.jsx(Rn,{children:t.map(L=>e.jsxs(Ms,{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:gs(new Date(L.created_at),"MMM d, yyyy")}),e.jsx(ht,{children:e.jsx(Mr,{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(K,{variant:"ghost",size:"icon",onClick:()=>A(L.code),title:"Copy invite link",children:e.jsx(Wa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>k(L.id),className:"text-destructive hover:text-destructive",title:"Delete code",children:e.jsx(xr,{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}}},kVt=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}),SVt=async(t,s)=>rE({title:"New Academy Video",body:`New video added: ${t}`,url:`/academy/${s}`}),CVt=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}),MVt=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}),TVt=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}),Jz={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 AVt(){const t=vr(),s=Qt(),[r,n]=S.useState(!1),[a,o]=S.useState(null),[l,i]=S.useState(Jz),[d,u]=S.useState(null),[p,f]=S.useState(null),[y,_]=S.useState(!1),b=S.useRef(null),[N,w]=S.useState(!1),[k,C]=S.useState(null),[A,I]=S.useState(!1),[L,O]=S.useState(null),[V,q]=S.useState(null),[B,U]=S.useState(!0),[te,Y]=S.useState(""),{data:J,isLoading:X}=gt({queryKey:["admin-events"],queryFn:async()=>{const{data:_e,error:Ge}=await G.from("events").select("*").order("event_date",{ascending:!0});if(Ge)throw Ge;return _e}}),{data:ce}=gt({queryKey:["event-registrations-count"],queryFn:async()=>{let _e=[],Ge=0;const We=1e3;for(;;){const{data:Ve,error:Xe}=await G.from("event_registrations").select("event_id").range(Ge,Ge+We-1);if(Xe)throw Xe;if(!Ve||Ve.length===0||(_e=_e.concat(Ve),Ve.length{it[Ve.event_id]=(it[Ve.event_id]||0)+1}),it}}),{data:ae,isLoading:ie}=gt({queryKey:["event-registrations-details",k==null?void 0:k.id],queryFn:async()=>{if(!k)return[];const{data:_e,error:Ge}=await G.from("event_registrations").select("id, user_id, registered_at, zoom_join_url, zoom_name, zoom_email").eq("event_id",k.id).order("registered_at",{ascending:!1});if(Ge)throw Ge;if(!_e||_e.length===0)return[];const We=_e.map(Xe=>Xe.user_id).filter(Boolean);let it=[];if(We.length>0){const{data:Xe,error:dt}=await G.from("profiles").select("id, name, email").in("id",We);if(dt)throw dt;it=Xe||[]}const Ve=new Map((it==null?void 0:it.map(Xe=>[Xe.id,Xe]))||[]);return _e.map(Xe=>({...Xe,profiles:Xe.user_id&&Ve.get(Xe.user_id)||null}))},enabled:!!k}),{data:oe,isLoading:me}=gt({queryKey:["event-attendees-details",k==null?void 0:k.id],queryFn:async()=>{if(!k)return[];const{data:_e,error:Ge}=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",k.id).order("created_at",{ascending:!1});if(Ge)throw Ge;if(!_e||_e.length===0)return[];const We=_e.map(pt=>pt.user_id).filter(Boolean);let it=[];if(We.length>0){const{data:pt,error:Je}=await G.from("profiles").select("id, name, email").in("id",We);if(Je)throw Je;it=pt||[]}const{data:Ve}=await G.from("agent_points").select("user_id").eq("event_id",k.id),Xe=new Set((Ve==null?void 0:Ve.map(pt=>pt.user_id))||[]),dt=new Map((it==null?void 0:it.map(pt=>[pt.id,pt]))||[]);return _e.map(pt=>({...pt,profiles:pt.user_id&&dt.get(pt.user_id)||null,points_awarded:pt.user_id?Xe.has(pt.user_id):!1}))},enabled:!!k}),ye=_e=>{C(_e),w(!0)},he=Et({mutationFn:async _e=>{const{data:{session:Ge}}=await G.auth.getSession();if(!Ge)throw new Error("Not authenticated");const We=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-registrations",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ge.access_token}`},body:JSON.stringify({event_id:_e})}),it=await We.json();if(!We.ok)throw new Error(it.error||"Failed to sync");return it},onSuccess:_e=>{s.invalidateQueries({queryKey:["event-registrations-details",k==null?void 0:k.id]}),s.invalidateQueries({queryKey:["event-registrations-count"]}),pe.success(_e.message)},onError:_e=>{pe.error("Failed to sync: "+_e.message)}}),ge=Et({mutationFn:async _e=>{const{data:{session:Ge}}=await G.auth.getSession();if(!Ge)throw new Error("Not authenticated");const We=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-attendees",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ge.access_token}`},body:JSON.stringify({event_id:_e})}),it=await We.json();if(!We.ok)throw new Error(it.error||"Failed to sync attendees");return it},onSuccess:_e=>{s.invalidateQueries({queryKey:["event-attendees-details",k==null?void 0:k.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]}),_e!=null&&_e.message?pe.success(_e.message):pe.success(`Synced ${_e.synced||0} attendees. ${_e.points_awarded||0} points awarded!`)},onError:_e=>{pe.error("Failed to sync attendees: "+_e.message)}}),Ne=Et({mutationFn:async({eventId:_e,testMode:Ge})=>{const{data:{session:We}}=await G.auth.getSession();if(!We)throw new Error("Not authenticated");const it=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-event-reminder",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${We.access_token}`},body:JSON.stringify({event_id:_e,test_mode:Ge})}),Ve=await it.json();if(!it.ok)throw new Error(Ve.error||"Failed to send reminders");return Ve},onSuccess:_e=>{_e.test?pe.success(_e.message||"Test email sent!"):pe.success(_e.message||`Reminder emails sent to ${_e.sent} registrants!`)},onError:_e=>{pe.error("Failed to send reminders: "+_e.message)}}),{data:Ue}=gt({queryKey:["all-profiles-for-linking"],queryFn:async()=>{let _e=[],Ge=0;const We=1e3;for(;;){const{data:it,error:Ve}=await G.from("profiles").select("id, name, email").order("name",{ascending:!0}).range(Ge,Ge+We-1);if(Ve)throw Ve;if(!it||it.length===0||(_e=[..._e,...it],it.length{const{error:Ve}=await G.from("event_attendees").update({user_id:Ge}).eq("id",_e);if(Ve)throw Ve;if(it&&We){const{error:dt}=await G.from("zoom_email_aliases").upsert({user_id:Ge,zoom_email:We.toLowerCase()},{onConflict:"zoom_email"});dt&&console.error("Failed to save alias:",dt)}const Xe=k==null?void 0:k.id;if(Xe){const{data:dt}=await G.from("user_roles").select("id").eq("user_id",Ge).eq("role","admin").single();if(!dt){const{data:pt}=await G.from("agent_points").select("id").eq("user_id",Ge).eq("event_id",Xe).single();pt||(await G.rpc("award_attendance_points",{p_user_id:Ge,p_event_id:Xe,p_points:10,p_reason:"Event Attendance (Manual Link)"}),await G.rpc("check_and_award_badges",{p_user_id:Ge}))}}return{userId:Ge,zoomEmail:We,shouldSaveAlias:it}},onSuccess:_e=>{s.invalidateQueries({queryKey:["event-attendees-details",k==null?void 0:k.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]});let Ge="Attendee linked and points awarded!";_e.shouldSaveAlias&&_e.zoomEmail&&(Ge+=` Email "${_e.zoomEmail}" will be auto-matched in the future.`),pe.success(Ge),I(!1),O(null),q(null),Y("")},onError:_e=>{pe.error("Failed to link attendee: "+_e.message)}}),Me=_e=>{O(_e),q(null),U(!0),Y(""),I(!0)},De=()=>{!L||!V||Te.mutate({attendeeId:L.id,userId:V,zoomEmail:L.zoom_email,shouldSaveAlias:B})},qe=(Ue==null?void 0:Ue.filter(_e=>{var We,it;if(!te)return!0;const Ge=te.toLowerCase();return((We=_e.name)==null?void 0:We.toLowerCase().includes(Ge))||((it=_e.email)==null?void 0:it.toLowerCase().includes(Ge))}))||[],ke=async _e=>{const Ge=_e.name.split(".").pop(),it=`${`${crypto.randomUUID()}.${Ge}`}`,{error:Ve}=await G.storage.from("event-images").upload(it,_e);if(Ve)throw Ve;const{data:{publicUrl:Xe}}=G.storage.from("event-images").getPublicUrl(it);return Xe},$e=_e=>{var We;const Ge=(We=_e.target.files)==null?void 0:We[0];if(Ge){if(Ge.size>5*1024*1024){pe.error("Image must be less than 5MB");return}u(Ge),f(URL.createObjectURL(Ge))}},Be=()=>{u(null),f(null),i({...l,image_url:""}),b.current&&(b.current.value="")},we=Et({mutationFn:async _e=>{_(!0);let Ge=_e.image_url;d&&(Ge=await ke(d)||"");const We=new Date(_e.event_date),[it,Ve]=_e.event_time.split(":");We.setHours(parseInt(it),parseInt(Ve));const Xe=[new Date(We)];if(_e.is_recurring&&_e.recurrence_end_date){let Ze=new Date(We);for(;_e.recurrence_pattern==="weekly"?Ze=x4(Ze,1):_e.recurrence_pattern==="biweekly"?Ze=x4(Ze,2):Ze=Am(Ze,1),!(Ze>_e.recurrence_end_date);)Xe.push(new Date(Ze))}const dt=Xe.map(Ze=>({title:_e.title,description:_e.description||null,image_url:Ge||null,video_url:_e.video_url||null,event_date:Ze.toISOString(),zoom_link:_e.zoom_link,zoom_meeting_id:_e.zoom_meeting_id||null,capacity:_e.capacity?parseInt(_e.capacity):null,is_published:_e.is_published})),{data:pt,error:Je}=await G.from("events").insert(dt).select();if(Je)throw Je;return pt&&pt.length>0&&CVt(_e.title,pt[0].id),Xe.length},onSuccess:_e=>{s.invalidateQueries({queryKey:["admin-events"]}),pe.success(_e>1?`${_e} recurring events created successfully`:"Event created successfully"),n(!1),i(Jz),u(null),f(null),_(!1)},onError:_e=>{pe.error("Failed to create event: "+_e.message),_(!1)}}),ut=Et({mutationFn:async({id:_e,data:Ge})=>{_(!0);let We=Ge.image_url;d&&(We=await ke(d)||"");const it=new Date(Ge.event_date),[Ve,Xe]=Ge.event_time.split(":");it.setHours(parseInt(Ve),parseInt(Xe));const{error:dt}=await G.from("events").update({title:Ge.title,description:Ge.description||null,image_url:We||null,video_url:Ge.video_url||null,event_date:it.toISOString(),zoom_link:Ge.zoom_link,zoom_meeting_id:Ge.zoom_meeting_id||null,capacity:Ge.capacity?parseInt(Ge.capacity):null,is_published:Ge.is_published}).eq("id",_e);if(dt)throw dt},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),pe.success("Event updated successfully"),n(!1),o(null),i(Jz),u(null),f(null),_(!1)},onError:_e=>{pe.error("Failed to update event: "+_e.message),_(!1)}}),fe=Et({mutationFn:async _e=>{const{error:Ge}=await G.from("events").delete().eq("id",_e);if(Ge)throw Ge},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),pe.success("Event deleted successfully")},onError:_e=>{pe.error("Failed to delete event: "+_e.message)}}),He=_e=>{var We;const Ge=new Date(_e.event_date);o(_e),i({title:_e.title,description:_e.description||"",image_url:_e.image_url||"",video_url:_e.video_url||"",event_date:Ge,event_time:gs(Ge,"HH:mm"),zoom_link:_e.zoom_link,zoom_meeting_id:_e.zoom_meeting_id||"",capacity:((We=_e.capacity)==null?void 0:We.toString())||"",is_published:_e.is_published,is_recurring:!1,recurrence_pattern:"weekly",recurrence_end_date:void 0}),f(_e.image_url||null),u(null),n(!0)},et=_e=>{if(_e.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?ut.mutate({id:a.id,data:l}):we.mutate(l)},tt=()=>{n(!1),o(null),i(Jz),u(null),f(null)};return e.jsx("div",{className:"min-h-screen bg-background p-6",children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>t("/dashboard"),children:e.jsx(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(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ft,{children:"All Events"}),e.jsxs(fs,{open:r,onOpenChange:_e=>!_e&&tt(),children:[e.jsx(hi,{asChild:!0,children:e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Event"]})}),e.jsxs(hs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:a?"Edit Event":"Create New Event"})}),e.jsxs("form",{onSubmit:et,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"title",children:"Title *"}),e.jsx(Le,{id:"title",value:l.title,onChange:_e=>i({...l,title:_e.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:_e=>i({...l,description:_e}),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:$e,className:"hidden"}),p?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:p,alt:"Event preview",className:"w-full h-32 object-cover rounded-lg border"}),e.jsx(K,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:Be,children:e.jsx(jr,{className:"h-4 w-4"})})]}):e.jsxs(K,{type:"button",variant:"outline",className:"w-full h-32 border-dashed flex flex-col gap-2",onClick:()=>{var _e;return(_e=b.current)==null?void 0:_e.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(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Dt("w-full justify-start text-left font-normal",!l.event_date&&"text-muted-foreground"),children:[e.jsx(ln,{className:"mr-2 h-4 w-4"}),l.event_date?gs(l.event_date,"PPP"):"Pick a date"]})}),e.jsx(uo,{className:"w-auto p-0",align:"start",children:e.jsx(uf,{mode:"single",selected:l.event_date,onSelect:_e=>i({...l,event_date:_e}),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(Le,{id:"time",type:"time",value:l.event_time,onChange:_e=>i({...l,event_time:_e.target.value}),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"zoom_link",children:"Zoom Link *"}),e.jsx(Le,{id:"zoom_link",value:l.zoom_link,onChange:_e=>i({...l,zoom_link:_e.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(Le,{id:"zoom_meeting_id",value:l.zoom_meeting_id,onChange:_e=>i({...l,zoom_meeting_id:_e.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(Le,{id:"video_url",value:l.video_url,onChange:_e=>i({...l,video_url:_e.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(Le,{id:"capacity",type:"number",value:l.capacity,onChange:_e=>i({...l,capacity:_e.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(Mr,{id:"is_recurring",checked:l.is_recurring,onCheckedChange:_e=>i({...l,is_recurring:_e})})]}),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(Fs,{value:l.recurrence_pattern,onValueChange:_e=>i({...l,recurrence_pattern:_e}),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsxs(Rs,{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(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Dt("w-full justify-start text-left font-normal",!l.recurrence_end_date&&"text-muted-foreground"),children:[e.jsx(ln,{className:"mr-2 h-4 w-4"}),l.recurrence_end_date?gs(l.recurrence_end_date,"PPP"):"Pick end date"]})}),e.jsx(uo,{className:"w-auto p-0",align:"start",children:e.jsx(uf,{mode:"single",selected:l.recurrence_end_date,onSelect:_e=>i({...l,recurrence_end_date:_e}),disabled:_e=>_e<(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 _e=1,Ge=new Date(l.event_date);for(;Ge=l.recurrence_pattern==="weekly"?x4(Ge,1):l.recurrence_pattern==="biweekly"?x4(Ge,2):Am(Ge,1),!(Ge>l.recurrence_end_date);)_e++;return _e})()," 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(Mr,{id:"is_published",checked:l.is_published,onCheckedChange:_e=>i({...l,is_published:_e})})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:tt,className:"flex-1",children:"Cancel"}),e.jsx(K,{type:"submit",className:"flex-1",disabled:we.isPending||ut.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(Re,{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(Ms,{children:[e.jsx(kt,{children:"Title"}),e.jsx(kt,{children:"Date & Time"}),e.jsx(kt,{children:"Registrations"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:J==null?void 0:J.map(_e=>e.jsxs(Ms,{children:[e.jsx(ht,{className:"font-medium",children:_e.title}),e.jsx(ht,{children:gs(new Date(_e.event_date),"PPP p")}),e.jsx(ht,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1",onClick:()=>ye(_e),children:[e.jsx(or,{className:"h-4 w-4"}),(ce==null?void 0:ce[_e.id])||0,_e.capacity&&` / ${_e.capacity}`]})}),e.jsx(ht,{children:e.jsx("span",{className:Dt("px-2 py-1 rounded-full text-xs font-medium",_e.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:_e.is_published?"Published":"Draft"})}),e.jsx(ht,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>window.open(_e.zoom_link,"_blank"),title:"Open Zoom Link",children:e.jsx(Zr,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>He(_e),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this event?")&&fe.mutate(_e.id)},children:e.jsx(xr,{className:"h-4 w-4 text-destructive"})})]})})]},_e.id))})]})})]}),e.jsx(fs,{open:N,onOpenChange:w,children:e.jsxs(hs,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(or,{className:"h-5 w-5"}),k==null?void 0:k.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(K,{variant:"ghost",size:"sm",onClick:()=>Ne.mutate({eventId:k.id,testMode:!0}),disabled:Ne.isPending,children:[e.jsx(tr,{className:Dt("h-4 w-4 mr-2",Ne.isPending&&"animate-spin")}),"Send Test to Me"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Ne.mutate({eventId:k.id}),disabled:Ne.isPending||!(ae!=null&&ae.length),children:[e.jsx(tr,{className:Dt("h-4 w-4 mr-2",Ne.isPending&&"animate-spin")}),Ne.isPending?"Sending...":"Send Reminder to All"]}),(k==null?void 0:k.zoom_meeting_id)&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>he.mutate(k.id),disabled:he.isPending,children:[e.jsx(Zi,{className:Dt("h-4 w-4 mr-2",he.isPending&&"animate-spin")}),he.isPending?"Syncing...":"Sync Registrations"]}),e.jsxs(K,{variant:"default",size:"sm",onClick:()=>ge.mutate(k.id),disabled:ge.isPending,children:[e.jsx(Vi,{className:Dt("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(ls,{value:"registrations",className:"gap-2",children:[e.jsx(or,{className:"h-4 w-4"}),"Registrations (",(ae==null?void 0:ae.length)||0,")"]}),e.jsxs(ls,{value:"attendees",className:"gap-2",children:[e.jsx(Hn,{className:"h-4 w-4"}),"Attendees (",(oe==null?void 0:oe.length)||0,")"]})]}),e.jsx(ws,{value:"registrations",className:"mt-4",children:ie?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading registrations..."}):(ae==null?void 0:ae.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No registrations yet for this event."}),(k==null?void 0:k.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(Ms,{children:[e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Email"}),e.jsx(kt,{children:"Registered"}),e.jsx(kt,{children:"Status"})]})}),e.jsx(Rn,{children:ae==null?void 0:ae.map(_e=>{var Ve,Xe;const Ge=((Ve=_e.profiles)==null?void 0:Ve.name)||_e.zoom_name||"Unknown",We=((Xe=_e.profiles)==null?void 0:Xe.email)||_e.zoom_email||null,it=!_e.user_id;return e.jsxs(Ms,{children:[e.jsx(ht,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[Ge,it&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"External"})]})}),e.jsx(ht,{children:We?e.jsxs("a",{href:`mailto:${We}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(tr,{className:"h-3 w-3"}),We]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(ht,{className:"text-muted-foreground text-sm",children:gs(new Date(_e.registered_at),"MMM d, yyyy h:mm a")}),e.jsx(ht,{children:_e.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"})})]},_e.id)})})]})}),e.jsx(ws,{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."}),(k==null?void 0:k.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(_e=>!_e.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(_e=>!_e.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(_e=>!_e.user_id).map(_e=>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:_e.zoom_name||"Unknown"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:_e.zoom_email||"No email"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Me(_e),className:"gap-1",children:[e.jsx(Do,{className:"h-3 w-3"}),"Link to Profile"]})]},_e.id))})]}),e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ms,{children:[e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Email"}),e.jsx(kt,{children:"Duration"}),e.jsx(kt,{children:"Points"})]})}),e.jsx(Rn,{children:oe==null?void 0:oe.filter(_e=>_e.user_id).map(_e=>{var it,Ve;const Ge=((it=_e.profiles)==null?void 0:it.name)||_e.zoom_name||"Unknown",We=((Ve=_e.profiles)==null?void 0:Ve.email)||_e.zoom_email||null;return e.jsxs(Ms,{children:[e.jsx(ht,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[Ge,_e.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:We?e.jsxs("a",{href:`mailto:${We}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(tr,{className:"h-3 w-3"}),We]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(ht,{children:_e.duration_minutes?e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-sm",children:[e.jsx(on,{className:"h-3 w-3"}),_e.duration_minutes," min"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(ht,{children:_e.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(Vi,{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"})})]},_e.id)})})]})]})})]})]})}),e.jsx(fs,{open:A,onOpenChange:I,children:e.jsxs(hs,{className:"max-w-md",children:[e.jsxs(js,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name or email...",value:te,onChange:_e=>Y(_e.target.value),className:"pl-9"})]})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-md",children:qe.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:qe.slice(0,20).map(_e=>e.jsxs("button",{type:"button",onClick:()=>q(_e.id),className:Dt("w-full p-3 text-left hover:bg-muted/50 transition-colors",V===_e.id&&"bg-primary/10 border-l-2 border-primary"),children:[e.jsx("p",{className:"text-sm font-medium",children:_e.name||"Unnamed"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:_e.email})]},_e.id))})}),L.zoom_email&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Hi,{id:"save-alias",checked:B,onCheckedChange:_e=>U(_e)}),e.jsx("label",{htmlFor:"save-alias",className:"text-sm text-muted-foreground cursor-pointer",children:"Remember this email for future auto-matching"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>I(!1),children:"Cancel"}),e.jsx(K,{onClick:De,disabled:!V||Te.isPending,children:Te.isPending?"Linking...":"Link & Award Points"})]})]})]})})]})})}function EVt({selectedKitIds:t,onChange:s}){const[r,n]=S.useState(""),[a,o]=S.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(jr,{className:"h-3 w-3"})})]},f.id))}),e.jsxs(yo,{open:a,onOpenChange:o,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(cl,{className:"h-3.5 w-3.5"}),"Add Toolkit"]})}),e.jsxs(uo,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(an,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search toolkits...",value:r,onChange:f=>n(f.target.value),className:"pl-7 h-8 text-sm"})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-0.5",children: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 PVt=()=>{const{user:t}=qs(),{toast:s}=ja(),r=Qt(),[n,a]=Nc(),[o,l]=S.useState(!1),[i,d]=S.useState(null),[u,p]=S.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]=S.useState(null),[_,b]=S.useState(0),[N,w]=S.useState(!1),[k,C]=S.useState(null),[A,I]=S.useState(""),[L,O]=S.useState([]),[V,q]=S.useState(""),[B,U]=S.useState(""),[te,Y]=S.useState(!1),[J,X]=S.useState(!1),{data:ce=[]}=gt({queryKey:["template-categories"],queryFn:async()=>{const{data:He,error:et}=await G.from("template_categories").select("*").order("name");if(et)throw et;return He}}),{data:ae=[]}=gt({queryKey:["template-types"],queryFn:async()=>{const{data:He,error:et}=await G.from("template_types").select("*").order("name");if(et)throw et;return He}}),{data:ie=[],isLoading:oe}=gt({queryKey:["canva-templates-admin"],queryFn:async()=>{const{data:He,error:et}=await G.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(et)throw et;const{data:tt,error:_e}=await G.from("template_links").select("*").order("sort_order");if(_e)throw _e;const{data:Ge,error:We}=await G.from("template_guides").select("*").order("sort_order");if(We)throw We;return He.map(Ve=>({...Ve,links:(tt==null?void 0:tt.filter(Xe=>Xe.template_id===Ve.id))||[],guides:(Ge==null?void 0:Ge.filter(Xe=>Xe.template_id===Ve.id))||[]}))}});S.useEffect(()=>{const He=n.get("edit");if(He&&ie.length>0){const et=ie.find(tt=>tt.id===He);et&&(Ue(et),a({},{replace:!0}))}},[ie,n]);const me=Et({mutationFn:async He=>{const{data:et,error:tt}=await G.from("template_categories").insert({name:He}).select().single();if(tt)throw tt;return et},onSuccess:He=>{r.invalidateQueries({queryKey:["template-categories"]}),p({...u,category_id:He.id}),q(""),Y(!1),s({title:"Category added"})},onError:He=>{s({title:"Error adding category",description:He.message,variant:"destructive"})}}),ye=Et({mutationFn:async He=>{const{data:et,error:tt}=await G.from("template_types").insert({name:He}).select().single();if(tt)throw tt;return et},onSuccess:He=>{r.invalidateQueries({queryKey:["template-types"]}),p({...u,type_id:He.id}),U(""),X(!1),s({title:"Type added"})},onError:He=>{s({title:"Error adding type",description:He.message,variant:"destructive"})}}),he=Et({mutationFn:async He=>{var We;let et=He.existingImageUrl;if(He.image){const it=He.image.name.split(".").pop(),Ve=`${Date.now()}-${Math.random().toString(36).substring(7)}.${it}`,{error:Xe}=await G.storage.from("template-previews").upload(Ve,He.image);if(Xe)throw Xe;const{data:dt}=G.storage.from("template-previews").getPublicUrl(Ve);et=dt.publicUrl}const tt={name:He.template.name,description:He.template.description||null,category_id:He.template.category_id||null,type_id:He.template.type_id||null,preview_image_url:et,video_url:He.videoUrl||null,publish_date:He.template.publish_date?new Date(He.template.publish_date).toISOString():new Date().toISOString(),created_by:t==null?void 0:t.id};let _e=He.templateId;if(_e){const{error:it}=await G.from("canva_templates").update(tt).eq("id",_e);if(it)throw it;const{error:Ve}=await G.from("template_links").delete().eq("template_id",_e);if(Ve)throw Ve;const Xe=((We=He.existingGuides)==null?void 0:We.map(Je=>Je.id).filter(Boolean))||[],dt=He.template.guides.map(Je=>Je.id).filter(Boolean),pt=Xe.filter(Je=>!dt.includes(Je));pt.length>0&&await G.from("template_guides").delete().in("id",pt)}else{const{data:it,error:Ve}=await G.from("canva_templates").insert(tt).select().single();if(Ve)throw Ve;_e=it.id,kVt(He.template.name,it.id)}const Ge=He.template.links.filter(it=>it.title.trim()&&it.canva_share_link.trim());if(Ge.length>0){const it=Ge.map((Xe,dt)=>({template_id:_e,title:Xe.title.trim(),canva_share_link:Xe.canva_share_link.trim(),sort_order:dt})),{error:Ve}=await G.from("template_links").insert(it);if(Ve)throw Ve}for(let it=0;it0)){const{error:it}=await G.from("resource_kit_templates").insert(He.linkedKitIds.map(Ve=>({template_id:_e,kit_id:Ve})));if(it)throw it}},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),Ne(),l(!1),s({title:i?"Template updated":"Template created"})},onError:He=>{s({title:"Error saving template",description:He.message,variant:"destructive"})}}),ge=Et({mutationFn:async He=>{const{error:et}=await G.from("canva_templates").delete().eq("id",He);if(et)throw et},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),s({title:"Template deleted"})},onError:He=>{s({title:"Error deleting template",description:He.message,variant:"destructive"})}}),Ne=()=>{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([])},Ue=async He=>{var tt;d(He),p({name:He.name,description:He.description||"",category_id:He.category_id||"",type_id:He.type_id||"",publish_date:He.publish_date?new Date(He.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],links:He.links&&He.links.length>0?He.links.map(_e=>({id:_e.id,title:_e.title,canva_share_link:_e.canva_share_link,sort_order:_e.sort_order})):[{title:"",canva_share_link:"",sort_order:0}],guides:((tt=He.guides)==null?void 0:tt.map(_e=>({id:_e.id,name:_e.name,file_url:_e.file_url,file_type:_e.file_type,file_size:_e.file_size,sort_order:_e.sort_order})))||[],video_url:He.video_url||""}),I(He.preview_image_url||""),y(null);const{data:et}=await G.from("resource_kit_templates").select("kit_id").eq("template_id",He.id);O((et||[]).map(_e=>_e.kit_id)),l(!0)},Te=He=>{var tt;const et=(tt=He.target.files)==null?void 0:tt[0];et&&(C(et),I(URL.createObjectURL(et)))},Me=()=>{p({...u,links:[...u.links,{title:"",canva_share_link:"",sort_order:u.links.length}]})},De=He=>{if(u.links.length<=1)return;const et=u.links.filter((tt,_e)=>_e!==He);p({...u,links:et})},qe=(He,et,tt)=>{const _e=[...u.links];_e[He]={..._e[He],[et]:tt},p({...u,links:_e})},ke=He=>{const et=He.target.files;if(!et)return;const tt=Array.from(et).map((_e,Ge)=>({name:_e.name.replace(/\.[^/.]+$/,""),file_url:"",file_type:_e.type,file_size:_e.size,sort_order:u.guides.length+Ge,file:_e}));p({...u,guides:[...u.guides,...tt]}),He.target.value=""},$e=He=>{const et=u.guides.filter((tt,_e)=>_e!==He);p({...u,guides:et})},Be=(He,et)=>{const tt=[...u.guides];tt[He]={...tt[He],name:et},p({...u,guides:tt})},we=async()=>{if(!f)return null;w(!0),b(0);try{const{data:He,error:et}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:u.name||f.name}});if(et)throw new Error(et.message);const{videoId:tt,libraryId:_e}=He,{data:Ge,error:We}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:tt}});if(We)throw new Error(We.message);const it=new XMLHttpRequest;return await new Promise((Xe,dt)=>{it.upload.addEventListener("progress",pt=>{if(pt.lengthComputable){const Je=Math.round(pt.loaded/pt.total*100);b(Je)}}),it.addEventListener("load",()=>{it.status>=200&&it.status<300?Xe():dt(new Error(`Upload failed with status ${it.status}`))}),it.addEventListener("error",()=>dt(new Error("Upload failed"))),it.open("PUT",Ge.uploadUrl),it.setRequestHeader("AccessKey",Ge.apiKey),it.send(f)}),`https://player.mediadelivery.net/embed/${_e}/${tt}`}catch(He){return console.error("Bunny upload error:",He),s({title:"Video upload failed",description:He instanceof Error?He.message:"Unknown error",variant:"destructive"}),null}finally{w(!1)}},ut=He=>{var tt;const et=(tt=He.target.files)==null?void 0:tt[0];et&&y(et),He.target.value=""},fe=async He=>{if(He.preventDefault(),!u.name.trim()){s({title:"Please enter a template name",variant:"destructive"});return}if(u.links.filter(_e=>_e.title.trim()&&_e.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 _e=await we();if(!_e)return;tt=_e}he.mutate({template:u,image:k,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(Es,{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(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Total Templates"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:ie.length})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Categories"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:ce.length})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Template Types"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:ae.length})})]})]}),e.jsxs(fs,{open:o,onOpenChange:He=>{l(He),He||Ne()},children:[e.jsx(hi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Bs,{className:"h-4 w-4"}),"Add Template"]})}),e.jsxs(hs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{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(Le,{id:"name",value:u.name,onChange:He=>p({...u,name:He.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:He=>p({...u,description:He}),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(K,{type:"button",variant:"outline",size:"sm",onClick:Me,className:"gap-1",children:[e.jsx(Bs,{className:"h-3 w-3"}),"Add Link"]})]}),e.jsx("div",{className:"space-y-3",children:u.links.map((He,et)=>e.jsxs("div",{className:"flex gap-2 items-start p-3 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(Le,{value:He.title,onChange:tt=>qe(et,"title",tt.target.value),placeholder:"Link title (e.g., Instagram Post, Story)"}),e.jsx(Le,{value:He.canva_share_link,onChange:tt=>qe(et,"canva_share_link",tt.target.value),placeholder:"https://www.canva.com/design/..."})]}),u.links.length>1&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>De(et),children:e.jsx(jr,{className:"h-4 w-4"})})]},et))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Category"}),te?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{value:V,onChange:He=>q(He.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>V.trim()&&me.mutate(V.trim()),disabled:me.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{Y(!1),q("")},children:e.jsx(jr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Fs,{value:u.category_id,onValueChange:He=>p({...u,category_id:He}),children:[e.jsx(Ds,{className:"flex-1",children:e.jsx(zs,{placeholder:"Select category"})}),e.jsx(Rs,{children:ce.map(He=>e.jsx(vt,{value:He.id,children:He.name},He.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>Y(!0),children:e.jsx(Bs,{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(Le,{value:B,onChange:He=>U(He.target.value),placeholder:"New type name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>B.trim()&&ye.mutate(B.trim()),disabled:ye.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{X(!1),U("")},children:e.jsx(jr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Fs,{value:u.type_id,onValueChange:He=>p({...u,type_id:He}),children:[e.jsx(Ds,{className:"flex-1",children:e.jsx(zs,{placeholder:"Select type"})}),e.jsx(Rs,{children:ae.map(He=>e.jsx(vt,{value:He.id,children:He.name},He.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>X(!0),children:e.jsx(Bs,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Le,{id:"publish_date",type:"date",value:u.publish_date,onChange:He=>p({...u,publish_date:He.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(K,{type:"button",size:"icon",variant:"destructive",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>{C(null),I("")},children:e.jsx(jr,{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(Le,{type:"file",accept:"image/*",onChange:Te,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(gn,{className:"h-5 w-5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:"Video uploaded"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>p({...u,video_url:""}),className:"text-destructive hover:text-destructive",children:"Remove"})]}),e.jsx("div",{className:"aspect-video max-w-md rounded-lg overflow-hidden border",children:e.jsx("iframe",{src:u.video_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})]}):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(fi,{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(gn,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:f.name}),e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[(f.size/1024/1024).toFixed(1)," MB"]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive h-8 w-8",onClick:()=>y(null),children:e.jsx(jr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(Le,{type:"file",accept:"video/*",onChange:ut,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(gn,{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(Le,{type:"file",accept:".pdf,.doc,.docx",multiple:!0,onChange:ke,className:"hidden"}),e.jsx(K,{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((He,et)=>e.jsxs("div",{className:"flex gap-2 items-center p-3 border rounded-lg bg-muted/30",children:[e.jsx(yn,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsx(Le,{value:He.name,onChange:tt=>Be(et,tt.target.value),placeholder:"Guide name",className:"flex-1"}),He.file_size&&e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[(He.file_size/1024).toFixed(0)," KB"]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive h-8 w-8",onClick:()=>$e(et),children:e.jsx(jr,{className:"h-4 w-4"})})]},He.id||et))}):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(EVt,{selectedKitIds:L,onChange:O}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>{l(!1),Ne()},children:"Cancel"}),e.jsx(K,{type:"submit",disabled:he.isPending,children:he.isPending?"Saving...":i?"Update":"Create"})]})]})]})]})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-0",children:oe?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading..."}):ie.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(Ms,{children:[e.jsx(kt,{children:"Preview"}),e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Links"}),e.jsx(kt,{children:"Category"}),e.jsx(kt,{children:"Type"}),e.jsx(kt,{children:"Publish Date"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:ie.map(He=>{var et,tt,_e,Ge,We;return e.jsxs(Ms,{children:[e.jsx(ht,{children:e.jsx("div",{className:"w-16 h-12 rounded overflow-hidden bg-muted",children:He.preview_image_url?e.jsx("img",{src:He.preview_image_url,alt:He.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:He.name}),e.jsx(ht,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs(Qe,{variant:"secondary",children:[((et=He.links)==null?void 0:et.length)||0," link",(((tt=He.links)==null?void 0:tt.length)||0)!==1?"s":""]}),(((_e=He.guides)==null?void 0:_e.length)||0)>0&&e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(yn,{className:"h-3 w-3"}),(Ge=He.guides)==null?void 0:Ge.length," guide",(((We=He.guides)==null?void 0:We.length)||0)!==1?"s":""]})]})}),e.jsx(ht,{children:He.category?e.jsx(Qe,{variant:"secondary",children:He.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(ht,{children:He.type?e.jsx(Qe,{variant:"outline",children:He.type.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(ht,{className:"text-muted-foreground",children:new Date(He.publish_date).toLocaleDateString()}),e.jsx(ht,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{size:"icon",variant:"ghost",onClick:()=>Ue(He),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&ge.mutate(He.id)},children:e.jsx(xr,{className:"h-4 w-4"})})]})})]},He.id)})})]})})})]})})};function ytt({selectedTemplateIds:t,onChange:s}){const[r,n]=S.useState(""),[a,o]=S.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(jr,{className:"h-3 w-3"})})]},f.id))}),e.jsxs(yo,{open:a,onOpenChange:o,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(iS,{className:"h-3.5 w-3.5"}),"Add Template"]})}),e.jsxs(uo,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(an,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search templates...",value:r,onChange:f=>n(f.target.value),className:"pl-7 h-8 text-sm"})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-0.5",children: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 IVt=[{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"}],LVt=()=>{const{user:t}=qs(),[s,r]=Nc(),{toast:n}=ja(),a=Qt(),[o,l]=S.useState(!1),[i,d]=S.useState(null),[u,p]=S.useState({title:"",description:"",video_url:"",video_type:"youtube",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[f,y]=S.useState(null),[_,b]=S.useState(""),[N,w]=S.useState([]),[k,C]=S.useState([]),[A,I]=S.useState([]),[L,O]=S.useState([]),[V,q]=S.useState(""),[B,U]=S.useState(!1),[te,Y]=S.useState(null),[J,X]=S.useState(0),[ce,ae]=S.useState(!1),[ie,oe]=S.useState(null),{data:me=[]}=gt({queryKey:["academy-categories"],queryFn:async()=>{const{data:fe,error:He}=await G.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(He)throw He;return fe}}),{data:ye=[],isLoading:he}=gt({queryKey:["academy-videos-admin"],queryFn:async()=>{const{data:fe,error:He}=await G.from("academy_videos").select(` *, category:academy_categories(id, name) `).order("publish_date",{ascending:!1});if(He)throw He;const{data:et,error:tt}=await G.from("academy_resources").select("*").order("sort_order");if(tt)throw tt;return fe.map(Ge=>({...Ge,resources:(et==null?void 0:et.filter(We=>We.video_id===Ge.id))||[]}))}});S.useEffect(()=>{const fe=s.get("edit");if(fe&&ye.length>0){const He=ye.find(et=>et.id===fe);He&&(De(He),r({},{replace:!0}))}},[ye,s]);const ge=Et({mutationFn:async fe=>{const{data:He,error:et}=await G.from("academy_categories").insert({name:fe,sort_order:me.length}).select().single();if(et)throw et;return He},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"})}}),Ne=Et({mutationFn:async fe=>{let He=fe.existingThumbnailUrl;if(fe.thumbnail){const _e=fe.thumbnail.name.split(".").pop(),Ge=`thumbnails/${Date.now()}-${Math.random().toString(36).substring(7)}.${_e}`,{error:We}=await G.storage.from("academy-resources").upload(Ge,fe.thumbnail);if(We)throw We;const{data:it}=G.storage.from("academy-resources").getPublicUrl(Ge);He=it.publicUrl}const et={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:He,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:_e}=await G.from("academy_videos").update(et).eq("id",tt);if(_e)throw _e}else{const{data:_e,error:Ge}=await G.from("academy_videos").insert(et).select().single();if(Ge)throw Ge;tt=_e.id,SVt(fe.video.title,_e.id)}if(fe.resourcesToDelete.length>0){const{error:_e}=await G.from("academy_resources").delete().in("id",fe.resourcesToDelete);if(_e)throw _e}for(let _e=0;_e0){const{error:_e}=await G.from("academy_video_templates").insert(L.map(Ge=>({video_id:tt,template_id:Ge})));if(_e)throw _e}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),Me(),l(!1),n({title:i?"Video updated":"Video created"})},onError:fe=>{n({title:"Error saving video",description:fe.message,variant:"destructive"})}}),Ue=Et({mutationFn:async fe=>{const{error:He}=await G.from("academy_videos").delete().eq("id",fe);if(He)throw He},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"})}}),Te=Et({mutationFn:async({id:fe,is_published:He})=>{const{error:et}=await G.from("academy_videos").update({is_published:He}).eq("id",fe);if(et)throw et},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]})},onError:fe=>{n({title:"Error updating video",description:fe.message,variant:"destructive"})}}),Me=()=>{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),ae(!1),oe(null)},De=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:He}=await G.from("academy_video_templates").select("template_id").eq("video_id",fe.id);O((He||[]).map(et=>et.template_id)),l(!0)},qe=fe=>{var et;const He=(et=fe.target.files)==null?void 0:et[0];He&&(y(He),b(URL.createObjectURL(He)))},ke=fe=>{const He=fe.target.files;if(He){const et=Array.from(He).map(tt=>({file:tt,title:tt.name.replace(/\.[^/.]+$/,"")}));w([...N,...et])}fe.target.value=""},$e=fe=>{w(N.filter((He,et)=>et!==fe))},Be=fe=>{I([...A,fe]),C(k.filter(He=>He.id!==fe))},we=async()=>{if(!te)return null;ae(!0),X(0);try{const{data:fe,error:He}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:u.title||te.name}});if(He)throw new Error(He.message);const{videoId:et,libraryId:tt}=fe;oe(et);const{data:_e,error:Ge}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:et}});if(Ge)throw new Error(Ge.message);const We=new XMLHttpRequest;return await new Promise((Ve,Xe)=>{We.upload.addEventListener("progress",dt=>{if(dt.lengthComputable){const pt=Math.round(dt.loaded/dt.total*100);X(pt)}}),We.addEventListener("load",()=>{We.status>=200&&We.status<300?Ve():Xe(new Error(`Upload failed with status ${We.status}`))}),We.addEventListener("error",()=>Xe(new Error("Upload failed"))),We.open("PUT",_e.uploadUrl),We.setRequestHeader("AccessKey",_e.apiKey),We.send(te)}),`https://player.mediadelivery.net/embed/${tt}/${et}`}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{ae(!1)}},ut=async fe=>{if(fe.preventDefault(),!u.title.trim()){n({title:"Please enter a video title",variant:"destructive"});return}let He=u.video_url;if(u.video_type==="bunny_stream"&&te&&!i){const et=await we();if(!et)return;He=et}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}Ne.mutate({video:{...u,video_url:He},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(Es,{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(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Total Videos"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:ye.length})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:ye.filter(fe=>fe.is_published).length})})]})]}),e.jsxs(fs,{open:o,onOpenChange:fe=>{l(fe),fe||Me()},children:[e.jsx(hi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Bs,{className:"h-4 w-4"}),"Add Video"]})}),e.jsxs(hs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:i?"Edit Video":"Add New Video"})}),e.jsxs("form",{onSubmit:ut,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"title",children:"Title *"}),e.jsx(Le,{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(Fs,{value:u.video_type,onValueChange:fe=>{p({...u,video_type:fe,video_url:""}),Y(null)},disabled:ce,children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsx(Rs,{children:IVt.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(Le,{type:"file",accept:"video/*",onChange:fe=>{var et;const He=(et=fe.target.files)==null?void 0:et[0];He&&Y(He)},disabled:ce}),te&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(gn,{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(fi,{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(Le,{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(Le,{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(Le,{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(Le,{value:V,onChange:fe=>q(fe.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>V.trim()&&ge.mutate(V.trim()),disabled:ge.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{U(!1),q("")},children:e.jsx(jr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Fs,{value:u.category_id,onValueChange:fe=>p({...u,category_id:fe}),children:[e.jsx(Ds,{className:"flex-1",children:e.jsx(zs,{placeholder:"Select category"})}),e.jsx(Rs,{children:me.map(fe=>e.jsx(vt,{value:fe.id,children:fe.name},fe.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:()=>U(!0),children:e.jsx(Bs,{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(Le,{type:"file",accept:"image/*",onChange:qe,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(K,{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:ke,className:"hidden"})]})})]}),(k.length>0||N.length>0)&&e.jsxs("div",{className:"space-y-2 mt-2",children:[k.map(fe=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(yn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm truncate",children:fe.title}),e.jsx(Qe,{variant:"outline",className:"text-xs",children:fe.file_type}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>Be(fe.id),className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})]},fe.id)),N.map((fe,He)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(yn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Le,{value:fe.title,onChange:et=>{const tt=[...N];tt[He].title=et.target.value,w(tt)},className:"flex-1 h-8",placeholder:"Resource title"}),e.jsx(Qe,{variant:"secondary",className:"text-xs",children:"New"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>$e(He),className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})]},He))]}),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(Mr,{id:"is_published",checked:u.is_published,onCheckedChange:fe=>p({...u,is_published:fe})}),e.jsx(xe,{htmlFor:"is_published",children:"Published"})]}),e.jsxs(_n,{children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),disabled:ce,children:"Cancel"}),e.jsx(K,{type:"submit",disabled:Ne.isPending||ce,children:ce?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):Ne.isPending?"Saving...":i?"Update Video":"Add Video"})]})]})]})]})]}),e.jsx(Pe,{children:e.jsx(Re,{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"})}):ye.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(gn,{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(Ms,{children:[e.jsx(kt,{children:"Title"}),e.jsx(kt,{children:"Category"}),e.jsx(kt,{children:"Duration"}),e.jsx(kt,{children:"Resources"}),e.jsx(kt,{children:"Publish Date"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"w-[120px]",children:"Actions"})]})}),e.jsx(Rn,{children:ye.map(fe=>e.jsxs(Ms,{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(gn,{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(Mr,{checked:fe.is_published,onCheckedChange:He=>Te.mutate({id:fe.id,is_published:He})})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>De(fe),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Ue.mutate(fe.id),className:"text-destructive hover:text-destructive",children:e.jsx(xr,{className:"h-4 w-4"})})]})})]},fe.id))})]})})})]})})};function DVt(){var Ne,Ue,Te;const t=Qt(),[s,r]=Nc(),[n,a]=S.useState(!1),[o,l]=S.useState(null),[i,d]=S.useState({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,p]=S.useState(null),[f,y]=S.useState(""),[_,b]=S.useState([]),[N,w]=S.useState([]),[k,C]=S.useState([]),[A,I]=S.useState(null),{data:L,isLoading:O}=gt({queryKey:["resource-kits"],queryFn:async()=>{const{data:Me,error:De}=await G.from("resource_kits").select("*").order("publish_date",{ascending:!1});if(De)throw De;return Me}}),{data:V}=gt({queryKey:["resource-kit-files"],queryFn:async()=>{const{data:Me,error:De}=await G.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(De)throw De;return Me}}),{data:q}=gt({queryKey:["resource-kit-links"],queryFn:async()=>{const{data:Me,error:De}=await G.from("resource_kit_links").select("*").order("sort_order",{ascending:!0});if(De)throw De;return Me}});S.useEffect(()=>{const Me=s.get("edit");if(Me&&L&&L.length>0&&V&&q){const De=L.find(qe=>qe.id===Me);De&&(U(De),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 Me=>{l(Me),d({name:Me.name,description:Me.description||"",publish_date:Me.publish_date.split("T")[0],is_published:Me.is_published}),y(Me.featured_image_url||"");const De=(V==null?void 0:V.filter($e=>$e.kit_id===Me.id))||[];b(De.map($e=>({id:$e.id,name:$e.name,file_url:$e.file_url,file_type:$e.file_type,file_size:$e.file_size,sort_order:$e.sort_order})));const qe=(q==null?void 0:q.filter($e=>$e.kit_id===Me.id))||[];w(qe.map($e=>({id:$e.id,title:$e.title,canva_share_link:$e.canva_share_link,sort_order:$e.sort_order})));const{data:ke}=await G.from("resource_kit_templates").select("template_id").eq("kit_id",Me.id);C((ke||[]).map($e=>$e.template_id)),a(!0)},te=Me=>{var qe;const De=(qe=Me.target.files)==null?void 0:qe[0];De&&(p(De),y(URL.createObjectURL(De)))},Y=()=>{b([..._,{name:"",file_url:"",sort_order:_.length}])},J=Me=>{b(_.filter((De,qe)=>qe!==Me))},X=(Me,De,qe)=>{const ke=[..._];ke[Me]={...ke[Me],[De]:qe},b(ke)},ce=()=>{w([...N,{title:"",canva_share_link:"",sort_order:N.length}])},ae=Me=>{w(N.filter((De,qe)=>qe!==Me))},ie=(Me,De,qe)=>{const ke=[...N];ke[Me]={...ke[Me],[De]:qe},w(ke)},oe=(Me,De)=>{var ke;const qe=(ke=De.target.files)==null?void 0:ke[0];if(qe){const $e=[..._],Be=qe.name.replace(/\.[^/.]+$/,"");$e[Me]={...$e[Me],file:qe,file_type:qe.type,file_size:qe.size,name:$e[Me].name||Be},b($e)}},me=Et({mutationFn:async()=>{let Me=(o==null?void 0:o.featured_image_url)||null;if(u){const Be=u.name.split(".").pop(),we=`${Date.now()}.${Be}`,{error:ut}=await G.storage.from("resource-kits").upload(`featured/${we}`,u);if(ut)throw ut;const{data:fe}=G.storage.from("resource-kits").getPublicUrl(`featured/${we}`);Me=fe.publicUrl}const De={name:i.name,description:i.description||null,featured_image_url:Me,publish_date:i.publish_date,is_published:i.is_published};let qe;const ke=!o,$e=(o==null?void 0:o.is_published)||!1;if(o){const{error:Be}=await G.from("resource_kits").update(De).eq("id",o.id);if(Be)throw Be;qe=o.id;const we=(V==null?void 0:V.filter(_e=>_e.kit_id===o.id).map(_e=>_e.id))||[],ut=_.filter(_e=>_e.id).map(_e=>_e.id),fe=we.filter(_e=>!ut.includes(_e));fe.length>0&&await G.from("resource_kit_files").delete().in("id",fe);const He=(q==null?void 0:q.filter(_e=>_e.kit_id===o.id).map(_e=>_e.id))||[],et=N.filter(_e=>_e.id).map(_e=>_e.id),tt=He.filter(_e=>!et.includes(_e));tt.length>0&&await G.from("resource_kit_links").delete().in("id",tt)}else{const{data:Be,error:we}=await G.from("resource_kits").insert(De).select().single();if(we)throw we;qe=Be.id}for(let Be=0;Be<_.length;Be++){const we=_[Be];let ut=we.file_url;if(we.file){const fe=we.file.name.split(".").pop(),He=`${Date.now()}-${Be}.${fe}`,{error:et}=await G.storage.from("resource-kits").upload(`files/${He}`,we.file);if(et)throw et;const{data:tt}=G.storage.from("resource-kits").getPublicUrl(`files/${He}`);ut=tt.publicUrl}we.id?await G.from("resource_kit_files").update({name:we.name,file_url:ut,file_type:we.file_type,file_size:we.file_size,sort_order:Be}).eq("id",we.id):ut&&we.name&&await G.from("resource_kit_files").insert({kit_id:qe,name:we.name,file_url:ut,file_type:we.file_type,file_size:we.file_size,sort_order:Be})}for(let Be=0;Be0){const{error:Be}=await G.from("resource_kit_templates").insert(k.map(we=>({kit_id:qe,template_id:we})));if(Be)throw Be}return{kitId:qe,kitName:i.name,isNewKit:ke,wasPublished:$e,isPublished:i.is_published}},onSuccess:Me=>{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"),Me.isPublished&&(Me.isNewKit||!Me.wasPublished)&&MVt(Me.kitName,Me.kitId),a(!1),B()},onError:Me=>{pe.error("Failed to save resource kit: "+Me.message)}}),ye=Et({mutationFn:async Me=>{const{error:De}=await G.from("resource_kits").delete().eq("id",Me);if(De)throw De},onSuccess:()=>{t.invalidateQueries({queryKey:["resource-kits"]}),t.invalidateQueries({queryKey:["resource-kit-files"]}),pe.success("Resource kit deleted")},onError:Me=>{pe.error("Failed to delete: "+Me.message)}}),he=Me=>{if(Me.preventDefault(),!i.name){pe.error("Please enter a name");return}me.mutate()},ge=Me=>(V==null?void 0:V.filter(De=>De.kit_id===Me).length)||0;return e.jsx(Es,{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(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Total Kits"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:(L==null?void 0:L.length)||0})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:(L==null?void 0:L.filter(Me=>Me.is_published).length)||0})})]})]}),e.jsxs(K,{onClick:()=>{B(),a(!0)},children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Resource Kit"]})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ms,{children:[e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Files"}),e.jsx(kt,{children:"Publish Date"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:O?e.jsx(Ms,{children:e.jsx(ht,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):(L==null?void 0:L.length)===0?e.jsx(Ms,{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(Me=>e.jsxs(Ms,{children:[e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Me.featured_image_url?e.jsx("img",{src:Me.featured_image_url,alt:Me.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:Me.name}),Me.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Me.description})]})]})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(yn,{className:"h-4 w-4 text-muted-foreground"}),ge(Me.id)]})}),e.jsx(ht,{children:gs(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":"bg-yellow-100 text-yellow-800"}`,children:Me.is_published?"Published":"Draft"})}),e.jsx(ht,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{const De=(V==null?void 0:V.filter(ke=>ke.kit_id===Me.id))||[],qe=(q==null?void 0:q.filter(ke=>ke.kit_id===Me.id))||[];I({...Me,files:De,links:qe})},children:e.jsx(Cn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>U(Me),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource kit?")&&ye.mutate(Me.id)},children:e.jsx(xr,{className:"h-4 w-4 text-destructive"})})]})})]},Me.id))})]})})}),e.jsx(fs,{open:n,onOpenChange:a,children:e.jsxs(hs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{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(Le,{type:"file",accept:"image/*",onChange:te})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"name",children:"Name *"}),e.jsx(Le,{id:"name",value:i.name,onChange:Me=>d({...i,name:Me.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:Me=>d({...i,description:Me}),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(Le,{id:"publish_date",type:"date",value:i.publish_date,onChange:Me=>d({...i,publish_date:Me.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(Mr,{checked:i.is_published,onCheckedChange:Me=>d({...i,is_published:Me})}),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(K,{type:"button",variant:"outline",size:"sm",onClick:Y,children:[e.jsx(Bs,{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((Me,De)=>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 ",De+1]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>J(De),children:e.jsx(jr,{className:"h-4 w-4"})})]}),e.jsx(Le,{placeholder:"File name (e.g., Getting Started Guide)",value:Me.name,onChange:qe=>X(De,"name",qe.target.value)}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{type:"file",onChange:qe=>oe(De,qe),className:"flex-1"}),Me.file_url&&!Me.file&&e.jsx("a",{href:Me.file_url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline whitespace-nowrap",children:"Current file"}),Me.file&&e.jsx("span",{className:"text-sm text-green-600 whitespace-nowrap",children:"New file selected"})]})]},De))})]}),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(K,{type:"button",variant:"outline",size:"sm",onClick:ce,children:[e.jsx(Bs,{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((Me,De)=>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 ",De+1]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>ae(De),children:e.jsx(jr,{className:"h-4 w-4"})})]}),e.jsx(Le,{placeholder:"Link title (e.g., Social Media Post Template)",value:Me.title,onChange:qe=>ie(De,"title",qe.target.value)}),e.jsx(Le,{placeholder:"Canva share link (e.g., https://www.canva.com/design/...)",value:Me.canva_share_link,onChange:qe=>ie(De,"canva_share_link",qe.target.value)})]},De))})]}),e.jsx(ytt,{selectedTemplateIds:k,onChange:C}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:me.isPending,children:me.isPending?"Saving...":o?"Update":"Create"})]})]})]})}),e.jsx(fs,{open:!!A,onOpenChange:()=>I(null),children:e.jsxs(hs,{className:"max-w-lg",children:[e.jsx(js,{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 (",((Ne=A==null?void 0:A.files)==null?void 0:Ne.length)||0,")"]}),((Ue=A==null?void 0:A.files)==null?void 0:Ue.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:(Te=A==null?void 0:A.files)==null?void 0:Te.map(Me=>e.jsxs("a",{href:Me.file_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 p-2 rounded-md hover:bg-muted transition-colors",children:[e.jsx(yn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Me.name})]},Me.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(Me=>e.jsxs("a",{href:Me.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(go,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Me.title})]},Me.id))})]})]})]})})]})})}const RVt=()=>{const{user:t}=qs(),{toast:s}=ja(),r=Qt(),[n,a]=S.useState(!1),[o,l]=S.useState(null),[i,d]=S.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,links:[{title:"",canva_share_link:"",sort_order:0}]}),[u,p]=S.useState(null),[f,y]=S.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=Et({mutationFn:async q=>{let B=q.existingImageUrl;if(q.image){const ce=q.image.name.split(".").pop(),ae=`${Date.now()}-${Math.random().toString(36).substring(7)}.${ce}`,{error:ie}=await G.storage.from("template-previews").upload(ae,q.image);if(ie)throw ie;const{data:oe}=G.storage.from("template-previews").getPublicUrl(ae);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:ae}=await G.from("social_swag").insert(U).select().single();if(ae)throw ae;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((ie,oe)=>({swag_id:te,title:ie.title.trim(),canva_share_link:ie.canva_share_link.trim(),sort_order:oe})),{error:ae}=await G.from("social_swag_links").insert(ce);if(ae)throw ae}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),k()},onError:q=>{s({title:"Error saving item",description:q.message,variant:"destructive"})}}),w=Et({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"})}}),k=()=>{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(Es,{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(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Total Items"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.length})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Re,{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||k()},children:[e.jsx(hi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Bs,{className:"h-4 w-4"}),"Add Item"]})}),e.jsxs(hs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{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(Le,{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(Le,{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(Mr,{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(K,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{p(null),y("")},children:e.jsx(jr,{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(Le,{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(K,{type:"button",variant:"outline",size:"sm",onClick:I,children:[e.jsx(Bs,{className:"h-3 w-3 mr-1"}),"Add Link"]})]}),i.links.map((q,B)=>e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4 pb-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground",children:["Link ",B+1]}),i.links.length>1&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>L(B),children:e.jsx(jr,{className:"h-3 w-3"})})]}),e.jsx(Le,{placeholder:"Link title (e.g., Instagram Post)",value:q.title,onChange:U=>O(B,"title",U.target.value)}),e.jsx(Le,{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(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:N.isPending,children:N.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(Pe,{children:e.jsx(Re,{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(Ms,{children:[e.jsx(kt,{className:"w-16",children:"Preview"}),e.jsx(kt,{children:"Title"}),e.jsx(kt,{children:"Links"}),e.jsx(kt,{children:"Publish Date"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:_.map(q=>{var B;return e.jsxs(Ms,{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(K,{variant:"ghost",size:"icon",onClick:()=>window.open(`/social-swag/${q.id}`,"_blank"),children:e.jsx(Cn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>C(q),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this item?")&&w.mutate(q.id)},children:e.jsx(xr,{className:"h-4 w-4"})})]})})]},q.id)})})]})})})]})})};function OVt(){for(var t=arguments.length,s=new Array(t),r=0;rn=>{s.forEach(a=>a(n))},s)}const Mhe=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 bp(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}=bp(t);return t instanceof s}function nO(t){return nE(t)?!1:t instanceof bp(t).HTMLElement}function vtt(t){return t instanceof bp(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=Mhe?S.useLayoutEffect:S.useEffect;function g4e(t){const s=S.useRef(t);return g0(()=>{s.current=t}),S.useCallback(function(){for(var r=arguments.length,n=new Array(r),a=0;a{t.current=setInterval(n,a)},[]),r=S.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[s,r]}function kD(t,s){s===void 0&&(s=[t]);const r=S.useRef(t);return g0(()=>{r.current!==t&&(r.current=t)},s),r}function aO(t,s){const r=S.useRef();return S.useMemo(()=>{const n=t(r.current);return r.current=n,n},[...s])}function fce(t){const s=g4e(t),r=S.useRef(null),n=S.useCallback(a=>{a!==r.current&&(s==null||s(a,r.current)),r.current=a},[]);return[r,n]}function Y_e(t){const s=S.useRef();return S.useEffect(()=>{s.current=t},[t]),s.current}let Cye={};function iO(t,s){return S.useMemo(()=>{if(s)return s;const r=Cye[t]==null?0:Cye[t]+1;return Cye[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 zVt(t){return"clientX"in t&&"clientY"in t}function y4e(t){if(!t)return!1;const{KeyboardEvent:s}=bp(t.target);return s&&t instanceof s}function BVt(t){if(!t)return!1;const{TouchEvent:s}=bp(t.target);return s&&t instanceof s}function X_e(t){if(BVt(t)){if(t.touches&&t.touches.length){const{clientX:s,clientY:r}=t.touches[0];return{x:s,y:r}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:s,clientY:r}=t.changedTouches[0];return{x:s,y:r}}}return zVt(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}}}),aDe="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function $Vt(t){return t.matches(aDe)?t:t.querySelector(aDe)}const qVt={display:"none"};function UVt(t){let{id:s,value:r}=t;return xt.createElement("div",{id:s,style:qVt},r)}function VVt(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 HVt(){const[t,s]=S.useState("");return{announce:S.useCallback(n=>{n!=null&&s(n)},[]),announcement:t}}const btt=S.createContext(null);function GVt(t){const s=S.useContext(btt);S.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of ");return s(t)},[t,s])}function WVt(){const[t]=S.useState(()=>new Set),s=S.useCallback(n=>(t.add(n),()=>t.delete(n)),[t]);return[S.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 KVt={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. `},ZVt={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 YVt(t){let{announcements:s=ZVt,container:r,hiddenTextDescribedById:n,screenReaderInstructions:a=KVt}=t;const{announce:o,announcement:l}=HVt(),i=iO("DndLiveRegion"),[d,u]=S.useState(!1);if(S.useEffect(()=>{u(!0)},[]),GVt(S.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(UVt,{id:n,value:a.draggable}),xt.createElement(VVt,{id:i,announcement:l}));return r?ip.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 xce(){}function gce(t,s){return S.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 XVt(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return n-r}function iDe(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 oDe(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=oDe(s,s.left,s.top),o=[];for(const l of n){const{id:i}=l,d=r.get(i);if(d){const u=wtt(oDe(d),a);o.push({id:i,data:{droppableContainer:l,value:u}})}}return o.sort(jtt)},QVt=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=iDe(s),o=[];for(const l of n){const{id:i}=l,d=r.get(i);if(d){const u=iDe(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 JVt(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=JVt(i,s);d>0&&a.push({id:l,data:{droppableContainer:o,value:d}})}}return a.sort(XVt)};function tHt(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 sHt(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 rHt=sHt(1);function nHt(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 aHt(t,s,r){const n=nHt(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 iHt={ignoreTransform:!1};function iE(t,s){s===void 0&&(s=iHt);let r=t.getBoundingClientRect();if(s.ignoreTransform){const{transform:u,transformOrigin:p}=bp(t).getComputedStyle(t);u&&(r=aHt(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 lDe(t){return iE(t,{ignoreTransform:!0})}function oHt(t){const s=t.innerWidth,r=t.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function lHt(t,s){return s===void 0&&(s=bp(t).getComputedStyle(t)),s.position==="fixed"}function cHt(t,s){s===void 0&&(s=bp(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 The(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=bp(t).getComputedStyle(a);return a!==t&&cHt(a,o)&&r.push(a),lHt(a,o)?r:n(a.parentNode)}return t?n(t):r}function Stt(t){const[s]=The(t,1);return s??null}function Mye(t){return!Mhe||!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!Mhe||!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 dHt={x:.2,y:.2};function uHt(t,s,r,n,a){let{top:o,left:l,right:i,bottom:d}=r;n===void 0&&(n=10),a===void 0&&(a=dHt);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 hHt(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 mHt(t){return t.reduce((s,r)=>s+Ctt(r),0)}function pHt(t){return t.reduce((s,r)=>s+Mtt(r),0)}function fHt(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 xHt=[["x",["left","right"],mHt],["y",["top","bottom"],pHt]];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=The(r),a=Ett(n);this.rect={...s},this.width=s.width,this.height=s.height;for(const[o,l,i]of xHt)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 gHt(t){const{EventTarget:s}=bp(t);return t instanceof s?t:aE(t)}function Tye(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 cDe(t){t.preventDefault()}function yHt(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]},vHt=(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(bp(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&&fHt(n),r(Vg)}handleKeyDown(s){if(y4e(s)){const{active:r,context:n,options:a}=this.props,{keyboardCodes:o=Ptt,coordinateGetter:l=vHt,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:k,isRight:C,isLeft:A,isBottom:I,maxScroll:L,minScroll:O}=Att(N),V=hHt(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&&!k;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 dDe(t){return!!(t&&"distance"in t)}function uDe(t){return!!(t&&"delay"in t)}class j4e{constructor(s,r,n){var a;n===void 0&&(n=gHt(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(bp(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,cDe),this.windowListeners.add(rx.VisibilityChange,this.handleCancel),this.windowListeners.add(rx.ContextMenu,cDe),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(uDe(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(dDe(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,yHt,{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(dDe(i)){if(i.tolerance!=null&&Tye(u,i.tolerance))return this.handleCancel();if(Tye(u,i.distance))return this.handleStart()}if(uDe(i)&&Tye(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 _Ht={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,_Ht,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 bHt={move:{name:"mousemove"},end:{name:"mouseup"}};var J_e;(function(t){t[t.RightClick=2]="RightClick"})(J_e||(J_e={}));class wHt extends j4e{constructor(s){super(s,bHt,aE(s.event.target))}}wHt.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 Aye={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class jHt extends j4e{constructor(s){super(s,Aye)}static setup(){return window.addEventListener(Aye.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(Aye.move.name,s)};function s(){}}}jHt.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 yce;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(yce||(yce={}));function NHt(t){let{acceleration:s,activator:r=v8.Pointer,canScroll:n,draggingRect:a,enabled:o,interval:l=5,order:i=yce.TreeOrder,pointerCoordinates:d,scrollableAncestors:u,scrollableAncestorRects:p,delta:f,threshold:y}=t;const _=SHt({delta:f,disabled:!o}),[b,N]=FVt(),w=S.useRef({x:0,y:0}),k=S.useRef({x:0,y:0}),C=S.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=S.useRef(null),I=S.useCallback(()=>{const O=A.current;if(!O)return;const V=w.current.x*k.current.x,q=w.current.y*k.current.y;O.scrollBy(V,q)},[]),L=S.useMemo(()=>i===yce.TreeOrder?[...u].reverse():u,[i,u]);S.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}=uHt(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,k.current=B;return}}w.current={x:0,y:0},k.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 kHt={x:{[Lu.Backward]:!1,[Lu.Forward]:!1},y:{[Lu.Backward]:!1,[Lu.Forward]:!1}};function SHt(t){let{delta:s,disabled:r}=t;const n=Y_e(s);return aO(a=>{if(r||!n||!a)return kHt;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 CHt(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 MHt(t,s){return S.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 hDe=new Map;function THt(t,s){let{dragging:r,dependencies:n,config:a}=s;const[o,l]=S.useState(null),{frequency:i,measure:d,strategy:u}=a,p=S.useRef(t),f=w(),y=kD(f),_=S.useCallback(function(k){k===void 0&&(k=[]),!y.current&&l(C=>C===null?k:C.concat(k.filter(A=>!C.includes(A))))},[y]),b=S.useRef(null),N=aO(k=>{if(f&&!r)return hDe;if(!k||k===hDe||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 k},[t,o,r,f,d]);return S.useEffect(()=>{p.current=t},[t]),S.useEffect(()=>{f||_()},[r,f]),S.useEffect(()=>{o&&o.length>0&&l(null)},[JSON.stringify(o)]),S.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 AHt(t,s){return Itt(t,s)}function EHt(t){let{callback:s,disabled:r}=t;const n=g4e(s),a=S.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(n)},[n,r]);return S.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function Ahe(t){let{callback:s,disabled:r}=t;const n=g4e(s),a=S.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(n)},[r]);return S.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function PHt(t){return new b4e(iE(t),t)}function mDe(t,s,r){s===void 0&&(s=PHt);const[n,a]=S.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=EHt({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=Ahe({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 IHt(t){const s=Itt(t);return ktt(t,s)}const pDe=[];function LHt(t){const s=S.useRef(t),r=aO(n=>t?n&&n!==pDe&&t&&s.current&&t.parentNode===s.current.parentNode?n:The(t):pDe,[t]);return S.useEffect(()=>{s.current=t},[t]),r}function DHt(t){const[s,r]=S.useState(null),n=S.useRef(t),a=S.useCallback(o=>{const l=Mye(o.target);l&&r(i=>i?(i.set(l,Q_e(l)),new Map(i)):null)},[]);return S.useEffect(()=>{const o=n.current;if(t!==o){l(o);const i=t.map(d=>{const u=Mye(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=Mye(d);u==null||u.removeEventListener("scroll",a)})}},[a,t]),S.useMemo(()=>t.length?s?Array.from(s.values()).reduce((o,l)=>QM(o,l),Vg):Ett(t):Vg,[t,s])}function fDe(t,s){s===void 0&&(s=[]);const r=S.useRef(null);return S.useEffect(()=>{r.current=null},s),S.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 RHt(t){S.useEffect(()=>{if(!Mhe)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 OHt(t,s){return S.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 S.useMemo(()=>t?oHt(t):null,[t])}const xDe=[];function FHt(t,s){s===void 0&&(s=iE);const[r]=t,n=Ltt(r?bp(r):null),[a,o]=S.useState(xDe);function l(){o(()=>t.length?t.map(d=>Ttt(d)?n:new b4e(s(d),d)):xDe)}const i=Ahe({callback:l});return g0(()=>{i==null||i.disconnect(),l(),t.forEach(d=>i==null?void 0:i.observe(d))},[t]),a}function zHt(t){if(!t)return null;if(t.children.length>1)return t;const s=t.children[0];return nO(s)?s:t}function BHt(t){let{measure:s}=t;const[r,n]=S.useState(null),a=S.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=Ahe({callback:a}),l=S.useCallback(u=>{const p=zHt(u);o==null||o.disconnect(),p&&(o==null||o.observe(p)),n(p?s(p):null)},[s,o]),[i,d]=fce(l);return S.useMemo(()=>({nodeRef:i,rect:r,setRef:d}),[r,i,d])}const $Ht=[{sensor:oO,options:{}},{sensor:w4e,options:{}}],qHt={current:{}},ioe={draggable:{measure:lDe},droppable:{measure:lDe,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 UHt={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:xce},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:ioe,measureDroppableContainers:xce,windowRect:null,measuringScheduled:!1},VHt={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:xce,draggableNodes:new Map,over:null,measureDroppableContainers:xce},Ehe=S.createContext(VHt),Dtt=S.createContext(UHt);function HHt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new _8}}}function GHt(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 WHt(t){let{disabled:s}=t;const{active:r,activatorEvent:n,draggableNodes:a}=S.useContext(Ehe),o=Y_e(n),l=Y_e(r==null?void 0:r.id);return S.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=$Vt(p);if(f){f.focus();break}}})}},[n,s,a,l,o]),null}function KHt(t,s){let{transform:r,...n}=s;return t!=null&&t.length?t.reduce((a,o)=>o({transform:a,...n}),r):r}function ZHt(t){return S.useMemo(()=>({draggable:{...ioe.draggable,...t==null?void 0:t.draggable},droppable:{...ioe.droppable,...t==null?void 0:t.droppable},dragOverlay:{...ioe.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 YHt(t){let{activeNode:s,measure:r,initialRect:n,config:a=!0}=t;const o=S.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=S.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=S.memo(function(s){var r,n,a,o;let{id:l,accessibility:i,autoScroll:d=!0,children:u,sensors:p=$Ht,collisionDetection:f=eHt,measuring:y,modifiers:_,...b}=s;const N=S.useReducer(GHt,void 0,HHt),[w,k]=N,[C,A]=WVt(),[I,L]=S.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=S.useRef({initial:null,translated:null}),J=S.useMemo(()=>{var $r;return V!=null?{id:V,data:($r=te==null?void 0:te.data)!=null?$r:qHt,rect:Y}:null},[V,te]),X=S.useRef(null),[ce,ae]=S.useState(null),[ie,oe]=S.useState(null),me=kD(b,Object.values(b)),ye=iO("DndDescribedBy",l),he=S.useMemo(()=>U.getEnabled(),[U]),ge=ZHt(y),{droppableRects:Ne,measureDroppableContainers:Ue,measuringScheduled:Te}=THt(he,{dragging:O,dependencies:[B.x,B.y],config:ge.droppable}),Me=CHt(q,V),De=S.useMemo(()=>ie?X_e(ie):null,[ie]),qe=Yr(),ke=AHt(Me,ge.draggable.measure);YHt({activeNode:V!=null?q.get(V):null,config:qe.layoutShiftCompensation,initialRect:ke,measure:ge.draggable.measure});const $e=mDe(Me,ge.draggable.measure,ke),Be=mDe(Me?Me.parentElement:null),we=S.useRef({activatorEvent:null,active:null,activeNode:Me,collisionRect:null,collisions:null,droppableRects:Ne,draggableNodes:q,draggingNode:null,draggingNodeRect:null,droppableContainers:U,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ut=U.getNodeFor((r=we.current.over)==null?void 0:r.id),fe=BHt({measure:ge.dragOverlay.measure}),He=(n=fe.nodeRef.current)!=null?n:Me,et=O?(a=fe.rect)!=null?a:$e:null,tt=!!(fe.nodeRef.current&&fe.rect),_e=IHt(tt?null:$e),Ge=Ltt(He?bp(He):null),We=LHt(O?ut??Me:null),it=FHt(We),Ve=KHt(_,{transform:{x:B.x-_e.x,y:B.y-_e.y,scaleX:1,scaleY:1},activatorEvent:ie,active:J,activeNodeRect:$e,containerNodeRect:Be,draggingNodeRect:et,over:we.current.over,overlayNodeRect:fe.rect,scrollableAncestors:We,scrollableAncestorRects:it,windowRect:Ge}),Xe=De?QM(De,B):null,dt=DHt(We),pt=fDe(dt),Je=fDe(dt,[$e]),Ze=QM(Ve,pt),Nt=et?rHt(et,Ve):null,Ot=J&&Nt?f({active:J,collisionRect:Nt,droppableRects:Ne,droppableContainers:he,pointerCoordinates:Xe}):null,Yt=Ntt(Ot,"id"),[Ps,$s]=S.useState(null),Zs=tt?Ve:QM(Ve,Je),Dr=tHt(Zs,(o=Ps==null?void 0:Ps.rect)!=null?o:null,$e),$t=S.useRef(null),Us=S.useCallback(($r,Gr)=>{let{sensor:nr,options:lr}=Gr;if(X.current==null)return;const Fr=q.get(X.current);if(!Fr)return;const Wr=$r.nativeEvent,Nn=new nr({active:X.current,activeNode:Fr,event:Wr,options:lr,context:we,onAbort(ns){if(!q.get(ns))return;const{onDragAbort:dn}=me.current,zr={id:ns};dn==null||dn(zr),C({type:"onDragAbort",event:zr})},onPending(ns,$n,dn,zr){if(!q.get(ns))return;const{onDragPending:La}=me.current,Zt={id:ns,constraint:$n,initialCoordinates:dn,offset:zr};La==null||La(Zt),C({type:"onDragPending",event:Zt})},onStart(ns){const $n=X.current;if($n==null)return;const dn=q.get($n);if(!dn)return;const{onDragStart:zr}=me.current,Kr={activatorEvent:Wr,active:{id:$n,data:dn.data,rect:Y}};ip.unstable_batchedUpdates(()=>{zr==null||zr(Kr),L(z_.Initializing),k({type:ru.DragStart,initialCoordinates:ns,active:$n}),C({type:"onDragStart",event:Kr}),ae($t.current),oe(Wr)})},onMove(ns){k({type:ru.DragMove,coordinates:ns})},onEnd:ai(ru.DragEnd),onCancel:ai(ru.DragCancel)});$t.current=Nn;function ai(ns){return async function(){const{active:dn,collisions:zr,over:Kr,scrollAdjustedTranslate:La}=we.current;let Zt=null;if(dn&&La){const{cancelDrop:Er}=me.current;Zt={activatorEvent:Wr,active:dn,collisions:zr,delta:La,over:Kr},ns===ru.DragEnd&&typeof Er=="function"&&await Promise.resolve(Er(Zt))&&(ns=ru.DragCancel)}X.current=null,ip.unstable_batchedUpdates(()=>{k({type:ns}),L(z_.Uninitialized),$s(null),ae(null),oe(null),$t.current=null;const Er=ns===ru.DragEnd?"onDragEnd":"onDragCancel";if(Zt){const Bt=me.current[Er];Bt==null||Bt(Zt),C({type:Er,event:Zt})}})}}},[q]),Nr=S.useCallback(($r,Gr)=>(nr,lr)=>{const Fr=nr.nativeEvent,Wr=q.get(lr);if(X.current!==null||!Wr||Fr.dndKit||Fr.defaultPrevented)return;const Nn={active:Wr};$r(nr,Gr.options,Nn)===!0&&(Fr.dndKit={capturedBy:Gr.sensor},X.current=lr,Us(nr,Gr))},[q,Us]),Xs=MHt(p,Nr);RHt(p),g0(()=>{$e&&I===z_.Initializing&&L(z_.Initialized)},[$e,I]),S.useEffect(()=>{const{onDragMove:$r}=me.current,{active:Gr,activatorEvent:nr,collisions:lr,over:Fr}=we.current;if(!Gr||!nr)return;const Wr={active:Gr,activatorEvent:nr,collisions:lr,delta:{x:Ze.x,y:Ze.y},over:Fr};ip.unstable_batchedUpdates(()=>{$r==null||$r(Wr),C({type:"onDragMove",event:Wr})})},[Ze.x,Ze.y]),S.useEffect(()=>{const{active:$r,activatorEvent:Gr,collisions:nr,droppableContainers:lr,scrollAdjustedTranslate:Fr}=we.current;if(!$r||X.current==null||!Gr||!Fr)return;const{onDragOver:Wr}=me.current,Nn=lr.get(Yt),ai=Nn&&Nn.rect.current?{id:Nn.id,rect:Nn.rect.current,data:Nn.data,disabled:Nn.disabled}:null,ns={active:$r,activatorEvent:Gr,collisions:nr,delta:{x:Fr.x,y:Fr.y},over:ai};ip.unstable_batchedUpdates(()=>{$s(ai),Wr==null||Wr(ns),C({type:"onDragOver",event:ns})})},[Yt]),g0(()=>{we.current={activatorEvent:ie,active:J,activeNode:Me,collisionRect:Nt,collisions:Ot,droppableRects:Ne,draggableNodes:q,draggingNode:He,draggingNodeRect:et,droppableContainers:U,over:Ps,scrollableAncestors:We,scrollAdjustedTranslate:Ze},Y.current={initial:et,translated:Nt}},[J,Me,Ot,Nt,q,He,et,Ne,U,Ps,We,Ze]),NHt({...qe,delta:B,draggingRect:Nt,pointerCoordinates:Xe,scrollableAncestors:We,scrollableAncestorRects:it});const kr=S.useMemo(()=>({active:J,activeNode:Me,activeNodeRect:$e,activatorEvent:ie,collisions:Ot,containerNodeRect:Be,dragOverlay:fe,draggableNodes:q,droppableContainers:U,droppableRects:Ne,over:Ps,measureDroppableContainers:Ue,scrollableAncestors:We,scrollableAncestorRects:it,measuringConfiguration:ge,measuringScheduled:Te,windowRect:Ge}),[J,Me,$e,ie,Ot,Be,fe,q,U,Ne,Ps,Ue,We,it,ge,Te,Ge]),fn=S.useMemo(()=>({activatorEvent:ie,activators:Xs,active:J,activeNodeRect:$e,ariaDescribedById:{draggable:ye},dispatch:k,draggableNodes:q,over:Ps,measureDroppableContainers:Ue}),[ie,Xs,J,$e,k,ye,q,Ps,Ue]);return xt.createElement(btt.Provider,{value:A},xt.createElement(Ehe.Provider,{value:fn},xt.createElement(Dtt.Provider,{value:kr},xt.createElement(Rtt.Provider,{value:Dr},u)),xt.createElement(WHt,{disabled:(i==null?void 0:i.restoreFocus)===!1})),xt.createElement(YVt,{...i,hiddenTextDescribedById:ye}));function Yr(){const $r=(ce==null?void 0:ce.autoScrollEnabled)===!1,Gr=typeof d=="object"?d.enabled===!1:d===!1,nr=O&&!$r&&!Gr;return typeof d=="object"?{...d,enabled:nr}:{enabled:nr}}}),XHt=S.createContext(null),gDe="button",QHt="Draggable";function JHt(t){let{id:s,data:r,disabled:n=!1,attributes:a}=t;const o=iO(QHt),{activators:l,activatorEvent:i,active:d,activeNodeRect:u,ariaDescribedById:p,draggableNodes:f,over:y}=S.useContext(Ehe),{role:_=gDe,roleDescription:b="draggable",tabIndex:N=0}=a??{},w=(d==null?void 0:d.id)===s,k=S.useContext(w?Rtt:XHt),[C,A]=fce(),[I,L]=fce(),O=OHt(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=S.useMemo(()=>({role:_,tabIndex:N,"aria-disabled":n,"aria-pressed":w&&_===gDe?!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:k}}function eGt(){return S.useContext(Dtt)}const tGt="Droppable",sGt={timeout:25};function rGt(t){let{data:s,disabled:r=!1,id:n,resizeObserverConfig:a}=t;const o=iO(tGt),{active:l,dispatch:i,over:d,measureDroppableContainers:u}=S.useContext(Ehe),p=S.useRef({disabled:r}),f=S.useRef(!1),y=S.useRef(null),_=S.useRef(null),{disabled:b,updateMeasurementsFor:N,timeout:w}={...sGt,...a},k=kD(N??n),C=S.useCallback(()=>{if(!f.current){f.current=!0;return}_.current!=null&&clearTimeout(_.current),_.current=setTimeout(()=>{u(Array.isArray(k.current)?k.current:[k.current]),_.current=null},w)},[w]),A=Ahe({callback:C,disabled:b||!l}),I=S.useCallback((q,B)=>{A&&(B&&(A.unobserve(B),f.current=!1),q&&A.observe(q))},[A]),[L,O]=fce(I),V=kD(s);return S.useEffect(()=>{!A||!L.current||(A.disconnect(),f.current=!1,A.observe(L.current))},[L,A]),S.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]),S.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 nGt(t,s){return t.reduce((r,n,a)=>{const o=s.get(n);return o&&(r[a]=o),r},Array(t.length))}function e9(t){return t!==null&&t>=0}function aGt(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=oGt(r,l,a);if(l===a){const u=r[o];return u?{x:aa&&l<=o?{x:-i.width-d,y:0,...t9}:l=o?{x:i.width+d,y:0,...t9}:{x:0,y:0,...t9}};function oGt(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}},s9={scaleX:1,scaleY:1},wAs=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,...s9}:a=l?{x:0,y:i.height+d,...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?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,k=S.useRef(_),C=!aGt(_,k.current),A=w!==-1&&N===-1||C,I=iGt(o);g0(()=>{C&&b&&p(_)},[C,_,b,p]),S.useEffect(()=>{k.current=_},[_]);const L=S.useMemo(()=>({activeIndex:N,containerId:f,disabled:I,disableTransforms:A,items:_,overIndex:w,useDragOverlay:y,sortedRects:nGt(_,d),strategy:a}),[N,f,I.draggable,I.droppable,A,_,w,d,y,a]);return xt.createElement(Ftt.Provider,{value:L},s)}const cGt=t=>{let{id:s,items:r,activeIndex:n,overIndex:a}=t;return k4e(r,n,a).indexOf(s)},dGt=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},uGt={duration:200,easing:"ease"},ztt="transform",hGt=iC.Transition.toString({property:ztt,duration:0,easing:"linear"}),mGt={roleDescription:"sortable"};function pGt(t){let{disabled:s,index:r,node:n,rect:a}=t;const[o,l]=S.useState(null),i=S.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]),S.useEffect(()=>{o&&l(null)},[o]),o}function C4e(t){let{animateLayoutChanges:s=dGt,attributes:r,disabled:n,data:a,getNewIndex:o=cGt,id:l,strategy:i,resizeObserverConfig:d,transition:u=uGt}=t;const{items:p,containerId:f,activeIndex:y,disabled:_,disableTransforms:b,sortedRects:N,overIndex:w,useDragOverlay:k,strategy:C}=S.useContext(Ftt),A=fGt(n,_),I=p.indexOf(l),L=S.useMemo(()=>({sortable:{containerId:f,index:I,items:p},...a}),[f,a,I,p]),O=S.useMemo(()=>p.slice(p.indexOf(l)),[p,l]),{rect:V,node:q,isOver:B,setNodeRef:U}=rGt({id:l,data:L,disabled:A.droppable,resizeObserverConfig:{updateMeasurementsFor:O,...d}}),{active:te,activatorEvent:Y,activeNodeRect:J,attributes:X,setNodeRef:ce,listeners:ae,isDragging:ie,over:oe,setActivatorNodeRef:me,transform:ye}=JHt({id:l,data:L,attributes:{...mGt,...r},disabled:A.draggable}),he=OVt(U,ce),ge=!!te,Ne=ge&&!b&&e9(y)&&e9(w),Ue=!k&&ie,Te=Ue&&Ne?ye:null,De=Ne?Te??(i??C)({rects:N,activeNodeRect:J,activeIndex:y,overIndex:w,index:I}):null,qe=e9(y)&&e9(w)?o({id:l,items:p,activeIndex:y,overIndex:w}):I,ke=te==null?void 0:te.id,$e=S.useRef({activeId:ke,items:p,newIndex:qe,containerId:f}),Be=p!==$e.current.items,we=s({active:te,containerId:f,isDragging:ie,isSorting:ge,id:l,index:I,items:p,newIndex:$e.current.newIndex,previousItems:$e.current.items,previousContainerId:$e.current.containerId,transition:u,wasDragging:$e.current.activeId!=null}),ut=pGt({disabled:!we,index:I,node:q,rect:V});return S.useEffect(()=>{ge&&$e.current.newIndex!==qe&&($e.current.newIndex=qe),f!==$e.current.containerId&&($e.current.containerId=f),p!==$e.current.items&&($e.current.items=p)},[ge,qe,f,p]),S.useEffect(()=>{if(ke===$e.current.activeId)return;if(ke!=null&&$e.current.activeId==null){$e.current.activeId=ke;return}const He=setTimeout(()=>{$e.current.activeId=ke},50);return()=>clearTimeout(He)},[ke]),{active:te,activeIndex:y,attributes:X,data:L,rect:V,index:I,newIndex:qe,items:p,isOver:B,isSorting:ge,isDragging:ie,listeners:ae,node:q,overIndex:w,over:oe,setNodeRef:he,setActivatorNodeRef:me,setDroppableNodeRef:U,setDraggableNodeRef:ce,transform:ut??De,transition:fe()};function fe(){if(ut||Be&&$e.current.newIndex===I)return hGt;if(!(Ue&&!y4e(Y)||!u)&&(ge||we))return iC.Transition.toString({...u,property:ztt})}}function fGt(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 vce(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 xGt=[to.Down,to.Right,to.Up,to.Left],gGt=(t,s)=>{let{context:{active:r,collisionRect:n,droppableRects:a,droppableContainers:o,over:l,scrollableAncestors:i}}=s;if(xGt.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=The(b).some((O,V)=>i[V]!==O),k=Btt(f,y),C=yGt(f,y),A=w||!k?{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!vce(t)||!vce(s)?!1:t.data.current.sortable.containerId===s.data.current.sortable.containerId}function yGt(t,s){return!vce(t)||!vce(s)||!Btt(t,s)?!1:t.data.current.sortable.indexs(t),children:e.jsx(ga,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"destructive",size:"icon",className:"h-7 w-7",onClick:()=>r(t),children:e.jsx(xr,{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(ln,{className:"h-2.5 w-2.5"}),gs(new Date(t.post_date+"T00:00:00"),"MMM d")]})})]}),e.jsxs(Re,{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-3",children:t.caption}),e.jsxs(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:Dt("w-full h-7 text-[11px] gap-1 justify-start font-normal",!t.post_date&&"text-muted-foreground"),children:[e.jsx(ln,{className:"h-3 w-3"}),t.post_date?gs(new Date(t.post_date+"T00:00:00"),"MMM d, yyyy"):"Set post date"]})}),e.jsxs(uo,{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?gs(f,"yyyy-MM-dd"):null),className:"p-3 pointer-events-auto"}),t.post_date&&e.jsx("div",{className:"p-2 border-t",children:e.jsx(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>n(t.id,null),children:"Clear date"})})]})]})]})]})})}const _Gt=()=>{const t=Qt(),[s,r]=S.useState("all"),[n,a]=S.useState(!1),[o,l]=S.useState(gs(new Date,"yyyy-MM")),[i,d]=S.useState([]),[u,p]=S.useState(!1),[f,y]=S.useState(null),[_,b]=S.useState(null),[N,w]=S.useState(""),[k,C]=S.useState(null),[A,I]=S.useState(!1),[L,O]=S.useState(!1),[V,q]=S.useState(gs(new Date,"yyyy-MM")),[B,U]=S.useState(null),[te,Y]=S.useState(""),[J,X]=S.useState(""),[ce,ae]=S.useState(""),[ie,oe]=S.useState(!1),me=v4e(gce(oO,{activationConstraint:{distance:5}}),gce(w4e,{coordinateGetter:gGt})),{data:ye=[],isLoading:he}=gt({queryKey:["admin-social-swag-2"],queryFn:async()=>{const{data:Xe,error:dt}=await G.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(dt)throw dt;return Xe}}),{data:ge=[]}=gt({queryKey:["admin-social-swag-2-months"],queryFn:async()=>{const{data:Xe,error:dt}=await G.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(dt)throw dt;return Xe}}),{data:Ne=[]}=gt({queryKey:["admin-social-swag-2-reels"],queryFn:async()=>{const{data:Xe,error:dt}=await G.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(dt)throw dt;return Xe}}),Ue=[...new Set(ye.map(Xe=>Xe.month))].sort((Xe,dt)=>dt.localeCompare(Xe)),Te=s==="all"?ye:ye.filter(Xe=>Xe.month===s),Me=Xe=>{const dt=sNe(Xe,"yyyy-MM",new Date);return gs(dt,"MMMM yyyy")},De=Xe=>{b(Xe),w(Xe.caption),C(Xe.post_date)},qe=async()=>{if(_){I(!0);try{const{error:Xe}=await G.from("social_swag_2").update({caption:N,post_date:k}).eq("id",_.id);if(Xe)throw Xe;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)}}},ke=async Xe=>{const{active:dt,over:pt}=Xe;if(!pt||dt.id===pt.id)return;const Je=Te,Ze=Je.findIndex(Yt=>Yt.id===dt.id),Nt=Je.findIndex(Yt=>Yt.id===pt.id);if(Ze===-1||Nt===-1)return;const Ot=k4e(Je,Ze,Nt);t.setQueryData(["admin-social-swag-2"],Yt=>{if(!Yt)return Yt;const Ps={};return Ot.forEach(($s,Zs)=>{Ps[$s.id]=Zs}),Yt.map($s=>Ps[$s.id]!==void 0?{...$s,sort_order:Ps[$s.id]}:$s).sort(($s,Zs)=>$s.month!==Zs.month?Zs.month.localeCompare($s.month):$s.sort_order-Zs.sort_order)});try{await Promise.all(Ot.map((Yt,Ps)=>G.from("social_swag_2").update({sort_order:Ps}).eq("id",Yt.id)))}catch{pe.error("Failed to save order"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})}},$e=Xe=>{const pt=Array.from(Xe.target.files||[]).sort((Je,Ze)=>Je.name.localeCompare(Ze.name,void 0,{numeric:!0,sensitivity:"base"})).slice(0,16-i.length).map(Je=>({file:Je,preview:URL.createObjectURL(Je),caption:""}));d(Je=>[...Je,...pt].slice(0,16))},Be=Xe=>{d(dt=>{const pt=[...dt];return URL.revokeObjectURL(pt[Xe].preview),pt.splice(Xe,1),pt})},we=(Xe,dt)=>{d(pt=>{const Je=[...pt];return Je[Xe]={...Je[Xe],caption:dt},Je})},ut=async()=>{var dt;if(i.length===0){pe.error("Please add at least one image");return}if(i.filter(pt=>!pt.caption.trim()).length>0){pe.error("Please add captions to all images");return}p(!0);try{const{data:pt}=await G.from("social_swag_2").select("sort_order").eq("month",o).order("sort_order",{ascending:!1}).limit(1),Je=(((dt=pt==null?void 0:pt[0])==null?void 0:dt.sort_order)??-1)+1;for(let Ze=0;Ze{const dt=Xe.image_url.split("/social-swag-2/");dt[1]&&await G.storage.from("social-swag-2").remove([dt[1]]);const{error:pt}=await G.from("social_swag_2").delete().eq("id",Xe.id);if(pt)throw pt},onSuccess:()=>{pe.success("Image deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})},onError:()=>pe.error("Failed to delete image")}),He=Et({mutationFn:async({id:Xe,postDate:dt})=>{const{error:pt}=await G.from("social_swag_2").update({post_date:dt}).eq("id",Xe);if(pt)throw pt},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")}),et=Et({mutationFn:async({month:Xe,link:dt})=>{const{error:pt}=await G.from("social_swag_2_months").upsert({month:Xe,canva_link:dt||null},{onConflict:"month"});if(pt)throw pt},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=Xe=>{var dt;return((dt=ge.find(pt=>pt.month===Xe))==null?void 0:dt.canva_link)||""},_e=Xe=>Ne.find(dt=>dt.month===Xe)||null,Ge=Xe=>{var pt;const dt=(pt=Xe.target.files)==null?void 0:pt[0];dt&&(U(dt),Y(URL.createObjectURL(dt)))},We=()=>{te&&URL.revokeObjectURL(te),U(null),Y(""),X(""),ae("")},it=async()=>{if(!B){pe.error("Please select an image");return}oe(!0);try{const Xe=B.name.split(".").pop(),dt=`reels/${V}-${Date.now()}.${Xe}`,{error:pt}=await G.storage.from("social-swag-2").upload(dt,B);if(pt)throw pt;const{data:{publicUrl:Je}}=G.storage.from("social-swag-2").getPublicUrl(dt),{error:Ze}=await G.from("social_swag_2_reels").upsert({month:V,image_url:Je,canva_link:ce||null,caption:J||null},{onConflict:"month"});if(Ze)throw Ze;pe.success("Reel uploaded successfully!"),Z_e(`${Me(V)} Reel`,"social-swag-2"),We(),O(!1),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})}catch(Xe){console.error("Reel upload error:",Xe),pe.error("Failed to upload reel")}finally{oe(!1)}},Ve=Et({mutationFn:async Xe=>{const dt=Xe.image_url.split("/social-swag-2/");dt[1]&&await G.storage.from("social-swag-2").remove([dt[1]]);const{error:pt}=await G.from("social_swag_2_reels").delete().eq("id",Xe.id);if(pt)throw pt},onSuccess:()=>{pe.success("Reel deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})},onError:()=>pe.error("Failed to delete reel")});return e.jsxs(Es,{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(hi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Bs,{className:"h-4 w-4"}),"Upload Images"]})}),e.jsxs(hs,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{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(Le,{type:"month",value:o,onChange:Xe=>l(Xe.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:$e,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((Xe,dt)=>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:Xe.preview,alt:`Upload ${dt+1}`,className:"w-full h-full object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>Be(dt),children:e.jsx(jr,{className:"h-3 w-3"})})]}),e.jsx(gr,{placeholder:"Caption...",value:Xe.caption,onChange:pt=>we(dt,pt.target.value),className:"text-xs h-20"})]},dt))}),e.jsx(K,{onClick:ut,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:Xe=>{O(Xe),Xe||We()},children:[e.jsx(hi,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"gap-2",children:[e.jsx(Rd,{className:"h-4 w-4"}),"Upload Reel"]})}),e.jsxs(hs,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsx(js,{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(Le,{type:"month",value:V,onChange:Xe=>q(Xe.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(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{URL.revokeObjectURL(te),U(null),Y("")},children:e.jsx(jr,{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:Ge,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(Le,{value:ce,onChange:Xe=>ae(Xe.target.value),placeholder:"https://www.canva.com/..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Caption"}),e.jsx(gr,{value:J,onChange:Xe=>X(Xe.target.value),placeholder:"Enter caption for this reel...",className:"h-24"})]}),e.jsx(K,{onClick:it,disabled:ie||!B,className:"w-full gap-2",children:ie?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(Re,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:ye.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total Images"})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:Ue.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(ls,{value:"all",children:"All"}),Ue.map(Xe=>e.jsx(ls,{value:Xe,children:Me(Xe)},Xe))]})}),s!=="all"&&e.jsx(Pe,{children:e.jsx(Re,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(go,{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 ",Me(s)]}),(f==null?void 0:f.month)===s?e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsx(Le,{value:f.link,onChange:Xe=>y({...f,link:Xe.target.value}),placeholder:"https://www.canva.com/..."}),e.jsx(K,{size:"sm",onClick:()=>et.mutate(f),children:"Save"}),e.jsx(K,{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(K,{size:"sm",variant:"outline",onClick:()=>y({month:s,link:tt(s)}),children:"Edit"})]})]})]})})}),s!=="all"&&e.jsx(Pe,{children:e.jsx(Re,{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 ",Me(s)]}),(()=>{const Xe=_e(s);return Xe?e.jsxs("div",{className:"flex items-center gap-4 mt-2",children:[e.jsx("img",{src:Xe.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:Xe.caption||"No caption"}),Xe.canva_link&&e.jsx("a",{href:Xe.canva_link,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-xs",children:"View Canva Link"})]}),e.jsx(K,{variant:"destructive",size:"sm",onClick:()=>Ve.mutate(Xe),children:e.jsx(xr,{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..."}):Te.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:ke,children:e.jsx(S4e,{items:Te.map(Xe=>Xe.id),strategy:lO,children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:Te.map(Xe=>e.jsx(vGt,{item:Xe,onEdit:De,onDelete:dt=>fe.mutate(dt),onDateChange:(dt,pt)=>He.mutate({id:dt,postDate:pt})},Xe.id))})})})]}),e.jsx(fs,{open:!!_,onOpenChange:Xe=>{Xe||b(null)},children:e.jsxs(hs,{className:"max-w-md",children:[e.jsx(js,{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(gr,{value:N,onChange:Xe=>w(Xe.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(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Dt("flex-1 justify-start gap-2 font-normal",!k&&"text-muted-foreground"),children:[e.jsx(ln,{className:"h-4 w-4"}),k?gs(new Date(k+"T00:00:00"),"MMM d, yyyy"):"Pick a date"]})}),e.jsx(uo,{className:"w-auto p-0",align:"start",children:e.jsx(uf,{mode:"single",selected:k?new Date(k+"T00:00:00"):void 0,onSelect:Xe=>C(Xe?gs(Xe,"yyyy-MM-dd"):null),className:"p-3 pointer-events-auto"})})]}),k&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>C(null),children:e.jsx(jr,{className:"h-4 w-4"})})]})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>b(null),children:"Cancel"}),e.jsx(K,{onClick:qe,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"})]})]})})]})},bGt=()=>{const{toast:t}=ja(),s=Qt(),[r,n]=S.useState("categories"),[a,o]=S.useState(!1),[l,i]=S.useState(null),[d,u]=S.useState({name:"",description:"",icon:""}),[p,f]=S.useState(!1),[y,_]=S.useState(null),[b,N]=S.useState({name:"",description:"",icon:""}),[w,k]=S.useState(!1),[C,A]=S.useState(null),[I,L]=S.useState(""),{data:O=[],isLoading:V}=gt({queryKey:["admin-community-categories"],queryFn:async()=>{const{data:ke,error:$e}=await G.from("community_categories").select("*").order("sort_order");if($e)throw $e;return ke}}),{data:q=[],isLoading:B}=gt({queryKey:["admin-private-groups"],queryFn:async()=>{const{data:ke,error:$e}=await G.from("community_private_groups").select("*").order("sort_order");if($e)throw $e;return ke}}),{data:U=[]}=gt({queryKey:["admin-group-members",C==null?void 0:C.id],queryFn:async()=>{if(!C)return[];const{data:ke,error:$e}=await G.from("community_private_group_members").select("*").eq("group_id",C.id);if($e)throw $e;return ke},enabled:!!C}),{data:te=[]}=gt({queryKey:["admin-all-profiles"],queryFn:async()=>{let $e=[],Be=0,we=!0;for(;we;){const{data:ut,error:fe}=await G.from("profiles").select("id, name, email, brokerage_id").order("name").range(Be,Be+1e3-1);if(fe)throw fe;ut&&ut.length>0?($e=[...$e,...ut],Be+=1e3,we=ut.length===1e3):we=!1}return $e}}),{data:Y=[]}=gt({queryKey:["admin-all-brokerages"],queryFn:async()=>{const{data:ke,error:$e}=await G.from("brokerages").select("*").order("name");if($e)throw $e;return ke}}),J=Et({mutationFn:async ke=>{if(ke.id){const{error:$e}=await G.from("community_categories").update({name:ke.name,description:ke.description||null,icon:ke.icon||null}).eq("id",ke.id);if($e)throw $e}else{const $e=Math.max(...O.map(we=>we.sort_order),0),{error:Be}=await G.from("community_categories").insert({name:ke.name,description:ke.description||null,icon:ke.icon||null,sort_order:$e+1});if(Be)throw Be}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),o(!1),i(null),u({name:"",description:"",icon:""}),t({title:l?"Category updated!":"Category created!"})},onError:ke=>{t({title:"Error",description:ke.message,variant:"destructive"})}}),X=Et({mutationFn:async ke=>{const{error:$e}=await G.from("community_categories").delete().eq("id",ke);if($e)throw $e},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),t({title:"Category deleted"})}}),ce=Et({mutationFn:async({id:ke,direction:$e})=>{const Be=O.findIndex(we=>we.id===ke);if($e==="up"&&Be>0){const we=O[Be-1],ut=O[Be];await G.from("community_categories").update({sort_order:ut.sort_order}).eq("id",we.id),await G.from("community_categories").update({sort_order:we.sort_order}).eq("id",ut.id)}else if($e==="down"&&Bes.invalidateQueries({queryKey:["admin-community-categories"]})}),ae=Et({mutationFn:async ke=>{if(ke.id){const{error:$e}=await G.from("community_private_groups").update({name:ke.name,description:ke.description||null,icon:ke.icon||null}).eq("id",ke.id);if($e)throw $e}else{const $e=Math.max(...q.map(we=>we.sort_order),0),{error:Be}=await G.from("community_private_groups").insert({name:ke.name,description:ke.description||null,icon:ke.icon||null,sort_order:$e+1});if(Be)throw Be}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),f(!1),_(null),N({name:"",description:"",icon:""}),t({title:y?"Private group updated!":"Private group created!"})},onError:ke=>{t({title:"Error",description:ke.message,variant:"destructive"})}}),ie=Et({mutationFn:async ke=>{const{error:$e}=await G.from("community_private_groups").delete().eq("id",ke);if($e)throw $e},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),t({title:"Private group deleted"})}}),oe=Et({mutationFn:async({id:ke,direction:$e})=>{const Be=q.findIndex(we=>we.id===ke);if($e==="up"&&Be>0){const we=q[Be-1],ut=q[Be];await G.from("community_private_groups").update({sort_order:ut.sort_order}).eq("id",we.id),await G.from("community_private_groups").update({sort_order:we.sort_order}).eq("id",ut.id)}else if($e==="down"&&Bes.invalidateQueries({queryKey:["admin-private-groups"]})}),me=Et({mutationFn:async({groupId:ke,userId:$e,isMember:Be})=>{if(Be){const{error:we}=await G.from("community_private_group_members").delete().eq("group_id",ke).eq("user_id",$e);if(we)throw we}else{const{error:we}=await G.from("community_private_group_members").insert({group_id:ke,user_id:$e});if(we)throw we}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",C==null?void 0:C.id]})}}),ye=Et({mutationFn:async({groupId:ke,brokerageId:$e,isMember:Be})=>{if(Be){const{error:we}=await G.from("community_private_group_members").delete().eq("group_id",ke).eq("brokerage_id",$e);if(we)throw we}else{const{error:we}=await G.from("community_private_group_members").insert({group_id:ke,brokerage_id:$e});if(we)throw we}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",C==null?void 0:C.id]})}}),he=ke=>{i(ke),u({name:ke.name,description:ke.description||"",icon:ke.icon||""}),o(!0)},ge=()=>{i(null),u({name:"",description:"",icon:""}),o(!0)},Ne=ke=>{_(ke),N({name:ke.name,description:ke.description||"",icon:ke.icon||""}),f(!0)},Ue=()=>{_(null),N({name:"",description:"",icon:""}),f(!0)},Te=ke=>{A(ke),L(""),k(!0)},Me=ke=>U.some($e=>$e.user_id===ke),De=ke=>U.some($e=>$e.brokerage_id===ke),qe=te.filter(ke=>ke.name.toLowerCase().includes(I.toLowerCase())||ke.email.toLowerCase().includes(I.toLowerCase()));return e.jsx(Es,{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(ls,{value:"categories",children:"Public Categories"}),e.jsxs(ls,{value:"private-groups",children:[e.jsx(vd,{className:"h-4 w-4 mr-1"}),"Private Groups"]})]}),e.jsxs(ws,{value:"categories",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Categories visible to all community members"}),e.jsxs(K,{onClick:ge,children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"pt-6",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ms,{children:[e.jsx(kt,{className:"w-[50px]",children:"Order"}),e.jsx(kt,{className:"w-[80px]",children:"Icon"}),e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Description"}),e.jsx(kt,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Rn,{children:V?e.jsx(Ms,{children:e.jsx(ht,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):O.length===0?e.jsx(Ms,{children:e.jsx(ht,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first one!"})}):O.map((ke,$e)=>e.jsxs(Ms,{children:[e.jsx(ht,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:$e===0,onClick:()=>ce.mutate({id:ke.id,direction:"up"}),children:"↑"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:$e===O.length-1,onClick:()=>ce.mutate({id:ke.id,direction:"down"}),children:"↓"})]})}),e.jsx(ht,{className:"text-2xl",children:ke.icon||"📁"}),e.jsx(ht,{className:"font-medium",children:ke.name}),e.jsx(ht,{className:"text-muted-foreground",children:ke.description||"—"}),e.jsx(ht,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>he(ke),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{confirm("Delete this category? Posts will be uncategorized.")&&X.mutate(ke.id)},children:e.jsx(xr,{className:"h-4 w-4"})})]})})]},ke.id))})]})})})]}),e.jsxs(ws,{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(K,{onClick:Ue,children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Private Group"]})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"pt-6",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ms,{children:[e.jsx(kt,{className:"w-[50px]",children:"Order"}),e.jsx(kt,{className:"w-[80px]",children:"Icon"}),e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Description"}),e.jsx(kt,{className:"w-[120px]",children:"Members"}),e.jsx(kt,{className:"w-[140px]",children:"Actions"})]})}),e.jsx(Rn,{children:B?e.jsx(Ms,{children:e.jsx(ht,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):q.length===0?e.jsx(Ms,{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((ke,$e)=>e.jsxs(Ms,{children:[e.jsx(ht,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:$e===0,onClick:()=>oe.mutate({id:ke.id,direction:"up"}),children:"↑"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:$e===q.length-1,onClick:()=>oe.mutate({id:ke.id,direction:"down"}),children:"↓"})]})}),e.jsx(ht,{className:"text-2xl",children:ke.icon||"🔒"}),e.jsx(ht,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[ke.name,ke.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(vd,{className:"h-3 w-3 mr-1"}),"Private"]})]})}),e.jsx(ht,{className:"text-muted-foreground",children:ke.description||"—"}),e.jsx(ht,{children:e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Te(ke),children:[e.jsx(or,{className:"h-4 w-4 mr-1"}),"Manage"]})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex gap-1",children:[!ke.brokerage_id&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ne(ke),children:e.jsx(ga,{className:"h-4 w-4"})}),!ke.brokerage_id&&e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{confirm("Delete this private group? All posts in this group will be deleted.")&&ie.mutate(ke.id)},children:e.jsx(xr,{className:"h-4 w-4"})}),ke.brokerage_id&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Managed via brokerage"})]})})]},ke.id))})]})})})]})]}),e.jsx(fs,{open:a,onOpenChange:o,children:e.jsxs(hs,{children:[e.jsx(js,{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(Le,{value:d.icon,onChange:ke=>u($e=>({...$e,icon:ke.target.value})),placeholder:"💬",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Name *"}),e.jsx(Le,{value:d.name,onChange:ke=>u($e=>({...$e,name:ke.target.value})),placeholder:"Category name",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Description"}),e.jsx(gr,{value:d.description,onChange:ke=>u($e=>({...$e,description:ke.target.value})),placeholder:"Brief description of this category",className:"mt-1"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(K,{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(hs,{children:[e.jsx(js,{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(Le,{value:b.icon,onChange:ke=>N($e=>({...$e,icon:ke.target.value})),placeholder:"🔒",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Name *"}),e.jsx(Le,{value:b.name,onChange:ke=>N($e=>({...$e,name:ke.target.value})),placeholder:"e.g., Pioneers",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Description"}),e.jsx(gr,{value:b.description,onChange:ke=>N($e=>({...$e,description:ke.target.value})),placeholder:"Brief description of this private group",className:"mt-1"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>f(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>ae.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:k,children:e.jsxs(hs,{className:"max-w-2xl",children:[e.jsx(js,{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(ls,{value:"brokerages",className:"flex-1",children:"By Brokerage"}),e.jsx(ls,{value:"users",className:"flex-1",children:"Individual Users"})]}),e.jsxs(ws,{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(ni,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[Y.map(ke=>e.jsxs("div",{className:"flex items-center justify-between p-2 hover:bg-muted rounded-md",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Hi,{checked:De(ke.id),onCheckedChange:()=>{C&&ye.mutate({groupId:C.id,brokerageId:ke.id,isMember:De(ke.id)})}}),e.jsx("span",{className:"font-medium",children:ke.name})]}),e.jsxs(Qe,{variant:"secondary",children:[te.filter($e=>$e.brokerage_id===ke.id).length," agents"]})]},ke.id)),Y.length===0&&e.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No brokerages found"})]})})]}),e.jsxs(ws,{value:"users",className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search users...",value:I,onChange:ke=>L(ke.target.value),className:"pl-9"})]}),e.jsx(ni,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[qe.map(ke=>e.jsx("div",{className:"flex items-center justify-between p-2 hover:bg-muted rounded-md",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Hi,{checked:Me(ke.id),onCheckedChange:()=>{C&&me.mutate({groupId:C.id,userId:ke.id,isMember:Me(ke.id)})}}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:ke.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:ke.email})]})]})},ke.id)),qe.length===0&&e.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No users found"})]})})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(K,{onClick:()=>k(!1),children:"Done"})})]})]})})]})})},yDe=t=>{switch(t){case"academy_video":return e.jsx(Co,{className:"h-3 w-3"});case"template":return e.jsx(yn,{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(Zr,{className:"h-3 w-3"})}},wGt=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}},jGt=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}},NGt=()=>{const{toast:t}=ja(),[s,r]=S.useState([]),[n,a]=S.useState([]),[o,l]=S.useState([]),[i,d]=S.useState(!0),[u,p]=S.useState(""),[f,y]=S.useState(null),[_,b]=S.useState([]),[N,w]=S.useState([]);S.useEffect(()=>{k()},[]);const k=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),ae=new Map((ce==null?void 0:ce.map(he=>[he.id,he]))||[]),ie=(U==null?void 0:U.map(he=>{var ge,Ne,Ue,Te;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:((Ne=he.profiles)==null?void 0:Ne.email)||"Unknown",brokerage_name:((Te=(Ue=he.profiles)==null?void 0:Ue.brokerages)==null?void 0:Te.name)||null}}))||[],oe=(Y==null?void 0:Y.map(he=>{var Ne;const ge=ae.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:((Ne=ge==null?void 0:ge.brokerages)==null?void 0:Ne.name)||null}}))||[];r(ie),a(oe);const me=new Map;ie.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 ye=Array.from(me.values()).sort((he,ge)=>new Date(ge.last_activity_at).getTime()-new Date(he.last_activity_at).getTime());l(ye)}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(Re,{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(Lt,{children:[e.jsx(Ft,{children:"User Activity"}),e.jsx(ur,{children:"App launches and content engagement - click to see full history"})]}),e.jsxs(Re,{children:[e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"relative",children:[e.jsx(an,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name, email, or brokerage...",value:u,onChange: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(Ms,{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(kt,{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(Ms,{children:e.jsx(ht,{colSpan:6,className:"text-center text-muted-foreground",children:"No activity found"})}):B.map(U=>e.jsxs(Ms,{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(Zr,{className:"h-3 w-3 mr-1"}),U.last_activity_name]}):e.jsxs(Qe,{variant:"outline",className:"flex items-center gap-1",children:[yDe(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(hs,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(js,{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(ls,{value:"content",children:["Content (",N.length,")"]}),e.jsxs(ls,{value:"apps",children:["App Launches (",_.length,")"]})]}),e.jsx(ws,{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(Ms,{children:[e.jsx(kt,{children:"Type"}),e.jsx(kt,{children:"Resource"}),e.jsx(kt,{children:"Action"}),e.jsx(kt,{children:"Time"})]})}),e.jsx(Rn,{children:N.length===0?e.jsx(Ms,{children:e.jsx(ht,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement"})}):N.map(U=>e.jsxs(Ms,{children:[e.jsx(ht,{children:e.jsxs(Qe,{variant:"outline",className:"flex items-center gap-1 w-fit",children:[yDe(U.resource_type),wGt(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:jGt(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(ws,{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(Ms,{children:[e.jsx(kt,{children:"App"}),e.jsx(kt,{children:"Time"})]})}),e.jsx(Rn,{children:_.length===0?e.jsx(Ms,{children:e.jsx(ht,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches"})}):_.map(U=>e.jsxs(Ms,{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))})]})})})]})]})})]})},kGt=()=>{const{toast:t}=ja(),[s,r]=S.useState({totalUsers:0,activeUsers:0,pendingUsers:0,totalBrokerages:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0,uniqueActiveThisWeek:0}),[n,a]=S.useState(!0);S.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(k=>k.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(Re,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Total Users"}),e.jsx(or,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Active Users"}),e.jsx(ti,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(on,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Brokerages"}),e.jsx(pa,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(lh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Launches This Week"}),e.jsx(lh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Launches This Month"}),e.jsx(lh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Active This Week"}),e.jsx(Qo,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.uniqueActiveThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Unique users"})]})]})]})},vDe={event:"Event",template:"Template",academy_video:"Academy Video",resource_kit:"Resource Kit",newsletter:"Newsletter",social_swag:"Social Swag"},_De={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]=S.useState([]),[a,o]=S.useState(!0),[l,i]=S.useState(""),[d,u]=S.useState("all");S.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()}),k=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(Lt,{className:"pb-2",children:e.jsx(ks,{className:"h-4 w-20"})}),e.jsx(Re,{children:e.jsx(ks,{className:"h-8 w-16"})})]},V))}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-6",children:e.jsx(ks,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Total Shares"}),e.jsx(_d,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:k})})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Active Sharers"}),e.jsx(or,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:C})})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Recipients Reached"}),e.jsx(Qo,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:A})})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Read Rate"}),e.jsx(yn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Re,{children:e.jsxs("div",{className:"text-2xl font-bold",children:[I,"%"]})})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-sm font-medium",children:"Shares by Resource Type"})}),e.jsx(Re,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Object.entries(L).map(([O,V])=>e.jsxs(Qe,{variant:"secondary",className:_De[O],children:[vDe[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(Lt,{children:[e.jsx(Ft,{children:"Share History"}),e.jsxs(ur,{children:["All resource shares ",t?"in your brokerage":"across the platform"]})]}),e.jsxs(Re,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by resource, sender, or recipient...",value:l,onChange:O=>i(O.target.value),className:"pl-9"})]}),e.jsxs(Fs,{value:d,onValueChange:u,children:[e.jsx(Ds,{className:"w-[180px]",children:e.jsx(zs,{placeholder:"Resource type"})}),e.jsxs(Rs,{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(ni,{className:"h-[400px]",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ms,{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(Ms,{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(Ms,{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:_De[O.resource_type],children:vDe[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:gs(new Date(O.created_at),"MMM d, yyyy")})]},O.id)})})]})})]})]})]})}const Eye={academy_video:{label:"Academy Videos",icon:gn,color:"bg-purple-100 text-purple-800",actionLabel:"Watched",actionIcon:Cn},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:Fl,color:"bg-pink-100 text-pink-800",actionLabel:"Accessed",actionIcon:au},event:{label:"Events",icon:ln,color:"bg-cyan-100 text-cyan-800",actionLabel:"Registered",actionIcon:au}};function bDe(t){return t.resource_type==="toolbox"?t.total_downloads:t.total_clicks}function SGt(t,s){return t==="toolbox"?s.downloads:s.clicks}function CGt(){var O;const[t,s]=S.useState([]),[r,n]=S.useState(!0),[a,o]=S.useState(null),l=S.useRef(null),{sortKey:i,sortDirection:d,handleSort:u,sortData:p}=sO("total_views","desc");S.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(Lt,{className:"pb-2",children:e.jsx(ks,{className:"h-4 w-20"})}),e.jsx(Re,{children:e.jsx(ks,{className:"h-8 w-16"})})]},q))}),e.jsx(Pe,{children:e.jsx(Re,{className:"py-8",children:e.jsx(ks,{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,k=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=>bDe(V),unique_users:V=>V.unique_users,last_activity:V=>V.last_engaged_at?new Date(V.last_engaged_at).getTime():0}),I=a?Eye[a]||{label:a,icon:Cn,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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Total Views"}),e.jsx(Cn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Total Clicks"}),e.jsx(au,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Downloads"}),e.jsx(Qa,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Assets Tracked"}),e.jsx(Qo,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(au,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Lt,{children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Engagement by Content Type"}),e.jsx(ur,{children:"Click a category to see individual asset performance"})]}),e.jsx(Re,{children:e.jsx("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-3",children:Object.entries(k).map(([V,q])=>{const B=Eye[V]||{label:V,icon:Cn,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(Cn,{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"})," ",SGt(V,q)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(or,{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(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{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(ur,{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(K,{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(Re,{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(ni,{className:"h-[400px]",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ms,{children:[e.jsx(kt,{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=Eye[V.resource_type]||{label:V.resource_type,color:"bg-muted text-muted-foreground",actionLabel:"Actions",actionIcon:au};return e.jsxs(Ms,{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:bDe(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 MGt=Array.isArray,wp=MGt,TGt=typeof fd=="object"&&fd&&fd.Object===Object&&fd,qtt=TGt,AGt=qtt,EGt=typeof self=="object"&&self&&self.Object===Object&&self,PGt=AGt||EGt||Function("return this")(),S0=PGt,IGt=S0,LGt=IGt.Symbol,cO=LGt,wDe=cO,Utt=Object.prototype,DGt=Utt.hasOwnProperty,RGt=Utt.toString,cI=wDe?wDe.toStringTag:void 0;function OGt(t){var s=DGt.call(t,cI),r=t[cI];try{t[cI]=void 0;var n=!0}catch{}var a=RGt.call(t);return n&&(s?t[cI]=r:delete t[cI]),a}var FGt=OGt,zGt=Object.prototype,BGt=zGt.toString;function $Gt(t){return BGt.call(t)}var qGt=$Gt,jDe=cO,UGt=FGt,VGt=qGt,HGt="[object Null]",GGt="[object Undefined]",NDe=jDe?jDe.toStringTag:void 0;function WGt(t){return t==null?t===void 0?GGt:HGt:NDe&&NDe in Object(t)?UGt(t):VGt(t)}var M1=WGt;function KGt(t){return t!=null&&typeof t=="object"}var T1=KGt,ZGt=M1,YGt=T1,XGt="[object Symbol]";function QGt(t){return typeof t=="symbol"||YGt(t)&&ZGt(t)==XGt}var oE=QGt,JGt=wp,eWt=oE,tWt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,sWt=/^\w*$/;function rWt(t,s){if(JGt(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||eWt(t)?!0:sWt.test(t)||!tWt.test(t)||s!=null&&t in Object(s)}var M4e=rWt;function nWt(t){var s=typeof t;return t!=null&&(s=="object"||s=="function")}var jw=nWt;const lE=no(jw);var aWt=M1,iWt=jw,oWt="[object AsyncFunction]",lWt="[object Function]",cWt="[object GeneratorFunction]",dWt="[object Proxy]";function uWt(t){if(!iWt(t))return!1;var s=aWt(t);return s==lWt||s==cWt||s==oWt||s==dWt}var T4e=uWt;const di=no(T4e);var hWt=S0,mWt=hWt["__core-js_shared__"],pWt=mWt,Pye=pWt,kDe=function(){var t=/[^.]+$/.exec(Pye&&Pye.keys&&Pye.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function fWt(t){return!!kDe&&kDe in t}var xWt=fWt,gWt=Function.prototype,yWt=gWt.toString;function vWt(t){if(t!=null){try{return yWt.call(t)}catch{}try{return t+""}catch{}}return""}var Vtt=vWt,_Wt=T4e,bWt=xWt,wWt=jw,jWt=Vtt,NWt=/[\\^$.*+?()[\]{}|]/g,kWt=/^\[object .+?Constructor\]$/,SWt=Function.prototype,CWt=Object.prototype,MWt=SWt.toString,TWt=CWt.hasOwnProperty,AWt=RegExp("^"+MWt.call(TWt).replace(NWt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function EWt(t){if(!wWt(t)||bWt(t))return!1;var s=_Wt(t)?AWt:kWt;return s.test(jWt(t))}var PWt=EWt;function IWt(t,s){return t==null?void 0:t[s]}var LWt=IWt,DWt=PWt,RWt=LWt;function OWt(t,s){var r=RWt(t,s);return DWt(r)?r:void 0}var AC=OWt,FWt=AC,zWt=FWt(Object,"create"),Phe=zWt,SDe=Phe;function BWt(){this.__data__=SDe?SDe(null):{},this.size=0}var $Wt=BWt;function qWt(t){var s=this.has(t)&&delete this.__data__[t];return this.size-=s?1:0,s}var UWt=qWt,VWt=Phe,HWt="__lodash_hash_undefined__",GWt=Object.prototype,WWt=GWt.hasOwnProperty;function KWt(t){var s=this.__data__;if(VWt){var r=s[t];return r===HWt?void 0:r}return WWt.call(s,t)?s[t]:void 0}var ZWt=KWt,YWt=Phe,XWt=Object.prototype,QWt=XWt.hasOwnProperty;function JWt(t){var s=this.__data__;return YWt?s[t]!==void 0:QWt.call(s,t)}var eKt=JWt,tKt=Phe,sKt="__lodash_hash_undefined__";function rKt(t,s){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=tKt&&s===void 0?sKt:s,this}var nKt=rKt,aKt=$Wt,iKt=UWt,oKt=ZWt,lKt=eKt,cKt=nKt;function cE(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s-1}var SKt=kKt,CKt=Ihe;function MKt(t,s){var r=this.__data__,n=CKt(r,t);return n<0?(++this.size,r.push([t,s])):r[n][1]=s,this}var TKt=MKt,AKt=hKt,EKt=_Kt,PKt=jKt,IKt=SKt,LKt=TKt;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 sYt(s)&&!dO(s)},iYt=function(s){return vi(s)},cu=function(s){return sn(s)||oC(s)},oYt=0,hE=function(s){var r=++oYt;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},lYt=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 fYt(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 IDe={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":""},LDe=null,Lye=null,z4e=function t(s){if(s===LDe&&Array.isArray(Lye))return Lye;var r=[];return S.Children.forEach(s,function(n){vi(n)||(XZt.isFragment(n)?r=r.concat(t(n.props.children)):r.push(n))}),Lye=r,LDe=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 DDe=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)},xYt=["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"],gYt=function(s){return s&&s.type&&oC(s.type)&&xYt.indexOf(s.type)>=0},yYt=function(s){return s&&sbe(s)==="object"&&"clipDot"in s},vYt=function(s,r,n,a){var o,l=(o=Iye==null?void 0:Iye[a])!==null&&o!==void 0?o:[];return r.startsWith("data-")||!di(s)&&(a&&l.includes(r)||uYt.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(S.isValidElement(s)&&(a=s.props),!lE(a))return null;var o={};return Object.keys(a).forEach(function(l){var i;vYt((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=S.Children.count(s);if(n!==S.Children.count(r))return!1;if(n===0)return!0;if(n===1)return RDe(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 NYt(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}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=jYt(t,wYt),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 kYt=["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 CYt(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=SYt(t,kYt),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:AYt(t,s,r)}var PYt=EYt,IYt="\\ud800-\\udfff",LYt="\\u0300-\\u036f",DYt="\\ufe20-\\ufe2f",RYt="\\u20d0-\\u20ff",OYt=LYt+DYt+RYt,FYt="\\ufe0e\\ufe0f",zYt="\\u200d",BYt=RegExp("["+zYt+IYt+OYt+FYt+"]");function $Yt(t){return BYt.test(t)}var est=$Yt;function qYt(t){return t.split("")}var UYt=qYt,tst="\\ud800-\\udfff",VYt="\\u0300-\\u036f",HYt="\\ufe20-\\ufe2f",GYt="\\u20d0-\\u20ff",WYt=VYt+HYt+GYt,KYt="\\ufe0e\\ufe0f",ZYt="["+tst+"]",obe="["+WYt+"]",lbe="\\ud83c[\\udffb-\\udfff]",YYt="(?:"+obe+"|"+lbe+")",sst="[^"+tst+"]",rst="(?:\\ud83c[\\udde6-\\uddff]){2}",nst="[\\ud800-\\udbff][\\udc00-\\udfff]",XYt="\\u200d",ast=YYt+"?",ist="["+KYt+"]?",QYt="(?:"+XYt+"(?:"+[sst,rst,nst].join("|")+")"+ist+ast+")*",JYt=ist+ast+QYt,eXt="(?:"+[sst+obe+"?",obe,rst,nst,ZYt].join("|")+")",tXt=RegExp(lbe+"(?="+lbe+")|"+eXt+JYt,"g");function sXt(t){return t.match(tXt)||[]}var rXt=sXt,nXt=UYt,aXt=est,iXt=rXt;function oXt(t){return aXt(t)?iXt(t):nXt(t)}var lXt=oXt,cXt=PYt,dXt=est,uXt=lXt,hXt=Ktt;function mXt(t){return function(s){s=hXt(s);var r=dXt(s)?uXt(s):void 0,n=r?r[0]:s.charAt(0),a=r?cXt(r,1).join(""):s.slice(1);return n[t]()+a}}var pXt=mXt,fXt=pXt,xXt=fXt("toUpperCase"),gXt=xXt;const Whe=no(gXt);function El(t){return function(){return t}}const ost=Math.cos,wce=Math.sin,Kg=Math.sqrt,jce=Math.PI,Khe=2*jce,cbe=Math.PI,dbe=2*cbe,a4=1e-6,yXt=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,k=Math.sqrt(N),C=Math.sqrt(y),A=o*Math.tan((cbe-Math.acos((N+y-w)/(2*k*C)))/2),I=A/C,L=A/k;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>yXt?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 _Xt(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 Zhe(t){return new cst(t)}function dst(t){return t[0]}function ust(t){return t[1]}function hst(t,s){var r=El(!0),n=null,a=Zhe,o=null,l=B4e(i);t=typeof t=="function"?t:t===void 0?dst:El(t),s=typeof s=="function"?s:s===void 0?ust:El(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()}k&&(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:El(+f),n=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:El(+f),u):t},u.x1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:El(+f),u):n},u.y=function(f){return arguments.length?(s=typeof f=="function"?f:El(+f),r=null,u):s},u.y0=function(f){return arguments.length?(s=typeof f=="function"?f:El(+f),u):s},u.y1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:El(+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:El(!!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 bXt(t){return new mst(t,!0)}function wXt(t){return new mst(t,!1)}const q4e={draw(t,s){const r=Kg(s/jce);t.moveTo(r,0),t.arc(0,0,r,0,Khe)}},jXt={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),NXt=pst*2,kXt={draw(t,s){const r=Kg(s/NXt),n=r*pst;t.moveTo(0,-r),t.lineTo(n,0),t.lineTo(0,r),t.lineTo(-n,0),t.closePath()}},SXt={draw(t,s){const r=Kg(s),n=-r/2;t.rect(n,n,r,r)}},CXt=.8908130915292852,fst=wce(jce/10)/wce(7*jce/10),MXt=wce(Khe/10)*fst,TXt=-ost(Khe/10)*fst,AXt={draw(t,s){const r=Kg(s*CXt),n=MXt*r,a=TXt*r;t.moveTo(0,-r),t.lineTo(n,a);for(let o=1;o<5;++o){const l=Khe*o/5,i=ost(l),d=wce(l);t.lineTo(d*r,-i*r),t.lineTo(i*n-d*a,d*n+i*a)}t.closePath()}},Dye=Kg(3),EXt={draw(t,s){const r=-Kg(s/(Dye*3));t.moveTo(0,r*2),t.lineTo(-Dye*r,-r),t.lineTo(Dye*r,-r),t.closePath()}},Vf=-.5,Hf=Kg(3)/2,ube=1/Kg(12),PXt=(ube/2+1)*3,IXt={draw(t,s){const r=Kg(s/PXt),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 LXt(t,s){let r=null,n=B4e(a);t=typeof t=="function"?t:El(t||q4e),s=typeof s=="function"?s:El(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:El(o),a):t},a.size=function(o){return arguments.length?(s=typeof o=="function"?o:El(+o),a):s},a.context=function(o){return arguments.length?(r=o??null,a):r},a}function Nce(){}function kce(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:kce(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:kce(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function DXt(t){return new xst(t)}function gst(t){this._context=t}gst.prototype={areaStart:Nce,areaEnd:Nce,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:kce(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function RXt(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:kce(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function OXt(t){return new yst(t)}function vst(t){this._context=t}vst.prototype={areaStart:Nce,areaEnd:Nce,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(t,s){t=+t,s=+s,this._point?this._context.lineTo(t,s):(this._point=1,this._context.moveTo(t,s))}};function FXt(t){return new vst(t)}function FDe(t){return t<0?-1:1}function zDe(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(FDe(o)+FDe(l))*Math.min(Math.abs(o),Math.abs(l),.5*Math.abs(i))||0}function BDe(t,s){var r=t._x1-t._x0;return r?(3*(t._y1-t._y0)/r-s)/2:s}function Rye(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 Sce(t){this._context=t}Sce.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:Rye(this,this._t0,BDe(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,Rye(this,BDe(this,r=zDe(this,t,s)),r);break;default:Rye(this,this._t0,r=zDe(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(Sce.prototype)).point=function(t,s){Sce.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 zXt(t){return new Sce(t)}function BXt(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=$De(t),a=$De(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 qXt(t){return new Yhe(t,.5)}function UXt(t){return new Yhe(t,0)}function VXt(t){return new Yhe(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 HXt(t,s){return t[s]}function GXt(t){const s=[];return s.key=t,s}function WXt(){var t=El([]),s=hbe,r=WT,n=HXt;function a(o){var l=Array.from(t.apply(this,arguments),GXt),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 sQt(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:jXt,symbolDiamond:kXt,symbolSquare:SXt,symbolStar:AXt,symbolTriangle:EXt,symbolWye:IXt},rQt=Math.PI/180,nQt=function(s){var r="symbol".concat(Whe(s));return jst[r]||q4e},aQt=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*rQt;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}},iQt=function(s,r){jst["symbol".concat(Whe(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=tQt(s,XXt),u=UDe(UDe({},d),{},{type:n,size:o,sizeType:i}),p=function(){var w=nQt(n),k=LXt().type(w).size(aQt(o,i,n));return k()},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=iQt;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(k,_,b):k))})}},{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())}}])}(S.PureComponent);TD(V4e,"displayName","Legend");TD(V4e,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var xQt=Lhe;function gQt(){this.__data__=new xQt,this.size=0}var yQt=gQt;function vQt(t){var s=this.__data__,r=s.delete(t);return this.size=s.size,r}var _Qt=vQt;function bQt(t){return this.__data__.get(t)}var wQt=bQt;function jQt(t){return this.__data__.has(t)}var NQt=jQt,kQt=Lhe,SQt=E4e,CQt=P4e,MQt=200;function TQt(t,s){var r=this.__data__;if(r instanceof kQt){var n=r.__data__;if(!SQt||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&XQt?new WQt:void 0;for(o.set(t,s),o.set(s,t);++f-1&&t%1==0&&t-1&&t%1==0&&t<=tes}var K4e=ses,res=M1,nes=K4e,aes=T1,ies="[object Arguments]",oes="[object Array]",les="[object Boolean]",ces="[object Date]",des="[object Error]",ues="[object Function]",hes="[object Map]",mes="[object Number]",pes="[object Object]",fes="[object RegExp]",xes="[object Set]",ges="[object String]",yes="[object WeakMap]",ves="[object ArrayBuffer]",_es="[object DataView]",bes="[object Float32Array]",wes="[object Float64Array]",jes="[object Int8Array]",Nes="[object Int16Array]",kes="[object Int32Array]",Ses="[object Uint8Array]",Ces="[object Uint8ClampedArray]",Mes="[object Uint16Array]",Tes="[object Uint32Array]",Kl={};Kl[bes]=Kl[wes]=Kl[jes]=Kl[Nes]=Kl[kes]=Kl[Ses]=Kl[Ces]=Kl[Mes]=Kl[Tes]=!0;Kl[ies]=Kl[oes]=Kl[ves]=Kl[les]=Kl[_es]=Kl[ces]=Kl[des]=Kl[ues]=Kl[hes]=Kl[mes]=Kl[pes]=Kl[fes]=Kl[xes]=Kl[ges]=Kl[yes]=!1;function Aes(t){return aes(t)&&nes(t.length)&&!!Kl[res(t)]}var Ees=Aes;function Pes(t){return function(s){return t(s)}}var Lst=Pes,Ace={exports:{}};Ace.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})(Ace,Ace.exports);var Ies=Ace.exports,Les=Ees,Des=Lst,YDe=Ies,XDe=YDe&&YDe.isTypedArray,Res=XDe?Des(XDe):Les,Dst=Res,Oes=BJt,Fes=G4e,zes=wp,Bes=Ist,$es=W4e,qes=Dst,Ues=Object.prototype,Ves=Ues.hasOwnProperty;function Hes(t,s){var r=zes(t),n=!r&&Fes(t),a=!r&&!n&&Bes(t),o=!r&&!n&&!a&&qes(t),l=r||n||a||o,i=l?Oes(t.length,String):[],d=i.length;for(var u in t)(s||Ves.call(t,u))&&!(l&&(u=="length"||a&&(u=="offset"||u=="parent")||o&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||$es(u,d)))&&i.push(u);return i}var Ges=Hes,Wes=Object.prototype;function Kes(t){var s=t&&t.constructor,r=typeof s=="function"&&s.prototype||Wes;return t===r}var Zes=Kes;function Yes(t,s){return function(r){return t(s(r))}}var Rst=Yes,Xes=Rst,Qes=Xes(Object.keys,Object),Jes=Qes,ets=Zes,tts=Jes,sts=Object.prototype,rts=sts.hasOwnProperty;function nts(t){if(!ets(t))return tts(t);var s=[];for(var r in Object(t))rts.call(t,r)&&r!="constructor"&&s.push(r);return s}var ats=nts,its=T4e,ots=K4e;function lts(t){return t!=null&&ots(t.length)&&!its(t)}var uO=lts,cts=Ges,dts=ats,uts=uO;function hts(t){return uts(t)?cts(t):dts(t)}var Xhe=hts,mts=MJt,pts=FJt,fts=Xhe;function xts(t){return mts(t,fts,pts)}var gts=xts,QDe=gts,yts=1,vts=Object.prototype,_ts=vts.hasOwnProperty;function bts(t,s,r,n,a,o){var l=r&yts,i=QDe(t),d=i.length,u=QDe(s),p=u.length;if(d!=p&&!l)return!1;for(var f=d;f--;){var y=i[f];if(!(l?y in s:_ts.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 vrs=yrs;function _rs(t,s,r){for(var n=-1,a=t==null?0:t.length;++n=Drs){var u=s?null:Irs(t);if(u)return Lrs(u);l=!1,a=Prs,d=new Trs}else d=s?[]:i;e:for(;++n=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Xrs(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 Qrs(t){return t.value}function Jrs(t,s){if(xt.isValidElement(t))return xt.cloneElement(t,s);if(typeof t=="function")return xt.createElement(t,s);s.ref;var r=Yrs(s,qrs);return xt.createElement(V4e,r)}var pRe=1,eT=function(t){function s(){var r;Urs(this,s);for(var n=arguments.length,a=new Array(n),o=0;opRe||Math.abs(a.height-this.lastBoundingBox.height)>pRe)&&(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=_}},Jrs(o,yv(yv({},this.props),{},{payload:Ust(p,u,Qrs)})))}}],[{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}}])}(S.PureComponent);Qhe(eT,"displayName","Legend");Qhe(eT,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var fRe=cO,ens=G4e,tns=wp,xRe=fRe?fRe.isConcatSpreadable:void 0;function sns(t){return tns(t)||ens(t)||!!(xRe&&t&&t[xRe])}var rns=sns,nns=Est,ans=rns;function Gst(t,s,r,n,a){var o=-1,l=t.length;for(r||(r=ans),a||(a=[]);++o0&&r(i)?s>1?Gst(i,s-1,r,n,a):nns(a,i):n||(a[a.length]=i)}return a}var Wst=Gst;function ins(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 ons=ins,lns=ons,cns=lns(),dns=cns,uns=dns,hns=Xhe;function mns(t,s){return t&&uns(t,s,hns)}var Kst=mns,pns=uO;function fns(t,s){return function(r,n){if(r==null)return r;if(!pns(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 Tns=Mns,Bye=L4e,Ans=D4e,Ens=C0,Pns=Zst,Ins=Nns,Lns=Lst,Dns=Tns,Rns=fE,Ons=wp;function Fns(t,s,r){s.length?s=Bye(s,function(o){return Ons(o)?function(l){return Ans(l,o.length===1?o[0]:o)}:o}):s=[Rns];var n=-1;s=Bye(s,Lns(Ens));var a=Pns(t,function(o,l,i){var d=Bye(s,function(u){return u(o)});return{criteria:d,index:++n,value:o}});return Ins(a,function(o,l){return Dns(o,l,r)})}var zns=Fns;function Bns(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 $ns=Bns,qns=$ns,yRe=Math.max;function Uns(t,s,r){return s=yRe(s===void 0?t.length-1:s,0),function(){for(var n=arguments,a=-1,o=yRe(n.length-s,0),l=Array(o);++a0){if(++s>=Jns)return arguments[0]}else s=0;return t.apply(void 0,arguments)}}var ras=sas,nas=Qns,aas=ras,ias=aas(nas),oas=ias,las=fE,cas=Vns,das=oas;function uas(t,s){return das(cas(t,s,las),t+"")}var has=uas,mas=A4e,pas=uO,fas=W4e,xas=jw;function gas(t,s,r){if(!xas(r))return!1;var n=typeof s;return(n=="number"?pas(r)&&fas(s,r.length):n=="string"&&s in r)?mas(r[s],t):!1}var Jhe=gas,yas=Wst,vas=zns,_as=has,_Re=Jhe,bas=_as(function(t,s){if(t==null)return[];var r=s.length;return r>1&&_Re(t,s[0],s[1])?s=[]:r>2&&_Re(s[0],s[1],s[2])&&(s=[s[0]]),vas(t,yas(s,1),[])}),was=bas;const X4e=no(was);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 Oas(t){var s=t.translateX,r=t.translateY,n=t.useTranslate3d;return{transform:n?"translate3d(".concat(s,"px, ").concat(r,"px, 0)"):"translate(".concat(s,"px, ").concat(r,"px)")}}function Fas(t){var s=t.allowEscapeViewBox,r=t.coordinate,n=t.offsetTopLeft,a=t.position,o=t.reverseDirection,l=t.tooltipBox,i=t.useTranslate3d,d=t.viewBox,u,p,f;return l.height>0&&l.width>0&&r?(p=jRe({allowEscapeViewBox:s,coordinate:r,key:"x",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.width,viewBox:d,viewBoxDimension:d.width}),f=jRe({allowEscapeViewBox:s,coordinate:r,key:"y",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.height,viewBox:d,viewBoxDimension:d.height}),u=Oas({translateX:p,translateY:f,useTranslate3d:i})):u=Das,{cssProperties:u,cssClasses:Ras({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 NRe(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 kRe(t){for(var s=1;sSRe||Math.abs(n.height-this.state.lastBoundingBox.height)>SRe)&&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,k=a.viewBox,C=a.wrapperStyle,A=Fas({allowEscapeViewBox:l,coordinate:p,offsetTopLeft:_,position:b,reverseDirection:N,tooltipBox:this.state.lastBoundingBox,useTranslate3d:w,viewBox:k}),I=A.cssClasses,L=A.cssProperties,O=kRe(kRe({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)}}])}(S.PureComponent),Kas=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},l0={isSsr:Kas(),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 CRe(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 MRe(t){for(var s=1;s0;return xt.createElement(Was,{allowEscapeViewBox:l,animationDuration:i,animationEasing:d,isAnimationActive:y,active:o,coordinate:p,hasPayload:O,offset:_,position:w,reverseDirection:k,useTranslate3d:C,viewBox:A,wrapperStyle:I},nis(u,MRe(MRe({},this.props),{},{payload:L})))}}])}(S.PureComponent);Q4e(ep,"displayName","Tooltip");Q4e(ep,"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 ais=S0,iis=function(){return ais.Date.now()},ois=iis,lis=/\s/;function cis(t){for(var s=t.length;s--&&lis.test(t.charAt(s)););return s}var dis=cis,uis=dis,his=/^\s+/;function mis(t){return t&&t.slice(0,uis(t)+1).replace(his,"")}var pis=mis,fis=pis,TRe=jw,xis=oE,ARe=NaN,gis=/^[-+]0x[0-9a-f]+$/i,yis=/^0b[01]+$/i,vis=/^0o[0-7]+$/i,_is=parseInt;function bis(t){if(typeof t=="number")return t;if(xis(t))return ARe;if(TRe(t)){var s=typeof t.valueOf=="function"?t.valueOf():t;t=TRe(s)?s+"":s}if(typeof t!="string")return t===0?t:+t;t=fis(t);var r=yis.test(t);return r||vis.test(t)?_is(t.slice(2),r?2:8):gis.test(t)?ARe:+t}var trt=bis,wis=jw,qye=ois,ERe=trt,jis="Expected a function",Nis=Math.max,kis=Math.min;function Sis(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(jis);s=ERe(s)||0,wis(r)&&(p=!!r.leading,f="maxWait"in r,o=f?Nis(ERe(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(k,s),p?_(O):l}function N(O){var V=O-d,q=O-u,B=s-V;return f?kis(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 k(){var O=qye();if(w(O))return C(O);i=setTimeout(k,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(qye())}function L(){var O=qye(),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(k,s),_(d)}return i===void 0&&(i=setTimeout(k,s)),l}return L.cancel=A,L.flush=I,L}var Cis=Sis,Mis=Cis,Tis=jw,Ais="Expected a function";function Eis(t,s,r){var n=!0,a=!0;if(typeof t!="function")throw new TypeError(Ais);return Tis(r)&&(n="leading"in r?!!r.leading:n,a="trailing"in r?!!r.trailing:a),Mis(t,s,{leading:n,maxWait:s,trailing:a})}var Pis=Eis;const srt=no(Pis);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 PRe(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 i9(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(),ae=ce.width,ie=ce.height;return te(ae,ie),X.observe(L.current),function(){X.disconnect()}},[te,N]);var Y=S.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,ae=k4(d)?X:d;r&&r>0&&(ce?ae=ce/r:ae&&(ce=ae*r),y&&ae>y&&(ae=y)),Rg(ce>0||ae>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,ae,l,d,p,f,r);var ie=!Array.isArray(_)&&n1(_.type).endsWith("Chart");return xt.Children.map(_,function(oe){return xt.isValidElement(oe)?S.cloneElement(oe,i9({width:ce,height:ae},ie?{style:i9({height:"100%",width:"100%",maxHeight:ae,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",k),style:i9(i9({},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 LRe(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=Gis(r),a=JSON.stringify({text:s,copyStyle:n});if(j5.widthCache[a])return j5.widthCache[a];try{var o=document.getElementById(DRe);o||(o=document.createElement("span"),o.setAttribute("id",DRe),o.setAttribute("aria-hidden","true"),document.body.appendChild(o));var l=Sbe(Sbe({},His),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>Vis&&(j5.cacheCount=0,j5.widthCache={}),d}catch{return{width:0,height:0}}},Wis=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 Lce(t,s){return Xis(t)||Yis(t,s)||Zis(t,s)||Kis()}function Kis(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Zis(t,s){if(t){if(typeof t=="string")return RRe(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 RRe(t,s)}}function RRe(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 uos(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 qRe(t,s){return fos(t)||pos(t,s)||mos(t,s)||hos()}function hos(){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 mos(t,s){if(t){if(typeof t=="string")return URe(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return URe(t,s)}}function URe(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r0&&arguments[0]!==void 0?arguments[0]:[];return ce.reduce(function(ae,ie){var oe=ie.word,me=ie.width,ye=ae[ae.length-1];if(ye&&(a==null||o||ye.width+me+nie.width?ae:ie})};if(!p)return _;for(var N="…",w=function(ce){var ae=f.slice(0,ce),ie=irt({breakAll:u,style:d,children:ae+N}).wordsWithComputedWidth,oe=y(ie),me=oe.length>l||b(oe).width>Number(a);return[me,oe]},k=0,C=f.length-1,A=0,I;k<=C&&A<=f.length-1;){var L=Math.floor((k+C)/2),O=L-1,V=w(O),q=qRe(V,2),B=q[0],U=q[1],te=w(L),Y=qRe(te,1),J=Y[0];if(!B&&!J&&(k=L+1),B&&J&&(C=L-1),!B&&J){I=U;break}A++}return I||_},VRe=function(s){var r=vi(s)?[]:s.toString().split(art);return[{words:r}]},gos=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 VRe(a);return xos({breakAll:l,children:a,maxLines:i,style:o},d,u,r,n)}return VRe(a)},HRe="#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,k=w===void 0?HRe:w,C=$Re(s,cos),A=S.useMemo(function(){return gos({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=$Re(C,dos);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=Uye("calc(".concat(u,")"));break;case"middle":Y=Uye("calc(".concat((A.length-1)/2," * -").concat(i," + (").concat(u," / 2))"));break;default:Y=Uye("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:k.includes("url")?HRe:k}),A.map(function(ae,ie){var oe=ae.words.join(q?"":" ");return xt.createElement("tspan",{x:U,dy:ie===0?Y:i,key:"".concat(oe,"-").concat(ie)},oe)}))};function Bb(t,s){return t==null||s==null?NaN:ts?1:t>=s?0:NaN}function yos(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===yos?t:vos,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 vos(){return 0}function ort(t){return t===null?NaN:+t}function*_os(t,s){for(let r of t)r!=null&&(r=+r)>=r&&(yield r)}const bos=J4e(Bb),mO=bos.right;J4e(ort).center;class GRe extends Map{constructor(s,r=Nos){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(WRe(this,s))}has(s){return super.has(WRe(this,s))}set(s,r){return super.set(wos(this,s),r)}delete(s){return super.delete(jos(this,s))}}function WRe({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):r}function wos({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):(t.set(n,r),r)}function jos({_intern:t,_key:s},r){const n=s(r);return t.has(n)&&(r=t.get(n),t.delete(n)),r}function Nos(t){return t!==null&&typeof t=="object"?t.valueOf():t}function kos(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 Sos=Math.sqrt(50),Cos=Math.sqrt(10),Mos=Math.sqrt(2);function Dce(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>=Sos?10:o>=Cos?5:o>=Mos?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 ZRe(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:kos(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 Tos(t,s,r){if(t=Float64Array.from(_os(t)),!(!(n=t.length)||isNaN(s=+s))){if(s<=0||n<2)return ZRe(t);if(s>=1)return KRe(t);var n,a=(n-1)*s,o=Math.floor(a),l=KRe(crt(t,o).subarray(0,o+1)),i=ZRe(t.subarray(o+1));return l+(i-l)*(a-o)}}function Aos(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 Eos(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?l9(s>>24&255,s>>16&255,s>>8&255,(s&255)/255):r===4?l9(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=Ios.exec(t))?new cp(s[1],s[2],s[3],1):(s=Los.exec(t))?new cp(s[1]*255/100,s[2]*255/100,s[3]*255/100,1):(s=Dos.exec(t))?l9(s[1],s[2],s[3],s[4]):(s=Ros.exec(t))?l9(s[1]*255/100,s[2]*255/100,s[3]*255/100,s[4]):(s=Oos.exec(t))?sOe(s[1],s[2]/100,s[3]/100,1):(s=Fos.exec(t))?sOe(s[1],s[2]/100,s[3]/100,s[4]):YRe.hasOwnProperty(t)?JRe(YRe[t]):t==="transparent"?new cp(NaN,NaN,NaN,0):null}function JRe(t){return new cp(t>>16&255,t>>8&255,t&255,1)}function l9(t,s,r,n){return n<=0&&(t=s=r=NaN),new cp(t,s,r,n)}function $os(t){return t instanceof pO||(t=FD(t)),t?(t=t.rgb(),new cp(t.r,t.g,t.b,t.opacity)):new cp}function Pbe(t,s,r,n){return arguments.length===1?$os(t):new cp(t,s,r,n??1)}function cp(t,s,r,n){this.r=+t,this.g=+s,this.b=+r,this.opacity=+n}tSe(cp,Pbe,urt(pO,{brighter(t){return t=t==null?Rce:Math.pow(Rce,t),new cp(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?RD:Math.pow(RD,t),new cp(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new cp(ES(this.r),ES(this.g),ES(this.b),Oce(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:eOe,formatHex:eOe,formatHex8:qos,formatRgb:tOe,toString:tOe}));function eOe(){return`#${S4(this.r)}${S4(this.g)}${S4(this.b)}`}function qos(){return`#${S4(this.r)}${S4(this.g)}${S4(this.b)}${S4((isNaN(this.opacity)?1:this.opacity)*255)}`}function tOe(){const t=Oce(this.opacity);return`${t===1?"rgb(":"rgba("}${ES(this.r)}, ${ES(this.g)}, ${ES(this.b)}${t===1?")":`, ${t})`}`}function Oce(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 sOe(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 Uos(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,Uos,urt(pO,{brighter(t){return t=t==null?Rce:Math.pow(Rce,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 cp(Vye(t>=240?t-240:t+120,a,n),Vye(t,a,n),Vye(t<120?t+240:t-120,a,n),this.opacity)},clamp(){return new Ng(rOe(this.h),c9(this.s),c9(this.l),Oce(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=Oce(this.opacity);return`${t===1?"hsl(":"hsla("}${rOe(this.h)}, ${c9(this.s)*100}%, ${c9(this.l)*100}%${t===1?")":`, ${t})`}`}}));function rOe(t){return t=(t||0)%360,t<0?t+360:t}function c9(t){return Math.max(0,Math.min(1,t||0))}function Vye(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 Vos(t,s){return function(r){return t+r*s}}function Hos(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 Gos(t){return(t=+t)==1?mrt:function(s,r){return r-s?Hos(s,r,t):sSe(isNaN(s)?r:s)}}function mrt(t,s){var r=s-t;return r?Vos(t,r):sSe(isNaN(t)?s:t)}const nOe=function t(s){var r=Gos(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 Wos(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:Fce(n,a)})),r=Hye.lastIndex;return rs&&(r=t,t=s,s=r),function(n){return Math.max(t,Math.min(s,n))}}function nls(t,s,r){var n=t[0],a=t[1],o=s[0],l=s[1];return a2?als:nls,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),Fce)))(y)))},f.domain=function(y){return arguments.length?(t=Array.from(y,zce),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 eme()(Nm,Nm)}function ils(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function Bce(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=Bce(Math.abs(t)),t?t[1]:NaN}function ols(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 lls(t){return function(s){return s.replace(/[0-9]/g,function(r){return t[+r]})}}var cls=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function zD(t){if(!(s=cls.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 dls(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 uls(t,s){var r=Bce(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")+Bce(t,Math.max(0,s+o-1))[0]}function iOe(t,s){var r=Bce(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 oOe={"%":(t,s)=>(t*100).toFixed(s),b:t=>Math.round(t).toString(2),c:t=>t+"",d:ils,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)=>iOe(t*100,s),r:iOe,s:uls,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function lOe(t){return t}var cOe=Array.prototype.map,dOe=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function hls(t){var s=t.grouping===void 0||t.thousands===void 0?lOe:ols(cOe.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?lOe:lls(cOe.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,k=f.width,C=f.comma,A=f.precision,I=f.trim,L=f.type;L==="n"?(C=!0,L="g"):oOe[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=oOe[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,ae;if(L==="c")J=q(te)+J,te="";else{te=+te;var ie=te<0||1/te<0;if(te=isNaN(te)?d:q(Math.abs(te),A),I&&(te=dls(te)),ie&&+te==0&&b!=="+"&&(ie=!1),Y=(ie?b==="("?b:i:b==="-"||b==="("?"":b)+Y,J=(L==="s"?dOe[8+prt/3]:"")+J+(ie&&b==="("?")":""),B){for(X=-1,ce=te.length;++Xae||ae>57){J=(ae===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=dOe[8+b/3];return function(k){return _(N*k)+w}}return{format:u,formatPrefix:p}}var d9,iSe,frt;mls({thousands:",",grouping:[3],currency:["$",""]});function mls(t){return d9=hls(t),iSe=d9.format,frt=d9.formatPrefix,d9}function pls(t){return Math.max(0,-QT(Math.abs(t)))}function fls(t,s){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(QT(s)/3)))*3-QT(Math.abs(t)))}function xls(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=fls(a,l))&&(n.precision=o),frt(n,l)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(o=xls(a,Math.max(Math.abs(t),Math.abs(s))))&&(n.precision=o-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(o=pls(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 $ce(){var t=nSe();return t.copy=function(){return fO(t,$ce())},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,zce),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,zce):[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 bls(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 mOe(t){return(s,r)=>-t(-s,r)}function oSe(t){const s=t(uOe,hOe),r=s.domain;let n=10,a,o;function l(){return a=bls(n),o=_ls(n),r()[0]<0?(a=mOe(a),o=mOe(o),t(gls,yls)):t(uOe,hOe),s}return s.base=function(i){return arguments.length?(n=+i,l()):n},s.domain=function(i){return arguments.length?(r(i),l()):r()},s.ticks=i=>{const d=r();let u=d[0],p=d[d.length-1];const f=p0){for(;y<=_;++y)for(b=1;bp)break;k.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;k.push(N)}k.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(eme()).domain([1,10]);return t.copy=()=>fO(t,vrt()).base(t.base()),Rx.apply(t,arguments),t}function pOe(t){return function(s){return Math.sign(s)*Math.log1p(Math.abs(s/t))}}function fOe(t){return function(s){return Math.sign(s)*Math.expm1(Math.abs(s))*t}}function lSe(t){var s=1,r=t(pOe(s),fOe(s));return r.constant=function(n){return arguments.length?t(pOe(s=+n),fOe(s)):s},Nw(r)}function _rt(){var t=lSe(eme());return t.copy=function(){return fO(t,_rt()).constant(t.constant())},Rx.apply(t,arguments)}function xOe(t){return function(s){return s<0?-Math.pow(-s,t):Math.pow(s,t)}}function wls(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function jls(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(wls,jls):t(xOe(r),xOe(1/r))}return s.exponent=function(a){return arguments.length?(r=+a,n()):r},Nw(s)}function dSe(){var t=cSe(eme());return t.copy=function(){return fO(t,dSe()).exponent(t.exponent())},Rx.apply(t,arguments),t}function Nls(){return dSe.apply(null,arguments).exponent(.5)}function gOe(t){return Math.sign(t)*t*t}function kls(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=kls(t(o));return isNaN(l)?n:r?Math.round(l):l}return a.invert=function(o){return t.invert(gOe(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,zce)).map(gOe)),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 Gye=new Date,Wye=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)=>(Gye.setTime(+o),Wye.setTime(+l),t(Gye),t(Wye),Math.floor(r(Gye,Wye))),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 qce=_u(()=>{},(t,s)=>{t.setTime(+t+s)},(t,s)=>s-t);qce.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):qce);qce.range;const qv=1e3,hx=qv*60,Uv=hx*60,g1=Uv*24,uSe=g1*7,yOe=g1*30,Kye=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 tme=_u(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/g1,t=>t.getUTCDate()-1);tme.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 sme=EC(0),Uce=EC(1),Sls=EC(2),Cls=EC(3),JT=EC(4),Mls=EC(5),Tls=EC(6);sme.range;Uce.range;Sls.range;Cls.range;JT.range;Mls.range;Tls.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 rme=PC(0),Vce=PC(1),Als=PC(2),Els=PC(3),eA=PC(4),Pls=PC(5),Ils=PC(6);rme.range;Vce.range;Als.range;Els.range;eA.range;Pls.range;Ils.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,yOe],[s,3,3*yOe],[t,1,Kye]];function i(u,p,f){const y=pw).right(l,y);if(_===l.length)return t.every(Abe(u/Kye,p/Kye,f));if(_===0)return qce.every(Math.max(Abe(u,p,f),1));const[b,N]=l[y/l[_-1][2]53)return null;"w"in we||(we.w=1),"Z"in we?(fe=Yye(hI(we.y,0,1)),He=fe.getUTCDay(),fe=He>4||He===0?Vce.ceil(fe):Vce(fe),fe=tme.offset(fe,(we.V-1)*7),we.y=fe.getUTCFullYear(),we.m=fe.getUTCMonth(),we.d=fe.getUTCDate()+(we.w+6)%7):(fe=Zye(hI(we.y,0,1)),He=fe.getDay(),fe=He>4||He===0?Uce.ceil(fe):Uce(fe),fe=xO.offset(fe,(we.V-1)*7),we.y=fe.getFullYear(),we.m=fe.getMonth(),we.d=fe.getDate()+(we.w+6)%7)}else("W"in we||"U"in we)&&("w"in we||(we.w="u"in we?we.u%7:"W"in we?1:0),He="Z"in we?Yye(hI(we.y,0,1)).getUTCDay():Zye(hI(we.y,0,1)).getDay(),we.m=0,we.d="W"in we?(we.w+6)%7+we.W*7-(He+5)%7:we.w+we.U*7-(He+6)%7);return"Z"in we?(we.H+=we.Z/100|0,we.M+=we.Z%100,Yye(we)):Zye(we)}}function q(ke,$e,Be,we){for(var ut=0,fe=$e.length,He=Be.length,et,tt;ut=He)return-1;if(et=$e.charCodeAt(ut++),et===37){if(et=$e.charAt(ut++),tt=L[et in vOe?$e.charAt(ut++):et],!tt||(we=tt(ke,Be,we))<0)return-1}else if(et!=Be.charCodeAt(we++))return-1}return we}function B(ke,$e,Be){var we=u.exec($e.slice(Be));return we?(ke.p=p.get(we[0].toLowerCase()),Be+we[0].length):-1}function U(ke,$e,Be){var we=_.exec($e.slice(Be));return we?(ke.w=b.get(we[0].toLowerCase()),Be+we[0].length):-1}function te(ke,$e,Be){var we=f.exec($e.slice(Be));return we?(ke.w=y.get(we[0].toLowerCase()),Be+we[0].length):-1}function Y(ke,$e,Be){var we=k.exec($e.slice(Be));return we?(ke.m=C.get(we[0].toLowerCase()),Be+we[0].length):-1}function J(ke,$e,Be){var we=N.exec($e.slice(Be));return we?(ke.m=w.get(we[0].toLowerCase()),Be+we[0].length):-1}function X(ke,$e,Be){return q(ke,s,$e,Be)}function ce(ke,$e,Be){return q(ke,r,$e,Be)}function ae(ke,$e,Be){return q(ke,n,$e,Be)}function ie(ke){return l[ke.getDay()]}function oe(ke){return o[ke.getDay()]}function me(ke){return d[ke.getMonth()]}function ye(ke){return i[ke.getMonth()]}function he(ke){return a[+(ke.getHours()>=12)]}function ge(ke){return 1+~~(ke.getMonth()/3)}function Ne(ke){return l[ke.getUTCDay()]}function Ue(ke){return o[ke.getUTCDay()]}function Te(ke){return d[ke.getUTCMonth()]}function Me(ke){return i[ke.getUTCMonth()]}function De(ke){return a[+(ke.getUTCHours()>=12)]}function qe(ke){return 1+~~(ke.getUTCMonth()/3)}return{format:function(ke){var $e=O(ke+="",A);return $e.toString=function(){return ke},$e},parse:function(ke){var $e=V(ke+="",!1);return $e.toString=function(){return ke},$e},utcFormat:function(ke){var $e=O(ke+="",I);return $e.toString=function(){return ke},$e},utcParse:function(ke){var $e=V(ke+="",!0);return $e.toString=function(){return ke},$e}}}var vOe={"-":"",_:" ",0:"0"},Gu=/^\s*\d+/,zls=/^%/,Bls=/[\\^$*+?|[\]().{}]/g;function Mo(t,s,r){var n=t<0?"-":"",a=(n?-t:t)+"",o=a.length;return n+(o[s.toLowerCase(),r]))}function qls(t,s,r){var n=Gu.exec(s.slice(r,r+1));return n?(t.w=+n[0],r+n[0].length):-1}function Uls(t,s,r){var n=Gu.exec(s.slice(r,r+1));return n?(t.u=+n[0],r+n[0].length):-1}function Vls(t,s,r){var n=Gu.exec(s.slice(r,r+2));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.V=+n[0],r+n[0].length):-1}function Gls(t,s,r){var n=Gu.exec(s.slice(r,r+2));return n?(t.W=+n[0],r+n[0].length):-1}function _Oe(t,s,r){var n=Gu.exec(s.slice(r,r+4));return n?(t.y=+n[0],r+n[0].length):-1}function bOe(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 Wls(t,s,r){var n=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(s.slice(r,r+6));return n?(t.Z=n[1]?0:-(n[2]+(n[3]||"00")),r+n[0].length):-1}function Kls(t,s,r){var n=Gu.exec(s.slice(r,r+1));return n?(t.q=n[0]*3-3,r+n[0].length):-1}function Zls(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 wOe(t,s,r){var n=Gu.exec(s.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function Yls(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 jOe(t,s,r){var n=Gu.exec(s.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function Xls(t,s,r){var n=Gu.exec(s.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function Qls(t,s,r){var n=Gu.exec(s.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function Jls(t,s,r){var n=Gu.exec(s.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function ecs(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 tcs(t,s,r){var n=zls.exec(s.slice(r,r+1));return n?r+n[0].length:-1}function scs(t,s,r){var n=Gu.exec(s.slice(r));return n?(t.Q=+n[0],r+n[0].length):-1}function rcs(t,s,r){var n=Gu.exec(s.slice(r));return n?(t.s=+n[0],r+n[0].length):-1}function NOe(t,s){return Mo(t.getDate(),s,2)}function ncs(t,s){return Mo(t.getHours(),s,2)}function acs(t,s){return Mo(t.getHours()%12||12,s,2)}function ics(t,s){return Mo(1+xO.count(y1(t),t),s,3)}function Crt(t,s){return Mo(t.getMilliseconds(),s,3)}function ocs(t,s){return Crt(t,s)+"000"}function lcs(t,s){return Mo(t.getMonth()+1,s,2)}function ccs(t,s){return Mo(t.getMinutes(),s,2)}function dcs(t,s){return Mo(t.getSeconds(),s,2)}function ucs(t){var s=t.getDay();return s===0?7:s}function hcs(t,s){return Mo(sme.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 mcs(t,s){return t=Mrt(t),Mo(JT.count(y1(t),t)+(y1(t).getDay()===4),s,2)}function pcs(t){return t.getDay()}function fcs(t,s){return Mo(Uce.count(y1(t)-1,t),s,2)}function xcs(t,s){return Mo(t.getFullYear()%100,s,2)}function gcs(t,s){return t=Mrt(t),Mo(t.getFullYear()%100,s,2)}function ycs(t,s){return Mo(t.getFullYear()%1e4,s,4)}function vcs(t,s){var r=t.getDay();return t=r>=4||r===0?JT(t):JT.ceil(t),Mo(t.getFullYear()%1e4,s,4)}function _cs(t){var s=t.getTimezoneOffset();return(s>0?"-":(s*=-1,"+"))+Mo(s/60|0,"0",2)+Mo(s%60,"0",2)}function kOe(t,s){return Mo(t.getUTCDate(),s,2)}function bcs(t,s){return Mo(t.getUTCHours(),s,2)}function wcs(t,s){return Mo(t.getUTCHours()%12||12,s,2)}function jcs(t,s){return Mo(1+tme.count(v1(t),t),s,3)}function Trt(t,s){return Mo(t.getUTCMilliseconds(),s,3)}function Ncs(t,s){return Trt(t,s)+"000"}function kcs(t,s){return Mo(t.getUTCMonth()+1,s,2)}function Scs(t,s){return Mo(t.getUTCMinutes(),s,2)}function Ccs(t,s){return Mo(t.getUTCSeconds(),s,2)}function Mcs(t){var s=t.getUTCDay();return s===0?7:s}function Tcs(t,s){return Mo(rme.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 Acs(t,s){return t=Art(t),Mo(eA.count(v1(t),t)+(v1(t).getUTCDay()===4),s,2)}function Ecs(t){return t.getUTCDay()}function Pcs(t,s){return Mo(Vce.count(v1(t)-1,t),s,2)}function Ics(t,s){return Mo(t.getUTCFullYear()%100,s,2)}function Lcs(t,s){return t=Art(t),Mo(t.getUTCFullYear()%100,s,2)}function Dcs(t,s){return Mo(t.getUTCFullYear()%1e4,s,4)}function Rcs(t,s){var r=t.getUTCDay();return t=r>=4||r===0?eA(t):eA.ceil(t),Mo(t.getUTCFullYear()%1e4,s,4)}function Ocs(){return"+0000"}function SOe(){return"%"}function COe(t){return+t}function MOe(t){return Math.floor(+t/1e3)}var N5,Ert,Prt;Fcs({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function Fcs(t){return N5=Fls(t),Ert=N5.format,N5.parse,Prt=N5.utcFormat,N5.utcParse,N5}function zcs(t){return new Date(t)}function Bcs(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"),k=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)=>Tos(t,o/n))},r.copy=function(){return Rrt(s).domain(t)},A1.apply(r,arguments)}function ame(){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=Wcs,Kcs=ime,Zcs=Brt,Ycs=fE;function Xcs(t){return t&&t.length?Kcs(t,Ycs,Zcs):void 0}var Qcs=Xcs;const ome=no(Qcs);function Jcs(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)*Xl;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*Xl+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/Xl+4),vc=!1;r%2&&(a=a.times(i),EOe(a.d,s)),r=yE(r/2),r!==0;)i=i.times(i),EOe(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/Xl),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,k,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/Xl+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?(k=N[0],V!=w&&(k=k*Pu+(N[1]||0)),p=k/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*Xl,r=t.d[0];r>=10;r/=10)s++;return s}function Xye(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),Xye(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=Xye(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(Xye(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 AOe(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/Xl),t.d=[],n=(r+1)%Xl,r<0&&(n+=Xl),nHce||t.e<-Hce))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+=Xl,a=s,u=f[p=0];else{if(p=Math.ceil((n+1)/Xl),o=f.length,p>=o)return t;for(u=o=f[p],l=1;o>=10;o/=10)l++;n%=Xl,a=n-Xl+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,(Xl-s%Xl)%Xl),t.e=yE(-s/Xl)||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,Xl-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>Hce||t.e<-Hce))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(_/Xl),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 EOe(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 AOe(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,_ds.test(o))AOe(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=bds,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(vds);ef=new wSe(1);const nl=wSe;function wds(t){return Sds(t)||kds(t)||Nds(t)||jds()}function jds(){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 Nds(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 kds(t){if(typeof Symbol<"u"&&Symbol.iterator in Object(t))return Array.from(t)}function Sds(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,POe(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 $ds(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=dme.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 qds(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(dme.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=Ads(Tds(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 Uds(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 qds(u,a,o);var y=Jrt(u,p,l,o),_=y.step,b=y.tickMin,N=y.tickMax,w=dme.rangeStep(b,N.add(new nl(.1).mul(_)),_);return r>n?Obe(w):w}function Vds(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(dme.rangeStep(new nl(d),new nl(u).sub(new nl(.99).mul(f)),f)),[u]);return n>a?Obe(y):y}var Hds=Zrt(Uds),Gds=Zrt(Vds),Wds="Invariant failed";function uC(t,s){throw new Error(Wds)}var Kds=["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 Gce(){return Gce=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 tus(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 sus(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function rus(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 k=[Math.min(f,(_+f)/2),Math.max(f,(_+f)/2)];if(s>k[0]&&s<=k[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},_us=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(k&&k.length){var C=k[0].type.defaultProps,A=C!==void 0?Yc(Yc({},C),k[0].props):k[0].props,I=A.barSize,L=A[w];l[L]||(l[L]=[]);var O=vi(I)?r:I;l[L].push({item:k[0],stackList:k.slice(1),barSize:vi(O)?void 0:jm(O,n,0)})}}return l},bus=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(DOe(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 k=jm(n,a,0,!0);a-2*k-(d-1)*u<=0&&(u=0);var C=(a-2*k-(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(DOe(I),[{item:L.item,position:{offset:k+(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},wus=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},jus=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 jus(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)?[lme(f),ome(f)]:[f,f],_=d.reduce(function(b,N){var w=ou(p,N,0),k=y[0]-Math.abs(Array.isArray(w)?w[0]:w),C=y[1]+Math.abs(Array.isArray(w)?w[1]:w);return[Math.min(k,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},Nus=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}})},Qye=new WeakMap,u9=function(s,r){if(typeof r!="function")return s;Qye.has(s)||Qye.set(s,new WeakMap);var n=Qye.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:$ce(),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:$ce(),realScaleType:"linear"};if(oC(a)){var d="scale".concat(Whe(a));return{scale:(TOe[d]||w8)(),realScaleType:TOe[d]?d:"point"}}return di(a)?{scale:a}:{scale:w8(),realScaleType:"point"}},OOe=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])-OOe,l=Math.max(a[0],a[1])+OOe,i=s(r[0]),d=s(r[n-1]);(il||dl)&&s.domain([r[0],r[n-1]])}},kus=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])}},Mus=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)}},Tus={sign:Cus,expand:KXt,none:WT,silhouette:ZXt,wiggle:YXt,positive:Mus},Aus=function(s,r,n){var a=r.map(function(i){return i.props.dataKey}),o=Tus[n],l=WXt().keys(a).value(function(i,d){return+ou(i,d,0)}).order(hbe).offset(o);return l(s)},Eus=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 k=b[n],C=f[k]||{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({},k,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 k=_.stackGroups[w];return Yc(Yc({},N),{},rT({},w,{numericAxisId:n,cateAxisId:a,items:k.items,stackedData:Aus(s,k.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=Hds(u,o,i);return s.domain([lme(p),ome(p)]),{niceTicks:p}}if(o&&a==="number"){var f=s.domain(),y=Gds(f,o,i);return{niceTicks:y}}return null};function FOe(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=_ce(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 zOe=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},Pus=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]},Ius=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},Lus=function(s){return s.reduce(function(r,n){return[lme(n.concat([r[0]]).filter(sn)),ome(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=Lus(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})},BOe=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,$Oe=/^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(BOe.test(s[0])){var o=+BOe.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($Oe.test(s[1])){var l=+$Oe.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},Kce=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},Uus=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,k){var C=r[k],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=Ous(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({},k,Y))},{})},Vus=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))},Hus=function(s,r){var n=s.x,a=s.y,o=r.cx,l=r.cy,i=Vus({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:qus(u),angleInRadian:u}},Gus=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}},Wus=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},HOe=function(s,r){var n=s.x,a=s.y,o=Hus({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=Gus(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:Wus(_,r)}):null},fnt=function(s){return!S.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 Kus=["offset"];function Zus(t){return Jus(t)||Qus(t)||Xus(t)||Yus()}function Yus(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Xus(t,s){if(t){if(typeof t=="string")return 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 Qus(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Jus(t){if(Array.isArray(t))return 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 ths(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 GOe(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=k<=0?I:!I;var L=Rl(u,p,w,A),O=Rl(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))},lhs=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 _=Rl(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,k=Rl(l,i,w,y),C=k.x,A=k.y;return{x:C,y:A,textAnchor:"middle",verticalAnchor:"middle"}},chs=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,k=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:k,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:k,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:k,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:k,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)},dhs=function(s){return"cx"in s&&sn(s.cx)};function Ru(t){var s=t.offset,r=s===void 0?5:s,n=ehs(t,Kus),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)&&!S.isValidElement(u)&&!di(u))return null;if(S.isValidElement(u))return S.cloneElement(u,a);var _;if(di(u)){if(_=S.createElement(u,a),S.isValidElement(_))return _}else _=ahs(a);var b=dhs(o),N=Ua(a,!0);if(b&&(l==="insideStart"||l==="insideEnd"||l==="end"))return ohs(a,_,N);var w=b?lhs(a):chs(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,k=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:k}:s.viewBox?s.viewBox:{}},uhs=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}):S.isValidElement(s)?s.type===Ru?S.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},hhs=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 S.cloneElement(d,{viewBox:r||o,key:"label-".concat(u)})});if(!n)return l;var i=uhs(s.label,r||o);return[i].concat(Zus(l))};Ru.parseViewBox=xnt;Ru.renderCallByParent=hhs;function mhs(t){var s=t==null?0:t.length;return s?t[s-1]:void 0}var phs=mhs;const fhs=no(phs);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 xhs=["valueAccessor"],ghs=["data","dataKey","clockWise","id","textBreakAll"];function yhs(t){return whs(t)||bhs(t)||_hs(t)||vhs()}function vhs(){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 _hs(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 bhs(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function whs(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 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}var Chs=function(s){return Array.isArray(s.value)?fhs(s.value):s.value};function i1(t){var s=t.valueAccessor,r=s===void 0?Chs:s,n=ZOe(t,xhs),a=n.data,o=n.dataKey,l=n.clockWise,i=n.id,d=n.textBreakAll,u=ZOe(n,ghs);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,Yce({},Ua(p,!0),u,_,{parentViewBox:p.parentViewBox,value:y,textBreakAll:d,viewBox:Ru.parseViewBox(vi(l)?p:KOe(KOe({},p),{},{clockWise:l})),key:"label-".concat(f),index:f}))}))}i1.displayName="LabelList";function Mhs(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,Yce({data:s},t,{key:"labelList-implicit"})):null:null}function Ths(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 S.cloneElement(l,{data:s,key:"labelList-".concat(i)})});if(!r)return a;var o=Mhs(t.label,s);return[o].concat(yhs(a))}i1.renderCallByParent=Ths;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 _=Rl(r,n,a,l),b=Rl(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},Lhs=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=h9({cx:r,cy:n,radius:o,angle:u,sign:f,cornerRadius:l,cornerIsExternal:d}),_=y.circleTangency,b=y.lineTangency,N=y.theta,w=h9({cx:r,cy:n,radius:o,angle:p,sign:-f,cornerRadius:l,cornerIsExternal:d}),k=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(k.x,",").concat(k.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(C.x,",").concat(C.y,` `);if(a>0){var O=h9({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=h9({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},Dhs={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},ynt=function(s){var r=XOe(XOe({},Dhs),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=Lhs({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 Yhs(t,s){return vE(t.getTime(),s.getTime())}function aFe(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 Xhs(t,s,r){var n=nFe(t),a=n.length;if(nFe(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=sFe(t),a=n.length;if(sFe(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=rFe(t,o),i=rFe(s,o),(l||i)&&(!l||!i||l.configurable!==i.configurable||l.enumerable!==i.enumerable||l.writable!==i.writable)))return!1;return!0}function Qhs(t,s){return vE(t.valueOf(),s.valueOf())}function Jhs(t,s){return t.source===s.source&&t.flags===s.flags}function iFe(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 ems(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 tms="[object Arguments]",sms="[object Boolean]",rms="[object Date]",nms="[object Map]",ams="[object Number]",ims="[object Object]",oms="[object RegExp]",lms="[object Set]",cms="[object String]",dms=Array.isArray,oFe=typeof ArrayBuffer=="function"&&ArrayBuffer.isView?ArrayBuffer.isView:null,lFe=Object.assign,ums=Object.prototype.toString.call.bind(Object.prototype.toString);function hms(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(dms(p))return s(p,f,y);if(oFe!=null&&oFe(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=ums(p);return b===rms?r(p,f,y):b===oms?l(p,f,y):b===nms?n(p,f,y):b===lms?i(p,f,y):b===ims?typeof p.then!="function"&&typeof f.then!="function"&&a(p,f,y):b===tms?a(p,f,y):b===sms||b===ams||b===cms?o(p,f,y):!1}}function mms(t){var s=t.circular,r=t.createCustomConfig,n=t.strict,a={areArraysEqual:n?gI:Zhs,areDatesEqual:Yhs,areMapsEqual:n?tFe(aFe,gI):aFe,areObjectsEqual:n?gI:Xhs,arePrimitiveWrappersEqual:Qhs,areRegExpsEqual:Jhs,areSetsEqual:n?tFe(iFe,gI):iFe,areTypedArraysEqual:n?gI:ems};if(r&&(a=lFe({},a,r(a))),s){var o=p9(a.areArraysEqual),l=p9(a.areMapsEqual),i=p9(a.areObjectsEqual),d=p9(a.areSetsEqual);a=lFe({},a,{areArraysEqual:o,areMapsEqual:l,areObjectsEqual:i,areSetsEqual:d})}return a}function pms(t){return function(s,r,n,a,o,l,i){return t(s,r,i)}}function fms(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 xms=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=mms(t),d=hms(i),u=n?n(d):pms(d);return fms({circular:r,comparator:d,createState:a,equals:u,strict:l})}function gms(t){typeof requestAnimationFrame<"u"&&requestAnimationFrame(t)}function cFe(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):gms(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 yms(t){return wms(t)||bms(t)||_ms(t)||vms()}function vms(){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 _ms(t,s){if(t){if(typeof t=="string")return dFe(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 dFe(t,s)}}function dFe(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:k<0?0:k},N=function(k){for(var C=k>1?1:k,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 Jms(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 Jye(t){return rps(t)||sps(t)||tps(t)||eps()}function eps(){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 tps(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 sps(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function rps(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 ede(t){return ede=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ede(t)}var v0=function(t){lps(r,t);var s=cps(r);function r(n,a){var o;nps(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 ips(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(!(xms(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,_=Yms(l,i,zms(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,k){if(k===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=k>0?l[k-1]:w,B=O||Object.keys(L);if(typeof I=="function"||I==="spring")return[].concat(Jye(N),[o.runJSAnimation.bind(o,{from:q.style,to:L,duration:C,easing:I}),C]);var U=mFe(B,C,I),te=lg(lg(lg({},q.style),L),{},{transition:U});return[].concat(Jye(N),[te,C,V]).filter(Cms)};return this.manager.start([d].concat(Jye(l.reduce(_,[p,Math.max(y,i)])),[a.onAnimationEnd]))}},{key:"runAnimation",value:function(a){this.manager||(this.manager=jms());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=mFe(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=Qms(a,Xms),u=S.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,k=b.className,C=S.cloneElement(_,lg(lg({},d),{},{style:lg(lg({},w),p),className:k}));return C};return u===1?f(S.Children.only(o)):xt.createElement("div",null,S.Children.map(o,function(y){return f(y)}))}}]),r}(S.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 tde(){return tde=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},vps=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},_ps={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=bFe(bFe({},_ps),s),n=S.useRef(),a=S.useState(-1),o=ups(a,2),l=o[0],i=o[1];S.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,k=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:k,easing:b},xt.createElement("path",tde({},Ua(r,!0),{className:A,d:wFe(V,q,L,O,y),ref:n})))}):xt.createElement("path",tde({},Ua(r,!0),{className:A,d:wFe(d,u,p,f,y)}))},bps=["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 jps(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 jFe(t){return Cps(t)||Sps(t)||kps(t)||Nps()}function Nps(){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 kps(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 Sps(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Cps(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){NFe(n)?r[r.length-1].push(n):r[r.length-1].length>0&&r.push([])}),NFe(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=Mps(s);r&&(n=[n.reduce(function(o,l){return[].concat(jFe(o),jFe(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},Tps=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))},Aps=function(s){var r=s.points,n=s.className,a=s.baseLinePoints,o=s.connectNulls,l=wps(s,bps);if(!r||!r.length)return null;var i=bi("recharts-polygon",n);if(a&&a.length){var d=l.stroke&&l.stroke!=="none",u=Tps(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 Ops(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 Fps=function(s,r,n,a,o,l){return"M".concat(s,",").concat(o,"v").concat(a,"M").concat(l,",").concat(r,"h").concat(n)},zps=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=Rps(s,Eps),w=Pps({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:Fps(n,o,f,_,i,u)}))},Bps=ime,$ps=Brt,qps=C0;function Ups(t,s){return t&&t.length?Bps(t,qps(s),$ps):void 0}var Vps=Ups;const Hps=no(Vps);var Gps=ime,Wps=C0,Kps=$rt;function Zps(t,s){return t&&t.length?Gps(t,Wps(s),Kps):void 0}var Yps=Zps;const Xps=no(Yps);var Qps=["cx","cy","angle","ticks","axisLine"],Jps=["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 efs(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 tfs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function MFe(t,s){for(var r=0;rEFe?l=a==="outer"?"start":"end":o<-EFe?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(ume,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 Rl(a,o,l,y.coordinate)});return xt.createElement(Aps,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),k=n.getTickTextAnchor(b),C=q2(q2(q2({textAnchor:k},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}}])}(S.PureComponent);pme(fme,"displayName","PolarAngleAxis");pme(fme,"axisType","angleAxis");pme(fme,"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 xfs=Rst,gfs=xfs(Object.getPrototypeOf,Object),yfs=gfs,vfs=M1,_fs=yfs,bfs=T1,wfs="[object Object]",jfs=Function.prototype,Nfs=Object.prototype,Lnt=jfs.toString,kfs=Nfs.hasOwnProperty,Sfs=Lnt.call(Object);function Cfs(t){if(!bfs(t)||vfs(t)!=wfs)return!1;var s=_fs(t);if(s===null)return!0;var r=kfs.call(s,"constructor")&&s.constructor;return typeof r=="function"&&r instanceof r&&Lnt.call(r)==Sfs}var Mfs=Cfs;const Tfs=no(Mfs);var Afs=M1,Efs=T1,Pfs="[object Boolean]";function Ifs(t){return t===!0||t===!1||Efs(t)&&Afs(t)==Pfs}var Lfs=Ifs;const Dfs=no(Lfs);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 nde(){return nde=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:k},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",nde({},Ua(r,!0),{className:C,d:DFe(V,q,I,L,O),ref:n})))}):xt.createElement("g",null,xt.createElement("path",nde({},Ua(r,!0),{className:C,d:DFe(d,u,p,f,y)})))},Gfs=["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 Wfs(t,s){if(t==null)return{};var r=Kfs(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 Kfs(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 RFe(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 ade(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=Al(Al({},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=Al(Al({},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(k){n.pieRef=k}},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,k,0);return q+(sn(U)?U:0)},0),O;if(L>0){var V;O=a.map(function(q,B){var U=ou(q,k,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,ae=(b.innerRadius+b.outerRadius)/2,ie=[{name:te,value:U,payload:q,dataKey:k,type:y}],oe=Rl(b.cx,b.cy,ae,ce);return V=Al(Al(Al({percent:Y,cornerRadius:o,name:te,tooltipPayload:ie,midAngle:ce,middleRadius:ae,tooltipPosition:oe},q),b),{},{value:ou(q,k),startAngle:J,endAngle:X,payload:q,paddingAngle:wm(N)*d}),V})}return Al(Al({},b),{},{sectors:O,data:a})});var fxs=Math.ceil,xxs=Math.max;function gxs(t,s,r,n){for(var a=-1,o=xxs(fxs((s-t)/(r||1)),0),l=Array(o);o--;)l[n?o:++a]=t,t+=r;return l}var yxs=gxs,vxs=trt,BFe=1/0,_xs=17976931348623157e292;function bxs(t){if(!t)return t===0?t:0;if(t=vxs(t),t===BFe||t===-BFe){var s=t<0?-1:1;return s*_xs}return t===t?t:0}var Fnt=bxs,wxs=yxs,jxs=Jhe,e0e=Fnt;function Nxs(t){return function(s,r,n){return n&&typeof n!="number"&&jxs(s,r,n)&&(r=n=void 0),s=e0e(s),r===void 0?(r=s,s=0):r=e0e(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=HFe(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 Fxs(s,t),Lxs(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=HFe(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,k={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)),k[l]=u+C;var A=this.getIndex(k),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=S.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,k=Math.max(n,this.props.x),C=t0e(t0e({},Ua(this.props,!1)),{},{x:k,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,lde({textAnchor:"end",verticalAnchor:"middle",x:Math.min(f,y)-_,y:l+i/2},b),this.getTextOfTick(a)),xt.createElement(cC,lde({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,k=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=Pxs("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||k||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 t0e({prevData:o,prevTravellerWidth:d,prevUpdateId:u,prevX:i,prevWidth:l},o&&o.length?Bxs({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}}])}(S.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 $xs=Y4e;function qxs(t,s){var r;return $xs(t,function(n,a,o){return r=s(n,a,o),!r}),!!r}var Uxs=qxs,Vxs=Mst,Hxs=C0,Gxs=Uxs,Wxs=wp,Kxs=Jhe;function Zxs(t,s,r){var n=Wxs(t)?Vxs:Gxs;return r&&Kxs(t,s,r)&&(s=void 0),n(t,Hxs(s))}var Yxs=Zxs;const Xxs=no(Yxs);var d0=function(s,r){var n=s.alwaysShow,a=s.ifOverflow;return n&&(a="extendDomain"),a===r},GFe=Yst;function Qxs(t,s,r){s=="__proto__"&&GFe?GFe(t,s,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[s]=r}var Jxs=Qxs,egs=Jxs,tgs=Kst,sgs=C0;function rgs(t,s){var r={};return s=sgs(s),tgs(t,function(n,a,o){egs(r,a,s(n,a,o))}),r}var ngs=rgs;const ags=no(ngs);function igs(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 jgs(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 Ngs(t,s){var r=t.x,n=t.y,a=wgs(t,ygs),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 KFe(t){return xt.createElement(Dnt,cwe({shapeType:"rectangle",propTransformer:Ngs,activeClassName:"recharts-active-bar"},t))}var kgs=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)||iYt(n);return o?s(n,a):(o||uC(),r)}},Sgs=["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 Cgs(t,s){if(t==null)return{};var r=Mgs(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 Mgs(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 dde(){return dde=Object.assign?Object.assign.bind():function(t){for(var s=1;s0&&Math.abs(ce)0&&Math.abs(X)0&&(J=Math.min((Ue||0)-(X[Te-1]||0),J))}),Number.isFinite(J)){var ce=J/Y,ae=N.layout==="vertical"?n.height:n.width;if(N.padding==="gap"&&(V=ce*ae/2),N.padding==="no-gap"){var ie=jm(s.barCategoryGap,ce*ae),oe=ce*ae/2;V=oe-ie-(oe-ie)/ae*ie}}}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),ye=me.scale,he=me.realScaleType;ye.domain(k).range(q),cnt(ye);var ge=dnt(ye,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 Ne=yg(yg(yg({},N),ge),{},{realScaleType:he,x:B,y:U,scale:ye,width:a==="xAxis"?n.width:N.width,height:a==="yAxis"?n.height:N.height});return Ne.bandSize=Kce(Ne,ge),!N.hide&&a==="xAxis"?f[O]+=(te?-1:1)*Ne.height:N.hide||(f[O]+=(te?-1:1)*Ne.width),yg(yg({},_),{},yme({},b,Ne))},{})},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)}},zgs=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){Rgs(this,t),this.scale=s}return Ogs(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)}}])}();yme(Znt,"EPS",1e-4);var kSe=function(s){var r=Object.keys(s).reduce(function(n,a){return yg(yg({},n),{},yme({},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 ags(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 Bgs(t){return(t%180+180)%180}var $gs=function(s){var r=s.width,n=s.height,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,o=Bgs(a),l=o*Math.PI/180,i=Math.atan(n/r),d=l>i&&l-1?a[o?s[l]:l]:void 0}}var Ggs=Hgs,Wgs=Fnt;function Kgs(t){var s=Wgs(t),r=s%1;return s===s?r?s-r:s:0}var Zgs=Kgs,Ygs=qst,Xgs=C0,Qgs=Zgs,Jgs=Math.max;function eys(t,s,r){var n=t==null?0:t.length;if(!n)return-1;var a=r==null?0:Qgs(r);return a<0&&(a=Jgs(n+a,0)),Ygs(t,Xgs(s),a)}var tys=eys,sys=Ggs,rys=tys,nys=sys(rys),ays=nys;const iys=no(ays);var oys=dZt(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=S.createContext(void 0),CSe=S.createContext(void 0),Ynt=S.createContext(void 0),Xnt=S.createContext({}),Qnt=S.createContext(void 0),Jnt=S.createContext(0),eat=S.createContext(0),JFe=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=oys(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)))))))},lys=function(){return S.useContext(Qnt)},tat=function(s){var r=S.useContext(SSe);r==null&&uC();var n=r[s];return n==null&&uC(),n},cys=function(){var s=S.useContext(SSe);return K_(s)},dys=function(){var s=S.useContext(CSe),r=iys(s,function(n){return qnt(n.domain,Number.isFinite)});return r||K_(s)},sat=function(s){var r=S.useContext(CSe);r==null&&uC();var n=r[s];return n==null&&uC(),n},uys=function(){var s=S.useContext(Ynt);return s},hys=function(){return S.useContext(Xnt)},MSe=function(){return S.useContext(eat)},TSe=function(){return S.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 mys(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function pys(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 Zys(t,s){return cat(t,s+1)}function Yys(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,k=function(){return w===void 0&&(w=r(b,N)),w},C=b.coordinate,A=d===0||fde(t,C,k,p,i);A||(d=0,p=l,u+=1),A&&(p=C+t*(k()/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 o7e(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 k=fde(t,_.tickCoord,N,i,d);k&&(d=_.tickCoord-t*(N()/2+a),o[y]=Mh(Mh({},_),{},{isShow:!0}))},p=l-1;p>=0;p--)u(p);return o}function t0s(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 _=fde(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=fde(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,k=Kys(o,w,_);return d==="equidistantPreserveStart"?Yys(w,k,N,a,l):(d==="preserveStart"||d==="preserveStartEnd"?y=t0s(w,k,N,a,l,d==="preserveStartEnd"):y=e0s(w,k,N,a,l),y.filter(function(C){return C.isShow}))}var s0s=["viewBox"],r0s=["viewBox"],n0s=["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 a0s(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function i0s(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function c7e(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}}])}(S.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 m0s=["x1","y1","x2","y2","key"],p0s=["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 d7e(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 y0s(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 v0s=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=u7e(s,m0s),u=Ua(d,!1);u.offset;var p=u7e(u,p0s);r=xt.createElement("line",M4({},p,{x1:n,y1:a,x2:o,y2:l,fill:"none",key:i}))}return r}function _0s(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 b0s(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 w0s(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 j0s(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 N0s=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)},k0s=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=hys(),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,k=p.verticalValues,C=cys(),A=dys();if(!sn(_)||_<=0||!sn(b)||b<=0||!sn(f)||f!==+f||!sn(y)||y!==+y)return null;var I=p.verticalCoordinatesGenerator||N0s,L=p.horizontalCoordinatesGenerator||k0s,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=k&&k.length,te=I({xAxis:C?Eh(Eh({},C),{},{ticks:U?k: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(v0s,{fill:p.fill,fillOpacity:p.fillOpacity,x:p.x,y:p.y,width:p.width,height:p.height,ry:p.ry}),xt.createElement(_0s,M4({},p,{offset:u,horizontalPoints:O,xAxis:C,yAxis:A})),xt.createElement(b0s,M4({},p,{offset:u,verticalPoints:V,xAxis:C,yAxis:A})),xt.createElement(w0s,M4({},p,{horizontalPoints:O})),xt.createElement(j0s,M4({},p,{verticalPoints:V})))}mat.displayName="CartesianGrid";var S0s=["type","layout","connectNulls","ref"],C0s=["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 h7e(t,s){if(t==null)return{};var r=M0s(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 M0s(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(k){return"".concat(k,"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 F0s(s,t),L0s(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 k=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,k)}),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=h7e(i,S0s),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(Xce,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,k=this.state,C=k.prevPoints,A=k.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],ae=Xp(ce.x,Y.x),ie=Xp(ce.y,Y.y);return Up(Up({},Y),{},{x:ae(L),y:ie(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 k=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=yYt(l)?l:{},X=J.clipDot,ce=X===void 0?!0:X,ae=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-ae/2,y:f-ae/2,width:_+ae,height:b+ae}))):null,!C&&this.renderCurve(O,V),this.renderErrorBar(O,V),(C||l)&&this.renderDots(O,ce,V),(!N||k)&&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 Cvs(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 Mvs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function Tvs(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=jme(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=_ce(_,l.dataKey,a)}else y=f&&f[n]||i[n];return y?[].concat(gA(d),[hnt(u,y)]):d},[])},_7e=function(s,r,n,a){var o=a||{x:s.chartX,y:s.chartY},l=$vs(o,n),i=s.orderedTooltipTicks,d=s.tooltipAxis,u=s.tooltipTicks,p=vus(l,i,u,d);if(p>=0&&u){var f=u[p]&&u[p].value,y=Mwe(s,r,p,f),_=qvs(n,i,p,o);return{activeTooltipIndex:p,activeLabel:f,activePayload:y,activeCoordinate:_}}return null},Uvs=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,k=N.type.defaultProps!==void 0?pr(pr({},N.type.defaultProps),N.props):N.props,C=k.type,A=k.dataKey,I=k.allowDataOverflow,L=k.allowDuplicatedCategory,O=k.scale,V=k.ticks,q=k.includeHidden,B=k[l];if(b[B])return b;var U=jme(s.data,{graphicalItems:a.filter(function(ge){var Ne,Ue=l in ge.props?ge.props[l]:(Ne=ge.type.defaultProps)===null||Ne===void 0?void 0:Ne[l];return Ue===B}),dataStartIndex:d,dataEndIndex:u}),te=U.length,Y,J,X;fvs(k.domain,I,C)&&(Y=qbe(k.domain,null,I),_&&(C==="number"||O!=="auto")&&(X=j8(U,A,"category")));var ce=Tat(C);if(!Y||Y.length===0){var ae,ie=(ae=k.domain)!==null&&ae!==void 0?ae:ce;if(A){if(Y=j8(U,A,C),C==="category"&&_){var oe=lYt(Y);L&&oe?(J=Y,Y=ode(0,te)):L||(Y=qOe(ie,Y,N).reduce(function(ge,Ne){return ge.indexOf(Ne)>=0?ge:[].concat(gA(ge),[Ne])},[]))}else if(C==="category")L?Y=Y.filter(function(ge){return ge!==""&&!vi(ge)}):Y=qOe(ie,Y,N).reduce(function(ge,Ne){return ge.indexOf(Ne)>=0||Ne===""||vi(Ne)?ge:[].concat(gA(ge),[Ne])},[]);else if(C==="number"){var me=Nus(U,a.filter(function(ge){var Ne,Ue,Te=l in ge.props?ge.props[l]:(Ne=ge.type.defaultProps)===null||Ne===void 0?void 0:Ne[l],Me="hide"in ge.props?ge.props.hide:(Ue=ge.type.defaultProps)===null||Ue===void 0?void 0:Ue.hide;return Te===B&&(q||!Me)}),A,o,p);me&&(Y=me)}_&&(C==="number"||O!=="auto")&&(X=j8(U,A,"category"))}else _?Y=ode(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 Ne=l in ge.props?ge.props[l]:ge.type.defaultProps[l],Ue="hide"in ge.props?ge.props.hide:ge.type.defaultProps.hide;return Ne===B&&(q||!Ue)}),C,p,!0);if(C==="number")Y=kwe(f,Y,B,o,V),ie&&(Y=qbe(ie,Y,I));else if(C==="category"&&ie){var ye=ie,he=Y.every(function(ge){return ye.indexOf(ge)>=0});he&&(Y=ye)}}return pr(pr({},b),{},Ya({},B,pr(pr({},k),{},{axisType:o,domain:Y,categoricalDomain:X,duplicateDomain:J,originalDomain:(w=k.domain)!==null&&w!==void 0?w:ce,isCategorical:_,layout:p})))},{})},Vvs=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=jme(s.data,{graphicalItems:n,dataStartIndex:d,dataEndIndex:u}),_=y.length,b=int(p,o),N=-1;return n.reduce(function(w,k){var C=k.type.defaultProps!==void 0?pr(pr({},k.type.defaultProps),k.props):k.props,A=C[l],I=Tat("number");if(!w[A]){N++;var L;return b?L=ode(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)),pr(pr({},w),{},Ya({},A,pr(pr({axisType:o},a.defaultProps),{},{hide:!0,orientation:hf(zvs,"".concat(o,".").concat(N%2),null),domain:L,originalDomain:I,isCategorical:b,layout:p})))}return w},{})},Hvs=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?_=Uvs(s,{axes:y,graphicalItems:l,axisType:a,axisIdKey:f,stackGroups:i,dataStartIndex:d,dataEndIndex:u}):l&&l.length&&(_=Vvs(s,{Axis:o,graphicalItems:l,axisType:a,axisIdKey:f,stackGroups:i,dataStartIndex:d,dataEndIndex:u})),_},Gvs=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:Kce(r,n)}},b7e=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}},Wvs=function(s){return!s||!s.length?!1:s.some(function(r){var n=n1(r&&r.type);return n&&n.indexOf("Bar")>=0})},w7e=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"}},Kvs=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?pr(pr({},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?pr(pr({},L),{},Ya({},q,hf(L,"".concat(q))+V.height)):L},{top:y.top||0,bottom:y.bottom||0}),k=pr(pr({},w),N),C=k.bottom;_&&(k.bottom+=_.props.height||oA.defaultProps.height),b&&r&&(k=wus(k,a,n,r));var A=u-k.left-k.right,I=p-k.top-k.bottom;return pr(pr({brushBottom:C},k),{},{width:Math.max(A,0),height:Math.max(I,0)})},Zvs=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(k,C){var A=C.graphicalItems,I=C.stackGroups,L=C.offset,O=C.updateId,V=C.dataStartIndex,q=C.dataEndIndex,B=k.barSize,U=k.layout,te=k.barGap,Y=k.barCategoryGap,J=k.maxBarSize,X=w7e(U),ce=X.numericAxisName,ae=X.cateAxisName,ie=Wvs(A),oe=[];return A.forEach(function(me,ye){var he=jme(k.data,{graphicalItems:[me],dataStartIndex:V,dataEndIndex:q}),ge=me.type.defaultProps!==void 0?pr(pr({},me.type.defaultProps),me.props):me.props,Ne=ge.dataKey,Ue=ge.maxBarSize,Te=ge["".concat(ce,"Id")],Me=ge["".concat(ae,"Id")],De={},qe=d.reduce(function(it,Ve){var Xe=C["".concat(Ve.axisType,"Map")],dt=ge["".concat(Ve.axisType,"Id")];Xe&&Xe[dt]||Ve.axisType==="zAxis"||uC();var pt=Xe[dt];return pr(pr({},it),{},Ya(Ya({},Ve.axisType,pt),"".concat(Ve.axisType,"Ticks"),Vv(pt)))},De),ke=qe[ae],$e=qe["".concat(ae,"Ticks")],Be=I&&I[Te]&&I[Te].hasStack&&Ius(me,I[Te].stackGroups),we=n1(me.type).indexOf("Bar")>=0,ut=Kce(ke,$e),fe=[],He=ie&&_us({barSize:B,stackGroups:I,totalSize:Zvs(qe,ae)});if(we){var et,tt,_e=vi(Ue)?J:Ue,Ge=(et=(tt=Kce(ke,$e,!0))!==null&&tt!==void 0?tt:_e)!==null&&et!==void 0?et:0;fe=bus({barGap:te,barCategoryGap:Y,bandSize:Ge!==ut?Ge:ut,sizeList:He[Me],maxBarSize:_e}),Ge!==ut&&(fe=fe.map(function(it){return pr(pr({},it),{},{position:pr(pr({},it.position),{},{offset:it.position.offset-Ge/2})})}))}var We=me&&me.type&&me.type.getComposedData;We&&oe.push({props:pr(pr({},We(pr(pr({},qe),{},{displayedData:he,props:k,dataKey:Ne,item:me,bandSize:ut,barPosition:fe,offset:L,stackedData:Be,layout:U,dataStartIndex:V,dataEndIndex:q}))),{},Ya(Ya(Ya({key:me.key||"item-".concat(ye)},ce,qe[ce]),ae,qe[ae]),"animationId",O)),childIndex:bYt(me,k.children),item:me})}),oe},_=function(k,C){var A=k.props,I=k.dataStartIndex,L=k.dataEndIndex,O=k.updateId;if(!DDe({props:A}))return null;var V=A.children,q=A.layout,B=A.stackOffset,U=A.data,te=A.reverseStackOrder,Y=w7e(q),J=Y.numericAxisName,X=Y.cateAxisName,ce=mf(V,n),ae=Eus(U,ce,"".concat(J,"Id"),"".concat(X,"Id"),B,te),ie=d.reduce(function(ge,Ne){var Ue="".concat(Ne.axisType,"Map");return pr(pr({},ge),{},Ya({},Ue,Hvs(A,pr(pr({},Ne),{},{graphicalItems:ce,stackGroups:Ne.axisType===J&&ae,dataStartIndex:I,dataEndIndex:L}))))},{}),oe=Kvs(pr(pr({},ie),{},{props:A,graphicalItems:ce}),C==null?void 0:C.legendBBox);Object.keys(ie).forEach(function(ge){ie[ge]=p(A,ie[ge],oe,ge.replace("Map",""),r)});var me=ie["".concat(X,"Map")],ye=Gvs(me),he=y(A,pr(pr({},ie),{},{dataStartIndex:I,dataEndIndex:L,updateId:O,graphicalItems:ce,stackGroups:ae,offset:oe}));return pr(pr({formattedGraphicalItems:he,graphicalItems:ce,offset:oe,stackGroups:ae},ye),ie)},b=function(w){function k(C){var A,I,L;return Mvs(this,k),L=Evs(this,k,[C]),Ya(L,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),Ya(L,"accessibilityManager",new pvs),Ya(L,"handleLegendBBoxUpdate",function(O){if(O){var V=L.state,q=V.dataStartIndex,B=V.dataEndIndex,U=V.updateId;L.setState(pr({legendBBox:O},_({props:L.props,dataStartIndex:q,dataEndIndex:B,updateId:U},pr(pr({},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 pr({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=pr(pr({},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?pr(pr({},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=_Yt(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=pr(pr({},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&&r0e.emit(n0e,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(pr({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,ae=L.state,ie=ae.offset,oe=ae.tooltipTicks;if(!ie)return;if(typeof B=="function")ce=B(oe,O);else if(B==="value"){ce=-1;for(var me=0;me=0){var Be,we;if(J.dataKey&&!J.allowDuplicatedCategory){var ut=typeof J.dataKey=="function"?$e:"payload.".concat(J.dataKey.toString());Be=_ce(me,ut,ce),we=ye&&he&&_ce(he,ut,ce)}else Be=me==null?void 0:me[X],we=ye&&he&&he[X];if(Me||Te){var fe=O.props.activeIndex!==void 0?O.props.activeIndex:X;return[S.cloneElement(O,pr(pr(pr({},B.props),qe),{},{activeIndex:fe})),null,null]}if(!vi(Be))return[ke].concat(gA(L.renderActivePoints({item:B,activePoint:Be,basePoint:we,childIndex:X,isRange:ye})))}else{var He,et=(He=L.getItemByXY(L.state.activeCoordinate))!==null&&He!==void 0?He:{graphicalItem:ke},tt=et.graphicalItem,_e=tt.item,Ge=_e===void 0?O:_e,We=tt.childIndex,it=pr(pr(pr({},B.props),qe),{},{activeIndex:We});return[S.cloneElement(Ge,it),null,null]}return ye?[ke,null,null]:[ke,null]}),Ya(L,"renderCustomized",function(O,V,q){return S.cloneElement(O,pr(pr({key:"recharts-customized-".concat(q)},L.props),L.state))}),Ya(L,"renderMap",{CartesianGrid:{handler:x9,once:!0},ReferenceArea:{handler:L.renderReferenceElement},ReferenceLine:{handler:x9},ReferenceDot:{handler:L.renderReferenceElement},XAxis:{handler:x9},YAxis:{handler:x9},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 Lvs(k,w),Avs(k,[{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,ep);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},ae=this.state.formattedGraphicalItems.find(function(oe){var me=oe.item;return me.type.name==="Scatter"});ae&&(ce=pr(pr({},ce),ae.props.points[B].tooltipPosition),te=ae.props.points[B].tooltipPayload);var ie={activeTooltipIndex:B,isTooltipActive:!0,activeLabel:U,activePayload:te,activeCoordinate:ce};this.setState(ie),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,ep)],[Wp(this.props.children,ep)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var A=Wp(this.props.children,ep);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=Wis(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=_7e(this.state,this.props.data,this.props.layout,B);if(J!=="axis"&&te&&Y){var ce=K_(te).scale,ae=K_(Y).scale,ie=ce&&ce.invert?ce.invert(V.chartX):null,oe=ae&&ae.invert?ae.invert(V.chartY):null;return pr(pr({},V),{},{xValue:ie,yValue:oe},X)}return X?pr(pr({},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 HOe({x:V,y:q},X)}return null}},{key:"parseEventsOfWrapper",value:function(){var A=this.props.children,I=this.getTooltipEventType(),L=Wp(A,ep),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=bce(this.props,this.handleOuterEvent);return pr(pr({},V),O)}},{key:"addListener",value:function(){r0e.on(n0e,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){r0e.removeListener(n0e,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:Mn,color:"text-foreground"},{label:"Total Emails Sent",value:l,icon:or,color:"text-green-600"},{label:"Avg Open Rate",value:`${f}%`,icon:Cn,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})),k=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?gs(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(Re,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Mn,{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(Re,{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(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Open & Click Rates by Campaign"})}),e.jsx(Re,{children:e.jsx("div",{className:"h-[280px]",children:e.jsx(tT,{width:"100%",height:"100%",children:e.jsxs(Aat,{data:k,children:[e.jsx(mC,{dataKey:"date",fontSize:11}),e.jsx(pC,{fontSize:11,unit:"%"}),e.jsx(ep,{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(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Send Volume by Agent"})}),e.jsx(Re,{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:j7e[A%j7e.length]},A))}),e.jsx(ep,{})]})})})})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Send Volume Trend"})}),e.jsx(Re,{children:e.jsx("div",{className:"h-[240px]",children:e.jsx(tT,{width:"100%",height:"100%",children:e.jsxs(Yvs,{data:k,children:[e.jsx(mC,{dataKey:"date",fontSize:11}),e.jsx(pC,{fontSize:11}),e.jsx(ep,{}),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(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Agent Performance"})}),e.jsx(Re,{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(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Campaign Leaderboard"})}),e.jsx(Re,{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?gs(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(Cn,{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 Qvs=()=>e.jsx(Es,{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(ls,{value:"analytics",children:"Analytics"}),e.jsx(ls,{value:"content",children:"Content"}),e.jsx(ls,{value:"email-campaigns",children:"Email Campaigns"}),e.jsx(ls,{value:"activity",children:"Activity"}),e.jsx(ls,{value:"shares",children:"Shares"})]}),e.jsx(ws,{value:"analytics",className:"space-y-4",children:e.jsx(kGt,{})}),e.jsx(ws,{value:"content",className:"space-y-4",children:e.jsx(CGt,{})}),e.jsx(ws,{value:"email-campaigns",className:"space-y-4",children:e.jsx(Xvs,{})}),e.jsx(ws,{value:"activity",className:"space-y-4",children:e.jsx(NGt,{})}),e.jsx(ws,{value:"shares",className:"space-y-4",children:e.jsx($tt,{})})]})]})});function Jvs(){const t=Qt(),[s,r]=S.useState(!1),[n,a]=S.useState(null),[o,l]=S.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),[i,d]=S.useState(null),[u,p]=S.useState(""),[f,y]=S.useState([]),[_,b]=S.useState([]),[N,w]=S.useState([]),[k,C]=S.useState(!1),[A,I]=S.useState(null),[L,O]=S.useState(""),{data:V,isLoading:q}=gt({queryKey:["brokerage-resources"],queryFn:async()=>{const{data:we,error:ut}=await G.from("brokerage_resources").select("*").order("publish_date",{ascending:!1});if(ut)throw ut;return we}}),{data:B}=gt({queryKey:["brokerage-resource-pdfs"],queryFn:async()=>{const{data:we,error:ut}=await G.from("brokerage_resource_pdfs").select("*").order("sort_order",{ascending:!0});if(ut)throw ut;return we}}),{data:U}=gt({queryKey:["brokerage-resource-videos"],queryFn:async()=>{const{data:we,error:ut}=await G.from("brokerage_resource_videos").select("*").order("sort_order",{ascending:!0});if(ut)throw ut;return we}}),{data:te}=gt({queryKey:["brokerage-resource-links"],queryFn:async()=>{const{data:we,error:ut}=await G.from("brokerage_resource_links").select("*").order("sort_order",{ascending:!0});if(ut)throw ut;return we}}),{data:Y,isLoading:J}=gt({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:we,error:ut}=await G.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(ut)throw ut;return we}}),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=we=>{a(we),l({title:we.title,description:we.description||"",publish_date:we.publish_date.split("T")[0],is_published:we.is_published,category_id:we.category_id||""}),p(we.preview_image_url||""),O("");const ut=(B==null?void 0:B.filter(et=>et.resource_id===we.id))||[];y(ut.map(et=>({id:et.id,name:et.name,file_url:et.file_url,file_size:et.file_size,sort_order:et.sort_order})));const fe=(U==null?void 0:U.filter(et=>et.resource_id===we.id))||[];b(fe.map(et=>({id:et.id,title:et.title,video_url:et.video_url,sort_order:et.sort_order})));const He=(te==null?void 0:te.filter(et=>et.resource_id===we.id))||[];w(He.map(et=>({id:et.id,title:et.title,canva_share_link:et.canva_share_link,sort_order:et.sort_order}))),r(!0)},ae=we=>{var fe;const ut=(fe=we.target.files)==null?void 0:fe[0];ut&&(d(ut),p(URL.createObjectURL(ut)))},ie=()=>{y([...f,{name:"",file_url:"",sort_order:f.length}])},oe=we=>{y(f.filter((ut,fe)=>fe!==we))},me=(we,ut,fe)=>{const He=[...f];if(ut==="file"&&fe instanceof File){const et=fe.name.replace(/\.[^/.]+$/,"");He[we]={...He[we],file:fe,file_size:fe.size,name:He[we].name||et}}else He[we]={...He[we],[ut]:fe};y(He)},ye=()=>{b([..._,{title:"",video_url:"",sort_order:_.length}])},he=we=>{b(_.filter((ut,fe)=>fe!==we))},ge=(we,ut,fe)=>{const He=[..._];ut==="file"&&fe instanceof File?He[we]={...He[we],file:fe}:He[we]={...He[we],[ut]:fe},b(He)},Ne=()=>{w([...N,{title:"",canva_share_link:"",sort_order:N.length}])},Ue=we=>{w(N.filter((ut,fe)=>fe!==we))},Te=(we,ut,fe)=>{const He=[...N];He[we]={...He[we],[ut]:fe},w(He)},Me=async(we,ut)=>{try{const fe=await G.functions.invoke("bunny-upload",{body:{action:"create",title:we.name}});if(fe.error)throw fe.error;const{videoId:He,uploadUrl:et,libraryId:tt}=fe.data,_e=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:He,libraryId:tt}});if(_e.error)throw _e.error;const{uploadUrl:Ge,apiKey:We}=_e.data,it=new XMLHttpRequest;return it.open("PUT",Ge,!0),it.setRequestHeader("AccessKey",We),it.upload.onprogress=Ve=>{if(Ve.lengthComputable){const Xe=Math.round(Ve.loaded/Ve.total*100),dt=[..._];dt[ut]={...dt[ut],uploadProgress:Xe},b(dt)}},await new Promise((Ve,Xe)=>{it.onload=()=>it.status>=200&&it.status<300?Ve():Xe(new Error("Upload failed")),it.onerror=()=>Xe(new Error("Upload failed")),it.send(we)}),`https://iframe.mediadelivery.net/embed/${tt}/${He}`}catch(fe){throw console.error("Bunny upload error:",fe),fe}},De=Et({mutationFn:async we=>{const{data:ut,error:fe}=await G.from("brokerage_resource_categories").insert({name:we,sort_order:(Y==null?void 0:Y.length)||0}).select().single();if(fe)throw fe;return ut},onSuccess:we=>{t.invalidateQueries({queryKey:["brokerage-resource-categories"]}),l({...o,category_id:we.id}),O(""),pe.success("Category created")},onError:we=>{pe.error("Failed to create category: "+we.message)}}),qe=Et({mutationFn:async()=>{C(!0);let we=(n==null?void 0:n.preview_image_url)||null;if(i){const He=i.name.split(".").pop(),et=`${Date.now()}.${He}`,{error:tt}=await G.storage.from("brokerage-resources").upload(`previews/${et}`,i);if(tt)throw tt;const{data:_e}=G.storage.from("brokerage-resources").getPublicUrl(`previews/${et}`);we=_e.publicUrl}const ut={title:o.title,description:o.description||null,preview_image_url:we,publish_date:o.publish_date,is_published:o.is_published,category_id:o.category_id||null};let fe;if(n){const{error:He}=await G.from("brokerage_resources").update(ut).eq("id",n.id);if(He)throw He;fe=n.id;const et=(B==null?void 0:B.filter(pt=>pt.resource_id===n.id).map(pt=>pt.id))||[],tt=f.filter(pt=>pt.id).map(pt=>pt.id),_e=et.filter(pt=>!tt.includes(pt));_e.length>0&&await G.from("brokerage_resource_pdfs").delete().in("id",_e);const Ge=(U==null?void 0:U.filter(pt=>pt.resource_id===n.id).map(pt=>pt.id))||[],We=_.filter(pt=>pt.id).map(pt=>pt.id),it=Ge.filter(pt=>!We.includes(pt));it.length>0&&await G.from("brokerage_resource_videos").delete().in("id",it);const Ve=(te==null?void 0:te.filter(pt=>pt.resource_id===n.id).map(pt=>pt.id))||[],Xe=N.filter(pt=>pt.id).map(pt=>pt.id),dt=Ve.filter(pt=>!Xe.includes(pt));dt.length>0&&await G.from("brokerage_resource_links").delete().in("id",dt)}else{const{data:He,error:et}=await G.from("brokerage_resources").insert(ut).select().single();if(et)throw et;fe=He.id}for(let He=0;He{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:we=>{pe.error("Failed to save resource: "+we.message),C(!1)}}),ke=Et({mutationFn:async we=>{const{error:ut}=await G.from("brokerage_resources").delete().eq("id",we);if(ut)throw ut},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:we=>{pe.error("Failed to delete: "+we.message)}}),$e=we=>{if(we.preventDefault(),!o.title){pe.error("Please enter a title");return}qe.mutate()},Be=we=>{const ut=(B==null?void 0:B.filter(et=>et.resource_id===we).length)||0,fe=(U==null?void 0:U.filter(et=>et.resource_id===we).length)||0,He=(te==null?void 0:te.filter(et=>et.resource_id===we).length)||0;return{pdfCount:ut,videoCount:fe,linkCount:He}};return e.jsx(Es,{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(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Total Resources"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:(V==null?void 0:V.length)||0})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:(V==null?void 0:V.filter(we=>we.is_published).length)||0})})]})]}),e.jsxs(K,{onClick:()=>{X(),r(!0)},children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Resource"]})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ms,{children:[e.jsx(kt,{children:"Title"}),e.jsx(kt,{children:"Category"}),e.jsx(kt,{children:"Content"}),e.jsx(kt,{children:"Publish Date"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:q?e.jsx(Ms,{children:e.jsx(ht,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):(V==null?void 0:V.length)===0?e.jsx(Ms,{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(we=>{const{pdfCount:ut,videoCount:fe,linkCount:He}=Be(we.id),et=Y==null?void 0:Y.find(tt=>tt.id===we.category_id);return e.jsxs(Ms,{children:[e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[we.preview_image_url?e.jsx("img",{src:we.preview_image_url,alt:we.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:we.title}),we.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:we.description})]})]})}),e.jsx(ht,{children:et?e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-muted",children:et.name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(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(yn,{className:"h-3.5 w-3.5"}),ut]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(gn,{className:"h-3.5 w-3.5"}),fe]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(go,{className:"h-3.5 w-3.5"}),He]})]})}),e.jsx(ht,{children:gs(new Date(we.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 ${we.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:we.is_published?"Published":"Draft"})}),e.jsx(ht,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{const tt=(B==null?void 0:B.filter(We=>We.resource_id===we.id))||[],_e=(U==null?void 0:U.filter(We=>We.resource_id===we.id))||[],Ge=(te==null?void 0:te.filter(We=>We.resource_id===we.id))||[];I({...we,pdfs:tt,videos:_e,links:Ge})},children:e.jsx(Cn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ce(we),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource?")&&ke.mutate(we.id)},children:e.jsx(xr,{className:"h-4 w-4 text-destructive"})})]})})]},we.id)})})]})})}),e.jsx(fs,{open:s,onOpenChange:r,children:e.jsxs(hs,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:n?"Edit Brokerage Resource":"Add Brokerage Resource"})}),e.jsxs("form",{onSubmit:$e,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(Le,{type:"file",accept:"image/*",onChange:ae})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"title",children:"Title *"}),e.jsx(Le,{id:"title",value:o.title,onChange:we=>l({...o,title:we.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(Fs,{value:o.category_id,onValueChange:we=>l({...o,category_id:we}),children:[e.jsx(Ds,{className:"flex-1",children:e.jsx(zs,{placeholder:"Select a category"})}),e.jsx(Rs,{children:Y==null?void 0:Y.map(we=>e.jsx(vt,{value:we.id,children:we.name},we.id))})]}),o.category_id&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>l({...o,category_id:""}),children:e.jsx(jr,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{placeholder:"Or create new category...",value:L,onChange:we=>O(we.target.value),className:"flex-1"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",disabled:!L.trim()||De.isPending,onClick:()=>De.mutate(L.trim()),children:[e.jsx(Bs,{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:we=>l({...o,description:we}),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(Le,{id:"publish_date",type:"date",value:o.publish_date,onChange:we=>l({...o,publish_date:we.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(Mr,{checked:o.is_published,onCheckedChange:we=>l({...o,is_published:we})}),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(yn,{className:"h-4 w-4"}),"PDF Documents (",f.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:ie,children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Add PDF"]})]}),f.map((we,ut)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/50",children:[e.jsx(Le,{placeholder:"PDF Name",value:we.name,onChange:fe=>me(ut,"name",fe.target.value),className:"flex-1"}),e.jsx(Le,{type:"file",accept:".pdf",onChange:fe=>{var et;const He=(et=fe.target.files)==null?void 0:et[0];He&&me(ut,"file",He)},className:"flex-1"}),we.file_url&&!we.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Uploaded"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>oe(ut),children:e.jsx(jr,{className:"h-4 w-4"})})]},ut))]}),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(gn,{className:"h-4 w-4"}),"Videos (",_.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:ye,children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Add Video"]})]}),_.map((we,ut)=>e.jsxs("div",{className:"space-y-2 p-3 border rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{placeholder:"Video Title",value:we.title,onChange:fe=>ge(ut,"title",fe.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>he(ut),children:e.jsx(jr,{className:"h-4 w-4"})})]}),e.jsx(Le,{type:"file",accept:"video/*",onChange:fe=>{var et;const He=(et=fe.target.files)==null?void 0:et[0];He&&ge(ut,"file",He)}}),we.uploadProgress!==void 0&&we.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:`${we.uploadProgress}%`}})}),we.video_url&&!we.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Video uploaded"})]},ut))]}),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(go,{className:"h-4 w-4"}),"Canva Links (",N.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:Ne,children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),N.map((we,ut)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/50",children:[e.jsx(Le,{placeholder:"Link Title",value:we.title,onChange:fe=>Te(ut,"title",fe.target.value),className:"flex-1"}),e.jsx(Le,{placeholder:"Canva Share Link",value:we.canva_share_link,onChange:fe=>Te(ut,"canva_share_link",fe.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>Ue(ut),children:e.jsx(jr,{className:"h-4 w-4"})})]},ut))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:qe.isPending||k,children:qe.isPending||k?"Saving...":n?"Update":"Create"})]})]})]})}),e.jsx(fs,{open:!!A,onOpenChange:()=>I(null),children:e.jsxs(hs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{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(yn,{className:"h-4 w-4"}),"PDF Documents (",A.pdfs.length,")"]}),e.jsx("div",{className:"space-y-1",children:A.pdfs.map(we=>e.jsx("a",{href:we.file_url,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:we.name},we.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(gn,{className:"h-4 w-4"}),"Videos (",A.videos.length,")"]}),e.jsx("div",{className:"space-y-2",children:A.videos.map(we=>e.jsx("div",{className:"p-2 border rounded",children:e.jsx("p",{className:"font-medium text-sm",children:we.title})},we.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(go,{className:"h-4 w-4"}),"Canva Links (",A.links.length,")"]}),e.jsx("div",{className:"space-y-1",children:A.links.map(we=>e.jsx("a",{href:we.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:we.title},we.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 e1s(){const[t,s]=S.useState([]),[r,n]=S.useState(!0),[a,o]=S.useState(!1),[l,i]=S.useState(!1),[d,u]=S.useState(null),[p,f]=S.useState(!1),[y,_]=S.useState(!1),[b,N]=S.useState(""),[w,k]=S.useState(""),[C,A]=S.useState(""),[I,L]=S.useState(""),[O,V]=S.useState("Learn More"),[q,B]=S.useState("top"),[U,te]=S.useState(""),[Y,J]=S.useState(!0),[X,ce]=S.useState(""),[ae,ie]=S.useState("");S.useEffect(()=>{oe()},[]);const oe=async()=>{try{const{data:De,error:qe}=await G.from("dashboard_banners").select("*").order("placement").order("sort_order");if(qe)throw qe;s(De||[])}catch(De){pe.error("Failed to load banners: "+De.message)}finally{n(!1)}},me=()=>{N(""),k(""),A(""),L(""),V("Learn More"),B("top"),te(""),J(!0),ce(""),ie(""),u(null)},ye=De=>{u(De),N(De.title),k(De.description||""),A(De.image_url),L(De.link_url||""),V(De.link_text||"Learn More"),B(De.placement),te(De.section_after||""),J(De.is_active),ce(De.start_date?gs(new Date(De.start_date),"yyyy-MM-dd'T'HH:mm"):""),ie(De.end_date?gs(new Date(De.end_date),"yyyy-MM-dd'T'HH:mm"):""),o(!0)},he=async De=>{var ke;const qe=(ke=De.target.files)==null?void 0:ke[0];if(qe){f(!0);try{const $e=qe.name.split(".").pop(),Be=`${Date.now()}.${$e}`,{error:we}=await G.storage.from("banner-images").upload(Be,qe);if(we)throw we;const{data:{publicUrl:ut}}=G.storage.from("banner-images").getPublicUrl(Be);A(ut),pe.success("Image uploaded successfully")}catch($e){pe.error("Failed to upload image: "+$e.message)}finally{f(!1)}}},ge=async()=>{if(!b.trim()||!C){pe.error("Please fill in required fields (title and image)");return}_(!0);try{const De={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:ae?new Date(ae).toISOString():null};if(d){const{error:qe}=await G.from("dashboard_banners").update(De).eq("id",d.id);if(qe)throw qe;pe.success("Banner updated successfully")}else{const qe=t.filter($e=>$e.placement===q).length,{error:ke}=await G.from("dashboard_banners").insert({...De,sort_order:qe});if(ke)throw ke;pe.success("Banner created successfully")}o(!1),me(),oe()}catch(De){pe.error("Failed to save banner: "+De.message)}finally{_(!1)}},Ne=async()=>{if(d)try{const{error:De}=await G.from("dashboard_banners").delete().eq("id",d.id);if(De)throw De;pe.success("Banner deleted successfully"),i(!1),u(null),oe()}catch(De){pe.error("Failed to delete banner: "+De.message)}},Ue=async De=>{try{const{error:qe}=await G.from("dashboard_banners").update({is_active:!De.is_active}).eq("id",De.id);if(qe)throw qe;pe.success(De.is_active?"Banner deactivated":"Banner activated"),oe()}catch(qe){pe.error("Failed to update banner: "+qe.message)}},Te=t.filter(De=>De.placement==="top"),Me=t.filter(De=>De.placement==="between");return r?e.jsx(Es,{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(Es,{title:"Dashboard Management",description:"Configure dashboard modules and banners",children:[e.jsxs("div",{className:"space-y-8",children:[e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(qo,{className:"h-5 w-5"}),"Hero Banners (Top of Dashboard)"]}),e.jsx(ur,{children:"These banners appear in a rotating carousel at the top of the dashboard"})]}),e.jsxs(fs,{open:a&&q==="top",onOpenChange:De=>{De||me(),o(De),De&&B("top")},children:[e.jsx(hi,{asChild:!0,children:e.jsxs(K,{onClick:()=>{me(),B("top")},children:[e.jsx(Bs,{className:"mr-2 h-4 w-4"}),"Add Hero Banner"]})}),e.jsxs(hs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(js,{children:[e.jsxs(_s,{children:[d?"Edit":"Create"," Banner"]}),e.jsx(Ir,{children:"Configure the banner's content and display settings"})]}),e.jsx(N7e,{title:b,setTitle:N,description:w,setDescription:k,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:ae,setEndDate:ie,handleImageUpload:he,uploading:p,showPlacementOptions:!1}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>{o(!1),me()},children:"Cancel"}),e.jsx(K,{onClick:ge,disabled:y,children:y?"Saving...":d?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(Re,{children:Te.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:Te.map(De=>e.jsx(k7e,{banner:De,onEdit:()=>ye(De),onDelete:()=>{u(De),i(!0)},onToggleActive:()=>Ue(De)},De.id))})})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(qo,{className:"h-5 w-5"}),"Section Banners"]}),e.jsx(ur,{children:"These banners appear between dashboard content sections"})]}),e.jsxs(fs,{open:a&&q==="between",onOpenChange:De=>{De||me(),o(De),De&&B("between")},children:[e.jsx(hi,{asChild:!0,children:e.jsxs(K,{onClick:()=>{me(),B("between")},children:[e.jsx(Bs,{className:"mr-2 h-4 w-4"}),"Add Section Banner"]})}),e.jsxs(hs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(js,{children:[e.jsxs(_s,{children:[d?"Edit":"Create"," Section Banner"]}),e.jsx(Ir,{children:"Configure where this banner appears between sections"})]}),e.jsx(N7e,{title:b,setTitle:N,description:w,setDescription:k,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:ae,setEndDate:ie,handleImageUpload:he,uploading:p,showPlacementOptions:!0}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>{o(!1),me()},children:"Cancel"}),e.jsx(K,{onClick:ge,disabled:y,children:y?"Saving...":d?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(Re,{children:Me.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:Me.map(De=>e.jsx(k7e,{banner:De,onEdit:()=>ye(De),onDelete:()=>{u(De),i(!0)},onToggleActive:()=>Ue(De),showSection:!0},De.id))})})]})]}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(hs,{children:[e.jsxs(js,{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(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:Ne,children:"Delete"})]})]})})]})}function N7e({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:k,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(Le,{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(gr,{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(Le,{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(Le,{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(Le,{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(Fs,{value:f,onValueChange:y,children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select section placement..."})}),e.jsx(Rs,{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(ln,{className:"h-4 w-4"}),"Start Date (optional)"]}),e.jsx(Le,{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(ln,{className:"h-4 w-4"}),"End Date (optional)"]}),e.jsx(Le,{id:"endDate",type:"datetime-local",value:k,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(Mr,{id:"isActive",checked:_,onCheckedChange:b}),e.jsx(xe,{htmlFor:"isActive",children:"Active"})]})})]})}function k7e({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]=S.useState(null);return S.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(K,{variant:"ghost",size:"icon",children:e.jsx(Zr,{className:"h-4 w-4"})})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:n,children:t.is_active?e.jsx(Cn,{className:"h-4 w-4"}):e.jsx(mp,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:s,children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(xr,{className:"h-4 w-4 text-destructive"})})]})]})}const g9={open:{label:"Open",icon:on,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:Ol,color:"bg-blue-500"},resolved:{label:"Resolved",icon:ti,color:"bg-green-500"},closed:{label:"Closed",icon:Ql,color:"bg-muted-foreground"}},S7e={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function t1s(){var O,V;const{user:t}=qs(),s=Qt(),[r,n]=S.useState(null),[a,o]=S.useState(""),[l,i]=S.useState("all"),[d,u]=S.useState("all"),[p,f]=S.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(ae=>ae.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(ae=>[ae.user_id,ae.receive_notifications]))||[]);return te.map(ae=>({...ae,receives_notifications:ce.get(ae.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=Et({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")}}),k=Et({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=Et({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=Et({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)};S.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?(g9[r.status].icon,e.jsx(Es,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>n(null),children:e.jsx(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:S7e[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(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm",children:"Status"})}),e.jsx(Re,{children:e.jsxs(Fs,{value:r.status,onValueChange:q=>{k.mutate({ticketId:r.id,status:q}),n({...r,status:q})},children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm",children:"Assigned To"})}),e.jsx(Re,{children:e.jsxs(Fs,{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(Ds,{children:e.jsx(zs,{placeholder:"Unassigned"})}),e.jsxs(Rs,{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(Lt,{children:e.jsxs(ur,{children:["Created on ",gs(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(Re,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"Conversation"})}),e.jsxs(Re,{children:[e.jsx(ni,{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:gs(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(xo,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(gr,{placeholder:"Type your reply...",value:a,onChange:q=>o(q.target.value),className:"min-h-[80px]"}),e.jsx(K,{onClick:I,disabled:!a.trim()||A.isPending,className:"self-end",children:e.jsx(Mn,{className:"h-4 w-4"})})]})]})]})]})})):e.jsx(Es,{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(hi,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(So,{className:"h-4 w-4 mr-2"}),"Notification Settings"]})}),e.jsxs(hs,{children:[e.jsxs(js,{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(Mr,{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(ls,{value:"all",children:"All"}),e.jsx(ls,{value:"open",children:"Open"}),e.jsx(ls,{value:"in_progress",children:"In Progress"}),e.jsx(ls,{value:"resolved",children:"Resolved"}),e.jsx(ls,{value:"closed",children:"Closed"})]})}),e.jsxs(Fs,{value:d,onValueChange:u,children:[e.jsx(Ds,{className:"w-[180px]",children:e.jsx(zs,{placeholder:"All Categories"})}),e.jsxs(Rs,{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(Re,{className:"text-center py-12",children:[e.jsx(Ol,{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=g9[q.status].icon;return e.jsx(Pe,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(q),children:e.jsx(Re,{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:S7e[q.category]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(U=q.profiles)==null?void 0:U.name," • ",gs(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:g9[q.status].color,children:[e.jsx(B,{className:"h-3 w-3 mr-1"}),g9[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 s1s({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())}});S.useEffect(()=>{n&&t!==n.getHTML()&&n.commands.setContent(t)},[t,n]);const a=l=>{n&&n.chain().focus().insertContent(`{{${l.key}}}`).run()},o=()=>{if(!n)return;const l=n.getAttributes("link").href,i=window.prompt("URL",l);if(i!==null){if(i===""){n.chain().focus().extendMarkRange("link").unsetLink().run();return}n.chain().focus().extendMarkRange("link").setLink({href:i}).run()}};return n?e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1 p-2 border-b bg-muted/30",children:[e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleBold().run(),className:n.isActive("bold")?"bg-muted":"",children:e.jsx(K4,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleItalic().run(),className:n.isActive("italic")?"bg-muted":"",children:e.jsx(rS,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleBulletList().run(),className:n.isActive("bulletList")?"bg-muted":"",children:e.jsx(Dh,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleOrderedList().run(),className:n.isActive("orderedList")?"bg-muted":"",children:e.jsx(Xy,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("left").run(),className:n.isActive({textAlign:"left"})?"bg-muted":"",children:e.jsx(H4,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("center").run(),className:n.isActive({textAlign:"center"})?"bg-muted":"",children:e.jsx(V4,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("right").run(),className:n.isActive({textAlign:"right"})?"bg-muted":"",children:e.jsx(G4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:o,className:n.isActive("link")?"bg-muted":"",children:e.jsx(go,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleCodeBlock().run(),className:n.isActive("codeBlock")?"bg-muted":"",children:e.jsx(Y4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().undo().run(),disabled:!n.can().undo(),children:e.jsx(wS,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().redo().run(),disabled:!n.can().redo(),children:e.jsx(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(K,{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 r1s(){const t=Qt(),[s,r]=S.useState(null),[n,a]=S.useState(null),[o,l]=S.useState(""),[i,d]=S.useState(""),[u,p]=S.useState(""),[f,y]=S.useState(!0),[_,b]=S.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||[]}))}}),k=Et({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&&k.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(Es,{title:"Edit Email Template",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(K,{variant:"ghost",onClick:()=>r(null),children:[e.jsx(Oa,{className:"h-4 w-4 mr-2"}),"Back to Templates"]}),e.jsx("div",{className:"flex-1"}),e.jsxs(K,{variant:"outline",onClick:()=>a(s),children:[e.jsx(Cn,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(K,{onClick:A,disabled:k.isPending,children:[e.jsx(bc,{className:"h-4 w-4 mr-2"}),k.isPending?"Saving...":"Save Changes"]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(tr,{className:"h-5 w-5"}),s.name]}),e.jsxs(ur,{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(Mr,{id:"active-toggle",checked:f,onCheckedChange:y})]})]})}),e.jsxs(Re,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"description",children:"Description"}),e.jsx(gr,{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(Le,{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(ls,{value:"visual",className:"text-xs px-3 h-6",children:[e.jsx(hS,{className:"h-3 w-3 mr-1"}),"Visual"]}),e.jsxs(ls,{value:"html",className:"text-xs px-3 h-6",children:[e.jsx(Y4,{className:"h-3 w-3 mr-1"}),"HTML"]})]})})]}),_==="visual"?e.jsx(s1s,{content:i,onChange:d,variables:s.available_variables}):e.jsx(gr,{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(hs,{className:"max-w-3xl max-h-[90vh] overflow-auto",children:[e.jsxs(js,{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(Es,{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(Lt,{children:[e.jsx(ks,{className:"h-5 w-48"}),e.jsx(ks,{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(Lt,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Ft,{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(ur,{children:L.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>a(L),children:[e.jsx(Cn,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(K,{size:"sm",onClick:()=>C(L),children:[e.jsx(Wc,{className:"h-4 w-4 mr-2"}),"Edit"]})]})]})}),e.jsx(Re,{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(hs,{className:"max-w-3xl max-h-[90vh] overflow-auto",children:[e.jsxs(js,{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 n1s(){const t=Qt(),[s,r]=S.useState("templates"),[n,a]=S.useState(null),[o,l]=S.useState(null),[i,d]=S.useState(!1),[u,p]=S.useState(!1),[f,y]=S.useState({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),[_,b]=S.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:k}=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=Et({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=Et({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=Et({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=Et({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(Es,{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(ls,{value:"templates",className:"gap-2",children:[e.jsx(tr,{className:"h-4 w-4"})," Templates"]}),e.jsxs(ls,{value:"categories",className:"gap-2",children:[e.jsx(Mm,{className:"h-4 w-4"})," Categories"]})]}),e.jsxs(ws,{value:"templates",className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{onClick:O,className:"gap-2",children:[e.jsx(Bs,{className:"h-4 w-4"})," Add Template"]})}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ms,{children:[e.jsx(kt,{children:"Template"}),e.jsx(kt,{className:"hidden md:table-cell",children:"Category"}),e.jsx(kt,{className:"hidden md:table-cell",children:"Tone"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:k?e.jsx(Ms,{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(Ms,{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(Ms,{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(K,{variant:"ghost",size:"icon",onClick:()=>V(U),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&A.mutate(U.id)},children:e.jsx(xr,{className:"h-4 w-4"})})]})})]},U.id))})]})})})]}),e.jsxs(ws,{value:"categories",className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{onClick:q,className:"gap-2",children:[e.jsx(Bs,{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(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ft,{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(K,{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(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:()=>{confirm("Delete this category?")&&L.mutate(U.id)},children:e.jsx(xr,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(Re,{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(hs,{className:"sm:max-w-[700px] max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{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(Le,{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(Fs,{value:f.category_id,onValueChange:U=>y(te=>({...te,category_id:U})),children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select category"})}),e.jsx(Rs,{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(Le,{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(gr,{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(Le,{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(Le,{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(Mr,{checked:f.is_active,onCheckedChange:U=>y(te=>({...te,is_active:U}))}),e.jsx(xe,{children:"Active"})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(K,{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(hs,{className:"sm:max-w-[450px]",children:[e.jsx(js,{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(Le,{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(Le,{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(Le,{value:_.description,onChange:U=>b(te=>({...te,description:U.target.value})),placeholder:"Brief description of this category"})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>p(!1),children:"Cancel"}),e.jsxs(K,{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 a1s=({brokerageId:t})=>{var Er,Bt;const{toast:s}=ja(),r=vr(),[n,a]=S.useState([]),[o,l]=S.useState(!0),[i,d]=S.useState(""),[u,p]=S.useState("all"),[f,y]=S.useState(new Set),[_,b]=S.useState(!1),[N,w]=S.useState({}),[k,C]=S.useState(!1),[A,I]=S.useState(!1),[L,O]=S.useState({email:"",name:"",password:"",phone:""}),[V,q]=S.useState(!1),[B,U]=S.useState(null),[te,Y]=S.useState(!1),[J,X]=S.useState(!1),[ce,ae]=S.useState(!1),[ie,oe]=S.useState(""),[me,ye]=S.useState(!1),[he,ge]=S.useState([]),[Ne,Ue]=S.useState(!1),[Te,Me]=S.useState(!1),[De,qe]=S.useState(null),[ke,$e]=S.useState({name:"",phone:"",email:""}),[Be,we]=S.useState(!1),[ut,fe]=S.useState(!1),[He,et]=S.useState(null),[tt,_e]=S.useState("asc"),[Ge,We]=S.useState(!1),[it,Ve]=S.useState(null),[Xe,dt]=S.useState(!1),[pt,Je]=S.useState(null),[Ze,Nt]=S.useState(""),[Ot,Yt]=S.useState(!1),[Ps,$s]=S.useState(null);S.useEffect(()=>{Dr(),Zs()},[t]);const Zs=async()=>{try{const{data:Se,error:Oe}=await G.from("brokerage_manager_assignments").select("user_id").eq("brokerage_id",t);if(Oe)throw Oe;ge((Se==null?void 0:Se.map(Ye=>Ye.user_id))||[])}catch(Se){console.error("Error loading brokerage managers:",Se)}},Dr=async()=>{try{l(!0);const{data:Se,error:Oe}=await G.functions.invoke("get-brokerage-agents",{body:{brokerageId:t}});if(Oe)throw Oe;const Ye=Se.agents||[];if(a(Ye),Ye.length>0){const yt=Ye.map(Tt=>Tt.id),{data:bt}=await G.from("agent_assistant_assignments").select("agent_id, assistant_id").in("agent_id",yt);if(bt&&bt.length>0){const Tt=bt.map(Xt=>Xt.assistant_id),{data:Ht}=await G.from("profiles").select("id, name, email").in("id",Tt),Ut={};for(const Xt of bt){const Ts=Ht==null?void 0:Ht.find(ys=>ys.id===Xt.assistant_id);Ts&&(Ut[Xt.agent_id]={name:Ts.name||"",email:Ts.email||""})}w(Ut)}else w({})}}catch(Se){console.error("Error loading agents:",Se),s({title:"Error",description:"Failed to load agents",variant:"destructive"})}finally{l(!1)}},$t=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(),Oe=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})}),Ye=await Oe.json();if(!Oe.ok)throw new Error(Ye.error||"Failed to create agent");s({title:"Success",description:`Agent ${L.email} created successfully`}),O({email:"",name:"",password:"",phone:""}),C(!1),Dr()}catch(Se){console.error("Error creating agent:",Se),s({title:"Error",description:Se.message||"Failed to create agent",variant:"destructive"})}finally{I(!1)}},Us=async Se=>{try{const{data:{session:Oe}}=await G.auth.getSession(),Ye=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Oe==null?void 0:Oe.access_token}`},body:JSON.stringify({userId:Se})}),yt=await Ye.json();if(!Ye.ok)throw new Error(yt.error||"Failed to resend welcome email");s({title:"Success",description:"Welcome email sent successfully"})}catch(Oe){console.error("Error resending welcome email:",Oe),s({title:"Error",description:Oe.message||"Failed to resend welcome email",variant:"destructive"})}},Nr=async(Se,Oe)=>{try{const{error:Ye}=await G.functions.invoke("send-password-reset",{body:{email:Se,redirectTo:window.location.origin}});if(Ye)throw Ye;s({title:"Password Reset Sent",description:`Password reset email sent to ${Oe}`})}catch(Ye){console.error("Error sending password reset:",Ye),s({title:"Error",description:Ye.message||"Failed to send password reset email",variant:"destructive"})}},Xs=Se=>{U(Se),q(!0)},kr=Se=>{qe(Se),$e({name:Se.name,phone:Se.phone||"",email:Se.email}),Me(!0)},fn=async()=>{if(!De)return;if(!ke.name.trim()){s({title:"Error",description:"Name is required",variant:"destructive"});return}const Se=ke.email.trim().toLowerCase()!==De.email.toLowerCase();we(!0);try{if(Se){if(!ke.email.trim())throw new Error("Email is required");fe(!0);const{data:{session:Ye}}=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 ${Ye==null?void 0:Ye.access_token}`},body:JSON.stringify({agentId:De.id,newEmail:ke.email.trim(),brokerageId:t})}),bt=await yt.json();if(fe(!1),!yt.ok)throw new Error(bt.error||"Failed to update email")}const{error:Oe}=await G.from("profiles").update({name:ke.name.trim(),phone:ke.phone.trim()||null}).eq("id",De.id);if(Oe)throw Oe;s({title:"Success",description:"Agent profile updated successfully"}),Me(!1),qe(null),Dr()}catch(Oe){console.error("Error updating agent:",Oe),s({title:"Error",description:Oe.message||"Failed to update agent",variant:"destructive"})}finally{we(!1),fe(!1)}},Yr=async()=>{if(!ie){s({title:"Error",description:"Please select an agent to promote",variant:"destructive"});return}ye(!0);try{const{data:{session:Se}}=await G.auth.getSession(),Oe=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:ie,role:"brokerage_manager",action:"add",brokerageId:t})}),Ye=await Oe.json();if(!Oe.ok)throw new Error(Ye.error||"Failed to add brokerage manager");s({title:"Success",description:"Brokerage manager added successfully"}),ae(!1),oe(""),Zs()}catch(Se){console.error("Error adding brokerage manager:",Se),s({title:"Error",description:Se.message||"Failed to add brokerage manager",variant:"destructive"})}finally{ye(!1)}},$r=async Se=>{try{const{data:{session:Oe}}=await G.auth.getSession(),Ye=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Oe==null?void 0:Oe.access_token}`},body:JSON.stringify({userId:Se,role:"brokerage_manager",action:"remove",brokerageId:t})}),yt=await Ye.json();if(!Ye.ok)throw new Error(yt.error||"Failed to remove brokerage manager");s({title:"Success",description:"Brokerage manager role removed"}),Zs()}catch(Oe){console.error("Error removing brokerage manager:",Oe),s({title:"Error",description:Oe.message||"Failed to remove brokerage manager",variant:"destructive"})}},Gr=Se=>he.includes(Se),nr=Se=>{Je(Se),Nt(""),dt(!0)},lr=async()=>{if(!(!pt||!Ze)){if(Ze.length<6){s({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}Yt(!0);try{const{data:{session:Se}}=await G.auth.getSession(),Oe=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:pt.id,brokerageId:t,action:"set_password",newPassword:Ze})}),Ye=await Oe.json();if(!Oe.ok)throw new Error(Ye.error||"Failed to set password");s({title:"Success",description:`Password set for ${pt.name}`}),dt(!1),Je(null),Nt("")}catch(Se){console.error("Error setting password:",Se),s({title:"Error",description:Se.message||"Failed to set password",variant:"destructive"})}finally{Yt(!1)}}},Fr=async Se=>{$s(Se.id);try{const{data:{session:Oe}}=await G.auth.getSession(),Ye=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Oe==null?void 0:Oe.access_token}`},body:JSON.stringify({agentId:Se.id,brokerageId:t,action:"claim_account"})}),yt=await Ye.json();if(!Ye.ok)throw new Error(yt.error||"Failed to claim account");s({title:"Success",description:`Account claimed for ${Se.name}`}),Dr()}catch(Oe){console.error("Error claiming account:",Oe),s({title:"Error",description:Oe.message||"Failed to claim account",variant:"destructive"})}finally{$s(null)}},Wr=async()=>{if(B){Y(!0);try{const{data:{session:Se}}=await G.auth.getSession(),Oe=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})}),Ye=await Oe.json();if(!Oe.ok)throw new Error(Ye.error||"Failed to remove agent");s({title:"Success",description:`${B.name} has been removed from your brokerage`}),q(!1),U(null),Dr()}catch(Se){console.error("Error removing agent:",Se),s({title:"Error",description:Se.message||"Failed to remove agent",variant:"destructive"})}finally{Y(!1)}}},Nn=Se=>{const Oe=Se.trim().split(" ");return Oe.length>1?Oe[Oe.length-1].toLowerCase():Se.toLowerCase()},ai=Se=>{He===Se?_e(tt==="asc"?"desc":"asc"):(et(Se),_e("asc"))},ns=Se=>He!==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"}),$n=n.filter(Se=>{if(u==="active"&&!Se.claimed||u==="pending"&&Se.claimed)return!1;if(!i)return!0;const Oe=i.toLowerCase();return Se.name.toLowerCase().includes(Oe)||Se.email.toLowerCase().includes(Oe)}),dn=[...$n].sort((Se,Oe)=>{if(!He)return 0;let Ye=0;return He==="name"?Ye=Nn(Se.name).localeCompare(Nn(Oe.name)):He==="status"&&(Ye=Se.claimed===Oe.claimed?0:Se.claimed?-1:1),tt==="asc"?Ye:-Ye});$n.filter(Se=>Se.claimed&&!Gr(Se.id));const zr=Se=>{y(Oe=>{const Ye=new Set(Oe);return Ye.has(Se)?Ye.delete(Se):Ye.add(Se),Ye})},Kr=()=>{f.size===dn.length?y(new Set):y(new Set(dn.map(Se=>Se.id)))},La=()=>{y(new Set)},Zt=async()=>{const Se=Array.from(f);if(Se.length===0)return;b(!0);let Oe=0,Ye=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?Oe++:Ye++}catch{Ye++}Oe>0?s({title:"Success",description:`Welcome emails sent to ${Oe} agent${Oe>1?"s":""}${Ye>0?` (${Ye} 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(Re,{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(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{children:"Agents"}),e.jsx(ur,{children:"Manage your brokerage's agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>ae(!0),children:[e.jsx(zu,{className:"mr-2 h-4 w-4"}),"Add Brokerage Manager"]}),e.jsxs(K,{variant:"outline",onClick:()=>X(!0),children:[e.jsx(Zv,{className:"mr-2 h-4 w-4"}),"Import CSV"]}),e.jsxs(K,{onClick:()=>C(!0),children:[e.jsx(Jo,{className:"mr-2 h-4 w-4"}),"Add Agent"]})]})]})}),e.jsxs(Re,{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(an,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search agents...",value:i,onChange:Se=>d(Se.target.value),className:"pl-9"})]}),e.jsxs(Fs,{value:u,onValueChange:Se=>p(Se),children:[e.jsx(Ds,{className:"w-[160px]",children:e.jsx(zs,{placeholder:"Filter by status"})}),e.jsxs(Rs,{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(K,{size:"sm",variant:"outline",onClick:()=>{const Oe=n.filter(Ye=>f.has(Ye.id)&&Ye.email).map(Ye=>({email:Ye.email,name:Ye.name}));sessionStorage.setItem("campaign_direct_recipients",JSON.stringify(Oe)),r("/admin/email-campaigns/new?directMode=1",{state:{directRecipients:Oe}})},disabled:_,children:[e.jsx(uh,{className:"mr-2 h-4 w-4"}),"Email Agents (",f.size,")"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:Zt,disabled:_,children:[e.jsx(tr,{className:"mr-2 h-4 w-4"}),_?"Sending...":"Resend Welcome Email"]}),e.jsx(K,{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(Ms,{children:[e.jsx(kt,{className:"w-[40px]",children:e.jsx(Hi,{checked:dn.length>0&&f.size===dn.length,onCheckedChange:Kr,"aria-label":"Select all"})}),e.jsx(kt,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>ai("name"),children:["Name (Last)",ns("name")]})}),e.jsx(kt,{children:"Email"}),e.jsx(kt,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>ai("status"),children:["Status",ns("status")]})}),e.jsx(kt,{children:"Actions"})]})}),e.jsx(Rn,{children:dn.length===0?e.jsx(Ms,{children:e.jsx(ht,{colSpan:5,className:"text-center text-muted-foreground",children:"No agents found"})}):dn.map(Se=>e.jsxs(Ms,{children:[e.jsx(ht,{children:e.jsx(Hi,{checked:f.has(Se.id),onCheckedChange:()=>zr(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"}),Gr(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(or,{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(K,{size:"sm",variant:"ghost",onClick:()=>{Ve(Se),We(!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(K,{size:"sm",variant:"ghost",onClick:()=>kr(Se),title:"Edit agent",children:e.jsx(ga,{className:"h-4 w-4"})}),!Se.claimed&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Us(Se.id),title:"Resend welcome email",children:e.jsx(tr,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Fr(Se),title:"Claim account for agent",disabled:Ps===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(K,{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(vd,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Nr(Se.email,Se.name),title:"Send password reset email",children:e.jsx(nS,{className:"h-4 w-4"})}),Gr(Se.id)&&e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>$r(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(K,{size:"sm",variant:"ghost",onClick:()=>Xs(Se),className:"text-destructive hover:text-destructive",title:"Remove agent",children:e.jsx(xr,{className:"h-4 w-4"})})]})})]},Se.id))})]})})]})]}),e.jsx(fs,{open:k,onOpenChange:C,children:e.jsxs(hs,{children:[e.jsxs(js,{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(Le,{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(Le,{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(Le,{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(Le,{id:"password",type:"password",value:L.password,onChange:Se=>O({...L,password:Se.target.value}),placeholder:"Temporary password"})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),e.jsx(K,{onClick:$t,disabled:A,children:A?"Creating...":"Create Agent"})]})]})}),e.jsx(fs,{open:V,onOpenChange:q,children:e.jsxs(hs,{children:[e.jsxs(js,{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(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>q(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:Wr,disabled:te,children:te?"Removing...":"Remove Agent"})]})]})}),e.jsx(utt,{open:J,onOpenChange:X,fixedBrokerageId:t,onSuccess:Dr}),e.jsx(fs,{open:ce,onOpenChange:ae,children:e.jsxs(hs,{children:[e.jsxs(js,{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(yo,{open:Ne,onOpenChange:Ue,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":Ne,className:"w-full justify-between",children:[ie?((Er=n.find(Se=>Se.id===ie))==null?void 0:Er.name)+" ("+((Bt=n.find(Se=>Se.id===ie))==null?void 0:Bt.email)+")":"Select an agent to promote...",e.jsx(gx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(uo,{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=>!Gr(Se.id)).map(Se=>e.jsxs(lp,{value:`${Se.name} ${Se.email}`,onSelect:()=>{oe(Se.id),Ue(!1)},children:[e.jsx(Zn,{className:`mr-2 h-4 w-4 ${ie===Se.id?"opacity-100":"opacity-0"}`}),Se.name," (",Se.email,")"]},Se.id))})]})]})})]}),n.filter(Se=>!Gr(Se.id)).length===0&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"All agents are already brokerage managers."})]})}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>ae(!1),children:"Cancel"}),e.jsx(K,{onClick:Yr,disabled:me||!ie,children:me?"Adding...":"Add as Manager"})]})]})}),e.jsx(fs,{open:Te,onOpenChange:Me,children:e.jsxs(hs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Edit Agent"}),e.jsxs(Ir,{children:["Update profile information for ",De==null?void 0:De.name]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"edit-name",children:"Name"}),e.jsx(Le,{id:"edit-name",value:ke.name,onChange:Se=>$e({...ke,name:Se.target.value}),placeholder:"Agent name"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"edit-email",children:"Email"}),e.jsx(Le,{id:"edit-email",type:"email",value:ke.email,onChange:Se=>$e({...ke,email:Se.target.value}),placeholder:"agent@example.com"}),ke.email.trim().toLowerCase()!==(De==null?void 0:De.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(Le,{id:"edit-phone",type:"tel",value:ke.phone,onChange:Se=>$e({...ke,phone:Se.target.value}),placeholder:"555-123-4567"})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>Me(!1),children:"Cancel"}),e.jsx(K,{onClick:fn,disabled:Be||ut,children:ut?"Updating email...":Be?"Saving...":"Save Changes"})]})]})}),it&&e.jsx(htt,{open:Ge,onOpenChange:Se=>{We(Se),Se||Ve(null)},userId:it.id,userName:it.name}),e.jsx(fs,{open:Xe,onOpenChange:dt,children:e.jsxs(hs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Set Password"}),e.jsxs(Ir,{children:["Set a new password for ",pt==null?void 0:pt.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(Le,{id:"new-password",type:"password",value:Ze,onChange:Se=>Nt(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(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>dt(!1),children:"Cancel"}),e.jsx(K,{onClick:lr,disabled:Ot||!Ze||Ze.length<6,children:Ot?"Setting...":"Set Password"})]})]})})]})},i1s={academy_video:"Academy Video",template:"Template",toolbox:"Toolbox Resource",newsletter:"Newsletter",social_swag:"Social Swag",event:"Event"},o1s={view:"Viewed",click_canva:"Opened Canva",click_pdf:"Downloaded PDF",click_video:"Watched Video",click_link:"Clicked Link",register:"Registered"},l1s=t=>{switch(t){case"academy_video":return e.jsx(gn,{className:"h-4 w-4"});case"template":return e.jsx(yn,{className:"h-4 w-4"});case"toolbox":return e.jsx(yn,{className:"h-4 w-4"});case"newsletter":return e.jsx(Jv,{className:"h-4 w-4"});case"social_swag":return e.jsx(Or,{className:"h-4 w-4"});case"event":return e.jsx(ln,{className:"h-4 w-4"});default:return e.jsx(Zr,{className:"h-4 w-4"})}},c1s=({brokerageId:t})=>{const{toast:s}=ja(),[r,n]=S.useState([]),[a,o]=S.useState([]),[l,i]=S.useState([]),[d,u]=S.useState(!0),[p,f]=S.useState(null);S.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 k=N.map(te=>te.id),C=new Map(N.map(te=>[te.id,te]));if(k.length===0){n([]),o([]),i([]);return}const{data:A,error:I}=await G.from("activity_logs").select("*").in("user_id",k).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",k).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(Re,{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(Lt,{children:[e.jsx(Ft,{children:"Agent Activity"}),e.jsx(ur,{children:"Track app usage and content engagement - click an agent for details"})]}),e.jsx(Re,{children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ms,{children:[e.jsx(kt,{children:"Agent"}),e.jsx(kt,{className:"text-center",children:"App Launches"}),e.jsx(kt,{className:"text-center",children:"Content Views"}),e.jsx(kt,{children:"Last Active"})]})}),e.jsx(Rn,{children:l.length===0?e.jsx(Ms,{children:e.jsx(ht,{colSpan:4,className:"text-center text-muted-foreground",children:"No activity yet"})}):l.map(N=>e.jsxs(Ms,{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(yn,{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(hs,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(js,{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(ls,{value:"content",children:"Content Engagement"}),e.jsx(ls,{value:"apps",children:"App Launches"})]}),e.jsx(ws,{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(Ms,{children:[e.jsx(kt,{children:"Resource"}),e.jsx(kt,{children:"Type"}),e.jsx(kt,{children:"Action"}),e.jsx(kt,{children:"Time"})]})}),e.jsx(Rn,{children:p&&b(p.id).length===0?e.jsx(Ms,{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(Ms,{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:[l1s(N.resource_type),i1s[N.resource_type]||N.resource_type]})}),e.jsx(ht,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:o1s[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(ws,{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(Ms,{children:[e.jsx(kt,{children:"App"}),e.jsx(kt,{children:"Time"})]})}),e.jsx(Rn,{children:p&&_(p.id).length===0?e.jsx(Ms,{children:e.jsx(ht,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches yet"})}):p&&_(p.id).map(N=>e.jsxs(Ms,{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))})]})})})]})]})})]})},d1s=({brokerageId:t})=>{const{toast:s}=ja(),[r,n]=S.useState({totalAgents:0,activeAgents:0,pendingAgents:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0}),[a,o]=S.useState(!0);S.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),k=new Date;k.setDate(k.getDate()-7);const{count:C}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u).gte("launched_at",k.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(Re,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Total Agents"}),e.jsx(or,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Active Agents"}),e.jsx(ti,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(on,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(lh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"This Week"}),e.jsx(lh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"This Month"}),e.jsx(lh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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"})]})]})]})},u1s=({brokerageId:t})=>{const[s,r]=S.useState([]),[n,a]=S.useState(!0),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState({description:"",maxUses:""});S.useEffect(()=>{f()},[t]);const f=async()=>{try{const{data:k,error:C}=await G.from("invite_codes").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(C)throw C;r(k||[])}catch(k){console.error("Error loading invite codes:",k),pe.error("Failed to load invite links")}finally{a(!1)}},y=()=>Math.random().toString(36).substring(2,8).toUpperCase(),_=async()=>{l(!0);try{const k=y(),{error:C}=await G.from("invite_codes").insert({code:k,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(k){console.error("Error creating invite code:",k),pe.error("Failed to create invite link")}finally{l(!1)}},b=async k=>{try{const{error:C}=await G.from("invite_codes").delete().eq("id",k);if(C)throw C;pe.success("Invite link deleted"),r(s.filter(A=>A.id!==k))}catch(C){console.error("Error deleting invite code:",C),pe.error("Failed to delete invite link")}},N=async(k,C)=>{try{const{error:A}=await G.from("invite_codes").update({is_active:!C}).eq("id",k);if(A)throw A;r(s.map(I=>I.id===k?{...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=k=>{const C=`${window.location.origin}/join?code=${k}`;navigator.clipboard.writeText(C),pe.success("Link copied to clipboard!")};return n?e.jsx(Pe,{children:e.jsx(Re,{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(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(go,{className:"h-5 w-5"}),"Agent Invite Links"]}),e.jsx(ur,{children:"Create shareable links for agents to join your brokerage"})]}),e.jsxs(fs,{open:i,onOpenChange:d,children:[e.jsx(hi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Bs,{className:"mr-2 h-4 w-4"}),"Create Link"]})}),e.jsxs(hs,{children:[e.jsxs(js,{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(Le,{id:"description",placeholder:"e.g., New agent recruiting campaign",value:u.description,onChange:k=>p({...u,description:k.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"maxUses",children:"Max Uses (optional)"}),e.jsx(Le,{id:"maxUses",type:"number",placeholder:"Leave empty for unlimited",value:u.maxUses,onChange:k=>p({...u,maxUses:k.target.value})})]}),e.jsx(K,{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(Re,{children:s.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(go,{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(k=>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:k.code}),e.jsx(Qe,{variant:k.is_active?"default":"secondary",children:k.is_active?"Active":"Inactive"})]}),k.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:k.description}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[k.uses_count," uses",k.max_uses&&` / ${k.max_uses} max`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>w(k.code),title:"Copy link",children:e.jsx(Wa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>N(k.id,k.is_active),title:k.is_active?"Deactivate":"Activate",children:k.is_active?"Disable":"Enable"}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>b(k.id),className:"text-destructive hover:text-destructive",title:"Delete",children:e.jsx(xr,{className:"h-4 w-4"})})]})]},k.id))})})]})},h1s=({open:t,onOpenChange:s,referralCode:r,brokerageId:n,senderName:a,brokerageName:o,onInvitesSent:l})=>{const[i,d]=S.useState(""),[u,p]=S.useState([]),[f,y]=S.useState(""),[_,b]=S.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")},k=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(hs,{className:"sm:max-w-[550px]",children:[e.jsxs(js,{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(yi,{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(Le,{id:"email",type:"email",placeholder:"Enter email and press Enter",value:i,onChange:I=>d(I.target.value),onKeyDown:C,onBlur:w}),e.jsx(K,{type:"button",variant:"secondary",onClick:w,children:"Add"})]}),u.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:u.map(I=>e.jsxs(Qe,{variant:"secondary",className:"flex items-center gap-1 pr-1",children:[I,e.jsx("button",{type:"button",onClick:()=>k(I),className:"ml-1 rounded-full p-0.5 hover:bg-muted",children:e.jsx(jr,{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(gr,{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(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{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(Mn,{className:"h-4 w-4 mr-2"}),"Send ",u.length>0&&`(${u.length})`," Invite",u.length!==1?"s":""]})})]})]})})},m1s=({brokerageId:t,refreshTrigger:s})=>{const[r,n]=S.useState([]),[a,o]=S.useState(!0);S.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(ti,{className:"h-3 w-3"}),"Signed Up"]});case"expired":return e.jsxs(Qe,{variant:"outline",className:"text-muted-foreground gap-1",children:[e.jsx(Ql,{className:"h-3 w-3"}),"Expired"]});default:return e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[e.jsx(on,{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 ",gs(new Date(d.sent_at),"MMM d, yyyy")]})]}),i(d.status)]},d.id))]})},p1s=()=>{const{brokerageId:t,user:s}=qs(),[r,n]=S.useState(null),[a,o]=S.useState(""),[l,i]=S.useState(""),[d,u]=S.useState([]),[p,f]=S.useState(!0),[y,_]=S.useState(!1),[b,N]=S.useState(0);S.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)}},k=()=>{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(yi,{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(ti,{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(Re,{className:"pt-6 space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs(K,{onClick:()=>_(!0),className:"w-full",size:"lg",children:[e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Invite Broker Friends"]}),e.jsxs(K,{onClick:k,variant:"outline",className:"w-full",size:"lg",children:[e.jsx(Wa,{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(or,{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(on,{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(m1s,{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(ti,{className:"h-3 w-3 mr-1"}),O.status]})]},O.id)})]})]})]}),e.jsx(h1s,{open:y,onOpenChange:_,referralCode:r||"",brokerageId:t||"",senderName:l||"A LevelUp Member",brokerageName:a,onInvitesSent:()=>N(O=>O+1)})]})},f1s=({brokerageId:t})=>{const s=vr(),{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:k}=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;(k||[]).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(Lt,{children:e.jsx(ks,{className:"h-5 w-32"})}),e.jsx(Re,{children:e.jsx(ks,{className:"h-24 w-full"})})]},p))});if(r.length===0)return e.jsx(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(or,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Teams Yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Create teams to organize your agents and track their performance."}),e.jsx(K,{onClick:()=>s("/brokerage/teams"),children:"Manage Teams"})]})});const i=(a||[]).reduce((p,f)=>p+f.member_count,0),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(Re,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(or,{className:"h-4 w-4"})," Teams"]}),e.jsx("p",{className:"text-2xl font-bold",children:r.length})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(or,{className:"h-4 w-4"})," Total Members"]}),e.jsx("p",{className:"text-2xl font-bold",children:i})]})}),e.jsx(Pe,{children:e.jsxs(Re,{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(Re,{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(Lt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ft,{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(wn,{className:"h-6 w-6",children:[e.jsx(Ma,{src:p.leader_avatar||""}),e.jsx(jn,{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(Re,{children:e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:p.total_contacts.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Contacts"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:p.total_deals.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Deals"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:p.total_videos.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Videos"})]})]})})]},p.team_id))}),e.jsx("div",{className:"flex justify-end",children:e.jsx(K,{variant:"outline",onClick:()=>s("/brokerage/teams"),children:"Manage Teams →"})})]})},x1s=()=>{const{user:t,isBrokerageManager:s,brokerageId:r,isAdmin:n,managedBrokerages:a,selectedBrokerageId:o,setSelectedBrokerageId:l}=qs(),i=vr(),{toast:d}=ja(),[u,p]=S.useState(""),[f,y]=S.useState(!0),_=o||(a.length>0?a[0].id:r);S.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(Es,{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(Es,{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(Fs,{value:o||"",onValueChange:l,children:[e.jsxs(Ds,{className:"w-[280px]",children:[e.jsx(pa,{className:"mr-2 h-4 w-4"}),e.jsx(zs,{placeholder:"Select brokerage"})]}),e.jsx(Rs,{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(ls,{value:"agents",children:"Agents"}),e.jsx(ls,{value:"teams",children:"Teams"}),e.jsx(ls,{value:"invite",children:"Invite Links"}),e.jsx(ls,{value:"referrals",children:"Referrals"}),e.jsx(ls,{value:"leaderboard",children:"Leaderboard"}),e.jsx(ls,{value:"activity",children:"Activity"}),e.jsx(ls,{value:"analytics",children:"Analytics"}),e.jsx(ls,{value:"shares",children:"Shares"})]}),e.jsx(ws,{value:"agents",className:"space-y-4",children:e.jsx(a1s,{brokerageId:_})}),e.jsx(ws,{value:"teams",className:"space-y-4",children:e.jsx(f1s,{brokerageId:_})}),e.jsx(ws,{value:"invite",className:"space-y-4",children:e.jsx(u1s,{brokerageId:_})}),e.jsx(ws,{value:"referrals",className:"space-y-4",children:e.jsx(p1s,{})}),e.jsx(ws,{value:"leaderboard",className:"space-y-4",children:e.jsx(Aet,{brokerageId:_,title:`${u} Event Leaderboard`,showUserStats:!1})}),e.jsx(ws,{value:"activity",className:"space-y-4",children:e.jsx(c1s,{brokerageId:_})}),e.jsx(ws,{value:"analytics",className:"space-y-4",children:e.jsx(d1s,{brokerageId:_})}),e.jsx(ws,{value:"shares",className:"space-y-4",children:e.jsx($tt,{brokerageOnly:!0,brokerageId:_})})]})]})}):e.jsx(Es,{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 g1s({brokerageId:t,canManage:s}){const{user:r}=qs(),[n,a]=S.useState([]),[o,l]=S.useState(!0),[i,d]=S.useState(!1),[u,p]=S.useState(null),[f,y]=S.useState(null),[_,b]=S.useState(!1),[N,w]=S.useState(""),[k,C]=S.useState(""),[A,I]=S.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(ie=>ie.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(ie=>[ie.id,ie]))||[]),ae=Y.map(ie=>({...ie,author:ce.get(ie.created_by)||{name:"Unknown",avatar_url:null}}));a(ae)}else a([])}catch(U){console.error("Error fetching announcements:",U)}finally{l(!1)}};S.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()||!k.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:k.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:k.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(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(uh,{className:"h-5 w-5"}),"Announcements"]})}),e.jsx(Re,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(uh,{className:"h-5 w-5 text-primary"}),"Announcements"]}),s&&e.jsxs(K,{size:"sm",onClick:()=>V(),className:"gap-1",children:[e.jsx(Bs,{className:"h-4 w-4"}),"New"]})]}),e.jsx(Re,{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(wn,{className:"h-5 w-5",children:[e.jsx(Ma,{src:((te=U.author)==null?void 0:te.avatar_url)||void 0}),e.jsx(jn,{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:gs(new Date(U.created_at),"MMM d, yyyy")})]})]}),s&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>V(U),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>y(U.id),children:e.jsx(xr,{className:"h-4 w-4"})})]})]})},U.id)})})})]}),e.jsx(fs,{open:i,onOpenChange:d,children:e.jsxs(hs,{children:[e.jsx(js,{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(Le,{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(gr,{id:"content",value:k,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(Mr,{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(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(K,{onClick:q,disabled:_,children:_?"Saving...":u?"Update":"Create"})]})]})]})}),e.jsx(Dl,{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 y1s({brokerageId:t,canManage:s=!1}){const{startImpersonation:r,isLoading:n}=hue(),{user:a}=qs(),[o,l]=S.useState([]),[i,d]=S.useState(!0),[u,p]=S.useState(""),[f,y]=S.useState(new Set);S.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 k=N.map(A=>A.id),{data:C}=await G.from("agent_assistant_assignments").select("agent_id").in("agent_id",k);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(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(or,{className:"h-5 w-5"}),"Agent Roster"]})}),e.jsx(Re,{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(Lt,{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 space-y-0",children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(or,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search agents...",value:u,onChange:b=>p(b.target.value),className:"pl-9"})]})]}),e.jsx(Re,{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(v1s,{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 v1s({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(wn,{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(jn,{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(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:n,disabled:a,children:e.jsx(lS,{className:"h-4 w-4"})})}),e.jsxs(Ll,{children:["Login as ",t.name]})]}),t.phone&&e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:`tel:${t.phone}`,title:`Call ${t.name}`,children:e.jsx(In,{className:"h-4 w-4"})})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:`mailto:${t.email}`,title:`Email ${t.name}`,children:e.jsx(tr,{className:"h-4 w-4"})})}),t.linkedin_url&&e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:t.linkedin_url,target:"_blank",rel:"noopener noreferrer",title:"LinkedIn",children:e.jsx(xp,{className:"h-4 w-4"})})}),t.instagram_url&&e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:t.instagram_url,target:"_blank",rel:"noopener noreferrer",title:"Instagram",children:e.jsx(pu,{className:"h-4 w-4"})})})]})]})}function _1s({brokerageId:t}){const[s,r]=S.useState([]),[n,a]=S.useState(!0);if(S.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(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Vi,{className:"h-5 w-5"}),"Team Leaderboard"]})}),e.jsx(Re,{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:Dt("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(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Vi,{className:"h-5 w-5 text-primary"}),"Team Leaderboard"]})}),e.jsx(Re,{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:Dt("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(wn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:i.avatar_url||void 0}),e.jsx(jn,{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 b1s({brokerageId:t}){const s=vr(),[r,n]=S.useState([]),[a,o]=S.useState(!0);S.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(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Sn,{className:"h-5 w-5"}),"Brokerage Listings"]})}),e.jsx(Re,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Sn,{className:"h-5 w-5 text-primary"}),"Brokerage Listings"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>s("/mission-control/listings"),className:"gap-1",children:[e.jsx(Bs,{className:"h-4 w-4"}),"Add Listing"]})]}),e.jsxs(Re,{children:[r.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Sn,{className:"h-10 w-10 text-muted-foreground mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No active listings from your brokerage yet"}),e.jsxs(K,{size:"sm",onClick:()=>s("/mission-control/listings/new"),className:"gap-1",children:[e.jsx(Bs,{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(Sn,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsx("span",{className:"text-[10px] font-medium bg-primary text-primary-foreground px-1.5 py-0.5 rounded uppercase",children:i.property_type.replace("_"," ")})})]}),e.jsxs("div",{className:"p-2.5",children:[e.jsx("p",{className:"font-semibold text-sm text-primary",children:l(i.price)}),e.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:i.property_address||"Address not available"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:i.city}),i.agent&&e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-1.5 truncate",children:["Listed by ",i.agent.name]})]})]},i.id))}),r.length>0&&e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full mt-3",onClick:()=>s("/mission-control/listings"),children:["View All Listings",e.jsx(Zr,{className:"h-3 w-3 ml-1"})]})]})]})}function w1s(){const{user:t,isAdmin:s,isBrokerageManager:r}=qs(),n=vr(),[a,o]=S.useState(!0),[l,i]=S.useState(null),[d,u]=S.useState(""),[p,f]=S.useState(0),[y,_]=S.useState(!1),[b,N]=S.useState(!1);return S.useEffect(()=>{(async()=>{if(t)try{const{data:k}=await G.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle();if(!(k!=null&&k.brokerage_id)){o(!1);return}i(k.brokerage_id);const{data:C}=await G.from("brokerages").select("name").eq("id",k.brokerage_id).maybeSingle();C&&u(C.name);const{count:A}=await G.from("profiles").select("id",{count:"exact",head:!0}).eq("brokerage_id",k.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",k.brokerage_id).maybeSingle();_(!!I),N(!!I)}}catch(k){console.error("Error fetching brokerage info:",k)}finally{o(!1)}})()},[t,s,r]),a?e.jsx(Es,{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(Es,{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(or,{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(K,{variant:"outline",onClick:()=>n("/brokerage-content"),children:[e.jsx(ch,{className:"h-4 w-4 mr-2"}),"Brokerage Content"]}),e.jsxs(K,{onClick:()=>n(`/mission-control/listings/new?brokerage=${l}`),children:[e.jsx(Sn,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]})]}),e.jsx(g1s,{brokerageId:l,canManage:y}),e.jsx(y1s,{brokerageId:l,canManage:y}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsx(_1s,{brokerageId:l}),e.jsx(b1s,{brokerageId:l})]})]})}):e.jsx(Es,{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 j1s(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 N1s(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 C7e={video:{icon:Co,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:yn,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:ln,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:Fl,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function k1s({item:t,canManage:s}){const[r,n]=S.useState(!1),[a,o]=S.useState(null),l=FLt(),i=vr(),d=C7e[t.content_type]||C7e.link,u=d.icon,p=S.useMemo(()=>t.thumbnail_url?t.thumbnail_url:t.content_type==="graphic"&&t.file_url?t.file_url:t.content_type==="video"?j1s(t.url):null,[t]);S.useEffect(()=>{p||!t.url||t.content_type!=="video"||!N1s(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(Re,{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:["📅 ",gs(new Date(t.event_date),"MMM d, yyyy · h:mm a")]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-2",children:["Added ",gs(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(K,{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(xr,{className:"h-4 w-4 mr-2"}),"Delete"]})})]})]})})]}),e.jsx(Dl,{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 S1s(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 M7e=[{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 C1s({brokerageId:t,categories:s}){var ge;const{user:r}=qs(),[n,a]=S.useState(!1),[o,l]=S.useState(!1),[i,d]=S.useState(""),[u,p]=S.useState("📁"),[f,y]=S.useState(!1);S.useRef(null);const[_,b]=S.useState("video"),[N,w]=S.useState(""),[k,C]=S.useState(""),[A,I]=S.useState(""),[L,O]=S.useState(""),[V,q]=S.useState(""),[B,U]=S.useState(""),[te,Y]=S.useState(""),J=OLt(),X=zLt(t),ce=BLt(),ae=$Lt(t),ie=()=>{b("video"),w(""),C(""),I(""),O(""),q(""),U(""),Y("")},oe=async(Ne,Ue)=>{var Me;const Te=(Me=Ne.target.files)==null?void 0:Me[0];if(Te){y(!0);try{const De=Te.name.split(".").pop(),qe=`${t}/${Date.now()}-${Math.random().toString(36).slice(2)}.${De}`,{error:ke}=await G.storage.from("brokerage-content").upload(qe,Te);if(ke)throw ke;const{data:{publicUrl:$e}}=G.storage.from("brokerage-content").getPublicUrl(qe);Ue==="file"?(O($e),_==="graphic"&&!V&&q($e)):q($e),pe.success("File uploaded")}catch(De){pe.error(De.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:k.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!"),ie(),a(!1)}catch(Ne){pe.error(Ne.message||"Failed to add content")}},ye=async()=>{if(i.trim())try{await X.mutateAsync({name:i.trim(),icon:u,sort_order:s.length}),d(""),p("📁"),pe.success("Category created")}catch(Ne){pe.error(Ne.message||"Failed to create category")}},he=async()=>{try{await ae.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(hi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Content"]})}),e.jsxs(hs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{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(Fs,{value:_,onValueChange:b,children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsx(Rs,{children:M7e.map(Ne=>e.jsx(vt,{value:Ne.value,children:Ne.label},Ne.value))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(ge=M7e.find(Ne=>Ne.value===_))==null?void 0:ge.hint})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Category"}),e.jsxs(Fs,{value:te,onValueChange:Y,children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select category (optional)"})}),e.jsx(Rs,{children:s.map(Ne=>e.jsxs(vt,{value:Ne.id,children:[Ne.icon," ",Ne.name]},Ne.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Title *"}),e.jsx(Le,{value:N,onChange:Ne=>w(Ne.target.value),placeholder:"Content title"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Description"}),e.jsx(gr,{value:k,onChange:Ne=>C(Ne.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(Le,{value:A,onChange:Ne=>{const Ue=Ne.target.value;if(I(Ue),_==="video"&&!V){const Te=S1s(Ue);Te&&q(Te)}},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(Le,{type:"file",accept:_==="pdf"?".pdf,.doc,.docx":"image/*",onChange:Ne=>oe(Ne,"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(Le,{type:"file",accept:"image/*",onChange:Ne=>oe(Ne,"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(jr,{className:"h-3 w-3"})})]})]}),_==="event"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{children:"Event Date & Time"}),e.jsx(Le,{type:"datetime-local",value:B,onChange:Ne=>U(Ne.target.value)})]}),e.jsxs(K,{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(Bs,{className:"h-4 w-4 mr-2"}),"Add Content"]})]})]})]}),e.jsxs(fs,{open:o,onOpenChange:l,children:[e.jsx(hi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",children:[e.jsx(So,{className:"h-4 w-4 mr-2"}),"Categories"]})}),e.jsxs(hs,{className:"max-w-md",children:[e.jsx(js,{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(K,{variant:"outline",size:"sm",onClick:he,disabled:ae.isPending,children:[ae.isPending?e.jsx(us,{className:"h-4 w-4 animate-spin mr-2"}):null,"Create Default Categories"]})]}),s.map(Ne=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg border",children:[e.jsxs("span",{className:"text-sm",children:[Ne.icon," ",Ne.name]}),!Ne.is_default&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:async()=>{await ce.mutateAsync(Ne.id),pe.success("Category deleted")},children:e.jsx(jr,{className:"h-4 w-4"})})]},Ne.id)),e.jsxs("div",{className:"flex gap-2 pt-2 border-t",children:[e.jsx(Le,{value:u,onChange:Ne=>p(Ne.target.value),className:"w-14 text-center",maxLength:2}),e.jsx(Le,{value:i,onChange:Ne=>d(Ne.target.value),placeholder:"New category name",className:"flex-1",onKeyDown:Ne=>Ne.key==="Enter"&&ye()}),e.jsx(K,{size:"sm",onClick:ye,disabled:!i.trim(),children:"Add"})]})]})]})]})]})}function M1s(){const{user:t,isAdmin:s,isBrokerageManager:r}=qs(),[n,a]=S.useState(!0),[o,l]=S.useState(null),[i,d]=S.useState(""),[u,p]=S.useState(!1),[f,y]=S.useState(null),[_,b]=S.useState("");S.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=[]}=LLt(o),{data:w=[],isLoading:k}=DLt(o,f),C=S.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(Es,{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(Es,{title:`${i} Content`,description:"Brokerage Content Hub",children:e.jsxs("div",{className:"space-y-6",children:[u&&o&&e.jsx(C1s,{brokerageId:o,categories:N}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search content...",value:_,onChange:A=>b(A.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(K,{variant:f===null?"default":"outline",size:"sm",onClick:()=>y(null),children:"All"}),N.map(A=>e.jsxs(K,{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))]})]}),k?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(Re,{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(k1s,{item:A,canManage:u},A.id))})]})}):e.jsx(Es,{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 T7e={video:{icon:Co,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:yn,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:ln,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:Fl,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function T1s(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 A1s(t){try{const s=new URL(t).hostname.replace("www.","");return["youtube.com","youtu.be","m.youtube.com"].includes(s)}catch{return!1}}function E1s(t){try{return new URL(t).hostname.includes("vimeo.com")}catch{return!1}}function P1s(t){try{const s=t.match(/vimeo\.com\/(\d+)/);if(s)return`https://player.vimeo.com/video/${s[1]}`}catch{}return null}function I1s(){const{contentId:t}=ao(),{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(Es,{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(Es,{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(K,{asChild:!0,className:"mt-4",children:e.jsx(da,{to:"/brokerage-content",children:"Back to Content"})})]})});const n=T7e[s.content_type]||T7e.link,a=n.icon,o=s.url||s.file_url,l=o&&A1s(o)?T1s(o):null,i=o&&E1s(o)?P1s(o):null,d=l||i;return e.jsx(Es,{title:s.title,children:e.jsxs("div",{className:"space-y-6 max-w-4xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(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 ",gs(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(Re,{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(Re,{className:"pt-6 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(ln,{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:gs(new Date(s.event_date),"EEEE, MMMM d, yyyy · h:mm a")})]})]})}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[s.file_url&&e.jsx(K,{asChild:!0,size:"lg",children:e.jsxs("a",{href:s.file_url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Qa,{className:"h-4 w-4 mr-2"}),s.content_type==="pdf"?"Download Document":"Download File"]})}),s.url&&e.jsx(K,{variant:s.file_url?"outline":"default",asChild:!0,size:"lg",children:e.jsxs("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Zr,{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 L1s(){const t=vr(),[s,r]=S.useState(""),[n,a]=S.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),k=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(Es,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search newsletters...",value:s,onChange:A=>r(A.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex gap-2",children:[s&&e.jsx(K,{variant:"outline",size:"sm",onClick:()=>r(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:n==="grid"?"secondary":"outline",size:"icon",onClick:()=>a("grid"),className:"rounded-full",children:e.jsx(fp,{className:"h-4 w-4"})}),e.jsx(K,{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:[(k==null?void 0:k.length)||0," item",(k==null?void 0:k.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(Re,{className:"p-0",children:[e.jsx(ks,{className:"aspect-[3/2] w-full"}),e.jsxs("div",{className:"p-4 space-y-2",children:[e.jsx(ks,{className:"h-5 w-3/4"}),e.jsx(ks,{className:"h-4 w-full"})]})]})},I))}),!l&&(k==null?void 0:k.length)===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(yn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("div",{className:"text-muted-foreground mb-4",children:s?"No newsletters match your search":"No newsletters available yet"}),s&&e.jsx(K,{variant:"outline",onClick:()=>r(""),children:"Clear Search"})]}),!l&&k&&k.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:k.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(yn,{className:"h-16 w-16"})})}),e.jsxs(Re,{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(ln,{className:"h-3 w-3"}),gs(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(Fl,{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(Ol,{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(yn,{className:"h-10 w-10"})})}),e.jsxs(Re,{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(ln,{className:"h-3 w-3"}),gs(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(Ol,{className:"h-3 w-3"})," ",f(A.id)]})]})]})]})},A.id)})})]})})}function D1s({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(Re,{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 R1s(){const{id:t}=ao(),s=vr(),{user:r}=qs(),{toast:n}=ja(),a=Qt(),{trackEngagement:o}=QA(),[l,i]=S.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});S.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)),k=Et({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=Et({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=Et({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(Es,{title:"",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ks,{className:"h-8 w-32"}),e.jsx(ks,{className:"h-64 w-full"}),e.jsx(ks,{className:"h-32 w-full"})]})}):d?e.jsx(Es,{title:"",description:"",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs(K,{variant:"ghost",onClick:()=>s("/newsletters"),className:"mb-4",children:[e.jsx(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:gs(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(D1s,{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(K,{variant:w?"default":"outline",size:"sm",onClick:()=>k.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(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"Canva Templates"})}),e.jsx(Re,{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(Fl,{className:"h-5 w-5 text-purple-500"}),e.jsx("span",{className:"font-medium",children:L.title}),e.jsx(Zr,{className:"h-4 w-4 text-muted-foreground ml-auto"})]},L.id))})]}),p&&p.length>0&&e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"Google Drive Files"})}),e.jsx(Re,{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(Zr,{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(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"PDF Downloads"})}),e.jsx(Re,{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(yn,{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(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"Videos"})}),e.jsx(Re,{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(Lt,{children:e.jsxs(Ft,{className:"text-lg",children:["Comments (",(N==null?void 0:N.length)||0,")"]})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(gr,{placeholder:"Write a comment...",value:l,onChange:L=>i(L.target.value),className:"flex-1"}),e.jsx(K,{onClick:()=>l.trim()&&C.mutate(l),disabled:!l.trim()||C.isPending,children:e.jsx(Mn,{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(wn,{className:"h-8 w-8",children:e.jsx(jn,{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:gs(new Date(L.created_at),"MMM d, yyyy")}),L.user_id===(r==null?void 0:r.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>A.mutate(L.id),children:e.jsx(xr,{className:"h-3 w-3"})})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:L.content})]})]},L.id)})})]})]})]})}):e.jsx(Es,{title:"Not Found",description:"",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground",children:"Newsletter not found"}),e.jsx(K,{variant:"link",onClick:()=>s("/newsletters"),children:"Back to Newsletters"})]})})}function O1s({rows:t,onChange:s}){const[r,n]=S.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:k}=G.storage.from("newsletter-content").getPublicUrl(N);l(u,p,"image_url",k.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(K,{type:"button",variant:"outline",size:"sm",onClick:a,children:[e.jsx(Bs,{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(K,{type:"button",variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-6 w-6 text-muted-foreground hover:text-destructive",onClick:()=>o(p),children:e.jsx(jr,{className:"h-4 w-4"})}),e.jsxs(Re,{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(K,{type:"button",variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>d(p,y),children:e.jsx(jr,{className:"h-3 w-3"})})]}):e.jsxs("div",{children:[e.jsx(Le,{type:"file",accept:"image/*",className:"hidden",id:`block-img-${_}`,onChange:b=>i(p,y,b)}),e.jsx(K,{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(Le,{placeholder:"Title",value:f.title,onChange:b=>l(p,y,"title",b.target.value),className:"h-8 text-sm"}),e.jsx(gr,{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 F1s(){const{toast:t}=ja(),s=Qt(),[r,n]=S.useState(!1),[a,o]=S.useState(null),[l,i]=S.useState({title:"",description:"",publish_date:gs(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),[d,u]=S.useState(null),[p,f]=S.useState(null),[y,_]=S.useState([]),[b,N]=S.useState([]),[w,k]=S.useState([]),[C,A]=S.useState([]),[I,L]=S.useState([]),[O,V]=S.useState([]),[q,B]=S.useState(!1),{data:U,isLoading:te}=gt({queryKey:["admin-newsletters"],queryFn:async()=>{const{data:Te,error:Me}=await G.from("newsletter_content").select("*").order("publish_date",{ascending:!1});if(Me)throw Me;return Te}}),Y=Et({mutationFn:async Te=>{const{data:Me,error:De}=await G.from("newsletter_content").insert({title:Te.title,description:Te.description||null,preview_image_url:Te.preview_image_url,publish_date:Te.publish_date,is_published:Te.is_published,content_blocks:Te.content_blocks}).select().single();if(De)throw De;return Me},onSuccess:async Te=>{await ce(Te.id),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter created successfully"}),Te.is_published&&TVt(Te.title,Te.id),oe()},onError:Te=>{t({title:"Error creating newsletter",description:Te.message,variant:"destructive"})}}),J=Et({mutationFn:async Te=>{const{error:Me}=await G.from("newsletter_content").update({title:Te.title,description:Te.description||null,preview_image_url:Te.preview_image_url,publish_date:Te.publish_date,is_published:Te.is_published,content_blocks:Te.content_blocks}).eq("id",Te.id);if(Me)throw Me;return Te.id},onSuccess:async Te=>{await ce(Te),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter updated successfully"}),oe()},onError:Te=>{t({title:"Error updating newsletter",description:Te.message,variant:"destructive"})}}),X=Et({mutationFn:async Te=>{const{error:Me}=await G.from("newsletter_content").delete().eq("id",Te);if(Me)throw Me},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter deleted successfully"})},onError:Te=>{t({title:"Error deleting newsletter",description:Te.message,variant:"destructive"})}}),ce=async Te=>{await G.from("newsletter_drive_links").delete().eq("newsletter_id",Te),await G.from("newsletter_pdfs").delete().eq("newsletter_id",Te),await G.from("newsletter_videos").delete().eq("newsletter_id",Te),await G.from("newsletter_canva_links").delete().eq("newsletter_id",Te);for(const Me of O){const De=`${Te}/${Date.now()}-${Me.file.name}`,{error:qe}=await G.storage.from("newsletter-content").upload(De,Me.file);if(!qe){const{data:ke}=G.storage.from("newsletter-content").getPublicUrl(De);b.push({name:Me.name,file_url:ke.publicUrl,file_size:Me.file.size,sort_order:b.length})}}y.length>0&&await G.from("newsletter_drive_links").insert(y.map((Me,De)=>({newsletter_id:Te,title:Me.title,drive_url:Me.drive_url,sort_order:De}))),b.length>0&&await G.from("newsletter_pdfs").insert(b.map((Me,De)=>({newsletter_id:Te,name:Me.name,file_url:Me.file_url,file_size:Me.file_size||null,sort_order:De}))),w.length>0&&await G.from("newsletter_videos").insert(w.map((Me,De)=>({newsletter_id:Te,title:Me.title,video_url:Me.video_url,sort_order:De}))),C.length>0&&await G.from("newsletter_canva_links").insert(C.map((Me,De)=>({newsletter_id:Te,title:Me.title,canva_share_link:Me.canva_share_link,sort_order:De})))},ae=async Te=>{o(Te),i({title:Te.title,description:Te.description||"",publish_date:gs(new Date(Te.publish_date),"yyyy-MM-dd'T'HH:mm"),is_published:Te.is_published}),f(Te.preview_image_url),L(Te.content_blocks||[]);const[Me,De,qe,ke]=await Promise.all([G.from("newsletter_drive_links").select("*").eq("newsletter_id",Te.id).order("sort_order"),G.from("newsletter_pdfs").select("*").eq("newsletter_id",Te.id).order("sort_order"),G.from("newsletter_videos").select("*").eq("newsletter_id",Te.id).order("sort_order"),G.from("newsletter_canva_links").select("*").eq("newsletter_id",Te.id).order("sort_order")]);_(Me.data||[]),N(De.data||[]),k(qe.data||[]),A(ke.data||[]),V([]),n(!0)},ie=async Te=>{const[Me,De,qe,ke]=await Promise.all([G.from("newsletter_drive_links").select("*").eq("newsletter_id",Te.id).order("sort_order"),G.from("newsletter_pdfs").select("*").eq("newsletter_id",Te.id).order("sort_order"),G.from("newsletter_videos").select("*").eq("newsletter_id",Te.id).order("sort_order"),G.from("newsletter_canva_links").select("*").eq("newsletter_id",Te.id).order("sort_order")]);o(null),i({title:`${Te.title} (Copy)`,description:Te.description||"",publish_date:gs(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),f(Te.preview_image_url),L(Te.content_blocks||[]),_((Me.data||[]).map(({id:$e,...Be})=>Be)),N((De.data||[]).map(({id:$e,...Be})=>Be)),k((qe.data||[]).map(({id:$e,...Be})=>Be)),A((ke.data||[]).map(({id:$e,...Be})=>Be)),V([]),n(!0)},oe=()=>{n(!1),o(null),i({title:"",description:"",publish_date:gs(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),u(null),f(null),_([]),N([]),k([]),A([]),L([]),V([])},me=async Te=>{var De;const Me=(De=Te.target.files)==null?void 0:De[0];Me&&(u(Me),f(URL.createObjectURL(Me)))},ye=async()=>{if(!l.title){t({title:"Title is required",variant:"destructive"});return}B(!0);let Te=p;if(d){const Me=`previews/${Date.now()}-${d.name}`,{error:De}=await G.storage.from("newsletter-content").upload(Me,d);if(!De){const{data:qe}=G.storage.from("newsletter-content").getPublicUrl(Me);Te=qe.publicUrl}}a?J.mutate({id:a.id,...l,preview_image_url:Te,content_blocks:I}):Y.mutate({...l,preview_image_url:Te,content_blocks:I}),B(!1)},he=()=>_([...y,{title:"",drive_url:"",sort_order:y.length}]),ge=()=>k([...w,{title:"",video_url:"",sort_order:w.length}]),Ne=()=>A([...C,{title:"",canva_share_link:"",sort_order:C.length}]),Ue=Te=>{const Me=Te.target.files;if(!Me)return;const De=Array.from(Me).map(qe=>({file:qe,name:qe.name.replace(/\.[^/.]+$/,"")}));V([...O,...De])};return e.jsx(Es,{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(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Total"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:(U==null?void 0:U.length)||0})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:(U==null?void 0:U.filter(Te=>Te.is_published).length)||0})})]})]}),e.jsxs(fs,{open:r,onOpenChange:Te=>!Te&&oe(),children:[e.jsx(hi,{asChild:!0,children:e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx(Bs,{className:"mr-2 h-4 w-4"})," Add Newsletter"]})}),e.jsxs(hs,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{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(Le,{value:l.title,onChange:Te=>i({...l,title:Te.target.value}),placeholder:"Newsletter title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Publish Date"}),e.jsx(Le,{type:"datetime-local",value:l.publish_date,onChange:Te=>i({...l,publish_date:Te.target.value})})]})]}),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:"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(K,{type:"button",variant:"destructive",size:"icon",className:"absolute -top-2 -right-2 h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{u(null),f(null)},children:e.jsx(jr,{className:"h-3 w-3"})})]}),e.jsxs("div",{children:[e.jsx(Le,{type:"file",accept:"image/*",onChange:me,className:"hidden",id:"preview-upload"}),e.jsx(K,{variant:"outline",asChild:!0,children:e.jsxs("label",{htmlFor:"preview-upload",className:"cursor-pointer",children:[e.jsx(Ra,{className:"mr-2 h-4 w-4"})," Upload Image"]})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mr,{checked:l.is_published,onCheckedChange:Te=>i({...l,is_published:Te})}),e.jsx(xe,{children:"Published"})]}),e.jsx(O1s,{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(K,{type:"button",variant:"outline",size:"sm",onClick:Ne,children:[e.jsx(Bs,{className:"mr-1 h-3 w-3"})," Add Canva Link"]})]}),C.map((Te,Me)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Le,{placeholder:"Link title",value:Te.title,onChange:De=>{const qe=[...C];qe[Me].title=De.target.value,A(qe)},className:"w-1/3"}),e.jsx(Le,{placeholder:"Canva share link",value:Te.canva_share_link,onChange:De=>{const qe=[...C];qe[Me].canva_share_link=De.target.value,A(qe)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>A(C.filter((De,qe)=>qe!==Me)),children:e.jsx(jr,{className:"h-4 w-4"})})]},Me))]}),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(K,{type:"button",variant:"outline",size:"sm",onClick:he,children:[e.jsx(Bs,{className:"mr-1 h-3 w-3"})," Add Link"]})]}),y.map((Te,Me)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Le,{placeholder:"Link title",value:Te.title,onChange:De=>{const qe=[...y];qe[Me].title=De.target.value,_(qe)},className:"w-1/3"}),e.jsx(Le,{placeholder:"Google Drive URL",value:Te.drive_url,onChange:De=>{const qe=[...y];qe[Me].drive_url=De.target.value,_(qe)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>_(y.filter((De,qe)=>qe!==Me)),children:e.jsx(jr,{className:"h-4 w-4"})})]},Me))]}),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(Le,{type:"file",accept:".pdf",multiple:!0,onChange:Ue,className:"hidden",id:"pdf-upload"}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("label",{htmlFor:"pdf-upload",className:"cursor-pointer",children:[e.jsx(Ra,{className:"mr-1 h-3 w-3"})," Upload PDF"]})})]})]}),b.map((Te,Me)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(yn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm",children:Te.name}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>N(b.filter((De,qe)=>qe!==Me)),children:e.jsx(jr,{className:"h-4 w-4"})})]},`existing-${Me}`)),O.map((Te,Me)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(yn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Le,{value:Te.name,onChange:De=>{const qe=[...O];qe[Me].name=De.target.value,V(qe)},className:"flex-1 h-8",placeholder:"PDF name"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"(new)"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>V(O.filter((De,qe)=>qe!==Me)),children:e.jsx(jr,{className:"h-4 w-4"})})]},`pending-${Me}`))]}),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(K,{type:"button",variant:"outline",size:"sm",onClick:ge,children:[e.jsx(Bs,{className:"mr-1 h-3 w-3"})," Add Video"]})]}),w.map((Te,Me)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Le,{placeholder:"Video title",value:Te.title,onChange:De=>{const qe=[...w];qe[Me].title=De.target.value,k(qe)},className:"w-1/3"}),e.jsx(Le,{placeholder:"Video URL",value:Te.video_url,onChange:De=>{const qe=[...w];qe[Me].video_url=De.target.value,k(qe)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>k(w.filter((De,qe)=>qe!==Me)),children:e.jsx(jr,{className:"h-4 w-4"})})]},Me))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(K,{variant:"outline",onClick:oe,children:"Cancel"}),e.jsx(K,{onClick:ye,disabled:q||Y.isPending||J.isPending,children:q?"Uploading...":a?"Update":"Create"})]})]})]})]})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ms,{children:[e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Publish Date"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:te?e.jsx(Ms,{children:e.jsx(ht,{colSpan:4,className:"text-center py-8",children:"Loading..."})}):(U==null?void 0:U.length)===0?e.jsx(Ms,{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(Te=>e.jsxs(Ms,{children:[e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Te.preview_image_url?e.jsx("img",{src:Te.preview_image_url,alt:Te.title,className:"w-10 h-10 rounded object-cover"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center",children:e.jsx(yn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Te.title}),Te.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Te.description.replace(/<[^>]*>/g,"")})]})]})}),e.jsx(ht,{children:gs(new Date(Te.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 ${Te.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:Te.is_published?"Published":"Draft"})}),e.jsx(ht,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ae(Te),title:"Edit",children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ie(Te),title:"Duplicate",children:e.jsx(Wa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",title:"Delete",onClick:()=>{confirm("Are you sure you want to delete this newsletter?")&&X.mutate(Te.id)},children:e.jsx(xr,{className:"h-4 w-4"})})]})})]},Te.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 z1s(){const{user:t}=qs(),{toast:s}=ja(),r=vr(),n=Qt(),[a,o]=S.useState(""),[l,i]=S.useState("popular"),[d,u]=S.useState(!1),[p,f]=S.useState(""),[y,_]=S.useState(""),[b,N]=S.useState(!1),{data:w=[],isLoading:k}=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(ae=>ae.user_id))||[])],{data:U}=await G.from("profiles").select("id, name").in("id",B),te=new Map((U==null?void 0:U.map(ae=>[ae.id,ae]))||[]);let Y=[];if(t){const{data:ae}=await G.from("wishlist_votes").select("item_id").eq("user_id",t.id);Y=(ae==null?void 0:ae.map(ie=>ie.item_id))||[]}const J=(V==null?void 0:V.map(ae=>ae.id))||[],{data:X}=await G.from("wishlist_comments").select("item_id").in("item_id",J),ce=new Map;return X==null||X.forEach(ae=>{ce.set(ae.item_id,(ce.get(ae.item_id)||0)+1)}),V==null?void 0:V.map(ae=>{const ie=te.get(ae.user_id),oe=(ie==null?void 0:ie.name)||"Unknown";return{...ae,user_name:oe,user_initials:oe.split(" ").map(me=>me[0]).join("").toUpperCase().slice(0,2),has_voted:Y.includes(ae.id),comment_count:ce.get(ae.id)||0}})}}),C=Et({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=Et({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(Es,{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(hi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Bs,{className:"h-4 w-4"}),"Add Idea"]})}),e.jsxs(hs,{children:[e.jsx(js,{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(Le,{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(gr,{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(K,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search ideas...",value:a,onChange:O=>o(O.target.value),className:"pl-10"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(ta,{value:l,onValueChange:O=>i(O),children:e.jsxs(Jn,{children:[e.jsx(ls,{value:"popular",children:"Most Popular"}),e.jsx(ls,{value:"latest",children:"Latest"}),e.jsx(ls,{value:"trending",children:"Trending"})]})})})]}),e.jsx("div",{className:"flex items-center gap-2 mb-4",children:e.jsx(K,{variant:b?"default":"outline",size:"sm",onClick:()=>N(!b),children:b?"Show All Ideas":"My Ideas"})}),k?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(K,{onClick:()=>u(!0),children:[e.jsx(Bs,{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:Dt("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:Dt("h-4 w-4",O.has_voted&&"fill-current")}),e.jsx("span",{className:"text-sm font-semibold",children:O.vote_count})]}),e.jsx(wn,{className:"h-10 w-10 bg-primary/20",children:e.jsx(jn,{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:Dt("text-xs",A7e[O.status].color),children:A7e[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(Si,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:O.comment_count})]})]})},O.id))})]})})}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"}};function B1s(){const{itemId:t}=ao(),s=vr(),{user:r}=qs(),{toast:n}=ja(),a=Qt(),[o,l]=S.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:k}=await G.from("user_roles").select("role").eq("user_id",r.id).eq("role","admin").maybeSingle();return!k&&!!w},enabled:!!r}),{data:d,isLoading:u}=gt({queryKey:["wishlist-item",t],queryFn:async()=>{const{data:w,error:k}=await G.from("wishlist_items").select("*").eq("id",t).single();if(k)throw k;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:k}=await G.from("wishlist_comments").select("*").eq("item_id",t).order("created_at",{ascending:!0});if(k)throw k;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=Et({mutationFn:async w=>{if(w){const{error:k}=await G.from("wishlist_votes").delete().eq("item_id",t).eq("user_id",r.id);if(k)throw k;return{wasAdded:!1}}else{const{error:k}=await G.from("wishlist_votes").insert({item_id:t,user_id:r.id});if(k)throw k;return{wasAdded:!0}}},onSuccess:async w=>{if(a.invalidateQueries({queryKey:["wishlist-item",t]}),a.invalidateQueries({queryKey:["wishlist-items"]}),w!=null&&w.wasAdded&&d){const k=(d.vote_count||0)+1;G.functions.invoke("wishlist-notify",{body:{itemId:t,voteCount:k}}).catch(console.error)}},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),_=Et({mutationFn:async w=>{const{error:k}=await G.from("wishlist_comments").insert({item_id:t,user_id:r.id,content:w});if(k)throw k},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),l(""),n({title:"Comment added!"})},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),b=Et({mutationFn:async w=>{const{error:k}=await G.from("wishlist_comments").delete().eq("id",w);if(k)throw k},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(Es,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx(ks,{className:"h-8 w-32 mb-6"}),e.jsx(ks,{className:"h-48 w-full mb-6"}),e.jsx(ks,{className:"h-32 w-full"})]})}):d?e.jsx(Es,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>s("/wishlist"),className:"mb-4",children:[e.jsx(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:Dt("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:Dt("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:Dt("text-xs",E7e[d.status].color),children:E7e[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(wn,{className:"h-6 w-6",children:e.jsx(jn,{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(pce,{placeholder:i?"Share your thoughts... Use # to link templates":"Share your thoughts on this idea...",value:o,onChange:l,minHeight:"60px",mentionFormat:"encoded",enableTemplateMentions:i}),e.jsx(K,{onClick:N,disabled:!o.trim()||_.isPending,size:"icon",className:"h-auto",children:_.isPending?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(Mn,{className:"h-4 w-4"})})]}),f?e.jsx("div",{className:"space-y-4",children:[1,2].map(w=>e.jsx(ks,{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(wn,{className:"h-8 w-8",children:e.jsx(jn,{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(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>b.mutate(w.id),children:e.jsx(xr,{className:"h-4 w-4"})})]},w.id))})]})]})}):e.jsx(Es,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground",children:"Item not found"}),e.jsx(K,{variant:"link",onClick:()=>s("/wishlist"),children:"Go back to Wishlist"})]})})}const P7e={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"}},I7e=["open","under_review","planned","in_progress","launched","declined"];function $1s(){const{toast:t}=ja(),s=vr(),r=Qt(),[n,a]=S.useState(""),[o,l]=S.useState("all"),[i,d]=S.useState(!1),[u,p]=S.useState(null),{data:f=[],isLoading:y}=gt({queryKey:["admin-wishlist-items"],queryFn:async()=>{const{data:k,error:C}=await G.from("wishlist_items").select("*").order("vote_count",{ascending:!1});if(C)throw C;const A=[...new Set((k==null?void 0:k.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=(k==null?void 0:k.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)}),k==null?void 0:k.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}})}}),_=Et({mutationFn:async({itemId:k,status:C})=>{const{error:A}=await G.from("wishlist_items").update({status:C}).eq("id",k);if(A)throw A},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),t({title:"Status updated!"})},onError:k=>{t({title:"Error",description:k.message,variant:"destructive"})}}),b=Et({mutationFn:async k=>{const{error:C}=await G.from("wishlist_items").delete().eq("id",k);if(C)throw C},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),d(!1),p(null),t({title:"Item deleted!"})},onError:k=>{t({title:"Error",description:k.message,variant:"destructive"})}}),N=f.filter(k=>{const C=k.title.toLowerCase().includes(n.toLowerCase())||k.description.toLowerCase().includes(n.toLowerCase())||k.user_name.toLowerCase().includes(n.toLowerCase()),A=o==="all"||k.status===o;return C&&A}),w={total:f.length,open:f.filter(k=>k.status==="open").length,inProgress:f.filter(k=>k.status==="in_progress").length,launched:f.filter(k=>k.status==="launched").length,highVotes:f.filter(k=>k.vote_count>=10).length};return e.jsx(Es,{title:"Admin - Wishlist",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s("/admin"),children:e.jsx(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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search ideas, users...",value:n,onChange:k=>a(k.target.value),className:"pl-10"})]}),e.jsxs(Fs,{value:o,onValueChange:k=>l(k),children:[e.jsx(Ds,{className:"w-[180px]",children:e.jsx(zs,{placeholder:"Filter by status"})}),e.jsxs(Rs,{children:[e.jsx(vt,{value:"all",children:"All Statuses"}),I7e.map(k=>e.jsx(vt,{value:k,children:P7e[k].label},k))]})]})]}),y?e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(k=>e.jsx(ks,{className:"h-16 w-full"},k))}):e.jsx("div",{className:"bg-card border rounded-lg overflow-hidden",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ms,{children:[e.jsx(kt,{className:"w-[60px]",children:"Votes"}),e.jsx(kt,{children:"Title"}),e.jsx(kt,{className:"hidden md:table-cell",children:"Submitted By"}),e.jsx(kt,{className:"hidden sm:table-cell",children:"Comments"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Rn,{children:N.length===0?e.jsx(Ms,{children:e.jsx(ht,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No items found"})}):N.map(k=>e.jsxs(Ms,{className:Dt(k.vote_count>=10&&"bg-primary/5"),children:[e.jsx(ht,{children:e.jsx(Qe,{variant:k.vote_count>=10?"default":"secondary",children:k.vote_count})}),e.jsx(ht,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium line-clamp-1",children:k.title}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:k.description})]})}),e.jsx(ht,{className:"hidden md:table-cell",children:e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",children:k.user_name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:k.user_email})]})}),e.jsx(ht,{className:"hidden sm:table-cell",children:k.comment_count}),e.jsx(ht,{children:e.jsxs(Fs,{value:k.status,onValueChange:C=>_.mutate({itemId:k.id,status:C}),children:[e.jsx(Ds,{className:"w-[140px] h-8",children:e.jsx(zs,{})}),e.jsx(Rs,{children:I7e.map(C=>e.jsx(vt,{value:C,children:P7e[C].label},C))})]})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>window.open(`/wishlist/${k.id}`,"_blank"),children:e.jsx(Zr,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{p(k.id),d(!0)},children:e.jsx(xr,{className:"h-4 w-4"})})]})})]},k.id))})]})}),e.jsx(fs,{open:i,onOpenChange:d,children:e.jsxs(hs,{children:[e.jsx(js,{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(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(K,{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 q1s(){const{user:t}=qs(),[s,r]=S.useState([]),[n,a]=S.useState(!0),[o,l]=S.useState(!1),[i,d]=S.useState(null),[u,p]=S.useState(!1),[f,y]=S.useState(null),[_,b]=S.useState(""),[N,w]=S.useState(""),[k,C]=S.useState(""),[A,I]=S.useState(""),[L,O]=S.useState(""),[V,q]=S.useState(!1),[B,U]=S.useState(""),[te,Y]=S.useState("once"),[J,X]=S.useState([]),[ce,ae]=S.useState([]),[ie,oe]=S.useState(!1),[me,ye]=S.useState(!1),[he,ge]=S.useState([]),[Ne,Ue]=S.useState({total:0,dismissed:0});S.useEffect(()=>{Te()},[]);const Te=async()=>{const{data:Xe,error:dt}=await G.from("levelup_briefs").select("*").order("created_at",{ascending:!1});dt?(pe.error("Failed to fetch briefs"),console.error(dt)):r(Xe||[]),a(!1)},Me=()=>{b(""),w(""),C(""),I(""),O(""),q(!1),U(new Date().toISOString().slice(0,16)),Y("once"),X([]),ae([]),d(null)},De=()=>{Me(),l(!0)},qe=async Xe=>{d(Xe),b(Xe.title),w(Xe.description||""),C(Xe.video_url||""),I(Xe.graphic_url||""),O(Xe.graphic_link_url||""),q(Xe.is_published),U(Xe.publish_date.slice(0,16)),Y(Xe.show_frequency);const{data:dt}=await G.from("levelup_brief_links").select("*").eq("brief_id",Xe.id).order("sort_order");X((dt==null?void 0:dt.map(Je=>({title:Je.title,url:Je.url})))||[]);const{data:pt}=await G.from("levelup_brief_polls").select("*").eq("brief_id",Xe.id).order("sort_order");if(pt){const Je=[];for(const Ze of pt){const{data:Nt}=await G.from("levelup_brief_poll_options").select("*").eq("poll_id",Ze.id).order("sort_order");Je.push({question:Ze.question,poll_type:Ze.poll_type,options:(Nt==null?void 0:Nt.map(Ot=>Ot.option_text))||[]})}ae(Je)}l(!0)},ke=async Xe=>{var pt;const dt=(pt=Xe.target.files)==null?void 0:pt[0];if(dt){oe(!0);try{const Je=await G.functions.invoke("bunny-upload",{body:{action:"create",title:dt.name.replace(/\.[^/.]+$/,"")}});if(Je.error)throw Je.error;const{videoId:Ze,libraryId:Nt}=Je.data,Ot=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Ze}});if(Ot.error)throw Ot.error;const{uploadUrl:Yt,apiKey:Ps}=Ot.data,$s=new XMLHttpRequest;await new Promise((Dr,$t)=>{$s.upload.addEventListener("progress",Us=>{if(Us.lengthComputable){const Nr=Math.round(Us.loaded/Us.total*100);console.log("Upload progress:",Nr)}}),$s.addEventListener("load",()=>{$s.status>=200&&$s.status<300?Dr():$t(new Error(`Upload failed with status ${$s.status}`))}),$s.addEventListener("error",()=>$t(new Error("Upload failed"))),$s.open("PUT",Yt),$s.setRequestHeader("AccessKey",Ps),$s.send(dt)});const Zs=`https://player.mediadelivery.net/embed/${Nt}/${Ze}`;C(Zs),pe.success("Video uploaded successfully! It may take a few minutes to process.")}catch(Je){console.error("Upload error:",Je),pe.error("Failed to upload video")}finally{oe(!1)}}},$e=async()=>{if(!_.trim()){pe.error("Title is required");return}try{let Xe;if(i){const{error:dt}=await G.from("levelup_briefs").update({title:_,description:N||null,video_url:k||null,graphic_url:A||null,graphic_link_url:L||null,is_published:V,publish_date:B,show_frequency:te}).eq("id",i.id);if(dt)throw dt;Xe=i.id,await G.from("levelup_brief_links").delete().eq("brief_id",Xe);const{data:pt}=await G.from("levelup_brief_polls").select("id").eq("brief_id",Xe);if(pt)for(const Je of pt)await G.from("levelup_brief_poll_options").delete().eq("poll_id",Je.id);await G.from("levelup_brief_polls").delete().eq("brief_id",Xe)}else{const{data:dt,error:pt}=await G.from("levelup_briefs").insert({title:_,description:N||null,video_url:k||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(pt)throw pt;Xe=dt.id}if(J.length>0){const dt=J.map((pt,Je)=>({brief_id:Xe,title:pt.title,url:pt.url,sort_order:Je}));await G.from("levelup_brief_links").insert(dt)}for(let dt=0;dt0){const Nt=pt.options.map((Ot,Yt)=>({poll_id:Je.id,option_text:Ot,sort_order:Yt}));await G.from("levelup_brief_poll_options").insert(Nt)}}pe.success(i?"Brief updated":"Brief created"),l(!1),Me(),Te()}catch(Xe){console.error("Error saving brief:",Xe),pe.error("Failed to save brief")}},Be=async Xe=>{if(confirm("Are you sure you want to delete this brief?"))try{const{error:dt}=await G.from("levelup_briefs").delete().eq("id",Xe);if(dt)throw dt;pe.success("Brief deleted"),Te()}catch(dt){console.error("Error deleting brief:",dt),pe.error("Failed to delete brief")}},we=async Xe=>{y(Xe);const{count:dt}=await G.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",Xe.id),{count:pt}=await G.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",Xe.id).not("dismissed_at","is",null);Ue({total:dt||0,dismissed:pt||0});const{data:Je}=await G.from("levelup_brief_polls").select("*").eq("brief_id",Xe.id).order("sort_order");if(Je){const Ze=[];for(const Nt of Je){const{data:Ot}=await G.from("levelup_brief_poll_options").select("*").eq("poll_id",Nt.id).order("sort_order"),{data:Yt}=await G.from("levelup_brief_poll_responses").select("option_id, user_id").eq("poll_id",Nt.id),Ps=[...new Set((Yt==null?void 0:Yt.map(Us=>Us.user_id))||[])];let $s={};if(Ps.length>0){const{data:Us}=await G.from("profiles").select("id, name, email").in("id",Ps);Us&&Us.forEach(Nr=>{$s[Nr.id]=Nr.name||Nr.email||"Unknown"})}const Zs=(Yt||[]).map(Us=>({optionId:Us.option_id,userName:$s[Us.user_id]||"Unknown",userId:Us.user_id})),Dr={};let $t=0;Ot&&Ot.forEach(Us=>{const Nr=(Yt==null?void 0:Yt.filter(Xs=>Xs.option_id===Us.id).length)||0;Dr[Us.id]=Nr,$t+=Nr}),Ze.push({...Nt,options:Ot||[],results:Dr,respondents:Zs,totalResponses:Nt.poll_type==="single"?new Set(Yt==null?void 0:Yt.map(Us=>Us.user_id)).size:$t})}ge(Ze)}p(!0)},ut=()=>{X([...J,{title:"",url:""}])},fe=(Xe,dt,pt)=>{const Je=[...J];Je[Xe][dt]=pt,X(Je)},He=Xe=>{X(J.filter((dt,pt)=>pt!==Xe))},et=()=>{ae([...ce,{question:"",poll_type:"single",options:["",""]}])},tt=(Xe,dt)=>{const pt=[...ce];pt[Xe].question=dt,ae(pt)},_e=(Xe,dt)=>{const pt=[...ce];pt[Xe].poll_type=dt,ae(pt)},Ge=Xe=>{const dt=[...ce];dt[Xe].options.push(""),ae(dt)},We=(Xe,dt,pt)=>{const Je=[...ce];Je[Xe].options[dt]=pt,ae(Je)},it=(Xe,dt)=>{const pt=[...ce];pt[Xe].options=pt[Xe].options.filter((Je,Ze)=>Ze!==dt),ae(pt)},Ve=Xe=>{ae(ce.filter((dt,pt)=>pt!==Xe))};return e.jsxs(Es,{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(K,{onClick:De,children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Create Brief"]})}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ms,{children:[e.jsx(kt,{children:"Title"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{children:"Frequency"}),e.jsx(kt,{children:"Publish Date"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:n?e.jsx(Ms,{children:e.jsx(ht,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):s.length===0?e.jsx(Ms,{children:e.jsx(ht,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No briefs created yet"})}):s.map(Xe=>e.jsxs(Ms,{children:[e.jsx(ht,{className:"font-medium",children:Xe.title}),e.jsx(ht,{children:e.jsx(Qe,{variant:Xe.is_published?"default":"secondary",children:Xe.is_published?"Published":"Draft"})}),e.jsx(ht,{className:"capitalize",children:Xe.show_frequency.replace("_"," ")}),e.jsx(ht,{children:gs(new Date(Xe.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(K,{variant:"ghost",size:"icon",onClick:()=>we(Xe),children:e.jsx(so,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>qe(Xe),children:e.jsx(Wc,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Be(Xe.id),children:e.jsx(xr,{className:"h-4 w-4 text-destructive"})})]})})]},Xe.id))})]})})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(hs,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{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(ls,{value:"content",children:"Content"}),e.jsx(ls,{value:"media",children:"Media"}),e.jsx(ls,{value:"links",children:"Links"}),e.jsx(ls,{value:"polls",children:"Polls"})]}),e.jsxs(ws,{value:"content",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Title *"}),e.jsx(Le,{value:_,onChange:Xe=>b(Xe.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:Xe=>w(Xe),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(Le,{type:"datetime-local",value:B,onChange:Xe=>U(Xe.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Show Frequency"}),e.jsxs(Fs,{value:te,onValueChange:Y,children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Mr,{checked:V,onCheckedChange:q}),e.jsx(xe,{children:"Publish immediately"})]})]}),e.jsxs(ws,{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(Le,{type:"file",accept:"video/*",onChange:ke,disabled:ie})}),ie&&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(Le,{value:k,onChange:Xe=>C(Xe.target.value),placeholder:"https://iframe.mediadelivery.net/embed/..."})]}),k&&e.jsx("div",{className:"aspect-video rounded-lg overflow-hidden bg-muted",children:e.jsx("iframe",{src:k,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(Le,{type:"file",accept:"image/*",onChange:async Xe=>{var pt;const dt=(pt=Xe.target.files)==null?void 0:pt[0];if(dt){ye(!0);try{const Je=dt.name.split(".").pop(),Ze=`brief-graphics/${Date.now()}.${Je}`,{error:Nt}=await G.storage.from("banner-images").upload(Ze,dt,{upsert:!0});if(Nt)throw Nt;const{data:Ot}=G.storage.from("banner-images").getPublicUrl(Ze);I(Ot.publicUrl),pe.success("Image uploaded!")}catch(Je){console.error(Je),pe.error("Failed to upload image")}finally{ye(!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(Le,{value:A,onChange:Xe=>I(Xe.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(Le,{value:L,onChange:Xe=>O(Xe.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(ws,{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(K,{variant:"outline",size:"sm",onClick:ut,children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),J.map((Xe,dt)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsx(Le,{value:Xe.title,onChange:pt=>fe(dt,"title",pt.target.value),placeholder:"Link title",className:"flex-1"}),e.jsx(Le,{value:Xe.url,onChange:pt=>fe(dt,"url",pt.target.value),placeholder:"https://...",className:"flex-[2]"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>He(dt),children:e.jsx(xr,{className:"h-4 w-4 text-destructive"})})]},dt)),J.length===0&&e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No links added yet"})]}),e.jsxs(ws,{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(K,{variant:"outline",size:"sm",onClick:et,children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Add Poll"]})]}),ce.map((Xe,dt)=>e.jsx(Pe,{className:"p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(Le,{value:Xe.question,onChange:pt=>tt(dt,pt.target.value),placeholder:"Poll question...",className:"flex-1 mr-2"}),e.jsxs(Fs,{value:Xe.poll_type,onValueChange:pt=>_e(dt,pt),children:[e.jsx(Ds,{className:"w-32",children:e.jsx(zs,{})}),e.jsxs(Rs,{children:[e.jsx(vt,{value:"single",children:"Single"}),e.jsx(vt,{value:"multi",children:"Multi-select"})]})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ve(dt),children:e.jsx(xr,{className:"h-4 w-4 text-destructive"})})]}),e.jsxs("div",{className:"space-y-2 pl-4",children:[Xe.options.map((pt,Je)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{value:pt,onChange:Ze=>We(dt,Je,Ze.target.value),placeholder:`Option ${Je+1}`}),Xe.options.length>2&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>it(dt,Je),children:e.jsx(xr,{className:"h-4 w-4 text-muted-foreground"})})]},Je)),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>Ge(dt),children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Add Option"]})]})]})},dt)),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(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:$e,children:i?"Update Brief":"Create Brief"})]})]})}),e.jsx(fs,{open:u,onOpenChange:p,children:e.jsxs(hs,{className:"max-w-2xl",children:[e.jsx(js,{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(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Total Views"})}),e.jsx(Re,{children:e.jsx("p",{className:"text-2xl font-bold",children:Ne.total})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Dismissed"})}),e.jsx(Re,{children:e.jsx("p",{className:"text-2xl font-bold",children:Ne.dismissed})})]})]}),he.length>0?e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-semibold",children:"Poll Results"}),he.map(Xe=>e.jsxs(Pe,{className:"p-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:Xe.question}),e.jsx("div",{className:"space-y-2",children:Xe.options.map(dt=>{const pt=Xe.results[dt.id]||0,Je=Xe.totalResponses>0?Math.round(pt/Xe.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:dt.option_text}),e.jsxs("span",{className:"text-muted-foreground",children:[pt," (",Je,"%)"]})]}),e.jsx("div",{className:"h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${Je}%`}})}),pt>0&&e.jsx("div",{className:"flex flex-wrap gap-1 pt-1",children:(Xe.respondents||[]).filter(Ze=>Ze.optionId===dt.id).map((Ze,Nt)=>e.jsx(Qe,{variant:"secondary",className:"text-xs font-normal",children:Ze.userName},Nt))})]},dt.id)})})]},Xe.id))]}):e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No polls in this brief"})]})]})})]})}const U1s=()=>{const{user:t}=qs(),{toast:s}=ja(),r=Qt(),[n,a]=S.useState(!1),[o,l]=S.useState(null),[i,d]=S.useState({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,p]=S.useState(null),[f,y]=S.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=Et({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),k()},onError:L=>{s({title:"Error saving service",description:L.message,variant:"destructive"})}}),w=Et({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"})}}),k=()=>{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(Es,{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(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Total Services"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.length})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Re,{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||k()},children:[e.jsx(hi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Bs,{className:"h-4 w-4"}),"Add Service"]})}),e.jsxs(hs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{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(Le,{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(Le,{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(Le,{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(Mr,{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(K,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{p(null),y("")},children:e.jsx(jr,{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(Le,{type:"file",accept:"image/*",onChange:A,className:"cursor-pointer"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:N.isPending,children:N.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(Pe,{children:e.jsx(Re,{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(Ms,{children:[e.jsx(kt,{className:"w-16",children:"Preview"}),e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Signup Link"}),e.jsx(kt,{children:"Publish Date"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:_.map(L=>e.jsxs(Ms,{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(Zr,{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(K,{variant:"ghost",size:"icon",onClick:()=>C(L),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this service?")&&w.mutate(L.id)},children:e.jsx(xr,{className:"h-4 w-4 text-destructive"})})]})})]},L.id))})]})})})]})})};function V1s(){const{toast:t}=ja(),[s,r]=S.useState([]),[n,a]=S.useState(!0),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""});S.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:w,error:k}=await G.functions.invoke("stripe-manage-coupons",{body:{action:"list"}});if(k)throw k;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:k,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:k}=await G.functions.invoke("stripe-manage-coupons",{body:{action:"delete",couponId:w}});if(k)throw k;t({title:"Success",description:"Coupon deleted successfully"}),f()}catch(k){console.error("Error deleting coupon:",k),t({title:"Error",description:k.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(Es,{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(hi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Bs,{className:"mr-2 h-4 w-4"}),"Create Coupon"]})}),e.jsxs(hs,{children:[e.jsxs(js,{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(Le,{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(Le,{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(Fs,{value:u.discountType,onValueChange:w=>{const k=w==="amount"&&u.duration==="forever"?"once":u.duration;p({...u,discountType:w,duration:k})},children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Le,{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(Le,{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(Fs,{value:u.duration,onValueChange:w=>p({...u,duration:w}),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Le,{type:"number",min:"1",placeholder:"3",value:u.durationInMonths,onChange:w=>p({...u,durationInMonths:w.target.value})})]}),e.jsx(K,{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(Lt,{children:[e.jsx(Ft,{children:"Active Coupons"}),e.jsx(ur,{children:"Share coupon codes with users to give them discounts on subscriptions"})]}),e.jsx(Re,{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(Ms,{children:[e.jsx(kt,{children:"Promo Code"}),e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Discount"}),e.jsx(kt,{children:"Duration"}),e.jsx(kt,{children:"Redemptions"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:s.map(w=>{var k;return e.jsxs(Ms,{children:[e.jsx(ht,{className:"font-mono font-medium",children:((k=w.promotion_codes)==null?void 0:k.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(K,{variant:"ghost",size:"sm",onClick:()=>_(w.id),children:e.jsx(xr,{className:"h-4 w-4 text-destructive"})})})]},w.id)})})]})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"How to Use Coupons"})}),e.jsxs(Re,{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 i0e={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 H1s(){const[t,s]=S.useState(""),[r,n]=S.useState("all"),[a,o]=S.useState("all"),[l,i]=S.useState(null),{data:d,isLoading:u,refetch:p}=gt({queryKey:["admin-subscriptions"],queryFn:async()=>{const{data:k,error:C}=await G.from("profiles").select(` *, brokerages:brokerage_id (id, name) `).order("created_at",{ascending:!1});if(C)throw C;return k}}),{data:f}=gt({queryKey:["admin-brokerages-subscriptions"],queryFn:async()=>{const{data:k,error:C}=await G.from("brokerages").select("*").order("name");if(C)throw C;return await Promise.all((k||[]).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:k,error:C}=await G.from("local_move_subscriptions").select("*").order("created_at",{ascending:!1});if(C)throw C;return k}}),_=k=>{if(k.is_grandfathered)return{status:"Grandfathered",badge:"Legacy",variant:"secondary"};if(k.brokerage_id&&!k.subscription_product_id)return{status:"Brokerage",badge:"Team Member",variant:"outline"};if(k.is_trial&&k.trial_expires_at)return new Date(k.trial_expires_at)>new Date?{status:"Trial",badge:"Active Trial",variant:"default"}:{status:"Trial Expired",badge:"Expired",variant:"destructive"};if(k.subscription_status==="active"||k.subscription_status==="trialing"){const C=i0e[k.subscription_product_id];return{status:(C==null?void 0:C.name)||"Active",badge:k.subscription_status==="trialing"?"Trial":"Active",variant:"default"}}return k.subscription_status==="canceled"||k.subscription_status==="past_due"?{status:"Canceled",badge:"Inactive",variant:"destructive"}:{status:"None",badge:"No Subscription",variant:"outline"}},b=d==null?void 0:d.filter(k=>{var A,I;if(!(((A=k.name)==null?void 0:A.toLowerCase().includes(t.toLowerCase()))||((I=k.email)==null?void 0:I.toLowerCase().includes(t.toLowerCase()))))return!1;if(a!=="all"){const L=k.subscription_source||"platform";if(a==="platform"&&L==="local_move_website"||a==="local_move_website"&&L!=="local_move_website")return!1}switch(_(k),r){case"active":return k.subscription_status==="active";case"trialing":return k.subscription_status==="trialing"||k.is_trial&&new Date(k.trial_expires_at)>new Date;case"grandfathered":return k.is_grandfathered;case"brokerage":return k.brokerage_id&&!k.subscription_product_id&&!k.is_grandfathered;case"expired":return k.subscription_status==="canceled"||k.subscription_status==="past_due"||k.is_trial&&new Date(k.trial_expires_at)<=new Date;case"none":return!k.subscription_status||k.subscription_status==="none";default:return!0}}),N={totalUsers:(d==null?void 0:d.length)||0,activeSubscriptions:(d==null?void 0:d.filter(k=>k.subscription_status==="active").length)||0,trials:(d==null?void 0:d.filter(k=>k.subscription_status==="trialing"||k.is_trial&&new Date(k.trial_expires_at)>new Date).length)||0,grandfathered:(d==null?void 0:d.filter(k=>k.is_grandfathered).length)||0,brokerageMembers:(d==null?void 0:d.filter(k=>k.brokerage_id&&!k.subscription_product_id&&!k.is_grandfathered).length)||0,individualSubscribers:(d==null?void 0:d.filter(k=>k.subscription_status==="active"&&k.subscription_product_id==="prod_Tc07cYplXUGNkm").length)||0,brokerageSubscribers:(d==null?void 0:d.filter(k=>k.subscription_status==="active"&&(k.subscription_product_id==="prod_Tc08MupgoVySDG"||k.subscription_product_id==="prod_Tc09N1tJ4RrAFn")).length)||0},w=k=>{window.open(`https://dashboard.stripe.com/customers/${k}`,"_blank")};return e.jsx(Es,{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(K,{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(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(or,{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(Re,{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(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(on,{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(Re,{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(Re,{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(Re,{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(Re,{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(ls,{value:"users",children:"All Users"}),e.jsx(ls,{value:"brokerages",children:"Brokerages"}),e.jsxs(ls,{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(ws,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name or email...",value:t,onChange:k=>s(k.target.value),className:"pl-9"})]}),e.jsxs(Fs,{value:a,onValueChange:k=>o(k),children:[e.jsx(Ds,{className:"w-[200px]",children:e.jsx(zs,{placeholder:"Source"})}),e.jsxs(Rs,{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(Fs,{value:r,onValueChange:k=>n(k),children:[e.jsx(Ds,{className:"w-[200px]",children:e.jsx(zs,{placeholder:"Filter by status"})}),e.jsxs(Rs,{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(Re,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ms,{children:[e.jsx(kt,{children:"User"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{children:"Plan"}),e.jsx(kt,{children:"Brokerage"}),e.jsx(kt,{children:"End Date"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:u?e.jsx(Ms,{children:e.jsx(ht,{colSpan:6,className:"text-center py-8",children:"Loading subscriptions..."})}):(b==null?void 0:b.length)===0?e.jsx(Ms,{children:e.jsx(ht,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No users found"})}):b==null?void 0:b.map(k=>{var I,L;const C=_(k),A=i0e[k.subscription_product_id];return e.jsxs(Ms,{children:[e.jsx(ht,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:k.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:k.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:k.is_grandfathered?"Legacy Access":k.brokerage_id&&!k.subscription_product_id?"Brokerage Subscription":(A==null?void 0:A.name)||C.status})}),e.jsx(ht,{children:(I=k.brokerages)!=null&&I.name?e.jsx("span",{className:"text-sm",children:k.brokerages.name}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(ht,{children:k.subscription_end_date?e.jsx("span",{className:"text-sm",children:gs(new Date(k.subscription_end_date),"MMM d, yyyy")}):k.trial_expires_at?e.jsxs("span",{className:"text-sm text-blue-600",children:["Trial: ",gs(new Date(k.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:[k.stripe_customer_id&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>w(k.stripe_customer_id),children:e.jsx(Zr,{className:"h-4 w-4"})}),e.jsxs(fs,{children:[e.jsx(hi,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",onClick:()=>i(k),children:"Details"})}),e.jsxs(hs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Subscription Details"}),e.jsxs(Ir,{children:[k.name," (",k.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:k.is_grandfathered?"Grandfathered (Legacy)":k.brokerage_id&&!k.subscription_product_id?"Brokerage Subscription":(A==null?void 0:A.name)||"None"})]}),k.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=k.brokerages)==null?void 0:L.name)||"Unknown"})]}),k.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:gs(new Date(k.subscription_end_date),"MMMM d, yyyy")})]}),k.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:gs(new Date(k.trial_expires_at),"MMMM d, yyyy")})]}),k.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:k.stripe_customer_id})]})]}),k.stripe_customer_id&&e.jsxs(K,{className:"w-full",onClick:()=>w(k.stripe_customer_id),children:[e.jsx(Zr,{className:"h-4 w-4 mr-2"}),"View in Stripe Dashboard"]})]})]})]})]})})]},k.id)})})]})})})]}),e.jsx(ws,{value:"brokerages",className:"space-y-4",children:e.jsx("div",{className:"grid gap-4",children:f==null?void 0:f.map(k=>{var A,I;const C=(A=k.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(Lt,{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(Ft,{className:"text-lg",children:k.name}),e.jsxs(ur,{children:[k.agentCount," agents"]})]})]}),e.jsx(Qe,{variant:C?"default":"outline",children:C?"Active Subscription":"No Active Subscription"})]})}),e.jsx(Re,{children:((I=k.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:"}),k.managers.map(L=>{const O=i0e[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"})})]},k.id)})})}),e.jsx(ws,{value:"websites",className:"space-y-4",children:e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(nd,{className:"h-5 w-5 text-primary"}),"Local Move Website Subscriptions"]}),e.jsx(ur,{children:"$249 setup fee + $99/mo subscriptions from TheLocalMove.com agent websites"})]}),e.jsx(Re,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ms,{children:[e.jsx(kt,{children:"Agent"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{children:"Setup Fee"}),e.jsx(kt,{children:"Monthly"}),e.jsx(kt,{children:"Next Renewal"}),e.jsx(kt,{children:"Started"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:y?y.length===0?e.jsx(Ms,{children:e.jsx(ht,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No website subscriptions yet"})}):y.map(k=>e.jsxs(Ms,{children:[e.jsx(ht,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:k.agent_name||"—"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:k.agent_email})]})}),e.jsx(ht,{children:e.jsx(Qe,{variant:k.status==="active"?"default":k.status==="canceled"?"destructive":"outline",children:k.status})}),e.jsx(ht,{children:k.setup_fee_paid?e.jsxs(Qe,{variant:"secondary",children:["Paid · $",(k.setup_fee_amount_cents/100).toFixed(0)]}):e.jsx(Qe,{variant:"outline",children:"Unpaid"})}),e.jsxs(ht,{className:"font-medium",children:["$",(k.monthly_amount_cents/100).toFixed(0),"/mo"]}),e.jsx(ht,{children:k.current_period_end?e.jsx("span",{className:"text-sm",children:gs(new Date(k.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:gs(new Date(k.created_at),"MMM d, yyyy")})}),e.jsx(ht,{className:"text-right",children:k.stripe_customer_id&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>w(k.stripe_customer_id),children:e.jsx(Zr,{className:"h-4 w-4"})})})]},k.id)):e.jsx(Ms,{children:e.jsx(ht,{colSpan:7,className:"text-center py-8",children:"Loading…"})})})]})})]})})]})]})})}function G1s(){const[t,s]=S.useState([]),[r,n]=S.useState(!0),[a,o]=S.useState(""),[l,i]=S.useState("all"),[d,u]=S.useState({total:0,qualified:0,pending:0,cancelled:0,totalDiscounts:0});S.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,k=(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:k,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 k,C,A,I,L,O;const N=((C=(k=b.referrer_brokerage)==null?void 0:k.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(ti,{className:"h-3 w-3 mr-1"}),"Qualified"]});case"pending":return e.jsxs(Qe,{variant:"secondary",children:[e.jsx(on,{className:"h-3 w-3 mr-1"}),"Pending"]});case"cancelled":return e.jsxs(Qe,{variant:"destructive",children:[e.jsx(Ql,{className:"h-3 w-3 mr-1"}),"Cancelled"]});default:return e.jsx(Qe,{children:b})}};return e.jsx(Es,{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(K,{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(Re,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(or,{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(Re,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ti,{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(Re,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(on,{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(Re,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ql,{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(Re,{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(Lt,{children:[e.jsx(Ft,{children:"All Referrals"}),e.jsx(ur,{children:"View and manage all referral relationships"})]}),e.jsxs(Re,{children:[e.jsxs("div",{className:"flex gap-4 mb-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by brokerage or email...",value:a,onChange:b=>o(b.target.value),className:"pl-10"})]}),e.jsxs(Fs,{value:l,onValueChange:i,children:[e.jsx(Ds,{className:"w-[180px]",children:e.jsx(zs,{placeholder:"Filter by status"})}),e.jsxs(Rs,{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(Ms,{children:[e.jsx(kt,{children:"Referrer"}),e.jsx(kt,{children:"Referred"}),e.jsx(kt,{children:"Signup Date"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{children:"Qualified Date"}),e.jsx(kt,{children:"Discount"})]})}),e.jsx(Rn,{children:y.length===0?e.jsx(Ms,{children:e.jsx(ht,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No referrals found"})}):y.map(b=>{var N,w,k,C;return e.jsxs(Ms,{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)||((k=b.referred_user)==null?void 0:k.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:gs(new Date(b.signup_date),"MMM d, yyyy")}),e.jsx(ht,{children:_(b.status)}),e.jsx(ht,{children:b.qualified_date?gs(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 o0e=[{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"}],W1s=[{value:"brokerage_manager",label:"Brokerage Manager"},{value:"agent",label:"Agent"}];function K1s(){const[t,s]=S.useState([]),[r,n]=S.useState(!0),[a,o]=S.useState(!1),[l,i]=S.useState(null),[d,u]=S.useState({title:"",description:"",action_type:"view_template",target_role:"agent",is_active:!0});S.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"),k=t.filter(C=>C.target_role==="agent");return e.jsxs(Es,{title:"Onboarding Checklist",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Onboarding Checklist"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage checklist items shown to new users on their dashboard"})]}),e.jsxs(K,{onClick:f,className:"gap-2",children:[e.jsx(Bs,{className:"h-4 w-4"}),"Add Item"]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Qe,{variant:"secondary",children:"Brokerage Manager"}),"Checklist Items"]})}),e.jsx(Re,{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(Ms,{children:[e.jsx(kt,{className:"w-12",children:"#"}),e.jsx(kt,{children:"Title"}),e.jsx(kt,{children:"Action Type"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:w.map((C,A)=>{var I;return e.jsxs(Ms,{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=o0e.find(L=>L.value===C.action_type))==null?void 0:I.label)||C.action_type})}),e.jsx(ht,{children:e.jsx(Mr,{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(K,{variant:"ghost",size:"icon",onClick:()=>y(C),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>b(C.id),children:e.jsx(xr,{className:"h-4 w-4 text-destructive"})})]})})]},C.id)})})]})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Qe,{variant:"secondary",children:"Agent"}),"Checklist Items"]})}),e.jsx(Re,{children:k.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(Ms,{children:[e.jsx(kt,{className:"w-12",children:"#"}),e.jsx(kt,{children:"Title"}),e.jsx(kt,{children:"Action Type"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:k.map((C,A)=>{var I;return e.jsxs(Ms,{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=o0e.find(L=>L.value===C.action_type))==null?void 0:I.label)||C.action_type})}),e.jsx(ht,{children:e.jsx(Mr,{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(K,{variant:"ghost",size:"icon",onClick:()=>y(C),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>b(C.id),children:e.jsx(xr,{className:"h-4 w-4 text-destructive"})})]})})]},C.id)})})]})})]})]}),e.jsx(fs,{open:a,onOpenChange:o,children:e.jsxs(hs,{children:[e.jsx(js,{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(Le,{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(gr,{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(Fs,{value:d.target_role,onValueChange:C=>u({...d,target_role:C}),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsx(Rs,{children:W1s.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(Fs,{value:d.action_type,onValueChange:C=>u({...d,action_type:C}),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsx(Rs,{children:o0e.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(Mr,{id:"is_active",checked:d.is_active,onCheckedChange:C=>u({...d,is_active:C})}),e.jsx(xe,{htmlFor:"is_active",children:"Active"})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(K,{onClick:_,children:l?"Save Changes":"Create Item"})]})]})})]})}function Z1s(){const[t,s]=S.useState(""),[r,n]=S.useState("all"),[a,o]=S.useState("name"),[l,i]=S.useState("asc"),[d,u]=S.useState(""),[p,f]=S.useState(""),[y,_]=S.useState(""),[b,N]=S.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}}),k=async U=>{let Y=[],J=0,X=!0;for(;X;){const{data:ce,error:ae}=await U(J,J+1e3-1);if(ae)throw ae;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 k((qe,ke)=>G.from("profiles").select("id, name, email, brokerage_id, created_at").range(qe,ke)),{data:te}=await G.from("brokerages").select("id, name"),Y=new Map((te==null?void 0:te.map(qe=>[qe.id,qe.name]))||[]),[{data:J},{data:X},{data:ce},{data:ae},{data:ie},{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")]),ye=new Map;J==null||J.forEach(qe=>ye.set(qe.owner_user_id,qe.contact_count));const he=new Map;X==null||X.forEach(qe=>he.set(qe.owner_user_id,qe.video_count));const ge=new Map;ce==null||ce.forEach(qe=>ge.set(qe.owner_user_id,qe.popby_count));const Ne=new Map;ae==null||ae.forEach(qe=>Ne.set(qe.agent_id,qe.listing_count));const Ue=new Map;ie==null||ie.forEach(qe=>Ue.set(qe.owner_user_id,qe.deal_count));const Te=new Map;oe==null||oe.forEach(qe=>Te.set(qe.owner_user_id,{total:qe.portal_count,active:qe.active_portal_count}));const Me=new Map;return me==null||me.forEach(qe=>Me.set(qe.owner_user_id,{total:qe.card_count,sent:qe.sent_card_count,views:qe.total_card_views})),U.map(qe=>{const ke=Te.get(qe.id),$e=Me.get(qe.id);return{id:qe.id,name:qe.name||"Unknown",email:qe.email||"",brokerage_id:qe.brokerage_id,brokerage_name:qe.brokerage_id&&Y.get(qe.brokerage_id)||null,contact_count:ye.get(qe.id)||0,video_count:he.get(qe.id)||0,popby_count:ge.get(qe.id)||0,listing_count:Ne.get(qe.id)||0,deal_count:Ue.get(qe.id)||0,portal_count:(ke==null?void 0:ke.total)||0,active_portal_count:(ke==null?void 0:ke.active)||0,card_count:($e==null?void 0:$e.total)||0,sent_card_count:($e==null?void 0:$e.sent)||0,total_card_views:($e==null?void 0:$e.views)||0,created_at:qe.created_at}})}}),I=S.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,ae=parseInt(p)||0,ie=parseInt(y)||0,oe=parseInt(b)||0,me=te.contact_count>=ce&&te.video_count>=ae&&te.popby_count>=ie&&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(ae=>[ae.name,ae.email,ae.brokerage_name||"None",ae.contact_count,ae.video_count,ae.popby_count,ae.listing_count,ae.deal_count,`${ae.portal_count} (${ae.active_portal_count})`,ae.card_count,ae.sent_card_count,ae.total_card_views]),Y=[U.join(","),...te.map(ae=>ae.map(ie=>`"${ie}"`).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=S.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=S.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(kt,{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(Lt,{className:"pb-2",children:e.jsxs(Ft,{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(Re,{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(Lt,{className:"pb-2",children:e.jsxs(Ft,{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(Re,{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(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(or,{className:"h-5 w-5"}),"User Activity Analytics"]}),e.jsx(ur,{children:"View all users and their Agent OS usage metrics"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:O,children:[e.jsx(Qa,{className:"h-4 w-4 mr-2"}),"Export CSV"]})]})}),e.jsxs(Re,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name or email...",value:t,onChange:U=>s(U.target.value),className:"pl-9"})]})}),e.jsx("div",{children:e.jsxs(Fs,{value:r,onValueChange:n,children:[e.jsxs(Ds,{children:[e.jsx(pa,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(zs,{placeholder:"Brokerage"})]}),e.jsxs(Rs,{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(Le,{type:"number",placeholder:"Min contacts",value:d,onChange:U=>u(U.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(Le,{type:"number",placeholder:"Min videos",value:p,onChange:U=>f(U.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(Le,{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(Ms,{children:[e.jsx(B,{field:"name",children:"Name"}),e.jsx(kt,{children:"Email"}),e.jsx(kt,{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(Ms,{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(Ms,{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(Jl,{children:[e.jsx(ec,{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(Ll,{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(Jl,{children:[e.jsx(ec,{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(Mn,{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(Cn,{className:"h-3 w-3"}),U.total_card_views]})]})}),e.jsxs(Ll,{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 Y1s(){ja(),Qt();const[t,s]=S.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(Es,{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(ls,{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(ls,{value:"relationship-types",className:"gap-2",children:[e.jsx(or,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Relationships"})]}),e.jsxs(ls,{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(ls,{value:"scripts",className:"gap-2",children:[e.jsx(yn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Scripts"})]}),e.jsxs(ls,{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(ls,{value:"plans",className:"gap-2",children:[e.jsx(ln,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Plans"})]}),e.jsxs(ls,{value:"popbys",className:"gap-2",children:[e.jsx(yi,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Popbys"})]}),e.jsxs(ls,{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(ls,{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(ws,{value:"user-analytics",className:"mt-6",children:e.jsx(Z1s,{})}),e.jsx(ws,{value:"relationship-types",className:"mt-6",children:e.jsx(X1s,{types:n||[],isLoading:a})}),e.jsx(ws,{value:"action-types",className:"mt-6",children:e.jsx(Q1s,{types:o||[],isLoading:l})}),e.jsx(ws,{value:"scripts",className:"mt-6",children:e.jsx(J1s,{scripts:i||[],actionTypes:o||[],isLoading:d})}),e.jsx(ws,{value:"video-scripts",className:"mt-6",children:e.jsx(r_s,{})}),e.jsx(ws,{value:"plans",className:"mt-6",children:e.jsx(e_s,{plans:u||[],actionTypes:o||[],scripts:i||[],isLoading:p})}),e.jsx(ws,{value:"popbys",className:"mt-6",children:e.jsx(s_s,{items:f||[],isLoading:y})}),e.jsx(ws,{value:"settings",className:"mt-6",children:e.jsx(n_s,{})}),e.jsx(ws,{value:"feature-flags",className:"mt-6",children:e.jsx(t_s,{flags:r||[]})})]})]})})}function X1s({types:t,isLoading:s}){const{toast:r}=ja(),n=Qt(),[a,o]=S.useState(null),[l,i]=S.useState(!1),d=Et({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(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{children:"Relationship Types"}),e.jsx(ur,{children:"Define the relationship categories for InnerCircle contacts"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Type"]})]}),e.jsx(Re,{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(Ms,{children:[e.jsx(kt,{className:"w-12"}),e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Description"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"w-24",children:"Actions"})]})}),e.jsx(Rn,{children:t.map(p=>e.jsxs(Ms,{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(Mr,{checked:p.active,onCheckedChange:()=>u(p)})}),e.jsx(ht,{children:e.jsx(K,{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(hs,{children:[e.jsx(js,{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(Le,{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(gr,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"icon",children:"Icon"}),e.jsx(Le,{id:"icon",name:"icon",defaultValue:(a==null?void 0:a.icon)||"",placeholder:"e.g., star, heart, user"})]})]}),e.jsxs(_n,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:d.isPending,children:[d.isPending&&e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Q1s({types:t,isLoading:s}){const{toast:r}=ja(),n=Qt(),[a,o]=S.useState(null),[l,i]=S.useState(!1),d=Et({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(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{children:"Action Types"}),e.jsx(ur,{children:"Define the types of touchpoint actions agents can take"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Action"]})]}),e.jsx(Re,{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(Ms,{children:[e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Description"}),e.jsx(kt,{children:"Color"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"w-24",children:"Actions"})]})}),e.jsx(Rn,{children:t.map(p=>e.jsxs(Ms,{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(Mr,{checked:p.active,onCheckedChange:()=>u(p)})}),e.jsx(ht,{children:e.jsx(K,{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(hs,{children:[e.jsx(js,{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(Le,{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(gr,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"icon",children:"Icon"}),e.jsx(Le,{id:"icon",name:"icon",defaultValue:(a==null?void 0:a.icon)||"",placeholder:"e.g., phone, message"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"color",children:"Color"}),e.jsx(Le,{id:"color",name:"color",type:"color",defaultValue:(a==null?void 0:a.color)||"#6366f1"})]})]}),e.jsxs(_n,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:d.isPending,children:[d.isPending&&e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function J1s({scripts:t,actionTypes:s,isLoading:r}){const{toast:n}=ja(),a=Qt(),[o,l]=S.useState(null),[i,d]=S.useState(!1),u=Et({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=Et({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(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{children:"Script Library"}),e.jsx(ur,{children:"Create and manage scripts for each action type"})]}),e.jsxs(K,{onClick:()=>{l(null),d(!0)},children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),e.jsx(Re,{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(Ms,{children:[e.jsx(kt,{children:"Title"}),e.jsx(kt,{children:"Action Type"}),e.jsx(kt,{children:"Tone"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"w-24",children:"Actions"})]})}),e.jsx(Rn,{children:t.map(f=>{var y;return e.jsxs(Ms,{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(K,{variant:"ghost",size:"icon",onClick:()=>{l(f),d(!0)},children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p.mutate(f.id),children:e.jsx(xr,{className:"h-4 w-4 text-destructive"})})]})]},f.id)})})]})}),e.jsx(fs,{open:i,onOpenChange:d,children:e.jsxs(hs,{className:"max-w-2xl",children:[e.jsx(js,{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(Le,{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(Fs,{name:"action_type_id",defaultValue:o==null?void 0:o.action_type_id,children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select action type"})}),e.jsx(Rs,{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(Le,{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(gr,{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(_n,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:u.isPending,children:[u.isPending&&e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function e_s({plans:t,actionTypes:s,scripts:r,isLoading:n}){const{toast:a}=ja(),o=Qt(),[l,i]=S.useState(null),[d,u]=S.useState(!1),[p,f]=S.useState(null),[y,_]=S.useState(!1),[b,N]=S.useState(null),[w,k]=S.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=Et({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=Et({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=Et({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=Et({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(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{children:"Touchpoint Plans"}),e.jsx(ur,{children:"Create annual touchpoint plans that agents can apply to their contacts"})]}),e.jsxs(K,{onClick:()=>{i(null),u(!0)},children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Plan"]})]}),e.jsx(Re,{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(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ft,{className:"text-base",children:B.name}),e.jsx(K,{variant:"ghost",size:"icon",onClick:U=>{U.stopPropagation(),i(B),u(!0)},children:e.jsx(ga,{className:"h-4 w-4"})})]})}),e.jsxs(Re,{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(Lt,{children:[e.jsx(Ft,{children:"Plan Schedule"}),e.jsx(ur,{children:"Configure the monthly touchpoint schedule. Select an action type for each month, then assign or create a script."})]}),e.jsx(Re,{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(Fs,{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(Ds,{className:"w-40",children:e.jsx(zs,{placeholder:"No action"})}),e.jsxs(Rs,{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(Fs,{value:U.default_script_id||"none",onValueChange:J=>{k(null),I.mutate({id:U.id,default_script_id:J==="none"?null:J})},children:[e.jsx(Ds,{className:"w-56",children:e.jsx(zs,{placeholder:"Select script"})}),e.jsxs(Rs,{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(K,{variant:"outline",size:"sm",onClick:()=>V(B,U.action_type_id,U.id),children:[e.jsx(Bs,{className:"h-3 w-3 mr-1"}),"New Script"]}),te&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>k((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(hs,{children:[e.jsx(js,{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(Le,{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(gr,{id:"description",name:"description",defaultValue:(l==null?void 0:l.description)||"",rows:3})]})]}),e.jsxs(_n,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>u(!1),children:"Cancel"}),e.jsxs(K,{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(hs,{className:"max-w-2xl",children:[e.jsxs(js,{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(Le,{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(Le,{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(gr,{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(_n,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:O.isPending,children:[O.isPending&&e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Create & Assign"]})]})]})]})})]})}function t_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(Lt,{children:[e.jsx(Ft,{children:"Feature Flags"}),e.jsx(ur,{children:"Control which features are enabled for members"})]}),e.jsx(Re,{children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ms,{children:[e.jsx(kt,{children:"Flag"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{children:"Notes"}),e.jsx(kt,{children:"Last Updated"})]})}),e.jsx(Rn,{children:t.map(a=>e.jsxs(Ms,{children:[e.jsx(ht,{className:"font-mono text-sm",children:a.key}),e.jsx(ht,{children:e.jsx(Mr,{checked:a.enabled,onCheckedChange:o=>n(a,{enabled:o})})}),e.jsx(ht,{children:e.jsx(Le,{defaultValue:a.notes||"",placeholder:"Add notes...",className:"max-w-xs",onBlur:o=>{o.target.value!==a.notes&&n(a,{notes:o.target.value})}})}),e.jsx(ht,{className:"text-muted-foreground text-sm",children:new Date(a.updated_at).toLocaleDateString()})]},a.id))})]})})]})}function s_s({items:t,isLoading:s}){const{toast:r}=ja(),n=Qt(),[a,o]=S.useState(null),[l,i]=S.useState(!1),d=Et({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(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{children:"Popby Ideas"}),e.jsx(ur,{children:"Manage global popby ideas that all agents can see"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsx(Re,{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(yi,{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(Ms,{children:[e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Description"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"w-24",children:"Actions"})]})}),e.jsx(Rn,{children:t.map(f=>e.jsxs(Ms,{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(Mr,{checked:f.is_active,onCheckedChange:()=>u(f)})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{o(f),i(!0)},children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p(f.id),children:e.jsx(xr,{className:"h-4 w-4 text-destructive"})})]})})]},f.id))})]})}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(hs,{children:[e.jsx(js,{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(Le,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0,placeholder:"e.g., Homemade Cookies"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"description",children:"Description"}),e.jsx(gr,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||"",placeholder:"Brief description of the popby idea..."})]})]}),e.jsxs(_n,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:d.isPending,children:[d.isPending&&e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function r_s(){var _;const{toast:t}=ja(),s=Qt(),[r,n]=S.useState(null),[a,o]=S.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=Et({mutationFn:async b=>{var N,w;if(b.id){const{error:k}=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(k)throw k}else{const{error:k}=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(k)throw k}},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(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{children:"Video Scripts"}),e.jsx(ur,{children:"Manage teleprompter scripts for Quick Video Touch"})]}),e.jsxs(K,{onClick:()=>{n(null),o(!0)},children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),e.jsx(Re,{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(Ms,{children:[e.jsx(kt,{children:"Title"}),e.jsx(kt,{children:"Category"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"w-24",children:"Actions"})]})}),e.jsx(Rn,{children:d==null?void 0:d.map(b=>{var N;return e.jsxs(Ms,{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(Mr,{checked:b.is_active,onCheckedChange:()=>f(b)})}),e.jsxs(ht,{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{n(b),o(!0)},children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>y(b.id),children:e.jsx(xr,{className:"h-4 w-4"})})]})]},b.id)})})]})}),e.jsx(fs,{open:a,onOpenChange:o,children:e.jsxs(hs,{className:"max-w-2xl",children:[e.jsx(js,{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(Le,{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(Fs,{name:"category_id",defaultValue:(r==null?void 0:r.category_id)||"",children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select category"})}),e.jsx(Rs,{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(gr,{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(Le,{id:"tags",name:"tags",defaultValue:((_=r==null?void 0:r.tags)==null?void 0:_.join(", "))||"",placeholder:"birthday, follow-up, thank-you"})]})]}),e.jsxs(_n,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:p.isPending,children:[p.isPending&&e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function n_s(){const{toast:t}=ja(),[s,r]=S.useState(""),[n,a]=S.useState(!0),[o,l]=S.useState(!1);S.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(Re,{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(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Ia,{className:"h-5 w-5"}),"Popby Map Settings"]}),e.jsx(ur,{children:"Configure the map feature for popbys"})]}),e.jsxs(Re,{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(Le,{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(K,{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 a_s=()=>{const[t,s]=S.useState(""),[r,n]=S.useState("grid"),a=vr(),{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(Es,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search services...",value:t,onChange:d=>s(d.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex gap-2",children:[t&&e.jsx(K,{variant:"outline",size:"sm",onClick:()=>s(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:r==="grid"?"secondary":"outline",size:"icon",onClick:()=>n("grid"),className:"rounded-full",children:e.jsx(fp,{className:"h-4 w-4"})}),e.jsx(K,{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(Re,{className:"p-4",children:[e.jsx(ks,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(ks,{className:"h-5 w-3/4 mb-2"}),e.jsx(ks,{className:"h-4 w-full mb-4"})]})},u))}),!l&&i.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:t?"No services match your search":"No additional services available yet"}),t&&e.jsx(K,{variant:"outline",onClick:()=>s(""),children:"Clear Search"})]}),!l&&i.length>0&&e.jsx("div",{className:r==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:i.map(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(Re,{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:Xde(d.description)})]})]},d.id))})]})})},i_s=()=>{const{serviceId:t}=ao(),s=vr(),{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(Es,{title:"Loading...",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsx(ks,{className:"h-8 w-48"}),e.jsx(ks,{className:"h-64 w-full rounded-lg"}),e.jsx(ks,{className:"h-24 w-full"})]})}):r?e.jsx(Es,{title:r.name,children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs(K,{variant:"ghost",onClick:()=>s("/additional-services"),className:"gap-2",children:[e.jsx(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(Re,{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(ln,{className:"h-4 w-4 mr-1"}),"Published ",gs(new Date(r.publish_date),"MMMM d, yyyy")]})]}),r.description&&e.jsx("div",{className:"prose prose-sm max-w-none text-muted-foreground [&_a]:text-primary [&_a]:underline",dangerouslySetInnerHTML:{__html:r.description}}),e.jsx("div",{className:"pt-4 border-t",children:e.jsxs(K,{size:"lg",className:"gap-2",onClick:()=>window.open(r.signup_link_url,"_blank"),children:[e.jsx(Zr,{className:"h-5 w-5"}),"Sign Up Now"]})})]})})]})}):e.jsx(Es,{title:"Not Found",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center py-12",children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground mb-4",children:"Service Not Found"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"The service you're looking for doesn't exist or has been removed."}),e.jsxs(K,{onClick:()=>s("/additional-services"),children:[e.jsx(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 o_s(){const[t,s]=S.useState(vI[0].id),r=vI.find(n=>n.id===t)||vI[0];return e.jsx(Es,{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(Fs,{value:t,onValueChange:s,children:[e.jsx(Ds,{className:"w-full",children:e.jsx(zs,{placeholder:"Select a tool"})}),e.jsx(Rs,{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(ls,{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 L7e="agent-os-onboarding-completed",y9=[{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:or,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:yd,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:yi,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"]}],l_s=()=>{const[t,s]=S.useState(!1),[r,n]=S.useState(0),[a,o]=S.useState(!1);S.useEffect(()=>{if(!localStorage.getItem(L7e)){const b=setTimeout(()=>s(!0),500);return()=>clearTimeout(b)}},[]);const l=()=>{r{n(r+1),o(!1)},150)):d()},i=()=>{d()},d=()=>{localStorage.setItem(L7e,"true"),s(!1)},u=y9[r],p=u.icon,f=r===y9.length-1,y=_=>{_||d(),s(_)};return e.jsx(fs,{open:t,onOpenChange:y,children:e.jsxs(hs,{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(js,{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:y9.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}=qs();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})},d_s=()=>{const t=Qt(),{user:s}=qs();return Et({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"]}),pn({title:"Touch snoozed!",description:"Contact has been snoozed."})},onError:r=>{pn({title:"Error snoozing contact",description:r.message,variant:"destructive"})}})},u_s=()=>{const t=Qt();return Et({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"]}),pn({title:"Snooze cancelled"})},onError:s=>{pn({title:"Error cancelling snooze",description:s.message,variant:"destructive"})}})},h_s=[{label:"1 week",days:7},{label:"2 weeks",days:14},{label:"1 month",days:30}];function Nme({open:t,onOpenChange:s,contactId:r,contactName:n}){const[a,o]=S.useState(null),l=d_s(),i=async()=>{a&&(await l.mutateAsync({contactId:r,days:a}),o(null),s(!1))},d=u=>gs(ml(new Date,u),"MMM d, yyyy");return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(hs,{className:"sm:max-w-md",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(on,{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:h_s.map(u=>e.jsxs("button",{type:"button",onClick:()=>o(u.days),className:Dt("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(ln,{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(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:i,disabled:!a||l.isPending,children:l.isPending?"Snoozing...":"Snooze Touch"})]})]})})}const m_s={Crown:Cm,FileText:yn,Users:or,Globe:nd,Star:Gn,Phone:In,MessageSquare:Si,PenTool:Mb,Video:gn,Gift:yi};function p_s({actions:t,onMarkComplete:s,onViewScript:r,isLoading:n,buildSmsLink:a,buildEmailLink:o,onGmailCompose:l}){const i=vr(),[d,u]=S.useState("name"),[p,f]=S.useState("asc"),[y,_]=S.useState(null),[b,N]=S.useState(""),w=L=>{d===L?f(O=>O==="asc"?"desc":"asc"):(u(L),f("asc"))},k=S.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=>m_s[L||"Phone"]||In,A=({field:L,children:O})=>e.jsxs(K,{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(Ms,{className:"bg-muted/50",children:[e.jsx(kt,{className:"w-[180px]",children:e.jsx(A,{field:"name",children:"Contact"})}),e.jsx(kt,{className:"w-[130px]",children:e.jsx(A,{field:"relationship_type",children:"Type"})}),e.jsx(kt,{className:"w-[120px]",children:e.jsx(A,{field:"action_type",children:"Action"})}),e.jsx(kt,{className:"w-[130px]",children:"Phone"}),e.jsx(kt,{className:"w-[200px]",children:"Quick Actions"})]})}),e.jsx(Rn,{children:k.map((L,O)=>{var Y,J,X,ce,ae,ie;const V=L.isSpecialDate,q=L.specialDateType,B=V?q==="birthday"?Fu:Sn:C(((Y=L.actionType)==null?void 0:Y.icon)||null),U=L.contact.phone,te=L.contact.email;return e.jsxs(Ms,{className:Dt("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:Dt("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(Sn,{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(Si,{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,(ae=L.script)==null?void 0:ae.email_subject,(ie=L.actionType)==null?void 0:ie.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",ye=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?${ye.toString()}`)},className:Dt("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(K,{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(K,{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(Hn,{className:"h-3.5 w-3.5 mr-1"}),"Done"]})]})})]},`${L.contact.id}-${O}`)})})]})}),e.jsx(Nme,{open:!!y,onOpenChange:L=>!L&&_(null),contactId:y||"",contactName:b})]})}function jp(){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 f_s({onSelect:t}){const[s,r]=S.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(ni,{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 DSe(){var a;const{user:t}=qs(),{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 kme(){const{user:t}=qs(),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=Et({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=Et({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=Et({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 x_s=5*1024*1024,vv=50,g_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 y_s(t){return t<1024?t+" B":t<1024*1024?(t/1024).toFixed(1)+" KB":(t/(1024*1024)).toFixed(1)+" MB"}function v_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}=qs(),u=Qt(),{isReady:p,settings:f}=DSe(),{intakePage:y}=kme(),_=y?`https://contacts.relevelup.com/${y.slug}`:null,b=!!n&&n.length>0,N=b&&p,w=b?n:r?[r]:[],k=w[0],C=b?Math.ceil(w.length/vv):1,A=b&&w.length>vv,[I,L]=S.useState((k==null?void 0:k.email)||""),[O,V]=S.useState(a),[q,B]=S.useState(o),[U,te]=S.useState(!1),[Y,J]=S.useState(!1),[X,ce]=S.useState([]),[ae,ie]=S.useState(a),[oe,me]=S.useState(o),[ye,he]=S.useState("composing"),[ge,Ne]=S.useState(0),[Ue,Te]=S.useState(0),[Me,De]=S.useState(0),[qe,ke]=S.useState(0),$e=S.useRef(!1),[Be,we]=S.useState(null);S.useEffect(()=>{t&&(L((k==null?void 0:k.email)||""),ie(a),me(o),V(v_(a,k||{first_name:""})),B(v_(o,k||{first_name:""})),J(!a&&!o),ce([]),he("composing"),Ne(0),Te(0),De(0),ke(0),$e.current=!1,we(null))},[t,k,a,o]);const ut=async Je=>{const Ze=Je.target.files;if(!Ze)return;const Nt=X.reduce((Yt,Ps)=>Yt+Ps.size,0),Ot=[];for(const Yt of Array.from(Ze)){if(!g_s.includes(Yt.type)){pe.error(`${Yt.name}: Unsupported file type`);continue}if(Nt+Yt.size>x_s){pe.error("Total attachments exceed 5MB limit");break}try{const Ps=await v_s(Yt);Ot.push({name:Yt.name,type:Yt.type,size:Yt.size,data:Ps})}catch{pe.error(`Failed to read ${Yt.name}`)}}ce(Yt=>[...Yt,...Ot]),Je.target.value=""},fe=Je=>{ce(Ze=>Ze.filter((Nt,Ot)=>Ot!==Je))},He=Je=>{ie(Je.subject),me(Je.body),V(v_(Je.subject,k||{first_name:""})),B(v_(Je.body,k||{first_name:""})),J(!1)},et=Je=>Je.split(/\n\n+/).map(Ze=>`

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

`).join(""),tt=async Je=>{const Ze=v_(ae,Je),Nt=v_(oe,Je),Ot=et(Nt);try{if(N){const Yt=(f==null?void 0:f.display_name)||"ReLevelUp",Ps=`${Yt.toLowerCase().replace(/[^a-z]/g,".")}@send.relevelup.com`,$s=`${Yt} <${Ps}>`,{data:Zs,error:Dr}=await G.functions.invoke("ses-send-campaign",{body:{action:"test_send",to:Je.email,from_email:$s,subject:Ze,body_html:Ot,reply_to:(f==null?void 0:f.reply_to_email)||void 0}});if(Dr)throw Dr;if(!(Zs!=null&&Zs.success))throw new Error((Zs==null?void 0:Zs.error)||"Failed to send")}else{const{data:Yt,error:Ps}=await G.functions.invoke("gmail-send",{body:{to:Je.email,subject:Ze,body:Ot,contactId:Je.id,attachments:X.map(({name:$s,type:Zs,data:Dr})=>({name:$s,type:Zs,data:Dr}))}});if(Ps)throw Ps;if(!(Yt!=null&&Yt.success))throw new Error((Yt==null?void 0:Yt.error)||"Failed to send")}return d&&await G.from("bulk_email_sends").insert({user_id:d.id,contact_id:Je.id,contact_email:Je.email,subject:Ze,source:N?"ses_bulk":"sphere_gaps"}),!0}catch(Yt){return console.error("Send error:",Yt),pe.error("Failed to send to "+Je.first_name+": "+(Yt instanceof Error?Yt.message:"Unknown error")),!1}},_e=()=>{const Je=ge*vv;return w.slice(Je,Je+vv)},Ge=async()=>{if(!O||!q){pe.error("Please fill in subject and message");return}const Je=_e();te(!0),he("sending");let Ze=0,Nt=0;for(let Yt=0;YtsetTimeout($s,150));Te(Yt=>Yt+Ze),De(Yt=>Yt+Nt),te(!1),u.invalidateQueries({queryKey:["bulk-email-sends"]}),ge>=C-1||$e.current?he("all_done"):he("batch_complete")},We=async()=>{if(!O||!q){pe.error("Please fill in subject and message");return}if(!b){te(!0);const Je=await tt(k);te(!1),Je&&(u.invalidateQueries({queryKey:["bulk-email-sends"]}),pe.success("Email sent successfully!"),s(!1),i==null||i());return}await Ge()},it=async()=>{Ne(Je=>Je+1),ke(0),await new Promise(Je=>setTimeout(Je,50)),await Ge()};S.useEffect(()=>{},[ge]);const Ve=()=>{if(U){$e.current=!0;return}s(!1),i==null||i()},Xe=ge*vv,dt=Math.min(Xe+vv,w.length),pt=b&&w.length>0?Math.round((Ue+Me)/w.length*100):0;return e.jsx(fs,{open:t,onOpenChange:Ve,children:e.jsxs(hs,{className:"sm:max-w-[600px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(js,{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&&ye==="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."]})]}),ye==="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:[qe," of ",_e().length," in this batch"]})]}),e.jsx(fi,{value:qe/_e().length*100,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Overall: ",Ue+Me," / ",w.length]}),e.jsxs("span",{children:[Ue," sent • ",Me," failed"]})]}),e.jsx(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{$e.current=!0},children:"Stop Sending"})]}),ye==="batch_complete"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(Hn,{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:[Ue," sent, ",Me," failed so far"]})]}),e.jsx(fi,{value:pt,className:"h-2"}),e.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:[w.length-Ue-Me," contacts remaining (",C-ge-1," batches left)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",className:"flex-1",onClick:Ve,children:"Done for Now"}),e.jsxs(K,{className:"flex-1 gap-2",onClick:it,children:[e.jsx(Mn,{className:"h-4 w-4"}),"Send Next ",Math.min(vv,w.length-dt)," Contacts"]})]})]}),ye==="all_done"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(Hn,{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:[Ue," emails sent successfully",Me>0&&e.jsxs("span",{className:"text-destructive",children:[" • ",Me," failed"]})]})]}),e.jsx(K,{className:"w-full",onClick:Ve,children:"Close"})]}),ye==="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(yn,{className:"h-4 w-4"})," Choose a Template"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>J(!1),className:"h-7 px-2 text-xs",children:[e.jsx(jr,{className:"h-3 w-3 mr-1"})," Write from scratch"]})]}),e.jsx(f_s,{onSelect:He})]}):e.jsxs(K,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>J(!0),children:[e.jsx(yn,{className:"h-4 w-4"}),"Browse Templates"]}),e.jsx(xo,{}),!b&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{htmlFor:"gmail-to",children:"To"}),e.jsx(Le,{id:"gmail-to",value:I,onChange:Je=>L(Je.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(Le,{id:"gmail-subject",value:O,onChange:Je=>{V(Je.target.value),ie(Je.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(Je=>Je+"{{first_name}}"),me(Je=>Je+"{{first_name}}")},children:"{{first_name}}"}),e.jsx(Qe,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>{B(Je=>Je+"{{last_name}}"),me(Je=>Je+"{{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 Je=` When you get a sec, can you share your latest contact info with me? It only takes about a minute: ${_} `;B(Ze=>Ze+Je),me(Ze=>Ze+Je)},title:"Insert your Connect Page link",children:"+ Connect Page"})]})]}),e.jsx(gr,{id:"gmail-body",value:q,onChange:Je=>{B(Je.target.value),me(Je.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(K,{type:"button",variant:"outline",size:"sm",className:"gap-2",onClick:()=>{var Je;return(Je=document.getElementById("gmail-attachments"))==null?void 0:Je.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:ut})]}),X.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:X.map((Je,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:Je.name}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["(",y_s(Je.size),")"]}),e.jsx("button",{type:"button",onClick:()=>fe(Ze),className:"ml-0.5 rounded-full p-0.5 hover:bg-muted",children:e.jsx(jr,{className:"h-3 w-3"})})]},Ze))})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),b?e.jsxs(K,{onClick:()=>{we(w[0]||null),he("reviewing")},disabled:!O||!q,className:"gap-2",children:["Review Emails",e.jsx(Ga,{className:"h-4 w-4"})]}):e.jsxs(K,{onClick:We,disabled:U||!O||!q,className:"gap-2",children:[U?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(Mn,{className:"h-4 w-4"}),U?"Sending...":"Send Email"]})]})]}),ye==="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(Je=>e.jsxs("div",{className:`text-sm px-2 py-1 rounded cursor-pointer transition-colors ${(Be==null?void 0:Be.id)===Je.id?"bg-primary/10 text-primary font-medium":"text-muted-foreground hover:bg-accent hover:text-foreground"}`,onClick:()=>we(Je),children:[Je.first_name," ",Je.last_name," — ",Je.email]},Je.id))})]}),Be&&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 ",Be.first_name," ",Be.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:"})," ",Be.email]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Subject:"})," ",v_(ae,Be)]})]}),e.jsx(xo,{}),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,Be)})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>{he("composing"),we(null)},children:[e.jsx(Oa,{className:"h-4 w-4 mr-1"}),"Back to Edit"]}),e.jsxs(K,{onClick:We,disabled:U,className:"gap-2",children:[U?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(Mn,{className:"h-4 w-4"}),A?`Send First ${vv}`:`Send to ${w.length}`]})]})]})]})})}function __s(){const t=vr(),{data:s}=qh(),{data:r}=WR(),n=nhe(),{isGmailConnected:a,gmailEmail:o}=jp(),[l,i]=S.useState(null),[d,u]=S.useState(!1),[p,f]=S.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=S.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}`)),pn({title:"Touch logged!",description:`Logged outreach for ${I.contact.first_name}`})}catch{pn({title:"Error",description:"Failed to log touch",variant:"destructive"})}},k=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(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ft,{className:"text-lg flex items-center gap-2",children:[e.jsx(yd,{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(Re,{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:Dt("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(wn,{className:Dt("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(jn,{className:Dt("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:Dt("text-[10px] shrink-0 whitespace-nowrap",A(I.daysUntil)),children:C(I.daysUntil)})]}),e.jsxs("div",{className:Dt("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(Sn,{className:"h-3 w-3"})," Home Anniversary"]}),e.jsx("span",{children:"·"}),e.jsx("span",{children:gs(I.date,"MMM d")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 mt-2 pl-[52px]",children:[I.contact.phone&&e.jsx(K,{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(K,{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(Si,{className:"h-3.5 w-3.5"})})}),I.contact.email&&e.jsx(K,{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(K,{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(gn,{className:"h-3.5 w-3.5"})}),e.jsxs(K,{variant:"ghost",size:"sm",className:Dt("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:()=>k(I),children:[e.jsx(Or,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Card"})]}),e.jsx(K,{variant:"ghost",size:"icon",className:Dt("h-7 w-7",V&&"text-green-600"),title:"Log a touch",disabled:V||n.isPending,onClick:()=>w(I),children:e.jsx(Hn,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"View contact",onClick:()=>t(`/mission-control/contacts/${I.contact.id}`),children:e.jsx(Cn,{className:"h-3.5 w-3.5"})})]})]},`${O}-${L}`)})]})]}),a&&l&&e.jsx(E1,{open:d,onOpenChange:u,contact:l,gmailEmail:o})]})}function b_s(t){const[s,r]=S.useState([]),[n,a]=S.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(k=>k.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});S.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?w_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 w_s(t){const s=new Set;return t.filter(r=>s.has(r.id)?!1:(s.add(r.id),!0))}const j_s={property_view:{label:"Viewed",icon:Cn,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 N_s(){const{user:t}=qs(),s=vr(),{isGmailConnected:r,gmailEmail:n}=jp(),{leadSite:a}=CC(),{count:o}=b_s(a==null?void 0:a.id),[l,i]=S.useState(!1),[d,u]=S.useState(null),{data:p,isLoading:f}=gt({queryKey:["lead-site-activity",t==null?void 0:t.id],queryFn:async()=>{const{data:k,error:C}=await G.rpc("get_lead_site_activity",{_user_id:t.id});if(C)throw C;return k},enabled:!!t,refetchInterval:6e4});if(f||!(p!=null&&p.has_site))return null;const y=(p.activities||[]).filter(k=>k.visitor_name&&k.visitor_name!=="Site Visitor"),_=y.filter(k=>k.activity_type==="new_lead"),b=(p.activities||[]).filter(k=>k.activity_type==="property_view").length,N=(p.activities||[]).filter(k=>k.activity_type==="saved_listing").length,w=k=>{if(k.visitor_email)if(r){const C=(k.visitor_name||"").split(" ");u({id:k.contact_id||"",first_name:C[0]||"",last_name:C.slice(1).join(" ")||null,email:k.visitor_email}),i(!0)}else window.location.href=`mailto:${k.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(K,{variant:"ghost",size:"sm",className:"text-primary gap-1",onClick:()=>s("/mission-control/website-activity"),children:["View All",e.jsx(Ga,{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(Cn,{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((k,C)=>{const A=j_s[k.activity_type],I=A.icon,L=Nl(new Date(k.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:()=>{k.contact_id&&s(`/mission-control/contacts/${k.contact_id}`)},children:k.visitor_name}),e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{children:A.label}),k.mls_number&&e.jsxs("span",{children:["· MLS# ",k.mls_number]}),k.lead_type&&e.jsxs("span",{children:["· ",k.lead_type]}),e.jsxs("span",{children:["· ",L]})]})]}),e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[k.visitor_email&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-primary",onClick:()=>w(k),children:e.jsx(tr,{className:"h-3.5 w-3.5"})}),k.visitor_phone&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-primary",onClick:()=>window.location.href=`tel:${k.visitor_phone}`,children:e.jsx(In,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-primary",onClick:()=>window.location.href=`sms:${k.visitor_phone}`,children:e.jsx(Si,{className:"h-3.5 w-3.5"})})]}),k.contact_id&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>s(`/mission-control/contacts/${k.contact_id}`),children:e.jsx(xa,{className:"h-3.5 w-3.5"})})]})]},`${k.activity_type}-${k.occurred_at}-${C}`)}),y.length>5&&e.jsxs(K,{variant:"outline",className:"w-full text-xs",onClick:()=>s("/mission-control/website-activity"),children:["View ",y.length-5," more activities",e.jsx(Ga,{className:"h-3.5 w-3.5 ml-1"})]})]}):e.jsx(Pe,{children:e.jsxs(Re,{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(K,{variant:"outline",size:"sm",className:"mt-3",onClick:()=>s("/mission-control/website-activity"),children:["View Full Activity",e.jsx(Ga,{className:"h-3.5 w-3.5 ml-1"})]})]})}),r&&d&&e.jsx(E1,{open:l,onOpenChange:i,contact:d,gmailEmail:n})]})}const D7e={Crown:Cm,FileText:yn,Users:or,Globe:nd,Star:Gn,Phone:In,MessageSquare:Si,PenTool:Mb,Video:gn,Gift:yi},k_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 S_s(){var We,it,Ve,Xe,dt,pt;const t=vr(),{user:s}=qs(),{data:r}=Nf(),{data:n}=_Xe(),{data:a}=qh(),{data:o}=WR(),{data:l}=kXe(),i=PLt(),d=oke(),u=ALt(90),p=nhe(),[f,y]=S.useState(null),[_,b]=S.useState(null),[N,w]=S.useState(!1),[k,C]=S.useState(""),[A,I]=S.useState(!1),[L,O]=S.useState(""),[V,q]=S.useState(wle()),[B,U]=S.useState("cards"),[te,Y]=S.useState(!1),[J,X]=S.useState(null),[ce,ae]=S.useState(null),[ie,oe]=S.useState(""),{isGmailConnected:me,gmailEmail:ye}=jp(),he=()=>{const Je=parseInt(L,10);if(isNaN(Je)||Je<1){pn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}q(Je),NXe(Je),I(!1),pn({title:"Goal updated",description:`Weekly touch goal set to ${Je}`})},ge=()=>{O(V.toString()),I(!0)};S.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]),S.useEffect(()=>{i.mutate()},[]);const Ne=Em(new Date),Ue=ml(Ne,7),Te=Je=>{if(!Je)return null;const Ze=Je.split(/[-/T]/);if(Ze.length<3)return null;const Nt=parseInt(Ze[1],10)-1,Ot=parseInt(Ze[2],10);return isNaN(Nt)||isNaN(Ot)?null:new Date(Ne.getFullYear(),Nt,Ot)},Me=(a==null?void 0:a.filter(Je=>{const Ze=Te(Je.birthday),Nt=Te(Je.home_anniversary);return Ze&&il(Ze,Ne)||Nt&&il(Nt,Ne)}))||[];a!=null&&a.filter(Je=>{if(!Je.birthday&&!Je.home_anniversary)return!1;const Ze=Nt=>{if(!Nt)return!1;const Ot=Te(Nt);return Ot?ZS(Ot,Ne)&&YS(Ot,Ue):!1};return Ze(Je.birthday)||Ze(Je.home_anniversary)}).slice(0,5);const De=[],qe=(o==null?void 0:o.find(Je=>Je.name==="Call"))||(o==null?void 0:o[0]);for(const Je of Me){const Ze=Te(Je.birthday),Nt=Te(Je.home_anniversary),Ot=Ze&&il(Ze,Ne),Yt=Nt&&il(Nt,Ne);Ot&&De.push({contact:Je,actionType:qe||{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:((Ve=(it=(We=Je.tags)==null?void 0:We[0])==null?void 0:it.relationship_type)==null?void 0:Ve.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"birthday"}),Yt&&De.push({contact:Je,actionType:qe||{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:((pt=(dt=(Xe=Je.tags)==null?void 0:Xe[0])==null?void 0:dt.relationship_type)==null?void 0:pt.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"anniversary"})}const $e=l!==void 0?l||[]:(a==null?void 0:a.slice(0,5).map((Je,Ze)=>{var Ot,Yt,Ps;const Nt=o==null?void 0:o[Ze%((o==null?void 0:o.length)||1)];return Nt?{contact:Je,actionType:Nt,planName:"Quick Touch",relationshipTypeName:((Ps=(Yt=(Ot=Je.tags)==null?void 0:Ot[0])==null?void 0:Yt.relationship_type)==null?void 0:Ps.name)||"",monthNumber:0}:null}).filter(Boolean))||[],Be=[...De,...$e],we=async(Je,Ze,Nt)=>{await p.mutateAsync({contactId:Je,actionTypeId:Ze,scriptUsedId:Nt}),w(!1),b(null)},ut=Je=>{Je.script?(b(Je),w(!0)):we(Je.contact.id,Je.actionType.id)},fe=Je=>D7e[Je||"Phone"]||In,He=Je=>D7e[Je||"Users"]||or,et=(Je,Ze)=>Je.replace(/\{\{FirstName\}\}/g,Ze.first_name).replace(/\{\{LastName\}\}/g,Ze.last_name||"").replace(/\{\{AgentName\}\}/g,k||"there"),tt=(Je,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}`})[Je]||`Hello ${Ze}!`,_e=(Je,Ze,Nt)=>{const Ot=`sms:${Je}`;if(Ze&&Nt){const Yt=et(Ze,Nt);return`${Ot}?body=${encodeURIComponent(Yt)}`}return Ot},Ge=(Je,Ze,Nt,Ot,Yt)=>{const Ps=`mailto:${Je}`,$s=[];if(Yt){const Zs=Nt||tt(Ot||"Email",Yt.first_name);if($s.push(`subject=${encodeURIComponent(Zs)}`),Ze){const Dr=et(Ze,Yt);$s.push(`body=${encodeURIComponent(Dr)}`)}}return $s.length>0?`${Ps}?${$s.join("&")}`:Ps};return e.jsxs(e.Fragment,{children:[e.jsxs(Es,{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(N_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(Je=>Je.active).map(Je=>{const Ze=He(Je.icon),Nt=(n==null?void 0:n[Je.id])||0,Ot=f===Je.id,Yt=k_s[Je.name]||"bg-secondary text-secondary-foreground";return e.jsxs("button",{onClick:()=>{Ot?(y(null),t("/mission-control/contacts")):(y(Je.id),t(`/mission-control/contacts?type=${Je.id}`))},className:` flex items-center gap-2 px-4 py-3 rounded-lg border transition-all ${Ot?Yt:"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:Je.name}),e.jsxs("div",{className:`text-sm ${Ot?"opacity-90":"text-muted-foreground"}`,children:[Nt," Contacts"]})]})]},Je.id)})})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsxs(K,{onClick:()=>t("/mission-control/video/record"),className:"w-full bg-gradient-to-r from-primary to-primary/80",children:[e.jsx(Rd,{className:"h-4 w-4 mr-1"}),"Quick Video"]}),e.jsxs(K,{onClick:()=>t("/mission-control/contacts"),className:"w-full",variant:"outline",children:["View Contacts",e.jsx(xa,{className:"h-4 w-4 ml-1"})]}),e.jsx(K,{variant:"outline",onClick:()=>t("/mission-control/video-library"),className:"w-full",children:"Video Library"}),e.jsx(K,{variant:"outline",onClick:()=>t("/mission-control/plans"),className:"w-full",children:"Manage Plans"})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Today in Your InnerCircle"}),l!==void 0&&e.jsxs(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(K,{variant:B==="cards"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>U("cards"),title:"Card view",children:e.jsx(fp,{className:"h-4 w-4"})}),e.jsx(K,{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(Re,{className:"p-4",children:Be.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No actions scheduled for today."}),e.jsx("p",{className:"text-sm mt-1",children:"Add contacts and enable touchpoint plans to get started."}),e.jsx(K,{variant:"outline",className:"mt-4",onClick:()=>t("/mission-control/plans"),children:"Manage Plans"})]}):B==="table"?e.jsx(p_s,{actions:Be,onMarkComplete:we,onViewScript:ut,isLoading:p.isPending,buildSmsLink:_e,buildEmailLink:Ge,onGmailCompose:me?Je=>{X(Je),Y(!0)}:void 0}):e.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[Be.map((Je,Ze)=>{var $t,Us,Nr,Xs,kr,fn,Yr;const Nt=Je.isSpecialDate,Ot=Je.specialDateType,Yt=Nt?Ot==="birthday"?Fu:Sn:fe((($t=Je.actionType)==null?void 0:$t.icon)||null),Ps=Je.contact.phone,$s=Je.contact.email,Zs=Nt?Ot==="birthday"?"#EC4899":"#8B5CF6":((Us=Je.actionType)==null?void 0:Us.color)||"#3B82F6",Dr=Nt?Ot==="birthday"?"🎂 Birthday Today!":"🏠 Home Anniversary!":(Nr=Je.actionType)==null?void 0:Nr.name;return e.jsxs("div",{className:`flex-shrink-0 w-[260px] border rounded-lg overflow-hidden ${Nt?"ring-2 ring-offset-2":""}`,style:Nt?{"--tw-ring-color":Zs}:void 0,children:[e.jsxs("div",{className:"p-3 text-white flex items-center gap-2",style:{backgroundColor:Zs},children:[e.jsx(Yt,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm",children:Dr})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("button",{onClick:()=>t(`/mission-control/contacts/${Je.contact.id}`),className:"font-medium text-sm hover:text-primary hover:underline transition-colors text-left",children:[Je.contact.first_name," ",Je.contact.last_name]}),e.jsxs("div",{className:"flex gap-1.5",children:[Ps&&e.jsxs(e.Fragment,{children:[e.jsxs("a",{href:`tel:${Je.contact.phone}`,className:"flex-1 flex items-center justify-center gap-1 px-2 py-1.5 bg-primary/10 hover:bg-primary/20 text-primary rounded text-xs font-medium transition-colors",title:"Call",children:[e.jsx(In,{className:"h-3 w-3"}),"Call"]}),e.jsxs("a",{href:_e(Je.contact.phone,(Xs=Je.script)==null?void 0:Xs.script_body,Je.contact),className:"flex-1 flex items-center justify-center gap-1 px-2 py-1.5 bg-emerald-500/10 hover:bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 rounded text-xs font-medium transition-colors",title:"Text",children:[e.jsx(Si,{className:"h-3 w-3"}),"Text"]})]}),$s&&(me?e.jsxs("button",{onClick:()=>{X({id:Je.contact.id,first_name:Je.contact.first_name,last_name:Je.contact.last_name,email:Je.contact.email}),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:Ge(Je.contact.email,(kr=Je.script)==null?void 0:kr.script_body,(fn=Je.script)==null?void 0:fn.email_subject,(Yr=Je.actionType)==null?void 0:Yr.name,Je.contact),className:"flex-1 flex items-center justify-center gap-1 px-2 py-1.5 bg-sky-500/10 hover:bg-sky-500/20 text-sky-600 dark:text-sky-400 rounded text-xs font-medium transition-colors",title:"Email",children:[e.jsx(tr,{className:"h-3 w-3"}),"Email"]}))]}),Nt&&e.jsxs("button",{onClick:()=>{const $r=`${Je.contact.first_name}${Je.contact.last_name?" "+Je.contact.last_name:""}`,Gr=Ot==="birthday"?"birthday":"home_anniversary",nr=new URLSearchParams({cardType:Gr,contactId:Je.contact.id,name:$r,...Je.contact.address?{address:Je.contact.address}:{},...Ot==="anniversary"&&Je.contact.home_anniversary?{date:Je.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 ",Ot==="birthday"?"Birthday":"Anniversary"," Card"]}),!Ps&&!$s&&e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No contact info"}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[Je.relationshipTypeName&&e.jsx(Qe,{variant:"secondary",className:"text-xs",children:Je.relationshipTypeName}),Je.monthNumber>0&&e.jsxs(Qe,{variant:"outline",className:"text-xs",children:["Month ",Je.monthNumber]})]}),Je.script&&e.jsx(K,{size:"sm",variant:"outline",className:"w-full",onClick:()=>ut(Je),children:"View Script"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"flex-1 gap-1",onClick:()=>{ae(Je.contact.id),oe(`${Je.contact.first_name} ${Je.contact.last_name||""}`.trim())},children:[e.jsx(hh,{className:"h-3.5 w-3.5"}),"Snooze"]}),e.jsx(K,{size:"sm",className:"flex-1",onClick:()=>{var $r;return we(Je.contact.id,Je.actionType.id,($r=Je.script)==null?void 0:$r.id)},disabled:p.isPending,children:"Mark Complete"})]})]})]},Je.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(K,{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(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ft,{className:"text-lg",children:"Momentum"}),e.jsxs(fs,{open:A,onOpenChange:I,children:[e.jsx(hi,{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(hs,{className:"sm:max-w-[360px]",children:[e.jsxs(js,{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(Le,{id:"weekly-goal-ic",type:"number",min:"1",value:L,onChange:Je=>O(Je.target.value),placeholder:"20",onKeyDown:Je=>{Je.key==="Enter"&&he()}})]}),e.jsx(K,{onClick:he,className:"w-full",children:"Save Goal"})]})]})]})]})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsx(fi,{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(on,{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(__s,{})]})]}),e.jsx(fs,{open:N,onOpenChange:w,children:e.jsxs(hs,{className:"max-w-md",children:[e.jsx(js,{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:et(_.script.script_body,_.contact)})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",className:"flex-1",onClick:()=>w(!1),children:"Close"}),e.jsx(K,{className:"flex-1",onClick:()=>{var Je;return we(_.contact.id,_.actionType.id,(Je=_.script)==null?void 0:Je.id)},disabled:p.isPending,children:"Mark Complete"})]})]})]})}),e.jsx(l_s,{})]}),me&&J&&e.jsx(E1,{open:te,onOpenChange:Y,contact:J,gmailEmail:ye}),e.jsx(Nme,{open:!!ce,onOpenChange:Je=>!Je&&ae(null),contactId:ce||"",contactName:ie})]})}var Lat="Toggle",RSe=S.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:Sr(t.onClick,()=>{t.disabled||i(!l)})})});RSe.displayName=Lat;var Dat=RSe,Cw="ToggleGroup",[Rat,jAs]=qc(Cw,[pw]),Oat=pw(),OSe=xt.forwardRef((t,s)=>{const{type:r,...n}=t;if(r==="single"){const a=n;return e.jsx(C_s,{...a,ref:s})}if(r==="multiple"){const a=n;return e.jsx(M_s,{...a,ref:s})}throw new Error(`Missing prop \`type\` expected on \`${Cw}\``)});OSe.displayName=Cw;var[Fat,zat]=Rat(Cw),C_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})})}),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}),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})})});OSe.displayName=Cw;var[T_s,A_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(T_s,{scope:r,rovingFocus:a,disabled:n,children:a?e.jsx(pue,{asChild:!0,...u,orientation:o,dir:p,loop:i,children:e.jsx(Jr.div,{...f,ref:s})}):e.jsx(Jr.div,{...f,ref:s})})}),bde="ToggleGroupItem",$at=xt.forwardRef((t,s)=>{const r=zat(bde,t.__scopeToggleGroup),n=A_s(bde,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(fue,{asChild:!0,...a,focusable:!l,active:o,ref:d,children:e.jsx(R7e,{...i,ref:s})}):e.jsx(R7e,{...i,ref:s})});$at.displayName=bde;var R7e=xt.forwardRef((t,s)=>{const{__scopeToggleGroup:r,value:n,...a}=t,o=zat(bde,r),l={role:"radio","aria-checked":t.pressed,"aria-pressed":void 0},i=o.type==="single"?l:void 0;return e.jsx(RSe,{...i,...a,ref:s,onPressedChange:d=>{d?o.onItemActivate(n):o.onItemDeactivate(n)}})}),qat=OSe,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"}}),E_s=S.forwardRef(({className:t,variant:s,size:r,...n},a)=>e.jsx(Dat,{ref:a,className:Dt(Vat({variant:s,size:r,className:t})),...n}));E_s.displayName=Dat.displayName;const Hat=S.createContext({size:"default",variant:"default"}),Gat=S.forwardRef(({className:t,variant:s,size:r,children:n,...a},o)=>e.jsx(qat,{ref:o,className:Dt("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=S.forwardRef(({className:t,children:s,variant:r,size:n,...a},o)=>{const l=S.useContext(Hat);return e.jsx(Uat,{ref:o,className:Dt(Vat({variant:l.variant||r,size:l.size||n}),t),...a,children:s})});Wat.displayName=Uat.displayName;const P_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:P_s.map(a=>e.jsxs(Jl,{children:[e.jsx(ec,{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(Ll,{children:a.tooltip})]},a.value))})]})}function O7e(){const t=Qt(),[s,r]=S.useState(!1),[n,a]=S.useState(null),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState(null),[f,y]=S.useState(null),[_,b]=S.useState(0),N=S.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}}),k=(w==null?void 0:w.sync_direction)||"bidirectional",C=u??k,A=Et({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=Et({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,ae=te.pull_total||0,ie=te.update_total||0,oe=0,me=0,ye=0;for(;J!=="finalize"&&!N.current;){const Ne=ce+ae+ie;J==="fetch_bt"?y("Fetching BoldTrail contacts..."):J==="analyze"?(y("Analyzing contacts..."),b(15)):J==="push"?(y(`Pushing contacts to BoldTrail... (${oe}/${ce})`),b(Ne>0?oe/Ne*90:0)):J==="pull"?(y(`Pulling contacts from BoldTrail... (${me}/${ae})`),b(Ne>0?(ce+me)/Ne*90:0)):J==="update"&&(y(`Updating existing contacts... (${ye}/${ie})`),b(Ne>0?(ce+ae+ye)/Ne*90:0));const{data:Ue,error:Te}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:J,offset:X,sync_log_id:Y,sync_direction:C}});if(Te)throw Te;if(Ue!=null&&Ue.error)throw new Error(Ue.error);const Me=Ue;oe+=Me.chunk_pushed||0,me+=Me.chunk_pulled||0,ye+=Me.chunk_updated||0,Me.push_total!==void 0&&(ce=Me.push_total||0),Me.pull_total!==void 0&&(ae=Me.pull_total||0),Me.update_total!==void 0&&(ie=Me.update_total||0),Me.progress&&y(Me.progress),J=Me.next_phase,X=Me.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(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsx(K,{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(Ll,{children:"Sync with BoldTrail"})]}),e.jsx(fs,{open:s,onOpenChange:B=>{I.isPending||r(B)},children:e.jsxs(hs,{className:"sm:max-w-lg",children:[e.jsxs(js,{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(or,{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(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(uu,{className:"h-3 w-3 text-emerald-600"}),L," contacts to push to BoldTrail"]}),e.jsx(Fi,{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(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ih,{className:"h-3 w-3 text-blue-600"}),O," contacts to pull from BoldTrail"]}),e.jsx(Fi,{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(fi,{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(K,{variant:"outline",onClick:()=>r(!1),disabled:I.isPending,children:"Cancel"}),e.jsxs(K,{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 I_s=()=>{const{user:t}=qs();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})},Sme=t=>{const{user:s}=qs();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})},FSe=()=>{const{user:t}=qs();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}=qs();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})},L_s=()=>{const{data:t}=qh();Nf();const{data:s}=Sme(),{data:r}=Kat(),{data:n}=FSe(),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=()=>L_s().filter(s=>s.isDue),D_s=()=>{const t=Qt(),{user:s}=qs();return Et({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"]}),pn({title:"Popby item created!"})},onError:r=>{pn({title:"Error creating popby item",description:r.message,variant:"destructive"})}})},R_s=()=>{const t=Qt(),{user:s}=qs();return Et({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"]}),pn({title:"Popby logged!"})},onError:r=>{pn({title:"Error logging popby",description:r.message,variant:"destructive"})}})},O_s=()=>{const t=Qt(),{user:s}=qs();return Et({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"]}),pn({title:"Frequency updated!"})},onError:r=>{pn({title:"Error updating frequency",description:r.message,variant:"destructive"})}})},F_s=()=>{const{data:t}=Sme(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 z_s(){const{user:t}=qs();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}=z_s(),{data:r}=Kat(),{data:n}=FSe(),{data:a}=c_s();return S.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,k)=>new Date(k.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(k=>{const C=n==null?void 0:n.find(A=>A.relationship_type_id===k.relationship_type_id);return C==null?void 0:C.frequency_days}).filter(k=>k!==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:on,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:Hn,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 ${gs(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:ln,text:"Never touched",className:"border-dashed"}}})(),a=n.icon;return e.jsxs(Qe,{variant:n.variant,className:Dt("gap-1",n.className),children:[e.jsx(a,{className:"h-3 w-3"}),n.text]})}function B_s({contact:t,onLogTouch:s,onSnooze:r}){const n=Yat(t),a=u_s(),[o,l]=S.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(on,{className:"h-5 w-5 text-amber-600 dark:text-amber-400"});case"on-track":return e.jsx(Hn,{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(ln,{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(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ln,{className:"h-4 w-4"}),"Next Touch"]})}),e.jsxs(Re,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d(),e.jsx("span",{className:Dt("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:"})," ",gs(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:"})," ",gs(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:"})," ",gs(n.lastTouchDate,"MMM d, yyyy")]}),n.status!=="snoozed"&&e.jsxs("div",{className:"text-xs text-muted-foreground border-t pt-2",children:["Touch frequency: Every ",n.frequencyDays," days"]}),n.status==="snoozed"&&e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"flex-1",onClick:p,disabled:a.isPending,children:[e.jsx(jr,{className:"h-4 w-4 mr-1"}),"Cancel Snooze"]}),s&&e.jsx(K,{size:"sm",className:"flex-1",onClick:s,children:"Log Touch"})]}),n.status!=="snoozed"&&e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>l(!0),children:[e.jsx(hh,{className:"h-4 w-4 mr-1"}),"Snooze"]}),(n.status==="overdue"||n.status==="due-soon"||n.status==="never-touched")&&s&&e.jsx(K,{size:"sm",className:"flex-1",variant:n.status==="overdue"?"default":"outline",onClick:s,children:"Log Touch"})]})]})]}),e.jsx(Nme,{open:o,onOpenChange:l,contactId:t.id,contactName:`${t.first_name} ${t.last_name||""}`.trim()})]})}const l0e=768;function bE(){const[t,s]=S.useState(void 0);return S.useEffect(()=>{const r=window.matchMedia(`(max-width: ${l0e-1}px)`),n=()=>{s(window.innerWidthr.removeEventListener("change",n)},[]),!!t}function $_s(){const{user:t}=qs(),{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 q_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"}},U_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=q_s[t.status],l=U_s[n],i=e.jsxs("div",{className:Dt("inline-flex items-center rounded-full font-medium",o.bgLightClass,o.textClass,l.badge,l.text,a),children:[e.jsx("span",{className:Dt("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(Jl,{children:[e.jsx(ec,{asChild:!0,children:i}),e.jsx(Ll,{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:Dt("font-bold",o.textClass),children:[t.score,"/100"]})]}),e.jsx(fi,{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 V_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}],v9=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]},H_s=({open:t,onOpenChange:s,relationshipTypes:r,onSuccess:n})=>{const{user:a}=qs(),{toast:o}=ja(),l=S.useRef(null),[i,d]=S.useState("upload"),[u,p]=S.useState([]),[f,y]=S.useState([]),[_,b]=S.useState({}),[N,w]=S.useState([]),[k,C]=S.useState([]),[A,I]=S.useState(!1),[L,O]=S.useState(null),V=()=>{d("upload"),p([]),y([]),b({}),w([]),C([]),O(null),l.current&&(l.current.value="")},q=()=>{V(),s(!1)},B=ye=>{const he=ye.split(` `).map(Te=>Te.trim()).filter(Te=>Te);if(he.length===0)return{headers:[],data:[]};const ge=Te=>{const Me=[];let De="",qe=!1;for(let ke=0;ke{var Ne;const he=(Ne=ye.target.files)==null?void 0:Ne[0];if(!he)return;const ge=new FileReader;ge.onload=Ue=>{var ke;const Te=(ke=Ue.target)==null?void 0:ke.result,{headers:Me,data:De}=B(Te);if(Me.length===0){o({title:"No data found",description:"The CSV file appears to be empty.",variant:"destructive"});return}p(Me),y(De);const qe={};Me.forEach($e=>{const Be=$e.toLowerCase().replace(/[_\s-]/g,"");Be.includes("firstname")||Be==="first"?qe.first_name=$e:Be.includes("lastname")||Be==="last"?qe.last_name=$e:Be.includes("spouse")&&Be.includes("email")?qe.spouse_email=$e:Be.includes("spouse")||Be.includes("partner")?qe.spouse_name=$e:Be.includes("email")?qe.email=$e:Be.includes("phone")||Be.includes("mobile")||Be.includes("cell")?qe.phone=$e:Be.includes("address")||Be.includes("street")?qe.address=$e:Be==="city"?qe.city=$e:Be==="state"||Be==="province"?qe.state=$e:Be==="zip"||Be==="zipcode"||Be==="postalcode"?qe.zip=$e:Be.includes("company")||Be.includes("organization")||Be.includes("business")?qe.company_name=$e:Be.includes("jobtitle")||Be.includes("title")&&!Be.includes("spouse")?qe.job_title=$e:Be.includes("birthday")||Be.includes("dob")||Be.includes("birthdate")?qe.birthday=$e:Be.includes("anniversary")||Be.includes("homeanniversary")?qe.home_anniversary=$e:(Be.includes("notes")||Be.includes("comment"))&&(qe.notes=$e)}),b(qe),d("mapping")},ge.readAsText(he)},te=(ye,he)=>{b(ge=>{if(he==="none"){const{[ye]:Ne,...Ue}=ge;return Ue}return{...ge,[ye]:he}})},Y=ye=>{w(he=>he.includes(ye)?he.filter(ge=>ge!==ye):[...he,ye])},J=async()=>{if(!(a!=null&&a.id))return;const{data:ye}=await G.from("innercircle_contacts").select("id, email, phone").eq("owner_user_id",a.id),he=new Set((ye||[]).filter(Ue=>Ue.email).map(Ue=>Ue.email.toLowerCase())),ge=new Set((ye||[]).filter(Ue=>Ue.phone).map(Ue=>Ue.phone.replace(/[^0-9]/g,""))),Ne=f.map(Ue=>{const Te=Be=>{const we=_[Be];if(!we)return"";const ut=u.indexOf(we);return ut>=0?(Ue[ut]||"").trim():""},Me=Te("first_name"),De=Te("email"),qe=Te("phone"),ke=Me.length>0,$e=!!(De&&he.has(De.toLowerCase())||qe&&ge.has(qe.replace(/[^0-9]/g,"")));return{first_name:Me,last_name:Te("last_name"),email:De,phone:qe,address:Te("address"),city:Te("city"),state:Te("state"),zip:Te("zip"),spouse_name:Te("spouse_name"),spouse_email:Te("spouse_email"),company_name:Te("company_name"),job_title:Te("job_title"),birthday:Te("birthday"),home_anniversary:Te("home_anniversary"),notes:Te("notes"),isValid:ke,isDuplicate:$e,error:ke?void 0:"First name is required"}});C(Ne),d("preview")},X=ye=>{const he=ye.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 ye=k.filter(Ue=>Ue.isValid);if(ye.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,Ne=0;try{for(const Ue of ye)try{let Te=null;if(Ue.email){const{data:qe}=await G.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",Ue.email).maybeSingle();Te=qe}if(!Te&&Ue.phone){const qe=Ue.phone.replace(/[^0-9]/g,""),{data:ke}=await G.from("innercircle_contacts").select("id, phone").eq("owner_user_id",a.id).not("phone","is",null);if(ke){const $e=ke.find(Be=>Be.phone&&Be.phone.replace(/[^0-9]/g,"")===qe);$e&&(Te={id:$e.id})}}const Me={owner_user_id:a.id,first_name:Ue.first_name,last_name:Ue.last_name||null,email:Ue.email||null,phone:Ue.phone||null,address:Ue.address||null,city:Ue.city||null,state:Ue.state||null,zip:Ue.zip||null,spouse_name:Ue.spouse_name||null,spouse_email:Ue.spouse_email||null,company_name:Ue.company_name||null,job_title:Ue.job_title||null,birthday:v9(Ue.birthday),home_anniversary:v9(Ue.home_anniversary),notes:Ue.notes||null};let De=null;if(Te){const{data:qe}=await G.from("innercircle_contacts").select("*").eq("id",Te.id).single();if(qe){const ke={},$e=["last_name","email","phone","address","city","state","zip","spouse_name","spouse_email","company_name","job_title","birthday","home_anniversary","notes"];for(const Be of $e){const we=qe[Be],ut=Me[Be];(!we||we==="")&&ut&&(ke[Be]=ut)}Object.keys(ke).length>0&&await G.from("innercircle_contacts").update(ke).eq("id",Te.id)}De=Te.id,ge++}else{const{data:qe,error:ke}=await G.from("innercircle_contacts").insert(Me).select("id").single();ke?(console.error("Insert error for contact:",Ue.first_name,ke),Ne++):qe?(De=qe.id,N.length>0&&await G.from("innercircle_contact_tags").insert(N.map($e=>({contact_id:qe.id,relationship_type_id:$e}))),he++):Ne++}if(De&&Ue.spouse_name){const qe=X(Ue.spouse_name);let ke=null;if(Ue.spouse_email){const{data:Be}=await G.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",Ue.spouse_email).maybeSingle();ke=Be}if(!ke){const{data:Be}=await G.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("first_name",qe.first_name).eq("last_name",qe.last_name||Ue.last_name||"").maybeSingle();ke=Be}let $e=null;if(ke){$e=ke.id;const Be=v9(Ue.home_anniversary);Be&&await G.from("innercircle_contacts").update({home_anniversary:Be}).eq("id",ke.id).is("home_anniversary",null)}else{const{data:Be}=await G.from("innercircle_contacts").insert({owner_user_id:a.id,first_name:qe.first_name,last_name:qe.last_name||Ue.last_name||null,email:Ue.spouse_email||null,address:Ue.address||null,city:Ue.city||null,state:Ue.state||null,zip:Ue.zip||null,home_anniversary:v9(Ue.home_anniversary),spouse_name:`${Ue.first_name}${Ue.last_name?" "+Ue.last_name:""}`,spouse_email:Ue.email||null,notes:`Spouse of ${Ue.first_name} ${Ue.last_name||""} (imported via CSV)`.trim()}).select("id").single();Be&&($e=Be.id,he++)}$e&&(await G.from("innercircle_contacts").update({spouse_contact_id:$e}).eq("id",De),await G.from("innercircle_contacts").update({spouse_contact_id:De}).eq("id",$e))}}catch(Te){console.error("Error importing contact:",Te),Ne++}O({created:he,updated:ge,failed:Ne}),d("result"),(he>0||ge>0)&&n(),o({title:"Import Complete",description:`${he} created, ${ge} updated${Ne>0?`, ${Ne} failed`:""}.`})}catch(Ue){console.error("Import error:",Ue),o({title:"Import Failed",description:Ue.message||"Failed to import contacts",variant:"destructive"})}finally{I(!1)}},ae=k.filter(ye=>ye.isValid).length,ie=k.filter(ye=>!ye.isValid).length,oe=k.filter(ye=>ye.isValid&&ye.isDuplicate).length,me=ae-oe;return e.jsx(fs,{open:t,onOpenChange:q,children:e.jsxs(hs,{className:"max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(js,{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(K,{onClick:()=>{var ye;return(ye=l.current)==null?void 0:ye.click()},children:"Select CSV File"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 text-sm",children:[e.jsx("p",{className:"font-medium mb-2",children:"Supported Fields:"}),e.jsx("p",{className:"text-muted-foreground text-xs mb-3",children:"First Name, Last Name, Email, Phone, Street Address, City, State, Zip, Spouse Name, Spouse Email, Company, Job Title, Birthday, Home Anniversary, Notes"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{const ye=`First Name,Last Name,Email,Phone,Street Address,City,State,Zip,Spouse Name,Spouse Email,Company,Job Title,Birthday,Home Anniversary,Notes John,Doe,john@example.com,555-123-4567,123 Main St,Austin,TX,78701,Jane Doe,jane@example.com,ABC Realty,Real Estate Agent,1985-06-15,2020-03-22,Met at open house`,he=new Blob([ye],{type:"text/csv"}),ge=URL.createObjectURL(he),Ne=document.createElement("a");Ne.href=ge,Ne.download="contact_import_template.csv",Ne.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:V_s.map(ye=>e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(xe,{className:"w-40 text-sm",children:[ye.label,ye.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(Fs,{value:_[ye.key]||"none",onValueChange:he=>te(ye.key,he),children:[e.jsx(Ds,{className:"w-48",children:e.jsx(zs,{placeholder:"Select column..."})}),e.jsxs(Rs,{children:[e.jsx(vt,{value:"none",children:"-- Not mapped --"}),u.map(he=>e.jsx(vt,{value:he,children:he},he))]})]})]},ye.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(ye=>e.jsx(Qe,{variant:N.includes(ye.id)?"default":"outline",className:"cursor-pointer",onClick:()=>Y(ye.id),children:ye.name},ye.id))})]}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-3 text-sm",children:e.jsxs("p",{className:"text-muted-foreground",children:["Preview: ",f.length," row(s) found in CSV"]})})]}),i==="preview"&&e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Hn,{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)"]})]}),ie>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:[ie," 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(Ms,{className:"bg-muted/30",children:[e.jsx(kt,{children:"First Name"}),e.jsx(kt,{children:"Last Name"}),e.jsx(kt,{children:"Email"}),e.jsx(kt,{children:"Phone"}),e.jsx(kt,{children:"Status"})]})}),e.jsx(Rn,{children:k.slice(0,100).map((ye,he)=>e.jsxs(Ms,{children:[e.jsx(ht,{children:ye.first_name}),e.jsx(ht,{children:ye.last_name}),e.jsx(ht,{children:ye.email}),e.jsx(ht,{children:ye.phone}),e.jsx(ht,{children:ye.isValid?ye.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:ye.error||"Invalid"})})]},he))})]}),k.length>100&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-2",children:["Showing first 100 of ",k.length," contacts"]})]})]}),i==="result"&&L&&e.jsxs("div",{className:"space-y-4 py-4 text-center",children:[e.jsx(Hn,{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(_n,{children:[i==="upload"&&e.jsx(K,{variant:"outline",onClick:q,children:"Cancel"}),i==="mapping"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:V,children:"Back"}),e.jsx(K,{onClick:J,disabled:!_.first_name,children:"Continue"})]}),i==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:()=>d("mapping"),children:"Back"}),e.jsx(K,{onClick:ce,disabled:A||ae===0,children:A?e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${ae} Contact${ae!==1?"s":""}`})]}),i==="result"&&e.jsx(K,{onClick:q,children:"Done"})]})]})})};function G_s(){return"contacts"in navigator&&"ContactsManager"in window}function W_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 K_s({open:t,onOpenChange:s,onComplete:r}){qs();const{data:n}=qh(),a=rhe(),o=S.useRef(null),[l,i]=S.useState("choose"),[d,u]=S.useState([]),[p,f]=S.useState(new Set),[y,_]=S.useState(0),[b,N]=S.useState(0),w=G_s(),k=S.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 ae,ie;const X=(ae=J.email)==null?void 0:ae.toLowerCase(),ce=(ie=J.phone)==null?void 0:ie.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,ye,he;const ie=(((oe=ce.name)==null?void 0:oe[0])||"").split(" ");return{first_name:ie[0]||"",last_name:ie.slice(1).join(" "),email:((me=ce.email)==null?void 0:me[0])||"",phone:((ye=ce.tel)==null?void 0:ye[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=k(Y);u(J);const X=new Set;J.forEach((ce,ae)=>{ce.isDuplicate||X.add(ae)}),f(X),i("preview")}catch(U){console.error("Contact Picker error:",U),pn({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,ae=W_s(ce);if(ae.length===0){pn({title:"No contacts found",description:"The file didn't contain any valid contacts.",variant:"destructive"});return}const ie=k(ae);u(ie);const oe=new Set;ie.forEach((ye,he)=>{ye.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(hs,{className:"sm:max-w-lg max-h-[90vh]",children:[e.jsxs(js,{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(K,{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(K,{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(K,{variant:"ghost",size:"sm",onClick:O,children:p.size===d.length?"Deselect All":"Select All"})]}),e.jsx(ni,{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(Hi,{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(K,{variant:"ghost",size:"sm",onClick:()=>i("choose"),children:"Back"}),e.jsxs(K,{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(K,{onClick:()=>V(!1),className:"mt-2",children:"Done"})]})]})})}function zSe(){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 Z_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 Y_s(){const t=ya(),s=Qt();return Et({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 Et({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 X_s(){const t=Qt();return Et({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 Q_s(){const t=ya(),s=Qt();return Et({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 J_s(){const t=Qt();return Et({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 ebs(){const t=Qt();return Et({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 tbs(){const t=Qt();return Et({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 sbs(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 rbs(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 Et({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 nbs(){const t=Qt();return Et({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 abs=[{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"}],Cme={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"},ibs={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"},obs=["🌱","💎","🏠","🔑","📧","💌","🎂","🥂","🤝","⭐","🎉","📞"];function eit({open:t,onOpenChange:s,campaignId:r}){const[n,a]=S.useState(r??null),[o,l]=S.useState("details");S.useEffect(()=>{a(r??null),l("details")},[r,t]);const i=n,d=!!i,{data:u}=Z_s(i||void 0),{data:p,isLoading:f}=Qat(i||void 0),y=Y_s(),_=Xat(),b=J_s(),[N,w]=S.useState(""),[k,C]=S.useState(""),[A,I]=S.useState("nurture"),[L,O]=S.useState("🌱"),[V,q]=S.useState("");S.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=ibs[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:k,category:A,icon:L,goal:V,cover_color:B}),pe.success("Campaign updated");else{const Y=await y.mutateAsync({name:N,description:k,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(hs,{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(ls,{value:"details",children:"Details"}),e.jsxs(ls,{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(ws,{value:"details",className:"flex-1 overflow-hidden mt-0",children:e.jsx(ni,{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(Le,{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(gr,{value:k,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(Le,{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(Fs,{value:A,onValueChange:Y=>I(Y),children:[e.jsx(Ds,{className:"mt-1",children:e.jsx(zs,{})}),e.jsx(Rs,{children:Object.entries(Cme).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:obs.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(ws,{value:"steps",className:"flex-1 overflow-hidden mt-0",children:e.jsx(ni,{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(K,{size:"sm",onClick:te,disabled:b.isPending,children:[e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1.5"})," Add first step"]})]}):e.jsxs(e.Fragment,{children:[p.map((Y,J)=>e.jsx(lbs,{step:Y,index:J,totalSteps:p.length},Y.id)),e.jsxs(K,{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(Bs,{className:"h-3.5 w-3.5 mr-1.5"}),"Add another step"]})]})})})})]}),e.jsxs(_n,{className:"border-t p-4 shrink-0",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:d?"Done":"Cancel"}),e.jsxs(K,{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 lbs({step:t,index:s,totalSteps:r}){const n=ebs(),a=tbs(),[o,l]=S.useState(!1),[i,d]=S.useState(t),[u,p]=S.useState(!1);S.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 k=i.anchor_field==="birthday"?"birthday":"home anniversary",C=i.anchor_offset_days||0;return C===0?`On their ${k}`:C<0?`${Math.abs(C)}d before ${k}`:`${C}d after ${k}`}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(ln,{className:"h-3 w-3"}):e.jsx(on,{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(Si,{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(Fi,{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(Fs,{value:i.channel,onValueChange:w=>d({...i,channel:w}),children:[e.jsx(Ds,{className:"mt-1 h-9",children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Fs,{value:i.delay_type,onValueChange:w=>d({...i,delay_type:w}),children:[e.jsx(Ds,{className:"mt-1 h-9",children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Le,{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(Le,{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(Fs,{value:i.anchor_field||"birthday",onValueChange:w=>d({...i,anchor_field:w}),children:[e.jsx(Ds,{className:"mt-1 h-9",children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Le,{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(Le,{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(gr,{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:"}),abs.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(Le,{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(K,{variant:"ghost",size:"sm",onClick:_,className:"text-destructive hover:text-destructive",children:[e.jsx(xr,{className:"h-3.5 w-3.5 mr-1"})," Delete step"]}),e.jsxs(K,{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 cbs({open:t,onOpenChange:s,contactIds:r,onSuccess:n}){const{data:a,isLoading:o}=zSe(),l=Jat(),[i,d]=S.useState(""),[u,p]=S.useState(null),[f,y]=S.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}),k=[`${w.enrolled} enrolled`];w.skipped>0&&k.push(`${w.skipped} skipped`),w.errors>0&&k.push(`${w.errors} errors`),pe.success(k.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(hs,{className:"max-w-md",children:[e.jsxs(js,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search campaigns...",value:i,onChange:w=>d(w.target.value),className:"pl-9 h-9"})]}),e.jsx(ni,{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(K,{size:"sm",onClick:()=>y(!0),children:[e.jsx(Bs,{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(_n,{className:"gap-2 sm:gap-2",children:[_.length>0&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>y(!0),className:"mr-auto text-xs",children:[e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1"})," New campaign"]}),e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{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 Mme(){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 dbs(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 BSe(){const t=Qt(),s=ya();return Et({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 ubs(){const t=Qt();return Et({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 hbs(){const t=Qt();return Et({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 Et({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 mbs(){const t=Qt();return Et({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 pbs(){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=vr(),{data:d}=Nf(),u=ike(),p=Qt(),{isGmailConnected:f}=jp(),{isReady:y}=DSe(),{data:_}=Mme(),b=BSe(),N=tit(),[w,k]=S.useState(!1),[C,A]=S.useState(!1),[I,L]=S.useState(!1),[O,V]=S.useState(!1),[q,B]=S.useState(""),U=t.size;if(U===0)return null;const te=async oe=>{k(!0);try{const ye=Array.from(t).map(ge=>({contact_id:ge,relationship_type_id:oe})),{error:he}=await G.from("innercircle_contact_tags").upsert(ye,{onConflict:"contact_id,relationship_type_id",ignoreDuplicates:!0});if(he)throw he;p.invalidateQueries({queryKey:["innercircle-contacts"]}),p.invalidateQueries({queryKey:["innercircle-contact-counts"]}),pn({title:`Assigned type to ${U} contacts`}),r()}catch(me){pn({title:"Error assigning type",description:me.message,variant:"destructive"})}finally{k(!1)}},Y=async oe=>{k(!0);try{const me=Array.from(t);for(const ye of me)try{await N.mutateAsync({contactId:ye,tagId:oe})}catch{}p.invalidateQueries({queryKey:["all-contact-custom-tags"]}),pn({title:`Tagged ${U} contacts`}),V(!1),B("")}catch(me){pn({title:"Error adding tags",description:me.message,variant:"destructive"})}finally{k(!1)}},J=async()=>{if(q.trim()){k(!0);try{const oe=await b.mutateAsync({name:q.trim()});await Y(oe.id)}catch(oe){pn({title:"Error creating tag",description:oe.message,variant:"destructive"}),k(!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()),ae=()=>{const oe=s.filter(Te=>t.has(Te.id)),me=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Notes","Relationship Types"],ye=oe.map(Te=>{var Me;return[Te.first_name,Te.last_name||"",Te.email||"",Te.phone||"",Te.address||"",Te.birthday||"",Te.home_anniversary||"",Te.notes||"",((Me=Te.tags)==null?void 0:Me.map(De=>{var qe;return(qe=De.relationship_type)==null?void 0:qe.name}).join("; "))||""]}),he=[me.join(","),...ye.map(Te=>Te.map(Me=>`"${(Me||"").replace(/"/g,'""')}"`).join(","))].join(` `),ge=new Blob([he],{type:"text/csv"}),Ne=URL.createObjectURL(ge),Ue=document.createElement("a");Ue.href=Ne,Ue.download=`contacts-export-${new Date().toISOString().slice(0,10)}.csv`,Ue.click(),URL.revokeObjectURL(Ne),pn({title:`Exported ${U} contacts`})},ie=async()=>{if(confirm(`Are you sure you want to delete ${U} contacts? This cannot be undone.`)){k(!0);try{const oe=Array.from(t);for(const me of oe)await u.mutateAsync(me);r()}catch(oe){pn({title:"Error deleting contacts",description:oe.message,variant:"destructive"})}finally{k(!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(Fs,{onValueChange:te,disabled:w,children:[e.jsx(Ds,{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(Rs,{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(yo,{open:O,onOpenChange:V,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",disabled:w,children:[e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1"}),"Add Tag"]})}),e.jsxs(uo,{className:"w-56 p-2",align:"start",children:[e.jsx(Le,{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(Bs,{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(K,{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(K,{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(K,{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(K,{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(K,{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(K,{variant:"outline",size:"sm",onClick:ae,disabled:w,children:[e.jsx(Qa,{className:"h-3.5 w-3.5 mr-1"}),"Export"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ie,disabled:w,className:"text-destructive hover:text-destructive",children:[e.jsx(xr,{className:"h-3.5 w-3.5 mr-1"}),"Delete"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:r,className:"ml-auto",children:[e.jsx(jr,{className:"h-3.5 w-3.5 mr-1"}),"Clear"]})]}),e.jsx(cbs,{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(ye=>ye.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 F7e({contact:t,onEdit:s,onDelete:r,onSnooze:n,onSendToLeadPond:a,showLeadPondAction:o,onTransfer:l,showTransferAction:i}){const d=vr(),{isReady:u}=DSe(),p=`${t.first_name} ${t.last_name||""}`.trim();return e.jsxs(Hd,{children:[e.jsx(Gd,{asChild:!0,children:e.jsx(K,{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(gn,{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(xr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})}function xbs(){const{user:t}=qs();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}=qs();return Et({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"]}),pn({title:"Smart filter saved"})},onError:r=>{pn({title:"Error saving smart filter",description:r.message,variant:"destructive"})}})}function ybs(){const t=Qt();return Et({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"]}),pn({title:"Smart filter deleted"})}})}function vbs({currentFilters:t,currentSortBy:s,onApplySmartList:r}){const{data:n}=xbs(),a=gbs(),o=ybs(),[l,i]=S.useState(!1),[d,u]=S.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(K,{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(Fi,{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(K,{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(xr,{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(hs,{className:"max-w-sm",children:[e.jsx(js,{children:e.jsx(_s,{children:"Save Smart Filter"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Le,{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(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{onClick:f,disabled:!d.trim()||a.isPending,children:"Save"})]})]})]})})]})}function z7e(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:on,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:Sn,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=S.useRef(null),l=S.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:z7e(u.birthday),daysToAnniv:z7e(u.home_anniversary)};for(const f of B7e)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(jr,{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:B7e.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 sit="innercircle_geocode_cache_v1";function bbs(){try{return JSON.parse(localStorage.getItem(sit)||"{}")}catch{return{}}}function wbs(t){try{localStorage.setItem(sit,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=S.useRef(null),o=S.useRef(null),[l,i]=S.useState(""),[d,u]=S.useState(!0),[p,f]=S.useState([]),[y,_]=S.useState({done:0,total:0}),[b,N]=S.useState(!1),[w,k]=S.useState("heat");S.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]),S.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 ae=L[ce];ae!==null&&(ae?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:ae.lat,lng:ae.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=S.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 S.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]),S.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(hs,{className:"max-w-6xl w-[95vw] h-[90vh] p-0 flex flex-col",children:[e.jsx(js,{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(K,{size:"sm",variant:w==="heat"?"default":"ghost",onClick:()=>k("heat"),className:"h-8",children:[e.jsx(rd,{className:"h-3.5 w-3.5 mr-1"})," Heat"]}),e.jsxs(K,{size:"sm",variant:w==="points"?"default":"ghost",onClick:()=>k("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(ni,{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(Re,{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 q7e({birthday:t,homeAnniversary:s,className:r,contactId:n,contactName:a,contactAddress:o}){const l=vr(),i=$7e(t,"birthday",7),d=$7e(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:Dt("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:Dt("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:Dt("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 U7e({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 V7e({count:t,className:s}){return!t||t<=0?null:e.jsxs(Qe,{variant:"outline",className:Dt("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}=Mme(),{data:n}=dbs(t),a=BSe(),o=tit(),l=mbs(),[i,d]=S.useState(!1),[u,p]=S.useState(""),f=S.useRef(null),y=new Set((n==null?void 0:n.map(k=>k.tag_id))||[]),_=(r==null?void 0:r.filter(k=>k.name.toLowerCase().includes(u.toLowerCase())))||[],b=r==null?void 0:r.find(k=>k.name.toLowerCase()===u.trim().toLowerCase()),N=async k=>{y.has(k.id)?await l.mutateAsync({contactId:t,tagId:k.id}):await o.mutateAsync({contactId:t,tagId:k.id})},w=async()=>{if(!(!u.trim()||b))try{const k=await a.mutateAsync({name:u.trim()});await o.mutateAsync({contactId:t,tagId:k.id}),p("")}catch{}};return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n==null?void 0:n.map(k=>{var C,A,I;return e.jsxs(Qe,{variant:"outline",className:"text-xs gap-1 pr-1",style:{borderColor:((C=k.tag)==null?void 0:C.color)||"#6366F1",color:((A=k.tag)==null?void 0:A.color)||"#6366F1"},children:[e.jsx(mh,{className:"h-2.5 w-2.5"}),(I=k.tag)==null?void 0:I.name,e.jsx("button",{onClick:L=>{L.stopPropagation(),l.mutate({contactId:t,tagId:k.tag_id})},className:"ml-0.5 rounded-full hover:bg-accent p-0.5",children:e.jsx(jr,{className:"h-2.5 w-2.5"})})]},k.id)}),e.jsxs(yo,{open:i,onOpenChange:d,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:s?"h-6 w-6 p-0":"h-6 px-2 text-xs",onClick:k=>k.stopPropagation(),children:[e.jsx(Bs,{className:"h-3 w-3"}),!s&&e.jsx("span",{className:"ml-1",children:"Tag"})]})}),e.jsxs(uo,{className:"w-56 p-2",align:"start",onClick:k=>k.stopPropagation(),children:[e.jsx(Le,{ref:f,placeholder:"Search or create tag...",value:u,onChange:k=>p(k.target.value),onKeyDown:k=>{k.key==="Enter"&&u.trim()&&!b?(k.preventDefault(),w()):k.key==="Enter"&&b&&!y.has(b.id)&&(k.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(k=>e.jsxs("button",{onClick:()=>N(k),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:k.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:k.name}),y.has(k.id)&&e.jsx(Zn,{className:"h-3.5 w-3.5 text-primary shrink-0"})]},k.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(Bs,{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 H7e({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 _9=["#6366F1","#8B5CF6","#EC4899","#EF4444","#F97316","#F59E0B","#10B981","#14B8A6","#06B6D4","#3B82F6","#6B7280","#1F2937"];function Mbs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=Mme(),a=BSe(),o=hbs(),l=ubs(),[i,d]=S.useState(""),[u,p]=S.useState(_9[0]),[f,y]=S.useState(null),[_,b]=S.useState(""),[N,w]=S.useState(""),k=async()=>{if(i.trim())try{await a.mutateAsync({name:i.trim(),color:u}),d(""),p(_9[0]),pn({title:"Tag created"})}catch(L){pn({title:"Error",description:L.message,variant:"destructive"})}},C=async L=>{if(_.trim())try{await o.mutateAsync({id:L,name:_.trim(),color:N}),y(null),pn({title:"Tag updated"})}catch(O){pn({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),pn({title:"Tag deleted"})}catch(V){pn({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(hs,{className:"max-w-md",children:[e.jsx(js,{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(Le,{placeholder:"New tag name...",value:i,onChange:L=>d(L.target.value),onKeyDown:L=>L.key==="Enter"&&k(),className:"flex-1 h-9"}),e.jsxs(K,{size:"sm",onClick:k,disabled:!i.trim()||a.isPending,className:"h-9",children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Add"]})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:_9.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:_9.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(Le,{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(K,{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(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>y(null),children:e.jsx(jr,{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(K,{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(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity text-destructive hover:text-destructive",onClick:()=>A(L.id,L.name),children:e.jsx(xr,{className:"h-3.5 w-3.5"})})]})},L.id))]})]})})}function Tbs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=JA(),a=lke(),o=p8t(),l=f8t(),[i,d]=S.useState(""),[u,p]=S.useState(null),[f,y]=S.useState(""),_=async()=>{if(i.trim())try{await a.mutateAsync(i.trim()),d("")}catch(k){pe.error(k.message||"Failed to add lead source")}},b=async k=>{if(f.trim())try{await o.mutateAsync({id:k,name:f.trim()}),p(null)}catch(C){pe.error(C.message||"Failed to update")}},N=async(k,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(k)}catch(A){pe.error(A.message||"Failed to remove")}},w=k=>{p(k.id),y(k.name)};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(hs,{className:"max-w-md",children:[e.jsx(js,{children:e.jsx(_s,{children:"Manage Lead Sources"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{placeholder:"New lead source name...",value:i,onChange:k=>d(k.target.value),onKeyDown:k=>k.key==="Enter"&&_(),className:"flex-1 h-9"}),e.jsxs(K,{size:"sm",onClick:_,disabled:!i.trim()||a.isPending,className:"h-9",children:[e.jsx(Bs,{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(k=>e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg hover:bg-accent/50 group",children:u===k.id?e.jsxs(e.Fragment,{children:[e.jsx(Le,{value:f,onChange:C=>y(C.target.value),onKeyDown:C=>C.key==="Enter"&&b(k.id),className:"flex-1 h-8 text-sm",autoFocus:!0}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>b(k.id),children:e.jsx(Zn,{className:"h-4 w-4 text-primary"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>p(null),children:e.jsx(jr,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1 text-sm",children:k.name}),k.owner_user_id&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>w(k),children:e.jsx(ga,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity text-destructive hover:text-destructive",onClick:()=>N(k.id,k.name),children:e.jsx(xr,{className:"h-3.5 w-3.5"})})]}),!k.owner_user_id&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Default"})]})},k.id))]})]})})}function rit({value:t,onChange:s,label:r="Lead Source"}){const{data:n}=JA(),a=lke(),[o,l]=S.useState(!1),[i,d]=S.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(Fs,{value:t||"_none",onValueChange:p=>s(p==="_none"?"":p),children:[e.jsx(Ds,{className:"flex-1",children:e.jsx(zs,{placeholder:"Select lead source"})}),e.jsxs(Rs,{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(K,{type:"button",variant:"outline",size:"icon",className:"shrink-0",onClick:()=>l(!o),children:o?e.jsx(jr,{className:"h-4 w-4"}):e.jsx(Bs,{className:"h-4 w-4"})})]}),o&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{placeholder:"New lead source name...",value:i,onChange:p=>d(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),u())},className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:u,disabled:!i.trim()||a.isPending,children:"Add"})]})]})}function Ewe({contactId:t,currentSpouseContactId:s,currentSpouseName:r,currentSpouseEmail:n,onLink:a,onUnlink:o,isEditing:l}){const i=vr(),[d,u]=S.useState(!1),[p,f]=S.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(K,{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(K,{variant:"ghost",size:"sm",onClick:()=>i(`/mission-control/contacts/${y.id}`),className:"shrink-0 h-7 px-2",children:e.jsx(Ga,{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(yo,{open:d,onOpenChange:u,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{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(uo,{className:"w-72 p-2",align:"end",children:e.jsx(G7e,{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(yo,{open:d,onOpenChange:u,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{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(uo,{className:"w-72 p-2",align:"start",children:e.jsx(G7e,{search:p,setSearch:f,results:_,onSelect:b=>{a(b),u(!1),f("")}})})]})]}):null}function G7e({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(an,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Le,{value:t,onChange:a=>s(a.target.value),placeholder:"Search contacts...",className:"pl-7 h-8 text-sm",autoFocus:!0})]}),e.jsx(ni,{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=vr(),[s,r]=Nc(),{user:n}=qs(),a=bE(),o=Qt(),l=s.get("type"),i=s.get("filter")??s.get("status"),d=s.get("new")==="true",{contactsWithScores:u,isLoading:p}=ohe(),{activeContactIds:f,hasLeadSite:y}=$_s(),{data:_}=kbs(),{data:b}=Nf(),{data:N}=Sbs(),{data:w}=Mme(),{data:k}=pbs(),[C,A]=S.useState(new Set),[I,L]=S.useState("any"),O=rhe(),V=ake(),q=ike(),B=bXe(),[U,te]=S.useState(""),[Y,J]=S.useState(!1),[X,ce]=S.useState(l||"all"),[ae,ie]=S.useState(i||"all"),[oe,me]=S.useState("date-added"),[ye,he]=S.useState(d),[ge,Ne]=S.useState(null),[Ue,Te]=S.useState(!1),[Me,De]=S.useState(!1),[qe,ke]=S.useState(null),[$e,Be]=S.useState(""),[we,ut]=S.useState(new Set),[fe,He]=S.useState(!1),et=Math.max(1,parseInt(s.get("page")||"1",10)||1),[tt,_e]=S.useState(et),Ge=S.useCallback(Zt=>{_e(Er=>{const Bt=typeof Zt=="function"?Zt(Er):Zt;return r(Se=>{const Oe=new URLSearchParams(Se);return Bt<=1?Oe.delete("page"):Oe.set("page",String(Bt)),Oe},{replace:!0}),Bt})},[]),[We,it]=S.useState(50),[Ve,Xe]=S.useState("my"),[dt,pt]=S.useState(!1),[Je,Ze]=S.useState(!1),{data:Nt}=Px(),{addToLeadPond:Ot}=mtt(Nt==null?void 0:Nt.teamId),Yt=!!((La=Nt==null?void 0:Nt.team)!=null&&La.lead_pond_enabled&&(Nt!=null&&Nt.teamId)),Ps=!!(Nt!=null&&Nt.teamId),[$s,Zs]=S.useState([]),[Dr,$t]=S.useState(!1),Us=Zt=>{Zs([Zt]),$t(!0)},Nr=Zt=>{Zs(Zt),$t(!0)},Xs=Zt=>{Nt!=null&&Nt.teamId&&Ot.mutate({contact_id:Zt,team_id:Nt.teamId})},kr=Zt=>{Nt!=null&&Nt.teamId&&Zt.forEach(Er=>{Ot.mutate({contact_id:Er,team_id:Nt.teamId})})},fn=S.useCallback(Zt=>{He(!1),ut(Er=>{const Bt=new Set(Er);return Bt.has(Zt)?Bt.delete(Zt):Bt.add(Zt),Bt})},[]);S.useEffect(()=>{if(!(n!=null&&n.id))return;const Zt=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(Zt)}},[o,n==null?void 0:n.id]),S.useEffect(()=>{i&&ie(i)},[i]);const[Yr,$r]=S.useState({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]});S.useEffect(()=>{d&&he(!0)},[d]),S.useEffect(()=>{var Zt;ge&&$r({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:((Zt=ge.tags)==null?void 0:Zt.map(Er=>Er.relationship_type_id))||[]})},[ge]);const Gr=S.useMemo(()=>{if(!u)return[];let Zt=u.filter(Er=>{var Ye,yt,bt,Tt,Ht;const Bt=U===""||`${Er.first_name} ${Er.last_name}`.toLowerCase().includes(U.toLowerCase())||((Ye=Er.email)==null?void 0:Ye.toLowerCase().includes(U.toLowerCase()))||((yt=Er.phone)==null?void 0:yt.includes(U))||((bt=Er.city)==null?void 0:bt.toLowerCase().includes(U.toLowerCase()))||((Tt=Er.state)==null?void 0:Tt.toLowerCase().includes(U.toLowerCase())),Se=X==="all"||((Ht=Er.tags)==null?void 0:Ht.some(Ut=>Ut.relationship_type_id===X)),Oe=C.size===0||(()=>{const Ut=(k==null?void 0:k.filter(Xt=>Xt.contact_id===Er.id).map(Xt=>Xt.tag_id))||[];return I==="any"?Ut.some(Xt=>C.has(Xt)):Array.from(C).every(Xt=>Ut.includes(Xt))})();return Bt&&Se&&Oe});return ae==="not-touched-90"?Zt=Zt.filter(Er=>{const Bt=Er.relationshipScore.daysSinceTouch;return Bt===null||Bt>90}):ae==="at-risk"?Zt=Zt.filter(Er=>Er.relationshipScore.status==="at-risk"):ae==="cooling"?Zt=Zt.filter(Er=>Er.relationshipScore.status==="cooling"):ae==="warm"?Zt=Zt.filter(Er=>Er.relationshipScore.status==="warm"):ae==="has-deal"?Zt=Zt.filter(Er=>N&&N[Er.id]):ae==="no-deal"?Zt=Zt.filter(Er=>!N||!N[Er.id]):ae==="open-house"?Zt=Zt.filter(Er=>{var Se;return(((Se=Er.lead_source_ref)==null?void 0:Se.name)||Er.lead_source)==="Open House"}):ae==="website-active"?Zt=Zt.filter(Er=>f.has(Er.id)):ae==="never-contacted"?Zt=Zt.filter(Er=>Er.relationshipScore.daysSinceTouch===null):ae==="vips"?Zt=Zt.filter(Er=>Er.relationshipScore.score>=80):ae==="missing-info"?Zt=Zt.filter(Er=>{var Bt,Se;return!((Bt=Er.email)!=null&&Bt.trim())&&!((Se=Er.phone)!=null&&Se.trim())}):ae==="birthdays-soon"?Zt=Zt.filter(Er=>{const Bt=l4(Er.birthday);return Bt!==null&&Bt<=30}):ae==="anniversary-soon"&&(Zt=Zt.filter(Er=>{const Bt=l4(Er.home_anniversary);return Bt!==null&&Bt<=30})),Zt=[...Zt].sort((Er,Bt)=>{switch(oe){case"important-dates":{const Se=l4(Er.birthday),Oe=l4(Bt.birthday),Ye=l4(Er.home_anniversary),yt=l4(Bt.home_anniversary),bt=[Se,Ye].filter(Ht=>Ht!==null).sort((Ht,Ut)=>(Ht??1/0)-(Ut??1/0))[0]??1/0,Tt=[Oe,yt].filter(Ht=>Ht!==null).sort((Ht,Ut)=>(Ht??1/0)-(Ut??1/0))[0]??1/0;return bt-Tt}case"last-touched":{const Se=Er.relationshipScore.lastTouchDate,Oe=Bt.relationshipScore.lastTouchDate;return!Se&&!Oe?0:Se?Oe?new Date(Se).getTime()-new Date(Oe).getTime():1:-1}case"next-touch":{const Se=Er.relationshipScore.daysSinceTouch,Oe=Bt.relationshipScore.daysSinceTouch;return Se===null&&Oe===null?0:Se===null?-1:Oe===null?1:Oe-Se}case"score":return Er.relationshipScore.score-Bt.relationshipScore.score;case"date-added":{const Se=Er.created_at,Oe=Bt.created_at;return!Se&&!Oe?0:Se?Oe?new Date(Oe).getTime()-new Date(Se).getTime():-1:1}case"name":default:{const Se=`${Er.first_name||""} ${Er.last_name||""}`.toLowerCase(),Oe=`${Bt.first_name||""} ${Bt.last_name||""}`.toLowerCase();return Se.localeCompare(Oe)}}}),Zt},[u,U,X,C,I,ae,oe,N,k,f]),nr=Gr.length,lr=Math.max(1,Math.ceil(nr/We)),Fr=Math.min(tt,lr),Wr=S.useMemo(()=>{const Zt=(Fr-1)*We;return Gr.slice(Zt,Zt+We)},[Gr,Fr,We]),Nn=S.useRef(!1);S.useEffect(()=>{if(!Nn.current){Nn.current=!0;return}Ge(1)},[U,X,C,I,ae,oe]);const ai=S.useCallback(()=>{He(!1),ut(Zt=>Zt.size>0?new Set:new Set(Wr.map(Er=>Er.id)))},[Wr]),ns=S.useCallback(()=>{He(!0),ut(new Set(Gr.map(Zt=>Zt.id)))},[Gr]),$n=S.useCallback((Zt,Er)=>{te(Zt.search||""),ce(Zt.type||"all"),ie(Zt.status||"all"),me(Er||"name")},[]),dn=()=>{$r({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]})},zr=async Zt=>{Zt.preventDefault();const Er={...Yr,lead_source_id:Yr.lead_source_id||null};ge?(await V.mutateAsync({id:ge.id,...Er}),Ne(null)):(await O.mutateAsync(Er),he(!1)),dn()},Kr=async Zt=>{confirm("Are you sure you want to delete this contact?")&&await q.mutateAsync(Zt)};return e.jsx(Es,{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"})]}),Nt&&e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsx("button",{onClick:()=>Xe("my"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${Ve==="my"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"My Contacts"}),(Nt.team.contact_visibility==="full_team"||Nt.team.contact_visibility==="leader_only"&&Nt.role==="team_leader")&&e.jsxs("button",{onClick:()=>Xe("team"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${Ve==="team"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(or,{className:"h-3.5 w-3.5"}),"Team"]}),Nt.team.lead_pond_enabled&&e.jsxs("button",{onClick:()=>Xe("lead-pond"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${Ve==="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(K,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control"),children:[e.jsx(Xo,{className:"h-4 w-4 mr-1"}),"Back"]})}),Ve==="team"?e.jsx(m4e,{}):Ve==="lead-pond"&&Nt?e.jsx(p4e,{teamId:Nt.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"}[ae]??null,onSelect:Zt=>{const Bt=Zt?{"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"}[Zt]:"all";ie(Bt),Ge(1)}}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name, email, or phone...",value:U,onChange:Zt=>te(Zt.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"space-y-2 sm:space-y-0",children:[e.jsxs(K,{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(K,{onClick:()=>he(!0),className:"h-10 w-full justify-center",children:[e.jsx(Bs,{className:"h-4 w-4 mr-1.5"}),e.jsx("span",{className:"truncate",children:"Add Contact"})]}),e.jsxs(K,{variant:"outline",onClick:()=>Te(!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(K,{variant:"outline",onClick:()=>De(!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(O7e,{})})]}),e.jsxs("div",{className:"hidden sm:flex items-center gap-2 flex-wrap",children:[e.jsxs(K,{onClick:()=>he(!0),className:"shrink-0",children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Add Contact"]}),e.jsxs(K,{variant:"outline",onClick:()=>Te(!0),className:"shrink-0",children:[e.jsx(Ra,{className:"h-4 w-4 mr-1"}),"Import CSV"]}),e.jsxs(K,{variant:"outline",onClick:()=>De(!0),className:"shrink-0",children:[e.jsx(Ig,{className:"h-4 w-4 mr-1"}),"Import from Phone"]}),e.jsx(O7e,{}),e.jsxs(K,{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(Fs,{value:X,onValueChange:ce,children:[e.jsx(Ds,{className:"w-[145px] h-9 text-sm",children:e.jsx(zs,{placeholder:"Filter by type"})}),e.jsxs(Rs,{children:[e.jsx(vt,{value:"all",children:"All Types"}),b==null?void 0:b.filter(Zt=>Zt.active).map(Zt=>e.jsx(vt,{value:Zt.id,children:Zt.name},Zt.id))]})]}),w&&w.length>0&&e.jsxs(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{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(uo,{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(Zt=>{const Er=C.has(Zt.id);return e.jsxs("button",{onClick:()=>{A(Bt=>{const Se=new Set(Bt);return Se.has(Zt.id)?Se.delete(Zt.id):Se.add(Zt.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(Hi,{checked:Er,className:"pointer-events-none"}),e.jsx("div",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:Zt.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:Zt.name})]},Zt.id)})}),C.size>0&&e.jsx(K,{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(K,{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:()=>pt(!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(Fs,{value:ae,onValueChange:ie,children:[e.jsx(Ds,{className:"w-[145px] h-9 text-sm",children:e.jsx(zs,{placeholder:"Filter by status"})}),e.jsxs(Rs,{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(Fs,{value:oe,onValueChange:me,children:[e.jsx(Ds,{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(zs,{placeholder:"Sort by"})]})}),e.jsxs(Rs,{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:ae},currentSortBy:oe,onApplySmartList:$n})]})]})})}),e.jsx(fbs,{selectedIds:we,contacts:Gr,onClearSelection:()=>{ut(new Set),He(!1)},showLeadPondAction:Yt,onSendToLeadPond:kr,showTransferAction:Ps,onTransfer:Nr}),we.size>0&&we.size===Wr.length&&!fe&&nr>We&&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 ",Wr.length," contacts on this page are selected."]}),e.jsxs(K,{variant:"link",size:"sm",className:"h-auto p-0 font-semibold",onClick:ns,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(K,{variant:"link",size:"sm",className:"h-auto p-0",onClick:()=>{ut(new Set),He(!1)},children:"Clear selection"})]}),nr>We&&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 ",(Fr-1)*We+1,"–",Math.min(Fr*We,nr)," of ",nr.toLocaleString()," contacts"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"sm",disabled:Fr<=1,onClick:()=>Ge(1),children:"First"}),e.jsx(K,{variant:"outline",size:"sm",disabled:Fr<=1,onClick:()=>Ge(Zt=>Zt-1),children:e.jsx(Xo,{className:"h-4 w-4"})}),e.jsxs("span",{className:"px-3 text-sm font-medium",children:["Page ",Fr," of ",lr]}),e.jsx(K,{variant:"outline",size:"sm",disabled:Fr>=lr,onClick:()=>Ge(Zt=>Zt+1),children:e.jsx(xa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"sm",disabled:Fr>=lr,onClick:()=>Ge(lr),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..."}):Gr.length===0?e.jsx(Pe,{className:"p-6 text-center text-muted-foreground",children:U||X!=="all"||ae!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"}):Wr.map(Zt=>{var Bt,Se,Oe;const{relationshipScore:Er}=Zt;return e.jsx(Pe,{className:"cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>{const Ye=new URLSearchParams;U&&Ye.set("search",U),X!=="all"&&Ye.set("type",X),ae!=="all"&&Ye.set("filter",ae);const yt=Ye.toString();t(`/mission-control/contacts/${Zt.id}${yt?`?${yt}`:""}`)},children:e.jsx(Re,{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:[Zt.first_name," ",Zt.last_name]}),e.jsx(V7e,{count:(_==null?void 0:_[Zt.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:[Zt.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:Zt.email})]}),Zt.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:Zt.phone})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1 mb-2",children:[e.jsx(M8,{score:Er,size:"sm"}),e.jsx(Awe,{contact:Zt}),(((Bt=Zt.lead_source_ref)==null?void 0:Bt.name)||Zt.lead_source)&&e.jsx(Qe,{variant:"outline",className:"text-xs gap-1 border-primary/30 text-primary",children:((Se=Zt.lead_source_ref)==null?void 0:Se.name)||Zt.lead_source}),(Oe=Zt.tags)==null?void 0:Oe.map(Ye=>{var yt;return e.jsx(Qe,{variant:"secondary",className:"text-xs",children:(yt=Ye.relationship_type)==null?void 0:yt.name},Ye.id)}),e.jsx(H7e,{contactId:Zt.id,tags:k==null?void 0:k.filter(Ye=>Ye.contact_id===Zt.id)}),e.jsx(U7e,{deal:N==null?void 0:N[Zt.id]})]}),e.jsx(q7e,{birthday:Zt.birthday,homeAnniversary:Zt.home_anniversary,className:"mb-2",contactId:Zt.id,contactName:`${Zt.first_name}${Zt.last_name?" "+Zt.last_name:""}`,contactAddress:[Zt.address,Zt.city,Zt.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[Er.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(on,{className:"h-3 w-3"}),gs(new Date(Er.lastTouchDate),"MMM d")]}):e.jsx("span",{className:"italic",children:"Never contacted"}),Zt.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ln,{className:"h-3 w-3"}),gs(ol(Zt.birthday),"MMM d")]}),Zt.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Sn,{className:"h-3 w-3"}),gs(ol(Zt.home_anniversary),"MMM d")]}),Zt.created_at&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Bs,{className:"h-3 w-3"}),"Added ",gs(new Date(Zt.created_at),"MMM d, yyyy")]})]})]}),e.jsx("div",{className:"ml-2",onClick:Ye=>Ye.stopPropagation(),children:e.jsx(F7e,{contact:Zt,onEdit:Ne,onDelete:Kr,onSnooze:(Ye,yt)=>{ke(Ye),Be(yt)},showLeadPondAction:Yt,onSendToLeadPond:Xs,showTransferAction:Ps,onTransfer:Us})})]})})},Zt.id)})}):e.jsx(Pe,{children:e.jsx(Re,{className:"p-0 overflow-x-auto",children:e.jsxs(Ln,{className:"min-w-[800px]",children:[e.jsx(Dn,{children:e.jsxs(Ms,{children:[e.jsx(kt,{className:"w-[40px]",children:e.jsx(Hi,{checked:Wr.length>0&&Wr.every(Zt=>we.has(Zt.id)),onCheckedChange:()=>ai()})}),e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{children:"Score"}),e.jsx(kt,{children:"Contact Info"}),e.jsx(kt,{children:"Types / Pipeline"}),e.jsx(kt,{children:"Last Contact"}),e.jsx(kt,{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(kt,{children:"Important Dates"}),e.jsx(kt,{className:"w-[50px]",children:"Actions"})]})}),e.jsx(Rn,{children:p?e.jsx(Ms,{children:e.jsx(ht,{colSpan:10,className:"text-center py-8",children:"Loading contacts..."})}):Gr.length===0?e.jsx(Ms,{children:e.jsx(ht,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:U||X!=="all"||ae!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"})}):Wr.map(Zt=>{var Se,Oe,Ye;const{relationshipScore:Er}=Zt,Bt=N==null?void 0:N[Zt.id];return e.jsxs(Ms,{className:`cursor-pointer hover:bg-accent/50 ${we.has(Zt.id)?"bg-accent/30":""}`,onClick:()=>{const yt=new URLSearchParams;U&&yt.set("search",U),X!=="all"&&yt.set("type",X),ae!=="all"&&yt.set("status",ae);const bt=yt.toString();t(`/mission-control/contacts/${Zt.id}${bt?`?${bt}`:""}`)},children:[e.jsx(ht,{onClick:yt=>yt.stopPropagation(),children:e.jsx(Hi,{checked:we.has(Zt.id),onCheckedChange:()=>fn(Zt.id)})}),e.jsx(ht,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{children:[Zt.first_name," ",Zt.last_name]}),e.jsx(V7e,{count:(_==null?void 0:_[Zt.id])??0})]})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(M8,{score:Er,size:"sm"}),e.jsx(Awe,{contact:Zt})]})}),e.jsx(ht,{children:e.jsx(M8,{score:Er,size:"sm",showScore:!0})}),e.jsx(ht,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[Zt.email&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(tr,{className:"h-3 w-3"}),Zt.email]}),Zt.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(In,{className:"h-3 w-3"}),Zt.phone]})]})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(((Se=Zt.lead_source_ref)==null?void 0:Se.name)||Zt.lead_source)&&e.jsx(Qe,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((Oe=Zt.lead_source_ref)==null?void 0:Oe.name)||Zt.lead_source}),(Ye=Zt.tags)==null?void 0:Ye.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(H7e,{contactId:Zt.id,tags:k==null?void 0:k.filter(yt=>yt.contact_id===Zt.id)}),e.jsx(U7e,{deal:Bt})]})}),e.jsx(ht,{children:e.jsx("div",{className:"text-sm",children:Er.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(on,{className:"h-3 w-3"}),gs(new Date(Er.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:Zt.created_at?gs(new Date(Zt.created_at),"MMM d, yyyy"):"—"})}),e.jsx(ht,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx(q7e,{birthday:Zt.birthday,homeAnniversary:Zt.home_anniversary,contactId:Zt.id,contactName:`${Zt.first_name}${Zt.last_name?" "+Zt.last_name:""}`,contactAddress:[Zt.address,Zt.city,Zt.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Zt.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ln,{className:"h-3 w-3"}),gs(ol(Zt.birthday),"MMM d")]}),Zt.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Sn,{className:"h-3 w-3"}),gs(ol(Zt.home_anniversary),"MMM d")]})]})]})}),e.jsx(ht,{children:e.jsx(F7e,{contact:Zt,onEdit:Ne,onDelete:Kr,onSnooze:(yt,bt)=>{ke(yt),Be(bt)},showLeadPondAction:Yt,onSendToLeadPond:Xs,showTransferAction:Ps,onTransfer:Us})})]},Zt.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 ",(Fr-1)*We+1,"–",Math.min(Fr*We,nr)," of ",nr.toLocaleString()," contacts"]}),e.jsxs(Fs,{value:String(We),onValueChange:Zt=>{it(Number(Zt)),Ge(1)},children:[e.jsx(Ds,{className:"w-[80px] h-8",children:e.jsx(zs,{})}),e.jsxs(Rs,{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(K,{variant:"outline",size:"sm",disabled:Fr<=1,onClick:()=>Ge(1),children:"First"}),e.jsx(K,{variant:"outline",size:"sm",disabled:Fr<=1,onClick:()=>Ge(Zt=>Zt-1),children:e.jsx(Xo,{className:"h-4 w-4"})}),e.jsxs("span",{className:"px-3 text-sm font-medium",children:["Page ",Fr," of ",lr]}),e.jsx(K,{variant:"outline",size:"sm",disabled:Fr>=lr,onClick:()=>Ge(Zt=>Zt+1),children:e.jsx(xa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"sm",disabled:Fr>=lr,onClick:()=>Ge(lr),children:"Last"})]})]}),e.jsx(fs,{open:ye||!!ge,onOpenChange:Zt=>{Zt||(he(!1),Ne(null),dn())},children:e.jsxs(hs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:ge?"Edit Contact":"Add Contact"})}),e.jsxs("form",{onSubmit:zr,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(Le,{id:"first_name",value:Yr.first_name,onChange:Zt=>$r({...Yr,first_name:Zt.target.value}),required:!0})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"last_name",children:"Last Name"}),e.jsx(Le,{id:"last_name",value:Yr.last_name,onChange:Zt=>$r({...Yr,last_name:Zt.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"email",children:"Email"}),e.jsx(Le,{id:"email",type:"email",value:Yr.email,onChange:Zt=>$r({...Yr,email:Zt.target.value})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"phone",children:"Phone"}),e.jsx(Le,{id:"phone",value:Yr.phone,onChange:Zt=>$r({...Yr,phone:Zt.target.value})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"address",children:"Address"}),e.jsx(Le,{id:"address",value:Yr.address,onChange:Zt=>$r({...Yr,address:Zt.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(Le,{id:"city",value:Yr.city,onChange:Zt=>$r({...Yr,city:Zt.target.value})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"state",children:"State"}),e.jsx(Le,{id:"state",value:Yr.state,onChange:Zt=>$r({...Yr,state:Zt.target.value})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"zip_code",children:"Zip"}),e.jsx(Le,{id:"zip_code",value:Yr.zip_code,onChange:Zt=>$r({...Yr,zip_code:Zt.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(Le,{id:"birthday",type:"date",value:Yr.birthday,onChange:Zt=>$r({...Yr,birthday:Zt.target.value})})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(Le,{id:"home_anniversary",type:"date",value:Yr.home_anniversary,onChange:Zt=>$r({...Yr,home_anniversary:Zt.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:Zt=>B.mutate({contactId:ge.id,spouseContactId:Zt}),onUnlink:()=>B.mutate({contactId:ge.id,spouseContactId:null}),isEditing:!0}),e.jsx(rit,{value:Yr.lead_source_id,onChange:Zt=>$r({...Yr,lead_source_id:Zt})}),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(Zt=>Zt.active).map(Zt=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Hi,{checked:Yr.tagIds.includes(Zt.id),onCheckedChange:Er=>{$r(Er?{...Yr,tagIds:[...Yr.tagIds,Zt.id]}:{...Yr,tagIds:Yr.tagIds.filter(Bt=>Bt!==Zt.id)})}}),e.jsx("span",{className:"text-sm",children:Zt.name})]},Zt.id))})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"notes",children:"Notes"}),e.jsx(gr,{id:"notes",value:Yr.notes,onChange:Zt=>$r({...Yr,notes:Zt.target.value}),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>{he(!1),Ne(null),dn()},children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:O.isPending||V.isPending,children:[ge?"Update":"Create"," Contact"]})]})]})]})}),e.jsx(H_s,{open:Ue,onOpenChange:Te,relationshipTypes:(b==null?void 0:b.filter(Zt=>Zt.active))||[],onSuccess:()=>{Te(!1)}}),e.jsx(K_s,{open:Me,onOpenChange:De,onComplete:()=>De(!1)}),e.jsx(Nme,{open:!!qe,onOpenChange:Zt=>{Zt||ke(null)},contactId:qe||"",contactName:$e}),e.jsx(Mbs,{open:dt,onOpenChange:pt}),e.jsx(Tbs,{open:Je,onOpenChange:Ze}),e.jsx(Nbs,{open:Y,onOpenChange:J,contacts:u||[],onCitySelect:Zt=>{te(Zt),Ge(1)}}),e.jsx(ptt,{open:Dr,onOpenChange:$t,contactIds:$s,contactNames:$s.map(Zt=>{const Er=Gr.find(Bt=>Bt.id===Zt);return Er?`${Er.first_name} ${Er.last_name||""}`.trim():""}),onComplete:()=>{Zs([]),ut(new Set),He(!1)}})]})]})})}const Ebs="9a88a47c-cb2a-4401-a2b5-111a76b19f9d";function Pbs({open:t,onOpenChange:s,contact:r}){var Y;const{user:n}=qs(),a=vr(),o=Qt(),{intakePage:l,isLoading:i}=kme(),{isGmailConnected:d,gmailEmail:u}=jp(),p=nhe(),{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=S.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,k]=S.useState("gmail"),[C,A]=S.useState(""),[I,L]=S.useState(""),[O,V]=S.useState(!1);S.useEffect(()=>{t&&(A(`Quick favor, ${r.first_name} — can you update your info?`),L(N),k(d?"gmail":"system"))},[t,N,r.first_name,d]);const q=S.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(hs,{className:"sm:max-w-[720px] max-h-[92vh] overflow-y-auto",children:[e.jsxs(js,{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=>k(J),className:"mt-1.5",children:e.jsxs(Jn,{className:"grid w-full grid-cols-2",children:[e.jsxs(ls,{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(ls,{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(Le,{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(gr,{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(Zr,{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(K,{variant:"outline",onClick:()=>s(!1),disabled:O,children:"Cancel"}),e.jsx(K,{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(Mn,{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(K,{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}=qs();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}=qs(),s=Qt();return Et({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}=qs();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}=qs(),s=Qt();return Et({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 Et({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 Et({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 Tme(){const{user:t}=qs();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 nit(){const{data:t,isLoading:s}=Tme(),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}=qs(),s=Qt();return Et({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 $Se(){const t=ya(),s=Qt();return Et({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 _O(){const t=Qt();return Et({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 Et({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 Et({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 Et({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 ait(){const t=Qt();return Et({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 Et({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 Et({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 Et({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=vr(),r=Qt(),[n,a]=S.useState(null),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState(""),[f,y]=S.useState(""),[_,b]=S.useState(null),N=_O(),w=ait(),{data:k,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=(k==null?void 0:k.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||!k||k.length===0?null:e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(nd,{className:"h-4 w-4"}),"Client Portal"]})}),e.jsx(Re,{className:"space-y-3",children:k.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:gs(new Date(te.created_at),"MMM d, yyyy")})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>L(q.slug),children:[n===q.slug?e.jsx(Zn,{className:"h-3 w-3 mr-1"}):e.jsx(Wa,{className:"h-3 w-3 mr-1"}),"Copy Link"]}),e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>window.open(o1(q.slug),"_blank"),children:[e.jsx(Zr,{className:"h-3 w-3 mr-1"}),"View"]}),e.jsxs(fs,{open:i,onOpenChange:d,children:[e.jsx(hi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>d(!0),children:[e.jsx(Si,{className:"h-3 w-3 mr-1"}),"Post Update"]})}),e.jsxs(hs,{children:[e.jsx(js,{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(Le,{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(gr,{value:f,onChange:ce=>y(ce.target.value),placeholder:"Add more details...",rows:3})]}),e.jsxs(K,{onClick:()=>O(q.id),disabled:!u.trim()||w.isPending,className:"w-full",children:[e.jsx(Mn,{className:"h-4 w-4 mr-1"}),"Post Update"]})]})]})]}),e.jsxs(fs,{open:o,onOpenChange:l,children:[e.jsx(hi,{asChild:!0,children:e.jsxs(K,{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(hs,{children:[e.jsx(js,{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(Mr,{checked:_.is_enabled,onCheckedChange:ce=>b({..._,is_enabled:ce})})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Welcome Message"}),e.jsx(gr,{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(Le,{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(Le,{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(Mr,{checked:_.show_post_close_tips,onCheckedChange:ce=>b({..._,show_post_close_tips:ce})})]}),e.jsx(xo,{}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{onClick:V,disabled:N.isPending,className:"flex-1",children:"Save Settings"}),e.jsxs(K,{variant:"outline",onClick:()=>s(`/mission-control/pipeline?deal=${q.deal_id}`),children:[e.jsx(Ga,{className:"h-4 w-4 mr-1"}),"Full Settings"]})]})]})]})]})]}),k.length>1&&e.jsx(xo,{})]},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(Lt,{className:"pb-2",children:e.jsxs(Ft,{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(Cn,{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(Re,{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(Sn,{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(on,{className:"h-3 w-3"}),e.jsx("span",{title:gs(new Date(l.viewed_at),"PPp"),children:Nl(new Date(l.viewed_at),{addSuffix:!0})})]})]}),i&&e.jsx(Zr,{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 W7e({value:t,onChange:s,onAdd:r,suggestions:n,placeholder:a,icon:o}){const[l,i]=S.useState(!1),d=S.useRef(null),u=S.useRef(null);S.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(Le,{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(Fi,{className:"absolute right-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground pointer-events-none"})]}),e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:()=>r(t),children:e.jsx(Bs,{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}=qs(),n=ya(),{hasLeadSite:a}=CC(),o=Qt(),[l,i]=S.useState(!1),[d,u]=S.useState(""),[p,f]=S.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 ae=Array.isArray(X.searchZipCodes)?X.searchZipCodes:[];return{cities:ce,zipCodes:ae}},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]=S.useState({}),k=()=>{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=Et({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=Et({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(Lt,{className:"pb-2",children:e.jsxs(Ft,{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(Re,{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(K,{variant:"outline",size:"sm",onClick:k,className:"flex-1",children:"Manage Alert"}),e.jsxs(K,{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(jr,{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(Lt,{className:"pb-3",children:e.jsxs(Ft,{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(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{children:"Alert Active"}),e.jsx(Mr,{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(Le,{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(Le,{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(Fs,{value:N.min_beds?String(N.min_beds):"any",onValueChange:Y=>w(J=>({...J,min_beds:Y==="any"?null:Number(Y)})),children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Any"})}),e.jsxs(Rs,{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(Fs,{value:N.min_baths?String(N.min_baths):"any",onValueChange:Y=>w(J=>({...J,min_baths:Y==="any"?null:Number(Y)})),children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Any"})}),e.jsxs(Rs,{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(Le,{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(Le,{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(W7e,{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(jr,{className:"h-3 w-3"})})]},Y))})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"mb-1.5",children:"Zip Codes"}),e.jsx(W7e,{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(jr,{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(Sn,{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(Fs,{value:N.frequency||"daily",onValueChange:Y=>w(J=>({...J,frequency:Y})),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsxs(Rs,{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(K,{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(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),_&&e.jsx(K,{variant:"destructive",size:"icon",onClick:()=>A.mutate(),disabled:A.isPending,children:e.jsx(jr,{className:"h-4 w-4"})})]})]})]}):e.jsx(Pe,{className:"overflow-hidden",children:e.jsx(Re,{className:"p-4",children:e.jsxs("button",{onClick:k,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 ae;const{user:r}=qs(),n=ya(),{hasLeadSite:a}=CC(),o=Qt(),[l,i]=S.useState(!1),[d,u]=S.useState(""),[p,f]=S.useState([]),[y,_]=S.useState(!1),[b,N]=S.useState(!1),[w,k]=S.useState(!1),[C,A]=S.useState(""),I=S.useRef(null),L=S.useRef(null),{data:O}=gt({queryKey:["agent-lead-site-cities",n],queryFn:async()=>{const{data:ie,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||!ie)return[];const me=ie.theme_config||{},ye=Array.isArray(me.searchCities)?me.searchCities:[];return ie.mls_market_area&&!ye.includes(ie.mls_market_area)&&ye.unshift(ie.mls_market_area),ye},enabled:!!n}),{data:V,isLoading:q}=gt({queryKey:["contact-market-report",t],queryFn:async()=>{const{data:ie,error:oe}=await G.from("innercircle_contacts").select("market_report_enabled, market_report_cities").eq("id",t).single();if(oe)throw oe;return ie},enabled:!!t&&!!r});S.useEffect(()=>{const ie=oe=>{L.current&&!L.current.contains(oe.target)&&I.current&&!I.current.contains(oe.target)&&N(!1)};return document.addEventListener("mousedown",ie),()=>document.removeEventListener("mousedown",ie)},[]);const B=()=>{_((V==null?void 0:V.market_report_enabled)??!1),f((V==null?void 0:V.market_report_cities)??[]),i(!0)},U=ie=>{const oe=(ie||d).trim();oe&&!p.includes(oe)&&f([...p,oe]),u(""),N(!1)},te=(O||[]).filter(ie=>!p.includes(ie)&&ie.toLowerCase().includes(d.toLowerCase())),Y=Et({mutationFn:async()=>{const{data:ie,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(ie&&!ie.ok&&ie.error)throw new Error(ie.error);return ie},onSuccess:ie=>{A(ie.html),k(!0)},onError:ie=>{pe.error(ie.message||"Failed to generate preview")}}),J=Et({mutationFn:async()=>{const{data:ie,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(ie&&!ie.ok&&ie.error)throw new Error(ie.error);return ie},onSuccess:()=>{pe.success(`Market report sent to ${s}!`)},onError:ie=>{pe.error(ie.message||"Failed to send report")}}),X=Et({mutationFn:async()=>{const{error:ie}=await G.from("innercircle_contacts").update({market_report_enabled:y,market_report_cities:p}).eq("id",t);if(ie)throw ie},onSuccess:()=>{o.invalidateQueries({queryKey:["contact-market-report",t]}),i(!1),pe.success(y?"Monthly market report enabled!":"Market report disabled")},onError:ie=>{pe.error(ie.message||"Failed to save")}}),ce=Et({mutationFn:async()=>{const{error:ie}=await G.from("innercircle_contacts").update({market_report_enabled:!1,market_report_cities:[]}).eq("id",t);if(ie)throw ie},onSuccess:()=>{o.invalidateQueries({queryKey:["contact-market-report",t]}),i(!1),_(!1),f([]),pe.success("Market report removed")},onError:ie=>{pe.error(ie.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(Lt,{className:"pb-2",children:e.jsxs(Ft,{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(Re,{className:"pt-0 space-y-2",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5 text-xs",children:((ae=V.market_report_cities)==null?void 0:ae.length)>0?V.market_report_cities.map(ie=>e.jsxs(Qe,{variant:"outline",className:"gap-1",children:[e.jsx(Ia,{className:"h-3 w-3"}),ie]},ie)):e.jsx("span",{className:"text-muted-foreground",children:"Using default market area"})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s," receives a branded market report on the 1st of each month."]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Y.mutate(),disabled:Y.isPending,className:"flex-1",children:[Y.isPending?e.jsx(us,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Cn,{className:"h-4 w-4 mr-1"}),"Preview"]}),e.jsxs(K,{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(Mn,{className:"h-4 w-4 mr-1"}),"Send Now"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:B,className:"flex-1",children:"Manage"}),e.jsxs(K,{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(jr,{className:"h-4 w-4 mr-1"}),"Remove"]})]}),e.jsx(fs,{open:w,onOpenChange:k,children:e.jsxs(hs,{className:"max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsx(js,{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(K,{onClick:()=>{k(!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(Mn,{className:"h-4 w-4 mr-1"}),"Send to ",s]}),e.jsx(K,{variant:"outline",onClick:()=>k(!1),children:"Close"})]})]})})]})]}):l?e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ft,{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(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{children:"Send Monthly Report"}),e.jsx(Mr,{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(Le,{ref:I,value:d,onChange:ie=>{u(ie.target.value),N(!0)},onFocus:()=>N(!0),placeholder:"Type to search cities...",onKeyDown:ie=>{ie.key==="Enter"&&(ie.preventDefault(),te.length>0?U(te[0]):U())}}),e.jsx(Fi,{className:"absolute right-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground pointer-events-none"})]}),e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:()=>U(),children:e.jsx(Bs,{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(ie=>e.jsxs("button",{type:"button",className:"w-full text-left px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors flex items-center gap-2",onClick:()=>U(ie),children:[e.jsx(Ia,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),ie]},ie))})]}),p.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:p.map(ie=>e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[ie,e.jsx("button",{onClick:()=>f(p.filter(oe=>oe!==ie)),children:e.jsx(jr,{className:"h-3 w-3"})})]},ie))})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(K,{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(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"})]})]})]}):e.jsx(Pe,{className:"overflow-hidden",children:e.jsx(Re,{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 K7e(t){return t==="sent"?e.jsx(Hn,{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(on,{className:"h-4 w-4 text-muted-foreground"})}function nws({contactId:t}){const s=vr(),{data:r,isLoading:n}=sws(t),[a,o]=S.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(Lt,{children:e.jsxs(Ft,{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(Re,{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(hi,{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:K7e(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(Si,{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"," · ",gs(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(hs,{className:"max-w-lg",children:[e.jsx(js,{children:e.jsxs(_s,{className:"flex items-center gap-2",children:[K7e(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:gs(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(K,{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(ks,{className:"w-full aspect-video rounded-lg"}),e.jsx(ks,{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=vr(),[r,n]=S.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(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ft,{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(K,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/tasks"),children:"View All"}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>n(!0),children:e.jsx(Bs,{className:"h-3.5 w-3.5"})})]})]})}),e.jsx(Re,{className:"space-y-1",children:o?e.jsx(ks,{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:gs(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]=S.useState(""),[o,l]=S.useState("medium"),[i,d]=S.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?gs(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(hs,{className:"sm:max-w-[400px]",children:[e.jsx(js,{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(Le,{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(Le,{type:"date",value:i?gs(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(K,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(K,{onClick:p,disabled:!n.trim(),children:"Create Task"})]})]})]})})}function lws({contactId:t}){const s=vr(),{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(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(dh,{className:"h-4 w-4"}),"Linked Deals"]})}),e.jsx(Re,{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(Ga,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors flex-shrink-0"})]})},a.id)})})]})}function cws(){var Ve,Xe,dt,pt,Je;const{contactId:t}=ao(),s=vr(),[r]=Nc(),n=r.get("search")||"",a=r.get("type")||"all",o=r.get("status")||"all",{data:l,isLoading:i}=vLt(t||""),{data:d}=Nf(),{data:u}=WR(),{data:p}=KR(3650),{data:f}=Sme(365),{data:y}=qbs(t),{contactsWithScores:_}=ohe(),b=ake(),N=ike(),w=nhe(),k=bXe(),[C,A]=S.useState(!1),[I,L]=S.useState({}),[O,V]=S.useState(!1),[q,B]=S.useState(null),[U,te]=S.useState(""),[Y,J]=S.useState(void 0),[X,ce]=S.useState(""),[ae,ie]=S.useState(null),[oe,me]=S.useState(!1),[ye,he]=S.useState(null),[ge,Ne]=S.useState(!1),{isGmailConnected:Ue,gmailEmail:Te}=jp(),{data:Me}=gt({queryKey:["gmail-sent-emails",t],queryFn:async()=>{const{data:Ze,error:Nt}=await G.from("gmail_sent_emails").select("*").eq("contact_id",t).order("sent_at",{ascending:!1});if(Nt)throw Nt;return Ze},enabled:!!t}),De=Ze=>{if(!Ze)return null;const Nt=Ze.match(/Video ID:\s*([a-f0-9-]+)/i);return Nt?Nt[1]:null},qe=S.useMemo(()=>{if(!_)return[];let Ze=_.filter(Nt=>{var Ps,$s,Zs;const Ot=n===""||`${Nt.first_name} ${Nt.last_name}`.toLowerCase().includes(n.toLowerCase())||((Ps=Nt.email)==null?void 0:Ps.toLowerCase().includes(n.toLowerCase()))||(($s=Nt.phone)==null?void 0:$s.includes(n)),Yt=a==="all"||((Zs=Nt.tags)==null?void 0:Zs.some(Dr=>Dr.relationship_type_id===a));return Ot&&Yt});return o==="not-touched-90"?Ze=Ze.filter(Nt=>{const Ot=Nt.relationshipScore.daysSinceTouch;return Ot===null||Ot>90}):o==="at-risk"?Ze=Ze.filter(Nt=>Nt.relationshipScore.status==="at-risk"):o==="cooling"?Ze=Ze.filter(Nt=>Nt.relationshipScore.status==="cooling"):o==="warm"&&(Ze=Ze.filter(Nt=>Nt.relationshipScore.status==="warm")),Ze.map(Nt=>Nt.id)},[_,n,a,o]),ke=qe.indexOf(t||""),$e=ke>0?qe[ke-1]:null,Be=ke1&&ke!==-1,ut=Ze=>{const Nt=new URLSearchParams;n&&Nt.set("search",n),a!=="all"&&Nt.set("type",a),o!=="all"&&Nt.set("status",o);const Ot=Nt.toString();return`/mission-control/contacts/${Ze}${Ot?`?${Ot}`:""}`},fe=S.useMemo(()=>{const Ze=((p==null?void 0:p.filter(Ot=>Ot.contact_id===t))||[]).map(Ot=>{var Zs,Dr,$t;const Yt=De(Ot.notes);let Ps=((Zs=Ot.action_type)==null?void 0:Zs.name)||"Touch",$s=Ot.notes;if(Ps==="Other"&&((Dr=Ot.notes)!=null&&Dr.startsWith("["))){const Us=Ot.notes.indexOf("]");Us>0&&(Ps=Ot.notes.substring(1,Us),$s=Ot.notes.substring(Us+1).replace(/^\s*—\s*/,"").trim()||null)}return{id:Ot.id,type:"touch",completed_at:Ot.completed_at,name:Ps,color:(($t=Ot.action_type)==null?void 0:$t.color)||"#3B82F6",notes:$s,videoId:Yt}}),Nt=((f==null?void 0:f.filter(Ot=>Ot.contact_id===t))||[]).map(Ot=>({id:Ot.id,type:"popby",completed_at:Ot.completed_at,name:"Pop-by",color:"#F97316",notes:Ot.notes,videoId:null}));return[...Ze,...Nt].sort((Ot,Yt)=>new Date(Yt.completed_at).getTime()-new Date(Ot.completed_at).getTime())},[p,f,t]),He=()=>{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(Nt=>Nt.relationship_type_id))||[]}),A(!0))},et=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"))},Ge=((Ve=u==null?void 0:u.find(Ze=>Ze.id===q))==null?void 0:Ve.name)==="Other",We=async()=>{if(!q||Ge&&!X.trim())return;const Ze=Y?new Date(Y.getFullYear(),Y.getMonth(),Y.getDate(),12,0,0).toISOString():void 0,Nt=Ge?`[${X.trim()}]${U?" — "+U:""}`:U;await w.mutateAsync({contactId:t,actionTypeId:q,notes:Nt,completedAt:Ze}),V(!1),B(null),te(""),J(void 0),ce("")},it=(Ze,Nt)=>{Ue&&l?(he({email:Ze,name:Nt||`${l.first_name} ${l.last_name||""}`.trim()}),me(!0)):window.location.href=`mailto:${Ze}`};return i?e.jsx(Es,{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(Es,{title:`${l.first_name} ${l.last_name||""}`,description:"Contact details and activity",children:e.jsxs("div",{className:"space-y-6 overflow-x-hidden",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>{window.history.length>1?s(-1):s("/mission-control/contacts")},children:[e.jsx(Xo,{className:"h-4 w-4 mr-1"}),"Back to Contacts"]}),we&&e.jsxs("div",{className:"flex items-center gap-1 ml-2 border-l pl-2",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>$e&&s(ut($e)),disabled:!$e,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:[ke+1," of ",qe.length]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>Be&&s(ut(Be)),disabled:!Be,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(K,{variant:"outline",onClick:()=>it(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(K,{variant:"outline",onClick:()=>Ne(!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(K,{variant:"default",onClick:()=>s(`/mission-control/video/record?contact_id=${t}`),className:"bg-gradient-to-r from-primary to-primary/80",children:[e.jsx(gn,{className:"h-4 w-4 mr-1"}),"Quick Video Touch"]}),e.jsxs(fs,{open:O,onOpenChange:V,children:[e.jsx(hi,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Log Action"]})}),e.jsxs(hs,{className:"max-h-[85vh] overflow-y-auto",children:[e.jsx(js,{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))}),Ge&&e.jsxs("div",{className:"mt-3",children:[e.jsx(xe,{htmlFor:"custom-action-name",children:"What did you do?"}),e.jsx(Le,{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(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Dt("w-full justify-start text-left font-normal mt-2",!Y&&"text-muted-foreground"),children:[e.jsx(ln,{className:"h-4 w-4 mr-2"}),Y?gs(Y,"PPP"):"Today (default)"]})}),e.jsx(uo,{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:Dt("p-3 pointer-events-auto")})})]})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"action-notes",children:"Notes (optional)"}),e.jsx(gr,{id:"action-notes",value:U,onChange:Ze=>te(Ze.target.value),placeholder:"Add any notes about this interaction...",rows:3})]}),e.jsxs(K,{onClick:We,disabled:!q||Ge&&!X.trim()||w.isPending,className:"w-full",children:[e.jsx(Zn,{className:"h-4 w-4 mr-1"}),"Complete Action"]})]})]})]}),e.jsxs(K,{variant:"outline",onClick:He,children:[e.jsx(Wc,{className:"h-4 w-4 mr-1"}),"Edit"]}),e.jsx(K,{variant:"destructive",size:"icon",onClick:tt,children:e.jsx(xr,{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||""]}),(((Xe=l.lead_source_ref)==null?void 0:Xe.name)||l.lead_source)&&e.jsx(Qe,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((dt=l.lead_source_ref)==null?void 0:dt.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:()=>it(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}),(pt=l.tags)==null?void 0:pt.map(Ze=>{const Nt=d==null?void 0:d.find(Ot=>Ot.id===Ze.relationship_type_id);return Nt?e.jsx(Qe,{variant:"secondary",className:"text-xs",children:Nt.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(Lt,{children:e.jsx(Ft,{children:"Contact Information"})}),e.jsx(Re,{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(Le,{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(Le,{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(Le,{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(Le,{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(Le,{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(Le,{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(Le,{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(Le,{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(Le,{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(Le,{id:"home_anniversary",type:"date",value:I.home_anniversary,onChange:Ze=>L({...I,home_anniversary:Ze.target.value})})]})]}),e.jsx(xo,{}),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=>k.mutate({contactId:t,spouseContactId:Ze}),onUnlink:()=>k.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(Le,{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(Le,{id:"job_title",value:I.job_title,onChange:Ze=>L({...I,job_title:Ze.target.value}),placeholder:"Enter job title"})]})]}),e.jsx(rit,{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 Nt;return e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Hi,{checked:(Nt=I.tagIds)==null?void 0:Nt.includes(Ze.id),onCheckedChange:Ot=>{var Yt;L(Ot?{...I,tagIds:[...I.tagIds||[],Ze.id]}:{...I,tagIds:(Yt=I.tagIds)==null?void 0:Yt.filter(Ps=>Ps!==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(gr,{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(K,{onClick:et,disabled:b.isPending,children:"Save Changes"}),e.jsx(K,{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(ln,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"Last Contacted:"})," ",gs(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:()=>it(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(ln,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Birthday: ",gs(ol(l.birthday),"MMMM d")]})]}),l.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Home Anniversary: ",gs(ol(l.home_anniversary),"MMMM d")]})]}),l.created_at&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bs,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Date Added: ",gs(new Date(l.created_at),"MMMM d, yyyy")]})]})]}),e.jsx(xo,{}),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=>k.mutate({contactId:t,spouseContactId:Ze}),onUnlink:()=>k.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(xo,{}),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:(Je=l.tags)!=null&&Je.length?l.tags.map(Ze=>{var Nt;return e.jsx(Qe,{variant:"secondary",children:(Nt=Ze.relationship_type)==null?void 0:Nt.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(xo,{}),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(B_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(Lt,{children:e.jsx(Ft,{children:"Activity Log"})}),e.jsx(Re,{children:fe.length>0?e.jsx("div",{className:"space-y-4",children:fe.map(Ze=>{var Nt;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(yi,{className:"h-4 w-4"}):(Nt=Ze.name)==null?void 0:Nt.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(K,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>ie(Ze.videoId),children:[e.jsx(Co,{className:"h-3 w-3 mr-1"}),"Preview"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:gs(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(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Si,{className:"h-5 w-5 text-primary"}),"Video Replies"]})}),e.jsx(Re,{children:e.jsx("div",{className:"space-y-4",children:y.map(Ze=>{var Nt,Ot;return e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0",children:[(Nt=Ze.video)!=null&&Nt.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:()=>ie(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:()=>ie(Ze.video_id),children:e.jsx(gn,{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: ",((Ot=Ze.video)==null?void 0:Ot.title)||"Untitled Video"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs flex-shrink-0",onClick:()=>ie(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:gs(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)})})})]}),Me&&Me.length>0&&e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Mn,{className:"h-5 w-5 text-sky-500"}),"Sent Emails"]})}),e.jsx(Re,{children:e.jsx("div",{className:"space-y-3",children:Me.map(Ze=>e.jsxs(fs,{children:[e.jsx(hi,{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," · ",gs(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(hs,{className:"max-w-2xl max-h-[85vh] flex flex-col",children:[e.jsxs(js,{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," · ",gs(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:!!ae,onOpenChange:Ze=>!Ze&&ie(null),children:e.jsxs(hs,{className:"max-w-2xl",children:[e.jsx(js,{children:e.jsx(_s,{children:"Video Preview"})}),ae&&e.jsx(aws,{videoId:ae})]})})]})]})}),Ue&&l&&ye&&e.jsx(E1,{open:oe,onOpenChange:me,contact:{id:l.id,first_name:l.first_name,last_name:l.last_name,email:ye.email},gmailEmail:Te}),l&&l.email&&e.jsx(Pbs,{open:ge,onOpenChange:Ne,contact:{id:l.id,first_name:l.first_name,last_name:l.last_name,email:l.email}})]}):e.jsx(Es,{title:"Contact Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"This contact was not found."}),e.jsx(K,{onClick:()=>s("/mission-control/contacts"),children:"Back to Contacts"})]})})}const Z7e={Crown:Cm,FileText:yn,Users:or,Globe:nd,Star:Gn,Phone:In,MessageSquare:Si,PenTool:Mb,Video:gn,Gift:yi},c0e=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function dws(){var dt,pt;const t=vr(),{user:s}=qs(),{data:r}=Nf(),{data:n}=bLt(),{data:a}=MLt(),{data:o}=_Xe(),{data:l}=WR(),{data:i}=_Lt(),d=TLt(),u=wLt(),p=NLt(),f=kLt(),y=SLt(),_=CLt(),b=jLt(),[N,w]=S.useState(null),[k,C]=S.useState(!1),[A,I]=S.useState(null),[L,O]=S.useState(""),[V,q]=S.useState(""),[B,U]=S.useState([]),[te,Y]=S.useState(null),[J,X]=S.useState(null),[ce,ae]=S.useState(!1),[ie,oe]=S.useState(""),[me,ye]=S.useState(""),[he,ge]=S.useState(""),[Ne,Ue]=S.useState(""),Te=(Je,Ze)=>a==null?void 0:a.some(Nt=>Nt.plan_id===Je&&Nt.relationship_type_id===Ze&&Nt.active),Me=Je=>a==null?void 0:a.find(Ze=>Ze.relationship_type_id===Je&&Ze.active),De=async(Je,Ze)=>{const Nt=Te(Je,Ze);await d.mutateAsync({planId:Je,relationshipTypeId:Ze,active:!Nt})},qe=(n==null?void 0:n.filter(Je=>Je.active&&!Je.owner_user_id))||[],ke=(n==null?void 0:n.filter(Je=>Je.owner_user_id===(s==null?void 0:s.id)))||[],$e=r==null?void 0:r.find(Je=>Je.id===N),Be=N?Me(N):null,we=n==null?void 0:n.find(Je=>Je.id===(Be==null?void 0:Be.plan_id)),ut=async()=>{if(!L.trim())return;const Je=await u.mutateAsync({name:L,description:V});Je&&B.length>0&&await y.mutateAsync({planId:Je.id,items:B}),et()},fe=async()=>{!L.trim()||!A||(await p.mutateAsync({id:A,name:L,description:V}),await y.mutateAsync({planId:A,items:B}),et())},He=Je=>{var Ze;I(Je.id),O(Je.name),q(Je.description||""),U(((Ze=Je.items)==null?void 0:Ze.map(Nt=>({month_number:Nt.month_number,action_type_id:Nt.action_type_id,default_script_id:Nt.default_script_id||void 0,notes:Nt.notes||void 0})))||[]),C(!0)},et=()=>{C(!1),I(null),O(""),q(""),U([])},tt=(Je,Ze)=>{X(Ze)},_e=(Je,Ze,Nt)=>{U(Ot=>[...Ot.filter(Ps=>Ps.month_number!==Je),{month_number:Je,action_type_id:Ze,default_script_id:Nt}]),Y(null),X(null)},Ge=Je=>{U(Ze=>Ze.filter(Nt=>Nt.month_number!==Je))},We=async()=>{if(!ie.trim()||!me.trim()||!J)return;const Je=await _.mutateAsync({actionTypeId:J,title:ie,scriptBody:me,emailSubject:he||void 0,tone:Ne||void 0});Je&&te!==null&&_e(te,J,Je.id),ae(!1),oe(""),ye(""),ge(""),Ue("")},it=J?i==null?void 0:i.filter(Je=>Je.action_type_id===J&&Je.active):[],Ve=Je=>Z7e[Je||"Phone"]||In,Xe=Je=>Z7e[Je||"Users"]||or;return e.jsxs(Es,{title:"Touchpoint Plans",description:"Assign plans to your contact groups",children:[e.jsxs("div",{className:"space-y-6 overflow-x-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Touchpoint Plans"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control"),children:[e.jsx(Xo,{className:"h-4 w-4 mr-1"}),"Back"]}),e.jsxs(K,{onClick:()=>C(!0),className:"w-full sm:w-auto",children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Create Custom Plan"]})]}),e.jsxs("div",{className:"grid lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Your Contact Groups"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select a group to assign a touchpoint plan"}),r==null?void 0:r.filter(Je=>Je.active).map(Je=>{const Ze=Xe(Je.icon),Nt=(o==null?void 0:o[Je.id])||0,Ot=Me(Je.id),Yt=n==null?void 0:n.find($s=>$s.id===(Ot==null?void 0:Ot.plan_id)),Ps=N===Je.id;return e.jsxs("button",{onClick:()=>w(Je.id),className:` w-full flex items-center gap-3 p-4 rounded-lg border text-left transition-all ${Ps?"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:Je.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Nt," contacts"]})]}),Yt?e.jsxs(Qe,{variant:"secondary",className:"text-xs",children:[e.jsx(ti,{className:"h-3 w-3 mr-1"}),Yt.name.split(" ")[0]]}):e.jsx(Qe,{variant:"outline",className:"text-xs text-muted-foreground",children:"No plan"})]},Je.id)})]}),e.jsx("div",{className:"lg:col-span-2",children:N&&$e?e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[(()=>{const Je=Xe($e.icon);return e.jsx(Je,{className:"h-5 w-5"})})(),$e.name," Touchpoint Plan"]}),e.jsxs(ur,{children:["Choose a plan for your ",$e.name," contacts"]})]}),e.jsxs(Re,{className:"space-y-6",children:[we&&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(ti,{className:"h-4 w-4 text-green-500"}),"Currently using: ",we.name]}),we.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:we.description})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>De(we.id,N),children:"Disable"})]}),we.items&&we.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(ln,{className:"h-4 w-4"}),"12-Month Schedule"]}),e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-2",children:c0e.map((Je,Ze)=>{var Ps,$s;const Nt=((Ps=we.items)==null?void 0:Ps.filter(Zs=>Zs.month_number===Ze+1))||[],Ot=($s=Nt[0])==null?void 0:$s.action_type,Yt=Ot?Ve(Ot.icon):null;return e.jsxs("div",{className:` p-2 rounded border text-center ${Nt.length>0?"bg-primary/10 border-primary":"bg-muted"} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:Je}),Yt&&e.jsx(Yt,{className:"h-4 w-4 mx-auto mt-1",style:{color:(Ot==null?void 0:Ot.color)||"#3B82F6"}})]},Ze)})})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:we?"Switch to a Different Plan":"Choose a Plan"}),qe.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"}),qe.map(Je=>{var Nt;const Ze=(we==null?void 0:we.id)===Je.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:Je.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((Nt=Je.items)==null?void 0:Nt.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",title:"Duplicate as my own plan",disabled:b.isPending,onClick:()=>{const Ot=`${Je.name} (Copy)`;b.mutate({sourcePlanId:Je.id,newName:Ot})},children:e.jsx(Wa,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:Ze?"outline":"default",disabled:Ze||d.isPending,onClick:()=>De(Je.id,N),children:Ze?"Active":"Use This"})]})]},Je.id)})]}),ke.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"My Custom Plans"}),ke.map(Je=>{var Nt;const Ze=(we==null?void 0:we.id)===Je.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:Je.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((Nt=Je.items)==null?void 0:Nt.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",title:"Edit plan",onClick:()=>He(Je),children:e.jsx(Ry,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",title:"Delete plan",onClick:()=>f.mutate(Je.id),children:e.jsx(xr,{className:"h-4 w-4 text-destructive"})}),e.jsx(K,{size:"sm",variant:Ze?"outline":"default",disabled:Ze||d.isPending,onClick:()=>De(Je.id,N),children:Ze?"Active":"Use This"})]})]},Je.id)})]}),qe.length===0&&ke.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No plans available. Create a custom plan to get started."})]})]})]}):e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(ln,{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(Re,{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:k,onOpenChange:Je=>{Je?C(!0):et()},children:e.jsxs(hs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{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(Le,{id:"plan-name",value:L,onChange:Je=>O(Je.target.value),placeholder:"e.g., My VIP Plan"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"plan-description",children:"Description (optional)"}),e.jsx(gr,{id:"plan-description",value:V,onChange:Je=>q(Je.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:c0e.map((Je,Ze)=>{const Nt=Ze+1,Ot=B.find($s=>$s.month_number===Nt),Yt=Ot?l==null?void 0:l.find($s=>$s.id===Ot.action_type_id):null,Ps=Yt?Ve(Yt.icon):null;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>Y(te===Nt?null:Nt),className:` w-full p-3 rounded-lg border text-center transition-all ${Ot?"bg-primary/10 border-primary":"bg-muted hover:bg-accent"} ${te===Nt?"ring-2 ring-primary":""} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground font-medium",children:Je}),Ps?e.jsx(Ps,{className:"h-5 w-5 mx-auto mt-1",style:{color:(Yt==null?void 0:Yt.color)||"#3B82F6"}}):e.jsx(Bs,{className:"h-5 w-5 mx-auto mt-1 text-muted-foreground/50"})]}),Ot&&e.jsx("button",{type:"button",onClick:$s=>{$s.stopPropagation(),Ge(Nt)},className:"absolute -top-1 -right-1 p-1 bg-destructive text-destructive-foreground rounded-full",children:e.jsx(jr,{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 ",c0e[te-1],":"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l==null?void 0:l.filter(Je=>Je.active).map(Je=>{const Ze=Ve(Je.icon);return e.jsxs("button",{type:"button",onClick:()=>tt(te,Je.id),className:"flex items-center gap-2 px-3 py-2 rounded-lg border bg-background hover:bg-accent transition-colors",children:[e.jsx(Ze,{className:"h-4 w-4",style:{color:Je.color||"#3B82F6"}}),e.jsx("span",{className:"text-sm",children:Je.name})]},Je.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(K,{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:()=>_e(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"})]})}),it==null?void 0:it.map(Je=>e.jsx("button",{type:"button",onClick:()=>_e(te,J,Je.id),className:"w-full flex items-center gap-3 p-3 rounded-lg border bg-background hover:bg-accent transition-colors text-left",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm",children:Je.title}),Je.tone&&e.jsx(Qe,{variant:"secondary",className:"text-xs mt-1",children:Je.tone}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:[Je.script_body.substring(0,100),"..."]})]})},Je.id)),e.jsxs("button",{type:"button",onClick:()=>ae(!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(Bs,{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(_n,{children:[e.jsx(K,{variant:"outline",onClick:et,children:"Cancel"}),e.jsxs(K,{onClick:A?fe:ut,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:ae,children:e.jsxs(hs,{className:"max-w-lg",children:[e.jsx(js,{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(Le,{id:"script-title",value:ie,onChange:Je=>oe(Je.target.value),placeholder:"e.g., Friendly Check-in Call"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"script-tone",children:"Tone (optional)"}),e.jsxs(Fs,{value:Ne,onValueChange:Ue,children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select tone..."})}),e.jsxs(Rs,{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"})]})]})]}),((pt=(dt=l==null?void 0:l.find(Je=>Je.id===J))==null?void 0:dt.name)==null?void 0:pt.toLowerCase().includes("email"))&&e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"script-email-subject",children:"Email Subject"}),e.jsx(Le,{id:"script-email-subject",value:he,onChange:Je=>ge(Je.target.value),placeholder:"e.g., Quick Hello!"})]}),e.jsxs("div",{children:[e.jsx(xe,{htmlFor:"script-body",children:"Script Content"}),e.jsx(gr,{id:"script-body",value:me,onChange:Je=>ye(Je.target.value),placeholder:"Write your script here... You can use {{FirstName}} and {{LastName}} as placeholders.",rows:6}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Tip: Use ","{{FirstName}}"," and ","{{LastName}}"," as placeholders"]})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>ae(!1),children:"Cancel"}),e.jsxs(K,{onClick:We,disabled:!ie.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 iit="popby_geocode_cache_v1";function hws(){try{return JSON.parse(localStorage.getItem(iit)||"{}")}catch{return{}}}function mws(t){try{localStorage.setItem(iit,JSON.stringify(t))}catch{}}function pws({contacts:t,onLogPopby:s}){const[r,n]=S.useState(null),[a,o]=S.useState("idle"),[l,i]=S.useState(5),[d,u]=S.useState(""),[p,f]=S.useState(new Map),[y,_]=S.useState(!1);S.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=S.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})};S.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[ae,ie]=ce.features[0].center;A[Y]={lat:ie,lng:ae},I.set(U.id,{lat:ie,lng:ae})}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=S.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]),k=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(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3 flex-wrap",children:[e.jsxs("div",{children:[e.jsxs(Ft,{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(Fs,{value:String(l),onValueChange:C=>i(Number(C)),children:[e.jsx(Ds,{className:"w-[110px] h-9",children:e.jsx(zs,{})}),e.jsxs(Rs,{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(K,{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(Re,{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(ks,{className:"h-14 w-full"}),e.jsx(ks,{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(K,{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(K,{size:"icon",variant:"ghost",onClick:()=>k(C),className:"h-9 w-9",title:"Directions",children:e.jsx(ML,{className:"h-4 w-4"})}),e.jsxs(K,{size:"sm",onClick:()=>s(C),children:[e.jsx(yi,{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=vr(),s=Zat(),{data:r}=I_s(),{data:n}=Nf(),{data:a}=FSe(),{data:o}=Sme(90),{data:l}=qh(),i=F_s(),d=R_s(),u=D_s(),p=O_s(),{data:f=[],isLoading:y}=gt({queryKey:["popby-templates"],queryFn:async()=>{const{data:ce,error:ae}=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(ae)throw ae;const{data:ie}=await G.from("template_likes").select("template_id"),{data:oe}=await G.from("template_comments").select("template_id"),me=new Map;ie==null||ie.forEach(he=>{me.set(he.template_id,(me.get(he.template_id)||0)+1)});const ye=new Map;return oe==null||oe.forEach(he=>{ye.set(he.template_id,(ye.get(he.template_id)||0)+1)}),(ce||[]).map(he=>({...he,likesCount:me.get(he.id)||0,commentsCount:ye.get(he.id)||0}))}}),_=ce=>{const ae=l==null?void 0:l.find(ie=>ie.id===ce);return ae?`${ae.first_name} ${ae.last_name||""}`.trim():"Unknown"},b=ce=>{if(!ce)return null;const ae=r==null?void 0:r.find(ie=>ie.id===ce);return(ae==null?void 0:ae.name)||null},[N,w]=S.useState(null),[k,C]=S.useState(!1),[A,I]=S.useState(!1),[L,O]=S.useState(!1),[V,q]=S.useState({popby_item_id:"",notes:""}),[B,U]=S.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,ae)=>{await p.mutateAsync({relationship_type_id:ce,frequency_days:parseInt(ae)})},X=ce=>{var ie;const ae=a==null?void 0:a.find(oe=>oe.relationship_type_id===ce);return((ie=ae==null?void 0:ae.frequency_days)==null?void 0:ie.toString())||"90"};return e.jsx(Es,{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(Re,{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(Re,{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(Re,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-amber-500",children:i.dueCount}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Due Now"})]})})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(K,{onClick:()=>t("/mission-control/popbys/map"),children:[e.jsx(Ia,{className:"h-4 w-4 mr-2"}),"View Map"]}),e.jsxs(K,{variant:"outline",onClick:()=>I(!0),children:[e.jsx(So,{className:"h-4 w-4 mr-2"}),"Frequency Settings"]}),e.jsxs(K,{variant:"outline",onClick:()=>O(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsxs(ta,{defaultValue:"due",children:[e.jsxs(Jn,{children:[e.jsx(ls,{value:"due",children:"Due for Popby"}),e.jsx(ls,{value:"activity",children:"Recent Activity"}),e.jsx(ls,{value:"library",children:"Popby Library"}),e.jsx(ls,{value:"templates",children:"Popby Templates"})]}),e.jsxs(ws,{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(Re,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(yi,{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(Re,{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(ae=>{var ie;return(ie=ae.relationship_type)==null?void 0:ie.name}).join(", ")})]}),ce.lastPopby&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Last popby: ",gs(new Date(ce.lastPopby),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[ce.phone&&e.jsx(K,{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(K,{size:"sm",onClick:()=>{w(ce),C(!0)},children:[e.jsx(ti,{className:"h-4 w-4 mr-1"}),"Log Popby"]})]})]})})},ce.id))})]}),e.jsx(ws,{value:"activity",className:"space-y-4 mt-4",children:!o||o.length===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(on,{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(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"Recent Popby Log"})}),e.jsx(Re,{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(yi,{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:gs(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(ws,{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(Re,{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(yi,{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(Re,{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(Bs,{className:"h-8 w-8 mx-auto mb-2"}),e.jsx("p",{children:"Add New Popby Idea"})]})})})]})}),e.jsxs(ws,{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,ae)=>e.jsx(Pe,{children:e.jsxs(Re,{className:"p-4",children:[e.jsx(ks,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(ks,{className:"h-5 w-3/4 mb-2"}),e.jsx(ks,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ks,{className:"h-5 w-16"}),e.jsx(ks,{className:"h-5 w-20"})]})]})},ae))}),!y&&f.length===0&&e.jsx(Pe,{children:e.jsxs(Re,{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(Re,{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:Xde(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(Ol,{className:"h-3.5 w-3.5"}),ce.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:ae=>{ae.stopPropagation(),t(`/templates/${ce.id}`)},children:[e.jsx(Zr,{className:"h-4 w-4"}),"View Template"]})]})]},ce.id))})]})]}),e.jsx(fs,{open:k,onOpenChange:C,children:e.jsxs(hs,{children:[e.jsx(js,{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(Fs,{value:V.popby_item_id,onValueChange:ce=>q(ae=>({...ae,popby_item_id:ce})),children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select a popby item..."})}),e.jsx(Rs,{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(gr,{placeholder:"Any notes about this popby...",value:V.notes,onChange:ce=>q(ae=>({...ae,notes:ce.target.value}))})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),e.jsx(K,{onClick:te,disabled:d.isPending,children:"Log Popby"})]})]})}),e.jsx(fs,{open:A,onOpenChange:I,children:e.jsxs(hs,{className:"max-w-md",children:[e.jsx(js,{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(Fs,{value:X(ce.id),onValueChange:ae=>J(ce.id,ae),children:[e.jsx(Ds,{className:"w-[180px]",children:e.jsx(zs,{})}),e.jsx(Rs,{children:xws.map(ae=>e.jsx(vt,{value:ae.value,children:ae.label},ae.value))})]})]},ce.id))]}),e.jsx(_n,{children:e.jsx(K,{onClick:()=>I(!1),children:"Done"})})]})}),e.jsx(fs,{open:L,onOpenChange:O,children:e.jsxs(hs,{children:[e.jsx(js,{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(Le,{placeholder:"e.g., Homemade cookies",value:B.name,onChange:ce=>U(ae=>({...ae,name:ce.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Description"}),e.jsx(gr,{placeholder:"Optional description...",value:B.description,onChange:ce=>U(ae=>({...ae,description:ce.target.value}))})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),e.jsx(K,{onClick:Y,disabled:!B.name.trim()||u.isPending,children:"Add Item"})]})]})})]})})}const yws=kC({property_address:Yl().min(1,"Property address is required"),city:Yl().optional(),state:Yl().optional(),zip:Yl().optional(),transaction_type:ZWe(["buyer","seller"]),close_date:Yl().min(1,"Close date is required"),sale_price:e8().min(0,"Sale price must be positive"),commission_amount:e8().optional(),lead_source_id:Yl().optional(),client_type_id:Yl().optional(),contact_id:Yl().optional(),notes:Yl().optional(),is_win:f3t()});function oit({open:t,onOpenChange:s,transaction:r}){const[n,a]=S.useState(!1),[o,l]=S.useState(""),[i,d]=S.useState(!1),[u,p]=S.useState(""),f=ahe(),y=x8t(),{data:_}=JA(),{data:b}=Nf(),{data:N}=qh(),w=rhe(),k=lke(),{data:C}=ihe(),A=(C==null?void 0:C.show_commission)??!0,I=Kue({resolver:Zue(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}});S.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 k.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(hs,{className:"max-w-lg max-h-[90vh]",children:[e.jsx(js,{children:e.jsx(_s,{children:r?"Edit Transaction":"Add Transaction"})}),e.jsx(ni,{className:"max-h-[70vh] pr-4",children:e.jsx(Yue,{...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(Le,{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(Le,{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(Le,{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(Le,{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(Fs,{onValueChange:B.onChange,value:B.value,children:[e.jsx(fc,{children:e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select type"})})}),e.jsxs(Rs,{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(Le,{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(Le,{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(Le,{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(Fs,{onValueChange:B.onChange,value:B.value||"",children:[e.jsx(fc,{children:e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select source"})})}),e.jsx(Rs,{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(Le,{placeholder:"Add custom source...",value:u,onChange:B=>p(B.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:V,disabled:!u.trim(),children:e.jsx(Bs,{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(Fs,{onValueChange:B.onChange,value:B.value||"",children:[e.jsx(fc,{children:e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select client type"})})}),e.jsx(Rs,{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(yo,{open:n,onOpenChange:a,children:[e.jsx(vo,{asChild:!0,children:e.jsx(fc,{children:e.jsxs(K,{variant:"outline",role:"combobox",className:Dt("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(uo,{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(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>d(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add New Contact"]})]})}),e.jsx(Ax,{children:N==null?void 0:N.map(U=>e.jsxs(lp,{value:`${U.first_name} ${U.last_name||""}`,onSelect:()=>{B.onChange(U.id),a(!1)},children:[e.jsx(Zn,{className:Dt("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(Le,{placeholder:"Enter contact name...",value:o,onChange:U=>l(U.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",onClick:O,disabled:!o.trim()||w.isPending,children:"Add Contact"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>{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(gr,{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(Mr,{checked:B.value,onCheckedChange:B.onChange})})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:f.isPending||y.isPending,children:[r?"Update":"Add"," Transaction"]})]})]})})})]})})}function qSe({transactions:t,showCommission:s,isLoading:r,agentNameMap:n,readOnly:a}){const[o,l]=S.useState(null),[i,d]=S.useState(null),[u,p]=S.useState(""),[f,y]=S.useState("all"),[_,b]=S.useState("all"),[N,w]=S.useState("all"),[k,C]=S.useState(!1),A=g8t(),I=ahe(),{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:ae,...ie}=U;I.mutate(ie)},q=()=>{i&&(A.mutate(i),d(null))},B=t.filter(U=>{var ae,ie,oe,me;const te=u===""||U.property_address.toLowerCase().includes(u.toLowerCase())||((ie=(ae=U.contact)==null?void 0:ae.first_name)==null?void 0:ie.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=!k||U.is_win;return te&&Y&&J&&X&&ce});return r?e.jsx(Pe,{children:e.jsx(Re,{className:"p-6 space-y-4",children:[1,2,3].map(U=>e.jsx(ks,{className:"h-16 w-full"},U))})}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Lt,{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(Ft,{children:["Transactions (",B.length,")"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(an,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search...",value:u,onChange:U=>p(U.target.value),className:"pl-8 w-[150px]"})]}),e.jsxs(Fs,{value:f,onValueChange:y,children:[e.jsx(Ds,{className:"w-[100px]",children:e.jsx(zs,{placeholder:"Type"})}),e.jsxs(Rs,{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(Fs,{value:_,onValueChange:b,children:[e.jsx(Ds,{className:"w-[130px]",children:e.jsx(zs,{placeholder:"Lead Source"})}),e.jsxs(Rs,{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(K,{variant:k?"default":"outline",size:"sm",onClick:()=>C(!k),children:[e.jsx(rc,{className:"h-4 w-4 mr-1"}),"Wins"]})]})]})}),e.jsx(Re,{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(rc,{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: "}),EEe(U.close_date)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Price: "}),Pl(U.sale_price)]}),s&&U.commission_amount&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Commission: "}),Pl(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(K,{variant:"ghost",size:"sm",onClick:()=>l(U),children:e.jsx(Wc,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>V(U),children:e.jsx(Wa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d(U.id),children:e.jsx(xr,{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(Ms,{children:[n&&e.jsx(kt,{children:"Agent"}),e.jsx(kt,{children:"Property"}),e.jsx(kt,{children:"Type"}),e.jsx(kt,{children:"Close Date"}),e.jsx(kt,{children:"Sale Price"}),s&&e.jsx(kt,{children:"Commission"}),e.jsx(kt,{children:"Lead Source"}),e.jsx(kt,{children:"Client"}),!a&&e.jsx(kt,{className:"w-[50px]"})]})}),e.jsx(Rn,{children:B.map(U=>{var te;return e.jsxs(Ms,{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(rc,{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:EEe(U.close_date)}),e.jsx(ht,{children:Pl(U.sale_price)}),s&&e.jsx(ht,{children:U.commission_amount?Pl(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(K,{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(Wa,{className:"h-4 w-4 mr-2"}),"Duplicate"]}),e.jsxs(_a,{onClick:()=>d(U.id),className:"text-destructive",children:[e.jsx(xr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},U.id)})})]})})})]}),e.jsx(oit,{open:!!o,onOpenChange:U=>!U&&l(null),transaction:o||void 0}),e.jsx(Dl,{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 lit({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,k=o/12*100,C=b>=k?"ahead":b>=k*.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(Lt,{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(Ft,{children:[r," Goals Progress"]})]})}),e.jsx(Re,{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(fi,{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(fi,{value:u.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[Pl(s.totalVolume,!0)," of ",Pl(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 ",Pl(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(fi,{value:p.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[Pl(s.totalCommission,!0)," of ",Pl(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 ",Pl(p.pace,!0),"/month"]})]})]})})]})}const vws={light:"",dark:".dark"},cit=S.createContext(null);function dit(){const t=S.useContext(cit);if(!t)throw new Error("useChart must be used within a ");return t}const uit=S.forwardRef(({id:t,className:s,children:r,config:n,...a},o)=>{const l=S.useId(),i=`chart-${t||l.replace(/:/g,"")}`;return e.jsx(cit.Provider,{value:{config:n},children:e.jsxs("div",{"data-chart":i,ref:o,className:Dt("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})]})})});uit.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},hit=S.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}=dit(),N=S.useMemo(()=>{var L;if(a||!(s!=null&&s.length))return null;const[k]=s,C=`${y||k.dataKey||k.name||"value"}`,A=Pwe(b,k,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:Dt("font-medium",d),children:i(I,s)}):I?e.jsx("div",{className:Dt("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:Dt("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((k,C)=>{const A=`${f||k.name||k.dataKey||"value"}`,I=Pwe(b,k,A),L=p||k.payload.fill||k.color;return e.jsx("div",{className:Dt("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&&(k==null?void 0:k.value)!==void 0&&k.name?u(k.value,k.name,k,C,k.payload):e.jsxs(e.Fragment,{children:[I!=null&&I.icon?e.jsx(I.icon,{}):!o&&e.jsx("div",{className:Dt("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:Dt("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)||k.name})]}),k.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:k.value.toLocaleString()})]})]})},k.dataKey)})})]})});hit.displayName="ChartTooltip";const bws=S.forwardRef(({className:t,hideIcon:s=!1,payload:r,verticalAlign:n="bottom",nameKey:a},o)=>{const{config:l}=dit();return r!=null&&r.length?e.jsx("div",{ref:o,className:Dt("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:Dt("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 b9=["hsl(var(--primary))","hsl(var(--secondary))","hsl(210, 70%, 50%)","hsl(170, 60%, 45%)","hsl(280, 60%, 55%)","hsl(30, 70%, 50%)","hsl(340, 65%, 55%)","hsl(200, 65%, 50%)"];function USe({stats:t,year:s}){const r=t.transactionsByMonth.some(a=>a.count>0),n=t.leadSourceBreakdown.length>0;return!r&&!n?e.jsx(Pe,{children:e.jsx(Re,{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(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Transactions by Month"})}),e.jsx(Re,{className:"overflow-hidden",children:e.jsx(uit,{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(ep,{content:e.jsx(hit,{})}),e.jsx(_1,{dataKey:"count",fill:"hsl(var(--primary))",radius:[4,4,0,0],name:"Transactions"})]})})})})]}),n&&e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Lead Sources"})}),e.jsxs(Re,{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:b9[o%b9.length]},`cell-${o}`))}),e.jsx(ep,{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:b9[o%b9.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 gs(a,"yyyy-MM-dd")}catch{}try{const n=new Date(s);if(w1e(n))return gs(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]=S.useState([]),[a,o]=S.useState(!1),[l,i]=S.useState(0),{data:d}=JA(),{data:u}=Nf(),p=ahe(),f=()=>{const k=jws.join(","),C=["123 Main St","Dallas","TX","75001","buyer","2024-06-15","450000","13500","Referral","Past Client","yes","Great transaction!"].join(","),A=`${k} ${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=k=>{const C=k.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 ie,oe,me,ye;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 Ne;const ge=A.indexOf(he);return ge>=0?(Ne=O[ge])==null?void 0:Ne.replace(/^["']|["']$/g,"").trim():""},U=(ie=B("transaction_type"))==null?void 0:ie.toLowerCase(),te=(oe=B("sale_price"))==null?void 0:oe.replace(/[$,]/g,""),Y=(me=B("commission_amount"))==null?void 0:me.replace(/[$,]/g,""),J=(ye=B("is_win"))==null?void 0:ye.toLowerCase(),X=B("close_date"),ce=wws(X);let ae;return B("property_address")?["buyer","seller"].includes(U)?ce?(!te||isNaN(Number(te)))&&(ae="Invalid sale price"):ae=`Invalid date format: "${X}" - use MM/DD/YYYY or YYYY-MM-DD`:ae='Transaction type must be "buyer" or "seller"':ae="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:ae}})},_=k=>{var I;const C=(I=k.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 k=r.filter(I=>!I.error);if(k.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)/k.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(k=>!k.error).length,w=r.filter(k=>k.error).length;return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(hs,{className:"max-w-2xl max-h-[90vh]",children:[e.jsxs(js,{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(K,{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(Le,{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(ni,{className:"h-[200px] border rounded-lg",children:e.jsxs("div",{className:"p-2 space-y-2",children:[r.slice(0,10).map((k,C)=>e.jsxs("div",{className:`p-2 rounded text-sm ${k.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:k.property_address||"(no address)"}),e.jsx(Qe,{variant:k.transaction_type==="buyer"?"default":"secondary",children:k.transaction_type})]}),e.jsxs("div",{className:"text-muted-foreground",children:[k.close_date," • $",k.sale_price.toLocaleString()]}),k.error&&e.jsx(c4e,{variant:"destructive",className:"mt-1 py-1",children:e.jsx(d4e,{className:"text-xs",children:k.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(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{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=y8t(),{data:o}=ihe(),l=(o==null?void 0:o.show_commission)??!0,i=Kue({resolver:Zue(kws),defaultValues:{transactions_goal:void 0,volume_goal:void 0,gci_goal:void 0}});S.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(hs,{className:"max-w-md",children:[e.jsxs(js,{children:[e.jsxs(_s,{children:[r," Goals"]}),e.jsx(Ir,{children:"Set your annual targets to track your progress throughout the year."})]}),e.jsx(Yue,{...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(Le,{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(Xie,{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(Le,{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(Xie,{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(Le,{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(Xie,{children:"Gross commission income target"}),e.jsx(vm,{})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:a.isPending,children:"Save Goals"})]})]})})]})})}function VSe({transactions:t,isLoading:s}){const r=S.useRef(null),n=S.useRef(null),a=S.useRef([]),o=S.useRef(null),{isAdmin:l}=qs(),[i,d]=S.useState(""),[u,p]=S.useState(!0),[f,y]=S.useState(0),[_,b]=S.useState(!1),N=t.filter(k=>k.latitude!=null&&k.longitude!=null),w=t.filter(k=>k.latitude==null||k.longitude==null);return S.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)})()},[]),S.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]),S.useEffect(()=>{if(!r.current||!i||n.current)return;Ko.accessToken=i;const k=t.filter(I=>I.latitude!=null&&I.longitude!=null);let C=[-98.5795,39.8283],A=4;if(k.length>0){const I=k.reduce((O,V)=>O+V.longitude,0)/k.length,L=k.reduce((O,V)=>O+V.latitude,0)/k.length;C=[I,L],A=k.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]),S.useEffect(()=>{var C;if(!n.current||!i)return;a.current.forEach(A=>A.remove()),a.current=[],(C=o.current)==null||C.remove();const k=t.filter(A=>A.latitude!=null&&A.longitude!=null);if(k.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)}),k.length>1){const A=new Ko.LngLatBounds;k.forEach(I=>A.extend([I.longitude,I.latitude])),n.current.fitBounds(A,{padding:60,maxZoom:13})}else k.length===1&&n.current.flyTo({center:[k[0].longitude,k[0].latitude],zoom:12})},[t,i,_]),u||s?e.jsx(Pe,{children:e.jsx(Re,{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(Re,{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(Re,{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 mit=()=>{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}=mit();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}=mit(),{data:n,isLoading:a}=Cws(t),o=vr(),l=r||a,{aggregate:i,memberStats:d,topPerformer:u,agentNameMap:p,teamChartStats:f}=S.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),k=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:k,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(ks,{className:"h-24"},_))}),e.jsx(ks,{className:"h-64"})]}):!i||d.length===0?e.jsx(Pe,{className:"py-12",children:e.jsxs(Re,{className:"text-center space-y-2",children:[e.jsx(or,{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(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(or,{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(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Sn,{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(Re,{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:Pl(i.totalVolume,!0)})]})}),e.jsx(Pe,{children:e.jsxs(Re,{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:Pl(i.avgPrice,!0)})]})}),e.jsx(Pe,{children:e.jsxs(Re,{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:Pl(i.totalGCI,!0)})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(rc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((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(Re,{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(Vi,{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:Pl(u.totalVolume,!0)})]})]})}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"Member Performance"})}),e.jsx(Re,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ms,{children:[e.jsx(kt,{children:"Agent"}),e.jsx(kt,{className:"text-center",children:"Transactions"}),e.jsx(kt,{className:"text-center",children:"B / S"}),e.jsx(kt,{className:"text-right",children:"Volume"}),e.jsx(kt,{className:"text-right",children:"Avg Price"}),e.jsx(kt,{className:"text-right",children:"GCI"}),e.jsx(kt,{className:"text-right"})]})}),e.jsx(Rn,{children:d.map((_,b)=>e.jsxs(Ms,{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(Vi,{className:"absolute -top-2 -right-2 h-3.5 w-3.5 text-amber-500"}),e.jsxs(wn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:_.member.avatar_url||void 0}),e.jsx(jn,{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:Pl(_.totalVolume,!0)}),e.jsx(ht,{className:"text-right text-sm",children:Pl(_.averagePrice,!0)}),e.jsx(ht,{className:"text-right font-medium",children:Pl(_.totalGCI,!0)}),e.jsx(ht,{className:"text-right",children:e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>o(`/mission-control/scorecard/${_.member.id}`),children:e.jsx(Cn,{className:"h-4 w-4"})})})]},_.member.id))})]})})})]}),e.jsxs(ta,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(Jn,{children:[e.jsxs(ls,{value:"transactions",children:[e.jsx(Dh,{className:"h-4 w-4 mr-1"}),"All Transactions"]}),e.jsxs(ls,{value:"charts",children:[e.jsx(so,{className:"h-4 w-4 mr-1"}),"Charts"]}),e.jsxs(ls,{value:"map",children:[e.jsx(Ia,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(ws,{value:"transactions",children:e.jsx(qSe,{transactions:n||[],showCommission:!0,isLoading:a,agentNameMap:p,readOnly:!0})}),e.jsx(ws,{value:"charts",children:f&&e.jsx(USe,{stats:f,year:t})}),e.jsx(ws,{value:"map",children:e.jsx(VSe,{transactions:n||[],isLoading:a})})]})]})}const pit=new Date().getFullYear(),Y7e=Array.from({length:10},(t,s)=>pit-s);function Ews(){var U;const[t,s]=S.useState(pit),[r,n]=S.useState(!1),[a,o]=S.useState(!1),[l,i]=S.useState(!1),[d,u]=S.useState(!1),[p,f]=S.useState("my"),{data:y}=Px(),_=(y==null?void 0:y.role)==="team_leader",{data:b,isLoading:N}=cke(t),{yearStats:w,lifetimeStats:k,isLoading:C,showCommission:A}=zXe(t),{data:I,isLoading:L}=FXe(t),{data:O}=ihe(),V=v8t(),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(ie=>{var oe,me;return[ie.property_address,ie.city||"",ie.state||"",ie.zip||"",ie.transaction_type,ie.close_date,ie.sale_price,...A?[ie.commission_amount||""]:[],((oe=ie.lead_source)==null?void 0:oe.name)||"",((me=ie.client_type)==null?void 0:me.name)||"",ie.contact?`${ie.contact.first_name} ${ie.contact.last_name||""}`.trim():"",ie.is_win?"Yes":"No",ie.notes||""]}),J=[te,...Y].map(ie=>ie.map(oe=>`"${String(oe).replace(/"/g,'""')}"`).join(",")).join(` `),X=new Blob([J],{type:"text/csv"}),ce=URL.createObjectURL(X),ae=document.createElement("a");ae.href=ce,ae.download=`transactions-${t}.csv`,ae.click(),URL.revokeObjectURL(ce)},B=!b||b.length===0;return e.jsxs(Es,{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(K,{variant:p==="my"?"default":"ghost",size:"sm",onClick:()=>f("my"),className:"h-8",children:"My Scorecard"}),e.jsxs(K,{variant:p==="team"?"default":"ghost",size:"sm",onClick:()=>f("team"),className:"h-8",children:[e.jsx(or,{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(Fs,{value:String(t),onValueChange:te=>s(Number(te)),children:[e.jsx(Ds,{className:"w-[120px]",children:e.jsx(zs,{})}),e.jsx(Rs,{children:Y7e.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(Fs,{value:String(t),onValueChange:te=>s(Number(te)),children:[e.jsx(Ds,{className:"w-[120px]",children:e.jsx(zs,{})}),e.jsx(Rs,{children:Y7e.map(te=>e.jsx(vt,{value:String(te),children:te},te))})]}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(!d),children:e.jsx(So,{className:"h-4 w-4"})})]})]}),d&&e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsx(Ft,{className:"text-lg",children:"Settings"})}),e.jsx(Re,{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(Mr,{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(Re,{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(K,{onClick:()=>n(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Your First Transaction"]}),e.jsxs(K,{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(K,{variant:"link",className:"h-auto p-0",asChild:!0,children:e.jsxs("a",{href:"/templates/transaction-import-template.csv",download:!0,children:[e.jsx(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(K,{onClick:()=>n(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Transaction"]}),e.jsxs(K,{variant:"outline",onClick:()=>i(!0),children:[e.jsx(Rh,{className:"h-4 w-4 mr-2"}),"Set Goals"]}),e.jsxs(K,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"}),"Import"]}),e.jsxs(K,{variant:"outline",onClick:q,disabled:B,children:[e.jsx(Qa,{className:"h-4 w-4 mr-2"}),"Export"]}),e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,children:e.jsxs("a",{href:"/templates/transaction-import-template.csv",download:!0,children:[e.jsx(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(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Sn,{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:[k.totalTransactions," lifetime"]})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(or,{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(Re,{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:Pl(w.totalVolume,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Pl(k.totalVolume,!0)," lifetime"]})]})}),e.jsx(Pe,{children:e.jsxs(Re,{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:Pl(w.averagePrice,!0)})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(rc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((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(Re,{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:Pl(w.totalCommission,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Pl(k.totalCommission,!0)," lifetime"]})]})}),A&&w.totalNetToAgent>0&&w.totalNetToAgent!==w.totalCommission&&e.jsx(Pe,{children:e.jsxs(Re,{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:Pl(w.totalNetToAgent,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Pl(k.totalNetToAgent,!0)," lifetime"]})]})})]}),I&&e.jsx(lit,{goals:I,stats:w,year:t,showCommission:A}),e.jsxs(ta,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(Jn,{children:[e.jsx(ls,{value:"transactions",children:"Transactions"}),e.jsx(ls,{value:"charts",children:"Charts"}),e.jsxs(ls,{value:"map",children:[e.jsx(Ia,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(ws,{value:"transactions",children:e.jsx(qSe,{transactions:b||[],showCommission:A,isLoading:N})}),e.jsx(ws,{value:"charts",children:e.jsx(USe,{stats:w,year:t})}),e.jsx(ws,{value:"map",children:e.jsx(VSe,{transactions:b||[],isLoading:N})})]})]})]})]}),e.jsx(oit,{open:r,onOpenChange:n}),e.jsx(Nws,{open:a,onOpenChange:o}),e.jsx(Sws,{open:l,onOpenChange:i,year:t,existingGoals:I})]})}function fit({open:t,onOpenChange:s,listingId:r,listingSlug:n,listingTitle:a}){const{user:o}=qs(),[l,i]=S.useState(null),[d,u]=S.useState(!1),[p,f]=S.useState(!1);S.useEffect(()=>{(async()=>{if(!(!t||!o)){u(!0);try{const{data:w,error:k}=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(k)throw k;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),k=encodeURIComponent(`Check out this listing: ${a}`);switch(N){case"email":window.open(`mailto:?subject=${k}&body=${w}`);break;case"text":window.open(`sms:?body=${k}%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(hs,{className:"sm:max-w-md",children:[e.jsxs(js,{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(Le,{value:d?"Generating...":y,readOnly:!0,className:"font-mono text-sm"}),e.jsx(K,{onClick:_,disabled:d||!y,variant:p?"default":"outline",children:p?e.jsx(Zn,{className:"h-4 w-4"}):e.jsx(Wa,{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(K,{variant:"outline",className:"flex-1",onClick:()=>b("email"),disabled:d,children:[e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Email"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>b("text"),disabled:d,children:[e.jsx(Si,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(K,{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(Cn,{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(or,{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 w9({listing:t,onClick:s,onEdit:r,onDelete:n,showActions:a}){var N,w;const{user:o}=qs(),{data:l}=PXe(t.id),i=EXe(),[d,u]=S.useState(!1),p=k=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(k),f=((N=t.photos)==null?void 0:N.find(k=>k.is_primary))||((w=t.photos)==null?void 0:w[0]),y=(o==null?void 0:o.id)===t.agent_id,_=async k=>{k.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=k=>{if(k.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(K,{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(K,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:b,title:y?"Copy link":"Share & earn leads",children:y?e.jsx(_d,{className:"h-4 w-4"}):e.jsx(Or,{className:"h-4 w-4 text-amber-500"})})]})]}),e.jsx(fit,{open:d,onOpenChange:u,listingId:t.id,listingSlug:t.slug||null,listingTitle:t.property_address||`${t.city}, ${t.state}`}),e.jsxs(Re,{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(or,{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(Cn,{className:"h-3 w-3"}),t.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(_d,{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(K,{variant:"outline",size:"sm",className:"flex-1",onClick:k=>{k.stopPropagation(),r()},children:[e.jsx(Wc,{className:"h-4 w-4 mr-2"}),"Edit"]}),n&&e.jsx(K,{variant:"destructive",size:"sm",onClick:k=>{k.stopPropagation(),n()},children:e.jsx(xr,{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(Lt,{className:"flex flex-row items-center justify-between pb-3",children:[e.jsx(Ft,{className:"text-lg",children:"Filters"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:n,children:"Clear All"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(jr,{className:"h-4 w-4"})})]})]}),e.jsxs(Re,{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(Fs,{value:t.status||"all",onValueChange:a=>s({...t,status:a==="all"?void 0:a}),children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"All statuses"})}),e.jsxs(Rs,{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(Fs,{value:t.propertyType||"all",onValueChange:a=>s({...t,propertyType:a==="all"?void 0:a}),children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"All types"})}),e.jsxs(Rs,{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(Le,{type:"number",placeholder:"No minimum",value:t.minPrice||"",onChange:a=>s({...t,minPrice:a.target.value?Number(a.target.value):void 0})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Max Price"}),e.jsx(Le,{type:"number",placeholder:"No maximum",value:t.maxPrice||"",onChange:a=>s({...t,maxPrice:a.target.value?Number(a.target.value):void 0})})]})]}),e.jsxs("div",{className:"flex items-center justify-between mt-4 pt-4 border-t",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Open to Referrals Only"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show only listings accepting buyer referrals"})]}),e.jsx(Mr,{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(Vi,{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(rc,{className:"h-5 w-5 text-amber-700"});default:return e.jsx("span",{className:"text-sm font-medium text-muted-foreground w-5 text-center",children:n+1})}},r=(n,a)=>!n||n.length===0?e.jsx("div",{className:"py-8 text-center text-muted-foreground",children:"No data yet. Start sharing to climb the leaderboard!"}):e.jsx("div",{className:"space-y-2",children:n.map((o,l)=>e.jsxs("div",{className:`flex items-center gap-4 p-3 rounded-lg ${l===0?"bg-gradient-to-r from-amber-500/10 to-amber-500/5 border border-amber-500/20":"bg-muted/50"}`,children:[e.jsx("div",{className:"flex items-center justify-center w-8",children:s(l)}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"font-medium truncate",children:o.name})}),e.jsxs(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(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Vi,{className:"h-5 w-5 text-amber-500"}),"Community Badges"]})}),e.jsx(Re,{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(_d,{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(Sn,{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(Vi,{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(Lt,{children:e.jsx(Ft,{children:"Community Leaderboard"})}),e.jsx(Re,{children:e.jsxs(ta,{defaultValue:"sharers",children:[e.jsxs(Jn,{className:"w-full",children:[e.jsxs(ls,{value:"sharers",className:"flex-1",children:[e.jsx(_d,{className:"h-4 w-4 mr-2"}),"Top Sharers"]}),e.jsxs(ls,{value:"listers",className:"flex-1",children:[e.jsx(Sn,{className:"h-4 w-4 mr-2"}),"Top Contributors"]})]}),e.jsx(ws,{value:"sharers",className:"mt-4",children:r(t==null?void 0:t.topSharers,"shares")}),e.jsx(ws,{value:"listers",className:"mt-4",children:r(t==null?void 0:t.topListers,"listings")})]})})]})]})}const X7e={coming_soon:"#F59E0B",active:"#10B981",price_improvement:"#8B5CF6",under_contract:"#3B82F6",sold:"#A855F7"},Q7e={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=vr(),n=S.useRef(null),a=S.useRef(null),o=S.useRef([]),{isAdmin:l}=qs(),[i,d]=S.useState(""),[u,p]=S.useState(!0),[f,y]=S.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 S.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)})()},[]),S.useEffect(()=>{if(!i||b.length===0||f)return;(async()=>{var w;y(!0);for(const k of b){const C=[k.property_address,k.city,k.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",k.id),k.latitude=O,k.longitude=L}}catch(A){console.error("Geocode error:",A)}}y(!1)})()},[i,t]),S.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],k=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],k=N.length===1?12:10}return a.current=new Ko.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:k,center:w}),a.current.addControl(new Ko.NavigationControl,"top-right"),()=>{var C;(C=a.current)==null||C.remove(),a.current=null}},[i]),S.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 k=X7e[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}
${Q7e[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(k=>w.extend([k.longitude,k.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]),S.useEffect(()=>(window.__navigateToListing__=N=>{r(`/mission-control/listings/${N}`)},()=>{delete window.__navigateToListing__}),[r]),u||s?e.jsx(Pe,{children:e.jsx(Re,{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(Re,{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(X7e).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:Q7e[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(Re,{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,ae;const t=vr(),{brokerageId:s}=qs(),{data:r,isLoading:n}=SXe(),[a,o]=S.useState("feed"),[l,i]=S.useState(!1),[d,u]=S.useState(""),[p,f]=S.useState({sortBy:"newest"}),{data:y,isLoading:_}=CXe({...p,city:d||p.city}),{data:b,isLoading:N}=t8t(),{data:w,isLoading:k}=MXe(),{data:C,isLoading:A}=a8t(),{data:I,isLoading:L}=l8t(),{data:O}=o8t(),V=AXe(),q=async ie=>{if(confirm("Are you sure you want to delete this listing? This action cannot be undone."))try{await V.mutateAsync(ie),pe.success("Listing deleted successfully")}catch{pe.error("Failed to delete listing")}};return n?e.jsx(Es,{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(Es,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Listing Exchange"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsxs(K,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(Bs,{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(Re,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(Sn,{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(Re,{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(Re,{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(Re,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-sky-500/10 rounded-lg",children:e.jsx(or,{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(ls,{value:"feed",children:"Community Feed"}),s&&e.jsx(ls,{value:"brokerage",children:"Brokerage"}),e.jsx(ls,{value:"my-listings",children:"My Listings"}),e.jsx(ls,{value:"saved",children:"Saved"}),e.jsx(ls,{value:"referrals",children:"Referrals"}),e.jsx(ls,{value:"map",children:"Map"}),e.jsx(ls,{value:"leaderboard",children:"Leaderboard"})]}),e.jsxs(ws,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by city or neighborhood...",value:d,onChange:ie=>u(ie.target.value),className:"pl-9"})]}),e.jsxs(Fs,{value:p.sortBy,onValueChange:ie=>f({...p,sortBy:ie}),children:[e.jsx(Ds,{className:"w-[180px]",children:e.jsx(zs,{placeholder:"Sort by"})}),e.jsxs(Rs,{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(K,{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((ie,oe)=>e.jsxs(Pe,{children:[e.jsx(ks,{className:"h-48 w-full"}),e.jsxs(Re,{className:"p-4 space-y-2",children:[e.jsx(ks,{className:"h-5 w-3/4"}),e.jsx(ks,{className:"h-4 w-1/2"}),e.jsx(ks,{className:"h-4 w-1/4"})]})]},oe))}):(y==null?void 0:y.length)===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center",children:[e.jsx(Sn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No listings found"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Be the first to share a listing with the community!"}),e.jsxs(K,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(Bs,{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(ie=>e.jsx(w9,{listing:ie,onClick:()=>t(`/mission-control/listings/${ie.id}`)},ie.id))})]}),e.jsx(ws,{value:"my-listings",className:"space-y-4",children:k?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((ie,oe)=>e.jsxs(Pe,{children:[e.jsx(ks,{className:"h-48 w-full"}),e.jsxs(Re,{className:"p-4 space-y-2",children:[e.jsx(ks,{className:"h-5 w-3/4"}),e.jsx(ks,{className:"h-4 w-1/2"})]})]},oe))}):(w==null?void 0:w.length)===0?e.jsx(Pe,{children:e.jsxs(Re,{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(K,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(Bs,{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(ie=>e.jsx(w9,{listing:ie,showActions:!0,onClick:()=>t(`/mission-control/listings/${ie.id}`),onEdit:()=>t(`/mission-control/listings/${ie.id}/edit`),onDelete:()=>q(ie.id)},ie.id))})}),e.jsx(ws,{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((ie,oe)=>e.jsxs(Pe,{children:[e.jsx(ks,{className:"h-48 w-full"}),e.jsxs(Re,{className:"p-4 space-y-2",children:[e.jsx(ks,{className:"h-5 w-3/4"}),e.jsx(ks,{className:"h-4 w-1/2"})]})]},oe))}):(b==null?void 0:b.length)===0?e.jsx(Pe,{children:e.jsxs(Re,{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(ie=>e.jsx(w9,{listing:ie.listing,onClick:()=>t(`/mission-control/listings/${ie.listing.id}`)},ie.id))})}),e.jsx(ws,{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(_d,{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(Re,{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(ie=>{var oe,me;return e.jsx(Pe,{children:e.jsx(Re,{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:ie.buyer_name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((oe=ie.listing)==null?void 0:oe.property_address)||((me=ie.listing)==null?void 0:me.city)})]}),e.jsx(Qe,{variant:ie.status==="closed"?"default":"secondary",children:ie.status.replace("_"," ")})]})})},ie.id)})})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold mb-3 flex items-center gap-2",children:[e.jsx(or,{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(Re,{className:"py-8 text-center text-muted-foreground",children:"No referrals received yet"})}):e.jsx("div",{className:"space-y-3",children:(ae=C==null?void 0:C.received)==null?void 0:ae.map(ie=>{var oe;return e.jsx(Pe,{children:e.jsxs(Re,{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:ie.buyer_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["From: ",(oe=ie.sender)==null?void 0:oe.name]})]}),e.jsx(Qe,{variant:ie.status==="closed"?"default":"secondary",children:ie.status.replace("_"," ")})]}),e.jsx(K,{size:"sm",variant:"outline",className:"w-full mt-2",onClick:()=>t(`/mission-control/listings/${ie.listing_id}`),children:"View Listing"})]})},ie.id)})})]})]})}),s&&e.jsx(ws,{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((ie,oe)=>e.jsxs(Pe,{children:[e.jsx(ks,{className:"h-48 w-full"}),e.jsxs(Re,{className:"p-4 space-y-2",children:[e.jsx(ks,{className:"h-5 w-3/4"}),e.jsx(ks,{className:"h-4 w-1/2"})]})]},oe))}):(I==null?void 0:I.length)===0?e.jsx(Pe,{children:e.jsxs(Re,{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(K,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(Bs,{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(ie=>e.jsx(w9,{listing:ie,onClick:()=>t(`/mission-control/listings/${ie.id}`)},ie.id))})}),e.jsx(ws,{value:"map",children:e.jsx(Bws,{listings:y||[],isLoading:_})}),e.jsx(ws,{value:"leaderboard",children:e.jsx(Fws,{leaderboard:O})})]})]})}):e.jsx(Es,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center",children:[e.jsx(Sn,{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}=qs(),{data:a=[],isLoading:o}=qh(),{data:l=[]}=Nf(),[i,d]=S.useState(""),[u,p]=S.useState("all"),[f,y]=S.useState(new Set),[_,b]=S.useState(!1),[N,w]=S.useState(null);S.useEffect(()=>{t||(d(""),p("all"),y(new Set),b(!1))},[t]),S.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 k=S.useMemo(()=>a.filter(q=>q.email),[a]),C=S.useMemo(()=>{let q=k;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},[k,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=S.useMemo(()=>k.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})),[k,f]),{defaultSubject:O,defaultBody:V}=S.useMemo(()=>{var he,ge,Ne,Ue;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}`,ae=((ge=(he=r.photos)==null?void 0:he.find(Te=>Te.is_primary))==null?void 0:ge.photo_url)||((Ue=(Ne=r.photos)==null?void 0:Ne[0])==null?void 0:Ue.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}`,ye=`

Hi {{first_name}},

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

${ae?` ${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:ye}},[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(hs,{className:"sm:max-w-[640px] max-h-[90vh] flex flex-col",children:[e.jsxs(js,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search contacts...",value:i,onChange:q=>d(q.target.value),className:"pl-9"})]}),e.jsxs(Fs,{value:u,onValueChange:p,children:[e.jsx(Ds,{className:"sm:w-[180px]",children:e.jsx(zs,{placeholder:"Filter by tag"})}),e.jsxs(Rs,{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(Hi,{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(or,{className:"h-3 w-3"}),f.size," selected"]})]}),e.jsx(ni,{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:k.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(Hi,{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(xo,{}),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(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{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 Ame(){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 xit(){const t=ya(),s=Qt();return Et({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 Eme(){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 git(){const t=ya(),s=Qt();return Et({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 yit(){const t=Qt();return Et({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 Et({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 Et({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 Et({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 Et({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 Et({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 Et({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 Et({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=vr(),[r,n]=S.useState(""),[a,o]=S.useState(!1),{data:l,isLoading:i}=Jws(t.id),{data:d,isLoading:u}=Ame(),{data:p,isLoading:f}=Eme(),y=xit(),_=e2s(),b=t2s(),N=git(),w=(p==null?void 0:p.filter(L=>!L.listing_id))||[],k=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=k(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(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2 text-base",children:[e.jsx(Yy,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsx(Re,{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(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"flex items-center gap-2 text-base",children:[e.jsx(Do,{className:"h-4 w-4 text-primary"}),"Linked to Pipeline"]})}),e.jsxs(Re,{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(K,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>s("/mission-control/pipeline"),children:["View Pipeline",e.jsx(Ga,{className:"h-3 w-3 ml-1"})]}),e.jsx(K,{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(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"flex items-center gap-2 text-base",children:[e.jsx(Yy,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Link this listing to your pipeline to track the deal and sync status changes."}),e.jsxs(K,{onClick: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(Bs,{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(Fs,{value:r,onValueChange:n,children:[e.jsx(Ds,{className:"flex-1 text-sm",children:e.jsx(zs,{placeholder:"Link to existing deal..."})}),e.jsx(Rs,{children:w.map(L=>e.jsx(vt,{value:L.id,children:L.deal_name},L.id))})]}),e.jsx(K,{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"},J7e={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function a2s(){var ce,ae,ie,oe,me,ye,he,ge,Ne;const{listingId:t}=ao(),s=vr(),{user:r}=qs(),{data:n,isLoading:a}=TXe(t||""),{data:o}=PXe(t||""),{data:l}=r8t(t||""),i=EXe(),d=s8t(),u=n8t(),p=AXe(),f=i8t(),[y,_]=S.useState(!1),[b,N]=S.useState(!1),[w,k]=S.useState(!1),[C,A]=S.useState(!1),[I,L]=S.useState(null),[O,V]=S.useState({buyerName:"",buyerType:"",notes:""}),q=(r==null?void 0:r.id)===(n==null?void 0:n.agent_id),B=Ue=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(Ue),U=async Ue=>{const Te=`https://listings.relevelup.com/${(n==null?void 0:n.slug)||(n==null?void 0:n.id)}`,Me=`Check out this listing: ${(n==null?void 0:n.property_address)||(n==null?void 0:n.city)}`;u.mutate({listingId:n.id,shareType:Ue});try{switch(Ue){case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(Te)}`,"_blank");break;case"copy":await navigator.clipboard.writeText(Te),pe.success("Link copied to clipboard!");break;case"text":window.open(`sms:?body=${encodeURIComponent(`${Me} ${Te}`)}`);break;case"email":window.open(`mailto:?subject=${encodeURIComponent(Me)}&body=${encodeURIComponent(`Check out this listing: ${Te}`)}`);break}}catch(De){console.error("Share error:",De),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=Ue=>{var Be,we;const Te=(n==null?void 0:n.property_address)||`${n==null?void 0:n.city}, ${n==null?void 0:n.state}`,Me=B((n==null?void 0:n.price)||0),De=n!=null&&n.bedrooms?`${n.bedrooms}BD`:"",qe=n!=null&&n.bathrooms?`${n.bathrooms}BA`:"",ke=n!=null&&n.square_footage?`${n.square_footage.toLocaleString()}SF`:"",$e=[De,qe,ke].filter(Boolean).join(" | ");switch(Ue){case"just_listed":return`🏡 JUST LISTED! ${Te} ${Me} ${$e} ${(n==null?void 0:n.description)||"Schedule your showing today!"} #JustListed #RealEstate #HomeForSale #${(Be=n==null?void 0:n.city)==null?void 0:Be.replace(/\s/g,"")}`;case"price_improvement":return`📣 PRICE IMPROVEMENT! ${Te} Now ${Me}! ${$e} Don't miss this opportunity! #PriceReduced #RealEstate #HomeForSale`;case"teaser":return`Looking for a ${J7e[(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! ${$e} DM me for details! 📩 #ComingSoon #RealEstate #${(we=n==null?void 0:n.city)==null?void 0:we.replace(/\s/g,"")}`;default:return""}};if(a)return e.jsx(Es,{title:"Listing",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ks,{className:"h-10 w-32"}),e.jsx(ks,{className:"h-[400px] w-full"}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsx(ks,{className:"h-48"}),e.jsx(ks,{className:"h-48"}),e.jsx(ks,{className:"h-48"})]})]})});if(!n)return e.jsx(Es,{title:"Listing Not Found",description:"",children:e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing could not be found."}),e.jsx(K,{onClick:()=>s("/mission-control/listings"),children:"Back to Listings"})]})})});const X=((ce=n.photos)==null?void 0:ce.find(Ue=>Ue.is_primary))||((ae=n.photos)==null?void 0:ae[0]);return e.jsxs(Es,{title:"",description:"",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs(K,{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:(ie=n.photos)==null?void 0:ie.slice(1,5).map((Ue,Te)=>e.jsx("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>L(Ue.photo_url),children:e.jsx("img",{src:Ue.photo_url,alt:`Photo ${Te+2}`,className:"w-full h-full object-cover"})},Ue.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(Re,{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(or,{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(K,{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(K,{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(K,{variant:"outline",className:"border-amber-500 text-amber-600 hover:bg-amber-50",onClick:()=>k(!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(K,{variant:"outline",children:[e.jsx(_d,{className:"h-4 w-4 mr-2"}),"Share"]})}),e.jsxs(Nd,{children:[e.jsxs(_a,{onClick:()=>U("copy"),children:[e.jsx(Wa,{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(Si,{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(K,{variant:"outline",onClick:()=>A(!0),className:"gap-2",children:[e.jsx(tr,{className:"h-4 w-4"}),"Email My Sphere"]}),e.jsxs(K,{variant:"outline",onClick:()=>s(`/mission-control/listings/${n.id}/edit`),children:[e.jsx(Wc,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsx(K,{variant:"destructive",size:"icon",onClick:()=>_(!0),children:e.jsx(xr,{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(ln,{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"}),J7e[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(K,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:n.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Zr,{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(Cn,{className:"h-4 w-4"}),n.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(_d,{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(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"Share Content"})}),e.jsx(Re,{className:"space-y-4",children:["just_listed","price_improvement","teaser"].map(Ue=>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:[Ue.replace("_"," ")," Caption"]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{navigator.clipboard.writeText(J(Ue)),pe.success("Caption copied!")},children:e.jsx(Wa,{className:"h-3 w-3"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:J(Ue)})]},Ue))})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"Listing Agent"})}),e.jsxs(Re,{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:((ye=n.agent)==null?void 0:ye.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:((Ne=n.agent)==null?void 0:Ne.email)&&e.jsx(K,{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(Lt,{children:e.jsxs(Ft,{className:"text-lg flex items-center gap-2",children:[e.jsx(or,{className:"h-5 w-5"}),"Send a Buyer"]})}),e.jsxs(Re,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Have a buyer interested in this property? Send a referral to the listing agent."}),e.jsx(K,{className:"w-full",onClick:()=>N(!0),children:"Send Referral"})]})]})]})]})]}),e.jsx(fs,{open:!!I,onOpenChange:()=>L(null),children:e.jsx(hs,{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(hs,{children:[e.jsxs(js,{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(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:te,disabled:p.isPending,children:p.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(fs,{open:b,onOpenChange:N,children:e.jsxs(hs,{children:[e.jsxs(js,{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(Le,{value:O.buyerName,onChange:Ue=>V({...O,buyerName:Ue.target.value}),placeholder:"Enter buyer's name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Buyer Type"}),e.jsxs(Fs,{value:O.buyerType,onValueChange:Ue=>V({...O,buyerType:Ue}),children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select type"})}),e.jsxs(Rs,{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(gr,{value:O.notes,onChange:Ue=>V({...O,notes:Ue.target.value}),placeholder:"Any additional information..."})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>N(!1),children:"Cancel"}),e.jsx(K,{onClick:Y,disabled:f.isPending,children:f.isPending?"Sending...":"Send Referral"})]})]})}),e.jsx(fit,{open:w,onOpenChange:k,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]=S.useState(""),[n,a]=S.useState([]),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState(null),f=S.useRef(),y=S.useRef(null);S.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()}`:"",k=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(Lt,{className:"pb-3",children:[e.jsxs(Ft,{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(Re,{children:e.jsxs("div",{ref:y,className:"relative",children:[e.jsxs("div",{className:"relative",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{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(jr,{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:k(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:Dt("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(jr,{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(gce(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(k=>k.id===p.id),_=i.findIndex(k=>k.id===f.id),b=[...i],[N]=b.splice(y,1);b.splice(_,0,N);const w=b.map((k,C)=>({...k,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=vr(),{user:a}=qs(),[o,l]=S.useState(!1),[i,d]=S.useState([]),[u,p]=S.useState(!1),[f,y]=S.useState(null),[_,b]=S.useState({});S.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)}},k=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(ae=>ae.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 ae of B)(U=X[ae.bunny_video_id])!=null&&U.thumbnailUrl&&(ce[ae.id]={thumbnailUrl:X[ae.bunny_video_id].thumbnailUrl});b(ae=>({...ae,...ce}))}catch(te){console.warn("Failed to bulk-fetch signed URLs",te)}},A=()=>{l(!0),k()},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(Re,{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(gn,{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(K,{type:"button",variant:"outline",size:"sm",onClick:A,children:"Change"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:L,className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})]})]})})}):e.jsx(Pe,{className:"border-dashed",children:e.jsx(Re,{className:"p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(gn,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Add a video walkthrough to showcase this property"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 justify-center",children:[e.jsxs(K,{type:"button",variant:"outline",onClick:A,className:"gap-2",children:[e.jsx(oS,{className:"h-4 w-4"}),"Select from Library"]}),e.jsxs(K,{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(hs,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsx(js,{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(gn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"No videos in your library yet"}),e.jsxs(K,{onClick:O,className:"gap-2",children:[e.jsx(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(gn,{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(K,{type:"button",variant:"ghost",onClick:O,className:"gap-2",children:[e.jsx(xx,{className:"h-4 w-4"}),"Record New Video"]}),e.jsx(K,{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(jr,{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(gce(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),[k]=N.splice(y,1);b.splice(_,0,w),N.splice(_,0,k),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 eze(){const{listingId:t}=ao(),[s]=Nc(),r=s.get("brokerage"),n=vr(),{user:a}=qs(),{hasLeadSite:o}=CC(),l=!!t&&t!=="new",i=!!r&&!l,[d,u]=S.useState([]),{data:p,isLoading:f}=TXe(l?t:""),y=KLt(),_=ZLt(),b=YLt(),N=XLt(),w=QLt(),k=JLt(),C=e8t(),{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]=S.useState(""),[O,V]=S.useState(!1),[q,B]=S.useState([]),[U,te]=S.useState([]),[Y,J]=S.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});S.useEffect(()=>{var he,ge,Ne,Ue,Te;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:((Ne=p.bathrooms)==null?void 0:Ne.toString())||"",square_footage:((Ue=p.square_footage)==null?void 0:Ue.toString())||"",lot_size:p.lot_size||"",year_built:((Te=p.year_built)==null?void 0:Te.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 Te,Me;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"},Ne=(he.propertyType||"").toLowerCase(),Ue=((Te=Object.entries(ge).find(([De])=>Ne.includes(De)))==null?void 0:Te[1])||"other";J(De=>({...De,property_address:he.address||De.property_address,city:he.city||De.city,state:he.state||De.state,price:he.price?String(he.price):De.price,property_type:Ue,bedrooms:he.bedrooms?String(he.bedrooms):De.bedrooms,bathrooms:he.bathrooms?String(he.bathrooms):De.bathrooms,square_footage:he.sqft?String(he.sqft):De.square_footage,lot_size:he.lotSize?String(he.lotSize):De.lot_size,year_built:he.yearBuilt?String(he.yearBuilt):De.year_built,description:he.description||De.description})),((Me=he.photos)==null?void 0:Me.length)>0&&(u(he.photos),U.forEach(De=>URL.revokeObjectURL(De)),B([]),te([]))},ce=he=>{if(!he)return;const ge=Array.from(he);B(Ue=>[...Ue,...ge]);const Ne=ge.map(Ue=>URL.createObjectURL(Ue));te(Ue=>[...Ue,...Ne])},ae=he=>{URL.revokeObjectURL(U[he]),B(ge=>ge.filter((Ne,Ue)=>Ue!==he)),te(ge=>ge.filter((Ne,Ue)=>Ue!==he))},ie=async he=>{var ge;if(!(!he||!p)){V(!0);try{for(const Ne of Array.from(he)){const Ue=Ne.name.split(".").pop(),Te=`${a==null?void 0:a.id}/${p.id}/${Date.now()}.${Ue}`,{error:Me}=await G.storage.from("listing-photos").upload(Te,Ne);if(Me)throw Me;const{data:{publicUrl:De}}=G.storage.from("listing-photos").getPublicUrl(Te);await N.mutateAsync({listingId:p.id,photoUrl:De,isPrimary:!((ge=p.photos)!=null&&ge.length)})}pe.success("Photos uploaded!")}catch(Ne){console.error("Upload error:",Ne),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")}},ye=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 Ne;if(i&&I?Ne=await _.mutateAsync({agentId:I,...ge}):Ne=await y.mutateAsync(ge),q.length>0)try{await oe(Ne.id),U.forEach(Ue=>URL.revokeObjectURL(Ue)),B([]),te([])}catch(Ue){console.error("Photo upload error:",Ue),pe.error("Listing created but some photos failed to upload")}if(d.length>0)try{for(let Ue=0;Uen(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(Lt,{children:e.jsx(Ft,{children:"Assign to Agent *"})}),e.jsxs(Re,{children:[e.jsxs(Fs,{value:I,onValueChange:L,children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select an agent..."})}),e.jsx(Rs,{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(Lt,{className:"pb-3",children:[e.jsxs(Ft,{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(Re,{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(K,{type:"button",variant:"ghost",size:"sm",className:"mt-2 text-destructive",onClick:()=>u([]),children:[e.jsx(jr,{className:"h-3 w-3 mr-1"})," Clear MLS photos"]})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"Property Details"})}),e.jsx(Re,{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(Le,{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(Le,{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(Le,{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(Le,{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(Le,{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(Fs,{value:Y.property_type,onValueChange:he=>J({...Y,property_type:he}),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsx(Rs,{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(Fs,{value:Y.status,onValueChange:he=>J({...Y,status:he}),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsx(Rs,{children:d2s.map(he=>e.jsx(vt,{value:he.value,children:he.label},he.value))})]})]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"Property Specs (Optional)"})}),e.jsx(Re,{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(Le,{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(Le,{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(Le,{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(Le,{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(Le,{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(Mr,{checked:Y.has_hoa,onCheckedChange:he=>J({...Y,has_hoa:he})}),e.jsx(xe,{children:"Has HOA"})]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"Description & Links"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Description"}),e.jsx(gr,{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(gr,{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(Mr,{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(Le,{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(Le,{value:Y.video_link,onChange:he=>J({...Y,video_link:he.target.value}),placeholder:"YouTube or Vimeo URL"})]})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(gn,{className:"h-5 w-5"}),"Property Video"]})}),e.jsx(Re,{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(Lt,{children:e.jsx(Ft,{children:"Photos"})}),e.jsx(Re,{children:l&&(p!=null&&p.photos)?e.jsx(l2s,{photos:p.photos,uploading:O,onUpload:he=>ie(he),onRemove:he=>me(he),onReorder:he=>{k.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:ae,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(Lt,{children:e.jsx(Ft,{children:"Sharing & Collaboration"})}),e.jsxs(Re,{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(Mr,{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(Mr,{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(Mr,{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(Mr,{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(Mr,{checked:Y.is_public,onCheckedChange:he=>J({...Y,is_public:he})})]})]})]}),e.jsx(K,{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 Zm=null;function p2s(){if(Zm)return Zm;try{const t=document.createElement("canvas"),s=t.getContext("webgl2")||t.getContext("webgl");if(!s)return Zm={canRunVirtualBg:!1,reason:"WebGL is not supported on this device"},Zm;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 Zm={canRunVirtualBg:!1,reason:"Your device uses a software renderer which may cause lag",renderer:n},Zm;const i=performance;return i.memory&&i.memory.jsHeapSizeLimit<256*1024*1024?(Zm={canRunVirtualBg:!1,reason:"Limited device memory detected",renderer:n},Zm):navigator.hardwareConcurrency&&navigator.hardwareConcurrency<2?(Zm={canRunVirtualBg:!1,reason:"Single-core device detected — virtual backgrounds may cause lag",renderer:n},Zm):(Zm={canRunVirtualBg:!0,renderer:n},Zm)}catch{return Zm={canRunVirtualBg:!0},Zm}}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=S.useRef(null),[l,i]=S.useState(!1),[d]=S.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:k,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),[]):k||[]}}),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 k=(C=w.target.files)==null?void 0:C[0];if(k){if(!k.type.startsWith("image/")){pe.error("Please select an image file");return}if(k.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=k.name.split(".").pop()||"jpg",L=`${A.id}/${crypto.randomUUID()}.${I}`,{error:O}=await G.storage.from("video-backgrounds").upload(L,k,{contentType:k.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:k.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:Dt("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,k)=>{const C=b(w);return e.jsxs("button",{type:"button",disabled:n,onClick:()=>s({type:w.type,imageUrl:w.imageUrl,blurRadius:15}),className:Dt("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||k}`)}),e.jsxs("button",{type:"button",disabled:n||l,onClick:()=>{var w;return(w=o.current)==null?void 0:w.click()},className:Dt("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(Bs,{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:Dt("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 vit(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 bit(t){yA.setTimeout(()=>{throw t},0)}var Iwe,_2s=vit(610401301,!1),sze=vit(748402147,!0);function rze(){var t=yA.navigator;return t&&(t=t.userAgent)?t:""}const nze=yA.navigator;function Pme(t){return Pme[" "](t),t}Iwe=nze&&nze.userAgentData||null,Pme[" "]=function(){};const wit={};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 jit(){if(!$I){$I={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),s=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){const n=t.concat(s[r].split(""));wit[r]=n;for(let a=0;a0)&&(rze().indexOf("Trident")!=-1||rze().indexOf("MSIE")!=-1))&&typeof btoa=="function";const aze=/[-_.]/g,j2s={"-":"+",_:"/",".":"="};function N2s(t){return j2s[t]||""}function kit(t){if(!Nit)return b2s(t);t=aze.test(t)?t.replace(aze,N2s):t,t=atob(t);const s=new Uint8Array(t.length);for(let r=0;r=s||(r[t]=n+1,Cit(t=Error(),"incident"),bit(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),ize=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),oze=T0();const Mit={Ga:{value:0,configurable:!0,writable:!0,enumerable:!1}},Tit=Object.defineProperties,ba=kE?C2s:"Ga";var IC;const lze=[];function bO(t,s){kE||ba in t||Tit(t,Mit),t[ba]|=s}function yu(t,s){kE||ba in t||Tit(t,Mit),t[ba]=s}function wO(t){return bO(t,34),t}function cR(t){return bO(t,8192),t}yu(lze,7),IC=Object.freeze(lze);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 WSe(t,s){if(t!=null){if(typeof t=="string")t=t?new u0(t,vA):fC();else if(t.constructor!==u0)if(HSe(t))t=t.length?new u0(new Uint8Array(t),vA):fC();else{if(!s)throw Error();t=void 0}}return t}class cze{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 Ait(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"),dze=Ime(t=>typeof t=="string"),I2s=Ime(t=>typeof t=="boolean"),Lme=typeof yA.BigInt=="function"&&typeof yA.BigInt(0)=="bigint";function ff(t){var s=t;if(dze(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 Lme?BigInt(t):t=I2s(t)?t?"1":"0":dze(t)?t.trim()||"0":String(t)}var Rwe=Ime(t=>Lme?t>=D2s&&t<=O2s:t[0]==="-"?uze(t,L2s):uze(t,R2s));const L2s=Number.MIN_SAFE_INTEGER.toString(),D2s=Lme?BigInt(Number.MIN_SAFE_INTEGER):void 0,R2s=Number.MAX_SAFE_INTEGER.toString(),O2s=Lme?BigInt(Number.MAX_SAFE_INTEGER):void 0;function uze(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){hze(-t);const[s,r]=YSe(Ic,Fd);Ic=s>>>0,Fd=r>>>0}else hze(t)}function KSe(t){const s=z2s||(z2s=new DataView(new ArrayBuffer(8)));s.setFloat32(0,+t,!0),Fd=0,Ic=s.getUint32(0,!0)}function Pit(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 Iit(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+mze(r)+mze(t));return r}function mze(t){return t=String(t),"0000000".slice(t.length)+t}function ZSe(t,s){if(2147483648&s)if(NE())t=""+(BigInt(0|s)<>>0));else{const[r,n]=YSe(t,s);t="-"+dR(r,n)}else t=dR(t,s);return t}function Dme(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]=YSe(Ic,Fd);Ic=n,Fd=a}}}function YSe(t,s){return s=~s,t?t=1+~t:s+=1,[t,s]}function Og(t){return Array.prototype.slice.call(t)}const jO=typeof BigInt=="function"?BigInt.asIntN:void 0,$2s=typeof BigInt=="function"?BigInt.asUintN:void 0,gC=Number.isSafeInteger,Rme=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 Lit(t){return t==null||typeof t=="boolean"?t:typeof t=="number"?!!t:void 0}const U2s=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function NO(t){switch(typeof t){case"bigint":return!0;case"number":return Rme(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 Rme(t)?0|t:void 0}function Dit(t){if(t==null)return t;if(typeof t=="string"&&t)t=+t;else if(typeof t!="number")return;return Rme(t)?t>>>0:void 0}function Rit(t){const s=t.length;return(t[0]==="-"?s<20||s===20&&t<="-9223372036854775808":s<19||s===19&&t<="9223372036854775807")?t:(Dme(t),ZSe(Ic,Fd))}function XSe(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=Pit(s,r))=="number"?t?-s:s:t?"-"+s:s}return t}function Oit(t){var s=NA(Number(t));return gC(s)?String(s):((s=t.indexOf("."))!==-1&&(t=t.substring(0,s)),Rit(t))}function Fit(t){var s=NA(Number(t));return gC(s)?ff(s):((s=t.indexOf("."))!==-1&&(t=t.substring(0,s)),NE()?ff(jO(64,BigInt(t))):ff(Rit(t)))}function zit(t){return gC(t)?t=ff(XSe(t)):(t=NA(t),gC(t)?t=String(t):(jA(t),t=ZSe(Ic,Fd)),t=ff(t)),t}function wde(t){const s=typeof t;return t==null?t:s==="bigint"?ff(jO(64,t)):NO(t)?s==="string"?Fit(t):zit(t):void 0}function Bit(t){if(typeof t!="string")throw Error();return t}function kO(t){if(t!=null&&typeof t!="string")throw Error();return t}function ph(t){return t==null||typeof t=="string"?t:void 0}function QSe(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[ize])||(wO((t=new s).v),t=s[ize]=t),s=t):s=new s:s=void 0,s)}function V2s(t,s,r){if(s)e:{if(!NO(s=t))throw Lwe("int64");switch(typeof s){case"string":s=Fit(s);break e;case"bigint":s=ff(jO(64,s));break e;default:s=zit(s)}}else s=wde(t);return(t=s)==null?r?q2s:void 0:t}const H2s={};let G2s=function(){try{return Pme(new class extends Map{constructor(){super()}}),!1}catch{return!0}}();class u0e{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(u0e.prototype,Map.prototype),Object.defineProperties(u0e.prototype,{size:{value:0,configurable:!0,enumerable:!0,writable:!0}}),u0e):class extends Map{constructor(){super()}};function pze(t){return t}function h0e(t){if(2&t.J)throw Error("Cannot mutate an immutable Map")}var b1=class extends W2s{constructor(t,s,r=pze,n=pze){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 h0e(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=QSe(t,n,r,o),a&&(t=eCe(t)),t}function Z2s(t){return[t,this.get(t)]}let Y2s;function fze(){return Y2s||(Y2s=new b1(wO([]),void 0,void 0,void 0,H2s))}function Ome(t){return pf?t[pf]:void 0}function jde(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 Fme(t,s,r,n){const a=n!==void 0;n=!!n;var o,l=pf;!a&&kE&&l&&(o=t[l])&&jde(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(k)}),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:Fme(t,s,hR)}if(t!=null&&t[bA]===wA)return $it(t);if(t instanceof u0){if((s=t.g)==null)t="";else if(typeof s=="string")t=s;else{if(Nit){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 $it(t){return Fme(t=t.v,0|t[ba],hR)}function IS(t,s){return qit(t,s[0],s[1])}function qit(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],sze&&1&a)throw Error("rfarr");if(2048&a&&!(2&a)&&function(){if(sze)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:xze(t,r,s)}if(t!=null&&t[bA]===wA)return gze(t);if(t instanceof b1){if(2&(s=t.J))return t;if(!t.size)return;if(r=wO(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=sCe(o,s))===IC?7:0|t[ba],d=rCe(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=QSe(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=Kit(a,o,s,r,n))==null)return s;if(o=0|a[ba],!yf(t,o)){const l=eCe(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 Zit(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=sCe(s,a))===IC?7:0|t[ba],p=rCe(u,r);if(i=!(4&p)){var f=t,y=r;const _=!!(2&p);_&&(y|=2);let b=!_,N=!0,w=0,k=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 dCe(t){let s=0,r=t.g;const n=r+10,a=t.h;for(;r>>0}function kde(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 Xit(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 Qit(t,s){if(s==0)return fC();var r=Xit(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 yze=[];function Jit(t,s,r,n){if(Sde.length){const a=Sde.pop();return a.o(n),a.g.init(t,s,r,n),a}return new njs(t,s,r,n)}function eot(t){t.g.clear(),t.l=-1,t.h=-1,Sde.length<100&&Sde.push(t)}function tot(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 loe(t){switch(t.h){case 0:t.h!=0?loe(t):dCe(t.g);break;case 1:RS(t=t.g,t.g+8);break;case 2:if(t.h!=2)loe(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(!tot(t))throw Error();if(t.h==4){if(t.l!=s)throw Error();break}loe(t)}break;default:throw Error()}}function SO(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 uCe(t){var s=_0(t.g),r=Xit(t=t.g,s);if(t=t.h,g2s){var n,a=t;(n=d0e)||(n=d0e=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(j9===void 0){try{n.decode(new Uint8Array([128]))}catch{}try{n.decode(new Uint8Array([97])),j9=!0}catch{j9=!1}}throw!j9&&(d0e=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=tze(d,r),r.length=0)}o=tze(d,r)}return o}function sot(t){const s=_0(t.g);return Qit(t.g,s)}function Bme(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 _ze(t){return t?/^-?\d+$/.test(t)?(Dme(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 $me(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 hCe(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 mCe(t,s){return Ox(t,s,2),s=t.g.end(),kA(t,s),s.push(t.h),s}function pCe(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 qme(t,s,r){Ox(t,s,2),PE(t.g,r.length),kA(t,t.g.end()),kA(t,r)}function Cde(t,s,r,n){r!=null&&(s=mCe(t,s),n(r,t),pCe(t,s))}function A0(){const t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var fCe=A0(),rot=A0(),xCe=A0(),gCe=A0(),yCe=A0(),not=A0(),ojs=A0(),Ume=A0(),aot=A0(),iot=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=qit(t,s,void 0,2048)}toJSON(){return $it(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,oze&&pf&&oze===void 0&&(n=(r=this.v)[pf])&&(n=n.da))try{n(r,s,X2s)}catch(o){bit(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 tCe(this,t,s)?JSe(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=fCe,this.l=!!t&&r===t||!1}};function Vme(t,s){return new IE(t,s,fCe)}function oot(t,s,r,n,a){Cde(t,r,uot(s,n),a)}const ljs=Vme(function(t,s,r,n,a){return t.h===2&&(SO(t,iCe(s,n,r),a),!0)},oot),cjs=Vme(function(t,s,r,n,a){return t.h===2&&(SO(t,iCe(s,n,r),a),!0)},oot);var Hme=Symbol(),Gme=Symbol(),Bwe=Symbol(),bze=Symbol(),wze=Symbol();let lot,cot;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,lot??(lot=o),cot??(cot=n[l+1]),o=n[l+=2]));const i={};for(;o&&Array.isArray(o)&&o.length&&typeof o[0]=="number"&&o[0]>0;){for(var d=0;da(o,l,i,n):a}function _Ce(t,s,r,n,a){const o=r.g;let l,i;t[s]=(d,u,p)=>o(d,u,p,i||(i=DC(Gme,vCe,_Ce,n).T),l||(l=bCe(n)),a)}function bCe(t){let s=t[Bwe];if(s!=null)return s;const r=DC(Gme,vCe,_Ce,t);return s=r.ma?(n,a)=>lot(n,a,r):(n,a)=>{for(;tot(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,loe(i),i.ha)var d=void 0;else d=i.g.g-l,i.g.g=l,d=Qit(i.g,d);l=void 0,i=n,d&&((l=i[pf]??(i[pf]=new Owe))[o]??(l[o]=[])).push(d)}}return(n=Ome(n))&&(n.da=r.qa[wze]),!0},t[Bwe]=s,t[wze]=djs.bind(t),s}function djs(t,s,r,n){var a=this[Gme];const o=this[Bwe],l=IS(void 0,a.T),i=Ome(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=Jit(_);try{d=!0,o(l,p)}finally{eot(p)}}else n==null||n(t,f,y)},s==null)jde(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?Ait(l,0|l[ba],(_,b)=>{y(_,b)}):y(s,w1(l,s,f))}}}}function ujs(t){const s=(t=dot(t))[0].g;if(t=t[1]){const r=bCe(t),n=DC(Gme,vCe,_Ce,t).T;return(a,o,l)=>s(a,o,l,n,r)}return s}function Wme(t,s,r){t[s]=r.h}function Kme(t,s,r,n){let a,o;const l=r.h;t[s]=(i,d,u)=>l(i,d,u,o||(o=DC(Hme,Wme,Kme,n).T),a||(a=hot(n)))}function hot(t){let s=t[bze];if(!s){const r=DC(Hme,Wme,Kme,t);s=(n,a)=>mot(n,a,r),t[bze]=s}return s}function mot(t,s,r){Ait(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=dot(d))[0].h;if(d=d[1]){const p=hot(d),f=DC(Hme,Wme,Kme,d).T;d=l.ma?cot(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=Ome(t))&&jde(t,(n,a,o)=>{for(kA(s,s.g.end()),n=0;n{Cde(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=_ze(s),nT(t.g,r.h,r.g)}}function xot(t,s,r){(s=CE(s))!=null&&s!=null&&(Ox(t,r,0),$me(t.g,s))}function got(t,s,r){(s=Lit(s))!=null&&(Ox(t,r,0),t.g.g.push(s?1:0))}function yot(t,s,r){(s=ph(s))!=null&&qme(t,r,_it(s))}function vot(t,s,r,n,a){Cde(t,r,uot(s,n),a)}function _ot(t,s,r){(s=s==null||typeof s=="string"||s instanceof u0?s:void 0)!=null&&qme(t,r,lCe(s,!0).buffer)}function bot(t,s,r){(s=Dit(s))!=null&&s!=null&&(Ox(t,r,0),PE(t.g,s))}function wot(t,s,r){return(t.h===5||t.h===2)&&(s=EE(s,0|s[ba],r),t.h==2?Bme(t,kde,s):s.push(kde(t.g)),!0)}var $d=Gh(function(t,s,r){return t.h===5&&(Wh(s,r,kde(t.g)),!0)},pot,Ume),pjs=DE(wot,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"))||(Dme(n),n=dR(Ic,Fd))),n;if(a==="number")return(n=NA(n))>=0&&gC(n)||(jA(n),n=Pit(Ic,Fd)),n}}(s),s!=null&&(typeof s=="string"&&vze(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=vze(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)},xot,gCe),CO=DE(function(t,s,r){return(t.h===0||t.h===2)&&(s=EE(s,0|s[ba],r),t.h==2?Bme(t,aw,s):s.push(aw(t.g)),!0)},function(t,s,r){if((s=LE(CE,s))!=null&&s.length){r=mCe(t,r);for(let n=0;n{{const o={ea:!0};n&&Object.assign(o,n),r=Jit(r,void 0,void 0,o);try{const l=new t,i=l.v;bCe(s)(i,r);var a=l}finally{eot(r)}}return a}}function Zme(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}}}};mot(this.v,s,DC(Hme,Wme,Kme,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=kze.createPolicy("goog#html",{createHTML:n,createScript:n,createScriptURL:n})}catch{}return r}()),t=(s=f0e)?s.createScriptURL(t):t,new class{constructor(r){this.g=r}toString(){return this.g+""}}(t)}function N9(t,...s){if(s.length===0)return Sze(t[0]);let r=t[0];for(let n=0;n({index:mx(n,1)??0??-1,score:md(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 ACe(((n=ko(r,Eot,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=jO(64,r),r=Rwe(r)?Number(r):String(r)),r):NO(r)?typeof r=="number"?XSe(r):Oit(r):void 0}(Oc(t,2,void 0,void 0,wde))!=null&&(s.timestampMs=nlt(Oc(t,2,void 0,void 0,wde)??Uit)),s}function alt(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 Fze(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 zze(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 llt(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 Bze(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]=llt(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 $ze(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 S9("vision",t??N9``,s)},z5.forTextTasks=function(t,s=!1){return S9("text",t??N9``,s)},z5.forGenAiTasks=function(t,s=!1){return S9("genai",t??N9``,s)},z5.forAudioTasks=function(t,s=!1){return S9("audio",t??N9``,s)},z5.isSimdSupported=function(t=!1){return ilt(t)};async function Kjs(t,s,r,n){return t=await(async(a,o,l,i,d)=>{if(o&&await zze(o),!self.ModuleFactory||l&&(await zze(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 y0e(t,s){const r=ko(t.baseOptions,Mde,1)||new Mde;typeof s=="string"?(al(r,2,kO(s)),al(r,1)):s instanceof Uint8Array&&(al(r,1,WSe(s,!1)),al(r,2)),Ha(t.baseOptions,0,1,r)}function qze(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 Jme(t,s){t.B=new Np,vf(t.B,2,"PassThroughCalculator"),wc(t.B,"free_memory"),co(t.B,"free_memory_unused_out"),Bc(s,"free_memory"),Fx(s,t.B)}function SA(t,s){wc(t.B,s),co(t.B,s+"_unused_out")}function epe(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,Mde,1))!=null&&a.g()||(o=ko(this.baseOptions,Mde,1))!=null&&o.l()||(l=t.baseOptions)!=null&&l.modelAssetBuffer||(i=t.baseOptions)!=null&&i.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if(function(u,p){let f=ko(u.baseOptions,Ize,3);if(!f){var y=f=new Ize,_=new Cze;T8(y,4,coe,_)}"delegate"in p&&(p.delegate==="GPU"?(p=f,y=new _js,T8(p,2,coe,y)):(p=f,y=new Cze,T8(p,4,coe,y))),Ha(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),y0e(this,"/model.dat"),this.m(),this.L()});if(d.modelAssetBuffer instanceof Uint8Array)y0e(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=>{y0e(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,qze(this)}finishProcessing(){this.g.finishProcessing(),qze(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 Uze(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 Vze(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 ECe(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 ECe(t,s),t.h||(t.m(),t.D()),r?(t.u||(t.u=Vze(t,!0)),r=t.u):(t.A||(t.A=Vze(t,!1)),r=t.A),s.useProgram(t.h),r.bind(),t.l(),t=n(),r.g.bindVertexArray(null),t}function clt(t,s,r){return ECe(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 dlt(t,s,r){ECe(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 ult=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=Uze(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=Uze(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=PCe(t);if(dlt(r,n,hlt(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 hlt(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=PCe(this);n.activeTexture(n.TEXTURE1),r=clt(a,n,this.m?n.LINEAR:n.NEAREST),n.bindTexture(n.TEXTURE_2D,r);const o=mlt(this);n.texImage2D(n.TEXTURE_2D,0,o,this.width,this.height,0,n.RED,n.FLOAT,null),n.bindTexture(n.TEXTURE_2D,null),dlt(a,n,r),Yjs(a,n,!1,()=>{plt(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)),Hze=-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 Hze=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()}}}((Gze=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:olt()?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]=Bze(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=>{$ze(this,Object.keys(t),a=>{$ze(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 Gze{get ga(){return this.i}pa(t,s,r){ka(this,s,n=>{const[a,o]=Bze(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 Gze,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??(olt()?void 0:document.createElement("canvas")),s,r)}function flt(t,s,r,n){if(t.U){const o=new Rot;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]=llt(s);r=md(o,3)*i/l,a=md(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'.");flt(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'.");flt(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 ult}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:[]},Ha(t=this.h=new Xme,0,1,s=new od),Pa(this.h,2,.5),Pa(this.h,3,.3)}get baseOptions(){return ko(this.h,od,1)}set baseOptions(t){Ha(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"),co(r,"DETECTIONS:detections"),r.o(s),Fx(t,r),this.g.attachProtoVectorListener("detections",(n,a)=>{for(const o of n)n=Iot(o),this.j.detections.push(alt(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 ICe=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]),LCe=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]),DCe=Zg([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),xlt=Zg([474,475],[475,476],[476,477],[477,474]),RCe=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]),OCe=Zg([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),glt=Zg([469,470],[470,471],[471,472],[472,469]),FCe=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]),ylt=[...ICe,...LCe,...DCe,...RCe,...OCe,...FCe],vlt=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 Wze(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,Ha(t=this.h=new $ot,0,1,s=new od),this.A=new Bot,Ha(this.h,0,3,this.A),this.u=new Xme,Ha(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,od,1)}set baseOptions(t){Ha(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 Wze(this),Xg(this,t,s),this.j}G(t,s,r){return Wze(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"),co(r,"NORM_LANDMARKS:face_landmarks"),r.o(s),Fx(t,r),this.g.attachProtoVectorListener("face_landmarks",(n,a)=>{for(const o of n)n=MO(o),this.j.faceLandmarks.push(Qme(n));ia(this,a)}),this.g.attachEmptyPacketListener("face_landmarks",n=>{ia(this,n)}),this.outputFaceBlendshapes&&(Lo(t,"blendshapes"),co(r,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",(n,a)=>{if(this.outputFaceBlendshapes)for(const o of n)n=Yme(o),this.j.faceBlendshapes.push(ACe(n.g()??[]));ia(this,a)}),this.g.attachEmptyPacketListener("blendshapes",n=>{ia(this,n)})),this.outputFacialTransformationMatrixes&&(Lo(t,"face_geometry"),co(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=ICe,Vc.FACE_LANDMARKS_LEFT_EYE=LCe,Vc.FACE_LANDMARKS_LEFT_EYEBROW=DCe,Vc.FACE_LANDMARKS_LEFT_IRIS=xlt,Vc.FACE_LANDMARKS_RIGHT_EYE=RCe,Vc.FACE_LANDMARKS_RIGHT_EYEBROW=OCe,Vc.FACE_LANDMARKS_RIGHT_IRIS=glt,Vc.FACE_LANDMARKS_FACE_OVAL=FCe,Vc.FACE_LANDMARKS_CONTOURS=ylt,Vc.FACE_LANDMARKS_TESSELATION=vlt;var zCe=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 Kze(t){t.gestures=[],t.landmarks=[],t.worldLandmarks=[],t.handedness=[]}function Zze(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 Yze(t,s=!0){const r=[];for(const a of t){var n=Yme(a);t=[];for(const o of n.g())n=s&&mx(o,1)!=null?mx(o,1)??0:-1,t.push({score:md(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=[],Ha(t=this.j=new Vot,0,1,s=new od),this.u=new SCe,Ha(this.j,0,2,this.u),this.D=new kCe,Ha(this.u,0,3,this.D),this.A=new Uot,Ha(this.u,0,2,this.A),this.h=new Rjs,Ha(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,od,1)}set baseOptions(t){Ha(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());Ha(r,0,2,n),Ha(this.h,0,3,s)}else t.cannedGesturesClassifierOptions===void 0&&((o=ko(this.h,M5,3))==null||o.g());return t.customGesturesClassifierOptions?(Ha(r=s=new M5,0,2,n=Vwe(t.customGesturesClassifierOptions,(l=ko(this.h,M5,4))==null?void 0:l.l())),Ha(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 Kze(this),Xg(this,t,s),Zze(this)}Ia(t,s,r){return Kze(this),I0(this,t,r,s),Zze(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"),co(r,"HAND_GESTURES:hand_gestures"),co(r,"LANDMARKS:hand_landmarks"),co(r,"WORLD_LANDMARKS:world_hand_landmarks"),co(r,"HANDEDNESS:handedness"),r.o(s),Fx(t,r),this.g.attachProtoVectorListener("hand_landmarks",(n,a)=>{for(const o of n){n=MO(o);const l=[];for(const i of j1(n,Dot,1))l.push({x:md(i,1)??0,y:md(i,2)??0,z:md(i,3)??0,visibility:md(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,Lot,1))l.push({x:md(i,1)??0,y:md(i,2)??0,z:md(i,3)??0,visibility:md(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(...Yze(n,!1)),ia(this,a)}),this.g.attachEmptyPacketListener("hand_gestures",n=>{ia(this,n)}),this.g.attachProtoVectorListener("handedness",(n,a)=>{this.handedness.push(...Yze(n)),ia(this,a)}),this.g.attachEmptyPacketListener("handedness",n=>{ia(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};function Xze(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=zCe;var Fp=class extends _f{constructor(t,s){super(new Yg(t,s),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],Ha(t=this.h=new SCe,0,1,s=new od),this.u=new kCe,Ha(this.h,0,3,this.u),this.j=new Uot,Ha(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,od,1)}set baseOptions(t){Ha(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),Xze(this)}G(t,s,r){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],I0(this,t,r,s),Xze(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"),co(r,"LANDMARKS:hand_landmarks"),co(r,"WORLD_LANDMARKS:world_hand_landmarks"),co(r,"HANDEDNESS:handedness"),r.o(s),Fx(t,r),this.g.attachProtoVectorListener("hand_landmarks",(n,a)=>{for(const o of n)n=MO(o),this.landmarks.push(Qme(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=Yme(d);const u=[];for(const p of n.g())u.push({score:md(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=zCe;var _lt=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 Qze(t){t.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function Jze(t){try{if(!t.D)return t.h;t.D(t.h)}finally{epe(t)}}function M9(t,s){t=MO(t),s.push(Qme(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,Ha(t=this.j=new Zot,0,1,s=new od),this.I=new kCe,Ha(this.j,0,2,this.I),this.W=new zjs,Ha(this.j,0,3,this.W),this.u=new Xme,Ha(this.j,0,4,this.u),this.O=new Bot,Ha(this.j,0,5,this.O),this.A=new Wot,Ha(this.j,0,6,this.A),this.M=new Kot,Ha(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,od,1)}set baseOptions(t){Ha(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,Qze(this),Xg(this,t,n),Jze(this)}G(t,s,r,n){const a=typeof r!="function"?r:{};return this.D=typeof r=="function"?r:n,Qze(this),I0(this,t,a,s),Jze(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 jze;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,Fme(o,0,hR));else{if(!(typeof o=="string"||o instanceof u0||HSe(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,WSe(o,!1),fC())}}(r,this.j.g());const n=new Np;vf(n,2,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),oCe(n,8,jze,r),wc(n,"IMAGE:input_frames_image"),co(n,"POSE_LANDMARKS:pose_landmarks"),co(n,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),co(n,"FACE_LANDMARKS:face_landmarks"),co(n,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),co(n,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),co(n,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),co(n,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),n.o(s),Fx(t,n),Jme(this,t),this.g.attachProtoListener("pose_landmarks",(a,o)=>{M9(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&&(co(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)=>{M9(a,this.h.faceLandmarks),ia(this,o)}),this.g.attachEmptyPacketListener("face_landmarks",a=>{ia(this,a)}),this.outputFaceBlendshapes&&(Lo(t,"extra_blendshapes"),co(n,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",(a,o)=>{var l=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(a=Yme(a),l.push(ACe(a.g()??[]))),ia(this,o)}),this.g.attachEmptyPacketListener("extra_blendshapes",a=>{ia(this,a)})),this.g.attachProtoListener("left_hand_landmarks",(a,o)=>{M9(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)=>{M9(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=zCe,uc.POSE_CONNECTIONS=_lt,uc.FACE_LANDMARKS_LIPS=ICe,uc.FACE_LANDMARKS_LEFT_EYE=LCe,uc.FACE_LANDMARKS_LEFT_EYEBROW=DCe,uc.FACE_LANDMARKS_LEFT_IRIS=xlt,uc.FACE_LANDMARKS_RIGHT_EYE=RCe,uc.FACE_LANDMARKS_RIGHT_EYEBROW=OCe,uc.FACE_LANDMARKS_RIGHT_IRIS=glt,uc.FACE_LANDMARKS_FACE_OVAL=FCe,uc.FACE_LANDMARKS_CONTOURS=ylt,uc.FACE_LANDMARKS_TESSELATION=vlt;var Kf=class extends _f{constructor(t,s){super(new Yg(t,s),"input_image","norm_rect",!0),this.j={classifications:[]},Ha(t=this.h=new Yot,0,1,s=new od)}get baseOptions(){return ko(this.h,od,1)}set baseOptions(t){Ha(this.h,0,1,t)}o(t){return Ha(this.h,0,2,Vwe(t,ko(this.h,jCe,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"),co(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 Xot,this.embeddings={embeddings:[]},Ha(t=this.h,0,1,s=new od)}get baseOptions(){return ko(this.h,od,1)}set baseOptions(t){Ha(this.h,0,1,t)}o(t){var s=this.h,r=ko(this.h,Pze,2);return r=r?r.clone():new Pze,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),Ha(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"),co(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 Kit(d,0|d[ba],Eze,m0e(l,1))!==void 0?(l=A4(l=ko(l,Eze,m0e(l,1),void 0),1,Gy,T4()),i.floatEmbedding=l.slice()):(d=new Uint8Array(0),i.quantizedEmbedding=((p=(u=ko(l,Tjs,m0e(l,2),void 0))==null?void 0:u.na())==null?void 0:p.h())??d),i}),timestampMs:nlt(Oc(o,2,void 0,void 0,wde)??Uit)}}(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=Fze(t.floatEmbedding,s.floatEmbedding);else{if(!t.quantizedEmbedding||!s.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");t=Fze(Oze(t.quantizedEmbedding),Oze(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 e9e(t){t.categoryMask=void 0,t.confidenceMasks=void 0,t.qualityScores=void 0}function t9e(t){try{const s=new Kwe(t.confidenceMasks,t.categoryMask,t.qualityScores);if(!t.j)return s;t.j(s)}finally{epe(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 TCe,this.A=new Qot,Ha(this.h,0,3,this.A),Ha(t=this.h,0,1,s=new od)}get baseOptions(){return ko(this.h,od,1)}set baseOptions(t){Ha(this.h,0,1,t)}o(t){return t.displayNamesLocale!==void 0?al(this.h,2,kO(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,e9e(this),Xg(this,t,n),t9e(this)}La(t,s,r,n){const a=typeof r!="function"?r:{};return this.j=typeof r=="function"?r:n,e9e(this),I0(this,t,a,s),t9e(this)}Da(){return this.u}m(){var t=new Sf;Bc(t,"image_in"),Bc(t,"norm_rect");const s=new kf;E0(s,elt,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),Jme(this,t),this.outputConfidenceMasks&&(Lo(t,"confidence_masks"),co(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"),co(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"),co(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 TCe,this.u=new Qot,Ha(this.h,0,3,this.u),Ha(t=this.h,0,1,s=new od)}get baseOptions(){return ko(this.h,od,1)}set baseOptions(t){Ha(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 tlt,s.keypoint&&s.scribble)throw Error("Cannot provide both keypoint and scribble.");if(s.keypoint){var o=new g0e;$_(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 g0e,3,uR(!0),!1),$_(s,1,qI(o.x),0),$_(s,2,qI(o.y),0),oCe(i,1,g0e,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{epe(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,elt,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),Jme(this,t),this.outputConfidenceMasks&&(Lo(t,"confidence_masks"),co(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"),co(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"),co(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:[]},Ha(t=this.h=new slt,0,1,s=new od)}get baseOptions(){return ko(this.h,od,1)}set baseOptions(t){Ha(this.h,0,1,t)}o(t){return t.displayNamesLocale!==void 0?al(this.h,2,kO(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?Nde(this.h,5,t.categoryAllowlist):"categoryAllowlist"in t&&al(this.h,5),t.categoryDenylist!==void 0?Nde(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"),co(r,"DETECTIONS:detections"),r.o(s),Fx(t,r),this.g.attachProtoVectorListener("detections",(n,a)=>{for(const o of n)n=Iot(o),this.j.detections.push(alt(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 s9e(t){t.landmarks=[],t.worldLandmarks=[],t.segmentationMasks=void 0}function r9e(t){try{const s=new Ywe(t.landmarks,t.worldLandmarks,t.segmentationMasks);if(!t.u)return s;t.u(s)}finally{epe(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,Ha(t=this.h=new rlt,0,1,s=new od),this.A=new Kot,Ha(this.h,0,3,this.A),this.j=new Wot,Ha(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,od,1)}set baseOptions(t){Ha(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,s9e(this),Xg(this,t,n),r9e(this)}G(t,s,r,n){const a=typeof r!="function"?r:{};return this.u=typeof r=="function"?r:n,s9e(this),I0(this,t,a,s),r9e(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"),co(r,"NORM_LANDMARKS:normalized_landmarks"),co(r,"WORLD_LANDMARKS:world_landmarks"),r.o(s),Fx(t,r),Jme(this,t),this.g.attachProtoVectorListener("normalized_landmarks",(n,a)=>{this.landmarks=[];for(const o of n)n=MO(o),this.landmarks.push(Qme(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&&(co(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=_lt;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=S.useRef(null),n=S.useRef(null),a=S.useRef(null),o=S.useRef(null),l=S.useRef(0),i=S.useRef(0),[d,u]=S.useState(null),[p,f]=S.useState(!1),[y,_]=S.useState(null),b=s.type!=="none"&&t!==null;return S.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]),S.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]),S.useEffect(()=>{if(!b){u(null),_(null);return}let N=!1;return(async()=>{f(!0),_(null);try{const k=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),ae=new Float32Array(A*I),ie=new Float32Array(A*I);let oe=!1;const me=4,ye=.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 Ne=a.current;if(Ne.readyState<2){l.current=requestAnimationFrame(he);return}try{const Te=k.segmentForVideo(Ne,ge).confidenceMasks;if(Te&&Te.length>0){ae.fill(0);for(let qe=1;qe$e?(ut=qe.height*$e,Be=(qe.width-ut)/2):(fe=qe.width/$e,we=(qe.height-fe)/2),O.drawImage(qe,Be,we,ut,fe,0,0,A,I)}q.clearRect(0,0,A,I),q.drawImage(Ne,0,0,A,I);const Me=q.getImageData(0,0,A,I),De=Me.data;for(let qe=0;qe{N=!0,l.current&&cancelAnimationFrame(l.current),u(null)}},[b,s.type,s.blurRadius,s.imageUrl,t]),S.useEffect(()=>()=>{sNs()},[]),{canvasRef:r,compositedStream:d,isLoading:p,isActive:b,error:y}}function TO({maxDurationSeconds:t=600,onRecordingComplete:s,onError:r,onRecordingStateChange:n,className:a,teleprompterContent:o}){const l=S.useRef(null),i=S.useRef(null),d=S.useRef(null),[u,p]=S.useState(null),f=S.useRef([]),y=S.useRef(null),_=S.useRef(null),b=S.useRef(null),N=S.useRef(null),w=bE(),[k,C]=S.useState("camera"),A=S.useRef(null),I=S.useRef(null),L=S.useRef(null),O=S.useRef(null),V=S.useRef(null),[q,B]=S.useState(!0),[U,te]=S.useState(!0),[Y,J]=S.useState(null),[X,ce]=S.useState(!1),[ae,ie]=S.useState(!1),[oe,me]=S.useState(null),[ye,he]=S.useState(null),[ge,Ne]=S.useState(0),[Ue,Te]=S.useState("user"),[Me,De]=S.useState(0),[qe,ke]=S.useState(!1),[$e,Be]=S.useState(!0),[we,ut]=S.useState(null),[fe,He]=S.useState(!1),[et,tt]=S.useState(null),_e=S.useRef(null),[Ge,We]=S.useState(()=>{try{const nr=localStorage.getItem("video-bg-config");if(nr)return JSON.parse(nr)}catch{}return{type:"none"}});S.useEffect(()=>{try{localStorage.setItem("video-bg-config",JSON.stringify(Ge))}catch{}},[Ge]);const{canvasRef:it,compositedStream:Ve,isLoading:Xe,isActive:dt,error:pt}=rNs(u,Ge),Je=S.useRef(r);Je.current=r;const Ze=S.useCallback(nr=>{B(nr)},[]),Nt=S.useRef(q),Ot=S.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)},[]),Yt=S.useCallback(async()=>{var nr;try{const lr=await navigator.mediaDevices.getDisplayMedia({video:{width:{ideal:1920},height:{ideal:1080}},audio:!0});A.current=lr;let Fr=null;try{Fr=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 Wr=null;if(!Fr)try{Wr=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{console.warn("[VideoRecorder] No mic audio")}const Nn=lr.getVideoTracks()[0],ai=Nn.getSettings(),ns=ai.width||1920,$n=ai.height||1080,dn=document.createElement("canvas");dn.width=ns,dn.height=$n,I.current=dn;const zr=dn.getContext("2d");let Kr=null;Fr&&(Kr=document.createElement("video"),Kr.srcObject=Fr,Kr.muted=!0,Kr.playsInline=!0,Kr.autoplay=!0,await Kr.play(),V.current=Kr);const La=document.createElement("video");La.srcObject=lr,La.muted=!0,La.playsInline=!0,La.autoplay=!0,await La.play();const Zt=()=>{if(zr.drawImage(La,0,0,ns,$n),Kr&&Kr.readyState>=2){const Ye=Math.round(ns*.2),yt=Math.round(Ye*(Kr.videoHeight/Kr.videoWidth||.75)),bt=ns-Ye-20,Tt=$n-yt-20,Ht=12;zr.save(),zr.beginPath(),zr.moveTo(bt+Ht,Tt),zr.lineTo(bt+Ye-Ht,Tt),zr.quadraticCurveTo(bt+Ye,Tt,bt+Ye,Tt+Ht),zr.lineTo(bt+Ye,Tt+yt-Ht),zr.quadraticCurveTo(bt+Ye,Tt+yt,bt+Ye-Ht,Tt+yt),zr.lineTo(bt+Ht,Tt+yt),zr.quadraticCurveTo(bt,Tt+yt,bt,Tt+yt-Ht),zr.lineTo(bt,Tt+Ht),zr.quadraticCurveTo(bt,Tt,bt+Ht,Tt),zr.closePath(),zr.clip(),zr.translate(bt+Ye,Tt),zr.scale(-1,1),zr.drawImage(Kr,0,0,Ye,yt),zr.restore(),zr.strokeStyle="rgba(255,255,255,0.6)",zr.lineWidth=2,zr.beginPath(),zr.moveTo(bt+Ht,Tt),zr.lineTo(bt+Ye-Ht,Tt),zr.quadraticCurveTo(bt+Ye,Tt,bt+Ye,Tt+Ht),zr.lineTo(bt+Ye,Tt+yt-Ht),zr.quadraticCurveTo(bt+Ye,Tt+yt,bt+Ye-Ht,Tt+yt),zr.lineTo(bt+Ht,Tt+yt),zr.quadraticCurveTo(bt,Tt+yt,bt,Tt+yt-Ht),zr.lineTo(bt,Tt+Ht),zr.quadraticCurveTo(bt,Tt,bt+Ht,Tt),zr.closePath(),zr.stroke()}L.current=requestAnimationFrame(Zt)};Zt();const Er=dn.captureStream(30),Bt=[],Se=lr.getAudioTracks();if(Se.length&&Bt.push(...Se),Fr){const Ye=Fr.getAudioTracks();Ye.length&&Bt.push(...Ye)}else Wr&&Bt.push(...Wr.getAudioTracks());const Oe=new MediaStream([...Er.getVideoTracks(),...Bt]);return O.current=Oe,Nn.onended=()=>{i.current&&i.current.state!=="inactive"&&i.current.stop(),Ot()},Oe}catch(lr){return console.error("[VideoRecorder] Screen capture error:",lr),lr.name!=="NotAllowedError"&&((nr=Je.current)==null||nr.call(Je,"Failed to start screen capture: "+(lr.message||"Unknown error"))),null}},[Ot]),Ps=S.useCallback(async()=>{var lr,Fr;te(!0),ut(null);const nr=w&&q;console.log("[VideoRecorder] initCamera start",{isMobile:w,usePortraitMode:q,shouldBePortrait:nr,facingMode:Ue});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($n=>$n.stop()));const Wr=w&&nr?{facingMode:{ideal:Ue},width:{ideal:720},height:{ideal:1280}}:{facingMode:{ideal:Ue},width:{ideal:1280},height:{ideal:720}};console.log("[VideoRecorder] requesting getUserMedia",Wr);const Nn=await navigator.mediaDevices.getUserMedia({video:Wr,audio:{echoCancellation:!0,noiseSuppression:!0}});if(console.log("[VideoRecorder] getUserMedia success"),Nn.getVideoTracks().length===0)throw new Error("Camera stream started but no video track was provided.");d.current=Nn,p(Nn),J(!0);const ns=Nn.getVideoTracks()[0].getSettings();if(console.log("[VideoRecorder] Camera initialized with dimensions:",ns.width,"x",ns.height),l.current){const $n=l.current;$n.srcObject=Nn,$n.muted=!0,$n.playsInline=!0,$n.autoplay=!0,$n.setAttribute("muted",""),$n.setAttribute("playsinline",""),$n.setAttribute("autoplay","");try{(lr=$n.load)==null||lr.call($n)}catch(zr){console.warn("[VideoRecorder] videoEl.load failed",zr)}const dn=async()=>{try{return await $n.play(),console.log("[VideoRecorder] preview play ok"),He(!1),setTimeout(()=>{console.debug("[VideoRecorder] preview metrics",{readyState:$n.readyState,videoWidth:$n.videoWidth,videoHeight:$n.videoHeight})},300),!0}catch(zr){return console.warn("[VideoRecorder] preview play blocked",zr),He(!0),!1}};await new Promise(zr=>{let Kr=!1;const La=()=>{Kr||(Kr=!0,zr())},Zt=()=>{dn().finally(La)};$n.onloadedmetadata=Zt,$n.onloadeddata=Zt,setTimeout(La,1500)})}try{_.current=new AudioContext;const $n=_.current.createMediaStreamSource(Nn);b.current=_.current.createAnalyser(),b.current.fftSize=256,$n.connect(b.current);const dn=()=>{if(b.current){const zr=new Uint8Array(b.current.frequencyBinCount);b.current.getByteFrequencyData(zr);const Kr=zr.reduce((La,Zt)=>La+Zt)/zr.length;De(Math.min(100,Kr/128*100))}N.current=requestAnimationFrame(dn)};dn()}catch($n){console.warn("Audio context not available:",$n)}}catch(Wr){console.error("Camera initialization error:",Wr),J(!1);let Nn="Failed to access camera or microphone.";Wr.name==="NotAllowedError"?Nn="Camera permission denied. Please allow camera access in your browser settings.":Wr.name==="NotFoundError"?Nn="No camera found. Please connect a camera and try again.":Wr.name==="NotReadableError"?Nn="Camera is in use by another application. Please close other apps using the camera.":Wr.message&&(Nn=Wr.message),ut(Nn),(Fr=Je.current)==null||Fr.call(Je,Nn)}finally{te(!1)}},[Ue,w,q]);S.useEffect(()=>{Nt.current!==q&&Y&&!X&&!ye&&(Nt.current=q,Ps())},[q,Y,X,ye,Ps]),S.useEffect(()=>(Ps(),()=>{d.current&&d.current.getTracks().forEach(nr=>nr.stop()),y.current&&clearInterval(y.current),N.current&&cancelAnimationFrame(N.current),_.current&&_.current.close(),_e.current&&clearInterval(_e.current),ye&&URL.revokeObjectURL(ye),Ot()}),[Ps,ye]),S.useEffect(()=>{if(U||Y!==!0||ye)return;const nr=d.current,lr=l.current;!nr||!lr||dt||(lr.srcObject!==nr&&(lr.srcObject=nr,lr.muted=!0,lr.playsInline=!0,lr.autoplay=!0,lr.setAttribute("muted",""),lr.setAttribute("playsinline",""),lr.setAttribute("autoplay","")),lr.play().then(()=>He(!1)).catch(Fr=>{He(!0),console.warn("Live preview play blocked on mount:",Fr)}))},[Y,U,ye,dt]),S.useEffect(()=>{n==null||n(X)},[X,n]);const $s=S.useCallback(async()=>{if(ye)return;const nr=l.current;if(nr)try{await nr.play(),He(!1)}catch(lr){He(!0),console.warn("Live preview still blocked (needs user gesture):",lr)}},[ye]),Zs=S.useCallback(()=>{i.current&&i.current.state!=="inactive"&&i.current.stop(),y.current&&(clearInterval(y.current),y.current=null),Ot(),ce(!1),ie(!1)},[Ot]),Dr=S.useCallback(async()=>{let nr=null;if(k==="screen"){if(nr=await Yt(),!nr)return}else nr=dt&&Ve?Ve:d.current;if(!nr)return;$s(),f.current=[],Ne(0);const Fr=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"].find(Nn=>MediaRecorder.isTypeSupported(Nn)),Wr=new MediaRecorder(nr,Fr?{mimeType:Fr,videoBitsPerSecond:k==="screen"?4e6:25e5}:{videoBitsPerSecond:k==="screen"?4e6:25e5});Wr.ondataavailable=Nn=>{Nn.data.size>0&&f.current.push(Nn.data)},Wr.onstop=()=>{var $n;const Nn=Wr.mimeType||Fr||(($n=f.current[0])==null?void 0:$n.type)||"video/webm",ai=new Blob(f.current,{type:Nn});me(ai);const ns=URL.createObjectURL(ai);he(ns)},i.current=Wr,Wr.start(100),ce(!0),y.current=setInterval(()=>{Ne(Nn=>Nn>=t-1?(Zs(),t):Nn+1)},1e3)},[$s,t,Zs,dt,Ve,k,Yt]),$t=S.useCallback(()=>{_e.current&&(clearInterval(_e.current),_e.current=null),tt(3);let nr=3;_e.current=setInterval(()=>{nr-=1,nr<=0?(_e.current&&clearInterval(_e.current),_e.current=null,tt(null),Dr()):tt(nr)},1e3)},[Dr]),Us=S.useCallback(()=>{i.current&&i.current.state==="recording"&&(i.current.pause(),ie(!0),y.current&&clearInterval(y.current))},[]),Nr=S.useCallback(()=>{i.current&&i.current.state==="paused"&&(i.current.resume(),ie(!1),y.current=setInterval(()=>{Ne(nr=>nr>=t-1?(Zs(),t):nr+1)},1e3))},[t,Zs]),Xs=S.useCallback(()=>{ye&&URL.revokeObjectURL(ye),me(null),he(null),Ne(0),ke(!1),Be(!0),l.current&&d.current&&!dt&&(l.current.srcObject=d.current,l.current.muted=!0,$s())},[$s,ye,dt]),kr=S.useCallback(()=>{Te(nr=>nr==="user"?"environment":"user")},[]),fn=S.useCallback(()=>{oe&&s(oe,ge)},[oe,ge,s]),Yr=S.useCallback(()=>{l.current&&ye&&(qe?l.current.pause():(Be(!1),l.current.muted=!1,l.current.play()),ke(!qe))},[ye,qe]);S.useEffect(()=>{if(!ye)return;const nr=l.current;if(!nr)return;Be(!1),nr.pause(),nr.removeAttribute("src"),nr.srcObject=null,nr.load(),nr.src=ye,nr.currentTime=0,nr.playsInline=!0,nr.muted=!1,nr.onended=()=>ke(!1);const lr=()=>{var Nn;const Fr=nr.error,Wr=Fr?`Recorded video failed to play (code ${Fr.code}). Likely unsupported format/codec in this browser.`:"Recorded video failed to play.";console.warn("[VideoRecorder] recorded playback error",Fr),(Nn=Je.current)==null||Nn.call(Je,Wr)};return nr.addEventListener("error",lr),nr.load(),()=>{nr.removeEventListener("error",lr)}},[ye]);const $r=nr=>{const lr=Math.floor(nr/60),Fr=nr%60;return`${lr}:${Fr.toString().padStart(2,"0")}`},Gr=k==="screen"?"aspect-video":w&&q?"aspect-[9/16]":"aspect-video";return U?e.jsx("div",{className:Dt("flex items-center justify-center bg-black rounded-lg",Gr,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:Dt("flex items-center justify-center bg-black rounded-lg",Gr,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:we||"Please allow camera and microphone access to record videos."}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(K,{onClick:()=>Ps(),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:Dt("flex flex-col gap-2",a),children:[!X&&!ye&&e.jsxs("div",{className:"flex items-center justify-center gap-1 p-1 bg-muted rounded-lg",children:[e.jsxs(K,{variant:k==="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(K,{variant:k==="screen"?"default":"ghost",size:"sm",className:"gap-1.5 flex-1",onClick:()=>C("screen"),children:[e.jsx(uS,{className:"h-4 w-4"}),"Screen"]})]}),k==="camera"&&!X&&!ye&&e.jsx(x2s,{value:Ge,onChange:We,isLoading:Xe,disabled:X}),k==="camera"&&w&&!X&&!ye&&e.jsxs("div",{className:"flex items-center justify-center gap-3 py-2 bg-muted/50 rounded-lg",children:[e.jsx(hS,{className:Dt("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(Mr,{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:Dt("h-4 w-4",q?"text-primary":"text-muted-foreground")})]}),k==="screen"&&!X&&!ye&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 px-4 bg-muted/50 rounded-lg text-sm text-muted-foreground",children:[e.jsx(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:Dt("relative bg-black rounded-lg overflow-hidden"),onPointerDown:()=>{$s()},children:[e.jsx("video",{ref:l,src:ye??void 0,className:Dt("w-full bg-black",q&&!ye?"object-contain":"object-cover",Gr,!ye&&Ue==="user"!==(Ge.mirror??!1)&&"scale-x-[-1]",dt&&!ye&&"hidden"),playsInline:!0,controls:!!ye,muted:ye?$e:!0,autoPlay:!ye},ye??"live"),dt&&!ye&&e.jsx("canvas",{ref:it,className:Dt("w-full bg-black",q?"object-contain":"object-cover",Gr,Ue==="user"!==(Ge.mirror??!1)&&"scale-x-[-1]")}),dt&&Xe&&!ye&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/60 z-20",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(us,{className:"h-8 w-8 animate-spin mx-auto mb-2"}),e.jsx("p",{className:"text-sm",children:"Loading virtual background…"})]})}),!ye&&fe&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40",children:e.jsx(K,{type:"button",variant:"secondary",onClick:()=>void $s(),className:"bg-white/20 hover:bg-white/30 text-white",children:"Tap to enable preview"})}),o&&!ye&&e.jsx("div",{className:"absolute inset-0 pointer-events-none",children:o}),et!==null&&!ye&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-30 pointer-events-none",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"text-white font-bold drop-shadow-lg animate-scale-in",style:{fontSize:"96px",lineHeight:1,textShadow:"0 4px 16px rgba(0,0,0,0.8)"},children:et},et),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:Dt("w-3 h-3 rounded-full",ae?"bg-yellow-500":"bg-red-500 animate-pulse")}),e.jsxs("span",{className:"text-white text-sm font-medium",children:[$r(ge)," / ",$r(t)]})]}),X&&e.jsx("div",{className:"absolute top-0 left-0 right-0",children:e.jsx(fi,{value:ge/t*100,className:"h-1 rounded-none"})}),!ye&&e.jsxs("div",{className:"absolute bottom-20 left-4 flex items-center gap-2 bg-black/50 px-3 py-1.5 rounded-full",children:[e.jsx(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:`${Me}%`}})})]}),e.jsx("div",{className:"absolute bottom-4 left-0 right-0 flex justify-center gap-3 px-4",children:ye?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"secondary",size:"lg",className:"bg-white/20 hover:bg-white/30 text-white",onClick:Xs,children:[e.jsx(Zi,{className:"h-5 w-5 mr-2"}),"Re-record"]}),e.jsx(K,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:Yr,children:qe?e.jsx(hh,{className:"h-5 w-5"}):e.jsx(Co,{className:"h-5 w-5"})}),e.jsxs(K,{size:"lg",className:"bg-green-500 hover:bg-green-600 text-white",onClick:fn,children:[e.jsx(Zn,{className:"h-5 w-5 mr-2"}),"Use This Video"]})]}):e.jsxs(e.Fragment,{children:[k==="camera"?e.jsx(K,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:kr,disabled:X||et!==null,children:e.jsx(t0,{className:"h-5 w-5"})}):e.jsx("div",{className:"h-12 w-12"}),!X&&et===null?e.jsx(K,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:k==="screen"?Dr:$t,children:k==="screen"?e.jsx(uS,{className:"h-6 w-6"}):e.jsx(gn,{className:"h-6 w-6"})}):e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:ae?Nr:Us,children:ae?e.jsx(Co,{className:"h-5 w-5"}):e.jsx(hh,{className:"h-5 w-5"})}),e.jsx(K,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:Zs,children:e.jsx(r0,{className:"h-6 w-6 fill-current"})})]}),e.jsx("div",{className:"h-12 w-12"})]})})]})]})}const blt="teleprompter_settings",v0e={scrollSpeed:30,fontSize:24,lineHeight:1.6,opacity:.85,position:"top",isMirrored:!1};function nNs(){try{const t=localStorage.getItem(blt);return t?{...v0e,...JSON.parse(t)}:v0e}catch{return v0e}}function aNs(t){try{localStorage.setItem(blt,JSON.stringify(t))}catch{}}function wlt({text:t,isVisible:s,onToggleVisibility:r,isRecording:n=!1,startCountdown:a=!1,onCountdownComplete:o,className:l}){const i=S.useRef(null),d=S.useRef(null),u=S.useRef(0),p=S.useRef(0),[f,y]=S.useState(nNs),{scrollSpeed:_,fontSize:b,lineHeight:N,opacity:w,position:k,isMirrored:C}=f,A=S.useCallback((Y,J)=>{y(X=>{const ce={...X,[Y]:J};return aNs(ce),ce})},[]),[I,L]=S.useState(!1),[O,V]=S.useState(null),q=S.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:ae,clientHeight:ie}=i.current;if(ce+ie>=ae){L(!1);return}d.current=requestAnimationFrame(q)},[_]);S.useEffect(()=>(I?(u.current=0,p.current=0,d.current=requestAnimationFrame(q)):d.current&&cancelAnimationFrame(d.current),()=>{d.current&&cancelAnimationFrame(d.current)}),[I,q]),S.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=S.useCallback(()=>{i.current&&(i.current.scrollTop=0),L(!1)},[]),U=S.useCallback(()=>{L(Y=>!Y)},[]);if(!s)return e.jsx("div",{className:Dt("absolute top-4 right-4 pointer-events-auto z-10",l),children:e.jsxs(K,{variant:"secondary",size:"sm",onClick:r,className:"bg-black/50 hover:bg-black/70 text-white border-0",children:[e.jsx(Cn,{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:Dt("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:Dt("absolute left-0 right-0 h-[60%] overflow-hidden pointer-events-auto",te[k],O!==null&&"opacity-30"),style:{opacity:O!==null?.3:w},children:e.jsxs("div",{ref:i,className:Dt("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(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsx(K,{variant:"secondary",size:"icon",className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:e.jsx(So,{className:"h-4 w-4"})})}),e.jsx(uo,{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(K,{variant:k==="top"?"default":"outline",size:"sm",onClick:()=>A("position","top"),children:e.jsx(af,{className:"h-4 w-4"})}),e.jsx(K,{variant:k==="center"?"default":"outline",size:"sm",onClick:()=>A("position","center"),children:e.jsx(Qy,{className:"h-4 w-4"})}),e.jsx(K,{variant:k==="bottom"?"default":"outline",size:"sm",onClick:()=>A("position","bottom"),children:e.jsx(Fi,{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(Mr,{checked:C,onCheckedChange:Y=>A("isMirrored",Y)})]})]})})]}),e.jsx(K,{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(K,{variant:"secondary",size:"icon",onClick:B,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:e.jsx(t0,{className:"h-4 w-4"})}),e.jsxs(K,{variant:"secondary",size:"sm",onClick:r,className:"bg-black/50 hover:bg-black/70 text-white border-0",children:[e.jsx(mp,{className:"h-4 w-4 mr-2"}),"Hide"]})]})]})}function iNs({onSelectScript:t,onCreateNew:s,selectedScriptId:r,className:n}){const{toast:a}=ja(),[o,l]=S.useState(""),[i,d]=S.useState(null),[u,p]=S.useState("levelup"),{data:f,isLoading:y}=Ibs(),{data:_,isLoading:b}=Lbs(),{data:N,isLoading:w}=Dbs(),k=Rbs(),C=S.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=S.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 k.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:Dt("flex flex-col h-full",n),children:[e.jsx("div",{className:"p-4 border-b",children:e.jsxs("div",{className:"relative",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search scripts...",value:o,onChange: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(ls,{value:"levelup",children:[e.jsx(yn,{className:"h-4 w-4 mr-2"}),"LevelUp Scripts"]}),e.jsxs(ls,{value:"my-scripts",children:[e.jsx(fx,{className:"h-4 w-4 mr-2"}),"My Scripts"]})]}),e.jsxs(ws,{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(ni,{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(yn,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No scripts found"})]}):e.jsx("div",{className:"space-y-2",children:C.map(V=>e.jsxs(Pe,{className:Dt("cursor-pointer hover:bg-accent/50 transition-colors",r===V.id&&"ring-2 ring-primary"),onClick:()=>I(V),children:[e.jsx(Lt,{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(Ft,{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(K,{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(Re,{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(ws,{value:"my-scripts",className:"flex-1 flex flex-col mt-0 p-4",children:[s&&e.jsxs(K,{variant:"outline",className:"mb-4",onClick:s,children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Create New Script"]}),e.jsx(ni,{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:Dt("cursor-pointer hover:bg-accent/50 transition-colors",r===V.id&&"ring-2 ring-primary"),onClick:()=>I(V),children:[e.jsx(Lt,{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(Ft,{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(Re,{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]=S.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:ZIt.map(i=>{const d=YIt(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(Fi,{className:Dt("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:Dt("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 jlt({open:t,onOpenChange:s,video:r,contactName:n,onTemplateUpdated:a}){const[o,l]=S.useState(r.page_template||"default"),[i,d]=S.useState(!1),[u,p]=S.useState(!1),[f,y]=S.useState(r.page_template||"default"),[_,b]=S.useState([]),[N,w]=S.useState(r.contact_id&&n?{id:r.contact_id,name:n,email:null}:null),[k,C]=S.useState(!1),[A,I]=S.useState(!1),L=r.share_token?`https://video.relevelup.com/${r.share_token}`:"";S.useEffect(()=>{t&&_.length===0&&O()},[t]);const O=async()=>{I(!0);try{const{data:ce,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;const ie=(ce||[]).map(oe=>({id:oe.id,name:[oe.first_name,oe.last_name].filter(Boolean).join(" ")||"Unnamed",email:oe.email||null}));b(ie)}catch(ce){console.error("Failed to fetch contacts:",ce)}finally{I(!1)}},V=async ce=>{w(ce),C(!1),d(!0);try{const{error:ae}=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(ae)throw ae;pe.success(ce?`Assigned to ${ce.name}`:"Contact removed"),a==null||a()}catch(ae){console.error("Failed to update contact:",ae),pe.error("Failed to update contact")}finally{d(!1)}},q=async ce=>{l(ce),d(!0);try{const{error:ae}=await G.from("agent_videos").update({page_template:ce}).eq("id",r.id);if(ae)throw ae;y(ce),pe.success("Template saved!"),a==null||a()}catch(ae){console.error("Failed to save template:",ae),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",ae=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(),ae=`Watch: ${r.title||"Video Message"} ${L}`;try{const ie=new Blob([ce],{type:"text/html"}),oe=new Blob([ae],{type:"text/plain"}),me=new ClipboardItem({"text/html":ie,"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(ae+` `+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 ae=GM(o).headerText(B),ie=o==="default"?`Check out this video: ${L}`:`${ae} Check out this special video: ${L}`;window.open(`sms:?body=${encodeURIComponent(ie)}`,"_self")},X=()=>{const ce=GM(o),ae=ce.headerText(B),ie=o==="default"?r.title||"Video Message":ae,oe=`${ce.subText} Watch the video: ${L}`,me=N!=null&&N.email?encodeURIComponent(N.email):"";window.open(`mailto:${me}?subject=${encodeURIComponent(ie)}&body=${encodeURIComponent(oe)}`,"_self")};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(hs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(go,{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(yo,{open:k,onOpenChange:C,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":k,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(uo,{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(lp,{value:ce.name,onSelect:()=>V(ce),children:[e.jsx(Zn,{className:Dt("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(K,{variant:"ghost",size:"icon",onClick:()=>V(null),disabled:i,className:"shrink-0",children:e.jsx(jr,{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(Le,{value:L,readOnly:!0,className:"font-mono text-sm"}),e.jsx(K,{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(Wa,{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(K,{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(K,{variant:"outline",className:"flex-1 gap-2",onClick:J,children:[e.jsx(Si,{className:"h-4 w-4"}),"Text"]}),e.jsxs(K,{variant:"outline",className:"flex-1 gap-2",onClick:X,children:[e.jsx(tr,{className:"h-4 w-4"}),"Email"]})]})]})]}),e.jsx(_n,{children:e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Done"})})]})})}function lNs(){var _e;const t=vr(),[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}=nit(),{data:p}=qh(),f=Mw(),y=$bs(),[_,b]=S.useState("record"),[N,w]=S.useState(""),[k,C]=S.useState(!1),[A,I]=S.useState(!1),[L,O]=S.useState(!1),[V,q]=S.useState(null),[B,U]=S.useState(0),[te,Y]=S.useState(0),[J,X]=S.useState(null),[ce,ae]=S.useState(null),[ie,oe]=S.useState(n||""),[me,ye]=S.useState(""),[he,ge]=S.useState(""),[Ne,Ue]=S.useState(null),[Te,Me]=S.useState(null),[De,qe]=S.useState(null),[ke,$e]=S.useState(!1),Be=S.useCallback(async(Ge,We)=>{q(Ge),b("uploading");try{const{videoId:it,uploadUrl:Ve}=await wE(me||"Quick Video Touch");X(it);const{apiKey:Xe}=await jE(it),dt=new XMLHttpRequest;dt.upload.onprogress=Nt=>{Nt.lengthComputable&&U(Nt.loaded/Nt.total*100)},await new Promise((Nt,Ot)=>{dt.onload=()=>{dt.status>=200&&dt.status<300?Nt():Ot(new Error(`Upload failed: ${dt.status}`))},dt.onerror=()=>Ot(new Error("Upload failed")),dt.open("PUT",Ve),dt.setRequestHeader("AccessKey",Xe),dt.send(Ge)}),b("processing");let pt=0;const Je=Date.now(),Ze=90*1e3;for(;pt<4;){if(await new Promise(Ot=>setTimeout(Ot,3e3)),Date.now()-Je>Ze){const Ot=Ge.size/1048576,Yt=`https://iframe.mediadelivery.net/play/${it}/${it}`;await f.mutateAsync({bunny_video_id:it,playback_url:Yt,file_size_mb:Ot,title:me||"Quick Video Touch",notes:he||void 0,contact_id:ie&&ie!=="none"?ie: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 Nt=await nw(it);if(pt=Nt.status,Y(Nt.encodeProgress||0),pt===4)ae({playbackUrl:Nt.directPlayUrl,thumbnailUrl:Nt.thumbnailUrl,previewUrl:Nt.previewUrl||null,duration:Nt.length||We,fileSizeMb:(Nt.storageSize||Ge.size)/(1024*1024)});else if(pt===5||pt===6)throw new Error("Video processing failed")}b("details")}catch(it){console.error("Upload error:",it),r({title:"Upload failed",description:"Please try recording again.",variant:"destructive"}),b("record")}},[me,r]),we=async()=>{if(!(!J||!ce))try{const Ge=ie&&ie!=="none"?ie:null,We=await f.mutateAsync({bunny_video_id:J,contact_id:Ge,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"});Ue(We.id),Me(We.share_token||null),Ge&&await y.mutateAsync({contactId:Ge,videoId:We.id,notes:he}),r({title:"Video saved successfully!"}),b("share")}catch(Ge){console.error("Save video error:",Ge),r({title:"Failed to save video",description:(Ge==null?void 0:Ge.message)||"Please try again.",variant:"destructive"})}},ut=(Ge,We)=>{navigator.clipboard.writeText(We),qe(Ge),setTimeout(()=>qe(null),2e3),r({title:"Copied to clipboard!"})},fe=()=>Te?`https://video.relevelup.com/${Te}`:(ce==null?void 0:ce.playbackUrl)||"",He=()=>{const Ge=p==null?void 0:p.find(dt=>dt.id===ie),We=Ge?`${Ge.first_name}`:"",it=(Ge==null?void 0:Ge.phone)||"",Ve=(Ge==null?void 0:Ge.email)||"",Xe=fe();return{text:`Hey${We?` ${We}`:""}! I recorded a quick video for you: ${Xe}`,link:Xe,contactPhone:it,contactEmail:Ve}},et=()=>{const{text:Ge,contactPhone:We}=He(),it=We?`sms:${We}?body=${encodeURIComponent(Ge)}`:`sms:?body=${encodeURIComponent(Ge)}`;window.open(it,"_self")},tt=()=>{const{link:Ge,contactEmail:We}=He(),it="Check out this video",Ve=`I recorded a quick video for you: ${Ge}`,Xe=We?`mailto:${We}?subject=${encodeURIComponent(it)}&body=${encodeURIComponent(Ve)}`:`mailto:?subject=${encodeURIComponent(it)}&body=${encodeURIComponent(Ve)}`;window.open(Xe,"_self")};return o?e.jsx(Es,{title:"QuickVid",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>t(-1),children:e.jsx(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(K,{variant:"outline",size:"sm",onClick:()=>t("/mission-control/video-library"),className:"gap-1.5",children:[e.jsx(yn,{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(TO,{maxDurationSeconds:600,onRecordingComplete:Be,onRecordingStateChange:O,className:"w-full",teleprompterContent:k&&N&&e.jsx(wlt,{text:N,isVisible:k,onToggleVisibility:()=>C(!1),isRecording:L,startCountdown:!1})}),!k&&N&&e.jsxs(K,{variant:"outline",className:"mt-4",onClick:()=>C(!0),children:[e.jsx(yn,{className:"h-4 w-4 mr-2"}),"Show Teleprompter"]})]}),e.jsxs(Pe,{className:"lg:col-span-1",children:[e.jsx(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-lg",children:"Teleprompter Script"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsx(gr,{placeholder:"Type or paste your script here...",value:N,onChange:Ge=>w(Ge.target.value),rows:6}),e.jsxs(ZA,{open:A,onOpenChange:I,children:[e.jsx(zNe,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"w-full",children:[e.jsx(yn,{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:Ge=>{w(Ge.text),I(!1),C(!0)},className:"h-[calc(100vh-80px)]"})]})]}),N&&e.jsx(K,{className:"w-full",onClick:()=>C(!0),children:"Use Script"})]})]})]}),_==="uploading"&&e.jsx(Pe,{className:"max-w-md mx-auto",children:e.jsxs(Re,{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(fi,{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(Re,{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(fi,{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(Lt,{children:e.jsx(Ft,{children:"Video Details"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Title"}),e.jsx(Le,{value:me,onChange:Ge=>ye(Ge.target.value),placeholder:"Quick Video Touch"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Attach to Contact (Optional)"}),e.jsxs(Fs,{value:ie,onValueChange:oe,children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"No contact - use anywhere"})}),e.jsxs(Rs,{children:[e.jsx(vt,{value:"none",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(go,{className:"h-4 w-4"}),"No contact - use anywhere"]})}),p==null?void 0:p.map(Ge=>e.jsx(vt,{value:Ge.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ai,{className:"h-4 w-4"}),Ge.first_name," ",Ge.last_name]})},Ge.id))]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Notes"}),e.jsx(gr,{value:he,onChange:Ge=>ge(Ge.target.value),placeholder:"Add notes about this video...",rows:3})]}),e.jsxs(K,{className:"w-full",onClick:we,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(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Zn,{className:"h-5 w-5 text-green-500"}),"Video Saved!"]})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Share your video with one click:"}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs(K,{variant:"outline",className:"justify-start",onClick:et,children:[e.jsx(Si,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:tt,children:[e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:()=>ut("link",He().link),children:[e.jsx(go,{className:"h-4 w-4 mr-2"}),"Copy Video Link",De==="link"&&e.jsx(Zn,{className:"h-4 w-4 ml-auto text-green-500"})]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:()=>$e(!0),children:[e.jsx(Fl,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(K,{variant:"outline",onClick:()=>t("/mission-control/video-library"),children:"View Library"}),e.jsx(K,{onClick:()=>{b("record"),q(null),X(null),ae(null)},children:"Record Another"})]})]})]}),Ne&&Te&&e.jsx(jlt,{open:ke,onOpenChange:$e,video:{id:Ne,share_token:Te,title:me||null,contact_id:ie||null,thumbnail_url:(ce==null?void 0:ce.thumbnailUrl)||null},contactName:((_e=p==null?void 0:p.find(Ge=>Ge.id===ie))==null?void 0:_e.first_name)||null})]})}):e.jsx(Es,{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(K,{onClick:()=>t("/mission-control/video-library"),children:"Open Video Library"})]})})}function cNs({open:t,onOpenChange:s}){const{data:r}=qh(),{data:n}=Tme(),a=Mw(),o=S.useRef(null),[l,i]=S.useState(null),[d,u]=S.useState(""),[p,f]=S.useState(""),[y,_]=S.useState(""),[b,N]=S.useState(!1),[w,k]=S.useState(0),[C,A]=S.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),k(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:ae}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:J,isAgentVideo:!0}});if(ae)throw new Error(ae.message);await new Promise((me,ye)=>{const he=new XMLHttpRequest;he.upload.addEventListener("progress",ge=>{if(ge.lengthComputable){const Ne=Math.round(ge.loaded/ge.total*100);k(Ne)}}),he.addEventListener("load",()=>{he.status>=200&&he.status<300?me():ye(new Error(`Upload failed with status ${he.status}`))}),he.addEventListener("error",()=>ye(new Error("Upload failed"))),he.open("PUT",ce.uploadUrl),he.setRequestHeader("AccessKey",ce.apiKey),he.send(l)}),A("processing");const ie=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:ie,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(""),_(""),k(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(hs,{className:"sm:max-w-md",children:[e.jsxs(js,{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(gn,{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(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:te=>{te.stopPropagation(),i(null)},children:e.jsx(jr,{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(Le,{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(Fs,{value:y||"__none__",onValueChange:te=>_(te==="__none__"?"":te),disabled:b,children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select a contact"})}),e.jsxs(Rs,{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(gr,{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(fi,{value:C==="uploading"?w:C==="processing"?100:10})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:B,disabled:b,children:"Cancel"}),e.jsx(K,{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}=qs();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}=qs();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}=qs(),s=Qt();return Et({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]=S.useState([]),[d,u]=S.useState(null),[p,f]=S.useState(!1),[y,_]=S.useState(!1),[b,N]=S.useState(""),[w,k]=S.useState(""),[C,A]=S.useState(""),[I,L]=S.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";S.useEffect(()=>{t&&l.length===0&&U()},[t]),S.useEffect(()=>{if(t&&(k(`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 ae=l.find(ie=>ie.id===r.contact_id);ae&&(u(ae),N(ae.email||""))}},[t,r.contact_id,l]);const U=async()=>{_(!0);try{const{data:ae,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;i(ae||[])}catch{console.error("Failed to fetch contacts")}finally{_(!1)}},te=ae=>{u(ae),f(!1),N(ae.email||""),A(`Hey ${ae.first_name}! I recorded a quick video just for you. Click below to watch it:`),k(`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=ae=>`${ae.first_name} ${ae.last_name||""}`.trim(),X=ae=>{const ie=C.split(/\n\n+/).map(ye=>`

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

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

▶ 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 ae;try{const ye=d?J(d):b.split("@")[0];ae=(await O.mutateAsync({video_id:r.id,recipient_email:b,recipient_name:ye,contact_id:(d==null?void 0:d.id)||null,sent_via:"gmail"})).share_token}catch(ye){console.warn("Failed to create tracking record, sending without tracking:",ye)}const ie=X(ae),{data:oe,error:me}=await G.functions.invoke("gmail-send",{body:{to:b,subject:w,body:ie,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(ae){console.error("Gmail send error:",ae),pe.error("Failed to send: "+(ae instanceof Error?ae.message:"Unknown error"))}finally{L(!1)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(hs,{className:"sm:max-w-[560px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(js,{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(yo,{open:p,onOpenChange:f,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{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(uo,{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(ae=>ae.email).map(ae=>e.jsxs(lp,{value:`${ae.first_name} ${ae.last_name||""} ${ae.email||""}`,onSelect:()=>te(ae),children:[e.jsx(Zn,{className:Dt("mr-2 h-4 w-4",(d==null?void 0:d.id)===ae.id?"opacity-100":"opacity-0")}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:J(ae)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ae.email})]})]},ae.id))})]})]})})]}),d&&e.jsx(K,{variant:"ghost",size:"icon",onClick:Y,className:"shrink-0",children:e.jsx(jr,{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(Le,{id:"video-to",value:b,onChange:ae=>N(ae.target.value),placeholder:"recipient@example.com",type:"email"})]}),e.jsx(xo,{}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{htmlFor:"video-subject",children:"Subject"}),e.jsx(Le,{id:"video-subject",value:w,onChange:ae=>k(ae.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{htmlFor:"video-message",children:"Personal Message"}),e.jsx(gr,{id:"video-message",value:C,onChange:ae=>A(ae.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(K,{variant:"outline",onClick:()=>s(!1),disabled:I,children:"Cancel"}),e.jsxs(K,{onClick:ce,disabled:I||!b||!w,className:"gap-2",children:[I?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(Mn,{className:"h-4 w-4"}),I?"Sending...":"Send Video Email"]})]})]})]})})}const gNs=()=>{const{user:t}=qs();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(Cn,{className:"h-2.5 w-2.5 mr-0.5"}),"Opened"]}):e.jsxs(Qe,{variant:"outline",className:"text-[10px]",children:[e.jsx(Mn,{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(hs,{className:"max-w-2xl max-h-[80vh]",children:[e.jsx(js,{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(ks,{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(ni,{className:"h-[400px]",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ms,{children:[e.jsx(kt,{children:"Recipient"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{children:"Sent"}),e.jsx(kt,{children:"Last Activity"})]})}),e.jsx(Rn,{children:a.map(l=>e.jsxs(Ms,{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:gs(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]=S.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(Lt,{className:"pb-2",children:e.jsx(ks,{className:"h-4 w-20"})}),e.jsx(Re,{children:e.jsx(ks,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Total Sent"}),e.jsx(Mn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:(t==null?void 0:t.totalSent)||0})})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Open Rate"}),e.jsx(Cn,{className:"h-4 w-4 text-amber-500"})]}),e.jsxs(Re,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(au,{className:"h-4 w-4 text-blue-500"})]}),e.jsxs(Re,{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(Lt,{children:[e.jsx(Ft,{className:"text-sm font-medium",children:"Send History by Video"}),e.jsx(ur,{children:"Click a video to see individual recipient tracking"})]}),e.jsx(Re,{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(gn,{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(Mn,{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(Cn,{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]=S.useState(!1),[l,i]=S.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(gn,{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[k,C]=S.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:k}),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(Re,{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(on,{className:"h-3 w-3"}),e.jsx("span",{children:gs(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(Cn,{className:"h-3 w-3"}),e.jsxs("span",{children:[t.view_count," ",t.view_count===1?"view":"views"]})]})]}),y&&t.share_token&&e.jsxs(K,{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(on,{className:"h-3 w-3"}),e.jsx("span",{children:gs(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(Cn,{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(K,{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(Cn,{className:"h-4 w-4 mr-2"}),"Watch"]}),e.jsx(Yb,{}),e.jsxs(_a,{onClick:A=>{A.stopPropagation(),p()},children:[e.jsx(Fl,{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(go,{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(Zr,{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(Mn,{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(xr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})})]})}function jNs(){var Ze,Nt;const t=vr(),{data:s,isLoading:r,refetch:n}=Obs(),{data:a}=Tme(),{data:o}=qh(),l=Bbs(),i=zbs(),{isGmailConnected:d,gmailEmail:u}=jp(),{data:p}=Px(),{data:f=[],isLoading:y}=gNs(),[_,b]=S.useState("my"),[N,w]=S.useState(""),[k,C]=S.useState(null),[A,I]=S.useState(!1),[L,O]=S.useState(!1),[V,q]=S.useState(!1),[B,U]=S.useState(!1),[te,Y]=S.useState(!1),[J,X]=S.useState(""),[ce,ae]=S.useState(!1),[ie,oe]=S.useState(!1),[me,ye]=S.useState(!1),[he,ge]=S.useState(!1),[Ne,Ue]=S.useState(""),[Te,Me]=S.useState({}),De=Ot=>{if(!Ot)return"Unassigned";const Yt=o==null?void 0:o.find(Ps=>Ps.id===Ot);return Yt?`${Yt.first_name} ${Yt.last_name||""}`.trim():"Unknown"},qe=Ot=>{if(!Ot)return"0:00";const Yt=Math.floor(Ot/60),Ps=Ot%60;return`${Yt}:${Ps.toString().padStart(2,"0")}`},ke=s==null?void 0:s.filter(Ot=>{if(!N)return!0;const Yt=De(Ot.contact_id).toLowerCase(),Ps=(Ot.title||"").toLowerCase(),$s=(Ot.notes||"").toLowerCase();return Yt.includes(N.toLowerCase())||Ps.includes(N.toLowerCase())||$s.includes(N.toLowerCase())}),[$e,Be]=S.useState(!1);S.useEffect(()=>{if($e)return;(async()=>{if(!(s!=null&&s.length))return;const Yt=s.filter($s=>$s.status==="processing"&&$s.bunny_video_id);if(!Yt.length)return;let Ps=!1;for(const $s of Yt)try{const{data:Zs,error:Dr}=await G.functions.invoke("bunny-upload",{body:{action:"status",videoId:$s.bunny_video_id,isAgentVideo:!0}});if(Dr||!Zs)continue;Zs.status===4&&(await G.from("agent_videos").update({status:"ready",playback_url:Zs.directPlayUrl,thumbnail_url:Zs.thumbnailUrl,preview_url:Zs.previewUrl,duration_seconds:Zs.length||$s.duration_seconds,updated_at:new Date().toISOString()}).eq("id",$s.id),Ps=!0)}catch(Zs){console.warn("Reconcile check failed for video",$s.id,Zs)}Be(!0),Ps&&n()})()},[s,$e,n]),S.useEffect(()=>{(async()=>{if(!(s!=null&&s.length))return;const Yt=s.filter($t=>($t==null?void 0:$t.bunny_video_id)&&!Te[$t.id]);if(!Yt.length)return;const Ps=Yt.map($t=>$t.bunny_video_id),{data:$s,error:Zs}=await G.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:Ps,isAgentVideo:!0}});if(Zs)throw Zs;const Dr=($s==null?void 0:$s.assets)||{};Me($t=>{const Us={...$t};for(const Nr of Yt)Dr[Nr.bunny_video_id]&&(Us[Nr.id]={previewUrl:Dr[Nr.bunny_video_id].previewUrl,thumbnailUrl:Dr[Nr.bunny_video_id].thumbnailUrl});return Us})})().catch(Yt=>console.warn("Failed to load signed Bunny asset URLs",Yt))},[s,Te]);const we=(a==null?void 0:a.total_storage_mb)||0,ut=(a==null?void 0:a.max_storage_mb)||1024,fe=we/ut*100,He=fe>=80,et=fe>=100,tt=async(Ot,Yt)=>{await navigator.clipboard.writeText(Ot),pe.success(`${Yt} copied to clipboard`)},_e=Ot=>Ot.share_token?`https://video.relevelup.com/${Ot.share_token}`:Ot.playback_url||"",Ge=Ot=>{const Yt=_e(Ot),Ps=o==null?void 0:o.find(Nr=>Nr.id===Ot.contact_id),$s=De(Ot.contact_id),Zs=$s!=="Unassigned"?$s.split(" ")[0]:"",Dr=(Ps==null?void 0:Ps.phone)||"",$t=`Hey${Zs?` ${Zs}`:""}! I recorded a quick video message for you. Check it out: ${Yt}`,Us=Dr?`sms:${Dr}?body=${encodeURIComponent($t)}`:`sms:?body=${encodeURIComponent($t)}`;window.open(Us,"_self")},We=Ot=>{const Yt=o==null?void 0:o.find(Us=>Us.id===Ot.contact_id),Ps=(Yt==null?void 0:Yt.email)||"",$s=_e(Ot),Zs="Check out this video",Dr=`I recorded a quick video for you: ${$s}`,$t=Ps?`mailto:${Ps}?subject=${encodeURIComponent(Zs)}&body=${encodeURIComponent(Dr)}`:`mailto:?subject=${encodeURIComponent(Zs)}&body=${encodeURIComponent(Dr)}`;window.open($t,"_self")},it=Ot=>{var Zs;const Yt=_e(Ot),Ps=Ot.title||"Video Message",$s=Ot.share_token?`https://video.relevelup.com/thumb/${Ot.share_token}`:((Zs=Te[Ot.id])==null?void 0:Zs.thumbnailUrl)||Ot.thumbnail_url||"";return``},Ve=async Ot=>{if(!Ot.thumbnail_url&&!Ot.share_token){pe.error("Video thumbnail not available yet");return}const Yt=it(Ot),Ps=_e(Ot),$s=`Watch: ${Ot.title||"Video Message"} ${Ps}`;try{const Zs=new Blob([Yt],{type:"text/html"}),Dr=new Blob([$s],{type:"text/plain"}),$t=new ClipboardItem({"text/html":Zs,"text/plain":Dr});await navigator.clipboard.write([$t]),pe.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText($s+` `+Yt),pe.success("Copied! Paste into your email.")}},Xe=async Ot=>{try{pe.loading("Preparing download...",{id:"download"});const{data:Yt,error:Ps}=await G.functions.invoke("bunny-upload",{body:{action:"download-url",videoId:Ot.bunny_video_id,isAgentVideo:!0}});if(Ps||!(Yt!=null&&Yt.downloadUrl))throw new Error((Ps==null?void 0:Ps.message)||"Failed to get download URL");const Zs=`${((Ot.title||"video").toString().trim()||"video").replace(/[\\/:*?"<>|]+/g,"-")}.mp4`,Dr=await fetch(Yt.downloadUrl);if(!Dr.ok)throw new Error("Failed to fetch video file");const $t=await Dr.blob(),Us=URL.createObjectURL($t),Nr=document.createElement("a");Nr.href=Us,Nr.download=Zs,Nr.rel="noreferrer",document.body.appendChild(Nr),Nr.click(),Nr.remove(),URL.revokeObjectURL(Us),pe.success("Download started",{id:"download"})}catch(Yt){console.error("Download error:",Yt),pe.error("Could not force download (your browser may block it).",{id:"download"})}},dt=async Ot=>{C(Ot),ae(!0),X(""),Y(!0);try{const{data:Yt,error:Ps}=await G.functions.invoke("bunny-upload",{body:{action:"crm-embed",videoId:Ot.bunny_video_id,title:Ot.title,isAgentVideo:!0,shareToken:Ot.share_token}});if(Ps||!(Yt!=null&&Yt.html))throw new Error("Failed to generate CRM embed code");X(Yt.html)}catch(Yt){console.error("CRM embed error:",Yt),pe.error("Failed to generate CRM embed code"),Y(!1)}finally{ae(!1)}},pt=Ot=>{C(Ot),I(!0)},Je=async()=>{if(k)try{await l.mutateAsync({id:k.id,bunnyVideoId:k.bunny_video_id,hardDelete:!0}),O(!1),C(null),pe.success("Video deleted successfully")}catch{pe.error("Failed to delete video")}};return e.jsx(Es,{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(or,{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(K,{variant:"outline",onClick:()=>q(!0),children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"}),"Upload Video"]}),e.jsxs(K,{onClick:()=>t("/mission-control/video/record"),children:[e.jsx(Bs,{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:He?"border-amber-500":et?"border-destructive":"",children:e.jsxs(Re,{className:"py-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(yL,{className:`h-5 w-5 ${et?"text-destructive":He?"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:[we.toFixed(1)," MB / ",ut>=1024?`${(ut/1024).toFixed(0)} GB`:`${ut} MB`]})]}),e.jsx(fi,{value:Math.min(fe,100),className:`h-2 ${et?"[&>div]:bg-destructive":He?"[&>div]:bg-amber-500":""}`})]}),He&&!et&&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"]}),et&&e.jsxs(Qe,{variant:"destructive",children:[e.jsx(ro,{className:"h-3 w-3 mr-1"}),"At Limit"]})]}),et&&e.jsx("p",{className:"text-sm text-destructive mt-2",children:"You've reached your storage limit. Delete videos to record more."})]})}),e.jsxs("div",{className:"relative",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search videos by contact, title, or notes...",value:N,onChange:Ot=>w(Ot.target.value),className:"pl-10"})]}),r?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})}):(ke==null?void 0:ke.length)===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center",children:[e.jsx(gn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No videos yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Record your first video touch to get started"}),e.jsxs(K,{onClick:()=>t("/mission-control/video/record"),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Record Video"]})]})}):e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-4",children:ke==null?void 0:ke.map(Ot=>{var Yt,Ps;return e.jsx(wNs,{video:Ot,previewSrc:(Yt=Te[Ot.id])==null?void 0:Yt.previewUrl,thumbnailSrc:(Ps=Te[Ot.id])==null?void 0:Ps.thumbnailUrl,onOpen:()=>pt(Ot),onDelete:()=>{C(Ot),O(!0)},onRename:()=>{C(Ot),Ue(Ot.title||""),ge(!0)},onNavigateToContact:()=>t(`/mission-control/contacts/${Ot.contact_id}`),onGetEmbedCode:()=>{C(Ot),U(!0)},onCopyEmailHtml:()=>Ve(Ot),onEmbedToCrm:()=>dt(Ot),onShareWithTemplate:()=>{C(Ot),oe(!0)},onSendViaGmail:()=>{C(Ot),ye(!0)},isGmailConnected:d,getContactName:De,getShareUrl:_e,copyToClipboard:tt,formatDuration:qe},Ot.id)})}),e.jsx(fs,{open:A,onOpenChange:I,children:e.jsxs(hs,{className:"max-w-2xl",children:[e.jsxs(js,{children:[e.jsx(_s,{children:(k==null?void 0:k.title)||"Video Preview"}),e.jsx(Ir,{children:(k==null?void 0:k.contact_id)&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ai,{className:"h-3 w-3"}),De(k.contact_id)]})})]}),k&&e.jsxs("div",{className:"space-y-4",children:[k.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(K,{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:k.playback_url?(()=>{let Ot=k.playback_url;return Ot.includes("iframe.mediadelivery.net/play/")&&(Ot=Ot.replace("/play/","/embed/"),Ot+=(Ot.includes("?")?"&":"?")+"autoplay=false&responsive=true"),Ot.includes("iframe.mediadelivery.net")?e.jsx("iframe",{src:Ot,title:k.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:k.playback_url,controls:!0,playsInline:!0,preload:"metadata",poster:k.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")},k.playback_url)})():e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-muted rounded-lg",children:[e.jsx(gn,{className:"h-12 w-12 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground ml-2",children:"Video not available"})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>Ge(k),children:[e.jsx(Si,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),!d&&e.jsxs(K,{variant:"outline",onClick:()=>We(k),children:[e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(K,{variant:"outline",onClick:()=>tt(_e(k),"Share link"),children:[e.jsx(Wa,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(K,{variant:"outline",onClick:()=>Ve(k),children:[e.jsx(tr,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(K,{variant:"outline",onClick:()=>Xe(k),children:[e.jsx(Qa,{className:"h-4 w-4 mr-2"}),"Download Video"]}),e.jsxs(K,{variant:"outline",onClick:()=>{I(!1),dt(k)},children:[e.jsx(Zr,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),e.jsxs(K,{variant:"outline",onClick:()=>{I(!1),oe(!0)},children:[e.jsx(Fl,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]}),d&&(k==null?void 0:k.share_token)&&e.jsxs(K,{variant:"outline",onClick:()=>{I(!1),ye(!0)},children:[e.jsx(Mn,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]})]}),e.jsx("div",{className:"flex justify-end pt-2 border-t",children:e.jsxs(K,{variant:"destructive",onClick:()=>{I(!1),O(!0)},children:[e.jsx(xr,{className:"h-4 w-4 mr-2"}),"Delete Video"]})})]})]})}),e.jsx(fs,{open:L,onOpenChange:O,children:e.jsxs(hs,{children:[e.jsxs(js,{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(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:Je,disabled:l.isPending,children:l.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(cNs,{open:V,onOpenChange:q}),e.jsx(fs,{open:B,onOpenChange:U,children:e.jsxs(hs,{className:"sm:max-w-lg",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Embed Video"}),e.jsx(Ir,{children:"Copy this code to embed the video on your website."})]}),k&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Embed Code"}),e.jsx(gr,{readOnly:!0,rows:5,value:``,className:"font-mono text-xs"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(K,{className:"flex-1",onClick:()=>{const Ot=``;tt(Ot,"Embed code")},children:[e.jsx(Wa,{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."})]})]})}),k&&e.jsx(jlt,{open:ie,onOpenChange:oe,video:k,contactName:De(k.contact_id)}),k&&e.jsx(xNs,{open:me,onOpenChange:ye,video:k,gmailEmail:u,signedThumbnailUrl:(Nt=Te[k.id])==null?void 0:Nt.thumbnailUrl}),e.jsx(fs,{open:he,onOpenChange:ge,children:e.jsxs(hs,{className:"max-w-sm",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Rename Video"}),e.jsx(Ir,{children:"Enter a new title for this video."})]}),e.jsx(Le,{value:Ne,onChange:Ot=>Ue(Ot.target.value),placeholder:"Video title",autoFocus:!0,onKeyDown:Ot=>{Ot.key==="Enter"&&Ne.trim()&&i.mutate({id:k.id,title:Ne.trim()},{onSuccess:()=>{pe.success("Video renamed"),ge(!1)}})}}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>ge(!1),children:"Cancel"}),e.jsx(K,{disabled:!Ne.trim()||i.isPending,onClick:()=>{i.mutate({id:k.id,title:Ne.trim()},{onSuccess:()=>{pe.success("Video renamed"),ge(!1)}})},children:i.isPending?"Saving...":"Save"})]})]})}),e.jsx(fs,{open:te,onOpenChange:Y,children:e.jsxs(hs,{className:"sm:max-w-lg",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(Zr,{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(gr,{readOnly:!0,rows:12,value:J,className:"font-mono text-xs"})]}),e.jsxs(K,{className:"w-full",onClick:()=>{tt(J,"CRM embed code")},children:[e.jsx(Wa,{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=S.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=S.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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search team videos by title, owner, or recipient...",value:r,onChange:i=>n(i.target.value),className:"pl-10"})]}),s?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})}):a.length===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center",children:[e.jsx(or,{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(wn,{className:"h-7 w-7",children:[e.jsx(Ma,{src:d.avatar||""}),e.jsx(jn,{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(gn,{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(Re,{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(Cn,{className:"h-3 w-3"}),u.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(on,{className:"h-3 w-3"}),gs(new Date(u.created_at),"MMM d")]})]})]})]},u.id))})]},i))})]})}const kNs=()=>{const{user:t}=qs();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})},n9e=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function SNs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=kNs(),[a,o]=S.useState(""),[l,i]=S.useState("all"),d=S.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:n9e[N%n9e.length]}),N++)}),b},[r]),u=S.useMemo(()=>Array.from(d.entries()).map(([b,N])=>({id:b,...N})),[d]),p=S.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 k,C,A,I;return w.deal_name.toLowerCase().includes(N)||((k=w.contact_name)==null?void 0:k.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=S.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 k=b.get(w);k.deals.push(N),k.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(hs,{className:"max-w-[95vw] w-full max-h-[90vh] flex flex-col",children:[e.jsx(js,{children:e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(or,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search deals...",value:a,onChange:b=>o(b.target.value),className:"pl-9"})]}),e.jsxs(Fs,{value:l,onValueChange:i,children:[e.jsx(Ds,{className:"w-[180px]",children:e.jsx(zs,{placeholder:"All Members"})}),e.jsxs(Rs,{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(ks,{className:"h-12 w-full mb-2 rounded-lg"}),e.jsx(ks,{className:"h-24 w-full mb-2 rounded-lg"}),e.jsx(ks,{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(or,{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(ni,{className:"flex-1 p-2",children:e.jsx("div",{className:"space-y-2",children:b.deals.map(w=>{const k=d.get(w.owner_user_id);return e.jsx(CNs,{deal:w,ownerColor:(k==null?void 0:k.color)||"#888",ownerName:(k==null?void 0:k.name)||"Unknown",ownerAvatar:(k==null?void 0:k.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(wn,{className:"h-4 w-4",children:[e.jsx(Ma,{src:n||""}),e.jsx(jn,{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:Dt("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(Sn,{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:Dt("shrink-0 border-r border-border/50 bg-muted/20 transition-all duration-300 flex flex-col",n?"w-[220px]":"w-[48px]"),children:[e.jsx("div",{className:"p-2 border-b border-border/50 shrink-0",children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 px-2",onClick:a,children:[e.jsx(or,{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(ni,{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:Dt("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(wn,{className:"h-7 w-7",children:[e.jsx(Ma,{src:l.avatar_url||""}),e.jsx(jn,{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:Dt("text-xs truncate flex-1",i?"font-medium text-foreground":"text-muted-foreground"),children:l.name}),e.jsx(Mr,{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(wn,{className:Dt("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(jn,{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 a9e=["#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:a9e[f%a9e.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 Nlt({stages:t,currentStageId:s,onStageSelect:r,disabled:n}){const[a,o]=S.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(K,{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:Dt("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 klt({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=S.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=S.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,k=I=>I?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(I):null;return e.jsx(Pe,{className:Dt("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(Re,{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(wn,{className:"h-4 w-4",children:[e.jsx(Ma,{src:i.avatar_url||""}),e.jsx(jn,{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:Dt("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(wn,{className:"h-5 w-5",children:e.jsxs(jn,{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(Vi,{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(Hn,{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:Dt("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(Sn,{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:k(t.expected_price)}),t.expected_commission&&e.jsxs("span",{className:"text-muted-foreground",children:["• ",k(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:["• ",k(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:Dt("flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px]",p.color),children:[e.jsx("div",{className:Dt("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(Nlt,{stages:n,currentStageId:t.stage_id||"",onStageSelect:(I,L)=>a(t.id,I,L)}):t.target_close_date?e.jsxs("div",{className:Dt("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(ln,{className:"h-3 w-3"}),e.jsx("span",{children:y?`${Math.abs(f)}d overdue`:_?`${f}d left`:gs(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=S.useRef(null),f=s.reduce((w,k)=>w+(k.expected_price||0),0),y=s.reduce((w,k)=>w+(k.expected_commission||0),0),_=s.reduce((w,k)=>w+(cx(k)||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:Dt("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(ni,{className:"flex-1 p-2",children:e.jsxs("div",{className:"space-y-2",children:[s.map(w=>e.jsx("div",{draggable:!0,onDragStart:k=>{k.dataTransfer.effectAllowed="move",a(w.id,t.id)},children:e.jsx(klt,{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(K,{variant:"ghost",size:"sm",className:"w-full justify-start text-muted-foreground hover:text-foreground",onClick:()=>n(t.id),children:[e.jsx(Bs,{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(Re,{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(Re,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:Dt("p-2 rounded-lg",a.bgColor),children:e.jsx(a.icon,{className:Dt("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(Jl,{children:[e.jsx(ec,{asChild:!0,children:o}),e.jsx(Ll,{children:e.jsx("p",{children:a.tooltip})})]},a.label):o})})})}function RNs({formData:t,onChange:s,isEditing:r}){const{isAdmin:n}=qs(),[a,o]=S.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(Fi,{className:Dt("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(Mr,{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:Dt("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(_le,{value:"private"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(vd,{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:Dt("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(_le,{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(Hi,{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(Hi,{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(Le,{value:t.client_name,onChange:i=>l({client_name:i.target.value}),placeholder:"Jane Smith"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs text-muted-foreground",children:"Email"}),e.jsx(Le,{type:"email",value:t.client_email,onChange:i=>l({client_email:i.target.value}),placeholder:"jane@example.com"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs text-muted-foreground",children:"Phone"}),e.jsx(Le,{type:"tel",value:t.client_phone,onChange:i=>l({client_phone:i.target.value}),placeholder:"(555) 123-4567"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs text-muted-foreground",children:"Preferred Invite Method"}),e.jsxs(Fs,{value:t.invite_method,onValueChange:i=>l({invite_method:i}),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsxs(Rs,{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}=Ame(),{data:o}=qh(),{data:l}=MXe(),i=rhe(),d=git(),u=yit(),p=$Se(),[f,y]=S.useState({portal_enabled:!1,visibility:"private",require_onboarding:!0,allow_spouse:!1,client_name:"",client_email:"",client_phone:"",invite_method:"email"}),[_,b]=S.useState(""),[N,w]=S.useState(!1),[k,C]=S.useState(!1),[A,I]=S.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]=S.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:""});S.useEffect(()=>{var J,X,ce,ae,ie,oe,me,ye;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:((ae=r.team_split_pct)==null?void 0:ae.toString())||"",referral_fee_pct:((ie=r.referral_fee_pct)==null?void 0:ie.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||((ye=a==null?void 0:a[0])==null?void 0:ye.id)||"",contact_id:"",listing_id:"",property_address:"",city:"",state:"",zip_code:"",expected_price:"",commission_percentage:"3",brokerage_split_pct:"",team_split_pct:"",referral_fee_pct:"",franchise_fee_pct:"",transaction_fee:"",commission_calc_method:"standard",target_close_date:void 0,contract_date:void 0,listing_date:void 0,priority:"medium",probability:"50",notes:""}),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,ae,ie;const X=_.toLowerCase();return((ce=J.first_name)==null?void 0:ce.toLowerCase().includes(X))||((ae=J.last_name)==null?void 0:ae.toLowerCase().includes(X))||((ie=J.email)==null?void 0:ie.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,ae=parseFloat(O.referral_fee_pct)||0,ie=parseFloat(O.franchise_fee_pct)||0,oe=parseFloat(O.transaction_fee)||0;if(O.commission_calc_method==="referral_first"){let ye=J;ae&&(ye-=J*ae/100);let he=ye;return X&&(he-=ye*X/100),ce&&(he-=J*ce/100),ie&&(he-=J*ie/100),oe&&(he-=oe),Math.max(0,he)}let me=J;return X&&(me=me*((100-X)/100)),ce&&(me=me*((100-ce)/100)),ae&&(me=me-J*ae/100),ie&&(me=me-J*ie/100),oe&&(me=me-oe),Math.max(0,me)},te=async J=>{var X,ce,ae;if(J.preventDefault(),!O.deal_name.trim()){pe.error("Please enter a deal name");return}try{const ie={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:((ae=O.listing_date)==null?void 0:ae.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,...ie}),pe.success("Deal updated successfully");else{const oe=await d.mutateAsync(ie);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(hs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(js,{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(Le,{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(Fs,{value:O.deal_type,onValueChange:J=>V(X=>({...X,deal_type:J})),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsx(Rs,{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(Fs,{value:O.stage_id||"none",onValueChange:J=>V(X=>({...X,stage_id:J==="none"?"":J})),children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select stage"})}),e.jsxs(Rs,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{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(),'"']})]})]})]}),k&&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(K,{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(Le,{placeholder:"First name *",value:A.first_name,onChange:J=>I(X=>({...X,first_name:J.target.value})),className:"h-8 text-sm"}),e.jsx(Le,{placeholder:"Last name",value:A.last_name,onChange:J=>I(X=>({...X,last_name:J.target.value})),className:"h-8 text-sm"}),e.jsx(Le,{placeholder:"Email",type:"email",value:A.email,onChange:J=>I(X=>({...X,email:J.target.value})),className:"h-8 text-sm"}),e.jsx(Le,{placeholder:"Phone",type:"tel",value:A.phone,onChange:J=>I(X=>({...X,phone:J.target.value})),className:"h-8 text-sm"})]}),e.jsx(K,{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(Fs,{value:O.listing_id||"none",onValueChange:J=>{const X=J==="none"?"":J,ce=L.find(ae=>ae.id===X);V(ce?ae=>{var ie;return{...ae,listing_id:X,deal_type:"seller",property_address:ce.property_address||ae.property_address,city:ce.city||ae.city,state:ce.state||ae.state,expected_price:((ie=ce.price)==null?void 0:ie.toString())||ae.expected_price}}:ae=>({...ae,listing_id:X}))},children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select a listing to sync status..."})}),e.jsxs(Rs,{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(Le,{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(Le,{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(Le,{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(Le,{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(Le,{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(Le,{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(Le,{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(Fs,{value:O.commission_calc_method,onValueChange:J=>V(X=>({...X,commission_calc_method:J})),children:[e.jsx(Ds,{className:"h-7 text-xs",children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Le,{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(Le,{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(Le,{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(Le,{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(Le,{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(Le,{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(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Dt("w-full justify-start text-left font-normal",!O.target_close_date&&"text-muted-foreground"),children:[e.jsx(ln,{className:"mr-2 h-4 w-4"}),O.target_close_date?gs(O.target_close_date,"PPP"):"Pick a date"]})}),e.jsx(uo,{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(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Dt("w-full justify-start text-left font-normal",!O.contract_date&&"text-muted-foreground"),children:[e.jsx(ln,{className:"mr-2 h-4 w-4"}),O.contract_date?gs(O.contract_date,"PPP"):"Pick a date"]})}),e.jsx(uo,{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(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Dt("w-full justify-start text-left font-normal",!O.listing_date&&"text-muted-foreground"),children:[e.jsx(ln,{className:"mr-2 h-4 w-4"}),O.listing_date?gs(O.listing_date,"PPP"):"Pick a date"]})}),e.jsx(uo,{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(Fs,{value:O.priority,onValueChange:J=>V(X=>({...X,priority:J})),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsx(Rs,{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(Le,{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(gr,{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(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{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]=S.useState(""),[o,l]=S.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(k=>k.tag))].sort()},enabled:!!s}),u=Et({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=Et({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(jr,{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(Bs,{className:"h-3 w-3"})," Add tag"]})]}),o&&e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(Le,{value:n,onChange: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 Et({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 Et({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 Et({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 i9e={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]=S.useState(!1),[u,p]=S.useState({question_text:"",field_type:"text",options:[],is_required:!1}),[f,y]=S.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(""))},k=C=>{p(A=>({...A,options:A.options.filter((I,L)=>L!==C)}))};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(hs,{className:"max-w-md max-h-[85vh] flex flex-col",children:[e.jsxs(js,{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(ni,{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:i9e[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(Mr,{checked:C.is_required,onCheckedChange:I=>N(C.id,I),className:"scale-75"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:()=>b(C.id),children:e.jsx(xr,{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(Le,{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(i9e).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:()=>k(A),className:"text-muted-foreground hover:text-destructive",children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]},A)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{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(K,{variant:"outline",size:"sm",onClick:w,disabled:!f.trim(),className:"h-8",children:e.jsx(Bs,{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(Mr,{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(K,{variant:"outline",size:"sm",onClick:()=>d(!1),className:"flex-1",children:"Cancel"}),e.jsxs(K,{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(K,{variant:"outline",size:"sm",onClick:()=>d(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"})," Add Question"]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>s(!1),children:"Done"})]})]})})}function WNs({portalId:t,ownerId:s,clientEmail:r,linkedPortalId:n,onLink:a}){const[o,l]=S.useState(""),[i,d]=S.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=S.useMemo(()=>!n||!u?null:u.find(b=>b.id===n),[n,u]),y=S.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]),_=S.useMemo(()=>{if(!u||!o.trim())return[];const b=o.toLowerCase();return u.filter(N=>{var k,C,A,I;const w=N.deal_pipeline;return((k=N.client_name)==null?void 0:k.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(K,{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(K,{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(an,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Le,{value:o,onChange: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 BCe({userId:t,onSelect:s,triggerLabel:r="Library",triggerSize:n="sm",triggerVariant:a="outline",triggerClassName:o}){const[l,i]=S.useState(!1),[d,u]=S.useState([]),[p,f]=S.useState(!1),[y,_]=S.useState("");S.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(hi,{asChild:!0,children:e.jsxs(K,{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(hs,{className:"max-w-lg max-h-[70vh] flex flex-col",children:[e.jsxs(js,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search videos...",value: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(ks,{className:"h-16 w-full"}),e.jsx(ks,{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 k=w.currentTarget.parentElement;if(k){w.currentTarget.remove();const C=document.createElement("span");C.innerHTML="🎬",C.className="text-lg",k.appendChild(C)}}}):e.jsx(gn,{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 $Ce({contactId:t,onVideoReady:s}){const[r,n]=S.useState(!1),[a,o]=S.useState("record"),[l,i]=S.useState(0),[d,u]=S.useState(0),p=Mw(),f=()=>{o("record"),i(0),u(0)},y=b=>{!b&&(a==="uploading"||a==="processing")||(n(b),b||f())},_=S.useCallback(async(b,N)=>{o("uploading");try{const w="Card Video",{videoId:k,libraryId:C}=await wE(w),{uploadUrl:A,apiKey:I}=await jE(k),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}/${k}`;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:k,playback_url:`https://iframe.mediadelivery.net/play/${C}/${k}`,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(k);if(O=Y.status,u(Y.encodeProgress||0),O===5||O===6)throw new Error("Video processing failed")}const U=await nw(k),te=(U.storageSize||b.size)/(1024*1024);await p.mutateAsync({bunny_video_id:k,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(hi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 w-full",children:[e.jsx(gn,{className:"h-3.5 w-3.5"}),"Record Video"]})}),e.jsxs(hs,{className:"sm:max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:"Record a Video for Your Card"})}),a==="record"&&e.jsx(TO,{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(fi,{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(fi,{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(ti,{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 Slt({open:t,onOpenChange:s,portal:r,dealOwnerId:n}){const a=_O(),[o,l]=S.useState(!1),i=S.useMemo(()=>KNs(r.id),[r.id]),[d,u]=S.useState(!1),[p,f]=S.useState(r.next_step_text||""),[y,_]=S.useState(r.next_step_video_url||""),[b,N]=S.useState(r.inspection_date||""),[w,k]=S.useState(r.appraisal_date||""),[C,A]=S.useState(r.welcome_message||""),[I,L]=S.useState(r.review_url||""),[O,V]=S.useState(r.show_post_close_tips),[q,B]=S.useState(r.notify_client),[U,te]=S.useState(r.require_onboarding),[Y,J]=S.useState(r.allow_spouse),[X,ce]=S.useState(r.visibility),[ae,ie]=S.useState(r.stage_mapping||[]),[oe,me]=S.useState(null),[ye,he]=S.useState(r.linked_portal_id||null),[ge,Ne]=S.useState(r.referral_enabled??!0),[Ue,Te]=S.useState(r.referral_reward_text||""),[Me,De]=S.useState(r.referral_cta_headline||""),[qe,ke]=S.useState(r.homeowner_hub_video_url||""),$e=()=>{f(r.next_step_text||""),_(r.next_step_video_url||""),N(r.inspection_date||""),k(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),ie(r.stage_mapping||[]),he(r.linked_portal_id||null),Ne(r.referral_enabled??!0),Te(r.referral_reward_text||""),De(r.referral_cta_headline||""),ke(r.homeowner_hub_video_url||"")};S.useEffect(()=>{u(!1);const tt=localStorage.getItem(i);if(tt)try{const _e=JSON.parse(tt);f(_e.nextStepText||""),_(_e.nextStepVideo||""),N(_e.inspectionDate||""),k(_e.appraisalDate||""),A(_e.welcomeMessage||""),L(_e.reviewUrl||""),V(!!_e.showPostClose),B(!!_e.notifyClient),te(!!_e.requireOnboarding),J(!!_e.allowSpouse),ce(_e.visibility||r.visibility),ie(_e.stageMapping||[]),he(_e.linkedPortalId??null),Ne(_e.referralEnabled??!0),Te(_e.referralRewardText||""),De(_e.referralCtaHeadline||""),ke(_e.homeownerHubVideoUrl||""),u(!0);return}catch{localStorage.removeItem(i)}$e(),u(!0)},[i,r]),S.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:ae,linkedPortalId:ye,referralEnabled:ge,referralRewardText:Ue,referralCtaHeadline:Me,homeownerHubVideoUrl:qe};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(ae)!==JSON.stringify(r.stage_mapping||[])||ye!==(r.linked_portal_id||null)||ge!==(r.referral_enabled??!0)||Ue!==(r.referral_reward_text||"")||Me!==(r.referral_cta_headline||"")||qe!==(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,ae,ye,ge,Ue,Me,qe,i,d,r]);const Be=()=>{localStorage.removeItem(i),$e()},we=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:ae.length>0?ae:null,linked_portal_id:ye,referral_enabled:ge,referral_reward_text:Ue||null,referral_cta_headline:Me||null,homeowner_hub_video_url:qe||null});const tt=r.linked_portal_id;ye&&ye!==tt&&await G.from("client_portals").update({linked_portal_id:r.id}).eq("id",ye),!ye&&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")}},ut=()=>{ie([...ae,{label:""}])},fe=tt=>{ie(ae.filter((_e,Ge)=>Ge!==tt)),oe===tt&&me(null)},He=(tt,_e,Ge)=>{const We=[...ae];We[tt]={...We[tt],[_e]:Ge},ie(We)},et=()=>{const _e=FNe(null).map(Ge=>({label:Ge.label,description:Ge.description,stageId:void 0}));ie(_e)};return e.jsxs(e.Fragment,{children:[e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(hs,{className:"max-w-lg max-h-[85vh] flex flex-col",children:[e.jsx(js,{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(ls,{value:"general",children:"General"}),e.jsx(ls,{value:"timeline",children:"Timeline"}),e.jsx(ls,{value:"content",children:"Content"})]}),e.jsxs(ni,{className:"flex-1 mt-4",children:[e.jsxs(ws,{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(Mr,{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(K,{variant:"outline",size:"sm",onClick:()=>l(!0),className:"text-xs",children:"Manage"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(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(Mr,{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(Mr,{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(Mr,{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:ye,onLink:he})}),e.jsx("div",{children:e.jsx(Le,{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(Le,{type:"date",value:w,onChange:tt=>k(tt.target.value),className:"mt-1"})]})]}),e.jsx(ws,{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(K,{variant:"outline",size:"sm",onClick:et,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.'}),ae.length===0&&e.jsxs("div",{className:"border border-dashed rounded-lg p-4 text-center",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"No custom mapping — using default client-friendly journey stages"}),e.jsx(K,{variant:"outline",size:"sm",onClick:et,children:"Customize journey labels"})]}),e.jsx("div",{className:"space-y-2 mt-2",children:ae.map((tt,_e)=>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(Le,{value:tt.label,onChange:Ge=>He(_e,"label",Ge.target.value),placeholder:`Stage ${_e+1} label`,className:"flex-1 h-9 text-sm"}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-9 px-2 text-xs text-muted-foreground hover:text-primary",onClick:()=>me(oe===_e?null:_e),children:oe===_e?"Less":"More"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-9 w-9 text-muted-foreground hover:text-destructive",onClick:()=>fe(_e),children:e.jsx(xr,{className:"h-3.5 w-3.5"})})]}),oe===_e&&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:Ge=>He(_e,"description",Ge.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(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-destructive hover:text-destructive",onClick:()=>He(_e,"video_url",""),children:"Remove"})]}):e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx($Ce,{onVideoReady:Ge=>He(_e,"video_url",Ge)}),e.jsx(BCe,{userId:n,onSelect:Ge=>He(_e,"video_url",Ge),triggerSize:"sm",triggerClassName:"gap-1.5 shrink-0 flex-1"}),e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1 text-xs text-muted-foreground flex-1",onClick:()=>{const Ge=prompt("Paste a YouTube or Loom URL:");Ge&&He(_e,"video_url",Ge)},children:[e.jsx(go,{className:"h-3 w-3"}),"Paste URL"]})]})]})]})]},_e))}),ae.length>0&&e.jsxs(K,{variant:"outline",size:"sm",onClick:ut,className:"mt-2 text-xs w-full",children:[e.jsx(Bs,{className:"h-3 w-3 mr-1"})," Add Stage"]})]})}),e.jsxs(ws,{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(Le,{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(Le,{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(Mr,{checked:ge,onCheckedChange:Ne})]}),ge&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(xe,{className:"text-sm font-medium",children:"Headline"}),e.jsx(Le,{value:Me,onChange:tt=>De(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(Le,{value:Ue,onChange:tt=>Te(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(Le,{value:qe,onChange:tt=>ke(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(K,{variant:"ghost",onClick:Be,children:"Reset Draft"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Close"}),e.jsxs(K,{onClick:we,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 Clt({open:t,onOpenChange:s,portalId:r,portalSlug:n,notifyClient:a}){const o=S.useMemo(()=>ZNs(r),[r]),[l,i]=S.useState(""),[d,u]=S.useState(""),[p,f]=S.useState(""),[y,_]=S.useState(!1),[b,N]=S.useState(a??!1),[w,k]=S.useState(!1),C=ait();S.useEffect(()=>{k(!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),k(!0);return}catch{localStorage.removeItem(o)}i(""),u(""),f(""),_(!1),N(a??!1),k(!0)},[o,a]),S.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(hs,{className:"max-w-md",children:[e.jsx(js,{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(Le,{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(Le,{value:p,onChange:L=>f(L.target.value),className:"pl-9",placeholder:"YouTube or Loom link"}),e.jsx(gn,{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(K,{variant:"ghost",onClick:A,children:"Clear Draft"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Close"}),e.jsxs(K,{onClick:I,disabled:!l.trim()||C.isPending,children:[C.isPending?e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Mn,{className:"h-4 w-4 mr-2"}),"Post Update"]})]})]})]})})}function Mlt({open:t,onOpenChange:s,portal:r,dealName:n}){const a=_O(),{isGmailConnected:o,gmailEmail:l}=jp(),[i,d]=S.useState(r.client_name||""),[u,p]=S.useState(r.client_email||""),[f,y]=S.useState(!1),[_,b]=S.useState(!1),N=o1(r.slug),w=i.split(" ")[0]||"there",k=`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:k,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(k),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(hs,{className:"max-w-md",children:[e.jsx(js,{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(Le,{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(Le,{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(K,{variant:"outline",size:"icon",onClick:A,className:"shrink-0",children:_?e.jsx(Zn,{className:"h-4 w-4 text-emerald-600"}):e.jsx(Wa,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[o?e.jsxs(K,{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(K,{onClick:L,disabled:!u.trim(),className:"w-full",variant:"outline",children:[e.jsx(Zr,{className:"h-4 w-4 mr-2"}),"Open in Email App"]}),e.jsxs(K,{variant:"ghost",onClick:A,className:"w-full text-muted-foreground",children:[e.jsx(Wa,{className:"h-4 w-4 mr-2"}),"Just Copy Link"]})]})]})]})})}function YNs({deal:t}){const{isAdmin:s,user:r}=qs(),{data:n,isLoading:a}=Ubs(t.id),o=$Se(),l=_O(),[i,d]=S.useState(!1),[u,p]=S.useState(!1),[f,y]=S.useState(!1),[_,b]=S.useState(!1),N=`portal-management-ui:${t.id}`;if(S.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]),S.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)}},k=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(K,{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(Mr,{checked:n.is_enabled,onCheckedChange:k})]}),e.jsxs("div",{className:"space-y-1.5 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Visibility:"}),e.jsx(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(K,{variant:"outline",size:"sm",onClick:C,className:"text-xs flex-1 min-w-0",children:[e.jsx(Wa,{className:"h-3 w-3 mr-1 shrink-0"}),"Copy"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:A,className:"text-xs flex-1 min-w-0",children:[e.jsx(Zr,{className:"h-3 w-3 mr-1 shrink-0"}),"Preview"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>b(!0),className:"text-xs flex-1 min-w-0",children:[e.jsx(Mn,{className:"h-3 w-3 mr-1 shrink-0"}),"Invite"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>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(K,{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(yi,{className:"h-3 w-3"}),"View incoming referrals"]})]}),e.jsx(Slt,{open:u,onOpenChange:p,portal:n,dealOwnerId:L}),e.jsx(Clt,{open:f,onOpenChange:y,portalId:n.id,portalSlug:n.slug,notifyClient:n.notify_client}),e.jsx(Mlt,{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 Et({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 Et({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=vr(),{data:n,isLoading:a}=QNs(t),{data:o}=qh(),l=JNs(),i=eks(),[d,u]=S.useState(!1),[p,f]=S.useState(""),[y,_]=S.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("")},k=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(or,{className:"h-4 w-4"}),"Additional Contacts"]})}),e.jsxs(yo,{open:d,onOpenChange:u,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"w-full text-muted-foreground",children:[e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1"}),"Link a contact (lender, spouse, vendor...)"]})}),e.jsx(uo,{className:"w-80 p-3",align:"start",children:e.jsx(o9e,{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(or,{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(yo,{open:d,onOpenChange:u,children:[e.jsx(vo,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 px-2",children:e.jsx(Bs,{className:"h-3.5 w-3.5"})})}),e.jsx(uo,{className:"w-80 p-3",align:"end",children:e.jsx(o9e,{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(wn,{className:"h-7 w-7",children:e.jsxs(jn,{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(K,{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(K,{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(K,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>k(A.id),children:e.jsx(xr,{className:"h-3 w-3"})})]})]},A.id)})})]})}function o9e({search:t,setSearch:s,selectedRole:r,setSelectedRole:n,filteredContacts:a,onAdd:o}){return e.jsxs("div",{className:"space-y-3",children:[e.jsxs(Fs,{value:r,onValueChange:n,children:[e.jsx(Ds,{className:"h-8 text-sm",children:e.jsx(zs,{placeholder:"Role"})}),e.jsx(Rs,{children:XNs.map(l=>e.jsx(vt,{value:l,children:l},l))})]}),e.jsxs("div",{className:"relative",children:[e.jsx(an,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Le,{value:t,onChange:l=>s(l.target.value),placeholder:"Search contacts...",className:"pl-7 h-8 text-sm",autoFocus:!0})]}),e.jsx(ni,{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:Si,call:In,email:tr,meeting:ln,stage_change:Zr,task_completed:Hn,document:Sn,system:on};function nks({deal:t,open:s,onOpenChange:r,onEdit:n,onAddToScorecard:a,isWonStage:o}){var De,qe;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(),k=UNs(),C=VNs(),A=S.useRef(null),[I,L]=S.useState(""),[O,V]=S.useState(""),[q,B]=S.useState(!1),[U,te]=S.useState(!1);if(!t)return null;const Y=sks[t.deal_type],J=(()=>{var Be;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const ke=((Be=t.listing)==null?void 0:Be.created_at)||t.listing_date;if(!ke)return null;const $e=t.contract_date?ol(t.contract_date):new Date;return $g($e,ol(ke))})(),X=ke=>ke?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(ke):"-",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")}},ae=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")}},ie=async(ke,$e)=>{try{await y.mutateAsync({id:ke,is_completed:$e,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(ke=>ke.is_completed).length)||0,ye=(d==null?void 0:d.length)||0,he=(b==null?void 0:b.length)||0,ge=ke=>ke<1024?`${ke} B`:ke<1024*1024?`${(ke/1024).toFixed(1)} KB`:`${(ke/(1024*1024)).toFixed(1)} MB`,Ne=ke=>ke?ke.startsWith("image/")?qo:ke.includes("pdf")?yn:kM:kM,Ue=async ke=>{const $e=ke.target.files;if(!(!$e||!t)){te(!0);try{for(const Be of Array.from($e)){if(Be.size>20*1024*1024){pe.error(`${Be.name} exceeds 20MB limit`);continue}await w.mutateAsync({dealId:t.id,file:Be})}pe.success("File(s) uploaded")}catch{pe.error("Failed to upload file")}finally{te(!1),A.current&&(A.current.value="")}}},Te=async(ke,$e)=>{if(t)try{await k.mutateAsync({fileId:ke,storagePath:$e,dealId:t.id}),pe.success("File deleted")}catch{pe.error("Failed to delete file")}},Me=async(ke,$e)=>{try{const Be=await HNs(ke),we=document.createElement("a");we.href=Be,we.download=$e,we.target="_blank",document.body.appendChild(we),we.click(),document.body.removeChild(we)}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:Dt("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(K,{variant:"outline",size:"icon",onClick:()=>n(t),children:e.jsx(Wc,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"icon",className:"text-destructive hover:bg-destructive/10",onClick:()=>B(!0),children:e.jsx(xr,{className:"h-4 w-4"})})]})]})}),e.jsx(ni,{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(wn,{className:"h-10 w-10",children:e.jsxs(jn,{className:"bg-primary/10 text-primary",children:[(De=t.contact.first_name)==null?void 0:De[0],(qe=t.contact.last_name)==null?void 0:qe[0]]})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"font-medium",children:[t.contact.first_name," ",t.contact.last_name]}),t.contact.email&&e.jsx("p",{className:"text-sm text-muted-foreground",children:t.contact.email})]}),e.jsxs("div",{className:"flex gap-2",children:[t.contact.phone&&e.jsx(K,{variant:"outline",size:"icon",asChild:!0,children:e.jsx("a",{href:`tel:${t.contact.phone}`,children:e.jsx(In,{className:"h-4 w-4"})})}),t.contact.email&&e.jsx(K,{variant:"outline",size:"icon",asChild:!0,children:e.jsx("a",{href:`mailto:${t.contact.email}`,children:e.jsx(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(Sn,{className:"h-4 w-4 text-muted-foreground mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:t.property_address||"Address TBD"}),e.jsx("p",{className:"text-muted-foreground",children:[t.city,t.state,t.zip_code].filter(Boolean).join(", ")})]})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Expected Price"}),e.jsx("p",{className:"text-lg font-bold",children:X(t.expected_price)})]}),e.jsxs("div",{className:"bg-emerald-500/10 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Expected GCI"}),e.jsx("p",{className:"text-lg font-bold text-emerald-600",children:X(t.expected_commission)})]}),(t.brokerage_split_pct||t.team_split_pct||t.referral_fee_pct||t.franchise_fee_pct||t.transaction_fee)&&e.jsxs("div",{className:"col-span-2 bg-muted/30 rounded-lg p-3 space-y-1.5",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-2",children:"Commission Splits"}),t.brokerage_split_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Brokerage Split"}),e.jsxs("span",{children:[t.brokerage_split_pct,"%",t.expected_commission?` (${X(t.expected_commission*t.brokerage_split_pct/100)})`:""]})]}),t.team_split_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Team Split"}),e.jsxs("span",{children:[t.team_split_pct,"%"]})]}),t.referral_fee_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Referral Fee"}),e.jsxs("span",{children:[t.referral_fee_pct,"%"]})]}),t.franchise_fee_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Franchise Fee"}),e.jsxs("span",{children:[t.franchise_fee_pct,"%"]})]}),t.transaction_fee!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Transaction Fee"}),e.jsx("span",{children:X(t.transaction_fee)})]}),t.net_commission!=null&&e.jsx(e.Fragment,{children:e.jsx("div",{className:"border-t pt-1.5 mt-1.5",children:e.jsxs("div",{className:"flex justify-between text-sm font-semibold",children:[e.jsx("span",{children:"Net to Agent"}),e.jsx("span",{className:"text-emerald-600",children:X(t.net_commission)})]})})})]}),o&&!t.scorecard_transaction_id&&a&&e.jsxs(K,{onClick:()=>a(t),className:"w-full bg-green-600 hover:bg-green-700",children:[e.jsx(Vi,{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(Hn,{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:Dt("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(ln,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Close: ",gs(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(ls,{value:"tasks",className:"gap-1",children:[e.jsx(Hn,{className:"h-4 w-4"}),"Tasks ",ye>0&&`(${me}/${ye})`]}),e.jsxs(ls,{value:"files",className:"gap-1",children:[e.jsx(mS,{className:"h-4 w-4"}),"Files ",he>0&&`(${he})`]}),e.jsxs(ls,{value:"activity",className:"gap-1",children:[e.jsx(on,{className:"h-4 w-4"}),"Activity"]})]}),e.jsxs(ws,{value:"tasks",className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{placeholder:"Add a new task...",value:O,onChange:ke=>V(ke.target.value),onKeyDown:ke=>ke.key==="Enter"&&ae()}),e.jsx(K,{onClick:ae,disabled:!O.trim(),children:e.jsx(Bs,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-2",children:[d==null?void 0:d.map(ke=>e.jsxs("div",{className:Dt("flex items-center gap-3 p-3 rounded-lg border transition-colors",ke.is_completed?"bg-muted/50 border-border":"bg-background"),children:[e.jsx(Hi,{checked:ke.is_completed,onCheckedChange:$e=>ie(ke.id,!!$e)}),e.jsx("span",{className:Dt("flex-1 text-sm",ke.is_completed&&"line-through text-muted-foreground"),children:ke.title}),ke.due_date&&e.jsx("span",{className:"text-xs text-muted-foreground",children:gs(new Date(ke.due_date),"MMM d")})]},ke.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(ws,{value:"files",className:"mt-4 space-y-3",children:[e.jsx("input",{type:"file",ref:A,className:"hidden",multiple:!0,onChange:Ue,accept:".pdf,.doc,.docx,.xls,.xlsx,.jpg,.jpeg,.png,.webp,.gif,.txt,.csv"}),e.jsxs(K,{variant:"outline",className:"w-full border-dashed",onClick:()=>{var ke;return(ke=A.current)==null?void 0:ke.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(ke=>{const $e=Ne(ke.file_type);return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-background",children:[e.jsx("div",{className:"w-8 h-8 rounded bg-muted flex items-center justify-center shrink-0",children:e.jsx($e,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:ke.file_name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ge(ke.file_size)," · ",gs(new Date(ke.created_at),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(S1,{children:e.jsxs(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:`h-8 w-8 transition-colors ${ke.visible_on_portal?"text-primary bg-primary/10 hover:bg-primary/20":"text-muted-foreground/40 hover:text-muted-foreground"}`,onClick:()=>C.mutate({fileId:ke.id,visible:!ke.visible_on_portal,dealId:t.id}),children:ke.visible_on_portal?e.jsx(Cn,{className:"h-4 w-4"}):e.jsx(mp,{className:"h-4 w-4"})})}),e.jsx(Ll,{side:"top",children:ke.visible_on_portal?"Visible on client portal":"Hidden from client portal"})]})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Me(ke.storage_path,ke.file_name),children:e.jsx(Qa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>Te(ke.id,ke.storage_path),children:e.jsx(jr,{className:"h-4 w-4"})})]})]},ke.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(ws,{value:"activity",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(gr,{placeholder:"Add a note...",value:I,onChange:ke=>L(ke.target.value),rows:2}),e.jsxs(K,{onClick:ce,disabled:!I.trim(),size:"sm",className:"w-full",children:[e.jsx(Mn,{className:"h-4 w-4 mr-2"}),"Add Note"]})]}),e.jsxs("div",{className:"space-y-3",children:[l==null?void 0:l.map(ke=>{const $e=rks[ke.activity_type]||on;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($e,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:ke.title}),ke.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:ke.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:Nl(new Date(ke.created_at),{addSuffix:!0})})]})]},ke.id)}),(l==null?void 0:l.length)===0&&e.jsx("p",{className:"text-center text-muted-foreground text-sm py-4",children:"No activity yet"})]})]})]})]})})]})}),e.jsx(Dl,{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=ahe(),o=yit(),{data:l}=JA(),{data:i}=Nf(),[d,u]=S.useState({property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:gs(new Date,"yyyy-MM-dd"),sale_price:0,commission_amount:0,lead_source_id:"",client_type_id:"",notes:""});S.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||gs(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(hs,{className:"sm:max-w-[550px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(js,{className:"space-y-3",children:[e.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-green-100 dark:bg-green-900/20",children:e.jsx(Vi,{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(Sn,{className:"h-4 w-4 text-muted-foreground"}),"Property Address *"]}),e.jsx(Le,{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(Le,{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(Le,{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(Le,{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(Fs,{value:d.transaction_type,onValueChange:y=>u(_=>({..._,transaction_type:y})),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsxs(Rs,{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(ln,{className:"h-4 w-4 text-muted-foreground"}),"Close Date *"]}),e.jsx(Le,{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(Le,{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(Le,{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(Fs,{value:d.lead_source_id,onValueChange:y=>u(_=>({..._,lead_source_id:y})),children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select source"})}),e.jsx(Rs,{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(Fs,{value:d.client_type_id,onValueChange:y=>u(_=>({..._,client_type_id:y})),children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select type"})}),e.jsx(Rs,{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(gr,{id:"notes",value:d.notes,onChange:y=>u(_=>({..._,notes:y.target.value})),placeholder:"Any additional notes about this transaction...",rows:2})]}),e.jsxs(_n,{className:"gap-2 sm:gap-0 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Skip for now"}),e.jsx(K,{type:"submit",disabled:a.isPending||o.isPending,className:"bg-green-600 hover:bg-green-700",children:a.isPending?"Adding...":e.jsxs(e.Fragment,{children:["Add to Scorecard",e.jsx(Ga,{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"}},l9e={urgent:0,high:1,medium:2,low:3};function oks({deals:t,stages:s,onDealClick:r,onStageChange:n}){const[a,o]=S.useState("target_close_date"),[l,i]=S.useState("asc"),d=_=>{a===_?i(b=>b==="asc"?"desc":"asc"):(o(_),i("asc"))},u=S.useMemo(()=>[...t].sort((_,b)=>{var w,k;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=((k=s.find(I=>I.id===b.stage_id))==null?void 0:k.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=l9e[_.priority]-l9e[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(K,{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(Ms,{className:"bg-muted/50",children:[e.jsx(kt,{className:"w-[250px]",children:e.jsx(y,{field:"deal_name",children:"Deal Name"})}),e.jsx(kt,{className:"w-[150px]",children:e.jsx(y,{field:"stage",children:"Stage"})}),e.jsx(kt,{className:"w-[100px]",children:"Type"}),e.jsx(kt,{className:"w-[120px]",children:e.jsx(y,{field:"expected_price",children:"Price"})}),e.jsx(kt,{className:"w-[120px]",children:e.jsx(y,{field:"expected_commission",children:"GCI"})}),e.jsx(kt,{className:"w-[130px]",children:e.jsx(y,{field:"target_close_date",children:"Close Date"})}),e.jsx(kt,{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,k=N!==null&&N<=7&&N>=0;return e.jsxs(Ms,{className:Dt("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(Nlt,{stages:s,currentStageId:_.stage_id||"",onStageSelect:(C,A)=>n(_.id,C,A)})}),e.jsx(ht,{children:e.jsx(Qe,{variant:"outline",className:Dt("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:Dt("flex items-center gap-1 text-sm",w&&"text-red-600",k&&!w&&"text-amber-600"),children:[w&&e.jsx(ro,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:gs(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:Dt("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 Et({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 Et({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 Et({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 qCe(){const t=Qt();return Et({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 Et({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 Et({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 Et({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 Et({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,_]=S.useState(new Set),[b,N]=S.useState(!1),w=(d||[]).filter(I=>I.status!=="done");S.useEffect(()=>{w.length>0&&_(new Set(w.map(I=>I.id)))},[d]);const k=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(hs,{className:"sm:max-w-[480px]",children:[e.jsxs(js,{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(Ga,{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(ni,{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(Hi,{checked:y.has(I.id),onCheckedChange:()=>k(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(K,{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(K,{variant:"outline",size:"sm",onClick:A,disabled:b,children:"Skip"}),e.jsxs(K,{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(Hn,{className:"h-8 w-8 text-emerald-500 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"All tasks completed! Ready to move."})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick: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=$Se(),u=_O(),p=Vbs(),f=Hbs(),[y,_]=S.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")}},k=()=>{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(K,{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(K,{variant:"ghost",size:"sm",onClick:()=>i(n),className:"text-xs gap-1 text-destructive hover:text-destructive",children:[e.jsx(xr,{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(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:k,title:"Copy link",children:e.jsx(Wa,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:C,title:"Preview",children:e.jsx(Zr,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(n,s),title:"Invite client",children:e.jsx(Mn,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>o(n),title:"Post update",children:e.jsx(IM,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>a(n),title:"Settings",children:e.jsx(So,{className:"h-3.5 w-3.5"})}),e.jsxs(Hd,{children:[e.jsx(Gd,{asChild:!0,children:e.jsx(K,{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(Mr,{checked:n.is_enabled,onCheckedChange:w,className:"ml-1"})]})]}):e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg border-dashed bg-muted/20",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r||"No contact"})]}),e.jsxs(K,{size:"sm",onClick: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}=Eme(),{data:r,isLoading:n}=_ks(),[a,o]=S.useState(""),[l,i]=S.useState("all"),d=Gbs(),[u,p]=S.useState(null),[f,y]=S.useState(null),[_,b]=S.useState(null),[N,w]=S.useState(null),k=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,ae,ie,oe,me;const te=A.get(U.id),Y=a.toLowerCase(),J=!Y||U.deal_name.toLowerCase().includes(Y)||((ae=(ce=U.contact)==null?void 0:ce.first_name)==null?void 0:ae.toLowerCase().includes(Y))||((oe=(ie=U.contact)==null?void 0:ie.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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search deals or clients...",value:a,onChange: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(jr,{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(K,{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(ni,{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(Slt,{open:!!u,onOpenChange:U=>!U&&p(null),portal:u,dealOwnerId:k||""}),f&&e.jsx(Clt,{open:!!f,onOpenChange:U=>!U&&y(null),portalId:f.id,portalSlug:f.slug,notifyClient:f.notify_client}),_&&e.jsx(Mlt,{open:!!_,onOpenChange:U=>!U&&b(null),portal:_.portal,dealName:_.dealName}),e.jsx(Dl,{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 S.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(Es,{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 Nr;const t=bE(),{data:s,isLoading:r}=Ame(),{data:n,isLoading:a,refetch:o}=Eme(),{data:l,isLoading:i}=Qws(),d=xit(),u=Hws(),[p,f]=S.useState("board"),[y,_]=S.useState(!1),[b,N]=S.useState(!1),[w,k]=S.useState(null),[C,A]=S.useState(null),[I,L]=S.useState(null),[O,V]=S.useState(null),[q,B]=S.useState(!1),[U,te]=S.useState(null),[Y,J]=S.useState(""),[X,ce]=S.useState("all"),[ae,ie]=S.useState("all"),{data:oe}=ENs(),[me,ye]=S.useState(!1),[he,ge]=S.useState(!1),[Ne,Ue]=S.useState(new Set),Te=S.useRef(!1),[Me,De]=S.useState(null),{data:qe}=Px(),{isTeamLeader:ke,teamMembers:$e}=TNs(),Be=S.useMemo(()=>Array.from(Ne),[Ne]),{data:we}=ANs(Be),ut=S.useMemo(()=>{const Xs=new Map;return $e.forEach(kr=>Xs.set(kr.id,{name:kr.name,avatar_url:kr.avatar_url,color:kr.color})),Xs},[$e]),fe=S.useCallback(Xs=>Xs.owner_user_id&&ut.get(Xs.owner_user_id)||null,[ut]),He=S.useCallback(Xs=>{Ue(kr=>{const fn=new Set(kr);return fn.has(Xs)?fn.delete(Xs):fn.add(Xs),fn})},[]);S.useEffect(()=>{!r&&s&&s.length===0&&d.mutate()},[r,s]);const[et,tt]=Nc(),_e=S.useRef(!1);S.useEffect(()=>{const Xs=et.get("deal");if(Xs&&n&&n.length>0&&!_e.current){const kr=n.find(fn=>fn.id===Xs);kr&&(_e.current=!0,k(kr),N(!0),et.delete("deal"),tt(et,{replace:!0}))}},[n,et]);const Ge=S.useMemo(()=>{if(!we||!s)return[];const Xs=new Map(s.map(kr=>[kr.name,kr.id]));return we.map(kr=>{const fn=kr._stage_name&&Xs.get(kr._stage_name)||null;return{...kr,stage_id:fn||kr.stage_id}})},[we,s]),We=S.useMemo(()=>[...n||[],...Ge],[n,Ge]);S.useEffect(()=>{if(Te.current||We.length===0)return;Te.current=!0;const Xs=sessionStorage.getItem(bI);if(Xs)try{const kr=JSON.parse(Xs);if(!kr.open||!kr.dealId)return;const fn=We.find(Yr=>Yr.id===kr.dealId);fn&&(k(fn),N(!0))}catch{sessionStorage.removeItem(bI)}},[We]),S.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 it=(oe==null?void 0:oe.byDeal)||{},Ve=(oe==null?void 0:oe.unique)||[],Xe=We.filter(Xs=>{var nr,lr,Fr,Wr,Nn,ai;const kr=Y.toLowerCase(),fn=it[Xs.id]||[],Yr=!kr||Xs.deal_name.toLowerCase().includes(kr)||((lr=(nr=Xs.contact)==null?void 0:nr.first_name)==null?void 0:lr.toLowerCase().includes(kr))||((Wr=(Fr=Xs.contact)==null?void 0:Fr.last_name)==null?void 0:Wr.toLowerCase().includes(kr))||((Nn=Xs.property_address)==null?void 0:Nn.toLowerCase().includes(kr))||((ai=Xs.city)==null?void 0:ai.toLowerCase().includes(kr))||fn.some(ns=>ns.toLowerCase().includes(kr)),$r=X==="all"||Xs.deal_type===X,Gr=ae==="all"||fn.includes(ae);return Yr&&$r&&Gr}),dt=S.useMemo(()=>{if(!s)return l||null;const Xs=new Set(s.filter(nr=>nr.is_won_stage).map(nr=>nr.id)),kr=new Set(s.filter(nr=>nr.is_lost_stage).map(nr=>nr.id)),fn=We.filter(nr=>nr.stage_id&&!Xs.has(nr.stage_id)&&!kr.has(nr.stage_id)),Yr=We.filter(nr=>nr.stage_id&&Xs.has(nr.stage_id)),$r=new Date().getFullYear(),Gr=Yr.filter(nr=>nr.actual_close_date?new Date(nr.actual_close_date).getFullYear()===$r:!0);return{totalDeals:We.length,activeDeals:fn.length,wonDeals:Yr.length,pipelineValue:fn.reduce((nr,lr)=>nr+(lr.expected_price||0),0),expectedCommission:fn.reduce((nr,lr)=>nr+(lr.expected_commission||0),0),expectedNetToAgent:fn.reduce((nr,lr)=>nr+(cx(lr)||0),0),wonValue:Yr.reduce((nr,lr)=>nr+(lr.expected_price||0),0),weightedGCI:fn.reduce((nr,lr)=>nr+(lr.expected_commission||0)*((lr.probability??50)/100),0),weightedNet:fn.reduce((nr,lr)=>nr+(cx(lr)||0)*((lr.probability??50)/100),0),ytdWonDeals:Gr.length,ytdWonGCI:Gr.reduce((nr,lr)=>nr+(lr.expected_commission||0),0),ytdWonNet:Gr.reduce((nr,lr)=>nr+(cx(lr)||0),0),projectedAnnualNet:Gr.reduce((nr,lr)=>nr+(cx(lr)||0),0)+fn.reduce((nr,lr)=>nr+(cx(lr)||0)*((lr.probability??50)/100),0)}},[We,s,l]),pt=Xs=>{k(Xs),N(!0)},Je=Xs=>{A(Xs||null),k(null),_(!0)},Ze=Xs=>{k(Xs),N(!1),_(!0)},Nt=Xs=>{N(Xs),Xs||sessionStorage.removeItem(bI)},Ot=(Xs,kr)=>{L(Xs)},Yt=(Xs,kr)=>{Xs.preventDefault(),Xs.dataTransfer.dropEffect="move",V(kr)},Ps=async(Xs,kr)=>{if(Xs.preventDefault(),V(null),!I)return;const fn=n==null?void 0:n.find(Gr=>Gr.id===I),Yr=s==null?void 0:s.find(Gr=>Gr.id===kr),$r=s==null?void 0:s.find(Gr=>Gr.id===(fn==null?void 0:fn.stage_id));if(!fn||!Yr||fn.stage_id===kr){L(null);return}De({dealId:I,dealName:fn.deal_name,fromStageName:($r==null?void 0:$r.name)||"Unknown",toStageName:Yr.name,toStageId:kr,isWonStage:Yr.is_won_stage,deal:fn}),L(null)},$s=async()=>{if(!Me)return;const{dealId:Xs,toStageId:kr,toStageName:fn,isWonStage:Yr,deal:$r}=Me;if(await u.mutateAsync({dealId:Xs,stageId:kr,stageName:fn}),pe.success(`Moved to ${fn}`),Yr&&!$r.scorecard_transaction_id){const Gr={...$r,stage_id:kr};te(Gr),B(!0)}},Zs=S.useCallback(async(Xs,kr,fn)=>{const Yr=n==null?void 0:n.find(nr=>nr.id===Xs),$r=s==null?void 0:s.find(nr=>nr.id===kr),Gr=s==null?void 0:s.find(nr=>nr.id===(Yr==null?void 0:Yr.stage_id));!Yr||!$r||Yr.stage_id===kr||De({dealId:Xs,dealName:Yr.deal_name,fromStageName:(Gr==null?void 0:Gr.name)||"Unknown",toStageName:fn,toStageId:kr,isWonStage:$r.is_won_stage,deal:Yr})},[n,s]),Dr=Xs=>Xe.filter(kr=>kr.stage_id===Xs),$t=r||a,Us=t?"list":p;return e.jsxs(Es,{children:[e.jsxs("div",{className:"flex flex-col h-[calc(100vh-4rem)]",children:[e.jsxs("div",{className:"shrink-0 p-4 md:p-6 pb-0 space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Deal Pipeline"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Track and manage your active deals"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>o(),className:"shrink-0",children:e.jsx(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(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsxs(K,{variant:p==="board"?"secondary":"ghost",size:"sm",onClick:()=>f("board"),className:"px-3 gap-1.5",children:[e.jsx(fp,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Board"})]})}),e.jsx(Ll,{children:"Kanban board view"})]}),e.jsxs(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsxs(K,{variant:p==="list"?"secondary":"ghost",size:"sm",onClick:()=>f("list"),className:"px-3 gap-1.5",children:[e.jsx(Dh,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"List"})]})}),e.jsx(Ll,{children:"Grouped list view"})]}),e.jsxs(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsxs(K,{variant:p==="table"?"secondary":"ghost",size:"sm",onClick:()=>f("table"),className:"px-3 gap-1.5",children:[e.jsx(RM,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Table"})]})}),e.jsx(Ll,{children:"Sortable table view"})]}),e.jsxs(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsxs(K,{variant:p==="portals"?"secondary":"ghost",size:"sm",onClick:()=>f("portals"),className:"px-3 gap-1.5",children:[e.jsx(Or,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Portals"})]})}),e.jsx(Ll,{children:"Client portal management"})]})]})}),qe&&!ke&&e.jsxs(K,{variant:"outline",onClick:()=>ye(!0),children:[e.jsx(or,{className:"h-4 w-4 mr-2"}),"Team"]}),e.jsxs(K,{onClick:()=>Je(),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Deal"]})]})]}),Us!=="portals"&&e.jsx(DNs,{stats:dt,isLoading:i}),Us!=="portals"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search deals, contacts, addresses, tags...",value:Y,onChange:Xs=>J(Xs.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(jr,{className:"h-4 w-4"})})]}),e.jsxs(Fs,{value:X,onValueChange:ce,children:[e.jsx(Ds,{className:"w-[140px]",children:e.jsx(zs,{placeholder:"All Types"})}),e.jsxs(Rs,{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(Fs,{value:ae,onValueChange:ie,children:[e.jsxs(Ds,{className:"w-[160px]",children:[e.jsx(mh,{className:"h-3.5 w-3.5 mr-1.5 text-muted-foreground"}),e.jsx(zs,{placeholder:"All Tags"})]}),e.jsxs(Rs,{className:"max-h-[300px]",children:[e.jsx(vt,{value:"all",children:"All Tags"}),Ve.length===0&&e.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No tags yet"}),Ve.map(Xs=>e.jsx(vt,{value:Xs,children:Xs},Xs))]})]}),ae!=="all"&&e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[e.jsx(mh,{className:"h-3 w-3"}),ae,e.jsx("button",{onClick:()=>ie("all"),className:"ml-1 hover:text-foreground","aria-label":"Clear tag filter",children:e.jsx(jr,{className:"h-3 w-3"})})]}),(Y||X!=="all"||ae!=="all")&&e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[Xe.length," of ",(n==null?void 0:n.length)||0," deals"]})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[ke&&!t&&$e.length>0&&e.jsx(MNs,{members:$e,enabledMembers:Ne,onToggleMember:He,isOpen:he,onToggleOpen:()=>ge(Xs=>!Xs)}),e.jsx("div",{className:"flex-1 min-w-0 min-h-0 p-4 md:p-6 pt-4",children:$t?e.jsx("div",{className:"flex gap-4 h-full",children:[1,2,3,4].map(Xs=>e.jsx("div",{className:"min-w-[280px] max-w-[320px] flex-shrink-0",children:e.jsx(ks,{className:"h-full rounded-xl"})},Xs))}):Us==="board"?e.jsxs(ni,{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(Xs=>e.jsx(LNs,{stage:Xs,deals:Dr(Xs.id),onDealClick:pt,onAddDeal:Je,onDragStart:Ot,onDragOver:Yt,onDrop:Ps,isDragOver:O===Xs.id,isWonStage:Xs.is_won_stage,getOwnerInfo:fe},Xs.id))}),e.jsx(Fue,{orientation:"horizontal"})]}):Us==="table"?e.jsx(ni,{className:"h-full",children:e.jsx(oks,{deals:Xe,stages:s||[],onDealClick:pt,onStageChange:Zs})}):Us==="portals"?e.jsx(wks,{}):e.jsx(ni,{className:"h-full",children:e.jsxs("div",{className:"space-y-6",children:[s==null?void 0:s.map(Xs=>{const kr=Dr(Xs.id);return kr.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:Xs.color}}),e.jsx("h3",{className:"font-semibold",children:Xs.name}),e.jsxs("span",{className:"text-muted-foreground text-sm",children:["(",kr.length,")"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:kr.map(fn=>e.jsx(klt,{deal:fn,onClick:()=>pt(fn),stages:s,onStageChange:Zs,showStagePicker:!0,isWonStage:Xs.is_won_stage,ownerInfo:fe(fn)},fn.id))})]},Xs.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(fp,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No deals yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Start tracking your opportunities by adding your first deal"}),e.jsxs(K,{onClick:()=>Je(),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Your First Deal"]})]}),((n==null?void 0:n.length)||0)>0&&Xe.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(an,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No matching deals"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Try adjusting your search or filters"}),e.jsx(K,{variant:"outline",onClick:()=>{J(""),ce("all")},children:"Clear Filters"})]})]})})})]})]}),e.jsx(zNs,{open:y,onOpenChange:_,deal:w,defaultStageId:C}),e.jsx(nks,{deal:w,open:b,onOpenChange:Nt,onEdit:Ze,isWonStage:w?(Nr=s==null?void 0:s.find(Xs=>Xs.id===w.stage_id))==null?void 0:Nr.is_won_stage:!1,onAddToScorecard:Xs=>{te(Xs),B(!0),N(!1)}}),e.jsx(aks,{open:q,onOpenChange:B,deal:U,onComplete:()=>{o(),te(null)}}),Me&&e.jsx(vks,{open:!!Me,onOpenChange:Xs=>{Xs||De(null)},dealId:Me.dealId,dealName:Me.dealName,fromStageName:Me.fromStageName,toStageName:Me.toStageName,toStageId:Me.toStageId,onConfirm:$s}),e.jsx(SNs,{open:me,onOpenChange:ye})]})}function kks(){return e.jsx(jks,{children:e.jsx(Nks,{})})}function Tlt({open:t,onOpenChange:s,editTask:r,defaultDealId:n,defaultStageId:a}){var J;const o=dks(),l=uks(),{data:i}=Eme(),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]=S.useState(""),[y,_]=S.useState(""),[b,N]=S.useState("none"),[w,k]=S.useState("none"),[C,A]=S.useState("medium"),[I,L]=S.useState("todo"),[O,V]=S.useState(),[q,B]=S.useState(!1),[U,te]=S.useState(!1);S.useEffect(()=>{r?(f(r.title),_(r.description||""),N(r.deal_id||"none"),k(r.contact_id||"none"),A(r.priority),L(r.status),V(r.due_date?xm(r.due_date):void 0)):(f(""),_(""),N(n||"none"),k("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?gs(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(hs,{className:"sm:max-w-[480px]",children:[e.jsx(js,{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(Le,{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(gr,{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(Fs,{value:C,onValueChange:X=>A(X),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Fs,{value:I,onValueChange:X=>L(X),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsxs(Rs,{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(yo,{children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Dt("w-full justify-start text-left font-normal",!O&&"text-muted-foreground"),children:[e.jsx(ln,{className:"mr-2 h-4 w-4"}),O?gs(O,"PPP"):"Pick a date"]})}),e.jsx(uo,{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(yo,{open:q,onOpenChange:B,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[e.jsxs("span",{className:"flex items-center gap-2 truncate",children:[e.jsx(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(uo,{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(lp,{value:"no-deal",onSelect:()=>{N("none"),B(!1)},children:[e.jsx(Zn,{className:Dt("mr-2 h-4 w-4",b==="none"?"opacity-100":"opacity-0")}),"No Deal"]}),i==null?void 0:i.map(X=>e.jsxs(lp,{value:X.deal_name,onSelect:()=>{N(X.id),B(!1)},children:[e.jsx(Zn,{className:Dt("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(yo,{open:U,onOpenChange:te,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[e.jsxs("span",{className:"flex items-center gap-2 truncate",children:[e.jsx(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(uo,{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(lp,{value:"no-contact",onSelect:()=>{k("none"),te(!1)},children:[e.jsx(Zn,{className:Dt("mr-2 h-4 w-4",w==="none"?"opacity-100":"opacity-0")}),"No Contact"]}),u==null?void 0:u.map(X=>e.jsxs(lp,{value:`${X.first_name} ${X.last_name}`,onSelect:()=>{k(X.id),te(!1)},children:[e.jsx(Zn,{className:Dt("mr-2 h-4 w-4",w===X.id?"opacity-100":"opacity-0")}),X.first_name," ",X.last_name]},X.id))]})]})]})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick: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=qCe(),r=hks(),n=vr(),[a,o]=S.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(Hn,{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(c9e,{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(c9e,{task:y,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:_=>n(`/mission-control/pipeline?deal=${_}`)},y.id))]},p)),a&&e.jsx(Tlt,{open:!!a,onOpenChange:()=>o(null),editTask:a})]})}function c9e({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:Dt("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(Hn,{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:Dt("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:Dt("text-[10px] shrink-0",d.color),children:[d.dot," ",d.label]}),t.due_date&&e.jsxs("span",{className:Dt("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(on,{className:"h-3 w-3"}),gs(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(xr,{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:sp,color:"border-t-blue-500"},{status:"done",label:"Done",icon:Hn,color:"border-t-emerald-500"}],Tks={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function Aks({tasks:t}){const s=qCe(),r=S.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:Dt("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:Dt("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:Dt("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:Dt("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(on,{className:"h-2.5 w-2.5"}),n?"Overdue — ":a?"Due today — ":"",gs(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 d9e={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function Pks({tasks:t}){const[s,r]=S.useState(new Date),n=qCe(),a=gc(s),o=tx(s),l=zh(a),i=Iue(o),d=E4t({start:l,end:i}),u=S.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=S.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(K,{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:gs(s,"MMMM yyyy")}),e.jsx(K,{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 _=gs(y,"yyyy-MM-dd"),b=u.get(_)||[],N=Due(y,s),w=iu(y);return e.jsxs("div",{className:Dt("border-r border-b min-h-[100px] p-1",!N&&"bg-muted/30",w&&"bg-primary/5"),children:[e.jsx("div",{className:Dt("text-xs font-medium mb-1 text-right px-1",!N&&"text-muted-foreground/40",w&&"text-primary font-bold"),children:gs(y,"d")}),e.jsxs("div",{className:"space-y-0.5",children:[b.slice(0,3).map(k=>e.jsxs("button",{onClick:()=>f(k),className:Dt("w-full text-left text-[10px] px-1 py-0.5 rounded truncate flex items-center gap-0.5 hover:bg-muted transition-colors",k.status==="done"?"text-muted-foreground line-through":"text-foreground"),children:[k.status==="done"?e.jsx(Hn,{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:[d9e[k.priority]," ",k.title]})]},k.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:Dt("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(Hn,{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:[d9e[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 k;const[n,a]=S.useState(((k=r[0])==null?void 0:k.id)||""),{data:o,isLoading:l}=pks(n||void 0),i=fks(),d=xks(),[u,p]=S.useState(""),[f,y]=S.useState("medium"),[_,b]=S.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(hs,{className:"sm:max-w-[560px]",children:[e.jsx(js,{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:Dt("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(ni,{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(xr,{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(Le,{placeholder:"Task title...",value:u,onChange:C=>p(C.target.value),className:"flex-1",onKeyDown:C=>C.key==="Enter"&&N()}),e.jsxs(Fs,{value:f,onValueChange:C=>y(C),children:[e.jsx(Ds,{className:"w-[100px]",children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Le,{type:"number",placeholder:"e.g., 7",value:_,onChange:C=>b(C.target.value)})]}),e.jsxs(K,{onClick:N,disabled:!u.trim()||i.isPending,children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"}),"Add"]})]})]})]})})}function Dks(){const{data:t,isLoading:s}=lks(),{data:r}=Ame(),[n,a]=S.useState("list"),[o,l]=S.useState(""),[i,d]=S.useState("active"),[u,p]=S.useState("all"),[f,y]=S.useState("all"),[_,b]=S.useState(!1),[N,w]=S.useState(!1),k=S.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=S.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=S.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&&CCt(xm(L.due_date))).length,completed:t.filter(L=>L.status==="done").length}},[t]);return e.jsx(Es,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-6 max-w-[1600px] mx-auto",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Manage tasks across deals and contacts"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>w(!0),children:[e.jsx(Eg,{className:"h-4 w-4 mr-1"}),"Templates"]}),e.jsxs(K,{size:"sm",onClick:()=>b(!0),children:[e.jsx(Bs,{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(on,{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(yd,{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(Hn,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search tasks...",value:o,onChange:I=>l(I.target.value),className:"pl-9"})]}),e.jsxs(Fs,{value:u,onValueChange:p,children:[e.jsx(Ds,{className:"w-[130px]",children:e.jsx(zs,{placeholder:"Priority"})}),e.jsxs(Rs,{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(Fs,{value:f,onValueChange:y,children:[e.jsx(Ds,{className:"w-[160px]",children:e.jsx(zs,{placeholder:"Deal"})}),e.jsxs(Rs,{children:[e.jsx(vt,{value:"all",children:"All Deals"}),e.jsx(vt,{value:"no_deal",children:"No Deal"}),k.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(yd,{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(Tlt,{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 Et({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 Et({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)),_0e=[{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]=S.useState("all"),[l,i]=S.useState({}),d=S.useMemo(()=>a==="all"?t:t.filter(_=>_.status===a),[t,a]),u=S.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,...k}=N;return k}),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(nc,{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(yi,{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"},..._0e.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(Re,{className:"py-12 text-center",children:[e.jsx(yi,{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 k,C;const b=_0e.find(A=>A.value===_.status),N=(k=_.client_portals)==null?void 0:k.slug,w=_.referrer_name||((C=_.client_portals)==null?void 0:C.client_name)||"Anonymous client";return e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between flex-wrap gap-2",children:[e.jsxs("div",{children:[e.jsx(Ft,{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(ln,{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(Fs,{value:_.status,onValueChange:A=>p(_,A),children:[e.jsx(Ds,{className:"h-8 w-[130px] text-xs",children:e.jsx(zs,{})}),e.jsx(Rs,{children:_0e.map(A=>e.jsx(vt,{value:A.value,className:"text-xs",children:A.label},A.value))})]})]})]})}),e.jsxs(Re,{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(Ol,{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(gr,{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(K,{size:"sm",onClick:()=>f(_),children:"Save"}),e.jsx(K,{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(Zr,{className:"h-3 w-3"}),"View source portal"]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>y(_),className:"text-destructive hover:text-destructive ml-auto h-8",children:e.jsx(xr,{className:"h-3.5 w-3.5"})})]})]})]},_.id)})})]})}const Xwe=[{value:"video_intro",label:"Video Intro",icon:gn,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:_d,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 Alt({cardId:t}){const{data:s,isLoading:r}=Nkt(t),n=kkt(),a=Skt(),o=Ckt(),[l,i]=S.useState(!1),[d,u]=S.useState(""),[p,f]=S.useState(null);if(r)return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ks,{className:"h-16 w-full"}),e.jsx(ks,{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)})},k=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(K,{size:"sm",onClick:()=>i(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"})," Add Block"]})]}):e.jsxs(e.Fragment,{children:[s.map((C,A)=>{const I=k(C.block_type),L=(I==null?void 0:I.icon)||mh;return e.jsx(Pe,{className:C.is_visible?"":"opacity-50",children:e.jsx(Re,{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(K,{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(K,{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(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>_(C),children:C.is_visible?e.jsx(Cn,{className:"h-3 w-3"}):e.jsx(mp,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>f(C),children:"Edit"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:()=>N(C),children:e.jsx(xr,{className:"h-3 w-3"})})]})]})})},C.id)}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>i(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"})," Add Block"]})]}),e.jsx(fs,{open:l,onOpenChange:i,children:e.jsxs(hs,{children:[e.jsx(js,{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(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{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]=S.useState(t.config),o=Xwe.find(l=>l.value===t.block_type);return e.jsx(fs,{open:!0,onOpenChange:r,children:e.jsxs(hs,{className:"max-w-lg max-h-[80vh] overflow-y-auto",children:[e.jsx(js,{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(_n,{children:[e.jsx(K,{variant:"outline",onClick:r,children:"Cancel"}),e.jsx(K,{onClick:()=>s(n),children:"Save"})]})]})})}function Gks({config:t,onChange:s,cardId:r}){var _,b;const[n,a]=S.useState(""),[o,l]=S.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(ls,{value:"library",className:"flex-1",children:"Video Library"}),e.jsx(ls,{value:"youtube",className:"flex-1",children:"YouTube URL"})]}),e.jsxs(ws,{value:"library",className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search videos...",value:n,onChange:N=>a(N.target.value),className:"pl-9"})]}),e.jsx(ni,{className:"h-[240px]",children:u?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ks,{className:"h-14 w-full"}),e.jsx(ks,{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 k;w.currentTarget.style.display="none",(k=w.currentTarget.nextElementSibling)==null||k.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(gn,{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(ws,{value:"youtube",className:"space-y-3 mt-3",children:e.jsxs("div",{children:[e.jsx(xe,{children:"YouTube URL"}),e.jsx(Le,{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(Re,{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(K,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>o(i),children:e.jsx(xr,{className:"h-3 w-3"})})]}),e.jsx(Le,{placeholder:"Client name",value:l.name,onChange:d=>n(i,"name",d.target.value)}),e.jsx(Le,{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(K,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"})," Add Testimonial"]})]})}function Kks({config:t,onChange:s}){const r=t.tags||[],[n,a]=S.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(Le,{placeholder:"Add your own...",value:n,onChange:i=>a(i.target.value),onKeyDown:i=>i.key==="Enter"&&(i.preventDefault(),l())}),e.jsx(K,{variant:"outline",size:"sm",onClick:l,children:"Add"})]})]}),r.length>0&&e.jsxs("div",{children:[e.jsxs(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(Le,{placeholder:"Button label",value:l.label,onChange:d=>n(i,"label",d.target.value)}),e.jsx(Le,{placeholder:"https://...",value:l.url,onChange:d=>n(i,"url",d.target.value)})]}),r.length>1&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 mt-1 text-destructive",onClick:()=>o(i),children:e.jsx(xr,{className:"h-3 w-3"})})]},i)),e.jsxs(K,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"})," Add Link"]})]})}const u9e=[{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=u9e.filter(d=>!r.find(u=>u.platform===d.value)),i=d=>{const u=b1e[d],p=u9e.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(Le,{placeholder:`Your ${p.label} profile URL`,value:d.url,onChange:f=>a(u,f.target.value)})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive flex-shrink-0",onClick:()=>o(u),children:e.jsx(xr,{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,Tde=Object.getOwnPropertySymbols,Elt=Object.prototype.hasOwnProperty,Plt=Object.prototype.propertyIsEnumerable,h9e=(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={}))Elt.call(s,r)&&h9e(t,r,s[r]);if(Tde)for(var r of Tde(s))Plt.call(s,r)&&h9e(t,r,s[r]);return t},Jwe=(t,s)=>{var r={};for(var n in t)Elt.call(t,n)&&s.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&Tde)for(var n of Tde(t))s.indexOf(n)<0&&Plt.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 qi{constructor(d,u,p,f){if(this.version=d,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],dqi.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=qi.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[qi.Ecc.MEDIUM,qi.Ecc.QUARTILE,qi.Ecc.HIGH])_&&N<=qi.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 k=qi.getNumDataCodewords(b,u)*8;a(w.length<=k),r(0,Math.min(4,k-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 qi(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(qi.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)*qi.PENALTY_N3),_=this.modules[y][w],b=1);d+=this.finderPenaltyTerminateAndCount(_,b,N)*qi.PENALTY_N3}for(let y=0;y5&&d++):(this.finderPenaltyAddHistory(b,N),_||(d+=this.finderPenaltyCountPatterns(N)*qi.PENALTY_N3),_=this.modules[w][y],b=1);d+=this.finderPenaltyTerminateAndCount(_,b,N)*qi.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*qi.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.lengthqi.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(qi.getNumRawDataModules(d)/8)-qi.ECC_CODEWORDS_PER_BLOCK[u.ordinal][d]*qi.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]^=qi.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},Ilt=128,Llt="L",Dlt="#FFFFFF",Rlt="#000000",Olt=!1,Flt=1,Jks=4,e4s=0,t4s=.1;function zlt(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 Blt(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),k=Math.ceil(d+p-N);y={x:b,y:N,w,h:k}}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 $lt({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=Ilt,level:l=Llt,bgColor:i=Dlt,fgColor:d=Rlt,includeMargin:u=Olt,minVersion:p=Flt,boostLevel:f,marginSize:y,imageSettings:_}=n,N=Jwe(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:w}=N,k=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}=$lt({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 ae=B;const ie=I.current,oe=te!=null&&ie!==null&&ie.complete&&ie.naturalHeight!==0&&ie.naturalWidth!==0;oe&&te.excavation!=null&&(ae=Blt(B,te.excavation));const me=window.devicePixelRatio||1;X.height=X.width=o*me;const ye=o/U*me;ce.scale(ye,ye),ce.fillStyle=i,ce.fillRect(0,0,U,U),ce.fillStyle=d,n4s?ce.fill(new Path2D(zlt(ae,q))):B.forEach(function(he,ge){he.forEach(function(Ne,Ue){Ne&&ce.fillRect(Ue+q,ge+q,1,1)})}),te&&(ce.globalAlpha=te.opacity),oe&&ce.drawImage(ie,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"},k)),J)});a4s.displayName="QRCodeCanvas";var AO=xt.forwardRef(function(s,r){const n=s,{value:a,size:o=Ilt,level:l=Llt,bgColor:i=Dlt,fgColor:d=Rlt,includeMargin:u=Olt,minVersion:p=Flt,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:k,numCells:C,calculatedImageSettings:A}=$lt({value:a,level:l,minVersion:p,boostLevel:f,includeMargin:u,marginSize:_,imageSettings:b,size:o});let I=k,L=null;b!=null&&A!=null&&(A.excavation!=null&&(I=Blt(k,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=zlt(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)});AO.displayName="QRCodeSVG";function i4s({slug:t,agentName:s}){const r=S.useRef(null),n=`https://cards.relevelup.com/${t}`,a=S.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(AO,{value:n,size:120,level:"H",bgColor:"#ffffff",fgColor:"#000000"})}),e.jsxs("div",{className:"space-y-2 min-w-0",children:[e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"Download this QR code to use on business cards, flyers, signs, or any print materials. Scanning it opens your digital card instantly."}),e.jsxs(K,{variant:"outline",size:"sm",onClick:a,className:"gap-1.5",children:[e.jsx(Qa,{className:"h-3.5 w-3.5"}),"Download PNG"]})]})]})]})}function b0e(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}=qs(),{data:s,isLoading:r}=bkt(t==null?void 0:t.id),n=bE(),[a,o]=S.useState(null),l=S.useMemo(()=>a||(s?b0e(s):null),[a,s]);if(r)return e.jsx(Es,{children:e.jsxs("div",{className:"max-w-2xl mx-auto p-4 space-y-4",children:[e.jsx(ks,{className:"h-8 w-48"}),e.jsx(ks,{className:"h-32 w-full"}),e.jsx(ks,{className:"h-32 w-full"})]})});if(!s)return e.jsx(Es,{children:e.jsx(c4s,{userId:t==null?void 0:t.id})});const i=l||b0e(s),d=u=>{o(p=>{const f=p||b0e(s);return typeof u=="function"?u(f):u})};return e.jsx(Es,{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=S.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]=S.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:Fl,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(Lt,{className:"text-center pb-2",children:[e.jsx(Ft,{className:"text-xl",children:"Set Up Your Card"}),e.jsx(ur,{children:"Choose a URL slug — this is the link you'll share with clients"})]}),e.jsxs(Re,{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(Le,{value:s||o,onChange:u=>r(u.target.value),placeholder:"your-name",className:"rounded-l-none"})]})]}),e.jsxs(K,{onClick:l,disabled:n.isPending,className:"w-full h-11 text-base font-semibold",size:"lg",children:[e.jsx(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(K,{variant:"outline",size:"sm",onClick:n,className:"gap-1.5",children:[e.jsx(Wa,{className:"h-3.5 w-3.5"})," Copy Link"]}),e.jsx(K,{size:"sm",asChild:!0,className:"gap-1.5",children:e.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Zr,{className:"h-3.5 w-3.5"})," Preview"]})})]})]})})}function u4s({userId:t}){const s=Qt(),r=S.useRef(null),[n,a]=S.useState(!1),[o,l]=S.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]=S.useState(null),[f,y]=S.useState(null),[_,b]=S.useState(null),[N,w]=S.useState(!1),k=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=Et({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(ie=>`${t}/${ie.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),ae=ce.publicUrl+"?t="+Date.now();await G.from("profiles").update({avatar_url:ae}).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(ks,{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(Re,{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(wn,{className:"h-16 w-16 ring-2 ring-muted",children:[e.jsx(Ma,{src:I||void 0,alt:k}),e.jsx(jn,{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(Le,{value:k,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(Le,{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(Le,{value:A,onChange:te=>b(te.target.value),placeholder:"you@example.com",className:"h-10",type:"email"})]})]})]}),e.jsx(K,{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]=S.useState(null),[o,l]=S.useState(t.brokerage_logo_url?"logo":"name"),[i,d]=S.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 k=N.name.split(".").pop()||"png",A=`${r}/${b==="brokerage_logo_url"?"brokerage-logo":"team-logo"}.${k}`,{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(Re,{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(K,{type:"button",variant:o==="name"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>u("name"),children:"Use Name"}),e.jsx(K,{type:"button",variant:o==="logo"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>u("logo"),children:"Use Logo"})]}),o==="name"?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs font-medium text-muted-foreground",children:"Brokerage Name"}),e.jsx(Le,{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(K,{type:"button",variant:i==="name"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>p("name"),children:"Use Name"}),e.jsx(K,{type:"button",variant:i==="logo"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>p("logo"),children:"Use Logo"})]}),i==="name"?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs font-medium text-muted-foreground",children:"Team Name"}),e.jsx(Le,{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(Fl,{className:"h-4 w-4"})," Brand Colors"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Customize colors to match your brand"})]}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-xs h-7",onClick:o,children:"Reset to Default"})]}),e.jsx("div",{className:"grid gap-3",children:l.map(({key:i,label: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(Le,{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]=S.useState(t.slug),[d,u]=S.useState(!1),[p,f]=S.useState("idle"),y=S.useRef(JSON.stringify(s)),_=S.useRef(null);S.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:k}=await G.from("agent_cards").select("id").eq("slug",w).neq("id",t.id).maybeSingle();if(k){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(ls,{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(ls,{value:"sections",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Cn,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Sections"]}),e.jsxs(ls,{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(ls,{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(ls,{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(ws,{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(Re,{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(Mr,{checked:s.is_published,onCheckedChange:w=>r(k=>({...k,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(Le,{value:l,onChange:w=>i(w.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"your-name",className:"rounded-l-none h-10"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick: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(Le,{value:s.display_email,onChange:w=>r(k=>({...k,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(Fs,{value:s.theme,onValueChange:w=>r(k=>({...k,theme:w})),children:[e.jsx(Ds,{className:"h-11",children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Le,{value:s.title,onChange:w=>r(k=>({...k,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(Le,{value:s.positioning_statement,onChange:w=>r(k=>({...k,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(gr,{value:s.bio,onChange:w=>r(k=>({...k,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(Le,{value:s.review_snippet,onChange:w=>r(k=>({...k,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(Le,{value:s.review_source_url,onChange:w=>r(k=>({...k,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(Le,{value:s.booking_url,onChange:w=>r(k=>({...k,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(Le,{value:s.custom_cta_label,onChange:w=>r(k=>({...k,custom_cta_label:w.target.value})),placeholder:"Book a Call",className:"h-11"})]})]})})]}),e.jsx(ws,{value:"sections",className:"mt-4",children:e.jsx(Pe,{children:e.jsx(Re,{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:k,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:k}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C})]}),e.jsx(Mr,{checked:s[w],onCheckedChange:A=>r(I=>({...I,[w]:A}))})]},w))})})}),e.jsx(ws,{value:"blocks",className:"mt-4",children:e.jsx(Alt,{cardId:t.id})}),e.jsx(ws,{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:Cn,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(Re,{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(Lt,{className:"pb-3",children:e.jsx(Ft,{className:"text-base",children:"Recent Leads"})}),e.jsx(Re,{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(Re,{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(ws,{value:"qrcode",className:"mt-4 space-y-4",children:e.jsx(Pe,{children:e.jsx(Re,{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]=S.useState(""),[n,a]=S.useState(!1),[o,l]=S.useState(!1),[i,d]=S.useState(null),[u,p]=S.useState(!1),[f,y]=S.useState(!1),[_,b]=S.useState(null),[N,w]=S.useState(null),[k,C]=S.useState(0),[A,I]=S.useState(""),[L,O]=S.useState(!1),{data:V,isLoading:q}=gt({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:me,error:ye}=await G.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(ye)throw ye;return me}}),B=Et({mutationFn:async me=>{const{data:ye,error:he}=await G.functions.invoke("boldtrail-sync",{body:{action:"save_token",api_token:me}});if(he)throw he;if(ye!=null&&ye.error)throw new Error(ye.error);return ye},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),r(""),pe.success("BoldTrail connected successfully!")},onError:me=>{pe.error(me.message||"Failed to connect BoldTrail")}}),U=Et({mutationFn:async()=>{const{data:me,error:ye}=await G.functions.invoke("boldtrail-sync",{body:{action:"disconnect"}});if(ye)throw ye;return me},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),pe.success("BoldTrail disconnected")},onError:()=>pe.error("Failed to disconnect")}),te=Et({mutationFn:async me=>{const{data:ye,error:he}=await G.functions.invoke("boldtrail-sync",{body:{action:"save_direction",sync_direction:me}});if(he)throw he;if(ye!=null&&ye.error)throw new Error(ye.error);return ye},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),pe.success("Sync direction saved")},onError:me=>{pe.error(me.message||"Failed to save sync direction")}}),Y=Et({mutationFn:async()=>{const{data:me,error:ye}=await G.functions.invoke("boldtrail-sync",{body:{action:"detect_owner"}});if(ye)throw ye;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 ye=me.detected_name||me.detected_email||`ID ${me.kvcore_user_id}`;pe.success(`Detected your BoldTrail account: ${ye}`)}else if(me.candidates&&me.candidates.length>0){const ye=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: ${ye}. 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=Et({mutationFn:async me=>{const{data:ye,error:he}=await G.functions.invoke("boldtrail-sync",{body:{action:"save_owner_settings",...me}});if(he)throw he;if(ye!=null&&ye.error)throw new Error(ye.error);return ye},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),pe.success("Settings saved"),O(!1)},onError:me=>pe.error(me.message||"Failed to save settings")}),X=Et({mutationFn:async()=>{const{data:me,error:ye}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync_preview"}});if(ye)throw ye;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=Et({mutationFn:async()=>{w("Initializing sync..."),C(5);const{data:me,error:ye}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:oe}});if(ye)throw ye;if(me!=null&&me.error)throw new Error(me.error);const he=me;let ge=he.sync_log_id,Ne=he.next_phase,Ue=he.next_offset,Te=he.push_total||0,Me=he.pull_total||0,De=0,qe=0;for(;Ne!=="finalize";){const Be=Te+Me;Ne==="fetch_bt"?w("Fetching BoldTrail contacts..."):Ne==="analyze"?(w("Analyzing contacts..."),C(15)):Ne==="push"?(w(`Pushing contacts to BoldTrail... (${De}/${Te})`),C(Be>0?De/Be*100:0)):Ne==="pull"&&(w(`Pulling contacts from BoldTrail... (${qe}/${Me})`),C(Be>0?(Te+qe)/Be*100:0));const{data:we,error:ut}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:Ne,offset:Ue,sync_log_id:ge,sync_direction:oe}});if(ut)throw ut;if(we!=null&&we.error)throw new Error(we.error);const fe=we;De+=fe.chunk_pushed||0,qe+=fe.chunk_pulled||0,fe.push_total!==void 0&&(Te=fe.push_total||0),fe.pull_total!==void 0&&(Me=fe.pull_total||0),fe.progress&&w(fe.progress),Ne==="pull"&&Me>0?C(Math.min(95,qe/Me*100)):Ne==="push"&&Te>0&&C(Math.min(95,De/Te*100)),Ne=fe.next_phase,Ue=fe.next_offset}w("Finalizing sync..."),C(95);const{data:ke,error:$e}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:ge,sync_direction:oe}});if($e)throw $e;return C(100),ke},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")}}),ae=V==null?void 0:V.connected,ie=(V==null?void 0:V.sync_direction)||"bidirectional",oe=_??ie;return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Lt,{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(Ft,{className:"text-lg flex items-center gap-2",children:["BoldTrail",ae&&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(sp,{className:"h-3.5 w-3.5"}),"Learn More"]})]}),e.jsx(ur,{children:"Sync contacts bidirectionally between Agent OS and your BoldTrail (kvCORE) CRM."})]})]})}),e.jsx(Re,{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(ti,{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(ti,{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(ti,{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"})]}),ae?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(Dl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(xr,{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(Mr,{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(Le,{type:"number",placeholder:"e.g. 12345",value:A,onChange:me=>I(me.target.value),className:"h-8 text-sm"}),e.jsx(K,{size:"sm",onClick:()=>{const me=A.trim()===""?null:Number(A);J.mutate({kvcore_user_id:me})},disabled:J.isPending,children:"Save"}),e.jsx(K,{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(K,{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(K,{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:ie,onChange:me=>te.mutate(me)})}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(K,{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(Cn,{className:"h-4 w-4"}),"Preview Sync"]})})]}):e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{type:"password",placeholder:"Paste your BoldTrail API token",value:s,onChange:me=>r(me.target.value),className:"flex-1"}),e.jsxs(K,{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(hs,{className:"sm:max-w-lg",children:[e.jsxs(js,{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,ye=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:ye}),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(or,{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(fi,{value:k||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(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(uu,{className:"h-3 w-3 text-emerald-600"}),me," contacts to push to BoldTrail"]}),e.jsx(Fi,{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"]})]})})]}),ye>0&&e.jsxs(lf,{open:f,onOpenChange:y,children:[e.jsx(cf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ih,{className:"h-3 w-3 text-blue-600"}),ye," contacts to pull from BoldTrail"]}),e.jsx(Fi,{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&&ye===0&&e.jsx("div",{className:"text-center py-4 text-sm text-muted-foreground",children:"✅ Everything is already in sync! No contacts to transfer."}),e.jsxs("div",{className:"flex gap-2 justify-end pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>a(!1),disabled:ce.isPending,children:"Cancel"}),e.jsxs(K,{onClick:()=>ce.mutate(),disabled:ce.isPending||me===0&&ye===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(hs,{className:"sm:max-w-2xl p-0 overflow-hidden",children:[e.jsx(js,{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 qlt(){const t=vr(),[s,r]=S.useState(""),[n,a]=S.useState(""),[o,l]=S.useState("Test from ReLevelUp"),[i,d]=S.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(Lt,{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(Ft,{className:"text-lg",children:"Amazon SES — Mass Email"}),e.jsx(ur,{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(ti,{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(Re,{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(Le,{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(Le,{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(Le,{value:o,onChange:_=>l(_.target.value),className:"text-sm"})]})]}),e.jsxs(K,{onClick:f,disabled:i,size:"sm",children:[i?e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Mn,{className:"h-4 w-4 mr-2"}),"Send Test"]})]}),e.jsxs(K,{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(Re,{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 w0e(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(Hn,{className:"h-3 w-3 mr-1"})," Verified"]}):t==="pending"?e.jsxs(Qe,{variant:"secondary",children:[e.jsx(on,{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 Ult({brokerageId:t,onVerifiedSelect:s}){const r=Qt(),[n,a]=S.useState(""),[o,l]=S.useState(""),[i,d]=S.useState(!1),[u,p]=S.useState(null),[f,y]=S.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=Et({mutationFn:async()=>w0e({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 w0e({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)}},k=Et({mutationFn:async C=>w0e({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(K,{size:"sm",variant:"outline",onClick:()=>s(C.email),children:"Use"}),C.status!=="verified"&&e.jsx(K,{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(K,{size:"sm",variant:"ghost",onClick:()=>y(C),className:"text-destructive hover:text-destructive",children:e.jsx(xr,{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(Le,{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(Le,{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(K,{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(K,{size:"sm",variant:"ghost",onClick:()=>{d(!1),a(""),l("")},children:"Cancel"})]})]}):e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>d(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"})," Add Sender Address"]}),e.jsx(Dl,{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&&k.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}=qs(),o=a||((I=n==null?void 0:n[0])==null?void 0:I.id)||null,l=(s||r)&&!!o,i=Qt(),[d,u]=S.useState(!1),[p,f]=S.useState(""),[y,_]=S.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())||"",k=((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())||"";S.useEffect(()=>{d||(f(w),_(k))},[d,w,k]);const C=Et({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(Lt,{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(Mn,{className:"h-5 w-5 text-orange-600"})}),e.jsxs("div",{children:[e.jsxs(Ft,{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(ti,{className:"h-3 w-3 mr-1"})," Set Up"]}):e.jsx(Qe,{variant:"secondary",className:"text-xs",children:"Setup Required"})]}),e.jsx(ur,{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(Re,{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:k||"No display name"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:w})]}),e.jsxs(K,{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(Le,{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(Le,{type:"email",placeholder:"your@email.com",value:p,onChange:B=>f(B.target.value)})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{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(K,{size:"sm",variant:"outline",onClick:()=>{u(!1),f(w),_(k)},children:[e.jsx(jr,{className:"h-4 w-4 mr-1"})," Cancel"]})]})]}),l&&e.jsxs(e.Fragment,{children:[e.jsx(xo,{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(Ult,{brokerageId:o})]})]})]})]})}function y4s(){const{isAdmin:t}=qs(),s=Qt(),[r,n]=S.useState(!1),[a,o]=S.useState(!1),[l,i]=S.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=Et({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=Et({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),k=(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(Es,{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(Lt,{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(Ft,{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(ur,{children:"Send emails directly from your contact pages and auto-log them as touchpoints."})]})]})}),e.jsx(Re,{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(ti,{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(ti,{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(ti,{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(Dl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(xr,{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(K,{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(Ga,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsxs(Pe,{className:t?"":"opacity-70",children:[e.jsx(Lt,{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(Ft,{className:"text-lg flex items-center gap-2",children:["Facebook",t?k.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(vd,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(ur,{children:"Connect Facebook Pages to post content and reach your audience."})]})]})}),t&&e.jsxs(Re,{className:"space-y-3",children:[k.length>0&&e.jsx("div",{className:"space-y-2",children:k.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(wn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:I.profile_picture_url||""}),e.jsx(jn,{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(Dl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(xr,{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(K,{onClick:y,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(Zi,{className:"h-4 w-4 animate-spin"}):e.jsx(Bs,{className:"h-4 w-4"}),"Connect Facebook Page"]})]})]}),e.jsxs(Pe,{className:t?"":"opacity-70",children:[e.jsx(Lt,{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(Ft,{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(vd,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(ur,{children:"Connect Instagram Business accounts to schedule and publish posts."})]})]})}),t&&e.jsxs(Re,{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(wn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:I.profile_picture_url||""}),e.jsx(jn,{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(Dl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(xr,{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(K,{onClick:y,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(Zi,{className:"h-4 w-4 animate-spin"}):e.jsx(Bs,{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(Lt,{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(xp,{className:"h-5 w-5 text-blue-700"})}),e.jsxs("div",{children:[e.jsxs(Ft,{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(vd,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(ur,{children:"Connect your LinkedIn profile to share content and grow your professional network."})]})]})}),t&&e.jsxs(Re,{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(wn,{className:"h-8 w-8",children:[e.jsx(Ma,{src:I.profile_picture_url||""}),e.jsx(jn,{children:e.jsx(xp,{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(Dl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(xr,{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(K,{onClick:_,disabled:l,variant:"outline",className:"gap-2",children:[l?e.jsx(Zi,{className:"h-4 w-4 animate-spin"}):e.jsx(Bs,{className:"h-4 w-4"}),"Connect LinkedIn"]})]})]}),e.jsx(f4s,{}),e.jsx(g4s,{}),t&&e.jsx(qlt,{})]})})}function v4s(){const[t]=Nc(),s=vr(),[r,n]=S.useState("loading"),[a,o]=S.useState("Connecting your Gmail account...");return S.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(Lt,{className:"text-center",children:[r==="loading"&&e.jsx(us,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(ti,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(Ql,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Ft,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(ur,{children:a})]}),e.jsx(Re,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"Back to Integrations":"Try Again"})})]})})}function _4s(){const t=vr();return S.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=vr(),[r,n]=S.useState("loading"),[a,o]=S.useState("Processing your connection...");return S.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(Lt,{className:"text-center",children:[r==="loading"&&e.jsx(us,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(ti,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(Ql,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Ft,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(ur,{children:a})]}),e.jsx(Re,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Integrations":"Try Again"})})]})})}const Vlt=new Date().getFullYear(),w4s=Array.from({length:5},(t,s)=>Vlt-s);function j4s(){const[t,s]=S.useState(Vlt),r=vr(),{data:n,isLoading:a}=_8t();return a?e.jsx(Es,{title:"Scorecard Admin",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ks,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(o=>e.jsx(ks,{className:"h-24"},o))}),e.jsx(ks,{className:"h-96"})]})}):e.jsx(Es,{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(Fs,{value:String(t),onValueChange:o=>s(Number(o)),children:[e.jsx(Ds,{className:"w-[120px]",children:e.jsx(zs,{})}),e.jsx(Rs,{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(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(or,{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(Re,{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(Lt,{children:[e.jsx(Ft,{children:"Agents with Scorecards"}),e.jsx(ur,{children:"Click to view individual agent scorecards"})]}),e.jsx(Re,{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(Ms,{children:[e.jsx(kt,{children:"Agent"}),e.jsx(kt,{children:"Email"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:n.map(o=>e.jsxs(Ms,{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(K,{variant:"ghost",size:"sm",onClick:()=>r(`/admin/scorecard/${o.id}`),children:[e.jsx(Cn,{className:"h-4 w-4 mr-2"}),"View Scorecard"]})})]},o.id))})]})})]})]})})}const Hlt=new Date().getFullYear(),N4s=Array.from({length:10},(t,s)=>Hlt-s);function m9e(){var N;const{userId:t}=ao(),s=vr(),n=Bl().pathname.startsWith("/mission-control"),[a,o]=S.useState(Hlt),{data:l,isLoading:i}=gt({queryKey:["agent-profile",t],queryFn:async()=>{const{data:w,error:k}=await G.from("profiles").select("id, name, email").eq("id",t).single();if(k)throw k;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(Es,{title:"Agent Scorecard",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ks,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(w=>e.jsx(ks,{className:"h-24"},w))})]})}):e.jsx(Es,{title:`${l==null?void 0:l.name}'s Scorecard`,children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s(n?"/mission-control/scorecard":"/admin/scorecard"),children:e.jsx(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(Fs,{value:String(a),onValueChange:w=>o(Number(w)),children:[e.jsx(Ds,{className:"w-[120px]",children:e.jsx(zs,{})}),e.jsx(Rs,{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(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Sn,{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(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(or,{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(Re,{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:Pl(p.totalVolume,!0)})]})}),e.jsx(Pe,{children:e.jsxs(Re,{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:Pl(p.averagePrice,!0)})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(rc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((N=p.topLeadSource)==null?void 0:N.name)||"-"})]})})]}),b&&e.jsx(lit,{goals:b,stats:p,year:a,showCommission:_}),e.jsxs(ta,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(Jn,{children:[e.jsx(ls,{value:"transactions",children:"Transactions"}),e.jsx(ls,{value:"charts",children:"Charts"}),e.jsxs(ls,{value:"map",children:[e.jsx(Ia,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(ws,{value:"transactions",children:e.jsx(qSe,{transactions:d||[],showCommission:_,isLoading:u})}),e.jsx(ws,{value:"charts",children:e.jsx(USe,{stats:p,year:a})}),e.jsx(ws,{value:"map",children:e.jsx(VSe,{transactions:d||[],isLoading:u})})]})]})})}function k4s(){const t=Qt(),[s,r]=S.useState(""),[n,a]=S.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=Et({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=Et({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")}}),_=Et({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=Et({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=Et({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,k=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(Es,{title:"Listing Exchange Admin",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Listing Exchange"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage community listings"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>f.mutate(),disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(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(Mr,{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(Re,{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(Re,{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(Re,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(or,{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(Re,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cn,{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(Re,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_d,{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(Re,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by city, address, or agent...",value:s,onChange:I=>r(I.target.value),className:"pl-9"})]}),e.jsx(ta,{value:n,onValueChange:I=>a(I),children:e.jsxs(Jn,{children:[e.jsx(ls,{value:"all",children:"All"}),e.jsx(ls,{value:"pending",children:"Pending"}),e.jsx(ls,{value:"approved",children:"Approved"})]})})]})})}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{children:["Listings (",(k==null?void 0:k.length)||0,")"]})}),e.jsx(Re,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ms,{children:[e.jsx(kt,{children:"Property"}),e.jsx(kt,{children:"Agent"}),e.jsx(kt,{children:"Price"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-center",children:"Approved"}),e.jsx(kt,{className:"text-center",children:"Featured"}),e.jsx(kt,{children:"Views"}),e.jsx(kt,{children:"Shares"}),e.jsx(kt,{children:"Date"}),e.jsx(kt,{})]})}),e.jsx(Rn,{children:d?e.jsx(Ms,{children:e.jsx(ht,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):(k==null?void 0:k.length)===0?e.jsx(Ms,{children:e.jsx(ht,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No listings found"})}):k==null?void 0:k.map(I=>{var L,O,V,q,B;return e.jsxs(Ms,{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(Mr,{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(Mr,{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:gs(new Date(I.created_at),"MMM d, yyyy")}),e.jsx(ht,{children:e.jsxs(Hd,{children:[e.jsx(Gd,{asChild:!0,children:e.jsx(K,{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(Cn,{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(jr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},I.id)})})]})})})]})]})})}const S4s=()=>{var f,y;const[t,s]=S.useState(""),[r,n]=S.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,k,C,A;const b=t.toLowerCase();return((w=(N=_.profiles)==null?void 0:N.name)==null?void 0:w.toLowerCase().includes(b))||((C=(k=_.profiles)==null?void 0:k.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:Dt("h-4 w-4",_>=b?"fill-yellow-400 text-yellow-400":"text-muted-foreground")},b))});return e.jsx(Es,{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(Lt,{className:"pb-2",children:[e.jsx(ur,{children:"Total Reviews"}),e.jsx(Ft,{className:"text-3xl",children:(a==null?void 0:a.length)||0})]})}),e.jsx(Pe,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(ur,{children:"Average Rating"}),e.jsxs(Ft,{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(Lt,{className:"pb-2",children:[e.jsx(ur,{children:"5-Star Reviews"}),e.jsx(Ft,{className:"text-3xl",children:(d==null?void 0:d[5])||0})]})}),e.jsx(Pe,{children:e.jsxs(Lt,{className:"pb-2",children:[e.jsx(ur,{children:"Posted to Google"}),e.jsxs(Ft,{className:"flex items-center gap-2 text-3xl",children:[u,e.jsx(Zr,{className:"h-5 w-5 text-muted-foreground"})]})]})})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(an,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name, email, or review...",value:t,onChange:_=>s(_.target.value),className:"pl-9"})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ms,{children:[e.jsx(kt,{children:"Member"}),e.jsx(kt,{children:"Rating"}),e.jsx(kt,{className:"hidden md:table-cell",children:"Review"}),e.jsx(kt,{children:"Google"}),e.jsx(kt,{children:"Date"})]})}),e.jsx(Rn,{children:o?e.jsx(Ms,{children:e.jsx(ht,{colSpan:5,className:"text-center py-8",children:"Loading reviews..."})}):(l==null?void 0:l.length)===0?e.jsx(Ms,{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(Ms,{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:gs(new Date(_.created_at),"MMM d, yyyy")})]},_.id)})})]})})}),e.jsx(fs,{open:!!r,onOpenChange:()=>n(null),children:e.jsxs(hs,{className:"max-w-lg",children:[e.jsx(js,{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(ln,{className:"h-4 w-4"}),gs(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(Zr,{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}=qs(),[r,n]=S.useState(!1),[a,o]=S.useState(!1),[l,i]=S.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});S.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=Et({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)}}),k=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 ae=X==null?void 0:X.resendId,ie=X==null?void 0:X.resendDetails,oe=ie==null?void 0:ie.status,me=((q=ie==null?void 0:ie.body)==null?void 0:q.status)||((U=(B=ie==null?void 0:ie.body)==null?void 0:B.data)==null?void 0:U.status),ye=((Y=(te=ie==null?void 0:ie.body)==null?void 0:te.error)==null?void 0:Y.message)||((J=ie==null?void 0:ie.body)==null?void 0:J.message);pe.success(ae?`Preview accepted by email provider (id: ${ae})${oe?`, status check: ${oe}`:""}${me?`, provider: ${me}`:""}${ye?` (${ye})`:""}. Check spam/promotions—delivery can take a few minutes.`:"Preview accepted by email provider. Check spam/promotions—delivery can take a few minutes.")}catch(X){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(Es,{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(Es,{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(ls,{value:"settings",className:"flex items-center gap-2",children:[e.jsx(So,{className:"h-4 w-4"}),"Settings"]}),e.jsxs(ls,{value:"stats",className:"flex items-center gap-2",children:[e.jsx(so,{className:"h-4 w-4"}),"Delivery Stats"]})]}),e.jsxs(ws,{value:"settings",className:"space-y-6",children:[L&&_&&e.jsx(Pe,{className:"border-primary/50 bg-primary/5",children:e.jsxs(Re,{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(fi,{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(Re,{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(or,{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(Re,{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(Hn,{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(Re,{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(Ql,{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(Re,{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(on,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:V.lastSent?gs(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(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-5 w-5"}),"Schedule"]}),e.jsx(ur,{children:"Configure when the digest is sent"})]}),e.jsxs(Re,{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(Mr,{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(Fs,{value:(d==null?void 0:d.cron_frequency)||"daily",onValueChange:q=>w.mutate({cron_frequency:q}),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Fs,{value:String(d==null?void 0:d.send_day),onValueChange:q=>w.mutate({send_day:parseInt(q)}),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsx(Rs,{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(Fs,{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(Ds,{children:e.jsx(zs,{})}),e.jsx(Rs,{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(K,{onClick:C,disabled:a,variant:"outline",className:"flex-1",children:[e.jsx(Cn,{className:"h-4 w-4 mr-2"}),a?"Sending...":"Send Preview to Me"]}),e.jsxs(K,{onClick:k,disabled:r,className:"flex-1",children:[e.jsx(Mn,{className:"h-4 w-4 mr-2"}),r?"Sending...":"Send to All"]})]}),N>0&&e.jsxs(K,{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(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(yn,{className:"h-5 w-5"}),"Content Sections"]}),e.jsx(ur,{children:"Choose what to include in the digest"})]}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(xe,{children:"New Resources"})]}),e.jsx(Mr,{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(or,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(xe,{children:"Community Highlights"})]}),e.jsx(Mr,{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(Mr,{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(ln,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(xe,{children:"Upcoming Events"})]}),e.jsx(Mr,{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(Mr,{checked:d==null?void 0:d.include_goals_progress,onCheckedChange:q=>w.mutate({include_goals_progress:q})})]})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsx(Ft,{children:"Custom Introduction"}),e.jsx(ur,{children:"Personalize the intro message (optional)"})]}),e.jsx(Re,{children:e.jsx(gr,{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(ws,{value:"stats",children:e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(tr,{className:"h-5 w-5"}),"Delivery History"]}),e.jsx(ur,{children:"Recent digest emails sent to members"})]}),e.jsx(Re,{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(Ms,{children:[e.jsx(kt,{children:"Email"}),e.jsx(kt,{children:"Sent At"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{children:"Resources"}),e.jsx(kt,{children:"Agent OS"})]})}),e.jsx(Rn,{children:p.map(q=>e.jsxs(Ms,{children:[e.jsx(ht,{className:"font-medium",children:q.email_sent_to}),e.jsx(ht,{children:gs(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,Ne,Ue;const t=Qt(),[s,r]=S.useState(""),[n,a]=S.useState(null),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState(""),[f,y]=S.useState(""),[_,b]=S.useState(!0),[N,w]=S.useState(!1),[k,C]=S.useState(""),[A,I]=S.useState(null),{data:L,isLoading:O}=gt({queryKey:["admin-agent-points"],queryFn:async()=>{const{data:Te,error:Me}=await G.from("agent_attendance_stats").select("*").order("total_points",{ascending:!1});if(Me)throw Me;const De=(Te==null?void 0:Te.map($e=>$e.user_id))||[],{data:qe}=await G.from("profiles").select("id, name, email").in("id",De),ke=new Map((qe==null?void 0:qe.map($e=>[$e.id,{name:$e.name,email:$e.email}]))||[]);return Te==null?void 0:Te.map($e=>({...$e,profile:ke.get($e.user_id)||null}))}}),{data:V}=gt({queryKey:["all-profiles-for-points",L],queryFn:async()=>{const Me=[];let De=0;for(;;){const{data:qe,error:ke}=await G.from("profiles").select("id, name, email").order("name").range(De,De+1e3-1);if(ke)throw ke;if(Me.push(...qe),!qe||qe.length<1e3)break;De+=1e3}return Me}}),B=((V==null?void 0:V.filter(Te=>!(L!=null&&L.some(Me=>Me.user_id===Te.id))))||[]).filter(Te=>{var De,qe;if(!k)return!0;const Me=k.toLowerCase();return((De=Te.name)==null?void 0:De.toLowerCase().includes(Me))||((qe=Te.email)==null?void 0:qe.toLowerCase().includes(Me))}),{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:Te,error:Me}=await G.from("agent_points").select("*").eq("user_id",n.user_id).order("created_at",{ascending:!1});if(Me)throw Me;return Te},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:Te,error:Me}=await G.from("agent_badges").select("*").eq("user_id",n.user_id).order("earned_at",{ascending:!1});if(Me)throw Me;return Te},enabled:!!(n!=null&&n.user_id)}),J=Et({mutationFn:async({userId:Te,points:Me,reason:De})=>{const{error:qe}=await G.from("agent_points").insert({user_id:Te,points:Me,reason:De});if(qe)throw qe;const{data:ke}=await G.from("agent_attendance_stats").select("total_points, spendable_points").eq("user_id",Te).maybeSingle(),$e=((ke==null?void 0:ke.total_points)||0)+Me,Be=((ke==null?void 0:ke.spendable_points)||0)+Me,{error:we}=await G.from("agent_attendance_stats").upsert({user_id:Te,total_points:Math.max(0,$e),spendable_points:Math.max(0,Be),updated_at:new Date().toISOString()},{onConflict:"user_id"});if(we)throw we},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:Te=>{console.error("Error modifying points:",Te),pe.error("Failed to modify points")}}),X=()=>{if(!n||!u||!f){pe.error("Please fill in all fields");return}const Te=parseInt(u);if(isNaN(Te)||Te<=0){pe.error("Please enter a valid positive number");return}J.mutate({userId:n.user_id,points:_?Te:-Te,reason:f})},ce=()=>{if(!A||!u||!f){pe.error("Please fill in all fields");return}const Te=parseInt(u);if(isNaN(Te)||Te<=0){pe.error("Please enter a valid positive number");return}J.mutate({userId:A.id,points:Te,reason:f},{onSuccess:()=>{w(!1),I(null),C("")}})},ae=(Te,Me)=>{a(Te),b(Me),l(!0)},ie=Te=>{a(Te),d(!0)},oe=L==null?void 0:L.filter(Te=>{var ke,$e,Be,we;const Me=(($e=(ke=Te.profile)==null?void 0:ke.name)==null?void 0:$e.toLowerCase())||"",De=((we=(Be=Te.profile)==null?void 0:Be.email)==null?void 0:we.toLowerCase())||"",qe=s.toLowerCase();return Me.includes(qe)||De.includes(qe)}),me=(L==null?void 0:L.reduce((Te,Me)=>Te+Me.total_points,0))||0,ye=(L==null?void 0:L.length)||0,he=ye>0?Math.round(me/ye):0;return O?e.jsx(Es,{title:"Agent Points",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ks,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-3 gap-4",children:[1,2,3].map(Te=>e.jsx(ks,{className:"h-24"},Te))}),e.jsx(ks,{className:"h-96"})]})}):e.jsx(Es,{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(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(or,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total Agents"})]}),e.jsx("p",{className:"text-2xl font-bold",children:ye}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with points tracked"})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Vi,{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(Re,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search agents...",value:s,onChange:Te=>r(Te.target.value),className:"pl-10"})]}),e.jsxs(K,{onClick:()=>w(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Award Points to New Agent"]})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsx(Ft,{children:"Agent Leaderboard"}),e.jsx(ur,{children:"All agents with their points, events, and streaks"})]}),e.jsx(Re,{children:!oe||oe.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Vi,{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(Ms,{children:[e.jsx(kt,{className:"w-12",children:"#"}),e.jsx(kt,{children:"Agent"}),e.jsx(kt,{className:"text-center",children:"Total Points"}),e.jsx(kt,{className:"text-center",children:"Spendable"}),e.jsx(kt,{className:"text-center",children:"Events"}),e.jsx(kt,{className:"text-center",children:"Streak"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:oe.map((Te,Me)=>{var De,qe,ke,$e;return e.jsxs(Ms,{children:[e.jsx(ht,{className:"font-medium",children:Me<3?e.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center ${Me===0?"bg-yellow-100 text-yellow-700":Me===1?"bg-gray-100 text-gray-600":"bg-amber-100 text-amber-700"}`,children:Me+1}):e.jsx("span",{className:"text-muted-foreground",children:Me+1})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(wn,{className:"h-8 w-8",children:e.jsx(jn,{children:((qe=(De=Te.profile)==null?void 0:De.name)==null?void 0:qe.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((ke=Te.profile)==null?void 0:ke.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:($e=Te.profile)==null?void 0:$e.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"}),Te.total_points]})}),e.jsx(ht,{className:"text-center",children:e.jsxs(Qe,{variant:"outline",className:"font-bold text-primary",children:[e.jsx(yi,{className:"h-3 w-3 mr-1"}),Te.spendable_points||0]})}),e.jsx(ht,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(ln,{className:"h-3 w-3 text-muted-foreground"}),Te.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"}),Te.current_streak]})}),e.jsx(ht,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ae(Te,!0),title:"Award points",children:e.jsx(Bs,{className:"h-4 w-4 text-green-600"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ae(Te,!1),title:"Deduct points",children:e.jsx(Qy,{className:"h-4 w-4 text-red-600"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ie(Te),title:"View history",children:e.jsx(MM,{className:"h-4 w-4"})})]})})]},Te.user_id)})})]})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(hs,{children:[e.jsxs(js,{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(Le,{id:"points",type:"number",min:"1",placeholder:"Enter points...",value:u,onChange:Te=>p(Te.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"reason",children:"Reason"}),e.jsx(gr,{id:"reason",placeholder:"Enter reason for this adjustment...",value:f,onChange:Te=>y(Te.target.value)})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{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(hs,{className:"max-w-2xl",children:[e.jsxs(js,{children:[e.jsxs(_s,{children:["Point History: ",(Ne=n==null?void 0:n.profile)==null?void 0:Ne.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(ls,{value:"history",children:"Point History"}),e.jsx(ls,{value:"badges",children:"Badges"})]}),e.jsx(ws,{value:"history",className:"mt-4",children:te?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(Te=>e.jsx(ks,{className:"h-12"},Te))}):!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(Te=>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:Te.reason}),e.jsx("p",{className:"text-xs text-muted-foreground",children:gs(new Date(Te.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(Qe,{variant:Te.points>=0?"default":"destructive",className:Te.points>=0?"bg-green-100 text-green-800":"",children:[Te.points>=0?"+":"",Te.points]})]},Te.id))})}),e.jsx(ws,{value:"badges",className:"mt-4",children:!Y||Y.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(rc,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No badges earned yet"})]}):e.jsx("div",{className:"grid grid-cols-2 gap-3",children:Y.map(Te=>e.jsxs("div",{className:`p-3 rounded-lg ${A4s[Te.badge_type]||"bg-gray-100"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(rc,{className:"h-5 w-5"}),e.jsx("span",{className:"font-medium",children:Te.badge_name})]}),Te.badge_description&&e.jsx("p",{className:"text-xs mt-1 opacity-80",children:Te.badge_description}),e.jsxs("p",{className:"text-xs mt-1 opacity-60",children:["Earned ",gs(new Date(Te.earned_at),"MMM d, yyyy")]})]},Te.id))})})]})]})}),e.jsx(fs,{open:N,onOpenChange:Te=>{w(Te),Te||(I(null),C(""),p(""),y(""))},children:e.jsxs(hs,{className:"max-w-md",children:[e.jsxs(js,{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(wn,{className:"h-10 w-10",children:e.jsx(jn,{children:((Ue=A.name)==null?void 0:Ue.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(K,{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(Le,{id:"new-points",type:"number",min:"1",placeholder:"Enter points...",value:u,onChange:Te=>p(Te.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"new-reason",children:"Reason"}),e.jsx(gr,{id:"new-reason",placeholder:"Enter reason for awarding points...",value:f,onChange:Te=>y(Te.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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name or email...",value:k,onChange:Te=>C(Te.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(or,{className:"h-6 w-6 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:k?"No matching agents found":"All agents already have points"})]}):B.slice(0,20).map(Te=>{var Me;return e.jsxs("button",{onClick:()=>I(Te),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(wn,{className:"h-8 w-8",children:e.jsx(jn,{children:((Me=Te.name)==null?void 0:Me.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:Te.name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Te.email})]})]},Te.id)})})]})}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),A&&e.jsxs(K,{onClick:ce,disabled:J.isPending,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Award Points"]})]})]})})]})})}function P4s(){const{data:t,isLoading:s}=_kt(),[r,n]=S.useState(null),[a,o]=S.useState(!1),[l,i]=S.useState(""),[d,u]=S.useState("all"),[p,f]=S.useState("newest"),[y,_]=S.useState("table"),b=S.useMemo(()=>(t==null?void 0:t.map(A=>A.user_id))||[],[t]),N=S.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:k}=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=S.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=k==null?void 0:k[L.id])==null?void 0:O.views)||0)-(((V=k==null?void 0:k[I.id])==null?void 0:V.views)||0)}):p==="views_asc"?A.sort((I,L)=>{var O,V;return(((O=k==null?void 0:k[I.id])==null?void 0:O.views)||0)-(((V=k==null?void 0:k[L.id])==null?void 0:V.views)||0)}):p==="leads_desc"?A.sort((I,L)=>{var O,V;return(((O=k==null?void 0:k[L.id])==null?void 0:O.leads)||0)-(((V=k==null?void 0:k[I.id])==null?void 0:V.leads)||0)}):p==="leads_asc"&&A.sort((I,L)=>{var O,V;return(((O=k==null?void 0:k[I.id])==null?void 0:O.leads)||0)-(((V=k==null?void 0:k[L.id])==null?void 0:V.leads)||0)}),A},[t,d,l,p,w]);return e.jsxs(Es,{title:"Digital Agent Cards",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Digital Agent Cards"}),e.jsx("p",{className:"text-muted-foreground",children:"Create and manage agent digital business cards"})]}),e.jsxs(K,{onClick:()=>o(!0),children:[e.jsx(Bs,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name, email, or slug...",value:l,onChange:A=>i(A.target.value),className:"pl-9"})]}),e.jsxs(Fs,{value:d,onValueChange:u,children:[e.jsx(Ds,{className:"w-full sm:w-36",children:e.jsx(zs,{placeholder:"Status"})}),e.jsxs(Rs,{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(Fs,{value:p,onValueChange:f,children:[e.jsx(Ds,{className:"w-full sm:w-44",children:e.jsx(zs,{placeholder:"Sort by"})}),e.jsxs(Rs,{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(K,{variant:y==="table"?"default":"ghost",size:"sm",onClick:()=>_("table"),className:"rounded-r-none",children:e.jsx(RM,{className:"h-4 w-4"})}),e.jsx(K,{variant:y==="grid"?"default":"ghost",size:"sm",onClick:()=>_("grid"),className:"rounded-l-none",children:e.jsx(fp,{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(ks,{className:"h-48"},A))}):C.length>0?y==="table"?e.jsx(I4s,{cards:C,cardProfiles:w,cardStats:k,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:k==null?void 0:k[A.id]},A.id))}):t&&t.length>0?e.jsx(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(an,{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(Re,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(or,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No cards yet"}),e.jsx("p",{className:"text-muted-foreground text-sm mb-4",children:"Create your first digital agent card"}),e.jsxs(K,{onClick:()=>o(!0),children:[e.jsx(Bs,{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(K,{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(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{navigator.clipboard.writeText(f),pe.success("Link copied!")},children:e.jsx(Wa,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",asChild:!0,children:e.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",children:e.jsx(Zr,{className:"h-3.5 w-3.5"})})})]})})]},d.id)})})]})})})}function L4s({card:t,onEdit:s,stats:r}){const[n,a]=S.useState(null);S.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(Re,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[e.jsxs(wn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:(n==null?void 0:n.avatar_url)||void 0}),e.jsx(jn,{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(Cn,{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(or,{className:"h-3.5 w-3.5"}),(r==null?void 0:r.leads)??0," leads"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:s,className:"flex-1",children:[e.jsx(ga,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsx(K,{variant:"outline",size:"sm",onClick:l,children:e.jsx(Wa,{className:"h-3 w-3"})}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:e.jsx(Zr,{className:"h-3 w-3"})})})]})]})})}function D4s({open:t,onOpenChange:s}){const[r,n]=S.useState(""),[a,o]=S.useState(""),[l,i]=S.useState(""),[d,u]=S.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]=S.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("")}})},k=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(hs,{children:[e.jsxs(js,{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(yo,{open:d,onOpenChange:u,children:[e.jsx(vo,{asChild:!0,children:e.jsxs(K,{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(uo,{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(lp,{value:C.id,onSelect:k,children:[e.jsx(Zn,{className:Dt("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(Le,{value:a,onChange:C=>o(C.target.value),placeholder:"john-doe"})]})]}),e.jsx(K,{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]=S.useState(null),[d,u]=S.useState(!1),[p,f]=S.useState(!1),[y,_]=S.useState(""),[b,N]=S.useState(t.slug),[w,k]=S.useState(!1),[C,A]=S.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});S.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}k(!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{k(!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:ae}=await G.storage.from("card-logos").upload(ce,te,{upsert:!0});if(ae)throw ae;const{data:ie}=G.storage.from("card-logos").getPublicUrl(ce),oe=ie.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(hs,{className:"max-w-2xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(js,{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(ls,{value:"content",className:"flex-1",children:"Content"}),e.jsx(ls,{value:"sections",className:"flex-1",children:"Sections"}),e.jsx(ls,{value:"blocks",className:"flex-1",children:"Blocks"}),e.jsx(ls,{value:"analytics",className:"flex-1",children:"Analytics"})]}),e.jsxs(ws,{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(Mr,{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(wn,{className:"h-16 w-16",children:[e.jsx(Ma,{src:l||void 0}),e.jsx(jn,{children:"?"})]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:I,disabled:d}),e.jsx(K,{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(Le,{value:b,onChange:B=>N(B.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"agent-name",className:"rounded-l-none"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:O,disabled:w||b===t.slug,className:"shrink-0",children:w?"Saving...":"Update"})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Theme"}),e.jsxs(Fs,{value:C.theme,onValueChange:B=>A(U=>({...U,theme:B})),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Le,{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(Le,{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(gr,{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(Le,{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(Le,{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(Le,{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(Le,{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(Le,{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(Le,{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(Le,{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(ws,{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(Mr,{checked:C[B],onCheckedChange:Y=>A(J=>({...J,[B]:Y}))})]},B))}),e.jsx(ws,{value:"blocks",className:"mt-4",children:e.jsx(Alt,{cardId:t.id})}),e.jsx(ws,{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(Re,{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(Re,{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(Re,{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(K,{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"},UCe={pending_payment:"bg-yellow-100 text-yellow-800",order_submitted:"bg-blue-100 text-blue-800",awaiting_proof_approval:"bg-orange-100 text-orange-800",proof_approved:"bg-green-100 text-green-800",processing:"bg-purple-100 text-purple-800",in_production:"bg-indigo-100 text-indigo-800",shipped:"bg-cyan-100 text-cyan-800",completed:"bg-green-200 text-green-900",cancelled:"bg-red-100 text-red-800",refunded:"bg-gray-100 text-gray-800"};function VCe(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 Et({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 Et({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 Et({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 Glt(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 Et({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 Et({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 Et({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 Et({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 Et({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 Et({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 Et({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 Et({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 Et({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}=qs();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}=qs();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}=qs();return Et({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 Et({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 Et({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 Et({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}=VCe(!1),r=O4s(),n=F4s(),a=z4s(),[o,l]=S.useState(!1),[i,d]=S.useState(null),[u,p]=S.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(Lt,{children:e.jsx(ks,{className:"h-8 w-48"})}),e.jsx(Re,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(N=>e.jsx(ks,{className:"h-12 w-full"},N))})})]}):e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ft,{children:"Categories"}),e.jsxs(fs,{open:o,onOpenChange:N=>{l(N),N||f()},children:[e.jsx(hi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Category"]})}),e.jsxs(hs,{children:[e.jsx(js,{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(Le,{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(gr,{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(Le,{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(Le,{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(Mr,{id:"is_active",checked:u.is_active,onCheckedChange:N=>p({...u,is_active:N})}),e.jsx(xe,{htmlFor:"is_active",children:"Active"})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:r.isPending||n.isPending,children:i?"Update Category":"Create Category"})]})]})]})]}),e.jsx(Re,{children:t&&t.length>0?e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ms,{children:[e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Description"}),e.jsx(kt,{children:"Sort Order"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:t.map(N=>e.jsxs(Ms,{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(K,{variant:"ghost",size:"icon",onClick:()=>y(N),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>b(N.id),disabled:a.isPending,children:e.jsx(xr,{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}=Glt(void 0,!1),{data:r}=VCe(!1),n=$4s(),a=q4s(),o=U4s(),l=V4s(),i=H4s(),d=G4s(),u=W4s(),p=K4s(),f=Z4s(),[y,_]=S.useState(!1),[b,N]=S.useState(!1),[w,k]=S.useState(!1),[C,A]=S.useState(null),[I,L]=S.useState(null),[O,V]=S.useState(!1),[q,B]=S.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]=S.useState({name:"",price_adjustment:0}),[Y,J]=S.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=Ne=>{A(Ne),B({name:Ne.name,description:Ne.description||"",base_price:Number(Ne.base_price),shipping_fee:Number(Ne.shipping_fee),category_id:Ne.category_id||"",allow_artwork_upload:Ne.allow_artwork_upload,requires_proof_approval:Ne.requires_proof_approval,is_active:Ne.is_active,sort_order:Ne.sort_order}),_(!0)},ae=async Ne=>{Ne.preventDefault();const Ue={...q,category_id:q.category_id||null};C?await a.mutateAsync({id:C.id,...Ue}):await n.mutateAsync(Ue),_(!1),X()},ie=async Ne=>{confirm("Are you sure you want to delete this product?")&&await o.mutateAsync(Ne)},oe=async Ne=>{if(!I||!Ne.target.files||Ne.target.files.length===0)return;V(!0);const Ue=Ne.target.files[0],Te=Ue.name.split(".").pop(),Me=`products/${I.id}/${Date.now()}.${Te}`;try{const{error:De}=await G.storage.from("marketplace").upload(Me,Ue);if(De)throw De;const{data:{publicUrl:qe}}=G.storage.from("marketplace").getPublicUrl(Me);await l.mutateAsync({product_id:I.id,image_url:qe,is_primary:!I.images||I.images.length===0}),pe.success("Image uploaded successfully")}catch(De){pe.error("Failed to upload image: "+De.message)}finally{V(!1)}},me=async Ne=>{Ne.preventDefault(),I&&(await u.mutateAsync({product_id:I.id,name:U.name,price_adjustment:U.price_adjustment}),te({name:"",price_adjustment:0}))},ye=async()=>{!I||!Y||(await f.mutateAsync({productId:I.id,videoUrl:Y}),J(""))};return s?e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(ks,{className:"h-8 w-48"})}),e.jsx(Re,{children:e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(Ne=>e.jsx(ks,{className:"h-64 w-full"},Ne))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ft,{children:"Products"}),e.jsxs(fs,{open:y,onOpenChange:Ne=>{_(Ne),Ne||X()},children:[e.jsx(hi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Product"]})}),e.jsxs(hs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:C?"Edit Product":"Add Product"})}),e.jsxs("form",{onSubmit:ae,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(Le,{id:"name",value:q.name,onChange:Ne=>B({...q,name:Ne.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"category",children:"Category"}),e.jsxs(Fs,{value:q.category_id,onValueChange:Ne=>B({...q,category_id:Ne}),children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select category"})}),e.jsx(Rs,{children:r==null?void 0:r.map(Ne=>e.jsx(vt,{value:Ne.id,children:Ne.name},Ne.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"description",children:"Description"}),e.jsx(gr,{id:"description",value:q.description,onChange:Ne=>B({...q,description:Ne.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(Le,{id:"base_price",type:"number",step:"0.01",min:"0",value:q.base_price,onChange:Ne=>B({...q,base_price:parseFloat(Ne.target.value)||0}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"shipping_fee",children:"Shipping Fee ($)"}),e.jsx(Le,{id:"shipping_fee",type:"number",step:"0.01",min:"0",value:q.shipping_fee,onChange:Ne=>B({...q,shipping_fee:parseFloat(Ne.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(Le,{id:"sort_order",type:"number",value:q.sort_order,onChange:Ne=>B({...q,sort_order:parseInt(Ne.target.value)||0})})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mr,{id:"allow_artwork_upload",checked:q.allow_artwork_upload,onCheckedChange:Ne=>B({...q,allow_artwork_upload:Ne})}),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(Mr,{id:"requires_proof_approval",checked:q.requires_proof_approval,onCheckedChange:Ne=>B({...q,requires_proof_approval:Ne})}),e.jsx(xe,{htmlFor:"requires_proof_approval",children:"Requires proof approval"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mr,{id:"is_active",checked:q.is_active,onCheckedChange:Ne=>B({...q,is_active:Ne})}),e.jsx(xe,{htmlFor:"is_active",children:"Active"})]})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:n.isPending||a.isPending,children:C?"Update Product":"Create Product"})]})]})]})]}),e.jsx(Re,{children:t&&t.length>0?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:t.map(Ne=>{var Ue,Te;return e.jsxs(Pe,{className:"overflow-hidden",children:[e.jsxs("div",{className:"aspect-video bg-muted relative",children:[Ne.images&&Ne.images.length>0?e.jsx("img",{src:((Ue=Ne.images.find(Me=>Me.is_primary))==null?void 0:Ue.image_url)||Ne.images[0].image_url,alt:Ne.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"}),!Ne.is_active&&e.jsx(Qe,{variant:"secondary",className:"absolute top-2 right-2",children:"Inactive"})]}),e.jsxs(Re,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold mb-1",children:Ne.name}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:((Te=Ne.category)==null?void 0:Te.name)||"No category"}),e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("span",{className:"font-bold",children:["$",Number(Ne.base_price).toFixed(2)]}),Number(Ne.shipping_fee)>0&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["+$",Number(Ne.shipping_fee).toFixed(2)," shipping"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mb-3",children:[Ne.allow_artwork_upload&&e.jsx(Qe,{variant:"outline",className:"text-xs",children:"Artwork Upload"}),Ne.requires_proof_approval&&e.jsx(Qe,{variant:"outline",className:"text-xs",children:"Proof Required"}),Ne.variants&&Ne.variants.length>0&&e.jsxs(Qe,{variant:"outline",className:"text-xs",children:[Ne.variants.length," Variants"]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>ce(Ne),children:[e.jsx(ga,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{L(Ne),N(!0)},children:[e.jsx(Xv,{className:"h-3 w-3 mr-1"}),"Images"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{L(Ne),k(!0)},children:[e.jsx(mh,{className:"h-3 w-3 mr-1"}),"Variants"]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ie(Ne.id),children:e.jsx(xr,{className:"h-3 w-3 text-destructive"})})]})]})]},Ne.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(hs,{className:"max-w-2xl",children:[e.jsx(js,{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(Ne=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:Ne.image_url,alt:"",className:"w-full aspect-square object-cover rounded-lg"}),Ne.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:[!Ne.is_primary&&e.jsx(K,{variant:"secondary",size:"icon",onClick:async()=>{var Ue;await d.mutateAsync({imageId:Ne.id,productId:I.id}),L({...I,images:(Ue=I.images)==null?void 0:Ue.map(Te=>({...Te,is_primary:Te.id===Ne.id}))})},disabled:d.isPending,title:"Set as primary",children:e.jsx(Gn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"destructive",size:"icon",onClick:async()=>{var Te;await i.mutateAsync({id:Ne.id,productId:I.id});const Ue=t==null?void 0:t.find(Me=>Me.id===I.id);Ue&&L({...Ue,images:(Te=Ue.images)==null?void 0:Te.filter(Me=>Me.id!==Ne.id)})},disabled:i.isPending,children:e.jsx(xr,{className:"h-4 w-4"})})]})]},Ne.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(Le,{placeholder:"Enter video URL (YouTube, Vimeo, etc.)",value:Y,onChange:Ne=>J(Ne.target.value)}),e.jsxs(K,{onClick:ye,disabled:!Y,children:[e.jsx(gn,{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:k,children:e.jsxs(hs,{children:[e.jsx(js,{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(Le,{placeholder:"Variant name (e.g., 500 count)",value:U.name,onChange:Ne=>te({...U,name:Ne.target.value}),required:!0}),e.jsx(Le,{type:"number",step:"0.01",placeholder:"Price adj.",value:U.price_adjustment,onChange:Ne=>te({...U,price_adjustment:parseFloat(Ne.target.value)||0}),className:"w-32"}),e.jsx(K,{type:"submit",children:"Add"})]}),e.jsxs("div",{className:"space-y-2",children:[(ge=I==null?void 0:I.variants)==null?void 0:ge.map(Ne=>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:Ne.name}),e.jsxs("span",{className:"text-sm text-muted-foreground ml-2",children:[Number(Ne.price_adjustment)>=0?"+":"","$",Number(Ne.price_adjustment).toFixed(2)]})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p.mutateAsync({id:Ne.id,productId:I.id}),children:e.jsx(xr,{className:"h-4 w-4 text-destructive"})})]},Ne.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,k;const{data:t,isLoading:s}=Y4s(),r=J4s(),n=eSs(),[a,o]=S.useState(null),[l,i]=S.useState(!1),[d,u]=S.useState({status:"",notes:"",trackingNumber:"",trackingUrl:""}),[p,f]=S.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(Lt,{children:e.jsx(ks,{className:"h-8 w-48"})}),e.jsx(Re,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(C=>e.jsx(ks,{className:"h-16 w-full"},C))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"Orders"})}),e.jsx(Re,{children:t&&t.length>0?e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ms,{children:[e.jsx(kt,{children:"Order #"}),e.jsx(kt,{children:"Customer"}),e.jsx(kt,{children:"Date"}),e.jsx(kt,{children:"Total"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:t.map(C=>{var A,I;return e.jsxs(Ms,{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:gs(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:UCe[C.status],children:iT[C.status]})}),e.jsx(ht,{className:"text-right",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>y(C),children:[e.jsx(Cn,{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(hs,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{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:(k=a.items)==null?void 0:k.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(K,{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(Fs,{value:d.status,onValueChange:C=>u({...d,status:C}),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsx(Rs,{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(Le,{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(Le,{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(gr,{value:d.notes,onChange:C=>u({...d,notes:C.target.value}),placeholder:"Add a note about this status change..."})]}),e.jsxs(K,{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:gs(new Date(C.created_at),"MMM d, h:mm a")})]},C.id))})]})]})]})})]})}function oSs(){const[t,s]=S.useState("products"),r=vr();return e.jsx(Es,{title:"Marketplace Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Marketplace Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage products, categories, and orders"})]}),e.jsxs(K,{variant:"outline",onClick:()=>r("/marketplace"),children:[e.jsx(Zr,{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(ls,{value:"products",className:"flex items-center gap-2",children:[e.jsx(cl,{className:"h-4 w-4"}),"Products"]}),e.jsxs(ls,{value:"categories",className:"flex items-center gap-2",children:[e.jsx(Mm,{className:"h-4 w-4"}),"Categories"]}),e.jsxs(ls,{value:"orders",className:"flex items-center gap-2",children:[e.jsx(op,{className:"h-4 w-4"}),"Orders"]})]}),e.jsx(ws,{value:"products",children:e.jsx(nSs,{})}),e.jsx(ws,{value:"categories",children:e.jsx(rSs,{})}),e.jsx(ws,{value:"orders",children:e.jsx(iSs,{})})]})]})})}function Wlt(){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 Et({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 Et({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 Et({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 Et({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 Et({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 Et({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 Et({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 j0e(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 Klt(){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 Et({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}=qs(),[s,r]=S.useState("items"),[n,a]=S.useState(!1),[o,l]=S.useState(null),[i,d]=S.useState(""),[u,p]=S.useState(""),[f,y]=S.useState(""),[_,b]=S.useState(null),[N,w]=S.useState(!1),[k,C]=S.useState(null),[A,I]=S.useState(""),[L,O]=S.useState(""),[V,q]=S.useState(null),[B,U]=S.useState(""),[te,Y]=S.useState("file"),[J,X]=S.useState(""),[ce,ae]=S.useState(""),[ie,oe]=S.useState(""),[me,ye]=S.useState(!0),[he,ge]=S.useState(null),[Ne,Ue]=S.useState(!1),[Te,Me]=S.useState(!1),De=S.useRef(null),qe=S.useRef(null),{data:ke,isLoading:$e}=Wlt(),{data:Be,isLoading:we}=lSs(),{data:ut,isLoading:fe}=uSs(),{data:He,isLoading:et}=Klt(),tt=pSs(),_e=fSs(),Ge=xSs(),We=gSs(),it=ySs(),Ve=vSs(),Xe=bSs(),[dt,pt]=S.useState({}),Je=$t=>{$t?(l($t),d($t.name),p($t.description||""),y($t.icon||"")):(l(null),d(""),p(""),y("")),a(!0)},Ze=async()=>{if(!i.trim()){pe.error("Please enter a category name");return}try{o?(await _e.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:((ke==null?void 0:ke.length)||0)+1}),pe.success("Category created successfully")),a(!1)}catch($t){console.error("Error saving category:",$t),pe.error("Failed to save category")}},Nt=async()=>{if(_)try{await Ge.mutateAsync(_),pe.success("Category deleted successfully"),b(null)}catch($t){console.error("Error deleting category:",$t),pe.error("Failed to delete category")}},Ot=$t=>{var Us;$t?(C($t),I($t.name),O($t.description||""),q($t.category_id),U($t.points_cost.toString()),Y($t.item_type),X($t.file_url||""),ae($t.preview_image_url||""),oe(((Us=$t.max_quantity)==null?void 0:Us.toString())||""),ye($t.is_active)):(C(null),I(""),O(""),q(null),U(""),Y("file"),X(""),ae(""),oe(""),ye(!0)),w(!0)},Yt=async($t,Us)=>{Us==="file"?Ue(!0):Me(!0);try{const Nr=$t.name.split(".").pop(),Xs=`${Date.now()}-${Math.random().toString(36).substring(7)}.${Nr}`,kr=`${Us==="file"?"items":"previews"}/${Xs}`,{error:fn}=await G.storage.from("reward-store").upload(kr,$t);if(fn)throw fn;const{data:{publicUrl:Yr}}=G.storage.from("reward-store").getPublicUrl(kr);Us==="file"?X(Yr):ae(Yr),pe.success("File uploaded successfully")}catch(Nr){console.error("Error uploading file:",Nr),pe.error("Failed to upload file")}finally{Us==="file"?Ue(!1):Me(!1)}},Ps=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 $t={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:ie?parseInt(ie):null,current_quantity:ie?parseInt(ie):null,is_active:me,created_by:t==null?void 0:t.id};k?(await it.mutateAsync({id:k.id,...$t,current_quantity:k.max_quantity!==(ie?parseInt(ie):null)?ie?parseInt(ie):null:k.current_quantity}),pe.success("Item updated successfully")):(await We.mutateAsync($t),pe.success("Item created successfully")),w(!1)}catch($t){console.error("Error saving item:",$t),pe.error("Failed to save item")}},$s=async()=>{if(he)try{await Ve.mutateAsync(he),pe.success("Item deleted successfully"),ge(null)}catch($t){console.error("Error deleting item:",$t),pe.error("Failed to delete item")}},Zs=async($t,Us)=>{const Nr=dt[$t];if(Nr===void 0||Nr===Us.toString())return;const Xs=parseInt(Nr);if(isNaN(Xs)||Xs<0){pe.error("Please enter a valid positive number");return}try{await Xe.mutateAsync({id:$t,points:Xs}),pe.success("Points updated successfully"),pt(kr=>{const fn={...kr};return delete fn[$t],fn})}catch(kr){console.error("Error updating points:",kr),pe.error("Failed to update points")}};return $e||we||fe||et?e.jsx(Es,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ks,{className:"h-8 w-64"}),e.jsx(ks,{className:"h-96"})]})}):e.jsxs(Es,{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(Re,{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:(Be==null?void 0:Be.length)||0}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(Be==null?void 0:Be.filter($t=>$t.is_active).length)||0," active"]})]})}),e.jsx(Pe,{children:e.jsxs(Re,{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:(ke==null?void 0:ke.length)||0})]})}),e.jsx(Pe,{children:e.jsxs(Re,{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:[Be&&Be.length>0?Math.round(Be.reduce(($t,Us)=>$t+Us.points_cost,0)/Be.length):0," pts"]})]})})]}),e.jsxs(ta,{value:s,onValueChange:r,children:[e.jsxs(Jn,{children:[e.jsx(ls,{value:"items",children:"Items"}),e.jsx(ls,{value:"categories",children:"Categories"}),e.jsx(ls,{value:"purchases",children:"Purchases"}),e.jsx(ls,{value:"point-settings",children:"Point Settings"})]}),e.jsx(ws,{value:"items",className:"mt-4",children:e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{children:"Store Items"}),e.jsx(ur,{children:"Manage rewards that agents can purchase"})]}),e.jsxs(K,{onClick:()=>Ot(),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Item"]})]}),e.jsx(Re,{children:!Be||Be.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(yi,{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(Ms,{children:[e.jsx(kt,{children:"Item"}),e.jsx(kt,{children:"Category"}),e.jsx(kt,{className:"text-center",children:"Cost"}),e.jsx(kt,{className:"text-center",children:"Type"}),e.jsx(kt,{className:"text-center",children:"Quantity"}),e.jsx(kt,{className:"text-center",children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:Be.map($t=>e.jsxs(Ms,{children:[e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[$t.preview_image_url?e.jsx("img",{src:$t.preview_image_url,alt:$t.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(yi,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:$t.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:$t.description||"No description"})]})]})}),e.jsx(ht,{children:$t.category?e.jsx(Qe,{variant:"outline",children:$t.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"}),$t.points_cost]})}),e.jsx(ht,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[$t.item_type==="file"?e.jsx(yn,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(go,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs capitalize",children:$t.item_type})]})}),e.jsx(ht,{className:"text-center",children:$t.max_quantity!==null?e.jsxs("span",{className:$t.current_quantity===0?"text-red-500":"",children:[$t.current_quantity,"/",$t.max_quantity]}):e.jsx("span",{className:"text-muted-foreground",children:"Unlimited"})}),e.jsx(ht,{className:"text-center",children:e.jsx(Qe,{variant:$t.is_active?"default":"secondary",children:$t.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(K,{variant:"ghost",size:"sm",onClick:()=>Ot($t),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ge($t.id),children:e.jsx(xr,{className:"h-4 w-4 text-destructive"})})]})})]},$t.id))})]})})]})}),e.jsx(ws,{value:"categories",className:"mt-4",children:e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{children:"Categories"}),e.jsx(ur,{children:"Organize your store items into categories"})]}),e.jsxs(K,{onClick:()=>Je(),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(Re,{children:!ke||ke.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(Ms,{children:[e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Description"}),e.jsx(kt,{className:"text-center",children:"Items"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(Rn,{children:ke.map($t=>e.jsxs(Ms,{children:[e.jsxs(ht,{className:"font-medium",children:[$t.icon&&e.jsx("span",{className:"mr-2",children:$t.icon}),$t.name]}),e.jsx(ht,{className:"text-muted-foreground",children:$t.description||"—"}),e.jsx(ht,{className:"text-center",children:(Be==null?void 0:Be.filter(Us=>Us.category_id===$t.id).length)||0}),e.jsx(ht,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Je($t),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>b($t.id),children:e.jsx(xr,{className:"h-4 w-4 text-destructive"})})]})})]},$t.id))})]})})]})}),e.jsx(ws,{value:"purchases",className:"mt-4",children:e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(op,{className:"h-5 w-5"}),"Purchase History"]}),e.jsx(ur,{children:"View all reward redemptions by agents"})]}),e.jsx(Re,{children:!ut||ut.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(op,{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(Ms,{children:[e.jsx(kt,{children:"Date"}),e.jsx(kt,{children:"Agent"}),e.jsx(kt,{children:"Item"}),e.jsx(kt,{className:"text-center",children:"Points Spent"})]})}),e.jsx(Rn,{children:ut.map($t=>{var Us,Nr,Xs,kr;return e.jsxs(Ms,{children:[e.jsx(ht,{className:"text-muted-foreground",children:gs(new Date($t.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:((Us=$t.user)==null?void 0:Us.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:((Nr=$t.user)==null?void 0:Nr.email)||"—"})]})]})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[(Xs=$t.item)!=null&&Xs.preview_image_url?e.jsx("img",{src:$t.item.preview_image_url,alt:$t.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(yi,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{children:((kr=$t.item)==null?void 0:kr.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"}),$t.points_spent]})})]},$t.id)})})]})})]})})]})]}),e.jsx(fs,{open:n,onOpenChange:a,children:e.jsxs(hs,{children:[e.jsxs(js,{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(Le,{id:"categoryName",value:i,onChange:$t=>d($t.target.value),placeholder:"e.g., Templates, Resources"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"categoryDescription",children:"Description"}),e.jsx(gr,{id:"categoryDescription",value:u,onChange:$t=>p($t.target.value),placeholder:"Optional description..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"categoryIcon",children:"Icon (emoji)"}),e.jsx(Le,{id:"categoryIcon",value:f,onChange:$t=>y($t.target.value),placeholder:"e.g., 📄, 🎁"})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{onClick:Ze,disabled:tt.isPending||_e.isPending,children:tt.isPending||_e.isPending?"Saving...":"Save"})]})]})}),e.jsx(fs,{open:N,onOpenChange:w,children:e.jsxs(hs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(js,{children:[e.jsx(_s,{children:k?"Edit Item":"Add Item"}),e.jsx(Ir,{children:k?"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(Le,{id:"itemName",value:A,onChange:$t=>I($t.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(gr,{id:"itemDescription",value:L,onChange:$t=>O($t.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(Fs,{value:V||"none",onValueChange:$t=>q($t==="none"?null:$t),children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select category"})}),e.jsxs(Rs,{children:[e.jsx(vt,{value:"none",children:"No category"}),ke==null?void 0:ke.map($t=>e.jsxs(vt,{value:$t.id,children:[$t.icon&&`${$t.icon} `,$t.name]},$t.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"itemPointsCost",children:"Points Cost *"}),e.jsx(Le,{id:"itemPointsCost",type:"number",min:"0",value:B,onChange:$t=>U($t.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(Fs,{value:te,onValueChange:Y,children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Le,{id:"itemMaxQuantity",type:"number",min:"1",value:ie,onChange:$t=>oe($t.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(Le,{value:J,onChange:$t=>X($t.target.value),placeholder:te==="file"?"Upload a file or paste URL":"Paste external link"}),te==="file"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>{var $t;return($t=De.current)==null?void 0:$t.click()},disabled:Ne,children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx("input",{ref:De,type:"file",className:"hidden",onChange:$t=>{var Nr;const Us=(Nr=$t.target.files)==null?void 0:Nr[0];Us&&Yt(Us,"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(Le,{value:ce,onChange:$t=>ae($t.target.value),placeholder:"Upload an image or paste URL"}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>{var $t;return($t=qe.current)==null?void 0:$t.click()},disabled:Te,children:e.jsx(qo,{className:"h-4 w-4"})}),e.jsx("input",{ref:qe,type:"file",accept:"image/*",className:"hidden",onChange:$t=>{var Nr;const Us=(Nr=$t.target.files)==null?void 0:Nr[0];Us&&Yt(Us,"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(Mr,{id:"itemIsActive",checked:me,onCheckedChange:ye}),e.jsx(xe,{htmlFor:"itemIsActive",children:"Active (visible to agents)"})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),e.jsx(K,{onClick:Ps,disabled:We.isPending||it.isPending,children:We.isPending||it.isPending?"Saving...":"Save"})]})]})}),e.jsx(Dl,{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:Nt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),e.jsx(Dl,{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:$s,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),s==="point-settings"&&e.jsxs(Pe,{className:"mt-4",children:[e.jsx(Lt,{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(Ft,{children:"Point Reward Settings"}),e.jsx(ur,{children:"Configure how many points agents earn for various actions. Adjust these values to run double-points promotions."})]})]})}),e.jsx(Re,{children:!He||He.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(Ms,{children:[e.jsx(kt,{children:"Action"}),e.jsx(kt,{children:"Description"}),e.jsx(kt,{className:"text-center w-32",children:"Points"}),e.jsx(kt,{className:"text-right w-24",children:"Save"})]})}),e.jsx(Rn,{children:He.map($t=>e.jsxs(Ms,{children:[e.jsx(ht,{children:e.jsx("p",{className:"font-medium",children:$t.action_name})}),e.jsx(ht,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:$t.description})}),e.jsx(ht,{className:"text-center",children:e.jsx(Le,{type:"number",min:"0",className:"w-20 mx-auto text-center",value:dt[$t.id]??$t.points.toString(),onChange:Us=>pt(Nr=>({...Nr,[$t.id]:Us.target.value}))})}),e.jsx(ht,{className:"text-right",children:e.jsx(K,{size:"sm",variant:"outline",disabled:dt[$t.id]===void 0||dt[$t.id]===$t.points.toString()||Xe.isPending,onClick:()=>Zs($t.id,$t.points),children:e.jsx(bc,{className:"h-4 w-4"})})})]},$t.id))})]})})]})]})}const p9e=()=>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"})]}),f9e=[{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]=S.useState(!1),[n,a]=S.useState(!1),[o,l]=S.useState(!1),[i,d]=S.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=Et({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=Et({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=Et({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")}),k=!!u;return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Lt,{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(p9e,{})}),e.jsxs("div",{children:[e.jsxs(Ft,{className:"text-lg flex items-center gap-2",children:["Canva Connect",k&&e.jsx(Qe,{variant:"default",className:"text-xs",children:"Connected"}),e.jsx(Qe,{variant:"outline",className:"text-xs",children:"Admin Only"})]}),e.jsx(ur,{children:"Auto-share brokerage asset folders with agents when they connect their Canva accounts."})]})]})})}),e.jsx(Re,{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(ti,{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(ti,{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(ti,{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"})]}),k?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(Dl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(xr,{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(Fi,{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=f9e.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(K,{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(jr,{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(K,{variant:"outline",size:"sm",className:"w-full gap-1.5 mt-1",onClick:()=>l(!0),children:[e.jsx(Bs,{className:"h-3.5 w-3.5"}),"Add Folder Mapping"]})]})]})]}):e.jsxs(K,{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(p9e,{})}),"Connect Canva",e.jsx(Ga,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(hs,{children:[e.jsx(js,{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(Fs,{value:i.brokerage_id,onValueChange:C=>d(A=>({...A,brokerage_id:C})),children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select a brokerage…"})}),e.jsx(Rs,{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(Le,{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(Le,{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(Fs,{value:i.folder_type,onValueChange:C=>d(A=>({...A,folder_type:C})),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsx(Rs,{children:f9e.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(Le,{placeholder:"What's in this folder?",value:i.description,onChange:C=>d(A=>({...A,description:C.target.value}))})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(K,{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(Es,{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(qlt,{})]})})}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]=S.useState("Test Push"),[n,a]=S.useState("Testing web push notification"),[o,l]=S.useState("/community"),[i,d]=S.useState(!1),[u,p]=S.useState(!1),[f,y]=S.useState({isSupported:typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window}),[_,b]=S.useState(null),[N,w]=S.useState(null),{data:k,isLoading:C}=gt({queryKey:["push-notification-settings"],queryFn:async()=>{const{data:ae,error:ie}=await G.from("push_notification_settings").select("*").order("setting_key");if(ie)throw ie;return ae}}),{data:A,isLoading:I}=gt({queryKey:["push-subscription-stats"],queryFn:async()=>{const{count:ae,error:ie}=await G.from("push_subscriptions").select("*",{count:"exact",head:!0});if(ie)throw ie;return{totalSubscriptions:ae||0}}}),L=Et({mutationFn:async({settingKey:ae,isEnabled:ie})=>{const{error:oe}=await G.from("push_notification_settings").update({is_enabled:ie}).eq("setting_key",ae);if(oe)throw oe},onSuccess:()=>{t.invalidateQueries({queryKey:["push-notification-settings"]}),pe.success("Notification setting updated")},onError:ae=>{pe.error("Failed to update setting: "+ae.message)}}),O=S.useMemo(()=>{var ae,ie;return f.isSupported?`perm=${f.permission??"unknown"} · controller=${f.controllerPresent?"yes":"no"} · sw=${((ae=f.serviceWorker)==null?void 0:ae.activeState)??"unknown"} · sub=${(ie=f.subscription)!=null&&ie.endpoint?"yes":"no"}`:"Push not supported in this browser."},[f]);S.useEffect(()=>{let ae=!0;const ie=async()=>{var he,ge,Ne,Ue,Te,Me,De;const me="serviceWorker"in navigator&&"PushManager"in window,ye={isSupported:me,permission:typeof Notification<"u"?Notification.permission:void 0,controllerPresent:!!((he=navigator.serviceWorker)!=null&&he.controller)};if(!me){ae&&y(ye);return}try{const{data:qe,error:ke}=await G.functions.invoke("get-vapid-public-key",{body:{}});if(ke)throw ke;ye.vapidPublicKey=qe==null?void 0:qe.vapidPublicKey;const Be=(await navigator.serviceWorker.getRegistrations()).find(we=>{var fe,He,et;return(((fe=we.active)==null?void 0:fe.scriptURL)||((He=we.waiting)==null?void 0:He.scriptURL)||((et=we.installing)==null?void 0:et.scriptURL)||"").includes("/sw.js")});if(Be){ye.pushWorkerScriptUrl=((ge=Be.active)==null?void 0:ge.scriptURL)||((Ne=Be.waiting)==null?void 0:Ne.scriptURL)||((Ue=Be.installing)==null?void 0:Ue.scriptURL),ye.serviceWorker={scope:Be.scope,activeState:(Te=Be.active)==null?void 0:Te.state};const we=await Be.pushManager.getSubscription();if(we){const ut=we.toJSON();ye.subscription={endpoint:ut.endpoint,p256dh:(Me=ut.keys)==null?void 0:Me.p256dh,auth:(De=ut.keys)==null?void 0:De.auth}}}}catch(qe){ye.error=(qe==null?void 0:qe.message)||String(qe)}ae&&y(ye)};ie();const oe=window.setInterval(ie,4e3);return()=>{ae=!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(ae){pe.error(`Local notification failed: ${(ae==null?void 0:ae.message)||String(ae)}`)}},q=async()=>{d(!0),b(null);try{const{data:ae,error:ie}=await G.functions.invoke("send-push-notification",{body:{title:s,body:n,url:o}});if(ie)throw ie;b({sent:ae==null?void 0:ae.sent,failed:ae==null?void 0:ae.failed,expiredCleaned:ae==null?void 0:ae.expiredCleaned,vapidPublicKey:ae==null?void 0:ae.vapidPublicKey}),(ae==null?void 0:ae.sent)>0?pe.success(`Test notification sent to ${ae.sent} subscriber(s)`):(ae==null?void 0:ae.failed)>0?pe.warning(`Notification failed for ${ae.failed} subscriber(s). ${ae.expired||0} expired subscriptions cleaned up.`):pe.info("No active subscriptions to send to")}catch(ae){console.error("Error sending test notification:",ae),b({error:(ae==null?void 0:ae.message)||String(ae)}),pe.error("Failed to send test notification: "+(ae.message||"Unknown error"))}finally{d(!1)}},B=async()=>{p(!0),w(null);try{const{data:ae,error:ie}=await G.functions.invoke("generate-vapid-keys",{body:{}});if(ie)throw ie;const oe=ae==null?void 0:ae.publicKey,me=ae==null?void 0:ae.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(ae){console.error("Error generating VAPID keys:",ae),pe.error("Failed to generate VAPID keys: "+((ae==null?void 0:ae.message)||"Unknown error"))}finally{p(!1)}},U=Et({mutationFn:async()=>{const{error:ae}=await G.from("push_subscriptions").delete().neq("id","00000000-0000-0000-0000-000000000000");if(ae)throw ae},onSuccess:()=>{pe.success("All subscriptions cleared. Users will need to re-enable notifications."),t.invalidateQueries({queryKey:["push-subscription-stats"]})},onError:ae=>{pe.error("Failed to clear subscriptions: "+ae.message)}});return e.jsx(Es,{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(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(or,{className:"h-5 w-5"}),"Push Notification Subscribers"]}),e.jsx(ur,{children:"Current active push notification subscriptions"})]}),e.jsx(Re,{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(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(So,{className:"h-5 w-5"}),"Notification Types"]}),e.jsx(ur,{children:"Control which types of push notifications are sent to users"})]}),e.jsx(Re,{children:C?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading settings..."}):e.jsx("div",{className:"space-y-4",children:k==null?void 0:k.map(ae=>{const ie=kSs[ae.setting_key]||{label:ae.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:ie.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:ie.label}),e.jsx("div",{className:"text-sm text-muted-foreground",children:ae.description})]})]}),e.jsx(Mr,{checked:ae.is_enabled,onCheckedChange:oe=>L.mutate({settingKey:ae.setting_key,isEnabled:oe}),disabled:L.isPending})]},ae.id)})})})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Sm,{className:"h-5 w-5"}),"Send Test Notification"]}),e.jsx(ur,{children:"Send a test push notification to all subscribed users"})]}),e.jsxs(Re,{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(K,{variant:"outline",onClick:V,children:"Local notification test"}),e.jsx(K,{variant:"outline",onClick:()=>window.location.reload(),children:"Reload page"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"test-title",children:"Notification Title"}),e.jsx(Le,{id:"test-title",value:s,onChange:ae=>r(ae.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(gr,{id:"test-body",value:n,onChange:ae=>a(ae.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(Le,{id:"test-url",value:o,onChange:ae=>l(ae.target.value),placeholder:"/community or full URL"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Where users will be taken when they click the notification"})]}),e.jsxs(K,{onClick:q,disabled:i||!s||!n,className:"w-full sm:w-auto",children:[e.jsx(Mn,{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(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2 text-destructive",children:[e.jsx(xr,{className:"h-5 w-5"}),"Subscription Maintenance"]}),e.jsx(ur,{children:"Clear all push subscriptions if VAPID keys were changed or subscriptions are invalid"})]}),e.jsxs(Re,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"If you've recently updated the VAPID keys, existing subscriptions will no longer work. Use this to clear all subscriptions so users can re-subscribe with the new keys."}),e.jsxs(K,{variant:"destructive",onClick:()=>U.mutate(),disabled:U.isPending,children:[e.jsx(xr,{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(K,{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]=S.useState([]),[n,a]=S.useState({totalPresentations:0,totalViews:0,totalLeads:0,totalCtaClicks:0,agentsUsing:0}),[o,l]=S.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});S.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:k,error:C}=await G.from("profiles").select("id, name, email, avatar_url").in("id",w);if(C)throw C;const A=new Map((k==null?void 0:k.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:or,color:"text-blue-600"},{label:"Total Presentations",value:n.totalPresentations,icon:Pg,color:"text-violet-600"},{label:"Total Views",value:n.totalViews,icon:Cn,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(Es,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:b.label}),e.jsx(b.icon,{className:`h-4 w-4 ${b.color}`})]}),e.jsx(Re,{children:o?e.jsx(ks,{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(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Qo,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(Re,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((b,N)=>e.jsx(ks,{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(Ms,{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,k;const N=b.total_views>0?(b.total_leads/b.total_views*100).toFixed(1):"0.0";return e.jsxs(Ms,{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:((k=(w=b.name)==null?void 0:w.charAt(0))==null?void 0:k.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]=S.useState([]),[n,a]=S.useState({totalOpenHouses:0,totalVisitors:0,totalLeads:0,activeOpenHouses:0,agentsUsing:0}),[o,l]=S.useState(!0);S.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 k=b.get(w.agent_id);return{agent_id:w.agent_id,name:(k==null?void 0:k.name)||"Unknown",email:(k==null?void 0:k.email)||"",avatar_url:(k==null?void 0:k.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,k)=>k.total_visitors-w.total_visitors),r(N),a({totalOpenHouses:N.reduce((w,k)=>w+k.open_house_count,0),totalVisitors:N.reduce((w,k)=>w+k.total_visitors,0),totalLeads:N.reduce((w,k)=>w+k.total_leads,0),activeOpenHouses:N.reduce((w,k)=>w+k.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:or,color:"text-blue-600"},{label:"Total Open Houses",value:n.totalOpenHouses,icon:Sn,color:"text-violet-600"},{label:"Active Now",value:n.activeOpenHouses,icon:ti,color:"text-emerald-600"},{label:"Total Visitors",value:n.totalVisitors,icon:Cn,color:"text-amber-600"},{label:"Leads Created",value:n.totalLeads,icon:Jo,color:"text-rose-600"}];return e.jsx(Es,{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(Lt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ft,{className:"text-sm font-medium",children:u.label}),e.jsx(u.icon,{className:`h-4 w-4 ${u.color}`})]}),e.jsx(Re,{children:o?e.jsx(ks,{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(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Qo,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(Re,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((u,p)=>e.jsx(ks,{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(Ms,{children:[e.jsx(kt,{children:"Agent"}),e.jsx(kt,{className:"text-center",children:"Open Houses"}),e.jsx(kt,{className:"text-center",children:"Active"}),e.jsx(kt,{className:"text-center",children:"Visitors"}),e.jsx(kt,{className:"text-center",children:"Leads"}),e.jsx(kt,{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(Ms,{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=vr(),[r,n]=S.useState("loading"),[a,o]=S.useState("Processing connection...");return S.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(Lt,{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(ti,{className:"h-12 w-12 text-green-500"}),r==="error"&&e.jsx(Ql,{className:"h-12 w-12 text-destructive"})]}),e.jsxs(Ft,{children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(ur,{children:a})]}),e.jsx(Re,{className:"flex justify-center",children:e.jsx(K,{onClick:()=>s("/admin/integrations"),children:r==="success"?"View Integrations":"Back to Integrations"})})]})})}function ASs(){const t=Qt(),[s,r]=S.useState(""),[n,a]=S.useState(""),[o,l]=S.useState([]),i=S.useRef(null),{data:d,isLoading:u}=gt({queryKey:["prospect-emails"],queryFn:async()=>{const{data:w,error:k}=await G.from("prospect_emails").select("*").order("sent_at",{ascending:!1});if(k)throw k;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=Et({mutationFn:async w=>{const{data:k,error:C}=await G.functions.invoke("send-prospect-email",{body:{emails:w}});if(C)throw C;return k},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=Et({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:k,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 k},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(k=>k.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 k=(A=w.target.files)==null?void 0:A[0];if(!k)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(k),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()))||[]),k=o.filter(C=>!w.has(C.email.toLowerCase()));if(k.length===0){pe.error("All emails have already been prospected");return}k.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(Re,{children:e.jsxs(ta,{defaultValue:"single",children:[e.jsxs(Jn,{className:"mb-4",children:[e.jsxs(ls,{value:"single",children:[e.jsx(Mn,{className:"h-4 w-4 mr-2"}),"Single Send"]}),e.jsxs(ls,{value:"bulk",children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"}),"Bulk CSV"]})]}),e.jsx(ws,{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(Le,{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(Le,{id:"prospect-name",placeholder:"First name (optional)",value:n,onChange:w=>a(w.target.value),onKeyDown:w=>w.key==="Enter"&&_()})]}),e.jsxs(K,{onClick:_,disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(Mn,{className:"h-4 w-4"}),"Send Invite"]})]})}),e.jsx(ws,{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(K,{variant:"outline",onClick:()=>{var w;return(w=i.current)==null?void 0:w.click()},className:"gap-2",children:[e.jsx(yn,{className:"h-4 w-4"}),"Upload CSV"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Format: email, first_name (one per line)"})]}),o.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[e.jsx(or,{className:"h-3 w-3"}),o.length," entries ready"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>l([]),children:[e.jsx(jr,{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,k)=>e.jsxs("div",{className:"text-muted-foreground",children:[w.email,w.first_name?` — ${w.first_name}`:""]},k)),o.length>20&&e.jsxs("div",{className:"text-muted-foreground/60",children:["...and ",o.length-20," more"]})]}),e.jsxs(K,{onClick:N,disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(Mn,{className:"h-4 w-4"}),"Send ",o.length," Invites"]})]})]})})]})})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(tr,{className:"h-5 w-5"}),"Prospect Log"]}),e.jsx(ur,{children:"Track all sent invitations and their conversion status"})]}),e.jsx(Re,{children:u?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((w,k)=>e.jsx(ks,{className:"h-12 w-full"},k))}):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:gs(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(Hn,{className:"h-3 w-3 mr-1"}),"Converted"]}):e.jsxs(Qe,{variant:"secondary",className:"gap-1",children:[e.jsx(on,{className:"h-3 w-3"}),"Sent"]})}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:w.converted_at?gs(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 EO(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=Et({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=Et({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=Et({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=Et({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 x9e=(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 Zlt({open:t,onOpenChange:s,stages:r,defaultStageId:n,onSubmit:a,isSubmitting:o}){const[l,i]=S.useState(x9e(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(x9e(n,r)),s(!1)};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(hs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{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(ls,{value:"basic",children:"Basic Info"}),e.jsx(ls,{value:"production",children:"Production"}),e.jsx(ls,{value:"social",children:"Social & Web"}),e.jsx(ls,{value:"personal",children:"Personal"})]}),e.jsxs(ws,{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(Le,{required:!0,value:l.first_name,onChange:d("first_name")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Last Name"}),e.jsx(Le,{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(Le,{type:"email",value:l.email,onChange:d("email")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Phone"}),e.jsx(Le,{value:l.phone,onChange:d("phone")})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Current Brokerage"}),e.jsx(Le,{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(Le,{value:l.license_number,onChange:d("license_number")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Experience (years)"}),e.jsx(Le,{type:"number",min:"0",value:l.experience_years,onChange:d("experience_years")})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Address"}),e.jsx(Le,{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(Le,{value:l.city,onChange:d("city")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"State"}),e.jsx(Le,{value:l.state,onChange:d("state")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Zip"}),e.jsx(Le,{value:l.zip_code,onChange:d("zip_code")})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Pipeline Stage"}),e.jsxs(Fs,{value:l.stage_id,onValueChange:p=>i(f=>({...f,stage_id:p})),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsx(Rs,{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(Le,{placeholder:"Who referred this prospect?",value:l.referred_by,onChange:d("referred_by")})]})]}),e.jsxs(ws,{value:"production",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Annual Production Volume"}),e.jsx(Le,{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(Le,{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(Le,{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(Le,{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(Le,{placeholder:"e.g. Luxury, First-time buyers, Investment",value:l.specialties,onChange:d("specialties")})]})]}),e.jsxs(ws,{value:"social",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"LinkedIn URL"}),e.jsx(Le,{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(Le,{type:"url",placeholder:"https://...",value:l.website_url,onChange:d("website_url")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Instagram Handle"}),e.jsx(Le,{placeholder:"@handle",value:l.instagram_handle,onChange:d("instagram_handle")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Facebook URL"}),e.jsx(Le,{type:"url",placeholder:"https://facebook.com/...",value:l.facebook_url,onChange:d("facebook_url")})]})]}),e.jsxs(ws,{value:"personal",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Birthday"}),e.jsx(Le,{type:"date",value:l.birthday,onChange:d("birthday")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Spouse / Partner Name"}),e.jsx(Le,{value:l.spouse_name,onChange:d("spouse_name")})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Interests / Hobbies"}),e.jsx(Le,{placeholder:"Golf, travel, community events...",value:l.interests,onChange:d("interests")})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Notes"}),e.jsx(gr,{value:l.notes,onChange:d("notes"),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:o,children:"Add Prospect"})]})]})]})})}const 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 Ylt(){const t=Qt(),{toast:s}=ja();return Et({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 Xlt(){const t=Qt();return Et({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 Qlt(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 Et({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 Et({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=[]}=Qlt(r),l=Ylt(),i=Mw(),d=Xlt(),[u,p]=S.useState("idle"),[f,y]=S.useState(0),[_,b]=S.useState(0),[N,w]=S.useState(""),[k,C]=S.useState(""),[A,I]=S.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=S.useCallback(async(U,te)=>{p("uploading");try{const Y=`Recruiting: ${s}`,{videoId:J,libraryId:X}=await wE(Y),{uploadUrl:ce,apiKey:ae}=await jE(J),ie=new XMLHttpRequest;ie.upload.onprogress=Te=>{Te.lengthComputable&&y(Te.loaded/Te.total*100)},await new Promise((Te,Me)=>{ie.onload=()=>ie.status>=200&&ie.status<300?Te():Me(new Error("Upload failed")),ie.onerror=()=>Me(new Error("Upload failed")),ie.open("PUT",ce),ie.setRequestHeader("AccessKey",ae),ie.send(U)}),p("processing");let oe=0;const me=Date.now(),ye=9e4,he=`https://iframe.mediadelivery.net/embed/${X}/${J}`;for(;oe<4&&(await new Promise(Me=>setTimeout(Me,3e3)),!(Date.now()-me>ye));){const Te=await nw(J);if(oe=Te.status,b(Te.encodeProgress||0),oe===5||oe===6)throw new Error("Video processing failed")}const ge=await nw(J),Ne=(ge.storageSize||U.size)/(1024*1024),Ue=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:Ne,title:Y,status:oe>=4?"ready":"processing",touch_type:"recruiting"});await l.mutateAsync({prospect_id:t,video_id:Ue.id,brokerage_id:r,message:k||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,k,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(gn,{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(hi,{asChild:!0,children:e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>p("script"),children:[e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1"})," Record Video"]})}),e.jsxs(hs,{className:"max-w-2xl",children:[e.jsx(js,{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(Fs,{value:N,onValueChange:w,children:[e.jsx(Ds,{className:"mt-1",children:e.jsx(zs,{placeholder:"No script — speak freely"})}),e.jsxs(Rs,{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(gr,{value:k,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(K,{onClick:()=>p("record"),className:"w-full",children:[e.jsx(gn,{className:"h-4 w-4 mr-2"})," Start Recording"]})]}),u==="record"&&e.jsx(TO,{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(fi,{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(fi,{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(gn,{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(Cn,{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(Mn,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]}):e.jsxs(Qe,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(on,{className:"h-2.5 w-2.5 mr-0.5"}),"Draft"]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:gs(new Date(U.created_at),"MMM d")})]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>q(U.share_token),children:e.jsx(Wa,{className:"h-3 w-3"})}),!U.sent_at&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>d.mutate({id:U.id,sent_via:"email"}),children:e.jsx(Mn,{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 g9e=[{value:"call",label:"Phone Call",icon:In},{value:"email",label:"Email",icon:tr},{value:"text",label:"Text Message",icon:Si},{value:"meeting",label:"Meeting",icon:ln},{value:"note",label:"Note",icon:yn},{value:"campaign_email",label:"Campaign Email",icon:Mn}];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 T9({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(Zr,{className:"h-3 w-3 opacity-50"})]}):null}function Gl({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(Le,{type:n,value:s,onChange:o=>r(o.target.value),placeholder:a,className:"mt-1 h-8 text-sm"})]})}function Jlt({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]=S.useState({type:"note",title:"",description:""}),[y,_]=S.useState(!1),[b,N]=S.useState(!1),[w,k]=S.useState({});if(!t)return null;const C=()=>{var Y,J;k({first_name:t.first_name||"",last_name:t.last_name||"",email:t.email||"",phone:t.phone||"",current_brokerage:t.current_brokerage||"",license_number:t.license_number||"",experience_years:((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=>k(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(ni,{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(K,{variant:"ghost",size:"icon",onClick:I,children:e.jsx(jr,{className:"h-4 w-4"})}),e.jsx(K,{variant:"default",size:"icon",onClick:A,children:e.jsx(bc,{className:"h-4 w-4"})})]}):e.jsx(K,{variant:"ghost",size:"icon",onClick:C,title:"Edit prospect",children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsxs(Dl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(xr,{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(Fs,{value:t.stage_id||"",onValueChange:Y=>o({id:t.id,stage_id:Y}),children:[e.jsx(Ds,{className:"mt-1",children:e.jsx(zs,{})}),e.jsx(Rs,{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(ls,{value:"details",className:"text-xs",children:"Details"}),e.jsx(ls,{value:"production",className:"text-xs",children:"Production"}),e.jsx(ls,{value:"social",className:"text-xs",children:"Social"}),e.jsx(ls,{value:"personal",className:"text-xs",children:"Personal"})]}),b?e.jsxs(e.Fragment,{children:[e.jsxs(ws,{value:"details",className:"mt-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Gl,{label:"First Name",value:w.first_name,onChange:L("first_name")}),e.jsx(Gl,{label:"Last Name",value:w.last_name,onChange:L("last_name")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Gl,{label:"Email",value:w.email,onChange:L("email"),type:"email"}),e.jsx(Gl,{label:"Phone",value:w.phone,onChange:L("phone")})]}),e.jsx(Gl,{label:"Current Brokerage",value:w.current_brokerage,onChange:L("current_brokerage")}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Gl,{label:"License #",value:w.license_number,onChange:L("license_number")}),e.jsx(Gl,{label:"Experience (years)",value:w.experience_years,onChange:L("experience_years"),type:"number"})]}),e.jsx(Gl,{label:"Address",value:w.address,onChange:L("address"),placeholder:"Street address"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(Gl,{label:"City",value:w.city,onChange:L("city")}),e.jsx(Gl,{label:"State",value:w.state,onChange:L("state")}),e.jsx(Gl,{label:"Zip",value:w.zip_code,onChange:L("zip_code")})]}),e.jsx(Gl,{label:"Source",value:w.source,onChange:L("source")}),e.jsx(Gl,{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(gr,{value:w.notes,onChange:Y=>k(J=>({...J,notes:Y.target.value})),rows:3,className:"mt-1 text-sm"})]})]}),e.jsxs(ws,{value:"production",className:"mt-3 space-y-3",children:[e.jsx(Gl,{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(Gl,{label:"Last Year Volume",value:w.last_year_volume,onChange:L("last_year_volume"),placeholder:"e.g. $8.2M"}),e.jsx(Gl,{label:"Last Year Transactions",value:w.last_year_transactions,onChange:L("last_year_transactions"),type:"number",placeholder:"e.g. 24"})]}),e.jsx(Gl,{label:"Avg Sale Price",value:w.avg_sale_price,onChange:L("avg_sale_price"),placeholder:"e.g. $350K"}),e.jsx(Gl,{label:"Specialties / Niche",value:w.specialties,onChange:L("specialties"),placeholder:"e.g. Luxury, Investment"})]}),e.jsxs(ws,{value:"social",className:"mt-3 space-y-3",children:[e.jsx(Gl,{label:"LinkedIn URL",value:w.linkedin_url,onChange:L("linkedin_url"),type:"url",placeholder:"https://linkedin.com/in/..."}),e.jsx(Gl,{label:"Website URL",value:w.website_url,onChange:L("website_url"),type:"url",placeholder:"https://..."}),e.jsx(Gl,{label:"Instagram Handle",value:w.instagram_handle,onChange:L("instagram_handle"),placeholder:"@handle"}),e.jsx(Gl,{label:"Facebook URL",value:w.facebook_url,onChange:L("facebook_url"),type:"url",placeholder:"https://facebook.com/..."})]}),e.jsxs(ws,{value:"personal",className:"mt-3 space-y-3",children:[e.jsx(Gl,{label:"Birthday",value:w.birthday,onChange:L("birthday"),type:"date"}),e.jsx(Gl,{label:"Spouse / Partner",value:w.spouse_name,onChange:L("spouse_name")}),e.jsx(Gl,{label:"Interests / Hobbies",value:w.interests,onChange:L("interests"),placeholder:"Golf, travel, community events..."})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(ws,{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(ws,{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(ws,{value:"social",className:"mt-3",children:U?e.jsxs("div",{className:"space-y-2",children:[e.jsx(T9,{label:"LinkedIn",url:t.linkedin_url,icon:xp}),e.jsx(T9,{label:"Website",url:t.website_url,icon:nd}),t.instagram_handle&&e.jsx(T9,{label:t.instagram_handle,url:`https://instagram.com/${t.instagram_handle.replace("@","")}`,icon:pu}),e.jsx(T9,{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(ws,{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?gs(new Date(t.birthday+"T00:00:00"),"MMMM d, yyyy"):null,icon:yi}),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(xo,{}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"font-semibold text-sm",children:"Activity Log"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>_(!y),children:[e.jsx(Bs,{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(Fs,{value:p.type,onValueChange:Y=>f(J=>({...J,type:Y})),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsx(Rs,{children:g9e.map(Y=>e.jsx(vt,{value:Y.value,children:Y.label},Y.value))})]}),e.jsx(Le,{placeholder:"Subject / Title",value:p.title,onChange:Y=>f(J=>({...J,title:Y.target.value}))}),e.jsx(gr,{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(K,{size:"sm",variant:"ghost",onClick:()=>_(!1),children:"Cancel"}),e.jsx(K,{size:"sm",onClick:O,disabled:!p.title.trim(),children:"Save"})]})]}),e.jsx("div",{className:"space-y-3",children:(()=>{const 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,ae=g9e.find(oe=>oe.value===ce.activity_type),ie=(ae==null?void 0:ae.icon)||yn;return e.jsxs("div",{className:"flex gap-3 text-sm",children:[e.jsx("div",{className:"mt-0.5",children:e.jsx("div",{className:"h-7 w-7 rounded-full bg-muted flex items-center justify-center",children:e.jsx(ie,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium",children: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:gs(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(Mn,{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(Mn,{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(Cn,{className:"h-2.5 w-2.5 mr-0.5"})," Opened ",gs(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 ",gs(new Date(X.clicked_at),"MMM d, h:mm a")]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:gs(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 ect({open:t,onOpenChange:s,brokerageId:r,stages:n}){var U;const{toast:a}=ja(),o=Qt(),l=S.useRef(null),[i,d]=S.useState([]),[u,p]=S.useState([]),[f,y]=S.useState({}),[_,b]=S.useState(((U=n[0])==null?void 0:U.id)||""),[N,w]=S.useState(!1),[k,C]=S.useState("upload"),[A,I]=S.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 ie=((ge=ce.target)==null?void 0:ge.result).split(/\r?\n/).filter(Ne=>Ne.trim());if(ie.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(ie[0]);p(oe);const me={},ye=new Set;oe.forEach((Ne,Ue)=>{const Te=Ne.toLowerCase().replace(/[^a-z0-9]/g,"");let Me=null;/^firstname$/.test(Te)||Te==="first"?Me="first_name":/^lastname$/.test(Te)||Te==="last"?Me="last_name":/^email$/.test(Te)||Te==="emailaddress"?Me="email":/^mobile$|^phone$|^cellphone$|^mobilephone$/.test(Te)?Me="phone":/officename|currentbrokerage|brokerage|company/.test(Te)?Me="current_brokerage":/membernumber|licensenumber|license/.test(Te)?Me="license_number":/experienceyears|yearsexperience/.test(Te)?Me="experience_years":/^totalvolume$|annualproduction/.test(Te)?Me="annual_production":/^address$/.test(Te)?Me="address":/^city$/.test(Te)?Me="city":/^state$/.test(Te)?Me="state":/^postalcode$|^zip$|^zipcode$/.test(Te)?Me="zip_code":/listsidevolume|lastyearvolume/.test(Te)?Me="last_year_volume":/^totalcount$|lastyeartransactions/.test(Te)?Me="last_year_transactions":/avgsaleprice|averageprice/.test(Te)?Me="avg_sale_price":/linkedin/.test(Te)?Me="linkedin_url":/website/.test(Te)?Me="website_url":/specialt/.test(Te)?Me="specialties":/referr/.test(Te)?Me="referred_by":/^notes$|^note$/.test(Te)&&(Me="notes"),Me&&!ye.has(Me)&&(me[String(Ue)]=Me,ye.add(Me))}),y(me);const he=ie.slice(1).map(Ne=>{const Ue=V(Ne),Te={};return oe.forEach((Me,De)=>{Te[String(De)]=Ue[De]||""}),Te});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"},ae=ce;return Object.entries(f).forEach(([ie,oe])=>{var ye;const me=(ye=X[ie])==null?void 0:ye.trim();me&&(oe==="experience_years"||oe==="last_year_transactions"?ae[oe]=parseInt(me.replace(/[^0-9.-]/g,""))||null:oe==="annual_production"||oe==="last_year_volume"||oe==="avg_sale_price"?ae[oe]=me.replace(/[^0-9.$,.-]/g,""):ae[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(hs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:"Import Prospects from CSV"})}),k==="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(K,{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(K,{variant:"link",className:"text-xs",onClick:B,children:"Download CSV template"})]}),k==="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(Fs,{value:_,onValueChange:b,children:[e.jsx(Ds,{className:"w-[180px]",children:e.jsx(zs,{})}),e.jsx(Rs,{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(Ms,{children:[e.jsx(kt,{className:"w-[140px]",children:"CSV Column"}),e.jsx(kt,{className:"w-[160px]",children:"Map To"}),e.jsx(kt,{children:"Preview"})]})}),e.jsx(Rn,{children:u.map((te,Y)=>{var J;return e.jsxs(Ms,{children:[e.jsx(ht,{className:"font-medium text-xs",children:te}),e.jsx(ht,{children:e.jsxs(Fs,{value:f[String(Y)]||"skip",onValueChange:X=>y(ce=>({...ce,[String(Y)]:X==="skip"?"":X})),children:[e.jsx(Ds,{className:"h-8 text-xs",children:e.jsx(zs,{})}),e.jsxs(Rs,{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(K,{variant:"outline",onClick:()=>{L()},children:"Back"}),e.jsx(K,{onClick:q,disabled:N||!Object.values(f).includes("first_name"),children:N?"Importing...":`Import ${i.length} Prospects`})]})]}),k==="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(K,{onClick:()=>{L(),s(!1)},children:"Close"})]})]})})}function tct({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=EO(t),[i,d]=S.useState(!1),[u,p]=S.useState(),[f,y]=S.useState(null),[_,b]=S.useState(!1),[N,w]=S.useState(!1),[k,C]=S.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(),k&&(o.mutate({id:k,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(K,{variant:"outline",onClick:()=>w(!0),children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(K,{onClick:()=>{p(void 0),d(!0)},children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"})," Add Prospect"]})]})]}),e.jsxs(ni,{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(K,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>V(B.id),children:e.jsx(Bs,{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(Fue,{orientation:"horizontal"})]}),e.jsx(Zlt,{open:i,onOpenChange:d,stages:s,defaultStageId:u,onSubmit:B=>a.mutate(B),isSubmitting:a.isPending}),e.jsx(Jlt,{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(ect,{open:N,onOpenChange:w,brokerageId:t,stages:s})]})}function Ade({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=EO(t),{user:i}=qs(),d=Qt(),[u,p]=S.useState(!1),[f,y]=S.useState(null),[_,b]=S.useState(!1),[N,w]=S.useState(!1),[k,C]=S.useState(""),[A,I]=S.useState("all"),[L,O]=S.useState("all"),[V,q]=S.useState("all"),[B,U]=S.useState(null),[te,Y]=S.useState("asc"),[J,X]=S.useState(new Set),[ce,ae]=S.useState(!1),[ie,oe]=S.useState(""),me=S.useMemo(()=>{const we=new Set;return r.forEach(ut=>{ut.current_brokerage&&we.add(ut.current_brokerage)}),Array.from(we).sort()},[r]),{data:ye=[]}=gt({queryKey:["recruit-campaigns-list",t],queryFn:async()=>{const{data:we,error:ut}=await G.from("recruit_campaigns").select("id, name, warmth_level").or(`brokerage_id.is.null,brokerage_id.eq.${t}`).order("name");if(ut)throw ut;return we}}),{data:he=[]}=gt({queryKey:["recruit-campaign-assignments-lookup",t],queryFn:async()=>{let ut=[],fe=0;for(;;){const{data:He,error:et}=await G.from("recruit_campaign_assignments").select("prospect_id, campaign_id, status").eq("brokerage_id",t).range(fe,fe+1e3-1);if(et)throw et;if(ut=ut.concat(He??[]),!He||He.length<1e3)break;fe+=1e3}return ut}}),ge=S.useMemo(()=>{const we=new Map;return he.forEach(ut=>{we.has(ut.prospect_id)||we.set(ut.prospect_id,new Set),we.get(ut.prospect_id).add(ut.campaign_id)}),we},[he]),Ne=we=>{B===we?Y(ut=>ut==="asc"?"desc":"asc"):(U(we),Y("asc"))},Ue=({column:we})=>B!==we?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"}),Te=we=>s.find(ut=>ut.id===we),Me=S.useMemo(()=>{let we=r.filter(ut=>{var _e,Ge,We;const fe=!k||`${ut.first_name} ${ut.last_name}`.toLowerCase().includes(k.toLowerCase())||((_e=ut.email)==null?void 0:_e.toLowerCase().includes(k.toLowerCase()))||((Ge=ut.current_brokerage)==null?void 0:Ge.toLowerCase().includes(k.toLowerCase())),He=A==="all"||ut.stage_id===A,et=L==="all"||ut.current_brokerage===L;let tt=!0;return V==="in_campaign"?tt=ge.has(ut.id):V==="not_in_campaign"?tt=!ge.has(ut.id):V!=="all"&&(tt=((We=ge.get(ut.id))==null?void 0:We.has(V))??!1),fe&&He&&et&&tt});return B&&(we=[...we].sort((ut,fe)=>{var _e,Ge;let He=null,et=null;switch(B){case"name":He=`${ut.first_name} ${ut.last_name||""}`.toLowerCase(),et=`${fe.first_name} ${fe.last_name||""}`.toLowerCase();break;case"stage":He=((_e=Te(ut.stage_id))==null?void 0:_e.sort_order)??999,et=((Ge=Te(fe.stage_id))==null?void 0:Ge.sort_order)??999;break;case"brokerage":He=(ut.current_brokerage||"").toLowerCase(),et=(fe.current_brokerage||"").toLowerCase();break;case"experience":He=ut.experience_years??-1,et=fe.experience_years??-1;break;case"production":He=(ut.annual_production||"").toLowerCase(),et=(fe.annual_production||"").toLowerCase();break;case"source":He=(ut.source||"").toLowerCase(),et=(fe.source||"").toLowerCase();break;default:return 0}if(He===et)return 0;if(He==null)return 1;if(et==null)return-1;const tt=He0&&Me.every(we=>J.has(we.id)),qe=Me.some(we=>J.has(we.id)),ke=()=>{X(De?new Set:new Set(Me.map(we=>we.id)))},$e=we=>{X(ut=>{const fe=new Set(ut);return fe.has(we)?fe.delete(we):fe.add(we),fe})},Be=Et({mutationFn:async()=>{if(!ie||!(i!=null&&i.id))throw new Error("Select a campaign");const we=new Set(he.filter(He=>He.campaign_id===ie).map(He=>He.prospect_id)),ut=Array.from(J).filter(He=>!we.has(He)).map(He=>({prospect_id:He,campaign_id:ie,brokerage_id:t,assigned_by:i.id,status:"active",current_email_number:0}));if(ut.length===0)throw new Error("All selected prospects are already in this campaign");const{error:fe}=await G.from("recruit_campaign_assignments").insert(ut);if(fe)throw fe;return ut.length},onSuccess:we=>{pe.success(`${we} prospect(s) added to campaign`),ae(!1),X(new Set),oe(""),d.invalidateQueries({queryKey:["recruit-campaign-assignments-lookup"]})},onError:we=>pe.error(we.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(an,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search prospects...",value:k,onChange:we=>C(we.target.value),className:"pl-8"})]}),e.jsxs("div",{className:"flex gap-2",children:[J.size>0&&e.jsxs(K,{variant:"secondary",onClick:()=>ae(!0),className:"gap-1.5",children:[e.jsx(Mn,{className:"h-4 w-4"})," Add ",J.size," to Campaign"]}),e.jsxs(K,{variant:"outline",onClick:()=>w(!0),children:[e.jsx(Ra,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(K,{onClick:()=>p(!0),children:[e.jsx(Bs,{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(Fs,{value:A,onValueChange:I,children:[e.jsx(Ds,{className:"w-[160px] h-8 text-xs",children:e.jsx(zs,{placeholder:"All stages"})}),e.jsxs(Rs,{children:[e.jsx(vt,{value:"all",children:"All stages"}),s.map(we=>e.jsx(vt,{value:we.id,children:we.name},we.id))]})]}),e.jsxs(Fs,{value:L,onValueChange:O,children:[e.jsxs(Ds,{className:"w-[200px] h-8 text-xs",children:[e.jsx(pa,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx(zs,{placeholder:"All brokerages"})]}),e.jsxs(Rs,{children:[e.jsx(vt,{value:"all",children:"All brokerages"}),me.map(we=>e.jsx(vt,{value:we,children:we},we))]})]}),e.jsxs(Fs,{value:V,onValueChange:q,children:[e.jsxs(Ds,{className:"w-[200px] h-8 text-xs",children:[e.jsx(tr,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx(zs,{placeholder:"Campaign status"})]}),e.jsxs(Rs,{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"}),ye.map(we=>e.jsxs(vt,{value:we.id,children:["In: ",we.name]},we.id))]})]}),(A!=="all"||L!=="all"||V!=="all")&&e.jsx(K,{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(Ms,{children:[e.jsx(kt,{className:"w-[40px]",children:e.jsx(Hi,{checked:De,onCheckedChange:ke,"aria-label":"Select all",...qe&&!De?{"data-state":"indeterminate"}:{}})}),e.jsx(kt,{className:"cursor-pointer select-none",onClick:()=>Ne("name"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Name ",e.jsx(Ue,{column:"name"})]})}),e.jsx(kt,{className:"cursor-pointer select-none",onClick:()=>Ne("stage"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Stage ",e.jsx(Ue,{column:"stage"})]})}),e.jsx(kt,{className:"hidden md:table-cell cursor-pointer select-none",onClick:()=>Ne("brokerage"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Brokerage ",e.jsx(Ue,{column:"brokerage"})]})}),e.jsx(kt,{className:"hidden md:table-cell",children:"Contact"}),e.jsx(kt,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>Ne("experience"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Experience ",e.jsx(Ue,{column:"experience"})]})}),e.jsx(kt,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>Ne("production"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Production ",e.jsx(Ue,{column:"production"})]})}),e.jsx(kt,{className:"hidden lg:table-cell",children:"Campaigns"}),e.jsx(kt,{className:"w-[50px]"})]})}),e.jsx(Rn,{children:Me.length===0?e.jsx(Ms,{children:e.jsx(ht,{colSpan:9,className:"text-center text-muted-foreground py-8",children:"No prospects found"})}):Me.map(we=>{const ut=Te(we.stage_id),fe=ge.get(we.id),He=(fe==null?void 0:fe.size)??0;return e.jsxs(Ms,{className:"cursor-pointer",onClick:()=>{y(we),b(!0)},children:[e.jsx(ht,{onClick:et=>et.stopPropagation(),children:e.jsx(Hi,{checked:J.has(we.id),onCheckedChange:()=>$e(we.id),"aria-label":`Select ${we.first_name}`})}),e.jsxs(ht,{className:"font-medium",children:[we.first_name," ",we.last_name]}),e.jsx(ht,{children:ut?e.jsxs(Qe,{variant:"outline",className:"text-xs gap-1 whitespace-nowrap",style:{borderColor:ut.color,color:ut.color,backgroundColor:`${ut.color}10`},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:ut.color}}),ut.name]}):e.jsx("span",{className:"text-muted-foreground text-xs",children:"—"})}),e.jsx(ht,{className:"hidden md:table-cell",children:we.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:we.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:[we.email&&e.jsx(tr,{className:"h-3.5 w-3.5 text-muted-foreground"}),we.phone&&e.jsx(In,{className:"h-3.5 w-3.5 text-muted-foreground"}),!we.email&&!we.phone&&e.jsx("span",{className:"text-muted-foreground",children:"—"})]})}),e.jsx(ht,{className:"hidden lg:table-cell",children:we.experience_years!=null?`${we.experience_years} yr`:"—"}),e.jsx(ht,{className:"hidden lg:table-cell",children:we.annual_production||"—"}),e.jsx(ht,{className:"hidden lg:table-cell",children:He>0?e.jsxs(Qe,{variant:"secondary",className:"text-xs",children:[He," campaign",He>1?"s":""]}):e.jsx("span",{className:"text-muted-foreground text-xs",children:"None"})}),e.jsx(ht,{children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:et=>{et.stopPropagation(),l.mutate(we.id)},children:e.jsx(xr,{className:"h-3.5 w-3.5"})})})]},we.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 · "]}),Me.length," of ",r.length," prospects"]}),e.jsx(fs,{open:ce,onOpenChange:ae,children:e.jsxs(hs,{className:"sm:max-w-md",children:[e.jsx(js,{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(Fs,{value:ie,onValueChange:oe,children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select a campaign..."})}),e.jsx(Rs,{children:ye.map(we=>e.jsxs(vt,{value:we.id,children:[we.name," ",e.jsxs("span",{className:"text-muted-foreground ml-1",children:["(",we.warmth_level,")"]})]},we.id))})]})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>ae(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>Be.mutate(),disabled:!ie||Be.isPending,children:Be.isPending?"Adding...":"Add to Campaign"})]})]})}),e.jsx(Zlt,{open:u,onOpenChange:p,stages:s,onSubmit:we=>a.mutate(we),isSubmitting:a.isPending}),e.jsx(Jlt,{prospect:f,stages:s,brokerageId:t,open:_,onOpenChange:b,onUpdate:we=>{o.mutate(we),y(ut=>ut?{...ut,...we}:null)},onDelete:we=>l.mutate(we)}),e.jsx(ect,{open:N,onOpenChange:w,brokerageId:t,stages:s})]})}function sct({brokerageId:t}){const{stages:s,prospects:r,isLoading:n}=EO(t),a=S.useMemo(()=>{if(!s.length||!r.length)return null;const o=r.length,l=s.find(k=>k.name==="Signed"),i=s.find(k=>k.name==="Onboarded"),d=r.filter(k=>k.stage_id===(l==null?void 0:l.id)||k.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((k,C)=>k+$g(p,new Date(C.created_at)),0)/o):0,y=s.map(k=>({...k,count:r.filter(C=>C.stage_id===k.id).length})),_={};r.forEach(k=>{const C=k.source||"unknown";_[C]=(_[C]||0)+1});const b=Object.entries(_).sort((k,C)=>C[1]-k[1]),N=new Date;N.setDate(N.getDate()-30);const w=r.filter(k=>new Date(k.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(Re,{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(or,{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(Re,{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(Re,{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(on,{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(Re,{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(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Pipeline Breakdown"})}),e.jsx(Re,{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(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Lead Sources"})}),e.jsxs(Re,{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 y9e=[{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 rct({brokerageId:t}){const{toast:s}=ja(),[r,n]=S.useState(null),[a,o]=S.useState(null),l=(d,u)=>{navigator.clipboard.writeText(d),n(u),s({title:"Copied to clipboard!"}),setTimeout(()=>n(null),2e3)},i=[...new Set(y9e.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]}),y9e.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(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{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(Re,{className:"pt-0 space-y-3",children:[e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Subject Line:"}),e.jsx("p",{className:"text-sm mb-3",children:u.subject}),e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Body:"}),e.jsx("pre",{className:"text-sm whitespace-pre-wrap font-sans",children:u.body})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:p=>{p.stopPropagation(),l(u.subject,u.id+"-subject")},children:[r===u.id+"-subject"?e.jsx(Zn,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(Wa,{className:"h-3.5 w-3.5 mr-1"}),"Copy Subject"]}),e.jsxs(K,{size:"sm",onClick:p=>{p.stopPropagation(),l(u.body,u.id+"-body")},children:[r===u.id+"-body"?e.jsx(Zn,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(Wa,{className:"h-3.5 w-3.5 mr-1"}),"Copy Body"]})]})]})]},u.id))]},d))]})}const v9e={call:In,email:tr,text:Si,meeting:ln,note:yn};function nct({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=$ie(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 k=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:k}}).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(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Recruiter Leaderboard (Last 30 Days)"})}),e.jsx(Re,{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=v9e[o]||yn;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(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Recent Activity"})}),e.jsx(Re,{className:"space-y-3",children:s.recentActivities.map(n=>{const a=v9e[n.activity_type]||yn;return e.jsxs("div",{className:"flex items-start gap-3 text-sm",children:[e.jsx("div",{className:"h-7 w-7 rounded-full bg-muted flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(a,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium",children:n.title}),n.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:gs(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 act({brokerageId:t}){const{toast:s}=ja(),r=Qt(),[n,a]=S.useState(!1),[o,l]=S.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:k}=await G.from("recruit_referrals").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(k)throw k;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=Et({mutationFn:async w=>{const{data:{user:k}}=await G.auth.getUser();if(!k)throw new Error("Not authenticated");const{error:C}=await G.from("recruit_referrals").insert({brokerage_id:t,referred_by:k.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"})}),_=Et({mutationFn:async({id:w,status:k,incentive_status:C})=>{const A={updated_at:new Date().toISOString()};k&&(A.status=k),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(Ql,{className:"h-3 w-3"}):e.jsx(on,{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(K,{onClick:()=>a(!0),children:[e.jsx(Bs,{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 k;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(yi,{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: ",((k=f[w.referred_by])==null?void 0:k.name)||"Unknown"," • ",gs(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(Fs,{value:w.status,onValueChange:C=>_.mutate({id:w.id,status:C}),children:[e.jsx(Ds,{className:"h-7 text-xs w-[110px]",children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Fs,{value:w.incentive_status||"pending",onValueChange:C=>_.mutate({id:w.id,incentive_status:C}),children:[e.jsx(Ds,{className:"h-7 text-xs w-[100px]",children:e.jsx(zs,{})}),e.jsxs(Rs,{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(hs,{children:[e.jsx(js,{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(Le,{required:!0,value:o.first_name,onChange:w=>l(k=>({...k,first_name:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Last Name"}),e.jsx(Le,{value:o.last_name,onChange:w=>l(k=>({...k,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(Le,{type:"email",value:o.email,onChange:w=>l(k=>({...k,email:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Phone"}),e.jsx(Le,{value:o.phone,onChange:w=>l(k=>({...k,phone:w.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Current Brokerage"}),e.jsx(Le,{value:o.current_brokerage,onChange:w=>l(k=>({...k,current_brokerage:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Notes"}),e.jsx(gr,{value:o.notes,onChange:w=>l(k=>({...k,notes:w.target.value})),rows:2})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:y.isPending,children:"Submit"})]})]})]})})]})}function ict({brokerageId:t}){const{toast:s}=ja(),r=Qt(),[n,a]=S.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=Et({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=Et({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(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Public Interest Form"})}),e.jsxs(Re,{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(Mr,{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(K,{size:"sm",variant:"outline",onClick:p,children:n?e.jsx(Zn,{className:"h-3.5 w-3.5"}):e.jsx(Wa,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:e.jsx(Zr,{className:"h-3.5 w-3.5"})})})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"text-base",children:["Interest Submissions (",l.length,")"]})}),e.jsx(Re,{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:gs(new Date(y.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(Fs,{value:y.status,onValueChange:_=>d.mutate({id:y.id,status:_}),children:[e.jsx(Ds,{className:"h-7 text-xs w-[110px]",children:e.jsx(zs,{})}),e.jsxs(Rs,{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 oct({brokerageId:t}){const{toast:s}=ja(),r=Qt(),[n,a]=S.useState(!1),[o,l]=S.useState({prospect_id:"",title:"",description:"",due_date:gs(ml(new Date,1),"yyyy-MM-dd'T'HH:mm")}),[i,d]=S.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])),_=Et({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:gs(ml(new Date,1),"yyyy-MM-dd'T'HH:mm")}),a(!1)},onError:L=>s({title:"Error",description:L.message,variant:"destructive"})}),b=Et({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))),k=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(Hi,{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(ln,{className:"h-3 w-3"}),gs(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(K,{size:"sm",variant:i===L?"default":"outline",onClick:()=>d(L),className:"capitalize text-xs",children:[L," ",L==="pending"&&w.length+k.length+C.length>0&&`(${w.length+k.length+C.length})`]},L))}),e.jsxs(K,{size:"sm",onClick:()=>a(!0),children:[e.jsx(Bs,{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"&&k.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(on,{className:"h-3.5 w-3.5"})," Today (",k.length,")"]}),k.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(ln,{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(hs,{children:[e.jsx(js,{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(Le,{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(gr,{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(Le,{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(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{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 lct({brokerageId:t}){const{toast:s}=ja(),r=Qt(),[n,a]=S.useState(null),{data:o,isLoading:l}=gt({queryKey:["recruit-landing-settings",t],queryFn:async()=>{const{data:w,error:k}=await G.from("recruit_landing_page_settings").select("*").eq("brokerage_id",t).maybeSingle();if(k)throw k;return w}}),[i,d]=S.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});S.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=Et({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:k}=await G.from("recruit_landing_page_settings").update(w).eq("id",i.id);if(k)throw k}else{const{error:k}=await G.from("recruit_landing_page_settings").insert(w);if(k)throw k}},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,k)=>{const C=w.name.split(".").pop(),A=`${t}/${k}-${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,k)=>{var A;const C=(A=w.target.files)==null?void 0:A[0];if(C){a(k);try{const I=await p(C,k);d(L=>({...L,[k]: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 k=(C=w.target.files)==null?void 0:C[0];if(k){a("gallery");try{const A=await p(k,"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,k)=>{var A;const C=(A=w.target.files)==null?void 0:A[0];if(C){a(`testimonial-${k}`);try{const I=await p(C,`testimonial-${k}`);d(L=>{const O=[...L.testimonials];return O[k]={...O[k],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:k}=await G.from("brokerages").select("recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(k)throw k;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(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsxs("a",{href:N,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Zr,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Branding"})}),e.jsx(Re,{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(K,{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(k=>({...k,primary_color:w.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Le,{value:i.primary_color,onChange:w=>d(k=>({...k,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(k=>({...k,accent_color:w.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Le,{value:i.accent_color,onChange:w=>d(k=>({...k,accent_color:w.target.value})),className:"font-mono text-xs"})]})]})]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Hero Section"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Headline"}),e.jsx(Le,{value:i.hero_headline,onChange:w=>d(k=>({...k,hero_headline:w.target.value})),placeholder:"Join Our Team"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Subtext"}),e.jsx(gr,{value:i.hero_subtext,onChange:w=>d(k=>({...k,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(K,{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(K,{variant:"ghost",size:"sm",onClick:()=>d(w=>({...w,hero_image_url:null})),children:e.jsx(xr,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ft,{className:"text-base",children:"Benefits / Why Join Us"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>d(w=>({...w,benefits:[...w.benefits,{title:"",description:"",icon:"✨"}]})),children:[e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(Re,{className:"space-y-3",children:[i.benefits.map((w,k)=>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(Le,{value:w.icon,onChange:C=>{const A=[...i.benefits];A[k]={...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(Le,{value:w.title,onChange:C=>{const A=[...i.benefits];A[k]={...w,title:C.target.value},d(I=>({...I,benefits:A}))},placeholder:"Benefit title"}),e.jsx(Le,{value:w.description,onChange:C=>{const A=[...i.benefits];A[k]={...w,description:C.target.value},d(I=>({...I,benefits:A}))},placeholder:"Short description"})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d(C=>({...C,benefits:C.benefits.filter((A,I)=>I!==k)})),children:e.jsx(xr,{className:"h-3.5 w-3.5 text-destructive"})})]},k)),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(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ft,{className:"text-base",children:"Testimonials"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>d(w=>({...w,testimonials:[...w.testimonials,{name:"",role:"",quote:""}]})),children:[e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(Re,{className:"space-y-3",children:[i.testimonials.map((w,k)=>{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-${k}`?"...":"Photo"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:A=>_(A,k)})]})]}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(Le,{value:w.name,onChange:A=>{const I=[...i.testimonials];I[k]={...w,name:A.target.value},d(L=>({...L,testimonials:I}))},placeholder:"Name"}),e.jsx(Le,{value:w.role,onChange:A=>{const I=[...i.testimonials];I[k]={...w,role:A.target.value},d(L=>({...L,testimonials:I}))},placeholder:"Role / Title"})]}),e.jsx(gr,{value:w.quote,onChange:A=>{const I=[...i.testimonials];I[k]={...w,quote:A.target.value},d(L=>({...L,testimonials:I}))},placeholder:"What they say about working here...",rows:2})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d(A=>({...A,testimonials:A.testimonials.filter((I,L)=>L!==k)})),children:e.jsx(xr,{className:"h-3.5 w-3.5 text-destructive"})})]},k)}),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(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ft,{className:"text-base",children:"Team & Culture Gallery"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{size:"sm",variant:"outline",asChild:!0,disabled:n==="gallery",children:e.jsxs("span",{children:[e.jsx(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(Re,{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,k)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:w,alt:`Gallery ${k+1}`,className:"h-24 w-full object-cover rounded-lg"}),e.jsx(K,{variant:"destructive",size:"sm",className:"absolute top-1 right-1 h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>d(C=>({...C,gallery_images:C.gallery_images.filter((A,I)=>I!==k)})),children:e.jsx(xr,{className:"h-3 w-3"})})]},k))}):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(Lt,{children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(Or,{className:"h-4 w-4 text-primary"})," Form Style & Trust"]})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Application Form Style"}),e.jsxs(Fs,{value:i.form_style,onValueChange:w=>d(k=>({...k,form_style:w})),children:[e.jsx(Ds,{className:"mt-1.5",children:e.jsx(zs,{})}),e.jsxs(Rs,{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(vd,{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(Mr,{checked:i.confidential_messaging,onCheckedChange:w=>d(k=>({...k,confidential_messaging:w}))})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(_M,{className:"h-4 w-4 text-primary"})," Split & Income Calculator"]}),e.jsx(Mr,{checked:i.calculator_enabled,onCheckedChange:w=>d(k=>({...k,calculator_enabled:w}))})]}),i.calculator_enabled&&e.jsxs(Re,{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(Le,{value:i.calculator_config.headline||"",onChange:w=>d(k=>({...k,calculator_config:{...k.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(Le,{value:i.calculator_config.subtext||"",onChange:w=>d(k=>({...k,calculator_config:{...k.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(Le,{type:"number",value:i.calculator_config.commission_split_pct??80,onChange:w=>d(k=>({...k,calculator_config:{...k.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(Le,{type:"number",value:i.calculator_config.cap_amount??16e3,onChange:w=>d(k=>({...k,calculator_config:{...k.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(Le,{type:"number",value:i.calculator_config.monthly_fee??99,onChange:w=>d(k=>({...k,calculator_config:{...k.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(Le,{type:"number",value:i.calculator_config.transaction_fee??0,onChange:w=>d(k=>({...k,calculator_config:{...k.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(Mr,{checked:i.calculator_config.show_email_capture!==!1,onCheckedChange:w=>d(k=>({...k,calculator_config:{...k.calculator_config,show_email_capture:w}}))})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs(Ft,{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(Mr,{checked:i.lead_magnet_enabled,onCheckedChange:w=>d(k=>({...k,lead_magnet_enabled:w}))})]}),i.lead_magnet_enabled&&e.jsxs(Re,{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(Le,{value:i.lead_magnet_config.title||"",onChange:w=>d(k=>({...k,lead_magnet_config:{...k.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(gr,{rows:2,value:i.lead_magnet_config.description||"",onChange:w=>d(k=>({...k,lead_magnet_config:{...k.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(Le,{value:i.lead_magnet_config.button_text||"",onChange:w=>d(k=>({...k,lead_magnet_config:{...k.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(Le,{value:i.lead_magnet_config.pdf_url||"",onChange:w=>d(k=>({...k,lead_magnet_config:{...k.lead_magnet_config,pdf_url:w.target.value||null}})),placeholder:"https://...",className:"flex-1"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{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 k=(C=w.target.files)==null?void 0:C[0];if(k){a("lead_magnet_pdf");try{const A=await p(k,"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(K,{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(Lt,{children:e.jsxs(Ft,{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(Re,{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:[gs(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(Cn,{className:"h-3 w-3 mr-1"}),t.view_count," views"]}):t.sent_at?e.jsxs(Qe,{variant:"secondary",children:[e.jsx(Mn,{className:"h-3 w-3 mr-1"}),"Sent"]}):e.jsxs(Qe,{variant:"outline",children:[e.jsx(on,{className:"h-3 w-3 mr-1"}),"Draft"]})}function cct({brokerageId:t}){const{data:s=[],isLoading:r}=PSs(t),{data:n=[]}=Qlt(t),a=LSs(),o=DSs(),l=Xlt(),[i,d]=S.useState(""),[u,p]=S.useState(!1),[f,y]=S.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=S.useCallback(C=>{if(!C)return;const A=`${window.location.origin}/recruit-video/${C}`;navigator.clipboard.writeText(A),pe.success("Share link copied")},[]),w=S.useCallback((C,A)=>{l.mutate({id:C,sent_via:A})},[l]),k=()=>{!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:gn,color:"text-primary"},{label:"Sent",value:b.sent,icon:Mn,color:"text-blue-500"},{label:"Viewed",value:b.viewed,icon:Cn,color:"text-amber-500"},{label:"CTA Clicked",value:b.ctaClicked,icon:Hn,color:"text-emerald-500"}].map(C=>e.jsx(Pe,{children:e.jsxs(Re,{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(ls,{value:"videos",children:[e.jsx(gn,{className:"h-4 w-4 mr-1.5"}),"All Videos"]}),e.jsxs(ls,{value:"scripts",children:[e.jsx(yn,{className:"h-4 w-4 mr-1.5"}),"Script Library"]}),e.jsxs(ls,{value:"analytics",children:[e.jsx(so,{className:"h-4 w-4 mr-1.5"}),"Engagement"]})]}),e.jsx(ws,{value:"videos",children:e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ft,{className:"text-lg",children:"Video Outreach"}),e.jsxs("div",{className:"relative w-64",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name or title...",value:i,onChange:C=>d(C.target.value),className:"pl-9"})]})]})}),e.jsx(Re,{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(gn,{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(gn,{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:[gs(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(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>N(C.share_token),title:"Copy share link",children:e.jsx(Wa,{className:"h-4 w-4"})}),!C.sent_at&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>w(C.id,"email"),title:"Mark as sent",children:e.jsx(Mn,{className:"h-4 w-4"})}),C.share_token&&e.jsx(K,{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(Zr,{className:"h-4 w-4"})})]})]},C.id)})})})]})}),e.jsx(ws,{value:"scripts",children:e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ft,{className:"text-lg",children:"Recruiting Scripts"}),e.jsxs(fs,{open:u,onOpenChange:p,children:[e.jsx(hi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Bs,{className:"h-4 w-4 mr-1.5"}),"New Script"]})}),e.jsxs(hs,{children:[e.jsx(js,{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(Le,{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(Fs,{value:f.category,onValueChange:C=>y(A=>({...A,category:C})),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsx(Rs,{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(gr,{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(K,{onClick:k,disabled:!f.title.trim()||!f.script_text.trim(),className:"w-full",children:"Save Script"})]})]})]})]})}),e.jsx(Re,{children:n.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(yn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No scripts yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Create teleprompter scripts for common recruiting conversations"})]}):e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:n.map(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(Re,{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(K,{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(xr,{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(ws,{value:"analytics",children:e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"Engagement Funnel"})}),e.jsxs(Re,{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(Cn,{className:"h-3.5 w-3.5"})," ",C.view_count]}),C.cta_clicked_at&&e.jsx(Hn,{className:"h-4 w-4 text-emerald-500"})]})]},C.id)})})]})]})]})})]})]})}function dct({brokerageId:t}){const{toast:s}=ja(),r=Qt(),{stages:n,prospects:a}=EO(t),[o,l]=S.useState(!1),[i,d]=S.useState({title:"",target_count:"10",target_stage_id:"",period_start:gs(new Date,"yyyy-MM-dd"),period_end:gs(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=Et({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=Et({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(k=>k.id===b.target_stage_id);return{count:a.filter(k=>gg(new Date(k.created_at),{start:new Date(b.period_start),end:new Date(b.period_end)})?b.target_stage_id?k.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(K,{size:"sm",onClick:()=>l(!0),children:[e.jsx(Bs,{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),k=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(Lt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{className:"text-sm",children:b.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[gs(new Date(b.period_start),"MMM d")," – ",gs(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(K,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground",onClick:()=>y.mutate(b.id),children:e.jsx(xr,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(Re,{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(fi,{value:k,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[k.toFixed(0),"% complete"]})]})]},b.id)})}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(hs,{children:[e.jsx(js,{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(Le,{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(Le,{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(Le,{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(Le,{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(K,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:f.isPending,children:"Create Goal"})]})]})]})})]})}const USs={first_name:"Sarah",brokerage_name:"ABC Realty",city:"Austin",sender_name:"Jeremy"};function uct({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(hs,{className:"max-w-2xl max-h-[85vh] overflow-y-auto p-0",children:[e.jsxs(js,{className:"px-6 pt-6 pb-4 border-b",children:[e.jsxs(_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(on,{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 HCe({brokerageId:t}){const s=Qt(),[r,n]=S.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}});S.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=Et({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(Le,{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(Le,{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(Le,{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(Ult,{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(Le,{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(Le,{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(Le,{value:r.merge_fields.sender_name||"",onChange:d=>i("sender_name",d.target.value),placeholder:"e.g. Jeremy"})]})]})]}),e.jsxs(K,{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()}}}),_9e=[{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(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:t,disabled:r,className:`h-8 w-8 p-0 ${s?"bg-accent text-accent-foreground":"text-muted-foreground hover:text-foreground"}`,children:e.jsx(n,{className:"h-4 w-4"})})}),e.jsx(Ll,{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())}});S.useEffect(()=>{r&&t!==r.getHTML()&&r.commands.setContent(t)},[t,r]);const n=S.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=S.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(xo,{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(xo,{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(xo,{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(xo,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(Qu,{onClick:n,active:r.isActive("link"),icon:go,tooltip:"Insert Link"}),e.jsx(xo,{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(K,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1.5 text-xs font-medium",onClick:()=>{r&&r.chain().focus().insertContent('

Learn More About Us

').run()},children:"🔘 CTA Button"}),e.jsxs(Hd,{children:[e.jsx(Gd,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1.5 text-xs font-medium",children:[e.jsx(FM,{className:"h-3.5 w-3.5"}),"Merge Tags"]})}),e.jsx(Nd,{align:"end",className:"w-56",children:_9e.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:"}),_9e.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(hs,{className:"max-w-3xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(js,{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(Mn,{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(A9,{icon:tr,color:"text-blue-500",label:"Total Sent",value:n.sent.toLocaleString()}),e.jsx(A9,{icon:Cn,color:"text-amber-500",label:"Opens",value:`${n.opened.toLocaleString()}`,sub:`${n.openRate.toFixed(1)}% open rate`}),e.jsx(A9,{icon:Tm,color:"text-green-500",label:"Clicks",value:`${n.clicked.toLocaleString()}`,sub:`${n.clickRate.toFixed(1)}% click rate`}),e.jsx(A9,{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(on,{className:"h-3 w-3"})," Last sent: ",gs(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(Re,{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(Cn,{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 A9({icon:t,color:s,label:r,value:n,sub:a}){return e.jsx(Pe,{children:e.jsx(Re,{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 hct(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 b9e={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 mct({brokerageId:t}){var De,qe,ke,$e;const{user:s}=qs(),r=Qt(),[n,a]=S.useState(null),[o,l]=S.useState(null),[i,d]=S.useState(null),[u,p]=S.useState(!1),[f,y]=S.useState(!1),[_,b]=S.useState("editor"),[N,w]=S.useState(null),[k,C]=S.useState(null),{data:A={}}=hct(t),[I,L]=S.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:Be,error:we}=await G.from("brokerages").select("name, city, state").eq("id",t).single();if(we)throw we;return Be}}),{data:V}=gt({queryKey:["brokerage-recruit-settings",t],queryFn:async()=>{const{data:Be,error:we}=await G.from("brokerage_recruit_settings").select("*").eq("brokerage_id",t).maybeSingle();if(we)throw we;return Be}}),q={first_name:"Sarah",brokerage_name:((De=V==null?void 0:V.merge_fields)==null?void 0:De.brokerage_name)||(O==null?void 0:O.name)||"Your Brokerage",city:((qe=V==null?void 0:V.merge_fields)==null?void 0:qe.city)||(O==null?void 0:O.city)||"Your City",sender_name:((ke=V==null?void 0:V.merge_fields)==null?void 0:ke.sender_name)||(V==null?void 0:V.sender_name)||"Your Name"},B=Be=>Be.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:Be,error:we}=await G.from("recruit_campaigns").select("*").or(`brokerage_id.is.null,brokerage_id.eq.${t}`).order("sort_order");if(we)throw we;return Be}}),{data:Y={}}=gt({queryKey:["recruit-campaign-emails",t],enabled:U.length>0,queryFn:async()=>{const Be=U.map(He=>He.id),{data:we,error:ut}=await G.from("recruit_campaign_emails").select("*").in("campaign_id",Be).order("email_number");if(ut)throw ut;const fe={};return we.forEach(He=>{fe[He.campaign_id]||(fe[He.campaign_id]=[]),fe[He.campaign_id].push(He)}),fe}}),J=Object.values(Y).flat().map(Be=>Be.id),{data:X=[]}=gt({queryKey:["recruit-subject-overrides",t],enabled:J.length>0,queryFn:async()=>{const{data:Be,error:we}=await G.from("recruit_brokerage_subject_overrides").select("*").eq("brokerage_id",t);if(we)throw we;return Be}}),ce={};X.forEach(Be=>{ce[Be.campaign_email_id]=Be.selected_subject_index});const ae=Et({mutationFn:async({campaignEmailId:Be,selectedIndex:we})=>{const{error:ut}=await G.from("recruit_brokerage_subject_overrides").upsert({brokerage_id:t,campaign_email_id:Be,selected_subject_index:we,updated_at:new Date().toISOString()},{onConflict:"brokerage_id,campaign_email_id"});if(ut)throw ut},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-subject-overrides",t]}),pe.success("Subject line updated for your brokerage")},onError:Be=>pe.error(Be.message)}),ie=Et({mutationFn:async Be=>{const{error:we}=await G.from("recruit_campaign_emails").update({title:Be.title,subject_line:Be.subject_line,subject_line_options:Be.subject_line_options,body_html:Be.body_html,body_text:Be.body_text,delay_days:Be.delay_days,updated_at:new Date().toISOString()}).eq("id",Be.id);if(we)throw we},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),pe.success("Email template saved!"),l(null)},onError:Be=>pe.error(Be.message)}),oe=Et({mutationFn:async()=>{const Be=I.name.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),{data:we,error:ut}=await G.from("recruit_campaigns").insert({name:I.name,slug:Be,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(ut)throw ut;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:He}=await G.from("recruit_campaign_emails").insert(fe.map(et=>({campaign_id:we.id,...et,body_html:"

Hi {{first_name}},

Write your message here...

Best,
{{sender_name}}

",body_text:"",subject_line_options:[],is_active:!0})));if(He)throw He;return we},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:Be=>pe.error(Be.message)}),me=Et({mutationFn:async Be=>{const{error:we}=await G.from("recruit_campaigns").update({name:Be.name,description:Be.description,theme:Be.theme,goal:Be.goal,primary_cta:Be.primary_cta,warmth_level:Be.warmth_level,sender_name:Be.sender_name,sender_email:Be.sender_email,reply_to_email:Be.reply_to_email,updated_at:new Date().toISOString()}).eq("id",Be.id);if(we)throw we},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaigns"]}),pe.success("Campaign settings saved!"),w(null)},onError:Be=>pe.error(Be.message)}),ye=Et({mutationFn:async Be=>{var tt,_e;const{data:we}=await G.from("recruit_campaign_emails").select("email_number, delay_days").eq("campaign_id",Be).order("email_number",{ascending:!1}).limit(1),ut=((tt=we==null?void 0:we[0])==null?void 0:tt.email_number)??0,fe=((_e=we==null?void 0:we[0])==null?void 0:_e.delay_days)??0,He=ut+1,{error:et}=await G.from("recruit_campaign_emails").insert({campaign_id:Be,email_number:He,title:`Email ${He}`,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(et)throw et},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),pe.success("Email added to campaign!")},onError:Be=>pe.error(Be.message)}),he=Et({mutationFn:async Be=>{const{error:we}=await G.from("recruit_campaigns").delete().eq("id",Be);if(we)throw we},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaigns"]}),r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),pe.success("Campaign deleted")},onError:Be=>pe.error(Be.message)}),ge=Et({mutationFn:async Be=>{const{error:we}=await G.from("recruit_campaign_emails").delete().eq("id",Be);if(we)throw we},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),pe.success("Email removed from campaign")},onError:Be=>pe.error(Be.message)}),Ne=Et({mutationFn:async({emailId:Be,delay_days:we})=>{const{error:ut}=await G.from("recruit_campaign_emails").update({delay_days:we,updated_at:new Date().toISOString()}).eq("id",Be);if(ut)throw ut},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),pe.success("Send delay updated")},onError:Be=>pe.error(Be.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 Ue=U.filter(Be=>!Be.brokerage_id),Te=U.filter(Be=>Be.brokerage_id===t);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold",children:"Recruiting Campaigns"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"System campaigns + custom campaigns · Each can have its own email settings"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>p(!0),className:"gap-1.5",children:[e.jsx(So,{className:"h-4 w-4"})," Default Settings"]}),e.jsxs(K,{size:"sm",onClick:()=>y(!0),className:"gap-1.5",children:[e.jsx(Bs,{className:"h-4 w-4"})," New Campaign"]})]})]}),e.jsx(Pe,{className:"border-primary/20 bg-primary/5",children:e.jsx(Re,{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."]})]})]})})}),Te.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:Te.map(Be=>Me(Be,!0))})]}),Ue.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-2",children:[e.jsx(Or,{className:"h-4 w-4"})," System Campaigns"]}),e.jsx("div",{className:"space-y-3",children:Ue.map(Be=>Me(Be,!1))})]}),U.length===0&&e.jsx(Pe,{children:e.jsxs(Re,{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(K,{className:"mt-4",onClick:()=>y(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"})," Create Campaign"]})]})}),e.jsx(GSs,{open:!!k,onClose:()=>C(null),campaignName:(k==null?void 0:k.name)||"",stat:k&&A[k.id]||null}),i&&e.jsx(uct,{email:i,mergeValues:q,selectedSubjectIndex:ce[i.id],onClose:()=>d(null)}),e.jsx(fs,{open:!!o,onOpenChange:Be=>!Be&&l(null),children:e.jsxs(hs,{className:"max-w-4xl max-h-[90vh] overflow-y-auto p-0",children:[e.jsxs(js,{className:"px-6 pt-6 pb-4 border-b",children:[e.jsxs(_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(Le,{value:o.title,onChange:Be=>l({...o,title:Be.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(Le,{type:"number",min:0,max:90,value:o.delay_days,onChange:Be=>l({...o,delay_days:parseInt(Be.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(Le,{value:o.subject_line,onChange:Be=>l({...o,subject_line:Be.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(gr,{value:(($e=o.subject_line_options)==null?void 0:$e.join(` `))||"",onChange:Be=>l({...o,subject_line_options:Be.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:Be=>b(Be),children:e.jsxs(Jn,{className:"h-7",children:[e.jsx(ls,{value:"editor",className:"text-xs px-3 h-6",children:"Editor"}),e.jsx(ls,{value:"preview",className:"text-xs px-3 h-6",children:"Preview"})]})})]}),_==="editor"?e.jsx(HSs,{content:o.body_html,onChange:Be=>l({...o,body_html:Be})}):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(K,{variant:"outline",size:"sm",onClick:()=>l(null),children:"Cancel"}),e.jsxs(K,{size:"sm",onClick:()=>ie.mutate(o),disabled:ie.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(hs,{className:"max-w-lg",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(Bs,{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(Le,{value:I.name,onChange:Be=>L({...I,name:Be.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(Fs,{value:I.warmth_level,onValueChange:Be=>L({...I,warmth_level:Be}),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Le,{value:I.primary_cta,onChange:Be=>L({...I,primary_cta:Be.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(gr,{value:I.description,onChange:Be=>L({...I,description:Be.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(Le,{value:I.goal,onChange:Be=>L({...I,goal:Be.target.value}),placeholder:"e.g. Convert warm leads to meetings"})]}),e.jsxs(lf,{children:[e.jsx(cf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs font-medium text-muted-foreground hover:text-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(tr,{className:"h-3.5 w-3.5"})," Email Settings Override"]}),e.jsx(Fi,{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(Le,{value:I.sender_name,onChange:Be=>L({...I,sender_name:Be.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(Le,{value:I.sender_email,onChange:Be=>L({...I,sender_email:Be.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(Le,{value:I.reply_to_email,onChange:Be=>L({...I,reply_to_email:Be.target.value}),placeholder:"e.g. jeremy@mybrokerage.com"})]})]})]}),e.jsxs(K,{className:"w-full",disabled:!I.name.trim()||oe.isPending,onClick:()=>oe.mutate(),children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"})," Create Campaign"]})]})]})}),e.jsx(fs,{open:!!N,onOpenChange:Be=>!Be&&w(null),children:e.jsxs(hs,{className:"max-w-lg",children:[e.jsxs(js,{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(Le,{value:N.name,onChange:Be=>w({...N,name:Be.target.value})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-xs font-medium",children:"Warmth Level"}),e.jsxs(Fs,{value:N.warmth_level,onValueChange:Be=>w({...N,warmth_level:Be}),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Le,{value:N.goal||"",onChange:Be=>w({...N,goal:Be.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(Le,{value:N.sender_name||"",onChange:Be=>w({...N,sender_name:Be.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(Le,{value:N.sender_email||"",onChange:Be=>w({...N,sender_email:Be.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(Le,{value:N.reply_to_email||"",onChange:Be=>w({...N,reply_to_email:Be.target.value}),placeholder:"Uses brokerage default"})]})]}),e.jsxs(K,{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(hs,{className:"max-w-lg",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Default Recruiting Email Settings"}),e.jsx(Ir,{children:"These defaults apply to campaigns without their own overrides."})]}),e.jsx(HCe,{brokerageId:t})]})})]});function Me(Be,we){const ut=b9e[Be.warmth_level]||b9e.cold,fe=ut.icon,He=Y[Be.id]||[],et=n===Be.id,tt=!!(Be.sender_name||Be.sender_email||Be.reply_to_email),_e=A[Be.id];return e.jsxs(Pe,{className:"overflow-hidden transition-shadow hover:shadow-md",children:[e.jsx(Lt,{className:"cursor-pointer hover:bg-muted/40 transition-colors py-4",onClick:()=>a(et?null:Be.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 ${ut.bg} flex items-center justify-center`,children:e.jsx(fe,{className:`h-5 w-5 ${ut.color}`})}),e.jsxs("div",{children:[e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[Be.name,e.jsx(Qe,{variant:Be.is_active?"default":"secondary",className:"text-[10px] px-1.5",children:Be.is_active?"Active":"Draft"}),we&&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(ur,{className:"text-xs mt-0.5",children:Be.theme||Be.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:Ge=>{Ge.stopPropagation(),w({...Be})},children:e.jsx(So,{className:"h-4 w-4 text-muted-foreground"})}),we&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:Ge=>{Ge.stopPropagation(),confirm("Delete this campaign and all its emails? This cannot be undone.")&&he.mutate(Be.id)},children:e.jsx(xr,{className:"h-4 w-4"})}),_e&&_e.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"})," ",_e.sent.toLocaleString()]}),e.jsxs(Qe,{variant:"outline",className:"text-[10px] gap-1 border-amber-500/30 text-amber-600 font-medium",title:`${_e.openRate.toFixed(1)}% open rate`,children:[e.jsx(Cn,{className:"h-2.5 w-2.5"})," ",_e.opened.toLocaleString()," (",_e.openRate.toFixed(0),"%)"]}),e.jsxs(Qe,{variant:"outline",className:"text-[10px] gap-1 border-green-500/30 text-green-600 font-medium",title:`${_e.clickRate.toFixed(1)}% click rate`,children:[e.jsx(Tm,{className:"h-2.5 w-2.5"})," ",_e.clicked.toLocaleString()," (",_e.clickRate.toFixed(1),"%)"]})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 px-2 gap-1 text-xs",onClick:Ge=>{Ge.stopPropagation(),C(Be)},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:[He.length," emails"]})]}),e.jsx("div",{className:"h-7 w-7 rounded-md flex items-center justify-center",children:et?e.jsx(af,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Fi,{className:"h-4 w-4 text-muted-foreground"})})]})]})}),et&&e.jsxs(Re,{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:Be.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:Be.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:[Be.sender_name&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Name:"})," ",Be.sender_name]}),Be.sender_email&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Email:"})," ",Be.sender_email]}),Be.reply_to_email&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Reply-To:"})," ",Be.reply_to_email]})]})]}),e.jsx("div",{className:"relative",children:He.map((Ge,We)=>{var it,Ve;return e.jsxs("div",{className:"relative flex gap-4 pb-4 last:pb-0",children:[WeXe.stopPropagation(),onBlur:Xe=>{const dt=parseInt(Xe.target.value)||0;dt!==Ge.delay_days&&Ne.mutate({emailId:Ge.id,delay_days:dt})},onKeyDown:Xe=>{Xe.key==="Enter"&&Xe.target.blur()}}),"days"]})]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(on,{className:"h-3 w-3"}),Ge.email_number===1?"Sent immediately":`Day ${Ge.delay_days}`]}),e.jsx("span",{className:"text-border",children:"•"}),e.jsxs("span",{className:"truncate",children:["Subject: ",B(((it=Ge.subject_line_options)==null?void 0:it.length)>0&&Ge.subject_line_options[ce[Ge.id]??0]||Ge.subject_line)]})]}),((Ve=Ge.subject_line_options)==null?void 0:Ve.length)>1&&e.jsx("div",{className:"mt-2",children:e.jsxs(Fs,{value:String(ce[Ge.id]??0),onValueChange:Xe=>ae.mutate({campaignEmailId:Ge.id,selectedIndex:parseInt(Xe)}),children:[e.jsx(Ds,{className:"h-7 text-xs w-full max-w-sm",children:e.jsx(zs,{placeholder:"Choose subject line"})}),e.jsx(Rs,{children:Ge.subject_line_options.map((Xe,dt)=>e.jsxs(vt,{value:String(dt),className:"text-xs",children:[e.jsxs("span",{className:"font-medium mr-1.5",children:[dt===0?"Primary":`Alt ${dt}`,":"]}),B(Xe)]},dt))})]})})]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>d(Ge),children:e.jsx(Cn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{l({...Ge}),b("editor")},children:e.jsx(ga,{className:"h-4 w-4"})}),we&&He.length>1&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>{confirm("Delete this email from the sequence?")&&ge.mutate(Ge.id)},children:e.jsx(xr,{className:"h-4 w-4"})})]})]})})]},Ge.id)})}),we&&e.jsxs(K,{variant:"outline",size:"sm",className:"w-full gap-1.5",onClick:()=>ye.mutate(Be.id),disabled:ye.isPending,children:[e.jsx(Bs,{className:"h-3.5 w-3.5"})," Add Email to Sequence"]})]})]},Be.id)}}const w9e={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:ti,color:"bg-blue-500/10 text-blue-600",label:"Completed"},cancelled:{icon:Ql,color:"bg-red-500/10 text-red-600",label:"Cancelled"}},j9e={sent:{icon:tr,color:"text-blue-500"},opened:{icon:Cn,color:"text-amber-500"},clicked:{icon:Tm,color:"text-green-500"},failed:{icon:Dc,color:"text-destructive"}};function pct({brokerageId:t}){var De,qe,ke,$e,Be;const{user:s}=qs(),r=Qt(),[n,a]=S.useState(!1),[o,l]=S.useState(""),[i,d]=S.useState(new Set),[u,p]=S.useState("assignments"),[f,y]=S.useState(null),[_,b]=S.useState(""),[N,w]=S.useState("all"),[k,C]=S.useState("all"),{data:A={}}=gt({queryKey:["recruit-campaign-emails-for-preview",t],queryFn:async()=>{const{data:we,error:ut}=await G.from("recruit_campaign_emails").select("*").order("email_number");if(ut)throw ut;const fe={};return(we??[]).forEach(He=>{fe[He.campaign_id]||(fe[He.campaign_id]=[]),fe[He.campaign_id].push(He)}),fe}}),{data:I}=gt({queryKey:["brokerage-detail",t],queryFn:async()=>{const{data:we,error:ut}=await G.from("brokerages").select("name, city, state").eq("id",t).single();if(ut)throw ut;return we}}),{data:L}=gt({queryKey:["brokerage-recruit-settings",t],queryFn:async()=>{const{data:we,error:ut}=await G.from("brokerage_recruit_settings").select("*").eq("brokerage_id",t).maybeSingle();if(ut)throw ut;return we}}),{data:O=[]}=gt({queryKey:["recruit-subject-overrides",t],queryFn:async()=>{const{data:we,error:ut}=await G.from("recruit_brokerage_subject_overrides").select("*").eq("brokerage_id",t);if(ut)throw ut;return we}}),V={};O.forEach(we=>{V[we.campaign_email_id]=we.selected_subject_index});const q={first_name:((De=f==null?void 0:f.prospect)==null?void 0:De.first_name)||"Sarah",brokerage_name:((qe=L==null?void 0:L.merge_fields)==null?void 0:qe.brokerage_name)||(I==null?void 0:I.name)||"Your Brokerage",city:((ke=L==null?void 0:L.merge_fields)==null?void 0:ke.city)||(I==null?void 0:I.city)||"Your City",sender_name:(($e=L==null?void 0:L.merge_fields)==null?void 0:$e.sender_name)||(L==null?void 0:L.sender_name)||"Your Name"},B=we=>{const ut=A[we.campaign_id]||[],fe=we.current_email_number+1;return ut.find(He=>He.email_number===fe)||null},{data:U=[],isLoading:te}=gt({queryKey:["recruit-campaign-assignments",t],queryFn:async()=>{let ut=[],fe=0;for(;;){const{data:He,error:et}=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(et)throw et;if(ut=ut.concat(He??[]),!He||He.length<1e3)break;fe+=1e3}return ut}}),{data:Y=[]}=gt({queryKey:["recruit-campaign-sends",t],queryFn:async()=>{const{data:we,error:ut}=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(ut)throw ut;return we}}),{data:J=[]}=gt({queryKey:["recruit-campaigns"],queryFn:async()=>{const{data:we,error:ut}=await G.from("recruit_campaigns").select("id, name, warmth_level").eq("is_active",!0).order("sort_order");if(ut)throw ut;return we}}),{data:X=[]}=gt({queryKey:["recruit-prospects-for-assign",t],queryFn:async()=>{let ut=[],fe=0;for(;;){const{data:He,error:et}=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(et)throw et;if(ut=ut.concat(He??[]),!He||He.length<1e3)break;fe+=1e3}return ut}}),ce=new Set(U.map(we=>`${we.prospect_id}-${we.campaign_id}`)),ae=Et({mutationFn:async()=>{if(!o||i.size===0)throw new Error("Select a campaign and at least one prospect");const we=new Date,ut=Array.from(i).filter(He=>!ce.has(`${He}-${o}`)).map(He=>({prospect_id:He,campaign_id:o,brokerage_id:t,assigned_by:s.id,status:"active",current_email_number:0,next_send_at:we.toISOString(),started_at:we.toISOString()}));if(ut.length===0)throw new Error("All selected prospects are already assigned to this campaign");const{error:fe}=await G.from("recruit_campaign_assignments").insert(ut);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:we=>pe.error(we.message)}),ie=Et({mutationFn:async({id:we,newStatus:ut})=>{const{error:fe}=await G.from("recruit_campaign_assignments").update({status:ut,updated_at:new Date().toISOString()}).eq("id",we);if(fe)throw fe},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),pe.success("Assignment updated")}}),oe=Et({mutationFn:async()=>{const{data:we,error:ut}=await G.functions.invoke("ses-recruit-drip",{body:{action:"process_drips"}});if(ut)throw ut;return we},onSuccess:we=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),r.invalidateQueries({queryKey:["recruit-campaign-sends",t]}),pe.success(`Wave sent! ${we.sent} emails delivered, ${we.skipped} skipped, ${we.failed} failed`)},onError:we=>pe.error(`Send failed: ${we.message}`)}),me=U.filter(we=>we.status==="active").length;U.filter(we=>we.status==="completed").length;const ye=U.filter(we=>we.status==="active"&&we.next_send_at&&new Date(we.next_send_at)<=new Date).length,{data:he={}}=hct(t),ge=U.reduce((we,ut)=>we+Math.max(0,ut.current_email_number||0),0),Ne=Object.values(he).reduce((we,ut)=>we+ut.opened,0),Ue=Object.values(he).reduce((we,ut)=>we+ut.clicked,0);Object.values(he).reduce((we,ut)=>we+ut.failed,0);const Te=ge>0?Math.round(Ne/ge*100):0,Me=ge>0?Ue/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:[ye>0&&e.jsxs(K,{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 (${ye})`]}),e.jsxs(K,{onClick:()=>a(!0),children:[e.jsx(Mn,{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(Re,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(or,{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(Re,{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(Re,{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(Re,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(Cn,{className:"h-7 w-7 text-amber-500"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xl font-bold",children:[Te,"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Open Rate (",Ne.toLocaleString(),")"]})]})]})}),e.jsx(Pe,{children:e.jsxs(Re,{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:[Me.toFixed(1),"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Click Rate (",Ue.toLocaleString(),")"]})]})]})})]}),e.jsxs(ta,{value:u,onValueChange:p,children:[e.jsxs(Jn,{children:[e.jsxs(ls,{value:"assignments",children:["Active Drips (",me,")"]}),e.jsxs(ls,{value:"history",children:["Send History (",ge.toLocaleString(),")"]})]}),e.jsx(ws,{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(Re,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(Mn,{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(we=>{var _e,Ge,We,it;const ut=w9e[we.status]||w9e.active,fe=ut.icon,et=(A[we.campaign_id]||[]).length||4,tt=B(we);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 ${ut.color} border-0`,children:[e.jsx(fe,{className:"h-3 w-3 mr-1"}),ut.label]}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(_e=we.prospect)==null?void 0:_e.first_name," ",(Ge=we.prospect)==null?void 0:Ge.last_name,e.jsx("span",{className:"text-muted-foreground font-normal ml-2",children:(We=we.prospect)==null?void 0:We.email})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(it=we.campaign)==null?void 0:it.name," · Email ",we.current_email_number,"/",et,we.next_send_at&&we.status==="active"&&e.jsxs(e.Fragment,{children:[" ","· ",e.jsx(on,{className:"h-3 w-3 inline"})," Next: ",gs(new Date(we.next_send_at),"MMM d, h:mm a"),new Date(we.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(K,{variant:"ghost",size:"sm",title:"Preview next email",onClick:()=>y(we),children:e.jsx(Cn,{className:"h-3.5 w-3.5"})}),we.status==="active"&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ie.mutate({id:we.id,newStatus:"paused"}),children:e.jsx(hh,{className:"h-3.5 w-3.5"})}),we.status==="paused"&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ie.mutate({id:we.id,newStatus:"active"}),children:e.jsx(Co,{className:"h-3.5 w-3.5"})}),(we.status==="active"||we.status==="paused")&&e.jsx(K,{variant:"ghost",size:"sm",className:"text-destructive",onClick:()=>ie.mutate({id:we.id,newStatus:"cancelled"}),children:e.jsx(Ql,{className:"h-3.5 w-3.5"})})]})]},we.id)})})}),e.jsxs(ws,{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(Fs,{value:N,onValueChange:w,children:[e.jsx(Ds,{className:"w-[220px] h-8 text-xs",children:e.jsx(zs,{placeholder:"All campaigns"})}),e.jsxs(Rs,{children:[e.jsx(vt,{value:"all",children:"All campaigns"}),J.map(we=>e.jsx(vt,{value:we.id,children:we.name},we.id))]})]}),e.jsxs(Fs,{value:k,onValueChange:C,children:[e.jsx(Ds,{className:"w-[160px] h-8 text-xs",children:e.jsx(zs,{placeholder:"All statuses"})}),e.jsxs(Rs,{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"||k!=="all")&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 text-xs",onClick:()=>{w("all"),C("all")},children:"Clear"})]}),(()=>{var ut;const we=Y.filter(fe=>{var He;return!(N!=="all"&&((He=fe.campaign_email)==null?void 0:He.campaign_id)!==N||k==="opened"&&!fe.opened_at||k==="clicked"&&!fe.clicked_at||k==="sent"&&(fe.opened_at||fe.clicked_at))});return we.length===0?e.jsx(Pe,{children:e.jsxs(Re,{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 ",we.length," of ",Y.length," recent sends",N!=="all"&&` · ${(ut=J.find(fe=>fe.id===N))==null?void 0:ut.name}`]}),e.jsx("div",{className:"space-y-1",children:we.map(fe=>{var _e,Ge,We;const He=j9e[fe.status]||j9e.sent,et=He.icon,tt=(_e=J.find(it=>{var Ve;return it.id===((Ve=fe.campaign_email)==null?void 0:Ve.campaign_id)}))==null?void 0:_e.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(et,{className:`h-4 w-4 flex-shrink-0 ${He.color}`}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm truncate",children:[(Ge=fe.prospect)==null?void 0:Ge.first_name," ",(We=fe.prospect)==null?void 0:We.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(Cn,{className:"h-3 w-3"})," ",gs(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"})," ",gs(new Date(fe.clicked_at),"MMM d")]}),e.jsx("span",{children:gs(new Date(fe.sent_at),"MMM d, h:mm a")})]})]},fe.id)})})]})})()]})]}),e.jsx(fs,{open:n,onOpenChange:we=>{a(we),we||(b(""),d(new Set),l(""))},children:e.jsxs(hs,{className:"max-w-lg max-h-[85vh] flex flex-col p-0",children:[e.jsxs(js,{className:"px-6 pt-6 pb-4",children:[e.jsx(_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(Fs,{value:o,onValueChange:l,children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Choose a campaign..."})}),e.jsx(Rs,{children:J.map(we=>e.jsx(vt,{value:we.id,children:we.name},we.id))})]})]}),o&&(()=>{const we=_.toLowerCase(),ut=X.filter(et=>`${et.first_name} ${et.last_name}`.toLowerCase().includes(we)||et.email.toLowerCase().includes(we)),fe=ut.filter(et=>!ce.has(`${et.id}-${o}`)),He=fe.length>0&&fe.every(et=>i.has(et.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(an,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name or email...",value:_,onChange:et=>b(et.target.value),className:"pl-9 h-9"})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"h-9 whitespace-nowrap",onClick:()=>{if(He){const et=new Set(i);fe.forEach(tt=>et.delete(tt.id)),d(et)}else{const et=new Set(i);fe.forEach(tt=>et.add(tt.id)),d(et)}},children:[e.jsx(uL,{className:"h-3.5 w-3.5 mr-1"}),He?"Deselect All":`Select All (${fe.length})`]})]}),e.jsx("div",{className:"border rounded-lg max-h-60 overflow-y-auto divide-y",children:ut.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"}):ut.map(et=>{const tt=ce.has(`${et.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(Hi,{checked:i.has(et.id),disabled:tt,onCheckedChange:_e=>{const Ge=new Set(i);_e?Ge.add(et.id):Ge.delete(et.id),d(Ge)}}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[et.first_name," ",et.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:et.email})]}),tt&&e.jsx(Qe,{variant:"outline",className:"text-[10px] shrink-0",children:"Already assigned"})]},et.id)})}),ut.length>0&&e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Showing ",ut.length," of ",X.length," prospects",fe.length0&&e.jsx(Pe,{className:"bg-primary/5 border-primary/20",children:e.jsxs(Re,{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:(Be=J.find(we=>we.id===o))==null?void 0:Be.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(_n,{className:"px-6 py-4 border-t",children:[e.jsx(K,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>ae.mutate(),disabled:ae.isPending||!o||i.size===0,children:[e.jsx(Mn,{className:"h-4 w-4 mr-1"}),ae.isPending?"Assigning...":`Assign & Start (${i.size})`]})]})]})}),f&&(()=>{const we=B(f);return we?e.jsx(uct,{email:we,mergeValues:q,selectedSubjectIndex:V[we.id],onClose:()=>y(null)}):null})()]})}function fct({brokerageId:t}){const s=Qt(),[r,n]=S.useState([]),[a,o]=S.useState([]),[l,i]=S.useState(!1),d=S.useRef(!1),{data:u,isLoading:p}=gt({queryKey:["recruit-stages-editor",t],queryFn:async()=>{const{data:w,error:k}=await G.from("recruit_pipeline_stages").select("*").eq("brokerage_id",t).order("sort_order");if(k)throw k;return w},enabled:!!t});S.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=Et({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),k=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(k.length>0){const{error:C}=await G.from("recruit_pipeline_stages").insert(k.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,k,C)=>{n(A=>A.map((I,L)=>L===w?{...I,[k]:C}:I)),i(!0)},_=()=>{const w=r.length>0?Math.max(...r.map(k=>k.sort_order)):0;n(k=>[...k,{name:"",color:"#6366f1",sort_order:w+1,isNew:!0}]),i(!0)},b=w=>{const k=r[w];k.id&&!k.isNew&&o(C=>[...C,k.id]),n(C=>C.filter((A,I)=>I!==w)),i(!0)},N=(w,k)=>{const C=w+k;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,k)=>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(k,-1),disabled:k===0,className:"text-muted-foreground hover:text-foreground disabled:opacity-30 text-xs",children:"▲"}),e.jsx("button",{type:"button",onClick:()=>N(k,1),disabled:k===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(k,"color",C.target.value),className:"h-8 w-8 rounded cursor-pointer border-0 p-0 shrink-0"}),e.jsx(Le,{value:w.name,onChange:C=>y(k,"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:k+1}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>b(k),className:"text-destructive hover:text-destructive shrink-0 h-8 w-8",children:e.jsx(xr,{className:"h-4 w-4"})})]},w.id||`new-${k}`))}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:_,className:"gap-1",children:[e.jsx(Bs,{className:"h-4 w-4"})," Add Stage"]}),l&&e.jsxs(K,{size:"sm",onClick:()=>f.mutate(),disabled:f.isPending,className:"gap-1",children:[e.jsx(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(Re,{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(Lt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs(Ft,{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(ln,{className:"h-3 w-3"}),n.unsubscribed_at&&gs(new Date(n.unsubscribed_at),"MMM d, yyyy")]})]})}),n.unsubscribe_reason&&e.jsx(Re,{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]=S.useState(!1),i=n??o,d=a??l,[u,p]=S.useState("pick-recipients"),[f,y]=S.useState(new Set(r?[r]:[])),[_,b]=S.useState("all"),[N,w]=S.useState(""),[k,C]=S.useState(null),[A,I]=S.useState(""),[L,O]=S.useState(0),[V,q]=S.useState(0),[B,U]=S.useState(""),[te,Y]=S.useState(""),[J,X]=S.useState(null),{prospects:ce,stages:ae}=EO(t),ie=Ylt(),oe=Mw(),{data:me=[]}=gt({queryKey:["brokerage-recruit-video-pool",t],queryFn:async()=>{const{data:ke,error:$e}=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($e)throw $e;return ke??[]},enabled:i&&u==="pick-video"}),ye=S.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=ke=>{!ke&&(u==="uploading"||u==="processing"||u==="sending")||(d(ke),ke||setTimeout(ye,200))},ge=S.useMemo(()=>ce.filter(ke=>{if(!ke.email||_!=="all"&&ke.stage_id!==_)return!1;if(N){const $e=N.toLowerCase();if(!`${ke.first_name} ${ke.last_name??""}`.toLowerCase().includes($e)&&!ke.email.toLowerCase().includes($e))return!1}return!0}),[ce,_,N]),Ne=ke=>{y($e=>{const Be=new Set($e);return Be.has(ke)?Be.delete(ke):Be.add(ke),Be})},Ue=()=>{f.size===ge.length?y(new Set):y(new Set(ge.map(ke=>ke.id)))},Te=S.useCallback(async(ke,$e)=>{p("uploading");try{const Be=`Recruiting blast (${f.size} recipients)`,{videoId:we,libraryId:ut}=await wE(Be),{uploadUrl:fe,apiKey:He}=await jE(we),et=new XMLHttpRequest;et.upload.onprogress=dt=>{dt.lengthComputable&&O(dt.loaded/dt.total*100)},await new Promise((dt,pt)=>{et.onload=()=>et.status>=200&&et.status<300?dt():pt(new Error("Upload failed")),et.onerror=()=>pt(new Error("Upload failed")),et.open("PUT",fe),et.setRequestHeader("AccessKey",He),et.send(ke)}),p("processing");const tt=`https://iframe.mediadelivery.net/embed/${ut}/${we}`;let _e=0;const Ge=Date.now(),We=9e4;for(;_e<4&&(await new Promise(pt=>setTimeout(pt,3e3)),!(Date.now()-Ge>We));){const dt=await nw(we);if(_e=dt.status,q(dt.encodeProgress||0),_e===5||_e===6)throw new Error("Video processing failed")}const it=await nw(we),Ve=(it.storageSize||ke.size)/(1024*1024),Xe=await oe.mutateAsync({bunny_video_id:we,playback_url:it.directPlayUrl||tt,thumbnail_url:it.thumbnailUrl,preview_url:it.previewUrl||null,duration_seconds:it.length||$e,file_size_mb:Ve,title:Be,status:_e>=4?"ready":"processing",touch_type:"recruiting"});C(Xe.id),I(Be),p("compose")}catch(Be){pe.error((Be==null?void 0:Be.message)||"Failed to upload video"),p("pick-video")}},[f.size,oe]),Me=S.useCallback(async()=>{if(!(!k||f.size===0)){p("sending");try{const ke=[];for(const we of f){const ut=await ie.mutateAsync({prospect_id:we,video_id:k,brokerage_id:t,message:te||void 0});ke.push(ut.id)}const{data:$e,error:Be}=await G.functions.invoke("send-recruit-video-email",{body:{recruit_video_ids:ke,brokerage_id:t,subject_override:B||void 0,message_override:te||void 0}});if(Be)throw new Error(Be.message);X({sent:($e==null?void 0:$e.sent)??0,total:($e==null?void 0:$e.total)??ke.length}),p("done"),pe.success(`Sent ${($e==null?void 0:$e.sent)??0} of ${($e==null?void 0:$e.total)??ke.length} videos`)}catch(ke){pe.error((ke==null?void 0:ke.message)||"Failed to send"),p("compose")}}},[k,f,t,te,B,ie]),De=f.size,qe=ce.filter(ke=>!ke.email).length;return e.jsxs(fs,{open:i,onOpenChange:he,children:[s&&e.jsx(hi,{asChild:!0,children:s}),e.jsxs(hs,{className:"max-w-3xl max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsx(js,{children:e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(gn,{className:"h-5 w-5 text-primary"}),"Send Recruiting Video",De>0&&e.jsxs(Qe,{variant:"secondary",className:"ml-2",children:[e.jsx(or,{className:"h-3 w-3 mr-1"}),De," ",De===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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search prospects...",value:N,onChange:ke=>w(ke.target.value),className:"pl-9"})]}),e.jsxs(Fs,{value:_,onValueChange:b,children:[e.jsx(Ds,{className:"w-48",children:e.jsx(zs,{})}),e.jsxs(Rs,{children:[e.jsx(vt,{value:"all",children:"All stages"}),ae.map(ke=>e.jsx(vt,{value:ke.id,children:ke.name},ke.id))]})]})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsxs("button",{onClick:Ue,className:"hover:underline",children:[f.size===ge.length&&ge.length>0?"Deselect all":"Select all"," ","(",ge.length,")"]}),qe>0&&e.jsxs("span",{children:[qe," prospect(s) hidden — no email on file"]})]}),e.jsx(ni,{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(ke=>{const $e=f.has(ke.id),Be=ae.find(we=>we.id===ke.stage_id);return e.jsxs("label",{className:"flex items-center gap-3 p-3 hover:bg-muted/30 cursor-pointer",children:[e.jsx(Hi,{checked:$e,onCheckedChange:()=>Ne(ke.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:[ke.first_name," ",ke.last_name]}),Be&&e.jsx(Qe,{variant:"outline",className:"text-[10px]",style:{borderColor:Be.color,color:Be.color},children:Be.name})]}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[ke.email," ",ke.current_brokerage&&`· ${ke.current_brokerage}`]})]})]},ke.id)})})}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>he(!1),children:"Cancel"}),e.jsx(K,{disabled:De===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(ls,{value:"record",children:[e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1"}),"Record New"]}),e.jsxs(ls,{value:"library",children:[e.jsx(oS,{className:"h-3.5 w-3.5 mr-1"}),"Use Existing"]})]}),e.jsx(ws,{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 ",De," ",De===1?"recipient":"recipients"," — each gets their own tracked link."]})]}),e.jsxs(K,{onClick:()=>p("record"),children:[e.jsx(gn,{className:"h-4 w-4 mr-2"}),"Start Recording"]})]})}),e.jsx(ws,{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(ke=>e.jsxs("button",{onClick:()=>{C(ke.id),I(ke.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:ke.thumbnail_url?e.jsx("img",{src:ke.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(gn,{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:ke.title||"Untitled"})})]},ke.id))})})]}),e.jsx(_n,{children:e.jsx(K,{variant:"outline",onClick:()=>p("pick-recipients"),children:"Back"})})]}),u==="record"&&e.jsxs("div",{className:"flex-1 overflow-auto",children:[e.jsx(TO,{maxDurationSeconds:600,onRecordingComplete:Te}),e.jsx("div",{className:"mt-2 flex justify-start",children:e.jsx(K,{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(fi,{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(Hn,{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:De})," recipient",De===1?"":"s"]})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Subject (optional override)"}),e.jsx(Le,{value:B,onChange:ke=>U(ke.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(gr,{value:te,onChange:ke=>Y(ke.target.value),placeholder:"Hey there — wanted to share a quick thought on what we're building here...",rows:5,className:"mt-1"})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>p("pick-video"),children:"Back"}),e.jsxs(K,{onClick:Me,disabled:!k||De===0,children:[e.jsx(Mn,{className:"h-4 w-4 mr-2"})," Send to ",De," ",De===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 ",De," recipient",De===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(Hn,{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(K,{onClick:()=>he(!1),children:"Done"})]})]})]})}function ZSs(){var i;const[t,s]=S.useState(""),[r,n]=S.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(Es,{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(Es,{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(Fs,{value:l,onValueChange:s,children:[e.jsxs(Ds,{className:"w-[280px]",children:[e.jsx(pa,{className:"mr-2 h-4 w-4"}),e.jsx(zs,{placeholder:"Select brokerage"})]}),e.jsx(Rs,{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(K,{size:"sm",className:"gap-1.5",children:[e.jsx(gn,{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(ls,{value:"pipeline",children:"Pipeline"}),e.jsxs(ls,{value:"contacts",children:[e.jsx(or,{className:"h-3.5 w-3.5 mr-1"}),"Contacts"]}),e.jsxs(ls,{value:"video-outreach",children:[e.jsx(gn,{className:"h-3.5 w-3.5 mr-1"}),"Video Outreach"]}),e.jsx(ls,{value:"follow-ups",children:"Follow-ups"}),e.jsx(ls,{value:"referrals",children:"Referrals"}),e.jsx(ls,{value:"interest",children:"Interest Form"}),e.jsx(ls,{value:"landing-page",children:"Landing Page"}),e.jsx(ls,{value:"goals",children:"Goals"}),e.jsx(ls,{value:"metrics",children:"Metrics"}),e.jsx(ls,{value:"templates",children:"Email Templates"}),e.jsxs(ls,{value:"campaigns",children:[e.jsx(tr,{className:"h-3.5 w-3.5 mr-1"}),"Campaigns"]}),e.jsxs(ls,{value:"drip-assignments",children:[e.jsx(Mn,{className:"h-3.5 w-3.5 mr-1"}),"Drip Assignments"]}),e.jsx(ls,{value:"activity",children:"Recruiter Activity"}),e.jsxs(ls,{value:"email-settings",children:[e.jsx(So,{className:"h-3.5 w-3.5 mr-1"}),"Email Settings"]}),e.jsxs(ls,{value:"pipeline-stages",children:[e.jsx(vS,{className:"h-3.5 w-3.5 mr-1"}),"Pipeline Stages"]}),e.jsxs(ls,{value:"unsubscribed",children:[e.jsx(gS,{className:"h-3.5 w-3.5 mr-1"}),"Unsubscribed"]})]}),e.jsxs(ws,{value:"pipeline",children:[e.jsx("div",{className:"flex justify-end mb-3",children:e.jsxs("div",{className:"flex items-center rounded-md border bg-muted p-0.5",children:[e.jsxs(K,{variant:r==="board"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>n("board"),children:[e.jsx(fp,{className:"h-3.5 w-3.5"})," Board"]}),e.jsxs(K,{variant:r==="table"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>n("table"),children:[e.jsx(OM,{className:"h-3.5 w-3.5"})," Table"]})]})}),r==="board"?e.jsx(tct,{brokerageId:l}):e.jsx(Ade,{brokerageId:l})]}),e.jsx(ws,{value:"contacts",children:e.jsx(Ade,{brokerageId:l})}),e.jsx(ws,{value:"video-outreach",children:e.jsx(cct,{brokerageId:l})}),e.jsx(ws,{value:"follow-ups",children:e.jsx(oct,{brokerageId:l})}),e.jsx(ws,{value:"referrals",children:e.jsx(act,{brokerageId:l})}),e.jsx(ws,{value:"interest",children:e.jsx(ict,{brokerageId:l})}),e.jsx(ws,{value:"landing-page",children:e.jsx(lct,{brokerageId:l})}),e.jsx(ws,{value:"goals",children:e.jsx(dct,{brokerageId:l})}),e.jsx(ws,{value:"metrics",children:e.jsx(sct,{brokerageId:l})}),e.jsx(ws,{value:"templates",children:e.jsx(rct,{brokerageId:l})}),e.jsx(ws,{value:"campaigns",children:e.jsx(mct,{brokerageId:l})}),e.jsx(ws,{value:"drip-assignments",children:e.jsx(pct,{brokerageId:l})}),e.jsx(ws,{value:"activity",children:e.jsx(nct,{brokerageId:l})}),e.jsx(ws,{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(HCe,{brokerageId:l})]})}),e.jsx(ws,{value:"pipeline-stages",children:e.jsx("div",{className:"max-w-2xl",children:e.jsx(fct,{brokerageId:l})})}),e.jsx(ws,{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}=qs(),[n,a]=S.useState("board"),o=s||((l=t[0])==null?void 0:l.id)||"";return t.length===0?e.jsx(Es,{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(Es,{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(Fs,{value:o,onValueChange:r,children:[e.jsxs(Ds,{className:"w-[280px]",children:[e.jsx(pa,{className:"mr-2 h-4 w-4"}),e.jsx(zs,{placeholder:"Select brokerage"})]}),e.jsx(Rs,{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(ls,{value:"pipeline",children:"Pipeline"}),e.jsxs(ls,{value:"contacts",children:[e.jsx(or,{className:"h-3.5 w-3.5 mr-1"}),"Contacts"]}),e.jsxs(ls,{value:"video-outreach",children:[e.jsx(gn,{className:"h-3.5 w-3.5 mr-1"}),"Video Outreach"]}),e.jsx(ls,{value:"follow-ups",children:"Follow-ups"}),e.jsx(ls,{value:"referrals",children:"Referrals"}),e.jsx(ls,{value:"interest",children:"Interest Form"}),e.jsx(ls,{value:"landing-page",children:"Landing Page"}),e.jsx(ls,{value:"goals",children:"Goals"}),e.jsx(ls,{value:"metrics",children:"Metrics"}),e.jsx(ls,{value:"templates",children:"Email Templates"}),e.jsxs(ls,{value:"campaigns",children:[e.jsx(tr,{className:"h-3.5 w-3.5 mr-1"}),"Campaigns"]}),e.jsxs(ls,{value:"drip-assignments",children:[e.jsx(Mn,{className:"h-3.5 w-3.5 mr-1"}),"Drip Assignments"]}),e.jsx(ls,{value:"activity",children:"Recruiter Activity"}),e.jsxs(ls,{value:"email-settings",children:[e.jsx(So,{className:"h-3.5 w-3.5 mr-1"}),"Email Settings"]}),e.jsxs(ls,{value:"pipeline-stages",children:[e.jsx(vS,{className:"h-3.5 w-3.5 mr-1"}),"Pipeline Stages"]})]}),e.jsxs(ws,{value:"pipeline",children:[e.jsx("div",{className:"flex justify-end mb-3",children:e.jsxs("div",{className:"flex items-center rounded-md border bg-muted p-0.5",children:[e.jsxs(K,{variant:n==="board"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>a("board"),children:[e.jsx(fp,{className:"h-3.5 w-3.5"})," Board"]}),e.jsxs(K,{variant:n==="table"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>a("table"),children:[e.jsx(OM,{className:"h-3.5 w-3.5"})," Table"]})]})}),n==="board"?e.jsx(tct,{brokerageId:o}):e.jsx(Ade,{brokerageId:o})]}),e.jsx(ws,{value:"contacts",children:e.jsx(Ade,{brokerageId:o})}),e.jsx(ws,{value:"video-outreach",children:e.jsx(cct,{brokerageId:o})}),e.jsx(ws,{value:"follow-ups",children:e.jsx(oct,{brokerageId:o})}),e.jsx(ws,{value:"referrals",children:e.jsx(act,{brokerageId:o})}),e.jsx(ws,{value:"interest",children:e.jsx(ict,{brokerageId:o})}),e.jsx(ws,{value:"landing-page",children:e.jsx(lct,{brokerageId:o})}),e.jsx(ws,{value:"goals",children:e.jsx(dct,{brokerageId:o})}),e.jsx(ws,{value:"metrics",children:e.jsx(sct,{brokerageId:o})}),e.jsx(ws,{value:"templates",children:e.jsx(rct,{brokerageId:o})}),e.jsx(ws,{value:"campaigns",children:e.jsx(mct,{brokerageId:o})}),e.jsx(ws,{value:"drip-assignments",children:e.jsx(pct,{brokerageId:o})}),e.jsx(ws,{value:"activity",children:e.jsx(nct,{brokerageId:o})}),e.jsx(ws,{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(HCe,{brokerageId:o})]})}),e.jsx(ws,{value:"pipeline-stages",children:e.jsx("div",{className:"max-w-2xl",children:e.jsx(fct,{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]=S.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(k=>k.brokerage_id===_.id),N=f.filter(k=>k.brokerage_id===_.id),w=b.length>0?b.reduce((k,C)=>C.created_at>k?C.created_at:k,b[0].created_at):null;return{brokerage_id:_.id,brokerage_name:_.name,total_items:b.length,videos:b.filter(k=>k.content_type==="video").length,pdfs:b.filter(k=>k.content_type==="pdf").length,links:b.filter(k=>k.content_type==="link"||k.content_type==="canva_link").length,events:b.filter(k=>k.content_type==="event").length,graphics:b.filter(k=>k.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(Es,{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(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Active Brokerages"})}),e.jsxs(Re,{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(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Total Content Items"})}),e.jsxs(Re,{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(Lt,{className:"pb-2",children:e.jsx(Ft,{className:"text-sm font-medium text-muted-foreground",children:"Total Brokerages"})}),e.jsxs(Re,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search brokerages...",value:t,onChange:i=>s(i.target.value),className:"pl-9"})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ms,{children:[e.jsx(kt,{children:"Brokerage"}),e.jsx(kt,{className:"text-center",children:"Total"}),e.jsx(kt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(gn,{className:"h-3 w-3"})," Videos"]})}),e.jsx(kt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(yn,{className:"h-3 w-3"})," PDFs"]})}),e.jsx(kt,{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(kt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(yd,{className:"h-3 w-3"})," Events"]})}),e.jsx(kt,{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(kt,{className:"text-center",children:"Categories"}),e.jsx(kt,{children:"Last Upload"})]})}),e.jsx(Rn,{children:n?e.jsx(Ms,{children:e.jsx(ht,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):a.length===0?e.jsx(Ms,{children:e.jsx(ht,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"No brokerages found"})}):a.map(i=>e.jsxs(Ms,{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:gs(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 Pde(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 vp=(t,s)=>{if(t instanceof s)return!0;const r=Object.getPrototypeOf(t);return r===null?!1:r.constructor.name===s.name||vp(r,s)};function iCs(t){const s=t.getPropertyValue("content");return`${t.cssText} content: '${s.replace(/'|"/g,"")}';`}function oCs(t,s){return xct(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 N9e(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){N9e(t,s,":before",r),N9e(t,s,":after",r)}const k9e="application/font-woff",S9e="image/jpeg",dCs={woff:k9e,woff2:k9e,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:S9e,jpeg:S9e,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function uCs(t){const s=/\.([^./]*?)$/g.exec(t);return s?s[1]:""}function GCe(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 yct(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 N0e={};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 WCe(t,s,r){const n=pCs(t,s,r.includeQueryParams);if(N0e[n]!=null)return N0e[n];r.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+new Date().getTime());let a;try{const o=await yct(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 N0e[n]=a,a}async function fCs(t){const s=t.toDataURL();return s==="data:,"?t.cloneNode(!1):Pde(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 Pde(i)}const r=t.poster,n=GCe(r),a=await WCe(r,n,s);return Pde(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 tpe(t.contentDocument.body,s,!0)}catch{}return t.cloneNode(!1)}async function yCs(t,s){return vp(t,HTMLCanvasElement)?fCs(t):vp(t,HTMLVideoElement)?xCs(t,s):vp(t,HTMLIFrameElement)?gCs(t,s):t.cloneNode(vct(t))}const vCs=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SLOT",vct=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SVG";async function _Cs(t,s,r){var n,a;if(vct(s))return s;let o=[];return vCs(t)&&t.assignedNodes?o=qb(t.assignedNodes()):vp(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||vp(t,HTMLVideoElement)||await o.reduce((l,i)=>l.then(()=>tpe(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):xct(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`),vp(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){vp(t,HTMLTextAreaElement)&&(s.innerHTML=t.value),vp(t,HTMLInputElement)&&s.setAttribute("value",t.value)}function jCs(t,s){if(vp(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 vp(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 _ct=/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(_ct,(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=GCe(s);let i;return a||(i=await WCe(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 bct(t){return t.search(_ct)!==-1}async function wct(t,s,r){if(!bct(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 wct(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=vp(t,HTMLImageElement);if(!(r&&!t2e(t.src))&&!(vp(t,SVGImageElement)&&!t2e(t.href.baseVal)))return;const n=r?t.src:t.href.baseVal,a=await WCe(n,GCe(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=>jct(a,s));await Promise.all(n).then(()=>t)}async function jct(t,s){vp(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 C9e={};async function M9e(t){let s=C9e[t];if(s!=null)return s;const n=await(await fetch(t)).text();return s={url:t,cssText:n},C9e[t]=s,s}async function T9e(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),yct(i,s.fetchRequestInit,({result:d})=>(r=r.replace(l,`url(${d})`),[l,d]))});return Promise.all(o).then(()=>r)}function A9e(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=M9e(d).then(p=>T9e(p,s)).then(p=>A9e(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(M9e(a.href).then(i=>T9e(i,s)).then(i=>A9e(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=>bct(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 Nct(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(Nct(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(Nct(o.style.fontFamily))).map(o=>{const l=o.parentStyleSheet?o.parentStyleSheet.href:null;return wct(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}=gct(t,s),a=await tpe(t,s,!0);return await $Cs(a,s),await jct(a,s),DCs(a,s),await aCs(a,r,n)}async function UCs(t,s={}){const{width:r,height:n}=gct(t,s),a=await qCs(t,s),o=await Pde(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),spe={"just-listed":"JUST LISTED","just-sold":"JUST SOLD","open-house":"OPEN HOUSE","price-drop":"PRICE DROP"},E9={"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})]})]}),kct=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=spe[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})]})]})]})});kct.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})]})]}),Sct=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=spe[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})]})]})});Sct.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})]})]}),Cct=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=spe[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})]})]})]})});Cct.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})]})]}),Mct=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=spe[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"}})]})]})})});Mct.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:"📉"}],E9e=[{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:"📰"}],P9e=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),I9e={"luxury-dark":kct,"modern-clean":Sct,"bold-colorful":Cct,editorial:Mct};function XCs(){const[t,s]=S.useState(""),[r,n]=S.useState("address"),[a,o]=S.useState(!1),[l,i]=S.useState([]),[d,u]=S.useState(null),[p,f]=S.useState(0),[y,_]=S.useState("just-listed"),[b,N]=S.useState(["instagram-square"]),[w,k]=S.useState("luxury-dark"),[C,A]=S.useState(!1),[I,L]=S.useState(""),[O,V]=S.useState(""),[q,B]=S.useState(""),[U,te]=S.useState(!1),[Y,J]=S.useState(!1),[X,ce]=S.useState([]),[ae,ie]=S.useState("search"),oe=S.useRef({});S.useEffect(()=>{(async()=>{const{data:{user:qe}}=await G.auth.getUser();if(!qe)return;const{data:ke}=await G.from("profiles").select("name, avatar_url, brokerages(name)").eq("id",qe.id).single();if(ke){L(ke.name||""),B(ke.avatar_url||"");const $e=ke.brokerages;V(($e==null?void 0:$e.name)||"")}})()},[]);const me=async()=>{var De;if(t.trim()){o(!0),i([]);try{const{data:qe,error:ke}=await G.functions.invoke("repliers-mls-search",{body:{searchType:r,query:t.trim()}});if(ke)throw ke;if(qe.error)throw new Error(qe.error);i(qe.listings||[]),((De=qe.listings)==null?void 0:De.length)===0&&pe.info("No listings found. Try a different search.")}catch(qe){pe.error(qe.message||"Search failed")}finally{o(!1)}}},ye=De=>{var qe;u(De),f(0),ie("customize"),De.soldDate||(qe=De.status)!=null&&qe.toLowerCase().includes("sold")?_("just-sold"):_("just-listed")},he=De=>{N(qe=>qe.includes(De)?qe.filter(ke=>ke!==De):[...qe,De])},ge=S.useCallback(async()=>{if(!(!d||b.length===0)){te(!0),ce([]),ie("generate");try{await new Promise(qe=>setTimeout(qe,500));const De=[];for(const qe of b){const ke=`${w}-${qe}`,$e=oe.current[ke];if(!$e)continue;const Be=E9[qe],we=await VCs($e,{width:Be.width,height:Be.height,pixelRatio:1,cacheBust:!0,style:{transform:"none",transformOrigin:"top left"}});De.push({format:qe,imageUrl:we})}ce(De),pe.success(`Generated ${De.length} social post${De.length>1?"s":""}!`)}catch(De){pe.error(De.message||"Generation failed")}finally{te(!1)}}},[d,b,w,p,C,I,O,q,y]),Ne=async()=>{if(!(!d||b.length===0)){te(!0),ce([]),ie("generate");try{const De={...d,photos:d.photos.length>0?[d.photos[p]]:[]},qe=[];for(const ke of b){const{data:$e,error:Be}=await G.functions.invoke("generate-listing-social-post",{body:{listing:De,postType:y,format:ke,branding:C?{enabled:!0,agentName:I,brokerage:O}:{enabled:!1}}});if(Be)throw Be;if($e.error)throw new Error($e.error);qe.push({format:ke,imageUrl:$e.imageUrl})}ce(qe),pe.success(`Generated ${qe.length} AI post${qe.length>1?"s":""}!`)}catch(De){pe.error(De.message||"AI generation failed")}finally{te(!1)}}},Ue=()=>Y?Ne():ge(),Te=(De,qe)=>{var $e;const ke=document.createElement("a");ke.href=De,ke.download=`${(($e=d==null?void 0:d.address)==null?void 0:$e.replace(/\s+/g,"-"))||"listing"}-${y}-${qe}.png`,document.body.appendChild(ke),ke.click(),document.body.removeChild(ke)},Me=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(Es,{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:()=>ie("search"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full transition-colors ${ae==="search"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:text-foreground"}`,children:[e.jsx(an,{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&&ie("customize"),disabled:!d,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full transition-colors ${ae==="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 ${ae==="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"]})]}),ae==="search"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(an,{className:"h-5 w-5 text-primary"})," Search MLS Listings ",e.jsx(IXe,{})]}),e.jsx(ur,{children:"Find a listing by MLS number or property address using Repliers.io"})]}),e.jsxs(Re,{className:"space-y-4",children:[e.jsx(ta,{value:r,onValueChange:De=>n(De),children:e.jsxs(Jn,{children:[e.jsxs(ls,{value:"address",children:[e.jsx(Ia,{className:"h-4 w-4 mr-1.5"})," Address"]}),e.jsxs(ls,{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(Le,{value:t,onChange:De=>s(De.target.value),placeholder:r==="mls"?"Enter MLS number...":"Enter property address...",className:"flex-1",onKeyDown:De=>De.key==="Enter"&&me()}),e.jsxs(K,{onClick:me,disabled:a||!t.trim(),children:[a?e.jsx(us,{className:"h-4 w-4 animate-spin"}):e.jsx(an,{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((De,qe)=>{var ke;return e.jsx(Pe,{className:"cursor-pointer hover:border-primary/50 hover:shadow-md transition-all group",onClick:()=>ye(De),children:e.jsx(Re,{className:"p-0",children:e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"w-32 h-28 flex-shrink-0 bg-muted rounded-l-lg overflow-hidden",children:(ke=De.photos)!=null&&ke[0]?e.jsx("img",{src:De.photos[0],alt:De.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(Sn,{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:P9e(De.price)}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:De.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[De.city,", ",De.state," ",De.zip]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1.5 text-xs text-muted-foreground",children:[De.bedrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(W4,{className:"h-3 w-3"})," ",De.bedrooms]}),De.bathrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(nf,{className:"h-3 w-3"})," ",De.bathrooms]}),De.sqft>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(jL,{className:"h-3 w-3"})," ",De.sqft.toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(Qe,{variant:"outline",className:"text-[10px]",children:De.mlsNumber}),e.jsx(Qe,{variant:"outline",className:"text-[10px]",children:De.status})]})]})]})})},De.mlsNumber||qe)})})]})]}),ae==="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(Lt,{className:"pb-3",children:e.jsx(Ft,{className:"text-base",children:"Selected Listing"})}),e.jsxs(Re,{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(K,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>f(De=>Math.max(0,De-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(K,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>f(De=>Math.min(d.photos.length-1,De+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:P9e(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(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{ie("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(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(Or,{className:"h-5 w-5 text-primary"})," Customize Your Post"]}),e.jsx(ur,{children:"Choose template, post type, format, and branding"})]}),e.jsxs(Re,{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(Fl,{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(Mr,{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(Fl,{className:"h-4 w-4"})," Template Style"]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:YCs.map(De=>e.jsxs("button",{onClick:()=>k(De.value),className:`flex flex-col items-center gap-1 px-3 py-3 rounded-lg border-2 transition-all text-center ${w===De.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-2xl",children:De.preview}),e.jsx("span",{className:"text-sm font-medium",children:De.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground leading-tight",children:De.description})]},De.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(De=>e.jsxs("button",{onClick:()=>_(De.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm font-medium ${y===De.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-lg",children:De.icon})," ",De.label]},De.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:E9e.map(De=>e.jsxs("button",{onClick:()=>he(De.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm ${b.includes(De.value)?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[De.icon,e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium",children:De.label}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:De.dimensions})]})]},De.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(Mr,{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(Le,{value:I,onChange:De=>L(De.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(Le,{value:O,onChange:De=>V(De.target.value),placeholder:"XYZ Realty"})]})]})]})]}),!Y&&Me&&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*(E9[b[0]||"instagram-square"].height/E9[b[0]||"instagram-square"].width)},children:(()=>{const De=I9e[w],qe=b[0]||"instagram-square";return e.jsx(De,{...Me,format:qe})})()})})]}),e.jsx(K,{onClick:Ue,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"})]})})]})]})]}),ae==="generate"&&e.jsxs("div",{className:"space-y-4",children:[U&&e.jsx(Pe,{children:e.jsxs(Re,{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(K,{variant:"outline",size:"sm",onClick:()=>ie("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((De,qe)=>{const ke=E9e.find($e=>$e.value===De.format);return e.jsxs(Pe,{className:"overflow-hidden",children:[e.jsx("div",{className:"bg-muted/30 p-1",children:e.jsx("img",{src:De.imageUrl,alt:`${De.format} social post`,className:"w-full rounded"})}),e.jsxs(Re,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[ke==null?void 0:ke.icon,e.jsx("span",{className:"text-sm font-medium",children:ke==null?void 0:ke.label})]}),e.jsx(Qe,{variant:"outline",className:"text-[10px]",children:ke==null?void 0:ke.dimensions})]}),e.jsxs(K,{size:"sm",className:"w-full gap-1.5",onClick:()=>Te(De.imageUrl,De.format),children:[e.jsx(Qa,{className:"h-3.5 w-3.5"})," Download"]})]})]},qe)})})]})]}),ae==="generate"&&!Y&&d&&Me&&e.jsx("div",{style:{position:"absolute",left:"-9999px",top:0},"aria-hidden":!0,children:b.map(De=>{const qe=I9e[w],ke=E9[De];return e.jsx("div",{style:{width:ke.width,height:ke.height},children:e.jsx(qe,{ref:$e=>{oe.current[`${w}-${De}`]=$e},...Me,format:De})},`${w}-${De}`)})})]})})}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 Et({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 Tct(){const t=Qt();return Et({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 Et({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 Et({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 Et({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 Et({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 Et({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 Et({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 Et({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 Act(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 Et({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}=qs(),s=vr(),{data:r,isLoading:n}=QCs(),a=e3s(),o=Tct(),l=t3s(),[i,d]=S.useState(!1),[u,p]=S.useState(""),[f,y]=S.useState(""),[_,b]=S.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")}},k=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(Es,{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(K,{variant:"outline",onClick:()=>s("/admin/lms/stats"),children:[e.jsx(so,{className:"h-4 w-4 mr-2"}),"Analytics"]}),e.jsxs(K,{onClick:()=>d(!0),children:[e.jsx(Bs,{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(Lt,{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(Lt,{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(Ft,{className:"text-base truncate",children:C.title}),C.description&&e.jsx(ur,{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(Re,{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(or,{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(K,{size:"sm",variant:"ghost",onClick:q=>{q.stopPropagation(),w(C)},children:[C.is_published?e.jsx(mp,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(Cn,{className:"h-3.5 w-3.5 mr-1"}),C.is_published?"Unpublish":"Publish"]}),e.jsx(K,{size:"sm",variant:"ghost",className:"text-destructive",onClick:q=>{q.stopPropagation(),k(C.id)},children:e.jsx(xr,{className:"h-3.5 w-3.5"})}),e.jsx("div",{className:"flex-1"}),e.jsx(Ga,{className:"h-4 w-4 text-muted-foreground"})]})]})]},C.id)})}):e.jsx(Pe,{className:"border-dashed",children:e.jsxs(Re,{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(K,{onClick:()=>d(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Create Course"]})]})})]}),e.jsx(fs,{open:i,onOpenChange:d,children:e.jsxs(hs,{children:[e.jsxs(js,{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(Le,{value:u,onChange:C=>p(C.target.value),placeholder:"e.g. LevelUp Onboarding"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Description"}),e.jsx(gr,{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(Mr,{checked:_,onCheckedChange:b})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(K,{onClick:N,disabled:!u.trim()||a.isPending,children:a.isPending?"Creating...":"Create Course"})]})]})})]})}function h3s(){const{courseId:t}=ao(),s=vr(),{data:r,isLoading:n}=JCs(t),a=Tct(),o=s3s(),l=r3s(),i=n3s(),d=a3s(),u=i3s(),p=o3s(),{data:f}=gt({queryKey:["all-brokerages"],queryFn:async()=>{const{data:Ve}=await G.from("brokerages").select("id, name").order("name");return Ve||[]}}),[y,_]=S.useState(null),[b,N]=S.useState(!1),[w,k]=S.useState({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),[C,A]=S.useState(null),[I,L]=S.useState({title:"",resource_type:"link",url:""}),[O,V]=S.useState(new Set),[q,B]=S.useState(null),[U,te]=S.useState(0),[Y,J]=S.useState(!1),X=S.useRef(null),ce=S.useRef(null),[ae,ie]=S.useState(!1),[oe,me]=S.useState(""),[ye,he]=S.useState(""),[ge,Ne]=S.useState(""),[Ue,Te]=S.useState(!1);if(n)return e.jsx(Es,{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(Es,{title:"Course Not Found",children:e.jsxs("div",{className:"text-center py-20",children:[e.jsx("p",{className:"text-muted-foreground",children:"Course not found"}),e.jsxs(K,{variant:"outline",className:"mt-4",onClick:()=>s("/admin/lms"),children:[e.jsx(Oa,{className:"h-4 w-4 mr-2"})," Back to Courses"]})]})});const Me=r.modules||[],De=r.access||[],qe=De.some(Ve=>Ve.access_type==="all"),ke=De.filter(Ve=>Ve.access_type==="brokerage").map(Ve=>Ve.brokerage_id),$e=(f||[]).filter(Ve=>Ve.name.toLowerCase().includes(oe.toLowerCase())),Be=Ve=>{const Xe=new Set(O);Xe.has(Ve)?Xe.delete(Ve):Xe.add(Ve),V(Xe)},we=async()=>{if(!q)return null;J(!0),te(0);try{const{data:Ve,error:Xe}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:q.name}});if(Xe)throw new Error(Xe.message);const{videoId:dt,libraryId:pt}=Ve,{data:Je,error:Ze}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:dt,libraryId:pt}});if(Ze)throw new Error(Ze.message);const Nt=new XMLHttpRequest;return await new Promise((Ot,Yt)=>{Nt.upload.onprogress=Ps=>{Ps.lengthComputable&&te(Math.round(Ps.loaded/Ps.total*100))},Nt.onload=()=>Nt.status>=200&&Nt.status<300?Ot():Yt(new Error(`Upload failed: ${Nt.status}`)),Nt.onerror=()=>Yt(new Error("Upload failed")),Nt.open("PUT",Je.uploadUrl),Nt.setRequestHeader("AccessKey",Je.apiKey),Nt.send(q)}),`https://iframe.mediadelivery.net/embed/${pt}/${dt}`}catch(Ve){return console.error("Bunny upload error:",Ve),pe.error("Video upload failed"),null}finally{J(!1),te(0)}},ut=async()=>{if(w.title.trim())try{let Ve=w.video_url.trim()||void 0;if(q){const Xe=await we();if(!Xe)return;Ve=Xe}await o.mutateAsync({course_id:r.id,title:w.title.trim(),description:w.description.trim()||void 0,video_url:Ve,text_content:w.text_content.trim()||void 0,duration_minutes:w.duration_minutes?parseInt(w.duration_minutes):void 0,sort_order:Me.length}),pe.success("Module added"),N(!1),k({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),B(null)}catch{pe.error("Failed to add module")}},fe=async()=>{if(y)try{let Ve=w.video_url.trim()||null;if(q){const Xe=await we();if(!Xe)return;Ve=Xe}await l.mutateAsync({id:y.id,title:w.title.trim(),description:w.description.trim()||null,video_url:Ve,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")}},He=async Ve=>{if(confirm("Delete this module?"))try{await i.mutateAsync(Ve),pe.success("Module deleted")}catch{pe.error("Failed to delete")}},et=async Ve=>{if(I.title.trim())try{await d.mutateAsync({module_id:Ve,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")}},_e=async Ve=>{const Xe=De.filter(Ze=>Ze.access_type==="brokerage").map(Ze=>Ze.brokerage_id),dt=Xe.includes(Ve);let pt;dt?pt=Xe.filter(Ze=>Ze!==Ve):pt=[...Xe,Ve];const Je=pt.map(Ze=>({access_type:"brokerage",brokerage_id:Ze}));try{await p.mutateAsync({courseId:r.id,accessRules:Je}),pe.success(dt?"Brokerage removed":"Brokerage added")}catch{pe.error("Failed to update access")}},Ge=async()=>{try{await p.mutateAsync({courseId:r.id,accessRules:[]}),pe.success("Access cleared")}catch{pe.error("Failed")}},We=async(Ve,Xe)=>{const dt=Xe==="up"?Ve-1:Ve+1;if(!(dt<0||dt>=Me.length))try{await Promise.all([l.mutateAsync({id:Me[Ve].id,sort_order:dt}),l.mutateAsync({id:Me[dt].id,sort_order:Ve})])}catch{pe.error("Failed to reorder")}},it=async()=>{try{await a.mutateAsync({id:r.id,title:ye,description:ge||null}),pe.success("Course updated"),Te(!1)}catch{pe.error("Failed to update")}};return e.jsxs(Es,{title:r.title,children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s("/admin/lms"),children:e.jsx(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:[Me.length," module",Me.length!==1?"s":""]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{he(r.title),Ne(r.description||""),Te(!0)},children:[e.jsx(ga,{className:"h-3.5 w-3.5 mr-1"})," Edit"]}),e.jsxs(K,{variant:r.is_published?"secondary":"default",size:"sm",onClick:()=>a.mutateAsync({id:r.id,is_published:!r.is_published}).then(()=>pe.success(r.is_published?"Unpublished":"Published")),children:[r.is_published?e.jsx(mp,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(Cn,{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(ls,{value:"modules",children:"Modules"}),e.jsx(ls,{value:"access",children:"Access & Permissions"}),e.jsx(ls,{value:"settings",children:"Settings"})]}),e.jsxs(ws,{value:"modules",className:"mt-6 space-y-4",children:[Me.map((Ve,Xe)=>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:()=>Be(Ve.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:dt=>{dt.stopPropagation(),We(Xe,"up")},disabled:Xe===0,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(af,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:dt=>{dt.stopPropagation(),We(Xe,"down")},disabled:Xe===Me.length-1,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(Fi,{className:"h-3.5 w-3.5"})})]})}),e.jsx(Qe,{variant:"outline",className:"shrink-0 font-mono text-xs",children:Xe+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:Ve.title}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-0.5",children:[Ve.video_url&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(gn,{className:"h-3 w-3"})," Video"]}),Ve.text_content&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(yn,{className:"h-3 w-3"})," Text"]}),Ve.duration_minutes&&e.jsxs("span",{children:[Ve.duration_minutes," min"]}),Ve.resources&&Ve.resources.length>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Do,{className:"h-3 w-3"})," ",Ve.resources.length," resource(s)"]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:dt=>{var pt;dt.stopPropagation(),_(Ve),k({title:Ve.title,description:Ve.description||"",video_url:Ve.video_url||"",text_content:Ve.text_content||"",duration_minutes:((pt=Ve.duration_minutes)==null?void 0:pt.toString())||""})},children:e.jsx(ga,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"ghost",className:"text-destructive",onClick:dt=>{dt.stopPropagation(),He(Ve.id)},children:e.jsx(xr,{className:"h-3.5 w-3.5"})})]})]}),O.has(Ve.id)&&e.jsxs("div",{className:"border-t bg-muted/30 p-4 space-y-3",children:[Ve.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:Ve.description}),Ve.video_url&&e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Video: "}),e.jsx("a",{href:Ve.video_url,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline break-all",children:Ve.video_url})]}),Ve.text_content&&e.jsx("div",{className:"text-sm bg-background rounded-md p-3 border max-h-40 overflow-auto whitespace-pre-wrap",children:Ve.text_content}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Resources"}),e.jsxs(K,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>{A(Ve.id),L({title:"",resource_type:"link",url:""})},children:[e.jsx(Bs,{className:"h-3 w-3 mr-1"})," Add Resource"]})]}),Ve.resources&&Ve.resources.length>0?e.jsx("div",{className:"space-y-1",children:Ve.resources.map(dt=>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:dt.resource_type}),e.jsx("span",{className:"flex-1 truncate",children:dt.title}),dt.url&&e.jsx("a",{href:dt.url,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline text-xs",children:"Open"}),e.jsx(K,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-destructive",onClick:()=>u.mutateAsync(dt.id),children:e.jsx(jr,{className:"h-3 w-3"})})]},dt.id))}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"No resources yet"})]})]})]},Ve.id)),e.jsxs(K,{variant:"outline",className:"w-full border-dashed",onClick:()=>{N(!0),k({title:"",description:"",video_url:"",text_content:"",duration_minutes:""})},children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"})," Add Module"]})]}),e.jsx(ws,{value:"access",className:"mt-6 space-y-4",children:e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Who can access this course?"})}),e.jsxs(Re,{className:"space-y-5",children:[e.jsxs("div",{className:Dt("flex items-center gap-3 p-4 rounded-xl border-2 cursor-pointer transition-all",qe?"border-primary bg-primary/5":"border-muted hover:border-muted-foreground/30"),onClick:tt,children:[e.jsx("div",{className:Dt("h-10 w-10 rounded-full flex items-center justify-center shrink-0",qe?"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(Mr,{checked:qe,onCheckedChange:tt})]}),!qe&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:"Select Brokerages"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ke.length===0?"No brokerages selected — agents won't see this course":`${ke.length} brokerage${ke.length!==1?"s":""} selected`})]}),ke.length>0&&e.jsx(K,{size:"sm",variant:"ghost",className:"text-xs text-muted-foreground",onClick:Ge,children:"Clear all"})]}),e.jsx(Le,{placeholder:"Search brokerages...",value:oe,onChange:Ve=>me(Ve.target.value),className:"h-9"}),e.jsx("div",{className:"border rounded-lg divide-y max-h-[360px] overflow-auto",children:$e.length===0?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No brokerages found"}):$e.map(Ve=>{const Xe=ke.includes(Ve.id);return e.jsxs("div",{className:Dt("flex items-center gap-3 px-3 py-2.5 cursor-pointer transition-colors",Xe?"bg-primary/5":"hover:bg-muted/50"),onClick:()=>_e(Ve.id),children:[e.jsx("div",{className:Dt("h-5 w-5 rounded border-2 flex items-center justify-center shrink-0 transition-colors",Xe?"bg-primary border-primary":"border-muted-foreground/30"),children:Xe&&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:Ve.name}),Xe&&e.jsx(Qe,{variant:"secondary",className:"text-[10px] shrink-0",children:"Active"})]},Ve.id)})})]})]})]})}),e.jsxs(ws,{value:"settings",className:"mt-6 space-y-4",children:[e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Course Thumbnail"})}),e.jsx(Re,{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(jr,{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 Ve=>{var dt;const Xe=(dt=Ve.target.files)==null?void 0:dt[0];if(!(!Xe||!r)){ie(!0);try{const pt=Xe.name.split(".").pop(),Je=`${r.id}/thumbnail.${pt}`,{error:Ze}=await G.storage.from("lms-thumbnails").upload(Je,Xe,{upsert:!0});if(Ze)throw Ze;const{data:Nt}=G.storage.from("lms-thumbnails").getPublicUrl(Je),Ot=`${Nt.publicUrl}?t=${Date.now()}`;await a.mutateAsync({id:r.id,thumbnail_url:Ot}),pe.success("Thumbnail uploaded")}catch{pe.error("Failed to upload thumbnail")}finally{ie(!1),ce.current&&(ce.current.value="")}}}}),e.jsxs(K,{variant:"outline",size:"sm",disabled:ae,onClick:()=>{var Ve;return(Ve=ce.current)==null?void 0:Ve.click()},children:[ae?e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Ra,{className:"h-4 w-4 mr-2"}),ae?"Uploading...":"Upload Thumbnail"]})]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Course Settings"})}),e.jsxs(Re,{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(Mr,{checked:r.is_sequential,onCheckedChange:Ve=>a.mutateAsync({id:r.id,is_sequential:Ve}).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(Mr,{checked:r.is_published,onCheckedChange:Ve=>a.mutateAsync({id:r.id,is_published:Ve}).then(()=>pe.success("Updated"))})]})]})]})]})]})]}),e.jsx(fs,{open:b||!!y,onOpenChange:Ve=>{Ve||(N(!1),_(null))},children:e.jsxs(hs,{className:"max-w-lg",children:[e.jsxs(js,{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(Le,{value:w.title,onChange:Ve=>k(Xe=>({...Xe,title:Ve.target.value})),placeholder:"Module title"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Description"}),e.jsx(gr,{value:w.description,onChange:Ve=>k(Xe=>({...Xe,description:Ve.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:Dt("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 Ve;return(Ve=X.current)==null?void 0:Ve.click()},children:[e.jsx("input",{ref:X,type:"file",accept:"video/*",className:"hidden",onChange:Ve=>{var dt;const Xe=(dt=Ve.target.files)==null?void 0:dt[0];Xe&&(B(Xe),k(pt=>({...pt,video_url:""})))}}),q?e.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm",children:[e.jsx(gn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-primary",children:q.name}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:Ve=>{Ve.stopPropagation(),B(null)},children:e.jsx(jr,{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(fi,{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(Le,{value:w.video_url,onChange:Ve=>k(Xe=>({...Xe,video_url:Ve.target.value})),placeholder:"YouTube, Vimeo, or Bunny.net URL"})]})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Text Content"}),e.jsx(gr,{value:w.text_content,onChange:Ve=>k(Xe=>({...Xe,text_content:Ve.target.value})),placeholder:"Additional text content, instructions, notes...",rows:4})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Duration (minutes)"}),e.jsx(Le,{type:"number",value:w.duration_minutes,onChange:Ve=>k(Xe=>({...Xe,duration_minutes:Ve.target.value})),placeholder:"e.g. 15"})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>{N(!1),_(null),B(null)},children:"Cancel"}),e.jsxs(K,{onClick:y?fe:ut,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:Ve=>{Ve||A(null)},children:e.jsxs(hs,{children:[e.jsxs(js,{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(Le,{value:I.title,onChange:Ve=>L(Xe=>({...Xe,title:Ve.target.value})),placeholder:"Resource title"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Type"}),e.jsxs(Fs,{value:I.resource_type,onValueChange:Ve=>L(Xe=>({...Xe,resource_type:Ve})),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Le,{value:I.url,onChange:Ve=>L(Xe=>({...Xe,url:Ve.target.value})),placeholder:"https://..."})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>A(null),children:"Cancel"}),e.jsx(K,{onClick:()=>C&&et(C),disabled:!I.title.trim(),children:"Add Resource"})]})]})}),e.jsx(fs,{open:Ue,onOpenChange:Te,children:e.jsxs(hs,{children:[e.jsxs(js,{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(Le,{value:ye,onChange:Ve=>he(Ve.target.value)})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Description"}),e.jsx(gr,{value:ge,onChange:Ve=>Ne(Ve.target.value),rows:3})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>Te(!1),children:"Cancel"}),e.jsx(K,{onClick:it,disabled:!ye.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=vr(),{data:s,isLoading:r}=m3s(),{data:n,isLoading:a}=p3s(),[o,l]=S.useState(null),{data:i,isLoading:d}=f3s(o),[u,p]=S.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:Hn,color:"text-emerald-500"},{label:"Enrolled Agents",value:(s==null?void 0:s.total_enrollments)??0,icon:or,color:"text-blue-500"},{label:"Modules Completed",value:(s==null?void 0:s.total_completions)??0,icon:Vi,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(Es,{title:"LevelUp U - Stats",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>t("/admin/lms"),children:e.jsx(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:Dt("transition-all",r&&"animate-pulse"),children:e.jsxs(Re,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(b.icon,{className:Dt("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(Re,{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:Dt("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(Re,{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:Dt("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(fi,{value:b.avg_completion_pct,className:"h-2"})]})]})},b.course_id)})}):e.jsx(Pe,{className:"border-dashed",children:e.jsx(Re,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{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(Re,{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:Dt("transition-all",w&&"border-emerald-200 bg-emerald-50/30 dark:border-emerald-900/40 dark:bg-emerald-950/10"),children:e.jsx(Re,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:Dt("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(wn,{className:"h-9 w-9 shrink-0",children:[e.jsx(Ma,{src:b.avatar_url||void 0}),e.jsx(jn,{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(Hn,{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(on,{className:"h-3 w-3"}),gs(new Date(b.last_activity),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"text-right shrink-0 w-20",children:[e.jsxs("p",{className:Dt("text-sm font-bold",w?"text-emerald-600 dark:text-emerald-400":"text-foreground"),children:[b.completion_pct,"%"]}),e.jsx(fi,{value:b.completion_pct,className:"h-1.5 mt-1"})]})]})})},b.user_id)})}):e.jsx(Pe,{className:"border-dashed",children:e.jsx(Re,{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(Re,{className:"py-16 text-center",children:[e.jsx(or,{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}=qs(),s=vr(),{data:r,isLoading:n}=l3s();return e.jsx(Es,{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(Re,{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(Re,{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}=Act(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(Re,{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(fi,{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}=ao(),s=vr(),{user:r}=qs(),{data:n,isLoading:a}=c3s(t),{data:o}=Act(t),l=d3s(),[i,d]=S.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;S.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(Es,{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(Es,{title:n.title,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s("/levelup-u"),children:e.jsx(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(fi,{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(Re,{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(ni,{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:Dt("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(vd,{className:"h-4 w-4 text-muted-foreground"}):L?e.jsx(Hn,{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:Dt("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(on,{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:k(_.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(Re,{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(Hn,{className:"h-3.5 w-3.5 mr-1"})," Completed"]}):e.jsxs(K,{size:"sm",onClick:w,disabled:l.isPending,children:[e.jsx(Hn,{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(yn,{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(Zr,{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(K,{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(Re,{className:"flex items-center justify-center py-16 text-muted-foreground",children:"Select a module to begin"})})})]})]})}):e.jsx(Es,{title:"Not Found",children:e.jsxs("div",{className:"text-center py-20",children:[e.jsx("p",{className:"text-muted-foreground",children:"Course not found"}),e.jsxs(K,{variant:"outline",className:"mt-4",onClick:()=>s("/levelup-u"),children:[e.jsx(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(dr.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(dr.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(dr.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(dr.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(dr.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(Ga,{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(dr.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=S.useRef(null),o=DEt(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(dr.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]=S.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(or,{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(jr,{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(Le,{required:!0,value:t.first_name,onChange:l=>s(i=>({...i,first_name:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"John"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-gray-700 text-sm font-medium",children:"Last Name"}),e.jsx(Le,{value:t.last_name,onChange:l=>s(i=>({...i,last_name:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"Smith"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-gray-700 text-sm font-medium",children:"Email *"}),e.jsx(Le,{type:"email",required:!0,value:t.email,onChange:l=>s(i=>({...i,email:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"john@email.com"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-gray-700 text-sm font-medium",children:"Phone"}),e.jsx(Le,{value:t.phone,onChange:l=>s(i=>({...i,phone:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"(555) 123-4567"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-gray-700 text-sm font-medium",children:"Current Brokerage"}),e.jsx(Le,{value:t.current_brokerage,onChange:l=>s(i=>({...i,current_brokerage:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"Your current brokerage name"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-gray-700 text-sm font-medium",children:"License #"}),e.jsx(Le,{value:t.license_number,onChange:l=>s(i=>({...i,license_number:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-gray-700 text-sm font-medium",children:"Years Experience"}),e.jsx(Le,{type:"number",min:"0",value:t.experience_years,onChange:l=>s(i=>({...i,experience_years:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-gray-700 text-sm font-medium",children:"Annual Production"}),e.jsx(Le,{value:t.annual_production,onChange:l=>s(i=>({...i,annual_production:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"e.g. $5M, 20 transactions"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(xe,{className:"text-gray-700 text-sm font-medium",children:"Why are you interested?"}),e.jsx(gr,{value:t.why_interested,onChange:l=>s(i=>({...i,why_interested:l.target.value})),rows:3,className:"rounded-lg border-gray-200 focus:border-gray-400 transition-colors resize-none",placeholder:"Tell us about your goals and what you're looking for..."})]}),e.jsx(K,{type:"submit",className:"w-full h-13 text-base font-semibold rounded-xl group transition-all duration-300 hover:shadow-lg",style:{background:`linear-gradient(135deg, ${a}, ${o})`},disabled:n,children:n?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent"}),"Submitting..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:["Send My Info",e.jsx(Ga,{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]=S.useState(1),[u,p]=S.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(vd,{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(dr.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(Ga,{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(dr.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(Le,{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(Le,{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(Le,{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(Le,{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(K,{type:"button",variant:"ghost",onClick:()=>d(1),className:"h-11",children:[e.jsx(Oa,{className:"h-4 w-4 mr-1"})," Back"]}),e.jsxs(K,{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(Ga,{className:"h-4 w-4 ml-1"})]})]})]},"step2"),i===3&&e.jsxs(dr.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(Le,{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(Le,{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(Le,{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(gr,{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(K,{type:"button",variant:"ghost",onClick:()=>d(2),className:"h-11",children:[e.jsx(Oa,{className:"h-4 w-4 mr-1"})," Back"]}),e.jsx(K,{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(Si,{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]=S.useState("250000"),[d,u]=S.useState("70"),[p,f]=S.useState("150"),[y,_]=S.useState(""),[b,N]=S.useState(!1),[w,k]=S.useState(!1),C=t.commission_split_pct??80,A=t.cap_amount??16e3,I=t.monthly_fee??99,L=t.transaction_fee??0,O=S.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),ae=B-ce-I*12-L,ie=ae-Y;return{currentNet:Y,newNet:ae,diff:ie}},[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){k(!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{k(!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(vd,{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(Le,{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(Le,{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(Le,{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(dr.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(Le,{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(K,{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]=S.useState(""),[i,d]=S.useState(""),[u,p]=S.useState(!1),[f,y]=S.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(vd,{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(Le,{value:i,onChange:b=>d(b.target.value),placeholder:"First name (optional)",className:"h-11"}),e.jsx(Le,{type:"email",required:!0,value:o,onChange:b=>l(b.target.value),placeholder:"your@email.com",className:"h-11"})]}),e.jsxs(K,{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}=ao(),{toast:s}=ja(),[r,n]=S.useState(!1),[a,o]=S.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",experience_years:"",annual_production:"",license_number:"",why_interested:""});S.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=Et({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)||[],k=(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(dr.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(Ga,{className:"h-3.5 w-3.5"})]})]})}),e.jsx(_3s,{headline:k,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}=ao(),s=S.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:k}=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(k)throw k;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(S.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(nc,{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(K,{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(ln,{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",L9e=`https://${E3s}.supabase.co/functions/v1/recruit-unsubscribe`;function P3s(){const[t]=Nc(),s=t.get("token")||"",[r,n]=S.useState(!0),[a,o]=S.useState(!1),[l,i]=S.useState(!1),[d,u]=S.useState(""),[p,f]=S.useState({});S.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(k=>document.querySelectorAll(k).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()}},[]),S.useEffect(()=>{if(!s){f({error:"Missing unsubscribe token in link."}),n(!1);return}fetch(`${L9e}?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(L9e,{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(Hn,{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(gr,{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(K,{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=vr(),s=Qt(),{isAdmin:r}=qs(),[n,a]=S.useState(!1),[o,l]=S.useState(null),[i,d]=S.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=Et({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"))||[],k=(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(Es,{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(K,{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(Re,{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(on,{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(Re,{className:"flex items-center gap-4 p-4",children:[e.jsx("div",{className:"rounded-full bg-green-500 p-2",children:e.jsx(ti,{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(Lt,{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(Ft,{className:"text-lg",children:"Facebook"}),e.jsx(ur,{children:"Connect your Facebook Pages"})]})]})}),e.jsxs(Re,{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(wn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:L.profile_picture_url||""}),e.jsx(jn,{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(Dl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(xr,{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(K,{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(Bs,{className:"h-4 w-4"}),N.length>0?"Connect Another Page":"Connect Facebook Page"]})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{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(Ft,{className:"text-lg",children:"Instagram"}),e.jsx(ur,{children:"Connect Instagram Business accounts"})]})]})}),e.jsxs(Re,{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(wn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:L.profile_picture_url||""}),e.jsx(jn,{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(Dl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(xr,{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(K,{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(Bs,{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(Lt,{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(xp,{className:"h-6 w-6 text-blue-700"})}),e.jsxs("div",{children:[e.jsx(Ft,{className:"text-lg",children:"LinkedIn"}),e.jsx(ur,{children:"Connect your LinkedIn profile"})]})]})}),e.jsxs(Re,{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"})}):k.length>0?e.jsx("div",{className:"space-y-3",children:k.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(wn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:L.profile_picture_url||""}),e.jsx(jn,{children:e.jsx(xp,{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(Dl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(xr,{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(K,{onClick:_,disabled:n,className:"w-full gap-2",variant:k.length>0?"outline":"default",children:[n?e.jsx(Zi,{className:"h-4 w-4 animate-spin"}):e.jsx(Bs,{className:"h-4 w-4"}),k.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(Lt,{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(Ft,{className:"text-lg",children:"Google Business"}),e.jsx(ur,{children:"Connect your Google Business Profile"})]})]})}),e.jsxs(Re,{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(wn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:L.profile_picture_url||""}),e.jsx(jn,{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(Dl,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(xr,{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(K,{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(Bs,{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(Lt,{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(Ft,{className:"text-lg",children:"Meta API Testing (Admin Only)"}),e.jsx(ur,{children:"Run API tests to trigger all required permissions for Meta App Review"})]})]})}),e.jsxs(Re,{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(K,{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(K,{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(Hn,{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(Ql,{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(Lt,{children:e.jsx(Ft,{className:"text-lg",children:"How it works"})}),e.jsx(Re,{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=vr(),[r,n]=S.useState("loading"),[a,o]=S.useState("Processing your connection...");return S.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(Lt,{className:"text-center",children:[r==="loading"&&e.jsx(us,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(ti,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(Ql,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Ft,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(ur,{children:a})]}),e.jsx(Re,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function D3s(){const[t]=Nc(),s=vr(),[r,n]=S.useState("loading"),[a,o]=S.useState("Connecting your Google Business Profile...");return S.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(Lt,{className:"text-center",children:[r==="loading"&&e.jsx(us,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(ti,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(Ql,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Ft,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(ur,{children:a})]}),e.jsx(Re,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/social-connections"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function R3s(){const[t]=Nc(),s=vr(),[r,n]=S.useState("loading"),[a,o]=S.useState("Connecting your LinkedIn account...");return S.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(Lt,{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(ti,{className:"h-8 w-8 text-green-600"}),r==="error"&&e.jsx(Ql,{className:"h-8 w-8 text-red-600"})]}),e.jsxs(Ft,{className:"flex items-center justify-center gap-2",children:[e.jsx(xp,{className:"h-5 w-5 text-blue-600"}),r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(ur,{children:a})]}),e.jsx(Re,{className:"flex justify-center",children:e.jsx(K,{onClick:()=>s("/social-connections"),disabled:r==="loading",children:r==="success"?"Continue":"Back to Connections"})})]})})}function O3s(){const t=vr(),[s,r]=S.useState(null),{data:n,isLoading:a}=Glt(s||void 0,!0),{data:o,isLoading:l}=VCe(!0),{cartItems:i}=the(),d=i.reduce((p,f)=>p+f.quantity,0),u=p=>{t(`/marketplace/${p.id}`)};return a||l?e.jsx(Es,{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(ks,{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(ks,{className:"h-72 w-full"},p))})]})}):e.jsx(Es,{title:"Marketplace",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-5xl font-bold text-foreground",children:"Marketplace"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Shop exclusive products for LevelUp members"})]}),e.jsxs(K,{variant:"outline",onClick:()=>t("/marketplace/cart"),className:"relative",children:[e.jsx(op,{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(K,{variant:s===null?"default":"outline",size:"sm",onClick:()=>r(null),children:"All"}),o.map(p=>e.jsx(K,{variant:s===p.id?"default":"outline",size:"sm",onClick:()=>r(p.id),children:p.name},p.id))]}),n&&n.length>0?e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:n.map(p=>{var f;return e.jsxs(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(Re,{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 Ect=S.forwardRef(({...t},s)=>e.jsx("nav",{ref:s,"aria-label":"breadcrumb",...t}));Ect.displayName="Breadcrumb";const Pct=S.forwardRef(({className:t,...s},r)=>e.jsx("ol",{ref:r,className:Dt("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",t),...s}));Pct.displayName="BreadcrumbList";const doe=S.forwardRef(({className:t,...s},r)=>e.jsx("li",{ref:r,className:Dt("inline-flex items-center gap-1.5",t),...s}));doe.displayName="BreadcrumbItem";const s2e=S.forwardRef(({asChild:t,className:s,...r},n)=>{const a=t?tje:"a";return e.jsx(a,{ref:n,className:Dt("transition-colors hover:text-foreground",s),...r})});s2e.displayName="BreadcrumbLink";const Ict=S.forwardRef(({className:t,...s},r)=>e.jsx("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:Dt("font-normal text-foreground",t),...s}));Ict.displayName="BreadcrumbPage";const r2e=({children:t,className:s,...r})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:Dt("[&>svg]:size-3.5",s),...r,children:t??e.jsx(xa,{})});r2e.displayName="BreadcrumbSeparator";function F3s(){var J,X;const{productId:t}=ao(),s=vr(),{data:r,isLoading:n}=B4s(t||""),{addToCart:a,cartItems:o}=the(),[l,i]=S.useState(null),[d,u]=S.useState(1),[p,f]=S.useState(0),[y,_]=S.useState(null),[b,N]=S.useState(!1),[w,k]=S.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,ae)=>ce+ae.quantity,0),B=async ce=>{if(!ce.target.files||ce.target.files.length===0)return;N(!0);const ae=ce.target.files[0],ie=ae.name.split(".").pop(),oe=`artwork/${Date.now()}-${Math.random().toString(36).substring(7)}.${ie}`;try{const{error:me}=await G.storage.from("marketplace").upload(oe,ae);if(me)throw me;const{data:{publicUrl:ye}}=G.storage.from("marketplace").getPublicUrl(oe);_(ye),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),k(!0),pe.success("Added to cart!"),setTimeout(()=>k(!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(Es,{title:"Product",children:e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[e.jsx(ks,{className:"aspect-square w-full"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(ks,{className:"h-8 w-3/4"}),e.jsx(ks,{className:"h-6 w-1/4"}),e.jsx(ks,{className:"h-24 w-full"}),e.jsx(ks,{className:"h-12 w-full"})]})]})}):r?e.jsxs(Es,{title:r.name,children:[e.jsx(Ect,{className:"mb-6",children:e.jsxs(Pct,{children:[e.jsx(doe,{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(doe,{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(doe,{children:e.jsx(Ict,{children:r.name})})]})}),e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"relative aspect-square bg-muted rounded-lg overflow-hidden flex items-center justify-center",children:r.images&&r.images.length>0?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:r.images[p].image_url,alt:r.name,className:"max-w-full max-h-full object-contain"}),r.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",className:"absolute left-2 top-1/2 -translate-y-1/2 bg-background/80 hover:bg-background",onClick:Y,children:e.jsx(Xo,{className:"h-6 w-6"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 bg-background/80 hover:bg-background",onClick: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,ae)=>e.jsx("button",{onClick:()=>f(ae),className:`w-16 h-16 flex-shrink-0 rounded-md overflow-hidden border-2 ${ae===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(Re,{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(K,{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(K,{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(K,{variant:"outline",size:"icon",onClick:()=>u(ce=>Math.max(1,ce-1)),children:"-"}),e.jsx(Le,{type:"number",value:d,onChange:ce=>u(Math.max(1,parseInt(ce.target.value)||1)),className:"w-20 text-center",min:"1"}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(ce=>ce+1),children:"+"})]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(K,{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(op,{className:"h-5 w-5 mr-2"}),"Add to Cart"]})}),e.jsxs(K,{variant:"outline",size:"lg",onClick:()=>s("/marketplace/cart"),className:"relative",children:[e.jsx(op,{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(Es,{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(K,{onClick:()=>s("/marketplace"),children:"Back to Marketplace"})]})})}function z3s(){const t=vr(),{cartItems:s,removeFromCart:r,updateQuantity:n,getItemPrice:a,getSubtotal:o,getShippingTotal:l,getTotal:i,clearCart:d}=the(),[u,p]=S.useState(!1),[f,y]=S.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 k;return{product_id:w.product.id,variant_id:((k=w.variant)==null?void 0:k.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(Es,{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(K,{onClick:()=>t("/marketplace"),children:"Browse Marketplace"})]})}):e.jsx(Es,{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(Re,{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(k=>k.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(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{var k;return r(b.product.id,(k=b.variant)==null?void 0:k.id)},children:e.jsx(xr,{className:"h-4 w-4 text-destructive"})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>{var k;return n(b.product.id,(k=b.variant)==null?void 0:k.id,b.quantity-1)},disabled:b.quantity<=1,children:e.jsx(Qy,{className:"h-3 w-3"})}),e.jsx(Le,{type:"number",value:b.quantity,onChange:k=>{var C;return n(b.product.id,(C=b.variant)==null?void 0:C.id,parseInt(k.target.value)||1)},className:"w-14 h-8 text-center text-sm",min:"1"}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>{var k;return n(b.product.id,(k=b.variant)==null?void 0:k.id,b.quantity+1)},children:e.jsx(Bs,{className:"h-3 w-3"})})]})]})]})})},`${b.product.id}-${((w=b.variant)==null?void 0:w.id)||"base"}`)}),e.jsx(K,{variant:"ghost",className:"text-destructive",onClick:d,children:"Clear Cart"})]}),e.jsx("div",{children:e.jsxs(Pe,{className:"sticky top-4",children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"Order Summary"})}),e.jsxs(Re,{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(xo,{}),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(xo,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"orderNotes",children:"Order Notes (Optional)"}),e.jsx(gr,{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(K,{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(Ga,{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=vr(),{data:s,isLoading:r}=X4s();return r?e.jsx(Es,{title:"My Orders",children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(n=>e.jsx(ks,{className:"h-32 w-full"},n))})}):!s||s.length===0?e.jsx(Es,{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(K,{onClick:()=>t("/marketplace"),children:"Browse Marketplace"})]})}):e.jsx(Es,{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(Re,{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:gs(new Date(n.created_at),"MMM d, yyyy")})]}),e.jsx(Qe,{className:UCe[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(K,{variant:"outline",size:"sm",onClick:i=>{i.stopPropagation(),window.open(n.tracking_url,"_blank")},children:[e.jsx(Zr,{className:"h-4 w-4 mr-1"}),"Track"]}),e.jsx(xa,{className:"h-5 w-5 text-muted-foreground"})]})]})]})},n.id)})})})}const D9e=["order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed"];function $3s({currentStatus:t,statusHistory:s}){const r=D9e.indexOf(t);return e.jsx("div",{className:"space-y-3",children:D9e.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(Hn,{className:"h-4 w-4"}):i?e.jsx(on,{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:[gs(new Date(o.created_at),"MMM d, yyyy h:mm a"),o.notes&&` — ${o.notes}`]})]})]},n)})})}function q3s(){var k;const{orderId:t}=ao(),s=vr(),{data:r,isLoading:n,refetch:a}=Q4s(t||""),o=tSs(),l=sSs(),[i,d]=S.useState(!1),[u,p]=S.useState(null),[f,y]=S.useState(""),[_,b]=S.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(Es,{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(ks,{className:"h-64 w-full"}),e.jsx(ks,{className:"h-48 w-full"})]}),e.jsx(ks,{className:"h-96 w-full"})]})}):r?e.jsxs(Es,{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(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ft,{children:"Order Status"}),e.jsx(Qe,{className:UCe[r.status],children:iT[r.status]})]}),e.jsx(Re,{children:e.jsx($3s,{currentStatus:r.status,statusHistory:r.status_history})})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"Items"})}),e.jsx(Re,{className:"space-y-4",children:(k=r.items)==null?void 0:k.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(Zr,{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(Zr,{className:"h-3 w-3"})]}),C.proof_status==="pending"&&e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsxs(K,{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(K,{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(Hn,{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(Lt,{children:e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(UL,{className:"h-5 w-5"}),"Shipping"]})}),e.jsxs(Re,{children:[e.jsx("p",{className:"font-medium",children:r.shipping_name}),e.jsxs("p",{className:"text-muted-foreground",children:[r.shipping_address,e.jsx("br",{}),r.shipping_city,", ",r.shipping_state," ",r.shipping_zip]}),r.tracking_number&&e.jsxs("div",{className:"mt-4 p-3 bg-muted rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Tracking Number:"}),e.jsx("p",{className:"font-mono font-medium",children:r.tracking_number}),r.tracking_url&&e.jsxs(K,{variant:"link",className:"p-0 h-auto mt-1",onClick:()=>window.open(r.tracking_url,"_blank"),children:["Track Package",e.jsx(Zr,{className:"h-3 w-3 ml-1"})]})]})]})]})]}),e.jsx("div",{children:e.jsxs(Pe,{className:"sticky top-4",children:[e.jsx(Lt,{children:e.jsx(Ft,{children:"Order Summary"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Placed on ",gs(new Date(r.created_at),"MMMM d, yyyy")]}),e.jsx(xo,{}),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(xo,{}),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(xo,{}),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(hs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Request Changes"}),e.jsx(Ir,{children:"Please describe what changes you'd like made to the proof."})]}),e.jsx(gr,{placeholder:"Describe the changes needed...",value:f,onChange:C=>y(C.target.value),rows:4}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(K,{onClick:w,disabled:!f.trim()||_!==null,children:[_?e.jsx(us,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Submit Request"]})]})]})})]}):e.jsx(Es,{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(K,{onClick:()=>s("/marketplace/orders"),children:"View All Orders"})]})})}function U3s(){const t=vr(),[s]=Nc();return s.get("session_id"),S.useEffect(()=>{localStorage.removeItem("marketplace-cart")},[]),e.jsx(Es,{title:"Order Confirmed",children:e.jsx("div",{className:"max-w-lg mx-auto text-center py-8",children:e.jsx(Pe,{children:e.jsxs(Re,{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(Hn,{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(K,{className:"flex-1",onClick:()=>t("/marketplace/orders"),children:["View My Orders",e.jsx(Ga,{className:"h-4 w-4 ml-2"})]}),e.jsx(K,{variant:"outline",className:"flex-1",onClick:()=>t("/marketplace"),children:"Continue Shopping"})]})]})})})})}function V3s(){const{user:t}=qs(),[s,r]=S.useState("store"),[n,a]=S.useState(null),[o,l]=S.useState(null),[i,d]=S.useState(!1),[u,p]=S.useState(5),[f,y]=S.useState(""),[_,b]=S.useState(!1),[N,w]=S.useState(!1),[k,C]=S.useState(""),[A,I]=S.useState(null),[L,O]=S.useState(!1),{hasSubmittedReview:V,submitReview:q,markPostedToGoogle:B}=XYe(),{data:U}=Klt(),{data:te,isLoading:Y}=Wlt(),{data:J,isLoading:X}=cSs(n),{data:ce,isLoading:ae}=dSs(t==null?void 0:t.id),{data:ie=0}=hSs(t==null?void 0:t.id),oe=mSs(),me=new Set((ce==null?void 0:ce.map(Me=>Me.item_id))||[]),ye=async()=>{if(o)try{const Me=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(Me){pe.error(Me.message||"Failed to purchase item")}},he=async()=>{if(!f.trim()){pe.error("Please write a review");return}b(!0);const Me=await q(u,f);b(!1),Me.success?(pe.success("Thank you for your review! You earned 25 points!"),C(f),w(!0),y(""),p(5)):pe.error(Me.error||"Failed to submit review")},ge=()=>{navigator.clipboard.writeText(k),pe.success("Review copied to clipboard!")},Ne=()=>{B(),window.open("https://g.page/r/CT8bqTBTm7nJEBM/review","_blank")},Ue=()=>{w(!1),d(!1),C("")};return Y||X||ae?e.jsx(Es,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ks,{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(Me=>e.jsx(ks,{className:"h-64"},Me))})]})}):e.jsxs(Es,{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(Re,{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:ie.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(Vi,{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(Lt,{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(Vi,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ft,{className:"text-base",children:"How to Earn Points"}),e.jsx(ur,{children:"See all the ways you can earn spendable points"})]})]}),L?e.jsx(af,{className:"h-5 w-5 text-muted-foreground"}):e.jsx(Fi,{className:"h-5 w-5 text-muted-foreground"})]})})}),e.jsx(df,{children:e.jsx(Re,{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(Me=>Me.is_active).map(Me=>{const De=qe=>{switch(qe){case"event_attendance":return e.jsx(ln,{className:"h-5 w-5"});case"leave_review":return e.jsx(Gn,{className:"h-5 w-5"});case"add_listing":return e.jsx(Sn,{className:"h-5 w-5"});case"first_contact":return e.jsx(or,{className:"h-5 w-5"});case"first_video":return e.jsx(gn,{className:"h-5 w-5"});case"first_community_post":return e.jsx(Si,{className:"h-5 w-5"});default:return e.jsx(yi,{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:De(Me.action_key)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:Me.action_name}),Me.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Me.description})]}),e.jsxs(Qe,{variant:"secondary",className:"font-bold shrink-0",children:["+",Me.points]})]},Me.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(Re,{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(Si,{className:"h-6 w-6 text-yellow-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Earn 25 Free Points!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Leave a quick review and earn 25 spendable points"})]})]}),e.jsxs(K,{onClick:()=>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(ls,{value:"store",className:"flex items-center gap-2",children:[e.jsx(s0,{className:"h-4 w-4"}),"Store"]}),e.jsxs(ls,{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(ws,{value:"store",className:"mt-6",children:[te&&te.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[e.jsx(K,{variant:n===null?"default":"outline",size:"sm",onClick:()=>a(null),children:"All"}),te.map(Me=>e.jsxs(K,{variant:n===Me.id?"default":"outline",size:"sm",onClick:()=>a(Me.id),children:[Me.icon&&`${Me.icon} `,Me.name]},Me.id))]}),!J||J.length===0?e.jsx(Pe,{children:e.jsx(Re,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(yi,{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(Me=>{const De=Me.item_type==="reelflow_credits",qe=!De&&me.has(Me.id),ke=!De&&Me.max_quantity!==null&&Me.current_quantity===0,$e=ie>=Me.points_cost;return e.jsxs(Pe,{className:`overflow-hidden transition-all cursor-pointer hover:shadow-lg ${qe?"ring-2 ring-green-500/50 bg-green-500/5":""}`,onClick:()=>I(Me),children:[Me.preview_image_url?e.jsxs("div",{className:"aspect-video relative overflow-hidden bg-muted",children:[e.jsx("img",{src:Me.preview_image_url,alt:Me.name,className:"w-full h-full object-cover"}),qe&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(Qe,{className:"bg-green-500 text-white",children:[e.jsx(Hn,{className:"h-3 w-3 mr-1"}),"Owned"]})}),ke&&!qe&&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(yi,{className:"h-12 w-12 text-muted-foreground/50"}),qe&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(Qe,{className:"bg-green-500 text-white",children:[e.jsx(Hn,{className:"h-3 w-3 mr-1"}),"Owned"]})})]}),e.jsxs(Lt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(Ft,{className:"text-lg",children:Me.name}),e.jsxs(Qe,{variant:"secondary",className:"font-bold shrink-0",children:[e.jsx(Gn,{className:"h-3 w-3 mr-1"}),Me.points_cost]})]}),Me.category&&e.jsxs(Qe,{variant:"outline",className:"w-fit",children:[Me.category.icon&&`${Me.category.icon} `,Me.category.name]})]}),e.jsxs(Re,{children:[e.jsx(ur,{className:"mb-4 line-clamp-2",children:Me.description||"No description available"}),Me.max_quantity!==null&&!qe&&!De&&e.jsxs("p",{className:"text-xs text-muted-foreground mb-3",children:[Me.current_quantity," of ",Me.max_quantity," remaining"]}),De&&e.jsxs("p",{className:"text-xs text-violet-600 font-medium mb-3",children:["🎬 Grants ",Me.max_quantity," ReelFlow credits per purchase"]}),qe?e.jsx(K,{className:"w-full",onClick:Be=>{Be.stopPropagation(),Me.file_url&&j0e(Me.file_url,Me.name)},disabled:!Me.file_url,children:Me.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(Zr,{className:"h-4 w-4 mr-2"}),"Access"]})}):e.jsx(K,{className:"w-full",onClick:Be=>{Be.stopPropagation(),l(Me)},disabled:ke||!$e,children:ke?"Sold Out":$e?e.jsxs(e.Fragment,{children:[e.jsx(s0,{className:"h-4 w-4 mr-2"}),"Purchase"]}):`Need ${Me.points_cost-ie} more pts`})]})]},Me.id)})})]}),e.jsx(ws,{value:"my-rewards",className:"mt-6",children:!ce||ce.length===0?e.jsx(Pe,{children:e.jsx(Re,{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(Me=>{var De,qe,ke,$e,Be,we,ut;return e.jsxs(Pe,{className:"overflow-hidden",children:[(De=Me.item)!=null&&De.preview_image_url?e.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted",children:e.jsx("img",{src:Me.item.preview_image_url,alt:((qe=Me.item)==null?void 0:qe.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(yi,{className:"h-12 w-12 text-muted-foreground/50"})}),e.jsxs(Lt,{className:"pb-2",children:[e.jsx(Ft,{className:"text-lg",children:((ke=Me.item)==null?void 0:ke.name)||"Unknown Item"}),e.jsxs(ur,{className:"text-xs",children:["Purchased for ",Me.points_spent," points • ",new Date(Me.purchased_at).toLocaleDateString()]})]}),e.jsx(Re,{children:(($e=Me.item)==null?void 0:$e.item_type)==="reelflow_credits"?e.jsxs(K,{className:"w-full",variant:"outline",disabled:!0,children:[e.jsx(Hn,{className:"h-4 w-4 mr-2 text-green-500"}),(Be=Me.item)==null?void 0:Be.max_quantity," Credits Applied"]}):e.jsx(K,{className:"w-full",onClick:()=>{var fe,He;(fe=Me.item)!=null&&fe.file_url&&j0e(Me.item.file_url,(He=Me.item)==null?void 0:He.name)},disabled:!((we=Me.item)!=null&&we.file_url),children:((ut=Me.item)==null?void 0:ut.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(Zr,{className:"h-4 w-4 mr-2"}),"Access"]})})})]},Me.id)})})})]})]}),e.jsx(Dl,{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:[ie," points"]}),". After this purchase, you'll have"," ",e.jsxs("strong",{children:[ie-((o==null?void 0:o.points_cost)||0)," points"]})," remaining."]})]}),e.jsxs(vl,{children:[e.jsx(wl,{children:"Cancel"}),e.jsx(ll,{onClick:ye,disabled:oe.isPending,children:oe.isPending?"Purchasing...":"Confirm Purchase"})]})]})}),e.jsx(fs,{open:i,onOpenChange:Me=>{!Me&&N?Ue():d(Me)},children:e.jsx(hs,{children:N?e.jsxs(e.Fragment,{children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(Hn,{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:['"',k,'"']})]}),e.jsxs(K,{variant:"outline",className:"w-full",onClick:ge,children:[e.jsx(Wa,{className:"h-4 w-4 mr-2"}),"Copy Review to Clipboard"]})]}),e.jsxs(_n,{className:"flex-col sm:flex-row gap-2",children:[e.jsx(K,{variant:"outline",onClick:Ue,children:"Maybe Later"}),e.jsxs(K,{onClick:Ne,className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(Zr,{className:"h-4 w-4 mr-2"}),"Leave Google Review"]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(js,{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(Me=>e.jsx("button",{type:"button",onClick:()=>p(Me),className:"focus:outline-none",children:e.jsx(Gn,{className:`h-8 w-8 transition-colors ${u>=Me?"fill-yellow-400 text-yellow-400":"text-muted-foreground hover:text-yellow-400"}`})},Me))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Your Review"}),e.jsx(gr,{placeholder:"What do you love about LevelUp? How has it helped your business?",value:f,onChange:Me=>y(Me.target.value),rows:4})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(K,{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(hs,{className:"max-w-lg",children:[e.jsxs(js,{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(_n,{children:A&&A.item_type!=="reelflow_credits"&&me.has(A.id)?e.jsx(K,{className:"w-full",onClick:()=>{A.file_url&&j0e(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(Zr,{className:"h-4 w-4 mr-2"}),"Access"]})}):A&&e.jsx(K,{className:"w-full",onClick:()=>{I(null),l(A)},disabled:A.item_type!=="reelflow_credits"&&A.max_quantity!==null&&A.current_quantity===0||ie{const{user:t}=qs(),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=Et({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=Et({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=Et({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=Et({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=Et({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}},H3s=()=>{const t=vr(),{presentations:s,isLoading:r,archivePresentation:n,saveAsTemplate:a}=Lct(),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(Es,{title:"Smart Presentations",children:e.jsxs("div",{className:"max-w-5xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("h1",{className:"text-2xl font-serif font-bold text-foreground",children:"Smart Presentations"})}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Create personalized, video-first presentations for your clients"})]}),e.jsxs(K,{onClick:()=>t("/mission-control/presentations/new"),className:"gap-2",children:[e.jsx(Bs,{className:"h-4 w-4"}),"Create Presentation"]})]}),r?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(i=>e.jsx(ks,{className:"h-20 w-full rounded-lg"},i))}):s.length===0?e.jsx(Pe,{children:e.jsxs(Re,{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(K,{onClick:()=>t("/mission-control/presentations/new"),className:"gap-2",children:[e.jsx(Bs,{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(Re,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(yn,{className:"h-5 w-5 text-primary"})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:"font-semibold truncate",children:i.title}),o(i)]}),e.jsxs("div",{className:"flex items-center gap-x-3 gap-y-0.5 flex-wrap text-sm text-muted-foreground mt-0.5",children:[i.client_name&&e.jsx("span",{children:i.client_name}),e.jsxs("span",{children:["Created ",gs(new Date(i.created_at),"MMM d, yyyy")]}),i.view_count>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Cn,{className:"h-3 w-3"})," ",i.view_count," view",i.view_count!==1?"s":""]}),i.cta_clicked_count>0&&e.jsx("span",{className:"text-emerald-600 font-medium",children:"CTA clicked"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap sm:flex-nowrap sm:shrink-0",children:[i.status==="published"&&i.share_token&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>l(i.share_token),children:[e.jsx(Wa,{className:"h-3.5 w-3.5 mr-1"}),"Copy Link"]}),i.status==="published"&&e.jsx(K,{variant:"outline",size:"sm",onClick:()=>t(`/mission-control/presentations/${i.id}?edit=true`),children:"Edit"}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>t(`/mission-control/presentations/${i.id}`),children:i.status==="draft"?"Edit":"View"}),e.jsxs(Hd,{children:[e.jsx(Gd,{asChild:!0,children:e.jsx(K,{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(Zr,{className:"h-4 w-4 mr-2"}),"Preview Link"]}),e.jsxs(_a,{onClick:()=>a.mutate(i),children:[e.jsx(yn,{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))})]})})},R9e={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."}]},G3s=[{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 W3s(t){const s=R9e[t];if(s)return s;const r=t.toLowerCase();for(const[n,a]of Object.entries(R9e))if(r.includes(n.toLowerCase())||n.toLowerCase().includes(r))return a;return G3s}function K3s({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=S.useState(!1),[o,l]=S.useState("script"),[i,d]=S.useState(0),[u,p]=S.useState(0),{canRecord:f}=nit(),y=Mw(),[_,b]=S.useState(""),[N,w]=S.useState(!1),[k,C]=S.useState(!0),[A,I]=S.useState(!1),[L,O]=S.useState(null),V=W3s(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=S.useCallback(async(X,ce)=>{l("uploading");try{const ae=t||"Presentation Video",{videoId:ie,uploadUrl:oe,libraryId:me}=await wE(ae),{apiKey:ye}=await jE(ie),he=new XMLHttpRequest;he.upload.onprogress=Me=>{Me.lengthComputable&&d(Me.loaded/Me.total*100)},await new Promise((Me,De)=>{he.onload=()=>he.status>=200&&he.status<300?Me():De(new Error("Upload failed")),he.onerror=()=>De(new Error("Upload failed")),he.open("PUT",oe),he.setRequestHeader("AccessKey",ye),he.send(X)}),l("processing");let ge=0;const Ne=Date.now(),Ue=9e4;let Te=null;for(;ge<4;){if(await new Promise(De=>setTimeout(De,3e3)),Date.now()-Ne>Ue){const De=X.size/1048576,qe=`https://iframe.mediadelivery.net/embed/${me}/${ie}?responsive=true`;await y.mutateAsync({bunny_video_id:ie,playback_url:qe,file_size_mb:De,title:ae,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(qe),pe.success("Video saved — still encoding. It will be ready shortly."),l("done"),setTimeout(()=>a(!1),1500);return}const Me=await nw(ie);if(ge=Me.status,p(Me.encodeProgress||0),ge===4)Te={playbackUrl:Me.directPlayUrl,thumbnailUrl:Me.thumbnailUrl,previewUrl:Me.previewUrl||null,duration:Me.length||ce,fileSizeMb:(Me.storageSize||X.size)/(1024*1024)};else if(ge===5||ge===6)throw new Error("Video processing failed")}if(!Te)throw new Error("No video data");await y.mutateAsync({bunny_video_id:ie,contact_id:s||void 0,playback_url:Te.playbackUrl,thumbnail_url:Te.thumbnailUrl,preview_url:Te.previewUrl,duration_seconds:Te.duration,file_size_mb:Te.fileSizeMb,title:ae,status:"ready",touch_type:"presentation"}),r(Te.playbackUrl),pe.success("Video recorded, saved to library & attached!"),l("done"),setTimeout(()=>a(!1),1500)}catch(ae){console.error("Recording upload error:",ae),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(hi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Record a video",children:[e.jsx(gn,{className:"h-3.5 w-3.5"}),"Record"]})}),e.jsxs(hs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto !top-[5%] !translate-y-0 sm:!top-[5%] sm:!translate-y-0",children:[e.jsx(js,{children:e.jsxs(_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:Dt("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(yn,{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(K,{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(gr,{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(gr,{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(K,{variant:"ghost",size:"sm",onClick:Y,className:"text-muted-foreground",children:"Skip — no teleprompter"}),e.jsx(K,{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(K,{variant:"ghost",size:"sm",onClick:()=>C(!k),className:"h-7 text-xs gap-1",children:[k?e.jsx(mp,{className:"h-3 w-3"}):e.jsx(Cn,{className:"h-3 w-3"}),k?"Hide Script":"Show Script"]})]}),e.jsx(TO,{maxDurationSeconds:600,onRecordingComplete:J,onRecordingStateChange:I,onError:X=>pe.error(X),teleprompterContent:_.trim()?e.jsx(wlt,{text:_,isVisible:k,onToggleVisibility:()=>C(!k),isRecording:A,startCountdown:!1}):void 0}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>l("script"),className:"text-xs text-muted-foreground",children:"← Back to script"})]}):o==="uploading"?e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(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(fi,{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(fi,{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(ti,{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 Z3s({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=S.useState(!1),[o,l]=S.useState(null),[i,d]=S.useState("idle"),[u,p]=S.useState(0),f=S.useRef(null),y=Mw(),{data:_}=Tme(),b=(_==null?void 0:_.total_storage_mb)||0,w=((_==null?void 0:_.max_storage_mb)||1024)-b,k=()=>{l(null),d("idle"),p(0)},C=V=>{!V&&i!=="idle"&&i!=="done"||(a(V),V||k())},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=S.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((ae,ie)=>{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?ae():ie(new Error(`Upload failed (${oe.status})`))),oe.addEventListener("error",()=>ie(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(hi,{asChild:!0,children:e.jsxs(K,{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(hs,{className:"sm:max-w-md",children:[e.jsx(js,{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(gn,{className:"h-8 w-8 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:o.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(o.size/(1024*1024)).toFixed(1)," MB"]})]}),!O&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(null),children:e.jsx(jr,{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(fi,{value:i==="uploading"?u:i==="processing"?100:10})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>C(!1),disabled:O,children:"Cancel"}),e.jsx(K,{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 O9e=[{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"}],F9e=()=>{const t=vr(),{id:s}=ao(),{user:r}=qs(),{templates:n,templatesLoading:a,createPresentation:o,updatePresentation:l,publishPresentation:i}=Lct(),{isGmailConnected:d,gmailEmail:u}=jp(),[p,f]=S.useState(!1),[y,_]=S.useState("client"),[b,N]=S.useState(!1),[w,k]=S.useState(""),[C,A]=S.useState([]),[I,L]=S.useState(!1),[O,V]=S.useState(null),[q,B]=S.useState(!1),[U,te]=S.useState(""),[Y,J]=S.useState(""),[X,ce]=S.useState(""),[ae,ie]=S.useState("buyer"),[oe,me]=S.useState(""),[ye,he]=S.useState(null),[ge,Ne]=S.useState(""),[Ue,Te]=S.useState([]),[Me,De]=S.useState("schedule_call"),[qe,ke]=S.useState("Schedule a Call"),[$e,Be]=S.useState(""),[we,ut]=S.useState(""),[fe,He]=S.useState(null),[et,tt]=S.useState(s||null),[_e,Ge]=S.useState(null),[We,it]=S.useState(!1),Ve=async($t,Us)=>{if(!r)return;const Nr=5*1024*1024;if($t.size>Nr){pe.error("Image must be under 5MB");return}if(!$t.type.startsWith("image/")){pe.error("Please upload an image file");return}He(Us);try{const Xs=$t.name.split(".").pop()||"jpg",kr=`${r.id}/${Date.now()}.${Xs}`,{error:fn}=await G.storage.from("listing-photos").upload(kr,$t);if(fn)throw fn;const{data:{publicUrl:Yr}}=G.storage.from("listing-photos").getPublicUrl(kr);Nt(Us,{image_url:Yr}),pe.success("Image uploaded")}catch{pe.error("Failed to upload image")}finally{He(null)}};S.useEffect(()=>{s&&Xe(s)},[s]);const Xe=async $t=>{const{data:Us,error:Nr}=await G.from("smart_presentations").select("*").eq("id",$t).single();if(Nr||!Us)return;const Xs=Us;if(N(!0),Ne(Xs.title),te(Xs.client_name||""),me(Xs.property_address||""),Te(Xs.sections||[]),De(Xs.cta_type||"schedule_call"),ke(Xs.cta_label||"Schedule a Call"),Be(Xs.cta_url||""),ut(Xs.heading||""),Ge(Xs.share_token),it(Xs.status==="published"),tt(Xs.id),_("builder"),Xs.contact_id){const{data:kr}=await G.from("innercircle_contacts").select("id, first_name, last_name, email, phone").eq("id",Xs.contact_id).maybeSingle();kr&&(V(kr),J(kr.email||""),ce(kr.phone||""))}};S.useEffect(()=>{if(!r||w.length<1){A([]);return}const $t=setTimeout(async()=>{L(!0);const{data:Us}=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(Us||[]),L(!1)},300);return()=>clearTimeout($t)},[w,r]);const dt=$t=>{V($t),te(`${$t.first_name} ${$t.last_name||""}`.trim()),J($t.email||""),ce($t.phone||""),B(!1)},pt=async()=>{if(!U.trim()){pe.error("Client name is required");return}const $t=U.trim().split(" "),Us=$t[0],Nr=$t.slice(1).join(" ")||null,{data:Xs,error:kr}=await G.from("innercircle_contacts").insert({owner_user_id:r.id,first_name:Us,last_name:Nr,email:Y||null,phone:X||null,lead_source:"Smart Presentation"}).select().single();if(kr){pe.error("Failed to create client");return}V(Xs),pe.success("Client created & saved to Agent OS"),_("template")},Je=$t=>{he($t);const Us=($t.sections||[]).map(Nr=>({...Nr,is_visible:!0,video_url:"",text:""}));if(Te(Us),Ne($t.name+(U?` for ${U}`:"")),$t.cta_config){const Nr=$t.cta_config;De(Nr.type||"schedule_call"),ke(Nr.label||"Schedule a Call")}_("builder")},Ze=()=>{Te([{title:"Welcome",description:"A personal welcome",type:"video",icon:"👋",is_visible:!0}]),Ne(U?`Presentation for ${U}`:"New Presentation"),_("builder")},Nt=($t,Us)=>{Te(Nr=>Nr.map((Xs,kr)=>kr===$t?{...Xs,...Us}:Xs))},Ot=$t=>{Nt($t,{is_visible:!Ue[$t].is_visible})},Yt=()=>{Te($t=>[...$t,{title:"New Section",description:"",type:"video",icon:"📝",is_visible:!0}])},Ps=$t=>{Te(Us=>Us.filter((Nr,Xs)=>Xs!==$t))},$s=async()=>{if(!ge.trim()){pe.error("Title is required");return}try{if(et){const $t=await l.mutateAsync({id:et,title:ge,sections:Ue,client_name:U,property_address:oe||null,cta_type:Me,cta_label:qe,cta_url:$e||null,heading:we||null});pe.success("Saved")}else{const $t=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:(ye==null?void 0:ye.id)||void 0,sections:Ue,cta_type:Me,cta_label:qe,cta_url:$e||void 0,heading:we||void 0});tt($t.id),Ge($t.share_token),pe.success("Presentation created!")}}catch($t){console.error("Failed to save presentation:",$t);const Us=($t==null?void 0:$t.message)||($t==null?void 0:$t.toString())||"Unknown error";pe.error(`Failed to save: ${Us}`)}},Zs=async()=>{try{await $s();const $t=et;if($t){const Us=await i.mutateAsync($t);Ge(Us.share_token),it(!0),_("share")}}catch($t){console.error("Failed to publish presentation:",$t),pe.error(`Failed to publish: ${($t==null?void 0:$t.message)||"Unknown error"}`)}},Dr=_e?`https://presentations.relevelup.com/${_e}`:"";return e.jsx(Es,{title:"Smart Presentations",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>t("/mission-control/presentations"),children:e.jsx(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(($t,Us)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:Dt("w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors",y===$t?"bg-primary text-primary-foreground":Us<["client","template","builder","share"].indexOf(y)?"bg-emerald-100 text-emerald-700":"bg-muted text-muted-foreground"),children:Us<["client","template","builder","share"].indexOf(y)?e.jsx(Zn,{className:"h-4 w-4"}):Us+1}),e.jsx("span",{className:"text-sm font-medium capitalize hidden sm:inline",children:$t}),Us<3&&e.jsx("div",{className:"w-8 h-px bg-border"})]},$t))}),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(Mn,{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(Ga,{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(Lt,{className:"pb-3",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(an,{className:"h-4 w-4 text-muted-foreground"}),"Select Existing Client"]})}),e.jsxs(Re,{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name or email...",value:w,onChange:$t=>k($t.target.value),className:"pl-10"})]}),e.jsxs("div",{className:"space-y-2 max-h-56 overflow-y-auto",children:[I&&e.jsx(ks,{className:"h-12 w-full"}),C.map($t=>e.jsxs("button",{onClick:()=>dt($t),className:Dt("w-full text-left p-3 rounded-lg border transition-colors",(O==null?void 0:O.id)===$t.id?"border-primary bg-primary/5":"border-border hover:border-primary/50"),children:[e.jsxs("p",{className:"font-medium text-sm",children:[$t.first_name," ",$t.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:$t.email||$t.phone||"No contact info"})]},$t.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(K,{onClick:()=>_("template"),className:"w-full gap-2",children:["Continue with ",O.first_name,e.jsx(Ga,{className:"h-4 w-4"})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ft,{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(Re,{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(Le,{value:U,onChange:$t=>{te($t.target.value),B(!0),V(null)},placeholder:"Sarah & Mike Johnson"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Email"}),e.jsx(Le,{value:Y,onChange:$t=>J($t.target.value),placeholder:"Optional",type:"email"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Phone"}),e.jsx(Le,{value:X,onChange:$t=>ce($t.target.value),placeholder:"Optional"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Client Type"}),e.jsxs(Fs,{value:ae,onValueChange:ie,children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsxs(Rs,{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(Le,{value:oe,onChange:$t=>me($t.target.value),placeholder:"Optional"})]})]}),q&&U&&e.jsxs(K,{onClick:pt,className:"w-full gap-2",children:["Create Client & Continue",e.jsx(Ga,{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(ls,{value:"mine",children:"My Core Templates"}),e.jsx(ls,{value:"system",children:"LevelUp Smart Templates"}),e.jsx(ls,{value:"blank",children:"+ Start Blank"})]}),e.jsx(ws,{value:"mine",className:"mt-4",children:a?e.jsx("div",{className:"grid grid-cols-2 gap-4",children:[1,2].map($t=>e.jsx(ks,{className:"h-32"},$t))}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter($t=>!$t.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($t=>!$t.is_system).map($t=>e.jsx(z9e,{template:$t,onSelect:Je},$t.id))})}),e.jsx(ws,{value:"system",className:"mt-4",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter($t=>$t.is_system).map($t=>e.jsx(z9e,{template:$t,onSelect:Je},$t.id))})}),e.jsx(ws,{value:"blank",className:"mt-4",children:e.jsx(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"Start with a blank canvas and add your own sections."}),e.jsx(K,{onClick:Ze,children:"Start from Scratch"})]})})})]}),e.jsxs(K,{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(Re,{className:"pt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Presentation Title"}),e.jsx(Le,{value:ge,onChange:$t=>Ne($t.target.value)})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Page Heading"}),e.jsx(Le,{value:we,onChange:$t=>ut($t.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(Le,{value:U,onChange:$t=>te($t.target.value)})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Property Address"}),e.jsx(Le,{value:oe,onChange:$t=>me($t.target.value),placeholder:"Optional"})]})]})]})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sections"}),e.jsx(K,{variant:"outline",size:"sm",onClick:Yt,children:"+ Add Section"})]}),e.jsx("div",{className:"space-y-3",children:Ue.map(($t,Us)=>e.jsx(Pe,{className:Dt(!$t.is_visible&&"opacity-50"),children:e.jsx(Re,{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:$t.icon})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Le,{value:$t.title,onChange:Nr=>Nt(Us,{title:Nr.target.value}),className:"font-semibold border-none p-0 h-auto text-base focus-visible:ring-0 bg-transparent"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ot(Us),children:$t.is_visible?e.jsx(Cn,{className:"h-4 w-4"}):e.jsx(mp,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ps(Us),className:"text-destructive hover:text-destructive",children:e.jsx(xr,{className:"h-4 w-4"})})]})]}),e.jsx(Le,{value:$t.description||"",onChange:Nr=>Nt(Us,{description:Nr.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(Le,{value:$t.video_url||"",onChange:Nr=>Nt(Us,{video_url:Nr.target.value}),placeholder:"Paste a YouTube or video URL...",className:"text-sm"})]}),e.jsx(K3s,{sectionTitle:$t.title,contactId:O==null?void 0:O.id,onVideoReady:Nr=>Nt(Us,{video_url:Nr})}),e.jsx(Z3s,{sectionTitle:$t.title,contactId:O==null?void 0:O.id,onVideoReady:Nr=>Nt(Us,{video_url:Nr})}),e.jsx(BCe,{userId:r==null?void 0:r.id,onSelect:Nr=>Nt(Us,{video_url:Nr})})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Image (optional — shown if no video is set)"}),$t.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:$t.image_url,alt:"",className:"w-full max-h-40 object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>Nt(Us,{image_url:""}),children:e.jsx(jr,{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===Us?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===Us?"Uploading...":"Click to upload an image"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",disabled:fe===Us,onChange:Nr=>{var kr;const Xs=(kr=Nr.target.files)==null?void 0:kr[0];Xs&&Ve(Xs,Us),Nr.target.value=""}})]})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Text (optional)"}),e.jsx(Wg,{content:$t.text||"",onChange:Nr=>Nt(Us,{text:Nr}),placeholder:"Add supporting text...",minHeight:"80px",compact:!0})]})]})]})})},Us))})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Call to Action"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"CTA Type"}),e.jsxs(Fs,{value:Me,onValueChange:$t=>{De($t);const Us=O9e.find(Nr=>Nr.value===$t);Us&&ke(Us.label)},children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsx(Rs,{children:O9e.map($t=>e.jsx(vt,{value:$t.value,children:$t.label},$t.value))})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Button Label"}),e.jsx(Le,{value:qe,onChange:$t=>ke($t.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(Le,{value:$e,onChange:$t=>Be($t.target.value),placeholder:"https://calendly.com/..."}),!$e&&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(K,{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(K,{variant:"outline",onClick:$s,disabled:o.isPending||l.isPending,children:"Save Draft"}),e.jsxs(K,{onClick:Zs,disabled:i.isPending,className:"gap-2",children:[e.jsx(Mn,{className:"h-4 w-4"}),We?"Update & Reshare":"Publish & Share"]})]})]})]}),y==="share"&&_e&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Pe,{children:e.jsxs(Re,{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(Le,{value:Dr,readOnly:!0,className:"text-center font-mono text-sm"}),e.jsx(K,{onClick:()=>{navigator.clipboard.writeText(Dr),pe.success("Link copied!")},children:e.jsx(Wa,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex gap-3 mt-6",children:[e.jsxs(K,{variant:"outline",className:"gap-2",onClick:()=>{const $t=`Hi ${U||""}! I put together something for you — check it out: ${Dr}`;navigator.clipboard.writeText($t),pe.success("Message copied!")},children:[e.jsx(Si,{className:"h-4 w-4"}),"Copy Text Message"]}),e.jsxs(K,{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: ${Dr} 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: ${Dr} Looking forward to connecting!`,gmailEmail:u})]})}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs(K,{variant:"outline",onClick:()=>_("builder"),children:[e.jsx(Oa,{className:"h-4 w-4 mr-2"}),"Edit Presentation"]}),e.jsx(K,{onClick:()=>t("/mission-control/presentations"),children:"Done"})]})]})]})})},z9e=({template:t,onSelect:s})=>e.jsx(Pe,{className:"hover:shadow-sm transition-shadow",children:e.jsxs(Re,{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(K,{className:"w-full mt-4",size:"sm",onClick:()=>s(t),children:"Use Template"})]})}),Y3s=()=>{var N;const{shareToken:t}=ao(),[s,r]=S.useState(null),[n,a]=S.useState(!0),[o,l]=S.useState(0),[i,d]=S.useState(!1);S.useEffect(()=>(document.body.classList.add("presentation-page"),()=>{document.body.classList.remove("presentation-page")}),[]),S.useEffect(()=>{t&&u()},[t]);const u=async()=>{const{data:w,error:k}=await G.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(k||!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(ks,{className:"h-12 w-3/4 mx-auto"}),e.jsx(ks,{className:"h-64 w-full"}),e.jsx(ks,{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 k=w.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(k)return`https://www.youtube.com/embed/${k[1]}?rel=0`;if(w.includes("iframe.mediadelivery.net/play/")){const 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,k)=>e.jsx("button",{onClick:()=>l(k),className:Dt("w-full text-left p-4 rounded-xl border transition-all",o===k?"border-blue-500 bg-blue-50 shadow-sm":"border-gray-200 bg-white hover:border-blue-200 hover:bg-blue-50/50"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("span",{className:"text-blue-600 font-bold text-sm mt-0.5",children:[String(k+1).padStart(2,"0"),"."]}),e.jsxs("div",{children:[e.jsx("span",{className:"mr-2",children:w.icon}),e.jsx("span",{className:"font-semibold text-gray-900",children:w.title}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:w.description})]})]})},k))})]}),e.jsxs("div",{className:"mt-12 max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6 text-center",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-20 w-20 rounded-full object-cover mx-auto mb-3 border-2 border-gray-100"}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-sm text-gray-500",children:s.owner_title}),s.brokerage_name&&e.jsx("p",{className:"text-sm text-gray-500",children:s.brokerage_name}),e.jsxs("div",{className:"mt-3 flex flex-col items-center gap-1 text-sm text-gray-600",children:[s.owner_phone&&e.jsx("a",{href:`tel:${s.owner_phone}`,className:"hover:text-blue-600 transition-colors",children:s.owner_phone}),s.owner_email&&e.jsx("a",{href:`mailto:${s.owner_email}`,className:"hover:text-blue-600 transition-colors",children:s.owner_email})]})]}),s.cta_label&&e.jsxs("div",{className:"text-center mt-8 py-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Ready to Get Started?"}),b?e.jsxs(K,{size:"lg",onClick:p,className:"text-lg px-8 py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",children:[s.cta_label,e.jsx(Zr,{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 X3s({openHouseId:t,enableSurvey:s,onToggleSurvey:r}){const{data:n,isLoading:a}=s4t(t),o=i4t(),l=o4t(),i=l4t(),d=c4t(),[u,p]=S.useState(""),[f,y]=S.useState("rating"),_=async k=>{r(k),k&&(!n||n.length===0)&&await d.mutateAsync(t)},b=async()=>{if(!u.trim())return;const k=(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:k+1}),p("")},N=async k=>{await l.mutateAsync({id:k.id,open_house_id:t,is_active:!k.is_active})},w=async k=>{await i.mutateAsync({id:k.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(Mr,{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(k=>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:k.question_text}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:k.question_type.replace("_"," ")})]}),e.jsx(Mr,{checked:k.is_active,onCheckedChange:()=>N(k),className:"scale-75"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>w(k),children:e.jsx(xr,{className:"h-3.5 w-3.5"})})]},k.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(Le,{value:u,onChange:k=>p(k.target.value),placeholder:"e.g. How did you hear about this listing?",className:"mt-1 h-9 text-sm",onKeyDown:k=>k.key==="Enter"&&b()})]}),e.jsxs(Fs,{value:f,onValueChange:y,children:[e.jsx(Ds,{className:"w-28 h-9 text-xs",children:e.jsx(zs,{})}),e.jsxs(Rs,{children:[e.jsx(vt,{value:"rating",children:"Rating"}),e.jsx(vt,{value:"open_text",children:"Text"})]})]}),e.jsx(K,{size:"sm",variant:"outline",onClick:b,disabled:!u.trim()||o.isPending,className:"h-9",children:e.jsx(Bs,{className:"h-3.5 w-3.5"})})]})]})})]})}function Q3s({open:t,onOpenChange:s,openHouse:r}){const n=kWe(),{user:a}=qs(),o=S.useRef(null),l=S.useRef(null),[i,d]=S.useState(r.auto_forward_to_card??!1),[u,p]=S.useState(r.disclosure_pdf_url??""),[f,y]=S.useState(r.enable_survey??!1),[_,b]=S.useState(r.ask_visitor_intent??!0),[N,w]=S.useState(r.photo_url??""),[k,C]=S.useState(!1),[A,I]=S.useState(!1),[L,O]=S.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){pn({title:"Image must be under 10MB",variant:"destructive"});return}if(!J.type.startsWith("image/")){pn({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:ae}=await G.storage.from("open-house-photos").upload(ce,J,{upsert:!0});if(ae){pn({title:"Upload failed",description:ae.message,variant:"destructive"}),I(!1);return}const{data:ie}=G.storage.from("open-house-photos").getPublicUrl(ce);w(ie.publicUrl),I(!1),pn({title:"Photo updated!"})},q=()=>{w(""),l.current&&(l.current.value="")},B=async Y=>{var ie;const J=(ie=Y.target.files)==null?void 0:ie[0];if(!J||!a)return;if(J.size>20*1024*1024){pn({title:"File must be under 20MB",variant:"destructive"});return}if(J.type!=="application/pdf"){pn({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){pn({title:"Upload failed",description:ce.message,variant:"destructive"}),C(!1);return}const{data:ae}=G.storage.from("open-house-photos").getPublicUrl(X);p(ae.publicUrl),C(!1),pn({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}),pn({title:"Settings saved!"}),s(!1)}catch{pn({title:"Failed to save",variant:"destructive"})}finally{O(!1)}};return e.jsx(fs,{open:t,onOpenChange:s,children:e.jsxs(hs,{className:"sm:max-w-md max-h-[85vh] overflow-y-auto",children:[e.jsxs(js,{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(K,{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(K,{variant:"secondary",size:"icon",className:"h-8 w-8",onClick:q,children:e.jsx(jr,{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(Mr,{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(yn,{className:"h-5 w-5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm truncate flex-1",children:"Disclosure PDF uploaded"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:U,children:e.jsx(jr,{className:"h-4 w-4"})})]}):e.jsx("button",{type:"button",onClick:()=>{var Y;return(Y=o.current)==null?void 0:Y.click()},disabled:k,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:k?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(Mr,{checked:_,onCheckedChange:b})]})}),e.jsx(X3s,{openHouseId:r.id,enableSurvey:f,onToggleSurvey:y}),e.jsx(K,{onClick:te,disabled:L,className:"w-full",children:L?"Saving...":"Save Settings"})]})]})})}const Dct={5:"Excellent",4:"Good",3:"Neutral",2:"Bad",1:"Very Bad"};function J3s({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:Dct[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 e5s({openHouseId:t}){const{data:s,isLoading:r}=a4t(t),{data:n}=NWe(t),a=S.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(Lt,{className:"pb-3",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(Nb,{className:"h-4 w-4"}),"Survey Results"]})}),e.jsx(Re,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No survey responses yet."})})]}):e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ft,{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(Re,{children:e.jsxs(ta,{defaultValue:"summary",children:[e.jsxs(Jn,{className:"mb-4",children:[e.jsxs(ls,{value:"summary",className:"text-xs gap-1",children:[e.jsx(so,{className:"h-3.5 w-3.5"})," Summary"]}),e.jsxs(ls,{value:"individual",className:"text-xs gap-1",children:[e.jsx(Ai,{className:"h-3.5 w-3.5"})," Per Visitor"]})]}),e.jsxs(ws,{value:"summary",className:"space-y-6",children:[i.map(f=>e.jsx(J3s,{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(ws,{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?Dct[b.rating_value]||b.rating_value:b.text_value})]},b.id):null})})]},f)})})]})})]})}const n2e="guestbook.relevelup.com";function t5s(){const{data:t,isLoading:s}=Qkt(),r=Jkt(),n=kWe(),a=e4t(),[o,l]=S.useState(!1),[i,d]=S.useState(null),{user:u}=qs(),p=ya(),[f,y]=S.useState(null),[_,b]=S.useState(null),[N,w]=S.useState(!1),k=S.useRef(null),[C,A]=S.useState({property_address:"",city:"",state:"",zip:"",event_date:gs(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){pn({title:"Photo must be under 5MB",variant:"destructive"});return}y(B),b(URL.createObjectURL(B))}},L=()=>{y(null),b(null),k.current&&(k.current.value="")},O=async()=>{if(!C.property_address){pn({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){pn({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:gs(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}`),pn({title:"Link copied!"})};return e.jsxs(Es,{title:"Guest Book",children:[e.jsx(nc,{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(hi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"New Open House"]})}),e.jsxs(hs,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[e.jsxs(js,{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(Le,{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(Le,{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(Le,{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(Le,{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(Le,{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(Le,{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(Le,{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(gr,{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:k,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(jr,{className:"h-4 w-4"})})]}):e.jsxs("button",{type:"button",onClick:()=>{var q;return(q=k.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(K,{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(Lt,{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(s5s,{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(Re,{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(K,{onClick:()=>l(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-2"}),"Create Your First Open House"]})]})})]})]})}function s5s({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]=S.useState(!1),[p,f]=S.useState(!1),[y,_]=S.useState(!1),b=S.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}`},k=()=>{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,'""'),gs(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=S.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=S.useCallback(()=>{var we;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=gs(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,ae=ce?"0.35in 0.75in 0.3in":"0.55in 0.75in 0.45in",ie=ce?"28px":"34px",oe=ce?"0.2in 0.75in":X?"0.3in 0.75in":"0.4in 0.75in",me=X?"0.15in":"0.3in",ye=X?"0.15in":"0.3in",he=ce?"14px 36px":"22px 44px",ge=ce?"20px":"24px",Ne=X?"0.2in":"0.35in",Ue=ce?"1.8in":"2.4in",Te=X?"0.15in":"0.3in",Me=ce?"140px":X?"160px":"200px",De=ce?"16px":"24px",qe=ce?"10px 20px":"16px 28px",ke=ce?"44px":"56px",$e="0.15in",Be=window.open("","_blank");Be&&(Be.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}`:`
${((we=i.name)==null?void 0:we.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
`),Be.document.close(),setTimeout(()=>{Be.focus(),Be.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;pn({title:"Email sent!",description:"Check your inbox for the guest book link."})}catch(L){pn({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(Lt,{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(Ft,{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(K,{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(Fi,{className:"h-4 w-4"})})]}),e.jsxs(ur,{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(ln,{className:"h-3 w-3"}),gs(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(on,{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(or,{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(K,{variant:"outline",size:"sm",onClick:()=>window.location.href=`/mission-control/guest-book/live/${t.id}`,title:"Go Live",className:"shrink-0 gap-1.5 text-emerald-600 border-emerald-200 hover:bg-emerald-50 dark:text-emerald-400 dark:border-emerald-800 dark:hover:bg-emerald-900/20 h-8 text-xs",children:[e.jsx(e1,{className:"h-3.5 w-3.5"}),"Live"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:n,title:"Copy link",className:"shrink-0 gap-1.5 h-8 text-xs",children:[e.jsx(Wa,{className:"h-3.5 w-3.5"}),"Copy"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>u(!0),title:"QR Code",className:"shrink-0 gap-1.5 h-8 text-xs",children:[e.jsx(Jy,{className:"h-3.5 w-3.5"}),"QR"]}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>f(!0),title:"Settings",className:"shrink-0 h-8 text-xs",children:e.jsx(So,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>window.open(N,"_blank"),title:"Preview",className:"shrink-0 h-8 text-xs",children:e.jsx(Zr,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:a,title:t.is_active?"Deactivate":"Activate",className:"shrink-0 h-8 text-xs",children:t.is_active?e.jsx(mp,{className:"h-3.5 w-3.5"}):e.jsx(Cn,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:o,title:"Delete",className:"shrink-0 h-8 text-xs text-destructive border-destructive/30 hover:bg-destructive/10",children:e.jsx(xr,{className:"h-3.5 w-3.5"})})]})]})}),s&&e.jsxs(Re,{className:"pt-0",children:[e.jsx(xo,{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(K,{variant:"outline",size:"sm",onClick:k,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:gs(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(e5s,{openHouseId:t.id})})]}),e.jsx(fs,{open:d,onOpenChange:u,children:e.jsxs(hs,{className:"sm:max-w-sm",children:[e.jsxs(js,{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(AO,{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(K,{variant:"outline",className:"flex-1",onClick:C,children:[e.jsx(Qa,{className:"h-4 w-4 mr-2"}),"Download"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:A,children:[e.jsx(PL,{className:"h-4 w-4 mr-2"}),"Print Flyer"]})]}),e.jsxs(K,{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(Q3s,{open:p,onOpenChange:f,openHouse:t})]})}function r5s(){const{slug:t}=ao();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 Rct({photoUrl:t,videoUrl:s,onPhotoChange:r,onVideoChange:n,contactId:a}){const{user:o}=qs(),l=Mw(),i=S.useRef(null),d=S.useRef(null),[u,p]=S.useState(!1),[f,y]=S.useState(!1),[_,b]=S.useState(0),N=async k=>{if(o){p(!0);try{const C=k.name.split(".").pop()||"jpg",A=`${o.id}/card-${Date.now()}.${C}`,{error:I}=await G.storage.from("listing-photos").upload(A,k);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 k=>{if(o){if(k.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(k)});const O=`https://iframe.mediadelivery.net/embed/${A}/${C}`;n(O);const V=parseFloat((k.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(ls,{value:"photo",className:"gap-1.5 text-xs",children:[e.jsx(qo,{className:"h-3.5 w-3.5"}),"Photo"]}),e.jsxs(ls,{value:"video",className:"gap-1.5 text-xs",children:[e.jsx(gn,{className:"h-3.5 w-3.5"}),"Video"]})]}),e.jsxs(ws,{value:"photo",className:"mt-3",children:[t?e.jsxs("div",{className:"relative rounded-lg overflow-hidden border border-border",children:[e.jsx("img",{src:t,alt:"Card photo",className:"w-full h-40 object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7",onClick:()=>r(null),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]}):e.jsx("button",{onClick:()=>{var k;return(k=i.current)==null?void 0:k.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:k=>{var A;const C=(A=k.target.files)==null?void 0:A[0];C&&N(C),k.target.value=""}})]}),e.jsxs(ws,{value:"video",className:"mt-3",children:[s?e.jsxs("div",{className:"relative rounded-lg overflow-hidden border border-border",children:[e.jsx("iframe",{src:`${s}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7",onClick:()=>n(null),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]}):e.jsx("button",{onClick:()=>{var k;return(k=d.current)==null?void 0:k.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($Ce,{contactId:a,onVideoReady:k=>n(k)})}),e.jsx("input",{ref:d,type:"file",accept:"video/*",className:"hidden",onChange:k=>{var A;const C=(A=k.target.files)==null?void 0:A[0];C&&w(C),k.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 n5s=[{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 a5s({onSelect:t}){return e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:n5s.map((s,r)=>e.jsxs(dr.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 B9e({initialOpen:t,initialCardType:s,initialContactId:r,initialRecipientName:n,initialAddress:a,initialDate:o,onOpenChange:l}){const{user:i}=qs(),d=Qt(),[u,p]=S.useState(!1),[f,y]=S.useState("type"),[_,b]=S.useState(""),[N,w]=S.useState(null),[k,C]=S.useState(!1),[A,I]=S.useState("home_anniversary"),[L,O]=S.useState(""),[V,q]=S.useState(""),[B,U]=S.useState(""),[te,Y]=S.useState(""),[J,X]=S.useState("elegant"),[ce,ae]=S.useState(null),[ie,oe]=S.useState(null),me=S.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:ye}=gt({queryKey:["contacts-for-card",i==null?void 0:i.id,_],queryFn:async()=>{let $e=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);_&&($e=$e.or(`first_name.ilike.%${_}%,last_name.ilike.%${_}%`));const{data:Be,error:we}=await $e;if(we)throw we;return Be},enabled:!!(i!=null&&i.id)&&u}),{data:he}=gt({queryKey:["agent-profile-card",i==null?void 0:i.id],queryFn:async()=>{const{data:$e,error:Be}=await G.from("profiles").select("name, email, phone, avatar_url, brokerage:brokerages(name)").eq("id",i.id).single();if(Be)throw Be;return $e},enabled:!!(i!=null&&i.id)}),ge=$e=>{w($e.id),O(`${$e.first_name}${$e.last_name?" "+$e.last_name:""}`),q([$e.address,$e.city,$e.state].filter(Boolean).join(", ")),U($e.home_anniversary||""),y("details")},Ne=$e=>{I($e),y("contact")},Ue=async()=>{var $e;if(!(!i||!he)){C(!0);try{const Be={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:ie||null,agent_name:he.name||"Agent",agent_photo_url:he.avatar_url,agent_phone:he.phone,agent_email:he.email,agent_brokerage:(($e=he.brokerage)==null?void 0:$e.name)||null},{error:we}=await G.from("sendable_cards").insert(Be);if(we)throw we;pe.success("Card created! Copy the link to share it."),d.invalidateQueries({queryKey:["sendable-cards"]}),Te()}catch(Be){pe.error(Be.message||"Failed to create card")}finally{C(!1)}}},Te=()=>{p(!1),y("type"),I("home_anniversary"),b(""),w(null),O(""),q(""),U(""),Y(""),X("elegant"),ae(null),oe(null)},Me={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"},De=RE[A],qe=A==="home_anniversary",ke=["home_anniversary","just_listed","just_sold"].includes(A);return e.jsxs(fs,{open:u,onOpenChange:$e=>{$e?p(!0):(Te(),l==null||l(!1))},children:[e.jsx(hi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Bs,{className:"h-4 w-4"}),"Create Card"]})}),e.jsxs(hs,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:f==="type"?"What type of card?":f==="contact"?`${Me[A]} — Choose a Contact`:`${Me[A]} — Customize`})}),f==="type"&&e.jsx(a5s,{onSelect:Ne}),f==="contact"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1.5 -ml-2 text-muted-foreground",onClick:()=>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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search contacts...",value:_,onChange:$e=>b($e.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:[ye==null?void 0:ye.map($e=>e.jsxs("button",{onClick:()=>ge($e),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:[$e.first_name," ",$e.last_name]}),$e.address&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate flex items-center gap-1",children:[e.jsx(Sn,{className:"h-3 w-3"}),$e.address]})]}),$e.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"})]},$e.id)),(ye==null?void 0:ye.length)===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No contacts found"})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsx(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{y("details")},children:"Skip — enter details manually"})})]}),f==="details"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1.5 -ml-2 text-muted-foreground",onClick:()=>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(Le,{value:L,onChange:$e=>O($e.target.value),placeholder:"John & Jane Smith"})]}),ke&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Property Address"}),e.jsx(Le,{value:V,onChange:$e=>q($e.target.value),placeholder:"123 Main St, Austin, TX"})]}),qe&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Home Anniversary Date"}),e.jsx(Le,{type:"date",value:B,onChange:$e=>U($e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{children:"Personal Message (optional)"}),e.jsx(gr,{value:te,onChange:$e=>Y($e.target.value),placeholder:De.defaultMessage,rows:3})]}),e.jsx(Rct,{photoUrl:ce,videoUrl:ie,onPhotoChange:ae,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:$e,label:Be,gradient:we})=>e.jsxs("button",{onClick:()=>X($e),className:`p-2 rounded-lg border-2 transition-all text-center ${J===$e?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("div",{className:`h-10 rounded-md mb-1.5 ${we}`}),e.jsx("span",{className:"text-[10px] font-medium",children:Be})]},$e))})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>y("contact"),className:"flex-1",children:"Back"}),e.jsx(K,{onClick:Ue,disabled:!L||k,className:"flex-1 gap-2",children:k?"Creating...":"Create Card"})]})]})]})]})}const i5s={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 o5s({card:t}){qs();const{isGmailConnected:s}=jp(),r=Qt(),[n,a]=S.useState(!1),[o,l]=S.useState("");S.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]=S.useState(i[t.card_type]||`A Special Card for ${t.recipient_name}!`),[p,f]=S.useState(""),y=`https://cardstudio.relevelup.com/c/${t.share_token}`,_=Et({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 ${i5s[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,k=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(!k.ok){const A=await k.json();throw new Error(A.error||"Failed to send")}return k.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(hi,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(Mn,{className:"h-3 w-3"})})}),e.jsxs(hs,{className:"sm:max-w-md",children:[e.jsx(js,{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(Le,{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(Le,{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(gr,{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(K,{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(Mn,{className:"h-4 w-4"})," Send Card"]})})]})]})]}):e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs opacity-50 cursor-not-allowed",title:"Connect Gmail in Settings to send cards via email",disabled:!0,children:e.jsx(Mn,{className:"h-3 w-3"})})}function l5s({card:t}){const s=Qt(),[r,n]=S.useState(!1),[a,o]=S.useState(!1),[l,i]=S.useState(t.recipient_name),[d,u]=S.useState(t.property_address||""),[p,f]=S.useState(t.home_anniversary_date||""),[y,_]=S.useState(t.custom_message||""),[b,N]=S.useState(t.template),[w,k]=S.useState(t.property_photo_url),[C,A]=S.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),k(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(hi,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(ga,{className:"h-3 w-3"})})}),e.jsxs(hs,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{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(Le,{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(Le,{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(Le,{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(gr,{value:y,onChange:O=>_(O.target.value),placeholder:"Wishing you many more happy years in your beautiful home!",rows:3})]}),e.jsx(Rct,{photoUrl:w,videoUrl:C,onPhotoChange:k,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(K,{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 c5s(){const{user:t}=qs(),s=Qt(),[r,n]=S.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=Et({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()))}),k={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(Es,{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(B9e,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search cards...",value:r,onChange: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(Re,{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:k[A.template]||A.template})})]}),e.jsxs(Re,{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(Cn,{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 ",gs(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(K,{variant:"outline",size:"sm",className:"flex-1 gap-1 text-xs",onClick:()=>N(A.share_token),children:[e.jsx(Wa,{className:"h-3 w-3"}),"Copy Link"]}),e.jsx(l5s,{card:A}),e.jsx(o5s,{card:A}),e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",onClick:()=>window.open(`https://cardstudio.relevelup.com/c/${A.share_token}`,"_blank"),children:e.jsx(Zr,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive gap-1 text-xs",onClick:()=>b.mutate(A.id),children:e.jsx(xr,{className:"h-3 w-3"})})]})]})]},A.id))}):e.jsx(Pe,{className:"border-dashed",children:e.jsxs(Re,{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(B9e,{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(dr.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 d5s(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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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 k0e({delay:t,x:s,y:r,color:n,size:a}){return e.jsx(dr.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(dr.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 $9e={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 u5s(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-br ${b.bg} flex items-center justify-center p-4 overflow-hidden relative`,children:[e.jsx(k0e,{delay:0,x:"10%",y:"10%",color:b.orbs[0],size:200}),e.jsx(k0e,{delay:1,x:"70%",y:"60%",color:b.orbs[1],size:180}),e.jsx(k0e,{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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(Sn,{className:"h-3.5 w-3.5"}),n]})]}),f&&e.jsx(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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 h5s({emoji:t,delay:s,x:r,duration:n}){return e.jsx(dr.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 q9e={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 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=q9e[s]||q9e.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(h5s,{emoji:N,delay:w*1.2,x:`${15+w*14}%`,duration:5+w%3},w)),e.jsx(dr.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(dr.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(dr.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(dr.div,{className:`h-28 bg-gradient-to-r ${b.header} relative overflow-hidden`,children:[e.jsx(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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 P9({delay:t,x:s,y:r,size:n,color:a}){return e.jsx(dr.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 S0e({delay:t,x:s,y:r,size:n}){return e.jsx(dr.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 U9e={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 p5s(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-slate-950 flex items-center justify-center p-4 overflow-hidden relative",children:[e.jsx(P9,{delay:0,x:"5%",y:"10%",size:300,color:b.mesh[0]}),e.jsx(P9,{delay:2,x:"60%",y:"50%",size:250,color:b.mesh[1]}),e.jsx(P9,{delay:4,x:"30%",y:"70%",size:200,color:b.mesh[2]}),e.jsx(P9,{delay:1,x:"80%",y:"15%",size:180,color:b.mesh[0]}),e.jsx(S0e,{delay:0,x:"15%",y:"20%",size:100}),e.jsx(S0e,{delay:3,x:"70%",y:"60%",size:140}),e.jsx(S0e,{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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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 C0e({delay:t,x:s,angle:r,color:n}){return e.jsx(dr.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 I9({delay:t,x:s}){return e.jsx(dr.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 V9e={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 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=V9e[s]||V9e.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(C0e,{delay:0,x:"20%",angle:15,color:b.stripe}),e.jsx(C0e,{delay:2,x:"75%",angle:-12,color:b.stripe}),e.jsx(C0e,{delay:4,x:"50%",angle:5,color:b.stripe}),e.jsx(I9,{delay:0,x:"30%"}),e.jsx(I9,{delay:1.5,x:"60%"}),e.jsx(I9,{delay:3,x:"45%"}),e.jsx(I9,{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(dr.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0},animate:{opacity:1},transition:{duration:1.2},children:[e.jsx(dr.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(dr.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(dr.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(dr.div,{className:"mb-6",initial:{opacity:0},animate:{opacity:1},transition:{delay:.7},children:[e.jsx(dr.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(dr.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(dr.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(dr.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(dr.div,{className:"flex items-center justify-center gap-3 my-8",initial:{opacity:0},animate:{opacity:1},transition:{delay:1.2},children:[e.jsx(dr.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(dr.span,{className:"text-white/10 text-xs",animate:{rotate:[0,360]},transition:{duration:20,repeat:1/0,ease:"linear"},children:"✦"}),e.jsx(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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(dr.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 Oct(){const{shareToken:t}=ao(),{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(S.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(u5s,{...o});case"warm":return e.jsx(m5s,{...o});case"glass":return e.jsx(p5s,{...o});case"cinematic":return e.jsx(f5s,{...o});case"elegant":default:return e.jsx(d5s,{...o})}}function x5s(){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 g5s(){const t=ya(),s=Qt();return Et({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 y5s(){const t=vr(),{isGmailConnected:s,gmailEmail:r}=jp(),{data:n,isLoading:a}=x5s(),o=g5s(),[l,i]=S.useState(!1),[d,u]=S.useState(!0),[p,f]=S.useState(!1);S.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(hi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(So,{className:"h-3.5 w-3.5"}),"Settings"]})}),e.jsxs(hs,{className:"sm:max-w-md",children:[e.jsxs(js,{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(Hn,{className:"h-3 w-3"}),"Active"]}):e.jsxs(K,{variant:"outline",size:"sm",className:"text-xs gap-1",onClick:()=>{f(!1),t("/mission-control/integrations")},children:[e.jsx(Zr,{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(xo,{}),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(Mr,{checked:l,onCheckedChange:y,disabled:a||o.isPending})]}),e.jsx(xo,{}),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(Mr,{checked:d,onCheckedChange:_,disabled:a||o.isPending})]}),d&&e.jsxs(K,{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 v5s(){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 _5s(){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 b5s(){const t=ya(),s=Qt();return Et({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 w5s(){const t=Qt();return Et({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 j5s(){const t=Qt();return Et({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 N5s(){const t=ya(),s=Qt();return Et({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 k5s=[{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 S5s({open:t,onOpenChange:s,campaignId:r,campaignName:n}){const{data:a,isLoading:o}=sbs(r||void 0),l=nbs(),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(hs,{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(or,{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(ks,{className:"h-14"},f))}):!a||a.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(or,{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: ",gs(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(K,{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(K,{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(K,{size:"sm",variant:"ghost",onClick:()=>d(f.id,"exited"),title:"Exit",children:e.jsx(jr,{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(K,{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 C5s(){var A;const{data:t,isLoading:s}=zSe(),{hasLeadSite:r}=CC(),n=Q_s(),a=X_s(),o=Xat(),[l,i]=S.useState(null),[d,u]=S.useState(!1),[p,f]=S.useState(null),[y,_]=S.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")}},k=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(ks,{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(Mn,{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(or,{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(K,{size:"sm",onClick:()=>{f(null),u(!0)},children:[e.jsx(Bs,{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(K,{size:"sm",onClick:()=>{f(null),u(!0)},children:[e.jsx(Bs,{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(M5s,{campaign:I,onPreview:()=>i(I.id),onToggleActive:()=>k(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(T5s,{campaign:I,onPreview:()=>i(I.id)},I.id))})]}),e.jsx(A5s,{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(S5s,{open:!!y,onOpenChange:I=>!I&&_(null),campaignId:y,campaignName:(A=b.find(I=>I.id===y))==null?void 0:A.name})]})}function M5s({campaign:t,onPreview:s,onToggleActive:r,onDelete:n,onEdit:a,onViewEnrollments:o}){const i=rbs(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:Cme[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(K,{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(K,{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 T5s({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:Cme[t.category]})]})]})}function A5s({campaignId:t,open:s,onOpenChange:r,onClone:n,isCloning:a,onEdit:o}){const{data:l}=zSe(),{data:i}=Qat(t||void 0),[d,u]=S.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",k=_.anchor_offset_days||0;return k===0?`On their ${w}`:k<0?`${Math.abs(k)} days before ${w}`:`${k} 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(hs,{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:Cme[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(ln,{className:"h-3 w-3"}):e.jsx(on,{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(_n,{className:"border-t p-4 shrink-0",children:[e.jsx(K,{variant:"outline",onClick:()=>r(!1),children:"Close"}),!p.is_starter&&o&&e.jsxs(K,{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(K,{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(Wa,{className:"h-3.5 w-3.5 mr-1.5"}),"Copy to my campaigns"]})]})]})})}function E5s(){const t=ya(),s=vr(),{isGmailConnected:r,gmailEmail:n,isLoading:a}=jp(),{data:o,isLoading:l}=v5s(),{data:i,isLoading:d}=_5s(),u=b5s(),p=w5s(),f=j5s(),y=N5s(),[_,b]=S.useState(null),[N,w]=S.useState(null),k=(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=>k.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(Es,{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(y5s,{})]}),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(K,{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(ls,{value:"my-drips",children:"Stage Drips"}),e.jsxs(ls,{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(ls,{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(ws,{value:"campaigns",children:e.jsx(C5s,{})}),e.jsx(ws,{value:"my-drips",children:q?e.jsx("div",{className:"space-y-3",children:[1,2,3,4].map(B=>e.jsx(ks,{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(Fi,{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(K,{variant:"outline",size:"sm",onClick:()=>L(B.id),disabled:u.isPending,children:[e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1.5"}),"Create Drip"]})]}):e.jsxs(e.Fragment,{children:[U.map(J=>e.jsx(H9e,{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(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>L(B.id),children:[e.jsx(Bs,{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(Fi,{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(K,{variant:"outline",size:"sm",onClick:()=>L(B.id),disabled:u.isPending,children:[e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1.5"})," Create Drip"]})]}):e.jsxs(e.Fragment,{children:[U.map(J=>e.jsx(H9e,{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(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>L(B.id),children:[e.jsx(Bs,{className:"h-3 w-3 mr-1"})," Add another drip"]})]})})]},B.id)})]})]})}),e.jsx(ws,{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(P5s,{template:B,onCopy:()=>V(B.id),isCopying:y.isPending},B.id))})})]})]})})}function H9e({template:t,isEditing:s,onToggleEdit:r,onToggleEnabled:n,onUpdate:a,onDelete:o,userId:l}){const[i,d]=S.useState(t.title),[u,p]=S.useState(t.subject),[f,y]=S.useState(t.body),[_,b]=S.useState(t.video_url||""),[N,w]=S.useState(t.channel),[k,C]=S.useState(t.delay_type),[A,I]=S.useState(t.delay_minutes),[L,O]=S.useState(!1),V=async()=>{O(!0);try{await a({title:i,subject:u,body:f,video_url:_||null,channel:N,delay_type:k,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(Si,{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(gn,{className:"h-3 w-3 text-primary"})]})]}),e.jsx(Mr,{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(Le,{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(Si,{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 ${k==="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 ${k==="scheduled"?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:[e.jsx(on,{className:"h-3 w-3 mr-1 inline"}),"Delay"]})]})]})]}),k==="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(Le,{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(Le,{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..."}),k5s.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(gn,{className:"h-3 w-3 inline mr-1 text-primary"}),_.length>50?_.slice(0,50)+"...":_]}),e.jsx(K,{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($Ce,{onVideoReady:B=>b(B)}),e.jsx(BCe,{userId:l,onSelect:B=>b(B),triggerSize:"sm",triggerClassName:"gap-1.5 flex-1"}),e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1 text-xs text-muted-foreground flex-1",onClick:()=>{const B=prompt("Paste a YouTube or Loom URL:");B&&b(B)},children:[e.jsx(go,{className:"h-3 w-3"})," Paste URL"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs(K,{variant:"ghost",size:"sm",className:"text-xs text-destructive hover:text-destructive",onClick:o,children:[e.jsx(xr,{className:"h-3 w-3 mr-1"})," Delete"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",className:"text-xs",onClick:r,children:"Cancel"}),e.jsx(K,{size:"sm",className:"text-xs",onClick:V,disabled:L,children:L?"Saving...":"Save Drip"})]})]})]})]})}function P5s({template:t,onCopy:s,isCopying:r}){const[n,a]=S.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(Si,{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(on,{className:"h-3 w-3"}),t.delay_type==="instant"?"Instant":i.replace("Sends ","")]}),n?e.jsx(Fi,{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(on,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:i})]}),e.jsxs(K,{onClick:d=>{d.stopPropagation(),s()},size:"sm",className:"w-full gap-1.5",disabled:r,children:[e.jsx(Wa,{className:"h-3.5 w-3.5"}),"Use This Template"]})]})]})}const Fct=()=>{const t=Bl();return S.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 I5s(){return S.useEffect(()=>(document.body.classList.add("cardstudio-page"),()=>{document.body.classList.remove("cardstudio-page")}),[]),e.jsxs(Voe,{children:[e.jsx(xs,{path:"/c/:shareToken",element:e.jsx(Oct,{})}),e.jsx(xs,{path:"*",element:e.jsx(Fct,{})})]})}const M0e={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function zct({slugOverride:t}){const s=ao(),r=t||s.slug,[n,a]=S.useState("types"),[o,l]=S.useState(null),[i,d]=S.useState(null),[u,p]=S.useState(null),[f,y]=S.useState(new Date),[_,b]=S.useState({name:"",email:"",phone:"",message:""}),[N,w]=S.useState(!1),{data:k,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",k==null?void 0:k.user_id],queryFn:async()=>{const{data:X,error:ce}=await G.from("profiles").select("name, avatar_url, email, phone, title, bio").eq("id",k.user_id).single();if(ce)throw ce;return X},enabled:!!(k!=null&&k.user_id)}),{data:I=[]}=gt({queryKey:["public-booking-types",k==null?void 0:k.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",k.user_id).eq("is_active",!0).order("sort_order");if(ce)throw ce;return X},enabled:!!(k!=null&&k.user_id)}),{data:L=[]}=gt({queryKey:["public-availability",k==null?void 0:k.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",k.user_id).eq("is_active",!0);if(ce)throw ce;return X},enabled:!!(k!=null&&k.user_id)}),{data:O=[]}=gt({queryKey:["public-blocked-dates",k==null?void 0:k.user_id],queryFn:async()=>{const{data:X,error:ce}=await G.from("agent_blocked_dates").select("blocked_date").eq("user_id",k.user_id);if(ce)throw ce;return X.map(ae=>ae.blocked_date)},enabled:!!(k!=null&&k.user_id)}),{data:V=[]}=gt({queryKey:["public-existing-bookings",k==null?void 0:k.user_id,i],queryFn:async()=>{if(!i)return[];const X=gs(i,"yyyy-MM-dd"),{data:ce,error:ae}=await G.from("bookings").select("start_time, end_time").eq("agent_user_id",k.user_id).eq("booking_date",X).eq("status","confirmed");if(ae)throw ae;return ce},enabled:!!(k!=null&&k.user_id)&&!!i}),q=S.useMemo(()=>[...new Set(L.map(X=>X.day_of_week))],[L]),B=X=>{const ce=Em(new Date),ae=ml(ce,(k==null?void 0:k.max_advance_days)||30),ie=ml(ce,0);return YS(X,ie)||ZS(X,ae)||O.includes(gs(X,"yyyy-MM-dd"))?!1:q.includes(X.getDay())},U=S.useMemo(()=>{if(!i||!o||!k)return[];const X=L.filter(ye=>ye.day_of_week===i.getDay()),ce=o.duration_minutes,ae=k.buffer_minutes||0,ie=[],oe=new Date,me=(k.min_notice_hours||2)*60*60*1e3;for(const ye of X){const[he,ge]=ye.start_time.split(":").map(Number),[Ne,Ue]=ye.end_time.split(":").map(Number);let Te=JL(QL(i,he),ge);const Me=JL(QL(i,Ne),Ue);for(;J5(Te,ce)<=Me;){const De=gs(Te,"HH:mm"),qe=gs(J5(Te,ce),"HH:mm");Te.getTime()-oe.getTime()>=me&&(V.some($e=>{const Be=$e.start_time.slice(0,5),we=$e.end_time.slice(0,5);return DeBe})||ie.push(De)),Te=J5(Te,ce+ae)}}return ie},[i,o,L,k,V]),te=S.useMemo(()=>{const X=f.getFullYear(),ce=f.getMonth(),ae=new Date(X,ce,1),ie=new Date(X,ce+1,0),oe=ae.getDay(),me=[];for(let ye=0;ye{if(!(!o||!i||!u||!_.name||!k)){w(!0);try{const X=gs(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:k.user_id,booking_type_id:o.id,booking_date:gs(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:k.user_id,guestName:_.name,guestEmail:_.email||null,guestPhone:_.phone||null,guestMessage:_.message||null,bookingTypeName:o.name,bookingDate:gs(i,"yyyy-MM-dd"),startTime:u,endTime:X,durationMinutes:o.duration_minutes,meetingLink:k.meeting_link||null}}).catch(ae=>console.error("Booking notify error:",ae)),a("confirmed")}catch(X){pe.error("Failed to book: "+X.message)}finally{w(!1)}}},J=X=>{const[ce,ae]=X.split(":").map(Number),ie=ce>=12?"PM":"AM";return`${ce%12||12}:${ae.toString().padStart(2,"0")} ${ie}`};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..."})]})}):k?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:M0e[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(on,{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:M0e[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(on,{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:gs(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 ae=B(X),ie=i&&il(X,i),oe=il(X,new Date);return e.jsx("button",{disabled:!ae,onClick:()=>{d(X),p(null)},className:`h-10 w-10 mx-auto rounded-xl text-sm font-medium transition-all duration-150 ${ie?"bg-[#406E71] text-white shadow-md shadow-[#406E71]/30 scale-105":ae?"hover:bg-[#406E71]/10 text-slate-700 hover:text-[#406E71]":"text-slate-200 cursor-not-allowed"} ${oe&&!ie?"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(yd,{className:"h-4 w-4 text-[#406E71]"}),e.jsx("h3",{className:"font-semibold text-sm text-slate-800",children:gs(i,"EEEE, MMMM d")})]}),U.length===0?e.jsxs("div",{className:"text-center py-8 space-y-2",children:[e.jsx(on,{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(K,{className:"w-full h-12 rounded-xl bg-[#406E71] hover:bg-[#365c5e] text-white font-semibold shadow-md shadow-[#406E71]/20 transition-all hover:shadow-lg",onClick:()=>a("form"),children:"Continue to Details"})]})]}),n==="form"&&o&&i&&u&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("button",{onClick:()=>a("date"),className:"flex items-center gap-1.5 text-xs font-medium text-slate-500 hover:text-slate-800 transition-colors",children:[e.jsx(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:M0e[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(yd,{className:"h-3.5 w-3.5 text-[#406E71]"}),gs(i,"EEE, MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(on,{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(Le,{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(Le,{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(Le,{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(gr,{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(K,{className:"w-full h-12 rounded-xl bg-[#406E71] hover:bg-[#365c5e] text-white font-semibold shadow-md shadow-[#406E71]/20 transition-all hover:shadow-lg disabled:opacity-60",onClick: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(Hn,{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&&gs(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(yd,{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 L5s(){const s=Bl().pathname.slice(1).split("/")[0];return S.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(zct,{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 D5s(){const s=Bl().pathname.slice(1);return S.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 Bct({slugOverride:t}){const{slug:s}=ao(),r=t||s,[n,a]=S.useState(!1),[o,l]=S.useState({}),[i,d]=S.useState(0),[u,p]=S.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)});S.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=Et({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",k=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}, ${k})`},children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl p-8 max-w-md mx-4 text-center",children:[e.jsx(Hn,{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(jr,{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}, ${k})`},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:"*"})]}),G9e(q,o,l)]},q.id)),e.jsx(K,{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}, ${k})`},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:"*"})]}),G9e(V,o,l)]},V.id)),e.jsx(K,{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 G9e(t,s,r,n){const a=s[t.label]||"",o=Array.isArray(t.options)?t.options:[];switch(t.field_type){case"text":case"email":case"phone":return e.jsx(Le,{type:t.field_type==="email"?"email":t.field_type==="phone"?"tel":"text",value:String(a),onChange:l=>r(i=>({...i,[t.label]:l.target.value})),placeholder:t.placeholder||"",className:"mt-1"});case"textarea":return e.jsx(gr,{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(Fs,{value:String(a),onValueChange:l=>r(i=>({...i,[t.label]:l})),children:[e.jsx(Ds,{className:"mt-1",children:e.jsx(zs,{placeholder:"Select..."})}),e.jsx(Rs,{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(Hi,{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(Mr,{checked:!!a,onCheckedChange:l=>r(i=>({...i,[t.label]:l?"Yes":"No"}))}),e.jsx("span",{className:"text-sm text-gray-600",children:a?"Yes":"No"})]});default:return e.jsx(Le,{value:String(a),onChange:l=>r(i=>({...i,[t.label]:l.target.value})),className:"mt-1"})}}function R5s(){const s=Bl().pathname.slice(1).split("/")[0];return S.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(Bct,{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 O5s=[{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}],SAs={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"},CAs={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"},W9e={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 MAs(t){return W9e[t]||W9e.basic}function F5s(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:O5s,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 z5s(){const s=window.location.hostname.match(/^([^.]+)\.thelocalmove\.com$/i);return s?s[1]:null}function B5s(){const t=z5s(),{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=F5s(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 $5s(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 $ct=S.createContext(null);function rpe(){const t=S.useContext($ct);if(!t)throw new Error("useLeadSiteAuth must be used within LeadSiteAuthProvider");return t}function q5s({siteConfig:t,children:s}){const[r,n]=S.useState(null),[a,o]=S.useState(null),[l,i]=S.useState(!0);S.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=S.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:k}=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}});k&&console.error("Lead insert error (CRM sync may not trigger):",k),$5s(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=S.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=S.useCallback(async()=>{await G.auth.signOut(),n(null),o(null)},[]);return e.jsx($ct.Provider,{value:{user:r,profile:a,isLoading:l,signUp:d,signIn:u,signOut:p},children:s})}function KCe({open:t,mode:s,siteConfig:r,onComplete:n,onSkip:a,theme:o="default",accentColor:l}){var J;const{signUp:i,signIn:d}=rpe(),[u,p]=S.useState(!1),[f,y]=S.useState(""),[_,b]=S.useState(""),[N,w]=S.useState(""),[k,C]=S.useState(!1),[A,I]=S.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 ae;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(ie){(ae=ie==null?void 0:ie.message)!=null&&ae.includes("Invalid login")?I("Invalid email or phone number. Please try again."):I((ie==null?void 0:ie.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(hs,{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(js,{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:k,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:k?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 ZCe({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"}},k=[{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:k.map((A,I)=>({"@type":"SiteNavigationElement",position:I+1,name:A.name,description:A.description,url:`${n}${A.path}`}))};return e.jsxs(nc,{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 TAs({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(nc,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})})}function AAs({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(nc,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})})}function U5s({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(nc,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(s)})})}function EAs({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(nc,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(d)})})}function YCe({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(U5s,{faqs:y})}const K9e="ls_visitor_geo",V5s=1e3*60*60;function H5s(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 G5s(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 W5s(){try{const t=localStorage.getItem(K9e);if(t){const s=JSON.parse(t);if(Date.now()-s.ts{o.current||(o.current=!0,W5s().then(l=>{a.current=l}))},[]),S.useEffect(()=>{if(!(t!=null&&t.id))return;const l=r.pathname;if(l===n.current)return;n.current=l;const i=H5s(l),d=G5s(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 K5s=3e4;function QCe(t,s){const r=Bl(),n=S.useRef(null),a=S.useRef(null),o=S.useRef(0),l=r.pathname,i=Z5s(l),d=Y5s(l,i),u=i==="listing"&&l.split("/listing/")[1]||null;S.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,K5s),()=>{a.current&&clearInterval(a.current)}},[t==null?void 0:t.id,s,l]),S.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 Z5s(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 Y5s(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 X5s({children:t,siteConfig:s}){var ye,he,ge,Ne,Ue,Te,Me,De,qe;const r=Bl(),n=vr(),[a,o]=S.useState(!1),[l,i]=S.useState(!1),[d,u]=S.useState(!1),[p,f]=S.useState([]),[y,_]=S.useState([]),[b,N]=S.useState(null),w=S.useRef(null),k=S.useRef(null),{user:C,profile:A,signOut:I}=rpe();XCe(s,C==null?void 0:C.id),QCe(s,C==null?void 0:C.id);const L=((ye=s.agent)==null?void 0:ye.full_name)||"Agent",O=s.siteTitle||`${L} Real Estate`,V=r.pathname==="/search",q=r.pathname==="/",B=s.leadRegistrationMode!=="disabled";S.useEffect(()=>{(async()=>{const{data:$e}=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($e||[])})()},[s.id]),S.useEffect(()=>{(async()=>{const{data:$e}=await G.from("lead_site_menu_items").select("*").eq("site_id",s.id).eq("is_visible",!0).order("sort_order",{ascending:!0});_($e||[])})()},[s.id]),S.useEffect(()=>{const ke=$e=>{w.current&&!w.current.contains($e.target)&&u(!1),k.current&&!k.current.contains($e.target)&&N(null)};return document.addEventListener("mousedown",ke),()=>document.removeEventListener("mousedown",ke)},[]);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(ke=>!ke.parent_id),X=ke=>y.filter($e=>$e.parent_id===ke),ce=q?"bg-transparent text-white":"bg-white/95 backdrop-blur text-gray-900 border-b border-gray-100 shadow-sm",ae=s.siteTitle||`${L} - Real Estate`,ie=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(ZCe,{siteConfig:s,pagePath:r.pathname}),e.jsx(YCe,{siteConfig:s}),e.jsxs(nc,{children:[e.jsx("title",{children:ae}),e.jsx("meta",{name:"description",content:ie}),e.jsx("meta",{property:"og:title",content:ae}),e.jsx("meta",{property:"og:description",content:ie}),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:ae}),e.jsx("meta",{name:"twitter:description",content:ie}),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(ke=>e.jsx(da,{to:ke.to,className:`px-4 py-2 rounded-lg text-sm font-medium tracking-wide transition-colors ${r.pathname===ke.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:ke.label},ke.to)),U&&J.map(ke=>{if(ke.item_type==="dropdown"){const $e=X(ke.id);return e.jsxs("div",{ref:k,className:"relative",children:[e.jsxs("button",{onClick:()=>N(b===ke.id?null:ke.id),className:`flex items-center gap-1 px-4 py-2 rounded-lg text-sm font-medium tracking-wide transition-colors ${q?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:[ke.label," ",e.jsx(Fi,{className:`h-3.5 w-3.5 transition-transform ${b===ke.id?"rotate-180":""}`})]}),b===ke.id&&$e.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:$e.map(Be=>e.jsx(L9,{item:Be,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"},Be.id))})]},ke.id)}return e.jsx(L9,{item:ke,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"}`},ke.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(Fi,{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(ke=>e.jsx("button",{onClick:()=>{n(`/homes-for-sale-in-${ke.city_slug}`),u(!1)},className:"w-full text-left px-4 py-2.5 text-sm text-gray-700 hover:bg-gray-50 hover:text-gray-900 transition-colors",children:ke.city_name},ke.city_slug))})]}),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:((Ne=A==null?void 0:A.name)==null?void 0:Ne.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(jr,{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(ke=>e.jsx(da,{to:ke.to,onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${r.pathname===ke.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:ke.label},ke.to)),U&&J.map(ke=>{if(ke.item_type==="dropdown"){const $e=X(ke.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:ke.label}),$e.map(Be=>e.jsx(L9,{item:Be,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"}`},Be.id))]},ke.id)}return e.jsx(L9,{item:ke,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"}`},ke.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(ke=>e.jsx(da,{to:`/homes-for-sale-in-${ke.city_slug}`,onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${r.pathname===`/homes-for-sale-in-${ke.city_slug}`?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:ke.city_name},ke.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:[((Ue=s.agent)==null?void 0:Ue.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:((Te=s.agent)==null?void 0:Te.title)||"Real Estate Professional"})]})]}),((Me=s.agent)==null?void 0:Me.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]})}),((De=s.agent)==null?void 0:De.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(ke=>e.jsx("li",{children:e.jsx(da,{to:ke.to,className:"hover:text-white transition-colors",children:ke.label})},ke.to))})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-white mb-4 text-sm tracking-wider uppercase",children:"Get In Touch"}),e.jsx("p",{className:"text-sm text-gray-500 leading-relaxed mb-4",children:"Ready to find your dream home? Get in touch today for a personalized consultation."}),e.jsx(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&&((qe=s.agent)==null?void 0:qe.avatar_url)&&e.jsx(Q5s,{agent:s.agent}),l&&e.jsx(KCe,{open:l,mode:"optional",siteConfig:s,onComplete:()=>i(!1),onSkip:()=>i(!1)})]})}function Q5s({agent:t}){var a;const[s,r]=S.useState(!1),n=vr();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(jr,{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 L9({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 J5s({children:t,siteConfig:s}){var me,ye,he,ge,Ne,Ue,Te;const r=Bl(),n=vr(),[a,o]=S.useState(!1),[l,i]=S.useState(!1),[d,u]=S.useState(!1),[p,f]=S.useState([]),[y,_]=S.useState(!1),b=S.useRef(null),{user:N,profile:w,signOut:k}=rpe();XCe(s,N==null?void 0:N.id),QCe(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=Me=>{if(!Me)return Me;const De=C.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),qe=new RegExp(`^\\s*${De}\\s*[|\\-–—:]\\s*`,"i");return Me.replace(qe,"").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";S.useEffect(()=>{const Me=()=>_(window.scrollY>80);return window.addEventListener("scroll",Me,{passive:!0}),()=>window.removeEventListener("scroll",Me)},[]),S.useEffect(()=>{(async()=>{const{data:De}=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(De||[])})()},[s.id]),S.useEffect(()=>{const Me=De=>{b.current&&!b.current.contains(De.target)&&u(!1)};return document.addEventListener("mousedown",Me),()=>document.removeEventListener("mousedown",Me)},[]);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}`,ae=s.ogImageUrl||((ye=s.agent)==null?void 0:ye.avatar_url)||"",ie=`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(ZCe,{siteConfig:s,pagePath:r.pathname}),e.jsx(YCe,{siteConfig:s}),e.jsxs(nc,{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:ie+r.pathname}),ae&&e.jsx("meta",{property:"og:image",content:ae}),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}),ae&&e.jsx("meta",{name:"twitter:image",content:ae}),s.faviconUrl&&e.jsx("link",{rel:"icon",href:s.faviconUrl,type:"image/png"}),e.jsx("link",{rel:"canonical",href:`${ie}${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(Me=>e.jsx(da,{to:Me.to,className:`px-4 py-2 text-xs tracking-[0.15em] uppercase transition-colors duration-300 ${r.pathname===Me.to?"text-white":"text-white/40 hover:text-white"}`,children:Me.label},Me.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(Fi,{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(Me=>e.jsx("button",{onClick:()=>{n(`/homes-for-sale-in-${Me.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:Me.city_name},Me.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(jr,{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(Me=>e.jsx(da,{to:Me.to,onClick:()=>o(!1),className:`block px-3 py-3 text-xs tracking-[0.2em] uppercase transition-colors ${r.pathname===Me.to?"text-white":"text-white/40 hover:text-white"}`,children:Me.label},Me.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(Me=>e.jsx(da,{to:`/homes-for-sale-in-${Me.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:Me.city_name},Me.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 k(),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"}),((Ne=s.agent)==null?void 0:Ne.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]}),((Ue=s.agent)==null?void 0:Ue.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(Me=>e.jsx("li",{children:e.jsx(da,{to:Me.to,className:"text-xs tracking-wider uppercase text-white/30 hover:text-white transition-colors",children:Me.label})},Me.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&&((Te=s.agent)==null?void 0:Te.avatar_url)&&e.jsx(eMs,{agent:s.agent,accentColor:Y}),l&&e.jsx(KCe,{open:l,mode:"optional",siteConfig:s,onComplete:()=>i(!1),onSkip:()=>i(!1),theme:"luxury",accentColor:Y})]})}function eMs({agent:t,accentColor:s}){var o;const[r,n]=S.useState(!1),a=vr();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(jr,{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 tMs({children:t,siteConfig:s}){var q,B,U;const r=Bl();vr();const[n,a]=S.useState(!1),[o,l]=S.useState(!1),[i,d]=S.useState(!1),[u,p]=S.useState([]),[f,y]=S.useState(!1),_=S.useRef(null),{user:b,profile:N,signOut:w}=rpe();XCe(s,b==null?void 0:b.id),QCe(s,b==null?void 0:b.id);const k=((q=s.agent)==null?void 0:q.full_name)||"Agent",C=s.siteTitle||`${k} Land & Ranch`,A=r.pathname==="/",I=s.leadRegistrationMode!=="disabled";S.useEffect(()=>{const te=()=>y(window.scrollY>80);return window.addEventListener("scroll",te,{passive:!0}),()=>window.removeEventListener("scroll",te)},[]),S.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]),S.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(nc,{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(ZCe,{siteConfig:s}),e.jsx(YCe,{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(Fi,{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(jr,{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(KCe,{open:o,mode:s.leadRegistrationMode==="required"?"required":"optional",siteConfig:s,onSkip:()=>l(!1),onComplete:()=>l(!1)})]})}const sMs=S.lazy(()=>Ba(()=>import("./LeadSiteHome-B10NY1B9.js"),__vite__mapDeps([0,1,2,3]))),rMs=S.lazy(()=>Ba(()=>import("./LeadSiteLuxuryHome-bH_WjiPM.js"),__vite__mapDeps([4,2,3]))),nMs=S.lazy(()=>Ba(()=>import("./LeadSiteLandRanchHome-5zCeXn71.js"),__vite__mapDeps([5,1,2,3]))),aMs=S.lazy(()=>Ba(()=>import("./LeadSiteSearch-Bvi507Sn.js"),__vite__mapDeps([6,1,7,3,8]))),iMs=S.lazy(()=>Ba(()=>import("./LeadSiteLuxurySearch-C9Hm42Qw.js"),__vite__mapDeps([9,1,7,3,8]))),oMs=S.lazy(()=>Ba(()=>import("./LeadSiteListingDetail-BpaLg3Qx.js"),__vite__mapDeps([10,11,3,12]))),lMs=S.lazy(()=>Ba(()=>import("./LeadSiteLuxuryListingDetail-CPBDEdqn.js"),__vite__mapDeps([13,11,3,12]))),cMs=S.lazy(()=>Ba(()=>import("./LeadSiteAbout-sTJ7mo41.js"),[])),dMs=S.lazy(()=>Ba(()=>import("./LeadSiteLuxuryAbout-DdvAbE5_.js"),[])),uMs=S.lazy(()=>Ba(()=>import("./LeadSiteContact-CVSz1vUJ.js"),[])),hMs=S.lazy(()=>Ba(()=>import("./LeadSiteLuxuryContact-Dn_MFX2t.js"),[])),mMs=S.lazy(()=>Ba(()=>import("./LeadSiteConsumerDashboard-C5VVAMEf.js"),[])),Z9e=S.lazy(()=>Ba(()=>import("./LeadSiteBlog-MdpGsLkw.js"),[])),pMs=S.lazy(()=>Ba(()=>import("./LeadSiteCommunity-C1CLoeLr.js"),[])),fMs=S.lazy(()=>Ba(()=>import("./LeadSiteSellers-dTDEUG9T.js"),[])),xMs=S.lazy(()=>Ba(()=>import("./LeadSiteCityPage-D8V5su2n.js"),__vite__mapDeps([14,3,8]))),gMs=S.lazy(()=>Ba(()=>import("./LeadSiteSubdivisionPage-z7EjThAS.js"),__vite__mapDeps([15,3]))),yMs=S.lazy(()=>Ba(()=>import("./LeadSiteCustomPage-Bs0eyqBc.js"),[]));function vMs(){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 _Ms(){const{siteConfig:t,themeConfig:s,isLoading:r,error:n}=B5s();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?tMs:a?J5s:X5s,i=o?e.jsx(nMs,{siteConfig:t,themeConfig:s??void 0}):a?e.jsx(rMs,{siteConfig:t,themeConfig:s??void 0}):e.jsx(sMs,{siteConfig:t,themeConfig:s??void 0});return e.jsx(q5s,{siteConfig:t,children:e.jsx(l,{siteConfig:t,children:e.jsx(S.Suspense,{fallback:e.jsx(vMs,{}),children:e.jsxs(Voe,{children:[e.jsx(xs,{path:"/",element:i}),e.jsx(xs,{path:"/search",element:a?e.jsx(iMs,{siteConfig:t}):e.jsx(aMs,{siteConfig:t})}),e.jsx(xs,{path:"/listing/:mlsNumber",element:a?e.jsx(lMs,{siteConfig:t}):e.jsx(oMs,{siteConfig:t})}),e.jsx(xs,{path:"/about",element:a?e.jsx(dMs,{siteConfig:t}):e.jsx(cMs,{siteConfig:t})}),e.jsx(xs,{path:"/contact",element:a?e.jsx(hMs,{siteConfig:t}):e.jsx(uMs,{siteConfig:t})}),e.jsx(xs,{path:"/account",element:e.jsx(mMs,{siteConfig:t})}),e.jsx(xs,{path:"/blog",element:e.jsx(Z9e,{siteConfig:t,isLuxury:a})}),e.jsx(xs,{path:"/blog/:slug",element:e.jsx(Z9e,{siteConfig:t,isLuxury:a})}),e.jsx(xs,{path:"/sell",element:e.jsx(fMs,{siteConfig:t,themeConfig:s??void 0,isLuxury:a})}),e.jsx(xs,{path:"/community",element:e.jsx(pMs,{siteConfig:t,isLuxury:a})}),e.jsx(xs,{path:"/p/:pageSlug",element:e.jsx(yMs,{siteConfig:t})}),e.jsx(xs,{path:"/*",element:e.jsx(bMs,{siteConfig:t})})]})})})})}function bMs({siteConfig:t}){const s=Bl(),r=s.pathname.match(/^\/homes-in-(.+)$/);if(r)return e.jsx(gMs,{siteConfig:t,subdivisionSlug:r[1]});const n=s.pathname.match(/^\/homes-for-sale-in-(.+)$/);return n?e.jsx(xMs,{siteConfig:t,citySlugOverride:n[1]}):null}const wMs=({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(Lt,{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(Ft,{className:"text-lg truncate",children:t.name}),t.description&&e.jsx(ur,{className:"mt-1 line-clamp-2",children:t.description})]}),e.jsxs(Qe,{variant:"secondary",className:"ml-2 shrink-0",children:[e.jsx(or,{className:"h-3 w-3 mr-1"}),(r==null?void 0:r.count)??"…"]})]})}),e.jsxs(Re,{className:"space-y-3",children:[(r==null?void 0:r.leaderProfile)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(wn,{className:"h-6 w-6",children:[e.jsx(Ma,{src:r.leaderProfile.avatar_url||""}),e.jsx(jn,{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"})]})]})]})},jMs=()=>{const{user:t,isAdmin:s,isBrokerageManager:r,brokerageId:n,managedBrokerages:a,selectedBrokerageId:o}=qs(),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,k]=S.useState(!1),[C,A]=S.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"});k(!1)};return!r&&!s?e.jsx(Es,{title:"Teams",description:"Team Management",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(or,{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(Es,{title:"Teams",description:"Create and manage teams within your brokerage",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Teams"}),e.jsx("p",{className:"text-muted-foreground",children:"Organize your agents into teams with leaders and shared resources."})]}),e.jsxs(K,{onClick:()=>k(!0),children:[e.jsx(Bs,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(gtt,{open:w,onOpenChange:k,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(Re,{className:"p-6",children:[e.jsx(ks,{className:"h-5 w-32 mb-3"}),e.jsx(ks,{className:"h-4 w-48 mb-4"}),e.jsx(ks,{className:"h-8 w-full"})]})},V))}),!u&&d.length===0&&!C&&e.jsx(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(or,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Teams Yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Create your first team to organize agents and share resources."}),e.jsxs(K,{onClick:()=>k(!0),children:[e.jsx(Bs,{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(wMs,{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})]})})},NMs=()=>{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(Es,{title:"My Team",description:"Your team",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(ks,{className:"h-8 w-48"}),e.jsx(ks,{className:"h-40 w-full"})]})});if(!t)return e.jsx(Es,{title:"My Team",description:"Your team",children:e.jsx(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(or,{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(Es,{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(ls,{value:"members",children:"Members"}),o.contact_visibility!=="private"&&e.jsxs(ls,{value:"contacts",children:[e.jsx(Q4,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),o.lead_pond_enabled&&e.jsxs(ls,{value:"lead-pond",children:[e.jsx(Ag,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),o.shared_assets_enabled&&e.jsxs(ls,{value:"shared-assets",children:[e.jsx(Mm,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]})]}),e.jsx(ws,{value:"members",className:"space-y-2",children:a?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(l=>e.jsx(ks,{className:"h-16 w-full"},l))}):n.map(l=>{var i,d,u,p;return e.jsx(Pe,{children:e.jsxs(Re,{className:"flex items-center gap-3 p-4",children:[e.jsxs(wn,{className:"h-10 w-10",children:[e.jsx(Ma,{src:((i=l.profile)==null?void 0:i.avatar_url)||""}),e.jsx(jn,{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(ws,{value:"contacts",className:"space-y-4",children:e.jsx(m4e,{})}),o.lead_pond_enabled&&e.jsx(ws,{value:"lead-pond",className:"space-y-4",children:e.jsx(p4e,{teamId:t.teamId})}),o.shared_assets_enabled&&e.jsx(ws,{value:"shared-assets",className:"space-y-4",children:e.jsx(ftt,{teamId:t.teamId})})]})]})})};function kMs(){const{user:t}=qs(),s=Qt(),r=gt({queryKey:["booking-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:k}=await G.from("agent_booking_settings").select("*").eq("user_id",t.id).maybeSingle();if(k)throw k;return w},enabled:!!t}),n=gt({queryKey:["booking-types",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:k}=await G.from("agent_booking_types").select("*").eq("user_id",t.id).order("sort_order");if(k)throw k;return w},enabled:!!t}),a=gt({queryKey:["availability-slots",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:k}=await G.from("agent_availability_slots").select("*").eq("user_id",t.id).order("day_of_week").order("start_time");if(k)throw k;return w},enabled:!!t}),o=gt({queryKey:["blocked-dates",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:k}=await G.from("agent_blocked_dates").select("*").eq("user_id",t.id).order("blocked_date");if(k)throw k;return w},enabled:!!t}),l=gt({queryKey:["bookings",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:k}=await G.from("bookings").select("*, booking_type:agent_booking_types(*)").eq("agent_user_id",t.id).order("booking_date",{ascending:!1});if(k)throw k;return w},enabled:!!t}),i=Et({mutationFn:async()=>{const{data:w,error:k}=await G.from("agent_booking_settings").insert({user_id:t.id,slug:""}).select().single();if(k)throw k;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=Et({mutationFn:async w=>{const{error:k}=await G.from("agent_booking_settings").update(w).eq("user_id",t.id);if(k)throw k},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),pe.success("Settings updated")},onError:w=>pe.error(w.message)}),u=Et({mutationFn:async w=>{const k={...w,user_id:t.id};if(w.id){const{error:C}=await G.from("agent_booking_types").update(k).eq("id",w.id);if(C)throw C}else{const{error:C}=await G.from("agent_booking_types").insert(k);if(C)throw C}},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),pe.success("Booking type saved")},onError:w=>pe.error(w.message)}),p=Et({mutationFn:async w=>{const{error:k}=await G.from("agent_booking_types").delete().eq("id",w);if(k)throw k},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),pe.success("Booking type deleted")},onError:w=>pe.error(w.message)}),f=Et({mutationFn:async w=>{const k={...w,user_id:t.id};if(w.id){const{error:C}=await G.from("agent_availability_slots").update(k).eq("id",w.id);if(C)throw C}else{const{error:C}=await G.from("agent_availability_slots").insert(k);if(C)throw C}},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:w=>pe.error(w.message)}),y=Et({mutationFn:async w=>{const{error:k}=await G.from("agent_availability_slots").delete().eq("id",w);if(k)throw k},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:w=>pe.error(w.message)}),_=Et({mutationFn:async w=>{const{error:k}=await G.from("agent_blocked_dates").insert({...w,user_id:t.id});if(k)throw k},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]}),pe.success("Date blocked")},onError:w=>pe.error(w.message)}),b=Et({mutationFn:async w=>{const{error:k}=await G.from("agent_blocked_dates").delete().eq("id",w);if(k)throw k},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]})},onError:w=>pe.error(w.message)}),N=Et({mutationFn:async({id:w,reason:k})=>{const{error:C}=await G.from("bookings").update({status:"cancelled",cancelled_at:new Date().toISOString(),cancel_reason:k}).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 Y9e={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function SMs({types:t,onSave:s,onDelete:r}){const[n,a]=S.useState(null),[o,l]=S.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(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ft,{children:"Booking Types"}),e.jsx(ur,{children:"The meeting types prospects can book with you"})]}),e.jsxs(K,{onClick:i,size:"sm",children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"})," Add Type"]})]}),e.jsx(Re,{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:Y9e[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(on,{className:"h-3 w-3"}),p.duration_minutes," min",p.description&&e.jsxs("span",{children:["· ",p.description.slice(0,60),p.description.length>60?"...":""]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>d(p),children:e.jsx(ga,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>r(p.id),className:"text-destructive hover:text-destructive",children:e.jsx(xr,{className:"h-4 w-4"})})]})]},p.id))})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(hs,{children:[e.jsx(js,{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(Le,{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(gr,{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(Le,{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(Le,{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(Y9e).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(Le,{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(Mr,{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(Mr,{checked:n.is_active??!0,onCheckedChange:p=>a({...n,is_active:p})})]})]}),e.jsxs(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:u,children:"Save"})]})]})})]})}const X9e=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function CMs({slots:t,onSave:s,onDelete:r}){const[n,a]=S.useState(null),[o,l]=S.useState("09:00"),[i,d]=S.useState("17:00"),u=X9e.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(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-5 w-5"}),"Weekly Availability"]}),e.jsx(ur,{children:"Set your available hours for each day"})]}),e.jsx(Re,{className:"space-y-2",children:X9e.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(Le,{type:"time",className:"w-28 h-8 text-sm",defaultValue:(N=b.start_time)==null?void 0:N.slice(0,5),onBlur:k=>s({id:b.id,start_time:k.target.value})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"to"}),e.jsx(Le,{type:"time",className:"w-28 h-8 text-sm",defaultValue:(w=b.end_time)==null?void 0:w.slice(0,5),onBlur:k=>s({id:b.id,end_time:k.target.value})}),e.jsx(Mr,{checked:b.is_active,onCheckedChange:k=>s({id:b.id,is_active:k})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>r(b.id),children:e.jsx(xr,{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(Le,{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(Le,{type:"time",className:"w-28 h-8 text-sm",value:i,onChange:b=>d(b.target.value)}),e.jsx(K,{size:"sm",className:"h-8",onClick:p,children:"Add"}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8",onClick:()=>a(null),children:"Cancel"})]}):e.jsxs(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground",onClick:()=>a(y),children:[e.jsx(Bs,{className:"h-3 w-3 mr-1"})," Add hours"]})]})]},f)})})]})}const MMs={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 TMs({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 ${MMs[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(yd,{className:"h-3.5 w-3.5"}),gs(new Date(o.booking_date+"T00:00:00"),"MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(on,{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(K,{variant:"ghost",size:"sm",onClick:()=>s(o.id),className:"text-destructive hover:text-destructive",children:[e.jsx(Ql,{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(Lt,{children:[e.jsx(Ft,{children:"Upcoming Bookings"}),e.jsxs(ur,{children:[r.length," upcoming appointment",r.length!==1?"s":""]})]}),e.jsx(Re,{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(Lt,{children:e.jsx(Ft,{children:"Past & Cancelled"})}),e.jsx(Re,{children:e.jsx("div",{className:"space-y-3",children:n.slice(0,20).map(o=>a(o))})})]})]})}function AMs({blockedDates:t,onAdd:s,onRemove:r}){const[n,a]=S.useState(!1),[o,l]=S.useState(""),[i,d]=S.useState(""),u=()=>{o&&(s({blocked_date:o,reason:i||void 0}),a(!1),l(""),d(""))};return e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(dL,{className:"h-5 w-5"}),"Blocked Dates"]}),e.jsx(ur,{children:"Block specific dates (vacations, holidays, etc.)"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>a(!0),children:[e.jsx(Bs,{className:"h-4 w-4 mr-1"})," Block Date"]})]}),e.jsxs(Re,{children:[n&&e.jsxs("div",{className:"flex items-center gap-2 mb-3 p-3 rounded-lg border bg-muted/30",children:[e.jsx(Le,{type:"date",value:o,onChange:p=>l(p.target.value),className:"w-40"}),e.jsx(Le,{placeholder:"Reason (optional)",value:i,onChange:p=>d(p.target.value),className:"flex-1"}),e.jsx(K,{size:"sm",onClick:u,children:"Add"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>a(!1),children:"Cancel"})]}),t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No blocked dates"}):e.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(p=>e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full border bg-muted/50 text-sm",children:[e.jsx("span",{children:gs(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(jr,{className:"h-3.5 w-3.5"})})]},p.id))})]})]})}function EMs(){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}=kMs(),[N,w]=S.useState("");S.useState(15),N||t!=null&&t.meeting_link;const k=t!=null&&t.slug?`https://booking.relevelup.com/${t.slug}`:null;return o?e.jsx(Es,{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(Es,{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(yd,{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:[k&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(k),pe.success("Booking link copied!")},children:[e.jsx(Wa,{className:"h-4 w-4 mr-1"})," Copy Link"]}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:k,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Zr,{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(Mr,{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(ls,{value:"types",children:"Booking Types"}),e.jsx(ls,{value:"availability",children:"Availability"}),e.jsx(ls,{value:"settings",children:"Settings"}),e.jsxs(ls,{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(ws,{value:"types",children:e.jsx(SMs,{types:s,onSave:C=>d.mutate(C),onDelete:C=>u.mutate(C)})}),e.jsx(ws,{value:"availability",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(CMs,{slots:r,onSave:C=>p.mutate(C),onDelete:C=>f.mutate(C)}),e.jsx(AMs,{blockedDates:n,onAdd:C=>y.mutate(C),onRemove:C=>_.mutate(C)})]})}),e.jsx(ws,{value:"settings",children:e.jsxs(Pe,{children:[e.jsxs(Lt,{children:[e.jsxs(Ft,{className:"flex items-center gap-2",children:[e.jsx(FL,{className:"h-5 w-5"}),"General Settings"]}),e.jsx(ur,{children:"Configure your booking page defaults"})]}),e.jsxs(Re,{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(Le,{value:t.slug,readOnly:!0,className:"bg-muted"}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>{k&&(navigator.clipboard.writeText(k),pe.success("Copied!"))},children:e.jsx(Wa,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:k})]}),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(Le,{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(Le,{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(Le,{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(Le,{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(ws,{value:"bookings",children:e.jsx(TMs,{bookings:a,onCancel:C=>b.mutate({id:C})})})]})]})}):e.jsx(Es,{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(yd,{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(Re,{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(xo,{}),e.jsxs("div",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:"✅ Auto-creates CRM contacts from every booking"}),e.jsx("p",{children:"✅ Optional pre-qualification questions per booking type"}),e.jsx("p",{children:"✅ Embeds on your Smart Card — replaces TidyCal"}),e.jsx("p",{children:"✅ Standalone shareable booking page"})]}),e.jsxs(K,{onClick:()=>l.mutate(),disabled:l.isPending,className:"w-full",size:"lg",children:[e.jsx(Or,{className:"h-4 w-4 mr-2"}),l.isPending?"Setting up...":"Activate Scheduler"]})]})})]})})}const Q9e=[{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 PMs(){const{user:t}=qs(),s=ya(),{toast:r}=ja(),n=vr(),a=Qt(),[o,l]=S.useState(!1),[i,d]=S.useState(null),[u,p]=S.useState(null),[f,y]=S.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=Et({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=IMs(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=Et({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"})}}),k=C=>`https://pages.relevelup.com/${C}`;return e.jsxs(Es,{title:"Landing Pages",children:[e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Landing Pages"}),e.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Create branded lead capture pages for events, consultations, and more"})]}),e.jsxs(K,{onClick:()=>l(!0),children:[e.jsx(Bs,{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(Re,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(yn,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"No landing pages yet"}),e.jsx("p",{className:"text-muted-foreground text-sm mt-1 mb-4",children:"Create your first page to start capturing leads"}),e.jsxs(K,{onClick:()=>l(!0),children:[e.jsx(Bs,{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(Re,{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=Q9e.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(Cn,{className:"h-3 w-3"})," ",C.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(yn,{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(K,{size:"sm",variant:"outline",onClick:()=>p(k(C.slug)),children:e.jsx(Jy,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>{navigator.clipboard.writeText(k(C.slug)),r({title:"Link copied!"})},children:e.jsx(Wa,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:k(C.slug),target:"_blank",rel:"noopener noreferrer",children:e.jsx(Zr,{className:"h-3.5 w-3.5"})})})]}),e.jsxs(Hd,{children:[e.jsx(Gd,{asChild:!0,children:e.jsx(K,{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(xr,{className:"h-3.5 w-3.5 mr-2"})," Delete"]})]})]})]})]})})},C.id)})})]}),e.jsx(fs,{open:o,onOpenChange:l,children:e.jsxs(hs,{children:[e.jsx(js,{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(Le,{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(gr,{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(Fs,{value:f.page_type,onValueChange:C=>y(A=>({...A,page_type:C})),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsx(Rs,{children:Q9e.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(_n,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>N.mutate(),disabled:!f.title.trim()||N.isPending,children:N.isPending?"Creating...":"Create Page"})]})]})}),e.jsx(Dl,{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(hs,{className:"max-w-sm",children:[e.jsx(js,{children:e.jsx(_s,{children:"QR Code"})}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[u&&e.jsx(AO,{value:u,size:240}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:u}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{u&&(navigator.clipboard.writeText(u),r({title:"URL copied!"}))},children:[e.jsx(Wa,{className:"h-3.5 w-3.5 mr-1"})," Copy URL"]})]})]})})]})}function IMs(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 LMs=[{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 DMs(){const{pageId:t}=ao(),s=vr(),{user:r}=qs(),n=ya(),{toast:a}=ja(),o=Qt(),[l,i]=S.useState(null),[d,u]=S.useState(!1),{data:p,isLoading:f}=gt({queryKey:["landing-page",t],queryFn:async()=>{const{data:ae,error:ie}=await G.from("landing_pages").select("*").eq("id",t).single();if(ie)throw ie;return ae},enabled:!!t}),{data:y=[],isLoading:_}=gt({queryKey:["landing-page-fields",t],queryFn:async()=>{const{data:ae,error:ie}=await G.from("landing_page_fields").select("*").eq("page_id",t).order("sort_order");if(ie)throw ie;return ae},enabled:!!t}),{data:b=[]}=gt({queryKey:["landing-page-submissions",t],queryFn:async()=>{const{data:ae,error:ie}=await G.from("landing_page_submissions").select("*").eq("page_id",t).order("created_at",{ascending:!1});if(ie)throw ie;return ae},enabled:!!t}),{data:N=[]}=gt({queryKey:["my-listings-for-pages",n],queryFn:async()=>{const{data:ae,error:ie}=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(ie)throw ie;return ae},enabled:!!r&&((p==null?void 0:p.page_type)==="just_listed"||(p==null?void 0:p.page_type)==="just_sold")}),[w,k]=S.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]=S.useState([]);S.useEffect(()=>{p&&k({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]),S.useEffect(()=>{y.length>0&&A(y.map(ae=>({id:ae.id,field_type:ae.field_type,label:ae.label,placeholder:ae.placeholder,is_required:ae.is_required,options:typeof ae.options=="string"?ae.options:ae.options?JSON.stringify(ae.options):null,sort_order:ae.sort_order})))},[y]);const I=Et({mutationFn:async()=>{const{error:ae}=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(ae)throw ae;if(await G.from("landing_page_fields").delete().eq("page_id",t),C.length>0){const{error:ie}=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(ie)throw ie}},onSuccess:()=>{o.invalidateQueries({queryKey:["landing-page",t]}),o.invalidateQueries({queryKey:["landing-page-fields",t]}),a({title:"Page saved!"})},onError:ae=>a({title:"Error",description:ae.message,variant:"destructive"})}),L=async(ae,ie)=>{const oe=ae.name.split(".").pop(),me=`landing-pages/${r.id}/${ie}-${Date.now()}.${oe}`,{error:ye}=await G.storage.from("recruit-landing").upload(me,ae);if(ye)throw ye;const{data:{publicUrl:he}}=G.storage.from("recruit-landing").getPublicUrl(me);return he},O=async(ae,ie)=>{var me;const oe=(me=ae.target.files)==null?void 0:me[0];if(oe){i(ie);try{const ye=await L(oe,ie);k(he=>({...he,[ie]:ye})),a({title:"Image uploaded!"})}catch(ye){a({title:"Upload failed",description:ye.message,variant:"destructive"})}finally{i(null)}}},V=async ae=>{var oe;const ie=(oe=ae.target.files)==null?void 0:oe[0];if(ie){i("lead_magnet");try{const me=await L(ie,"lead-magnet");k(ye=>({...ye,lead_magnet_file_url:me,lead_magnet_file_name:ie.name})),a({title:"File uploaded!"})}catch(me){a({title:"Upload failed",description:me.message,variant:"destructive"})}finally{i(null)}}},q=async ae=>{const ie=ae.target.files;if(!(!ie||ie.length===0)){i("property_photos");try{const oe=[];for(const me of Array.from(ie)){const ye=await L(me,"property-photo");oe.push(ye)}k(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 ae=>{const ie=N.find(me=>me.id===ae);if(!ie)return;const{data:oe}=await G.from("listing_photos").select("photo_url").eq("listing_id",ae).order("sort_order");k(me=>({...me,listing_id:ae,property_address:ie.property_address||`${ie.city}, ${ie.state}`,property_price:ie.price?`$${ie.price.toLocaleString()}`:"",property_beds:ie.bedrooms?String(ie.bedrooms):"",property_baths:ie.bathrooms?String(ie.bathrooms):"",property_sqft:ie.square_footage?ie.square_footage.toLocaleString():"",property_description:ie.description||"",property_photos:(oe==null?void 0:oe.map(ye=>ye.photo_url))||me.property_photos})),a({title:"Listing data imported!"})},U=()=>{A(ae=>[...ae,{field_type:"text",label:"",placeholder:"",is_required:!1,options:null,sort_order:ae.length}])},te=(ae,ie)=>{A(oe=>oe.map((me,ye)=>ye===ae?{...me,...ie}:me))},Y=ae=>{A(ie=>ie.filter((oe,me)=>me!==ae))},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(Es,{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(Es,{title:w.title||"Edit Page",children:[e.jsxs("div",{className:"space-y-6 max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/landing-pages"),children:e.jsx(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(Cn,{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(or,{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(K,{size:"sm",variant:"outline",onClick:()=>u(!0),children:e.jsx(Jy,{className:"h-3.5 w-3.5"})}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{navigator.clipboard.writeText(J),a({title:"Link copied!"})},children:[e.jsx(Wa,{className:"h-3.5 w-3.5 mr-1"})," Copy Link"]}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsxs("a",{href:J,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Zr,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(K,{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(ls,{value:"design",children:"Design"}),X&&e.jsx(ls,{value:"lead_magnet",children:"Lead Magnet"}),ce&&e.jsx(ls,{value:"property",children:"Property Details"}),e.jsxs(ls,{value:"fields",children:["Form Fields (",C.length,")"]}),e.jsxs(ls,{value:"submissions",children:["Submissions (",b.length,")"]}),e.jsx(ls,{value:"settings",children:"Settings"})]}),e.jsxs(ws,{value:"design",className:"space-y-4 mt-4",children:[e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Page Details"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Page Title (internal)"}),e.jsx(Le,{value:w.title,onChange:ae=>k(ie=>({...ie,title:ae.target.value}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Description (internal)"}),e.jsx(Le,{value:w.description,onChange:ae=>k(ie=>({...ie,description:ae.target.value}))})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Hero Section"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Headline"}),e.jsx(Le,{value:w.hero_headline,onChange:ae=>k(ie=>({...ie,hero_headline:ae.target.value})),placeholder:"Join us for..."})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Subtext"}),e.jsx(gr,{value:w.hero_subtext,onChange:ae=>k(ie=>({...ie,hero_subtext:ae.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(K,{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:ae=>O(ae,"hero_image_url")})]}),w.hero_image_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>k(ae=>({...ae,hero_image_url:null})),children:e.jsx(xr,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Branding"})}),e.jsxs(Re,{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(K,{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:ae=>O(ae,"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(K,{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:ae=>O(ae,"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:ae=>k(ie=>({...ie,primary_color:ae.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Le,{value:w.primary_color,onChange:ae=>k(ie=>({...ie,primary_color:ae.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:ae=>k(ie=>({...ie,accent_color:ae.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Le,{value:w.accent_color,onChange:ae=>k(ie=>({...ie,accent_color:ae.target.value})),className:"font-mono text-xs"})]})]})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Agent Info (shown on page)"})}),e.jsx(Re,{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(Le,{value:w.agent_name,onChange:ae=>k(ie=>({...ie,agent_name:ae.target.value}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Phone"}),e.jsx(Le,{value:w.agent_phone,onChange:ae=>k(ie=>({...ie,agent_phone:ae.target.value}))})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Email"}),e.jsx(Le,{value:w.agent_email,onChange:ae=>k(ie=>({...ie,agent_email:ae.target.value}))})]})]})})]})]}),X&&e.jsx(ws,{value:"lead_magnet",className:"space-y-4 mt-4",children:e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(Qa,{className:"h-4 w-4"})," Giveaway File"]})}),e.jsxs(Re,{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(K,{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(K,{variant:"ghost",size:"sm",onClick:()=>k(ae=>({...ae,lead_magnet_file_url:null,lead_magnet_file_name:null})),children:e.jsx(xr,{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(Le,{value:w.lead_magnet_external_url||"",onChange:ae=>k(ie=>({...ie,lead_magnet_external_url:ae.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(ws,{value:"property",className:"space-y-4 mt-4",children:[e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(Sn,{className:"h-4 w-4"})," Import from Listing Exchange"]})}),e.jsxs(Re,{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(Fs,{value:w.listing_id||"",onValueChange:ae=>B(ae),children:[e.jsx(Ds,{children:e.jsx(zs,{placeholder:"Select a listing to import..."})}),e.jsx(Rs,{children:N.map(ae=>{var ie;return e.jsxs(vt,{value:ae.id,children:[ae.property_address||`${ae.city}, ${ae.state}`," — $",(ie=ae.price)==null?void 0:ie.toLocaleString()]},ae.id)})})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Property Information"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(xe,{children:"Property Address"}),e.jsx(Le,{value:w.property_address,onChange:ae=>k(ie=>({...ie,property_address:ae.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(Le,{value:w.property_price,onChange:ae=>k(ie=>({...ie,property_price:ae.target.value})),placeholder:"$450,000"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Beds"}),e.jsx(Le,{value:w.property_beds,onChange:ae=>k(ie=>({...ie,property_beds:ae.target.value})),placeholder:"4"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Baths"}),e.jsx(Le,{value:w.property_baths,onChange:ae=>k(ie=>({...ie,property_baths:ae.target.value})),placeholder:"3"})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Sq Ft"}),e.jsx(Le,{value:w.property_sqft,onChange:ae=>k(ie=>({...ie,property_sqft:ae.target.value})),placeholder:"2,400"})]})]}),e.jsxs("div",{children:[e.jsx(xe,{children:"Description"}),e.jsx(gr,{value:w.property_description,onChange:ae=>k(ie=>({...ie,property_description:ae.target.value})),rows:3,placeholder:"Beautiful home in a great neighborhood..."})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Property Photos"})}),e.jsxs(Re,{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((ae,ie)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:ae,alt:`Property ${ie+1}`,className:"h-24 w-full object-cover rounded"}),e.jsx(K,{variant:"destructive",size:"sm",className:"absolute top-1 right-1 h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>k(oe=>({...oe,property_photos:oe.property_photos.filter((me,ye)=>ye!==ie)})),children:e.jsx(xr,{className:"h-3 w-3"})})]},ie))}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="property_photos",children:e.jsxs("span",{children:[e.jsx(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(ws,{value:"fields",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure the form fields visitors will fill out"}),e.jsxs(K,{size:"sm",onClick:U,children:[e.jsx(Bs,{className:"h-3.5 w-3.5 mr-1"})," Add Field"]})]}),C.length===0?e.jsx(Pe,{children:e.jsx(Re,{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((ae,ie)=>e.jsx(Pe,{children:e.jsx(Re,{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(Fs,{value:ae.field_type,onValueChange:oe=>te(ie,{field_type:oe}),children:[e.jsx(Ds,{children:e.jsx(zs,{})}),e.jsx(Rs,{children:LMs.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(Le,{value:ae.label,onChange:oe=>te(ie,{label:oe.target.value}),placeholder:"e.g. Full Name"})]}),e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Placeholder"}),e.jsx(Le,{value:ae.placeholder||"",onChange:oe=>te(ie,{placeholder:oe.target.value}),placeholder:"Optional hint text"})]})]}),(ae.field_type==="select"||ae.field_type==="multiselect")&&e.jsxs("div",{children:[e.jsx(xe,{className:"text-xs",children:"Options (comma-separated)"}),e.jsx(Le,{value:ae.options?(typeof ae.options=="string"?JSON.parse(ae.options):ae.options).join(", "):"",onChange:oe=>te(ie,{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(Mr,{checked:ae.is_required,onCheckedChange:oe=>te(ie,{is_required:oe})}),e.jsx(xe,{className:"text-xs",children:"Required"})]})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Y(ie),children:e.jsx(xr,{className:"h-3.5 w-3.5 text-destructive"})})]})})},ie))})]}),e.jsx(ws,{value:"submissions",className:"mt-4",children:b.length===0?e.jsx(Pe,{children:e.jsx(Re,{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(ae=>e.jsx(Pe,{children:e.jsx(Re,{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:ae.contact_name||"Anonymous"}),ae.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:[ae.contact_email&&e.jsx("span",{className:"mr-3",children:ae.contact_email}),ae.contact_phone&&e.jsx("span",{children:ae.contact_phone})]}),ae.answers&&typeof ae.answers=="object"&&e.jsx("div",{className:"mt-2 text-sm space-y-1",children:Object.entries(ae.answers).map(([ie,oe])=>e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-muted-foreground",children:[ie,":"]})," ",e.jsx("span",{children:String(oe)})]},ie))})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(ae.created_at).toLocaleDateString()})]})})},ae.id))})}),e.jsxs(ws,{value:"settings",className:"space-y-4 mt-4",children:[e.jsxs(Pe,{children:[e.jsx(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Publishing"})}),e.jsxs(Re,{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(Mr,{checked:w.is_published,onCheckedChange:ae=>k(ie=>({...ie,is_published:ae}))})]}),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(Lt,{children:e.jsx(Ft,{className:"text-base",children:"Thank You Message"})}),e.jsx(Re,{children:e.jsx(gr,{value:w.success_message,onChange:ae=>k(ie=>({...ie,success_message:ae.target.value})),rows:2,placeholder:"Message shown after form submission"})})]})]})]})]}),e.jsx(fs,{open:d,onOpenChange:u,children:e.jsxs(hs,{className:"max-w-sm",children:[e.jsx(js,{children:e.jsx(_s,{children:"QR Code"})}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[e.jsx(AO,{value:J,size:240}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:J})]})]})})]}):e.jsx(Es,{title:"Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground",children:"Page not found"}),e.jsx(K,{variant:"link",onClick:()=>s("/mission-control/landing-pages"),children:"Go back"})]})})}function J9e({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 RMs={Phone:In,MessageSquare:Si,Mail:tr,Gift:yi,PenTool:Mb,Video:gn},eBe=["bg-primary","bg-emerald-500","bg-amber-500","bg-sky-500","bg-purple-500","bg-orange-500","bg-pink-500","bg-teal-500"];function OMs(){const t=vr(),{contactsWithScores:s,stats:r,isLoading:n}=ohe(),{data:a}=KR(365),{data:o}=dke(),{data:l}=WR(),i=oke(),d=S.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=S.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=S.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=S.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=S.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]),_=S.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=S.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=S.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]),k=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(Es,{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:[gs(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(Re,{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(Re,{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(J9e,{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(Re,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(or,{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(Re,{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(J9e,{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(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(Rh,{className:"h-4 w-4 text-primary"}),"Weekly Goal"]})}),e.jsxs(Re,{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(fi,{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(Vi,{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(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(rd,{className:"h-4 w-4 text-orange-500"}),"Momentum"]})}),e.jsxs(Re,{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(Lt,{className:"pb-2",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(lh,{className:"h-4 w-4"}),"How You're Reaching Out"]})}),e.jsx(Re,{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=RMs[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(fi,{value:I.percent,className:Dt("h-1.5 bg-muted [&>div]:",eBe[L%eBe.length])})]},I.id)})})})]})]}),_.length>0&&e.jsxs(Pe,{className:"border-l-4 border-l-primary",children:[e.jsxs(Lt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ft,{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(ur,{children:"These relationships need attention the most"})]}),e.jsx(Re,{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(K,{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(K,{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(Lt,{className:"pb-3",children:[e.jsxs(Ft,{className:"text-lg flex items-center gap-2",children:[e.jsx(rc,{className:"h-5 w-5 text-emerald-500"}),"Biggest Wins This Month"]}),e.jsx(ur,{children:"Relationships you've successfully warmed up"})]}),e.jsx(Re,{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(Re,{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(fi,{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(Re,{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(fi,{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(Re,{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(fi,{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(Re,{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(ls,{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(ls,{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(ls,{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:k}].map(({key:I,contacts:L})=>e.jsx(ws,{value:I,children:e.jsx(Pe,{children:e.jsx(Re,{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(Ms,{children:[e.jsx(kt,{children:"Contact"}),e.jsx(kt,{className:"hidden md:table-cell",children:"Last Touch"}),e.jsx(kt,{className:"hidden md:table-cell",children:"Touches (12mo)"}),e.jsx(kt,{children:"Score"}),e.jsx(kt,{className:"w-10"})]})}),e.jsx(Rn,{children:L.slice(0,20).map(O=>e.jsxs(Ms,{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 qct=({className:t,...s})=>e.jsx("nav",{role:"navigation","aria-label":"pagination",className:Dt("mx-auto flex w-full justify-center",t),...s});qct.displayName="Pagination";const Uct=S.forwardRef(({className:t,...s},r)=>e.jsx("ul",{ref:r,className:Dt("flex flex-row items-center gap-1",t),...s}));Uct.displayName="PaginationContent";const VI=S.forwardRef(({className:t,...s},r)=>e.jsx("li",{ref:r,className:Dt("",t),...s}));VI.displayName="PaginationItem";const npe=({className:t,isActive:s,size:r="icon",...n})=>e.jsx("a",{"aria-current":s?"page":void 0,className:Dt(TT({variant:s?"outline":"ghost",size:r}),t),...n});npe.displayName="PaginationLink";const Vct=({className:t,...s})=>e.jsxs(npe,{"aria-label":"Go to previous page",size:"default",className:Dt("gap-1 pl-2.5",t),...s,children:[e.jsx(Xo,{className:"h-4 w-4"}),e.jsx("span",{children:"Previous"})]});Vct.displayName="PaginationPrevious";const Hct=({className:t,...s})=>e.jsxs(npe,{"aria-label":"Go to next page",size:"default",className:Dt("gap-1 pr-2.5",t),...s,children:[e.jsx("span",{children:"Next"}),e.jsx(xa,{className:"h-4 w-4"})]});Hct.displayName="PaginationNext";const Gct=({className:t,...s})=>e.jsxs("span",{"aria-hidden":!0,className:Dt("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"})]});Gct.displayName="PaginationEllipsis";function FMs(){const{user:t}=qs();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 zMs(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:Sn,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 BMs({contact:t,onClose:s}){const r=ake(),[n,a]=S.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(Le,{type:"email",placeholder:"email@example.com",value:n.email,onChange:i=>a(d=>({...d,email:i.target.value})),className:Dt(!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(Le,{type:"tel",placeholder:"(555) 123-4567",value:n.phone,onChange:i=>a(d=>({...d,phone:i.target.value})),className:Dt(!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(Le,{placeholder:"123 Main St, City, ST 12345",value:n.address,onChange:i=>a(d=>({...d,address:i.target.value})),className:Dt(!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(Le,{type:"date",value:n.birthday,onChange:i=>a(d=>({...d,birthday:i.target.value})),className:Dt(!t.birthday&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(xe,{className:"flex items-center gap-1.5",children:[e.jsx(Sn,{className:"h-3.5 w-3.5"})," Home Anniversary"]}),e.jsx(Le,{type:"date",value:n.home_anniversary,onChange:i=>a(d=>({...d,home_anniversary:i.target.value})),className:Dt(!t.home_anniversary&&"border-amber-500/50")})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(K,{className:"flex-1",onClick:o,disabled:r.isPending,children:[e.jsx(bc,{className:"h-4 w-4 mr-1.5"}),r.isPending?"Saving...":"Save Changes"]}),e.jsx(K,{variant:"outline",onClick:s,children:"Cancel"})]})]})]})})}const T0e="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 $Ms(){const t=vr(),{data:s,isLoading:r}=qh(),{data:n}=Nf(),{intakePage:a}=kme(),{isGmailConnected:o,gmailEmail:l}=jp(),{data:i}=FMs(),[d,u]=S.useState("blocked"),[p,f]=S.useState("all"),[y,_]=S.useState(null),[b,N]=S.useState(!1),[w,k]=S.useState(1),[C,A]=S.useState(25);S.useEffect(()=>{k(1)},[d,p,C]);const[I,L]=S.useState(!1),[O,V]=S.useState(null),[q,B]=S.useState([]),[U,te]=S.useState(""),[Y,J]=S.useState(""),X=S.useMemo(()=>s?p==="all"?s:s.filter(_e=>{var Ge;return(Ge=_e.tags)==null?void 0:Ge.some(We=>We.relationship_type_id===p)}):[],[s,p]),ce=S.useMemo(()=>X.filter(_e=>!_e.email&&!_e.phone),[X]),ae=S.useMemo(()=>{if(!X.length)return{overallCompleteness:0,fullyComplete:0,contactsByGap:{}};const _e={};_e.blocked=ce,HI.forEach(Ve=>{_e[Ve.key]=X.filter(Ve.check)});const Ge=X.map(B5),We=X.length>0?Math.round(Ge.reduce((Ve,Xe)=>Ve+Xe,0)/X.length):0,it=Ge.filter(Ve=>Ve===100).length;return{contactsByGap:_e,overallCompleteness:We,fullyComplete:it}},[X,ce]),ie=S.useMemo(()=>{if(!s||s.length===0)return null;const _e=gc(g4(new Date,1)),Ge=s.filter(Xe=>new Date(Xe.created_at)<_e);if(Ge.length===0)return null;const We=Math.round(Ge.map(B5).reduce((Xe,dt)=>Xe+dt,0)/Ge.length),it=ae.overallCompleteness,Ve=it-We;return{oldCompleteness:We,currentCompleteness:it,diff:Ve,oldCount:Ge.length}},[s,ae.overallCompleteness]),oe=X.length,me=S.useCallback(()=>{var Je;const _e=ae.contactsByGap[d];if(!(_e!=null&&_e.length))return;const Ge=d==="blocked"?"Outreach Blocked":((Je=HI.find(Ze=>Ze.key===d))==null?void 0:Je.label)||d,We=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Completeness %"],it=_e.map(Ze=>[Ze.first_name,Ze.last_name||"",Ze.email||"",Ze.phone||"",Ze.address||"",Ze.birthday||"",Ze.home_anniversary||"",B5(Ze).toString()]),Ve=[We.join(","),...it.map(Ze=>Ze.map(Nt=>`"${Nt.replace(/"/g,'""')}"`).join(","))].join(` `),Xe=new Blob([Ve],{type:"text/csv"}),dt=URL.createObjectURL(Xe),pt=document.createElement("a");pt.href=dt,pt.download=`sphere-gaps-${Ge.toLowerCase().replace(/\s+/g,"-")}-${gs(new Date,"yyyy-MM-dd")}.csv`,pt.click(),URL.revokeObjectURL(dt),pn({title:`Exported ${_e.length} contacts to CSV`})},[ae.contactsByGap,d]),ye=S.useCallback(async _e=>{if(!a)return null;try{const{data:Ge,error:We}=await G.from("contact_intake_tokens").insert({contact_id:_e,intake_page_id:a.id}).select("token").single();if(We)throw We;return Ge.token}catch{return null}},[a]),he=S.useCallback(_e=>a?`https://contacts.relevelup.com/${a.slug}?t=${_e}`:"",[a]),ge=S.useCallback(async _e=>{if(!a){pe.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const Ge=await ye(_e);Ge?(await navigator.clipboard.writeText(he(Ge)),pe.success("Update link copied!")):pe.error("Failed to generate link")},[a,ye,he,t]),Ne=S.useCallback(async _e=>{if(!a){pe.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}if(!_e.email){pe.error("This contact has no email address");return}const Ge=await ye(_e.id);if(!Ge){pe.error("Failed to generate link");return}const We=he(Ge),it=tBe.replace("{{update_link}}",We).replace(/\{\{first_name\}\}/g,_e.first_name).replace(/\{\{last_name\}\}/g,_e.last_name||""),Ve=T0e.replace(/\{\{first_name\}\}/g,_e.first_name).replace(/\{\{last_name\}\}/g,_e.last_name||"");if(o)V({id:_e.id,first_name:_e.first_name,last_name:_e.last_name,email:_e.email}),B([]),te(Ve),J(it),L(!0);else{const Xe=encodeURIComponent(T0e.replace("{{first_name}}",_e.first_name)),dt=encodeURIComponent(it.replace(/\{\{first_name\}\}/g,_e.first_name));window.location.href=`mailto:${_e.email}?subject=${Xe}&body=${dt}`}},[a,ye,he,o,t]),Ue=S.useCallback(async _e=>{if(!a){pe.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const Ge=_e.filter(Ve=>Ve.email);if(!Ge.length){pe.error("No contacts with email addresses in this group");return}const We=new Set((i||[]).map(Ve=>Ve.contact_id)),it=Ge.filter(Ve=>!We.has(Ve.id));if(it.length===0){pe.info(`All ${Ge.length} contacts with email have already been sent this update request.`);return}if(it.lengthOt.id),intake_page_id:a.id}});if(Xe)throw Xe;const dt=typeof Ve=="string"?JSON.parse(Ve):Ve,pt=Array.isArray(dt)?dt:Array.isArray(dt==null?void 0:dt.tokens)?dt.tokens:[],Je=new Map(pt.filter(Ot=>(Ot==null?void 0:Ot.contact_id)&&(Ot==null?void 0:Ot.token)).map(Ot=>[Ot.contact_id,Ot.token]));if(Je.size===0&&(await Promise.all(Ge.map(async Yt=>({contactId:Yt.id,token:await ye(Yt.id)})))).forEach(({contactId:Yt,token:Ps})=>{Ps&&Je.set(Yt,Ps)}),Je.size===0){pe.error("Failed to generate update links. Please try again.");return}const Ze=it.filter(Ot=>Je.has(Ot.id)).map(Ot=>({id:Ot.id,first_name:Ot.first_name,last_name:Ot.last_name,email:Ot.email,updateLink:he(Je.get(Ot.id))})),Nt=tBe;V(null),B(Ze),te(T0e),J(Nt),L(!0),pe.success(`Ready to email ${Ze.length} contacts`)}catch{pe.error("Failed to generate links")}finally{N(!1)}},[a,o,he,ye,t]),Me=[{key:"blocked",label:"Outreach Blocked",icon:Tv,color:"text-destructive",description:"Missing BOTH email AND phone — completely unreachable"},...HI].find(_e=>_e.key===d),De=ae.contactsByGap[d]||[],qe=De.filter(_e=>_e.email).length,ke=new Set((i||[]).map(_e=>_e.contact_id)),$e=De.filter(_e=>_e.email&&ke.has(_e.id)).length,Be=qe-$e,we=Math.max(1,Math.ceil(De.length/C)),ut=Math.min(w,we),fe=(ut-1)*C,He=fe+C,et=De.slice(fe,He),tt=S.useMemo(()=>{if(we<=7)return Array.from({length:we},(it,Ve)=>Ve+1);const _e=[1];ut>3&&_e.push("ellipsis");const Ge=Math.max(2,ut-1),We=Math.min(we-1,ut+1);for(let it=Ge;it<=We;it++)_e.push(it);return ute.jsx(vt,{value:_e.id,children:_e.name},_e.id))]})]})]})]}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Database Completeness",p!=="all"&&e.jsx("span",{className:"ml-1 text-primary",children:"(filtered)"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("p",{className:"text-4xl font-bold",children:[ae.overallCompleteness,"%"]}),ie&&ie.diff!==0&&p==="all"&&e.jsxs("div",{className:Dt("flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",ie.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:[ie.diff>0?"↑":"↓"," ",Math.abs(ie.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:[ae.fullyComplete," ",e.jsxs("span",{className:"text-base font-normal text-muted-foreground",children:["/ ",oe]})]})]})]}),e.jsx(fi,{value:ae.overallCompleteness,className:"h-3"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:ae.overallCompleteness>=80?"🎉 Great job! Your database is well maintained.":ae.overallCompleteness>=50?"⚡ Good start — fill in the gaps below to unlock more outreach channels.":"🔍 Your database needs attention. Start with emails and phone numbers."})]})}),ce.length>0&&e.jsx(Pe,{className:Dt("border-l-4 border-l-destructive cursor-pointer transition-all hover:shadow-md",d==="blocked"&&"ring-2 ring-primary"),onClick:()=>u("blocked"),children:e.jsx(Re,{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:ce.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(_e=>{var Xe;const Ge=((Xe=ae.contactsByGap[_e.key])==null?void 0:Xe.length)||0,We=oe>0?Math.round(Ge/oe*100):0,it=_e.icon,Ve=d===_e.key;return e.jsx(Pe,{className:Dt("cursor-pointer transition-all hover:shadow-md",Ve&&"ring-2 ring-primary"),onClick:()=>u(_e.key),children:e.jsxs(Re,{className:"pt-5 pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(it,{className:Dt("h-5 w-5",_e.color)}),e.jsx("span",{className:"text-sm font-medium",children:_e.label})]}),e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsx("span",{className:"text-2xl font-bold",children:Ge}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[We,"% of contacts"]})]}),e.jsx(fi,{value:100-We,className:"mt-2 h-1.5"})]})},_e.key)})}),e.jsxs(Pe,{children:[e.jsxs(Lt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ft,{className:"text-lg",children:[(Me==null?void 0:Me.label)||"Contacts"," — Contacts to Fix"]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(Qe,{variant:"secondary",children:[De.length," contacts"]}),$e>0&&e.jsxs(Qe,{variant:"outline",className:"gap-1 text-muted-foreground",children:[e.jsx(Hn,{className:"h-3 w-3"}),$e," already emailed"]}),De.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:me,className:"gap-1.5",children:[e.jsx(Qa,{className:"h-3.5 w-3.5"}),"Export"]}),Be>0&&a&&e.jsxs(K,{size:"sm",onClick:()=>Ue(De),disabled:b,className:"gap-1.5",children:[b?e.jsx(us,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Mn,{className:"h-3.5 w-3.5"}),"Email ",Be," Update Links"]})]})]})]}),e.jsx(ur,{children:Me==null?void 0:Me.description})]}),e.jsxs(Re,{className:"p-0",children:[De.length===0?e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(Hn,{className:"h-10 w-10 text-emerald-500 mx-auto mb-2"}),e.jsx("p",{className:"text-muted-foreground",children:d==="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(Ms,{children:[e.jsx(kt,{children:"Contact"}),e.jsx(kt,{className:"hidden md:table-cell",children:"Email"}),e.jsx(kt,{className:"hidden md:table-cell",children:"Phone"}),e.jsx(kt,{children:"Completeness"}),e.jsx(kt,{className:"w-28",children:"Actions"})]})}),e.jsx(Rn,{children:et.map(_e=>{const Ge=zMs(i,_e.id);return e.jsxs(Ms,{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/${_e.id}`),children:[_e.first_name," ",_e.last_name]}),!_e.email&&!_e.phone&&d!=="blocked"&&e.jsx(Qe,{variant:"destructive",className:"text-[10px] px-1 py-0",children:"Blocked"}),Ge&&e.jsxs(Jl,{children:[e.jsx(ec,{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(Ge),{addSuffix:!0})]})}),e.jsxs(Ll,{children:["Last bulk emailed ",gs(new Date(Ge),"MMM d, yyyy h:mm a")]})]})]})}),e.jsx(ht,{className:"hidden md:table-cell text-muted-foreground",children:_e.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:_e.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(fi,{value:B5(_e),className:"h-2 w-16"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[B5(_e),"%"]})]})}),e.jsx(ht,{children:e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsxs(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>_(_e),children:e.jsx(Ev,{className:"h-3.5 w-3.5"})})}),e.jsx(Ll,{children:"Quick edit"})]}),(_e.email||_e.phone)&&a&&e.jsxs(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>ge(_e.id),children:e.jsx(Wa,{className:"h-3.5 w-3.5"})})}),e.jsx(Ll,{children:"Copy update link"})]}),_e.email&&a&&e.jsxs(Jl,{children:[e.jsx(ec,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Ne(_e),children:e.jsx(tr,{className:"h-3.5 w-3.5"})})}),e.jsx(Ll,{children:"Email update link"})]})]})})]},_e.id)})})]}),De.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:fe+1}),"–",e.jsx("span",{className:"font-medium text-foreground",children:Math.min(He,De.length)})," of"," ",e.jsx("span",{className:"font-medium text-foreground",children:De.length})]}),e.jsxs(Fs,{value:String(C),onValueChange:_e=>A(Number(_e)),children:[e.jsx(Ds,{className:"h-8 w-[110px] text-xs",children:e.jsx(zs,{})}),e.jsxs(Rs,{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"})]})]})]}),we>1&&e.jsx(qct,{className:"md:mx-0 md:justify-end",children:e.jsxs(Uct,{children:[e.jsx(VI,{children:e.jsx(Vct,{href:"#",onClick:_e=>{_e.preventDefault(),ut>1&&k(ut-1)},className:Dt(ut===1&&"pointer-events-none opacity-50")})}),tt.map((_e,Ge)=>_e==="ellipsis"?e.jsx(VI,{children:e.jsx(Gct,{})},`e-${Ge}`):e.jsx(VI,{children:e.jsx(npe,{href:"#",isActive:_e===ut,onClick:We=>{We.preventDefault(),k(_e)},children:_e})},_e)),e.jsx(VI,{children:e.jsx(Hct,{href:"#",onClick:_e=>{_e.preventDefault(),ut_(null)}),e.jsx(E1,{open:I,onOpenChange:L,contact:O||void 0,bulkContacts:q.length>0?q:void 0,defaultSubject:U,defaultBody:Y,gmailEmail:l})]})}function qMs(){const{user:t}=qs(),{intakePage:s,isLoading:r,createPage:n,updatePage:a,submissions:o,loadingSubmissions:l}=kme(),[i,d]=S.useState(""),[u,p]=S.useState(""),[f,y]=S.useState(!1);S.useEffect(()=>{s&&p(s.welcome_message||"")},[s]),S.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(Re,{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(Lt,{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(Ft,{children:"Connect Page"}),e.jsx(ur,{children:"Create a public link to capture contact info from new leads or update existing contacts"})]})]})}),e.jsx(Re,{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(Le,{value:i,onChange:A=>d(A.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"jane-smith",className:"max-w-[200px]"})]})]}),e.jsxs(K,{onClick:()=>n.mutate(i),disabled:!i.trim()||n.isPending,children:[n.isPending?e.jsx(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),k=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(on,{className:"h-3 w-3"}),gs(new Date(A.created_at),"MMM d")]}),I&&e.jsx(Hn,{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(Lt,{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(Ft,{children:"Connect Page"}),e.jsx(ur,{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(Mr,{id:"active-toggle",checked:s.is_active,onCheckedChange:A=>a.mutate({is_active:A})})]})]})}),e.jsxs(Re,{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(K,{size:"sm",variant:"outline",onClick:b,children:[e.jsx(Wa,{className:"h-3.5 w-3.5 mr-1.5"})," Copy"]}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:_,target:"_blank",rel:"noopener noreferrer",children:e.jsx(Zr,{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(K,{size:"sm",onClick:()=>{a.mutate({welcome_message:u}),y(!1)},children:"Save"}),e.jsx(K,{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(Lt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(or,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx(Ft,{className:"text-base",children:"New Submissions"}),k>0&&e.jsxs(ur,{children:[k," awaiting sync"]})]})]}),k>0&&e.jsxs(K,{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 ",k," to CRM"]})]})}),e.jsx(Re,{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(Lt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Hn,{className:"h-5 w-5 text-emerald-500"}),e.jsxs("div",{children:[e.jsx(Ft,{className:"text-base",children:"Synced to CRM"}),e.jsxs(ur,{children:[w.length," contacts already in your database"]})]})]})}),e.jsx(Re,{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 UMs(){return e.jsx(Es,{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(qMs,{})]})})}const VMs={property_view:{label:"Viewed Listing",icon:Cn,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"}},HMs={home:"🏠",search:"🔍",listing:"🏡",city:"🌆",sell:"💰",blog:"📝",dashboard:"📊",other:"📄"};function GMs({locations:t}){const s=S.useRef(null),r=S.useRef(null),[n,a]=S.useState(null);return S.useEffect(()=>{G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle().then(({data:o})=>{o!=null&&o.value&&a(o.value)})},[]),S.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]),S.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 Wct(){var L,O,V,q;const{user:t}=qs(),s=vr(),{isGmailConnected:r,gmailEmail:n}=jp(),[a,o]=S.useState("all"),[l,i]=S.useState("30"),[d,u]=S.useState(""),[p,f]=S.useState(!1),[y,_]=S.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=S.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,ae;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))||((ae=te.lead_type)==null?void 0:ae.toLowerCase().includes(U))})}return B},[b==null?void 0:b.activities,a,d]),k=b==null?void 0:b.subdomain,C=B=>k?`https://${k}.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(Es,{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(Es,{title:"Website Activity",description:"Monitor and act on your website leads",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s("/mission-control"),children:e.jsx(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(K,{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:yn,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:Cn,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(Re,{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(ls,{value:"overview",className:"gap-1.5",children:[e.jsx(so,{className:"h-4 w-4"})," Overview"]}),e.jsxs(ls,{value:"leads",className:"gap-1.5",children:[e.jsx(Oh,{className:"h-4 w-4"})," Lead Inbox"]}),e.jsxs(ls,{value:"map",className:"gap-1.5",children:[e.jsx(cS,{className:"h-4 w-4"})," Visitor Map"]})]}),e.jsxs(ws,{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(Lt,{className:"pb-3",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(Qo,{className:"h-4 w-4 text-primary"}),"Most Viewed Listings"]})}),e.jsx(Re,{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(Sn,{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(Sn,{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(Zr,{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(Lt,{className:"pb-3",children:e.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[e.jsx(yn,{className:"h-4 w-4 text-primary"}),"Most Visited Pages"]})}),e.jsx(Re,{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(yn,{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:HMs[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(Lt,{className:"pb-3",children:e.jsxs(Ft,{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(Re,{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(ws,{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(an,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Le,{placeholder:"Search by name, email, address...",value: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(K,{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(Re,{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=VMs[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(Re,{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(Zr,{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(on,{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(K,{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(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-primary",title:"Call",onClick:()=>window.location.href=`tel:${B.visitor_phone}`,children:e.jsx(In,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-primary",title:"Text",onClick:()=>window.location.href=`sms:${B.visitor_phone}`,children:e.jsx(Si,{className:"h-4 w-4"})})]}),B.contact_id&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",title:"View Contact",onClick:()=>s(`/mission-control/contacts/${B.contact_id}`),children:e.jsx(xa,{className:"h-4 w-4"})})]})]})})},`${B.activity_type}-${B.occurred_at}-${U}`)})})]}),e.jsxs(ws,{value:"map",className:"space-y-4",children:[e.jsxs(Pe,{children:[e.jsx(Lt,{className:"pb-3",children:e.jsxs(Ft,{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(Re,{className:"pt-0",children:e.jsx("div",{className:"h-[450px] rounded-xl overflow-hidden border",children:e.jsx(GMs,{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(Lt,{className:"pb-3",children:e.jsx(Ft,{className:"text-base",children:"Location Breakdown"})}),e.jsx(Re,{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 WMs=Object.freeze(Object.defineProperty({__proto__:null,default:Wct},Symbol.toStringTag,{value:"Module"})),KMs=S.lazy(()=>Ba(()=>import("./MobileAgentApp-86yqdAyk.js"),[])),ZMs=S.lazy(()=>Ba(()=>import("./PostcardManager-Cuq0uV3T.js"),__vite__mapDeps([16,17]))),YMs=S.lazy(()=>Ba(()=>import("./HomeReelManager--QgcZygs.js"),[])),XMs=S.lazy(()=>Ba(()=>import("./AdminCredits-BnmQtGc5.js"),[])),QMs=S.lazy(()=>Ba(()=>import("./AdminCleanup-BSDZcp4c.js"),[])),JMs=S.lazy(()=>Ba(()=>import("./DirectMail-DJ6SWmEP.js"),__vite__mapDeps([18,17,19]))),eTs=S.lazy(()=>Ba(()=>import("./InnerCirclePopbyMap-BP2A5k17.js"),[])),tTs=S.lazy(()=>Ba(()=>import("./LiveVisitorFeed-rTqH_-pw.js"),[])),sTs=S.lazy(()=>Ba(()=>import("./LeadSites-5GQd76pI.js"),[])),sBe=S.lazy(()=>Ba(()=>import("./LeadSiteEditor-CV9stTNo.js"),__vite__mapDeps([20,21,22]))),rTs=S.lazy(()=>Ba(()=>import("./AdminLeadSiteThemes-DuCvqjKm.js"),__vite__mapDeps([23,21]))),nTs=S.lazy(()=>Ba(()=>import("./AdminMlsFeeds-YzhKfGbb.js"),[])),aTs=S.lazy(()=>Ba(()=>import("./AdminLeadSiteAnalytics-BknkX64T.js"),[])),iTs=S.lazy(()=>Ba(()=>import("./AdminWebsiteInterests-CQXo18rC.js"),[])),oTs=S.lazy(()=>Ba(()=>import("./AdminMlsFeeTracker-CQ0gBVvY.js"),[])),lTs=S.lazy(()=>Ba(()=>import("./MLSListings-bFoG5kYW.js"),[])),cTs=S.lazy(()=>Ba(()=>import("./MLSListingDetail-BgMw-_3F.js"),__vite__mapDeps([24,12,19]))),dTs=S.lazy(()=>Ba(()=>import("./MarketReportPage-DHrfIhpB.js"),[]));S.lazy(()=>Ba(()=>Promise.resolve().then(()=>WMs),void 0));const uTs=S.lazy(()=>Ba(()=>import("./EmailCampaigns-BhRqNQgZ.js"),[])),hTs=S.lazy(()=>Ba(()=>import("./EmailCampaignComposer-DADdZqvr.js"),__vite__mapDeps([25,26]))),mTs=S.lazy(()=>Ba(()=>import("./EmailCampaignDetail-CCet0-wf.js"),[])),pTs=S.lazy(()=>Ba(()=>import("./SharedCampaignTemplates-BdCMln4T.js"),__vite__mapDeps([27,28,26]))),fTs=S.lazy(()=>Ba(()=>import("./AgentTemplates-DcZJqQ0f.js"),__vite__mapDeps([29,28,26]))),rBe=S.lazy(()=>Ba(()=>import("./TheLocalMoveHome-Cgm0ofBf.js"),__vite__mapDeps([30,31]))),nBe=S.lazy(()=>Ba(()=>import("./TheLocalMoveGetStarted-CyVKJvsI.js"),__vite__mapDeps([32,31]))),aBe=S.lazy(()=>Ba(()=>import("./TheLocalMoveCheckout-2620_k8M.js"),[])),iBe=S.lazy(()=>Ba(()=>import("./TheLocalMoveCheckoutSuccess-DAiH0LDQ.js"),[])),xTs=S.lazy(()=>Ba(()=>import("./AdminWebsiteOrders-3qnlsIqB.js"),[])),gTs=new jvt({defaultOptions:{queries:{refetchOnWindowFocus:!1,staleTime:5*60*1e3}}}),yTs=()=>{const t=window.location.hostname;return t==="listings.relevelup.com"||t.startsWith("listings.")},vTs=()=>{const t=window.location.hostname;return t==="cards.relevelup.com"||t.startsWith("cards.")},_Ts=()=>{const t=window.location.hostname;return t==="presentations.relevelup.com"||t.startsWith("presentations.")},bTs=()=>{const t=window.location.hostname;return t==="guestbook.relevelup.com"||t.startsWith("guestbook.")},wTs=()=>{const t=window.location.hostname;return t==="clients.relevelup.com"||t.startsWith("clients.")},jTs=()=>{const t=window.location.hostname;return t==="cardstudio.relevelup.com"||t.startsWith("cardstudio.")},NTs=()=>{const t=window.location.hostname;return t==="booking.relevelup.com"||t.startsWith("booking.")},kTs=()=>{const t=window.location.hostname;return t==="contacts.relevelup.com"||t.startsWith("contacts.")},STs=()=>{const t=window.location.hostname;return t==="pages.relevelup.com"||t.startsWith("pages.")},Kct=()=>{const t=window.location.hostname;return t==="thelocalmove.com"||t==="www.thelocalmove.com"},CTs=()=>window.location.hostname.endsWith(".thelocalmove.com")&&!Kct(),MTs=()=>e.jsx(Mvt,{client:gTs,children:e.jsx(yVe,{children:e.jsxs(S1,{children:[e.jsx(syt,{}),e.jsx(Lyt,{}),e.jsx(F1t,{children:e.jsx(Awt,{children:e.jsx(Ewt,{children:e.jsxs(Iwt,{children:[e.jsx(Pwt,{}),e.jsx(hNt,{}),e.jsx(MNt,{}),jTs()?e.jsx(I5s,{}):vTs()?e.jsx(Wkt,{}):yTs()?e.jsx(fkt,{}):_Ts()?e.jsx(Ykt,{}):bTs()?e.jsx(FEt,{}):wTs()?e.jsx(nPt,{}):NTs()?e.jsx(L5s,{}):kTs()?e.jsx(D5s,{}):STs()?e.jsx(R5s,{}):Kct()?e.jsxs(Voe,{children:[e.jsx(xs,{path:"/get-started",element:e.jsx(S.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(nBe,{})})}),e.jsx(xs,{path:"/checkout",element:e.jsx(S.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(aBe,{})})}),e.jsx(xs,{path:"/checkout/success",element:e.jsx(S.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(iBe,{})})}),e.jsx(xs,{path:"/privacy-policy",element:e.jsx(IIe,{})}),e.jsx(xs,{path:"/terms-of-service",element:e.jsx(LIe,{})}),e.jsx(xs,{path:"*",element:e.jsx(S.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(rBe,{})})})]}):CTs()?e.jsx(_Ms,{}):e.jsxs(Voe,{children:[e.jsx(xs,{path:"/",element:e.jsx(mPt,{})}),e.jsx(xs,{path:"/the-local-move",element:e.jsx(S.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(rBe,{})})}),e.jsx(xs,{path:"/get-started",element:e.jsx(S.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(nBe,{})})}),e.jsx(xs,{path:"/local-move/checkout",element:e.jsx(S.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(aBe,{})})}),e.jsx(xs,{path:"/local-move/checkout/success",element:e.jsx(S.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(iBe,{})})}),e.jsx(xs,{path:"/privacy-policy",element:e.jsx(IIe,{})}),e.jsx(xs,{path:"/terms-of-service",element:e.jsx(LIe,{})}),e.jsx(xs,{path:"/data-deletion",element:e.jsx(pPt,{})}),e.jsx(xs,{path:"/public/listings",element:e.jsx(xWe,{})}),e.jsx(xs,{path:"/public/listing/:slugOrId",element:e.jsx(nLt,{})}),e.jsx(xs,{path:"/card/:slug",element:e.jsx(aLt,{})}),e.jsx(xs,{path:"/join-brokerage/:slug",element:e.jsx(M3s,{})}),e.jsx(xs,{path:"/recruit-unsubscribe",element:e.jsx(P3s,{})}),e.jsx(xs,{path:"/recruit-video/:shareToken",element:e.jsx(A3s,{})}),e.jsx(xs,{path:"/connect/:slug",element:e.jsx(pXe,{})}),e.jsx(xs,{path:"/auth",element:e.jsx(xPt,{})}),e.jsx(xs,{path:"/subscription-success",element:e.jsx(gPt,{})}),e.jsx(xs,{path:"/subscription",element:e.jsx(rr,{children:e.jsx(dIt,{})})}),e.jsxs(xs,{path:"/share/video",element:e.jsx(XIt,{}),children:[e.jsx(xs,{path:":shareToken",element:e.jsx(nLe,{})}),e.jsx(xs,{path:":shareToken/r/:recipientToken",element:e.jsx(nLe,{})})]}),e.jsx(xs,{path:"/p/:shareToken",element:e.jsx(Y3s,{})}),e.jsx(xs,{path:"/portal/:slug",element:e.jsx(r5s,{})}),e.jsx(xs,{path:"/portal/:slug/refer",element:e.jsx(XZe,{})}),e.jsx(xs,{path:"/og/video/:token",element:e.jsx(QIt,{})}),e.jsx(xs,{path:"/setup-brokerage",element:e.jsx(rr,{children:e.jsx(uIt,{})})}),e.jsx(xs,{path:"/claim-account",element:e.jsx(tLe,{})}),e.jsx(xs,{path:"/claim",element:e.jsx(tLe,{})}),e.jsx(xs,{path:"/join",element:e.jsx(hIt,{})}),e.jsx(xs,{path:"/trial",element:e.jsx(jIt,{})}),e.jsx(xs,{path:"/trial/success",element:e.jsx(NIt,{})}),e.jsx(xs,{path:"/dashboard",element:e.jsx(rr,{children:e.jsx(S8t,{})})}),e.jsx(xs,{path:"/profile",element:e.jsx(rr,{children:e.jsx(g$t,{})})}),e.jsx(xs,{path:"/apps",element:e.jsx(rr,{children:e.jsx(M$t,{})})}),e.jsx(xs,{path:"/admin",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(rDe,{})})}),e.jsx(xs,{path:"/admin/dashboard",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(rDe,{})})}),e.jsx(xs,{path:"/admin/apps",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(fVt,{})})}),e.jsx(xs,{path:"/admin/members",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(jVt,{})})}),e.jsx(xs,{path:"/admin/invite-codes",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(NVt,{})})}),e.jsx(xs,{path:"/admin/events",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(AVt,{})})}),e.jsx(xs,{path:"/events",element:e.jsx(rr,{children:e.jsx(N$t,{})})}),e.jsx(xs,{path:"/events/:eventId",element:e.jsx(rr,{children:e.jsx(S$t,{})})}),e.jsx(xs,{path:"/templates",element:e.jsx(rr,{children:e.jsx(T$t,{})})}),e.jsx(xs,{path:"/templates/:templateId",element:e.jsx(rr,{children:e.jsx(I$t,{})})}),e.jsx(xs,{path:"/admin/templates",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(PVt,{})})}),e.jsx(xs,{path:"/academy",element:e.jsx(rr,{children:e.jsx(L$t,{})})}),e.jsx(xs,{path:"/academy/:videoId",element:e.jsx(rr,{children:e.jsx(R$t,{})})}),e.jsx(xs,{path:"/admin/academy",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(LVt,{})})}),e.jsx(xs,{path:"/toolbox",element:e.jsx(rr,{children:e.jsx(O$t,{})})}),e.jsx(xs,{path:"/toolbox/:kitId",element:e.jsx(rr,{children:e.jsx(F$t,{})})}),e.jsx(xs,{path:"/admin/toolbox",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(DVt,{})})}),e.jsx(xs,{path:"/social-swag",element:e.jsx(rr,{children:e.jsx(z$t,{})})}),e.jsx(xs,{path:"/social-swag-2",element:e.jsx(rr,{children:e.jsx(OUt,{})})}),e.jsx(xs,{path:"/social-swag/:swagId",element:e.jsx(rr,{children:e.jsx(FUt,{})})}),e.jsx(xs,{path:"/social-connections",element:e.jsx(rr,{children:e.jsx(I3s,{})})}),e.jsx(xs,{path:"/social-connections/callback",element:e.jsx(rr,{children:e.jsx(L3s,{})})}),e.jsx(xs,{path:"/social-connections/linkedin-callback",element:e.jsx(rr,{children:e.jsx(R3s,{})})}),e.jsx(xs,{path:"/social-connections/google-callback",element:e.jsx(rr,{children:e.jsx(D3s,{})})}),e.jsx(xs,{path:"/admin/social-swag",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(RVt,{})})}),e.jsx(xs,{path:"/admin/social-swag-2",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(_Gt,{})})}),e.jsx(xs,{path:"/community",element:e.jsx(rr,{children:e.jsx(rVt,{})})}),e.jsx(xs,{path:"/support",element:e.jsx(rr,{children:e.jsx(nVt,{})})}),e.jsx(xs,{path:"/admin/community",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(bGt,{})})}),e.jsx(xs,{path:"/admin/support-tickets",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(t1s,{})})}),e.jsx(xs,{path:"/admin/email-templates",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(r1s,{})})}),e.jsx(xs,{path:"/admin/agent-email-templates",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(n1s,{})})}),e.jsx(xs,{path:"/admin/analytics",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(Qvs,{})})}),e.jsx(xs,{path:"/admin/brokerage-resources",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(Jvs,{})})}),e.jsx(xs,{path:"/admin/dashboard-management",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(e1s,{})})}),e.jsx(xs,{path:"/brokerage/dashboard",element:e.jsx(rr,{requireBrokerageManager:!0,children:e.jsx(x1s,{})})}),e.jsx(xs,{path:"/brokerage/teams",element:e.jsx(rr,{requireBrokerageManager:!0,children:e.jsx(jMs,{})})}),e.jsx(xs,{path:"/brokerage/recruiting",element:e.jsx(rr,{requireBrokerageManager:!0,children:e.jsx(YSs,{})})}),e.jsx(xs,{path:"/my-team",element:e.jsx(rr,{children:e.jsx(NMs,{})})}),e.jsx(xs,{path:"/my-brokerage",element:e.jsx(rr,{children:e.jsx(w1s,{})})}),e.jsx(xs,{path:"/brokerage-content",element:e.jsx(rr,{children:e.jsx(M1s,{})})}),e.jsx(xs,{path:"/brokerage-content/:contentId",element:e.jsx(rr,{children:e.jsx(I1s,{})})}),e.jsx(xs,{path:"/brokerage-resources",element:e.jsx(rr,{requireBrokerageManager:!0,children:e.jsx(dVt,{})})}),e.jsx(xs,{path:"/brokerage-resources/:resourceId",element:e.jsx(rr,{requireBrokerageManager:!0,children:e.jsx(uVt,{})})}),e.jsx(xs,{path:"/newsletters",element:e.jsx(rr,{children:e.jsx(L1s,{})})}),e.jsx(xs,{path:"/newsletters/:id",element:e.jsx(rr,{children:e.jsx(R1s,{})})}),e.jsx(xs,{path:"/wishlist",element:e.jsx(rr,{children:e.jsx(z1s,{})})}),e.jsx(xs,{path:"/wishlist/:itemId",element:e.jsx(rr,{children:e.jsx(B1s,{})})}),e.jsx(xs,{path:"/admin/wishlist",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx($1s,{})})}),e.jsx(xs,{path:"/admin/levelup-brief",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(q1s,{})})}),e.jsx(xs,{path:"/admin/newsletters",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(F1s,{})})}),e.jsx(xs,{path:"/admin/additional-services",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(U1s,{})})}),e.jsx(xs,{path:"/admin/discounts",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(V1s,{})})}),e.jsx(xs,{path:"/admin/subscriptions",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(H1s,{})})}),e.jsx(xs,{path:"/admin/referrals",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(G1s,{})})}),e.jsx(xs,{path:"/admin/prospector",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(ASs,{})})}),e.jsx(xs,{path:"/admin/recruiting",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(ZSs,{})})}),e.jsx(xs,{path:"/admin/beta/social-post-generator",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(XCs,{})})}),e.jsx(xs,{path:"/admin/credits",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(XMs,{})})})}),e.jsx(xs,{path:"/admin/cleanup",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(QMs,{})})})}),e.jsx(xs,{path:"/admin/beta/postcard-manager",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(ZMs,{})})})}),e.jsx(xs,{path:"/admin/beta/homereel",element:e.jsx(rr,{children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(YMs,{})})})}),e.jsx(xs,{path:"/admin/lms",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(u3s,{})})}),e.jsx(xs,{path:"/admin/lms/stats",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(x3s,{})})}),e.jsx(xs,{path:"/admin/lms/:courseId",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(h3s,{})})}),e.jsx(xs,{path:"/levelup-u",element:e.jsx(rr,{children:e.jsx(g3s,{})})}),e.jsx(xs,{path:"/levelup-u/:courseId",element:e.jsx(rr,{children:e.jsx(v3s,{})})}),e.jsx(xs,{path:"/admin/brokerage-content-activity",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(XSs,{})})}),e.jsx(xs,{path:"/admin/onboarding-checklist",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(K1s,{})})}),e.jsx(xs,{path:"/admin/marketplace",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(oSs,{})})}),e.jsx(xs,{path:"/admin/agent-points",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(E4s,{})})}),e.jsx(xs,{path:"/admin/reward-store",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(wSs,{})})}),e.jsx(xs,{path:"/admin/integrations",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(NSs,{})})}),e.jsx(xs,{path:"/admin/integrations/callback",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(TSs,{})})}),e.jsx(xs,{path:"/admin/email-campaigns",element:e.jsx(rr,{children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(uTs,{})})})}),e.jsx(xs,{path:"/admin/email-campaigns/templates",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(pTs,{})})})}),e.jsx(xs,{path:"/email-campaigns/templates",element:e.jsx(rr,{children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(fTs,{})})})}),e.jsx(xs,{path:"/admin/email-campaigns/new",element:e.jsx(rr,{children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(hTs,{})})})}),e.jsx(xs,{path:"/admin/email-campaigns/:id",element:e.jsx(rr,{children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(mTs,{})})})}),e.jsx(xs,{path:"/reward-store",element:e.jsx(rr,{children:e.jsx(V3s,{})})}),e.jsx(xs,{path:"/additional-services",element:e.jsx(rr,{children:e.jsx(a_s,{})})}),e.jsx(xs,{path:"/additional-services/:serviceId",element:e.jsx(rr,{children:e.jsx(i_s,{})})}),e.jsx(xs,{path:"/ai-toolkit",element:e.jsx(rr,{children:e.jsx(o_s,{})})}),e.jsx(xs,{path:"/mission-control",element:e.jsx(rr,{children:e.jsx(S_s,{})})}),e.jsx(xs,{path:"/mission-control/contacts",element:e.jsx(rr,{children:e.jsx(Abs,{})})}),e.jsx(xs,{path:"/mission-control/contacts/:contactId",element:e.jsx(rr,{children:e.jsx(cws,{})})}),e.jsx(xs,{path:"/mission-control/plans",element:e.jsx(rr,{children:e.jsx(dws,{})})}),e.jsx(xs,{path:"/mission-control/popbys",element:e.jsx(rr,{children:e.jsx(gws,{})})}),e.jsx(xs,{path:"/mission-control/popbys/map",element:e.jsx(rr,{children:e.jsx(eTs,{})})}),e.jsx(xs,{path:"/admin/notification-settings",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(SSs,{})})}),e.jsx(xs,{path:"/admin/agent-os",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(Y1s,{})})}),e.jsx(xs,{path:"/mission-control/listings",element:e.jsx(rr,{children:e.jsx($ws,{})})}),e.jsx(xs,{path:"/mission-control/listings/new",element:e.jsx(rr,{children:e.jsx(eze,{})})}),e.jsx(xs,{path:"/mission-control/listings/:listingId",element:e.jsx(rr,{children:e.jsx(a2s,{})})}),e.jsx(xs,{path:"/mission-control/listings/:listingId/edit",element:e.jsx(rr,{children:e.jsx(eze,{})})}),e.jsx(xs,{path:"/admin/listing-exchange",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(k4s,{})})}),e.jsx(xs,{path:"/mission-control/pipeline",element:e.jsx(rr,{children:e.jsx(kks,{})})}),e.jsx(xs,{path:"/mission-control/tasks",element:e.jsx(rr,{children:e.jsx(Dks,{})})}),e.jsx(xs,{path:"/mission-control/portal-referrals",element:e.jsx(rr,{children:e.jsx($ks,{})})}),e.jsx(xs,{path:"/mission-control/my-card",element:e.jsx(rr,{children:e.jsx(o4s,{})})}),e.jsx(xs,{path:"/mission-control/integrations",element:e.jsx(rr,{children:e.jsx(y4s,{})})}),e.jsx(xs,{path:"/mission-control/integrations/gmail/callback",element:e.jsx(rr,{children:e.jsx(v4s,{})})}),e.jsx(xs,{path:"/mission-control/integrations/canva/callback",element:e.jsx(_4s,{})}),e.jsx(xs,{path:"/mission-control/integrations/meta/callback",element:e.jsx(rr,{children:e.jsx(b4s,{})})}),e.jsx(xs,{path:"/mission-control/scorecard",element:e.jsx(rr,{children:e.jsx(Ews,{})})}),e.jsx(xs,{path:"/admin/scorecard",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(j4s,{})})}),e.jsx(xs,{path:"/admin/scorecard/:userId",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(m9e,{})})}),e.jsx(xs,{path:"/mission-control/scorecard/:userId",element:e.jsx(rr,{children:e.jsx(m9e,{})})}),e.jsx(xs,{path:"/mission-control/relationship-scorecard",element:e.jsx(rr,{children:e.jsx(OMs,{})})}),e.jsx(xs,{path:"/mission-control/sphere-gaps",element:e.jsx(rr,{children:e.jsx($Ms,{})})}),e.jsx(xs,{path:"/mission-control/website-activity",element:e.jsx(rr,{children:e.jsx(Wct,{})})}),e.jsx(xs,{path:"/mission-control/connect-page",element:e.jsx(rr,{children:e.jsx(UMs,{})})}),e.jsx(xs,{path:"/admin/membership-reviews",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(S4s,{})})}),e.jsx(xs,{path:"/admin/weekly-digest",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(T4s,{})})}),e.jsx(xs,{path:"/mission-control/video/record",element:e.jsx(rr,{children:e.jsx(lNs,{})})}),e.jsx(xs,{path:"/mission-control/video-library",element:e.jsx(rr,{children:e.jsx(jNs,{})})}),e.jsx(xs,{path:"/marketplace",element:e.jsx(rr,{children:e.jsx(O3s,{})})}),e.jsx(xs,{path:"/marketplace/:productId",element:e.jsx(rr,{children:e.jsx(F3s,{})})}),e.jsx(xs,{path:"/marketplace/cart",element:e.jsx(rr,{children:e.jsx(z3s,{})})}),e.jsx(xs,{path:"/marketplace/orders",element:e.jsx(rr,{children:e.jsx(B3s,{})})}),e.jsx(xs,{path:"/marketplace/orders/:orderId",element:e.jsx(rr,{children:e.jsx(q3s,{})})}),e.jsx(xs,{path:"/marketplace/success",element:e.jsx(rr,{children:e.jsx(U3s,{})})}),e.jsx(xs,{path:"/admin/agent-cards",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(P4s,{})})}),e.jsx(xs,{path:"/admin/presentation-analytics",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(CSs,{})})}),e.jsx(xs,{path:"/admin/guest-book-analytics",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(MSs,{})})}),e.jsx(xs,{path:"/mission-control/smart-drips",element:e.jsx(rr,{children:e.jsx(E5s,{})})}),e.jsx(xs,{path:"/mission-control/direct-mail",element:e.jsx(rr,{children:e.jsx(S.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(JMs,{})})})}),e.jsx(xs,{path:"/mission-control/presentations",element:e.jsx(rr,{children:e.jsx(H3s,{})})}),e.jsx(xs,{path:"/mission-control/presentations/new",element:e.jsx(rr,{children:e.jsx(F9e,{})})}),e.jsx(xs,{path:"/mission-control/presentations/:id",element:e.jsx(rr,{children:e.jsx(F9e,{})})}),e.jsx(xs,{path:"/mission-control/guest-book",element:e.jsx(rr,{children:e.jsx(t5s,{})})}),e.jsx(xs,{path:"/mission-control/guest-book/live/:id",element:e.jsx(rr,{children:e.jsx(tTs,{})})}),e.jsx(xs,{path:"/guestbook/:slug",element:e.jsx(YWe,{})}),e.jsx(xs,{path:"/mission-control/card-studio",element:e.jsx(rr,{children:e.jsx(c5s,{})})}),e.jsx(xs,{path:"/mission-control/scheduler",element:e.jsx(rr,{children:e.jsx(EMs,{})})}),e.jsx(xs,{path:"/c/:shareToken",element:e.jsx(Oct,{})}),e.jsx(xs,{path:"/book/:slug",element:e.jsx(zct,{})}),e.jsx(xs,{path:"/page/:slug",element:e.jsx(Bct,{})}),e.jsx(xs,{path:"/mission-control/landing-pages",element:e.jsx(rr,{children:e.jsx(PMs,{})})}),e.jsx(xs,{path:"/mission-control/landing-pages/:pageId",element:e.jsx(rr,{children:e.jsx(DMs,{})})}),e.jsx(xs,{path:"/my-website/:siteId/edit",element:e.jsx(rr,{children:e.jsx(S.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(xs,{path:"/my-website/mls-listings",element:e.jsx(rr,{children:e.jsx(S.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(xs,{path:"/my-website/mls-listings/:mlsId",element:e.jsx(rr,{children:e.jsx(S.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(xs,{path:"/my-website/market-report",element:e.jsx(rr,{children:e.jsx(S.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(xs,{path:"/admin/lead-sites",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(S.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(sTs,{})})})}),e.jsx(xs,{path:"/admin/lead-sites/themes",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(S.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(rTs,{})})})}),e.jsx(xs,{path:"/admin/lead-sites/:siteId/edit",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(S.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(xs,{path:"/admin/mls-feeds",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(S.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(xs,{path:"/admin/lead-site-analytics",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(S.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(xs,{path:"/admin/website-interests",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(S.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(xs,{path:"/admin/website-orders",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(S.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(xTs,{})})})}),e.jsx(xs,{path:"/admin/mls-fee-tracker",element:e.jsx(rr,{requireAdmin:!0,children:e.jsx(S.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(xs,{path:"/m/*",element:e.jsx(S.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(KMs,{})})}),e.jsx(xs,{path:"*",element:e.jsx(Fct,{})})]}),")"]})})})})]})})}),Vp=window.location.hostname,TTs=Vp.includes("lovable.app")||Vp.includes("lovableproject.com"),ATs=(()=>{try{return window.self!==window.top}catch{return!0}})(),ETs=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;TTs||ATs||ETs?((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-CX0fbzXa.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(MTs,{}));export{dbs as $,Fi as A,pe as B,so as C,Bs as D,Cn as E,rd as F,Oa as G,Sn as H,OY as I,dh as J,mh as K,ga as L,Si as M,Qxe as N,T1t as O,In as P,Ia as Q,ln as R,an as S,Qo as T,or as U,EEe as V,Xa as W,jr as X,Mme as Y,Oh as Z,Ba as _,vr as a,kae as a$,tit as a0,mbs as a1,BSe as a2,Zn as a3,ao as a4,jp as a5,Et as a6,nd as a7,Mn as a8,E1 as a9,ws as aA,K as aB,Ln as aC,Dn as aD,Ms as aE,kt as aF,Rn as aG,ht as aH,Qe as aI,Mr as aJ,fs as aK,hs as aL,js as aM,_s as aN,xe as aO,Le as aP,Fs as aQ,Ds as aR,zs as aS,Rs as aT,vt as aU,_n as aV,QTs as aW,gs as aX,yi as aY,gr as aZ,qo as a_,vS as aa,us as ab,Zy as ac,nf as ad,jL as ae,_d as af,GU as ag,_L as ah,qy as ai,Ag as aj,Xo as ak,Zr as al,Sm as am,EM as an,Voe as ao,xs as ap,Pe as aq,Lt as ar,Ft as as,_c as at,ur as au,Re as av,ta as aw,Jn as ax,ls as ay,cl as az,ip as b,Ir as b$,H4 as b0,pa as b1,bc as b2,Wa as b3,xr as b4,Es as b5,iS as b6,hi as b7,Ra as b8,Sb as b9,S4e as bA,bAs as bB,$V as bC,C4e as bD,iC as bE,mu as bF,Jl as bG,ec as bH,Gv as bI,Ll as bJ,vse as bK,yo as bL,vo as bM,uo as bN,ni as bO,hL as bP,Hn as bQ,ro as bR,bJ as bS,fJ as bT,oL as bU,Hu as bV,MM as bW,yn as bX,AV as bY,WL as bZ,yx as b_,CJ as ba,hh as bb,Co as bc,Jae as bd,Cg as be,Iv as bf,fi as bg,Qa as bh,oS as bi,Zi as bj,Rd as bk,gn as bl,Ig as bm,hS as bn,Qy as bo,nIt as bp,wn as bq,Ma as br,jn as bs,v4e as bt,gce as bu,w4e as bv,oO as bw,cre as bx,N4e as by,_4e as bz,Dt as c,_a as c$,Vj as c0,S1 as c1,UL as c2,Dc as c3,PL as c4,Hi as c5,pn as c6,bpt as c7,no as c8,xt as c9,Wre as cA,tS as cB,cS as cC,iJ as cD,Cm as cE,zu as cF,bZ as cG,uu as cH,Ih as cI,k4e as cJ,Av as cK,wAs as cL,SAs as cM,CAs as cN,mp as cO,MAs as cP,gGt as cQ,Gn as cR,uh as cS,Kv as cT,xx as cU,Ab as cV,fd as cW,Hd as cX,Gd as cY,Nd as cZ,ije as c_,L_s as ca,I_s as cb,R_s as cc,Ko as cd,AM as ce,ML as cf,ti as cg,eAs as ch,NWe as ci,sAs as cj,rAs as ck,nAs as cl,e1 as cm,DNe as cn,Do as co,dr as cp,n0 as cq,ZA as cr,SC as cs,YA as ct,XA as cu,Gre as cv,Fl as cw,gx as cx,EL as cy,ste as cz,So as d,Nb as d$,FL as d0,dS as d1,O5s as d2,Jo as d3,pp as d4,mL as d5,fx as d6,td as d7,DSe as d8,ya as d9,Ev as dA,vne as dB,Z4 as dC,Oke as dD,zke as dE,Zke as dF,R9t 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,go as dS,wS as dT,fS as dU,Dke as dV,ja as dW,nc as dX,Q4 as dY,Rh as dZ,yj as d_,pbs as da,Eie as db,BCe as dc,Jy as dd,xo as de,hu as df,jae as dg,AO as dh,Ga 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,ep as ds,Aat as dt,mC as du,pC as dv,_1 as dw,au as dx,iL as dy,xS as dz,qs as e,aS as e0,lL as e1,CW as e2,cte as e3,vd as e4,eN as e5,t1 as e6,e0 as e7,pS as e8,jM as e9,DEt as ea,zvt as eb,rpe as ec,dq as ed,KCe as ee,$5s as ef,AAs as eg,TAs as eh,lW as ei,Bne as ej,die as ek,_M as el,rc as em,EAs as en,ZCe as eo,LM as ep,U5s as eq,da as er,Nc as f,gt as g,CC as h,b_s as i,e as j,xa as k,tr as l,Qt as m,iu as n,Z6t as o,Or as p,Nl as q,S as r,G as s,Ai as t,Bl as u,on as v,rhe as w,Nf as x,JA as y,af as z};